|
|
!(function(){var MY=Object.defineProperty,SY=Object.defineProperties;var TY=Object.getOwnPropertyDescriptors;var P3=Object.getOwnPropertySymbols,EY=Object.getPrototypeOf,AY=Object.prototype.hasOwnProperty,CY=Object.prototype.propertyIsEnumerable,RY=Reflect.get;var ip=Math.pow,uE=(se,ee,b)=>ee in se?MY(se,ee,{enumerable:!0,configurable:!0,writable:!0,value:b}):se[ee]=b,Ys=(se,ee)=>{for(var b in ee||(ee={}))AY.call(ee,b)&&uE(se,b,ee[b]);if(P3)for(var b of P3(ee))CY.call(ee,b)&&uE(se,b,ee[b]);return se},cc=(se,ee)=>SY(se,TY(ee));var ca=(se,ee,b)=>uE(se,typeof ee!="symbol"?ee+"":ee,b);var I3=(se,ee,b)=>RY(EY(se),b,ee);var hr=(se,ee,b)=>new Promise((w,k)=>{var O=C=>{try{S(b.next(C))}catch(x){k(x)}},R=C=>{try{S(b.throw(C))}catch(x){k(x)}},S=C=>C.done?w(C.value):Promise.resolve(C.value).then(O,R);S((b=b.apply(se,ee)).next())});(self.webpackChunk=self.webpackChunk||[]).push([[6475],{17663:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return x}});var w=b(87462),k=b(67294),O={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}},{tag:"path",attrs:{d:"M623.6 316.7C593.6 290.4 554 276 512 276s-81.6 14.5-111.6 40.7C369.2 344 352 380.7 352 420v7.6c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V420c0-44.1 43.1-80 96-80s96 35.9 96 80c0 31.1-22 59.6-56.1 72.7-21.2 8.1-39.2 22.3-52.1 40.9-13.1 19-19.9 41.8-19.9 64.9V620c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8v-22.7a48.3 48.3 0 0130.9-44.8c59-22.7 97.1-74.7 97.1-132.5.1-39.3-17.1-76-48.3-103.3zM472 732a40 40 0 1080 0 40 40 0 10-80 0z"}}]},name:"question-circle",theme:"outlined"},R=O,S=b(74643),C=function(N,L){return k.createElement(S.Z,(0,w.Z)({},N,{ref:L,icon:R}))},x=k.forwardRef(C)},73686:function(se,ee,b){"use strict";b.d(ee,{ni:function(){return fh},EF:function(){return oi}});var w=function($,q){var oe=$.nodes,xe=$.edges,Ae=[],ze={};if(!oe)throw new Error("invalid nodes data!");return oe&&oe.forEach(function(xt,St){ze[xt.id]=St;var Lt=[];Ae.push(Lt)}),xe&&xe.forEach(function(xt){var St=xt.source,Lt=xt.target,Vt=ze[St],Ht=ze[Lt];!Vt&&Vt!==0||!Ht&&Ht!==0||(Ae[Vt][Ht]=1,q||(Ae[Ht][Vt]=1))}),Ae},k=w,O=function($,q){return $===q},R=function(){function ne($,q){q===void 0&&(q=null),this.value=$,this.next=q}return ne.prototype.toString=function($){return $?$(this.value):"".concat(this.value)},ne}(),S=function(){function ne($){$===void 0&&($=O),this.head=null,this.tail=null,this.compare=$}return ne.prototype.prepend=function($){var q=new R($,this.head);return this.head=q,this.tail||(this.tail=q),this},ne.prototype.append=function($){var q=new R($);return this.head?(this.tail.next=q,this.tail=q,this):(this.head=q,this.tail=q,this)},ne.prototype.delete=function($){if(!this.head)return null;for(var q=null;this.head&&this.compare(this.head.value,$);)q=this.head,this.head=this.head.next;var oe=this.head;if(oe!==null)for(;oe.next;)this.compare(oe.next.value,$)?(q=oe.next,oe.next=oe.next.next):oe=oe.next;return this.compare(this.tail.value,$)&&(this.tail=oe),q},ne.prototype.find=function($){var q=$.value,oe=q===void 0?void 0:q,xe=$.callback,Ae=xe===void 0?void 0:xe;if(!this.head)return null;for(var ze=this.head;ze;){if(Ae&&Ae(ze.value)||oe!==void 0&&this.compare(ze.value,oe))return ze;ze=ze.next}return null},ne.prototype.deleteTail=function(){var $=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,$;for(var q=this.head;q.next;)q.next.next?q=q.next:q.next=null;return this.tail=q,$},ne.prototype.deleteHead=function(){if(!this.head)return null;var $=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),$},ne.prototype.fromArray=function($){var q=this;return $.forEach(function(oe){return q.append(oe)}),this},ne.prototype.toArray=function(){for(var $=[],q=this.head;q;)$.push(q),q=q.next;return $},ne.prototype.reverse=function(){for(var $=this.head,q=null,oe=null;$;)oe=$.next,$.next=q,q=$,$=oe;this.tail=this.head,this.head=q},ne.prototype.toString=function($){return $===void 0&&($=void 0),this.toArray().map(function(q){return q.toString($)}).toString()},ne}(),C=S,x=function(){function ne(){this.linkedList=new C}return ne.prototype.isEmpty=function(){return!this.linkedList.head},ne.prototype.peek=function(){return this.linkedList.head?this.linkedList.head.value:null},ne.prototype.enqueue=function($){this.linkedList.append($)},ne.prototype.dequeue=function(){var $=this.linkedList.deleteHead();return $?$.value:null},ne.prototype.toString=function($){return this.linkedList.toString($)},ne}(),E=x,N=function($,q,oe){q===void 0&&(q=[]);var xe=q.filter(function(St){return St.source===$||St.target===$});if(oe==="target"){var Ae=function(Lt){return Lt.source===$};return xe.filter(Ae).map(function(St){return St.target})}if(oe==="source"){var ze=function(Lt){return Lt.target===$};return xe.filter(ze).map(function(St){return St.source})}var xt=function(Lt){return Lt.source===$?Lt.target:Lt.source};return xe.map(xt)},L=function($,q){return q.filter(function(oe){return oe.source===$})},P=function($,q){return q.filter(function(oe){return oe.source===$||oe.target===$})},W=function($){$===void 0&&($=0);var q="".concat(Math.random()).split(".")[1].substr(0,5),oe="".concat(Math.random()).split(".")[1].substr(0,5);return"".concat($,"-").concat(q).concat(oe)};function Y(ne){ne===void 0&&(ne={});var $=ne,q=function(){},oe=function(){var xe={};return function(Ae){var ze=Ae.next,xt=ze;return xe[xt]?!1:(xe[xt]=!0,!0)}}();return $.allowTraversal=ne.allowTraversal||oe,$.enter=ne.enter||q,$.leave=ne.leave||q,$}var ie=function($,q,oe,xe){xe===void 0&&(xe=!0);var Ae=Y(oe),ze=new E,xt=$.edges,St=xt===void 0?[]:xt;ze.enqueue(q);for(var Lt="",Vt=function(){var hn=ze.dequeue();Ae.enter({current:hn,previous:Lt}),N(hn,St,xe?"target":void 0).forEach(function(Ft){Ae.allowTraversal({previous:Lt,current:hn,next:Ft})&&ze.enqueue(Ft)}),Ae.leave({current:hn,previous:Lt}),Lt=hn};!ze.isEmpty();)Vt()},pe=ie,fe=function($){for(var q=$.nodes,oe=q===void 0?[]:q,xe=$.edges,Ae=xe===void 0?[]:xe,ze=[],xt={},St=[],Lt=function Ft(_n){St.push(_n),xt[_n.id]=!0;for(var Nn=N(_n.id,Ae),Pn=function(On){var di=Nn[On];if(!xt[di]){var Ri=oe.filter(function(ji){return ji.id===di});Ri.length>0&&Ft(Ri[0])}},ei=0;ei<Nn.length;++ei)Pn(ei)},Vt=0;Vt<oe.length;Vt++){var Ht=oe[Vt];if(!xt[Ht.id]){Lt(Ht);for(var hn=[];St.length>0;)hn.push(St.pop());ze.push(hn)}}return ze},ae=function($){for(var q=$.nodes,oe=q===void 0?[]:q,xe=$.edges,Ae=xe===void 0?[]:xe,ze=[],xt={},St={},Lt={},Vt=[],Ht=0,hn=function Pn(ei){St[ei.id]=Ht,Lt[ei.id]=Ht,Ht+=1,ze.push(ei),xt[ei.id]=!0;for(var ai=N(ei.id,Ae,"target").filter(function(Qi){return oe.map(function(er){return er.id}).indexOf(Qi)>-1}),On=function(er){var gr=ai[er];if(!St[gr]&&St[gr]!==0){var yr=oe.filter(function(Pr){return Pr.id===gr});yr.length>0&&Pn(yr[0]),Lt[ei.id]=Math.min(Lt[ei.id],Lt[gr])}else xt[gr]&&(Lt[ei.id]=Math.min(Lt[ei.id],St[gr]))},di=0;di<ai.length;di++)On(di);if(Lt[ei.id]===St[ei.id]){for(var Ri=[];ze.length>0;){var ji=ze.pop();if(xt[ji.id]=!1,Ri.push(ji),ji===ei)break}Ri.length>0&&Vt.push(Ri)}},Ft=0,_n=oe;Ft<_n.length;Ft++){var Nn=_n[Ft];!St[Nn.id]&&St[Nn.id]!==0&&hn(Nn)}return Vt};function ye(ne,$){return $?ae(ne):fe(ne)}var ue=function($){var q={},oe=$.nodes,xe=oe===void 0?[]:oe,Ae=$.edges,ze=Ae===void 0?[]:Ae;return xe.forEach(function(xt){q[xt.id]={degree:0,inDegree:0,outDegree:0}}),ze.forEach(function(xt){q[xt.source].degree++,q[xt.source].outDegree++,q[xt.target].degree++,q[xt.target].inDegree++}),q},Ne=ue,Te=function($,q){var oe=ue($);return oe[q]?ue($)[q].inDegree:0},_e=function($,q){var oe=ue($);return oe[q]?ue($)[q].outDegree:0};function Xe(ne){ne===void 0&&(ne={});var $=ne,q=function(){},oe=function(){var xe={};return function(Ae){var ze=Ae.next;return xe[ze]?!1:(xe[ze]=!0,!0)}}();return $.allowTraversal=ne.allowTraversal||oe,$.enter=ne.enter||q,$.leave=ne.leave||q,$}function Se(ne,$,q,oe,xe){xe===void 0&&(xe=!0),oe.enter({current:$,previous:q});var Ae=ne.edges,ze=Ae===void 0?[]:Ae;N($,ze,xe?"target":void 0).forEach(function(xt){oe.allowTraversal({previous:q,current:$,next:xt})&&Se(ne,xt,$,oe,xe)}),oe.leave({current:$,previous:q})}function Ge(ne,$,q,oe){oe===void 0&&(oe=!0),Se(ne,$,"",Xe(q),oe)}var He=function($){var q=null,oe=$.nodes,xe=oe===void 0?[]:oe,Ae={},ze={},xt={},St={};xe.forEach(function(Ht){ze[Ht.id]=Ht});for(var Lt={enter:function(hn){var Ft=hn.current,_n=hn.previous;if(xt[Ft]){q={};for(var Nn=Ft,Pn=_n;Pn!==Ft;)q[Nn]=Pn,Nn=Pn,Pn=Ae[Pn];q[Nn]=Pn}else xt[Ft]=Ft,delete ze[Ft],Ae[Ft]=_n},leave:function(hn){var Ft=hn.current;St[Ft]=Ft,delete xt[Ft]},allowTraversal:function(hn){var Ft=hn.next;return q?!1:!St[Ft]}};Object.keys(ze).length;){var Vt=Object.keys(ze)[0];Ge($,Vt,Lt)}return q},vt=function($,q,oe){var xe,Ae;oe===void 0&&(oe=!0);for(var ze=[],xt=ye($,!1),St=0,Lt=xt;St<Lt.length;St++){var Vt=Lt[St];if(Vt.length)for(var Ht=Vt[0],hn=Ht.id,Ft=[Ht],_n=(xe={},xe[hn]=Ht,xe),Nn=(Ae={},Ae[hn]=new Set,Ae);Ft.length>0;)for(var Pn=Ft.pop(),ei=Pn.id,ai=N(ei,$.edges),On=function(ji){var Qi,er=ai[ji],gr=$.nodes.find(function(As){return As.id===er});if(er===ei)ze.push((Qi={},Qi[er]=Pn,Qi));else if(!(er in Nn))_n[er]=Pn,Ft.push(gr),Nn[er]=new Set([Pn]);else if(!Nn[ei].has(gr)){for(var yr=!0,Pr=[gr,Pn],Ji=_n[ei];Nn[er].size&&!Nn[er].has(Ji)&&(Pr.push(Ji),Ji!==_n[Ji.id]);)Ji=_n[Ji.id];if(Pr.push(Ji),q&&oe?(yr=!1,Pr.findIndex(function(As){return q.indexOf(As.id)>-1})>-1&&(yr=!0)):q&&!oe&&Pr.findIndex(function(As){return q.indexOf(As.id)>-1})>-1&&(yr=!1),yr){for(var us={},fs=1;fs<Pr.length;fs+=1)us[Pr[fs-1].id]=Pr[fs];Pr.length&&(us[Pr[Pr.length-1].id]=Pr[0]),ze.push(us)}Nn[er].add(Pn)}},di=0;di<ai.length;di+=1)On(di)}return ze},It=function($,q,oe){oe===void 0&&(oe=!0);for(var xe=[],Ae=new Set,ze=[],xt=[],St={},Lt={},Vt=function(Ji){for(var us=[Ji];us.length>0;){var fs=us.pop();Ae.has(fs)&&(Ae.delete(fs),ze[fs.id].forEach(function(As){us.push(As)}),ze[fs.id].clear())}},Ht=function Pr(Ji,us,fs){var As=!1;if(q&&oe===!1&&q.indexOf(Ji.id)>-1)return As;xe.push(Ji),Ae.add(Ji);for(var Ws=fs[Ji.id],Cs=0;Cs<Ws.length;Cs+=1){var hs=St[Ws[Cs]];if(hs===us){for(var Mi={},Xi=1;Xi<xe.length;Xi+=1)Mi[xe[Xi-1].id]=xe[Xi];xe.length&&(Mi[xe[xe.length-1].id]=xe[0]),xt.push(Mi),As=!0}else Ae.has(hs)||Pr(hs,us,fs)&&(As=!0)}if(As)Vt(Ji);else for(var Cs=0;Cs<Ws.length;Cs+=1){var hs=St[Ws[Cs]];ze[hs.id].has(Ji)||ze[hs.id].add(Ji)}return xe.pop(),As},hn=$.nodes,Ft=hn===void 0?[]:hn,_n=0;_n<Ft.length;_n+=1){var Nn=Ft[_n],Pn=Nn.id;Lt[Pn]=_n,St[_n]=Nn}if(q&&oe)for(var ei=function(Ji){var us=q[Ji];Lt[Ft[Ji].id]=Lt[us],Lt[us]=0,St[0]=Ft.find(function(fs){return fs.id===us}),St[Lt[Ft[Ji].id]]=Ft[Ji]},_n=0;_n<q.length;_n++)ei(_n);for(var ai=function(Ji){for(var us,fs,As=1/0,Ws=0;Ws<Ji.length;Ws+=1)for(var Cs=Ji[Ws],hs=0;hs<Cs.length;hs++){var Mi=Lt[Cs[hs].id];Mi<As&&(As=Mi,fs=Ws)}for(var Xi=Ji[fs],Ur=[],Ws=0;Ws<Xi.length;Ws+=1){var zr=Xi[Ws];Ur[zr.id]=[];for(var Or=0,Qr=N(zr.id,$.edges,"target").filter(function(Qa){return Xi.map(function(ao){return ao.id}).indexOf(Qa)>-1});Or<Qr.length;Or++){var Ds=Qr[Or];Ds===zr.id&&!(oe===!1&&q.indexOf(zr.id)>-1)?xt.push((us={},us[zr.id]=zr,us)):Ur[zr.id].push(Lt[Ds])}}return{component:Xi,adjList:Ur,minIdx:As}},On=0;On<Ft.length;){var di=Ft.filter(function(Pr){return Lt[Pr.id]>=On}),Ri=ae({nodes:di,edges:$.edges}).filter(function(Pr){return Pr.length>1});if(Ri.length===0)break;var ji=ai(Ri),Qi=ji.minIdx,er=ji.adjList,gr=ji.component;if(gr.length>1){gr.forEach(function(Pr){ze[Pr.id]=new Set});var yr=St[Qi];if(q&&oe&&q.indexOf(yr.id)===-1)return xt;Ht(yr,yr,er),On=Qi+1}else break}return xt},zt=function($,q,oe,xe){return xe===void 0&&(xe=!0),q?It($,oe,xe):vt($,oe,xe)},Yt=He,At=function(ne,$){return At=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(q,oe){q.__proto__=oe}||function(q,oe){for(var xe in oe)Object.prototype.hasOwnProperty.call(oe,xe)&&(q[xe]=oe[xe])},At(ne,$)};function lt(ne,$){if(typeof $!="function"&&$!==null)throw new TypeError("Class extends value "+String($)+" is not a constructor or null");At(ne,$);function q(){this.constructor=ne}ne.prototype=$===null?Object.create($):(q.prototype=$.prototype,new q)}var Ot=function(){return Ot=Object.assign||function($){for(var q,oe=1,xe=arguments.length;oe<xe;oe++){q=arguments[oe];for(var Ae in q)Object.prototype.hasOwnProperty.call(q,Ae)&&($[Ae]=q[Ae])}return $},Ot.apply(this,arguments)};function le(ne,$){var q={};for(var oe in ne)Object.prototype.hasOwnProperty.call(ne,oe)&&$.indexOf(oe)<0&&(q[oe]=ne[oe]);if(ne!=null&&typeof Object.getOwnPropertySymbols=="function")for(var xe=0,oe=Object.getOwnPropertySymbols(ne);xe<oe.length;xe++)$.indexOf(oe[xe])<0&&Object.prototype.propertyIsEnumerable.call(ne,oe[xe])&&(q[oe[xe]]=ne[oe[xe]]);return q}function Fe(ne,$,q,oe){var xe=arguments.length,Ae=xe<3?$:oe===null?oe=Object.getOwnPropertyDescriptor($,q):oe,ze;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Ae=Reflect.decorate(ne,$,q,oe);else for(var xt=ne.length-1;xt>=0;xt--)(ze=ne[xt])&&(Ae=(xe<3?ze(Ae):xe>3?ze($,q,Ae):ze($,q))||Ae);return xe>3&&Ae&&Object.defineProperty($,q,Ae),Ae}function gt(ne,$){return function(q,oe){$(q,oe,ne)}}function Jt(ne,$,q,oe,xe,Ae){function ze(ei){if(ei!==void 0&&typeof ei!="function")throw new TypeError("Function expected");return ei}for(var xt=oe.kind,St=xt==="getter"?"get":xt==="setter"?"set":"value",Lt=!$&&ne?oe.static?ne:ne.prototype:null,Vt=$||(Lt?Object.getOwnPropertyDescriptor(Lt,oe.name):{}),Ht,hn=!1,Ft=q.length-1;Ft>=0;Ft--){var _n={};for(var Nn in oe)_n[Nn]=Nn==="access"?{}:oe[Nn];for(var Nn in oe.access)_n.access[Nn]=oe.access[Nn];_n.addInitializer=function(ei){if(hn)throw new TypeError("Cannot add initializers after decoration has completed");Ae.push(ze(ei||null))};var Pn=(0,q[Ft])(xt==="accessor"?{get:Vt.get,set:Vt.set}:Vt[St],_n);if(xt==="accessor"){if(Pn===void 0)continue;if(Pn===null||typeof Pn!="object")throw new TypeError("Object expected");(Ht=ze(Pn.get))&&(Vt.get=Ht),(Ht=ze(Pn.set))&&(Vt.set=Ht),(Ht=ze(Pn.init))&&xe.push(Ht)}else(Ht=ze(Pn))&&(xt==="field"?xe.push(Ht):Vt[St]=Ht)}Lt&&Object.defineProperty(Lt,oe.name,Vt),hn=!0}function Ze(ne,$,q){for(var oe=arguments.length>2,xe=0;xe<$.length;xe++)q=oe?$[xe].call(ne,q):$[xe].call(ne);return oe?q:void 0}function rt(ne){return typeof ne=="symbol"?ne:"".concat(ne)}function Mt(ne,$,q){return typeof $=="symbol"&&($=$.description?"[".concat($.description,"]"):""),Object.defineProperty(ne,"name",{configurable:!0,value:q?"".concat(q," ",$):$})}function Ue(ne,$){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(ne,$)}function Ye(ne,$,q,oe){function xe(Ae){return Ae instanceof q?Ae:new q(function(ze){ze(Ae)})}return new(q||(q=Promise))(function(Ae,ze){function xt(Vt){try{Lt(oe.next(Vt))}catch(Ht){ze(Ht)}}function St(Vt){try{Lt(oe.throw(Vt))}catch(Ht){ze(Ht)}}function Lt(Vt){Vt.done?Ae(Vt.value):xe(Vt.value).then(xt,St)}Lt((oe=oe.apply(ne,$||[])).next())})}function be(ne,$){var q={label:0,sent:function(){if(Ae[0]&1)throw Ae[1];return Ae[1]},trys:[],ops:[]},oe,xe,Ae,ze;return ze={next:xt(0),throw:xt(1),return:xt(2)},typeof Symbol=="function"&&(ze[Symbol.iterator]=function(){return this}),ze;function xt(Lt){return function(Vt){return St([Lt,Vt])}}function St(Lt){if(oe)throw new TypeError("Generator is already executing.");for(;ze&&(ze=0,Lt[0]&&(q=0)),q;)try{if(oe=1,xe&&(Ae=Lt[0]&2?xe.return:Lt[0]?xe.throw||((Ae=xe.return)&&Ae.call(xe),0):xe.next)&&!(Ae=Ae.call(xe,Lt[1])).done)return Ae;switch(xe=0,Ae&&(Lt=[Lt[0]&2,Ae.value]),Lt[0]){case 0:case 1:Ae=Lt;break;case 4:return q.label++,{value:Lt[1],done:!1};case 5:q.label++,xe=Lt[1],Lt=[0];continue;case 7:Lt=q.ops.pop(),q.trys.pop();continue;default:if(Ae=q.trys,!(Ae=Ae.length>0&&Ae[Ae.length-1])&&(Lt[0]===6||Lt[0]===2)){q=0;continue}if(Lt[0]===3&&(!Ae||Lt[1]>Ae[0]&&Lt[1]<Ae[3])){q.label=Lt[1];break}if(Lt[0]===6&&q.label<Ae[1]){q.label=Ae[1],Ae=Lt;break}if(Ae&&q.label<Ae[2]){q.label=Ae[2],q.ops.push(Lt);break}Ae[2]&&q.ops.pop(),q.trys.pop();continue}Lt=$.call(ne,q)}catch(Vt){Lt=[6,Vt],xe=0}finally{oe=Ae=0}if(Lt[0]&5)throw Lt[1];return{value:Lt[0]?Lt[1]:void 0,done:!0}}}var ge=Object.create?function(ne,$,q,oe){oe===void 0&&(oe=q);var xe=Object.getOwnPropertyDescriptor($,q);(!xe||("get"in xe?!$.__esModule:xe.writable||xe.configurable))&&(xe={enumerable:!0,get:function(){return $[q]}}),Object.defineProperty(ne,oe,xe)}:function(ne,$,q,oe){oe===void 0&&(oe=q),ne[oe]=$[q]};function Ke(ne,$){for(var q in ne)q!=="default"&&!Object.prototype.hasOwnProperty.call($,q)&&ge($,ne,q)}function wt(ne){var $=typeof Symbol=="function"&&Symbol.iterator,q=$&&ne[$],oe=0;if(q)return q.call(ne);if(ne&&typeof ne.length=="number")return{next:function(){return ne&&oe>=ne.length&&(ne=void 0),{value:ne&&ne[oe++],done:!ne}}};throw new TypeError($?"Object is not iterable.":"Symbol.iterator is not defined.")}function Be(ne,$){var q=typeof Symbol=="function"&&ne[Symbol.iterator];if(!q)return ne;var oe=q.call(ne),xe,Ae=[],ze;try{for(;($===void 0||$-- >0)&&!(xe=oe.next()).done;)Ae.push(xe.value)}catch(xt){ze={error:xt}}finally{try{xe&&!xe.done&&(q=oe.return)&&q.call(oe)}finally{if(ze)throw ze.error}}return Ae}function ut(){for(var ne=[],$=0;$<arguments.length;$++)ne=ne.concat(Be(arguments[$]));return ne}function Et(){for(var ne=0,$=0,q=arguments.length;$<q;$++)ne+=arguments[$].length;for(var oe=Array(ne),xe=0,$=0;$<q;$++)for(var Ae=arguments[$],ze=0,xt=Ae.length;ze<xt;ze++,xe++)oe[xe]=Ae[ze];return oe}function je(ne,$,q){if(q||arguments.length===2)for(var oe=0,xe=$.length,Ae;oe<xe;oe++)(Ae||!(oe in $))&&(Ae||(Ae=Array.prototype.slice.call($,0,oe)),Ae[oe]=$[oe]);return ne.concat(Ae||Array.prototype.slice.call($))}function tt(ne){return this instanceof tt?(this.v=ne,this):new tt(ne)}function yt(ne,$,q){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var oe=q.apply(ne,$||[]),xe,Ae=[];return xe={},ze("next"),ze("throw"),ze("return"),xe[Symbol.asyncIterator]=function(){return this},xe;function ze(hn){oe[hn]&&(xe[hn]=function(Ft){return new Promise(function(_n,Nn){Ae.push([hn,Ft,_n,Nn])>1||xt(hn,Ft)})})}function xt(hn,Ft){try{St(oe[hn](Ft))}catch(_n){Ht(Ae[0][3],_n)}}function St(hn){hn.value instanceof tt?Promise.resolve(hn.value.v).then(Lt,Vt):Ht(Ae[0][2],hn)}function Lt(hn){xt("next",hn)}function Vt(hn){xt("throw",hn)}function Ht(hn,Ft){hn(Ft),Ae.shift(),Ae.length&&xt(Ae[0][0],Ae[0][1])}}function B(ne){var $,q;return $={},oe("next"),oe("throw",function(xe){throw xe}),oe("return"),$[Symbol.iterator]=function(){return this},$;function oe(xe,Ae){$[xe]=ne[xe]?function(ze){return(q=!q)?{value:tt(ne[xe](ze)),done:!1}:Ae?Ae(ze):ze}:Ae}}function te(ne){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var $=ne[Symbol.asyncIterator],q;return $?$.call(ne):(ne=typeof wt=="function"?wt(ne):ne[Symbol.iterator](),q={},oe("next"),oe("throw"),oe("return"),q[Symbol.asyncIterator]=function(){return this},q);function oe(Ae){q[Ae]=ne[Ae]&&function(ze){return new Promise(function(xt,St){ze=ne[Ae](ze),xe(xt,St,ze.done,ze.value)})}}function xe(Ae,ze,xt,St){Promise.resolve(St).then(function(Lt){Ae({value:Lt,done:xt})},ze)}}function ot(ne,$){return Object.defineProperty?Object.defineProperty(ne,"raw",{value:$}):ne.raw=$,ne}var _t=Object.create?function(ne,$){Object.defineProperty(ne,"default",{enumerable:!0,value:$})}:function(ne,$){ne.default=$};function ct(ne){if(ne&&ne.__esModule)return ne;var $={};if(ne!=null)for(var q in ne)q!=="default"&&Object.prototype.hasOwnProperty.call(ne,q)&&ge($,ne,q);return _t($,ne),$}function qt(ne){return ne&&ne.__esModule?ne:{default:ne}}function en(ne,$,q,oe){if(q==="a"&&!oe)throw new TypeError("Private accessor was defined without a getter");if(typeof $=="function"?ne!==$||!oe:!$.has(ne))throw new TypeError("Cannot read private member from an object whose class did not declare it");return q==="m"?oe:q==="a"?oe.call(ne):oe?oe.value:$.get(ne)}function nn(ne,$,q,oe,xe){if(oe==="m")throw new TypeError("Private method is not writable");if(oe==="a"&&!xe)throw new TypeError("Private accessor was defined without a setter");if(typeof $=="function"?ne!==$||!xe:!$.has(ne))throw new TypeError("Cannot write private member to an object whose class did not declare it");return oe==="a"?xe.call(ne,q):xe?xe.value=q:$.set(ne,q),q}function we(ne,$){if($===null||typeof $!="object"&&typeof $!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof ne=="function"?$===ne:ne.has($)}var Q={}.toString,De=function(ne,$){return Q.call(ne)==="[object "+$+"]"},We=De,Ce=function(ne){return We(ne,"Function")},Re=function(ne){return Array.isArray?Array.isArray(ne):We(ne,"Array")},qe=function(ne){var $=typeof ne;return ne!==null&&$==="object"||$==="function"};function st(ne,$){if(ne){var q;if(Re(ne))for(var oe=0,xe=ne.length;oe<xe&&(q=$(ne[oe],oe),q!==!1);oe++);else if(qe(ne)){for(var Ae in ne)if(ne.hasOwnProperty(Ae)&&(q=$(ne[Ae],Ae),q===!1))break}}}var $e=st,ft=Object.keys?function(ne){return Object.keys(ne)}:function(ne){var $=[];return $e(ne,function(q,oe){Ce(ne)&&oe==="prototype"||$.push(oe)}),$},Ct=null;function jt(ne,$){var q=keys($),oe=q.length;if(isNil(ne))return!oe;for(var xe=0;xe<oe;xe+=1){var Ae=q[xe];if($[Ae]!==ne[Ae]||!(Ae in ne))return!1}return!0}var Qt=null,pn=function(ne){if(!isObjectLike(ne)||!isType(ne,"Object"))return!1;if(Object.getPrototypeOf(ne)===null)return!0;for(var $=ne;Object.getPrototypeOf($)!==null;)$=Object.getPrototypeOf($);return Object.getPrototypeOf(ne)===$},Wn=null;function Rn(ne,$){if(!isArray(ne))return null;var q;if(isFunction($)&&(q=$),isPlainObject($)&&(q=function(xe){return isMatch(xe,$)}),q){for(var oe=0;oe<ne.length;oe+=1)if(q(ne[oe]))return ne[oe]}return null}var bi=null,Dr=function(ne,$){for(var q=null,oe=0;oe<ne.length;oe++){var xe=ne[oe],Ae=xe[$];if(!isNil(Ae)){isArray(Ae)?q=Ae[0]:q=Ae;break}}return q},Qn=null,Vi=function(ne){if(!isArray(ne))return[];for(var $=[],q=0;q<ne.length;q++)$=$.concat(ne[q]);return $},Oi=null,Gi=function(ne,$){if($===void 0&&($=[]),!isArray(ne))$.push(ne);else for(var q=0;q<ne.length;q+=1)Gi(ne[q],$);return $},ir=null,gs=function(ne){if(isArray(ne))return ne.reduce(function($,q){return Math.max($,q)},ne[0])},Ls=function(ne){if(isArray(ne))return ne.reduce(function($,q){return Math.min($,q)},ne[0])},ls=function(ne){var $=ne.filter(function(ze){return!isNaN(ze)});if(!$.length)return{min:0,max:0};if(isArray(ne[0])){for(var q=[],oe=0;oe<ne.length;oe++)q=q.concat(ne[oe]);$=q}var xe=getMax($),Ae=getMin($);return{min:Ae,max:xe}},ys=null,Gs=Array.prototype,Yl=Gs.splice,Zl=Gs.indexOf,Fa=function(ne){for(var $=[],q=1;q<arguments.length;q++)$[q-1]=arguments[q];for(var oe=0;oe<$.length;oe++)for(var xe=$[oe],Ae=-1;(Ae=Zl.call(ne,xe))>-1;)Yl.call(ne,Ae,1);return ne},Fl=null,su=Array.prototype.splice,Bu=function($,q){if(!isArrayLike($))return[];for(var oe=$?q.length:0,xe=oe-1;oe--;){var Ae=void 0,ze=q[oe];(oe===xe||ze!==Ae)&&(Ae=ze,su.call($,ze,1))}return $},Pe=null,D=function(ne,$,q){if(!isArray(ne)&&!isPlainObject(ne))return ne;var oe=q;return each(ne,function(xe,Ae){oe=$(oe,xe,Ae)}),oe},U=null,_=function(ne,$){var q=[];if(!isArrayLike(ne))return q;for(var oe=-1,xe=[],Ae=ne.length;++oe<Ae;){var ze=ne[oe];$(ze,oe,ne)&&(q.push(ze),xe.push(oe))}return pullAt(ne,xe),q},F=null,X=function(ne){return We(ne,"String")};function Ie(ne,$){var q;if(isFunction($))q=function(xe,Ae){return $(xe)-$(Ae)};else{var oe=[];isString($)?oe.push($):isArray($)&&(oe=$),q=function(xe,Ae){for(var ze=0;ze<oe.length;ze+=1){var xt=oe[ze];if(xe[xt]>Ae[xt])return 1;if(xe[xt]<Ae[xt])return-1}return 0}}return ne.sort(q),ne}var ke=null;function et(ne,$){$===void 0&&($=new Map);var q=[];if(Array.isArray(ne))for(var oe=0,xe=ne.length;oe<xe;oe++){var Ae=ne[oe];$.has(Ae)||(q.push(Ae),$.set(Ae,!0))}return q}var nt=function(ne,$){for(var q=[],oe={},xe=0;xe<ne.length;xe++){var Ae=ne[xe],ze=Ae[$];if(!isNil(ze)){isArray(ze)||(ze=[ze]);for(var xt=0;xt<ze.length;xt++){var St=ze[xt];oe[St]||(q.push(St),oe[St]=!0)}}}return q};function Wt(ne,$){return isArray(ne)||isString(ne)?ne[0]===$:!1}var Tt=null;function on(ne,$){return isArray(ne)||isString(ne)?ne[ne.length-1]===$:!1}var Un=null,sn=Object.prototype.hasOwnProperty;function bn(ne,$){if(!$||!isArray(ne))return{};for(var q={},oe=isFunction($)?$:function(xt){return xt[$]},xe,Ae=0;Ae<ne.length;Ae++){var ze=ne[Ae];xe=oe(ze),sn.call(q,xe)?q[xe].push(ze):q[xe]=[ze]}return q}var ti=null;function Bt(ne,$){if(!$)return{0:ne};if(!isFunction($)){var q=isArray($)?$:$.replace(/\s+/g,"").split("*");$=function(oe){for(var xe="_",Ae=0,ze=q.length;Ae<ze;Ae++)xe+=oe[q[Ae]]&&oe[q[Ae]].toString();return xe}}return groupBy(ne,$)}var $n=function(ne,$){if(!$)return[ne];var q=groupToMap(ne,$),oe=[];for(var xe in q)oe.push(q[xe]);return oe},ni={};function Pi(ne){var $=ni[ne];if(!$){for(var q=ne.toString(16),oe=q.length;oe<6;oe++)q="0"+q;$="#"+q,ni[ne]=$}return $}var ui=null;function Lr(ne){var $=0,q=0,oe=0,xe=0;return isArray(ne)?ne.length===1?$=q=oe=xe=ne[0]:ne.length===2?($=oe=ne[0],q=xe=ne[1]):ne.length===3?($=ne[0],q=xe=ne[1],oe=ne[2]):($=ne[0],q=ne[1],oe=ne[2],xe=ne[3]):$=q=oe=xe=ne,{r1:$,r2:q,r3:oe,r4:xe}}var yi=null,vi=function(ne){return We(ne,"Number")},Mr=vi,Zt=function(ne){return isNumber(ne)&&ne%1!==0},Fn=null,hi=function(ne){return isNumber(ne)&&ne%2===0},Xn=null,ds=Number.isInteger?Number.isInteger:function(ne){return Mr(ne)&&ne%1===0},qr=null,vs=function(ne){return isNumber(ne)&&ne<0},kr=null,Fs=function(ne){return isNumber(ne)&&ne%2!==0},io=null,ro=function(ne){return isNumber(ne)&&ne>0},To=null,Eo=function(ne,$){if(isArray(ne)){for(var q,oe=-1/0,xe=0;xe<ne.length;xe++){var Ae=ne[xe],ze=isFunction($)?$(Ae):Ae[$];ze>oe&&(q=Ae,oe=ze)}return q}},Wr=function(ne,$){if(isArray(ne)){for(var q,oe=1/0,xe=0;xe<ne.length;xe++){var Ae=ne[xe],ze=isFunction($)?$(Ae):Ae[$];ze<oe&&(q=Ae,oe=ze)}return q}},eo=180/Math.PI,Ao=function(ne){return eo*ne},so=null,Yr=Math.PI/180,ua=function(ne){return Yr*ne},Co=null,sl=null,ol=Object.values?function(ne){return Object.values(ne)}:function(ne){var $=[];return $e(ne,function(q,oe){Ce(ne)&&oe==="prototype"||$.push(q)}),$},ha=ol,Ba=function(ne,$){return contains(values(ne),$)},al={}.toString,wo=function(ne){return al.call(ne).replace(/^\[object /,"").replace(/]$/,"")},Lc=null,ox=function(ne){return isType(ne,"Arguments")},hh=null,M0=function(ne){return isType(ne,"Boolean")},rp=null,sp=function(ne){return isType(ne,"Date")},S0=null,Bm=function(ne){return isType(ne,"Error")},Xa=null;function Jd(ne){return isNumber(ne)&&isFinite(ne)}var ea=Object.prototype,uo=function(ne){var $=ne&&ne.constructor,q=typeof $=="function"&&$.prototype||ea;return ne===q},ou=null,dh=function(ne){return isType(ne,"RegExp")},Fi=null,a1=function(){for(var ne=[],$=0;$<arguments.length;$++)ne[$]=arguments[$];for(var q=ne[0],oe=1;oe<ne.length;oe++){var xe=ne[oe];isFunction(xe)&&(xe=xe.prototype),mix(q.prototype,xe)}},Kl=null,Um=function(ne){if(typeof ne!="object"||ne===null)return ne;var $;if(Re(ne)){$=[];for(var q=0,oe=ne.length;q<oe;q++)typeof ne[q]=="object"&&ne[q]!=null?$[q]=Um(ne[q]):$[q]=ne[q]}else{$={};for(var xe in ne)typeof ne[xe]=="object"&&ne[xe]!=null?$[xe]=Um(ne[xe]):$[xe]=ne[xe]}return $},Qd=Um,ax=function(ne,$){if(!Ce(ne))throw new TypeError("Expected a function");var q=function(){for(var oe=[],xe=0;xe<arguments.length;xe++)oe[xe]=arguments[xe];var Ae=$?$.apply(this,oe):oe[0],ze=q.cache;if(ze.has(Ae))return ze.get(Ae);var xt=ne.apply(this,oe);return ze.set(Ae,xt),xt};return q.cache=new Map,q},lx=5;function T0(ne,$,q,oe){q=q||0,oe=oe||lx;for(var xe in $)if($.hasOwnProperty(xe)){var Ae=$[xe];Ae!==null&&isPlainObject(Ae)?(isPlainObject(ne[xe])||(ne[xe]={}),q<oe?T0(ne[xe],Ae,q+1,oe):ne[xe]=$[xe]):isArray(Ae)?(ne[xe]=[],ne[xe]=ne[xe].concat(Ae)):Ae!==void 0&&(ne[xe]=Ae)}}var l1=function(ne){for(var $=[],q=1;q<arguments.length;q++)$[q-1]=arguments[q];for(var oe=0;oe<$.length;oe+=1)T0(ne,$[oe]);return ne},c1=null,u1=function(ne,$,q,oe){isFunction($)||(q=$,$=ne,ne=function(){});var xe=Object.create?function(ze,xt){return Object.create(ze,{constructor:{value:xt}})}:function(ze,xt){function St(){}St.prototype=ze;var Lt=new St;return Lt.constructor=xt,Lt},Ae=xe($.prototype,ne);return ne.prototype=mix(Ae,ne.prototype),ne.superclass=xe($.prototype,$),mix(Ae,q),mix(ne,oe),ne},h1=null,cx=Object.prototype.hasOwnProperty;function d1(ne){if(isNil(ne))return!0;if(isArrayLike(ne))return!ne.length;var $=getType(ne);if($==="Map"||$==="Set")return!ne.size;if(isPrototype(ne))return!Object.keys(ne).length;for(var q in ne)if(cx.call(ne,q))return!1;return!0}var f1=null,ux=function(ne){return typeof ne=="object"&&ne!==null},Jh=ux,km=function(ne){return ne!==null&&typeof ne!="function"&&isFinite(ne.length)},ef=km,tf=function(ne,$){if(ne===$)return!0;if(!ne||!$||X(ne)||X($))return!1;if(ef(ne)||ef($)){if(ne.length!==$.length)return!1;for(var q=!0,oe=0;oe<ne.length&&(q=tf(ne[oe],$[oe]),!!q);oe++);return q}if(Jh(ne)||Jh($)){var xe=Object.keys(ne),Ae=Object.keys($);if(xe.length!==Ae.length)return!1;for(var q=!0,oe=0;oe<xe.length&&(q=tf(ne[xe[oe]],$[xe[oe]]),!!q);oe++);return q}return!1},op=tf,E0=function(ne,$,q){return isFunction(q)?!!q(ne,$):isEqual(ne,$)},A0=function(ne,$,q){for(var oe=0,xe=isString($)?$.split("."):$;ne&&oe<xe.length;)ne=ne[xe[oe++]];return ne===void 0||oe<xe.length?q:ne},C0=function(ne,$,q){var oe=ne,xe=isString($)?$.split("."):$;return xe.forEach(function(Ae,ze){ze<xe.length-1?(isObject(oe[Ae])||(oe[Ae]=isNumber(xe[ze+1])?[]:{}),oe=oe[Ae]):oe[Ae]=q}),ne},zm=Object.prototype.hasOwnProperty,Uu=function(ne,$){if(ne===null||!isPlainObject(ne))return{};var q={};return each($,function(oe){zm.call(ne,oe)&&(q[oe]=ne[oe])}),q},nf=function(ne,$){return reduce(ne,function(q,oe,xe){return $.includes(xe)||(q[xe]=oe),q},{})},Vm={},fE=function(ne){return ne=ne||"g",Vm[ne]?Vm[ne]+=1:Vm[ne]=1,ne+Vm[ne]},Gm,pE=ax(function(ne,$){$===void 0&&($={});var q=$.fontSize,oe=$.fontFamily,xe=$.fontWeight,Ae=$.fontStyle,ze=$.fontVariant;return Gm||(Gm=document.createElement("canvas").getContext("2d")),Gm.font=[Ae,ze,xe,q+"px",oe].join(" "),Gm.measureText(X(ne)?ne:"").width},function(ne,$){return $===void 0&&($={}),Et([ne],ha($)).join("")}),mE=function(ne,$,q,oe){oe===void 0&&(oe="...");var xe=16,Ae=measureTextWidth(oe,q),ze=isString(ne)?ne:toString(ne),xt=$,St=[],Lt,Vt;if(measureTextWidth(ne,q)<=$)return ne;for(;Lt=ze.substr(0,xe),Vt=measureTextWidth(Lt,q),!(Vt+Ae>xt&&Vt>xt);)if(St.push(Lt),xt-=Vt,ze=ze.substr(xe),!ze)return St.join("");for(;Lt=ze.substr(0,1),Vt=measureTextWidth(Lt,q),!(Vt+Ae>xt);)if(St.push(Lt),xt-=Vt,ze=ze.substr(1),!ze)return St.join("");return""+St.join("")+oe},gE=function(){function ne(){this.map={}}return ne.prototype.has=function($){return this.map[$]!==void 0},ne.prototype.get=function($,q){var oe=this.map[$];return oe===void 0?q:oe},ne.prototype.set=function($,q){this.map[$]=q},ne.prototype.clear=function(){this.map={}},ne.prototype.delete=function($){delete this.map[$]},ne.prototype.size=function(){return Object.keys(this.map).length},ne}(),yE=null,p1=function($,q,oe){for(var xe=1/0,Ae,ze=0;ze<q.length;ze++){var xt=q[ze].id;!oe[xt]&&$[xt]<=xe&&(xe=$[xt],Ae=q[ze])}return Ae},R0=function($,q,oe,xe){var Ae=$.nodes,ze=Ae===void 0?[]:Ae,xt=$.edges,St=xt===void 0?[]:xt,Lt=[],Vt={},Ht={},hn={};ze.forEach(function(On,di){var Ri=On.id;Lt.push(Ri),Ht[Ri]=1/0,Ri===q&&(Ht[Ri]=0)});for(var Ft=ze.length,_n=function(di){var Ri=p1(Ht,ze,Vt),ji=Ri.id;if(Vt[ji]=!0,Ht[ji]===1/0)return"continue";var Qi=[];oe?Qi=L(ji,St):Qi=P(ji,St),Qi.forEach(function(er){var gr=er.target,yr=er.source,Pr=gr===ji?yr:gr,Ji=xe&&er[xe]?er[xe]:1;Ht[Pr]>Ht[Ri.id]+Ji?(Ht[Pr]=Ht[Ri.id]+Ji,hn[Pr]=[Ri.id]):Ht[Pr]===Ht[Ri.id]+Ji&&hn[Pr].push(Ri.id)})},Nn=0;Nn<Ft;Nn++)_n(Nn);hn[q]=[q];var Pn={};for(var ei in Ht)Ht[ei]!==1/0&&qa(q,ei,hn,Pn);var ai={};for(var ei in Pn)ai[ei]=Pn[ei][0];return{length:Ht,path:ai,allPath:Pn}},oo=R0;function qa(ne,$,q,oe){if(ne===$)return[ne];if(oe[$])return oe[$];for(var xe=[],Ae=0,ze=q[$];Ae<ze.length;Ae++){var xt=ze[Ae],St=qa(ne,xt,q,oe);if(!St)return;for(var Lt=0,Vt=St;Lt<Vt.length;Lt++){var Ht=Vt[Lt];Re(Ht)?xe.push(je(je([],Ht,!0),[$],!1)):xe.push([Ht,$])}}return oe[$]=xe,oe[$]}var fh=function($,q,oe,xe,Ae){var ze=oo($,q,xe,Ae),xt=ze.length,St=ze.path,Lt=ze.allPath;return{length:xt[oe],path:St[oe],allPath:Lt[oe]}},m1=function($,q,oe,xe){var Ae;if(q===oe)return[[q]];var ze=$.edges,xt=ze===void 0?[]:ze,St=[q],Lt=(Ae={},Ae[q]=!0,Ae),Vt=[],Ht=[],hn=xe?N(q,xt,"target"):N(q,xt);for(Vt.push(hn);St.length>0&&Vt.length>0;){var Ft=Vt[Vt.length-1];if(Ft.length){var _n=Ft.shift();_n&&(St.push(_n),Lt[_n]=!0,hn=xe?N(_n,xt,"target"):N(_n,xt),Vt.push(hn.filter(function(ei){return!Lt[ei]})))}else{var Nn=St.pop();Lt[Nn]=!1,Vt.pop();continue}if(St[St.length-1]===oe){var Pn=St.map(function(ai){return ai});Ht.push(Pn);var Nn=St.pop();Lt[Nn]=!1,Vt.pop()}}return Ht},g1=function($,q){for(var oe=k($,q),xe=[],Ae=oe.length,ze=0;ze<Ae;ze+=1){xe[ze]=[];for(var xt=0;xt<Ae;xt+=1)ze===xt?xe[ze][xt]=0:oe[ze][xt]===0||!oe[ze][xt]?xe[ze][xt]=1/0:xe[ze][xt]=oe[ze][xt]}for(var St=0;St<Ae;St+=1)for(var ze=0;ze<Ae;ze+=1)for(var xt=0;xt<Ae;xt+=1)xe[ze][xt]>xe[ze][St]+xe[St][xt]&&(xe[ze][xt]=xe[ze][St]+xe[St][xt]);return xe},Bl=g1,Ya=function($,q,oe,xe){q===void 0&&(q=!1),oe===void 0&&(oe="weight"),xe===void 0&&(xe=1e3);var Ae=$.nodes,ze=Ae===void 0?[]:Ae,xt=$.edges,St=xt===void 0?[]:xt,Lt={},Vt={};ze.forEach(function(di,Ri){var ji=W();di.clusterId=ji,Lt[ji]={id:ji,nodes:[di]},Vt[di.id]={node:di,idx:Ri}});var Ht=k($,q),hn=[],Ft={};Ht.forEach(function(di,Ri){var ji=0,Qi=ze[Ri].id;Ft[Qi]={},di.forEach(function(er,gr){if(er){ji+=er;var yr=ze[gr].id;Ft[Qi][yr]=er}}),hn.push(ji)});for(var _n=0,Nn=function(){var Ri=!1;if(ze.forEach(function(ji){var Qi={};Object.keys(Ft[ji.id]).forEach(function(As){var Ws=Ft[ji.id][As],Cs=Vt[As].node,hs=Cs.clusterId;Qi[hs]||(Qi[hs]=0),Qi[hs]+=Ws});var er=-1/0,gr=[];if(Object.keys(Qi).forEach(function(As){er<Qi[As]?(er=Qi[As],gr=[As]):er===Qi[As]&&gr.push(As)}),!(gr.length===1&&gr[0]===ji.clusterId)){var yr=gr.indexOf(ji.clusterId);if(yr>=0&&gr.splice(yr,1),gr&&gr.length){Ri=!0;var Pr=Lt[ji.clusterId],Ji=Pr.nodes.indexOf(ji);Pr.nodes.splice(Ji,1);var us=Math.floor(Math.random()*gr.length),fs=Lt[gr[us]];fs.nodes.push(ji),ji.clusterId=fs.id}}}),!Ri)return"break";_n++};_n<xe;){var Pn=Nn();if(Pn==="break")break}Object.keys(Lt).forEach(function(di){var Ri=Lt[di];(!Ri.nodes||!Ri.nodes.length)&&delete Lt[di]});var ei=[],ai={};St.forEach(function(di){var Ri=di.source,ji=di.target,Qi=di[oe]||1,er=Vt[Ri].node.clusterId,gr=Vt[ji].node.clusterId,yr="".concat(er,"---").concat(gr);if(ai[yr])ai[yr].weight+=Qi,ai[yr].count++;else{var Pr={source:er,target:gr,weight:Qi,count:1};ai[yr]=Pr,ei.push(Pr)}});var On=[];return Object.keys(Lt).forEach(function(di){On.push(Lt[di])}),{clusters:On,clusterEdges:ei}},ku=Ya,uc=function(){function ne($){this.arr=$}return ne.prototype.getArr=function(){return this.arr||[]},ne.prototype.add=function($){var q,oe=$.arr;if(!(!((q=this.arr)===null||q===void 0)&&q.length))return new ne(oe);if(!(oe!=null&&oe.length))return new ne(this.arr);if(this.arr.length===oe.length){var xe=[];for(var Ae in this.arr)xe[Ae]=this.arr[Ae]+oe[Ae];return new ne(xe)}},ne.prototype.subtract=function($){var q,oe=$.arr;if(!(!((q=this.arr)===null||q===void 0)&&q.length))return new ne(oe);if(!(oe!=null&&oe.length))return new ne(this.arr);if(this.arr.length===oe.length){var xe=[];for(var Ae in this.arr)xe[Ae]=this.arr[Ae]-oe[Ae];return new ne(xe)}},ne.prototype.avg=function($){var q=[];if($!==0)for(var oe in this.arr)q[oe]=this.arr[oe]/$;return new ne(q)},ne.prototype.negate=function(){var $=[];for(var q in this.arr)$[q]=-this.arr[q];return new ne($)},ne.prototype.squareEuclideanDistance=function($){var q,oe=$.arr;if(!(!((q=this.arr)===null||q===void 0)&&q.length)||!(oe!=null&&oe.length))return 0;if(this.arr.length===oe.length){var xe=0;for(var Ae in this.arr)xe+=Math.pow(this.arr[Ae]-$.arr[Ae],2);return xe}},ne.prototype.euclideanDistance=function($){var q,oe=$.arr;if(!(!((q=this.arr)===null||q===void 0)&&q.length)||!(oe!=null&&oe.length))return 0;if(this.arr.length===oe.length){var xe=0;for(var Ae in this.arr)xe+=Math.pow(this.arr[Ae]-$.arr[Ae],2);return Math.sqrt(xe)}else console.error("The two vectors are unequal in length.")},ne.prototype.normalize=function(){var $=[],q=Qd(this.arr);q.sort(function(ze,xt){return ze-xt});var oe=q[q.length-1],xe=q[0];for(var Ae in this.arr)$[Ae]=(this.arr[Ae]-xe)/(oe-xe);return new ne($)},ne.prototype.norm2=function(){var $;if(!(!(($=this.arr)===null||$===void 0)&&$.length))return 0;var q=0;for(var oe in this.arr)q+=Math.pow(this.arr[oe],2);return Math.sqrt(q)},ne.prototype.dot=function($){var q,oe=$.arr;if(!(!((q=this.arr)===null||q===void 0)&&q.length)||!(oe!=null&&oe.length))return 0;if(this.arr.length===oe.length){var xe=0;for(var Ae in this.arr)xe+=this.arr[Ae]*$.arr[Ae];return xe}else console.error("The two vectors are unequal in length.")},ne.prototype.equal=function($){var q,oe=$.arr;if(((q=this.arr)===null||q===void 0?void 0:q.length)!==(oe==null?void 0:oe.length))return!1;for(var xe in this.arr)if(this.arr[xe]!==oe[xe])return!1;return!0},ne}(),Ua=uc,xl=/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/,Sr=/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/,ap=function($,q){$===void 0&&($=[]),q===void 0&&(q=100);var oe={};$.forEach(function(Ae){Ae.properties&&Object.keys(Ae.properties).forEach(function(ze){if(ze==="id"||!"".concat(Ae.properties[ze]).match(xl)&&!"".concat(Ae.properties[ze]).match(Sr)&&isNaN(Number(Ae.properties[ze]))){oe.hasOwnProperty(ze)&&delete oe[ze];return}oe.hasOwnProperty(ze)?oe[ze]+=1:oe[ze]=1})});var xe=Object.keys(oe).sort(function(Ae,ze){return oe[ze]-oe[Ae]});return xe.length<q?xe:xe.slice(0,q)},hx=function($,q){return q.map(function(oe){return $.hasOwnProperty(oe)?$[oe]:0})},Wm=function($){for(var q=ap($),oe=[],xe=0;xe<$.length;xe++)oe[xe]=hx($[xe].properties,q);return oe},_r=function($,q){q===void 0&&(q=void 0);var oe=[];return $.forEach(function(xe){q===void 0&&oe.push(xe),xe[q]!==void 0&&oe.push(xe[q])}),oe},Xs={getAllSortProperties:ap,getPropertyWeight:Wm,getAllProperties:_r},Ul;(function(ne){ne.EuclideanDistance="euclideanDistance"})(Ul||(Ul={}));var N0=function($,q,oe){var xe=[];q!=null&&q.length?xe=q:($.forEach(function(ze){xe=xe.concat(Object.keys(ze))}),xe=et(xe));var Ae={};return xe.forEach(function(ze){var xt=[];$.forEach(function(St){St[ze]!==void 0&&St[ze]!==""&&xt.push(St[ze])}),xt.length&&!(oe!=null&&oe.includes(ze))&&(Ae[ze]=et(xt))}),Ae},zu=function($,q,oe){var xe=N0($,q,oe),Ae=[];if(!Object.keys(xe).length)return Ae;var ze=Object.values(xe),xt=ze.every(function(St){return St.every(function(Lt){return typeof Lt=="number"})});return $.forEach(function(St,Lt){var Vt=[];Object.keys(xe).forEach(function(Ht){var hn=St[Ht],Ft=xe[Ht],_n=Ft.findIndex(function(ei){return hn===ei}),Nn=[];if(xt)Nn.push(hn);else for(var Pn=0;Pn<Ft.length;Pn++)Pn===_n?Nn.push(1):Nn.push(0);Vt=Vt.concat(Nn)}),Ae[Lt]=Vt}),Ae},wa=function($,q,oe,xe){oe===void 0&&(oe=Ul.EuclideanDistance);var Ae=0;switch(oe){case Ul.EuclideanDistance:Ae=new Ua($).euclideanDistance(new Ua(q));break;default:break}return Ae},P0={getAllKeyValueMap:N0,oneHot:zu,getDistance:wa},au=function($,q,oe,xe){for(var Ae=q.length,ze=2*xe,xt=0,St=0;St<Ae;St++)for(var Lt=$[St].clusterId,Vt=0;Vt<Ae;Vt++){var Ht=$[Vt].clusterId;if(Lt===Ht){var hn=q[St][Vt]||0,Ft=oe[St]||0,_n=oe[Vt]||0;xt+=hn-Ft*_n/ze}}return xt*=1/ze,xt},Vu=function($,q){$===void 0&&($=[]);for(var oe=$.length,xe=new Ua([]),Ae=0;Ae<oe;Ae++)xe=xe.add(new Ua(q[Ae]));var ze=xe.avg(oe);ze.normalize();for(var xt=0,Ae=0;Ae<oe;Ae++){var St=new Ua(q[Ae]),Lt=St.squareEuclideanDistance(ze);xt+=Lt}var Vt=[];$.forEach(function(){Vt.push([])});for(var Ae=0;Ae<oe;Ae++){var St=new Ua(q[Ae]);$[Ae].clusterInertial=0;for(var Ht=0;Ht<oe;Ht++){if(Ae===Ht){Vt[Ae][Ht]=0;continue}var hn=new Ua(q[Ht]);Vt[Ae][Ht]=St.squareEuclideanDistance(hn),$[Ae].clusterInertial+=Vt[Ae][Ht]}}for(var Ft=0,_n=2*oe*xt,Ae=0;Ae<oe;Ae++)for(var Nn=$[Ae].clusterId,Ht=0;Ht<oe;Ht++){var Pn=$[Ht].clusterId;if(!(Ae===Ht||Nn!==Pn)){var ei=$[Ae].clusterInertial*$[Ht].clusterInertial/Math.pow(_n,2)-Vt[Ae][Ht]/_n;Ft+=ei}}return Number(Ft.toFixed(4))},El=function($,q,oe,xe,Ae,ze,xt,St,Lt){q===void 0&&(q=!1),oe===void 0&&(oe="weight"),xe===void 0&&(xe=1e-4),Ae===void 0&&(Ae=!1),ze===void 0&&(ze=void 0),xt===void 0&&(xt=[]),St===void 0&&(St=["id"]),Lt===void 0&&(Lt=1);var Vt=$.nodes,Ht=Vt===void 0?[]:Vt,hn=$.edges,Ft=hn===void 0?[]:hn,_n=[];if(Ae){Ht.forEach(function(Mi,Xi){Mi.properties=Mi.properties||{},Mi.originIndex=Xi});var Nn=[];Ht.every(function(Mi){return Mi.hasOwnProperty("nodeType")})&&(Nn=Array.from(new Set(Ht.map(function(Mi){return Mi.nodeType}))),Ht.forEach(function(Mi){Mi.properties.nodeType=Nn.findIndex(function(Xi){return Xi===Mi.nodeType})}));var Pn=_r(Ht,ze);_n=zu(Pn,xt,St)}var ei=1,ai={},On={};Ht.forEach(function(Mi,Xi){var Ur=String(ei++);Mi.clusterId=Ur,ai[Ur]={id:Ur,nodes:[Mi]},On[Mi.id]={node:Mi,idx:Xi}});var di=k($,q),Ri=[],ji={},Qi=0;di.forEach(function(Mi,Xi){var Ur=0,zr=Ht[Xi].id;ji[zr]={},Mi.forEach(function(Or,Qr){if(Or){Ur+=Or;var Ds=Ht[Qr].id;ji[zr][Ds]=Or,Qi+=Or}}),Ri.push(Ur)}),Qi/=2;for(var er=1/0,gr=1/0,yr=0,Pr=[],Ji={};;){Ae&&Ht.every(function(Mi){return Mi.hasOwnProperty("properties")})?er=au(Ht,di,Ri,Qi)+Vu(Ht,_n)*Lt:er=au(Ht,di,Ri,Qi),yr===0&&(gr=er,Pr=Ht,Ji=ai);var us=er>0&&er>gr&&er-gr<xe;if(er>gr&&(Pr=Ht.map(function(Mi){return{node:Mi,clusterId:Mi.clusterId}}),Ji=Qd(ai),gr=er),us||yr>100)break;yr++,Object.keys(ai).forEach(function(Mi){var Xi=0;Ft.forEach(function(Ur){var zr=Ur.source,Or=Ur.target,Qr=On[zr].node.clusterId,Ds=On[Or].node.clusterId;(Qr===Mi&&Ds!==Mi||Ds===Mi&&Qr!==Mi)&&(Xi=Xi+(Ur[oe]||1))}),ai[Mi].sumTot=Xi}),Ht.forEach(function(Mi,Xi){var Ur=ai[Mi.clusterId],zr=0,Or,Qr=Ri[Xi]/(2*Qi),Ds=0,Do=Ur.nodes;Do.forEach(function($o){var Sa=On[$o.id].idx;Ds+=di[Xi][Sa]||0});var Qa=Ds-Ur.sumTot*Qr,ao=Do.filter(function($o){return $o.id!==Mi.id}),cl=[];ao.forEach(function($o,Sa){cl[Sa]=_n[$o.originIndex]});var _s=Vu(ao,_n)*Lt,pa=ji[Mi.id];if(Object.keys(pa).forEach(function($o){var Sa=On[$o].node,ia=Sa.clusterId;if(ia!==Mi.clusterId){var ul=ai[ia],ra=ul.nodes;if(!(!ra||!ra.length)){var rs=0;ra.forEach(function(Hr){var xs=On[Hr.id].idx;rs+=di[Xi][xs]||0});var Us=rs-ul.sumTot*Qr,jn=ra.concat([Mi]),br=[];jn.forEach(function(Hr,xs){br[xs]=_n[Hr.originIndex]});var Oo=Vu(jn,_n)*Lt,Ei=Us-Qa;Ae&&(Ei=Us+Oo-(Qa+_s)),Ei>zr&&(zr=Ei,Or=ul)}}}),zr>0){Or.nodes.push(Mi);var Zs=Mi.clusterId;Mi.clusterId=Or.id;var Bc=Ur.nodes.indexOf(Mi);Ur.nodes.splice(Bc,1);var Ro=0,zl=0;Ft.forEach(function($o){var Sa=$o.source,ia=$o.target,ul=On[Sa].node.clusterId,ra=On[ia].node.clusterId;(ul===Or.id&&ra!==Or.id||ra===Or.id&&ul!==Or.id)&&(Ro=Ro+($o[oe]||1)),(ul===Zs&&ra!==Zs||ra===Zs&&ul!==Zs)&&(zl=zl+($o[oe]||1))}),Or.sumTot=Ro,Ur.sumTot=zl}})}var fs={},As=0;Object.keys(Ji).forEach(function(Mi){var Xi=Ji[Mi];if(!Xi.nodes||!Xi.nodes.length){delete Ji[Mi];return}var Ur=String(As+1);Ur!==Mi&&(Xi.id=Ur,Xi.nodes=Xi.nodes.map(function(zr){return{id:zr.id,clusterId:Ur}}),Ji[Ur]=Xi,fs[Mi]=Ur,delete Ji[Mi],As++)}),Pr.forEach(function(Mi){var Xi=Mi.node,Ur=Mi.clusterId;Xi&&(Xi.clusterId=Ur,Xi.clusterId&&fs[Xi.clusterId]&&(Xi.clusterId=fs[Xi.clusterId]))});var Ws=[],Cs={};Ft.forEach(function(Mi){var Xi=Mi.source,Ur=Mi.target,zr=Mi[oe]||1,Or=On[Xi].node.clusterId,Qr=On[Ur].node.clusterId;if(!(!Or||!Qr)){var Ds="".concat(Or,"---").concat(Qr);if(Cs[Ds])Cs[Ds].weight+=zr,Cs[Ds].count++;else{var Do={source:Or,target:Qr,weight:zr,count:1};Cs[Ds]=Do,Ws.push(Do)}}});var hs=[];return Object.keys(Ji).forEach(function(Mi){hs.push(Ji[Mi])}),{clusters:hs,clusterEdges:Ws}},Br=El,lp=function($,q,oe,xe,Ae,ze,xt,St){return q===void 0&&(q=!1),oe===void 0&&(oe="weight"),xe===void 0&&(xe=1e-4),Ae===void 0&&(Ae=void 0),ze===void 0&&(ze=[]),xt===void 0&&(xt=["id"]),St===void 0&&(St=1),Br($,q,oe,xe,!0,Ae,ze,xt,St)},I0=lp,L0=function($,q){var oe;q===void 0&&(q=1);for(var xe=Qd($),Ae=xe.nodes,ze=Ae===void 0?[]:Ae,xt=xe.edges,St=xt===void 0?[]:xt,Lt=function(){var hn=Ne({nodes:ze,edges:St}),Ft=Object.keys(hn);Ft.sort(function(Pn,ei){var ai,On;return((ai=hn[Pn])===null||ai===void 0?void 0:ai.degree)-((On=hn[ei])===null||On===void 0?void 0:On.degree)});var _n=Ft[0];if(!ze.length||((oe=hn[_n])===null||oe===void 0?void 0:oe.degree)>=q)return"break";var Nn=ze.findIndex(function(Pn){return Pn.id===_n});ze.splice(Nn,1),St=St.filter(function(Pn){return!(Pn.source===_n||Pn.target===_n)})};;){var Vt=Lt();if(Vt==="break")break}return{nodes:ze,edges:St}},Qh=L0,Za=function($,q,oe){var xe=[];switch($){case Ul.EuclideanDistance:xe=q[oe];break;default:xe=[];break}return xe},cs=function($,q,oe,xe,Ae,ze){q===void 0&&(q=3),oe===void 0&&(oe=void 0),xe===void 0&&(xe=[]),Ae===void 0&&(Ae=["id"]),ze===void 0&&(ze=Ul.EuclideanDistance);var xt=$.nodes,St=xt===void 0?[]:xt,Lt=$.edges,Vt=Lt===void 0?[]:Lt,Ht={clusters:[{id:"0",nodes:St}],clusterEdges:[]};if(ze===Ul.EuclideanDistance&&!St.every(function(Ur){return Ur.hasOwnProperty(oe)}))return Ht;var hn=[],Ft=[];if(ze===Ul.EuclideanDistance&&(hn=_r(St,oe),Ft=zu(hn,xe,Ae)),!Ft.length)return Ht;for(var _n=et(Ft.map(function(Ur){return Ur.join("")})),Nn=Math.min(q,St.length,_n.length),Pn=0;Pn<St.length;Pn++)St[Pn].originIndex=Pn;for(var ei=[],ai=[],On=[],Pn=0;Pn<Nn;Pn++)if(Pn===0){var di=Math.floor(Math.random()*St.length);switch(ze){case Ul.EuclideanDistance:ei[Pn]=Ft[di];break;default:ei[Pn]=[];break}ai.push(di),On[Pn]=[St[di]],St[di].clusterId=String(Pn)}else{for(var Ri=-1/0,ji=0,Qi=function(Or){if(!ai.includes(Or)){for(var Qr=0,Ds=0;Ds<ei.length;Ds++){var Do=0;switch(ze){case Ul.EuclideanDistance:Do=wa(Ft[St[Or].originIndex],ei[Ds],ze);break;default:break}Qr+=Do}var Qa=Qr/ei.length;Qa>Ri&&!ei.find(function(ao){return op(ao,Za(ze,Ft,St[Or].originIndex))})&&(Ri=Qa,ji=Or)}},er=0;er<St.length;er++)Qi(er);ei[Pn]=Za(ze,Ft,ji),ai.push(ji),On[Pn]=[St[ji]],St[ji].clusterId=String(Pn)}for(var gr=0;;){for(var Pn=0;Pn<St.length;Pn++){var yr=0,Pr=1/0;if(!(gr===0&&ai.includes(Pn))){for(var Ji=0;Ji<ei.length;Ji++){var us=0;switch(ze){case Ul.EuclideanDistance:us=wa(Ft[Pn],ei[Ji],ze);break;default:break}us<Pr&&(Pr=us,yr=Ji)}if(St[Pn].clusterId!==void 0)for(var fs=On[Number(St[Pn].clusterId)].length-1;fs>=0;fs--)On[Number(St[Pn].clusterId)][fs].id===St[Pn].id&&On[Number(St[Pn].clusterId)].splice(fs,1);St[Pn].clusterId=String(yr),On[yr].push(St[Pn])}}for(var As=!1,Pn=0;Pn<On.length;Pn++){for(var Ws=On[Pn],Cs=new Ua([]),Ji=0;Ji<Ws.length;Ji++)Cs=Cs.add(new Ua(Ft[Ws[Ji].originIndex]));var hs=Cs.avg(Ws.length);hs.equal(new Ua(ei[Pn]))||(As=!0,ei[Pn]=hs.getArr())}if(gr++,St.every(function(Ur){return Ur.clusterId!==void 0})&&As||gr>=1e3)break}var Mi=[],Xi={};return Vt.forEach(function(Ur){var zr,Or,Qr=Ur.source,Ds=Ur.target,Do=(zr=St.find(function(_s){return _s.id===Qr}))===null||zr===void 0?void 0:zr.clusterId,Qa=(Or=St.find(function(_s){return _s.id===Ds}))===null||Or===void 0?void 0:Or.clusterId,ao="".concat(Do,"---").concat(Qa);if(Xi[ao])Xi[ao].count++;else{var cl={source:Do,target:Qa,count:1};Xi[ao]=cl,Mi.push(cl)}}),{clusters:On,clusterEdges:Mi}},ed=cs,yn=function($,q){var oe=new Ua(q),xe=oe.norm2(),Ae=new Ua($),ze=Ae.norm2(),xt=oe.dot(Ae),St=xe*ze,Lt=St?xt/St:0;return Lt},ta=yn,it=function($,q,oe,xe,Ae){$===void 0&&($=[]),oe===void 0&&(oe=void 0),xe===void 0&&(xe=[]),Ae===void 0&&(Ae=[]);var ze=Qd($.filter(function(hn){return hn.id!==q.id})),xt=$.findIndex(function(hn){return hn.id===q.id}),St=_r($,oe),Lt=zu(St,xe,Ae),Vt=Lt[xt],Ht=[];return ze.forEach(function(hn,Ft){if(hn.id!==q.id){var _n=Lt[Ft],Nn=ta(_n,Vt);Ht.push(Nn),hn.cosineSimilarity=Nn}}),ze.sort(function(hn,Ft){return Ft.cosineSimilarity-hn.cosineSimilarity}),{allCosineSimilarity:Ht,similarNodes:ze}},cp=it,Hm=function(){function ne($){this.count=$.length,this.parent={};for(var q=0,oe=$;q<oe.length;q++){var xe=oe[q];this.parent[xe]=xe}}return ne.prototype.find=function($){for(;this.parent[$]!==$;)$=this.parent[$];return $},ne.prototype.union=function($,q){var oe=this.find($),xe=this.find(q);oe!==xe&&(oe<xe?(this.parent[q]!==q&&this.union(this.parent[q],$),this.parent[q]=this.parent[$]):(this.parent[$]!==$&&this.union(this.parent[$],q),this.parent[$]=this.parent[q]))},ne.prototype.connected=function($,q){return this.find($)===this.find(q)},ne}(),jr=Hm,up=function($,q){return $-q},hp=function(){function ne($){$===void 0&&($=up),this.compareFn=$,this.list=[]}return ne.prototype.getLeft=function($){return 2*$+1},ne.prototype.getRight=function($){return 2*$+2},ne.prototype.getParent=function($){return $===0?null:Math.floor(($-1)/2)},ne.prototype.isEmpty=function(){return this.list.length<=0},ne.prototype.top=function(){return this.isEmpty()?void 0:this.list[0]},ne.prototype.delMin=function(){var $=this.top(),q=this.list.pop();return this.list.length>0&&(this.list[0]=q,this.moveDown(0)),$},ne.prototype.insert=function($){if($!==null){this.list.push($);var q=this.list.length-1;return this.moveUp(q),!0}return!1},ne.prototype.moveUp=function($){for(var q=this.getParent($);$&&$>0&&this.compareFn(this.list[q],this.list[$])>0;){var oe=this.list[q];this.list[q]=this.list[$],this.list[$]=oe,$=q,q=this.getParent($)}},ne.prototype.moveDown=function($){var q,oe=$,xe=this.getLeft($),Ae=this.getRight($),ze=this.list.length;xe!==null&&xe<ze&&this.compareFn(this.list[oe],this.list[xe])>0?oe=xe:Ae!==null&&Ae<ze&&this.compareFn(this.list[oe],this.list[Ae])>0&&(oe=Ae),$!==oe&&(q=[this.list[oe],this.list[$]],this.list[$]=q[0],this.list[oe]=q[1],this.moveDown(oe))},ne}(),D0=hp,ph=function($,q){var oe=[],xe=$.nodes,Ae=xe===void 0?[]:xe,ze=$.edges,xt=ze===void 0?[]:ze;if(Ae.length===0)return oe;var St=Ae[0],Lt=new Set;Lt.add(St);var Vt=function(Pn,ei){return q?Pn.weight-ei.weight:0},Ht=new D0(Vt);for(P(St.id,xt).forEach(function(Nn){Ht.insert(Nn)});!Ht.isEmpty();){var hn=Ht.delMin(),Ft=hn.source,_n=hn.target;Lt.has(Ft)&&Lt.has(_n)||(oe.push(hn),Lt.has(Ft)||(Lt.add(Ft),P(Ft,xt).forEach(function(Nn){Ht.insert(Nn)})),Lt.has(_n)||(Lt.add(_n),P(_n,xt).forEach(function(Nn){Ht.insert(Nn)})))}return oe},mh=function($,q){var oe=[],xe=$.nodes,Ae=xe===void 0?[]:xe,ze=$.edges,xt=ze===void 0?[]:ze;if(Ae.length===0)return oe;var St=xt.map(function(Ft){return Ft});q&&St.sort(function(Ft,_n){return Ft.weight-_n.weight});for(var Lt=new jr(Ae.map(function(Ft){return Ft.id}));St.length>0;){var Vt=St.shift(),Ht=Vt.source,hn=Vt.target;Lt.connected(Ht,hn)||(oe.push(Vt),Lt.union(Ht,hn))}return oe},Ka=function($,q,oe){var xe={prim:ph,kruskal:mh};return oe?xe[oe]($,q):mh($,q)},is=Ka,ll=function($,q,oe){typeof q!="number"&&(q=1e-6),typeof oe!="number"&&(oe=.85);for(var xe=1,Ae=0,ze=1e3,xt=$.nodes,St=xt===void 0?[]:xt,Lt=$.edges,Vt=Lt===void 0?[]:Lt,Ht=St.length,hn,Ft={},_n={},Nn=0;Nn<Ht;++Nn){var Pn=St[Nn],ei=Pn.id;Ft[ei]=1/Ht,_n[ei]=1/Ht}for(var ai=Ne($);ze>0&&xe>q;){Ae=0;for(var Nn=0;Nn<Ht;++Nn){var Pn=St[Nn],ei=Pn.id;if(hn=0,ai[Pn.id].inDegree===0)Ft[ei]=0;else{for(var On=N(ei,Vt,"source"),di=0;di<On.length;++di){var Ri=On[di],ji=ai[Ri].outDegree;ji>0&&(hn+=_n[Ri]/ji)}Ft[ei]=oe*hn,Ae+=Ft[ei]}}Ae=(1-Ae)/Ht,xe=0;for(var Nn=0;Nn<Ht;++Nn){var Pn=St[Nn],ei=Pn.id;hn=Ft[ei]+Ae,xe+=Math.abs(hn-_n[ei]),_n[ei]=hn}ze-=1}return _n},oi=ll,_l=-1,Rt=-1,rf="-1",Ki="-1",da=-1,Gu="-1",lu=function(){function ne($,q,oe,xe){$===void 0&&($=_l),q===void 0&&(q=Rt),oe===void 0&&(oe=Rt),xe===void 0&&(xe=rf),this.id=$,this.from=q,this.to=oe,this.label=xe}return ne}(),$m=function(){function ne($,q){$===void 0&&($=Rt),q===void 0&&(q=Ki),this.id=$,this.label=q,this.edges=[],this.edgeMap={}}return ne.prototype.addEdge=function($){this.edges.push($),this.edgeMap[$.id]=$},ne}(),jm=function(){function ne($,q,oe){$===void 0&&($=Rt),q===void 0&&(q=!0),oe===void 0&&(oe=!1),this.id=$,this.edgeIdAutoIncrease=q,this.edges=[],this.nodes=[],this.nodeMap={},this.edgeMap={},this.nodeLabelMap={},this.edgeLabelMap={},this.counter=0,this.directed=oe}return ne.prototype.getNodeNum=function(){return this.nodes.length},ne.prototype.addNode=function($,q){if(!this.nodeMap[$]){var oe=new $m($,q);this.nodes.push(oe),this.nodeMap[$]=oe,this.nodeLabelMap[q]||(this.nodeLabelMap[q]=[]),this.nodeLabelMap[q].push($)}},ne.prototype.addEdge=function($,q,oe,xe){if((this.edgeIdAutoIncrease||$===void 0)&&($=this.counter++),!(this.nodeMap[q]&&this.nodeMap[oe]&&this.nodeMap[oe].edgeMap[$])){var Ae=new lu($,q,oe,xe);if(this.edges.push(Ae),this.edgeMap[$]=Ae,this.nodeMap[q].addEdge(Ae),this.edgeLabelMap[xe]||(this.edgeLabelMap[xe]=[]),this.edgeLabelMap[xe].push(Ae),!this.directed){var ze=new lu($,oe,q,xe);this.nodeMap[oe].addEdge(ze),this.edgeLabelMap[xe].push(ze)}}},ne}(),Mo=function(){function ne($,q,oe,xe,Ae){this.fromNode=$,this.toNode=q,this.nodeEdgeNodeLabel={nodeLabel1:oe||Ki,edgeLabel:xe||rf,nodeLabel2:Ae||Ki}}return ne.prototype.equalTo=function($){return this.fromNode===$.formNode&&this.toNode===$.toNode&&this.nodeEdgeNodeLabel===$.nodeEdgeNodeLabel},ne.prototype.notEqualTo=function($){return!this.equalTo($)},ne}(),kl=function(){function ne(){this.rmpath=[],this.dfsEdgeList=[]}return ne.prototype.equalTo=function($){var q=this.dfsEdgeList.length,oe=$.length;if(q!==oe)return!1;for(var xe=0;xe<q;xe++)if(this.dfsEdgeList[xe]!==$[xe])return!1;return!0},ne.prototype.notEqualTo=function($){return!this.equalTo($)},ne.prototype.pushBack=function($,q,oe,xe,Ae){return this.dfsEdgeList.push(new Mo($,q,oe,xe,Ae)),this.dfsEdgeList},ne.prototype.toGraph=function($,q){$===void 0&&($=da),q===void 0&&(q=!1);var oe=new jm($,!0,q);return this.dfsEdgeList.forEach(function(xe){var Ae=xe.fromNode,ze=xe.toNode,xt=xe.nodeEdgeNodeLabel,St=xt.nodeLabel1,Lt=xt.edgeLabel,Vt=xt.nodeLabel2;St!==Ki&&oe.addNode(Ae,St),Vt!==Ki&&oe.addNode(ze,Vt),St!==Ki&&Vt!==St&&oe.addEdge(void 0,Ae,ze,Lt)}),oe},ne.prototype.buildRmpath=function(){this.rmpath=[];for(var $=void 0,q=this.dfsEdgeList.length,oe=q-1;oe>=0;oe--){var xe=this.dfsEdgeList[oe],Ae=xe.fromNode,ze=xe.toNode;Ae<ze&&($===void 0||ze===$)&&(this.rmpath.push(oe),$=Ae)}return this.rmpath},ne.prototype.getNodeNum=function(){var $={};return this.dfsEdgeList.forEach(function(q){$[q.fromNode]||($[q.fromNode]=!0),$[q.toNode]||($[q.toNode]=!0)}),Object.keys($).length},ne}(),Dc=function(){function ne($){if(this.his={},this.nodesUsed={},this.edgesUsed={},this.edges=[],!!$){for(;$;){var q=$.edge;this.edges.push(q),this.nodesUsed[q.from]=1,this.nodesUsed[q.to]=1,this.edgesUsed[q.id]=1,$=$.preNode}this.edges=this.edges.reverse()}}return ne.prototype.hasNode=function($){return this.nodesUsed[$.id]===1},ne.prototype.hasEdge=function($){return this.edgesUsed[$.id]===1},ne}(),cu=function(){function ne($){var q=$.graphs,oe=$.minSupport,xe=oe===void 0?2:oe,Ae=$.minNodeNum,ze=Ae===void 0?1:Ae,xt=$.maxNodeNum,St=xt===void 0?4:xt,Lt=$.top,Vt=Lt===void 0?10:Lt,Ht=$.directed,hn=Ht===void 0?!1:Ht,Ft=$.verbose,_n=Ft===void 0?!1:Ft;this.graphs=q,this.dfsCode=new kl,this.support=0,this.frequentSize1Subgraphs=[],this.frequentSubgraphs=[],this.minSupport=xe,this.top=Vt,this.directed=hn,this.counter=0,this.maxNodeNum=St,this.minNodeNum=ze,this.verbose=_n,this.maxNodeNum<this.minNodeNum&&(this.maxNodeNum=this.minNodeNum),this.reportDF=[]}return ne.prototype.findForwardRootEdges=function($,q){var oe=this,xe=[],Ae=$.nodeMap;return q.edges.forEach(function(ze){(oe.directed||q.label<=Ae[ze.to].label)&&xe.push(ze)}),xe},ne.prototype.findBackwardEdge=function($,q,oe,xe){if(!this.directed&&q===oe)return null;for(var Ae=$.nodeMap,ze=Ae[oe.to],xt=ze.edges,St=xt.length,Lt=0;Lt<St;Lt++){var Vt=xt[Lt];if(!(xe.hasEdge(Vt)||Vt.to!==q.from)){if(this.directed){if(Ae[q.from].label<Ae[oe.to].label||Ae[q.from].label===Ae[oe.to].label&&q.label<=Vt.label)return Vt}else if(q.label<Vt.label||q.label===Vt.label&&Ae[q.to].label<=Ae[oe.to].label)return Vt}}return null},ne.prototype.findForwardPureEdges=function($,q,oe,xe){for(var Ae=[],ze=q.to,xt=$.nodeMap[ze].edges,St=xt.length,Lt=0;Lt<St;Lt++){var Vt=xt[Lt],Ht=$.nodeMap[Vt.to];oe<=Ht.label&&!xe.hasNode(Ht)&&Ae.push(Vt)}return Ae},ne.prototype.findForwardRmpathEdges=function($,q,oe,xe){for(var Ae=[],ze=$.nodeMap,xt=ze[q.to].label,St=ze[q.from],Lt=St.edges,Vt=Lt.length,Ht=0;Ht<Vt;Ht++){var hn=Lt[Ht],Ft=ze[hn.to].label;q.to===hn.to||oe>Ft||xe.hasNode(ze[hn.to])||(q.label<hn.label||q.label===hn.label&&xt<=Ft)&&Ae.push(hn)}return Ae},ne.prototype.getSupport=function($){var q={};return $.forEach(function(oe){q[oe.graphId]||(q[oe.graphId]=!0)}),Object.keys(q).length},ne.prototype.findMinLabel=function($){var q=void 0;return Object.keys($).forEach(function(oe){var xe=$[oe],Ae=xe.nodeLabel1,ze=xe.edgeLabel,xt=xe.nodeLabel2;if(!q){q={nodeLabel1:Ae,edgeLabel:ze,nodeLabel2:xt};return}(Ae<q.nodeLabel1||Ae===q.nodeLabel1&&ze<q.edgeLabel||Ae===q.nodeLabel1&&ze===q.edgeLabel&&xt<q.nodeLabel2)&&(q={nodeLabel1:Ae,edgeLabel:ze,nodeLabel2:xt})}),q},ne.prototype.isMin=function(){var $=this,q=this.dfsCode;if(this.verbose&&console.log("isMin checking",q),q.dfsEdgeList.length===1)return!0;var oe=this.directed,xe=q.toGraph(da,oe),Ae=xe.nodeMap,ze=new kl,xt={};xe.nodes.forEach(function(Ht){var hn=$.findForwardRootEdges(xe,Ht);hn.forEach(function(Ft){var _n=Ae[Ft.to],Nn="".concat(Ht.label,"-").concat(Ft.label,"-").concat(_n.label);xt[Nn]||(xt[Nn]={projected:[],nodeLabel1:Ht.label,edgeLabel:Ft.label,nodeLabel2:_n.label});var Pn={graphId:xe.id,edge:Ft,preNode:null};xt[Nn].projected.push(Pn)})});var St=this.findMinLabel(xt);if(St){ze.dfsEdgeList.push(new Mo(0,1,St.nodeLabel1,St.edgeLabel,St.nodeLabel2));var Lt=function Ht(hn){for(var Ft=ze.buildRmpath(),_n=ze.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,Nn=ze.dfsEdgeList[Ft[0]].toNode,Pn={},ei=!1,ai=0,On=oe?-1:0,di=function(Cs){if(ei)return"break";hn.forEach(function(hs){var Mi=new Dc(hs),Xi=$.findBackwardEdge(xe,Mi.edges[Ft[Cs]],Mi.edges[Ft[0]],Mi);Xi&&(Pn[Xi.label]||(Pn[Xi.label]={projected:[],edgeLabel:Xi.label}),Pn[Xi.label].projected.push({graphId:xe.id,edge:Pn,preNode:hs}),ai=ze.dfsEdgeList[Ft[Cs]].fromNode,ei=!0)})},Ri=Ft.length-1;Ri>On;Ri--){var ji=di(Ri);if(ji==="break")break}if(ei){var Qi=$.findMinLabel(Pn);ze.dfsEdgeList.push(new Mo(Nn,ai,Ki,Qi.edgeLabel,Ki));var er=ze.dfsEdgeList.length-1;return $.dfsCode.dfsEdgeList[er]!==ze.dfsEdgeList[er]?!1:Ht(Pn[Qi.edgeLabel].projected)}var gr={};ei=!1;var yr=0;hn.forEach(function(Ws){var Cs=new Dc(Ws),hs=$.findForwardPureEdges(xe,Cs.edges[Ft[0]],_n,Cs);hs.length>0&&(ei=!0,yr=Nn,hs.forEach(function(Mi){var Xi="".concat(Mi.label,"-").concat(Ae[Mi.to].label);gr[Xi]||(gr[Xi]={projected:[],edgeLabel:Mi.label,nodeLabel2:Ae[Mi.to].label}),gr[Xi].projected.push({graphId:xe.id,edge:Mi,preNode:Ws})}))});for(var Pr=Ft.length,Ji=function(Cs){if(ei)return"break";var hs=Ft[Cs];hn.forEach(function(Mi){var Xi=new Dc(Mi),Ur=$.findForwardRmpathEdges(xe,Xi.edges[hs],_n,Xi);Ur.length>0&&(ei=!0,yr=ze.dfsEdgeList[hs].fromNode,Ur.forEach(function(zr){var Or="".concat(zr.label,"-").concat(Ae[zr.to].label);gr[Or]||(gr[Or]={projected:[],edgeLabel:zr.label,nodeLabel2:Ae[zr.to].label}),gr[Or].projected.push({graphId:xe.id,edge:zr,preNode:Mi})}))})},Ri=0;Ri<Pr;Ri++){var us=Ji(Ri);if(us==="break")break}if(!ei)return!0;var fs=$.findMinLabel(gr);ze.dfsEdgeList.push(new Mo(yr,Nn+1,Ki,fs.edgeLabel,fs.nodeLabel2));var As=ze.dfsEdgeList.length-1;return q.dfsEdgeList[As]!==ze.dfsEdgeList[As]?!1:Ht(gr["".concat(fs.edgeLabel,"-").concat(fs.nodeLabel2)].projected)},Vt="".concat(St.nodeLabel1,"-").concat(St.edgeLabel,"-").concat(St.nodeLabel2);return Lt(xt[Vt].projected)}},ne.prototype.report=function(){if(!(this.dfsCode.getNodeNum()<this.minNodeNum)){this.counter++;var $=this.dfsCode.toGraph(this.counter,this.directed);this.frequentSubgraphs.push(Qd($))}},ne.prototype.subGraphMining=function($){var q=this,oe=this.getSupport($);if(!(oe<this.minSupport)&&this.isMin()){this.report();var xe=this.dfsCode.getNodeNum(),Ae=this.dfsCode.buildRmpath(),ze=this.dfsCode.dfsEdgeList[Ae[0]].toNode,xt=this.dfsCode.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,St={},Lt={};$.forEach(function(Vt){for(var Ht=q.graphs[Vt.graphId],hn=Ht.nodeMap,Ft=new Dc(Vt),_n=Ae.length-1;_n>=0;_n--){var Nn=q.findBackwardEdge(Ht,Ft.edges[Ae[_n]],Ft.edges[Ae[0]],Ft);if(Nn){var Pn="".concat(q.dfsCode.dfsEdgeList[Ae[_n]].fromNode,"-").concat(Nn.label);Lt[Pn]||(Lt[Pn]={projected:[],toNodeId:q.dfsCode.dfsEdgeList[Ae[_n]].fromNode,edgeLabel:Nn.label}),Lt[Pn].projected.push({graphId:Vt.graphId,edge:Nn,preNode:Vt})}}if(!(xe>=q.maxNodeNum)){var ei=q.findForwardPureEdges(Ht,Ft.edges[Ae[0]],xt,Ft);ei.forEach(function(On){var di="".concat(ze,"-").concat(On.label,"-").concat(hn[On.to].label);St[di]||(St[di]={projected:[],fromNodeId:ze,edgeLabel:On.label,nodeLabel2:hn[On.to].label}),St[di].projected.push({graphId:Vt.graphId,edge:On,preNode:Vt})});for(var ai=function(di){var Ri=q.findForwardRmpathEdges(Ht,Ft.edges[Ae[di]],xt,Ft);Ri.forEach(function(ji){var Qi="".concat(q.dfsCode.dfsEdgeList[Ae[di]].fromNode,"-").concat(ji.label,"-").concat(hn[ji.to].label);St[Qi]||(St[Qi]={projected:[],fromNodeId:q.dfsCode.dfsEdgeList[Ae[di]].fromNode,edgeLabel:ji.label,nodeLabel2:hn[ji.to].label}),St[Qi].projected.push({graphId:Vt.graphId,edge:ji,preNode:Vt})})},_n=0;_n<Ae.length;_n++)ai(_n)}}),Object.keys(Lt).forEach(function(Vt){var Ht=Lt[Vt],hn=Ht.toNodeId,Ft=Ht.edgeLabel;q.dfsCode.dfsEdgeList.push(new Mo(ze,hn,"-1",Ft,"-1")),q.subGraphMining(Lt[Vt].projected),q.dfsCode.dfsEdgeList.pop()}),Object.keys(St).forEach(function(Vt){var Ht=St[Vt],hn=Ht.fromNodeId,Ft=Ht.edgeLabel,_n=Ht.nodeLabel2;q.dfsCode.dfsEdgeList.push(new Mo(hn,ze+1,Ki,Ft,_n)),q.subGraphMining(St[Vt].projected),q.dfsCode.dfsEdgeList.pop()})}},ne.prototype.generate1EdgeFrequentSubGraphs=function(){var $=this.graphs,q=this.directed,oe=this.minSupport,xe=this.frequentSize1Subgraphs,Ae={},ze={},xt={},St={};return Object.keys($).forEach(function(Lt){var Vt=$[Lt],Ht=Vt.nodeMap;Vt.nodes.forEach(function(hn,Ft){var _n=hn.label,Nn="".concat(Lt,"-").concat(_n);if(!xt[Nn]){var Pn=Ae[_n]||0;Pn++,Ae[_n]=Pn}xt[Nn]={graphKey:Lt,label:_n},hn.edges.forEach(function(ei){var ai=_n,On=Ht[ei.to].label;if(!q&&ai>On){var di=On;On=ai,ai=di}var Ri=ei.label,ji="".concat(Lt,"-").concat(ai,"-").concat(Ri,"-").concat(On),Qi="".concat(ai,"-").concat(Ri,"-").concat(On);if(!ze[Qi]){var er=ze[Qi]||0;er++,ze[Qi]=er}St[ji]={graphId:Lt,nodeLabel1:ai,edgeLabel:Ri,nodeLabel2:On}})})}),Object.keys(Ae).forEach(function(Lt){var Vt=Ae[Lt];if(!(Vt<oe)){var Ht={nodes:[],edges:[]};Ht.nodes.push({id:"0",label:Lt}),xe.push(Ht)}}),xe},ne.prototype.run=function(){var $=this;if(this.frequentSize1Subgraphs=this.generate1EdgeFrequentSubGraphs(),!(this.maxNodeNum<2)){var q=this.graphs,oe=this.directed,xe={};Object.keys(q).forEach(function(Ae){var ze=q[Ae],xt=ze.nodeMap;ze.nodes.forEach(function(St){var Lt=$.findForwardRootEdges(ze,St);Lt.forEach(function(Vt){var Ht=xt[Vt.to],hn="".concat(St.label,"-").concat(Vt.label,"-").concat(Ht.label);xe[hn]||(xe[hn]={projected:[],nodeLabel1:St.label,edgeLabel:Vt.label,nodeLabel2:Ht.label});var Ft={graphId:Ae,edge:Vt,preNode:null};xe[hn].projected.push(Ft)})})}),Object.keys(xe).forEach(function(Ae){var ze=xe[Ae],xt=ze.projected,St=ze.nodeLabel1,Lt=ze.edgeLabel,Vt=ze.nodeLabel2;$.dfsCode.dfsEdgeList.push(new Mo(0,1,St,Lt,Vt)),$.subGraphMining(xt),$.dfsCode.dfsEdgeList.pop()})}},ne}(),Ho=function($,q,oe,xe){var Ae={};return Object.keys($).forEach(function(ze,xt){var St=$[ze],Lt=new jm(xt,!0,q),Vt={};St.nodes.forEach(function(Ht,hn){Lt.addNode(hn,Ht[oe]),Vt[Ht.id]=hn}),St.edges.forEach(function(Ht,hn){var Ft=Vt[Ht.source],_n=Vt[Ht.target];Lt.addEdge(-1,Ft,_n,Ht[xe])}),Lt&&Lt.getNodeNum()&&(Ae[Lt.id]=Lt)}),Ae},mr=function($,q,oe){var xe=[];return $.forEach(function(Ae){var ze={nodes:[],edges:[]};Ae.nodes.forEach(function(xt){var St;ze.nodes.push((St={id:"".concat(xt.id)},St[q]=xt.label,St))}),Ae.edges.forEach(function(xt){var St;ze.edges.push((St={source:"".concat(xt.from),target:"".concat(xt.to)},St[oe]=xt.label,St))}),xe.push(ze)}),xe},Ja="cluster",hc=function($){var q=$.graphs,oe=$.directed,xe=oe===void 0?!1:oe,Ae=$.nodeLabelProp,ze=Ae===void 0?Ja:Ae,xt=$.edgeLabelProp,St=xt===void 0?Ja:xt,Lt=Ho(q,xe,ze,St),Vt=$.minSupport,Ht=$.maxNodeNum,hn=$.minNodeNum,Ft=$.verbose,_n=$.top,Nn={graphs:Lt,minSupport:Vt,maxNodeNum:Ht,minNodeNum:hn,top:_n,verbose:Ft,directed:xe},Pn=new cu(Nn);Pn.run();var ei=mr(Pn.frequentSubgraphs,ze,St);return ei},sf=hc,dp=function($,q,oe,xe){oe===void 0&&(oe="cluster"),xe===void 0&&(xe=2);var Ae=[],ze=$.nodes;return q.forEach(function(xt,St){Ae.push(bl(ze,xt,St,oe,xe))}),Ae},bl=function($,q,oe,xe,Ae){var ze=[oe],xt=[],St={};return q.forEach(function(Lt,Vt){if(Lt<=Ae&&oe!==Vt){ze.push(Vt),xt.push($[Vt]);var Ht=$[Vt][xe];St[Ht]?(St[Ht].count++,St[Ht].dists.push(Lt)):St[Ht]={count:1,dists:[Lt]}}}),Object.keys(St).forEach(function(Lt){St[Lt].dists=St[Lt].dists.sort(function(Vt,Ht){return Vt-Ht})}),{nodeIdx:oe,nodeId:$[oe].id,nodeIdxs:ze,neighbors:xt,neighborNum:ze.length-1,nodeLabelCountMap:St}},ka=function($,q,oe,xe,Ae){var ze=Math.ceil(oe/q),xt={},St=0;return xe.forEach(function(Lt,Vt){for(var Ht=0,hn=0,Ft=Lt.nodeIdxs,_n=Lt.neighborNum-1;Ht<ze;){for(var Nn=Ft[1+Math.floor(Math.random()*_n)],Pn=0;(xt["".concat(Vt,"-").concat(Nn)]||xt["".concat(Nn,"-").concat(Vt)])&&(Nn=Math.floor(Math.random()*q),Pn++,!(Pn>2*q)););if(Pn<2*q&&(xt["".concat(Vt,"-").concat(Nn)]={start:Vt,end:Nn,distance:Ae[Vt][Nn]},Ht++,St++,St>=oe))return xt;if(hn++,hn>2*q)break}if(Ht<ze){var ei=ze-Ht;ze=(ze+ei)/(q-Vt-1)}}),xt},fa=function($,q,oe,xe){var Ae=oe.nodes;return xe||(xe={}),Object.keys($).forEach(function(ze){var xt,St;if(!(xe&&xe[ze])){xe[ze]={nodes:[],edges:[]};var Lt=$[ze],Vt=(xt=q[Lt.start])===null||xt===void 0?void 0:xt.nodeIdxs,Ht=(St=q[Lt.end])===null||St===void 0?void 0:St.nodeIdxs;if(!(!Vt||!Ht)){var hn=new Set(Ht),Ft=Vt.filter(function(ai){return hn.has(ai)});if(!(!Ft||!Ft.length)){for(var _n={},Nn=Ft.length,Pn=0;Pn<Nn;Pn++){var ei=Ae[Ft[Pn]];xe[ze].nodes.push(ei),_n[ei.id]=!0}oe.edges.forEach(function(ai){_n[ai.source]&&_n[ai.target]&&xe[ze].edges.push(ai)})}}}}),xe},Jl=function($,q,oe,xe){var Ae,ze,xt={};$.nodes.forEach(function(Lt){xt[Lt.id]=Lt});var St=0;return!(!((Ae=q==null?void 0:q.edges)===null||Ae===void 0)&&Ae.length)||((ze=q==null?void 0:q.nodes)===null||ze===void 0?void 0:ze.length)<2?0:($.edges.forEach(function(Lt){var Vt=xt[Lt.source][oe],Ht=xt[Lt.target][oe],hn=q==null?void 0:q.nodes[0][oe],Ft=q==null?void 0:q.nodes[1][oe],_n=q==null?void 0:q.edges[0][xe];Lt[xe]===_n&&(Vt===hn&&Ht===Ft||Vt===Ft&&Ht===hn)&&St++}),St)},Ql=function($,q,oe){for(var xe=1/0,Ae=0,ze=function(Lt){var Vt=$[Lt],Ht=Object.keys(Vt).sort(function(ai,On){return Vt[ai]-Vt[On]}),hn=10,Ft=[];Ht.forEach(function(ai,On){Ft[On%hn]||(Ft[On%hn]={graphs:[],totalCount:0,aveCount:0}),Ft[On%hn].graphs.push(ai),Ft[On%hn].totalCount+=Vt[ai]});var _n=0,Nn=[];Ft.forEach(function(ai){var On=ai.totalCount/ai.graphs.length;ai.aveCount=On,Nn.push(On);var di=0,Ri=ai.length;ai.graphs.forEach(function(ji,Qi){var er=Vt[ji];ai.graphs.forEach(function(gr,yr){Qi!==yr&&(di+=Math.abs(er-Vt[gr]))})}),di/=Ri*(Ri-1)/2,_n+=di}),_n/=Ft.length;var Pn=0;Nn.forEach(function(ai,On){Nn.forEach(function(di,Ri){On!==Ri&&(Pn+=Math.abs(ai-di))}),Pn/=Nn.length*(Nn.length-1)/2});var ei=Pn-_n;xe<ei&&(xe=ei,Ae=Lt)},xt=0;xt<q;xt++)ze(xt);return{structure:oe[Ae],structureCountMap:$[Ae]}},of=function($,q){var oe={},xe={};return $.forEach(function(Ae,ze){oe[Ae.id]={idx:ze,node:Ae,degree:0,inDegree:0,outDegree:0};var xt=Ae[q];xe[xt]||(xe[xt]=[]),xe[xt].push(Ae)}),{nodeMap:oe,nodeLabelMap:xe}},uu=function($,q,oe){var xe={},Ae={};return $.forEach(function(ze,xt){xe["".concat(W)]={idx:xt,edge:ze};var St=ze[q];Ae[St]||(Ae[St]=[]),Ae[St].push(ze);var Lt=oe[ze.source];Lt&&(Lt.degree++,Lt.outDegree++);var Vt=oe[ze.target];Vt&&(Vt.degree++,Vt.inDegree++)}),{edgeMap:xe,edgeLabelMap:Ae}},gh=function($,q,oe){var xe=q.length,Ae={};return q.forEach(function(ze,xt){for(var St=oe?0:xt+1,Lt=$[xt].id,Vt=St;Vt<xe;Vt++)if(xt!==Vt){var Ht=$[Vt].id,hn=ze[Vt];Ae["".concat(Lt,"-").concat(Ht)]=hn,oe||(Ae["".concat(Ht,"-").concat(Lt)]=hn)}}),Ae},na=function($,q,oe,xe,Ae,ze,xt,St,Lt,Vt,Ht){var hn,Ft="".concat(q.id,"-").concat(oe.id);if(Vt&&Vt[Ft])return Vt[Ft];var _n=Ht?Ht[Ft]:void 0;if(!_n){var Nn=(hn={},hn[Ft]={start:xe[q.id].idx,end:xe[oe.id].idx,distance:Ae},hn);Ht=fa(Nn,ze,$,Ht),_n=Ht[Ft]}return Jl(_n,xt,St,Lt)},za=function($,q,oe,xe){var Ae,ze,xt,St=(Ae=$[q])===null||Ae===void 0?void 0:Ae.degree,Lt=(ze=$[q])===null||ze===void 0?void 0:ze.inDegree,Vt=(xt=$[q])===null||xt===void 0?void 0:xt.outDegree;return $[q]===void 0&&(St=1/0,Lt=1/0,Vt=1/0,xe[q].forEach(function(Ht){var hn=oe[Ht.id].degree;St>hn&&(St=hn);var Ft=oe[Ht.id].inDegree;Lt>Ft&&(Lt=Ft);var _n=oe[Ht.id].outDegree;Vt>_n&&(Vt=_n)}),$[q]={degree:St,inDegree:Lt,outDegree:Vt}),{minPatternNodeLabelDegree:St,minPatternNodeLabelInDegree:Lt,minPatternNodeLabelOutDegree:Vt}},Ma=function($,q,oe,xe,Ae,ze,xt){var St;if(oe===void 0&&(oe=!1),ze===void 0&&(ze="cluster"),xt===void 0&&(xt="cluster"),!(!$||!$.nodes)){var Lt=$.nodes.length;if(Lt){var Vt=Bl($,oe),Ht=Bl(q,oe),hn=gh($.nodes,Vt,oe),Ft=gh(q.nodes,Ht,oe),_n=of($.nodes,ze),Nn=_n.nodeMap,Pn=_n.nodeLabelMap,ei=of(q.nodes,ze),ai=ei.nodeMap,On=ei.nodeLabelMap;uu($.edges,xt,Nn);var di=uu(q.edges,xt,ai).edgeLabelMap,Ri=[];Ht==null||Ht.forEach(function(rs){Ri=Ri.concat(rs)}),Ae||(Ae=Math.max.apply(Math,je(je([],Ri,!1),[2],!1))),xe||(xe=Ae);var ji=dp($,Vt,ze,xe),Qi=dp(q,Ht,ze,xe),er=Math.min(100,Lt*(Lt-1)/2),gr=ka(xe,Lt,er,ji,Vt),yr=fa(gr,ji,$),Pr=10,Ji=1,us=1,fs=4,As={graphs:yr,nodeLabelProp:ze,edgeLabelProp:xt,minSupport:Ji,minNodeNum:us,maxNodeNum:fs,directed:oe},Ws=sf(As).slice(0,Pr),Cs=Ws.length,hs=[];Ws.forEach(function(rs,Us){hs[Us]={},Object.keys(yr).forEach(function(jn){var br=yr[jn],Oo=Jl(br,rs,ze,xt);hs[Us][jn]=Oo})});var Mi=Ql(hs,Cs,Ws),Xi=Mi.structure,Ur=Mi.structureCountMap,zr=q.nodes[0],Or=[],Qr=(St=q.nodes[0])===null||St===void 0?void 0:St[ze],Ds=-1/0;q.nodes.forEach(function(rs){var Us=rs[ze],jn=Pn[Us];(jn==null?void 0:jn.length)>Ds&&(Ds=jn.length,Or=jn,Qr=Us,zr=rs)});var Do={},Qa={},ao={},cl={},_s={},pa={};Object.keys(On).forEach(function(rs,Us){_s[rs]=[],oe&&(pa[rs]=[]);var jn=-1/0,br=On[rs],Oo={};br.forEach(function(vr){var Rs=Ft["".concat(zr.id,"-").concat(vr.id)];if(Rs&&_s[rs].push(Rs),jn<Rs&&(jn=Rs),Oo["".concat(zr.id,"-").concat(vr.id)]={start:0,end:ai[vr.id].idx,distance:Rs},oe){var No=Ft["".concat(vr.id,"-").concat(zr.id)];No&&pa[rs].push(No)}}),_s[rs]=_s[rs].sort(function(vr,Rs){return vr-Rs}),oe&&(pa[rs]=pa[rs].sort(function(vr,Rs){return vr-Rs})),Qa=fa(Oo,Qi,q,Qa);var Ei=[];if(Object.keys(Oo).forEach(function(vr){if(ao[vr]){Ei.push(ao[vr]);return}var Rs=Qa[vr];ao[vr]=Jl(Rs,Xi,ze,xt),Ei.push(ao[vr])}),Ei=Ei.sort(function(vr,Rs){return Rs-vr}),cl["".concat(zr.id,"-").concat(rs)]=Ei,rs!==Qr)for(var Hr=(Or==null?void 0:Or.length)||0,xs=function(Rs){var No=Or[Rs],Ss=ji[Nn[No.id].idx],Hs=Ss.nodeLabelCountMap[rs],yh=On[rs].length;if(!Hs||Hs.count<yh)return Or.splice(Rs,1),"continue";for(var es=!1,Ta=0;Ta<yh;Ta++)if(Hs.dists[Ta]>_s[rs][Ta]){es=!0;break}if(es)return Or.splice(Rs,1),"continue";var pc={};Ss.neighbors.forEach(function(Va){var vo=hn["".concat(No.id,"-").concat(Va.id)];pc["".concat(No.id,"-").concat(Va.id)]={start:Nn[No.id].idx,end:Nn[Va.id].idx,distance:vo}}),yr=fa(pc,ji,$,yr);var lo=[];Object.keys(pc).forEach(function(Va){if(Ur[Va]){lo.push(Ur[Va]);return}var vo=yr[Va];Ur[Va]=Jl(vo,Xi,ze,xt),lo.push(Ur[Va])}),lo=lo.sort(function(Va,vo){return vo-Va});for(var mc=!1,Ta=0;Ta<yh;Ta++)if(lo[Ta]<Ei[Ta]){mc=!0;break}if(mc)return Or.splice(Rs,1),"continue"},ar=Hr-1;ar>=0;ar--)xs(ar)});var Zs=[];Or==null||Or.forEach(function(rs){for(var Us=Nn[rs.id].idx,jn=bl($.nodes,Vt[Us],Us,ze,Ae),br=jn.neighbors,Oo=br.length,Ei=!1,Hr=Oo-1;Hr>=0;Hr--){if(br.length+1<q.nodes.length){Ei=!0;return}var xs=br[Hr],ar=xs[ze];if(!On[ar]||!On[ar].length){br.splice(Hr,1);continue}if(!_s[ar]||!_s[ar].length){br.splice(Hr,1);continue}var vr="".concat(rs.id,"-").concat(xs.id),Rs=hn[vr],No=_s[ar].length-1,Ss=_s[ar][No];if(Rs>Ss){br.splice(Hr,1);continue}if(oe){var Hs="".concat(xs.id,"-").concat(rs.id),yh=hn[Hs];No=pa[ar].length-1;var es=pa[ar][No];if(yh>es){br.splice(Hr,1);continue}}var Ta=Ur[vr]?Ur[vr]:na($,rs,xs,Nn,Rs,ji,Xi,ze,xt,Ur,yr),pc="".concat(zr.id,"-").concat(ar),lo=cl[pc][cl[pc].length-1];if(Ta<lo){br.splice(Hr,1);continue}var mc=za(Do,ar,ai,On),Va=mc.minPatternNodeLabelDegree,vo=mc.minPatternNodeLabelInDegree,gc=mc.minPatternNodeLabelOutDegree;if(Nn[xs.id].degree<Va){br.splice(Hr,1);continue}}Ei||Zs.push({nodes:[rs].concat(br)})});var Bc=oo(q,zr.id,!1).length,Ro={};oe?(Object.keys(Bc).forEach(function(rs){var Us=ai[rs].node[ze];Ro[Us]?Ro[Us].push(Bc[rs]):Ro[Us]=[Bc[rs]]}),Object.keys(Ro).forEach(function(rs){Ro[rs].sort(function(Us,jn){return Us-jn})})):Ro=_s;for(var zl=Zs.length,$o=function(Us){var jn=Zs[Us],br=jn.nodes[0],Oo={},Ei={};jn.nodes.forEach(function(ps,Aa){Ei[ps.id]={idx:Aa,node:ps,degree:0,inDegree:0,outDegree:0};var bs=ps[ze];Oo[bs]?Oo[bs]++:Oo[bs]=1});var Hr=[],xs={};$.edges.forEach(function(ps){Ei[ps.source]&&Ei[ps.target]&&(Hr.push(ps),xs[ps[xt]]?xs[ps[xt]]++:xs[ps[xt]]=1,Ei[ps.source].degree++,Ei[ps.target].degree++,Ei[ps.source].outDegree++,Ei[ps.target].inDegree++)});for(var ar=Object.keys(di).length,vr=!1,Rs=0;Rs<ar;Rs++){var No=Object.keys(di)[Rs];if(!xs[No]||xs[No]<di[No].length){vr=!0;break}}if(vr)return Zs.splice(Us,1),"continue";var Ss=Hr.length;if(Ss<q.edges.length)return Zs.splice(Us,1),"break";for(var Hs=!1,yh=function(Aa){var bs=Hr[Aa],Fr=bs[xt],ec=di[Fr];if(!ec||!ec.length)return xs[Fr]--,ec&&xs[Fr]<ec.length?(Hs=!0,"break"):(Hr.splice(Aa,1),Ei[bs.source].degree--,Ei[bs.target].degree--,Ei[bs.source].outDegree--,Ei[bs.target].inDegree--,"continue");var yc=Ei[bs.source].node[ze],hu=Ei[bs.target].node[ze],td=!1;if(ec.forEach(function(du){var Ks=ai[du.source].node,nd=ai[du.target].node;Ks[ze]===yc&&nd[ze]===hu&&(td=!0),!oe&&Ks[ze]===hu&&nd[ze]===yc&&(td=!0)}),!td)return xs[Fr]--,ec&&xs[Fr]<ec.length?(Hs=!0,"break"):(Hr.splice(Aa,1),Ei[bs.source].degree--,Ei[bs.target].degree--,Ei[bs.source].outDegree--,Ei[bs.target].inDegree--,"continue")},Rs=Ss-1;Rs>=0;Rs--){var es=yh(Rs);if(es==="break")break}if(Hs)return Zs.splice(Us,1),"continue";jn.edges=Hr;var Ta=oo(jn,jn.nodes[0].id,!1).length;if(Object.keys(Ta).reverse().forEach(function(ps){if(!(ps===jn.nodes[0].id||Hs)){if(Ta[ps]===1/0){var Aa=Ei[ps].node[ze];if(Oo[Aa]--,Oo[Aa]<On[Aa].length){Hs=!0;return}var bs=jn.nodes.indexOf(Ei[ps].node);jn.nodes.splice(bs,1),Ei[ps]=void 0;return}var Fr=Nn[ps].node[ze];if(!Ro[Fr]||!Ro[Fr].length||Ta[ps]>Ro[Fr][Ro[Fr].length-1]){var Aa=Ei[ps].node[ze];if(Oo[Aa]--,Oo[Aa]<On[Aa].length){Hs=!0;return}var bs=jn.nodes.indexOf(Ei[ps].node);jn.nodes.splice(bs,1),Ei[ps]=void 0}}}),Hs)return Zs.splice(Us,1),"continue";for(var pc=!0,lo=0;pc&&!Hs;){pc=!1;var mc=oe?Ei[br.id].degree<ai[zr.id].degree||Ei[br.id].inDegree<ai[zr.id].inDegree||Ei[br.id].outDegree<ai[zr.id].outDegree:Ei[br.id].degree<ai[zr.id].degree;if(mc){Hs=!0;break}if(Oo[br[ze]]<On[br[ze]].length){Hs=!0;break}for(var Va=jn.nodes.length,vo=Va-1;vo>=0;vo--){var gc=jn.nodes[vo],Xm=Ei[gc.id].degree,Zi=Ei[gc.id].inDegree,dx=Ei[gc.id].outDegree,Vl=gc[ze],af=za(Do,Vl,ai,On),Wu=af.minPatternNodeLabelDegree,Gl=af.minPatternNodeLabelInDegree,qi=af.minPatternNodeLabelOutDegree,Ea=oe?Xm<Wu||Zi<Gl||dx<qi:Xm<Wu;if(Ea){if(Oo[gc[ze]]--,Oo[gc[ze]]<On[gc[ze]].length){Hs=!0;break}jn.nodes.splice(vo,1),Ei[gc.id]=void 0,pc=!0}}if(Hs||!pc&&lo!==0)break;Ss=Hr.length;for(var xr=Ss-1;xr>=0;xr--){var Wl=Hr[xr];if(!Ei[Wl.source]||!Ei[Wl.target]){Hr.splice(xr,1);var hl=Wl[xt];if(xs[hl]--,Ei[Wl.source]&&(Ei[Wl.source].degree--,Ei[Wl.source].outDegree--),Ei[Wl.target]&&(Ei[Wl.target].degree--,Ei[Wl.target].inDegree--),di[hl]&&xs[hl]<di[hl].length){Hs=!0;break}pc=!0}}lo++}if(Hs||Hs||jn.nodes.length<q.nodes.length||Hr.length<q.edges.length)return Zs.splice(Us,1),"continue"},Sa=zl-1;Sa>=0;Sa--){var ia=$o(Sa);if(ia==="break")break}for(var ul=Zs.length,ra=function(Us){var jn=Zs[Us],br={};jn.edges.forEach(function(Hr){var xs="".concat(Hr.source,"-").concat(Hr.target,"-").concat(Hr.label);br[xs]?br[xs]++:br[xs]=1});for(var Oo=function(xs){var ar=Zs[xs],vr={};ar.edges.forEach(function(No){var Ss="".concat(No.source,"-").concat(No.target,"-").concat(No.label);vr[Ss]?vr[Ss]++:vr[Ss]=1});var Rs=!0;Object.keys(vr).length!==Object.keys(br).length?Rs=!1:Object.keys(br).forEach(function(No){vr[No]!==br[No]&&(Rs=!1)}),Rs&&Zs.splice(xs,1)},Ei=ul-1;Ei>Us;Ei--)Oo(Ei);ul=Zs.length},Sa=0;Sa<=ul-1;Sa++)ra(Sa);return Zs}}},dc=Ma,fc=function(){function ne($){$===void 0&&($=10),this.linkedList=new C,this.maxStep=$}return Object.defineProperty(ne.prototype,"length",{get:function(){return this.linkedList.toArray().length},enumerable:!1,configurable:!0}),ne.prototype.isEmpty=function(){return!this.linkedList.head},ne.prototype.isMaxStack=function(){return this.toArray().length>=this.maxStep},ne.prototype.peek=function(){return this.isEmpty()?null:this.linkedList.head.value},ne.prototype.push=function($){this.linkedList.prepend($),this.length>this.maxStep&&this.linkedList.deleteTail()},ne.prototype.pop=function(){var $=this.linkedList.deleteHead();return $?$.value:null},ne.prototype.toArray=function(){return this.linkedList.toArray().map(function($){return $.value})},ne.prototype.clear=function(){for(;!this.isEmpty();)this.pop()},ne}(),Oc=fc,Fc=Yt,Al={getAdjMatrix:k,breadthFirstSearch:pe,connectedComponent:ye,getDegree:Ne,getInDegree:Te,getOutDegree:_e,detectCycle:Yt,detectDirectedCycle:Fc,detectAllCycles:zt,detectAllDirectedCycle:It,detectAllUndirectedCycle:vt,depthFirstSearch:Ge,dijkstra:oo,findAllPath:m1,findShortestPath:fh,floydWarshall:Bl,labelPropagation:ku,louvain:Br,iLouvain:I0,kCore:Qh,kMeans:ed,cosineSimilarity:ta,nodesCosineSimilarity:cp,minimumSpanningTree:is,pageRank:oi,getNeighbors:N,Stack:Oc,GADDI:dc}},90494:function(se,ee){"use strict";var b="*",w=function(){function k(){this._events={}}return k.prototype.on=function(O,R,S){return this._events[O]||(this._events[O]=[]),this._events[O].push({callback:R,once:!!S}),this},k.prototype.once=function(O,R){return this.on(O,R,!0)},k.prototype.emit=function(O){for(var R=this,S=[],C=1;C<arguments.length;C++)S[C-1]=arguments[C];var x=this._events[O]||[],E=this._events[b]||[],N=function(L){for(var P=L.length,W=0;W<P;W++)if(L[W]){var Y=L[W],ie=Y.callback,pe=Y.once;pe&&(L.splice(W,1),L.length===0&&delete R._events[O],P--,W--),ie.apply(R,S)}};N(x),N(E)},k.prototype.off=function(O,R){if(!O)this._events={};else if(!R)delete this._events[O];else{for(var S=this._events[O]||[],C=S.length,x=0;x<C;x++)S[x].callback===R&&(S.splice(x,1),C--,x--);S.length===0&&delete this._events[O]}return this},k.prototype.getEvents=function(){return this._events},k}();ee.Z=w},11702:function(se,ee,b){"use strict";b.d(ee,{TE:function(){return R},U4:function(){return He},Xk:function(){return Ge},Y1:function(){return We},_x:function(){return It},hE:function(){return Be},l5:function(){return Fe},ph:function(){return Ze},vp:function(){return ye},x4:function(){return we}});var w=b(97582),k=b(80450),O=b(31437);function R(Ce,Re,qe,st){var $e=Ce-qe,ft=Re-st;return Math.sqrt($e*$e+ft*ft)}function S(Ce,Re){var qe=Math.min.apply(Math,(0,w.ev)([],(0,w.CR)(Ce),!1)),st=Math.min.apply(Math,(0,w.ev)([],(0,w.CR)(Re),!1)),$e=Math.max.apply(Math,(0,w.ev)([],(0,w.CR)(Ce),!1)),ft=Math.max.apply(Math,(0,w.ev)([],(0,w.CR)(Re),!1));return{x:qe,y:st,width:$e-qe,height:ft-st}}function C(Ce){return(Ce+Math.PI*2)%(Math.PI*2)}function x(Ce,Re){var qe=Math.abs(Ce);return Re>0?qe:qe*-1}function E(Ce,Re,qe,st,$e,ft){var Ct=qe,jt=st;if(Ct===0||jt===0)return{x:Ce,y:Re};for(var Qt=$e-Ce,pn=ft-Re,Wn=Math.abs(Qt),Rn=Math.abs(pn),bi=Ct*Ct,Dr=jt*jt,Qn=Math.PI/4,Vi=0,Oi=0,Gi=0;Gi<4;Gi++){Vi=Ct*Math.cos(Qn),Oi=jt*Math.sin(Qn);var ir=(bi-Dr)*Math.pow(Math.cos(Qn),3)/Ct,gs=(Dr-bi)*Math.pow(Math.sin(Qn),3)/jt,Ls=Vi-ir,ls=Oi-gs,ys=Wn-ir,Gs=Rn-gs,Yl=Math.hypot(ls,Ls),Zl=Math.hypot(Gs,ys),Fa=Yl*Math.asin((Ls*Gs-ls*ys)/(Yl*Zl)),Fl=Fa/Math.sqrt(bi+Dr-Vi*Vi-Oi*Oi);Qn+=Fl,Qn=Math.min(Math.PI/2,Math.max(0,Qn))}return{x:Ce+x(Vi,Qt),y:Re+x(Oi,pn)}}function N(Ce,Re,qe,st,$e,ft,Ct,jt){return-1*qe*Math.cos($e)*Math.sin(jt)-st*Math.sin($e)*Math.cos(jt)}function L(Ce,Re,qe,st,$e,ft,Ct,jt){return-1*qe*Math.sin($e)*Math.sin(jt)+st*Math.cos($e)*Math.cos(jt)}function P(Ce,Re,qe){return Math.atan(-Re/Ce*Math.tan(qe))}function W(Ce,Re,qe){return Math.atan(Re/(Ce*Math.tan(qe)))}function Y(Ce,Re,qe,st,$e,ft){return qe*Math.cos($e)*Math.cos(ft)-st*Math.sin($e)*Math.sin(ft)+Ce}function ie(Ce,Re,qe,st,$e,ft){return qe*Math.sin($e)*Math.cos(ft)+st*Math.cos($e)*Math.sin(ft)+Re}function pe(Ce,Re,qe,st){var $e=Math.atan2(st*Ce,qe*Re);return($e+Math.PI*2)%(Math.PI*2)}function fe(Ce,Re,qe){return{x:Ce*Math.cos(qe),y:Re*Math.sin(qe)}}function ae(Ce,Re,qe){var st=Math.cos(qe),$e=Math.sin(qe);return[Ce*st-Re*$e,Ce*$e+Re*st]}function ye(Ce,Re,qe,st,$e,ft,Ct){for(var jt=P(qe,st,$e),Qt=1/0,pn=-1/0,Wn=[ft,Ct],Rn=-Math.PI*2;Rn<=Math.PI*2;Rn+=Math.PI){var bi=jt+Rn;ft<Ct?ft<bi&&bi<Ct&&Wn.push(bi):Ct<bi&&bi<ft&&Wn.push(bi)}for(var Rn=0;Rn<Wn.length;Rn++){var Dr=Y(Ce,Re,qe,st,$e,Wn[Rn]);Dr<Qt&&(Qt=Dr),Dr>pn&&(pn=Dr)}for(var Qn=W(qe,st,$e),Vi=1/0,Oi=-1/0,Gi=[ft,Ct],Rn=-Math.PI*2;Rn<=Math.PI*2;Rn+=Math.PI){var ir=Qn+Rn;ft<Ct?ft<ir&&ir<Ct&&Gi.push(ir):Ct<ir&&ir<ft&&Gi.push(ir)}for(var Rn=0;Rn<Gi.length;Rn++){var gs=ie(Ce,Re,qe,st,$e,Gi[Rn]);gs<Vi&&(Vi=gs),gs>Oi&&(Oi=gs)}return{x:Qt,y:Vi,width:pn-Qt,height:Oi-Vi}}function ue(Ce,Re,qe,st,$e,ft,Ct,jt,Qt){var pn=ae(jt-Ce,Qt-Re,-$e),Wn=__read(pn,2),Rn=Wn[0],bi=Wn[1],Dr=E(0,0,qe,st,Rn,bi),Qn=pe(qe,st,Dr.x,Dr.y);Qn<ft?Dr=fe(qe,st,ft):Qn>Ct&&(Dr=fe(qe,st,Ct));var Vi=ae(Dr.x,Dr.y,$e);return{x:Vi[0]+Ce,y:Vi[1]+Re}}function Ne(Ce,Re,qe,st,$e,ft,Ct,jt){var Qt=(Ct-ft)*jt+ft,pn=N(Ce,Re,qe,st,$e,ft,Ct,Qt),Wn=L(Ce,Re,qe,st,$e,ft,Ct,Qt);return C(Math.atan2(Wn,pn))}var Te=1e-4;function _e(Ce,Re,qe,st,$e,ft){var Ct=-1,jt=1/0,Qt=[qe,st],pn=20;ft&&ft>200&&(pn=ft/10);for(var Wn=1/pn,Rn=Wn/10,bi=0;bi<=pn;bi++){var Dr=bi*Wn,Qn=[$e.apply(void 0,(0,w.ev)([],(0,w.CR)(Ce.concat([Dr])),!1)),$e.apply(void 0,(0,w.ev)([],(0,w.CR)(Re.concat([Dr])),!1))],Vi=R(Qt[0],Qt[1],Qn[0],Qn[1]);Vi<jt&&(Ct=Dr,jt=Vi)}if(Ct===0)return{x:Ce[0],y:Re[0]};if(Ct===1){var Oi=Ce.length;return{x:Ce[Oi-1],y:Re[Oi-1]}}jt=1/0;for(var bi=0;bi<32&&!(Rn<Te);bi++){var Gi=Ct-Rn,ir=Ct+Rn,Qn=[$e.apply(void 0,(0,w.ev)([],(0,w.CR)(Ce.concat([Gi])),!1)),$e.apply(void 0,(0,w.ev)([],(0,w.CR)(Re.concat([Gi])),!1))],Vi=R(Qt[0],Qt[1],Qn[0],Qn[1]);if(Gi>=0&&Vi<jt)Ct=Gi,jt=Vi;else{var gs=[$e.apply(void 0,(0,w.ev)([],(0,w.CR)(Ce.concat([ir])),!1)),$e.apply(void 0,(0,w.ev)([],(0,w.CR)(Re.concat([ir])),!1))],Ls=R(Qt[0],Qt[1],gs[0],gs[1]);ir<=1&&Ls<jt?(Ct=ir,jt=Ls):Rn*=.5}}return{x:$e.apply(void 0,(0,w.ev)([],(0,w.CR)(Ce.concat([Ct])),!1)),y:$e.apply(void 0,(0,w.ev)([],(0,w.CR)(Re.concat([Ct])),!1))}}function Xe(Ce,Re){for(var qe=0,st=Ce.length,$e=0;$e<st;$e++){var ft=Ce[$e],Ct=Re[$e],jt=Ce[($e+1)%st],Qt=Re[($e+1)%st];qe+=R(ft,Ct,jt,Qt)}return qe/2}function Se(Ce,Re,qe,st){return S([Ce,qe],[Re,st])}function Ge(Ce,Re,qe,st){return R(Ce,Re,qe,st)}function He(Ce,Re,qe,st,$e){return{x:(1-$e)*Ce+$e*qe,y:(1-$e)*Re+$e*st}}function vt(Ce,Re,qe,st,$e,ft){var Ct=(qe-Ce)*($e-Ce)+(st-Re)*(ft-Re);if(Ct<0)return R(Ce,Re,$e,ft);var jt=(qe-Ce)*(qe-Ce)+(st-Re)*(st-Re);return Ct>jt?R(qe,st,$e,ft):It(Ce,Re,qe,st,$e,ft)}function It(Ce,Re,qe,st,$e,ft){var Ct=[qe-Ce,st-Re];if(O.I6(Ct,[0,0]))return Math.sqrt(($e-Ce)*($e-Ce)+(ft-Re)*(ft-Re));var jt=[-Ct[1],Ct[0]];O.Fv(jt,jt);var Qt=[$e-Ce,ft-Re];return Math.abs(O.AK(Qt,jt))}function zt(Ce,Re,qe,st){return Math.atan2(st-Re,qe-Ce)}function Yt(Ce,Re,qe,st,$e){var ft=1-$e;return ft*ft*ft*Ce+3*Re*$e*ft*ft+3*qe*$e*$e*ft+st*$e*$e*$e}function At(Ce,Re,qe,st,$e){var ft=1-$e;return 3*(ft*ft*(Re-Ce)+2*ft*$e*(qe-Re)+$e*$e*(st-qe))}function lt(Ce,Re,qe,st){var $e=-3*Ce+9*Re-9*qe+3*st,ft=6*Ce-12*Re+6*qe,Ct=3*Re-3*Ce,jt=[],Qt,pn,Wn;if((0,k.Z)($e,0))(0,k.Z)(ft,0)||(Qt=-Ct/ft,Qt>=0&&Qt<=1&&jt.push(Qt));else{var Rn=ft*ft-4*$e*Ct;(0,k.Z)(Rn,0)?jt.push(-ft/(2*$e)):Rn>0&&(Wn=Math.sqrt(Rn),Qt=(-ft+Wn)/(2*$e),pn=(-ft-Wn)/(2*$e),Qt>=0&&Qt<=1&&jt.push(Qt),pn>=0&&pn<=1&&jt.push(pn))}return jt}function Ot(Ce,Re,qe,st,$e,ft,Ct,jt,Qt){var pn=Yt(Ce,qe,$e,Ct,Qt),Wn=Yt(Re,st,ft,jt,Qt),Rn=He(Ce,Re,qe,st,Qt),bi=He(qe,st,$e,ft,Qt),Dr=He($e,ft,Ct,jt,Qt),Qn=He(Rn.x,Rn.y,bi.x,bi.y,Qt),Vi=He(bi.x,bi.y,Dr.x,Dr.y,Qt);return[[Ce,Re,Rn.x,Rn.y,Qn.x,Qn.y,pn,Wn],[pn,Wn,Vi.x,Vi.y,Dr.x,Dr.y,Ct,jt]]}function le(Ce,Re,qe,st,$e,ft,Ct,jt,Qt){if(Qt===0)return Xe([Ce,qe,$e,Ct],[Re,st,ft,jt]);var pn=Ot(Ce,Re,qe,st,$e,ft,Ct,jt,.5),Wn=__spreadArray(__spreadArray([],__read(pn[0]),!1),[Qt-1],!1),Rn=__spreadArray(__spreadArray([],__read(pn[1]),!1),[Qt-1],!1);return le.apply(void 0,__spreadArray([],__read(Wn),!1))+le.apply(void 0,__spreadArray([],__read(Rn),!1))}function Fe(Ce,Re,qe,st,$e,ft,Ct,jt){for(var Qt=[Ce,Ct],pn=[Re,jt],Wn=lt(Ce,qe,$e,Ct),Rn=lt(Re,st,ft,jt),bi=0;bi<Wn.length;bi++)Qt.push(Yt(Ce,qe,$e,Ct,Wn[bi]));for(var bi=0;bi<Rn.length;bi++)pn.push(Yt(Re,st,ft,jt,Rn[bi]));return S(Qt,pn)}function gt(Ce,Re,qe,st,$e,ft,Ct,jt){return le(Ce,Re,qe,st,$e,ft,Ct,jt,3)}function Jt(Ce,Re,qe,st,$e,ft,Ct,jt,Qt,pn,Wn){return _e([Ce,qe,$e,Ct],[Re,st,ft,jt],Qt,pn,Yt,Wn)}function Ze(Ce,Re,qe,st,$e,ft,Ct,jt,Qt,pn,Wn){var Rn=Jt(Ce,Re,qe,st,$e,ft,Ct,jt,Qt,pn,Wn);return R(Rn.x,Rn.y,Qt,pn)}function rt(Ce,Re,qe,st,$e,ft,Ct,jt,Qt){return{x:Yt(Ce,qe,$e,Ct,Qt),y:Yt(Re,st,ft,jt,Qt)}}function Mt(Ce,Re,qe,st,$e,ft,Ct,jt,Qt){var pn=At(Ce,qe,$e,Ct,Qt),Wn=At(Re,st,ft,jt,Qt);return C(Math.atan2(Wn,pn))}function Ue(Ce){for(var Re=0,qe=[],st=0;st<Ce.length-1;st++){var $e=Ce[st],ft=Ce[st+1],Ct=R($e[0],$e[1],ft[0],ft[1]),jt={from:$e,to:ft,length:Ct};qe.push(jt),Re+=Ct}return{segments:qe,totalLength:Re}}function Ye(Ce){if(Ce.length<2)return 0;for(var Re=0,qe=0;qe<Ce.length-1;qe++){var st=Ce[qe],$e=Ce[qe+1];Re+=R(st[0],st[1],$e[0],$e[1])}return Re}function be(Ce,Re){if(Re>1||Re<0||Ce.length<2)return null;var qe=Ue(Ce),st=qe.segments,$e=qe.totalLength;if($e===0)return{x:Ce[0][0],y:Ce[0][1]};for(var ft=0,Ct=null,jt=0;jt<st.length;jt++){var Qt=st[jt],pn=Qt.from,Wn=Qt.to,Rn=Qt.length/$e;if(Re>=ft&&Re<=ft+Rn){var bi=(Re-ft)/Rn;Ct=He(pn[0],pn[1],Wn[0],Wn[1],bi);break}ft+=Rn}return Ct}function ge(Ce,Re){if(Re>1||Re<0||Ce.length<2)return 0;for(var qe=Ue(Ce),st=qe.segments,$e=qe.totalLength,ft=0,Ct=0,jt=0;jt<st.length;jt++){var Qt=st[jt],pn=Qt.from,Wn=Qt.to,Rn=Qt.length/$e;if(Re>=ft&&Re<=ft+Rn){Ct=Math.atan2(Wn[1]-pn[1],Wn[0]-pn[0]);break}ft+=Rn}return Ct}function Ke(Ce,Re,qe){for(var st=1/0,$e=0;$e<Ce.length-1;$e++){var ft=Ce[$e],Ct=Ce[$e+1],jt=vt(ft[0],ft[1],Ct[0],Ct[1],Re,qe);jt<st&&(st=jt)}return st}function wt(Ce){for(var Re=[],qe=[],st=0;st<Ce.length;st++){var $e=Ce[st];Re.push($e[0]),qe.push($e[1])}return S(Re,qe)}function Be(Ce){return Ye(Ce)}function ut(Ce,Re){return be(Ce,Re)}function Et(Ce,Re,qe){return Ke(Ce,Re,qe)}function je(Ce,Re){return ge(Ce,Re)}function tt(Ce){var Re=Ce.slice(0);return Ce.length&&Re.push(Ce[0]),Re}function yt(Ce){return wt(Ce)}function B(Ce){return Ye(tt(Ce))}function te(Ce,Re){return be(tt(Ce),Re)}function ot(Ce,Re,qe){return Ke(tt(Ce),Re,qe)}function _t(Ce,Re){return ge(tt(Ce),Re)}function ct(Ce,Re,qe,st){var $e=1-st;return $e*$e*Ce+2*st*$e*Re+st*st*qe}function qt(Ce,Re,qe){var st=Ce+qe-2*Re;if((0,k.Z)(st,0))return[.5];var $e=(Ce-Re)/st;return $e<=1&&$e>=0?[$e]:[]}function en(Ce,Re,qe,st,$e,ft,Ct){var jt=ct(Ce,qe,$e,Ct),Qt=ct(Re,st,ft,Ct),pn=He(Ce,Re,qe,st,Ct),Wn=He(qe,st,$e,ft,Ct);return[[Ce,Re,pn.x,pn.y,jt,Qt],[jt,Qt,Wn.x,Wn.y,$e,ft]]}function nn(Ce,Re,qe,st,$e,ft,Ct){if(Ct===0)return(R(Ce,Re,qe,st)+R(qe,st,$e,ft)+R(Ce,Re,$e,ft))/2;var jt=en(Ce,Re,qe,st,$e,ft,.5),Qt=jt[0],pn=jt[1];return Qt.push(Ct-1),pn.push(Ct-1),nn.apply(void 0,__spreadArray([],__read(Qt),!1))+nn.apply(void 0,__spreadArray([],__read(pn),!1))}function we(Ce,Re,qe,st,$e,ft){var Ct=qt(Ce,qe,$e)[0],jt=qt(Re,st,ft)[0],Qt=[Ce,$e],pn=[Re,ft];return Ct!==void 0&&Qt.push(ct(Ce,qe,$e,Ct)),jt!==void 0&&pn.push(ct(Re,st,ft,jt)),S(Qt,pn)}function Q(Ce,Re,qe,st,$e,ft){return nn(Ce,Re,qe,st,$e,ft,3)}function De(Ce,Re,qe,st,$e,ft,Ct,jt){return _e([Ce,qe,$e],[Re,st,ft],Ct,jt,ct)}function We(Ce,Re,qe,st,$e,ft,Ct,jt){var Qt=De(Ce,Re,qe,st,$e,ft,Ct,jt);return R(Qt.x,Qt.y,Ct,jt)}},44326:function(se,ee,b){"use strict";b.d(ee,{k:function(){return R}});var w=b(90494),k=b(69991),O=b(35105);class R extends w.Z{constructor(x){super();ca(this,"nodeMap",new Map);ca(this,"edgeMap",new Map);ca(this,"inEdgesMap",new Map);ca(this,"outEdgesMap",new Map);ca(this,"bothEdgesMap",new Map);ca(this,"treeIndices",new Map);ca(this,"changes",[]);ca(this,"batchCount",0);ca(this,"onChanged",()=>{});ca(this,"batch",x=>{this.batchCount+=1,x(),this.batchCount-=1,this.batchCount||this.commit()});x&&(x.nodes&&this.addNodes(x.nodes),x.edges&&this.addEdges(x.edges),x.tree&&this.addTree(x.tree),x.onChanged&&(this.onChanged=x.onChanged))}commit(){const x=this.changes;this.changes=[];const E={graph:this,changes:x};this.emit("changed",E),this.onChanged(E)}reduceChanges(x){let E=[];return x.forEach(N=>{switch(N.type){case"NodeRemoved":{let L=!1;E=E.filter(P=>{if(P.type==="NodeAdded"){const W=P.value.id===N.value.id;return W&&(L=!0),!W}else{if(P.type==="NodeDataUpdated")return P.id!==N.value.id;if(P.type==="TreeStructureChanged")return P.nodeId!==N.value.id}return!0}),L||E.push(N);break}case"EdgeRemoved":{let L=!1;E=E.filter(P=>{if(P.type==="EdgeAdded"){const W=P.value.id===N.value.id;return W&&(L=!0),!W}else if(P.type==="EdgeDataUpdated"||P.type==="EdgeUpdated")return P.id!==N.value.id;return!0}),L||E.push(N);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const L=E.findIndex(W=>W.type===N.type&&W.id===N.id&&(N.propertyName===void 0||W.propertyName===N.propertyName)),P=E[L];P?N.propertyName!==void 0?P.newValue=N.newValue:(E.splice(L,1),E.push(N)):E.push(N);break}case"TreeStructureDetached":{E=E.filter(L=>L.type==="TreeStructureAttached"||L.type==="TreeStructureChanged"?L.treeKey!==N.treeKey:!0),E.push(N);break}case"TreeStructureChanged":{const L=E.find(P=>P.type==="TreeStructureChanged"&&P.treeKey===N.treeKey&&P.nodeId===N.nodeId);L?L.newParentId=N.newParentId:E.push(N);break}default:E.push(N);break}}),E}checkNodeExistence(x){this.getNode(x)}hasNode(x){return this.nodeMap.has(x)}areNeighbors(x,E){return this.getNeighbors(E).some(N=>N.id===x)}getNode(x){const E=this.nodeMap.get(x);if(!E)throw new Error("Node not found for id: "+x);return E}getRelatedEdges(x,E){if(this.checkNodeExistence(x),E==="in"){const N=this.inEdgesMap.get(x);return Array.from(N)}else if(E==="out"){const N=this.outEdgesMap.get(x);return Array.from(N)}else{const N=this.bothEdgesMap.get(x);return Array.from(N)}}getDegree(x,E){return this.getRelatedEdges(x,E).length}getSuccessors(x){const N=this.getRelatedEdges(x,"out").map(L=>this.getNode(L.target));return Array.from(new Set(N))}getPredecessors(x){const N=this.getRelatedEdges(x,"in").map(L=>this.getNode(L.source));return Array.from(new Set(N))}getNeighbors(x){const E=this.getPredecessors(x),N=this.getSuccessors(x);return Array.from(new Set([...E,...N]))}doAddNode(x){if(this.hasNode(x.id))throw new Error("Node already exists: "+x.id);this.nodeMap.set(x.id,x),this.inEdgesMap.set(x.id,new Set),this.outEdgesMap.set(x.id,new Set),this.bothEdgesMap.set(x.id,new Set),this.treeIndices.forEach(E=>{E.childrenMap.set(x.id,new Set)}),this.changes.push({type:"NodeAdded",value:x})}addNodes(x){this.batch(()=>{for(const E of x)this.doAddNode(E)})}addNode(x){this.addNodes([x])}doRemoveNode(x){const E=this.getNode(x),N=this.bothEdgesMap.get(x);N==null||N.forEach(L=>this.doRemoveEdge(L.id)),this.nodeMap.delete(x),this.treeIndices.forEach(L=>{var W,Y;(W=L.childrenMap.get(x))==null||W.forEach(ie=>{L.parentMap.delete(ie.id)});const P=L.parentMap.get(x);P&&((Y=L.childrenMap.get(P.id))==null||Y.delete(E)),L.parentMap.delete(x),L.childrenMap.delete(x)}),this.bothEdgesMap.delete(x),this.inEdgesMap.delete(x),this.outEdgesMap.delete(x),this.changes.push({type:"NodeRemoved",value:E})}removeNodes(x){this.batch(()=>{x.forEach(E=>this.doRemoveNode(E))})}removeNode(x){this.removeNodes([x])}updateNodeDataProperty(x,E,N){const L=this.getNode(x);this.batch(()=>{const P=L.data[E],W=N;L.data[E]=W,this.changes.push({type:"NodeDataUpdated",id:x,propertyName:E,oldValue:P,newValue:W})})}mergeNodeData(x,E){this.batch(()=>{Object.entries(E).forEach(([N,L])=>{this.updateNodeDataProperty(x,N,L)})})}updateNodeData(...x){const E=x[0],N=this.getNode(E);if(typeof x[1]=="string"){this.updateNodeDataProperty(E,x[1],x[2]);return}let L;if(typeof x[1]=="function"){const P=x[1];L=P(N.data)}else typeof x[1]=="object"&&(L=x[1]);this.batch(()=>{const P=N.data,W=L;N.data=L,this.changes.push({type:"NodeDataUpdated",id:E,oldValue:P,newValue:W})})}checkEdgeExistence(x){if(!this.hasEdge(x))throw new Error("Edge not found for id: "+x)}hasEdge(x){return this.edgeMap.has(x)}getEdge(x){return this.checkEdgeExistence(x),this.edgeMap.get(x)}getEdgeDetail(x){const E=this.getEdge(x);return{edge:E,source:this.getNode(E.source),target:this.getNode(E.target)}}doAddEdge(x){if(this.hasEdge(x.id))throw new Error("Edge already exists: "+x.id);this.checkNodeExistence(x.source),this.checkNodeExistence(x.target),this.edgeMap.set(x.id,x);const E=this.inEdgesMap.get(x.target),N=this.outEdgesMap.get(x.source),L=this.bothEdgesMap.get(x.source),P=this.bothEdgesMap.get(x.target);E.add(x),N.add(x),L.add(x),P.add(x),this.changes.push({type:"EdgeAdded",value:x})}addEdges(x){this.batch(()=>{for(const E of x)this.doAddEdge(E)})}addEdge(x){this.addEdges([x])}doRemoveEdge(x){const E=this.getEdge(x),N=this.outEdgesMap.get(E.source),L=this.inEdgesMap.get(E.target),P=this.bothEdgesMap.get(E.source),W=this.bothEdgesMap.get(E.target);N.delete(E),L.delete(E),P.delete(E),W.delete(E),this.edgeMap.delete(x),this.changes.push({type:"EdgeRemoved",value:E})}removeEdges(x){this.batch(()=>{x.forEach(E=>this.doRemoveEdge(E))})}removeEdge(x){this.removeEdges([x])}updateEdgeSource(x,E){const N=this.getEdge(x);this.checkNodeExistence(E);const L=N.source,P=E;this.outEdgesMap.get(L).delete(N),this.bothEdgesMap.get(L).delete(N),this.outEdgesMap.get(P).add(N),this.bothEdgesMap.get(P).add(N),N.source=E,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:x,propertyName:"source",oldValue:L,newValue:P})})}updateEdgeTarget(x,E){const N=this.getEdge(x);this.checkNodeExistence(E);const L=N.target,P=E;this.inEdgesMap.get(L).delete(N),this.bothEdgesMap.get(L).delete(N),this.inEdgesMap.get(P).add(N),this.bothEdgesMap.get(P).add(N),N.target=E,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:x,propertyName:"target",oldValue:L,newValue:P})})}updateEdgeDataProperty(x,E,N){const L=this.getEdge(x);this.batch(()=>{const P=L.data[E],W=N;L.data[E]=W,this.changes.push({type:"EdgeDataUpdated",id:x,propertyName:E,oldValue:P,newValue:W})})}updateEdgeData(...x){const E=x[0],N=this.getEdge(E);if(typeof x[1]=="string"){this.updateEdgeDataProperty(E,x[1],x[2]);return}let L;if(typeof x[1]=="function"){const P=x[1];L=P(N.data)}else typeof x[1]=="object"&&(L=x[1]);this.batch(()=>{const P=N.data,W=L;N.data=L,this.changes.push({type:"EdgeDataUpdated",id:E,oldValue:P,newValue:W})})}mergeEdgeData(x,E){this.batch(()=>{Object.entries(E).forEach(([N,L])=>{this.updateEdgeDataProperty(x,N,L)})})}checkTreeExistence(x){if(!this.hasTreeStructure(x))throw new Error("Tree structure not found for treeKey: "+x)}hasTreeStructure(x){return this.treeIndices.has(x)}attachTreeStructure(x){this.treeIndices.has(x)||(this.treeIndices.set(x,{parentMap:new Map,childrenMap:new Map}),this.batch(()=>{this.changes.push({type:"TreeStructureAttached",treeKey:x})}))}detachTreeStructure(x){this.checkTreeExistence(x),this.treeIndices.delete(x),this.batch(()=>{this.changes.push({type:"TreeStructureDetached",treeKey:x})})}addTree(x,E){this.batch(()=>{this.attachTreeStructure(E);const N=[],L=Array.isArray(x)?x:[x];for(;L.length;){const P=L.shift();N.push(P),P.children&&L.push(...P.children)}this.addNodes(N),N.forEach(P=>{var W;(W=P.children)==null||W.forEach(Y=>{this.setParent(Y.id,P.id,E)})})})}getRoots(x){return this.checkTreeExistence(x),this.getAllNodes().filter(E=>!this.getParent(E.id,x))}getChildren(x,E){this.checkNodeExistence(x),this.checkTreeExistence(E);const L=this.treeIndices.get(E).childrenMap.get(x);return Array.from(L||[])}getParent(x,E){return this.checkNodeExistence(x),this.checkTreeExistence(E),this.treeIndices.get(E).parentMap.get(x)||null}getAncestors(x,E){const N=[];let L=this.getNode(x),P;for(;P=this.getParent(L.id,E);)N.push(P),L=P;return N}setParent(x,E,N){var pe,fe;this.checkTreeExistence(N);const L=this.treeIndices.get(N),P=this.getNode(x),W=L.parentMap.get(x);if((W==null?void 0:W.id)===E)return;if(E===void 0){W&&((pe=L.childrenMap.get(W.id))==null||pe.delete(P)),L.parentMap.delete(x);return}const Y=this.getNode(E);L.parentMap.set(x,Y),W&&((fe=L.childrenMap.get(W.id))==null||fe.delete(P));let ie=L.childrenMap.get(Y.id);ie||(ie=new Set,L.childrenMap.set(Y.id,ie)),ie.add(P),this.batch(()=>{this.changes.push({type:"TreeStructureChanged",treeKey:N,nodeId:x,oldParentId:W==null?void 0:W.id,newParentId:Y.id})})}dfsTree(x,E,N){const L=P=>this.getChildren(P,N);return(0,O.I)(this.getNode(x),new Set,E,L)}bfsTree(x,E,N){const L=P=>this.getChildren(P,N);return(0,O.O)([this.getNode(x)],new Set,E,L)}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(x,E,N="out"){const L={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[N];return(0,O.O)([this.getNode(x)],new Set,E,L)}dfs(x,E,N="out"){const L={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[N];return(0,O.I)(this.getNode(x),new Set,E,L)}clone(){const x=this.getAllNodes().map(L=>cc(Ys({},L),{data:Ys({},L.data)})),E=this.getAllEdges().map(L=>cc(Ys({},L),{data:Ys({},L.data)})),N=new R({nodes:x,edges:E});return this.treeIndices.forEach(({parentMap:L,childrenMap:P},W)=>{const Y=new Map;L.forEach((pe,fe)=>{Y.set(fe,N.getNode(pe.id))});const ie=new Map;P.forEach((pe,fe)=>{ie.set(fe,new Set(Array.from(pe).map(ae=>N.getNode(ae.id))))}),N.treeIndices.set(W,{parentMap:Y,childrenMap:ie})}),N}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}createView(x){return new k.t(Ys({graph:this},x))}}},69991:function(se,ee,b){"use strict";b.d(ee,{t:function(){return O}});var w=b(35105);const k=()=>!0;class O{constructor(S){ca(this,"graph");ca(this,"nodeFilter");ca(this,"edgeFilter");ca(this,"cacheEnabled");ca(this,"inEdgesMap",new Map);ca(this,"outEdgesMap",new Map);ca(this,"bothEdgesMap",new Map);ca(this,"allNodesMap",new Map);ca(this,"allEdgesMap",new Map);ca(this,"clearCache",()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()});ca(this,"refreshCache",()=>{this.clearCache(),this.updateCache(this.graph.getAllNodes().map(S=>S.id))});ca(this,"updateCache",S=>{const C=new Set;S.forEach(x=>{const E=this.bothEdgesMap.get(x);if(E&&E.forEach(N=>C.add(N.id)),!this.hasNode(x))this.inEdgesMap.delete(x),this.outEdgesMap.delete(x),this.bothEdgesMap.delete(x),this.allNodesMap.delete(x);else{const N=this.graph.getRelatedEdges(x,"in").filter(this.edgeFilter),L=this.graph.getRelatedEdges(x,"out").filter(this.edgeFilter),P=Array.from(new Set([...N,...L]));P.forEach(W=>C.add(W.id)),this.inEdgesMap.set(x,N),this.outEdgesMap.set(x,L),this.bothEdgesMap.set(x,P),this.allNodesMap.set(x,this.graph.getNode(x))}}),C.forEach(x=>{this.hasEdge(x)?this.allEdgesMap.set(x,this.graph.getEdge(x)):this.allEdgesMap.delete(x)})});ca(this,"handleGraphChanged",S=>{const C=new Set;S.changes.forEach(x=>{switch(x.type){case"NodeAdded":C.add(x.value.id);break;case"NodeDataUpdated":C.add(x.id);break;case"EdgeAdded":C.add(x.value.source),C.add(x.value.target);break;case"EdgeUpdated":(x.propertyName==="source"||x.propertyName==="target")&&(C.add(x.oldValue),C.add(x.newValue));break;case"EdgeDataUpdated":if(S.graph.hasEdge(x.id)){const E=S.graph.getEdge(x.id);C.add(E.source),C.add(E.target)}break;case"EdgeRemoved":C.add(x.value.source),C.add(x.value.target);break;case"NodeRemoved":C.add(x.value.id);break;default:break}}),this.updateCache(C)});this.graph=S.graph;const C=S.nodeFilter||k,x=S.edgeFilter||k;this.nodeFilter=C,this.edgeFilter=E=>{const{source:N,target:L}=this.graph.getEdgeDetail(E.id);return!C(N)||!C(L)?!1:x(E,N,L)},S.cache==="auto"?(this.cacheEnabled=!0,this.startAutoCache()):S.cache==="manual"?this.cacheEnabled=!0:this.cacheEnabled=!1}startAutoCache(){this.refreshCache(),this.graph.on("changed",this.handleGraphChanged)}stopAutoCache(){this.graph.off("changed",this.handleGraphChanged)}checkNodeExistence(S){this.getNode(S)}hasNode(S){if(!this.graph.hasNode(S))return!1;const C=this.graph.getNode(S);return this.nodeFilter(C)}areNeighbors(S,C){return this.checkNodeExistence(S),this.getNeighbors(C).some(x=>x.id===S)}getNode(S){const C=this.graph.getNode(S);if(!this.nodeFilter(C))throw new Error("Node not found for id: "+S);return C}getRelatedEdges(S,C){return this.checkNodeExistence(S),this.cacheEnabled?C==="in"?this.inEdgesMap.get(S):C==="out"?this.outEdgesMap.get(S):this.bothEdgesMap.get(S):this.graph.getRelatedEdges(S,C).filter(this.edgeFilter)}getDegree(S,C){return this.getRelatedEdges(S,C).length}getSuccessors(S){const x=this.getRelatedEdges(S,"out").map(E=>this.getNode(E.target));return Array.from(new Set(x))}getPredecessors(S){const x=this.getRelatedEdges(S,"in").map(E=>this.getNode(E.source));return Array.from(new Set(x))}getNeighbors(S){const C=this.getPredecessors(S),x=this.getSuccessors(S);return Array.from(new Set([...C,...x]))}hasEdge(S){if(!this.graph.hasEdge(S))return!1;const C=this.graph.getEdge(S);return this.edgeFilter(C)}getEdge(S){const C=this.graph.getEdge(S);if(!this.edgeFilter(C))throw new Error("Edge not found for id: "+S);return C}getEdgeDetail(S){const C=this.getEdge(S);return{edge:C,source:this.getNode(C.source),target:this.getNode(C.target)}}hasTreeStructure(S){return this.graph.hasTreeStructure(S)}getRoots(S){return this.graph.getRoots(S).filter(this.nodeFilter)}getChildren(S,C){return this.checkNodeExistence(S),this.graph.getChildren(S,C).filter(this.nodeFilter)}getParent(S,C){this.checkNodeExistence(S);const x=this.graph.getParent(S,C);return!x||!this.nodeFilter(x)?null:x}getAllNodes(){return this.cacheEnabled?Array.from(this.allNodesMap.values()):this.graph.getAllNodes().filter(this.nodeFilter)}getAllEdges(){return this.cacheEnabled?Array.from(this.allEdgesMap.values()):this.graph.getAllEdges().filter(this.edgeFilter)}bfs(S,C,x="out"){const E={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[x];(0,w.O)([this.getNode(S)],new Set,C,E)}dfs(S,C,x="out"){const E={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[x];(0,w.I)(this.getNode(S),new Set,C,E)}}},35105:function(se,ee,b){"use strict";b.d(ee,{I:function(){return k},O:function(){return w}});function w(O,R,S,C){for(;O.length;){const x=O.shift();if(S(x))return!0;R.add(x.id),C(x.id).forEach(N=>{R.has(N.id)||(R.add(N.id),O.push(N))})}return!1}function k(O,R,S,C){if(S(O))return!0;R.add(O.id);for(const E of C(O.id))if(!R.has(E.id)&&k(E,R,S,C))return!0;return!1}},81746:function(se){(function(b,w){se.exports=w()})(typeof self!="undefined"?self:this,function(){return function(ee){var b={};function w(k){if(b[k])return b[k].exports;var O=b[k]={i:k,l:!1,exports:{}};return ee[k].call(O.exports,O,O.exports,w),O.l=!0,O.exports}return w.m=ee,w.c=b,w.d=function(k,O,R){w.o(k,O)||Object.defineProperty(k,O,{configurable:!1,enumerable:!0,get:R})},w.n=function(k){var O=k&&k.__esModule?function(){return k.default}:function(){return k};return w.d(O,"a",O),O},w.o=function(k,O){return Object.prototype.hasOwnProperty.call(k,O)},w.p="",w(w.s=5)}([function(ee,b){function w(k,O,R,S){return S===void 0&&(S="height"),R==="center"?(k[S]+O[S])/2:k.height}ee.exports={assign:Object.assign,getHeight:w}},function(ee,b,w){var k=w(3),O=function(){function R(C,x){x===void 0&&(x={});var E=this;E.options=x,E.rootNode=k(C,x)}var S=R.prototype;return S.execute=function(){throw new Error("please override this method")},R}();ee.exports=O},function(ee,b,w){var k=w(4),O=["LR","RL","TB","BT","H","V"],R=["LR","RL","H"],S=function(N){return R.indexOf(N)>-1},C=O[0];ee.exports=function(E,N,L){var P=N.direction||C;if(N.isHorizontal=S(P),P&&O.indexOf(P)===-1)throw new TypeError("Invalid direction: "+P);if(P===O[0])L(E,N);else if(P===O[1])L(E,N),E.right2left();else if(P===O[2])L(E,N);else if(P===O[3])L(E,N),E.bottom2top();else if(P===O[4]||P===O[5]){var W=k(E,N),Y=W.left,ie=W.right;L(Y,N),L(ie,N),N.isHorizontal?Y.right2left():Y.bottom2top(),ie.translate(Y.x-ie.x,Y.y-ie.y),E.x=Y.x,E.y=ie.y;var pe=E.getBoundingBox();N.isHorizontal?pe.top<0&&E.translate(0,-pe.top):pe.left<0&&E.translate(-pe.left,0)}var fe=N.fixedRoot;return fe===void 0&&(fe=!0),fe&&E.translate(-(E.x+E.width/2+E.hgap),-(E.y+E.height/2+E.vgap)),x(E,N),E};function x(E,N){if(N.radial){var L=N.isHorizontal?["x","y"]:["y","x"],P=L[0],W=L[1],Y={x:1/0,y:1/0},ie={x:-1/0,y:-1/0},pe=0;E.DFTraverse(function(ye){pe++;var ue=ye.x,Ne=ye.y;Y.x=Math.min(Y.x,ue),Y.y=Math.min(Y.y,Ne),ie.x=Math.max(ie.x,ue),ie.y=Math.max(ie.y,Ne)});var fe=ie[W]-Y[W];if(fe===0)return;var ae=Math.PI*2/pe;E.DFTraverse(function(ye){var ue=(ye[W]-Y[W])/fe*(Math.PI*2-ae)+ae,Ne=ye[P]-E[P];ye.x=Math.cos(ue)*Ne,ye.y=Math.sin(ue)*Ne})}}},function(ee,b,w){var k=w(0),O=18,R=O*2,S=O,C={getId:function(L){return L.id||L.name},getPreH:function(L){return L.preH||0},getPreV:function(L){return L.preV||0},getHGap:function(L){return L.hgap||S},getVGap:function(L){return L.vgap||S},getChildren:function(L){return L.children},getHeight:function(L){return L.height||R},getWidth:function(L){var P=L.label||" ";return L.width||P.split("").length*O}};function x(N,L){var P=this;if(P.vgap=P.hgap=0,N instanceof x)return N;P.data=N;var W=L.getHGap(N),Y=L.getVGap(N);return P.preH=L.getPreH(N),P.preV=L.getPreV(N),P.width=L.getWidth(N),P.height=L.getHeight(N),P.width+=P.preH,P.height+=P.preV,P.id=L.getId(N),P.x=P.y=0,P.depth=0,P.children||(P.children=[]),P.addGap(W,Y),P}k.assign(x.prototype,{isRoot:function(){return this.depth===0},isLeaf:function(){return this.children.length===0},addGap:function(L,P){var W=this;W.hgap+=L,W.vgap+=P,W.width+=2*L,W.height+=2*P},eachNode:function(L){for(var P=this,W=[P],Y;Y=W.shift();)L(Y),W=Y.children.concat(W)},DFTraverse:function(L){this.eachNode(L)},BFTraverse:function(L){for(var P=this,W=[P],Y;Y=W.shift();)L(Y),W=W.concat(Y.children)},getBoundingBox:function(){var L={left:Number.MAX_VALUE,top:Number.MAX_VALUE,width:0,height:0};return this.eachNode(function(P){L.left=Math.min(L.left,P.x),L.top=Math.min(L.top,P.y),L.width=Math.max(L.width,P.x+P.width),L.height=Math.max(L.height,P.y+P.height)}),L},translate:function(L,P){L===void 0&&(L=0),P===void 0&&(P=0),this.eachNode(function(W){W.x+=L,W.y+=P,W.x+=W.preH,W.y+=W.preV})},right2left:function(){var L=this,P=L.getBoundingBox();L.eachNode(function(W){W.x=W.x-(W.x-P.left)*2-W.width}),L.translate(P.width,0)},bottom2top:function(){var L=this,P=L.getBoundingBox();L.eachNode(function(W){W.y=W.y-(W.y-P.top)*2-W.height}),L.translate(0,P.height)}});function E(N,L,P){L===void 0&&(L={}),L=k.assign({},C,L);var W=new x(N,L),Y=[W],ie;if(!P&&!N.collapsed){for(;ie=Y.shift();)if(!ie.data.collapsed){var pe=L.getChildren(ie.data),fe=pe?pe.length:0;if(ie.children=new Array(fe),pe&&fe)for(var ae=0;ae<fe;ae++){var ye=new x(pe[ae],L);ie.children[ae]=ye,Y.push(ye),ye.parent=ie,ye.depth=ie.depth+1}}}return W}ee.exports=E},function(ee,b,w){var k=w(3);ee.exports=function(O,R){for(var S=k(O.data,R,!0),C=k(O.data,R,!0),x=O.children.length,E=Math.round(x/2),N=R.getSide||function(Y,ie){return ie<E?"right":"left"},L=0;L<x;L++){var P=O.children[L],W=N(P,L);W==="right"?C.children.push(P):S.children.push(P)}return S.eachNode(function(Y){Y.isRoot()||(Y.side="left")}),C.eachNode(function(Y){Y.isRoot()||(Y.side="right")}),{left:S,right:C}}},function(ee,b,w){var k={compactBox:w(6),dendrogram:w(8),indented:w(10),mindmap:w(12)};ee.exports=k},function(ee,b,w){function k(P,W){P.prototype=Object.create(W.prototype),P.prototype.constructor=P,O(P,W)}function O(P,W){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(Y,ie){return Y.__proto__=ie,Y},O(P,W)}var R=w(1),S=w(7),C=w(2),x=w(0),E=function(P){function W(){return P.apply(this,arguments)||this}k(W,P);var Y=W.prototype;return Y.execute=function(){var pe=this;return C(pe.rootNode,pe.options,S)},W}(R),N={};function L(P,W){return W=x.assign({},N,W),new E(P,W).execute()}ee.exports=L},function(ee,b){function w(x,E,N,L){L===void 0&&(L=[]);var P=this;P.w=x||0,P.h=E||0,P.y=N||0,P.x=0,P.c=L||[],P.cs=L.length,P.prelim=0,P.mod=0,P.shift=0,P.change=0,P.tl=null,P.tr=null,P.el=null,P.er=null,P.msel=0,P.mser=0}w.fromNode=function(x,E){if(!x)return null;var N=[];return x.children.forEach(function(L){N.push(w.fromNode(L,E))}),E?new w(x.height,x.width,x.x,N):new w(x.width,x.height,x.y,N)};function k(x,E,N){N?x.y+=E:x.x+=E,x.children.forEach(function(L){k(L,E,N)})}function O(x,E){var N=E?x.y:x.x;return x.children.forEach(function(L){N=Math.min(O(L,E),N)}),N}function R(x,E){var N=O(x,E);k(x,-N,E)}function S(x,E,N){N?E.y=x.x:E.x=x.x,x.c.forEach(function(L,P){S(L,E.children[P],N)})}function C(x,E,N){N===void 0&&(N=0),E?(x.x=N,N+=x.width):(x.y=N,N+=x.height),x.children.forEach(function(L){C(L,E,N)})}ee.exports=function(x,E){E===void 0&&(E={});var N=E.isHorizontal;function L(Ge){if(Ge.cs===0){P(Ge);return}L(Ge.c[0]);for(var He=Xe(fe(Ge.c[0].el),0,null),vt=1;vt<Ge.cs;++vt){L(Ge.c[vt]);var It=fe(Ge.c[vt].er);W(Ge,vt,He),He=Xe(It,vt,He)}ue(Ge),P(Ge)}function P(Ge){Ge.cs===0?(Ge.el=Ge,Ge.er=Ge,Ge.msel=Ge.mser=0):(Ge.el=Ge.c[0].el,Ge.msel=Ge.c[0].msel,Ge.er=Ge.c[Ge.cs-1].er,Ge.mser=Ge.c[Ge.cs-1].mser)}function W(Ge,He,vt){for(var It=Ge.c[He-1],zt=It.mod,Yt=Ge.c[He],At=Yt.mod;It!==null&&Yt!==null;){fe(It)>vt.low&&(vt=vt.nxt);var lt=zt+It.prelim+It.w-(At+Yt.prelim);lt>0&&(At+=lt,Y(Ge,He,vt.index,lt));var Ot=fe(It),le=fe(Yt);Ot<=le&&(It=pe(It),It!==null&&(zt+=It.mod)),Ot>=le&&(Yt=ie(Yt),Yt!==null&&(At+=Yt.mod))}!It&&Yt?ae(Ge,He,Yt,At):It&&!Yt&&ye(Ge,He,It,zt)}function Y(Ge,He,vt,It){Ge.c[He].mod+=It,Ge.c[He].msel+=It,Ge.c[He].mser+=It,Te(Ge,He,vt,It)}function ie(Ge){return Ge.cs===0?Ge.tl:Ge.c[0]}function pe(Ge){return Ge.cs===0?Ge.tr:Ge.c[Ge.cs-1]}function fe(Ge){return Ge.y+Ge.h}function ae(Ge,He,vt,It){var zt=Ge.c[0].el;zt.tl=vt;var Yt=It-vt.mod-Ge.c[0].msel;zt.mod+=Yt,zt.prelim-=Yt,Ge.c[0].el=Ge.c[He].el,Ge.c[0].msel=Ge.c[He].msel}function ye(Ge,He,vt,It){var zt=Ge.c[He].er;zt.tr=vt;var Yt=It-vt.mod-Ge.c[He].mser;zt.mod+=Yt,zt.prelim-=Yt,Ge.c[He].er=Ge.c[He-1].er,Ge.c[He].mser=Ge.c[He-1].mser}function ue(Ge){Ge.prelim=(Ge.c[0].prelim+Ge.c[0].mod+Ge.c[Ge.cs-1].mod+Ge.c[Ge.cs-1].prelim+Ge.c[Ge.cs-1].w)/2-Ge.w/2}function Ne(Ge,He){He+=Ge.mod,Ge.x=Ge.prelim+He,_e(Ge);for(var vt=0;vt<Ge.cs;vt++)Ne(Ge.c[vt],He)}function Te(Ge,He,vt,It){if(vt!==He-1){var zt=He-vt;Ge.c[vt+1].shift+=It/zt,Ge.c[He].shift-=It/zt,Ge.c[He].change-=It-It/zt}}function _e(Ge){for(var He=0,vt=0,It=0;It<Ge.cs;It++)He+=Ge.c[It].shift,vt+=He+Ge.c[It].change,Ge.c[It].mod+=vt}function Xe(Ge,He,vt){for(;vt!==null&&Ge>=vt.low;)vt=vt.nxt;return{low:Ge,index:He,nxt:vt}}C(x,N);var Se=w.fromNode(x,N);return L(Se),Ne(Se,0),S(Se,x,N),R(x,N),x}},function(ee,b,w){function k(P,W){P.prototype=Object.create(W.prototype),P.prototype.constructor=P,O(P,W)}function O(P,W){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(Y,ie){return Y.__proto__=ie,Y},O(P,W)}var R=w(1),S=w(9),C=w(2),x=w(0),E=function(P){function W(){return P.apply(this,arguments)||this}k(W,P);var Y=W.prototype;return Y.execute=function(){var pe=this;return pe.rootNode.width=0,C(pe.rootNode,pe.options,S)},W}(R),N={};function L(P,W){return W=x.assign({},N,W),new E(P,W).execute()}ee.exports=L},function(ee,b,w){var k=w(0);function O(C,x){C===void 0&&(C=0),x===void 0&&(x=[]);var E=this;E.x=E.y=0,E.leftChild=E.rightChild=null,E.height=0,E.children=x}var R={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};function S(C,x,E){E?(x.x=C.x,x.y=C.y):(x.x=C.y,x.y=C.x),C.children.forEach(function(N,L){S(N,x.children[L],E)})}ee.exports=function(C,x){x===void 0&&(x={}),x=k.assign({},R,x);var E=0;function N(ie){if(!ie)return null;ie.width=0,ie.depth&&ie.depth>E&&(E=ie.depth);var pe=ie.children,fe=pe.length,ae=new O(ie.height,[]);return pe.forEach(function(ye,ue){var Ne=N(ye);ae.children.push(Ne),ue===0&&(ae.leftChild=Ne),ue===fe-1&&(ae.rightChild=Ne)}),ae.originNode=ie,ae.isLeaf=ie.isLeaf(),ae}function L(ie){if(ie.isLeaf||ie.children.length===0)ie.drawingDepth=E;else{var pe=ie.children.map(function(ae){return L(ae)}),fe=Math.min.apply(null,pe);ie.drawingDepth=fe-1}return ie.drawingDepth}var P;function W(ie){ie.x=ie.drawingDepth*x.rankSep,ie.isLeaf?(ie.y=0,P&&(ie.y=P.y+P.height+x.nodeSep,ie.originNode.parent!==P.originNode.parent&&(ie.y+=x.subTreeSep)),P=ie):(ie.children.forEach(function(pe){W(pe)}),ie.y=(ie.leftChild.y+ie.rightChild.y)/2)}var Y=N(C);return L(Y),W(Y),S(Y,C,x.isHorizontal),C}},function(ee,b,w){function k(Y,ie){Y.prototype=Object.create(ie.prototype),Y.prototype.constructor=Y,O(Y,ie)}function O(Y,ie){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(pe,fe){return pe.__proto__=fe,pe},O(Y,ie)}var R=w(1),S=w(11),C=w(4),x=w(0),E=["LR","RL","H"],N=E[0],L=function(Y){function ie(){return Y.apply(this,arguments)||this}k(ie,Y);var pe=ie.prototype;return pe.execute=function(){var ae=this,ye=ae.options,ue=ae.rootNode;ye.isHorizontal=!0;var Ne=ye.indent,Te=Ne===void 0?20:Ne,_e=ye.dropCap,Xe=_e===void 0?!0:_e,Se=ye.direction,Ge=Se===void 0?N:Se,He=ye.align;if(Ge&&E.indexOf(Ge)===-1)throw new TypeError("Invalid direction: "+Ge);if(Ge===E[0])S(ue,Te,Xe,He);else if(Ge===E[1])S(ue,Te,Xe,He),ue.right2left();else if(Ge===E[2]){var vt=C(ue,ye),It=vt.left,zt=vt.right;S(It,Te,Xe,He),It.right2left(),S(zt,Te,Xe,He);var Yt=It.getBoundingBox();zt.translate(Yt.width,0),ue.x=zt.x-ue.width/2}return ue},ie}(R),P={};function W(Y,ie){return ie=x.assign({},P,ie),new L(Y,ie).execute()}ee.exports=W},function(ee,b,w){var k=w(0);function O(R,S,C,x,E){var N=(typeof C=="function"?C(R):C)*R.depth;if(!x)try{if(R.id===R.parent.children[0].id){R.x+=N,R.y=S?S.y:0;return}}catch(W){}if(R.x+=N,S){if(R.y=S.y+k.getHeight(S,R,E),S.parent&&R.parent.id!==S.parent.id){var L=S.parent,P=L.y+k.getHeight(L,R,E);R.y=P>R.y?P:R.y}}else R.y=0}ee.exports=function(R,S,C,x){var E=null;R.eachNode(function(N){O(N,E,S,C,x),E=N})}},function(ee,b,w){function k(P,W){P.prototype=Object.create(W.prototype),P.prototype.constructor=P,O(P,W)}function O(P,W){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(Y,ie){return Y.__proto__=ie,Y},O(P,W)}var R=w(1),S=w(13),C=w(2),x=w(0),E=function(P){function W(){return P.apply(this,arguments)||this}k(W,P);var Y=W.prototype;return Y.execute=function(){var pe=this;return C(pe.rootNode,pe.options,S)},W}(R),N={};function L(P,W){return W=x.assign({},N,W),new E(P,W).execute()}ee.exports=L},function(ee,b,w){var k=w(0);function O(C,x){var E=0;return C.children.length?C.children.forEach(function(N){E+=O(N,x)}):E=C.height,C._subTreeSep=x.getSubTreeSep(C.data),C.totalHeight=Math.max(C.height,E)+2*C._subTreeSep,C.totalHeight}function R(C){var x=C.children,E=x.length;if(E){x.forEach(function(ie){R(ie)});var N=x[0],L=x[E-1],P=L.y-N.y+L.height,W=0;if(x.forEach(function(ie){W+=ie.totalHeight}),P>C.height)C.y=N.y+P/2-C.height/2;else if(x.length!==1||C.height>W){var Y=C.y+(C.height-P)/2-N.y;x.forEach(function(ie){ie.translate(0,Y)})}else C.y=(N.y+N.height/2+L.y+L.height/2)/2-C.height/2}}var S={getSubTreeSep:function(){return 0}};ee.exports=function(C,x){x===void 0&&(x={}),x=k.assign({},S,x),C.parent={x:0,width:0,height:0,y:0},C.BFTraverse(function(E){E.x=E.parent.x+E.parent.width}),C.parent=null,O(C,x),C.startY=0,C.y=C.totalHeight/2-C.height/2,C.eachNode(function(E){var N=E.children,L=N.length;if(L){var P=N[0];if(P.startY=E.startY+E._subTreeSep,L===1)P.y=E.y+E.height/2-P.height/2;else{P.y=P.startY+P.totalHeight/2-P.height/2;for(var W=1;W<L;W++){var Y=N[W];Y.startY=N[W-1].startY+N[W-1].totalHeight,Y.y=Y.startY+Y.totalHeight/2-Y.height/2}}}}),R(C)}}])})},15278:function(se,ee,b){"use strict";b.d(ee,{t:function(){return ae}});function w({map:ye,initKey:ue},Ne){const Te=ue(Ne);return ye.has(Te)?ye.get(Te):Ne}function k({map:ye,initKey:ue},Ne){const Te=ue(Ne);return ye.has(Te)?ye.get(Te):(ye.set(Te,Ne),Ne)}function O({map:ye,initKey:ue},Ne){const Te=ue(Ne);return ye.has(Te)&&(Ne=ye.get(Te),ye.delete(Te)),Ne}function R(ye){return typeof ye=="object"?ye.valueOf():ye}class S extends Map{constructor(ue){if(super(),this.map=new Map,this.initKey=R,ue!==null)for(const[Ne,Te]of ue)this.set(Ne,Te)}get(ue){return super.get(w({map:this.map,initKey:this.initKey},ue))}has(ue){return super.has(w({map:this.map,initKey:this.initKey},ue))}set(ue,Ne){return super.set(k({map:this.map,initKey:this.initKey},ue),Ne)}delete(ue){return super.delete(O({map:this.map,initKey:this.initKey},ue))}}var C=b(74271);const x=Symbol("defaultUnknown");function E(ye,ue,Ne){for(let Te=0;Te<ue.length;Te+=1)ye.has(ue[Te])||ye.set(Ne(ue[Te]),Te)}function N(ye){const{value:ue,from:Ne,to:Te,mapper:_e,notFoundReturn:Xe}=ye;let Se=_e.get(ue);if(Se===void 0){if(Xe!==x)return Xe;Se=Ne.push(ue)-1,_e.set(ue,Se)}return Te[Se%Te.length]}function L(ye){return ye instanceof Date?ue=>`${ue}`:typeof ye=="object"?ue=>JSON.stringify(ue):ue=>ue}class P extends C.X{getDefaultOptions(){return{domain:[],range:[],unknown:x}}constructor(ue){super(ue)}map(ue){return this.domainIndexMap.size===0&&E(this.domainIndexMap,this.getDomain(),this.domainKey),N({value:this.domainKey(ue),mapper:this.domainIndexMap,from:this.getDomain(),to:this.getRange(),notFoundReturn:this.options.unknown})}invert(ue){return this.rangeIndexMap.size===0&&E(this.rangeIndexMap,this.getRange(),this.rangeKey),N({value:this.rangeKey(ue),mapper:this.rangeIndexMap,from:this.getRange(),to:this.getDomain(),notFoundReturn:this.options.unknown})}rescale(ue){const[Ne]=this.options.domain,[Te]=this.options.range;if(this.domainKey=L(Ne),this.rangeKey=L(Te),!this.rangeIndexMap){this.rangeIndexMap=new Map,this.domainIndexMap=new Map;return}(!ue||ue.range)&&this.rangeIndexMap.clear(),(!ue||ue.domain||ue.compare)&&(this.domainIndexMap.clear(),this.sortedDomain=void 0)}clone(){return new P(this.options)}getRange(){return this.options.range}getDomain(){if(this.sortedDomain)return this.sortedDomain;const{domain:ue,compare:Ne}=this.options;return this.sortedDomain=Ne?[...ue].sort(Ne):ue,this.sortedDomain}}function W(ye){const ue=Math.min(...ye);return ye.map(Ne=>Ne/ue)}function Y(ye,ue){const Ne=ye.length,Te=ue-Ne;return Te>0?[...ye,...new Array(Te).fill(1)]:Te<0?ye.slice(0,ue):ye}function ie(ye){return Math.round(ye*1e12)/1e12}function pe(ye){const{domain:ue,range:Ne,paddingOuter:Te,paddingInner:_e,flex:Xe,round:Se,align:Ge}=ye,He=ue.length,vt=Y(Xe,He),[It,zt]=Ne,Yt=zt-It,At=2/He*Te+1-1/He*_e,lt=Yt/At,Ot=lt*_e/He,le=lt-He*Ot,Fe=W(vt),gt=Fe.reduce((wt,Be)=>wt+Be),Jt=le/gt,Ze=new S(ue.map((wt,Be)=>{const ut=Fe[Be]*Jt;return[wt,Se?Math.floor(ut):ut]})),rt=new S(ue.map((wt,Be)=>{const Et=Fe[Be]*Jt+Ot;return[wt,Se?Math.floor(Et):Et]})),Mt=Array.from(rt.values()).reduce((wt,Be)=>wt+Be),Ye=(Yt-(Mt-Mt/He*_e))*Ge,be=It+Ye;let ge=Se?Math.round(be):be;const Ke=new Array(He);for(let wt=0;wt<He;wt+=1){Ke[wt]=ie(ge);const Be=ue[wt];ge+=rt.get(Be)}return{valueBandWidth:Ze,valueStep:rt,adjustedRange:Ke}}function fe(ye){var ue;const{domain:Ne}=ye,Te=Ne.length;if(Te===0)return{valueBandWidth:void 0,valueStep:void 0,adjustedRange:[]};if(!!(!((ue=ye.flex)===null||ue===void 0)&&ue.length))return pe(ye);const{range:Xe,paddingOuter:Se,paddingInner:Ge,round:He,align:vt}=ye;let It,zt,Yt=Xe[0];const lt=Xe[1]-Yt,Ot=Se*2,le=Te-Ge;It=lt/Math.max(1,Ot+le),He&&(It=Math.floor(It)),Yt+=(lt-It*(Te-Ge))*vt,zt=It*(1-Ge),He&&(Yt=Math.round(Yt),zt=Math.round(zt));const Fe=new Array(Te).fill(0).map((gt,Jt)=>Yt+Jt*It);return{valueStep:It,valueBandWidth:zt,adjustedRange:Fe}}class ae extends P{getDefaultOptions(){return{domain:[],range:[0,1],align:.5,round:!1,paddingInner:0,paddingOuter:0,padding:0,unknown:x,flex:[]}}constructor(ue){super(ue)}clone(){return new ae(this.options)}getStep(ue){return this.valueStep===void 0?1:typeof this.valueStep=="number"?this.valueStep:ue===void 0?Array.from(this.valueStep.values())[0]:this.valueStep.get(ue)}getBandWidth(ue){return this.valueBandWidth===void 0?1:typeof this.valueBandWidth=="number"?this.valueBandWidth:ue===void 0?Array.from(this.valueBandWidth.values())[0]:this.valueBandWidth.get(ue)}getRange(){return this.adjustedRange}getPaddingInner(){const{padding:ue,paddingInner:Ne}=this.options;return ue>0?ue:Ne}getPaddingOuter(){const{padding:ue,paddingOuter:Ne}=this.options;return ue>0?ue:Ne}rescale(){super.rescale();const{align:ue,domain:Ne,range:Te,round:_e,flex:Xe}=this.options,{adjustedRange:Se,valueBandWidth:Ge,valueStep:He}=fe({align:ue,range:Te,round:_e,flex:Xe,paddingInner:this.getPaddingInner(),paddingOuter:this.getPaddingOuter(),domain:Ne});this.valueStep=He,this.valueBandWidth=Ge,this.adjustedRange=Se}}},74271:function(se,ee,b){"use strict";b.d(ee,{X:function(){return k}});var w=b(83787);class k{constructor(R){this.options=(0,w.Z)({},this.getDefaultOptions()),this.update(R)}getOptions(){return this.options}update(R={}){this.options=(0,w.Z)({},this.options,R),this.rescale(R)}rescale(R){}}},53715:function(se,ee,b){"use strict";b.d(ee,{b:function(){return Yt}});var w=function(At){return At},k=b(74271);function O(At,lt){return lt-At?Ot=>(Ot-At)/(lt-At):Ot=>.5}function R(At,...lt){return lt.reduce((Ot,le)=>Fe=>Ot(le(Fe)),At)}function S(At,lt,Ot,le,Fe){let gt=Ot||0,Jt=le||At.length;const Ze=Fe||(rt=>rt);for(;gt<Jt;){const rt=Math.floor((gt+Jt)/2);Ze(At[rt])>lt?Jt=rt:gt=rt+1}return gt}var C=b(19818),x=b.n(C);function E(At,lt,Ot){let le=Ot;return le<0&&(le+=1),le>1&&(le-=1),le<1/6?At+(lt-At)*6*le:le<1/2?lt:le<2/3?At+(lt-At)*(2/3-le)*6:At}function N(At){const lt=At[0]/360,Ot=At[1]/100,le=At[2]/100,Fe=At[3];if(Ot===0)return[le*255,le*255,le*255,Fe];const gt=le<.5?le*(1+Ot):le+Ot-le*Ot,Jt=2*le-gt,Ze=E(Jt,gt,lt+1/3),rt=E(Jt,gt,lt),Mt=E(Jt,gt,lt-1/3);return[Ze*255,rt*255,Mt*255,Fe]}function L(At){const lt=x().get(At);if(!lt)return null;const{model:Ot,value:le}=lt;return Ot==="rgb"?le:Ot==="hsl"?N(le):null}const P=(At,lt)=>Ot=>At*(1-Ot)+lt*Ot,W=(At,lt)=>{const Ot=L(At),le=L(lt);return Ot===null||le===null?Ot?()=>At:()=>lt:Fe=>{const gt=new Array(4);for(let Ue=0;Ue<4;Ue+=1){const Ye=Ot[Ue],be=le[Ue];gt[Ue]=Ye*(1-Fe)+be*Fe}const[Jt,Ze,rt,Mt]=gt;return`rgba(${Math.round(Jt)}, ${Math.round(Ze)}, ${Math.round(rt)}, ${Mt})`}},Y=(At,lt)=>typeof At=="number"&&typeof lt=="number"?P(At,lt):typeof At=="string"&&typeof lt=="string"?W(At,lt):()=>At,ie=(At,lt)=>{const Ot=P(At,lt);return le=>Math.round(Ot(le))};var pe=b(71154);function fe(At){return At===null}function ae(At){return!(0,pe.Z)(At)&&!fe(At)&&!Number.isNaN(At)}const ye=Math.sqrt(50),ue=Math.sqrt(10),Ne=Math.sqrt(2);function Te(At,lt,Ot){const le=(lt-At)/Math.max(0,Ot),Fe=Math.floor(Math.log(le)/Math.LN10),gt=le/ip(10,Fe);return Fe>=0?(gt>=ye?10:gt>=ue?5:gt>=Ne?2:1)*ip(10,Fe):-ip(10,-Fe)/(gt>=ye?10:gt>=ue?5:gt>=Ne?2:1)}function _e(At,lt,Ot){const le=Math.abs(lt-At)/Math.max(0,Ot);let Fe=ip(10,Math.floor(Math.log(le)/Math.LN10));const gt=le/Fe;return gt>=ye?Fe*=10:gt>=ue?Fe*=5:gt>=Ne&&(Fe*=2),lt<At?-Fe:Fe}const Xe=(At,lt,Ot=5)=>{const le=[At,lt];let Fe=0,gt=le.length-1,Jt=le[Fe],Ze=le[gt],rt;return Ze<Jt&&([Jt,Ze]=[Ze,Jt],[Fe,gt]=[gt,Fe]),rt=Te(Jt,Ze,Ot),rt>0?(Jt=Math.floor(Jt/rt)*rt,Ze=Math.ceil(Ze/rt)*rt,rt=Te(Jt,Ze,Ot)):rt<0&&(Jt=Math.ceil(Jt*rt)/rt,Ze=Math.floor(Ze*rt)/rt,rt=Te(Jt,Ze,Ot)),rt>0?(le[Fe]=Math.floor(Jt/rt)*rt,le[gt]=Math.ceil(Ze/rt)*rt):rt<0&&(le[Fe]=Math.ceil(Jt*rt)/rt,le[gt]=Math.floor(Ze*rt)/rt),le};function Se(At,lt){const Ot=lt<At?lt:At,le=At>lt?At:lt;return Fe=>Math.min(Math.max(Ot,Fe),le)}const Ge=(At,lt,Ot)=>{const[le,Fe]=At,[gt,Jt]=lt;let Ze,rt;return le<Fe?(Ze=O(le,Fe),rt=Ot(gt,Jt)):(Ze=O(Fe,le),rt=Ot(Jt,gt)),R(rt,Ze)},He=(At,lt,Ot)=>{const le=Math.min(At.length,lt.length)-1,Fe=new Array(le),gt=new Array(le),Jt=At[0]>At[le],Ze=Jt?[...At].reverse():At,rt=Jt?[...lt].reverse():lt;for(let Mt=0;Mt<le;Mt+=1)Fe[Mt]=O(Ze[Mt],Ze[Mt+1]),gt[Mt]=Ot(rt[Mt],rt[Mt+1]);return Mt=>{const Ue=S(At,Mt,1,le)-1,Ye=Fe[Ue],be=gt[Ue];return R(be,Ye)(Mt)}},vt=(At,lt,Ot,le)=>(Math.min(At.length,lt.length)>2?He:Ge)(At,lt,le?ie:Ot);class It extends k.X{getDefaultOptions(){return{domain:[0,1],range:[0,1],nice:!1,clamp:!1,round:!1,interpolate:P,tickCount:5}}map(lt){return ae(lt)?this.output(lt):this.options.unknown}invert(lt){return ae(lt)?this.input(lt):this.options.unknown}nice(){if(!this.options.nice)return;const[lt,Ot,le,...Fe]=this.getTickMethodOptions();this.options.domain=this.chooseNice()(lt,Ot,le,...Fe)}getTicks(){const{tickMethod:lt}=this.options,[Ot,le,Fe,...gt]=this.getTickMethodOptions();return lt(Ot,le,Fe,...gt)}getTickMethodOptions(){const{domain:lt,tickCount:Ot}=this.options,le=lt[0],Fe=lt[lt.length-1];return[le,Fe,Ot]}chooseNice(){return Xe}rescale(){this.nice();const[lt,Ot]=this.chooseTransforms();this.composeOutput(lt,this.chooseClamp(lt)),this.composeInput(lt,Ot,this.chooseClamp(Ot))}chooseClamp(lt){const{clamp:Ot,range:le}=this.options,Fe=this.options.domain.map(lt),gt=Math.min(Fe.length,le.length);return Ot?Se(Fe[0],Fe[gt-1]):w}composeOutput(lt,Ot){const{domain:le,range:Fe,round:gt,interpolate:Jt}=this.options,Ze=vt(le.map(lt),Fe,Jt,gt);this.output=R(Ze,Ot,lt)}composeInput(lt,Ot,le){const{domain:Fe,range:gt}=this.options,Jt=vt(gt,Fe.map(lt),P);this.input=R(Ot,le,Jt)}}const zt=(At,lt,Ot)=>{let le,Fe,gt=At,Jt=lt;if(gt===Jt&&Ot>0)return[gt];let Ze=Te(gt,Jt,Ot);if(Ze===0||!Number.isFinite(Ze))return[];if(Ze>0){gt=Math.ceil(gt/Ze),Jt=Math.floor(Jt/Ze),Fe=new Array(le=Math.ceil(Jt-gt+1));for(let rt=0;rt<le;rt+=1)Fe[rt]=(gt+rt)*Ze}else{Ze=-Ze,gt=Math.ceil(gt*Ze),Jt=Math.floor(Jt*Ze),Fe=new Array(le=Math.ceil(Jt-gt+1));for(let rt=0;rt<le;rt+=1)Fe[rt]=(gt+rt)/Ze}return Fe};class Yt extends It{getDefaultOptions(){return{domain:[0,1],range:[0,1],unknown:void 0,nice:!1,clamp:!1,round:!1,interpolate:Y,tickMethod:zt,tickCount:5}}chooseTransforms(){return[w,w]}clone(){return new Yt(this.options)}}},88204:function(se,ee,b){"use strict";b.d(ee,{L:function(){return w}});function w(k){var O=document.createElement("div");O.innerHTML=k;var R=O.childNodes[0];return R&&O.contains(R)&&O.removeChild(R),R}},81957:function(se,ee){"use strict";var b=function(w,k,O){return w<k?k:w>O?O:w};ee.Z=b},83207:function(se,ee,b){"use strict";var w=b(44978),k=function(O){if(typeof O!="object"||O===null)return O;var R;if((0,w.Z)(O)){R=[];for(var S=0,C=O.length;S<C;S++)typeof O[S]=="object"&&O[S]!=null?R[S]=k(O[S]):R[S]=O[S]}else{R={};for(var x in O)typeof O[x]=="object"&&O[x]!=null?R[x]=k(O[x]):R[x]=O[x]}return R};ee.Z=k},68040:function(se,ee){"use strict";function b(w,k,O){var R;return function(){var S=this,C=arguments,x=function(){R=null,O||w.apply(S,C)},E=O&&!R;clearTimeout(R),R=setTimeout(x,k),E&&w.apply(S,C)}}ee.Z=b},83787:function(se,ee,b){"use strict";var w=b(44978),k=b(83845),O=5;function R(x,E){if(Object.hasOwn)return Object.hasOwn(x,E);if(x==null)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(Object(x),E)}function S(x,E,N,L){N=N||0,L=L||O;for(var P in E)if(R(E,P)){var W=E[P];W!==null&&(0,k.Z)(W)?((0,k.Z)(x[P])||(x[P]={}),N<L?S(x[P],W,N+1,L):x[P]=E[P]):(0,w.Z)(W)?(x[P]=[],x[P]=x[P].concat(W)):W!==void 0&&(x[P]=W)}}var C=function(x){for(var E=[],N=1;N<arguments.length;N++)E[N-1]=arguments[N];for(var L=0;L<E.length;L+=1)S(x,E[L]);return x};ee.Z=C},50814:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return x}});var w=b(82844),k=function(E,N){if(!(0,w.Z)(E))return E;for(var L=[],P=0;P<E.length;P++){var W=E[P];N(W,P)&&L.push(W)}return L},O=k,R=function(E,N){return(0,w.Z)(E)?E.indexOf(N)>-1:!1},S=R,C=function(E,N){return N===void 0&&(N=[]),O(E,function(L){return!S(N,L)})},x=C},15255:function(se,ee,b){"use strict";var w=b(44978),k=b(4637);function O(R,S){if(R){var C;if((0,w.Z)(R))for(var x=0,E=R.length;x<E&&(C=S(R[x],x),C!==!1);x++);else if((0,k.Z)(R)){for(var N in R)if(R.hasOwnProperty(N)&&(C=S(R[N],N),C===!1))break}}}ee.Z=O},53032:function(se,ee,b){"use strict";var w=b(76714);ee.Z=function(k,O,R){for(var S=0,C=(0,w.Z)(O)?O.split("."):O;k&&S<C.length;)k=k[C[S++]];return k===void 0||S<C.length?R:k}},73584:function(se,ee,b){"use strict";var w=b(44978),k=b(45607),O=Object.prototype.hasOwnProperty;function R(S,C){if(!C||!(0,w.Z)(S))return{};for(var x={},E=(0,k.Z)(C)?C:function(W){return W[C]},N,L=0;L<S.length;L++){var P=S[L];N=E(P),O.call(x,N)?x[N].push(P):x[N]=[P]}return x}ee.Z=R},82844:function(se,ee){"use strict";var b=function(w){return w!==null&&typeof w!="function"&&isFinite(w.length)};ee.Z=b},44978:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(k){return Array.isArray(k)}},90134:function(se,ee,b){"use strict";var w=b(95456),k=function(O){return(0,w.Z)(O,"Boolean")};ee.Z=k},69246:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(k){return k instanceof Date}},95904:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return P}});var w=b(95147),k=b(82844),O={}.toString,R=function(W){return O.call(W).replace(/^\[object /,"").replace(/]$/,"")},S=R,C=Object.prototype,x=function(W){var Y=W&&W.constructor,ie=typeof Y=="function"&&Y.prototype||C;return W===ie},E=x,N=Object.prototype.hasOwnProperty;function L(W){if((0,w.Z)(W))return!0;if((0,k.Z)(W))return!W.length;var Y=S(W);if(Y==="Map"||Y==="Set")return!W.size;if(E(W))return!Object.keys(W).length;for(var ie in W)if(N.call(W,ie))return!1;return!0}var P=L},30335:function(se,ee,b){"use strict";var w=b(6241),k=b(82844),O=b(76714),R=function(S,C){if(S===C)return!0;if(!S||!C||(0,O.Z)(S)||(0,O.Z)(C))return!1;if((0,k.Z)(S)||(0,k.Z)(C)){if(S.length!==C.length)return!1;for(var x=!0,E=0;E<S.length&&(x=R(S[E],C[E]),!!x);E++);return x}if((0,w.Z)(S)||(0,w.Z)(C)){var N=Object.keys(S),L=Object.keys(C);if(N.length!==L.length)return!1;for(var x=!0,E=0;E<N.length&&(x=R(S[N[E]],C[N[E]]),!!x);E++);return x}return!1};ee.Z=R},45607:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(k){return typeof k=="function"}},95147:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(k){return k==null}},80450:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return k}});var w=1e-5;function k(O,R,S){return S===void 0&&(S=w),O===R||Math.abs(O-R)<S}},25897:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(k){return typeof k=="number"}},6241:function(se,ee){"use strict";var b=function(w){return typeof w=="object"&&w!==null};ee.Z=b},4637:function(se,ee){"use strict";ee.Z=function(b){var w=typeof b;return b!==null&&w==="object"||w==="function"}},83845:function(se,ee,b){"use strict";var w=b(6241),k=b(95456),O=function(R){if(!(0,w.Z)(R)||!(0,k.Z)(R,"Object"))return!1;if(Object.getPrototypeOf(R)===null)return!0;for(var S=R;Object.getPrototypeOf(S)!==null;)S=Object.getPrototypeOf(S);return Object.getPrototypeOf(R)===S};ee.Z=O},76714:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(k){return typeof k=="string"}},95456:function(se,ee){"use strict";var b={}.toString,w=function(k,O){return b.call(k)==="[object "+O+"]"};ee.Z=w},71154:function(se,ee){"use strict";var b=function(w){return w===void 0};ee.Z=b},73576:function(se,ee,b){"use strict";var w=b(92123),k=function(O){var R=(0,w.Z)(O);return R.charAt(0).toLowerCase()+R.substring(1)};ee.Z=k},93442:function(se,ee,b){"use strict";var w=b(44978),k=b(45607);ee.Z=function(O,R){if((0,w.Z)(O)){for(var S,C=-1/0,x=0;x<O.length;x++){var E=O[x],N=(0,k.Z)(R)?R(E):E[R];N>C&&(S=E,C=N)}return S}}},13882:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(k){if(!Array.isArray(k))return-1/0;var O=k.length;if(!O)return-1/0;for(var R=k[0],S=1;S<O;S++)R=Math.max(R,k[S]);return R}},92426:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return O}});function w(R){var S,C,x,E=R||1;function N(P,W){++S>E&&(x=C,L(1),++S),C[P]=W}function L(P){S=0,C=Object.create(null),P||(x=Object.create(null))}return L(),{clear:L,has:function(P){return C[P]!==void 0||x[P]!==void 0},get:function(P){var W=C[P];if(W!==void 0)return W;if((W=x[P])!==void 0)return N(P,W),W},set:function(P,W){C[P]!==void 0?C[P]=W:N(P,W)}}}var k=new Map;function O(R,S,C){C===void 0&&(C=128);var x=function(){for(var E=[],N=0;N<arguments.length;N++)E[N]=arguments[N];var L=S?S.apply(this,E):E[0];k.has(R)||k.set(R,w(C));var P=k.get(R);if(P.has(L))return P.get(L);var W=R.apply(this,E);return P.set(L,W),W};return x}},89372:function(se,ee,b){"use strict";var w=b(44978),k=b(45607);ee.Z=function(O,R){if((0,w.Z)(O)){for(var S,C=1/0,x=0;x<O.length;x++){var E=O[x],N=(0,k.Z)(R)?R(E):E[R];N<C&&(S=E,C=N)}return S}}},71523:function(se,ee,b){"use strict";var w=b(44978);ee.Z=function(k){if((0,w.Z)(k))return k.reduce(function(O,R){return Math.min(O,R)},k[0])}},8614:function(se,ee){"use strict";var b=function(w,k){return(w%k+k)%k};ee.Z=b},13279:function(se,ee){"use strict";ee.Z=function(){}},35278:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return C}});var w=b(15255),k=b(44978),O=b(83845),R=function(x,E,N){if(!(0,k.Z)(x)&&!(0,O.Z)(x))return x;var L=N;return(0,w.Z)(x,function(P,W){L=E(L,P,W)}),L},S=R,C=function(x,E){return S(x,function(N,L,P){return E.includes(P)||(N[P]=L),N},{})}},23413:function(se,ee,b){"use strict";var w=b(15255),k=b(83845),O=Object.prototype.hasOwnProperty;ee.Z=function(R,S){if(R===null||!(0,k.Z)(R))return{};var C={};return(0,w.Z)(S,function(x){O.call(R,x)&&(C[x]=R[x])}),C}},17829:function(se,ee,b){"use strict";var w=b(4637),k=b(76714),O=b(25897);ee.Z=function(R,S,C){var x=R,E=(0,k.Z)(S)?S.split("."):S;return E.forEach(function(N,L){L<E.length-1?((0,w.Z)(x[N])||(x[N]=(0,O.Z)(E[L+1])?[]:{}),x=x[N]):x[N]=C}),R}},68856:function(se,ee){"use strict";function b(w,k){return!w||!k?w:w.replace(/\\?\{([^{}]+)\}/g,function(O,R){return O.charAt(0)==="\\"?O.slice(1):k[R]===void 0?"":k[R]})}ee.Z=b},99711:function(se,ee){"use strict";ee.Z=function(b,w,k){var O,R,S,C,x=0;k||(k={});var E=function(){x=k.leading===!1?0:Date.now(),O=null,C=b.apply(R,S),O||(R=S=null)},N=function(){var L=Date.now();!x&&k.leading===!1&&(x=L);var P=w-(L-x);return R=this,S=arguments,P<=0||P>w?(O&&(clearTimeout(O),O=null),x=L,C=b.apply(R,S),O||(R=S=null)):!O&&k.trailing!==!1&&(O=setTimeout(E,P)),C};return N.cancel=function(){clearTimeout(O),x=0,O=R=S=null},N}},92123:function(se,ee,b){"use strict";var w=b(95147);ee.Z=function(k){return(0,w.Z)(k)?"":k.toString()}},58029:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(k,O){O===void 0&&(O=new Map);var R=[];if(Array.isArray(k))for(var S=0,C=k.length;S<C;S++){var x=k[S];O.has(x)||(R.push(x),O.set(x,!0))}return R}},71701:function(se,ee){"use strict";var b={};ee.Z=function(w){return w=w||"g",b[w]?b[w]+=1:b[w]=1,w+b[w]}},83914:function(se,ee,b){"use strict";var w=b(92123),k=function(O){var R=(0,w.Z)(O);return R.charAt(0).toUpperCase()+R.substring(1)};ee.Z=k},75839:function(se,ee,b){"use strict";b.d(ee,{Y:function(){return W}});var w=b(97582),k=b(64985);function O(Y,ie,pe){if(Y[pe].length>7){Y[pe].shift();for(var fe=Y[pe],ae=pe;fe.length;)ie[pe]="A",Y.splice(ae+=1,0,["C"].concat(fe.splice(0,6)));Y.splice(pe,1)}}var R=b(4848),S=b(11013);function C(Y){return(0,S.y)(Y)&&Y.every(function(ie){var pe=ie[0];return"MC".includes(pe)})}var x=b(74873);function E(Y,ie,pe,fe,ae,ye){var ue=.3333333333333333,Ne=2/3;return[ue*Y+Ne*pe,ue*ie+Ne*fe,ue*ae+Ne*pe,ue*ye+Ne*fe,ae,ye]}var N=b(17570),L=function(Y,ie,pe,fe){var ae=.5,ye=(0,N.k)([Y,ie],[pe,fe],ae);return(0,w.ev)((0,w.ev)([],ye,!0),[pe,fe,pe,fe],!1)};function P(Y,ie){var pe=Y[0],fe=Y.slice(1).map(Number),ae=fe[0],ye=fe[1],ue,Ne=ie.x1,Te=ie.y1,_e=ie.x,Xe=ie.y;switch("TQ".includes(pe)||(ie.qx=null,ie.qy=null),pe){case"M":return ie.x=ae,ie.y=ye,Y;case"A":return ue=[Ne,Te].concat(fe),["C"].concat((0,x.W)(ue[0],ue[1],ue[2],ue[3],ue[4],ue[5],ue[6],ue[7],ue[8],ue[9]));case"Q":return ie.qx=ae,ie.qy=ye,ue=[Ne,Te].concat(fe),["C"].concat(E(ue[0],ue[1],ue[2],ue[3],ue[4],ue[5]));case"L":return["C"].concat(L(Ne,Te,ae,ye));case"Z":return Ne===_e&&Te===Xe?["C",Ne,Te,_e,Xe,_e,Xe]:["C"].concat(L(Ne,Te,_e,Xe));default:}return Y}function W(Y,ie){if(ie===void 0&&(ie=!1),C(Y)){var pe=[].concat(Y);return ie?[pe,[]]:pe}for(var fe=(0,R.A)(Y),ae=(0,w.pi)({},k.z),ye=[],ue="",Ne=fe.length,Te,_e,Xe=[],Se=0;Se<Ne;Se+=1){fe[Se]&&(ue=fe[Se][0]),ye[Se]=ue;var Ge=P(fe[Se],ae);fe[Se]=Ge,O(fe,ye,Se),Ne=fe.length,ue==="Z"&&Xe.push(Se),Te=fe[Se],_e=Te.length,ae.x1=+Te[_e-2],ae.y1=+Te[_e-1],ae.x2=+Te[_e-4]||ae.x1,ae.y2=+Te[_e-3]||ae.y1}return ie?[fe,Xe]:fe}},18323:function(se,ee,b){"use strict";b.d(ee,{R:function(){return w}});var w={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0}},64985:function(se,ee,b){"use strict";b.d(ee,{z:function(){return w}});var w={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null}},74873:function(se,ee,b){"use strict";b.d(ee,{W:function(){return k}});function w(O,R,S){var C=O*Math.cos(S)-R*Math.sin(S),x=O*Math.sin(S)+R*Math.cos(S);return{x:C,y:x}}function k(O,R,S,C,x,E,N,L,P,W){var Y=O,ie=R,pe=S,fe=C,ae=L,ye=P,ue=Math.PI*120/180,Ne=Math.PI/180*(+x||0),Te=[],_e,Xe,Se,Ge,He;if(W)Xe=W[0],Se=W[1],Ge=W[2],He=W[3];else{_e=w(Y,ie,-Ne),Y=_e.x,ie=_e.y,_e=w(ae,ye,-Ne),ae=_e.x,ye=_e.y;var vt=(Y-ae)/2,It=(ie-ye)/2,zt=vt*vt/(pe*pe)+It*It/(fe*fe);zt>1&&(zt=Math.sqrt(zt),pe*=zt,fe*=zt);var Yt=pe*pe,At=fe*fe,lt=(E===N?-1:1)*Math.sqrt(Math.abs((Yt*At-Yt*It*It-At*vt*vt)/(Yt*It*It+At*vt*vt)));Ge=lt*pe*It/fe+(Y+ae)/2,He=lt*-fe*vt/pe+(ie+ye)/2,Xe=Math.asin(((ie-He)/fe*Math.pow(10,9)>>0)/Math.pow(10,9)),Se=Math.asin(((ye-He)/fe*Math.pow(10,9)>>0)/Math.pow(10,9)),Xe=Y<Ge?Math.PI-Xe:Xe,Se=ae<Ge?Math.PI-Se:Se,Xe<0&&(Xe=Math.PI*2+Xe),Se<0&&(Se=Math.PI*2+Se),N&&Xe>Se&&(Xe-=Math.PI*2),!N&&Se>Xe&&(Se-=Math.PI*2)}var Ot=Se-Xe;if(Math.abs(Ot)>ue){var le=Se,Fe=ae,gt=ye;Se=Xe+ue*(N&&Se>Xe?1:-1),ae=Ge+pe*Math.cos(Se),ye=He+fe*Math.sin(Se),Te=k(ae,ye,pe,fe,x,0,N,Fe,gt,[Se,le,Ge,He])}Ot=Se-Xe;var Jt=Math.cos(Xe),Ze=Math.sin(Xe),rt=Math.cos(Se),Mt=Math.sin(Se),Ue=Math.tan(Ot/4),Ye=4/3*pe*Ue,be=4/3*fe*Ue,ge=[Y,ie],Ke=[Y+Ye*Ze,ie-be*Jt],wt=[ae+Ye*Mt,ye-be*rt],Be=[ae,ye];if(Ke[0]=2*ge[0]-Ke[0],Ke[1]=2*ge[1]-Ke[1],W)return Ke.concat(wt,Be,Te);Te=Ke.concat(wt,Be,Te);for(var ut=[],Et=0,je=Te.length;Et<je;Et+=1)ut[Et]=Et%2?w(Te[Et-1],Te[Et],Ne).y:w(Te[Et],Te[Et+1],Ne).x;return ut}},28659:function(se,ee,b){"use strict";b.d(ee,{U:function(){return w}});function w(k){return k.map(function(O){return Array.isArray(O)?[].concat(O):O})}},4848:function(se,ee,b){"use strict";b.d(ee,{A:function(){return Te}});var w=b(97582),k=b(11013),O=b(64985),R=b(41010),S=b(56346),C=b(18323);function x(_e){for(var Xe=_e.pathValue[_e.segmentStart],Se=Xe.toLowerCase(),Ge=_e.data;Ge.length>=C.R[Se]&&(Se==="m"&&Ge.length>2?(_e.segments.push([Xe].concat(Ge.splice(0,2))),Se="l",Xe=Xe==="m"?"l":"L"):_e.segments.push([Xe].concat(Ge.splice(0,C.R[Se]))),!!C.R[Se]););}function E(_e){var Xe=_e.index,Se=_e.pathValue,Ge=Se.charCodeAt(Xe);if(Ge===48){_e.param=0,_e.index+=1;return}if(Ge===49){_e.param=1,_e.index+=1;return}_e.err='[path-util]: invalid Arc flag "'.concat(Se[Xe],'", expecting 0 or 1 at index ').concat(Xe)}function N(_e){return _e>=48&&_e<=57||_e===43||_e===45||_e===46}function L(_e){return _e>=48&&_e<=57}function P(_e){var Xe=_e.max,Se=_e.pathValue,Ge=_e.index,He=Ge,vt=!1,It=!1,zt=!1,Yt=!1,At;if(He>=Xe){_e.err="[path-util]: Invalid path value at index ".concat(He,', "pathValue" is missing param');return}if(At=Se.charCodeAt(He),(At===43||At===45)&&(He+=1,At=Se.charCodeAt(He)),!L(At)&&At!==46){_e.err="[path-util]: Invalid path value at index ".concat(He,', "').concat(Se[He],'" is not a number');return}if(At!==46){if(vt=At===48,He+=1,At=Se.charCodeAt(He),vt&&He<Xe&&At&&L(At)){_e.err="[path-util]: Invalid path value at index ".concat(Ge,', "').concat(Se[Ge],'" illegal number');return}for(;He<Xe&&L(Se.charCodeAt(He));)He+=1,It=!0;At=Se.charCodeAt(He)}if(At===46){for(Yt=!0,He+=1;L(Se.charCodeAt(He));)He+=1,zt=!0;At=Se.charCodeAt(He)}if(At===101||At===69){if(Yt&&!It&&!zt){_e.err="[path-util]: Invalid path value at index ".concat(He,', "').concat(Se[He],'" invalid float exponent');return}if(He+=1,At=Se.charCodeAt(He),(At===43||At===45)&&(He+=1),He<Xe&&L(Se.charCodeAt(He)))for(;He<Xe&&L(Se.charCodeAt(He));)He+=1;else{_e.err="[path-util]: Invalid path value at index ".concat(He,', "').concat(Se[He],'" invalid integer exponent');return}}_e.index=He,_e.param=+_e.pathValue.slice(Ge,He)}function W(_e){var Xe=[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279];return _e===10||_e===13||_e===8232||_e===8233||_e===32||_e===9||_e===11||_e===12||_e===160||_e>=5760&&Xe.includes(_e)}function Y(_e){for(var Xe=_e.pathValue,Se=_e.max;_e.index<Se&&W(Xe.charCodeAt(_e.index));)_e.index+=1}function ie(_e){switch(_e|32){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:return!0;default:return!1}}function pe(_e){return(_e|32)===97}function fe(_e){var Xe=_e.max,Se=_e.pathValue,Ge=_e.index,He=Se.charCodeAt(Ge),vt=C.R[Se[Ge].toLowerCase()];if(_e.segmentStart=Ge,!ie(He)){_e.err='[path-util]: Invalid path value "'.concat(Se[Ge],'" is not a path command');return}if(_e.index+=1,Y(_e),_e.data=[],!vt){x(_e);return}for(;;){for(var It=vt;It>0;It-=1){if(pe(He)&&(It===3||It===4)?E(_e):P(_e),_e.err.length)return;_e.data.push(_e.param),Y(_e),_e.index<Xe&&Se.charCodeAt(_e.index)===44&&(_e.index+=1,Y(_e))}if(_e.index>=_e.max||!N(Se.charCodeAt(_e.index)))break}x(_e)}var ae=function(){function _e(Xe){this.pathValue=Xe,this.segments=[],this.max=Xe.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""}return _e}();function ye(_e){if((0,S.n)(_e))return[].concat(_e);var Xe=new ae(_e);for(Y(Xe);Xe.index<Xe.max&&!Xe.err.length;)fe(Xe);return Xe.err?Xe.err:Xe.segments}function ue(_e){if((0,R.b)(_e))return[].concat(_e);var Xe=ye(_e),Se=0,Ge=0,He=0,vt=0;return Xe.map(function(It){var zt=It.slice(1).map(Number),Yt=It[0],At=Yt.toUpperCase();if(Yt==="M")return Se=zt[0],Ge=zt[1],He=Se,vt=Ge,["M",Se,Ge];var lt;if(Yt!==At)switch(At){case"A":lt=[At,zt[0],zt[1],zt[2],zt[3],zt[4],zt[5]+Se,zt[6]+Ge];break;case"V":lt=[At,zt[0]+Ge];break;case"H":lt=[At,zt[0]+Se];break;default:{var Ot=zt.map(function(Fe,gt){return Fe+(gt%2?Ge:Se)});lt=[At].concat(Ot)}}else lt=[At].concat(zt);var le=lt.length;switch(At){case"Z":Se=He,Ge=vt;break;case"H":Se=lt[1];break;case"V":Ge=lt[1];break;default:Se=lt[le-2],Ge=lt[le-1],At==="M"&&(He=Se,vt=Ge)}return lt})}function Ne(_e,Xe){var Se=_e[0],Ge=Xe.x1,He=Xe.y1,vt=Xe.x2,It=Xe.y2,zt=_e.slice(1).map(Number),Yt=_e;if("TQ".includes(Se)||(Xe.qx=null,Xe.qy=null),Se==="H")Yt=["L",_e[1],He];else if(Se==="V")Yt=["L",Ge,_e[1]];else if(Se==="S"){var At=Ge*2-vt,lt=He*2-It;Xe.x1=At,Xe.y1=lt,Yt=["C",At,lt].concat(zt)}else if(Se==="T"){var Ot=Ge*2-Xe.qx,le=He*2-Xe.qy;Xe.qx=Ot,Xe.qy=le,Yt=["Q",Ot,le].concat(zt)}else if(Se==="Q"){var Fe=zt[0],gt=zt[1];Xe.qx=Fe,Xe.qy=gt}return Yt}function Te(_e){if((0,k.y)(_e))return[].concat(_e);for(var Xe=ue(_e),Se=(0,w.pi)({},O.z),Ge=0;Ge<Xe.length;Ge+=1){Xe[Ge]=Ne(Xe[Ge],Se);var He=Xe[Ge],vt=He.length;Se.x1=+He[vt-2],Se.y1=+He[vt-1],Se.x2=+He[vt-4]||Se.x1,Se.y2=+He[vt-3]||Se.y1}return Xe}},65850:function(se,ee,b){"use strict";b.d(ee,{G:function(){return w}});function w(k){var O=k.slice(1).map(function(R,S,C){return S?C[S-1].slice(-2).concat(R.slice(1)):k[0].slice(1).concat(R.slice(1))}).map(function(R){return R.map(function(S,C){return R[R.length-C-2*(1-C%2)]})}).reverse();return[["M"].concat(O[0].slice(0,2))].concat(O.map(function(R){return["C"].concat(R.slice(2))}))}},44078:function(se,ee,b){"use strict";b.d(ee,{y:function(){return w}});function w(k,O){return Math.sqrt((k[0]-O[0])*(k[0]-O[0])+(k[1]-O[1])*(k[1]-O[1]))}},99872:function(se,ee,b){"use strict";b.d(ee,{x:function(){return S}});var w=b(17570),k=b(6489);function O(C,x){x===void 0&&(x=.5);var E=C.slice(0,2),N=C.slice(2,4),L=C.slice(4,6),P=C.slice(6,8),W=(0,w.k)(E,N,x),Y=(0,w.k)(N,L,x),ie=(0,w.k)(L,P,x),pe=(0,w.k)(W,Y,x),fe=(0,w.k)(Y,ie,x),ae=(0,w.k)(pe,fe,x);return[["C"].concat(W,pe,ae),["C"].concat(fe,ie,P)]}function R(C){return C.map(function(x,E,N){var L=E&&N[E-1].slice(-2).concat(x.slice(1)),P=E?(0,k.S)(L[0],L[1],L[2],L[3],L[4],L[5],L[6],L[7],L[8],{bbox:!1}).length:0,W;return E?W=P?O(L):[x,x]:W=[x],{s:x,ss:W,l:P}})}function S(C,x,E){var N=R(C),L=R(x),P=N.length,W=L.length,Y=N.filter(function(_e){return _e.l}).length,ie=L.filter(function(_e){return _e.l}).length,pe=N.filter(function(_e){return _e.l}).reduce(function(_e,Xe){var Se=Xe.l;return _e+Se},0)/Y||0,fe=L.filter(function(_e){return _e.l}).reduce(function(_e,Xe){var Se=Xe.l;return _e+Se},0)/ie||0,ae=E||Math.max(P,W),ye=[pe,fe],ue=[ae-P,ae-W],Ne=0,Te=[N,L].map(function(_e,Xe){return _e.l===ae?_e.map(function(Se){return Se.s}):_e.map(function(Se,Ge){return Ne=Ge&&ue[Xe]&&Se.l>=ye[Xe],ue[Xe]-=Ne?1:0,Ne?Se.ss:[Se.s]}).flat()});return Te[0].length===Te[1].length?Te:S(Te[0],Te[1],ae)}},92455:function(se,ee,b){"use strict";b.d(ee,{b:function(){return R}});var w=b(75839);function k(S,C,x,E,N,L,P,W){return 3*((W-C)*(x+N)-(P-S)*(E+L)+E*(S-N)-x*(C-L)+W*(N+S/3)-P*(L+C/3))/20}function O(S){var C=0,x=0,E=0;return(0,w.Y)(S).map(function(N){var L;switch(N[0]){case"M":return C=N[1],x=N[2],0;default:var P=N.slice(1),W=P[0],Y=P[1],ie=P[2],pe=P[3],fe=P[4],ae=P[5];return E=k(C,x,W,Y,ie,pe,fe,ae),L=N.slice(-2),C=L[0],x=L[1],E}}).reduce(function(N,L){return N+L},0)}function R(S){return O(S)>=0}},84329:function(se,ee,b){"use strict";b.d(ee,{r:function(){return O}});var w=b(97582),k=b(32262);function O(R,S,C){return(0,k.s)(R,S,(0,w.pi)((0,w.pi)({},C),{bbox:!1,length:!0})).point}},83555:function(se,ee,b){"use strict";b.d(ee,{g:function(){return O}});var w=b(44078);function k(R){var S=R.length,C=S-1;return R.map(function(x,E){return R.map(function(N,L){var P=E+L,W;return L===0||R[P]&&R[P][0]==="M"?(W=R[P],["M"].concat(W.slice(-2))):(P>=S&&(P-=C),R[P])})})}function O(R,S){var C=R.length-1,x=[],E=0,N=0,L=k(R);return L.forEach(function(P,W){R.slice(1).forEach(function(Y,ie){N+=(0,w.y)(R[(W+ie)%C].slice(-2),S[ie%C].slice(-2))}),x[W]=N,N=0}),E=x.indexOf(Math.min.apply(null,x)),L[E]}},69877:function(se,ee,b){"use strict";b.d(ee,{D:function(){return O}});var w=b(97582),k=b(32262);function O(R,S){return(0,k.s)(R,void 0,(0,w.pi)((0,w.pi)({},S),{bbox:!1,length:!0})).length}},41010:function(se,ee,b){"use strict";b.d(ee,{b:function(){return k}});var w=b(56346);function k(O){return(0,w.n)(O)&&O.every(function(R){var S=R[0];return S===S.toUpperCase()})}},11013:function(se,ee,b){"use strict";b.d(ee,{y:function(){return k}});var w=b(41010);function k(O){return(0,w.b)(O)&&O.every(function(R){var S=R[0];return"ACLMQZ".includes(S)})}},56346:function(se,ee,b){"use strict";b.d(ee,{n:function(){return k}});var w=b(18323);function k(O){return Array.isArray(O)&&O.every(function(R){var S=R[0].toLowerCase();return w.R[S]===R.length-1&&"achlmqstvz".includes(S)})}},17570:function(se,ee,b){"use strict";b.d(ee,{k:function(){return w}});function w(k,O,R){var S=k[0],C=k[1],x=O[0],E=O[1];return[S+(x-S)*R,C+(E-C)*R]}},32262:function(se,ee,b){"use strict";b.d(ee,{s:function(){return P}});var w=b(4848),k=b(17570),O=b(44078);function R(W,Y,ie,pe,fe){var ae=(0,O.y)([W,Y],[ie,pe]),ye={x:0,y:0};if(typeof fe=="number")if(fe<=0)ye={x:W,y:Y};else if(fe>=ae)ye={x:ie,y:pe};else{var ue=(0,k.k)([W,Y],[ie,pe],fe/ae),Ne=ue[0],Te=ue[1];ye={x:Ne,y:Te}}return{length:ae,point:ye,min:{x:Math.min(W,ie),y:Math.min(Y,pe)},max:{x:Math.max(W,ie),y:Math.max(Y,pe)}}}function S(W,Y){var ie=W.x,pe=W.y,fe=Y.x,ae=Y.y,ye=ie*fe+pe*ae,ue=Math.sqrt((Math.pow(ie,2)+Math.pow(pe,2))*(Math.pow(fe,2)+Math.pow(ae,2))),Ne=ie*ae-pe*fe<0?-1:1,Te=Ne*Math.acos(ye/ue);return Te}function C(W,Y,ie,pe,fe,ae,ye,ue,Ne,Te){var _e=Math.abs,Xe=Math.sin,Se=Math.cos,Ge=Math.sqrt,He=Math.PI,vt=_e(ie),It=_e(pe),zt=(fe%360+360)%360,Yt=zt*(He/180);if(W===ue&&Y===Ne)return{x:W,y:Y};if(vt===0||It===0)return R(W,Y,ue,Ne,Te).point;var At=(W-ue)/2,lt=(Y-Ne)/2,Ot={x:Se(Yt)*At+Xe(Yt)*lt,y:-Xe(Yt)*At+Se(Yt)*lt},le=Math.pow(Ot.x,2)/Math.pow(vt,2)+Math.pow(Ot.y,2)/Math.pow(It,2);le>1&&(vt*=Ge(le),It*=Ge(le));var Fe=Math.pow(vt,2)*Math.pow(It,2)-Math.pow(vt,2)*Math.pow(Ot.y,2)-Math.pow(It,2)*Math.pow(Ot.x,2),gt=Math.pow(vt,2)*Math.pow(Ot.y,2)+Math.pow(It,2)*Math.pow(Ot.x,2),Jt=Fe/gt;Jt=Jt<0?0:Jt;var Ze=(ae!==ye?1:-1)*Ge(Jt),rt={x:Ze*(vt*Ot.y/It),y:Ze*(-(It*Ot.x)/vt)},Mt={x:Se(Yt)*rt.x-Xe(Yt)*rt.y+(W+ue)/2,y:Xe(Yt)*rt.x+Se(Yt)*rt.y+(Y+Ne)/2},Ue={x:(Ot.x-rt.x)/vt,y:(Ot.y-rt.y)/It},Ye=S({x:1,y:0},Ue),be={x:(-Ot.x-rt.x)/vt,y:(-Ot.y-rt.y)/It},ge=S(Ue,be);!ye&&ge>0?ge-=2*He:ye&&ge<0&&(ge+=2*He),ge%=2*He;var Ke=Ye+ge*Te,wt=vt*Se(Ke),Be=It*Xe(Ke),ut={x:Se(Yt)*wt-Xe(Yt)*Be+Mt.x,y:Xe(Yt)*wt+Se(Yt)*Be+Mt.y};return ut}function x(W,Y,ie,pe,fe,ae,ye,ue,Ne,Te,_e){var Xe,Se=_e.bbox,Ge=Se===void 0?!0:Se,He=_e.length,vt=He===void 0?!0:He,It=_e.sampleSize,zt=It===void 0?30:It,Yt=typeof Te=="number",At=W,lt=Y,Ot=0,le=[At,lt,Ot],Fe=[At,lt],gt=0,Jt={x:0,y:0},Ze=[{x:At,y:lt}];Yt&&Te<=0&&(Jt={x:At,y:lt});for(var rt=0;rt<=zt;rt+=1){if(gt=rt/zt,Xe=C(W,Y,ie,pe,fe,ae,ye,ue,Ne,gt),At=Xe.x,lt=Xe.y,Ge&&Ze.push({x:At,y:lt}),vt&&(Ot+=(0,O.y)(Fe,[At,lt])),Fe=[At,lt],Yt&&Ot>=Te&&Te>le[2]){var Mt=(Ot-Te)/(Ot-le[2]);Jt={x:Fe[0]*(1-Mt)+le[0]*Mt,y:Fe[1]*(1-Mt)+le[1]*Mt}}le=[At,lt,Ot]}return Yt&&Te>=Ot&&(Jt={x:ue,y:Ne}),{length:Ot,point:Jt,min:{x:Math.min.apply(null,Ze.map(function(Ue){return Ue.x})),y:Math.min.apply(null,Ze.map(function(Ue){return Ue.y}))},max:{x:Math.max.apply(null,Ze.map(function(Ue){return Ue.x})),y:Math.max.apply(null,Ze.map(function(Ue){return Ue.y}))}}}var E=b(6489);function N(W,Y,ie,pe,fe,ae,ye){var ue=1-ye;return{x:Math.pow(ue,2)*W+2*ue*ye*ie+Math.pow(ye,2)*fe,y:Math.pow(ue,2)*Y+2*ue*ye*pe+Math.pow(ye,2)*ae}}function L(W,Y,ie,pe,fe,ae,ye,ue){var Ne,Te=ue.bbox,_e=Te===void 0?!0:Te,Xe=ue.length,Se=Xe===void 0?!0:Xe,Ge=ue.sampleSize,He=Ge===void 0?10:Ge,vt=typeof ye=="number",It=W,zt=Y,Yt=0,At=[It,zt,Yt],lt=[It,zt],Ot=0,le={x:0,y:0},Fe=[{x:It,y:zt}];vt&&ye<=0&&(le={x:It,y:zt});for(var gt=0;gt<=He;gt+=1){if(Ot=gt/He,Ne=N(W,Y,ie,pe,fe,ae,Ot),It=Ne.x,zt=Ne.y,_e&&Fe.push({x:It,y:zt}),Se&&(Yt+=(0,O.y)(lt,[It,zt])),lt=[It,zt],vt&&Yt>=ye&&ye>At[2]){var Jt=(Yt-ye)/(Yt-At[2]);le={x:lt[0]*(1-Jt)+At[0]*Jt,y:lt[1]*(1-Jt)+At[1]*Jt}}At=[It,zt,Yt]}return vt&&ye>=Yt&&(le={x:fe,y:ae}),{length:Yt,point:le,min:{x:Math.min.apply(null,Fe.map(function(Ze){return Ze.x})),y:Math.min.apply(null,Fe.map(function(Ze){return Ze.y}))},max:{x:Math.max.apply(null,Fe.map(function(Ze){return Ze.x})),y:Math.max.apply(null,Fe.map(function(Ze){return Ze.y}))}}}function P(W,Y,ie){for(var pe,fe,ae,ye,ue,Ne,Te=(0,w.A)(W),_e=typeof Y=="number",Xe,Se=[],Ge,He=0,vt=0,It=0,zt=0,Yt,At=[],lt=[],Ot=0,le={x:0,y:0},Fe=le,gt=le,Jt=le,Ze=0,rt=0,Mt=Te.length;rt<Mt;rt+=1)Yt=Te[rt],Ge=Yt[0],Xe=Ge==="M",Se=Xe?Se:[He,vt].concat(Yt.slice(1)),Xe?(It=Yt[1],zt=Yt[2],le={x:It,y:zt},Fe=le,Ot=0,_e&&Y<.001&&(Jt=le)):Ge==="L"?(pe=R(Se[0],Se[1],Se[2],Se[3],(Y||0)-Ze),Ot=pe.length,le=pe.min,Fe=pe.max,gt=pe.point):Ge==="A"?(fe=x(Se[0],Se[1],Se[2],Se[3],Se[4],Se[5],Se[6],Se[7],Se[8],(Y||0)-Ze,ie||{}),Ot=fe.length,le=fe.min,Fe=fe.max,gt=fe.point):Ge==="C"?(ae=(0,E.S)(Se[0],Se[1],Se[2],Se[3],Se[4],Se[5],Se[6],Se[7],(Y||0)-Ze,ie||{}),Ot=ae.length,le=ae.min,Fe=ae.max,gt=ae.point):Ge==="Q"?(ye=L(Se[0],Se[1],Se[2],Se[3],Se[4],Se[5],(Y||0)-Ze,ie||{}),Ot=ye.length,le=ye.min,Fe=ye.max,gt=ye.point):Ge==="Z"&&(Se=[He,vt,It,zt],ue=R(Se[0],Se[1],Se[2],Se[3],(Y||0)-Ze),Ot=ue.length,le=ue.min,Fe=ue.max,gt=ue.point),_e&&Ze<Y&&Ze+Ot>=Y&&(Jt=gt),lt.push(Fe),At.push(le),Ze+=Ot,Ne=Ge!=="Z"?Yt.slice(-2):[It,zt],He=Ne[0],vt=Ne[1];return _e&&Y>=Ze&&(Jt={x:He,y:vt}),{length:Ze,point:Jt,min:{x:Math.min.apply(null,At.map(function(Ue){return Ue.x})),y:Math.min.apply(null,At.map(function(Ue){return Ue.y}))},max:{x:Math.max.apply(null,lt.map(function(Ue){return Ue.x})),y:Math.max.apply(null,lt.map(function(Ue){return Ue.y}))}}}},6489:function(se,ee,b){"use strict";b.d(ee,{S:function(){return O}});var w=b(44078);function k(R,S,C,x,E,N,L,P,W){var Y=1-W;return{x:Math.pow(Y,3)*R+3*Math.pow(Y,2)*W*C+3*Y*Math.pow(W,2)*E+Math.pow(W,3)*L,y:Math.pow(Y,3)*S+3*Math.pow(Y,2)*W*x+3*Y*Math.pow(W,2)*N+Math.pow(W,3)*P}}function O(R,S,C,x,E,N,L,P,W,Y){var ie,pe=Y.bbox,fe=pe===void 0?!0:pe,ae=Y.length,ye=ae===void 0?!0:ae,ue=Y.sampleSize,Ne=ue===void 0?10:ue,Te=typeof W=="number",_e=R,Xe=S,Se=0,Ge=[_e,Xe,Se],He=[_e,Xe],vt=0,It={x:0,y:0},zt=[{x:_e,y:Xe}];Te&&W<=0&&(It={x:_e,y:Xe});for(var Yt=0;Yt<=Ne;Yt+=1){if(vt=Yt/Ne,ie=k(R,S,C,x,E,N,L,P,vt),_e=ie.x,Xe=ie.y,fe&&zt.push({x:_e,y:Xe}),ye&&(Se+=(0,w.y)(He,[_e,Xe])),He=[_e,Xe],Te&&Se>=W&&W>Ge[2]){var At=(Se-W)/(Se-Ge[2]);It={x:He[0]*(1-At)+Ge[0]*At,y:He[1]*(1-At)+Ge[1]*At}}Ge=[_e,Xe,Se]}return Te&&W>=Se&&(It={x:L,y:P}),{length:Se,point:It,min:{x:Math.min.apply(null,zt.map(function(lt){return lt.x})),y:Math.min.apply(null,zt.map(function(lt){return lt.y}))},max:{x:Math.max.apply(null,zt.map(function(lt){return lt.x})),y:Math.max.apply(null,zt.map(function(lt){return lt.y}))}}}},48202:function(se,ee,b){"use strict";var w,k=Object.defineProperty,O=Pe=>{throw TypeError(Pe)},R=Math.pow,S=(Pe,D,U)=>D in Pe?k(Pe,D,{enumerable:!0,configurable:!0,writable:!0,value:U}):Pe[D]=U,C=(Pe,D,U)=>S(Pe,typeof D!="symbol"?D+"":D,U),x=(Pe,D,U)=>D.has(Pe)||O("Cannot "+U),E=(Pe,D,U)=>(x(Pe,D,"read from private field"),U?U.call(Pe):D.get(Pe)),N=(Pe,D,U)=>D.has(Pe)?O("Cannot add the same private member more than once"):D instanceof WeakSet?D.add(Pe):D.set(Pe,U),L=(Pe,D,U,_)=>(x(Pe,D,"write to private field"),_?_.call(Pe,U):D.set(Pe,U),U),P=(Pe,D,U)=>(x(Pe,D,"access private method"),U),W,Y,ie;w={value:!0};var pe=b(44091),fe=b(75823);const ae=" ".repeat(2),ye=" ".repeat(4);function ue(){return Ne(this)}function Ne(Pe,D={}){const{maxRows:U=15,maxColumns:_=10,maxNumSize:F=8,padMinus:X="auto"}=D;return`${Pe.constructor.name} {
|
|
|
${ae}[
|
|
|
${ye}${Te(Pe,U,_,F,X)}
|
|
|
${ae}]
|
|
|
${ae}rows: ${Pe.rows}
|
|
|
${ae}columns: ${Pe.columns}
|
|
|
}`}function Te(Pe,D,U,_,F){const{rows:X,columns:Ie}=Pe,ke=Math.min(X,D),et=Math.min(Ie,U),nt=[];if(F==="auto"){F=!1;e:for(let Wt=0;Wt<ke;Wt++)for(let Tt=0;Tt<et;Tt++)if(Pe.get(Wt,Tt)<0){F=!0;break e}}for(let Wt=0;Wt<ke;Wt++){let Tt=[];for(let on=0;on<et;on++)Tt.push(_e(Pe.get(Wt,on),_,F));nt.push(`${Tt.join(" ")}`)}return et!==Ie&&(nt[nt.length-1]+=` ... ${Ie-U} more columns`),ke!==X&&nt.push(`... ${X-D} more rows`),nt.join(`
|
|
|
${ye}`)}function _e(Pe,D,U){return(Pe>=0&&U?` ${Xe(Pe,D-1)}`:Xe(Pe,D)).padEnd(D)}function Xe(Pe,D){let U=Pe.toString();if(U.length<=D)return U;let _=Pe.toFixed(D);if(_.length>D&&(_=Pe.toFixed(Math.max(0,D-(_.length-D)))),_.length<=D&&!_.startsWith("0.000")&&!_.startsWith("-0.000"))return _;let F=Pe.toExponential(D);return F.length>D&&(F=Pe.toExponential(Math.max(0,D-(F.length-D)))),F.slice(0)}function Se(Pe,D){Pe.prototype.add=function(_){return typeof _=="number"?this.addS(_):this.addM(_)},Pe.prototype.addS=function(_){for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)+_);return this},Pe.prototype.addM=function(_){if(_=D.checkMatrix(_),this.rows!==_.rows||this.columns!==_.columns)throw new RangeError("Matrices dimensions must be equal");for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)+_.get(F,X));return this},Pe.add=function(_,F){return new D(_).add(F)},Pe.prototype.sub=function(_){return typeof _=="number"?this.subS(_):this.subM(_)},Pe.prototype.subS=function(_){for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)-_);return this},Pe.prototype.subM=function(_){if(_=D.checkMatrix(_),this.rows!==_.rows||this.columns!==_.columns)throw new RangeError("Matrices dimensions must be equal");for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)-_.get(F,X));return this},Pe.sub=function(_,F){return new D(_).sub(F)},Pe.prototype.subtract=Pe.prototype.sub,Pe.prototype.subtractS=Pe.prototype.subS,Pe.prototype.subtractM=Pe.prototype.subM,Pe.subtract=Pe.sub,Pe.prototype.mul=function(_){return typeof _=="number"?this.mulS(_):this.mulM(_)},Pe.prototype.mulS=function(_){for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)*_);return this},Pe.prototype.mulM=function(_){if(_=D.checkMatrix(_),this.rows!==_.rows||this.columns!==_.columns)throw new RangeError("Matrices dimensions must be equal");for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)*_.get(F,X));return this},Pe.mul=function(_,F){return new D(_).mul(F)},Pe.prototype.multiply=Pe.prototype.mul,Pe.prototype.multiplyS=Pe.prototype.mulS,Pe.prototype.multiplyM=Pe.prototype.mulM,Pe.multiply=Pe.mul,Pe.prototype.div=function(_){return typeof _=="number"?this.divS(_):this.divM(_)},Pe.prototype.divS=function(_){for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)/_);return this},Pe.prototype.divM=function(_){if(_=D.checkMatrix(_),this.rows!==_.rows||this.columns!==_.columns)throw new RangeError("Matrices dimensions must be equal");for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)/_.get(F,X));return this},Pe.div=function(_,F){return new D(_).div(F)},Pe.prototype.divide=Pe.prototype.div,Pe.prototype.divideS=Pe.prototype.divS,Pe.prototype.divideM=Pe.prototype.divM,Pe.divide=Pe.div,Pe.prototype.mod=function(_){return typeof _=="number"?this.modS(_):this.modM(_)},Pe.prototype.modS=function(_){for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)%_);return this},Pe.prototype.modM=function(_){if(_=D.checkMatrix(_),this.rows!==_.rows||this.columns!==_.columns)throw new RangeError("Matrices dimensions must be equal");for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)%_.get(F,X));return this},Pe.mod=function(_,F){return new D(_).mod(F)},Pe.prototype.modulus=Pe.prototype.mod,Pe.prototype.modulusS=Pe.prototype.modS,Pe.prototype.modulusM=Pe.prototype.modM,Pe.modulus=Pe.mod,Pe.prototype.and=function(_){return typeof _=="number"?this.andS(_):this.andM(_)},Pe.prototype.andS=function(_){for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)&_);return this},Pe.prototype.andM=function(_){if(_=D.checkMatrix(_),this.rows!==_.rows||this.columns!==_.columns)throw new RangeError("Matrices dimensions must be equal");for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)&_.get(F,X));return this},Pe.and=function(_,F){return new D(_).and(F)},Pe.prototype.or=function(_){return typeof _=="number"?this.orS(_):this.orM(_)},Pe.prototype.orS=function(_){for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)|_);return this},Pe.prototype.orM=function(_){if(_=D.checkMatrix(_),this.rows!==_.rows||this.columns!==_.columns)throw new RangeError("Matrices dimensions must be equal");for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)|_.get(F,X));return this},Pe.or=function(_,F){return new D(_).or(F)},Pe.prototype.xor=function(_){return typeof _=="number"?this.xorS(_):this.xorM(_)},Pe.prototype.xorS=function(_){for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)^_);return this},Pe.prototype.xorM=function(_){if(_=D.checkMatrix(_),this.rows!==_.rows||this.columns!==_.columns)throw new RangeError("Matrices dimensions must be equal");for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)^_.get(F,X));return this},Pe.xor=function(_,F){return new D(_).xor(F)},Pe.prototype.leftShift=function(_){return typeof _=="number"?this.leftShiftS(_):this.leftShiftM(_)},Pe.prototype.leftShiftS=function(_){for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)<<_);return this},Pe.prototype.leftShiftM=function(_){if(_=D.checkMatrix(_),this.rows!==_.rows||this.columns!==_.columns)throw new RangeError("Matrices dimensions must be equal");for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)<<_.get(F,X));return this},Pe.leftShift=function(_,F){return new D(_).leftShift(F)},Pe.prototype.signPropagatingRightShift=function(_){return typeof _=="number"?this.signPropagatingRightShiftS(_):this.signPropagatingRightShiftM(_)},Pe.prototype.signPropagatingRightShiftS=function(_){for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)>>_);return this},Pe.prototype.signPropagatingRightShiftM=function(_){if(_=D.checkMatrix(_),this.rows!==_.rows||this.columns!==_.columns)throw new RangeError("Matrices dimensions must be equal");for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)>>_.get(F,X));return this},Pe.signPropagatingRightShift=function(_,F){return new D(_).signPropagatingRightShift(F)},Pe.prototype.rightShift=function(_){return typeof _=="number"?this.rightShiftS(_):this.rightShiftM(_)},Pe.prototype.rightShiftS=function(_){for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)>>>_);return this},Pe.prototype.rightShiftM=function(_){if(_=D.checkMatrix(_),this.rows!==_.rows||this.columns!==_.columns)throw new RangeError("Matrices dimensions must be equal");for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,this.get(F,X)>>>_.get(F,X));return this},Pe.rightShift=function(_,F){return new D(_).rightShift(F)},Pe.prototype.zeroFillRightShift=Pe.prototype.rightShift,Pe.prototype.zeroFillRightShiftS=Pe.prototype.rightShiftS,Pe.prototype.zeroFillRightShiftM=Pe.prototype.rightShiftM,Pe.zeroFillRightShift=Pe.rightShift,Pe.prototype.not=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,~this.get(_,F));return this},Pe.not=function(_){return new D(_).not()},Pe.prototype.abs=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.abs(this.get(_,F)));return this},Pe.abs=function(_){return new D(_).abs()},Pe.prototype.acos=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.acos(this.get(_,F)));return this},Pe.acos=function(_){return new D(_).acos()},Pe.prototype.acosh=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.acosh(this.get(_,F)));return this},Pe.acosh=function(_){return new D(_).acosh()},Pe.prototype.asin=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.asin(this.get(_,F)));return this},Pe.asin=function(_){return new D(_).asin()},Pe.prototype.asinh=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.asinh(this.get(_,F)));return this},Pe.asinh=function(_){return new D(_).asinh()},Pe.prototype.atan=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.atan(this.get(_,F)));return this},Pe.atan=function(_){return new D(_).atan()},Pe.prototype.atanh=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.atanh(this.get(_,F)));return this},Pe.atanh=function(_){return new D(_).atanh()},Pe.prototype.cbrt=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.cbrt(this.get(_,F)));return this},Pe.cbrt=function(_){return new D(_).cbrt()},Pe.prototype.ceil=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.ceil(this.get(_,F)));return this},Pe.ceil=function(_){return new D(_).ceil()},Pe.prototype.clz32=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.clz32(this.get(_,F)));return this},Pe.clz32=function(_){return new D(_).clz32()},Pe.prototype.cos=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.cos(this.get(_,F)));return this},Pe.cos=function(_){return new D(_).cos()},Pe.prototype.cosh=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.cosh(this.get(_,F)));return this},Pe.cosh=function(_){return new D(_).cosh()},Pe.prototype.exp=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.exp(this.get(_,F)));return this},Pe.exp=function(_){return new D(_).exp()},Pe.prototype.expm1=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.expm1(this.get(_,F)));return this},Pe.expm1=function(_){return new D(_).expm1()},Pe.prototype.floor=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.floor(this.get(_,F)));return this},Pe.floor=function(_){return new D(_).floor()},Pe.prototype.fround=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.fround(this.get(_,F)));return this},Pe.fround=function(_){return new D(_).fround()},Pe.prototype.log=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.log(this.get(_,F)));return this},Pe.log=function(_){return new D(_).log()},Pe.prototype.log1p=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.log1p(this.get(_,F)));return this},Pe.log1p=function(_){return new D(_).log1p()},Pe.prototype.log10=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.log10(this.get(_,F)));return this},Pe.log10=function(_){return new D(_).log10()},Pe.prototype.log2=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.log2(this.get(_,F)));return this},Pe.log2=function(_){return new D(_).log2()},Pe.prototype.round=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.round(this.get(_,F)));return this},Pe.round=function(_){return new D(_).round()},Pe.prototype.sign=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.sign(this.get(_,F)));return this},Pe.sign=function(_){return new D(_).sign()},Pe.prototype.sin=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.sin(this.get(_,F)));return this},Pe.sin=function(_){return new D(_).sin()},Pe.prototype.sinh=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.sinh(this.get(_,F)));return this},Pe.sinh=function(_){return new D(_).sinh()},Pe.prototype.sqrt=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.sqrt(this.get(_,F)));return this},Pe.sqrt=function(_){return new D(_).sqrt()},Pe.prototype.tan=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.tan(this.get(_,F)));return this},Pe.tan=function(_){return new D(_).tan()},Pe.prototype.tanh=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.tanh(this.get(_,F)));return this},Pe.tanh=function(_){return new D(_).tanh()},Pe.prototype.trunc=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,Math.trunc(this.get(_,F)));return this},Pe.trunc=function(_){return new D(_).trunc()},Pe.pow=function(_,F){return new D(_).pow(F)},Pe.prototype.pow=function(_){return typeof _=="number"?this.powS(_):this.powM(_)},Pe.prototype.powS=function(_){for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,R(this.get(F,X),_));return this},Pe.prototype.powM=function(_){if(_=D.checkMatrix(_),this.rows!==_.rows||this.columns!==_.columns)throw new RangeError("Matrices dimensions must be equal");for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,R(this.get(F,X),_.get(F,X)));return this}}function Ge(Pe,D,U){let _=U?Pe.rows:Pe.rows-1;if(D<0||D>_)throw new RangeError("Row index out of range")}function He(Pe,D,U){let _=U?Pe.columns:Pe.columns-1;if(D<0||D>_)throw new RangeError("Column index out of range")}function vt(Pe,D){if(D.to1DArray&&(D=D.to1DArray()),D.length!==Pe.columns)throw new RangeError("vector size must be the same as the number of columns");return D}function It(Pe,D){if(D.to1DArray&&(D=D.to1DArray()),D.length!==Pe.rows)throw new RangeError("vector size must be the same as the number of rows");return D}function zt(Pe,D){if(!pe.isAnyArray(D))throw new TypeError("row indices must be an array");for(let U=0;U<D.length;U++)if(D[U]<0||D[U]>=Pe.rows)throw new RangeError("row indices are out of range")}function Yt(Pe,D){if(!pe.isAnyArray(D))throw new TypeError("column indices must be an array");for(let U=0;U<D.length;U++)if(D[U]<0||D[U]>=Pe.columns)throw new RangeError("column indices are out of range")}function At(Pe,D,U,_,F){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(Ot("startRow",D),Ot("endRow",U),Ot("startColumn",_),Ot("endColumn",F),D>U||_>F||D<0||D>=Pe.rows||U<0||U>=Pe.rows||_<0||_>=Pe.columns||F<0||F>=Pe.columns)throw new RangeError("Submatrix indices are out of range")}function lt(Pe,D=0){let U=[];for(let _=0;_<Pe;_++)U.push(D);return U}function Ot(Pe,D){if(typeof D!="number")throw new TypeError(`${Pe} must be a number`)}function le(Pe){if(Pe.isEmpty())throw new Error("Empty matrix has no elements to index")}function Fe(Pe){let D=lt(Pe.rows);for(let U=0;U<Pe.rows;++U)for(let _=0;_<Pe.columns;++_)D[U]+=Pe.get(U,_);return D}function gt(Pe){let D=lt(Pe.columns);for(let U=0;U<Pe.rows;++U)for(let _=0;_<Pe.columns;++_)D[_]+=Pe.get(U,_);return D}function Jt(Pe){let D=0;for(let U=0;U<Pe.rows;U++)for(let _=0;_<Pe.columns;_++)D+=Pe.get(U,_);return D}function Ze(Pe){let D=lt(Pe.rows,1);for(let U=0;U<Pe.rows;++U)for(let _=0;_<Pe.columns;++_)D[U]*=Pe.get(U,_);return D}function rt(Pe){let D=lt(Pe.columns,1);for(let U=0;U<Pe.rows;++U)for(let _=0;_<Pe.columns;++_)D[_]*=Pe.get(U,_);return D}function Mt(Pe){let D=1;for(let U=0;U<Pe.rows;U++)for(let _=0;_<Pe.columns;_++)D*=Pe.get(U,_);return D}function Ue(Pe,D,U){const _=Pe.rows,F=Pe.columns,X=[];for(let Ie=0;Ie<_;Ie++){let ke=0,et=0,nt=0;for(let Wt=0;Wt<F;Wt++)nt=Pe.get(Ie,Wt)-U[Ie],ke+=nt,et+=nt*nt;D?X.push((et-ke*ke/F)/(F-1)):X.push((et-ke*ke/F)/F)}return X}function Ye(Pe,D,U){const _=Pe.rows,F=Pe.columns,X=[];for(let Ie=0;Ie<F;Ie++){let ke=0,et=0,nt=0;for(let Wt=0;Wt<_;Wt++)nt=Pe.get(Wt,Ie)-U[Ie],ke+=nt,et+=nt*nt;D?X.push((et-ke*ke/_)/(_-1)):X.push((et-ke*ke/_)/_)}return X}function be(Pe,D,U){const _=Pe.rows,F=Pe.columns,X=_*F;let Ie=0,ke=0,et=0;for(let nt=0;nt<_;nt++)for(let Wt=0;Wt<F;Wt++)et=Pe.get(nt,Wt)-U,Ie+=et,ke+=et*et;return D?(ke-Ie*Ie/X)/(X-1):(ke-Ie*Ie/X)/X}function ge(Pe,D){for(let U=0;U<Pe.rows;U++)for(let _=0;_<Pe.columns;_++)Pe.set(U,_,Pe.get(U,_)-D[U])}function Ke(Pe,D){for(let U=0;U<Pe.rows;U++)for(let _=0;_<Pe.columns;_++)Pe.set(U,_,Pe.get(U,_)-D[_])}function wt(Pe,D){for(let U=0;U<Pe.rows;U++)for(let _=0;_<Pe.columns;_++)Pe.set(U,_,Pe.get(U,_)-D)}function Be(Pe){const D=[];for(let U=0;U<Pe.rows;U++){let _=0;for(let F=0;F<Pe.columns;F++)_+=R(Pe.get(U,F),2)/(Pe.columns-1);D.push(Math.sqrt(_))}return D}function ut(Pe,D){for(let U=0;U<Pe.rows;U++)for(let _=0;_<Pe.columns;_++)Pe.set(U,_,Pe.get(U,_)/D[U])}function Et(Pe){const D=[];for(let U=0;U<Pe.columns;U++){let _=0;for(let F=0;F<Pe.rows;F++)_+=R(Pe.get(F,U),2)/(Pe.rows-1);D.push(Math.sqrt(_))}return D}function je(Pe,D){for(let U=0;U<Pe.rows;U++)for(let _=0;_<Pe.columns;_++)Pe.set(U,_,Pe.get(U,_)/D[_])}function tt(Pe){const D=Pe.size-1;let U=0;for(let _=0;_<Pe.columns;_++)for(let F=0;F<Pe.rows;F++)U+=R(Pe.get(F,_),2)/D;return Math.sqrt(U)}function yt(Pe,D){for(let U=0;U<Pe.rows;U++)for(let _=0;_<Pe.columns;_++)Pe.set(U,_,Pe.get(U,_)/D)}class B{static from1DArray(D,U,_){if(D*U!==_.length)throw new RangeError("data length does not match given dimensions");let X=new ct(D,U);for(let Ie=0;Ie<D;Ie++)for(let ke=0;ke<U;ke++)X.set(Ie,ke,_[Ie*U+ke]);return X}static rowVector(D){let U=new ct(1,D.length);for(let _=0;_<D.length;_++)U.set(0,_,D[_]);return U}static columnVector(D){let U=new ct(D.length,1);for(let _=0;_<D.length;_++)U.set(_,0,D[_]);return U}static zeros(D,U){return new ct(D,U)}static ones(D,U){return new ct(D,U).fill(1)}static rand(D,U,_={}){if(typeof _!="object")throw new TypeError("options must be an object");const{random:F=Math.random}=_;let X=new ct(D,U);for(let Ie=0;Ie<D;Ie++)for(let ke=0;ke<U;ke++)X.set(Ie,ke,F());return X}static randInt(D,U,_={}){if(typeof _!="object")throw new TypeError("options must be an object");const{min:F=0,max:X=1e3,random:Ie=Math.random}=_;if(!Number.isInteger(F))throw new TypeError("min must be an integer");if(!Number.isInteger(X))throw new TypeError("max must be an integer");if(F>=X)throw new RangeError("min must be smaller than max");let ke=X-F,et=new ct(D,U);for(let nt=0;nt<D;nt++)for(let Wt=0;Wt<U;Wt++){let Tt=F+Math.round(Ie()*ke);et.set(nt,Wt,Tt)}return et}static eye(D,U,_){U===void 0&&(U=D),_===void 0&&(_=1);let F=Math.min(D,U),X=this.zeros(D,U);for(let Ie=0;Ie<F;Ie++)X.set(Ie,Ie,_);return X}static diag(D,U,_){let F=D.length;U===void 0&&(U=F),_===void 0&&(_=U);let X=Math.min(F,U,_),Ie=this.zeros(U,_);for(let ke=0;ke<X;ke++)Ie.set(ke,ke,D[ke]);return Ie}static min(D,U){D=this.checkMatrix(D),U=this.checkMatrix(U);let _=D.rows,F=D.columns,X=new ct(_,F);for(let Ie=0;Ie<_;Ie++)for(let ke=0;ke<F;ke++)X.set(Ie,ke,Math.min(D.get(Ie,ke),U.get(Ie,ke)));return X}static max(D,U){D=this.checkMatrix(D),U=this.checkMatrix(U);let _=D.rows,F=D.columns,X=new this(_,F);for(let Ie=0;Ie<_;Ie++)for(let ke=0;ke<F;ke++)X.set(Ie,ke,Math.max(D.get(Ie,ke),U.get(Ie,ke)));return X}static checkMatrix(D){return B.isMatrix(D)?D:new ct(D)}static isMatrix(D){return D!=null&&D.klass==="Matrix"}get size(){return this.rows*this.columns}apply(D){if(typeof D!="function")throw new TypeError("callback must be a function");for(let U=0;U<this.rows;U++)for(let _=0;_<this.columns;_++)D.call(this,U,_);return this}to1DArray(){let D=[];for(let U=0;U<this.rows;U++)for(let _=0;_<this.columns;_++)D.push(this.get(U,_));return D}to2DArray(){let D=[];for(let U=0;U<this.rows;U++){D.push([]);for(let _=0;_<this.columns;_++)D[U].push(this.get(U,_))}return D}toJSON(){return this.to2DArray()}isRowVector(){return this.rows===1}isColumnVector(){return this.columns===1}isVector(){return this.rows===1||this.columns===1}isSquare(){return this.rows===this.columns}isEmpty(){return this.rows===0||this.columns===0}isSymmetric(){if(this.isSquare()){for(let D=0;D<this.rows;D++)for(let U=0;U<=D;U++)if(this.get(D,U)!==this.get(U,D))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let D=0;D<this.rows;D++)if(this.get(D,D)!==0)return!1;return!0}isEchelonForm(){let D=0,U=0,_=-1,F=!0,X=!1;for(;D<this.rows&&F;){for(U=0,X=!1;U<this.columns&&X===!1;)this.get(D,U)===0?U++:this.get(D,U)===1&&U>_?(X=!0,_=U):(F=!1,X=!0);D++}return F}isReducedEchelonForm(){let D=0,U=0,_=-1,F=!0,X=!1;for(;D<this.rows&&F;){for(U=0,X=!1;U<this.columns&&X===!1;)this.get(D,U)===0?U++:this.get(D,U)===1&&U>_?(X=!0,_=U):(F=!1,X=!0);for(let Ie=U+1;Ie<this.rows;Ie++)this.get(D,Ie)!==0&&(F=!1);D++}return F}echelonForm(){let D=this.clone(),U=0,_=0;for(;U<D.rows&&_<D.columns;){let F=U;for(let X=U;X<D.rows;X++)D.get(X,_)>D.get(F,_)&&(F=X);if(D.get(F,_)===0)_++;else{D.swapRows(U,F);let X=D.get(U,_);for(let Ie=_;Ie<D.columns;Ie++)D.set(U,Ie,D.get(U,Ie)/X);for(let Ie=U+1;Ie<D.rows;Ie++){let ke=D.get(Ie,_)/D.get(U,_);D.set(Ie,_,0);for(let et=_+1;et<D.columns;et++)D.set(Ie,et,D.get(Ie,et)-D.get(U,et)*ke)}U++,_++}}return D}reducedEchelonForm(){let D=this.echelonForm(),U=D.columns,_=D.rows,F=_-1;for(;F>=0;)if(D.maxRow(F)===0)F--;else{let X=0,Ie=!1;for(;X<_&&Ie===!1;)D.get(F,X)===1?Ie=!0:X++;for(let ke=0;ke<F;ke++){let et=D.get(ke,X);for(let nt=X;nt<U;nt++){let Wt=D.get(ke,nt)-et*D.get(F,nt);D.set(ke,nt,Wt)}}F--}return D}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(D={}){if(typeof D!="object")throw new TypeError("options must be an object");const{rows:U=1,columns:_=1}=D;if(!Number.isInteger(U)||U<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(_)||_<=0)throw new TypeError("columns must be a positive integer");let F=new ct(this.rows*U,this.columns*_);for(let X=0;X<U;X++)for(let Ie=0;Ie<_;Ie++)F.setSubMatrix(this,this.rows*X,this.columns*Ie);return F}fill(D){for(let U=0;U<this.rows;U++)for(let _=0;_<this.columns;_++)this.set(U,_,D);return this}neg(){return this.mulS(-1)}getRow(D){Ge(this,D);let U=[];for(let _=0;_<this.columns;_++)U.push(this.get(D,_));return U}getRowVector(D){return ct.rowVector(this.getRow(D))}setRow(D,U){Ge(this,D),U=vt(this,U);for(let _=0;_<this.columns;_++)this.set(D,_,U[_]);return this}swapRows(D,U){Ge(this,D),Ge(this,U);for(let _=0;_<this.columns;_++){let F=this.get(D,_);this.set(D,_,this.get(U,_)),this.set(U,_,F)}return this}getColumn(D){He(this,D);let U=[];for(let _=0;_<this.rows;_++)U.push(this.get(_,D));return U}getColumnVector(D){return ct.columnVector(this.getColumn(D))}setColumn(D,U){He(this,D),U=It(this,U);for(let _=0;_<this.rows;_++)this.set(_,D,U[_]);return this}swapColumns(D,U){He(this,D),He(this,U);for(let _=0;_<this.rows;_++){let F=this.get(_,D);this.set(_,D,this.get(_,U)),this.set(_,U,F)}return this}addRowVector(D){D=vt(this,D);for(let U=0;U<this.rows;U++)for(let _=0;_<this.columns;_++)this.set(U,_,this.get(U,_)+D[_]);return this}subRowVector(D){D=vt(this,D);for(let U=0;U<this.rows;U++)for(let _=0;_<this.columns;_++)this.set(U,_,this.get(U,_)-D[_]);return this}mulRowVector(D){D=vt(this,D);for(let U=0;U<this.rows;U++)for(let _=0;_<this.columns;_++)this.set(U,_,this.get(U,_)*D[_]);return this}divRowVector(D){D=vt(this,D);for(let U=0;U<this.rows;U++)for(let _=0;_<this.columns;_++)this.set(U,_,this.get(U,_)/D[_]);return this}addColumnVector(D){D=It(this,D);for(let U=0;U<this.rows;U++)for(let _=0;_<this.columns;_++)this.set(U,_,this.get(U,_)+D[U]);return this}subColumnVector(D){D=It(this,D);for(let U=0;U<this.rows;U++)for(let _=0;_<this.columns;_++)this.set(U,_,this.get(U,_)-D[U]);return this}mulColumnVector(D){D=It(this,D);for(let U=0;U<this.rows;U++)for(let _=0;_<this.columns;_++)this.set(U,_,this.get(U,_)*D[U]);return this}divColumnVector(D){D=It(this,D);for(let U=0;U<this.rows;U++)for(let _=0;_<this.columns;_++)this.set(U,_,this.get(U,_)/D[U]);return this}mulRow(D,U){Ge(this,D);for(let _=0;_<this.columns;_++)this.set(D,_,this.get(D,_)*U);return this}mulColumn(D,U){He(this,D);for(let _=0;_<this.rows;_++)this.set(_,D,this.get(_,D)*U);return this}max(D){if(this.isEmpty())return NaN;switch(D){case"row":{const U=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.get(_,F)>U[_]&&(U[_]=this.get(_,F));return U}case"column":{const U=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.get(_,F)>U[F]&&(U[F]=this.get(_,F));return U}case void 0:{let U=this.get(0,0);for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.get(_,F)>U&&(U=this.get(_,F));return U}default:throw new Error(`invalid option: ${D}`)}}maxIndex(){le(this);let D=this.get(0,0),U=[0,0];for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.get(_,F)>D&&(D=this.get(_,F),U[0]=_,U[1]=F);return U}min(D){if(this.isEmpty())return NaN;switch(D){case"row":{const U=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.get(_,F)<U[_]&&(U[_]=this.get(_,F));return U}case"column":{const U=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.get(_,F)<U[F]&&(U[F]=this.get(_,F));return U}case void 0:{let U=this.get(0,0);for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.get(_,F)<U&&(U=this.get(_,F));return U}default:throw new Error(`invalid option: ${D}`)}}minIndex(){le(this);let D=this.get(0,0),U=[0,0];for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.get(_,F)<D&&(D=this.get(_,F),U[0]=_,U[1]=F);return U}maxRow(D){if(Ge(this,D),this.isEmpty())return NaN;let U=this.get(D,0);for(let _=1;_<this.columns;_++)this.get(D,_)>U&&(U=this.get(D,_));return U}maxRowIndex(D){Ge(this,D),le(this);let U=this.get(D,0),_=[D,0];for(let F=1;F<this.columns;F++)this.get(D,F)>U&&(U=this.get(D,F),_[1]=F);return _}minRow(D){if(Ge(this,D),this.isEmpty())return NaN;let U=this.get(D,0);for(let _=1;_<this.columns;_++)this.get(D,_)<U&&(U=this.get(D,_));return U}minRowIndex(D){Ge(this,D),le(this);let U=this.get(D,0),_=[D,0];for(let F=1;F<this.columns;F++)this.get(D,F)<U&&(U=this.get(D,F),_[1]=F);return _}maxColumn(D){if(He(this,D),this.isEmpty())return NaN;let U=this.get(0,D);for(let _=1;_<this.rows;_++)this.get(_,D)>U&&(U=this.get(_,D));return U}maxColumnIndex(D){He(this,D),le(this);let U=this.get(0,D),_=[0,D];for(let F=1;F<this.rows;F++)this.get(F,D)>U&&(U=this.get(F,D),_[0]=F);return _}minColumn(D){if(He(this,D),this.isEmpty())return NaN;let U=this.get(0,D);for(let _=1;_<this.rows;_++)this.get(_,D)<U&&(U=this.get(_,D));return U}minColumnIndex(D){He(this,D),le(this);let U=this.get(0,D),_=[0,D];for(let F=1;F<this.rows;F++)this.get(F,D)<U&&(U=this.get(F,D),_[0]=F);return _}diag(){let D=Math.min(this.rows,this.columns),U=[];for(let _=0;_<D;_++)U.push(this.get(_,_));return U}norm(D="frobenius"){switch(D){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${D}`)}}cumulativeSum(){let D=0;for(let U=0;U<this.rows;U++)for(let _=0;_<this.columns;_++)D+=this.get(U,_),this.set(U,_,D);return this}dot(D){B.isMatrix(D)&&(D=D.to1DArray());let U=this.to1DArray();if(U.length!==D.length)throw new RangeError("vectors do not have the same size");let _=0;for(let F=0;F<U.length;F++)_+=U[F]*D[F];return _}mmul(D){D=ct.checkMatrix(D);let U=this.rows,_=this.columns,F=D.columns,X=new ct(U,F),Ie=new Float64Array(_);for(let ke=0;ke<F;ke++){for(let et=0;et<_;et++)Ie[et]=D.get(et,ke);for(let et=0;et<U;et++){let nt=0;for(let Wt=0;Wt<_;Wt++)nt+=this.get(et,Wt)*Ie[Wt];X.set(et,ke,nt)}}return X}mpow(D){if(!this.isSquare())throw new RangeError("Matrix must be square");if(!Number.isInteger(D)||D<0)throw new RangeError("Exponent must be a non-negative integer");let U=ct.eye(this.rows),_=this;for(let F=D;F>1;F/=2)F&1&&(U=U.mmul(_)),_=_.mmul(_);return U}strassen2x2(D){D=ct.checkMatrix(D);let U=new ct(2,2);const _=this.get(0,0),F=D.get(0,0),X=this.get(0,1),Ie=D.get(0,1),ke=this.get(1,0),et=D.get(1,0),nt=this.get(1,1),Wt=D.get(1,1),Tt=(_+nt)*(F+Wt),on=(ke+nt)*F,Un=_*(Ie-Wt),sn=nt*(et-F),bn=(_+X)*Wt,ti=(ke-_)*(F+Ie),Bt=(X-nt)*(et+Wt),$n=Tt+sn-bn+Bt,ni=Un+bn,Pi=on+sn,ui=Tt-on+Un+ti;return U.set(0,0,$n),U.set(0,1,ni),U.set(1,0,Pi),U.set(1,1,ui),U}strassen3x3(D){D=ct.checkMatrix(D);let U=new ct(3,3);const _=this.get(0,0),F=this.get(0,1),X=this.get(0,2),Ie=this.get(1,0),ke=this.get(1,1),et=this.get(1,2),nt=this.get(2,0),Wt=this.get(2,1),Tt=this.get(2,2),on=D.get(0,0),Un=D.get(0,1),sn=D.get(0,2),bn=D.get(1,0),ti=D.get(1,1),Bt=D.get(1,2),$n=D.get(2,0),ni=D.get(2,1),Pi=D.get(2,2),ui=(_+F+X-Ie-ke-Wt-Tt)*ti,Lr=(_-Ie)*(-Un+ti),yi=ke*(-on+Un+bn-ti-Bt-$n+Pi),vi=(-_+Ie+ke)*(on-Un+ti),Mr=(Ie+ke)*(-on+Un),Zt=_*on,Fn=(-_+nt+Wt)*(on-sn+Bt),hi=(-_+nt)*(sn-Bt),Xn=(nt+Wt)*(-on+sn),ds=(_+F+X-ke-et-nt-Wt)*Bt,qr=Wt*(-on+sn+bn-ti-Bt-$n+ni),vs=(-X+Wt+Tt)*(ti+$n-ni),kr=(X-Tt)*(ti-ni),Fs=X*$n,io=(Wt+Tt)*(-$n+ni),ro=(-X+ke+et)*(Bt+$n-Pi),To=(X-et)*(Bt-Pi),Eo=(ke+et)*(-$n+Pi),Wr=F*bn,eo=et*ni,Ao=Ie*sn,so=nt*Un,Yr=Tt*Pi,ua=Zt+Fs+Wr,Co=ui+vi+Mr+Zt+vs+Fs+io,sl=Zt+Fn+Xn+ds+Fs+ro+Eo,ol=Lr+yi+vi+Zt+Fs+ro+To,ha=Lr+vi+Mr+Zt+eo,Ba=Fs+ro+To+Eo+Ao,al=Zt+Fn+hi+qr+vs+kr+Fs,wo=vs+kr+Fs+io+so,Lc=Zt+Fn+hi+Xn+Yr;return U.set(0,0,ua),U.set(0,1,Co),U.set(0,2,sl),U.set(1,0,ol),U.set(1,1,ha),U.set(1,2,Ba),U.set(2,0,al),U.set(2,1,wo),U.set(2,2,Lc),U}mmulStrassen(D){D=ct.checkMatrix(D);let U=this.clone(),_=U.rows,F=U.columns,X=D.rows,Ie=D.columns;F!==X&&console.warn(`Multiplying ${_} x ${F} and ${X} x ${Ie} matrix: dimensions do not match.`);function ke(Tt,on,Un){let sn=Tt.rows,bn=Tt.columns;if(sn===on&&bn===Un)return Tt;{let ti=B.zeros(on,Un);return ti=ti.setSubMatrix(Tt,0,0),ti}}let et=Math.max(_,X),nt=Math.max(F,Ie);U=ke(U,et,nt),D=ke(D,et,nt);function Wt(Tt,on,Un,sn){if(Un<=512||sn<=512)return Tt.mmul(on);Un%2===1&&sn%2===1?(Tt=ke(Tt,Un+1,sn+1),on=ke(on,Un+1,sn+1)):Un%2===1?(Tt=ke(Tt,Un+1,sn),on=ke(on,Un+1,sn)):sn%2===1&&(Tt=ke(Tt,Un,sn+1),on=ke(on,Un,sn+1));let bn=parseInt(Tt.rows/2,10),ti=parseInt(Tt.columns/2,10),Bt=Tt.subMatrix(0,bn-1,0,ti-1),$n=on.subMatrix(0,bn-1,0,ti-1),ni=Tt.subMatrix(0,bn-1,ti,Tt.columns-1),Pi=on.subMatrix(0,bn-1,ti,on.columns-1),ui=Tt.subMatrix(bn,Tt.rows-1,0,ti-1),Lr=on.subMatrix(bn,on.rows-1,0,ti-1),yi=Tt.subMatrix(bn,Tt.rows-1,ti,Tt.columns-1),vi=on.subMatrix(bn,on.rows-1,ti,on.columns-1),Mr=Wt(B.add(Bt,yi),B.add($n,vi),bn,ti),Zt=Wt(B.add(ui,yi),$n,bn,ti),Fn=Wt(Bt,B.sub(Pi,vi),bn,ti),hi=Wt(yi,B.sub(Lr,$n),bn,ti),Xn=Wt(B.add(Bt,ni),vi,bn,ti),ds=Wt(B.sub(ui,Bt),B.add($n,Pi),bn,ti),qr=Wt(B.sub(ni,yi),B.add(Lr,vi),bn,ti),vs=B.add(Mr,hi);vs.sub(Xn),vs.add(qr);let kr=B.add(Fn,Xn),Fs=B.add(Zt,hi),io=B.sub(Mr,Zt);io.add(Fn),io.add(ds);let ro=B.zeros(2*vs.rows,2*vs.columns);return ro=ro.setSubMatrix(vs,0,0),ro=ro.setSubMatrix(kr,vs.rows,0),ro=ro.setSubMatrix(Fs,0,vs.columns),ro=ro.setSubMatrix(io,vs.rows,vs.columns),ro.subMatrix(0,Un-1,0,sn-1)}return Wt(U,D,et,nt)}scaleRows(D={}){if(typeof D!="object")throw new TypeError("options must be an object");const{min:U=0,max:_=1}=D;if(!Number.isFinite(U))throw new TypeError("min must be a number");if(!Number.isFinite(_))throw new TypeError("max must be a number");if(U>=_)throw new RangeError("min must be smaller than max");let F=new ct(this.rows,this.columns);for(let X=0;X<this.rows;X++){const Ie=this.getRow(X);Ie.length>0&&fe(Ie,{min:U,max:_,output:Ie}),F.setRow(X,Ie)}return F}scaleColumns(D={}){if(typeof D!="object")throw new TypeError("options must be an object");const{min:U=0,max:_=1}=D;if(!Number.isFinite(U))throw new TypeError("min must be a number");if(!Number.isFinite(_))throw new TypeError("max must be a number");if(U>=_)throw new RangeError("min must be smaller than max");let F=new ct(this.rows,this.columns);for(let X=0;X<this.columns;X++){const Ie=this.getColumn(X);Ie.length&&fe(Ie,{min:U,max:_,output:Ie}),F.setColumn(X,Ie)}return F}flipRows(){const D=Math.ceil(this.columns/2);for(let U=0;U<this.rows;U++)for(let _=0;_<D;_++){let F=this.get(U,_),X=this.get(U,this.columns-1-_);this.set(U,_,X),this.set(U,this.columns-1-_,F)}return this}flipColumns(){const D=Math.ceil(this.rows/2);for(let U=0;U<this.columns;U++)for(let _=0;_<D;_++){let F=this.get(_,U),X=this.get(this.rows-1-_,U);this.set(_,U,X),this.set(this.rows-1-_,U,F)}return this}kroneckerProduct(D){D=ct.checkMatrix(D);let U=this.rows,_=this.columns,F=D.rows,X=D.columns,Ie=new ct(U*F,_*X);for(let ke=0;ke<U;ke++)for(let et=0;et<_;et++)for(let nt=0;nt<F;nt++)for(let Wt=0;Wt<X;Wt++)Ie.set(F*ke+nt,X*et+Wt,this.get(ke,et)*D.get(nt,Wt));return Ie}kroneckerSum(D){if(D=ct.checkMatrix(D),!this.isSquare()||!D.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let U=this.rows,_=D.rows,F=this.kroneckerProduct(ct.eye(_,_)),X=ct.eye(U,U).kroneckerProduct(D);return F.add(X)}transpose(){let D=new ct(this.columns,this.rows);for(let U=0;U<this.rows;U++)for(let _=0;_<this.columns;_++)D.set(_,U,this.get(U,_));return D}sortRows(D=te){for(let U=0;U<this.rows;U++)this.setRow(U,this.getRow(U).sort(D));return this}sortColumns(D=te){for(let U=0;U<this.columns;U++)this.setColumn(U,this.getColumn(U).sort(D));return this}subMatrix(D,U,_,F){At(this,D,U,_,F);let X=new ct(U-D+1,F-_+1);for(let Ie=D;Ie<=U;Ie++)for(let ke=_;ke<=F;ke++)X.set(Ie-D,ke-_,this.get(Ie,ke));return X}subMatrixRow(D,U,_){if(U===void 0&&(U=0),_===void 0&&(_=this.columns-1),U>_||U<0||U>=this.columns||_<0||_>=this.columns)throw new RangeError("Argument out of range");let F=new ct(D.length,_-U+1);for(let X=0;X<D.length;X++)for(let Ie=U;Ie<=_;Ie++){if(D[X]<0||D[X]>=this.rows)throw new RangeError(`Row index out of range: ${D[X]}`);F.set(X,Ie-U,this.get(D[X],Ie))}return F}subMatrixColumn(D,U,_){if(U===void 0&&(U=0),_===void 0&&(_=this.rows-1),U>_||U<0||U>=this.rows||_<0||_>=this.rows)throw new RangeError("Argument out of range");let F=new ct(_-U+1,D.length);for(let X=0;X<D.length;X++)for(let Ie=U;Ie<=_;Ie++){if(D[X]<0||D[X]>=this.columns)throw new RangeError(`Column index out of range: ${D[X]}`);F.set(Ie-U,X,this.get(Ie,D[X]))}return F}setSubMatrix(D,U,_){if(D=ct.checkMatrix(D),D.isEmpty())return this;let F=U+D.rows-1,X=_+D.columns-1;At(this,U,F,_,X);for(let Ie=0;Ie<D.rows;Ie++)for(let ke=0;ke<D.columns;ke++)this.set(U+Ie,_+ke,D.get(Ie,ke));return this}selection(D,U){zt(this,D),Yt(this,U);let _=new ct(D.length,U.length);for(let F=0;F<D.length;F++){let X=D[F];for(let Ie=0;Ie<U.length;Ie++){let ke=U[Ie];_.set(F,Ie,this.get(X,ke))}}return _}trace(){let D=Math.min(this.rows,this.columns),U=0;for(let _=0;_<D;_++)U+=this.get(_,_);return U}clone(){return this.constructor.copy(this,new ct(this.rows,this.columns))}static copy(D,U){for(const[_,F,X]of D.entries())U.set(_,F,X);return U}sum(D){switch(D){case"row":return Fe(this);case"column":return gt(this);case void 0:return Jt(this);default:throw new Error(`invalid option: ${D}`)}}product(D){switch(D){case"row":return Ze(this);case"column":return rt(this);case void 0:return Mt(this);default:throw new Error(`invalid option: ${D}`)}}mean(D){const U=this.sum(D);switch(D){case"row":{for(let _=0;_<this.rows;_++)U[_]/=this.columns;return U}case"column":{for(let _=0;_<this.columns;_++)U[_]/=this.rows;return U}case void 0:return U/this.size;default:throw new Error(`invalid option: ${D}`)}}variance(D,U={}){if(typeof D=="object"&&(U=D,D=void 0),typeof U!="object")throw new TypeError("options must be an object");const{unbiased:_=!0,mean:F=this.mean(D)}=U;if(typeof _!="boolean")throw new TypeError("unbiased must be a boolean");switch(D){case"row":{if(!pe.isAnyArray(F))throw new TypeError("mean must be an array");return Ue(this,_,F)}case"column":{if(!pe.isAnyArray(F))throw new TypeError("mean must be an array");return Ye(this,_,F)}case void 0:{if(typeof F!="number")throw new TypeError("mean must be a number");return be(this,_,F)}default:throw new Error(`invalid option: ${D}`)}}standardDeviation(D,U){typeof D=="object"&&(U=D,D=void 0);const _=this.variance(D,U);if(D===void 0)return Math.sqrt(_);for(let F=0;F<_.length;F++)_[F]=Math.sqrt(_[F]);return _}center(D,U={}){if(typeof D=="object"&&(U=D,D=void 0),typeof U!="object")throw new TypeError("options must be an object");const{center:_=this.mean(D)}=U;switch(D){case"row":{if(!pe.isAnyArray(_))throw new TypeError("center must be an array");return ge(this,_),this}case"column":{if(!pe.isAnyArray(_))throw new TypeError("center must be an array");return Ke(this,_),this}case void 0:{if(typeof _!="number")throw new TypeError("center must be a number");return wt(this,_),this}default:throw new Error(`invalid option: ${D}`)}}scale(D,U={}){if(typeof D=="object"&&(U=D,D=void 0),typeof U!="object")throw new TypeError("options must be an object");let _=U.scale;switch(D){case"row":{if(_===void 0)_=Be(this);else if(!pe.isAnyArray(_))throw new TypeError("scale must be an array");return ut(this,_),this}case"column":{if(_===void 0)_=Et(this);else if(!pe.isAnyArray(_))throw new TypeError("scale must be an array");return je(this,_),this}case void 0:{if(_===void 0)_=tt(this);else if(typeof _!="number")throw new TypeError("scale must be a number");return yt(this,_),this}default:throw new Error(`invalid option: ${D}`)}}toString(D){return Ne(this,D)}[Symbol.iterator](){return this.entries()}*entries(){for(let D=0;D<this.rows;D++)for(let U=0;U<this.columns;U++)yield[D,U,this.get(D,U)]}*values(){for(let D=0;D<this.rows;D++)for(let U=0;U<this.columns;U++)yield this.get(D,U)}}B.prototype.klass="Matrix",typeof Symbol!="undefined"&&(B.prototype[Symbol.for("nodejs.util.inspect.custom")]=ue);function te(Pe,D){return Pe-D}function ot(Pe){return Pe.every(D=>typeof D=="number")}B.random=B.rand,B.randomInt=B.randInt,B.diagonal=B.diag,B.prototype.diagonal=B.prototype.diag,B.identity=B.eye,B.prototype.negate=B.prototype.neg,B.prototype.tensorProduct=B.prototype.kroneckerProduct;const _t=class hE extends B{constructor(D,U){if(super(),N(this,W),C(this,"data"),hE.isMatrix(D))P(this,W,Y).call(this,D.rows,D.columns),hE.copy(D,this);else if(Number.isInteger(D)&&D>=0)P(this,W,Y).call(this,D,U);else if(pe.isAnyArray(D)){const _=D;if(D=_.length,U=D?_[0].length:0,typeof U!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let F=0;F<D;F++){if(_[F].length!==U)throw new RangeError("Inconsistent array dimensions");if(!ot(_[F]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(_[F]))}this.rows=D,this.columns=U}else throw new TypeError("First argument must be a positive number or an array")}set(D,U,_){return this.data[D][U]=_,this}get(D,U){return this.data[D][U]}removeRow(D){return Ge(this,D),this.data.splice(D,1),this.rows-=1,this}addRow(D,U){return U===void 0&&(U=D,D=this.rows),Ge(this,D,!0),U=Float64Array.from(vt(this,U)),this.data.splice(D,0,U),this.rows+=1,this}removeColumn(D){He(this,D);for(let U=0;U<this.rows;U++){const _=new Float64Array(this.columns-1);for(let F=0;F<D;F++)_[F]=this.data[U][F];for(let F=D+1;F<this.columns;F++)_[F-1]=this.data[U][F];this.data[U]=_}return this.columns-=1,this}addColumn(D,U){typeof U=="undefined"&&(U=D,D=this.columns),He(this,D,!0),U=It(this,U);for(let _=0;_<this.rows;_++){const F=new Float64Array(this.columns+1);let X=0;for(;X<D;X++)F[X]=this.data[_][X];for(F[X++]=U[_];X<this.columns+1;X++)F[X]=this.data[_][X-1];this.data[_]=F}return this.columns+=1,this}};W=new WeakSet,Y=function(Pe,D){if(this.data=[],Number.isInteger(D)&&D>=0)for(let U=0;U<Pe;U++)this.data.push(new Float64Array(D));else throw new TypeError("nColumns must be a positive integer");this.rows=Pe,this.columns=D};let ct=_t;Se(B,ct);const qt=class dE extends B{constructor(D){if(super(),N(this,ie),ct.isMatrix(D)){if(!D.isSymmetric())throw new TypeError("not symmetric data");L(this,ie,ct.copy(D,new ct(D.rows,D.rows)))}else if(Number.isInteger(D)&&D>=0)L(this,ie,new ct(D,D));else if(L(this,ie,new ct(D)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return E(this,ie).size}get rows(){return E(this,ie).rows}get columns(){return E(this,ie).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(D){return ct.isMatrix(D)&&D.klassType==="SymmetricMatrix"}static zeros(D){return new this(D)}static ones(D){return new this(D).fill(1)}clone(){const D=new dE(this.diagonalSize);for(const[U,_,F]of this.upperRightEntries())D.set(U,_,F);return D}toMatrix(){return new ct(this)}get(D,U){return E(this,ie).get(D,U)}set(D,U,_){return E(this,ie).set(D,U,_),E(this,ie).set(U,D,_),this}removeCross(D){return E(this,ie).removeRow(D),E(this,ie).removeColumn(D),this}addCross(D,U){U===void 0&&(U=D,D=this.diagonalSize);const _=U.slice();return _.splice(D,1),E(this,ie).addRow(D,_),E(this,ie).addColumn(D,U),this}applyMask(D){if(D.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const U=[];for(const[_,F]of D.entries())F||U.push(_);U.reverse();for(const _ of U)this.removeCross(_);return this}toCompact(){const{diagonalSize:D}=this,U=new Array(D*(D+1)/2);for(let _=0,F=0,X=0;X<U.length;X++)U[X]=this.get(F,_),++_>=D&&(_=++F);return U}static fromCompact(D){const U=D.length,_=(Math.sqrt(8*U+1)-1)/2;if(!Number.isInteger(_))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(D)}`);const F=new dE(_);for(let X=0,Ie=0,ke=0;ke<U;ke++)F.set(X,Ie,D[ke]),++X>=_&&(X=++Ie);return F}*upperRightEntries(){for(let D=0,U=0;D<this.diagonalSize;void 0){const _=this.get(D,U);yield[D,U,_],++U>=this.diagonalSize&&(U=++D)}}*upperRightValues(){for(let D=0,U=0;D<this.diagonalSize;void 0)yield this.get(D,U),++U>=this.diagonalSize&&(U=++D)}};ie=new WeakMap;let en=qt;en.prototype.klassType="SymmetricMatrix";class nn extends en{static isDistanceMatrix(D){return en.isSymmetricMatrix(D)&&D.klassSubType==="DistanceMatrix"}constructor(D){if(super(D),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(D,U,_){return D===U&&(_=0),super.set(D,U,_)}addCross(D,U){return U===void 0&&(U=D,D=this.diagonalSize),U=U.slice(),U[D]=0,super.addCross(D,U)}toSymmetricMatrix(){return new en(this)}clone(){const D=new nn(this.diagonalSize);for(const[U,_,F]of this.upperRightEntries())U!==_&&D.set(U,_,F);return D}toCompact(){const{diagonalSize:D}=this,U=(D-1)*D/2,_=new Array(U);for(let F=1,X=0,Ie=0;Ie<_.length;Ie++)_[Ie]=this.get(X,F),++F>=D&&(F=++X+1);return _}static fromCompact(D){const U=D.length;if(U===0)return new this(0);const _=(Math.sqrt(8*U+1)+1)/2;if(!Number.isInteger(_))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(D)}`);const F=new this(_);for(let X=1,Ie=0,ke=0;ke<U;ke++)F.set(X,Ie,D[ke]),++X>=_&&(X=++Ie+1);return F}}nn.prototype.klassSubType="DistanceMatrix";class we extends B{constructor(D,U,_){super(),this.matrix=D,this.rows=U,this.columns=_}}class Q extends we{constructor(D,U){He(D,U),super(D,D.rows,1),this.column=U}set(D,U,_){return this.matrix.set(D,this.column,_),this}get(D){return this.matrix.get(D,this.column)}}class De extends we{constructor(D,U){Yt(D,U),super(D,D.rows,U.length),this.columnIndices=U}set(D,U,_){return this.matrix.set(D,this.columnIndices[U],_),this}get(D,U){return this.matrix.get(D,this.columnIndices[U])}}class We extends we{constructor(D){super(D,D.rows,D.columns)}set(D,U,_){return this.matrix.set(D,this.columns-U-1,_),this}get(D,U){return this.matrix.get(D,this.columns-U-1)}}class Ce extends we{constructor(D){super(D,D.rows,D.columns)}set(D,U,_){return this.matrix.set(this.rows-D-1,U,_),this}get(D,U){return this.matrix.get(this.rows-D-1,U)}}class Re extends we{constructor(D,U){Ge(D,U),super(D,1,D.columns),this.row=U}set(D,U,_){return this.matrix.set(this.row,U,_),this}get(D,U){return this.matrix.get(this.row,U)}}class qe extends we{constructor(D,U){zt(D,U),super(D,U.length,D.columns),this.rowIndices=U}set(D,U,_){return this.matrix.set(this.rowIndices[D],U,_),this}get(D,U){return this.matrix.get(this.rowIndices[D],U)}}class st extends we{constructor(D,U,_){zt(D,U),Yt(D,_),super(D,U.length,_.length),this.rowIndices=U,this.columnIndices=_}set(D,U,_){return this.matrix.set(this.rowIndices[D],this.columnIndices[U],_),this}get(D,U){return this.matrix.get(this.rowIndices[D],this.columnIndices[U])}}class $e extends we{constructor(D,U,_,F,X){At(D,U,_,F,X),super(D,_-U+1,X-F+1),this.startRow=U,this.startColumn=F}set(D,U,_){return this.matrix.set(this.startRow+D,this.startColumn+U,_),this}get(D,U){return this.matrix.get(this.startRow+D,this.startColumn+U)}}class ft extends we{constructor(D){super(D,D.columns,D.rows)}set(D,U,_){return this.matrix.set(U,D,_),this}get(D,U){return this.matrix.get(U,D)}}class Ct extends B{constructor(D,U={}){const{rows:_=1}=U;if(D.length%_!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=_,this.columns=D.length/_,this.data=D}set(D,U,_){let F=this._calculateIndex(D,U);return this.data[F]=_,this}get(D,U){let _=this._calculateIndex(D,U);return this.data[_]}_calculateIndex(D,U){return D*this.columns+U}}class jt extends B{constructor(D){super(),this.data=D,this.rows=D.length,this.columns=D[0].length}set(D,U,_){return this.data[D][U]=_,this}get(D,U){return this.data[D][U]}}function Qt(Pe,D){if(pe.isAnyArray(Pe))return Pe[0]&&pe.isAnyArray(Pe[0])?new jt(Pe):new Ct(Pe,D);throw new Error("the argument is not an array")}class pn{constructor(D){D=jt.checkMatrix(D);let U=D.clone(),_=U.rows,F=U.columns,X=new Float64Array(_),Ie=1,ke,et,nt,Wt,Tt,on,Un,sn,bn;for(ke=0;ke<_;ke++)X[ke]=ke;for(sn=new Float64Array(_),et=0;et<F;et++){for(ke=0;ke<_;ke++)sn[ke]=U.get(ke,et);for(ke=0;ke<_;ke++){for(bn=Math.min(ke,et),Tt=0,nt=0;nt<bn;nt++)Tt+=U.get(ke,nt)*sn[nt];sn[ke]-=Tt,U.set(ke,et,sn[ke])}for(Wt=et,ke=et+1;ke<_;ke++)Math.abs(sn[ke])>Math.abs(sn[Wt])&&(Wt=ke);if(Wt!==et){for(nt=0;nt<F;nt++)on=U.get(Wt,nt),U.set(Wt,nt,U.get(et,nt)),U.set(et,nt,on);Un=X[Wt],X[Wt]=X[et],X[et]=Un,Ie=-Ie}if(et<_&&U.get(et,et)!==0)for(ke=et+1;ke<_;ke++)U.set(ke,et,U.get(ke,et)/U.get(et,et))}this.LU=U,this.pivotVector=X,this.pivotSign=Ie}isSingular(){let D=this.LU,U=D.columns;for(let _=0;_<U;_++)if(D.get(_,_)===0)return!0;return!1}solve(D){D=ct.checkMatrix(D);let U=this.LU;if(U.rows!==D.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let F=D.columns,X=D.subMatrixRow(this.pivotVector,0,F-1),Ie=U.columns,ke,et,nt;for(nt=0;nt<Ie;nt++)for(ke=nt+1;ke<Ie;ke++)for(et=0;et<F;et++)X.set(ke,et,X.get(ke,et)-X.get(nt,et)*U.get(ke,nt));for(nt=Ie-1;nt>=0;nt--){for(et=0;et<F;et++)X.set(nt,et,X.get(nt,et)/U.get(nt,nt));for(ke=0;ke<nt;ke++)for(et=0;et<F;et++)X.set(ke,et,X.get(ke,et)-X.get(nt,et)*U.get(ke,nt))}return X}get determinant(){let D=this.LU;if(!D.isSquare())throw new Error("Matrix must be square");let U=this.pivotSign,_=D.columns;for(let F=0;F<_;F++)U*=D.get(F,F);return U}get lowerTriangularMatrix(){let D=this.LU,U=D.rows,_=D.columns,F=new ct(U,_);for(let X=0;X<U;X++)for(let Ie=0;Ie<_;Ie++)X>Ie?F.set(X,Ie,D.get(X,Ie)):X===Ie?F.set(X,Ie,1):F.set(X,Ie,0);return F}get upperTriangularMatrix(){let D=this.LU,U=D.rows,_=D.columns,F=new ct(U,_);for(let X=0;X<U;X++)for(let Ie=0;Ie<_;Ie++)X<=Ie?F.set(X,Ie,D.get(X,Ie)):F.set(X,Ie,0);return F}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function Wn(Pe,D){let U=0;return Math.abs(Pe)>Math.abs(D)?(U=D/Pe,Math.abs(Pe)*Math.sqrt(1+U*U)):D!==0?(U=Pe/D,Math.abs(D)*Math.sqrt(1+U*U)):0}class Rn{constructor(D){D=jt.checkMatrix(D);let U=D.clone(),_=D.rows,F=D.columns,X=new Float64Array(F),Ie,ke,et,nt;for(et=0;et<F;et++){let Wt=0;for(Ie=et;Ie<_;Ie++)Wt=Wn(Wt,U.get(Ie,et));if(Wt!==0){for(U.get(et,et)<0&&(Wt=-Wt),Ie=et;Ie<_;Ie++)U.set(Ie,et,U.get(Ie,et)/Wt);for(U.set(et,et,U.get(et,et)+1),ke=et+1;ke<F;ke++){for(nt=0,Ie=et;Ie<_;Ie++)nt+=U.get(Ie,et)*U.get(Ie,ke);for(nt=-nt/U.get(et,et),Ie=et;Ie<_;Ie++)U.set(Ie,ke,U.get(Ie,ke)+nt*U.get(Ie,et))}}X[et]=-Wt}this.QR=U,this.Rdiag=X}solve(D){D=ct.checkMatrix(D);let U=this.QR,_=U.rows;if(D.rows!==_)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let F=D.columns,X=D.clone(),Ie=U.columns,ke,et,nt,Wt;for(nt=0;nt<Ie;nt++)for(et=0;et<F;et++){for(Wt=0,ke=nt;ke<_;ke++)Wt+=U.get(ke,nt)*X.get(ke,et);for(Wt=-Wt/U.get(nt,nt),ke=nt;ke<_;ke++)X.set(ke,et,X.get(ke,et)+Wt*U.get(ke,nt))}for(nt=Ie-1;nt>=0;nt--){for(et=0;et<F;et++)X.set(nt,et,X.get(nt,et)/this.Rdiag[nt]);for(ke=0;ke<nt;ke++)for(et=0;et<F;et++)X.set(ke,et,X.get(ke,et)-X.get(nt,et)*U.get(ke,nt))}return X.subMatrix(0,Ie-1,0,F-1)}isFullRank(){let D=this.QR.columns;for(let U=0;U<D;U++)if(this.Rdiag[U]===0)return!1;return!0}get upperTriangularMatrix(){let D=this.QR,U=D.columns,_=new ct(U,U),F,X;for(F=0;F<U;F++)for(X=0;X<U;X++)F<X?_.set(F,X,D.get(F,X)):F===X?_.set(F,X,this.Rdiag[F]):_.set(F,X,0);return _}get orthogonalMatrix(){let D=this.QR,U=D.rows,_=D.columns,F=new ct(U,_),X,Ie,ke,et;for(ke=_-1;ke>=0;ke--){for(X=0;X<U;X++)F.set(X,ke,0);for(F.set(ke,ke,1),Ie=ke;Ie<_;Ie++)if(D.get(ke,ke)!==0){for(et=0,X=ke;X<U;X++)et+=D.get(X,ke)*F.get(X,Ie);for(et=-et/D.get(ke,ke),X=ke;X<U;X++)F.set(X,Ie,F.get(X,Ie)+et*D.get(X,ke))}}return F}}class bi{constructor(D,U={}){if(D=jt.checkMatrix(D),D.isEmpty())throw new Error("Matrix must be non-empty");let _=D.rows,F=D.columns;const{computeLeftSingularVectors:X=!0,computeRightSingularVectors:Ie=!0,autoTranspose:ke=!1}=U;let et=!!X,nt=!!Ie,Wt=!1,Tt;if(_<F)if(!ke)Tt=D.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else{Tt=D.transpose(),_=Tt.rows,F=Tt.columns,Wt=!0;let Zt=et;et=nt,nt=Zt}else Tt=D.clone();let on=Math.min(_,F),Un=Math.min(_+1,F),sn=new Float64Array(Un),bn=new ct(_,on),ti=new ct(F,F),Bt=new Float64Array(F),$n=new Float64Array(_),ni=new Float64Array(Un);for(let Zt=0;Zt<Un;Zt++)ni[Zt]=Zt;let Pi=Math.min(_-1,F),ui=Math.max(0,Math.min(F-2,_)),Lr=Math.max(Pi,ui);for(let Zt=0;Zt<Lr;Zt++){if(Zt<Pi){sn[Zt]=0;for(let Fn=Zt;Fn<_;Fn++)sn[Zt]=Wn(sn[Zt],Tt.get(Fn,Zt));if(sn[Zt]!==0){Tt.get(Zt,Zt)<0&&(sn[Zt]=-sn[Zt]);for(let Fn=Zt;Fn<_;Fn++)Tt.set(Fn,Zt,Tt.get(Fn,Zt)/sn[Zt]);Tt.set(Zt,Zt,Tt.get(Zt,Zt)+1)}sn[Zt]=-sn[Zt]}for(let Fn=Zt+1;Fn<F;Fn++){if(Zt<Pi&&sn[Zt]!==0){let hi=0;for(let Xn=Zt;Xn<_;Xn++)hi+=Tt.get(Xn,Zt)*Tt.get(Xn,Fn);hi=-hi/Tt.get(Zt,Zt);for(let Xn=Zt;Xn<_;Xn++)Tt.set(Xn,Fn,Tt.get(Xn,Fn)+hi*Tt.get(Xn,Zt))}Bt[Fn]=Tt.get(Zt,Fn)}if(et&&Zt<Pi)for(let Fn=Zt;Fn<_;Fn++)bn.set(Fn,Zt,Tt.get(Fn,Zt));if(Zt<ui){Bt[Zt]=0;for(let Fn=Zt+1;Fn<F;Fn++)Bt[Zt]=Wn(Bt[Zt],Bt[Fn]);if(Bt[Zt]!==0){Bt[Zt+1]<0&&(Bt[Zt]=0-Bt[Zt]);for(let Fn=Zt+1;Fn<F;Fn++)Bt[Fn]/=Bt[Zt];Bt[Zt+1]+=1}if(Bt[Zt]=-Bt[Zt],Zt+1<_&&Bt[Zt]!==0){for(let Fn=Zt+1;Fn<_;Fn++)$n[Fn]=0;for(let Fn=Zt+1;Fn<_;Fn++)for(let hi=Zt+1;hi<F;hi++)$n[Fn]+=Bt[hi]*Tt.get(Fn,hi);for(let Fn=Zt+1;Fn<F;Fn++){let hi=-Bt[Fn]/Bt[Zt+1];for(let Xn=Zt+1;Xn<_;Xn++)Tt.set(Xn,Fn,Tt.get(Xn,Fn)+hi*$n[Xn])}}if(nt)for(let Fn=Zt+1;Fn<F;Fn++)ti.set(Fn,Zt,Bt[Fn])}}let yi=Math.min(F,_+1);if(Pi<F&&(sn[Pi]=Tt.get(Pi,Pi)),_<yi&&(sn[yi-1]=0),ui+1<yi&&(Bt[ui]=Tt.get(ui,yi-1)),Bt[yi-1]=0,et){for(let Zt=Pi;Zt<on;Zt++){for(let Fn=0;Fn<_;Fn++)bn.set(Fn,Zt,0);bn.set(Zt,Zt,1)}for(let Zt=Pi-1;Zt>=0;Zt--)if(sn[Zt]!==0){for(let Fn=Zt+1;Fn<on;Fn++){let hi=0;for(let Xn=Zt;Xn<_;Xn++)hi+=bn.get(Xn,Zt)*bn.get(Xn,Fn);hi=-hi/bn.get(Zt,Zt);for(let Xn=Zt;Xn<_;Xn++)bn.set(Xn,Fn,bn.get(Xn,Fn)+hi*bn.get(Xn,Zt))}for(let Fn=Zt;Fn<_;Fn++)bn.set(Fn,Zt,-bn.get(Fn,Zt));bn.set(Zt,Zt,1+bn.get(Zt,Zt));for(let Fn=0;Fn<Zt-1;Fn++)bn.set(Fn,Zt,0)}else{for(let Fn=0;Fn<_;Fn++)bn.set(Fn,Zt,0);bn.set(Zt,Zt,1)}}if(nt)for(let Zt=F-1;Zt>=0;Zt--){if(Zt<ui&&Bt[Zt]!==0)for(let Fn=Zt+1;Fn<F;Fn++){let hi=0;for(let Xn=Zt+1;Xn<F;Xn++)hi+=ti.get(Xn,Zt)*ti.get(Xn,Fn);hi=-hi/ti.get(Zt+1,Zt);for(let Xn=Zt+1;Xn<F;Xn++)ti.set(Xn,Fn,ti.get(Xn,Fn)+hi*ti.get(Xn,Zt))}for(let Fn=0;Fn<F;Fn++)ti.set(Fn,Zt,0);ti.set(Zt,Zt,1)}let vi=yi-1,Mr=Number.EPSILON;for(;yi>0;){let Zt,Fn;for(Zt=yi-2;Zt>=-1&&Zt!==-1;Zt--){const hi=Number.MIN_VALUE+Mr*Math.abs(sn[Zt]+Math.abs(sn[Zt+1]));if(Math.abs(Bt[Zt])<=hi||Number.isNaN(Bt[Zt])){Bt[Zt]=0;break}}if(Zt===yi-2)Fn=4;else{let hi;for(hi=yi-1;hi>=Zt&&hi!==Zt;hi--){let Xn=(hi!==yi?Math.abs(Bt[hi]):0)+(hi!==Zt+1?Math.abs(Bt[hi-1]):0);if(Math.abs(sn[hi])<=Mr*Xn){sn[hi]=0;break}}hi===Zt?Fn=3:hi===yi-1?Fn=1:(Fn=2,Zt=hi)}switch(Zt++,Fn){case 1:{let hi=Bt[yi-2];Bt[yi-2]=0;for(let Xn=yi-2;Xn>=Zt;Xn--){let ds=Wn(sn[Xn],hi),qr=sn[Xn]/ds,vs=hi/ds;if(sn[Xn]=ds,Xn!==Zt&&(hi=-vs*Bt[Xn-1],Bt[Xn-1]=qr*Bt[Xn-1]),nt)for(let kr=0;kr<F;kr++)ds=qr*ti.get(kr,Xn)+vs*ti.get(kr,yi-1),ti.set(kr,yi-1,-vs*ti.get(kr,Xn)+qr*ti.get(kr,yi-1)),ti.set(kr,Xn,ds)}break}case 2:{let hi=Bt[Zt-1];Bt[Zt-1]=0;for(let Xn=Zt;Xn<yi;Xn++){let ds=Wn(sn[Xn],hi),qr=sn[Xn]/ds,vs=hi/ds;if(sn[Xn]=ds,hi=-vs*Bt[Xn],Bt[Xn]=qr*Bt[Xn],et)for(let kr=0;kr<_;kr++)ds=qr*bn.get(kr,Xn)+vs*bn.get(kr,Zt-1),bn.set(kr,Zt-1,-vs*bn.get(kr,Xn)+qr*bn.get(kr,Zt-1)),bn.set(kr,Xn,ds)}break}case 3:{const hi=Math.max(Math.abs(sn[yi-1]),Math.abs(sn[yi-2]),Math.abs(Bt[yi-2]),Math.abs(sn[Zt]),Math.abs(Bt[Zt])),Xn=sn[yi-1]/hi,ds=sn[yi-2]/hi,qr=Bt[yi-2]/hi,vs=sn[Zt]/hi,kr=Bt[Zt]/hi,Fs=((ds+Xn)*(ds-Xn)+qr*qr)/2,io=Xn*qr*(Xn*qr);let ro=0;(Fs!==0||io!==0)&&(Fs<0?ro=0-Math.sqrt(Fs*Fs+io):ro=Math.sqrt(Fs*Fs+io),ro=io/(Fs+ro));let To=(vs+Xn)*(vs-Xn)+ro,Eo=vs*kr;for(let Wr=Zt;Wr<yi-1;Wr++){let eo=Wn(To,Eo);eo===0&&(eo=Number.MIN_VALUE);let Ao=To/eo,so=Eo/eo;if(Wr!==Zt&&(Bt[Wr-1]=eo),To=Ao*sn[Wr]+so*Bt[Wr],Bt[Wr]=Ao*Bt[Wr]-so*sn[Wr],Eo=so*sn[Wr+1],sn[Wr+1]=Ao*sn[Wr+1],nt)for(let Yr=0;Yr<F;Yr++)eo=Ao*ti.get(Yr,Wr)+so*ti.get(Yr,Wr+1),ti.set(Yr,Wr+1,-so*ti.get(Yr,Wr)+Ao*ti.get(Yr,Wr+1)),ti.set(Yr,Wr,eo);if(eo=Wn(To,Eo),eo===0&&(eo=Number.MIN_VALUE),Ao=To/eo,so=Eo/eo,sn[Wr]=eo,To=Ao*Bt[Wr]+so*sn[Wr+1],sn[Wr+1]=-so*Bt[Wr]+Ao*sn[Wr+1],Eo=so*Bt[Wr+1],Bt[Wr+1]=Ao*Bt[Wr+1],et&&Wr<_-1)for(let Yr=0;Yr<_;Yr++)eo=Ao*bn.get(Yr,Wr)+so*bn.get(Yr,Wr+1),bn.set(Yr,Wr+1,-so*bn.get(Yr,Wr)+Ao*bn.get(Yr,Wr+1)),bn.set(Yr,Wr,eo)}Bt[yi-2]=To;break}case 4:{if(sn[Zt]<=0&&(sn[Zt]=sn[Zt]<0?-sn[Zt]:0,nt))for(let hi=0;hi<=vi;hi++)ti.set(hi,Zt,-ti.get(hi,Zt));for(;Zt<vi&&!(sn[Zt]>=sn[Zt+1]);){let hi=sn[Zt];if(sn[Zt]=sn[Zt+1],sn[Zt+1]=hi,nt&&Zt<F-1)for(let Xn=0;Xn<F;Xn++)hi=ti.get(Xn,Zt+1),ti.set(Xn,Zt+1,ti.get(Xn,Zt)),ti.set(Xn,Zt,hi);if(et&&Zt<_-1)for(let Xn=0;Xn<_;Xn++)hi=bn.get(Xn,Zt+1),bn.set(Xn,Zt+1,bn.get(Xn,Zt)),bn.set(Xn,Zt,hi);Zt++}yi--;break}}}if(Wt){let Zt=ti;ti=bn,bn=Zt}this.m=_,this.n=F,this.s=sn,this.U=bn,this.V=ti}solve(D){let U=D,_=this.threshold,F=this.s.length,X=ct.zeros(F,F);for(let on=0;on<F;on++)Math.abs(this.s[on])<=_?X.set(on,on,0):X.set(on,on,1/this.s[on]);let Ie=this.U,ke=this.rightSingularVectors,et=ke.mmul(X),nt=ke.rows,Wt=Ie.rows,Tt=ct.zeros(nt,Wt);for(let on=0;on<nt;on++)for(let Un=0;Un<Wt;Un++){let sn=0;for(let bn=0;bn<F;bn++)sn+=et.get(on,bn)*Ie.get(Un,bn);Tt.set(on,Un,sn)}return Tt.mmul(U)}solveForDiagonal(D){return this.solve(ct.diag(D))}inverse(){let D=this.V,U=this.threshold,_=D.rows,F=D.columns,X=new ct(_,this.s.length);for(let Wt=0;Wt<_;Wt++)for(let Tt=0;Tt<F;Tt++)Math.abs(this.s[Tt])>U&&X.set(Wt,Tt,D.get(Wt,Tt)/this.s[Tt]);let Ie=this.U,ke=Ie.rows,et=Ie.columns,nt=new ct(_,ke);for(let Wt=0;Wt<_;Wt++)for(let Tt=0;Tt<ke;Tt++){let on=0;for(let Un=0;Un<et;Un++)on+=X.get(Wt,Un)*Ie.get(Tt,Un);nt.set(Wt,Tt,on)}return nt}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let D=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,U=0,_=this.s;for(let F=0,X=_.length;F<X;F++)_[F]>D&&U++;return U}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return ct.diag(this.s)}}function Dr(Pe,D=!1){return Pe=jt.checkMatrix(Pe),D?new bi(Pe).inverse():Qn(Pe,ct.eye(Pe.rows))}function Qn(Pe,D,U=!1){return Pe=jt.checkMatrix(Pe),D=jt.checkMatrix(D),U?new bi(Pe).solve(D):Pe.isSquare()?new pn(Pe).solve(D):new Rn(Pe).solve(D)}function Vi(Pe){if(Pe=ct.checkMatrix(Pe),Pe.isSquare()){if(Pe.columns===0)return 1;let D,U,_,F;if(Pe.columns===2)return D=Pe.get(0,0),U=Pe.get(0,1),_=Pe.get(1,0),F=Pe.get(1,1),D*F-U*_;if(Pe.columns===3){let X,Ie,ke;return X=new st(Pe,[1,2],[1,2]),Ie=new st(Pe,[1,2],[0,2]),ke=new st(Pe,[1,2],[0,1]),D=Pe.get(0,0),U=Pe.get(0,1),_=Pe.get(0,2),D*Vi(X)-U*Vi(Ie)+_*Vi(ke)}else return new pn(Pe).determinant}else throw Error("determinant can only be calculated for a square matrix")}function Oi(Pe,D){let U=[];for(let _=0;_<Pe;_++)_!==D&&U.push(_);return U}function Gi(Pe,D,U,_=1e-9,F=1e-9){if(Pe>F)return new Array(D.rows+1).fill(0);{let X=D.addRow(U,[0]);for(let Ie=0;Ie<X.rows;Ie++)Math.abs(X.get(Ie,0))<_&&X.set(Ie,0,0);return X.to1DArray()}}function ir(Pe,D={}){const{thresholdValue:U=1e-9,thresholdError:_=1e-9}=D;Pe=ct.checkMatrix(Pe);let F=Pe.rows,X=new ct(F,F);for(let Ie=0;Ie<F;Ie++){let ke=ct.columnVector(Pe.getRow(Ie)),et=Pe.subMatrixRow(Oi(F,Ie)).transpose(),Wt=new bi(et).solve(ke),Tt=ct.sub(ke,et.mmul(Wt)).abs().max();X.setRow(Ie,Gi(Tt,Wt,Ie,U,_))}return X}function gs(Pe,D=Number.EPSILON){if(Pe=ct.checkMatrix(Pe),Pe.isEmpty())return Pe.transpose();let U=new bi(Pe,{autoTranspose:!0}),_=U.leftSingularVectors,F=U.rightSingularVectors,X=U.diagonal;for(let Ie=0;Ie<X.length;Ie++)Math.abs(X[Ie])>D?X[Ie]=1/X[Ie]:X[Ie]=0;return F.mmul(ct.diag(X).mmul(_.transpose()))}function Ls(Pe,D=Pe,U={}){Pe=new ct(Pe);let _=!1;if(typeof D=="object"&&!ct.isMatrix(D)&&!pe.isAnyArray(D)?(U=D,D=Pe,_=!0):D=new ct(D),Pe.rows!==D.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:F=!0}=U;F&&(Pe=Pe.center("column"),_||(D=D.center("column")));const X=Pe.transpose().mmul(D);for(let Ie=0;Ie<X.rows;Ie++)for(let ke=0;ke<X.columns;ke++)X.set(Ie,ke,X.get(Ie,ke)*(1/(Pe.rows-1)));return X}function ls(Pe,D=Pe,U={}){Pe=new ct(Pe);let _=!1;if(typeof D=="object"&&!ct.isMatrix(D)&&!pe.isAnyArray(D)?(U=D,D=Pe,_=!0):D=new ct(D),Pe.rows!==D.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:F=!0,scale:X=!0}=U;F&&(Pe.center("column"),_||D.center("column")),X&&(Pe.scale("column"),_||D.scale("column"));const Ie=Pe.standardDeviation("column",{unbiased:!0}),ke=_?Ie:D.standardDeviation("column",{unbiased:!0}),et=Pe.transpose().mmul(D);for(let nt=0;nt<et.rows;nt++)for(let Wt=0;Wt<et.columns;Wt++)et.set(nt,Wt,et.get(nt,Wt)*(1/(Ie[nt]*ke[Wt]))*(1/(Pe.rows-1)));return et}class ys{constructor(D,U={}){const{assumeSymmetric:_=!1}=U;if(D=jt.checkMatrix(D),!D.isSquare())throw new Error("Matrix is not a square matrix");if(D.isEmpty())throw new Error("Matrix must be non-empty");let F=D.columns,X=new ct(F,F),Ie=new Float64Array(F),ke=new Float64Array(F),et=D,nt,Wt,Tt=!1;if(_?Tt=!0:Tt=D.isSymmetric(),Tt){for(nt=0;nt<F;nt++)for(Wt=0;Wt<F;Wt++)X.set(nt,Wt,et.get(nt,Wt));Gs(F,ke,Ie,X),Yl(F,ke,Ie,X)}else{let on=new ct(F,F),Un=new Float64Array(F);for(Wt=0;Wt<F;Wt++)for(nt=0;nt<F;nt++)on.set(nt,Wt,et.get(nt,Wt));Zl(F,on,Un,X),Fa(F,ke,Ie,X,on)}this.n=F,this.e=ke,this.d=Ie,this.V=X}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let D=this.n,U=this.e,_=this.d,F=new ct(D,D),X,Ie;for(X=0;X<D;X++){for(Ie=0;Ie<D;Ie++)F.set(X,Ie,0);F.set(X,X,_[X]),U[X]>0?F.set(X,X+1,U[X]):U[X]<0&&F.set(X,X-1,U[X])}return F}}function Gs(Pe,D,U,_){let F,X,Ie,ke,et,nt,Wt,Tt;for(et=0;et<Pe;et++)U[et]=_.get(Pe-1,et);for(ke=Pe-1;ke>0;ke--){for(Tt=0,Ie=0,nt=0;nt<ke;nt++)Tt=Tt+Math.abs(U[nt]);if(Tt===0)for(D[ke]=U[ke-1],et=0;et<ke;et++)U[et]=_.get(ke-1,et),_.set(ke,et,0),_.set(et,ke,0);else{for(nt=0;nt<ke;nt++)U[nt]/=Tt,Ie+=U[nt]*U[nt];for(F=U[ke-1],X=Math.sqrt(Ie),F>0&&(X=-X),D[ke]=Tt*X,Ie=Ie-F*X,U[ke-1]=F-X,et=0;et<ke;et++)D[et]=0;for(et=0;et<ke;et++){for(F=U[et],_.set(et,ke,F),X=D[et]+_.get(et,et)*F,nt=et+1;nt<=ke-1;nt++)X+=_.get(nt,et)*U[nt],D[nt]+=_.get(nt,et)*F;D[et]=X}for(F=0,et=0;et<ke;et++)D[et]/=Ie,F+=D[et]*U[et];for(Wt=F/(Ie+Ie),et=0;et<ke;et++)D[et]-=Wt*U[et];for(et=0;et<ke;et++){for(F=U[et],X=D[et],nt=et;nt<=ke-1;nt++)_.set(nt,et,_.get(nt,et)-(F*D[nt]+X*U[nt]));U[et]=_.get(ke-1,et),_.set(ke,et,0)}}U[ke]=Ie}for(ke=0;ke<Pe-1;ke++){if(_.set(Pe-1,ke,_.get(ke,ke)),_.set(ke,ke,1),Ie=U[ke+1],Ie!==0){for(nt=0;nt<=ke;nt++)U[nt]=_.get(nt,ke+1)/Ie;for(et=0;et<=ke;et++){for(X=0,nt=0;nt<=ke;nt++)X+=_.get(nt,ke+1)*_.get(nt,et);for(nt=0;nt<=ke;nt++)_.set(nt,et,_.get(nt,et)-X*U[nt])}}for(nt=0;nt<=ke;nt++)_.set(nt,ke+1,0)}for(et=0;et<Pe;et++)U[et]=_.get(Pe-1,et),_.set(Pe-1,et,0);_.set(Pe-1,Pe-1,1),D[0]=0}function Yl(Pe,D,U,_){let F,X,Ie,ke,et,nt,Wt,Tt,on,Un,sn,bn,ti,Bt,$n,ni;for(Ie=1;Ie<Pe;Ie++)D[Ie-1]=D[Ie];D[Pe-1]=0;let Pi=0,ui=0,Lr=Number.EPSILON;for(nt=0;nt<Pe;nt++){for(ui=Math.max(ui,Math.abs(U[nt])+Math.abs(D[nt])),Wt=nt;Wt<Pe&&!(Math.abs(D[Wt])<=Lr*ui);)Wt++;if(Wt>nt)do{for(F=U[nt],Tt=(U[nt+1]-F)/(2*D[nt]),on=Wn(Tt,1),Tt<0&&(on=-on),U[nt]=D[nt]/(Tt+on),U[nt+1]=D[nt]*(Tt+on),Un=U[nt+1],X=F-U[nt],Ie=nt+2;Ie<Pe;Ie++)U[Ie]-=X;for(Pi=Pi+X,Tt=U[Wt],sn=1,bn=sn,ti=sn,Bt=D[nt+1],$n=0,ni=0,Ie=Wt-1;Ie>=nt;Ie--)for(ti=bn,bn=sn,ni=$n,F=sn*D[Ie],X=sn*Tt,on=Wn(Tt,D[Ie]),D[Ie+1]=$n*on,$n=D[Ie]/on,sn=Tt/on,Tt=sn*U[Ie]-$n*F,U[Ie+1]=X+$n*(sn*F+$n*U[Ie]),et=0;et<Pe;et++)X=_.get(et,Ie+1),_.set(et,Ie+1,$n*_.get(et,Ie)+sn*X),_.set(et,Ie,sn*_.get(et,Ie)-$n*X);Tt=-$n*ni*ti*Bt*D[nt]/Un,D[nt]=$n*Tt,U[nt]=sn*Tt}while(Math.abs(D[nt])>Lr*ui);U[nt]=U[nt]+Pi,D[nt]=0}for(Ie=0;Ie<Pe-1;Ie++){for(et=Ie,Tt=U[Ie],ke=Ie+1;ke<Pe;ke++)U[ke]<Tt&&(et=ke,Tt=U[ke]);if(et!==Ie)for(U[et]=U[Ie],U[Ie]=Tt,ke=0;ke<Pe;ke++)Tt=_.get(ke,Ie),_.set(ke,Ie,_.get(ke,et)),_.set(ke,et,Tt)}}function Zl(Pe,D,U,_){let F=0,X=Pe-1,Ie,ke,et,nt,Wt,Tt,on;for(Tt=F+1;Tt<=X-1;Tt++){for(on=0,nt=Tt;nt<=X;nt++)on=on+Math.abs(D.get(nt,Tt-1));if(on!==0){for(et=0,nt=X;nt>=Tt;nt--)U[nt]=D.get(nt,Tt-1)/on,et+=U[nt]*U[nt];for(ke=Math.sqrt(et),U[Tt]>0&&(ke=-ke),et=et-U[Tt]*ke,U[Tt]=U[Tt]-ke,Wt=Tt;Wt<Pe;Wt++){for(Ie=0,nt=X;nt>=Tt;nt--)Ie+=U[nt]*D.get(nt,Wt);for(Ie=Ie/et,nt=Tt;nt<=X;nt++)D.set(nt,Wt,D.get(nt,Wt)-Ie*U[nt])}for(nt=0;nt<=X;nt++){for(Ie=0,Wt=X;Wt>=Tt;Wt--)Ie+=U[Wt]*D.get(nt,Wt);for(Ie=Ie/et,Wt=Tt;Wt<=X;Wt++)D.set(nt,Wt,D.get(nt,Wt)-Ie*U[Wt])}U[Tt]=on*U[Tt],D.set(Tt,Tt-1,on*ke)}}for(nt=0;nt<Pe;nt++)for(Wt=0;Wt<Pe;Wt++)_.set(nt,Wt,nt===Wt?1:0);for(Tt=X-1;Tt>=F+1;Tt--)if(D.get(Tt,Tt-1)!==0){for(nt=Tt+1;nt<=X;nt++)U[nt]=D.get(nt,Tt-1);for(Wt=Tt;Wt<=X;Wt++){for(ke=0,nt=Tt;nt<=X;nt++)ke+=U[nt]*_.get(nt,Wt);for(ke=ke/U[Tt]/D.get(Tt,Tt-1),nt=Tt;nt<=X;nt++)_.set(nt,Wt,_.get(nt,Wt)+ke*U[nt])}}}function Fa(Pe,D,U,_,F){let X=Pe-1,Ie=0,ke=Pe-1,et=Number.EPSILON,nt=0,Wt=0,Tt=0,on=0,Un=0,sn=0,bn=0,ti=0,Bt,$n,ni,Pi,ui,Lr,yi,vi,Mr,Zt,Fn,hi,Xn,ds,qr;for(Bt=0;Bt<Pe;Bt++)for((Bt<Ie||Bt>ke)&&(U[Bt]=F.get(Bt,Bt),D[Bt]=0),$n=Math.max(Bt-1,0);$n<Pe;$n++)Wt=Wt+Math.abs(F.get(Bt,$n));for(;X>=Ie;){for(Pi=X;Pi>Ie&&(sn=Math.abs(F.get(Pi-1,Pi-1))+Math.abs(F.get(Pi,Pi)),sn===0&&(sn=Wt),!(Math.abs(F.get(Pi,Pi-1))<et*sn));)Pi--;if(Pi===X)F.set(X,X,F.get(X,X)+nt),U[X]=F.get(X,X),D[X]=0,X--,ti=0;else if(Pi===X-1){if(yi=F.get(X,X-1)*F.get(X-1,X),Tt=(F.get(X-1,X-1)-F.get(X,X))/2,on=Tt*Tt+yi,bn=Math.sqrt(Math.abs(on)),F.set(X,X,F.get(X,X)+nt),F.set(X-1,X-1,F.get(X-1,X-1)+nt),vi=F.get(X,X),on>=0){for(bn=Tt>=0?Tt+bn:Tt-bn,U[X-1]=vi+bn,U[X]=U[X-1],bn!==0&&(U[X]=vi-yi/bn),D[X-1]=0,D[X]=0,vi=F.get(X,X-1),sn=Math.abs(vi)+Math.abs(bn),Tt=vi/sn,on=bn/sn,Un=Math.sqrt(Tt*Tt+on*on),Tt=Tt/Un,on=on/Un,$n=X-1;$n<Pe;$n++)bn=F.get(X-1,$n),F.set(X-1,$n,on*bn+Tt*F.get(X,$n)),F.set(X,$n,on*F.get(X,$n)-Tt*bn);for(Bt=0;Bt<=X;Bt++)bn=F.get(Bt,X-1),F.set(Bt,X-1,on*bn+Tt*F.get(Bt,X)),F.set(Bt,X,on*F.get(Bt,X)-Tt*bn);for(Bt=Ie;Bt<=ke;Bt++)bn=_.get(Bt,X-1),_.set(Bt,X-1,on*bn+Tt*_.get(Bt,X)),_.set(Bt,X,on*_.get(Bt,X)-Tt*bn)}else U[X-1]=vi+Tt,U[X]=vi+Tt,D[X-1]=bn,D[X]=-bn;X=X-2,ti=0}else{if(vi=F.get(X,X),Mr=0,yi=0,Pi<X&&(Mr=F.get(X-1,X-1),yi=F.get(X,X-1)*F.get(X-1,X)),ti===10){for(nt+=vi,Bt=Ie;Bt<=X;Bt++)F.set(Bt,Bt,F.get(Bt,Bt)-vi);sn=Math.abs(F.get(X,X-1))+Math.abs(F.get(X-1,X-2)),vi=Mr=.75*sn,yi=-.4375*sn*sn}if(ti===30&&(sn=(Mr-vi)/2,sn=sn*sn+yi,sn>0)){for(sn=Math.sqrt(sn),Mr<vi&&(sn=-sn),sn=vi-yi/((Mr-vi)/2+sn),Bt=Ie;Bt<=X;Bt++)F.set(Bt,Bt,F.get(Bt,Bt)-sn);nt+=sn,vi=Mr=yi=.964}for(ti=ti+1,ui=X-2;ui>=Pi&&(bn=F.get(ui,ui),Un=vi-bn,sn=Mr-bn,Tt=(Un*sn-yi)/F.get(ui+1,ui)+F.get(ui,ui+1),on=F.get(ui+1,ui+1)-bn-Un-sn,Un=F.get(ui+2,ui+1),sn=Math.abs(Tt)+Math.abs(on)+Math.abs(Un),Tt=Tt/sn,on=on/sn,Un=Un/sn,!(ui===Pi||Math.abs(F.get(ui,ui-1))*(Math.abs(on)+Math.abs(Un))<et*(Math.abs(Tt)*(Math.abs(F.get(ui-1,ui-1))+Math.abs(bn)+Math.abs(F.get(ui+1,ui+1))))));)ui--;for(Bt=ui+2;Bt<=X;Bt++)F.set(Bt,Bt-2,0),Bt>ui+2&&F.set(Bt,Bt-3,0);for(ni=ui;ni<=X-1&&(ds=ni!==X-1,ni!==ui&&(Tt=F.get(ni,ni-1),on=F.get(ni+1,ni-1),Un=ds?F.get(ni+2,ni-1):0,vi=Math.abs(Tt)+Math.abs(on)+Math.abs(Un),vi!==0&&(Tt=Tt/vi,on=on/vi,Un=Un/vi)),vi!==0);ni++)if(sn=Math.sqrt(Tt*Tt+on*on+Un*Un),Tt<0&&(sn=-sn),sn!==0){for(ni!==ui?F.set(ni,ni-1,-sn*vi):Pi!==ui&&F.set(ni,ni-1,-F.get(ni,ni-1)),Tt=Tt+sn,vi=Tt/sn,Mr=on/sn,bn=Un/sn,on=on/Tt,Un=Un/Tt,$n=ni;$n<Pe;$n++)Tt=F.get(ni,$n)+on*F.get(ni+1,$n),ds&&(Tt=Tt+Un*F.get(ni+2,$n),F.set(ni+2,$n,F.get(ni+2,$n)-Tt*bn)),F.set(ni,$n,F.get(ni,$n)-Tt*vi),F.set(ni+1,$n,F.get(ni+1,$n)-Tt*Mr);for(Bt=0;Bt<=Math.min(X,ni+3);Bt++)Tt=vi*F.get(Bt,ni)+Mr*F.get(Bt,ni+1),ds&&(Tt=Tt+bn*F.get(Bt,ni+2),F.set(Bt,ni+2,F.get(Bt,ni+2)-Tt*Un)),F.set(Bt,ni,F.get(Bt,ni)-Tt),F.set(Bt,ni+1,F.get(Bt,ni+1)-Tt*on);for(Bt=Ie;Bt<=ke;Bt++)Tt=vi*_.get(Bt,ni)+Mr*_.get(Bt,ni+1),ds&&(Tt=Tt+bn*_.get(Bt,ni+2),_.set(Bt,ni+2,_.get(Bt,ni+2)-Tt*Un)),_.set(Bt,ni,_.get(Bt,ni)-Tt),_.set(Bt,ni+1,_.get(Bt,ni+1)-Tt*on)}}}if(Wt!==0){for(X=Pe-1;X>=0;X--)if(Tt=U[X],on=D[X],on===0)for(Pi=X,F.set(X,X,1),Bt=X-1;Bt>=0;Bt--){for(yi=F.get(Bt,Bt)-Tt,Un=0,$n=Pi;$n<=X;$n++)Un=Un+F.get(Bt,$n)*F.get($n,X);if(D[Bt]<0)bn=yi,sn=Un;else if(Pi=Bt,D[Bt]===0?F.set(Bt,X,yi!==0?-Un/yi:-Un/(et*Wt)):(vi=F.get(Bt,Bt+1),Mr=F.get(Bt+1,Bt),on=(U[Bt]-Tt)*(U[Bt]-Tt)+D[Bt]*D[Bt],Lr=(vi*sn-bn*Un)/on,F.set(Bt,X,Lr),F.set(Bt+1,X,Math.abs(vi)>Math.abs(bn)?(-Un-yi*Lr)/vi:(-sn-Mr*Lr)/bn)),Lr=Math.abs(F.get(Bt,X)),et*Lr*Lr>1)for($n=Bt;$n<=X;$n++)F.set($n,X,F.get($n,X)/Lr)}else if(on<0)for(Pi=X-1,Math.abs(F.get(X,X-1))>Math.abs(F.get(X-1,X))?(F.set(X-1,X-1,on/F.get(X,X-1)),F.set(X-1,X,-(F.get(X,X)-Tt)/F.get(X,X-1))):(qr=Fl(0,-F.get(X-1,X),F.get(X-1,X-1)-Tt,on),F.set(X-1,X-1,qr[0]),F.set(X-1,X,qr[1])),F.set(X,X-1,0),F.set(X,X,1),Bt=X-2;Bt>=0;Bt--){for(Zt=0,Fn=0,$n=Pi;$n<=X;$n++)Zt=Zt+F.get(Bt,$n)*F.get($n,X-1),Fn=Fn+F.get(Bt,$n)*F.get($n,X);if(yi=F.get(Bt,Bt)-Tt,D[Bt]<0)bn=yi,Un=Zt,sn=Fn;else if(Pi=Bt,D[Bt]===0?(qr=Fl(-Zt,-Fn,yi,on),F.set(Bt,X-1,qr[0]),F.set(Bt,X,qr[1])):(vi=F.get(Bt,Bt+1),Mr=F.get(Bt+1,Bt),hi=(U[Bt]-Tt)*(U[Bt]-Tt)+D[Bt]*D[Bt]-on*on,Xn=(U[Bt]-Tt)*2*on,hi===0&&Xn===0&&(hi=et*Wt*(Math.abs(yi)+Math.abs(on)+Math.abs(vi)+Math.abs(Mr)+Math.abs(bn))),qr=Fl(vi*Un-bn*Zt+on*Fn,vi*sn-bn*Fn-on*Zt,hi,Xn),F.set(Bt,X-1,qr[0]),F.set(Bt,X,qr[1]),Math.abs(vi)>Math.abs(bn)+Math.abs(on)?(F.set(Bt+1,X-1,(-Zt-yi*F.get(Bt,X-1)+on*F.get(Bt,X))/vi),F.set(Bt+1,X,(-Fn-yi*F.get(Bt,X)-on*F.get(Bt,X-1))/vi)):(qr=Fl(-Un-Mr*F.get(Bt,X-1),-sn-Mr*F.get(Bt,X),bn,on),F.set(Bt+1,X-1,qr[0]),F.set(Bt+1,X,qr[1]))),Lr=Math.max(Math.abs(F.get(Bt,X-1)),Math.abs(F.get(Bt,X))),et*Lr*Lr>1)for($n=Bt;$n<=X;$n++)F.set($n,X-1,F.get($n,X-1)/Lr),F.set($n,X,F.get($n,X)/Lr)}for(Bt=0;Bt<Pe;Bt++)if(Bt<Ie||Bt>ke)for($n=Bt;$n<Pe;$n++)_.set(Bt,$n,F.get(Bt,$n));for($n=Pe-1;$n>=Ie;$n--)for(Bt=Ie;Bt<=ke;Bt++){for(bn=0,ni=Ie;ni<=Math.min($n,ke);ni++)bn=bn+_.get(Bt,ni)*F.get(ni,$n);_.set(Bt,$n,bn)}}}function Fl(Pe,D,U,_){let F,X;return Math.abs(U)>Math.abs(_)?(F=_/U,X=U+F*_,[(Pe+F*D)/X,(D-F*Pe)/X]):(F=U/_,X=_+F*U,[(F*Pe+D)/X,(F*D-Pe)/X])}class su{constructor(D){if(D=jt.checkMatrix(D),!D.isSymmetric())throw new Error("Matrix is not symmetric");let U=D,_=U.rows,F=new ct(_,_),X=!0,Ie,ke,et;for(ke=0;ke<_;ke++){let nt=0;for(et=0;et<ke;et++){let Wt=0;for(Ie=0;Ie<et;Ie++)Wt+=F.get(et,Ie)*F.get(ke,Ie);Wt=(U.get(ke,et)-Wt)/F.get(et,et),F.set(ke,et,Wt),nt=nt+Wt*Wt}for(nt=U.get(ke,ke)-nt,X&&(X=nt>0),F.set(ke,ke,Math.sqrt(Math.max(nt,0))),et=ke+1;et<_;et++)F.set(ke,et,0)}this.L=F,this.positiveDefinite=X}isPositiveDefinite(){return this.positiveDefinite}solve(D){D=jt.checkMatrix(D);let U=this.L,_=U.rows;if(D.rows!==_)throw new Error("Matrix dimensions do not match");if(this.isPositiveDefinite()===!1)throw new Error("Matrix is not positive definite");let F=D.columns,X=D.clone(),Ie,ke,et;for(et=0;et<_;et++)for(ke=0;ke<F;ke++){for(Ie=0;Ie<et;Ie++)X.set(et,ke,X.get(et,ke)-X.get(Ie,ke)*U.get(et,Ie));X.set(et,ke,X.get(et,ke)/U.get(et,et))}for(et=_-1;et>=0;et--)for(ke=0;ke<F;ke++){for(Ie=et+1;Ie<_;Ie++)X.set(et,ke,X.get(et,ke)-X.get(Ie,ke)*U.get(Ie,et));X.set(et,ke,X.get(et,ke)/U.get(et,et))}return X}get lowerTriangularMatrix(){return this.L}}class Bu{constructor(D,U={}){D=jt.checkMatrix(D);let{Y:_}=U;const{scaleScores:F=!1,maxIterations:X=1e3,terminationCriteria:Ie=1e-10}=U;let ke;if(_){if(pe.isAnyArray(_)&&typeof _[0]=="number"?_=ct.columnVector(_):_=jt.checkMatrix(_),_.rows!==D.rows)throw new Error("Y should have the same number of rows as X");ke=_.getColumnVector(0)}else ke=D.getColumnVector(0);let et=1,nt,Wt,Tt,on;for(let Un=0;Un<X&&et>Ie;Un++)Tt=D.transpose().mmul(ke).div(ke.transpose().mmul(ke).get(0,0)),Tt=Tt.div(Tt.norm()),nt=D.mmul(Tt).div(Tt.transpose().mmul(Tt).get(0,0)),Un>0&&(et=nt.clone().sub(on).pow(2).sum()),on=nt.clone(),_?(Wt=_.transpose().mmul(nt).div(nt.transpose().mmul(nt).get(0,0)),Wt=Wt.div(Wt.norm()),ke=_.mmul(Wt).div(Wt.transpose().mmul(Wt).get(0,0))):ke=nt;if(_){let Un=D.transpose().mmul(nt).div(nt.transpose().mmul(nt).get(0,0));Un=Un.div(Un.norm());let sn=D.clone().sub(nt.clone().mmul(Un.transpose())),bn=ke.transpose().mmul(nt).div(nt.transpose().mmul(nt).get(0,0)),ti=_.clone().sub(nt.clone().mulS(bn.get(0,0)).mmul(Wt.transpose()));this.t=nt,this.p=Un.transpose(),this.w=Tt.transpose(),this.q=Wt,this.u=ke,this.s=nt.transpose().mmul(nt),this.xResidual=sn,this.yResidual=ti,this.betas=bn}else this.w=Tt.transpose(),this.s=nt.transpose().mmul(nt).sqrt(),F?this.t=nt.clone().div(this.s.get(0,0)):this.t=nt,this.xResidual=D.sub(nt.mmul(Tt.transpose()))}}ee.XA=B,ee.a_=su,ee.yQ=su,ee.Hs=nn,ee.Ec=ys,ee.dx=ys,ee.LU=pn,ee.Rm=pn,ee.y3=ct,ee.qK=De,ee.pb=Q,ee.j=We,ee.sO=Ce,ee.BZ=qe,ee.EK=Re,ee.Db=st,ee.Fx=$e,ee.tU=ft,ee.Ym=Bu,ee.rs=Bu,ee.QR=Rn,ee.TB=Rn,ee.oH=bi,ee.Sc=bi,ee.BN=en,ee.it=Ct,ee.$r=jt,ee.QM=ls,ee.AV=Ls,w=ct,ee.GH=Vi,ee.SO=Dr,ee.uZ=ir,ee.yU=gs,ee.F1=Qn,ee.re=Qt},22150:function(se,ee,b){"use strict";b.d(ee,{default:function(){return U}});var w=b(74902),k=b(94184),O=b.n(k),R=b(38379),S=b(67294),C=b(33603),x=b(65223);function E(_){const[F,X]=S.useState(_);return S.useEffect(()=>{const Ie=setTimeout(()=>{X(_)},_.length?0:10);return()=>{clearTimeout(Ie)}},[_]),F}var N=b(14747),L=b(50438),P=b(33507),W=b(45503),Y=b(67968),pe=_=>{const{componentCls:F}=_,X=`${F}-show-help`,Ie=`${F}-show-help-item`;return{[X]:{transition:`opacity ${_.motionDurationSlow} ${_.motionEaseInOut}`,"&-appear, &-enter":{opacity:0,"&-active":{opacity:1}},"&-leave":{opacity:1,"&-active":{opacity:0}},[Ie]:{overflow:"hidden",transition:`height ${_.motionDurationSlow} ${_.motionEaseInOut},
|
|
|
opacity ${_.motionDurationSlow} ${_.motionEaseInOut},
|
|
|
transform ${_.motionDurationSlow} ${_.motionEaseInOut} !important`,[`&${Ie}-appear, &${Ie}-enter`]:{transform:"translateY(-5px)",opacity:0,"&-active":{transform:"translateY(0)",opacity:1}},[`&${Ie}-leave-active`]:{transform:"translateY(-5px)"}}}}};const fe=_=>({legend:{display:"block",width:"100%",marginBottom:_.marginLG,padding:0,color:_.colorTextDescription,fontSize:_.fontSizeLG,lineHeight:"inherit",border:0,borderBottom:`${_.lineWidth}px ${_.lineType} ${_.colorBorder}`},label:{fontSize:_.fontSize},'input[type="search"]':{boxSizing:"border-box"},'input[type="radio"], input[type="checkbox"]':{lineHeight:"normal"},'input[type="file"]':{display:"block"},'input[type="range"]':{display:"block",width:"100%"},"select[multiple], select[size]":{height:"auto"},"input[type='file']:focus,\n input[type='radio']:focus,\n input[type='checkbox']:focus":{outline:0,boxShadow:`0 0 0 ${_.controlOutlineWidth}px ${_.controlOutline}`},output:{display:"block",paddingTop:15,color:_.colorText,fontSize:_.fontSize,lineHeight:_.lineHeight}}),ae=(_,F)=>{const{formItemCls:X}=_;return{[X]:{[`${X}-label > label`]:{height:F},[`${X}-control-input`]:{minHeight:F}}}},ye=_=>{const{componentCls:F}=_;return{[_.componentCls]:Object.assign(Object.assign(Object.assign({},(0,N.Wf)(_)),fe(_)),{[`${F}-text`]:{display:"inline-block",paddingInlineEnd:_.paddingSM},"&-small":Object.assign({},ae(_,_.controlHeightSM)),"&-large":Object.assign({},ae(_,_.controlHeightLG))})}},ue=_=>{const{formItemCls:F,iconCls:X,componentCls:Ie,rootPrefixCls:ke,labelRequiredMarkColor:et,labelColor:nt,labelFontSize:Wt,labelHeight:Tt,labelColonMarginInlineStart:on,labelColonMarginInlineEnd:Un,itemMarginBottom:sn}=_;return{[F]:Object.assign(Object.assign({},(0,N.Wf)(_)),{marginBottom:sn,verticalAlign:"top","&-with-help":{transition:"none"},[`&-hidden,
|
|
|
&-hidden.${ke}-row`]:{display:"none"},"&-has-warning":{[`${F}-split`]:{color:_.colorError}},"&-has-error":{[`${F}-split`]:{color:_.colorWarning}},[`${F}-label`]:{flexGrow:0,overflow:"hidden",whiteSpace:"nowrap",textAlign:"end",verticalAlign:"middle","&-left":{textAlign:"start"},"&-wrap":{overflow:"unset",lineHeight:`${_.lineHeight} - 0.25em`,whiteSpace:"unset"},"> label":{position:"relative",display:"inline-flex",alignItems:"center",maxWidth:"100%",height:Tt,color:nt,fontSize:Wt,[`> ${X}`]:{fontSize:_.fontSize,verticalAlign:"top"},[`&${F}-required:not(${F}-required-mark-optional)::before`]:{display:"inline-block",marginInlineEnd:_.marginXXS,color:et,fontSize:_.fontSize,fontFamily:"SimSun, sans-serif",lineHeight:1,content:'"*"',[`${Ie}-hide-required-mark &`]:{display:"none"}},[`${F}-optional`]:{display:"inline-block",marginInlineStart:_.marginXXS,color:_.colorTextDescription,[`${Ie}-hide-required-mark &`]:{display:"none"}},[`${F}-tooltip`]:{color:_.colorTextDescription,cursor:"help",writingMode:"horizontal-tb",marginInlineStart:_.marginXXS},"&::after":{content:'":"',position:"relative",marginBlock:0,marginInlineStart:on,marginInlineEnd:Un},[`&${F}-no-colon::after`]:{content:'"\\a0"'}}},[`${F}-control`]:{"--ant-display":"flex",flexDirection:"column",flexGrow:1,[`&:first-child:not([class^="'${ke}-col-'"]):not([class*="' ${ke}-col-'"])`]:{width:"100%"},"&-input":{position:"relative",display:"flex",alignItems:"center",minHeight:_.controlHeight,"&-content":{flex:"auto",maxWidth:"100%"}}},[F]:{"&-explain, &-extra":{clear:"both",color:_.colorTextDescription,fontSize:_.fontSize,lineHeight:_.lineHeight},"&-explain-connected":{width:"100%"},"&-extra":{minHeight:_.controlHeightSM,transition:`color ${_.motionDurationMid} ${_.motionEaseOut}`},"&-explain":{"&-error":{color:_.colorError},"&-warning":{color:_.colorWarning}}},[`&-with-help ${F}-explain`]:{height:"auto",opacity:1},[`${F}-feedback-icon`]:{fontSize:_.fontSize,textAlign:"center",visibility:"visible",animationName:L.kr,animationDuration:_.motionDurationMid,animationTimingFunction:_.motionEaseOutBack,pointerEvents:"none","&-success":{color:_.colorSuccess},"&-error":{color:_.colorError},"&-warning":{color:_.colorWarning},"&-validating":{color:_.colorPrimary}}})}},Ne=_=>{const{componentCls:F,formItemCls:X}=_;return{[`${F}-horizontal`]:{[`${X}-label`]:{flexGrow:0},[`${X}-control`]:{flex:"1 1 0",minWidth:0},[`${X}-label[class$='-24'], ${X}-label[class*='-24 ']`]:{[`& + ${X}-control`]:{minWidth:"unset"}}}}},Te=_=>{const{componentCls:F,formItemCls:X}=_;return{[`${F}-inline`]:{display:"flex",flexWrap:"wrap",[X]:{flex:"none",marginInlineEnd:_.margin,marginBottom:0,"&-row":{flexWrap:"nowrap"},[`> ${X}-label,
|
|
|
> ${X}-control`]:{display:"inline-block",verticalAlign:"top"},[`> ${X}-label`]:{flex:"none"},[`${F}-text`]:{display:"inline-block"},[`${X}-has-feedback`]:{display:"inline-block"}}}}},_e=_=>({padding:_.verticalLabelPadding,margin:_.verticalLabelMargin,whiteSpace:"initial",textAlign:"start","> label":{margin:0,"&::after":{visibility:"hidden"}}}),Xe=_=>{const{componentCls:F,formItemCls:X,rootPrefixCls:Ie}=_;return{[`${X} ${X}-label`]:_e(_),[F]:{[X]:{flexWrap:"wrap",[`${X}-label, ${X}-control`]:{[`&:not([class*=" ${Ie}-col-xs"])`]:{flex:"0 0 100%",maxWidth:"100%"}}}}}},Se=_=>{const{componentCls:F,formItemCls:X,rootPrefixCls:Ie}=_;return{[`${F}-vertical`]:{[X]:{"&-row":{flexDirection:"column"},"&-label > label":{height:"auto"},[`${F}-item-control`]:{width:"100%"}}},[`${F}-vertical ${X}-label,
|
|
|
.${Ie}-col-24${X}-label,
|
|
|
.${Ie}-col-xl-24${X}-label`]:_e(_),[`@media (max-width: ${_.screenXSMax}px)`]:[Xe(_),{[F]:{[`.${Ie}-col-xs-24${X}-label`]:_e(_)}}],[`@media (max-width: ${_.screenSMMax}px)`]:{[F]:{[`.${Ie}-col-sm-24${X}-label`]:_e(_)}},[`@media (max-width: ${_.screenMDMax}px)`]:{[F]:{[`.${Ie}-col-md-24${X}-label`]:_e(_)}},[`@media (max-width: ${_.screenLGMax}px)`]:{[F]:{[`.${Ie}-col-lg-24${X}-label`]:_e(_)}}}},Ge=(_,F)=>(0,W.TS)(_,{formItemCls:`${_.componentCls}-item`,rootPrefixCls:F});var He=(0,Y.Z)("Form",(_,F)=>{let{rootPrefixCls:X}=F;const Ie=Ge(_,X);return[ye(Ie),ue(Ie),pe(Ie),Ne(Ie),Te(Ie),Se(Ie),(0,P.Z)(Ie),L.kr]},_=>({labelRequiredMarkColor:_.colorError,labelColor:_.colorTextHeading,labelFontSize:_.fontSize,labelHeight:_.controlHeight,labelColonMarginInlineStart:_.marginXXS/2,labelColonMarginInlineEnd:_.marginXS,itemMarginBottom:_.marginLG,verticalLabelPadding:`0 0 ${_.paddingXS}px`,verticalLabelMargin:0}),{order:-1e3});const vt=[];function It(_,F,X){let Ie=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;return{key:typeof _=="string"?_:`${F}-${Ie}`,error:_,errorStatus:X}}var Yt=_=>{let{help:F,helpStatus:X,errors:Ie=vt,warnings:ke=vt,className:et,fieldId:nt,onVisibleChanged:Wt}=_;const{prefixCls:Tt}=S.useContext(x.Rk),on=`${Tt}-item-explain`,[,Un]=He(Tt),sn=(0,S.useMemo)(()=>(0,C.Z)(Tt),[Tt]),bn=E(Ie),ti=E(ke),Bt=S.useMemo(()=>F!=null?[It(F,"help",X)]:[].concat((0,w.Z)(bn.map((ni,Pi)=>It(ni,"error","error",Pi))),(0,w.Z)(ti.map((ni,Pi)=>It(ni,"warning","warning",Pi)))),[F,X,bn,ti]),$n={};return nt&&($n.id=`${nt}_help`),S.createElement(R.default,{motionDeadline:sn.motionDeadline,motionName:`${Tt}-show-help`,visible:!!Bt.length,onVisibleChanged:Wt},ni=>{const{className:Pi,style:ui}=ni;return S.createElement("div",Object.assign({},$n,{className:O()(on,Pi,et,Un),style:ui,role:"alert"}),S.createElement(R.CSSMotionList,Object.assign({keys:Bt},(0,C.Z)(Tt),{motionName:`${Tt}-show-help-item`,component:!1}),Lr=>{const{key:yi,error:vi,errorStatus:Mr,className:Zt,style:Fn}=Lr;return S.createElement("div",{key:yi,className:O()(Zt,{[`${on}-${Mr}`]:Mr}),style:Fn},vi)}))})},At=b(58083),lt=b(53124),Ot=b(98866),le=b(97647),Fe=b(98675),gt=b(17423);const Jt=["parentNode"],Ze="form_item";function rt(_){return _===void 0||_===!1?[]:Array.isArray(_)?_:[_]}function Mt(_,F){if(!_.length)return;const X=_.join("_");return F?`${F}_${X}`:Jt.includes(X)?`${Ze}_${X}`:X}function Ue(_,F,X,Ie,ke,et){let nt=Ie;return et!==void 0?nt=et:X.validating?nt="validating":_.length?nt="error":F.length?nt="warning":(X.touched||ke&&X.validated)&&(nt="success"),nt}function Ye(_){return rt(_).join("_")}function be(_){const[F]=(0,At.useForm)(),X=S.useRef({}),Ie=S.useMemo(()=>_!=null?_:Object.assign(Object.assign({},F),{__INTERNAL__:{itemRef:ke=>et=>{const nt=Ye(ke);et?X.current[nt]=et:delete X.current[nt]}},scrollToField:function(ke){let et=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const nt=rt(ke),Wt=Mt(nt,Ie.__INTERNAL__.name),Tt=Wt?document.getElementById(Wt):null;Tt&&(0,gt.Z)(Tt,Object.assign({scrollMode:"if-needed",block:"nearest"},et))},getFieldInstance:ke=>{const et=Ye(ke);return X.current[et]}}),[_,F]);return[Ie]}var ge=b(37920),Ke=function(_,F){var X={};for(var Ie in _)Object.prototype.hasOwnProperty.call(_,Ie)&&F.indexOf(Ie)<0&&(X[Ie]=_[Ie]);if(_!=null&&typeof Object.getOwnPropertySymbols=="function")for(var ke=0,Ie=Object.getOwnPropertySymbols(_);ke<Ie.length;ke++)F.indexOf(Ie[ke])<0&&Object.prototype.propertyIsEnumerable.call(_,Ie[ke])&&(X[Ie[ke]]=_[Ie[ke]]);return X};const wt=(_,F)=>{const X=S.useContext(Ot.Z),{getPrefixCls:Ie,direction:ke,form:et}=S.useContext(lt.E_),{prefixCls:nt,className:Wt,rootClassName:Tt,size:on,disabled:Un=X,form:sn,colon:bn,labelAlign:ti,labelWrap:Bt,labelCol:$n,wrapperCol:ni,hideRequiredMark:Pi,layout:ui="horizontal",scrollToFirstError:Lr,requiredMark:yi,onFinishFailed:vi,name:Mr,style:Zt,feedbackIcons:Fn}=_,hi=Ke(_,["prefixCls","className","rootClassName","size","disabled","form","colon","labelAlign","labelWrap","labelCol","wrapperCol","hideRequiredMark","layout","scrollToFirstError","requiredMark","onFinishFailed","name","style","feedbackIcons"]),Xn=(0,Fe.Z)(on),ds=S.useContext(ge.Z),qr=(0,S.useMemo)(()=>yi!==void 0?yi:et&&et.requiredMark!==void 0?et.requiredMark:!Pi,[Pi,yi,et]),vs=bn!=null?bn:et==null?void 0:et.colon,kr=Ie("form",nt),[Fs,io]=He(kr),ro=O()(kr,`${kr}-${ui}`,{[`${kr}-hide-required-mark`]:qr===!1,[`${kr}-rtl`]:ke==="rtl",[`${kr}-${Xn}`]:Xn},io,et==null?void 0:et.className,Wt,Tt),[To]=be(sn),{__INTERNAL__:Eo}=To;Eo.name=Mr;const Wr=(0,S.useMemo)(()=>({name:Mr,labelAlign:ti,labelCol:$n,labelWrap:Bt,wrapperCol:ni,vertical:ui==="vertical",colon:vs,requiredMark:qr,itemRef:Eo.itemRef,form:To,feedbackIcons:Fn}),[Mr,ti,$n,ni,ui,vs,qr,To,Fn]);S.useImperativeHandle(F,()=>To);const eo=(so,Yr)=>{if(so){let ua={block:"nearest"};typeof so=="object"&&(ua=so),To.scrollToField(Yr,ua)}},Ao=so=>{if(vi==null||vi(so),so.errorFields.length){const Yr=so.errorFields[0].name;if(Lr!==void 0){eo(Lr,Yr);return}et&&et.scrollToFirstError!==void 0&&eo(et.scrollToFirstError,Yr)}};return Fs(S.createElement(Ot.n,{disabled:Un},S.createElement(le.q,{size:Xn},S.createElement(x.RV,Object.assign({},{validateMessages:ds}),S.createElement(x.q3.Provider,{value:Wr},S.createElement(At.default,Object.assign({id:Mr},hi,{name:Mr,onFinishFailed:Ao,form:To,style:Object.assign(Object.assign({},et==null?void 0:et.style),Zt),className:ro})))))))};var ut=S.forwardRef(wt),Et=b(9475),je=b(17799),tt=b(96159),yt=b(37419);function B(_){if(typeof _=="function")return _;const F=(0,yt.Z)(_);return F.length<=1?F[0]:F}const te=()=>{const{status:_,errors:F=[],warnings:X=[]}=(0,S.useContext)(x.aM);return{status:_,errors:F,warnings:X}};te.Context=x.aM;var ot=te,_t=b(96523);function ct(_){const[F,X]=S.useState(_),Ie=(0,S.useRef)(null),ke=(0,S.useRef)([]),et=(0,S.useRef)(!1);S.useEffect(()=>(et.current=!1,()=>{et.current=!0,_t.Z.cancel(Ie.current),Ie.current=null}),[]);function nt(Wt){et.current||(Ie.current===null&&(ke.current=[],Ie.current=(0,_t.Z)(()=>{Ie.current=null,X(Tt=>{let on=Tt;return ke.current.forEach(Un=>{on=Un(on)}),on})})),ke.current.push(Wt))}return[F,nt]}function qt(){const{itemRef:_}=S.useContext(x.q3),F=S.useRef({});function X(Ie,ke){const et=ke&&typeof ke=="object"&&ke.ref,nt=Ie.join("_");return(F.current.name!==nt||F.current.originRef!==et)&&(F.current.name=nt,F.current.originRef=et,F.current.ref=(0,je.sQ)(_(Ie),et)),F.current.ref}return X}var en=b(48130),nn=b(14075),we=b(10366),Q=b(92820),De=b(21584);const We=_=>{const{formItemCls:F}=_;return{"@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none)":{[`${F}-control`]:{display:"flex"}}}};var Ce=(0,Y.b)(["Form","item-item"],(_,F)=>{let{rootPrefixCls:X}=F;const Ie=Ge(_,X);return[We(Ie)]}),qe=_=>{const{prefixCls:F,status:X,wrapperCol:Ie,children:ke,errors:et,warnings:nt,_internalItemRender:Wt,extra:Tt,help:on,fieldId:Un,marginBottom:sn,onErrorVisibleChanged:bn}=_,ti=`${F}-item`,Bt=S.useContext(x.q3),$n=Ie||Bt.wrapperCol||{},ni=O()(`${ti}-control`,$n.className),Pi=S.useMemo(()=>Object.assign({},Bt),[Bt]);delete Pi.labelCol,delete Pi.wrapperCol;const ui=S.createElement("div",{className:`${ti}-control-input`},S.createElement("div",{className:`${ti}-control-input-content`},ke)),Lr=S.useMemo(()=>({prefixCls:F,status:X}),[F,X]),yi=sn!==null||et.length||nt.length?S.createElement("div",{style:{display:"flex",flexWrap:"nowrap"}},S.createElement(x.Rk.Provider,{value:Lr},S.createElement(Yt,{fieldId:Un,errors:et,warnings:nt,help:on,helpStatus:X,className:`${ti}-explain-connected`,onVisibleChanged:bn})),!!sn&&S.createElement("div",{style:{width:0,height:sn}})):null,vi={};Un&&(vi.id=`${Un}_extra`);const Mr=Tt?S.createElement("div",Object.assign({},vi,{className:`${ti}-extra`}),Tt):null,Zt=Wt&&Wt.mark==="pro_table_render"&&Wt.render?Wt.render(_,{input:ui,errorList:yi,extra:Mr}):S.createElement(S.Fragment,null,ui,yi,Mr);return S.createElement(x.q3.Provider,{value:Pi},S.createElement(De.Z,Object.assign({},$n,{className:ni}),Zt),S.createElement(Ce,{prefixCls:F}))},st=b(17663),$e=b(24457),ft=b(10110),Ct=b(83062),jt=function(_,F){var X={};for(var Ie in _)Object.prototype.hasOwnProperty.call(_,Ie)&&F.indexOf(Ie)<0&&(X[Ie]=_[Ie]);if(_!=null&&typeof Object.getOwnPropertySymbols=="function")for(var ke=0,Ie=Object.getOwnPropertySymbols(_);ke<Ie.length;ke++)F.indexOf(Ie[ke])<0&&Object.prototype.propertyIsEnumerable.call(_,Ie[ke])&&(X[Ie[ke]]=_[Ie[ke]]);return X};function Qt(_){return _?typeof _=="object"&&!S.isValidElement(_)?_:{title:_}:null}var Wn=_=>{let{prefixCls:F,label:X,htmlFor:Ie,labelCol:ke,labelAlign:et,colon:nt,required:Wt,requiredMark:Tt,tooltip:on}=_;var Un;const[sn]=(0,ft.Z)("Form"),{vertical:bn,labelAlign:ti,labelCol:Bt,labelWrap:$n,colon:ni}=S.useContext(x.q3);if(!X)return null;const Pi=ke||Bt||{},ui=et||ti,Lr=`${F}-item-label`,yi=O()(Lr,ui==="left"&&`${Lr}-left`,Pi.className,{[`${Lr}-wrap`]:!!$n});let vi=X;const Mr=nt===!0||ni!==!1&&nt!==!1;Mr&&!bn&&typeof X=="string"&&X.trim()!==""&&(vi=X.replace(/[:|:]\s*$/,""));const Fn=Qt(on);if(Fn){const{icon:qr=S.createElement(st.Z,null)}=Fn,vs=jt(Fn,["icon"]),kr=S.createElement(Ct.Z,Object.assign({},vs),S.cloneElement(qr,{className:`${F}-item-tooltip`,title:""}));vi=S.createElement(S.Fragment,null,vi,kr)}const hi=Tt==="optional",Xn=typeof Tt=="function";Xn?vi=Tt(vi,{required:!!Wt}):hi&&!Wt&&(vi=S.createElement(S.Fragment,null,vi,S.createElement("span",{className:`${F}-item-optional`,title:""},(sn==null?void 0:sn.optional)||((Un=$e.Z.Form)===null||Un===void 0?void 0:Un.optional))));const ds=O()({[`${F}-item-required`]:Wt,[`${F}-item-required-mark-optional`]:hi||Xn,[`${F}-item-no-colon`]:!Mr});return S.createElement(De.Z,Object.assign({},Pi,{className:yi}),S.createElement("label",{htmlFor:Ie,className:ds,title:typeof X=="string"?X:""},vi))},Rn=b(87725),bi=b(16646),Dr=b(87995),Qn=b(3407);const Vi={success:Rn.Z,warning:Dr.Z,error:bi.Z,validating:Qn.Z};function Oi(_){let{children:F,errors:X,warnings:Ie,hasFeedback:ke,validateStatus:et,prefixCls:nt,meta:Wt,noStyle:Tt}=_;const on=`${nt}-item`,{feedbackIcons:Un}=S.useContext(x.q3),sn=Ue(X,Ie,Wt,null,!!ke,et),{isFormItemInput:bn,status:ti}=S.useContext(x.aM),Bt=S.useMemo(()=>{var $n;let ni;if(ke){const Lr=ke!==!0&&ke.icons||Un,yi=sn&&(($n=Lr==null?void 0:Lr({status:sn,errors:X,warnings:Ie}))===null||$n===void 0?void 0:$n[sn]),vi=sn&&Vi[sn];ni=yi!==!1&&vi?S.createElement("span",{className:O()(`${on}-feedback-icon`,`${on}-feedback-icon-${sn}`)},yi||S.createElement(vi,null)):null}let Pi=!0,ui=sn||"";return Tt&&(Pi=bn,ui=(sn!=null?sn:ti)||""),{status:ui,errors:X,warnings:Ie,hasFeedback:!!ke,feedbackIcon:ni,isFormItemInput:Pi}},[sn,ke,Tt,bn,ti]);return S.createElement(x.aM.Provider,{value:Bt},F)}var Gi=function(_,F){var X={};for(var Ie in _)Object.prototype.hasOwnProperty.call(_,Ie)&&F.indexOf(Ie)<0&&(X[Ie]=_[Ie]);if(_!=null&&typeof Object.getOwnPropertySymbols=="function")for(var ke=0,Ie=Object.getOwnPropertySymbols(_);ke<Ie.length;ke++)F.indexOf(Ie[ke])<0&&Object.prototype.propertyIsEnumerable.call(_,Ie[ke])&&(X[Ie[ke]]=_[Ie[ke]]);return X};function ir(_){const{prefixCls:F,className:X,rootClassName:Ie,style:ke,help:et,errors:nt,warnings:Wt,validateStatus:Tt,meta:on,hasFeedback:Un,hidden:sn,children:bn,fieldId:ti,required:Bt,isRequired:$n,onSubItemMetaChange:ni}=_,Pi=Gi(_,["prefixCls","className","rootClassName","style","help","errors","warnings","validateStatus","meta","hasFeedback","hidden","children","fieldId","required","isRequired","onSubItemMetaChange"]),ui=`${F}-item`,{requiredMark:Lr}=S.useContext(x.q3),yi=S.useRef(null),vi=E(nt),Mr=E(Wt),Zt=et!=null,Fn=!!(Zt||nt.length||Wt.length),hi=!!yi.current&&(0,en.Z)(yi.current),[Xn,ds]=S.useState(null);(0,nn.Z)(()=>{if(Fn&&yi.current){const io=getComputedStyle(yi.current);ds(parseInt(io.marginBottom,10))}},[Fn,hi]);const qr=io=>{io||ds(null)},kr=function(){let io=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;const ro=io?vi:on.errors,To=io?Mr:on.warnings;return Ue(ro,To,on,"",!!Un,Tt)}(),Fs=O()(ui,X,Ie,{[`${ui}-with-help`]:Zt||vi.length||Mr.length,[`${ui}-has-feedback`]:kr&&Un,[`${ui}-has-success`]:kr==="success",[`${ui}-has-warning`]:kr==="warning",[`${ui}-has-error`]:kr==="error",[`${ui}-is-validating`]:kr==="validating",[`${ui}-hidden`]:sn});return S.createElement("div",{className:Fs,style:ke,ref:yi},S.createElement(Q.Z,Object.assign({className:`${ui}-row`},(0,we.Z)(Pi,["_internalItemRender","colon","dependencies","extra","fieldKey","getValueFromEvent","getValueProps","htmlFor","id","initialValue","isListField","label","labelAlign","labelCol","labelWrap","messageVariables","name","normalize","noStyle","preserve","requiredMark","rules","shouldUpdate","trigger","tooltip","validateFirst","validateTrigger","valuePropName","wrapperCol","validateDebounce"])),S.createElement(Wn,Object.assign({htmlFor:ti},_,{requiredMark:Lr,required:Bt!=null?Bt:$n,prefixCls:F})),S.createElement(qe,Object.assign({},_,on,{errors:vi,warnings:Mr,prefixCls:F,status:kr,help:et,marginBottom:Xn,onErrorVisibleChanged:qr}),S.createElement(x.qI.Provider,{value:ni},S.createElement(Oi,{prefixCls:F,meta:on,errors:on.errors,warnings:on.warnings,hasFeedback:Un,validateStatus:kr},bn)))),!!Xn&&S.createElement("div",{className:`${ui}-margin-offset`,style:{marginBottom:-Xn}}))}const gs="__SPLIT__",Ls=null,ls=S.memo(_=>{let{children:F}=_;return F},(_,F)=>_.value===F.value&&_.update===F.update&&_.childProps.length===F.childProps.length&&_.childProps.every((X,Ie)=>X===F.childProps[Ie]));function ys(_){return _!=null}function Gs(){return{errors:[],warnings:[],touched:!1,validating:!1,name:[],validated:!1}}function Yl(_){const{name:F,noStyle:X,className:Ie,dependencies:ke,prefixCls:et,shouldUpdate:nt,rules:Wt,children:Tt,required:on,label:Un,messageVariables:sn,trigger:bn="onChange",validateTrigger:ti,hidden:Bt,help:$n}=_,{getPrefixCls:ni}=S.useContext(lt.E_),{name:Pi}=S.useContext(x.q3),ui=B(Tt),Lr=typeof ui=="function",yi=S.useContext(x.qI),{validateTrigger:vi}=S.useContext(At.FieldContext),Mr=ti!==void 0?ti:vi,Zt=ys(F),Fn=ni("form",et),[hi,Xn]=He(Fn),ds=S.useContext(At.ListContext),qr=S.useRef(),[vs,kr]=ct({}),[Fs,io]=(0,Et.Z)(()=>Gs()),ro=Yr=>{const ua=ds==null?void 0:ds.getKey(Yr.name);if(io(Yr.destroy?Gs():Yr,!0),X&&$n!==!1&&yi){let Co=Yr.name;if(Yr.destroy)Co=qr.current||Co;else if(ua!==void 0){const[sl,ol]=ua;Co=[sl].concat((0,w.Z)(ol)),qr.current=Co}yi(Yr,Co)}},To=(Yr,ua)=>{kr(Co=>{const sl=Object.assign({},Co),ha=[].concat((0,w.Z)(Yr.name.slice(0,-1)),(0,w.Z)(ua)).join(gs);return Yr.destroy?delete sl[ha]:sl[ha]=Yr,sl})},[Eo,Wr]=S.useMemo(()=>{const Yr=(0,w.Z)(Fs.errors),ua=(0,w.Z)(Fs.warnings);return Object.values(vs).forEach(Co=>{Yr.push.apply(Yr,(0,w.Z)(Co.errors||[])),ua.push.apply(ua,(0,w.Z)(Co.warnings||[]))}),[Yr,ua]},[vs,Fs.errors,Fs.warnings]),eo=qt();function Ao(Yr,ua,Co){return X&&!Bt?S.createElement(Oi,{prefixCls:Fn,hasFeedback:_.hasFeedback,validateStatus:_.validateStatus,meta:Fs,errors:Eo,warnings:Wr,noStyle:!0},Yr):S.createElement(ir,Object.assign({key:"row"},_,{className:O()(Ie,Xn),prefixCls:Fn,fieldId:ua,isRequired:Co,errors:Eo,warnings:Wr,meta:Fs,onSubItemMetaChange:To}),Yr)}if(!Zt&&!Lr&&!ke)return hi(Ao(ui));let so={};return typeof Un=="string"?so.label=Un:F&&(so.label=String(F)),sn&&(so=Object.assign(Object.assign({},so),sn)),hi(S.createElement(At.Field,Object.assign({},_,{messageVariables:so,trigger:bn,validateTrigger:Mr,onMetaChange:ro}),(Yr,ua,Co)=>{const sl=rt(F).length&&ua?ua.name:[],ol=Mt(sl,Pi),ha=on!==void 0?on:!!(Wt&&Wt.some(wo=>{if(wo&&typeof wo=="object"&&wo.required&&!wo.warningOnly)return!0;if(typeof wo=="function"){const Lc=wo(Co);return Lc&&Lc.required&&!Lc.warningOnly}return!1})),Ba=Object.assign({},Yr);let al=null;if(Array.isArray(ui)&&Zt)al=ui;else if(!(Lr&&(!(nt||ke)||Zt))){if(!(ke&&!Lr&&!Zt))if((0,tt.l$)(ui)){const wo=Object.assign(Object.assign({},ui.props),Ba);if(wo.id||(wo.id=ol),$n||Eo.length>0||Wr.length>0||_.extra){const hh=[];($n||Eo.length>0)&&hh.push(`${ol}_help`),_.extra&&hh.push(`${ol}_extra`),wo["aria-describedby"]=hh.join(" ")}Eo.length>0&&(wo["aria-invalid"]="true"),ha&&(wo["aria-required"]="true"),(0,je.Yr)(ui)&&(wo.ref=eo(sl,ui)),new Set([].concat((0,w.Z)(rt(bn)),(0,w.Z)(rt(Mr)))).forEach(hh=>{wo[hh]=function(){for(var M0,rp,sp,S0,Bm,Xa=arguments.length,Jd=new Array(Xa),ea=0;ea<Xa;ea++)Jd[ea]=arguments[ea];(sp=Ba[hh])===null||sp===void 0||(M0=sp).call.apply(M0,[Ba].concat(Jd)),(Bm=(S0=ui.props)[hh])===null||Bm===void 0||(rp=Bm).call.apply(rp,[S0].concat(Jd))}});const ox=[wo["aria-required"],wo["aria-invalid"],wo["aria-describedby"]];al=S.createElement(ls,{value:Ba[_.valuePropName||"value"],update:ui,childProps:ox},(0,tt.Tm)(ui,wo))}else Lr&&(nt||ke)&&!Zt?al=ui(Co):al=ui}return Ao(al,ol,ha)}))}const Zl=Yl;Zl.useStatus=ot;var Fa=Zl,Fl=function(_,F){var X={};for(var Ie in _)Object.prototype.hasOwnProperty.call(_,Ie)&&F.indexOf(Ie)<0&&(X[Ie]=_[Ie]);if(_!=null&&typeof Object.getOwnPropertySymbols=="function")for(var ke=0,Ie=Object.getOwnPropertySymbols(_);ke<Ie.length;ke++)F.indexOf(Ie[ke])<0&&Object.prototype.propertyIsEnumerable.call(_,Ie[ke])&&(X[Ie[ke]]=_[Ie[ke]]);return X},Bu=_=>{var{prefixCls:F,children:X}=_,Ie=Fl(_,["prefixCls","children"]);const{getPrefixCls:ke}=S.useContext(lt.E_),et=ke("form",F),nt=S.useMemo(()=>({prefixCls:et,status:"error"}),[et]);return S.createElement(At.List,Object.assign({},Ie),(Wt,Tt,on)=>S.createElement(x.Rk.Provider,{value:nt},X(Wt.map(Un=>Object.assign(Object.assign({},Un),{fieldKey:Un.key})),Tt,{errors:on.errors,warnings:on.warnings})))};function Pe(){const{form:_}=(0,S.useContext)(x.q3);return _}const D=ut;D.Item=Fa,D.List=Bu,D.ErrorList=Yt,D.useForm=be,D.useFormInstance=Pe,D.useWatch=At.useWatch,D.Provider=x.RV,D.create=()=>{};var U=D},78045:function(se,ee,b){"use strict";b.d(ee,{ZP:function(){return Jt}});var w=b(94184),k=b.n(w),O=b(5663),R=b(1337),S=b(67294),C=b(53124),x=b(98675);const E=S.createContext(null),N=E.Provider;var L=E;const P=S.createContext(null),W=P.Provider;var Y=b(95860),ie=b(17799),pe=b(98866),fe=b(65223),ae=b(14747),ye=b(67968),ue=b(45503);const Ne=Ze=>{const{componentCls:rt,antCls:Mt}=Ze,Ue=`${rt}-group`;return{[Ue]:Object.assign(Object.assign({},(0,ae.Wf)(Ze)),{display:"inline-block",fontSize:0,[`&${Ue}-rtl`]:{direction:"rtl"},[`${Mt}-badge ${Mt}-badge-count`]:{zIndex:1},[`> ${Mt}-badge:not(:first-child) > ${Mt}-button-wrapper`]:{borderInlineStart:"none"}})}},Te=Ze=>{const{componentCls:rt,wrapperMarginInlineEnd:Mt,colorPrimary:Ue,radioSize:Ye,motionDurationSlow:be,motionDurationMid:ge,motionEaseInOutCirc:Ke,colorBgContainer:wt,colorBorder:Be,lineWidth:ut,dotSize:Et,colorBgContainerDisabled:je,colorTextDisabled:tt,paddingXS:yt,dotColorDisabled:B,lineType:te,radioDotDisabledSize:ot,wireframe:_t,colorWhite:ct}=Ze,qt=`${rt}-inner`;return{[`${rt}-wrapper`]:Object.assign(Object.assign({},(0,ae.Wf)(Ze)),{display:"inline-flex",alignItems:"baseline",marginInlineStart:0,marginInlineEnd:Mt,cursor:"pointer",[`&${rt}-wrapper-rtl`]:{direction:"rtl"},"&-disabled":{cursor:"not-allowed",color:Ze.colorTextDisabled},"&::after":{display:"inline-block",width:0,overflow:"hidden",content:'"\\a0"'},[`${rt}-checked::after`]:{position:"absolute",insetBlockStart:0,insetInlineStart:0,width:"100%",height:"100%",border:`${ut}px ${te} ${Ue}`,borderRadius:"50%",visibility:"hidden",content:'""'},[rt]:Object.assign(Object.assign({},(0,ae.Wf)(Ze)),{position:"relative",display:"inline-block",outline:"none",cursor:"pointer",alignSelf:"center",borderRadius:"50%"}),[`${rt}-wrapper:hover &,
|
|
|
&:hover ${qt}`]:{borderColor:Ue},[`${rt}-input:focus-visible + ${qt}`]:Object.assign({},(0,ae.oN)(Ze)),[`${rt}:hover::after, ${rt}-wrapper:hover &::after`]:{visibility:"visible"},[`${rt}-inner`]:{"&::after":{boxSizing:"border-box",position:"absolute",insetBlockStart:"50%",insetInlineStart:"50%",display:"block",width:Ye,height:Ye,marginBlockStart:Ye/-2,marginInlineStart:Ye/-2,backgroundColor:_t?Ue:ct,borderBlockStart:0,borderInlineStart:0,borderRadius:Ye,transform:"scale(0)",opacity:0,transition:`all ${be} ${Ke}`,content:'""'},boxSizing:"border-box",position:"relative",insetBlockStart:0,insetInlineStart:0,display:"block",width:Ye,height:Ye,backgroundColor:wt,borderColor:Be,borderStyle:"solid",borderWidth:ut,borderRadius:"50%",transition:`all ${ge}`},[`${rt}-input`]:{position:"absolute",inset:0,zIndex:1,cursor:"pointer",opacity:0},[`${rt}-checked`]:{[qt]:{borderColor:Ue,backgroundColor:_t?wt:Ue,"&::after":{transform:`scale(${Et/Ye})`,opacity:1,transition:`all ${be} ${Ke}`}}},[`${rt}-disabled`]:{cursor:"not-allowed",[qt]:{backgroundColor:je,borderColor:Be,cursor:"not-allowed","&::after":{backgroundColor:B}},[`${rt}-input`]:{cursor:"not-allowed"},[`${rt}-disabled + span`]:{color:tt,cursor:"not-allowed"},[`&${rt}-checked`]:{[qt]:{"&::after":{transform:`scale(${ot/Ye})`}}}},[`span${rt} + *`]:{paddingInlineStart:yt,paddingInlineEnd:yt}})}},_e=Ze=>{const{buttonColor:rt,controlHeight:Mt,componentCls:Ue,lineWidth:Ye,lineType:be,colorBorder:ge,motionDurationSlow:Ke,motionDurationMid:wt,buttonPaddingInline:Be,fontSize:ut,buttonBg:Et,fontSizeLG:je,controlHeightLG:tt,controlHeightSM:yt,paddingXS:B,borderRadius:te,borderRadiusSM:ot,borderRadiusLG:_t,buttonCheckedBg:ct,buttonSolidCheckedColor:qt,colorTextDisabled:en,colorBgContainerDisabled:nn,buttonCheckedBgDisabled:we,buttonCheckedColorDisabled:Q,colorPrimary:De,colorPrimaryHover:We,colorPrimaryActive:Ce,buttonSolidCheckedBg:Re,buttonSolidCheckedHoverBg:qe,buttonSolidCheckedActiveBg:st}=Ze;return{[`${Ue}-button-wrapper`]:{position:"relative",display:"inline-block",height:Mt,margin:0,paddingInline:Be,paddingBlock:0,color:rt,fontSize:ut,lineHeight:`${Mt-Ye*2}px`,background:Et,border:`${Ye}px ${be} ${ge}`,borderBlockStartWidth:Ye+.02,borderInlineStartWidth:0,borderInlineEndWidth:Ye,cursor:"pointer",transition:[`color ${wt}`,`background ${wt}`,`box-shadow ${wt}`].join(","),a:{color:rt},[`> ${Ue}-button`]:{position:"absolute",insetBlockStart:0,insetInlineStart:0,zIndex:-1,width:"100%",height:"100%"},"&:not(:first-child)":{"&::before":{position:"absolute",insetBlockStart:-Ye,insetInlineStart:-Ye,display:"block",boxSizing:"content-box",width:1,height:"100%",paddingBlock:Ye,paddingInline:0,backgroundColor:ge,transition:`background-color ${Ke}`,content:'""'}},"&:first-child":{borderInlineStart:`${Ye}px ${be} ${ge}`,borderStartStartRadius:te,borderEndStartRadius:te},"&:last-child":{borderStartEndRadius:te,borderEndEndRadius:te},"&:first-child:last-child":{borderRadius:te},[`${Ue}-group-large &`]:{height:tt,fontSize:je,lineHeight:`${tt-Ye*2}px`,"&:first-child":{borderStartStartRadius:_t,borderEndStartRadius:_t},"&:last-child":{borderStartEndRadius:_t,borderEndEndRadius:_t}},[`${Ue}-group-small &`]:{height:yt,paddingInline:B-Ye,paddingBlock:0,lineHeight:`${yt-Ye*2}px`,"&:first-child":{borderStartStartRadius:ot,borderEndStartRadius:ot},"&:last-child":{borderStartEndRadius:ot,borderEndEndRadius:ot}},"&:hover":{position:"relative",color:De},"&:has(:focus-visible)":Object.assign({},(0,ae.oN)(Ze)),[`${Ue}-inner, input[type='checkbox'], input[type='radio']`]:{width:0,height:0,opacity:0,pointerEvents:"none"},[`&-checked:not(${Ue}-button-wrapper-disabled)`]:{zIndex:1,color:De,background:ct,borderColor:De,"&::before":{backgroundColor:De},"&:first-child":{borderColor:De},"&:hover":{color:We,borderColor:We,"&::before":{backgroundColor:We}},"&:active":{color:Ce,borderColor:Ce,"&::before":{backgroundColor:Ce}}},[`${Ue}-group-solid &-checked:not(${Ue}-button-wrapper-disabled)`]:{color:qt,background:Re,borderColor:Re,"&:hover":{color:qt,background:qe,borderColor:qe},"&:active":{color:qt,background:st,borderColor:st}},"&-disabled":{color:en,backgroundColor:nn,borderColor:ge,cursor:"not-allowed","&:first-child, &:hover":{color:en,backgroundColor:nn,borderColor:ge}},[`&-disabled${Ue}-button-wrapper-checked`]:{color:Q,backgroundColor:we,borderColor:ge,boxShadow:"none"}}}},Xe=Ze=>Ze-4*2;var Se=(0,ye.Z)("Radio",Ze=>{const{controlOutline:rt,controlOutlineWidth:Mt,radioSize:Ue}=Ze,Ye=`0 0 0 ${Mt}px ${rt}`,be=Ye,ge=Xe(Ue),Ke=(0,ue.TS)(Ze,{radioDotDisabledSize:ge,radioFocusShadow:Ye,radioButtonFocusShadow:be});return[Ne(Ke),Te(Ke),_e(Ke)]},Ze=>{const{wireframe:rt,padding:Mt,marginXS:Ue,lineWidth:Ye,fontSizeLG:be,colorText:ge,colorBgContainer:Ke,colorTextDisabled:wt,controlItemBgActiveDisabled:Be,colorTextLightSolid:ut,colorPrimary:Et,colorPrimaryHover:je,colorPrimaryActive:tt}=Ze,yt=4,B=be,te=rt?Xe(B):B-(yt+Ye)*2;return{radioSize:B,dotSize:te,dotColorDisabled:wt,buttonSolidCheckedColor:ut,buttonSolidCheckedBg:Et,buttonSolidCheckedHoverBg:je,buttonSolidCheckedActiveBg:tt,buttonBg:Ke,buttonCheckedBg:Ke,buttonColor:ge,buttonCheckedBgDisabled:Be,buttonCheckedColorDisabled:wt,buttonPaddingInline:Mt-Ye,wrapperMarginInlineEnd:Ue}}),Ge=b(45353),He=b(92429),vt=function(Ze,rt){var Mt={};for(var Ue in Ze)Object.prototype.hasOwnProperty.call(Ze,Ue)&&rt.indexOf(Ue)<0&&(Mt[Ue]=Ze[Ue]);if(Ze!=null&&typeof Object.getOwnPropertySymbols=="function")for(var Ye=0,Ue=Object.getOwnPropertySymbols(Ze);Ye<Ue.length;Ye++)rt.indexOf(Ue[Ye])<0&&Object.prototype.propertyIsEnumerable.call(Ze,Ue[Ye])&&(Mt[Ue[Ye]]=Ze[Ue[Ye]]);return Mt};const It=(Ze,rt)=>{var Mt,Ue;const Ye=S.useContext(L),be=S.useContext(P),{getPrefixCls:ge,direction:Ke,radio:wt}=S.useContext(C.E_),Be=S.useRef(null),ut=(0,ie.sQ)(rt,Be),{isFormItemInput:Et}=S.useContext(fe.aM),je=Ce=>{var Re,qe;(Re=Ze.onChange)===null||Re===void 0||Re.call(Ze,Ce),(qe=Ye==null?void 0:Ye.onChange)===null||qe===void 0||qe.call(Ye,Ce)},{prefixCls:tt,className:yt,rootClassName:B,children:te,style:ot}=Ze,_t=vt(Ze,["prefixCls","className","rootClassName","children","style"]),ct=ge("radio",tt),qt=((Ye==null?void 0:Ye.optionType)||be)==="button",en=qt?`${ct}-button`:ct,[nn,we]=Se(ct),Q=Object.assign({},_t),De=S.useContext(pe.Z);Ye&&(Q.name=Ye.name,Q.onChange=je,Q.checked=Ze.value===Ye.value,Q.disabled=(Mt=Q.disabled)!==null&&Mt!==void 0?Mt:Ye.disabled),Q.disabled=(Ue=Q.disabled)!==null&&Ue!==void 0?Ue:De;const We=k()(`${en}-wrapper`,{[`${en}-wrapper-checked`]:Q.checked,[`${en}-wrapper-disabled`]:Q.disabled,[`${en}-wrapper-rtl`]:Ke==="rtl",[`${en}-wrapper-in-form-item`]:Et},wt==null?void 0:wt.className,yt,B,we);return nn(S.createElement(Ge.Z,{component:"Radio",disabled:Q.disabled},S.createElement("label",{className:We,style:Object.assign(Object.assign({},wt==null?void 0:wt.style),ot),onMouseEnter:Ze.onMouseEnter,onMouseLeave:Ze.onMouseLeave},S.createElement(Y.Z,Object.assign({},Q,{className:k()(Q.className,!qt&&He.A),type:"radio",prefixCls:en,ref:ut})),te!==void 0?S.createElement("span",null,te):null)))};var Yt=S.forwardRef(It);const At=S.forwardRef((Ze,rt)=>{const{getPrefixCls:Mt,direction:Ue}=S.useContext(C.E_),[Ye,be]=(0,O.Z)(Ze.defaultValue,{value:Ze.value}),ge=Re=>{const qe=Ye,st=Re.target.value;"value"in Ze||be(st);const{onChange:$e}=Ze;$e&&st!==qe&&$e(Re)},{prefixCls:Ke,className:wt,rootClassName:Be,options:ut,buttonStyle:Et="outline",disabled:je,children:tt,size:yt,style:B,id:te,onMouseEnter:ot,onMouseLeave:_t,onFocus:ct,onBlur:qt}=Ze,en=Mt("radio",Ke),nn=`${en}-group`,[we,Q]=Se(en);let De=tt;ut&&ut.length>0&&(De=ut.map(Re=>typeof Re=="string"||typeof Re=="number"?S.createElement(Yt,{key:Re.toString(),prefixCls:en,disabled:je,value:Re,checked:Ye===Re},Re):S.createElement(Yt,{key:`radio-group-value-options-${Re.value}`,prefixCls:en,disabled:Re.disabled||je,value:Re.value,checked:Ye===Re.value,title:Re.title,style:Re.style},Re.label)));const We=(0,x.Z)(yt),Ce=k()(nn,`${nn}-${Et}`,{[`${nn}-${We}`]:We,[`${nn}-rtl`]:Ue==="rtl"},wt,Be,Q);return we(S.createElement("div",Object.assign({},(0,R.Z)(Ze,{aria:!0,data:!0}),{className:Ce,style:B,onMouseEnter:ot,onMouseLeave:_t,onFocus:ct,onBlur:qt,id:te,ref:rt}),S.createElement(N,{value:{onChange:ge,value:Ye,disabled:Ze.disabled,name:Ze.name,optionType:Ze.optionType}},De)))});var lt=S.memo(At),Ot=function(Ze,rt){var Mt={};for(var Ue in Ze)Object.prototype.hasOwnProperty.call(Ze,Ue)&&rt.indexOf(Ue)<0&&(Mt[Ue]=Ze[Ue]);if(Ze!=null&&typeof Object.getOwnPropertySymbols=="function")for(var Ye=0,Ue=Object.getOwnPropertySymbols(Ze);Ye<Ue.length;Ye++)rt.indexOf(Ue[Ye])<0&&Object.prototype.propertyIsEnumerable.call(Ze,Ue[Ye])&&(Mt[Ue[Ye]]=Ze[Ue[Ye]]);return Mt};const le=(Ze,rt)=>{const{getPrefixCls:Mt}=S.useContext(C.E_),{prefixCls:Ue}=Ze,Ye=Ot(Ze,["prefixCls"]),be=Mt("radio",Ue);return S.createElement(W,{value:"button"},S.createElement(Yt,Object.assign({prefixCls:be},Ye,{type:"radio",ref:rt})))};var Fe=S.forwardRef(le);const gt=Yt;gt.Button=Fe,gt.Group=lt,gt.__ANT_RADIO=!0;var Jt=gt},89558:function(se,ee,b){"use strict";b.d(ee,{Ae:function(){return ae},CF:function(){return ct},vC:function(){return B},x1:function(){return C}});function w(we,Q,De,We,Ce,Re){const qe=we,st=Q,$e=De-qe,ft=We-st;let Ct=Ce-qe,jt=Re-st,Qt=Ct*$e+jt*ft,pn=0;Qt<=0?pn=0:(Ct=$e-Ct,jt=ft-jt,Qt=Ct*$e+jt*ft,Qt<=0?pn=0:pn=Qt*Qt/($e*$e+ft*ft));const Wn=Ct*Ct+jt*jt-pn;return Wn<0?0:Wn}function k(we,Q,De,We){return(we-De)*(we-De)+(Q-We)*(Q-We)}function O(we,Q,De,We,Ce){return k(we,Q,De,We)<Ce*Ce}function R(we){if(!Number.isFinite(we))return De=>De;if(we===0)return Math.round;const Q=Math.pow(10,we);return De=>Math.round(De*Q)/Q}function S(we){const Q=Math.min(we.x1,we.x2),De=Math.max(we.x1,we.x2),We=Math.min(we.y1,we.y2),Ce=Math.max(we.y1,we.y2);return{x:Q,y:We,x2:De,y2:Ce,width:De-Q,height:Ce-We}}class C{constructor(Q,De,We,Ce){this.x1=Q,this.y1=De,this.x2=We,this.y2=Ce}equals(Q){return this.x1===Q.x1&&this.y1===Q.y1&&this.x2===Q.x2&&this.y2===Q.y2}draw(Q){Q.moveTo(this.x1,this.y1),Q.lineTo(this.x2,this.y2)}toString(){return`Line(from=(${this.x1},${this.y1}),to=(${this.x2},${this.y2}))`}static from(Q){return new C(Q.x1,Q.y1,Q.x2,Q.y2)}cuts(Q,De){if(this.y1===this.y2||De<this.y1&&De<=this.y2||De>this.y1&&De>=this.y2||Q>this.x1&&Q>=this.x2)return!1;if(Q<this.x1&&Q<=this.x2)return!0;const We=this.x1+(De-this.y1)*(this.x2-this.x1)/(this.y2-this.y1);return Q<=We}distSquare(Q,De){return w(this.x1,this.y1,this.x2,this.y2,Q,De)}ptClose(Q,De,We){if(this.x1<this.x2){if(Q<this.x1-We||Q>this.x2+We)return!1}else if(Q<this.x2-We||Q>this.x1+We)return!1;if(this.y1<this.y2){if(De<this.y1-We||De>this.y2+We)return!1}else if(De<this.y2-We||De>this.y1+We)return!1;return!0}}var x;(function(we){we[we.POINT=1]="POINT",we[we.PARALLEL=2]="PARALLEL",we[we.COINCIDENT=3]="COINCIDENT",we[we.NONE=4]="NONE"})(x||(x={}));class E{constructor(Q,De=0,We=0){this.state=Q,this.x=De,this.y=We}}function N(we,Q){const De=(Q.x2-Q.x1)*(we.y1-Q.y1)-(Q.y2-Q.y1)*(we.x1-Q.x1),We=(we.x2-we.x1)*(we.y1-Q.y1)-(we.y2-we.y1)*(we.x1-Q.x1),Ce=(Q.y2-Q.y1)*(we.x2-we.x1)-(Q.x2-Q.x1)*(we.y2-we.y1);if(Ce){const Re=De/Ce,qe=We/Ce;return 0<=Re&&Re<=1&&0<=qe&&qe<=1?new E(x.POINT,we.x1+Re*(we.x2-we.x1),we.y1+Re*(we.y2-we.y1)):new E(x.NONE)}return new E(De===0||We===0?x.COINCIDENT:x.PARALLEL)}function L(we,Q){const De=(Q.x2-Q.x1)*(we.y1-Q.y1)-(Q.y2-Q.y1)*(we.x1-Q.x1),We=(we.x2-we.x1)*(we.y1-Q.y1)-(we.y2-we.y1)*(we.x1-Q.x1),Ce=(Q.y2-Q.y1)*(we.x2-we.x1)-(Q.x2-Q.x1)*(we.y2-we.y1);if(Ce){const Re=De/Ce,qe=We/Ce;if(0<=Re&&Re<=1&&0<=qe&&qe<=1)return Re}return Number.POSITIVE_INFINITY}function P(we,Q){function De(Ce,Re,qe,st){let $e=L(Q,new C(Ce,Re,qe,st));return $e=Math.abs($e-.5),$e>=0&&$e<=1?1:0}let We=De(we.x,we.y,we.x2,we.y);return We+=De(we.x,we.y,we.x,we.y2),We>1||(We+=De(we.x,we.y2,we.x2,we.y2),We>1)?!0:(We+=De(we.x2,we.y,we.x2,we.y2),We>0)}var W;(function(we){we[we.LEFT=0]="LEFT",we[we.TOP=1]="TOP",we[we.RIGHT=2]="RIGHT",we[we.BOTTOM=3]="BOTTOM"})(W||(W={}));function Y(we,Q,De){const We=new Set;return we.width<=0?(We.add(W.LEFT),We.add(W.RIGHT)):Q<we.x?We.add(W.LEFT):Q>we.x+we.width&&We.add(W.RIGHT),we.height<=0?(We.add(W.TOP),We.add(W.BOTTOM)):De<we.y?We.add(W.TOP):De>we.y+we.height&&We.add(W.BOTTOM),We}function ie(we,Q){let De=Q.x1,We=Q.y1;const Ce=Q.x2,Re=Q.y2,qe=Array.from(Y(we,Ce,Re));if(qe.length===0)return!0;let st=Y(we,De,We);for(;st.size!==0;){for(const $e of qe)if(st.has($e))return!1;if(st.has(W.RIGHT)||st.has(W.LEFT)){let $e=we.x;st.has(W.RIGHT)&&($e+=we.width),We=We+($e-De)*(Re-We)/(Ce-De),De=$e}else{let $e=we.y;st.has(W.BOTTOM)&&($e+=we.height),De=De+($e-We)*(Ce-De)/(Re-We),We=$e}st=Y(we,De,We)}return!0}function pe(we,Q){let De=Number.POSITIVE_INFINITY,We=0;function Ce(Re,qe,st,$e){let ft=L(Q,new C(Re,qe,st,$e));ft=Math.abs(ft-.5),ft>=0&&ft<=1&&(We++,ft<De&&(De=ft))}return Ce(we.x,we.y,we.x2,we.y),Ce(we.x,we.y,we.x,we.y2),We>1||(Ce(we.x,we.y2,we.x2,we.y2),We>1)?De:(Ce(we.x2,we.y,we.x2,we.y2),We===0?-1:De)}function fe(we,Q){let De=0;const We=N(we,new C(Q.x,Q.y,Q.x2,Q.y));De+=We.state===x.POINT?1:0;const Ce=N(we,new C(Q.x,Q.y,Q.x,Q.y2));De+=Ce.state===x.POINT?1:0;const Re=N(we,new C(Q.x,Q.y2,Q.x2,Q.y2));De+=Re.state===x.POINT?1:0;const qe=N(we,new C(Q.x2,Q.y,Q.x2,Q.y2));return De+=qe.state===x.POINT?1:0,{top:We,left:Ce,bottom:Re,right:qe,count:De}}class ae{constructor(Q,De,We,Ce){this.x=Q,this.y=De,this.width=We,this.height=Ce}get x2(){return this.x+this.width}get y2(){return this.y+this.height}get cx(){return this.x+this.width/2}get cy(){return this.y+this.height/2}get radius(){return Math.max(this.width,this.height)/2}static from(Q){return new ae(Q.x,Q.y,Q.width,Q.height)}equals(Q){return this.x===Q.x&&this.y===Q.y&&this.width===Q.width&&this.height===Q.height}clone(){return new ae(this.x,this.y,this.width,this.height)}add(Q){const De=Math.min(this.x,Q.x),We=Math.min(this.y,Q.y),Ce=Math.max(this.x2,Q.x+Q.width),Re=Math.max(this.y2,Q.y+Q.height);this.x=De,this.y=We,this.width=Ce-De,this.height=Re-We}addPoint(Q){const De=Math.min(this.x,Q.x),We=Math.min(this.y,Q.y),Ce=Math.max(this.x2,Q.x),Re=Math.max(this.y2,Q.y);this.x=De,this.y=We,this.width=Ce-De,this.height=Re-We}toString(){return`Rectangle[x=${this.x}, y=${this.y}, w=${this.width}, h=${this.height}]`}draw(Q){Q.rect(this.x,this.y,this.width,this.height)}containsPt(Q,De){return Q>=this.x&&Q<=this.x2&&De>=this.y&&De<=this.y2}get area(){return this.width*this.height}intersects(Q){return this.area<=0||Q.width<=0||Q.height<=0?!1:Q.x+Q.width>this.x&&Q.y+Q.height>this.y&&Q.x<this.x2&&Q.y<this.y2}distSquare(Q,De){if(this.containsPt(Q,De))return 0;const We=Y(this,Q,De);return We.has(W.TOP)?We.has(W.LEFT)?k(Q,De,this.x,this.y):We.has(W.RIGHT)?k(Q,De,this.x2,this.y):(this.y-De)*(this.y-De):We.has(W.BOTTOM)?We.has(W.LEFT)?k(Q,De,this.x,this.y2):We.has(W.RIGHT)?k(Q,De,this.x2,this.y2):(De-this.y2)*(De-this.y2):We.has(W.LEFT)?(this.x-Q)*(this.x-Q):We.has(W.RIGHT)?(Q-this.x2)*(Q-this.x2):0}}function ye(we){if(we.length===0)return null;const Q=we[0],De=new ae(Q.x,Q.y,0,0);for(const We of we)De.addPoint(We);return De}class ue{constructor(Q,De,We){this.cx=Q,this.cy=De,this.radius=We}get x(){return this.cx-this.radius}get x2(){return this.cx+this.radius}get width(){return this.radius*2}get y(){return this.cy-this.radius}get y2(){return this.cy+this.radius}get height(){return this.radius*2}static from(Q){return new ue(Q.cx,Q.cy,Q.radius)}containsPt(Q,De){return k(this.cx,this.cy,Q,De)<this.radius*this.radius}distSquare(Q,De){const We=k(this.cx,this.cy,Q,De);if(We<this.radius*this.radius)return 0;const Ce=Math.sqrt(We)-this.radius;return Ce*Ce}draw(Q){Q.ellipse(this.cx,this.cy,this.radius,this.radius,0,0,Math.PI*2)}}class Ne{constructor(Q,De=0,We=0,Ce=0,Re=0,qe=10,st=10,$e=new Float32Array(Math.max(0,qe*st)).fill(0)){this.pixelGroup=Q,this.i=De,this.j=We,this.pixelX=Ce,this.pixelY=Re,this.width=qe,this.height=st,this.area=$e}createSub(Q,De){return new Ne(this.pixelGroup,Q.x,Q.y,De.x,De.y,Q.width,Q.height)}static fromPixelRegion(Q,De){return new Ne(De,0,0,Q.x,Q.y,Math.ceil(Q.width/De),Math.ceil(Q.height/De))}copy(Q,De){return new Ne(this.pixelGroup,this.scaleX(De.x),this.scaleY(De.y),De.x,De.y,Q.width,Q.height,Q.area)}boundX(Q){return Q<this.i?this.i:Q>=this.width?this.width-1:Q}boundY(Q){return Q<this.j?this.j:Q>=this.height?this.height-1:Q}scaleX(Q){return this.boundX(Math.floor((Q-this.pixelX)/this.pixelGroup))}scaleY(Q){return this.boundY(Math.floor((Q-this.pixelY)/this.pixelGroup))}scale(Q){const De=this.scaleX(Q.x),We=this.scaleY(Q.y),Ce=this.boundX(Math.ceil((Q.x+Q.width-this.pixelX)/this.pixelGroup)),Re=this.boundY(Math.ceil((Q.y+Q.height-this.pixelY)/this.pixelGroup)),qe=Ce-De,st=Re-We;return new ae(De,We,qe,st)}invertScaleX(Q){return Math.round(Q*this.pixelGroup+this.pixelX)}invertScaleY(Q){return Math.round(Q*this.pixelGroup+this.pixelY)}addPadding(Q,De){const We=Math.ceil(De/this.pixelGroup),Ce=this.boundX(Q.x-We),Re=this.boundY(Q.y-We),qe=this.boundX(Q.x2+We),st=this.boundY(Q.y2+We),$e=qe-Ce,ft=st-Re;return new ae(Ce,Re,$e,ft)}get(Q,De){return Q<0||De<0||Q>=this.width||De>=this.height?Number.NaN:this.area[Q+De*this.width]}inc(Q,De,We){Q<0||De<0||Q>=this.width||De>=this.height||(this.area[Q+De*this.width]+=We)}set(Q,De,We){Q<0||De<0||Q>=this.width||De>=this.height||(this.area[Q+De*this.width]=We)}incArea(Q,De){if(Q.width<=0||Q.height<=0||De===0)return;const We=this.width,Ce=Q.width,Re=Math.max(0,Q.i),qe=Math.max(0,Q.j),st=Math.min(Q.i+Q.width,We),$e=Math.min(Q.j+Q.height,this.height);if(!($e<=0||st<=0||Re>=We||$e>=this.height))for(let ft=qe;ft<$e;ft++){const Ct=(ft-Q.j)*Ce,jt=ft*We;for(let Qt=Re;Qt<st;Qt++){const pn=Q.area[Qt-Q.i+Ct];pn!==0&&(this.area[Qt+jt]+=De*pn)}}}fill(Q){this.area.fill(Q)}fillArea(Q,De){const We=Q.x+Q.y*this.width;for(let Ce=0;Ce<Q.height;Ce++){const Re=We+Ce*this.width;this.area.fill(De,Re,Re+Q.width)}}fillHorizontalLine(Q,De,We,Ce){const Re=Q+De*this.width;this.area.fill(Ce,Re,Re+We)}fillVerticalLine(Q,De,We,Ce){const Re=Q+De*this.width;for(let qe=0;qe<We;qe++)this.area[Re+qe*this.width]=Ce}clear(){this.area.fill(0)}toString(){let Q="";for(let De=0;De<this.height;De++){const We=De*this.width;for(let Ce=0;Ce<this.width;Ce++){const Re=this.area[We+Ce];Q+=Re.toFixed(1).padStart(6),Q+=" "}Q+=`
|
|
|
`}return Q}draw(Q,De=!0){if(this.width<=0||this.height<=0)return;Q.save(),De&&Q.translate(this.pixelX,this.pixelY);const We=this.area.reduce((qe,st)=>Math.min(qe,st),Number.POSITIVE_INFINITY),Ce=this.area.reduce((qe,st)=>Math.max(qe,st),Number.NEGATIVE_INFINITY),Re=qe=>(qe-We)/(Ce-We);Q.scale(this.pixelGroup,this.pixelGroup);for(let qe=0;qe<this.width;qe++)for(let st=0;st<this.height;st++){const $e=this.area[qe+st*this.width];Q.fillStyle=`rgba(0, 0, 0, ${Re($e)})`,Q.fillRect(qe,st,1,1)}Q.restore()}drawThreshold(Q,De,We=!0){if(!(this.width<=0||this.height<=0)){Q.save(),We&&Q.translate(this.pixelX,this.pixelY),Q.scale(this.pixelGroup,this.pixelGroup);for(let Ce=0;Ce<this.width;Ce++)for(let Re=0;Re<this.height;Re++){const qe=this.area[Ce+Re*this.width];Q.fillStyle=qe>De?"black":"white",Q.fillRect(Ce,Re,1,1)}Q.restore()}}}function Te(we,Q){const De=We=>({x:We.x-Q,y:We.y-Q,width:We.width+2*Q,height:We.height+2*Q});return Array.isArray(we)?we.map(De):De(we)}function _e(we,Q,De){return Xe(Object.assign(S(we),{distSquare:(We,Ce)=>w(we.x1,we.y1,we.x2,we.y2,We,Ce)}),Q,De)}function Xe(we,Q,De){const We=Te(we,De),Ce=Q.scale(We),Re=Q.createSub(Ce,We);return Se(Re,Q,De,(qe,st)=>we.distSquare(qe,st)),Re}function Se(we,Q,De,We){const Ce=De*De;for(let Re=0;Re<we.height;Re++)for(let qe=0;qe<we.width;qe++){const st=Q.invertScaleX(we.i+qe),$e=Q.invertScaleY(we.j+Re),ft=We(st,$e);if(ft===0){we.set(qe,Re,Ce);continue}if(ft<Ce){const Ct=De-Math.sqrt(ft);we.set(qe,Re,Ct*Ct)}}return we}function Ge(we,Q,De){const We=Q.scale(we),Ce=Q.addPadding(We,De),Re=Q.createSub(Ce,{x:we.x-De,y:we.y-De}),qe=We.x-Ce.x,st=We.y-Ce.y,$e=Ce.x2-We.x2,ft=Ce.y2-We.y2,Ct=Ce.width-qe-$e,jt=Ce.height-st-ft,Qt=De*De;Re.fillArea({x:qe,y:st,width:Ct+1,height:jt+1},Qt);const pn=[0],Wn=Math.max(st,qe,$e,ft);{const Qn=Q.invertScaleX(We.x+We.width/2);for(let Vi=1;Vi<Wn;Vi++){const Oi=Q.invertScaleY(We.y-Vi),Gi=we.distSquare(Qn,Oi);if(Gi<Qt){const ir=De-Math.sqrt(Gi);pn.push(ir*ir)}else break}}const Rn=[],bi=Math.max(qe,$e),Dr=Math.max(st,$e);for(let Qn=1;Qn<bi;Qn++){const Vi=Q.invertScaleX(We.x-Qn),Oi=[];for(let Gi=1;Gi<Dr;Gi++){const ir=Q.invertScaleY(We.y-Gi),gs=we.distSquare(Vi,ir);if(gs<Qt){const Ls=De-Math.sqrt(gs);Oi.push(Ls*Ls)}else Oi.push(0)}Rn.push(Oi)}for(let Qn=1;Qn<Math.min(st,pn.length);Qn++){const Vi=pn[Qn];Re.fillHorizontalLine(qe,st-Qn,Ct+1,Vi)}for(let Qn=1;Qn<Math.min(ft,pn.length);Qn++){const Vi=pn[Qn];Re.fillHorizontalLine(qe,st+jt+Qn,Ct+1,Vi)}for(let Qn=1;Qn<Math.min(qe,pn.length);Qn++){const Vi=pn[Qn];Re.fillVerticalLine(qe-Qn,st,jt+1,Vi)}for(let Qn=1;Qn<Math.min(ft,pn.length);Qn++){const Vi=pn[Qn];Re.fillVerticalLine(qe+Ct+Qn,st,jt+1,Vi)}for(let Qn=1;Qn<qe;Qn++){const Vi=Rn[Qn-1],Oi=qe-Qn;for(let Gi=1;Gi<st;Gi++)Re.set(Oi,st-Gi,Vi[Gi-1]);for(let Gi=1;Gi<ft;Gi++)Re.set(Oi,st+jt+Gi,Vi[Gi-1])}for(let Qn=1;Qn<$e;Qn++){const Vi=Rn[Qn-1],Oi=qe+Ct+Qn;for(let Gi=1;Gi<st;Gi++)Re.set(Oi,st-Gi,Vi[Gi-1]);for(let Gi=1;Gi<ft;Gi++)Re.set(Oi,st+jt+Gi,Vi[Gi-1])}return Re}function He(we,Q,De,We){return{x:we,y:Q,width:De,height:We}}function vt(we,Q,De){return{cx:we,cy:Q,radius:De}}function It(we,Q,De,We){return{x1:we,y1:Q,x2:De,y2:We}}function zt(we,Q){return{x:we,y:Q}}function Yt(we,Q,De,We){if(we.length===0)return[];const Ce=Fe(we);return Ce.map((Re,qe)=>{const st=Ce.slice(0,qe);return At(Q,Re,st,De,We)}).flat()}function At(we,Q,De,We,Ce){const Re=zt(Q.cx,Q.cy),qe=le(Re,De,we);if(qe==null)return[];const st=new C(Re.x,Re.y,qe.cx,qe.cy),$e=lt(st,we,We,Ce);return Ot($e,we)}function lt(we,Q,De,We){const Ce=[],Re=[];Re.push(we);let qe=!0;for(let st=0;st<De&&qe;st++)for(qe=!1;!qe&&Re.length>0;){const $e=Re.pop(),ft=Ze(Q,$e),Ct=ft?fe($e,ft):null;if(!ft||!Ct||Ct.count!==2){qe||Ce.push($e);continue}let jt=We,Qt=Mt(ft,jt,Ct,!0),pn=Jt(Qt,Re)||Jt(Qt,Ce),Wn=gt(Qt,Q);for(;!pn&&Wn&&jt>=1;)jt/=1.5,Qt=Mt(ft,jt,Ct,!0),pn=Jt(Qt,Re)||Jt(Qt,Ce),Wn=gt(Qt,Q);if(Qt&&!pn&&!Wn&&(Re.push(new C($e.x1,$e.y1,Qt.x,Qt.y)),Re.push(new C(Qt.x,Qt.y,$e.x2,$e.y2)),qe=!0),qe)continue;jt=We,Qt=Mt(ft,jt,Ct,!1);let Rn=Jt(Qt,Re)||Jt(Qt,Ce);for(Wn=gt(Qt,Q);!Rn&&Wn&&jt>=1;)jt/=1.5,Qt=Mt(ft,jt,Ct,!1),Rn=Jt(Qt,Re)||Jt(Qt,Ce),Wn=gt(Qt,Q);Qt&&!Rn&&(Re.push(new C($e.x1,$e.y1,Qt.x,Qt.y)),Re.push(new C(Qt.x,Qt.y,$e.x2,$e.y2)),qe=!0),qe||Ce.push($e)}for(;Re.length>0;)Ce.push(Re.pop());return Ce}function Ot(we,Q){const De=[];for(;we.length>0;){const We=we.pop();if(we.length===0){De.push(We);break}const Ce=we.pop(),Re=new C(We.x1,We.y1,Ce.x2,Ce.y2);Ze(Q,Re)?(De.push(We),we.push(Ce)):we.push(Re)}return De}function le(we,Q,De){let We=Number.POSITIVE_INFINITY;return Q.reduce((Ce,Re)=>{const qe=k(we.x,we.y,Re.cx,Re.cy);if(qe>We)return Ce;const st=new C(we.x,we.y,Re.cx,Re.cy),$e=rt(De,st);return qe*($e+1)*($e+1)<We&&(Ce=Re,We=qe*($e+1)*($e+1)),Ce},null)}function Fe(we){if(we.length<2)return we;let Q=0,De=0;return we.forEach(We=>{Q+=We.cx,De+=We.cy}),Q/=we.length,De/=we.length,we.map(We=>{const Ce=Q-We.cx,Re=De-We.cy,qe=Ce*Ce+Re*Re;return[We,qe]}).sort((We,Ce)=>We[1]-Ce[1]).map(We=>We[0])}function gt(we,Q){return Q.some(De=>De.containsPt(we.x,we.y))}function Jt(we,Q){return Q.some(De=>!!(O(De.x1,De.y1,we.x,we.y,.001)||O(De.x2,De.y2,we.x,we.y,.001)))}function Ze(we,Q){let De=Number.POSITIVE_INFINITY,We=null;for(const Ce of we){if(!ie(Ce,Q))continue;const Re=pe(Ce,Q);Re>=0&&Re<De&&(We=Ce,De=Re)}return We}function rt(we,Q){return we.reduce((De,We)=>ie(We,Q)&&P(We,Q)?De+1:De,0)}function Mt(we,Q,De,We){const Ce=De.top,Re=De.left,qe=De.bottom,st=De.right;if(We){if(Re.state===x.POINT){if(Ce.state===x.POINT)return zt(we.x-Q,we.y-Q);if(qe.state===x.POINT)return zt(we.x-Q,we.y2+Q);const Qt=we.width*we.height;return we.width*((Re.y-we.y+(st.y-we.y))*.5)<Qt*.5?Re.y>st.y?zt(we.x-Q,we.y-Q):zt(we.x2+Q,we.y-Q):Re.y<st.y?zt(we.x-Q,we.y2+Q):zt(we.x2+Q,we.y2+Q)}if(st.state===x.POINT){if(Ce.state===x.POINT)return zt(we.x2+Q,we.y-Q);if(qe.state===x.POINT)return zt(we.x2+Q,we.y2+Q)}const Ct=we.height*we.width;return we.height*((Ce.x-we.x+(st.x-we.x))*.5)<Ct*.5?Ce.x>qe.x?zt(we.x-Q,we.y-Q):zt(we.x-Q,we.y2+Q):Ce.x<qe.x?zt(we.x2+Q,we.y-Q):zt(we.x2+Q,we.y2+Q)}if(Re.state===x.POINT){if(Ce.state===x.POINT)return zt(we.x2+Q,we.y2+Q);if(qe.state===x.POINT)return zt(we.x2+Q,we.y-Q);const Ct=we.height*we.width;return we.width*((Re.y-we.y+(st.y-we.y))*.5)<Ct*.5?Re.y>st.y?zt(we.x2+Q,we.y2+Q):zt(we.x-Q,we.y2+Q):Re.y<st.y?zt(we.x2+Q,we.y-Q):zt(we.x-Q,we.y-Q)}if(st.state===x.POINT){if(Ce.state===x.POINT)return zt(we.x-Q,we.y2+Q);if(qe.state===x.POINT)return zt(we.x-Q,we.y-Q)}const $e=we.height*we.width;return we.height*((Ce.x-we.x+(st.x-we.x))*.5)<$e*.5?Ce.x>qe.x?zt(we.x2+Q,we.y2+Q):zt(we.x2+Q,we.y-Q):Ce.x<qe.x?zt(we.x-Q,we.y2+Q):zt(we.x-Q,we.y-Q)}function Ue(we,Q,De,We){if(!(we.closed?De<we.length:De<we.length-1))return!1;const Re=we.get(Q),qe=we.get(De+1);for(let st=Q+1;st<=De;st++){const $e=we.get(st);if(w(Re.x,Re.y,qe.x,qe.y,$e.x,$e.y)>We)return!1}return!0}function Ye(we=0){return Q=>{if(we<0||Q.length<3)return Q;const De=[];let We=0;const Ce=we*we;for(;We<Q.length;){let Re=We+1;for(;Ue(Q,We,Re,Ce);)Re++;De.push(Q.get(We)),We=Re}return new wt(De)}}function be(we,Q){switch(we){case-2:return(((-Q+3)*Q-3)*Q+1)/6;case-1:return((3*Q-6)*Q*Q+4)/6;case 0:return(((-3*Q+3)*Q+3)*Q+1)/6;case 1:return Q*Q*Q/6;default:throw new Error("unknown error")}}function ge(we=6){function Re(qe,st,$e){let ft=0,Ct=0;for(let jt=-2;jt<=1;jt++){const Qt=qe.get(st+jt),pn=be(jt,$e);ft+=pn*Qt.x,Ct+=pn*Qt.y}return{x:ft,y:Ct}}return qe=>{if(qe.length<3)return qe;const st=[],$e=qe.closed,ft=qe.length+3-1+($e?0:2);st.push(Re(qe,2-($e?0:2),0));for(let Ct=2-($e?0:2);Ct<ft;Ct++)for(let jt=1;jt<=we;jt++)st.push(Re(qe,Ct,jt/we));return new wt(st)}}function Ke(we=8){return Q=>{let De=we,We=Q.length;if(De>1)for(We=Math.floor(Q.length/De);We<3&&De>1;)De-=1,We=Math.floor(Q.length/De);const Ce=[];for(let Re=0,qe=0;qe<We;qe++,Re+=De)Ce.push(Q.get(Re));return new wt(Ce)}}class wt{constructor(Q=[],De=!0){this.points=Q,this.closed=De}get(Q){const De=Q,We=this.points.length;return Q<0?this.closed?this.get(Q+We):this.points[0]:Q>=We?this.closed?this.get(Q-We):this.points[We-1]:this.points[De]}get length(){return this.points.length}toString(Q=1/0){const De=this.points;if(De.length===0)return"";const We=typeof Q=="function"?Q:R(Q);let Ce="M";for(const Re of De)Ce+=`${We(Re.x)},${We(Re.y)} L`;return Ce=Ce.slice(0,-1),this.closed&&(Ce+=" Z"),Ce}draw(Q){const De=this.points;if(De.length!==0){Q.beginPath(),Q.moveTo(De[0].x,De[0].y);for(const We of De)Q.lineTo(We.x,We.y);this.closed&&Q.closePath()}}sample(Q){return Ke(Q)(this)}simplify(Q){return Ye(Q)(this)}bSplines(Q){return ge(Q)(this)}apply(Q){return Q(this)}containsElements(Q){const De=ye(this.points);return De?Q.every(We=>De.containsPt(We.cx,We.cy)&&this.withinArea(We.cx,We.cy)):!1}withinArea(Q,De){if(this.length===0)return!1;let We=0;const Ce=this.points[0],Re=new C(Ce.x,Ce.y,Ce.x,Ce.y);for(let qe=1;qe<this.points.length;qe++){const st=this.points[qe];Re.x1=Re.x2,Re.y1=Re.y2,Re.x2=st.x,Re.y2=st.y,Re.cuts(Q,De)&&We++}return Re.x1=Re.x2,Re.y1=Re.y2,Re.x2=Ce.x,Re.y2=Ce.y,Re.cuts(Q,De)&&We++,We%2===1}}class Be{constructor(Q=0){this.count=0,this.arr=[],this.set=new Set,this.arr.length=Q}add(Q){this.set.add(`${Q.x}x${Q.y}`),this.arr[this.count++]=Q}contains(Q){return this.set.has(`${Q.x}x${Q.y}`)}isFirst(Q){if(this.count===0)return!1;const De=this.arr[0];return De!=null&&De.x===Q.x&&De.y===Q.y}path(){return new wt(this.arr.slice(0,this.count))}clear(){this.set.clear(),this.count=0}get(Q){return this.arr[Q]}get length(){return this.count}}const ut=0,Et=1,je=2,tt=3;function yt(we,Q){const De=(Math.floor(we.width)+Math.floor(we.height))*2,We=new Be(De);function Ce($e,ft,Ct,jt){const Qt=we.get($e,ft);return Number.isNaN(Qt)?Number.NaN:Qt>Q?Ct+jt:Ct}function Re($e,ft){let Ct=ut;return Ct=Ce($e,ft,Ct,1),Ct=Ce($e+1,ft,Ct,2),Ct=Ce($e,ft+1,Ct,4),Ct=Ce($e+1,ft+1,Ct,8),Number.isNaN(Ct)?-1:Ct}let qe=Et;function st($e,ft){let Ct=$e,jt=ft,Qt=we.invertScaleX(Ct),pn=we.invertScaleY(jt);for(let Wn=0;Wn<we.width*we.height;Wn++){const Rn={x:Qt,y:pn};if(We.contains(Rn)){if(We.isFirst(Rn))return!0}else We.add(Rn);const bi=Re(Ct,jt);switch(bi){case-1:return!0;case 0:case 3:case 2:case 7:qe=je;break;case 12:case 14:case 4:qe=tt;break;case 6:qe=qe===ut?tt:je;break;case 1:case 13:case 5:qe=ut;break;case 9:qe=qe===je?ut:Et;break;case 10:case 8:case 11:qe=Et;break;default:return console.warn("Marching squares invalid state: "+bi),!0}switch(qe){case ut:jt--,pn-=we.pixelGroup;break;case Et:jt++,pn+=we.pixelGroup;break;case tt:Ct--,Qt-=we.pixelGroup;break;case je:Ct++,Qt+=we.pixelGroup;break;default:return console.warn("Marching squares invalid state: "+bi),!0}}return!0}for(let $e=0;$e<we.width;$e++)for(let ft=0;ft<we.height;ft++){if(we.get($e,ft)<=Q)continue;const Ct=Re($e,ft);if(!(Ct<0||Ct===15)&&st($e,ft))return We.path()}return null}const B={maxRoutingIterations:100,maxMarchingIterations:20,pixelGroup:4,edgeR0:10,edgeR1:20,nodeR0:15,nodeR1:50,morphBuffer:10,threshold:1,memberInfluenceFactor:1,edgeInfluenceFactor:1,nonMemberInfluenceFactor:-.8,virtualEdges:!0};function te(we){return we!=null&&typeof we.radius=="number"}function ot(we,Q){if(te(we)!==te(Q))return!1;if(te(we)){const We=Q;return we.cx===We.cx&&we.cy===We.cy&&we.radius===We.radius}const De=Q;return we.x===De.x&&we.y===De.y&&we.width===De.width&&we.height===De.height}var _t;(function(we){we[we.MEMBERS=0]="MEMBERS",we[we.NON_MEMBERS=1]="NON_MEMBERS",we[we.EDGES=2]="EDGES"})(_t||(_t={}));class ct{constructor(Q={}){this.dirty=new Set,this.members=[],this.nonMembers=[],this.virtualEdges=[],this.edges=[],this.activeRegion=new ae(0,0,0,0),this.potentialArea=new Ne(1,0,0,0,0,0,0),this.o=Object.assign({},B,Q)}pushMember(...Q){if(Q.length!==0){this.dirty.add(_t.MEMBERS);for(const De of Q)this.members.push({raw:De,obj:te(De)?ue.from(De):ae.from(De),area:null})}}removeMember(Q){const De=this.members.findIndex(We=>ot(We.raw,Q));return De<0?!1:(this.members.splice(De,1),this.dirty.add(_t.MEMBERS),!0)}removeNonMember(Q){const De=this.nonMembers.findIndex(We=>ot(We.raw,Q));return De<0?!1:(this.nonMembers.splice(De,1),this.dirty.add(_t.NON_MEMBERS),!0)}removeEdge(Q){const De=this.edges.findIndex(We=>We.obj.equals(Q));return De<0?!1:(this.edges.splice(De,1),this.dirty.add(_t.NON_MEMBERS),!0)}pushNonMember(...Q){if(Q.length!==0){this.dirty.add(_t.NON_MEMBERS);for(const De of Q)this.nonMembers.push({raw:De,obj:te(De)?ue.from(De):ae.from(De),area:null})}}pushEdge(...Q){if(Q.length!==0){this.dirty.add(_t.EDGES);for(const De of Q)this.edges.push({raw:De,obj:C.from(De),area:null})}}update(){const Q=this.dirty.has(_t.MEMBERS),De=this.dirty.has(_t.NON_MEMBERS);let We=this.dirty.has(_t.EDGES);this.dirty.clear();const Ce=this.members.map(ft=>ft.obj);if(this.o.virtualEdges&&(Q||De)){const ft=this.nonMembers.map(Qt=>Qt.obj),Ct=Yt(Ce,ft,this.o.maxRoutingIterations,this.o.morphBuffer),jt=new Map(this.virtualEdges.map(Qt=>[Qt.obj.toString(),Qt.area]));this.virtualEdges=Ct.map(Qt=>{var pn;return{raw:Qt,obj:Qt,area:(pn=jt.get(Qt.toString()))!==null&&pn!==void 0?pn:null}}),We=!0}let Re=!1;if(Q||We){const ft=this.virtualEdges.concat(this.edges).map(pn=>pn.obj),Ct=en(Ce,ft),jt=Math.max(this.o.edgeR1,this.o.nodeR1)+this.o.morphBuffer,Qt=ae.from(Te(Ct,jt));Qt.equals(this.activeRegion)||(Re=!0,this.activeRegion=Qt)}if(Re){const ft=Math.ceil(this.activeRegion.width/this.o.pixelGroup),Ct=Math.ceil(this.activeRegion.height/this.o.pixelGroup);this.activeRegion.x!==this.potentialArea.pixelX||this.activeRegion.y!==this.potentialArea.pixelY?(this.potentialArea=Ne.fromPixelRegion(this.activeRegion,this.o.pixelGroup),this.members.forEach(jt=>jt.area=null),this.nonMembers.forEach(jt=>jt.area=null),this.edges.forEach(jt=>jt.area=null),this.virtualEdges.forEach(jt=>jt.area=null)):(ft!==this.potentialArea.width||Ct!==this.potentialArea.height)&&(this.potentialArea=Ne.fromPixelRegion(this.activeRegion,this.o.pixelGroup))}const qe=new Map,st=ft=>{if(ft.area){const Ct=`${ft.obj.width}x${ft.obj.height}x${ft.obj instanceof ae?"R":"C"}`;qe.set(Ct,ft.area)}},$e=ft=>{if(ft.area)return;const Ct=`${ft.obj.width}x${ft.obj.height}x${ft.obj instanceof ae?"R":"C"}`;if(qe.has(Ct)){const Qt=qe.get(Ct);ft.area=this.potentialArea.copy(Qt,{x:ft.obj.x-this.o.nodeR1,y:ft.obj.y-this.o.nodeR1});return}const jt=ft.obj instanceof ae?Ge(ft.obj,this.potentialArea,this.o.nodeR1):Xe(ft.obj,this.potentialArea,this.o.nodeR1);ft.area=jt,qe.set(Ct,jt)};this.members.forEach(st),this.nonMembers.forEach(st),this.members.forEach($e),this.nonMembers.forEach(ft=>{this.activeRegion.intersects(ft.obj)?$e(ft):ft.area=null}),this.edges.forEach(ft=>{ft.area||(ft.area=_e(ft.obj,this.potentialArea,this.o.edgeR1))}),this.virtualEdges.forEach(ft=>{ft.area||(ft.area=_e(ft.obj,this.potentialArea,this.o.edgeR1))})}drawMembers(Q){for(const De of this.members)De.obj.draw(Q)}drawNonMembers(Q){for(const De of this.nonMembers)De.obj.draw(Q)}drawEdges(Q){for(const De of this.edges)De.obj.draw(Q)}drawPotentialArea(Q,De=!0){this.potentialArea.draw(Q,De)}compute(){if(this.members.length===0)return new wt([]);this.dirty.size>0&&this.update();const{o:Q,potentialArea:De}=this,We=this.members.map(st=>st.area),Ce=this.virtualEdges.concat(this.edges).map(st=>st.area),Re=this.nonMembers.filter(st=>st.area!=null).map(st=>st.area),qe=this.members.map(st=>st.obj);return qt(De,We,Ce,Re,st=>st.containsElements(qe),Q)}}function qt(we,Q,De,We,Ce,Re={}){const qe=Object.assign({},B,Re);let st=qe.threshold,$e=qe.memberInfluenceFactor,ft=qe.edgeInfluenceFactor,Ct=qe.nonMemberInfluenceFactor;const jt=(qe.nodeR0-qe.nodeR1)*(qe.nodeR0-qe.nodeR1),Qt=(qe.edgeR0-qe.edgeR1)*(qe.edgeR0-qe.edgeR1);for(let pn=0;pn<qe.maxMarchingIterations;pn++){if(we.clear(),$e!==0){const Rn=$e/jt;for(const bi of Q)we.incArea(bi,Rn)}if(ft!==0){const Rn=ft/Qt;for(const bi of De)we.incArea(bi,Rn)}if(Ct!==0){const Rn=Ct/jt;for(const bi of We)we.incArea(bi,Rn)}const Wn=yt(we,st);if(Wn&&Ce(Wn))return Wn;if(st*=.95,pn<=qe.maxMarchingIterations*.5)$e*=1.2,ft*=1.2;else if(Ct!==0&&We.length>0)Ct*=.8;else break}return new wt([])}function en(we,Q){if(we.length===0)return new ae(0,0,0,0);const De=ae.from(we[0]);for(const We of we)De.add(We);for(const We of Q)De.add(S(We));return De}function nn(we,Q=[],De=[],We={}){if(we.length===0)return new wt([]);const Ce=new ct(We);return Ce.pushMember(...we),Ce.pushNonMember(...Q),Ce.pushEdge(...De),Ce.compute()}},8874:function(se){"use strict";se.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},19818:function(se,ee,b){var w=b(8874),k=b(86851),O=Object.hasOwnProperty,R=Object.create(null);for(var S in w)O.call(w,S)&&(R[w[S]]=S);var C=se.exports={to:{},get:{}};C.get=function(N){var L=N.substring(0,3).toLowerCase(),P,W;switch(L){case"hsl":P=C.get.hsl(N),W="hsl";break;case"hwb":P=C.get.hwb(N),W="hwb";break;default:P=C.get.rgb(N),W="rgb";break}return P?{model:W,value:P}:null},C.get.rgb=function(N){if(!N)return null;var L=/^#([a-f0-9]{3,4})$/i,P=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,W=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,Y=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,ie=/^(\w+)$/,pe=[0,0,0,1],fe,ae,ye;if(fe=N.match(P)){for(ye=fe[2],fe=fe[1],ae=0;ae<3;ae++){var ue=ae*2;pe[ae]=parseInt(fe.slice(ue,ue+2),16)}ye&&(pe[3]=parseInt(ye,16)/255)}else if(fe=N.match(L)){for(fe=fe[1],ye=fe[3],ae=0;ae<3;ae++)pe[ae]=parseInt(fe[ae]+fe[ae],16);ye&&(pe[3]=parseInt(ye+ye,16)/255)}else if(fe=N.match(W)){for(ae=0;ae<3;ae++)pe[ae]=parseInt(fe[ae+1],0);fe[4]&&(fe[5]?pe[3]=parseFloat(fe[4])*.01:pe[3]=parseFloat(fe[4]))}else if(fe=N.match(Y)){for(ae=0;ae<3;ae++)pe[ae]=Math.round(parseFloat(fe[ae+1])*2.55);fe[4]&&(fe[5]?pe[3]=parseFloat(fe[4])*.01:pe[3]=parseFloat(fe[4]))}else return(fe=N.match(ie))?fe[1]==="transparent"?[0,0,0,0]:O.call(w,fe[1])?(pe=w[fe[1]],pe[3]=1,pe):null:null;for(ae=0;ae<3;ae++)pe[ae]=x(pe[ae],0,255);return pe[3]=x(pe[3],0,1),pe},C.get.hsl=function(N){if(!N)return null;var L=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,P=N.match(L);if(P){var W=parseFloat(P[4]),Y=(parseFloat(P[1])%360+360)%360,ie=x(parseFloat(P[2]),0,100),pe=x(parseFloat(P[3]),0,100),fe=x(isNaN(W)?1:W,0,1);return[Y,ie,pe,fe]}return null},C.get.hwb=function(N){if(!N)return null;var L=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,P=N.match(L);if(P){var W=parseFloat(P[4]),Y=(parseFloat(P[1])%360+360)%360,ie=x(parseFloat(P[2]),0,100),pe=x(parseFloat(P[3]),0,100),fe=x(isNaN(W)?1:W,0,1);return[Y,ie,pe,fe]}return null},C.to.hex=function(){var N=k(arguments);return"#"+E(N[0])+E(N[1])+E(N[2])+(N[3]<1?E(Math.round(N[3]*255)):"")},C.to.rgb=function(){var N=k(arguments);return N.length<4||N[3]===1?"rgb("+Math.round(N[0])+", "+Math.round(N[1])+", "+Math.round(N[2])+")":"rgba("+Math.round(N[0])+", "+Math.round(N[1])+", "+Math.round(N[2])+", "+N[3]+")"},C.to.rgb.percent=function(){var N=k(arguments),L=Math.round(N[0]/255*100),P=Math.round(N[1]/255*100),W=Math.round(N[2]/255*100);return N.length<4||N[3]===1?"rgb("+L+"%, "+P+"%, "+W+"%)":"rgba("+L+"%, "+P+"%, "+W+"%, "+N[3]+")"},C.to.hsl=function(){var N=k(arguments);return N.length<4||N[3]===1?"hsl("+N[0]+", "+N[1]+"%, "+N[2]+"%)":"hsla("+N[0]+", "+N[1]+"%, "+N[2]+"%, "+N[3]+")"},C.to.hwb=function(){var N=k(arguments),L="";return N.length>=4&&N[3]!==1&&(L=", "+N[3]),"hwb("+N[0]+", "+N[1]+"%, "+N[2]+"%"+L+")"},C.to.keyword=function(N){return R[N.slice(0,3)]};function x(N,L,P){return Math.min(Math.max(L,N),P)}function E(N){var L=Math.round(N).toString(16).toUpperCase();return L.length<2?"0"+L:L}},70681:function(se,ee,b){se.exports={graphlib:b(70574),layout:b(98123),debug:b(27570),util:{time:b(11138).time,notime:b(11138).notime},version:b(88177)}},92188:function(se,ee,b){"use strict";var w=b(38436),k=b(74079);se.exports={run:O,undo:S};function O(C){var x=C.graph().acyclicer==="greedy"?k(C,E(C)):R(C);w.forEach(x,function(N){var L=C.edge(N);C.removeEdge(N),L.forwardName=N.name,L.reversed=!0,C.setEdge(N.w,N.v,L,w.uniqueId("rev"))});function E(N){return function(L){return N.edge(L).weight}}}function R(C){var x=[],E={},N={};function L(P){w.has(N,P)||(N[P]=!0,E[P]=!0,w.forEach(C.outEdges(P),function(W){w.has(E,W.w)?x.push(W):L(W.w)}),delete E[P])}return w.forEach(C.nodes(),L),x}function S(C){w.forEach(C.edges(),function(x){var E=C.edge(x);if(E.reversed){C.removeEdge(x);var N=E.forwardName;delete E.reversed,delete E.forwardName,C.setEdge(x.w,x.v,E,N)}})}},61133:function(se,ee,b){var w=b(38436),k=b(11138);se.exports=O;function O(S){function C(x){var E=S.children(x),N=S.node(x);if(E.length&&w.forEach(E,C),w.has(N,"minRank")){N.borderLeft=[],N.borderRight=[];for(var L=N.minRank,P=N.maxRank+1;L<P;++L)R(S,"borderLeft","_bl",x,N,L),R(S,"borderRight","_br",x,N,L)}}w.forEach(S.children(),C)}function R(S,C,x,E,N,L){var P={width:0,height:0,rank:L,borderType:C},W=N[C][L-1],Y=k.addDummyNode(S,"border",P,x);N[C][L]=Y,S.setParent(Y,E),W&&S.setEdge(W,Y,{weight:1})}},53258:function(se,ee,b){"use strict";var w=b(38436);se.exports={adjust:k,undo:O};function k(L){var P=L.graph().rankdir.toLowerCase();(P==="lr"||P==="rl")&&R(L)}function O(L){var P=L.graph().rankdir.toLowerCase();(P==="bt"||P==="rl")&&C(L),(P==="lr"||P==="rl")&&(E(L),R(L))}function R(L){w.forEach(L.nodes(),function(P){S(L.node(P))}),w.forEach(L.edges(),function(P){S(L.edge(P))})}function S(L){var P=L.width;L.width=L.height,L.height=P}function C(L){w.forEach(L.nodes(),function(P){x(L.node(P))}),w.forEach(L.edges(),function(P){var W=L.edge(P);w.forEach(W.points,x),w.has(W,"y")&&x(W)})}function x(L){L.y=-L.y}function E(L){w.forEach(L.nodes(),function(P){N(L.node(P))}),w.forEach(L.edges(),function(P){var W=L.edge(P);w.forEach(W.points,N),w.has(W,"x")&&N(W)})}function N(L){var P=L.x;L.x=L.y,L.y=P}},77822:function(se){se.exports=ee;function ee(){var k={};k._next=k._prev=k,this._sentinel=k}ee.prototype.dequeue=function(){var k=this._sentinel,O=k._prev;if(O!==k)return b(O),O},ee.prototype.enqueue=function(k){var O=this._sentinel;k._prev&&k._next&&b(k),k._next=O._next,O._next._prev=k,O._next=k,k._prev=O},ee.prototype.toString=function(){for(var k=[],O=this._sentinel,R=O._prev;R!==O;)k.push(JSON.stringify(R,w)),R=R._prev;return"["+k.join(", ")+"]"};function b(k){k._prev._next=k._next,k._next._prev=k._prev,delete k._next,delete k._prev}function w(k,O){if(k!=="_next"&&k!=="_prev")return O}},27570:function(se,ee,b){var w=b(38436),k=b(11138),O=b(70574).Graph;se.exports={debugOrdering:R};function R(S){var C=k.buildLayerMatrix(S),x=new O({compound:!0,multigraph:!0}).setGraph({});return w.forEach(S.nodes(),function(E){x.setNode(E,{label:E}),x.setParent(E,"layer"+S.node(E).rank)}),w.forEach(S.edges(),function(E){x.setEdge(E.v,E.w,{},E.name)}),w.forEach(C,function(E,N){var L="layer"+N;x.setNode(L,{rank:"same"}),w.reduce(E,function(P,W){return x.setEdge(P,W,{style:"invis"}),W})}),x}},70574:function(se,ee,b){var w;try{w=b(28282)}catch(k){}w||(w=window.graphlib),se.exports=w},74079:function(se,ee,b){var w=b(38436),k=b(70574).Graph,O=b(77822);se.exports=S;var R=w.constant(1);function S(L,P){if(L.nodeCount()<=1)return[];var W=E(L,P||R),Y=C(W.graph,W.buckets,W.zeroIdx);return w.flatten(w.map(Y,function(ie){return L.outEdges(ie.v,ie.w)}),!0)}function C(L,P,W){for(var Y=[],ie=P[P.length-1],pe=P[0],fe;L.nodeCount();){for(;fe=pe.dequeue();)x(L,P,W,fe);for(;fe=ie.dequeue();)x(L,P,W,fe);if(L.nodeCount()){for(var ae=P.length-2;ae>0;--ae)if(fe=P[ae].dequeue(),fe){Y=Y.concat(x(L,P,W,fe,!0));break}}}return Y}function x(L,P,W,Y,ie){var pe=ie?[]:void 0;return w.forEach(L.inEdges(Y.v),function(fe){var ae=L.edge(fe),ye=L.node(fe.v);ie&&pe.push({v:fe.v,w:fe.w}),ye.out-=ae,N(P,W,ye)}),w.forEach(L.outEdges(Y.v),function(fe){var ae=L.edge(fe),ye=fe.w,ue=L.node(ye);ue.in-=ae,N(P,W,ue)}),L.removeNode(Y.v),pe}function E(L,P){var W=new k,Y=0,ie=0;w.forEach(L.nodes(),function(ae){W.setNode(ae,{v:ae,in:0,out:0})}),w.forEach(L.edges(),function(ae){var ye=W.edge(ae.v,ae.w)||0,ue=P(ae),Ne=ye+ue;W.setEdge(ae.v,ae.w,Ne),ie=Math.max(ie,W.node(ae.v).out+=ue),Y=Math.max(Y,W.node(ae.w).in+=ue)});var pe=w.range(ie+Y+3).map(function(){return new O}),fe=Y+1;return w.forEach(W.nodes(),function(ae){N(pe,fe,W.node(ae))}),{graph:W,buckets:pe,zeroIdx:fe}}function N(L,P,W){W.out?W.in?L[W.out-W.in+P].enqueue(W):L[L.length-1].enqueue(W):L[0].enqueue(W)}},98123:function(se,ee,b){"use strict";var w=b(38436),k=b(92188),O=b(45995),R=b(78093),S=b(11138).normalizeRanks,C=b(24219),x=b(11138).removeEmptyRanks,E=b(72981),N=b(61133),L=b(53258),P=b(53408),W=b(17873),Y=b(11138),ie=b(70574).Graph;se.exports=pe;function pe(Ue,Ye){var be=Ye&&Ye.debugTiming?Y.time:Y.notime;be("layout",function(){var ge=be(" buildLayoutGraph",function(){return He(Ue)});be(" runLayout",function(){fe(ge,be)}),be(" updateInputGraph",function(){ae(Ue,ge)})})}function fe(Ue,Ye){Ye(" makeSpaceForEdgeLabels",function(){vt(Ue)}),Ye(" removeSelfEdges",function(){gt(Ue)}),Ye(" acyclic",function(){k.run(Ue)}),Ye(" nestingGraph.run",function(){E.run(Ue)}),Ye(" rank",function(){R(Y.asNonCompoundGraph(Ue))}),Ye(" injectEdgeLabelProxies",function(){It(Ue)}),Ye(" removeEmptyRanks",function(){x(Ue)}),Ye(" nestingGraph.cleanup",function(){E.cleanup(Ue)}),Ye(" normalizeRanks",function(){S(Ue)}),Ye(" assignRankMinMax",function(){zt(Ue)}),Ye(" removeEdgeLabelProxies",function(){Yt(Ue)}),Ye(" normalize.run",function(){O.run(Ue)}),Ye(" parentDummyChains",function(){C(Ue)}),Ye(" addBorderSegments",function(){N(Ue)}),Ye(" order",function(){P(Ue)}),Ye(" insertSelfEdges",function(){Jt(Ue)}),Ye(" adjustCoordinateSystem",function(){L.adjust(Ue)}),Ye(" position",function(){W(Ue)}),Ye(" positionSelfEdges",function(){Ze(Ue)}),Ye(" removeBorderNodes",function(){Fe(Ue)}),Ye(" normalize.undo",function(){O.undo(Ue)}),Ye(" fixupEdgeLabelCoords",function(){Ot(Ue)}),Ye(" undoCoordinateSystem",function(){L.undo(Ue)}),Ye(" translateGraph",function(){At(Ue)}),Ye(" assignNodeIntersects",function(){lt(Ue)}),Ye(" reversePoints",function(){le(Ue)}),Ye(" acyclic.undo",function(){k.undo(Ue)})}function ae(Ue,Ye){w.forEach(Ue.nodes(),function(be){var ge=Ue.node(be),Ke=Ye.node(be);ge&&(ge.x=Ke.x,ge.y=Ke.y,Ye.children(be).length&&(ge.width=Ke.width,ge.height=Ke.height))}),w.forEach(Ue.edges(),function(be){var ge=Ue.edge(be),Ke=Ye.edge(be);ge.points=Ke.points,w.has(Ke,"x")&&(ge.x=Ke.x,ge.y=Ke.y)}),Ue.graph().width=Ye.graph().width,Ue.graph().height=Ye.graph().height}var ye=["nodesep","edgesep","ranksep","marginx","marginy"],ue={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},Ne=["acyclicer","ranker","rankdir","align"],Te=["width","height"],_e={width:0,height:0},Xe=["minlen","weight","width","height","labeloffset"],Se={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Ge=["labelpos"];function He(Ue){var Ye=new ie({multigraph:!0,compound:!0}),be=Mt(Ue.graph());return Ye.setGraph(w.merge({},ue,rt(be,ye),w.pick(be,Ne))),w.forEach(Ue.nodes(),function(ge){var Ke=Mt(Ue.node(ge));Ye.setNode(ge,w.defaults(rt(Ke,Te),_e)),Ye.setParent(ge,Ue.parent(ge))}),w.forEach(Ue.edges(),function(ge){var Ke=Mt(Ue.edge(ge));Ye.setEdge(ge,w.merge({},Se,rt(Ke,Xe),w.pick(Ke,Ge)))}),Ye}function vt(Ue){var Ye=Ue.graph();Ye.ranksep/=2,w.forEach(Ue.edges(),function(be){var ge=Ue.edge(be);ge.minlen*=2,ge.labelpos.toLowerCase()!=="c"&&(Ye.rankdir==="TB"||Ye.rankdir==="BT"?ge.width+=ge.labeloffset:ge.height+=ge.labeloffset)})}function It(Ue){w.forEach(Ue.edges(),function(Ye){var be=Ue.edge(Ye);if(be.width&&be.height){var ge=Ue.node(Ye.v),Ke=Ue.node(Ye.w),wt={rank:(Ke.rank-ge.rank)/2+ge.rank,e:Ye};Y.addDummyNode(Ue,"edge-proxy",wt,"_ep")}})}function zt(Ue){var Ye=0;w.forEach(Ue.nodes(),function(be){var ge=Ue.node(be);ge.borderTop&&(ge.minRank=Ue.node(ge.borderTop).rank,ge.maxRank=Ue.node(ge.borderBottom).rank,Ye=w.max(Ye,ge.maxRank))}),Ue.graph().maxRank=Ye}function Yt(Ue){w.forEach(Ue.nodes(),function(Ye){var be=Ue.node(Ye);be.dummy==="edge-proxy"&&(Ue.edge(be.e).labelRank=be.rank,Ue.removeNode(Ye))})}function At(Ue){var Ye=Number.POSITIVE_INFINITY,be=0,ge=Number.POSITIVE_INFINITY,Ke=0,wt=Ue.graph(),Be=wt.marginx||0,ut=wt.marginy||0;function Et(je){var tt=je.x,yt=je.y,B=je.width,te=je.height;Ye=Math.min(Ye,tt-B/2),be=Math.max(be,tt+B/2),ge=Math.min(ge,yt-te/2),Ke=Math.max(Ke,yt+te/2)}w.forEach(Ue.nodes(),function(je){Et(Ue.node(je))}),w.forEach(Ue.edges(),function(je){var tt=Ue.edge(je);w.has(tt,"x")&&Et(tt)}),Ye-=Be,ge-=ut,w.forEach(Ue.nodes(),function(je){var tt=Ue.node(je);tt.x-=Ye,tt.y-=ge}),w.forEach(Ue.edges(),function(je){var tt=Ue.edge(je);w.forEach(tt.points,function(yt){yt.x-=Ye,yt.y-=ge}),w.has(tt,"x")&&(tt.x-=Ye),w.has(tt,"y")&&(tt.y-=ge)}),wt.width=be-Ye+Be,wt.height=Ke-ge+ut}function lt(Ue){w.forEach(Ue.edges(),function(Ye){var be=Ue.edge(Ye),ge=Ue.node(Ye.v),Ke=Ue.node(Ye.w),wt,Be;be.points?(wt=be.points[0],Be=be.points[be.points.length-1]):(be.points=[],wt=Ke,Be=ge),be.points.unshift(Y.intersectRect(ge,wt)),be.points.push(Y.intersectRect(Ke,Be))})}function Ot(Ue){w.forEach(Ue.edges(),function(Ye){var be=Ue.edge(Ye);if(w.has(be,"x"))switch((be.labelpos==="l"||be.labelpos==="r")&&(be.width-=be.labeloffset),be.labelpos){case"l":be.x-=be.width/2+be.labeloffset;break;case"r":be.x+=be.width/2+be.labeloffset;break}})}function le(Ue){w.forEach(Ue.edges(),function(Ye){var be=Ue.edge(Ye);be.reversed&&be.points.reverse()})}function Fe(Ue){w.forEach(Ue.nodes(),function(Ye){if(Ue.children(Ye).length){var be=Ue.node(Ye),ge=Ue.node(be.borderTop),Ke=Ue.node(be.borderBottom),wt=Ue.node(w.last(be.borderLeft)),Be=Ue.node(w.last(be.borderRight));be.width=Math.abs(Be.x-wt.x),be.height=Math.abs(Ke.y-ge.y),be.x=wt.x+be.width/2,be.y=ge.y+be.height/2}}),w.forEach(Ue.nodes(),function(Ye){Ue.node(Ye).dummy==="border"&&Ue.removeNode(Ye)})}function gt(Ue){w.forEach(Ue.edges(),function(Ye){if(Ye.v===Ye.w){var be=Ue.node(Ye.v);be.selfEdges||(be.selfEdges=[]),be.selfEdges.push({e:Ye,label:Ue.edge(Ye)}),Ue.removeEdge(Ye)}})}function Jt(Ue){var Ye=Y.buildLayerMatrix(Ue);w.forEach(Ye,function(be){var ge=0;w.forEach(be,function(Ke,wt){var Be=Ue.node(Ke);Be.order=wt+ge,w.forEach(Be.selfEdges,function(ut){Y.addDummyNode(Ue,"selfedge",{width:ut.label.width,height:ut.label.height,rank:Be.rank,order:wt+ ++ge,e:ut.e,label:ut.label},"_se")}),delete Be.selfEdges})})}function Ze(Ue){w.forEach(Ue.nodes(),function(Ye){var be=Ue.node(Ye);if(be.dummy==="selfedge"){var ge=Ue.node(be.e.v),Ke=ge.x+ge.width/2,wt=ge.y,Be=be.x-Ke,ut=ge.height/2;Ue.setEdge(be.e,be.label),Ue.removeNode(Ye),be.label.points=[{x:Ke+2*Be/3,y:wt-ut},{x:Ke+5*Be/6,y:wt-ut},{x:Ke+Be,y:wt},{x:Ke+5*Be/6,y:wt+ut},{x:Ke+2*Be/3,y:wt+ut}],be.label.x=be.x,be.label.y=be.y}})}function rt(Ue,Ye){return w.mapValues(w.pick(Ue,Ye),Number)}function Mt(Ue){var Ye={};return w.forEach(Ue,function(be,ge){Ye[ge.toLowerCase()]=be}),Ye}},38436:function(se,ee,b){var w;try{w={cloneDeep:b(50361),constant:b(75703),defaults:b(91747),each:b(85768),filter:b(63105),find:b(13311),flatten:b(85564),forEach:b(84486),forIn:b(62620),has:b(18721),isUndefined:b(52353),last:b(10928),map:b(35161),mapValues:b(8521),max:b(6162),merge:b(82492),min:b(53632),minBy:b(22762),now:b(7771),pick:b(78718),range:b(96026),reduce:b(54061),sortBy:b(89734),uniqueId:b(73955),values:b(52628),zipObject:b(7287)}}catch(k){}w||(w=window._),se.exports=w},72981:function(se,ee,b){var w=b(38436),k=b(11138);se.exports={run:O,cleanup:x};function O(E){var N=k.addDummyNode(E,"root",{},"_root"),L=S(E),P=w.max(w.values(L))-1,W=2*P+1;E.graph().nestingRoot=N,w.forEach(E.edges(),function(ie){E.edge(ie).minlen*=W});var Y=C(E)+1;w.forEach(E.children(),function(ie){R(E,N,W,Y,P,L,ie)}),E.graph().nodeRankFactor=W}function R(E,N,L,P,W,Y,ie){var pe=E.children(ie);if(!pe.length){ie!==N&&E.setEdge(N,ie,{weight:0,minlen:L});return}var fe=k.addBorderNode(E,"_bt"),ae=k.addBorderNode(E,"_bb"),ye=E.node(ie);E.setParent(fe,ie),ye.borderTop=fe,E.setParent(ae,ie),ye.borderBottom=ae,w.forEach(pe,function(ue){R(E,N,L,P,W,Y,ue);var Ne=E.node(ue),Te=Ne.borderTop?Ne.borderTop:ue,_e=Ne.borderBottom?Ne.borderBottom:ue,Xe=Ne.borderTop?P:2*P,Se=Te!==_e?1:W-Y[ie]+1;E.setEdge(fe,Te,{weight:Xe,minlen:Se,nestingEdge:!0}),E.setEdge(_e,ae,{weight:Xe,minlen:Se,nestingEdge:!0})}),E.parent(ie)||E.setEdge(N,fe,{weight:0,minlen:W+Y[ie]})}function S(E){var N={};function L(P,W){var Y=E.children(P);Y&&Y.length&&w.forEach(Y,function(ie){L(ie,W+1)}),N[P]=W}return w.forEach(E.children(),function(P){L(P,1)}),N}function C(E){return w.reduce(E.edges(),function(N,L){return N+E.edge(L).weight},0)}function x(E){var N=E.graph();E.removeNode(N.nestingRoot),delete N.nestingRoot,w.forEach(E.edges(),function(L){var P=E.edge(L);P.nestingEdge&&E.removeEdge(L)})}},45995:function(se,ee,b){"use strict";var w=b(38436),k=b(11138);se.exports={run:O,undo:S};function O(C){C.graph().dummyChains=[],w.forEach(C.edges(),function(x){R(C,x)})}function R(C,x){var E=x.v,N=C.node(E).rank,L=x.w,P=C.node(L).rank,W=x.name,Y=C.edge(x),ie=Y.labelRank;if(P!==N+1){C.removeEdge(x);var pe,fe,ae;for(ae=0,++N;N<P;++ae,++N)Y.points=[],fe={width:0,height:0,edgeLabel:Y,edgeObj:x,rank:N},pe=k.addDummyNode(C,"edge",fe,"_d"),N===ie&&(fe.width=Y.width,fe.height=Y.height,fe.dummy="edge-label",fe.labelpos=Y.labelpos),C.setEdge(E,pe,{weight:Y.weight},W),ae===0&&C.graph().dummyChains.push(pe),E=pe;C.setEdge(E,L,{weight:Y.weight},W)}}function S(C){w.forEach(C.graph().dummyChains,function(x){var E=C.node(x),N=E.edgeLabel,L;for(C.setEdge(E.edgeObj,N);E.dummy;)L=C.successors(x)[0],C.removeNode(x),N.points.push({x:E.x,y:E.y}),E.dummy==="edge-label"&&(N.x=E.x,N.y=E.y,N.width=E.width,N.height=E.height),x=L,E=C.node(x)})}},55093:function(se,ee,b){var w=b(38436);se.exports=k;function k(O,R,S){var C={},x;w.forEach(S,function(E){for(var N=O.parent(E),L,P;N;){if(L=O.parent(N),L?(P=C[L],C[L]=N):(P=x,x=N),P&&P!==N){R.setEdge(P,N);return}N=L}})}},35439:function(se,ee,b){var w=b(38436);se.exports=k;function k(O,R){return w.map(R,function(S){var C=O.inEdges(S);if(C.length){var x=w.reduce(C,function(E,N){var L=O.edge(N),P=O.node(N.v);return{sum:E.sum+L.weight*P.order,weight:E.weight+L.weight}},{sum:0,weight:0});return{v:S,barycenter:x.sum/x.weight,weight:x.weight}}else return{v:S}})}},23128:function(se,ee,b){var w=b(38436),k=b(70574).Graph;se.exports=O;function O(S,C,x){var E=R(S),N=new k({compound:!0}).setGraph({root:E}).setDefaultNodeLabel(function(L){return S.node(L)});return w.forEach(S.nodes(),function(L){var P=S.node(L),W=S.parent(L);(P.rank===C||P.minRank<=C&&C<=P.maxRank)&&(N.setNode(L),N.setParent(L,W||E),w.forEach(S[x](L),function(Y){var ie=Y.v===L?Y.w:Y.v,pe=N.edge(ie,L),fe=w.isUndefined(pe)?0:pe.weight;N.setEdge(ie,L,{weight:S.edge(Y).weight+fe})}),w.has(P,"minRank")&&N.setNode(L,{borderLeft:P.borderLeft[C],borderRight:P.borderRight[C]}))}),N}function R(S){for(var C;S.hasNode(C=w.uniqueId("_root")););return C}},56630:function(se,ee,b){"use strict";var w=b(38436);se.exports=k;function k(R,S){for(var C=0,x=1;x<S.length;++x)C+=O(R,S[x-1],S[x]);return C}function O(R,S,C){for(var x=w.zipObject(C,w.map(C,function(Y,ie){return ie})),E=w.flatten(w.map(S,function(Y){return w.sortBy(w.map(R.outEdges(Y),function(ie){return{pos:x[ie.w],weight:R.edge(ie).weight}}),"pos")}),!0),N=1;N<C.length;)N<<=1;var L=2*N-1;N-=1;var P=w.map(new Array(L),function(){return 0}),W=0;return w.forEach(E.forEach(function(Y){var ie=Y.pos+N;P[ie]+=Y.weight;for(var pe=0;ie>0;)ie%2&&(pe+=P[ie+1]),ie=ie-1>>1,P[ie]+=Y.weight;W+=Y.weight*pe})),W}},53408:function(se,ee,b){"use strict";var w=b(38436),k=b(2588),O=b(56630),R=b(61026),S=b(23128),C=b(55093),x=b(70574).Graph,E=b(11138);se.exports=N;function N(Y){var ie=E.maxRank(Y),pe=L(Y,w.range(1,ie+1),"inEdges"),fe=L(Y,w.range(ie-1,-1,-1),"outEdges"),ae=k(Y);W(Y,ae);for(var ye=Number.POSITIVE_INFINITY,ue,Ne=0,Te=0;Te<4;++Ne,++Te){P(Ne%2?pe:fe,Ne%4>=2),ae=E.buildLayerMatrix(Y);var _e=O(Y,ae);_e<ye&&(Te=0,ue=w.cloneDeep(ae),ye=_e)}W(Y,ue)}function L(Y,ie,pe){return w.map(ie,function(fe){return S(Y,fe,pe)})}function P(Y,ie){var pe=new x;w.forEach(Y,function(fe){var ae=fe.graph().root,ye=R(fe,ae,pe,ie);w.forEach(ye.vs,function(ue,Ne){fe.node(ue).order=Ne}),C(fe,pe,ye.vs)})}function W(Y,ie){w.forEach(ie,function(pe){w.forEach(pe,function(fe,ae){Y.node(fe).order=ae})})}},2588:function(se,ee,b){"use strict";var w=b(38436);se.exports=k;function k(O){var R={},S=w.filter(O.nodes(),function(L){return!O.children(L).length}),C=w.max(w.map(S,function(L){return O.node(L).rank})),x=w.map(w.range(C+1),function(){return[]});function E(L){if(!w.has(R,L)){R[L]=!0;var P=O.node(L);x[P.rank].push(L),w.forEach(O.successors(L),E)}}var N=w.sortBy(S,function(L){return O.node(L).rank});return w.forEach(N,E),x}},83678:function(se,ee,b){"use strict";var w=b(38436);se.exports=k;function k(S,C){var x={};w.forEach(S,function(N,L){var P=x[N.v]={indegree:0,in:[],out:[],vs:[N.v],i:L};w.isUndefined(N.barycenter)||(P.barycenter=N.barycenter,P.weight=N.weight)}),w.forEach(C.edges(),function(N){var L=x[N.v],P=x[N.w];!w.isUndefined(L)&&!w.isUndefined(P)&&(P.indegree++,L.out.push(x[N.w]))});var E=w.filter(x,function(N){return!N.indegree});return O(E)}function O(S){var C=[];function x(L){return function(P){P.merged||(w.isUndefined(P.barycenter)||w.isUndefined(L.barycenter)||P.barycenter>=L.barycenter)&&R(L,P)}}function E(L){return function(P){P.in.push(L),--P.indegree===0&&S.push(P)}}for(;S.length;){var N=S.pop();C.push(N),w.forEach(N.in.reverse(),x(N)),w.forEach(N.out,E(N))}return w.map(w.filter(C,function(L){return!L.merged}),function(L){return w.pick(L,["vs","i","barycenter","weight"])})}function R(S,C){var x=0,E=0;S.weight&&(x+=S.barycenter*S.weight,E+=S.weight),C.weight&&(x+=C.barycenter*C.weight,E+=C.weight),S.vs=C.vs.concat(S.vs),S.barycenter=x/E,S.weight=E,S.i=Math.min(C.i,S.i),C.merged=!0}},61026:function(se,ee,b){var w=b(38436),k=b(35439),O=b(83678),R=b(87304);se.exports=S;function S(E,N,L,P){var W=E.children(N),Y=E.node(N),ie=Y?Y.borderLeft:void 0,pe=Y?Y.borderRight:void 0,fe={};ie&&(W=w.filter(W,function(_e){return _e!==ie&&_e!==pe}));var ae=k(E,W);w.forEach(ae,function(_e){if(E.children(_e.v).length){var Xe=S(E,_e.v,L,P);fe[_e.v]=Xe,w.has(Xe,"barycenter")&&x(_e,Xe)}});var ye=O(ae,L);C(ye,fe);var ue=R(ye,P);if(ie&&(ue.vs=w.flatten([ie,ue.vs,pe],!0),E.predecessors(ie).length)){var Ne=E.node(E.predecessors(ie)[0]),Te=E.node(E.predecessors(pe)[0]);w.has(ue,"barycenter")||(ue.barycenter=0,ue.weight=0),ue.barycenter=(ue.barycenter*ue.weight+Ne.order+Te.order)/(ue.weight+2),ue.weight+=2}return ue}function C(E,N){w.forEach(E,function(L){L.vs=w.flatten(L.vs.map(function(P){return N[P]?N[P].vs:P}),!0)})}function x(E,N){w.isUndefined(E.barycenter)?(E.barycenter=N.barycenter,E.weight=N.weight):(E.barycenter=(E.barycenter*E.weight+N.barycenter*N.weight)/(E.weight+N.weight),E.weight+=N.weight)}},87304:function(se,ee,b){var w=b(38436),k=b(11138);se.exports=O;function O(C,x){var E=k.partition(C,function(fe){return w.has(fe,"barycenter")}),N=E.lhs,L=w.sortBy(E.rhs,function(fe){return-fe.i}),P=[],W=0,Y=0,ie=0;N.sort(S(!!x)),ie=R(P,L,ie),w.forEach(N,function(fe){ie+=fe.vs.length,P.push(fe.vs),W+=fe.barycenter*fe.weight,Y+=fe.weight,ie=R(P,L,ie)});var pe={vs:w.flatten(P,!0)};return Y&&(pe.barycenter=W/Y,pe.weight=Y),pe}function R(C,x,E){for(var N;x.length&&(N=w.last(x)).i<=E;)x.pop(),C.push(N.vs),E++;return E}function S(C){return function(x,E){return x.barycenter<E.barycenter?-1:x.barycenter>E.barycenter?1:C?E.i-x.i:x.i-E.i}}},24219:function(se,ee,b){var w=b(38436);se.exports=k;function k(S){var C=R(S);w.forEach(S.graph().dummyChains,function(x){for(var E=S.node(x),N=E.edgeObj,L=O(S,C,N.v,N.w),P=L.path,W=L.lca,Y=0,ie=P[Y],pe=!0;x!==N.w;){if(E=S.node(x),pe){for(;(ie=P[Y])!==W&&S.node(ie).maxRank<E.rank;)Y++;ie===W&&(pe=!1)}if(!pe){for(;Y<P.length-1&&S.node(ie=P[Y+1]).minRank<=E.rank;)Y++;ie=P[Y]}S.setParent(x,ie),x=S.successors(x)[0]}})}function O(S,C,x,E){var N=[],L=[],P=Math.min(C[x].low,C[E].low),W=Math.max(C[x].lim,C[E].lim),Y,ie;Y=x;do Y=S.parent(Y),N.push(Y);while(Y&&(C[Y].low>P||W>C[Y].lim));for(ie=Y,Y=E;(Y=S.parent(Y))!==ie;)L.push(Y);return{path:N.concat(L.reverse()),lca:ie}}function R(S){var C={},x=0;function E(N){var L=x;w.forEach(S.children(N),E),C[N]={low:L,lim:x++}}return w.forEach(S.children(),E),C}},3573:function(se,ee,b){"use strict";var w=b(38436),k=b(70574).Graph,O=b(11138);se.exports={positionX:pe,findType1Conflicts:R,findType2Conflicts:S,addConflict:x,hasConflict:E,verticalAlignment:N,horizontalCompaction:L,alignCoordinates:Y,findSmallestWidthAlignment:W,balance:ie};function R(ye,ue){var Ne={};function Te(_e,Xe){var Se=0,Ge=0,He=_e.length,vt=w.last(Xe);return w.forEach(Xe,function(It,zt){var Yt=C(ye,It),At=Yt?ye.node(Yt).order:He;(Yt||It===vt)&&(w.forEach(Xe.slice(Ge,zt+1),function(lt){w.forEach(ye.predecessors(lt),function(Ot){var le=ye.node(Ot),Fe=le.order;(Fe<Se||At<Fe)&&!(le.dummy&&ye.node(lt).dummy)&&x(Ne,Ot,lt)})}),Ge=zt+1,Se=At)}),Xe}return w.reduce(ue,Te),Ne}function S(ye,ue){var Ne={};function Te(Xe,Se,Ge,He,vt){var It;w.forEach(w.range(Se,Ge),function(zt){It=Xe[zt],ye.node(It).dummy&&w.forEach(ye.predecessors(It),function(Yt){var At=ye.node(Yt);At.dummy&&(At.order<He||At.order>vt)&&x(Ne,Yt,It)})})}function _e(Xe,Se){var Ge=-1,He,vt=0;return w.forEach(Se,function(It,zt){if(ye.node(It).dummy==="border"){var Yt=ye.predecessors(It);Yt.length&&(He=ye.node(Yt[0]).order,Te(Se,vt,zt,Ge,He),vt=zt,Ge=He)}Te(Se,vt,Se.length,He,Xe.length)}),Se}return w.reduce(ue,_e),Ne}function C(ye,ue){if(ye.node(ue).dummy)return w.find(ye.predecessors(ue),function(Ne){return ye.node(Ne).dummy})}function x(ye,ue,Ne){if(ue>Ne){var Te=ue;ue=Ne,Ne=Te}var _e=ye[ue];_e||(ye[ue]=_e={}),_e[Ne]=!0}function E(ye,ue,Ne){if(ue>Ne){var Te=ue;ue=Ne,Ne=Te}return w.has(ye[ue],Ne)}function N(ye,ue,Ne,Te){var _e={},Xe={},Se={};return w.forEach(ue,function(Ge){w.forEach(Ge,function(He,vt){_e[He]=He,Xe[He]=He,Se[He]=vt})}),w.forEach(ue,function(Ge){var He=-1;w.forEach(Ge,function(vt){var It=Te(vt);if(It.length){It=w.sortBy(It,function(Ot){return Se[Ot]});for(var zt=(It.length-1)/2,Yt=Math.floor(zt),At=Math.ceil(zt);Yt<=At;++Yt){var lt=It[Yt];Xe[vt]===vt&&He<Se[lt]&&!E(Ne,vt,lt)&&(Xe[lt]=vt,Xe[vt]=_e[vt]=_e[lt],He=Se[lt])}}})}),{root:_e,align:Xe}}function L(ye,ue,Ne,Te,_e){var Xe={},Se=P(ye,ue,Ne,_e),Ge=_e?"borderLeft":"borderRight";function He(zt,Yt){for(var At=Se.nodes(),lt=At.pop(),Ot={};lt;)Ot[lt]?zt(lt):(Ot[lt]=!0,At.push(lt),At=At.concat(Yt(lt))),lt=At.pop()}function vt(zt){Xe[zt]=Se.inEdges(zt).reduce(function(Yt,At){return Math.max(Yt,Xe[At.v]+Se.edge(At))},0)}function It(zt){var Yt=Se.outEdges(zt).reduce(function(lt,Ot){return Math.min(lt,Xe[Ot.w]-Se.edge(Ot))},Number.POSITIVE_INFINITY),At=ye.node(zt);Yt!==Number.POSITIVE_INFINITY&&At.borderType!==Ge&&(Xe[zt]=Math.max(Xe[zt],Yt))}return He(vt,Se.predecessors.bind(Se)),He(It,Se.successors.bind(Se)),w.forEach(Te,function(zt){Xe[zt]=Xe[Ne[zt]]}),Xe}function P(ye,ue,Ne,Te){var _e=new k,Xe=ye.graph(),Se=fe(Xe.nodesep,Xe.edgesep,Te);return w.forEach(ue,function(Ge){var He;w.forEach(Ge,function(vt){var It=Ne[vt];if(_e.setNode(It),He){var zt=Ne[He],Yt=_e.edge(zt,It);_e.setEdge(zt,It,Math.max(Se(ye,vt,He),Yt||0))}He=vt})}),_e}function W(ye,ue){return w.minBy(w.values(ue),function(Ne){var Te=Number.NEGATIVE_INFINITY,_e=Number.POSITIVE_INFINITY;return w.forIn(Ne,function(Xe,Se){var Ge=ae(ye,Se)/2;Te=Math.max(Xe+Ge,Te),_e=Math.min(Xe-Ge,_e)}),Te-_e})}function Y(ye,ue){var Ne=w.values(ue),Te=w.min(Ne),_e=w.max(Ne);w.forEach(["u","d"],function(Xe){w.forEach(["l","r"],function(Se){var Ge=Xe+Se,He=ye[Ge],vt;if(He!==ue){var It=w.values(He);vt=Se==="l"?Te-w.min(It):_e-w.max(It),vt&&(ye[Ge]=w.mapValues(He,function(zt){return zt+vt}))}})})}function ie(ye,ue){return w.mapValues(ye.ul,function(Ne,Te){if(ue)return ye[ue.toLowerCase()][Te];var _e=w.sortBy(w.map(ye,Te));return(_e[1]+_e[2])/2})}function pe(ye){var ue=O.buildLayerMatrix(ye),Ne=w.merge(R(ye,ue),S(ye,ue)),Te={},_e;w.forEach(["u","d"],function(Se){_e=Se==="u"?ue:w.values(ue).reverse(),w.forEach(["l","r"],function(Ge){Ge==="r"&&(_e=w.map(_e,function(zt){return w.values(zt).reverse()}));var He=(Se==="u"?ye.predecessors:ye.successors).bind(ye),vt=N(ye,_e,Ne,He),It=L(ye,_e,vt.root,vt.align,Ge==="r");Ge==="r"&&(It=w.mapValues(It,function(zt){return-zt})),Te[Se+Ge]=It})});var Xe=W(ye,Te);return Y(Te,Xe),ie(Te,ye.graph().align)}function fe(ye,ue,Ne){return function(Te,_e,Xe){var Se=Te.node(_e),Ge=Te.node(Xe),He=0,vt;if(He+=Se.width/2,w.has(Se,"labelpos"))switch(Se.labelpos.toLowerCase()){case"l":vt=-Se.width/2;break;case"r":vt=Se.width/2;break}if(vt&&(He+=Ne?vt:-vt),vt=0,He+=(Se.dummy?ue:ye)/2,He+=(Ge.dummy?ue:ye)/2,He+=Ge.width/2,w.has(Ge,"labelpos"))switch(Ge.labelpos.toLowerCase()){case"l":vt=Ge.width/2;break;case"r":vt=-Ge.width/2;break}return vt&&(He+=Ne?vt:-vt),vt=0,He}}function ae(ye,ue){return ye.node(ue).width}},17873:function(se,ee,b){"use strict";var w=b(38436),k=b(11138),O=b(3573).positionX;se.exports=R;function R(C){C=k.asNonCompoundGraph(C),S(C),w.forEach(O(C),function(x,E){C.node(E).x=x})}function S(C){var x=k.buildLayerMatrix(C),E=C.graph().ranksep,N=0;w.forEach(x,function(L){var P=w.max(w.map(L,function(W){return C.node(W).height}));w.forEach(L,function(W){C.node(W).y=N+P/2}),N+=P+E})}},20300:function(se,ee,b){"use strict";var w=b(38436),k=b(70574).Graph,O=b(76681).slack;se.exports=R;function R(E){var N=new k({directed:!1}),L=E.nodes()[0],P=E.nodeCount();N.setNode(L,{});for(var W,Y;S(N,E)<P;)W=C(N,E),Y=N.hasNode(W.v)?O(E,W):-O(E,W),x(N,E,Y);return N}function S(E,N){function L(P){w.forEach(N.nodeEdges(P),function(W){var Y=W.v,ie=P===Y?W.w:Y;!E.hasNode(ie)&&!O(N,W)&&(E.setNode(ie,{}),E.setEdge(P,ie,{}),L(ie))})}return w.forEach(E.nodes(),L),E.nodeCount()}function C(E,N){return w.minBy(N.edges(),function(L){if(E.hasNode(L.v)!==E.hasNode(L.w))return O(N,L)})}function x(E,N,L){w.forEach(E.nodes(),function(P){N.node(P).rank+=L})}},78093:function(se,ee,b){"use strict";var w=b(76681),k=w.longestPath,O=b(20300),R=b(42472);se.exports=S;function S(N){switch(N.graph().ranker){case"network-simplex":E(N);break;case"tight-tree":x(N);break;case"longest-path":C(N);break;default:E(N)}}var C=k;function x(N){k(N),O(N)}function E(N){R(N)}},42472:function(se,ee,b){"use strict";var w=b(38436),k=b(20300),O=b(76681).slack,R=b(76681).longestPath,S=b(70574).alg.preorder,C=b(70574).alg.postorder,x=b(11138).simplify;se.exports=E,E.initLowLimValues=W,E.initCutValues=N,E.calcCutValue=P,E.leaveEdge=ie,E.enterEdge=pe,E.exchangeEdges=fe;function E(Ne){Ne=x(Ne),R(Ne);var Te=k(Ne);W(Te),N(Te,Ne);for(var _e,Xe;_e=ie(Te);)Xe=pe(Te,Ne,_e),fe(Te,Ne,_e,Xe)}function N(Ne,Te){var _e=C(Ne,Ne.nodes());_e=_e.slice(0,_e.length-1),w.forEach(_e,function(Xe){L(Ne,Te,Xe)})}function L(Ne,Te,_e){var Xe=Ne.node(_e),Se=Xe.parent;Ne.edge(_e,Se).cutvalue=P(Ne,Te,_e)}function P(Ne,Te,_e){var Xe=Ne.node(_e),Se=Xe.parent,Ge=!0,He=Te.edge(_e,Se),vt=0;return He||(Ge=!1,He=Te.edge(Se,_e)),vt=He.weight,w.forEach(Te.nodeEdges(_e),function(It){var zt=It.v===_e,Yt=zt?It.w:It.v;if(Yt!==Se){var At=zt===Ge,lt=Te.edge(It).weight;if(vt+=At?lt:-lt,ye(Ne,_e,Yt)){var Ot=Ne.edge(_e,Yt).cutvalue;vt+=At?-Ot:Ot}}}),vt}function W(Ne,Te){arguments.length<2&&(Te=Ne.nodes()[0]),Y(Ne,{},1,Te)}function Y(Ne,Te,_e,Xe,Se){var Ge=_e,He=Ne.node(Xe);return Te[Xe]=!0,w.forEach(Ne.neighbors(Xe),function(vt){w.has(Te,vt)||(_e=Y(Ne,Te,_e,vt,Xe))}),He.low=Ge,He.lim=_e++,Se?He.parent=Se:delete He.parent,_e}function ie(Ne){return w.find(Ne.edges(),function(Te){return Ne.edge(Te).cutvalue<0})}function pe(Ne,Te,_e){var Xe=_e.v,Se=_e.w;Te.hasEdge(Xe,Se)||(Xe=_e.w,Se=_e.v);var Ge=Ne.node(Xe),He=Ne.node(Se),vt=Ge,It=!1;Ge.lim>He.lim&&(vt=He,It=!0);var zt=w.filter(Te.edges(),function(Yt){return It===ue(Ne,Ne.node(Yt.v),vt)&&It!==ue(Ne,Ne.node(Yt.w),vt)});return w.minBy(zt,function(Yt){return O(Te,Yt)})}function fe(Ne,Te,_e,Xe){var Se=_e.v,Ge=_e.w;Ne.removeEdge(Se,Ge),Ne.setEdge(Xe.v,Xe.w,{}),W(Ne),N(Ne,Te),ae(Ne,Te)}function ae(Ne,Te){var _e=w.find(Ne.nodes(),function(Se){return!Te.node(Se).parent}),Xe=S(Ne,_e);Xe=Xe.slice(1),w.forEach(Xe,function(Se){var Ge=Ne.node(Se).parent,He=Te.edge(Se,Ge),vt=!1;He||(He=Te.edge(Ge,Se),vt=!0),Te.node(Se).rank=Te.node(Ge).rank+(vt?He.minlen:-He.minlen)})}function ye(Ne,Te,_e){return Ne.hasEdge(Te,_e)}function ue(Ne,Te,_e){return _e.low<=Te.lim&&Te.lim<=_e.lim}},76681:function(se,ee,b){"use strict";var w=b(38436);se.exports={longestPath:k,slack:O};function k(R){var S={};function C(x){var E=R.node(x);if(w.has(S,x))return E.rank;S[x]=!0;var N=w.min(w.map(R.outEdges(x),function(L){return C(L.w)-R.edge(L).minlen}));return(N===Number.POSITIVE_INFINITY||N===void 0||N===null)&&(N=0),E.rank=N}w.forEach(R.sources(),C)}function O(R,S){return R.node(S.w).rank-R.node(S.v).rank-R.edge(S).minlen}},11138:function(se,ee,b){"use strict";var w=b(38436),k=b(70574).Graph;se.exports={addDummyNode:O,simplify:R,asNonCompoundGraph:S,successorWeights:C,predecessorWeights:x,intersectRect:E,buildLayerMatrix:N,normalizeRanks:L,removeEmptyRanks:P,addBorderNode:W,maxRank:Y,partition:ie,time:pe,notime:fe};function O(ae,ye,ue,Ne){var Te;do Te=w.uniqueId(Ne);while(ae.hasNode(Te));return ue.dummy=ye,ae.setNode(Te,ue),Te}function R(ae){var ye=new k().setGraph(ae.graph());return w.forEach(ae.nodes(),function(ue){ye.setNode(ue,ae.node(ue))}),w.forEach(ae.edges(),function(ue){var Ne=ye.edge(ue.v,ue.w)||{weight:0,minlen:1},Te=ae.edge(ue);ye.setEdge(ue.v,ue.w,{weight:Ne.weight+Te.weight,minlen:Math.max(Ne.minlen,Te.minlen)})}),ye}function S(ae){var ye=new k({multigraph:ae.isMultigraph()}).setGraph(ae.graph());return w.forEach(ae.nodes(),function(ue){ae.children(ue).length||ye.setNode(ue,ae.node(ue))}),w.forEach(ae.edges(),function(ue){ye.setEdge(ue,ae.edge(ue))}),ye}function C(ae){var ye=w.map(ae.nodes(),function(ue){var Ne={};return w.forEach(ae.outEdges(ue),function(Te){Ne[Te.w]=(Ne[Te.w]||0)+ae.edge(Te).weight}),Ne});return w.zipObject(ae.nodes(),ye)}function x(ae){var ye=w.map(ae.nodes(),function(ue){var Ne={};return w.forEach(ae.inEdges(ue),function(Te){Ne[Te.v]=(Ne[Te.v]||0)+ae.edge(Te).weight}),Ne});return w.zipObject(ae.nodes(),ye)}function E(ae,ye){var ue=ae.x,Ne=ae.y,Te=ye.x-ue,_e=ye.y-Ne,Xe=ae.width/2,Se=ae.height/2;if(!Te&&!_e)throw new Error("Not possible to find intersection inside of the rectangle");var Ge,He;return Math.abs(_e)*Xe>Math.abs(Te)*Se?(_e<0&&(Se=-Se),Ge=Se*Te/_e,He=Se):(Te<0&&(Xe=-Xe),Ge=Xe,He=Xe*_e/Te),{x:ue+Ge,y:Ne+He}}function N(ae){var ye=w.map(w.range(Y(ae)+1),function(){return[]});return w.forEach(ae.nodes(),function(ue){var Ne=ae.node(ue),Te=Ne.rank;w.isUndefined(Te)||(ye[Te][Ne.order]=ue)}),ye}function L(ae){var ye=w.min(w.map(ae.nodes(),function(ue){return ae.node(ue).rank}));w.forEach(ae.nodes(),function(ue){var Ne=ae.node(ue);w.has(Ne,"rank")&&(Ne.rank-=ye)})}function P(ae){var ye=w.min(w.map(ae.nodes(),function(_e){return ae.node(_e).rank})),ue=[];w.forEach(ae.nodes(),function(_e){var Xe=ae.node(_e).rank-ye;ue[Xe]||(ue[Xe]=[]),ue[Xe].push(_e)});var Ne=0,Te=ae.graph().nodeRankFactor;w.forEach(ue,function(_e,Xe){w.isUndefined(_e)&&Xe%Te!==0?--Ne:Ne&&w.forEach(_e,function(Se){ae.node(Se).rank+=Ne})})}function W(ae,ye,ue,Ne){var Te={width:0,height:0};return arguments.length>=4&&(Te.rank=ue,Te.order=Ne),O(ae,"border",Te,ye)}function Y(ae){return w.max(w.map(ae.nodes(),function(ye){var ue=ae.node(ye).rank;if(!w.isUndefined(ue))return ue}))}function ie(ae,ye){var ue={lhs:[],rhs:[]};return w.forEach(ae,function(Ne){ye(Ne)?ue.lhs.push(Ne):ue.rhs.push(Ne)}),ue}function pe(ae,ye){var ue=w.now();try{return ye()}finally{console.log(ae+" time: "+(w.now()-ue)+"ms")}}function fe(ae,ye){return ye()}},88177:function(se){se.exports="0.8.5"},26729:function(se){"use strict";var ee=Object.prototype.hasOwnProperty,b="~";function w(){}Object.create&&(w.prototype=Object.create(null),new w().__proto__||(b=!1));function k(C,x,E){this.fn=C,this.context=x,this.once=E||!1}function O(C,x,E,N,L){if(typeof E!="function")throw new TypeError("The listener must be a function");var P=new k(E,N||C,L),W=b?b+x:x;return C._events[W]?C._events[W].fn?C._events[W]=[C._events[W],P]:C._events[W].push(P):(C._events[W]=P,C._eventsCount++),C}function R(C,x){--C._eventsCount===0?C._events=new w:delete C._events[x]}function S(){this._events=new w,this._eventsCount=0}S.prototype.eventNames=function(){var x=[],E,N;if(this._eventsCount===0)return x;for(N in E=this._events)ee.call(E,N)&&x.push(b?N.slice(1):N);return Object.getOwnPropertySymbols?x.concat(Object.getOwnPropertySymbols(E)):x},S.prototype.listeners=function(x){var E=b?b+x:x,N=this._events[E];if(!N)return[];if(N.fn)return[N.fn];for(var L=0,P=N.length,W=new Array(P);L<P;L++)W[L]=N[L].fn;return W},S.prototype.listenerCount=function(x){var E=b?b+x:x,N=this._events[E];return N?N.fn?1:N.length:0},S.prototype.emit=function(x,E,N,L,P,W){var Y=b?b+x:x;if(!this._events[Y])return!1;var ie=this._events[Y],pe=arguments.length,fe,ae;if(ie.fn){switch(ie.once&&this.removeListener(x,ie.fn,void 0,!0),pe){case 1:return ie.fn.call(ie.context),!0;case 2:return ie.fn.call(ie.context,E),!0;case 3:return ie.fn.call(ie.context,E,N),!0;case 4:return ie.fn.call(ie.context,E,N,L),!0;case 5:return ie.fn.call(ie.context,E,N,L,P),!0;case 6:return ie.fn.call(ie.context,E,N,L,P,W),!0}for(ae=1,fe=new Array(pe-1);ae<pe;ae++)fe[ae-1]=arguments[ae];ie.fn.apply(ie.context,fe)}else{var ye=ie.length,ue;for(ae=0;ae<ye;ae++)switch(ie[ae].once&&this.removeListener(x,ie[ae].fn,void 0,!0),pe){case 1:ie[ae].fn.call(ie[ae].context);break;case 2:ie[ae].fn.call(ie[ae].context,E);break;case 3:ie[ae].fn.call(ie[ae].context,E,N);break;case 4:ie[ae].fn.call(ie[ae].context,E,N,L);break;default:if(!fe)for(ue=1,fe=new Array(pe-1);ue<pe;ue++)fe[ue-1]=arguments[ue];ie[ae].fn.apply(ie[ae].context,fe)}}return!0},S.prototype.on=function(x,E,N){return O(this,x,E,N,!1)},S.prototype.once=function(x,E,N){return O(this,x,E,N,!0)},S.prototype.removeListener=function(x,E,N,L){var P=b?b+x:x;if(!this._events[P])return this;if(!E)return R(this,P),this;var W=this._events[P];if(W.fn)W.fn===E&&(!L||W.once)&&(!N||W.context===N)&&R(this,P);else{for(var Y=0,ie=[],pe=W.length;Y<pe;Y++)(W[Y].fn!==E||L&&!W[Y].once||N&&W[Y].context!==N)&&ie.push(W[Y]);ie.length?this._events[P]=ie.length===1?ie[0]:ie:R(this,P)}return this},S.prototype.removeAllListeners=function(x){var E;return x?(E=b?b+x:x,this._events[E]&&R(this,E)):(this._events=new w,this._eventsCount=0),this},S.prototype.off=S.prototype.removeListener,S.prototype.addListener=S.prototype.on,S.prefixed=b,S.EventEmitter=S,se.exports=S},49685:function(se,ee,b){"use strict";b.d(ee,{Ib:function(){return w},WT:function(){return k}});var w=1e-6,k=typeof Float32Array!="undefined"?Float32Array:Array,O=Math.random;function R(E){k=E}var S=Math.PI/180;function C(E){return E*S}function x(E,N){return Math.abs(E-N)<=w*Math.max(1,Math.abs(E),Math.abs(N))}Math.hypot||(Math.hypot=function(){for(var E=0,N=arguments.length;N--;)E+=arguments[N]*arguments[N];return Math.sqrt(E)})},35600:function(se,ee,b){"use strict";b.d(ee,{Ue:function(){return k},al:function(){return C},xO:function(){return O}});var w=b(49685);function k(){var le=new w.WT(9);return w.WT!=Float32Array&&(le[1]=0,le[2]=0,le[3]=0,le[5]=0,le[6]=0,le[7]=0),le[0]=1,le[4]=1,le[8]=1,le}function O(le,Fe){return le[0]=Fe[0],le[1]=Fe[1],le[2]=Fe[2],le[3]=Fe[4],le[4]=Fe[5],le[5]=Fe[6],le[6]=Fe[8],le[7]=Fe[9],le[8]=Fe[10],le}function R(le){var Fe=new glMatrix.ARRAY_TYPE(9);return Fe[0]=le[0],Fe[1]=le[1],Fe[2]=le[2],Fe[3]=le[3],Fe[4]=le[4],Fe[5]=le[5],Fe[6]=le[6],Fe[7]=le[7],Fe[8]=le[8],Fe}function S(le,Fe){return le[0]=Fe[0],le[1]=Fe[1],le[2]=Fe[2],le[3]=Fe[3],le[4]=Fe[4],le[5]=Fe[5],le[6]=Fe[6],le[7]=Fe[7],le[8]=Fe[8],le}function C(le,Fe,gt,Jt,Ze,rt,Mt,Ue,Ye){var be=new w.WT(9);return be[0]=le,be[1]=Fe,be[2]=gt,be[3]=Jt,be[4]=Ze,be[5]=rt,be[6]=Mt,be[7]=Ue,be[8]=Ye,be}function x(le,Fe,gt,Jt,Ze,rt,Mt,Ue,Ye,be){return le[0]=Fe,le[1]=gt,le[2]=Jt,le[3]=Ze,le[4]=rt,le[5]=Mt,le[6]=Ue,le[7]=Ye,le[8]=be,le}function E(le){return le[0]=1,le[1]=0,le[2]=0,le[3]=0,le[4]=1,le[5]=0,le[6]=0,le[7]=0,le[8]=1,le}function N(le,Fe){if(le===Fe){var gt=Fe[1],Jt=Fe[2],Ze=Fe[5];le[1]=Fe[3],le[2]=Fe[6],le[3]=gt,le[5]=Fe[7],le[6]=Jt,le[7]=Ze}else le[0]=Fe[0],le[1]=Fe[3],le[2]=Fe[6],le[3]=Fe[1],le[4]=Fe[4],le[5]=Fe[7],le[6]=Fe[2],le[7]=Fe[5],le[8]=Fe[8];return le}function L(le,Fe){var gt=Fe[0],Jt=Fe[1],Ze=Fe[2],rt=Fe[3],Mt=Fe[4],Ue=Fe[5],Ye=Fe[6],be=Fe[7],ge=Fe[8],Ke=ge*Mt-Ue*be,wt=-ge*rt+Ue*Ye,Be=be*rt-Mt*Ye,ut=gt*Ke+Jt*wt+Ze*Be;return ut?(ut=1/ut,le[0]=Ke*ut,le[1]=(-ge*Jt+Ze*be)*ut,le[2]=(Ue*Jt-Ze*Mt)*ut,le[3]=wt*ut,le[4]=(ge*gt-Ze*Ye)*ut,le[5]=(-Ue*gt+Ze*rt)*ut,le[6]=Be*ut,le[7]=(-be*gt+Jt*Ye)*ut,le[8]=(Mt*gt-Jt*rt)*ut,le):null}function P(le,Fe){var gt=Fe[0],Jt=Fe[1],Ze=Fe[2],rt=Fe[3],Mt=Fe[4],Ue=Fe[5],Ye=Fe[6],be=Fe[7],ge=Fe[8];return le[0]=Mt*ge-Ue*be,le[1]=Ze*be-Jt*ge,le[2]=Jt*Ue-Ze*Mt,le[3]=Ue*Ye-rt*ge,le[4]=gt*ge-Ze*Ye,le[5]=Ze*rt-gt*Ue,le[6]=rt*be-Mt*Ye,le[7]=Jt*Ye-gt*be,le[8]=gt*Mt-Jt*rt,le}function W(le){var Fe=le[0],gt=le[1],Jt=le[2],Ze=le[3],rt=le[4],Mt=le[5],Ue=le[6],Ye=le[7],be=le[8];return Fe*(be*rt-Mt*Ye)+gt*(-be*Ze+Mt*Ue)+Jt*(Ye*Ze-rt*Ue)}function Y(le,Fe,gt){var Jt=Fe[0],Ze=Fe[1],rt=Fe[2],Mt=Fe[3],Ue=Fe[4],Ye=Fe[5],be=Fe[6],ge=Fe[7],Ke=Fe[8],wt=gt[0],Be=gt[1],ut=gt[2],Et=gt[3],je=gt[4],tt=gt[5],yt=gt[6],B=gt[7],te=gt[8];return le[0]=wt*Jt+Be*Mt+ut*be,le[1]=wt*Ze+Be*Ue+ut*ge,le[2]=wt*rt+Be*Ye+ut*Ke,le[3]=Et*Jt+je*Mt+tt*be,le[4]=Et*Ze+je*Ue+tt*ge,le[5]=Et*rt+je*Ye+tt*Ke,le[6]=yt*Jt+B*Mt+te*be,le[7]=yt*Ze+B*Ue+te*ge,le[8]=yt*rt+B*Ye+te*Ke,le}function ie(le,Fe,gt){var Jt=Fe[0],Ze=Fe[1],rt=Fe[2],Mt=Fe[3],Ue=Fe[4],Ye=Fe[5],be=Fe[6],ge=Fe[7],Ke=Fe[8],wt=gt[0],Be=gt[1];return le[0]=Jt,le[1]=Ze,le[2]=rt,le[3]=Mt,le[4]=Ue,le[5]=Ye,le[6]=wt*Jt+Be*Mt+be,le[7]=wt*Ze+Be*Ue+ge,le[8]=wt*rt+Be*Ye+Ke,le}function pe(le,Fe,gt){var Jt=Fe[0],Ze=Fe[1],rt=Fe[2],Mt=Fe[3],Ue=Fe[4],Ye=Fe[5],be=Fe[6],ge=Fe[7],Ke=Fe[8],wt=Math.sin(gt),Be=Math.cos(gt);return le[0]=Be*Jt+wt*Mt,le[1]=Be*Ze+wt*Ue,le[2]=Be*rt+wt*Ye,le[3]=Be*Mt-wt*Jt,le[4]=Be*Ue-wt*Ze,le[5]=Be*Ye-wt*rt,le[6]=be,le[7]=ge,le[8]=Ke,le}function fe(le,Fe,gt){var Jt=gt[0],Ze=gt[1];return le[0]=Jt*Fe[0],le[1]=Jt*Fe[1],le[2]=Jt*Fe[2],le[3]=Ze*Fe[3],le[4]=Ze*Fe[4],le[5]=Ze*Fe[5],le[6]=Fe[6],le[7]=Fe[7],le[8]=Fe[8],le}function ae(le,Fe){return le[0]=1,le[1]=0,le[2]=0,le[3]=0,le[4]=1,le[5]=0,le[6]=Fe[0],le[7]=Fe[1],le[8]=1,le}function ye(le,Fe){var gt=Math.sin(Fe),Jt=Math.cos(Fe);return le[0]=Jt,le[1]=gt,le[2]=0,le[3]=-gt,le[4]=Jt,le[5]=0,le[6]=0,le[7]=0,le[8]=1,le}function ue(le,Fe){return le[0]=Fe[0],le[1]=0,le[2]=0,le[3]=0,le[4]=Fe[1],le[5]=0,le[6]=0,le[7]=0,le[8]=1,le}function Ne(le,Fe){return le[0]=Fe[0],le[1]=Fe[1],le[2]=0,le[3]=Fe[2],le[4]=Fe[3],le[5]=0,le[6]=Fe[4],le[7]=Fe[5],le[8]=1,le}function Te(le,Fe){var gt=Fe[0],Jt=Fe[1],Ze=Fe[2],rt=Fe[3],Mt=gt+gt,Ue=Jt+Jt,Ye=Ze+Ze,be=gt*Mt,ge=Jt*Mt,Ke=Jt*Ue,wt=Ze*Mt,Be=Ze*Ue,ut=Ze*Ye,Et=rt*Mt,je=rt*Ue,tt=rt*Ye;return le[0]=1-Ke-ut,le[3]=ge-tt,le[6]=wt+je,le[1]=ge+tt,le[4]=1-be-ut,le[7]=Be-Et,le[2]=wt-je,le[5]=Be+Et,le[8]=1-be-Ke,le}function _e(le,Fe){var gt=Fe[0],Jt=Fe[1],Ze=Fe[2],rt=Fe[3],Mt=Fe[4],Ue=Fe[5],Ye=Fe[6],be=Fe[7],ge=Fe[8],Ke=Fe[9],wt=Fe[10],Be=Fe[11],ut=Fe[12],Et=Fe[13],je=Fe[14],tt=Fe[15],yt=gt*Ue-Jt*Mt,B=gt*Ye-Ze*Mt,te=gt*be-rt*Mt,ot=Jt*Ye-Ze*Ue,_t=Jt*be-rt*Ue,ct=Ze*be-rt*Ye,qt=ge*Et-Ke*ut,en=ge*je-wt*ut,nn=ge*tt-Be*ut,we=Ke*je-wt*Et,Q=Ke*tt-Be*Et,De=wt*tt-Be*je,We=yt*De-B*Q+te*we+ot*nn-_t*en+ct*qt;return We?(We=1/We,le[0]=(Ue*De-Ye*Q+be*we)*We,le[1]=(Ye*nn-Mt*De-be*en)*We,le[2]=(Mt*Q-Ue*nn+be*qt)*We,le[3]=(Ze*Q-Jt*De-rt*we)*We,le[4]=(gt*De-Ze*nn+rt*en)*We,le[5]=(Jt*nn-gt*Q-rt*qt)*We,le[6]=(Et*ct-je*_t+tt*ot)*We,le[7]=(je*te-ut*ct-tt*B)*We,le[8]=(ut*_t-Et*te+tt*yt)*We,le):null}function Xe(le,Fe,gt){return le[0]=2/Fe,le[1]=0,le[2]=0,le[3]=0,le[4]=-2/gt,le[5]=0,le[6]=-1,le[7]=1,le[8]=1,le}function Se(le){return"mat3("+le[0]+", "+le[1]+", "+le[2]+", "+le[3]+", "+le[4]+", "+le[5]+", "+le[6]+", "+le[7]+", "+le[8]+")"}function Ge(le){return Math.hypot(le[0],le[1],le[2],le[3],le[4],le[5],le[6],le[7],le[8])}function He(le,Fe,gt){return le[0]=Fe[0]+gt[0],le[1]=Fe[1]+gt[1],le[2]=Fe[2]+gt[2],le[3]=Fe[3]+gt[3],le[4]=Fe[4]+gt[4],le[5]=Fe[5]+gt[5],le[6]=Fe[6]+gt[6],le[7]=Fe[7]+gt[7],le[8]=Fe[8]+gt[8],le}function vt(le,Fe,gt){return le[0]=Fe[0]-gt[0],le[1]=Fe[1]-gt[1],le[2]=Fe[2]-gt[2],le[3]=Fe[3]-gt[3],le[4]=Fe[4]-gt[4],le[5]=Fe[5]-gt[5],le[6]=Fe[6]-gt[6],le[7]=Fe[7]-gt[7],le[8]=Fe[8]-gt[8],le}function It(le,Fe,gt){return le[0]=Fe[0]*gt,le[1]=Fe[1]*gt,le[2]=Fe[2]*gt,le[3]=Fe[3]*gt,le[4]=Fe[4]*gt,le[5]=Fe[5]*gt,le[6]=Fe[6]*gt,le[7]=Fe[7]*gt,le[8]=Fe[8]*gt,le}function zt(le,Fe,gt,Jt){return le[0]=Fe[0]+gt[0]*Jt,le[1]=Fe[1]+gt[1]*Jt,le[2]=Fe[2]+gt[2]*Jt,le[3]=Fe[3]+gt[3]*Jt,le[4]=Fe[4]+gt[4]*Jt,le[5]=Fe[5]+gt[5]*Jt,le[6]=Fe[6]+gt[6]*Jt,le[7]=Fe[7]+gt[7]*Jt,le[8]=Fe[8]+gt[8]*Jt,le}function Yt(le,Fe){return le[0]===Fe[0]&&le[1]===Fe[1]&&le[2]===Fe[2]&&le[3]===Fe[3]&&le[4]===Fe[4]&&le[5]===Fe[5]&&le[6]===Fe[6]&&le[7]===Fe[7]&&le[8]===Fe[8]}function At(le,Fe){var gt=le[0],Jt=le[1],Ze=le[2],rt=le[3],Mt=le[4],Ue=le[5],Ye=le[6],be=le[7],ge=le[8],Ke=Fe[0],wt=Fe[1],Be=Fe[2],ut=Fe[3],Et=Fe[4],je=Fe[5],tt=Fe[6],yt=Fe[7],B=Fe[8];return Math.abs(gt-Ke)<=glMatrix.EPSILON*Math.max(1,Math.abs(gt),Math.abs(Ke))&&Math.abs(Jt-wt)<=glMatrix.EPSILON*Math.max(1,Math.abs(Jt),Math.abs(wt))&&Math.abs(Ze-Be)<=glMatrix.EPSILON*Math.max(1,Math.abs(Ze),Math.abs(Be))&&Math.abs(rt-ut)<=glMatrix.EPSILON*Math.max(1,Math.abs(rt),Math.abs(ut))&&Math.abs(Mt-Et)<=glMatrix.EPSILON*Math.max(1,Math.abs(Mt),Math.abs(Et))&&Math.abs(Ue-je)<=glMatrix.EPSILON*Math.max(1,Math.abs(Ue),Math.abs(je))&&Math.abs(Ye-tt)<=glMatrix.EPSILON*Math.max(1,Math.abs(Ye),Math.abs(tt))&&Math.abs(be-yt)<=glMatrix.EPSILON*Math.max(1,Math.abs(be),Math.abs(yt))&&Math.abs(ge-B)<=glMatrix.EPSILON*Math.max(1,Math.abs(ge),Math.abs(B))}var lt=null,Ot=null},85975:function(se,ee,b){"use strict";b.r(ee),b.d(ee,{add:function(){return Ke},adjoint:function(){return L},clone:function(){return O},copy:function(){return R},create:function(){return k},determinant:function(){return P},equals:function(){return je},exactEquals:function(){return Et},frob:function(){return ge},fromQuat:function(){return lt},fromQuat2:function(){return He},fromRotation:function(){return Te},fromRotationTranslation:function(){return Ge},fromRotationTranslationScale:function(){return Yt},fromRotationTranslationScaleOrigin:function(){return At},fromScaling:function(){return Ne},fromTranslation:function(){return ue},fromValues:function(){return S},fromXRotation:function(){return _e},fromYRotation:function(){return Xe},fromZRotation:function(){return Se},frustum:function(){return Ot},getRotation:function(){return zt},getScaling:function(){return It},getTranslation:function(){return vt},identity:function(){return x},invert:function(){return N},lookAt:function(){return Ue},mul:function(){return tt},multiply:function(){return W},multiplyScalar:function(){return Be},multiplyScalarAndAdd:function(){return ut},ortho:function(){return rt},orthoNO:function(){return Ze},orthoZO:function(){return Mt},perspective:function(){return Fe},perspectiveFromFieldOfView:function(){return Jt},perspectiveNO:function(){return le},perspectiveZO:function(){return gt},rotate:function(){return pe},rotateX:function(){return fe},rotateY:function(){return ae},rotateZ:function(){return ye},scale:function(){return ie},set:function(){return C},str:function(){return be},sub:function(){return yt},subtract:function(){return wt},targetTo:function(){return Ye},translate:function(){return Y},transpose:function(){return E}});var w=b(49685);function k(){var B=new w.WT(16);return w.WT!=Float32Array&&(B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[6]=0,B[7]=0,B[8]=0,B[9]=0,B[11]=0,B[12]=0,B[13]=0,B[14]=0),B[0]=1,B[5]=1,B[10]=1,B[15]=1,B}function O(B){var te=new w.WT(16);return te[0]=B[0],te[1]=B[1],te[2]=B[2],te[3]=B[3],te[4]=B[4],te[5]=B[5],te[6]=B[6],te[7]=B[7],te[8]=B[8],te[9]=B[9],te[10]=B[10],te[11]=B[11],te[12]=B[12],te[13]=B[13],te[14]=B[14],te[15]=B[15],te}function R(B,te){return B[0]=te[0],B[1]=te[1],B[2]=te[2],B[3]=te[3],B[4]=te[4],B[5]=te[5],B[6]=te[6],B[7]=te[7],B[8]=te[8],B[9]=te[9],B[10]=te[10],B[11]=te[11],B[12]=te[12],B[13]=te[13],B[14]=te[14],B[15]=te[15],B}function S(B,te,ot,_t,ct,qt,en,nn,we,Q,De,We,Ce,Re,qe,st){var $e=new w.WT(16);return $e[0]=B,$e[1]=te,$e[2]=ot,$e[3]=_t,$e[4]=ct,$e[5]=qt,$e[6]=en,$e[7]=nn,$e[8]=we,$e[9]=Q,$e[10]=De,$e[11]=We,$e[12]=Ce,$e[13]=Re,$e[14]=qe,$e[15]=st,$e}function C(B,te,ot,_t,ct,qt,en,nn,we,Q,De,We,Ce,Re,qe,st,$e){return B[0]=te,B[1]=ot,B[2]=_t,B[3]=ct,B[4]=qt,B[5]=en,B[6]=nn,B[7]=we,B[8]=Q,B[9]=De,B[10]=We,B[11]=Ce,B[12]=Re,B[13]=qe,B[14]=st,B[15]=$e,B}function x(B){return B[0]=1,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=1,B[6]=0,B[7]=0,B[8]=0,B[9]=0,B[10]=1,B[11]=0,B[12]=0,B[13]=0,B[14]=0,B[15]=1,B}function E(B,te){if(B===te){var ot=te[1],_t=te[2],ct=te[3],qt=te[6],en=te[7],nn=te[11];B[1]=te[4],B[2]=te[8],B[3]=te[12],B[4]=ot,B[6]=te[9],B[7]=te[13],B[8]=_t,B[9]=qt,B[11]=te[14],B[12]=ct,B[13]=en,B[14]=nn}else B[0]=te[0],B[1]=te[4],B[2]=te[8],B[3]=te[12],B[4]=te[1],B[5]=te[5],B[6]=te[9],B[7]=te[13],B[8]=te[2],B[9]=te[6],B[10]=te[10],B[11]=te[14],B[12]=te[3],B[13]=te[7],B[14]=te[11],B[15]=te[15];return B}function N(B,te){var ot=te[0],_t=te[1],ct=te[2],qt=te[3],en=te[4],nn=te[5],we=te[6],Q=te[7],De=te[8],We=te[9],Ce=te[10],Re=te[11],qe=te[12],st=te[13],$e=te[14],ft=te[15],Ct=ot*nn-_t*en,jt=ot*we-ct*en,Qt=ot*Q-qt*en,pn=_t*we-ct*nn,Wn=_t*Q-qt*nn,Rn=ct*Q-qt*we,bi=De*st-We*qe,Dr=De*$e-Ce*qe,Qn=De*ft-Re*qe,Vi=We*$e-Ce*st,Oi=We*ft-Re*st,Gi=Ce*ft-Re*$e,ir=Ct*Gi-jt*Oi+Qt*Vi+pn*Qn-Wn*Dr+Rn*bi;return ir?(ir=1/ir,B[0]=(nn*Gi-we*Oi+Q*Vi)*ir,B[1]=(ct*Oi-_t*Gi-qt*Vi)*ir,B[2]=(st*Rn-$e*Wn+ft*pn)*ir,B[3]=(Ce*Wn-We*Rn-Re*pn)*ir,B[4]=(we*Qn-en*Gi-Q*Dr)*ir,B[5]=(ot*Gi-ct*Qn+qt*Dr)*ir,B[6]=($e*Qt-qe*Rn-ft*jt)*ir,B[7]=(De*Rn-Ce*Qt+Re*jt)*ir,B[8]=(en*Oi-nn*Qn+Q*bi)*ir,B[9]=(_t*Qn-ot*Oi-qt*bi)*ir,B[10]=(qe*Wn-st*Qt+ft*Ct)*ir,B[11]=(We*Qt-De*Wn-Re*Ct)*ir,B[12]=(nn*Dr-en*Vi-we*bi)*ir,B[13]=(ot*Vi-_t*Dr+ct*bi)*ir,B[14]=(st*jt-qe*pn-$e*Ct)*ir,B[15]=(De*pn-We*jt+Ce*Ct)*ir,B):null}function L(B,te){var ot=te[0],_t=te[1],ct=te[2],qt=te[3],en=te[4],nn=te[5],we=te[6],Q=te[7],De=te[8],We=te[9],Ce=te[10],Re=te[11],qe=te[12],st=te[13],$e=te[14],ft=te[15];return B[0]=nn*(Ce*ft-Re*$e)-We*(we*ft-Q*$e)+st*(we*Re-Q*Ce),B[1]=-(_t*(Ce*ft-Re*$e)-We*(ct*ft-qt*$e)+st*(ct*Re-qt*Ce)),B[2]=_t*(we*ft-Q*$e)-nn*(ct*ft-qt*$e)+st*(ct*Q-qt*we),B[3]=-(_t*(we*Re-Q*Ce)-nn*(ct*Re-qt*Ce)+We*(ct*Q-qt*we)),B[4]=-(en*(Ce*ft-Re*$e)-De*(we*ft-Q*$e)+qe*(we*Re-Q*Ce)),B[5]=ot*(Ce*ft-Re*$e)-De*(ct*ft-qt*$e)+qe*(ct*Re-qt*Ce),B[6]=-(ot*(we*ft-Q*$e)-en*(ct*ft-qt*$e)+qe*(ct*Q-qt*we)),B[7]=ot*(we*Re-Q*Ce)-en*(ct*Re-qt*Ce)+De*(ct*Q-qt*we),B[8]=en*(We*ft-Re*st)-De*(nn*ft-Q*st)+qe*(nn*Re-Q*We),B[9]=-(ot*(We*ft-Re*st)-De*(_t*ft-qt*st)+qe*(_t*Re-qt*We)),B[10]=ot*(nn*ft-Q*st)-en*(_t*ft-qt*st)+qe*(_t*Q-qt*nn),B[11]=-(ot*(nn*Re-Q*We)-en*(_t*Re-qt*We)+De*(_t*Q-qt*nn)),B[12]=-(en*(We*$e-Ce*st)-De*(nn*$e-we*st)+qe*(nn*Ce-we*We)),B[13]=ot*(We*$e-Ce*st)-De*(_t*$e-ct*st)+qe*(_t*Ce-ct*We),B[14]=-(ot*(nn*$e-we*st)-en*(_t*$e-ct*st)+qe*(_t*we-ct*nn)),B[15]=ot*(nn*Ce-we*We)-en*(_t*Ce-ct*We)+De*(_t*we-ct*nn),B}function P(B){var te=B[0],ot=B[1],_t=B[2],ct=B[3],qt=B[4],en=B[5],nn=B[6],we=B[7],Q=B[8],De=B[9],We=B[10],Ce=B[11],Re=B[12],qe=B[13],st=B[14],$e=B[15],ft=te*en-ot*qt,Ct=te*nn-_t*qt,jt=te*we-ct*qt,Qt=ot*nn-_t*en,pn=ot*we-ct*en,Wn=_t*we-ct*nn,Rn=Q*qe-De*Re,bi=Q*st-We*Re,Dr=Q*$e-Ce*Re,Qn=De*st-We*qe,Vi=De*$e-Ce*qe,Oi=We*$e-Ce*st;return ft*Oi-Ct*Vi+jt*Qn+Qt*Dr-pn*bi+Wn*Rn}function W(B,te,ot){var _t=te[0],ct=te[1],qt=te[2],en=te[3],nn=te[4],we=te[5],Q=te[6],De=te[7],We=te[8],Ce=te[9],Re=te[10],qe=te[11],st=te[12],$e=te[13],ft=te[14],Ct=te[15],jt=ot[0],Qt=ot[1],pn=ot[2],Wn=ot[3];return B[0]=jt*_t+Qt*nn+pn*We+Wn*st,B[1]=jt*ct+Qt*we+pn*Ce+Wn*$e,B[2]=jt*qt+Qt*Q+pn*Re+Wn*ft,B[3]=jt*en+Qt*De+pn*qe+Wn*Ct,jt=ot[4],Qt=ot[5],pn=ot[6],Wn=ot[7],B[4]=jt*_t+Qt*nn+pn*We+Wn*st,B[5]=jt*ct+Qt*we+pn*Ce+Wn*$e,B[6]=jt*qt+Qt*Q+pn*Re+Wn*ft,B[7]=jt*en+Qt*De+pn*qe+Wn*Ct,jt=ot[8],Qt=ot[9],pn=ot[10],Wn=ot[11],B[8]=jt*_t+Qt*nn+pn*We+Wn*st,B[9]=jt*ct+Qt*we+pn*Ce+Wn*$e,B[10]=jt*qt+Qt*Q+pn*Re+Wn*ft,B[11]=jt*en+Qt*De+pn*qe+Wn*Ct,jt=ot[12],Qt=ot[13],pn=ot[14],Wn=ot[15],B[12]=jt*_t+Qt*nn+pn*We+Wn*st,B[13]=jt*ct+Qt*we+pn*Ce+Wn*$e,B[14]=jt*qt+Qt*Q+pn*Re+Wn*ft,B[15]=jt*en+Qt*De+pn*qe+Wn*Ct,B}function Y(B,te,ot){var _t=ot[0],ct=ot[1],qt=ot[2],en,nn,we,Q,De,We,Ce,Re,qe,st,$e,ft;return te===B?(B[12]=te[0]*_t+te[4]*ct+te[8]*qt+te[12],B[13]=te[1]*_t+te[5]*ct+te[9]*qt+te[13],B[14]=te[2]*_t+te[6]*ct+te[10]*qt+te[14],B[15]=te[3]*_t+te[7]*ct+te[11]*qt+te[15]):(en=te[0],nn=te[1],we=te[2],Q=te[3],De=te[4],We=te[5],Ce=te[6],Re=te[7],qe=te[8],st=te[9],$e=te[10],ft=te[11],B[0]=en,B[1]=nn,B[2]=we,B[3]=Q,B[4]=De,B[5]=We,B[6]=Ce,B[7]=Re,B[8]=qe,B[9]=st,B[10]=$e,B[11]=ft,B[12]=en*_t+De*ct+qe*qt+te[12],B[13]=nn*_t+We*ct+st*qt+te[13],B[14]=we*_t+Ce*ct+$e*qt+te[14],B[15]=Q*_t+Re*ct+ft*qt+te[15]),B}function ie(B,te,ot){var _t=ot[0],ct=ot[1],qt=ot[2];return B[0]=te[0]*_t,B[1]=te[1]*_t,B[2]=te[2]*_t,B[3]=te[3]*_t,B[4]=te[4]*ct,B[5]=te[5]*ct,B[6]=te[6]*ct,B[7]=te[7]*ct,B[8]=te[8]*qt,B[9]=te[9]*qt,B[10]=te[10]*qt,B[11]=te[11]*qt,B[12]=te[12],B[13]=te[13],B[14]=te[14],B[15]=te[15],B}function pe(B,te,ot,_t){var ct=_t[0],qt=_t[1],en=_t[2],nn=Math.hypot(ct,qt,en),we,Q,De,We,Ce,Re,qe,st,$e,ft,Ct,jt,Qt,pn,Wn,Rn,bi,Dr,Qn,Vi,Oi,Gi,ir,gs;return nn<w.Ib?null:(nn=1/nn,ct*=nn,qt*=nn,en*=nn,we=Math.sin(ot),Q=Math.cos(ot),De=1-Q,We=te[0],Ce=te[1],Re=te[2],qe=te[3],st=te[4],$e=te[5],ft=te[6],Ct=te[7],jt=te[8],Qt=te[9],pn=te[10],Wn=te[11],Rn=ct*ct*De+Q,bi=qt*ct*De+en*we,Dr=en*ct*De-qt*we,Qn=ct*qt*De-en*we,Vi=qt*qt*De+Q,Oi=en*qt*De+ct*we,Gi=ct*en*De+qt*we,ir=qt*en*De-ct*we,gs=en*en*De+Q,B[0]=We*Rn+st*bi+jt*Dr,B[1]=Ce*Rn+$e*bi+Qt*Dr,B[2]=Re*Rn+ft*bi+pn*Dr,B[3]=qe*Rn+Ct*bi+Wn*Dr,B[4]=We*Qn+st*Vi+jt*Oi,B[5]=Ce*Qn+$e*Vi+Qt*Oi,B[6]=Re*Qn+ft*Vi+pn*Oi,B[7]=qe*Qn+Ct*Vi+Wn*Oi,B[8]=We*Gi+st*ir+jt*gs,B[9]=Ce*Gi+$e*ir+Qt*gs,B[10]=Re*Gi+ft*ir+pn*gs,B[11]=qe*Gi+Ct*ir+Wn*gs,te!==B&&(B[12]=te[12],B[13]=te[13],B[14]=te[14],B[15]=te[15]),B)}function fe(B,te,ot){var _t=Math.sin(ot),ct=Math.cos(ot),qt=te[4],en=te[5],nn=te[6],we=te[7],Q=te[8],De=te[9],We=te[10],Ce=te[11];return te!==B&&(B[0]=te[0],B[1]=te[1],B[2]=te[2],B[3]=te[3],B[12]=te[12],B[13]=te[13],B[14]=te[14],B[15]=te[15]),B[4]=qt*ct+Q*_t,B[5]=en*ct+De*_t,B[6]=nn*ct+We*_t,B[7]=we*ct+Ce*_t,B[8]=Q*ct-qt*_t,B[9]=De*ct-en*_t,B[10]=We*ct-nn*_t,B[11]=Ce*ct-we*_t,B}function ae(B,te,ot){var _t=Math.sin(ot),ct=Math.cos(ot),qt=te[0],en=te[1],nn=te[2],we=te[3],Q=te[8],De=te[9],We=te[10],Ce=te[11];return te!==B&&(B[4]=te[4],B[5]=te[5],B[6]=te[6],B[7]=te[7],B[12]=te[12],B[13]=te[13],B[14]=te[14],B[15]=te[15]),B[0]=qt*ct-Q*_t,B[1]=en*ct-De*_t,B[2]=nn*ct-We*_t,B[3]=we*ct-Ce*_t,B[8]=qt*_t+Q*ct,B[9]=en*_t+De*ct,B[10]=nn*_t+We*ct,B[11]=we*_t+Ce*ct,B}function ye(B,te,ot){var _t=Math.sin(ot),ct=Math.cos(ot),qt=te[0],en=te[1],nn=te[2],we=te[3],Q=te[4],De=te[5],We=te[6],Ce=te[7];return te!==B&&(B[8]=te[8],B[9]=te[9],B[10]=te[10],B[11]=te[11],B[12]=te[12],B[13]=te[13],B[14]=te[14],B[15]=te[15]),B[0]=qt*ct+Q*_t,B[1]=en*ct+De*_t,B[2]=nn*ct+We*_t,B[3]=we*ct+Ce*_t,B[4]=Q*ct-qt*_t,B[5]=De*ct-en*_t,B[6]=We*ct-nn*_t,B[7]=Ce*ct-we*_t,B}function ue(B,te){return B[0]=1,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=1,B[6]=0,B[7]=0,B[8]=0,B[9]=0,B[10]=1,B[11]=0,B[12]=te[0],B[13]=te[1],B[14]=te[2],B[15]=1,B}function Ne(B,te){return B[0]=te[0],B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=te[1],B[6]=0,B[7]=0,B[8]=0,B[9]=0,B[10]=te[2],B[11]=0,B[12]=0,B[13]=0,B[14]=0,B[15]=1,B}function Te(B,te,ot){var _t=ot[0],ct=ot[1],qt=ot[2],en=Math.hypot(_t,ct,qt),nn,we,Q;return en<w.Ib?null:(en=1/en,_t*=en,ct*=en,qt*=en,nn=Math.sin(te),we=Math.cos(te),Q=1-we,B[0]=_t*_t*Q+we,B[1]=ct*_t*Q+qt*nn,B[2]=qt*_t*Q-ct*nn,B[3]=0,B[4]=_t*ct*Q-qt*nn,B[5]=ct*ct*Q+we,B[6]=qt*ct*Q+_t*nn,B[7]=0,B[8]=_t*qt*Q+ct*nn,B[9]=ct*qt*Q-_t*nn,B[10]=qt*qt*Q+we,B[11]=0,B[12]=0,B[13]=0,B[14]=0,B[15]=1,B)}function _e(B,te){var ot=Math.sin(te),_t=Math.cos(te);return B[0]=1,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=_t,B[6]=ot,B[7]=0,B[8]=0,B[9]=-ot,B[10]=_t,B[11]=0,B[12]=0,B[13]=0,B[14]=0,B[15]=1,B}function Xe(B,te){var ot=Math.sin(te),_t=Math.cos(te);return B[0]=_t,B[1]=0,B[2]=-ot,B[3]=0,B[4]=0,B[5]=1,B[6]=0,B[7]=0,B[8]=ot,B[9]=0,B[10]=_t,B[11]=0,B[12]=0,B[13]=0,B[14]=0,B[15]=1,B}function Se(B,te){var ot=Math.sin(te),_t=Math.cos(te);return B[0]=_t,B[1]=ot,B[2]=0,B[3]=0,B[4]=-ot,B[5]=_t,B[6]=0,B[7]=0,B[8]=0,B[9]=0,B[10]=1,B[11]=0,B[12]=0,B[13]=0,B[14]=0,B[15]=1,B}function Ge(B,te,ot){var _t=te[0],ct=te[1],qt=te[2],en=te[3],nn=_t+_t,we=ct+ct,Q=qt+qt,De=_t*nn,We=_t*we,Ce=_t*Q,Re=ct*we,qe=ct*Q,st=qt*Q,$e=en*nn,ft=en*we,Ct=en*Q;return B[0]=1-(Re+st),B[1]=We+Ct,B[2]=Ce-ft,B[3]=0,B[4]=We-Ct,B[5]=1-(De+st),B[6]=qe+$e,B[7]=0,B[8]=Ce+ft,B[9]=qe-$e,B[10]=1-(De+Re),B[11]=0,B[12]=ot[0],B[13]=ot[1],B[14]=ot[2],B[15]=1,B}function He(B,te){var ot=new w.WT(3),_t=-te[0],ct=-te[1],qt=-te[2],en=te[3],nn=te[4],we=te[5],Q=te[6],De=te[7],We=_t*_t+ct*ct+qt*qt+en*en;return We>0?(ot[0]=(nn*en+De*_t+we*qt-Q*ct)*2/We,ot[1]=(we*en+De*ct+Q*_t-nn*qt)*2/We,ot[2]=(Q*en+De*qt+nn*ct-we*_t)*2/We):(ot[0]=(nn*en+De*_t+we*qt-Q*ct)*2,ot[1]=(we*en+De*ct+Q*_t-nn*qt)*2,ot[2]=(Q*en+De*qt+nn*ct-we*_t)*2),Ge(B,te,ot),B}function vt(B,te){return B[0]=te[12],B[1]=te[13],B[2]=te[14],B}function It(B,te){var ot=te[0],_t=te[1],ct=te[2],qt=te[4],en=te[5],nn=te[6],we=te[8],Q=te[9],De=te[10];return B[0]=Math.hypot(ot,_t,ct),B[1]=Math.hypot(qt,en,nn),B[2]=Math.hypot(we,Q,De),B}function zt(B,te){var ot=new w.WT(3);It(ot,te);var _t=1/ot[0],ct=1/ot[1],qt=1/ot[2],en=te[0]*_t,nn=te[1]*ct,we=te[2]*qt,Q=te[4]*_t,De=te[5]*ct,We=te[6]*qt,Ce=te[8]*_t,Re=te[9]*ct,qe=te[10]*qt,st=en+De+qe,$e=0;return st>0?($e=Math.sqrt(st+1)*2,B[3]=.25*$e,B[0]=(We-Re)/$e,B[1]=(Ce-we)/$e,B[2]=(nn-Q)/$e):en>De&&en>qe?($e=Math.sqrt(1+en-De-qe)*2,B[3]=(We-Re)/$e,B[0]=.25*$e,B[1]=(nn+Q)/$e,B[2]=(Ce+we)/$e):De>qe?($e=Math.sqrt(1+De-en-qe)*2,B[3]=(Ce-we)/$e,B[0]=(nn+Q)/$e,B[1]=.25*$e,B[2]=(We+Re)/$e):($e=Math.sqrt(1+qe-en-De)*2,B[3]=(nn-Q)/$e,B[0]=(Ce+we)/$e,B[1]=(We+Re)/$e,B[2]=.25*$e),B}function Yt(B,te,ot,_t){var ct=te[0],qt=te[1],en=te[2],nn=te[3],we=ct+ct,Q=qt+qt,De=en+en,We=ct*we,Ce=ct*Q,Re=ct*De,qe=qt*Q,st=qt*De,$e=en*De,ft=nn*we,Ct=nn*Q,jt=nn*De,Qt=_t[0],pn=_t[1],Wn=_t[2];return B[0]=(1-(qe+$e))*Qt,B[1]=(Ce+jt)*Qt,B[2]=(Re-Ct)*Qt,B[3]=0,B[4]=(Ce-jt)*pn,B[5]=(1-(We+$e))*pn,B[6]=(st+ft)*pn,B[7]=0,B[8]=(Re+Ct)*Wn,B[9]=(st-ft)*Wn,B[10]=(1-(We+qe))*Wn,B[11]=0,B[12]=ot[0],B[13]=ot[1],B[14]=ot[2],B[15]=1,B}function At(B,te,ot,_t,ct){var qt=te[0],en=te[1],nn=te[2],we=te[3],Q=qt+qt,De=en+en,We=nn+nn,Ce=qt*Q,Re=qt*De,qe=qt*We,st=en*De,$e=en*We,ft=nn*We,Ct=we*Q,jt=we*De,Qt=we*We,pn=_t[0],Wn=_t[1],Rn=_t[2],bi=ct[0],Dr=ct[1],Qn=ct[2],Vi=(1-(st+ft))*pn,Oi=(Re+Qt)*pn,Gi=(qe-jt)*pn,ir=(Re-Qt)*Wn,gs=(1-(Ce+ft))*Wn,Ls=($e+Ct)*Wn,ls=(qe+jt)*Rn,ys=($e-Ct)*Rn,Gs=(1-(Ce+st))*Rn;return B[0]=Vi,B[1]=Oi,B[2]=Gi,B[3]=0,B[4]=ir,B[5]=gs,B[6]=Ls,B[7]=0,B[8]=ls,B[9]=ys,B[10]=Gs,B[11]=0,B[12]=ot[0]+bi-(Vi*bi+ir*Dr+ls*Qn),B[13]=ot[1]+Dr-(Oi*bi+gs*Dr+ys*Qn),B[14]=ot[2]+Qn-(Gi*bi+Ls*Dr+Gs*Qn),B[15]=1,B}function lt(B,te){var ot=te[0],_t=te[1],ct=te[2],qt=te[3],en=ot+ot,nn=_t+_t,we=ct+ct,Q=ot*en,De=_t*en,We=_t*nn,Ce=ct*en,Re=ct*nn,qe=ct*we,st=qt*en,$e=qt*nn,ft=qt*we;return B[0]=1-We-qe,B[1]=De+ft,B[2]=Ce-$e,B[3]=0,B[4]=De-ft,B[5]=1-Q-qe,B[6]=Re+st,B[7]=0,B[8]=Ce+$e,B[9]=Re-st,B[10]=1-Q-We,B[11]=0,B[12]=0,B[13]=0,B[14]=0,B[15]=1,B}function Ot(B,te,ot,_t,ct,qt,en){var nn=1/(ot-te),we=1/(ct-_t),Q=1/(qt-en);return B[0]=qt*2*nn,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=qt*2*we,B[6]=0,B[7]=0,B[8]=(ot+te)*nn,B[9]=(ct+_t)*we,B[10]=(en+qt)*Q,B[11]=-1,B[12]=0,B[13]=0,B[14]=en*qt*2*Q,B[15]=0,B}function le(B,te,ot,_t,ct){var qt=1/Math.tan(te/2),en;return B[0]=qt/ot,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=qt,B[6]=0,B[7]=0,B[8]=0,B[9]=0,B[11]=-1,B[12]=0,B[13]=0,B[15]=0,ct!=null&&ct!==1/0?(en=1/(_t-ct),B[10]=(ct+_t)*en,B[14]=2*ct*_t*en):(B[10]=-1,B[14]=-2*_t),B}var Fe=le;function gt(B,te,ot,_t,ct){var qt=1/Math.tan(te/2),en;return B[0]=qt/ot,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=qt,B[6]=0,B[7]=0,B[8]=0,B[9]=0,B[11]=-1,B[12]=0,B[13]=0,B[15]=0,ct!=null&&ct!==1/0?(en=1/(_t-ct),B[10]=ct*en,B[14]=ct*_t*en):(B[10]=-1,B[14]=-_t),B}function Jt(B,te,ot,_t){var ct=Math.tan(te.upDegrees*Math.PI/180),qt=Math.tan(te.downDegrees*Math.PI/180),en=Math.tan(te.leftDegrees*Math.PI/180),nn=Math.tan(te.rightDegrees*Math.PI/180),we=2/(en+nn),Q=2/(ct+qt);return B[0]=we,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=Q,B[6]=0,B[7]=0,B[8]=-((en-nn)*we*.5),B[9]=(ct-qt)*Q*.5,B[10]=_t/(ot-_t),B[11]=-1,B[12]=0,B[13]=0,B[14]=_t*ot/(ot-_t),B[15]=0,B}function Ze(B,te,ot,_t,ct,qt,en){var nn=1/(te-ot),we=1/(_t-ct),Q=1/(qt-en);return B[0]=-2*nn,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=-2*we,B[6]=0,B[7]=0,B[8]=0,B[9]=0,B[10]=2*Q,B[11]=0,B[12]=(te+ot)*nn,B[13]=(ct+_t)*we,B[14]=(en+qt)*Q,B[15]=1,B}var rt=Ze;function Mt(B,te,ot,_t,ct,qt,en){var nn=1/(te-ot),we=1/(_t-ct),Q=1/(qt-en);return B[0]=-2*nn,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=-2*we,B[6]=0,B[7]=0,B[8]=0,B[9]=0,B[10]=Q,B[11]=0,B[12]=(te+ot)*nn,B[13]=(ct+_t)*we,B[14]=qt*Q,B[15]=1,B}function Ue(B,te,ot,_t){var ct,qt,en,nn,we,Q,De,We,Ce,Re,qe=te[0],st=te[1],$e=te[2],ft=_t[0],Ct=_t[1],jt=_t[2],Qt=ot[0],pn=ot[1],Wn=ot[2];return Math.abs(qe-Qt)<w.Ib&&Math.abs(st-pn)<w.Ib&&Math.abs($e-Wn)<w.Ib?x(B):(De=qe-Qt,We=st-pn,Ce=$e-Wn,Re=1/Math.hypot(De,We,Ce),De*=Re,We*=Re,Ce*=Re,ct=Ct*Ce-jt*We,qt=jt*De-ft*Ce,en=ft*We-Ct*De,Re=Math.hypot(ct,qt,en),Re?(Re=1/Re,ct*=Re,qt*=Re,en*=Re):(ct=0,qt=0,en=0),nn=We*en-Ce*qt,we=Ce*ct-De*en,Q=De*qt-We*ct,Re=Math.hypot(nn,we,Q),Re?(Re=1/Re,nn*=Re,we*=Re,Q*=Re):(nn=0,we=0,Q=0),B[0]=ct,B[1]=nn,B[2]=De,B[3]=0,B[4]=qt,B[5]=we,B[6]=We,B[7]=0,B[8]=en,B[9]=Q,B[10]=Ce,B[11]=0,B[12]=-(ct*qe+qt*st+en*$e),B[13]=-(nn*qe+we*st+Q*$e),B[14]=-(De*qe+We*st+Ce*$e),B[15]=1,B)}function Ye(B,te,ot,_t){var ct=te[0],qt=te[1],en=te[2],nn=_t[0],we=_t[1],Q=_t[2],De=ct-ot[0],We=qt-ot[1],Ce=en-ot[2],Re=De*De+We*We+Ce*Ce;Re>0&&(Re=1/Math.sqrt(Re),De*=Re,We*=Re,Ce*=Re);var qe=we*Ce-Q*We,st=Q*De-nn*Ce,$e=nn*We-we*De;return Re=qe*qe+st*st+$e*$e,Re>0&&(Re=1/Math.sqrt(Re),qe*=Re,st*=Re,$e*=Re),B[0]=qe,B[1]=st,B[2]=$e,B[3]=0,B[4]=We*$e-Ce*st,B[5]=Ce*qe-De*$e,B[6]=De*st-We*qe,B[7]=0,B[8]=De,B[9]=We,B[10]=Ce,B[11]=0,B[12]=ct,B[13]=qt,B[14]=en,B[15]=1,B}function be(B){return"mat4("+B[0]+", "+B[1]+", "+B[2]+", "+B[3]+", "+B[4]+", "+B[5]+", "+B[6]+", "+B[7]+", "+B[8]+", "+B[9]+", "+B[10]+", "+B[11]+", "+B[12]+", "+B[13]+", "+B[14]+", "+B[15]+")"}function ge(B){return Math.hypot(B[0],B[1],B[2],B[3],B[4],B[5],B[6],B[7],B[8],B[9],B[10],B[11],B[12],B[13],B[14],B[15])}function Ke(B,te,ot){return B[0]=te[0]+ot[0],B[1]=te[1]+ot[1],B[2]=te[2]+ot[2],B[3]=te[3]+ot[3],B[4]=te[4]+ot[4],B[5]=te[5]+ot[5],B[6]=te[6]+ot[6],B[7]=te[7]+ot[7],B[8]=te[8]+ot[8],B[9]=te[9]+ot[9],B[10]=te[10]+ot[10],B[11]=te[11]+ot[11],B[12]=te[12]+ot[12],B[13]=te[13]+ot[13],B[14]=te[14]+ot[14],B[15]=te[15]+ot[15],B}function wt(B,te,ot){return B[0]=te[0]-ot[0],B[1]=te[1]-ot[1],B[2]=te[2]-ot[2],B[3]=te[3]-ot[3],B[4]=te[4]-ot[4],B[5]=te[5]-ot[5],B[6]=te[6]-ot[6],B[7]=te[7]-ot[7],B[8]=te[8]-ot[8],B[9]=te[9]-ot[9],B[10]=te[10]-ot[10],B[11]=te[11]-ot[11],B[12]=te[12]-ot[12],B[13]=te[13]-ot[13],B[14]=te[14]-ot[14],B[15]=te[15]-ot[15],B}function Be(B,te,ot){return B[0]=te[0]*ot,B[1]=te[1]*ot,B[2]=te[2]*ot,B[3]=te[3]*ot,B[4]=te[4]*ot,B[5]=te[5]*ot,B[6]=te[6]*ot,B[7]=te[7]*ot,B[8]=te[8]*ot,B[9]=te[9]*ot,B[10]=te[10]*ot,B[11]=te[11]*ot,B[12]=te[12]*ot,B[13]=te[13]*ot,B[14]=te[14]*ot,B[15]=te[15]*ot,B}function ut(B,te,ot,_t){return B[0]=te[0]+ot[0]*_t,B[1]=te[1]+ot[1]*_t,B[2]=te[2]+ot[2]*_t,B[3]=te[3]+ot[3]*_t,B[4]=te[4]+ot[4]*_t,B[5]=te[5]+ot[5]*_t,B[6]=te[6]+ot[6]*_t,B[7]=te[7]+ot[7]*_t,B[8]=te[8]+ot[8]*_t,B[9]=te[9]+ot[9]*_t,B[10]=te[10]+ot[10]*_t,B[11]=te[11]+ot[11]*_t,B[12]=te[12]+ot[12]*_t,B[13]=te[13]+ot[13]*_t,B[14]=te[14]+ot[14]*_t,B[15]=te[15]+ot[15]*_t,B}function Et(B,te){return B[0]===te[0]&&B[1]===te[1]&&B[2]===te[2]&&B[3]===te[3]&&B[4]===te[4]&&B[5]===te[5]&&B[6]===te[6]&&B[7]===te[7]&&B[8]===te[8]&&B[9]===te[9]&&B[10]===te[10]&&B[11]===te[11]&&B[12]===te[12]&&B[13]===te[13]&&B[14]===te[14]&&B[15]===te[15]}function je(B,te){var ot=B[0],_t=B[1],ct=B[2],qt=B[3],en=B[4],nn=B[5],we=B[6],Q=B[7],De=B[8],We=B[9],Ce=B[10],Re=B[11],qe=B[12],st=B[13],$e=B[14],ft=B[15],Ct=te[0],jt=te[1],Qt=te[2],pn=te[3],Wn=te[4],Rn=te[5],bi=te[6],Dr=te[7],Qn=te[8],Vi=te[9],Oi=te[10],Gi=te[11],ir=te[12],gs=te[13],Ls=te[14],ls=te[15];return Math.abs(ot-Ct)<=w.Ib*Math.max(1,Math.abs(ot),Math.abs(Ct))&&Math.abs(_t-jt)<=w.Ib*Math.max(1,Math.abs(_t),Math.abs(jt))&&Math.abs(ct-Qt)<=w.Ib*Math.max(1,Math.abs(ct),Math.abs(Qt))&&Math.abs(qt-pn)<=w.Ib*Math.max(1,Math.abs(qt),Math.abs(pn))&&Math.abs(en-Wn)<=w.Ib*Math.max(1,Math.abs(en),Math.abs(Wn))&&Math.abs(nn-Rn)<=w.Ib*Math.max(1,Math.abs(nn),Math.abs(Rn))&&Math.abs(we-bi)<=w.Ib*Math.max(1,Math.abs(we),Math.abs(bi))&&Math.abs(Q-Dr)<=w.Ib*Math.max(1,Math.abs(Q),Math.abs(Dr))&&Math.abs(De-Qn)<=w.Ib*Math.max(1,Math.abs(De),Math.abs(Qn))&&Math.abs(We-Vi)<=w.Ib*Math.max(1,Math.abs(We),Math.abs(Vi))&&Math.abs(Ce-Oi)<=w.Ib*Math.max(1,Math.abs(Ce),Math.abs(Oi))&&Math.abs(Re-Gi)<=w.Ib*Math.max(1,Math.abs(Re),Math.abs(Gi))&&Math.abs(qe-ir)<=w.Ib*Math.max(1,Math.abs(qe),Math.abs(ir))&&Math.abs(st-gs)<=w.Ib*Math.max(1,Math.abs(st),Math.abs(gs))&&Math.abs($e-Ls)<=w.Ib*Math.max(1,Math.abs($e),Math.abs(Ls))&&Math.abs(ft-ls)<=w.Ib*Math.max(1,Math.abs(ft),Math.abs(ls))}var tt=W,yt=wt},32945:function(se,ee,b){"use strict";b.d(ee,{Fv:function(){return Ze},JG:function(){return vt},Jp:function(){return L},Su:function(){return Xe},U_:function(){return Ne},Ue:function(){return S},al:function(){return He},dC:function(){return Yt},t8:function(){return It},yY:function(){return x}});var w=b(49685),k=b(35600),O=b(33983),R=b(98333);function S(){var ge=new w.WT(4);return w.WT!=Float32Array&&(ge[0]=0,ge[1]=0,ge[2]=0),ge[3]=1,ge}function C(ge){return ge[0]=0,ge[1]=0,ge[2]=0,ge[3]=1,ge}function x(ge,Ke,wt){wt=wt*.5;var Be=Math.sin(wt);return ge[0]=Be*Ke[0],ge[1]=Be*Ke[1],ge[2]=Be*Ke[2],ge[3]=Math.cos(wt),ge}function E(ge,Ke){var wt=Math.acos(Ke[3])*2,Be=Math.sin(wt/2);return Be>glMatrix.EPSILON?(ge[0]=Ke[0]/Be,ge[1]=Ke[1]/Be,ge[2]=Ke[2]/Be):(ge[0]=1,ge[1]=0,ge[2]=0),wt}function N(ge,Ke){var wt=lt(ge,Ke);return Math.acos(2*wt*wt-1)}function L(ge,Ke,wt){var Be=Ke[0],ut=Ke[1],Et=Ke[2],je=Ke[3],tt=wt[0],yt=wt[1],B=wt[2],te=wt[3];return ge[0]=Be*te+je*tt+ut*B-Et*yt,ge[1]=ut*te+je*yt+Et*tt-Be*B,ge[2]=Et*te+je*B+Be*yt-ut*tt,ge[3]=je*te-Be*tt-ut*yt-Et*B,ge}function P(ge,Ke,wt){wt*=.5;var Be=Ke[0],ut=Ke[1],Et=Ke[2],je=Ke[3],tt=Math.sin(wt),yt=Math.cos(wt);return ge[0]=Be*yt+je*tt,ge[1]=ut*yt+Et*tt,ge[2]=Et*yt-ut*tt,ge[3]=je*yt-Be*tt,ge}function W(ge,Ke,wt){wt*=.5;var Be=Ke[0],ut=Ke[1],Et=Ke[2],je=Ke[3],tt=Math.sin(wt),yt=Math.cos(wt);return ge[0]=Be*yt-Et*tt,ge[1]=ut*yt+je*tt,ge[2]=Et*yt+Be*tt,ge[3]=je*yt-ut*tt,ge}function Y(ge,Ke,wt){wt*=.5;var Be=Ke[0],ut=Ke[1],Et=Ke[2],je=Ke[3],tt=Math.sin(wt),yt=Math.cos(wt);return ge[0]=Be*yt+ut*tt,ge[1]=ut*yt-Be*tt,ge[2]=Et*yt+je*tt,ge[3]=je*yt-Et*tt,ge}function ie(ge,Ke){var wt=Ke[0],Be=Ke[1],ut=Ke[2];return ge[0]=wt,ge[1]=Be,ge[2]=ut,ge[3]=Math.sqrt(Math.abs(1-wt*wt-Be*Be-ut*ut)),ge}function pe(ge,Ke){var wt=Ke[0],Be=Ke[1],ut=Ke[2],Et=Ke[3],je=Math.sqrt(wt*wt+Be*Be+ut*ut),tt=Math.exp(Et),yt=je>0?tt*Math.sin(je)/je:0;return ge[0]=wt*yt,ge[1]=Be*yt,ge[2]=ut*yt,ge[3]=tt*Math.cos(je),ge}function fe(ge,Ke){var wt=Ke[0],Be=Ke[1],ut=Ke[2],Et=Ke[3],je=Math.sqrt(wt*wt+Be*Be+ut*ut),tt=je>0?Math.atan2(je,Et)/je:0;return ge[0]=wt*tt,ge[1]=Be*tt,ge[2]=ut*tt,ge[3]=.5*Math.log(wt*wt+Be*Be+ut*ut+Et*Et),ge}function ae(ge,Ke,wt){return fe(ge,Ke),At(ge,ge,wt),pe(ge,ge),ge}function ye(ge,Ke,wt,Be){var ut=Ke[0],Et=Ke[1],je=Ke[2],tt=Ke[3],yt=wt[0],B=wt[1],te=wt[2],ot=wt[3],_t,ct,qt,en,nn;return ct=ut*yt+Et*B+je*te+tt*ot,ct<0&&(ct=-ct,yt=-yt,B=-B,te=-te,ot=-ot),1-ct>w.Ib?(_t=Math.acos(ct),qt=Math.sin(_t),en=Math.sin((1-Be)*_t)/qt,nn=Math.sin(Be*_t)/qt):(en=1-Be,nn=Be),ge[0]=en*ut+nn*yt,ge[1]=en*Et+nn*B,ge[2]=en*je+nn*te,ge[3]=en*tt+nn*ot,ge}function ue(ge){var Ke=glMatrix.RANDOM(),wt=glMatrix.RANDOM(),Be=glMatrix.RANDOM(),ut=Math.sqrt(1-Ke),Et=Math.sqrt(Ke);return ge[0]=ut*Math.sin(2*Math.PI*wt),ge[1]=ut*Math.cos(2*Math.PI*wt),ge[2]=Et*Math.sin(2*Math.PI*Be),ge[3]=Et*Math.cos(2*Math.PI*Be),ge}function Ne(ge,Ke){var wt=Ke[0],Be=Ke[1],ut=Ke[2],Et=Ke[3],je=wt*wt+Be*Be+ut*ut+Et*Et,tt=je?1/je:0;return ge[0]=-wt*tt,ge[1]=-Be*tt,ge[2]=-ut*tt,ge[3]=Et*tt,ge}function Te(ge,Ke){return ge[0]=-Ke[0],ge[1]=-Ke[1],ge[2]=-Ke[2],ge[3]=Ke[3],ge}function _e(ge,Ke){var wt=Ke[0]+Ke[4]+Ke[8],Be;if(wt>0)Be=Math.sqrt(wt+1),ge[3]=.5*Be,Be=.5/Be,ge[0]=(Ke[5]-Ke[7])*Be,ge[1]=(Ke[6]-Ke[2])*Be,ge[2]=(Ke[1]-Ke[3])*Be;else{var ut=0;Ke[4]>Ke[0]&&(ut=1),Ke[8]>Ke[ut*3+ut]&&(ut=2);var Et=(ut+1)%3,je=(ut+2)%3;Be=Math.sqrt(Ke[ut*3+ut]-Ke[Et*3+Et]-Ke[je*3+je]+1),ge[ut]=.5*Be,Be=.5/Be,ge[3]=(Ke[Et*3+je]-Ke[je*3+Et])*Be,ge[Et]=(Ke[Et*3+ut]+Ke[ut*3+Et])*Be,ge[je]=(Ke[je*3+ut]+Ke[ut*3+je])*Be}return ge}function Xe(ge,Ke,wt,Be){var ut=.5*Math.PI/180;Ke*=ut,wt*=ut,Be*=ut;var Et=Math.sin(Ke),je=Math.cos(Ke),tt=Math.sin(wt),yt=Math.cos(wt),B=Math.sin(Be),te=Math.cos(Be);return ge[0]=Et*yt*te-je*tt*B,ge[1]=je*tt*te+Et*yt*B,ge[2]=je*yt*B-Et*tt*te,ge[3]=je*yt*te+Et*tt*B,ge}function Se(ge){return"quat("+ge[0]+", "+ge[1]+", "+ge[2]+", "+ge[3]+")"}var Ge=R.d9,He=R.al,vt=R.JG,It=R.t8,zt=R.IH,Yt=L,At=R.bA,lt=R.AK,Ot=R.t7,le=R.kE,Fe=null,gt=R.we,Jt=null,Ze=R.Fv,rt=R.I6,Mt=R.fS,Ue=function(){var ge=O.Ue(),Ke=O.al(1,0,0),wt=O.al(0,1,0);return function(Be,ut,Et){var je=O.AK(ut,Et);return je<-.999999?(O.kC(ge,Ke,ut),O.Zh(ge)<1e-6&&O.kC(ge,wt,ut),O.Fv(ge,ge),x(Be,ge,Math.PI),Be):je>.999999?(Be[0]=0,Be[1]=0,Be[2]=0,Be[3]=1,Be):(O.kC(ge,ut,Et),Be[0]=ge[0],Be[1]=ge[1],Be[2]=ge[2],Be[3]=1+je,Ze(Be,Be))}}(),Ye=function(){var ge=S(),Ke=S();return function(wt,Be,ut,Et,je,tt){return ye(ge,Be,je,tt),ye(Ke,ut,Et,tt),ye(wt,ge,Ke,2*tt*(1-tt)),wt}}(),be=function(){var ge=k.Ue();return function(Ke,wt,Be,ut){return ge[0]=Be[0],ge[3]=Be[1],ge[6]=Be[2],ge[1]=ut[0],ge[4]=ut[1],ge[7]=ut[2],ge[2]=-wt[0],ge[5]=-wt[1],ge[8]=-wt[2],Ze(Ke,_e(Ke,ge))}}()},31437:function(se,ee,b){"use strict";b.d(ee,{AK:function(){return Ge},Fv:function(){return Se},I6:function(){return Jt},JG:function(){return S},Ue:function(){return k},t8:function(){return C}});var w=b(49685);function k(){var Be=new w.WT(2);return w.WT!=Float32Array&&(Be[0]=0,Be[1]=0),Be}function O(Be){var ut=new glMatrix.ARRAY_TYPE(2);return ut[0]=Be[0],ut[1]=Be[1],ut}function R(Be,ut){var Et=new glMatrix.ARRAY_TYPE(2);return Et[0]=Be,Et[1]=ut,Et}function S(Be,ut){return Be[0]=ut[0],Be[1]=ut[1],Be}function C(Be,ut,Et){return Be[0]=ut,Be[1]=Et,Be}function x(Be,ut,Et){return Be[0]=ut[0]+Et[0],Be[1]=ut[1]+Et[1],Be}function E(Be,ut,Et){return Be[0]=ut[0]-Et[0],Be[1]=ut[1]-Et[1],Be}function N(Be,ut,Et){return Be[0]=ut[0]*Et[0],Be[1]=ut[1]*Et[1],Be}function L(Be,ut,Et){return Be[0]=ut[0]/Et[0],Be[1]=ut[1]/Et[1],Be}function P(Be,ut){return Be[0]=Math.ceil(ut[0]),Be[1]=Math.ceil(ut[1]),Be}function W(Be,ut){return Be[0]=Math.floor(ut[0]),Be[1]=Math.floor(ut[1]),Be}function Y(Be,ut,Et){return Be[0]=Math.min(ut[0],Et[0]),Be[1]=Math.min(ut[1],Et[1]),Be}function ie(Be,ut,Et){return Be[0]=Math.max(ut[0],Et[0]),Be[1]=Math.max(ut[1],Et[1]),Be}function pe(Be,ut){return Be[0]=Math.round(ut[0]),Be[1]=Math.round(ut[1]),Be}function fe(Be,ut,Et){return Be[0]=ut[0]*Et,Be[1]=ut[1]*Et,Be}function ae(Be,ut,Et,je){return Be[0]=ut[0]+Et[0]*je,Be[1]=ut[1]+Et[1]*je,Be}function ye(Be,ut){var Et=ut[0]-Be[0],je=ut[1]-Be[1];return Math.hypot(Et,je)}function ue(Be,ut){var Et=ut[0]-Be[0],je=ut[1]-Be[1];return Et*Et+je*je}function Ne(Be){var ut=Be[0],Et=Be[1];return Math.hypot(ut,Et)}function Te(Be){var ut=Be[0],Et=Be[1];return ut*ut+Et*Et}function _e(Be,ut){return Be[0]=-ut[0],Be[1]=-ut[1],Be}function Xe(Be,ut){return Be[0]=1/ut[0],Be[1]=1/ut[1],Be}function Se(Be,ut){var Et=ut[0],je=ut[1],tt=Et*Et+je*je;return tt>0&&(tt=1/Math.sqrt(tt)),Be[0]=ut[0]*tt,Be[1]=ut[1]*tt,Be}function Ge(Be,ut){return Be[0]*ut[0]+Be[1]*ut[1]}function He(Be,ut,Et){var je=ut[0]*Et[1]-ut[1]*Et[0];return Be[0]=Be[1]=0,Be[2]=je,Be}function vt(Be,ut,Et,je){var tt=ut[0],yt=ut[1];return Be[0]=tt+je*(Et[0]-tt),Be[1]=yt+je*(Et[1]-yt),Be}function It(Be,ut){ut=ut||1;var Et=glMatrix.RANDOM()*2*Math.PI;return Be[0]=Math.cos(Et)*ut,Be[1]=Math.sin(Et)*ut,Be}function zt(Be,ut,Et){var je=ut[0],tt=ut[1];return Be[0]=Et[0]*je+Et[2]*tt,Be[1]=Et[1]*je+Et[3]*tt,Be}function Yt(Be,ut,Et){var je=ut[0],tt=ut[1];return Be[0]=Et[0]*je+Et[2]*tt+Et[4],Be[1]=Et[1]*je+Et[3]*tt+Et[5],Be}function At(Be,ut,Et){var je=ut[0],tt=ut[1];return Be[0]=Et[0]*je+Et[3]*tt+Et[6],Be[1]=Et[1]*je+Et[4]*tt+Et[7],Be}function lt(Be,ut,Et){var je=ut[0],tt=ut[1];return Be[0]=Et[0]*je+Et[4]*tt+Et[12],Be[1]=Et[1]*je+Et[5]*tt+Et[13],Be}function Ot(Be,ut,Et,je){var tt=ut[0]-Et[0],yt=ut[1]-Et[1],B=Math.sin(je),te=Math.cos(je);return Be[0]=tt*te-yt*B+Et[0],Be[1]=tt*B+yt*te+Et[1],Be}function le(Be,ut){var Et=Be[0],je=Be[1],tt=ut[0],yt=ut[1],B=Math.sqrt(Et*Et+je*je)*Math.sqrt(tt*tt+yt*yt),te=B&&(Et*tt+je*yt)/B;return Math.acos(Math.min(Math.max(te,-1),1))}function Fe(Be){return Be[0]=0,Be[1]=0,Be}function gt(Be){return"vec2("+Be[0]+", "+Be[1]+")"}function Jt(Be,ut){return Be[0]===ut[0]&&Be[1]===ut[1]}function Ze(Be,ut){var Et=Be[0],je=Be[1],tt=ut[0],yt=ut[1];return Math.abs(Et-tt)<=glMatrix.EPSILON*Math.max(1,Math.abs(Et),Math.abs(tt))&&Math.abs(je-yt)<=glMatrix.EPSILON*Math.max(1,Math.abs(je),Math.abs(yt))}var rt=null,Mt=null,Ue=null,Ye=null,be=null,ge=null,Ke=null,wt=function(){var Be=k();return function(ut,Et,je,tt,yt,B){var te,ot;for(Et||(Et=2),je||(je=0),tt?ot=Math.min(tt*Et+je,ut.length):ot=ut.length,te=je;te<ot;te+=Et)Be[0]=ut[te],Be[1]=ut[te+1],yt(Be,Be,B),ut[te]=Be[0],ut[te+1]=Be[1];return ut}}()},33983:function(se,ee,b){"use strict";b.d(ee,{$X:function(){return N},AK:function(){return Ge},Fp:function(){return pe},Fv:function(){return Se},IH:function(){return E},JG:function(){return C},Jp:function(){return L},TK:function(){return Ke},Ue:function(){return k},VC:function(){return Ot},VV:function(){return ie},Zh:function(){return Be},al:function(){return S},bA:function(){return ae},d9:function(){return O},fF:function(){return At},fS:function(){return Ue},kC:function(){return He},kE:function(){return R},kK:function(){return lt},lu:function(){return Ye},t7:function(){return vt},t8:function(){return x}});var w=b(49685);function k(){var je=new w.WT(3);return w.WT!=Float32Array&&(je[0]=0,je[1]=0,je[2]=0),je}function O(je){var tt=new w.WT(3);return tt[0]=je[0],tt[1]=je[1],tt[2]=je[2],tt}function R(je){var tt=je[0],yt=je[1],B=je[2];return Math.hypot(tt,yt,B)}function S(je,tt,yt){var B=new w.WT(3);return B[0]=je,B[1]=tt,B[2]=yt,B}function C(je,tt){return je[0]=tt[0],je[1]=tt[1],je[2]=tt[2],je}function x(je,tt,yt,B){return je[0]=tt,je[1]=yt,je[2]=B,je}function E(je,tt,yt){return je[0]=tt[0]+yt[0],je[1]=tt[1]+yt[1],je[2]=tt[2]+yt[2],je}function N(je,tt,yt){return je[0]=tt[0]-yt[0],je[1]=tt[1]-yt[1],je[2]=tt[2]-yt[2],je}function L(je,tt,yt){return je[0]=tt[0]*yt[0],je[1]=tt[1]*yt[1],je[2]=tt[2]*yt[2],je}function P(je,tt,yt){return je[0]=tt[0]/yt[0],je[1]=tt[1]/yt[1],je[2]=tt[2]/yt[2],je}function W(je,tt){return je[0]=Math.ceil(tt[0]),je[1]=Math.ceil(tt[1]),je[2]=Math.ceil(tt[2]),je}function Y(je,tt){return je[0]=Math.floor(tt[0]),je[1]=Math.floor(tt[1]),je[2]=Math.floor(tt[2]),je}function ie(je,tt,yt){return je[0]=Math.min(tt[0],yt[0]),je[1]=Math.min(tt[1],yt[1]),je[2]=Math.min(tt[2],yt[2]),je}function pe(je,tt,yt){return je[0]=Math.max(tt[0],yt[0]),je[1]=Math.max(tt[1],yt[1]),je[2]=Math.max(tt[2],yt[2]),je}function fe(je,tt){return je[0]=Math.round(tt[0]),je[1]=Math.round(tt[1]),je[2]=Math.round(tt[2]),je}function ae(je,tt,yt){return je[0]=tt[0]*yt,je[1]=tt[1]*yt,je[2]=tt[2]*yt,je}function ye(je,tt,yt,B){return je[0]=tt[0]+yt[0]*B,je[1]=tt[1]+yt[1]*B,je[2]=tt[2]+yt[2]*B,je}function ue(je,tt){var yt=tt[0]-je[0],B=tt[1]-je[1],te=tt[2]-je[2];return Math.hypot(yt,B,te)}function Ne(je,tt){var yt=tt[0]-je[0],B=tt[1]-je[1],te=tt[2]-je[2];return yt*yt+B*B+te*te}function Te(je){var tt=je[0],yt=je[1],B=je[2];return tt*tt+yt*yt+B*B}function _e(je,tt){return je[0]=-tt[0],je[1]=-tt[1],je[2]=-tt[2],je}function Xe(je,tt){return je[0]=1/tt[0],je[1]=1/tt[1],je[2]=1/tt[2],je}function Se(je,tt){var yt=tt[0],B=tt[1],te=tt[2],ot=yt*yt+B*B+te*te;return ot>0&&(ot=1/Math.sqrt(ot)),je[0]=tt[0]*ot,je[1]=tt[1]*ot,je[2]=tt[2]*ot,je}function Ge(je,tt){return je[0]*tt[0]+je[1]*tt[1]+je[2]*tt[2]}function He(je,tt,yt){var B=tt[0],te=tt[1],ot=tt[2],_t=yt[0],ct=yt[1],qt=yt[2];return je[0]=te*qt-ot*ct,je[1]=ot*_t-B*qt,je[2]=B*ct-te*_t,je}function vt(je,tt,yt,B){var te=tt[0],ot=tt[1],_t=tt[2];return je[0]=te+B*(yt[0]-te),je[1]=ot+B*(yt[1]-ot),je[2]=_t+B*(yt[2]-_t),je}function It(je,tt,yt,B,te,ot){var _t=ot*ot,ct=_t*(2*ot-3)+1,qt=_t*(ot-2)+ot,en=_t*(ot-1),nn=_t*(3-2*ot);return je[0]=tt[0]*ct+yt[0]*qt+B[0]*en+te[0]*nn,je[1]=tt[1]*ct+yt[1]*qt+B[1]*en+te[1]*nn,je[2]=tt[2]*ct+yt[2]*qt+B[2]*en+te[2]*nn,je}function zt(je,tt,yt,B,te,ot){var _t=1-ot,ct=_t*_t,qt=ot*ot,en=ct*_t,nn=3*ot*ct,we=3*qt*_t,Q=qt*ot;return je[0]=tt[0]*en+yt[0]*nn+B[0]*we+te[0]*Q,je[1]=tt[1]*en+yt[1]*nn+B[1]*we+te[1]*Q,je[2]=tt[2]*en+yt[2]*nn+B[2]*we+te[2]*Q,je}function Yt(je,tt){tt=tt||1;var yt=glMatrix.RANDOM()*2*Math.PI,B=glMatrix.RANDOM()*2-1,te=Math.sqrt(1-B*B)*tt;return je[0]=Math.cos(yt)*te,je[1]=Math.sin(yt)*te,je[2]=B*tt,je}function At(je,tt,yt){var B=tt[0],te=tt[1],ot=tt[2],_t=yt[3]*B+yt[7]*te+yt[11]*ot+yt[15];return _t=_t||1,je[0]=(yt[0]*B+yt[4]*te+yt[8]*ot+yt[12])/_t,je[1]=(yt[1]*B+yt[5]*te+yt[9]*ot+yt[13])/_t,je[2]=(yt[2]*B+yt[6]*te+yt[10]*ot+yt[14])/_t,je}function lt(je,tt,yt){var B=tt[0],te=tt[1],ot=tt[2];return je[0]=B*yt[0]+te*yt[3]+ot*yt[6],je[1]=B*yt[1]+te*yt[4]+ot*yt[7],je[2]=B*yt[2]+te*yt[5]+ot*yt[8],je}function Ot(je,tt,yt){var B=yt[0],te=yt[1],ot=yt[2],_t=yt[3],ct=tt[0],qt=tt[1],en=tt[2],nn=te*en-ot*qt,we=ot*ct-B*en,Q=B*qt-te*ct,De=te*Q-ot*we,We=ot*nn-B*Q,Ce=B*we-te*nn,Re=_t*2;return nn*=Re,we*=Re,Q*=Re,De*=2,We*=2,Ce*=2,je[0]=ct+nn+De,je[1]=qt+we+We,je[2]=en+Q+Ce,je}function le(je,tt,yt,B){var te=[],ot=[];return te[0]=tt[0]-yt[0],te[1]=tt[1]-yt[1],te[2]=tt[2]-yt[2],ot[0]=te[0],ot[1]=te[1]*Math.cos(B)-te[2]*Math.sin(B),ot[2]=te[1]*Math.sin(B)+te[2]*Math.cos(B),je[0]=ot[0]+yt[0],je[1]=ot[1]+yt[1],je[2]=ot[2]+yt[2],je}function Fe(je,tt,yt,B){var te=[],ot=[];return te[0]=tt[0]-yt[0],te[1]=tt[1]-yt[1],te[2]=tt[2]-yt[2],ot[0]=te[2]*Math.sin(B)+te[0]*Math.cos(B),ot[1]=te[1],ot[2]=te[2]*Math.cos(B)-te[0]*Math.sin(B),je[0]=ot[0]+yt[0],je[1]=ot[1]+yt[1],je[2]=ot[2]+yt[2],je}function gt(je,tt,yt,B){var te=[],ot=[];return te[0]=tt[0]-yt[0],te[1]=tt[1]-yt[1],te[2]=tt[2]-yt[2],ot[0]=te[0]*Math.cos(B)-te[1]*Math.sin(B),ot[1]=te[0]*Math.sin(B)+te[1]*Math.cos(B),ot[2]=te[2],je[0]=ot[0]+yt[0],je[1]=ot[1]+yt[1],je[2]=ot[2]+yt[2],je}function Jt(je,tt){var yt=je[0],B=je[1],te=je[2],ot=tt[0],_t=tt[1],ct=tt[2],qt=Math.sqrt(yt*yt+B*B+te*te),en=Math.sqrt(ot*ot+_t*_t+ct*ct),nn=qt*en,we=nn&&Ge(je,tt)/nn;return Math.acos(Math.min(Math.max(we,-1),1))}function Ze(je){return je[0]=0,je[1]=0,je[2]=0,je}function rt(je){return"vec3("+je[0]+", "+je[1]+", "+je[2]+")"}function Mt(je,tt){return je[0]===tt[0]&&je[1]===tt[1]&&je[2]===tt[2]}function Ue(je,tt){var yt=je[0],B=je[1],te=je[2],ot=tt[0],_t=tt[1],ct=tt[2];return Math.abs(yt-ot)<=w.Ib*Math.max(1,Math.abs(yt),Math.abs(ot))&&Math.abs(B-_t)<=w.Ib*Math.max(1,Math.abs(B),Math.abs(_t))&&Math.abs(te-ct)<=w.Ib*Math.max(1,Math.abs(te),Math.abs(ct))}var Ye=N,be=null,ge=null,Ke=ue,wt=null,Be=R,ut=null,Et=function(){var je=k();return function(tt,yt,B,te,ot,_t){var ct,qt;for(yt||(yt=3),B||(B=0),te?qt=Math.min(te*yt+B,tt.length):qt=tt.length,ct=B;ct<qt;ct+=yt)je[0]=tt[ct],je[1]=tt[ct+1],je[2]=tt[ct+2],ot(je,je,_t),tt[ct]=je[0],tt[ct+1]=je[1],tt[ct+2]=je[2];return tt}}()},98333:function(se,ee,b){"use strict";b.d(ee,{AK:function(){return Ge},Fv:function(){return Se},I6:function(){return Ot},IH:function(){return x},JG:function(){return S},Ue:function(){return k},al:function(){return R},bA:function(){return fe},d9:function(){return O},fF:function(){return zt},fS:function(){return le},kE:function(){return Ne},t7:function(){return vt},t8:function(){return C},we:function(){return Te}});var w=b(49685);function k(){var be=new w.WT(4);return w.WT!=Float32Array&&(be[0]=0,be[1]=0,be[2]=0,be[3]=0),be}function O(be){var ge=new w.WT(4);return ge[0]=be[0],ge[1]=be[1],ge[2]=be[2],ge[3]=be[3],ge}function R(be,ge,Ke,wt){var Be=new w.WT(4);return Be[0]=be,Be[1]=ge,Be[2]=Ke,Be[3]=wt,Be}function S(be,ge){return be[0]=ge[0],be[1]=ge[1],be[2]=ge[2],be[3]=ge[3],be}function C(be,ge,Ke,wt,Be){return be[0]=ge,be[1]=Ke,be[2]=wt,be[3]=Be,be}function x(be,ge,Ke){return be[0]=ge[0]+Ke[0],be[1]=ge[1]+Ke[1],be[2]=ge[2]+Ke[2],be[3]=ge[3]+Ke[3],be}function E(be,ge,Ke){return be[0]=ge[0]-Ke[0],be[1]=ge[1]-Ke[1],be[2]=ge[2]-Ke[2],be[3]=ge[3]-Ke[3],be}function N(be,ge,Ke){return be[0]=ge[0]*Ke[0],be[1]=ge[1]*Ke[1],be[2]=ge[2]*Ke[2],be[3]=ge[3]*Ke[3],be}function L(be,ge,Ke){return be[0]=ge[0]/Ke[0],be[1]=ge[1]/Ke[1],be[2]=ge[2]/Ke[2],be[3]=ge[3]/Ke[3],be}function P(be,ge){return be[0]=Math.ceil(ge[0]),be[1]=Math.ceil(ge[1]),be[2]=Math.ceil(ge[2]),be[3]=Math.ceil(ge[3]),be}function W(be,ge){return be[0]=Math.floor(ge[0]),be[1]=Math.floor(ge[1]),be[2]=Math.floor(ge[2]),be[3]=Math.floor(ge[3]),be}function Y(be,ge,Ke){return be[0]=Math.min(ge[0],Ke[0]),be[1]=Math.min(ge[1],Ke[1]),be[2]=Math.min(ge[2],Ke[2]),be[3]=Math.min(ge[3],Ke[3]),be}function ie(be,ge,Ke){return be[0]=Math.max(ge[0],Ke[0]),be[1]=Math.max(ge[1],Ke[1]),be[2]=Math.max(ge[2],Ke[2]),be[3]=Math.max(ge[3],Ke[3]),be}function pe(be,ge){return be[0]=Math.round(ge[0]),be[1]=Math.round(ge[1]),be[2]=Math.round(ge[2]),be[3]=Math.round(ge[3]),be}function fe(be,ge,Ke){return be[0]=ge[0]*Ke,be[1]=ge[1]*Ke,be[2]=ge[2]*Ke,be[3]=ge[3]*Ke,be}function ae(be,ge,Ke,wt){return be[0]=ge[0]+Ke[0]*wt,be[1]=ge[1]+Ke[1]*wt,be[2]=ge[2]+Ke[2]*wt,be[3]=ge[3]+Ke[3]*wt,be}function ye(be,ge){var Ke=ge[0]-be[0],wt=ge[1]-be[1],Be=ge[2]-be[2],ut=ge[3]-be[3];return Math.hypot(Ke,wt,Be,ut)}function ue(be,ge){var Ke=ge[0]-be[0],wt=ge[1]-be[1],Be=ge[2]-be[2],ut=ge[3]-be[3];return Ke*Ke+wt*wt+Be*Be+ut*ut}function Ne(be){var ge=be[0],Ke=be[1],wt=be[2],Be=be[3];return Math.hypot(ge,Ke,wt,Be)}function Te(be){var ge=be[0],Ke=be[1],wt=be[2],Be=be[3];return ge*ge+Ke*Ke+wt*wt+Be*Be}function _e(be,ge){return be[0]=-ge[0],be[1]=-ge[1],be[2]=-ge[2],be[3]=-ge[3],be}function Xe(be,ge){return be[0]=1/ge[0],be[1]=1/ge[1],be[2]=1/ge[2],be[3]=1/ge[3],be}function Se(be,ge){var Ke=ge[0],wt=ge[1],Be=ge[2],ut=ge[3],Et=Ke*Ke+wt*wt+Be*Be+ut*ut;return Et>0&&(Et=1/Math.sqrt(Et)),be[0]=Ke*Et,be[1]=wt*Et,be[2]=Be*Et,be[3]=ut*Et,be}function Ge(be,ge){return be[0]*ge[0]+be[1]*ge[1]+be[2]*ge[2]+be[3]*ge[3]}function He(be,ge,Ke,wt){var Be=Ke[0]*wt[1]-Ke[1]*wt[0],ut=Ke[0]*wt[2]-Ke[2]*wt[0],Et=Ke[0]*wt[3]-Ke[3]*wt[0],je=Ke[1]*wt[2]-Ke[2]*wt[1],tt=Ke[1]*wt[3]-Ke[3]*wt[1],yt=Ke[2]*wt[3]-Ke[3]*wt[2],B=ge[0],te=ge[1],ot=ge[2],_t=ge[3];return be[0]=te*yt-ot*tt+_t*je,be[1]=-(B*yt)+ot*Et-_t*ut,be[2]=B*tt-te*Et+_t*Be,be[3]=-(B*je)+te*ut-ot*Be,be}function vt(be,ge,Ke,wt){var Be=ge[0],ut=ge[1],Et=ge[2],je=ge[3];return be[0]=Be+wt*(Ke[0]-Be),be[1]=ut+wt*(Ke[1]-ut),be[2]=Et+wt*(Ke[2]-Et),be[3]=je+wt*(Ke[3]-je),be}function It(be,ge){ge=ge||1;var Ke,wt,Be,ut,Et,je;do Ke=glMatrix.RANDOM()*2-1,wt=glMatrix.RANDOM()*2-1,Et=Ke*Ke+wt*wt;while(Et>=1);do Be=glMatrix.RANDOM()*2-1,ut=glMatrix.RANDOM()*2-1,je=Be*Be+ut*ut;while(je>=1);var tt=Math.sqrt((1-Et)/je);return be[0]=ge*Ke,be[1]=ge*wt,be[2]=ge*Be*tt,be[3]=ge*ut*tt,be}function zt(be,ge,Ke){var wt=ge[0],Be=ge[1],ut=ge[2],Et=ge[3];return be[0]=Ke[0]*wt+Ke[4]*Be+Ke[8]*ut+Ke[12]*Et,be[1]=Ke[1]*wt+Ke[5]*Be+Ke[9]*ut+Ke[13]*Et,be[2]=Ke[2]*wt+Ke[6]*Be+Ke[10]*ut+Ke[14]*Et,be[3]=Ke[3]*wt+Ke[7]*Be+Ke[11]*ut+Ke[15]*Et,be}function Yt(be,ge,Ke){var wt=ge[0],Be=ge[1],ut=ge[2],Et=Ke[0],je=Ke[1],tt=Ke[2],yt=Ke[3],B=yt*wt+je*ut-tt*Be,te=yt*Be+tt*wt-Et*ut,ot=yt*ut+Et*Be-je*wt,_t=-Et*wt-je*Be-tt*ut;return be[0]=B*yt+_t*-Et+te*-tt-ot*-je,be[1]=te*yt+_t*-je+ot*-Et-B*-tt,be[2]=ot*yt+_t*-tt+B*-je-te*-Et,be[3]=ge[3],be}function At(be){return be[0]=0,be[1]=0,be[2]=0,be[3]=0,be}function lt(be){return"vec4("+be[0]+", "+be[1]+", "+be[2]+", "+be[3]+")"}function Ot(be,ge){return be[0]===ge[0]&&be[1]===ge[1]&&be[2]===ge[2]&&be[3]===ge[3]}function le(be,ge){var Ke=be[0],wt=be[1],Be=be[2],ut=be[3],Et=ge[0],je=ge[1],tt=ge[2],yt=ge[3];return Math.abs(Ke-Et)<=w.Ib*Math.max(1,Math.abs(Ke),Math.abs(Et))&&Math.abs(wt-je)<=w.Ib*Math.max(1,Math.abs(wt),Math.abs(je))&&Math.abs(Be-tt)<=w.Ib*Math.max(1,Math.abs(Be),Math.abs(tt))&&Math.abs(ut-yt)<=w.Ib*Math.max(1,Math.abs(ut),Math.abs(yt))}var Fe=null,gt=null,Jt=null,Ze=null,rt=null,Mt=null,Ue=null,Ye=function(){var be=k();return function(ge,Ke,wt,Be,ut,Et){var je,tt;for(Ke||(Ke=4),wt||(wt=0),Be?tt=Math.min(Be*Ke+wt,ge.length):tt=ge.length,je=wt;je<tt;je+=Ke)be[0]=ge[je],be[1]=ge[je+1],be[2]=ge[je+2],be[3]=ge[je+3],ut(be,be,Et),ge[je]=be[0],ge[je+1]=be[1],ge[je+2]=be[2],ge[je+3]=be[3];return ge}}()},28282:function(se,ee,b){var w=b(82354);se.exports={Graph:w.Graph,json:b(28974),alg:b(12440),version:w.version}},2842:function(se,ee,b){var w=b(89126);se.exports=k;function k(O){var R={},S=[],C;function x(E){w.has(R,E)||(R[E]=!0,C.push(E),w.each(O.successors(E),x),w.each(O.predecessors(E),x))}return w.each(O.nodes(),function(E){C=[],x(E),C.length&&S.push(C)}),S}},53984:function(se,ee,b){var w=b(89126);se.exports=k;function k(R,S,C){w.isArray(S)||(S=[S]);var x=(R.isDirected()?R.successors:R.neighbors).bind(R),E=[],N={};return w.each(S,function(L){if(!R.hasNode(L))throw new Error("Graph does not have node: "+L);O(R,L,C==="post",N,x,E)}),E}function O(R,S,C,x,E,N){w.has(x,S)||(x[S]=!0,C||N.push(S),w.each(E(S),function(L){O(R,L,C,x,E,N)}),C&&N.push(S))}},84847:function(se,ee,b){var w=b(63763),k=b(89126);se.exports=O;function O(R,S,C){return k.transform(R.nodes(),function(x,E){x[E]=w(R,E,S,C)},{})}},63763:function(se,ee,b){var w=b(89126),k=b(75639);se.exports=R;var O=w.constant(1);function R(C,x,E,N){return S(C,String(x),E||O,N||function(L){return C.outEdges(L)})}function S(C,x,E,N){var L={},P=new k,W,Y,ie=function(pe){var fe=pe.v!==W?pe.v:pe.w,ae=L[fe],ye=E(pe),ue=Y.distance+ye;if(ye<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+pe+" Weight: "+ye);ue<ae.distance&&(ae.distance=ue,ae.predecessor=W,P.decrease(fe,ue))};for(C.nodes().forEach(function(pe){var fe=pe===x?0:Number.POSITIVE_INFINITY;L[pe]={distance:fe},P.add(pe,fe)});P.size()>0&&(W=P.removeMin(),Y=L[W],Y.distance!==Number.POSITIVE_INFINITY);)N(W).forEach(ie);return L}},9096:function(se,ee,b){var w=b(89126),k=b(5023);se.exports=O;function O(R){return w.filter(k(R),function(S){return S.length>1||S.length===1&&R.hasEdge(S[0],S[0])})}},38924:function(se,ee,b){var w=b(89126);se.exports=O;var k=w.constant(1);function O(S,C,x){return R(S,C||k,x||function(E){return S.outEdges(E)})}function R(S,C,x){var E={},N=S.nodes();return N.forEach(function(L){E[L]={},E[L][L]={distance:0},N.forEach(function(P){L!==P&&(E[L][P]={distance:Number.POSITIVE_INFINITY})}),x(L).forEach(function(P){var W=P.v===L?P.w:P.v,Y=C(P);E[L][W]={distance:Y,predecessor:L}})}),N.forEach(function(L){var P=E[L];N.forEach(function(W){var Y=E[W];N.forEach(function(ie){var pe=Y[L],fe=P[ie],ae=Y[ie],ye=pe.distance+fe.distance;ye<ae.distance&&(ae.distance=ye,ae.predecessor=fe.predecessor)})})}),E}},12440:function(se,ee,b){se.exports={components:b(2842),dijkstra:b(63763),dijkstraAll:b(84847),findCycles:b(9096),floydWarshall:b(38924),isAcyclic:b(62707),postorder:b(58828),preorder:b(92648),prim:b(80514),tarjan:b(5023),topsort:b(2166)}},62707:function(se,ee,b){var w=b(2166);se.exports=k;function k(O){try{w(O)}catch(R){if(R instanceof w.CycleException)return!1;throw R}return!0}},58828:function(se,ee,b){var w=b(53984);se.exports=k;function k(O,R){return w(O,R,"post")}},92648:function(se,ee,b){var w=b(53984);se.exports=k;function k(O,R){return w(O,R,"pre")}},80514:function(se,ee,b){var w=b(89126),k=b(30771),O=b(75639);se.exports=R;function R(S,C){var x=new k,E={},N=new O,L;function P(Y){var ie=Y.v===L?Y.w:Y.v,pe=N.priority(ie);if(pe!==void 0){var fe=C(Y);fe<pe&&(E[ie]=L,N.decrease(ie,fe))}}if(S.nodeCount()===0)return x;w.each(S.nodes(),function(Y){N.add(Y,Number.POSITIVE_INFINITY),x.setNode(Y)}),N.decrease(S.nodes()[0],0);for(var W=!1;N.size()>0;){if(L=N.removeMin(),w.has(E,L))x.setEdge(L,E[L]);else{if(W)throw new Error("Input graph is not connected: "+S);W=!0}S.nodeEdges(L).forEach(P)}return x}},5023:function(se,ee,b){var w=b(89126);se.exports=k;function k(O){var R=0,S=[],C={},x=[];function E(N){var L=C[N]={onStack:!0,lowlink:R,index:R++};if(S.push(N),O.successors(N).forEach(function(Y){w.has(C,Y)?C[Y].onStack&&(L.lowlink=Math.min(L.lowlink,C[Y].index)):(E(Y),L.lowlink=Math.min(L.lowlink,C[Y].lowlink))}),L.lowlink===L.index){var P=[],W;do W=S.pop(),C[W].onStack=!1,P.push(W);while(N!==W);x.push(P)}}return O.nodes().forEach(function(N){w.has(C,N)||E(N)}),x}},2166:function(se,ee,b){var w=b(89126);se.exports=k,k.CycleException=O;function k(R){var S={},C={},x=[];function E(N){if(w.has(C,N))throw new O;w.has(S,N)||(C[N]=!0,S[N]=!0,w.each(R.predecessors(N),E),delete C[N],x.push(N))}if(w.each(R.sinks(),E),w.size(S)!==R.nodeCount())throw new O;return x}function O(){}O.prototype=new Error},75639:function(se,ee,b){var w=b(89126);se.exports=k;function k(){this._arr=[],this._keyIndices={}}k.prototype.size=function(){return this._arr.length},k.prototype.keys=function(){return this._arr.map(function(O){return O.key})},k.prototype.has=function(O){return w.has(this._keyIndices,O)},k.prototype.priority=function(O){var R=this._keyIndices[O];if(R!==void 0)return this._arr[R].priority},k.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},k.prototype.add=function(O,R){var S=this._keyIndices;if(O=String(O),!w.has(S,O)){var C=this._arr,x=C.length;return S[O]=x,C.push({key:O,priority:R}),this._decrease(x),!0}return!1},k.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var O=this._arr.pop();return delete this._keyIndices[O.key],this._heapify(0),O.key},k.prototype.decrease=function(O,R){var S=this._keyIndices[O];if(R>this._arr[S].priority)throw new Error("New priority is greater than current priority. Key: "+O+" Old: "+this._arr[S].priority+" New: "+R);this._arr[S].priority=R,this._decrease(S)},k.prototype._heapify=function(O){var R=this._arr,S=2*O,C=S+1,x=O;S<R.length&&(x=R[S].priority<R[x].priority?S:x,C<R.length&&(x=R[C].priority<R[x].priority?C:x),x!==O&&(this._swap(O,x),this._heapify(x)))},k.prototype._decrease=function(O){for(var R=this._arr,S=R[O].priority,C;O!==0&&(C=O>>1,!(R[C].priority<S));)this._swap(O,C),O=C},k.prototype._swap=function(O,R){var S=this._arr,C=this._keyIndices,x=S[O],E=S[R];S[O]=E,S[R]=x,C[E.key]=O,C[x.key]=R}},30771:function(se,ee,b){"use strict";var w=b(89126);se.exports=S;var k="\0",O="\0",R="";function S(P){this._isDirected=w.has(P,"directed")?P.directed:!0,this._isMultigraph=w.has(P,"multigraph")?P.multigraph:!1,this._isCompound=w.has(P,"compound")?P.compound:!1,this._label=void 0,this._defaultNodeLabelFn=w.constant(void 0),this._defaultEdgeLabelFn=w.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[O]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}S.prototype._nodeCount=0,S.prototype._edgeCount=0,S.prototype.isDirected=function(){return this._isDirected},S.prototype.isMultigraph=function(){return this._isMultigraph},S.prototype.isCompound=function(){return this._isCompound},S.prototype.setGraph=function(P){return this._label=P,this},S.prototype.graph=function(){return this._label},S.prototype.setDefaultNodeLabel=function(P){return w.isFunction(P)||(P=w.constant(P)),this._defaultNodeLabelFn=P,this},S.prototype.nodeCount=function(){return this._nodeCount},S.prototype.nodes=function(){return w.keys(this._nodes)},S.prototype.sources=function(){var P=this;return w.filter(this.nodes(),function(W){return w.isEmpty(P._in[W])})},S.prototype.sinks=function(){var P=this;return w.filter(this.nodes(),function(W){return w.isEmpty(P._out[W])})},S.prototype.setNodes=function(P,W){var Y=arguments,ie=this;return w.each(P,function(pe){Y.length>1?ie.setNode(pe,W):ie.setNode(pe)}),this},S.prototype.setNode=function(P,W){return w.has(this._nodes,P)?(arguments.length>1&&(this._nodes[P]=W),this):(this._nodes[P]=arguments.length>1?W:this._defaultNodeLabelFn(P),this._isCompound&&(this._parent[P]=O,this._children[P]={},this._children[O][P]=!0),this._in[P]={},this._preds[P]={},this._out[P]={},this._sucs[P]={},++this._nodeCount,this)},S.prototype.node=function(P){return this._nodes[P]},S.prototype.hasNode=function(P){return w.has(this._nodes,P)},S.prototype.removeNode=function(P){var W=this;if(w.has(this._nodes,P)){var Y=function(ie){W.removeEdge(W._edgeObjs[ie])};delete this._nodes[P],this._isCompound&&(this._removeFromParentsChildList(P),delete this._parent[P],w.each(this.children(P),function(ie){W.setParent(ie)}),delete this._children[P]),w.each(w.keys(this._in[P]),Y),delete this._in[P],delete this._preds[P],w.each(w.keys(this._out[P]),Y),delete this._out[P],delete this._sucs[P],--this._nodeCount}return this},S.prototype.setParent=function(P,W){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(w.isUndefined(W))W=O;else{W+="";for(var Y=W;!w.isUndefined(Y);Y=this.parent(Y))if(Y===P)throw new Error("Setting "+W+" as parent of "+P+" would create a cycle");this.setNode(W)}return this.setNode(P),this._removeFromParentsChildList(P),this._parent[P]=W,this._children[W][P]=!0,this},S.prototype._removeFromParentsChildList=function(P){delete this._children[this._parent[P]][P]},S.prototype.parent=function(P){if(this._isCompound){var W=this._parent[P];if(W!==O)return W}},S.prototype.children=function(P){if(w.isUndefined(P)&&(P=O),this._isCompound){var W=this._children[P];if(W)return w.keys(W)}else{if(P===O)return this.nodes();if(this.hasNode(P))return[]}},S.prototype.predecessors=function(P){var W=this._preds[P];if(W)return w.keys(W)},S.prototype.successors=function(P){var W=this._sucs[P];if(W)return w.keys(W)},S.prototype.neighbors=function(P){var W=this.predecessors(P);if(W)return w.union(W,this.successors(P))},S.prototype.isLeaf=function(P){var W;return this.isDirected()?W=this.successors(P):W=this.neighbors(P),W.length===0},S.prototype.filterNodes=function(P){var W=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});W.setGraph(this.graph());var Y=this;w.each(this._nodes,function(fe,ae){P(ae)&&W.setNode(ae,fe)}),w.each(this._edgeObjs,function(fe){W.hasNode(fe.v)&&W.hasNode(fe.w)&&W.setEdge(fe,Y.edge(fe))});var ie={};function pe(fe){var ae=Y.parent(fe);return ae===void 0||W.hasNode(ae)?(ie[fe]=ae,ae):ae in ie?ie[ae]:pe(ae)}return this._isCompound&&w.each(W.nodes(),function(fe){W.setParent(fe,pe(fe))}),W},S.prototype.setDefaultEdgeLabel=function(P){return w.isFunction(P)||(P=w.constant(P)),this._defaultEdgeLabelFn=P,this},S.prototype.edgeCount=function(){return this._edgeCount},S.prototype.edges=function(){return w.values(this._edgeObjs)},S.prototype.setPath=function(P,W){var Y=this,ie=arguments;return w.reduce(P,function(pe,fe){return ie.length>1?Y.setEdge(pe,fe,W):Y.setEdge(pe,fe),fe}),this},S.prototype.setEdge=function(){var P,W,Y,ie,pe=!1,fe=arguments[0];typeof fe=="object"&&fe!==null&&"v"in fe?(P=fe.v,W=fe.w,Y=fe.name,arguments.length===2&&(ie=arguments[1],pe=!0)):(P=fe,W=arguments[1],Y=arguments[3],arguments.length>2&&(ie=arguments[2],pe=!0)),P=""+P,W=""+W,w.isUndefined(Y)||(Y=""+Y);var ae=E(this._isDirected,P,W,Y);if(w.has(this._edgeLabels,ae))return pe&&(this._edgeLabels[ae]=ie),this;if(!w.isUndefined(Y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(P),this.setNode(W),this._edgeLabels[ae]=pe?ie:this._defaultEdgeLabelFn(P,W,Y);var ye=N(this._isDirected,P,W,Y);return P=ye.v,W=ye.w,Object.freeze(ye),this._edgeObjs[ae]=ye,C(this._preds[W],P),C(this._sucs[P],W),this._in[W][ae]=ye,this._out[P][ae]=ye,this._edgeCount++,this},S.prototype.edge=function(P,W,Y){var ie=arguments.length===1?L(this._isDirected,arguments[0]):E(this._isDirected,P,W,Y);return this._edgeLabels[ie]},S.prototype.hasEdge=function(P,W,Y){var ie=arguments.length===1?L(this._isDirected,arguments[0]):E(this._isDirected,P,W,Y);return w.has(this._edgeLabels,ie)},S.prototype.removeEdge=function(P,W,Y){var ie=arguments.length===1?L(this._isDirected,arguments[0]):E(this._isDirected,P,W,Y),pe=this._edgeObjs[ie];return pe&&(P=pe.v,W=pe.w,delete this._edgeLabels[ie],delete this._edgeObjs[ie],x(this._preds[W],P),x(this._sucs[P],W),delete this._in[W][ie],delete this._out[P][ie],this._edgeCount--),this},S.prototype.inEdges=function(P,W){var Y=this._in[P];if(Y){var ie=w.values(Y);return W?w.filter(ie,function(pe){return pe.v===W}):ie}},S.prototype.outEdges=function(P,W){var Y=this._out[P];if(Y){var ie=w.values(Y);return W?w.filter(ie,function(pe){return pe.w===W}):ie}},S.prototype.nodeEdges=function(P,W){var Y=this.inEdges(P,W);if(Y)return Y.concat(this.outEdges(P,W))};function C(P,W){P[W]?P[W]++:P[W]=1}function x(P,W){--P[W]||delete P[W]}function E(P,W,Y,ie){var pe=""+W,fe=""+Y;if(!P&&pe>fe){var ae=pe;pe=fe,fe=ae}return pe+R+fe+R+(w.isUndefined(ie)?k:ie)}function N(P,W,Y,ie){var pe=""+W,fe=""+Y;if(!P&&pe>fe){var ae=pe;pe=fe,fe=ae}var ye={v:pe,w:fe};return ie&&(ye.name=ie),ye}function L(P,W){return E(P,W.v,W.w,W.name)}},82354:function(se,ee,b){se.exports={Graph:b(30771),version:b(49631)}},28974:function(se,ee,b){var w=b(89126),k=b(30771);se.exports={write:O,read:C};function O(x){var E={options:{directed:x.isDirected(),multigraph:x.isMultigraph(),compound:x.isCompound()},nodes:R(x),edges:S(x)};return w.isUndefined(x.graph())||(E.value=w.clone(x.graph())),E}function R(x){return w.map(x.nodes(),function(E){var N=x.node(E),L=x.parent(E),P={v:E};return w.isUndefined(N)||(P.value=N),w.isUndefined(L)||(P.parent=L),P})}function S(x){return w.map(x.edges(),function(E){var N=x.edge(E),L={v:E.v,w:E.w};return w.isUndefined(E.name)||(L.name=E.name),w.isUndefined(N)||(L.value=N),L})}function C(x){var E=new k(x.options).setGraph(x.value);return w.each(x.nodes,function(N){E.setNode(N.v,N.value),N.parent&&E.setParent(N.v,N.parent)}),w.each(x.edges,function(N){E.setEdge({v:N.v,w:N.w,name:N.name},N.value)}),E}},89126:function(se,ee,b){var w;try{w={clone:b(66678),constant:b(75703),each:b(85768),filter:b(63105),has:b(18721),isArray:b(1469),isEmpty:b(58367),isFunction:b(23560),isUndefined:b(52353),keys:b(3674),map:b(35161),reduce:b(54061),size:b(84238),transform:b(68718),union:b(93386),values:b(52628)}}catch(k){}w||(w=window._),se.exports=w},49631:function(se){se.exports="2.1.8"},80817:function(se){function ee(O,R,S){return(R[0]-O[0])*(S[1]-O[1])-(R[1]-O[1])*(S[0]-O[0])}function b(O){const R=[];for(let S=0;S<O.length;S++){for(;R.length>=2&&ee(R[R.length-2],R[R.length-1],O[S])<=0;)R.pop();R.push(O[S])}return R.pop(),R}function w(O){const R=O.reverse(),S=[];for(let C=0;C<R.length;C++){for(;S.length>=2&&ee(S[S.length-2],S[S.length-1],R[C])<=0;)S.pop();S.push(R[C])}return S.pop(),S}function k(O){const R=b(O),C=w(O).concat(R);return C.push(O[0]),C}se.exports=k},63652:function(se){se.exports={toXy:function(ee,b){return b===void 0?ee.slice():ee.map(function(w){return new Function("pt","return [pt"+b[0]+",pt"+b[1]+"];")(w)})},fromXy:function(ee,b){return b===void 0?ee.slice():ee.map(function(w){return new Function("pt","const o = {}; o"+b[0]+"= pt[0]; o"+b[1]+"= pt[1]; return o;")(w)})}}},58867:function(se){function ee(w,k){this._cells=[],this._cellSize=k,this._reverseCellSize=1/k;for(let O=0;O<w.length;O++){const R=w[O],S=this.coordToCellNum(R[0]),C=this.coordToCellNum(R[1]);if(this._cells[S])this._cells[S][C]?this._cells[S][C].push(R):this._cells[S][C]=[R];else{const x=[];x[C]=[R],this._cells[S]=x}}}ee.prototype={cellPoints:function(w,k){return this._cells[w]!==void 0&&this._cells[w][k]!==void 0?this._cells[w][k]:[]},rangePoints:function(w){const k=this.coordToCellNum(w[0]),O=this.coordToCellNum(w[1]),R=this.coordToCellNum(w[2]),S=this.coordToCellNum(w[3]),C=[];for(let x=k;x<=R;x++)for(let E=O;E<=S;E++)for(let N=0;N<this.cellPoints(x,E).length;N++)C.push(this.cellPoints(x,E)[N]);return C},removePoint:function(w){const k=this.coordToCellNum(w[0]),O=this.coordToCellNum(w[1]),R=this._cells[k][O];let S;for(let C=0;C<R.length;C++)if(R[C][0]===w[0]&&R[C][1]===w[1]){S=C;break}return R.splice(S,1),R},trunc:Math.trunc||function(w){return w-w%1},coordToCellNum:function(w){return this.trunc(w*this._reverseCellSize)},extendBbox:function(w,k){return[w[0]-k*this._cellSize,w[1]-k*this._cellSize,w[2]+k*this._cellSize,w[3]+k*this._cellSize]}};function b(w,k){return new ee(w,k)}se.exports=b},1344:function(se,ee,b){"use strict";const w=b(77444),k=b(58867),O=b(63652),R=b(80817);function S(ae){const ye=[ae[0]];let ue=ae[0];for(let Ne=1;Ne<ae.length;Ne++){const Te=ae[Ne];(ue[0]!==Te[0]||ue[1]!==Te[1])&&ye.push(Te),ue=Te}return ye}function C(ae){return ae.sort(function(ye,ue){return ye[0]-ue[0]||ye[1]-ue[1]})}function x(ae,ye){return Math.pow(ye[0]-ae[0],2)+Math.pow(ye[1]-ae[1],2)}function E(ae,ye,ue){const Ne=[ye[0]-ae[0],ye[1]-ae[1]],Te=[ue[0]-ae[0],ue[1]-ae[1]],_e=x(ae,ye),Xe=x(ae,ue);return(Ne[0]*Te[0]+Ne[1]*Te[1])/Math.sqrt(_e*Xe)}function N(ae,ye){for(let ue=0;ue<ye.length-1;ue++){const Ne=[ye[ue],ye[ue+1]];if(!(ae[0][0]===Ne[0][0]&&ae[0][1]===Ne[0][1]||ae[0][0]===Ne[1][0]&&ae[0][1]===Ne[1][1])&&w(ae,Ne))return!0}return!1}function L(ae){let ye=1/0,ue=1/0,Ne=-1/0,Te=-1/0;for(let _e=ae.length-1;_e>=0;_e--)ae[_e][0]<ye&&(ye=ae[_e][0]),ae[_e][1]<ue&&(ue=ae[_e][1]),ae[_e][0]>Ne&&(Ne=ae[_e][0]),ae[_e][1]>Te&&(Te=ae[_e][1]);return[Ne-ye,Te-ue]}function P(ae){return[Math.min(ae[0][0],ae[1][0]),Math.min(ae[0][1],ae[1][1]),Math.max(ae[0][0],ae[1][0]),Math.max(ae[0][1],ae[1][1])]}function W(ae,ye,ue){let Ne=null,Te=pe,_e=pe,Xe,Se;for(let Ge=0;Ge<ye.length;Ge++)Xe=E(ae[0],ae[1],ye[Ge]),Se=E(ae[1],ae[0],ye[Ge]),Xe>Te&&Se>_e&&!N([ae[0],ye[Ge]],ue)&&!N([ae[1],ye[Ge]],ue)&&(Te=Xe,_e=Se,Ne=ye[Ge]);return Ne}function Y(ae,ye,ue,Ne,Te){let _e=!1;for(let Xe=0;Xe<ae.length-1;Xe++){const Se=[ae[Xe],ae[Xe+1]],Ge=Se[0][0]+","+Se[0][1]+","+Se[1][0]+","+Se[1][1];if(x(Se[0],Se[1])<ye||Te.has(Ge))continue;let He=0,vt=P(Se),It,zt,Yt;do vt=Ne.extendBbox(vt,He),It=vt[2]-vt[0],zt=vt[3]-vt[1],Yt=W(Se,Ne.rangePoints(vt),ae),He++;while(Yt===null&&(ue[0]>It||ue[1]>zt));It>=ue[0]&&zt>=ue[1]&&Te.add(Ge),Yt!==null&&(ae.splice(Xe+1,0,Yt),Ne.removePoint(Yt),_e=!0)}return _e?Y(ae,ye,ue,Ne,Te):ae}function ie(ae,ye,ue){let Ne=ye||20;const Te=S(C(O.toXy(ae,ue)));if(Te.length<4){const It=Te.concat([Te[0]]);return ue?O.fromXy(It,ue):It}const _e=L(Te),Xe=[_e[0]*fe,_e[1]*fe],Se=R(Te),Ge=Te.filter(function(It){return Se.indexOf(It)<0}),He=Math.ceil(1/(Te.length/(_e[0]*_e[1]))),vt=Y(Se,Math.pow(Ne,2),Xe,k(Ge,He),new Set);return ue?O.fromXy(vt,ue):vt}const pe=Math.cos(90/(180/Math.PI)),fe=.6;se.exports=ie},77444:function(se){function ee(w,k,O,R,S,C){const x=(C-k)*(O-w)-(R-k)*(S-w);return x>0?!0:!(x<0)}function b(w,k){const O=w[0][0],R=w[0][1],S=w[1][0],C=w[1][1],x=k[0][0],E=k[0][1],N=k[1][0],L=k[1][1];return ee(O,R,x,E,N,L)!==ee(S,C,x,E,N,L)&&ee(O,R,S,C,x,E)!==ee(O,R,S,C,N,L)}se.exports=b},44091:function(se,ee,b){"use strict";b.r(ee),b.d(ee,{isAnyArray:function(){return k}});const w=Object.prototype.toString;function k(O){const R=w.call(O);return R.endsWith("Array]")&&!R.includes("Big")}},18552:function(se,ee,b){var w=b(10852),k=b(55639),O=w(k,"DataView");se.exports=O},53818:function(se,ee,b){var w=b(10852),k=b(55639),O=w(k,"Promise");se.exports=O},58525:function(se,ee,b){var w=b(10852),k=b(55639),O=w(k,"Set");se.exports=O},88668:function(se,ee,b){var w=b(83369),k=b(90619),O=b(72385);function R(S){var C=-1,x=S==null?0:S.length;for(this.__data__=new w;++C<x;)this.add(S[C])}R.prototype.add=R.prototype.push=k,R.prototype.has=O,se.exports=R},70577:function(se,ee,b){var w=b(10852),k=b(55639),O=w(k,"WeakMap");se.exports=O},77412:function(se){function ee(b,w){for(var k=-1,O=b==null?0:b.length;++k<O&&w(b[k],k,b)!==!1;);return b}se.exports=ee},34963:function(se){function ee(b,w){for(var k=-1,O=b==null?0:b.length,R=0,S=[];++k<O;){var C=b[k];w(C,k,b)&&(S[R++]=C)}return S}se.exports=ee},47443:function(se,ee,b){var w=b(42118);function k(O,R){var S=O==null?0:O.length;return!!S&&w(O,R,0)>-1}se.exports=k},1196:function(se){function ee(b,w,k){for(var O=-1,R=b==null?0:b.length;++O<R;)if(k(w,b[O]))return!0;return!1}se.exports=ee},29932:function(se){function ee(b,w){for(var k=-1,O=b==null?0:b.length,R=Array(O);++k<O;)R[k]=w(b[k],k,b);return R}se.exports=ee},62488:function(se){function ee(b,w){for(var k=-1,O=w.length,R=b.length;++k<O;)b[R+k]=w[k];return b}se.exports=ee},62663:function(se){function ee(b,w,k,O){var R=-1,S=b==null?0:b.length;for(O&&S&&(k=b[++R]);++R<S;)k=w(k,b[R],R,b);return k}se.exports=ee},82908:function(se){function ee(b,w){for(var k=-1,O=b==null?0:b.length;++k<O;)if(w(b[k],k,b))return!0;return!1}se.exports=ee},48983:function(se,ee,b){var w=b(40371),k=w("length");se.exports=k},44037:function(se,ee,b){var w=b(98363),k=b(3674);function O(R,S){return R&&w(S,k(S),R)}se.exports=O},63886:function(se,ee,b){var w=b(98363),k=b(81704);function O(R,S){return R&&w(S,k(S),R)}se.exports=O},85990:function(se,ee,b){var w=b(46384),k=b(77412),O=b(34865),R=b(44037),S=b(63886),C=b(64626),x=b(278),E=b(18805),N=b(1911),L=b(58234),P=b(46904),W=b(64160),Y=b(43824),ie=b(29148),pe=b(38517),fe=b(1469),ae=b(44144),ye=b(56688),ue=b(13218),Ne=b(72928),Te=b(3674),_e=b(81704),Xe=1,Se=2,Ge=4,He="[object Arguments]",vt="[object Array]",It="[object Boolean]",zt="[object Date]",Yt="[object Error]",At="[object Function]",lt="[object GeneratorFunction]",Ot="[object Map]",le="[object Number]",Fe="[object Object]",gt="[object RegExp]",Jt="[object Set]",Ze="[object String]",rt="[object Symbol]",Mt="[object WeakMap]",Ue="[object ArrayBuffer]",Ye="[object DataView]",be="[object Float32Array]",ge="[object Float64Array]",Ke="[object Int8Array]",wt="[object Int16Array]",Be="[object Int32Array]",ut="[object Uint8Array]",Et="[object Uint8ClampedArray]",je="[object Uint16Array]",tt="[object Uint32Array]",yt={};yt[He]=yt[vt]=yt[Ue]=yt[Ye]=yt[It]=yt[zt]=yt[be]=yt[ge]=yt[Ke]=yt[wt]=yt[Be]=yt[Ot]=yt[le]=yt[Fe]=yt[gt]=yt[Jt]=yt[Ze]=yt[rt]=yt[ut]=yt[Et]=yt[je]=yt[tt]=!0,yt[Yt]=yt[At]=yt[Mt]=!1;function B(te,ot,_t,ct,qt,en){var nn,we=ot&Xe,Q=ot&Se,De=ot&Ge;if(_t&&(nn=qt?_t(te,ct,qt,en):_t(te)),nn!==void 0)return nn;if(!ue(te))return te;var We=fe(te);if(We){if(nn=Y(te),!we)return x(te,nn)}else{var Ce=W(te),Re=Ce==At||Ce==lt;if(ae(te))return C(te,we);if(Ce==Fe||Ce==He||Re&&!qt){if(nn=Q||Re?{}:pe(te),!we)return Q?N(te,S(nn,te)):E(te,R(nn,te))}else{if(!yt[Ce])return qt?te:{};nn=ie(te,Ce,we)}}en||(en=new w);var qe=en.get(te);if(qe)return qe;en.set(te,nn),Ne(te)?te.forEach(function(ft){nn.add(B(ft,ot,_t,ft,te,en))}):ye(te)&&te.forEach(function(ft,Ct){nn.set(Ct,B(ft,ot,_t,Ct,te,en))});var st=De?Q?P:L:Q?_e:Te,$e=We?void 0:st(te);return k($e||te,function(ft,Ct){$e&&(Ct=ft,ft=te[Ct]),O(nn,Ct,B(ft,ot,_t,Ct,te,en))}),nn}se.exports=B},89881:function(se,ee,b){var w=b(47816),k=b(99291),O=k(w);se.exports=O},56029:function(se,ee,b){var w=b(33448);function k(O,R,S){for(var C=-1,x=O.length;++C<x;){var E=O[C],N=R(E);if(N!=null&&(L===void 0?N===N&&!w(N):S(N,L)))var L=N,P=E}return P}se.exports=k},80760:function(se,ee,b){var w=b(89881);function k(O,R){var S=[];return w(O,function(C,x,E){R(C,x,E)&&S.push(C)}),S}se.exports=k},41848:function(se){function ee(b,w,k,O){for(var R=b.length,S=k+(O?1:-1);O?S--:++S<R;)if(w(b[S],S,b))return S;return-1}se.exports=ee},21078:function(se,ee,b){var w=b(62488),k=b(37285);function O(R,S,C,x,E){var N=-1,L=R.length;for(C||(C=k),E||(E=[]);++N<L;){var P=R[N];S>0&&C(P)?S>1?O(P,S-1,C,x,E):w(E,P):x||(E[E.length]=P)}return E}se.exports=O},47816:function(se,ee,b){var w=b(28483),k=b(3674);function O(R,S){return R&&w(R,S,k)}se.exports=O},97786:function(se,ee,b){var w=b(71811),k=b(40327);function O(R,S){S=w(S,R);for(var C=0,x=S.length;R!=null&&C<x;)R=R[k(S[C++])];return C&&C==x?R:void 0}se.exports=O},64055:function(se,ee,b){var w=b(62488),k=b(1469);function O(R,S,C){var x=S(R);return k(R)?x:w(x,C(R))}se.exports=O},53325:function(se){function ee(b,w){return b>w}se.exports=ee},78565:function(se){var ee=Object.prototype,b=ee.hasOwnProperty;function w(k,O){return k!=null&&b.call(k,O)}se.exports=w},13:function(se){function ee(b,w){return b!=null&&w in Object(b)}se.exports=ee},42118:function(se,ee,b){var w=b(41848),k=b(62722),O=b(42351);function R(S,C,x){return C===C?O(S,C,x):w(S,k,x)}se.exports=R},90939:function(se,ee,b){var w=b(2492),k=b(37005);function O(R,S,C,x,E){return R===S?!0:R==null||S==null||!k(R)&&!k(S)?R!==R&&S!==S:w(R,S,C,x,O,E)}se.exports=O},2492:function(se,ee,b){var w=b(46384),k=b(67114),O=b(18351),R=b(16096),S=b(64160),C=b(1469),x=b(44144),E=b(36719),N=1,L="[object Arguments]",P="[object Array]",W="[object Object]",Y=Object.prototype,ie=Y.hasOwnProperty;function pe(fe,ae,ye,ue,Ne,Te){var _e=C(fe),Xe=C(ae),Se=_e?P:S(fe),Ge=Xe?P:S(ae);Se=Se==L?W:Se,Ge=Ge==L?W:Ge;var He=Se==W,vt=Ge==W,It=Se==Ge;if(It&&x(fe)){if(!x(ae))return!1;_e=!0,He=!1}if(It&&!He)return Te||(Te=new w),_e||E(fe)?k(fe,ae,ye,ue,Ne,Te):O(fe,ae,Se,ye,ue,Ne,Te);if(!(ye&N)){var zt=He&&ie.call(fe,"__wrapped__"),Yt=vt&&ie.call(ae,"__wrapped__");if(zt||Yt){var At=zt?fe.value():fe,lt=Yt?ae.value():ae;return Te||(Te=new w),Ne(At,lt,ye,ue,Te)}}return It?(Te||(Te=new w),R(fe,ae,ye,ue,Ne,Te)):!1}se.exports=pe},25588:function(se,ee,b){var w=b(64160),k=b(37005),O="[object Map]";function R(S){return k(S)&&w(S)==O}se.exports=R},2958:function(se,ee,b){var w=b(46384),k=b(90939),O=1,R=2;function S(C,x,E,N){var L=E.length,P=L,W=!N;if(C==null)return!P;for(C=Object(C);L--;){var Y=E[L];if(W&&Y[2]?Y[1]!==C[Y[0]]:!(Y[0]in C))return!1}for(;++L<P;){Y=E[L];var ie=Y[0],pe=C[ie],fe=Y[1];if(W&&Y[2]){if(pe===void 0&&!(ie in C))return!1}else{var ae=new w;if(N)var ye=N(pe,fe,ie,C,x,ae);if(!(ye===void 0?k(fe,pe,O|R,N,ae):ye))return!1}}return!0}se.exports=S},62722:function(se){function ee(b){return b!==b}se.exports=ee},29221:function(se,ee,b){var w=b(64160),k=b(37005),O="[object Set]";function R(S){return k(S)&&w(S)==O}se.exports=R},67206:function(se,ee,b){var w=b(91573),k=b(16432),O=b(6557),R=b(1469),S=b(39601);function C(x){return typeof x=="function"?x:x==null?O:typeof x=="object"?R(x)?k(x[0],x[1]):w(x):S(x)}se.exports=C},280:function(se,ee,b){var w=b(25726),k=b(86916),O=Object.prototype,R=O.hasOwnProperty;function S(C){if(!w(C))return k(C);var x=[];for(var E in Object(C))R.call(C,E)&&E!="constructor"&&x.push(E);return x}se.exports=S},70433:function(se){function ee(b,w){return b<w}se.exports=ee},69199:function(se,ee,b){var w=b(89881),k=b(98612);function O(R,S){var C=-1,x=k(R)?Array(R.length):[];return w(R,function(E,N,L){x[++C]=S(E,N,L)}),x}se.exports=O},91573:function(se,ee,b){var w=b(2958),k=b(1499),O=b(42634);function R(S){var C=k(S);return C.length==1&&C[0][2]?O(C[0][0],C[0][1]):function(x){return x===S||w(x,S,C)}}se.exports=R},16432:function(se,ee,b){var w=b(90939),k=b(27361),O=b(79095),R=b(15403),S=b(89162),C=b(42634),x=b(40327),E=1,N=2;function L(P,W){return R(P)&&S(W)?C(x(P),W):function(Y){var ie=k(Y,P);return ie===void 0&&ie===W?O(Y,P):w(W,ie,E|N)}}se.exports=L},82689:function(se,ee,b){var w=b(29932),k=b(97786),O=b(67206),R=b(69199),S=b(63922),C=b(7518),x=b(85022),E=b(6557),N=b(1469);function L(P,W,Y){W.length?W=w(W,function(fe){return N(fe)?function(ae){return k(ae,fe.length===1?fe[0]:fe)}:fe}):W=[E];var ie=-1;W=w(W,C(O));var pe=R(P,function(fe,ae,ye){var ue=w(W,function(Ne){return Ne(fe)});return{criteria:ue,index:++ie,value:fe}});return S(pe,function(fe,ae){return x(fe,ae,Y)})}se.exports=L},25970:function(se,ee,b){var w=b(63012),k=b(79095);function O(R,S){return w(R,S,function(C,x){return k(R,x)})}se.exports=O},63012:function(se,ee,b){var w=b(97786),k=b(10611),O=b(71811);function R(S,C,x){for(var E=-1,N=C.length,L={};++E<N;){var P=C[E],W=w(S,P);x(W,P)&&k(L,O(P,S),W)}return L}se.exports=R},40371:function(se){function ee(b){return function(w){return w==null?void 0:w[b]}}se.exports=ee},79152:function(se,ee,b){var w=b(97786);function k(O){return function(R){return w(R,O)}}se.exports=k},40098:function(se){var ee=Math.ceil,b=Math.max;function w(k,O,R,S){for(var C=-1,x=b(ee((O-k)/(R||1)),0),E=Array(x);x--;)E[S?x:++C]=k,k+=R;return E}se.exports=w},10107:function(se){function ee(b,w,k,O,R){return R(b,function(S,C,x){k=O?(O=!1,S):w(k,S,C,x)}),k}se.exports=ee},10611:function(se,ee,b){var w=b(34865),k=b(71811),O=b(65776),R=b(13218),S=b(40327);function C(x,E,N,L){if(!R(x))return x;E=k(E,x);for(var P=-1,W=E.length,Y=W-1,ie=x;ie!=null&&++P<W;){var pe=S(E[P]),fe=N;if(pe==="__proto__"||pe==="constructor"||pe==="prototype")return x;if(P!=Y){var ae=ie[pe];fe=L?L(ae,pe,ie):void 0,fe===void 0&&(fe=R(ae)?ae:O(E[P+1])?[]:{})}w(ie,pe,fe),ie=ie[pe]}return x}se.exports=C},63922:function(se){function ee(b,w){var k=b.length;for(b.sort(w);k--;)b[k]=b[k].value;return b}se.exports=ee},80531:function(se,ee,b){var w=b(62705),k=b(29932),O=b(1469),R=b(33448),S=1/0,C=w?w.prototype:void 0,x=C?C.toString:void 0;function E(N){if(typeof N=="string")return N;if(O(N))return k(N,E)+"";if(R(N))return x?x.call(N):"";var L=N+"";return L=="0"&&1/N==-S?"-0":L}se.exports=E},27561:function(se,ee,b){var w=b(67990),k=/^\s+/;function O(R){return R&&R.slice(0,w(R)+1).replace(k,"")}se.exports=O},45652:function(se,ee,b){var w=b(88668),k=b(47443),O=b(1196),R=b(74757),S=b(23593),C=b(21814),x=200;function E(N,L,P){var W=-1,Y=k,ie=N.length,pe=!0,fe=[],ae=fe;if(P)pe=!1,Y=O;else if(ie>=x){var ye=L?null:S(N);if(ye)return C(ye);pe=!1,Y=R,ae=new w}else ae=L?[]:fe;e:for(;++W<ie;){var ue=N[W],Ne=L?L(ue):ue;if(ue=P||ue!==0?ue:0,pe&&Ne===Ne){for(var Te=ae.length;Te--;)if(ae[Te]===Ne)continue e;L&&ae.push(Ne),fe.push(ue)}else Y(ae,Ne,P)||(ae!==fe&&ae.push(Ne),fe.push(ue))}return fe}se.exports=E},47415:function(se,ee,b){var w=b(29932);function k(O,R){return w(R,function(S){return O[S]})}se.exports=k},1757:function(se){function ee(b,w,k){for(var O=-1,R=b.length,S=w.length,C={};++O<R;){var x=O<S?w[O]:void 0;k(C,b[O],x)}return C}se.exports=ee},74757:function(se){function ee(b,w){return b.has(w)}se.exports=ee},54290:function(se,ee,b){var w=b(6557);function k(O){return typeof O=="function"?O:w}se.exports=k},71811:function(se,ee,b){var w=b(1469),k=b(15403),O=b(55514),R=b(79833);function S(C,x){return w(C)?C:k(C,x)?[C]:O(R(C))}se.exports=S},57157:function(se,ee,b){var w=b(74318);function k(O,R){var S=R?w(O.buffer):O.buffer;return new O.constructor(S,O.byteOffset,O.byteLength)}se.exports=k},93147:function(se){var ee=/\w*$/;function b(w){var k=new w.constructor(w.source,ee.exec(w));return k.lastIndex=w.lastIndex,k}se.exports=b},40419:function(se,ee,b){var w=b(62705),k=w?w.prototype:void 0,O=k?k.valueOf:void 0;function R(S){return O?Object(O.call(S)):{}}se.exports=R},26393:function(se,ee,b){var w=b(33448);function k(O,R){if(O!==R){var S=O!==void 0,C=O===null,x=O===O,E=w(O),N=R!==void 0,L=R===null,P=R===R,W=w(R);if(!L&&!W&&!E&&O>R||E&&N&&P&&!L&&!W||C&&N&&P||!S&&P||!x)return 1;if(!C&&!E&&!W&&O<R||W&&S&&x&&!C&&!E||L&&S&&x||!N&&x||!P)return-1}return 0}se.exports=k},85022:function(se,ee,b){var w=b(26393);function k(O,R,S){for(var C=-1,x=O.criteria,E=R.criteria,N=x.length,L=S.length;++C<N;){var P=w(x[C],E[C]);if(P){if(C>=L)return P;var W=S[C];return P*(W=="desc"?-1:1)}}return O.index-R.index}se.exports=k},18805:function(se,ee,b){var w=b(98363),k=b(99551);function O(R,S){return w(R,k(R),S)}se.exports=O},1911:function(se,ee,b){var w=b(98363),k=b(51442);function O(R,S){return w(R,k(R),S)}se.exports=O},99291:function(se,ee,b){var w=b(98612);function k(O,R){return function(S,C){if(S==null)return S;if(!w(S))return O(S,C);for(var x=S.length,E=R?x:-1,N=Object(S);(R?E--:++E<x)&&C(N[E],E,N)!==!1;);return S}}se.exports=k},67740:function(se,ee,b){var w=b(67206),k=b(98612),O=b(3674);function R(S){return function(C,x,E){var N=Object(C);if(!k(C)){var L=w(x,3);C=O(C),x=function(W){return L(N[W],W,N)}}var P=S(C,x,E);return P>-1?N[L?C[P]:P]:void 0}}se.exports=R},47445:function(se,ee,b){var w=b(40098),k=b(16612),O=b(18601);function R(S){return function(C,x,E){return E&&typeof E!="number"&&k(C,x,E)&&(x=E=void 0),C=O(C),x===void 0?(x=C,C=0):x=O(x),E=E===void 0?C<x?1:-1:O(E),w(C,x,E,S)}}se.exports=R},23593:function(se,ee,b){var w=b(58525),k=b(50308),O=b(21814),R=1/0,S=w&&1/O(new w([,-0]))[1]==R?function(C){return new w(C)}:k;se.exports=S},67114:function(se,ee,b){var w=b(88668),k=b(82908),O=b(74757),R=1,S=2;function C(x,E,N,L,P,W){var Y=N&R,ie=x.length,pe=E.length;if(ie!=pe&&!(Y&&pe>ie))return!1;var fe=W.get(x),ae=W.get(E);if(fe&&ae)return fe==E&&ae==x;var ye=-1,ue=!0,Ne=N&S?new w:void 0;for(W.set(x,E),W.set(E,x);++ye<ie;){var Te=x[ye],_e=E[ye];if(L)var Xe=Y?L(_e,Te,ye,E,x,W):L(Te,_e,ye,x,E,W);if(Xe!==void 0){if(Xe)continue;ue=!1;break}if(Ne){if(!k(E,function(Se,Ge){if(!O(Ne,Ge)&&(Te===Se||P(Te,Se,N,L,W)))return Ne.push(Ge)})){ue=!1;break}}else if(!(Te===_e||P(Te,_e,N,L,W))){ue=!1;break}}return W.delete(x),W.delete(E),ue}se.exports=C},18351:function(se,ee,b){var w=b(62705),k=b(11149),O=b(77813),R=b(67114),S=b(68776),C=b(21814),x=1,E=2,N="[object Boolean]",L="[object Date]",P="[object Error]",W="[object Map]",Y="[object Number]",ie="[object RegExp]",pe="[object Set]",fe="[object String]",ae="[object Symbol]",ye="[object ArrayBuffer]",ue="[object DataView]",Ne=w?w.prototype:void 0,Te=Ne?Ne.valueOf:void 0;function _e(Xe,Se,Ge,He,vt,It,zt){switch(Ge){case ue:if(Xe.byteLength!=Se.byteLength||Xe.byteOffset!=Se.byteOffset)return!1;Xe=Xe.buffer,Se=Se.buffer;case ye:return!(Xe.byteLength!=Se.byteLength||!It(new k(Xe),new k(Se)));case N:case L:case Y:return O(+Xe,+Se);case P:return Xe.name==Se.name&&Xe.message==Se.message;case ie:case fe:return Xe==Se+"";case W:var Yt=S;case pe:var At=He&x;if(Yt||(Yt=C),Xe.size!=Se.size&&!At)return!1;var lt=zt.get(Xe);if(lt)return lt==Se;He|=E,zt.set(Xe,Se);var Ot=R(Yt(Xe),Yt(Se),He,vt,It,zt);return zt.delete(Xe),Ot;case ae:if(Te)return Te.call(Xe)==Te.call(Se)}return!1}se.exports=_e},16096:function(se,ee,b){var w=b(58234),k=1,O=Object.prototype,R=O.hasOwnProperty;function S(C,x,E,N,L,P){var W=E&k,Y=w(C),ie=Y.length,pe=w(x),fe=pe.length;if(ie!=fe&&!W)return!1;for(var ae=ie;ae--;){var ye=Y[ae];if(!(W?ye in x:R.call(x,ye)))return!1}var ue=P.get(C),Ne=P.get(x);if(ue&&Ne)return ue==x&&Ne==C;var Te=!0;P.set(C,x),P.set(x,C);for(var _e=W;++ae<ie;){ye=Y[ae];var Xe=C[ye],Se=x[ye];if(N)var Ge=W?N(Se,Xe,ye,x,C,P):N(Xe,Se,ye,C,x,P);if(!(Ge===void 0?Xe===Se||L(Xe,Se,E,N,P):Ge)){Te=!1;break}_e||(_e=ye=="constructor")}if(Te&&!_e){var He=C.constructor,vt=x.constructor;He!=vt&&"constructor"in C&&"constructor"in x&&!(typeof He=="function"&&He instanceof He&&typeof vt=="function"&&vt instanceof vt)&&(Te=!1)}return P.delete(C),P.delete(x),Te}se.exports=S},99021:function(se,ee,b){var w=b(85564),k=b(45357),O=b(30061);function R(S){return O(k(S,void 0,w),S+"")}se.exports=R},58234:function(se,ee,b){var w=b(64055),k=b(99551),O=b(3674);function R(S){return w(S,O,k)}se.exports=R},46904:function(se,ee,b){var w=b(64055),k=b(51442),O=b(81704);function R(S){return w(S,O,k)}se.exports=R},1499:function(se,ee,b){var w=b(89162),k=b(3674);function O(R){for(var S=k(R),C=S.length;C--;){var x=S[C],E=R[x];S[C]=[x,E,w(E)]}return S}se.exports=O},99551:function(se,ee,b){var w=b(34963),k=b(70479),O=Object.prototype,R=O.propertyIsEnumerable,S=Object.getOwnPropertySymbols,C=S?function(x){return x==null?[]:(x=Object(x),w(S(x),function(E){return R.call(x,E)}))}:k;se.exports=C},51442:function(se,ee,b){var w=b(62488),k=b(85924),O=b(99551),R=b(70479),S=Object.getOwnPropertySymbols,C=S?function(x){for(var E=[];x;)w(E,O(x)),x=k(x);return E}:R;se.exports=C},64160:function(se,ee,b){var w=b(18552),k=b(57071),O=b(53818),R=b(58525),S=b(70577),C=b(44239),x=b(80346),E="[object Map]",N="[object Object]",L="[object Promise]",P="[object Set]",W="[object WeakMap]",Y="[object DataView]",ie=x(w),pe=x(k),fe=x(O),ae=x(R),ye=x(S),ue=C;(w&&ue(new w(new ArrayBuffer(1)))!=Y||k&&ue(new k)!=E||O&&ue(O.resolve())!=L||R&&ue(new R)!=P||S&&ue(new S)!=W)&&(ue=function(Ne){var Te=C(Ne),_e=Te==N?Ne.constructor:void 0,Xe=_e?x(_e):"";if(Xe)switch(Xe){case ie:return Y;case pe:return E;case fe:return L;case ae:return P;case ye:return W}return Te}),se.exports=ue},222:function(se,ee,b){var w=b(71811),k=b(35694),O=b(1469),R=b(65776),S=b(41780),C=b(40327);function x(E,N,L){N=w(N,E);for(var P=-1,W=N.length,Y=!1;++P<W;){var ie=C(N[P]);if(!(Y=E!=null&&L(E,ie)))break;E=E[ie]}return Y||++P!=W?Y:(W=E==null?0:E.length,!!W&&S(W)&&R(ie,W)&&(O(E)||k(E)))}se.exports=x},62689:function(se){var ee="\\ud800-\\udfff",b="\\u0300-\\u036f",w="\\ufe20-\\ufe2f",k="\\u20d0-\\u20ff",O=b+w+k,R="\\ufe0e\\ufe0f",S="\\u200d",C=RegExp("["+S+ee+O+R+"]");function x(E){return C.test(E)}se.exports=x},43824:function(se){var ee=Object.prototype,b=ee.hasOwnProperty;function w(k){var O=k.length,R=new k.constructor(O);return O&&typeof k[0]=="string"&&b.call(k,"index")&&(R.index=k.index,R.input=k.input),R}se.exports=w},29148:function(se,ee,b){var w=b(74318),k=b(57157),O=b(93147),R=b(40419),S=b(77133),C="[object Boolean]",x="[object Date]",E="[object Map]",N="[object Number]",L="[object RegExp]",P="[object Set]",W="[object String]",Y="[object Symbol]",ie="[object ArrayBuffer]",pe="[object DataView]",fe="[object Float32Array]",ae="[object Float64Array]",ye="[object Int8Array]",ue="[object Int16Array]",Ne="[object Int32Array]",Te="[object Uint8Array]",_e="[object Uint8ClampedArray]",Xe="[object Uint16Array]",Se="[object Uint32Array]";function Ge(He,vt,It){var zt=He.constructor;switch(vt){case ie:return w(He);case C:case x:return new zt(+He);case pe:return k(He,It);case fe:case ae:case ye:case ue:case Ne:case Te:case _e:case Xe:case Se:return S(He,It);case E:return new zt;case N:case W:return new zt(He);case L:return O(He);case P:return new zt;case Y:return R(He)}}se.exports=Ge},37285:function(se,ee,b){var w=b(62705),k=b(35694),O=b(1469),R=w?w.isConcatSpreadable:void 0;function S(C){return O(C)||k(C)||!!(R&&C&&C[R])}se.exports=S},15403:function(se,ee,b){var w=b(1469),k=b(33448),O=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,R=/^\w*$/;function S(C,x){if(w(C))return!1;var E=typeof C;return E=="number"||E=="symbol"||E=="boolean"||C==null||k(C)?!0:R.test(C)||!O.test(C)||x!=null&&C in Object(x)}se.exports=S},89162:function(se,ee,b){var w=b(13218);function k(O){return O===O&&!w(O)}se.exports=k},68776:function(se){function ee(b){var w=-1,k=Array(b.size);return b.forEach(function(O,R){k[++w]=[R,O]}),k}se.exports=ee},42634:function(se){function ee(b,w){return function(k){return k==null?!1:k[b]===w&&(w!==void 0||b in Object(k))}}se.exports=ee},24523:function(se,ee,b){var w=b(88306),k=500;function O(R){var S=w(R,function(x){return C.size===k&&C.clear(),x}),C=S.cache;return S}se.exports=O},86916:function(se,ee,b){var w=b(5569),k=w(Object.keys,Object);se.exports=k},90619:function(se){var ee="__lodash_hash_undefined__";function b(w){return this.__data__.set(w,ee),this}se.exports=b},72385:function(se){function ee(b){return this.__data__.has(b)}se.exports=ee},21814:function(se){function ee(b){var w=-1,k=Array(b.size);return b.forEach(function(O){k[++w]=O}),k}se.exports=ee},42351:function(se){function ee(b,w,k){for(var O=k-1,R=b.length;++O<R;)if(b[O]===w)return O;return-1}se.exports=ee},88016:function(se,ee,b){var w=b(48983),k=b(62689),O=b(21903);function R(S){return k(S)?O(S):w(S)}se.exports=R},55514:function(se,ee,b){var w=b(24523),k=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,O=/\\(\\)?/g,R=w(function(S){var C=[];return S.charCodeAt(0)===46&&C.push(""),S.replace(k,function(x,E,N,L){C.push(N?L.replace(O,"$1"):E||x)}),C});se.exports=R},40327:function(se,ee,b){var w=b(33448),k=1/0;function O(R){if(typeof R=="string"||w(R))return R;var S=R+"";return S=="0"&&1/R==-k?"-0":S}se.exports=O},67990:function(se){var ee=/\s/;function b(w){for(var k=w.length;k--&&ee.test(w.charAt(k)););return k}se.exports=b},21903:function(se){var ee="\\ud800-\\udfff",b="\\u0300-\\u036f",w="\\ufe20-\\ufe2f",k="\\u20d0-\\u20ff",O=b+w+k,R="\\ufe0e\\ufe0f",S="["+ee+"]",C="["+O+"]",x="\\ud83c[\\udffb-\\udfff]",E="(?:"+C+"|"+x+")",N="[^"+ee+"]",L="(?:\\ud83c[\\udde6-\\uddff]){2}",P="[\\ud800-\\udbff][\\udc00-\\udfff]",W="\\u200d",Y=E+"?",ie="["+R+"]?",pe="(?:"+W+"(?:"+[N,L,P].join("|")+")"+ie+Y+")*",fe=ie+Y+pe,ae="(?:"+[N+C+"?",C,L,P,S].join("|")+")",ye=RegExp(x+"(?="+x+")|"+ae+fe,"g");function ue(Ne){for(var Te=ye.lastIndex=0;ye.test(Ne);)++Te;return Te}se.exports=ue},66678:function(se,ee,b){var w=b(85990),k=4;function O(R){return w(R,k)}se.exports=O},50361:function(se,ee,b){var w=b(85990),k=1,O=4;function R(S){return w(S,k|O)}se.exports=R},91747:function(se,ee,b){var w=b(18460),k=b(77813),O=b(16612),R=b(81704),S=Object.prototype,C=S.hasOwnProperty,x=w(function(E,N){E=Object(E);var L=-1,P=N.length,W=P>2?N[2]:void 0;for(W&&O(N[0],N[1],W)&&(P=1);++L<P;)for(var Y=N[L],ie=R(Y),pe=-1,fe=ie.length;++pe<fe;){var ae=ie[pe],ye=E[ae];(ye===void 0||k(ye,S[ae])&&!C.call(E,ae))&&(E[ae]=Y[ae])}return E});se.exports=x},85768:function(se,ee,b){se.exports=b(84486)},63105:function(se,ee,b){var w=b(34963),k=b(80760),O=b(67206),R=b(1469);function S(C,x){var E=R(C)?w:k;return E(C,O(x,3))}se.exports=S},13311:function(se,ee,b){var w=b(67740),k=b(30998),O=w(k);se.exports=O},30998:function(se,ee,b){var w=b(41848),k=b(67206),O=b(40554),R=Math.max;function S(C,x,E){var N=C==null?0:C.length;if(!N)return-1;var L=E==null?0:O(E);return L<0&&(L=R(N+L,0)),w(C,k(x,3),L)}se.exports=S},85564:function(se,ee,b){var w=b(21078);function k(O){var R=O==null?0:O.length;return R?w(O,1):[]}se.exports=k},84486:function(se,ee,b){var w=b(77412),k=b(89881),O=b(54290),R=b(1469);function S(C,x){var E=R(C)?w:k;return E(C,O(x))}se.exports=S},62620:function(se,ee,b){var w=b(28483),k=b(54290),O=b(81704);function R(S,C){return S==null?S:w(S,k(C),O)}se.exports=R},27361:function(se,ee,b){var w=b(97786);function k(O,R,S){var C=O==null?void 0:w(O,R);return C===void 0?S:C}se.exports=k},18721:function(se,ee,b){var w=b(78565),k=b(222);function O(R,S){return R!=null&&k(R,S,w)}se.exports=O},79095:function(se,ee,b){var w=b(13),k=b(222);function O(R,S){return R!=null&&k(R,S,w)}se.exports=O},58367:function(se,ee,b){var w=b(280),k=b(64160),O=b(35694),R=b(1469),S=b(98612),C=b(44144),x=b(25726),E=b(36719),N="[object Map]",L="[object Set]",P=Object.prototype,W=P.hasOwnProperty;function Y(ie){if(ie==null)return!0;if(S(ie)&&(R(ie)||typeof ie=="string"||typeof ie.splice=="function"||C(ie)||E(ie)||O(ie)))return!ie.length;var pe=k(ie);if(pe==N||pe==L)return!ie.size;if(x(ie))return!w(ie).length;for(var fe in ie)if(W.call(ie,fe))return!1;return!0}se.exports=Y},56688:function(se,ee,b){var w=b(25588),k=b(7518),O=b(31167),R=O&&O.isMap,S=R?k(R):w;se.exports=S},72928:function(se,ee,b){var w=b(29221),k=b(7518),O=b(31167),R=O&&O.isSet,S=R?k(R):w;se.exports=S},47037:function(se,ee,b){var w=b(44239),k=b(1469),O=b(37005),R="[object String]";function S(C){return typeof C=="string"||!k(C)&&O(C)&&w(C)==R}se.exports=S},33448:function(se,ee,b){var w=b(44239),k=b(37005),O="[object Symbol]";function R(S){return typeof S=="symbol"||k(S)&&w(S)==O}se.exports=R},52353:function(se){function ee(b){return b===void 0}se.exports=ee},3674:function(se,ee,b){var w=b(14636),k=b(280),O=b(98612);function R(S){return O(S)?w(S):k(S)}se.exports=R},10928:function(se){function ee(b){var w=b==null?0:b.length;return w?b[w-1]:void 0}se.exports=ee},35161:function(se,ee,b){var w=b(29932),k=b(67206),O=b(69199),R=b(1469);function S(C,x){var E=R(C)?w:O;return E(C,k(x,3))}se.exports=S},8521:function(se,ee,b){var w=b(89465),k=b(47816),O=b(67206);function R(S,C){var x={};return C=O(C,3),k(S,function(E,N,L){w(x,N,C(E,N,L))}),x}se.exports=R},6162:function(se,ee,b){var w=b(56029),k=b(53325),O=b(6557);function R(S){return S&&S.length?w(S,O,k):void 0}se.exports=R},88306:function(se,ee,b){var w=b(83369),k="Expected a function";function O(R,S){if(typeof R!="function"||S!=null&&typeof S!="function")throw new TypeError(k);var C=function(){var x=arguments,E=S?S.apply(this,x):x[0],N=C.cache;if(N.has(E))return N.get(E);var L=R.apply(this,x);return C.cache=N.set(E,L)||N,L};return C.cache=new(O.Cache||w),C}O.Cache=w,se.exports=O},53632:function(se,ee,b){var w=b(56029),k=b(70433),O=b(6557);function R(S){return S&&S.length?w(S,O,k):void 0}se.exports=R},22762:function(se,ee,b){var w=b(56029),k=b(67206),O=b(70433);function R(S,C){return S&&S.length?w(S,k(C,2),O):void 0}se.exports=R},50308:function(se){function ee(){}se.exports=ee},7771:function(se,ee,b){var w=b(55639),k=function(){return w.Date.now()};se.exports=k},78718:function(se,ee,b){var w=b(25970),k=b(99021),O=k(function(R,S){return R==null?{}:w(R,S)});se.exports=O},39601:function(se,ee,b){var w=b(40371),k=b(79152),O=b(15403),R=b(40327);function S(C){return O(C)?w(R(C)):k(C)}se.exports=S},96026:function(se,ee,b){var w=b(47445),k=w();se.exports=k},54061:function(se,ee,b){var w=b(62663),k=b(89881),O=b(67206),R=b(10107),S=b(1469);function C(x,E,N){var L=S(x)?w:R,P=arguments.length<3;return L(x,O(E,4),N,P,k)}se.exports=C},84238:function(se,ee,b){var w=b(280),k=b(64160),O=b(98612),R=b(47037),S=b(88016),C="[object Map]",x="[object Set]";function E(N){if(N==null)return 0;if(O(N))return R(N)?S(N):N.length;var L=k(N);return L==C||L==x?N.size:w(N).length}se.exports=E},89734:function(se,ee,b){var w=b(21078),k=b(82689),O=b(18460),R=b(16612),S=O(function(C,x){if(C==null)return[];var E=x.length;return E>1&&R(C,x[0],x[1])?x=[]:E>2&&R(x[0],x[1],x[2])&&(x=[x[0]]),k(C,w(x,1),[])});se.exports=S},70479:function(se){function ee(){return[]}se.exports=ee},18601:function(se,ee,b){var w=b(14841),k=1/0,O=17976931348623157e292;function R(S){if(!S)return S===0?S:0;if(S=w(S),S===k||S===-k){var C=S<0?-1:1;return C*O}return S===S?S:0}se.exports=R},40554:function(se,ee,b){var w=b(18601);function k(O){var R=w(O),S=R%1;return R===R?S?R-S:R:0}se.exports=k},14841:function(se,ee,b){var w=b(27561),k=b(13218),O=b(33448),R=NaN,S=/^[-+]0x[0-9a-f]+$/i,C=/^0b[01]+$/i,x=/^0o[0-7]+$/i,E=parseInt;function N(L){if(typeof L=="number")return L;if(O(L))return R;if(k(L)){var P=typeof L.valueOf=="function"?L.valueOf():L;L=k(P)?P+"":P}if(typeof L!="string")return L===0?L:+L;L=w(L);var W=C.test(L);return W||x.test(L)?E(L.slice(2),W?2:8):S.test(L)?R:+L}se.exports=N},79833:function(se,ee,b){var w=b(80531);function k(O){return O==null?"":w(O)}se.exports=k},68718:function(se,ee,b){var w=b(77412),k=b(3118),O=b(47816),R=b(67206),S=b(85924),C=b(1469),x=b(44144),E=b(23560),N=b(13218),L=b(36719);function P(W,Y,ie){var pe=C(W),fe=pe||x(W)||L(W);if(Y=R(Y,4),ie==null){var ae=W&&W.constructor;fe?ie=pe?new ae:[]:N(W)?ie=E(ae)?k(S(W)):{}:ie={}}return(fe?w:O)(W,function(ye,ue,Ne){return Y(ie,ye,ue,Ne)}),ie}se.exports=P},93386:function(se,ee,b){var w=b(21078),k=b(18460),O=b(45652),R=b(29246),S=k(function(C){return O(w(C,1,R,!0))});se.exports=S},73955:function(se,ee,b){var w=b(79833),k=0;function O(R){var S=++k;return w(R)+S}se.exports=O},52628:function(se,ee,b){var w=b(47415),k=b(3674);function O(R){return R==null?[]:w(R,k(R))}se.exports=O},7287:function(se,ee,b){var w=b(34865),k=b(1757);function O(R,S){return k(R||[],S||[],w)}se.exports=O},75823:function(se,ee,b){"use strict";b.r(ee),b.d(ee,{default:function(){return R}});var w=b(44091);function k(S){var C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!(0,w.isAnyArray)(S))throw new TypeError("input must be an array");if(S.length===0)throw new TypeError("input must not be empty");var x=C.fromIndex,E=x===void 0?0:x,N=C.toIndex,L=N===void 0?S.length:N;if(E<0||E>=S.length||!Number.isInteger(E))throw new Error("fromIndex must be a positive integer smaller than length");if(L<=E||L>S.length||!Number.isInteger(L))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var P=S[E],W=E+1;W<L;W++)S[W]>P&&(P=S[W]);return P}function O(S){var C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!(0,w.isAnyArray)(S))throw new TypeError("input must be an array");if(S.length===0)throw new TypeError("input must not be empty");var x=C.fromIndex,E=x===void 0?0:x,N=C.toIndex,L=N===void 0?S.length:N;if(E<0||E>=S.length||!Number.isInteger(E))throw new Error("fromIndex must be a positive integer smaller than length");if(L<=E||L>S.length||!Number.isInteger(L))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var P=S[E],W=E+1;W<L;W++)S[W]<P&&(P=S[W]);return P}function R(S){var C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if((0,w.isAnyArray)(S)){if(S.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var x;if(C.output!==void 0){if(!(0,w.isAnyArray)(C.output))throw new TypeError("output option must be an array if specified");x=C.output}else x=new Array(S.length);var E=O(S),N=k(S);if(E===N)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var L=C.min,P=L===void 0?C.autoMinMax?E:0:L,W=C.max,Y=W===void 0?C.autoMinMax?N:1:W;if(P>=Y)throw new RangeError("min option must be smaller than max option");for(var ie=(Y-P)/(N-E),pe=0;pe<S.length;pe++)x[pe]=(S[pe]-E)*ie+P;return x}},16505:function(se,ee,b){se.exports=k,se.exports.simulator=b(45818);var w=b(77797);function k(R,S){if(!R)throw new Error("Graph structure cannot be undefined");var C=S&&S.createSimulator||b(45818),x=C(S);if(Array.isArray(S))throw new Error("Physics settings is expected to be an object");var E=R.version>19?Ot:lt;S&&typeof S.nodeMass=="function"&&(E=S.nodeMass);var N=new Map,L={},P=0,W=x.settings.springTransform||O;Xe(),Ne();var Y=!1,ie={step:function(){if(P===0)return pe(!0),!0;var le=x.step();ie.lastMove=le,ie.fire("step");var Fe=le/P,gt=Fe<=.01;return pe(gt),gt},getNodePosition:function(le){return At(le).pos},setNodePosition:function(le){var Fe=At(le);Fe.setPosition.apply(Fe,Array.prototype.slice.call(arguments,1))},getLinkPosition:function(le){var Fe=L[le];if(Fe)return{from:Fe.from.pos,to:Fe.to.pos}},getGraphRect:function(){return x.getBBox()},forEachBody:fe,pinNode:function(le,Fe){var gt=At(le.id);gt.isPinned=!!Fe},isNodePinned:function(le){return At(le.id).isPinned},dispose:function(){R.off("changed",_e),ie.fire("disposed")},getBody:ue,getSpring:ye,getForceVectorLength:ae,simulator:x,graph:R,lastMove:0};return w(ie),ie;function pe(le){Y!==le&&(Y=le,Te(le))}function fe(le){N.forEach(le)}function ae(){var le=0,Fe=0;return fe(function(gt){le+=Math.abs(gt.force.x),Fe+=Math.abs(gt.force.y)}),Math.sqrt(le*le+Fe*Fe)}function ye(le,Fe){var gt;if(Fe===void 0)typeof le!="object"?gt=le:gt=le.id;else{var Jt=R.hasLink(le,Fe);if(!Jt)return;gt=Jt.id}return L[gt]}function ue(le){return N.get(le)}function Ne(){R.on("changed",_e)}function Te(le){ie.fire("stable",le)}function _e(le){for(var Fe=0;Fe<le.length;++Fe){var gt=le[Fe];gt.changeType==="add"?(gt.node&&Se(gt.node.id),gt.link&&He(gt.link)):gt.changeType==="remove"&&(gt.node&&Ge(gt.node),gt.link&&vt(gt.link))}P=R.getNodesCount()}function Xe(){P=0,R.forEachNode(function(le){Se(le.id),P+=1}),R.forEachLink(He)}function Se(le){var Fe=N.get(le);if(!Fe){var gt=R.getNode(le);if(!gt)throw new Error("initBody() was called with unknown node id");var Jt=gt.position;if(!Jt){var Ze=It(gt);Jt=x.getBestNewBodyPosition(Ze)}Fe=x.addBodyAt(Jt),Fe.id=le,N.set(le,Fe),zt(le),Yt(gt)&&(Fe.isPinned=!0)}}function Ge(le){var Fe=le.id,gt=N.get(Fe);gt&&(N.delete(Fe),x.removeBody(gt))}function He(le){zt(le.fromId),zt(le.toId);var Fe=N.get(le.fromId),gt=N.get(le.toId),Jt=x.addSpring(Fe,gt,le.length);W(le,Jt),L[le.id]=Jt}function vt(le){var Fe=L[le.id];if(Fe){var gt=R.getNode(le.fromId),Jt=R.getNode(le.toId);gt&&zt(gt.id),Jt&&zt(Jt.id),delete L[le.id],x.removeSpring(Fe)}}function It(le){var Fe=[];if(!le.links)return Fe;for(var gt=Math.min(le.links.length,2),Jt=0;Jt<gt;++Jt){var Ze=le.links[Jt],rt=Ze.fromId!==le.id?N.get(Ze.fromId):N.get(Ze.toId);rt&&rt.pos&&Fe.push(rt)}return Fe}function zt(le){var Fe=N.get(le);if(Fe.mass=E(le),Number.isNaN(Fe.mass))throw new Error("Node mass should be a number")}function Yt(le){return le&&(le.isPinned||le.data&&le.data.isPinned)}function At(le){var Fe=N.get(le);return Fe||(Se(le),Fe=N.get(le)),Fe}function lt(le){var Fe=R.getLinks(le);return Fe?1+Fe.length/3:1}function Ot(le){var Fe=R.getLinks(le);return Fe?1+Fe.size/3:1}}function O(){}},15189:function(se,ee,b){const w=b(16422);se.exports=function(O){return R;function R(S,C){let x=C&&C.indent||0,E=C&&C.join!==void 0?C.join:`
|
|
|
`,N=Array(x+1).join(" "),L=[];for(let P=0;P<O;++P){let W=w(P),Y=P===0?"":N;L.push(Y+S.replace(/{var}/g,W))}return L.join(E)}}},30891:function(se,ee,b){se.exports=k,se.exports.generateFunctionBody=O;const w=b(15189);function k(R){let S=O(R);return new Function("bodies","settings","random",S)}function O(R){let S=w(R);return`
|
|
|
var boundingBox = {
|
|
|
${S("min_{var}: 0, max_{var}: 0,",{indent:4})}
|
|
|
};
|
|
|
|
|
|
return {
|
|
|
box: boundingBox,
|
|
|
|
|
|
update: updateBoundingBox,
|
|
|
|
|
|
reset: resetBoundingBox,
|
|
|
|
|
|
getBestNewPosition: function (neighbors) {
|
|
|
var ${S("base_{var} = 0",{join:", "})};
|
|
|
|
|
|
if (neighbors.length) {
|
|
|
for (var i = 0; i < neighbors.length; ++i) {
|
|
|
let neighborPos = neighbors[i].pos;
|
|
|
${S("base_{var} += neighborPos.{var};",{indent:10})}
|
|
|
}
|
|
|
|
|
|
${S("base_{var} /= neighbors.length;",{indent:8})}
|
|
|
} else {
|
|
|
${S("base_{var} = (boundingBox.min_{var} + boundingBox.max_{var}) / 2;",{indent:8})}
|
|
|
}
|
|
|
|
|
|
var springLength = settings.springLength;
|
|
|
return {
|
|
|
${S("{var}: base_{var} + (random.nextDouble() - 0.5) * springLength,",{indent:8})}
|
|
|
};
|
|
|
}
|
|
|
};
|
|
|
|
|
|
function updateBoundingBox() {
|
|
|
var i = bodies.length;
|
|
|
if (i === 0) return; // No bodies - no borders.
|
|
|
|
|
|
${S("var max_{var} = -Infinity;",{indent:4})}
|
|
|
${S("var min_{var} = Infinity;",{indent:4})}
|
|
|
|
|
|
while(i--) {
|
|
|
// this is O(n), it could be done faster with quadtree, if we check the root node bounds
|
|
|
var bodyPos = bodies[i].pos;
|
|
|
${S("if (bodyPos.{var} < min_{var}) min_{var} = bodyPos.{var};",{indent:6})}
|
|
|
${S("if (bodyPos.{var} > max_{var}) max_{var} = bodyPos.{var};",{indent:6})}
|
|
|
}
|
|
|
|
|
|
${S("boundingBox.min_{var} = min_{var};",{indent:4})}
|
|
|
${S("boundingBox.max_{var} = max_{var};",{indent:4})}
|
|
|
}
|
|
|
|
|
|
function resetBoundingBox() {
|
|
|
${S("boundingBox.min_{var} = boundingBox.max_{var} = 0;",{indent:4})}
|
|
|
}
|
|
|
`}},6410:function(se,ee,b){const w=b(15189);se.exports=k,se.exports.generateCreateBodyFunctionBody=O,se.exports.getVectorCode=S,se.exports.getBodyCode=R;function k(C,x){let E=O(C,x),{Body:N}=new Function(E)();return N}function O(C,x){return`
|
|
|
${S(C,x)}
|
|
|
${R(C,x)}
|
|
|
return {Body: Body, Vector: Vector};
|
|
|
`}function R(C){let x=w(C),E=x("{var}",{join:", "});return`
|
|
|
function Body(${E}) {
|
|
|
this.isPinned = false;
|
|
|
this.pos = new Vector(${E});
|
|
|
this.force = new Vector();
|
|
|
this.velocity = new Vector();
|
|
|
this.mass = 1;
|
|
|
|
|
|
this.springCount = 0;
|
|
|
this.springLength = 0;
|
|
|
}
|
|
|
|
|
|
Body.prototype.reset = function() {
|
|
|
this.force.reset();
|
|
|
this.springCount = 0;
|
|
|
this.springLength = 0;
|
|
|
}
|
|
|
|
|
|
Body.prototype.setPosition = function (${E}) {
|
|
|
${x("this.pos.{var} = {var} || 0;",{indent:2})}
|
|
|
};`}function S(C,x){let E=w(C),N="";return x&&(N=`${E(`
|
|
|
var v{var};
|
|
|
Object.defineProperty(this, '{var}', {
|
|
|
set: function(v) {
|
|
|
if (!Number.isFinite(v)) throw new Error('Cannot set non-numbers to {var}');
|
|
|
v{var} = v;
|
|
|
},
|
|
|
get: function() { return v{var}; }
|
|
|
});`)}`),`function Vector(${E("{var}",{join:", "})}) {
|
|
|
${N}
|
|
|
if (typeof arguments[0] === 'object') {
|
|
|
// could be another vector
|
|
|
let v = arguments[0];
|
|
|
${E('if (!Number.isFinite(v.{var})) throw new Error("Expected value is not a finite number at Vector constructor ({var})");',{indent:4})}
|
|
|
${E("this.{var} = v.{var};",{indent:4})}
|
|
|
} else {
|
|
|
${E('this.{var} = typeof {var} === "number" ? {var} : 0;',{indent:4})}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Vector.prototype.reset = function () {
|
|
|
${E("this.{var} = ",{join:""})}0;
|
|
|
};`}},36647:function(se,ee,b){const w=b(15189);se.exports=k,se.exports.generateCreateDragForceFunctionBody=O;function k(R){let S=O(R);return new Function("options",S)}function O(R){return`
|
|
|
if (!Number.isFinite(options.dragCoefficient)) throw new Error('dragCoefficient is not a finite number');
|
|
|
|
|
|
return {
|
|
|
update: function(body) {
|
|
|
${w(R)("body.force.{var} -= options.dragCoefficient * body.velocity.{var};",{indent:6})}
|
|
|
}
|
|
|
};
|
|
|
`}},34079:function(se,ee,b){const w=b(15189);se.exports=k,se.exports.generateCreateSpringForceFunctionBody=O;function k(R){let S=O(R);return new Function("options","random",S)}function O(R){let S=w(R);return`
|
|
|
if (!Number.isFinite(options.springCoefficient)) throw new Error('Spring coefficient is not a number');
|
|
|
if (!Number.isFinite(options.springLength)) throw new Error('Spring length is not a number');
|
|
|
|
|
|
return {
|
|
|
/**
|
|
|
* Updates forces acting on a spring
|
|
|
*/
|
|
|
update: function (spring) {
|
|
|
var body1 = spring.from;
|
|
|
var body2 = spring.to;
|
|
|
var length = spring.length < 0 ? options.springLength : spring.length;
|
|
|
${S("var d{var} = body2.pos.{var} - body1.pos.{var};",{indent:6})}
|
|
|
var r = Math.sqrt(${S("d{var} * d{var}",{join:" + "})});
|
|
|
|
|
|
if (r === 0) {
|
|
|
${S("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:8})}
|
|
|
r = Math.sqrt(${S("d{var} * d{var}",{join:" + "})});
|
|
|
}
|
|
|
|
|
|
var d = r - length;
|
|
|
var coefficient = ((spring.coefficient > 0) ? spring.coefficient : options.springCoefficient) * d / r;
|
|
|
|
|
|
${S("body1.force.{var} += coefficient * d{var}",{indent:6})};
|
|
|
body1.springCount += 1;
|
|
|
body1.springLength += r;
|
|
|
|
|
|
${S("body2.force.{var} -= coefficient * d{var}",{indent:6})};
|
|
|
body2.springCount += 1;
|
|
|
body2.springLength += r;
|
|
|
}
|
|
|
};
|
|
|
`}},51763:function(se,ee,b){const w=b(15189);se.exports=k,se.exports.generateIntegratorFunctionBody=O;function k(R){let S=O(R);return new Function("bodies","timeStep","adaptiveTimeStepWeight",S)}function O(R){let S=w(R);return`
|
|
|
var length = bodies.length;
|
|
|
if (length === 0) return 0;
|
|
|
|
|
|
${S("var d{var} = 0, t{var} = 0;",{indent:2})}
|
|
|
|
|
|
for (var i = 0; i < length; ++i) {
|
|
|
var body = bodies[i];
|
|
|
if (body.isPinned) continue;
|
|
|
|
|
|
if (adaptiveTimeStepWeight && body.springCount) {
|
|
|
timeStep = (adaptiveTimeStepWeight * body.springLength/body.springCount);
|
|
|
}
|
|
|
|
|
|
var coeff = timeStep / body.mass;
|
|
|
|
|
|
${S("body.velocity.{var} += coeff * body.force.{var};",{indent:4})}
|
|
|
${S("var v{var} = body.velocity.{var};",{indent:4})}
|
|
|
var v = Math.sqrt(${S("v{var} * v{var}",{join:" + "})});
|
|
|
|
|
|
if (v > 1) {
|
|
|
// We normalize it so that we move within timeStep range.
|
|
|
// for the case when v <= 1 - we let velocity to fade out.
|
|
|
${S("body.velocity.{var} = v{var} / v;",{indent:6})}
|
|
|
}
|
|
|
|
|
|
${S("d{var} = timeStep * body.velocity.{var};",{indent:4})}
|
|
|
|
|
|
${S("body.pos.{var} += d{var};",{indent:4})}
|
|
|
|
|
|
${S("t{var} += Math.abs(d{var});",{indent:4})}
|
|
|
}
|
|
|
|
|
|
return (${S("t{var} * t{var}",{join:" + "})})/length;
|
|
|
`}},1584:function(se,ee,b){const w=b(15189),k=b(16422);se.exports=O,se.exports.generateQuadTreeFunctionBody=R,se.exports.getInsertStackCode=N,se.exports.getQuadNodeCode=E,se.exports.isSamePosition=S,se.exports.getChildBodyCode=x,se.exports.setChildBodyCode=C;function O(L){let P=R(L);return new Function(P)()}function R(L){let P=w(L),W=Math.pow(2,L);return`
|
|
|
${N()}
|
|
|
${E(L)}
|
|
|
${S(L)}
|
|
|
${x(L)}
|
|
|
${C(L)}
|
|
|
|
|
|
function createQuadTree(options, random) {
|
|
|
options = options || {};
|
|
|
options.gravity = typeof options.gravity === 'number' ? options.gravity : -1;
|
|
|
options.theta = typeof options.theta === 'number' ? options.theta : 0.8;
|
|
|
|
|
|
var gravity = options.gravity;
|
|
|
var updateQueue = [];
|
|
|
var insertStack = new InsertStack();
|
|
|
var theta = options.theta;
|
|
|
|
|
|
var nodesCache = [];
|
|
|
var currentInCache = 0;
|
|
|
var root = newNode();
|
|
|
|
|
|
return {
|
|
|
insertBodies: insertBodies,
|
|
|
|
|
|
/**
|
|
|
* Gets root node if it is present
|
|
|
*/
|
|
|
getRoot: function() {
|
|
|
return root;
|
|
|
},
|
|
|
|
|
|
updateBodyForce: update,
|
|
|
|
|
|
options: function(newOptions) {
|
|
|
if (newOptions) {
|
|
|
if (typeof newOptions.gravity === 'number') {
|
|
|
gravity = newOptions.gravity;
|
|
|
}
|
|
|
if (typeof newOptions.theta === 'number') {
|
|
|
theta = newOptions.theta;
|
|
|
}
|
|
|
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
gravity: gravity,
|
|
|
theta: theta
|
|
|
};
|
|
|
}
|
|
|
};
|
|
|
|
|
|
function newNode() {
|
|
|
// To avoid pressure on GC we reuse nodes.
|
|
|
var node = nodesCache[currentInCache];
|
|
|
if (node) {
|
|
|
${fe(" node.")}
|
|
|
node.body = null;
|
|
|
node.mass = ${P("node.mass_{var} = ",{join:""})}0;
|
|
|
${P("node.min_{var} = node.max_{var} = ",{join:""})}0;
|
|
|
} else {
|
|
|
node = new QuadNode();
|
|
|
nodesCache[currentInCache] = node;
|
|
|
}
|
|
|
|
|
|
++currentInCache;
|
|
|
return node;
|
|
|
}
|
|
|
|
|
|
function update(sourceBody) {
|
|
|
var queue = updateQueue;
|
|
|
var v;
|
|
|
${P("var d{var};",{indent:4})}
|
|
|
var r;
|
|
|
${P("var f{var} = 0;",{indent:4})}
|
|
|
var queueLength = 1;
|
|
|
var shiftIdx = 0;
|
|
|
var pushIdx = 1;
|
|
|
|
|
|
queue[0] = root;
|
|
|
|
|
|
while (queueLength) {
|
|
|
var node = queue[shiftIdx];
|
|
|
var body = node.body;
|
|
|
|
|
|
queueLength -= 1;
|
|
|
shiftIdx += 1;
|
|
|
var differentBody = (body !== sourceBody);
|
|
|
if (body && differentBody) {
|
|
|
// If the current node is a leaf node (and it is not source body),
|
|
|
// calculate the force exerted by the current node on body, and add this
|
|
|
// amount to body's net force.
|
|
|
${P("d{var} = body.pos.{var} - sourceBody.pos.{var};",{indent:8})}
|
|
|
r = Math.sqrt(${P("d{var} * d{var}",{join:" + "})});
|
|
|
|
|
|
if (r === 0) {
|
|
|
// Poor man's protection against zero distance.
|
|
|
${P("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:10})}
|
|
|
r = Math.sqrt(${P("d{var} * d{var}",{join:" + "})});
|
|
|
}
|
|
|
|
|
|
// This is standard gravitation force calculation but we divide
|
|
|
// by r^3 to save two operations when normalizing force vector.
|
|
|
v = gravity * body.mass * sourceBody.mass / (r * r * r);
|
|
|
${P("f{var} += v * d{var};",{indent:8})}
|
|
|
} else if (differentBody) {
|
|
|
// Otherwise, calculate the ratio s / r, where s is the width of the region
|
|
|
// represented by the internal node, and r is the distance between the body
|
|
|
// and the node's center-of-mass
|
|
|
${P("d{var} = node.mass_{var} / node.mass - sourceBody.pos.{var};",{indent:8})}
|
|
|
r = Math.sqrt(${P("d{var} * d{var}",{join:" + "})});
|
|
|
|
|
|
if (r === 0) {
|
|
|
// Sorry about code duplication. I don't want to create many functions
|
|
|
// right away. Just want to see performance first.
|
|
|
${P("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:10})}
|
|
|
r = Math.sqrt(${P("d{var} * d{var}",{join:" + "})});
|
|
|
}
|
|
|
// If s / r < \u03B8, treat this internal node as a single body, and calculate the
|
|
|
// force it exerts on sourceBody, and add this amount to sourceBody's net force.
|
|
|
if ((node.max_${k(0)} - node.min_${k(0)}) / r < theta) {
|
|
|
// in the if statement above we consider node's width only
|
|
|
// because the region was made into square during tree creation.
|
|
|
// Thus there is no difference between using width or height.
|
|
|
v = gravity * node.mass * sourceBody.mass / (r * r * r);
|
|
|
${P("f{var} += v * d{var};",{indent:10})}
|
|
|
} else {
|
|
|
// Otherwise, run the procedure recursively on each of the current node's children.
|
|
|
|
|
|
// I intentionally unfolded this loop, to save several CPU cycles.
|
|
|
${pe()}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
${P("sourceBody.force.{var} += f{var};",{indent:4})}
|
|
|
}
|
|
|
|
|
|
function insertBodies(bodies) {
|
|
|
${P("var {var}min = Number.MAX_VALUE;",{indent:4})}
|
|
|
${P("var {var}max = Number.MIN_VALUE;",{indent:4})}
|
|
|
var i = bodies.length;
|
|
|
|
|
|
// To reduce quad tree depth we are looking for exact bounding box of all particles.
|
|
|
while (i--) {
|
|
|
var pos = bodies[i].pos;
|
|
|
${P("if (pos.{var} < {var}min) {var}min = pos.{var};",{indent:6})}
|
|
|
${P("if (pos.{var} > {var}max) {var}max = pos.{var};",{indent:6})}
|
|
|
}
|
|
|
|
|
|
// Makes the bounds square.
|
|
|
var maxSideLength = -Infinity;
|
|
|
${P("if ({var}max - {var}min > maxSideLength) maxSideLength = {var}max - {var}min ;",{indent:4})}
|
|
|
|
|
|
currentInCache = 0;
|
|
|
root = newNode();
|
|
|
${P("root.min_{var} = {var}min;",{indent:4})}
|
|
|
${P("root.max_{var} = {var}min + maxSideLength;",{indent:4})}
|
|
|
|
|
|
i = bodies.length - 1;
|
|
|
if (i >= 0) {
|
|
|
root.body = bodies[i];
|
|
|
}
|
|
|
while (i--) {
|
|
|
insert(bodies[i], root);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function insert(newBody) {
|
|
|
insertStack.reset();
|
|
|
insertStack.push(root, newBody);
|
|
|
|
|
|
while (!insertStack.isEmpty()) {
|
|
|
var stackItem = insertStack.pop();
|
|
|
var node = stackItem.node;
|
|
|
var body = stackItem.body;
|
|
|
|
|
|
if (!node.body) {
|
|
|
// This is internal node. Update the total mass of the node and center-of-mass.
|
|
|
${P("var {var} = body.pos.{var};",{indent:8})}
|
|
|
node.mass += body.mass;
|
|
|
${P("node.mass_{var} += body.mass * {var};",{indent:8})}
|
|
|
|
|
|
// Recursively insert the body in the appropriate quadrant.
|
|
|
// But first find the appropriate quadrant.
|
|
|
var quadIdx = 0; // Assume we are in the 0's quad.
|
|
|
${P("var min_{var} = node.min_{var};",{indent:8})}
|
|
|
${P("var max_{var} = (min_{var} + node.max_{var}) / 2;",{indent:8})}
|
|
|
|
|
|
${ie(8)}
|
|
|
|
|
|
var child = getChild(node, quadIdx);
|
|
|
|
|
|
if (!child) {
|
|
|
// The node is internal but this quadrant is not taken. Add
|
|
|
// subnode to it.
|
|
|
child = newNode();
|
|
|
${P("child.min_{var} = min_{var};",{indent:10})}
|
|
|
${P("child.max_{var} = max_{var};",{indent:10})}
|
|
|
child.body = body;
|
|
|
|
|
|
setChild(node, quadIdx, child);
|
|
|
} else {
|
|
|
// continue searching in this quadrant.
|
|
|
insertStack.push(child, body);
|
|
|
}
|
|
|
} else {
|
|
|
// We are trying to add to the leaf node.
|
|
|
// We have to convert current leaf into internal node
|
|
|
// and continue adding two nodes.
|
|
|
var oldBody = node.body;
|
|
|
node.body = null; // internal nodes do not cary bodies
|
|
|
|
|
|
if (isSamePosition(oldBody.pos, body.pos)) {
|
|
|
// Prevent infinite subdivision by bumping one node
|
|
|
// anywhere in this quadrant
|
|
|
var retriesCount = 3;
|
|
|
do {
|
|
|
var offset = random.nextDouble();
|
|
|
${P("var d{var} = (node.max_{var} - node.min_{var}) * offset;",{indent:12})}
|
|
|
|
|
|
${P("oldBody.pos.{var} = node.min_{var} + d{var};",{indent:12})}
|
|
|
retriesCount -= 1;
|
|
|
// Make sure we don't bump it out of the box. If we do, next iteration should fix it
|
|
|
} while (retriesCount > 0 && isSamePosition(oldBody.pos, body.pos));
|
|
|
|
|
|
if (retriesCount === 0 && isSamePosition(oldBody.pos, body.pos)) {
|
|
|
// This is very bad, we ran out of precision.
|
|
|
// if we do not return from the method we'll get into
|
|
|
// infinite loop here. So we sacrifice correctness of layout, and keep the app running
|
|
|
// Next layout iteration should get larger bounding box in the first step and fix this
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
// Next iteration should subdivide node further.
|
|
|
insertStack.push(node, oldBody);
|
|
|
insertStack.push(node, body);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return createQuadTree;
|
|
|
|
|
|
`;function ie(ae){let ye=[],ue=Array(ae+1).join(" ");for(let Ne=0;Ne<L;++Ne)ye.push(ue+`if (${k(Ne)} > max_${k(Ne)}) {`),ye.push(ue+` quadIdx = quadIdx + ${Math.pow(2,Ne)};`),ye.push(ue+` min_${k(Ne)} = max_${k(Ne)};`),ye.push(ue+` max_${k(Ne)} = node.max_${k(Ne)};`),ye.push(ue+"}");return ye.join(`
|
|
|
`)}function pe(){let ae=Array(11).join(" "),ye=[];for(let ue=0;ue<W;++ue)ye.push(ae+`if (node.quad${ue}) {`),ye.push(ae+` queue[pushIdx] = node.quad${ue};`),ye.push(ae+" queueLength += 1;"),ye.push(ae+" pushIdx += 1;"),ye.push(ae+"}");return ye.join(`
|
|
|
`)}function fe(ae){let ye=[];for(let ue=0;ue<W;++ue)ye.push(`${ae}quad${ue} = null;`);return ye.join(`
|
|
|
`)}}function S(L){let P=w(L);return`
|
|
|
function isSamePosition(point1, point2) {
|
|
|
${P("var d{var} = Math.abs(point1.{var} - point2.{var});",{indent:2})}
|
|
|
|
|
|
return ${P("d{var} < 1e-8",{join:" && "})};
|
|
|
}
|
|
|
`}function C(L){var P=Math.pow(2,L);return`
|
|
|
function setChild(node, idx, child) {
|
|
|
${W()}
|
|
|
}`;function W(){let Y=[];for(let ie=0;ie<P;++ie){let pe=ie===0?" ":" else ";Y.push(`${pe}if (idx === ${ie}) node.quad${ie} = child;`)}return Y.join(`
|
|
|
`)}}function x(L){return`function getChild(node, idx) {
|
|
|
${P()}
|
|
|
return null;
|
|
|
}`;function P(){let W=[],Y=Math.pow(2,L);for(let ie=0;ie<Y;++ie)W.push(` if (idx === ${ie}) return node.quad${ie};`);return W.join(`
|
|
|
`)}}function E(L){let P=w(L),W=Math.pow(2,L);var Y=`
|
|
|
function QuadNode() {
|
|
|
// body stored inside this node. In quad tree only leaf nodes (by construction)
|
|
|
// contain bodies:
|
|
|
this.body = null;
|
|
|
|
|
|
// Child nodes are stored in quads. Each quad is presented by number:
|
|
|
// 0 | 1
|
|
|
// -----
|
|
|
// 2 | 3
|
|
|
${ie(" this.")}
|
|
|
|
|
|
// Total mass of current node
|
|
|
this.mass = 0;
|
|
|
|
|
|
// Center of mass coordinates
|
|
|
${P("this.mass_{var} = 0;",{indent:2})}
|
|
|
|
|
|
// bounding box coordinates
|
|
|
${P("this.min_{var} = 0;",{indent:2})}
|
|
|
${P("this.max_{var} = 0;",{indent:2})}
|
|
|
}
|
|
|
`;return Y;function ie(pe){let fe=[];for(let ae=0;ae<W;++ae)fe.push(`${pe}quad${ae} = null;`);return fe.join(`
|
|
|
`)}}function N(){return`
|
|
|
/**
|
|
|
* Our implementation of QuadTree is non-recursive to avoid GC hit
|
|
|
* This data structure represent stack of elements
|
|
|
* which we are trying to insert into quad tree.
|
|
|
*/
|
|
|
function InsertStack () {
|
|
|
this.stack = [];
|
|
|
this.popIdx = 0;
|
|
|
}
|
|
|
|
|
|
InsertStack.prototype = {
|
|
|
isEmpty: function() {
|
|
|
return this.popIdx === 0;
|
|
|
},
|
|
|
push: function (node, body) {
|
|
|
var item = this.stack[this.popIdx];
|
|
|
if (!item) {
|
|
|
// we are trying to avoid memory pressure: create new element
|
|
|
// only when absolutely necessary
|
|
|
this.stack[this.popIdx] = new InsertStackElement(node, body);
|
|
|
} else {
|
|
|
item.node = node;
|
|
|
item.body = body;
|
|
|
}
|
|
|
++this.popIdx;
|
|
|
},
|
|
|
pop: function () {
|
|
|
if (this.popIdx > 0) {
|
|
|
return this.stack[--this.popIdx];
|
|
|
}
|
|
|
},
|
|
|
reset: function () {
|
|
|
this.popIdx = 0;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
function InsertStackElement(node, body) {
|
|
|
this.node = node; // QuadTree node
|
|
|
this.body = body; // physical body which needs to be inserted to node
|
|
|
}
|
|
|
`}},16422:function(se){se.exports=function(b){return b===0?"x":b===1?"y":b===2?"z":"c"+(b+1)}},45818:function(se,ee,b){se.exports=E;var w=b(6410),k=b(1584),O=b(30891),R=b(36647),S=b(34079),C=b(51763),x={};function E(P){var W=b(68403),Y=b(35510),ie=b(77797);if(P){if(P.springCoeff!==void 0)throw new Error("springCoeff was renamed to springCoefficient");if(P.dragCoeff!==void 0)throw new Error("dragCoeff was renamed to dragCoefficient")}P=Y(P,{springLength:10,springCoefficient:.8,gravity:-12,theta:.8,dragCoefficient:.9,timeStep:.5,adaptiveTimeStepWeight:0,dimensions:2,debug:!1});var pe=x[P.dimensions];if(!pe){var fe=P.dimensions;pe={Body:w(fe,P.debug),createQuadTree:k(fe),createBounds:O(fe),createDragForce:R(fe),createSpringForce:S(fe),integrate:C(fe)},x[fe]=pe}var ae=pe.Body,ye=pe.createQuadTree,ue=pe.createBounds,Ne=pe.createDragForce,Te=pe.createSpringForce,_e=pe.integrate,Xe=Ye=>new ae(Ye),Se=b(78712).random(42),Ge=[],He=[],vt=ye(P,Se),It=ue(Ge,P,Se),zt=Te(P,Se),Yt=Ne(P),At=0,lt=[],Ot=new Map,le=0;Jt("nbody",Mt),Jt("spring",Ue);var Fe={bodies:Ge,quadTree:vt,springs:He,settings:P,addForce:Jt,removeForce:Ze,getForces:rt,step:function(){for(var Ye=0;Ye<lt.length;++Ye)lt[Ye](le);var be=_e(Ge,P.timeStep,P.adaptiveTimeStepWeight);return le+=1,be},addBody:function(Ye){if(!Ye)throw new Error("Body is required");return Ge.push(Ye),Ye},addBodyAt:function(Ye){if(!Ye)throw new Error("Body position is required");var be=Xe(Ye);return Ge.push(be),be},removeBody:function(Ye){if(Ye){var be=Ge.indexOf(Ye);if(!(be<0))return Ge.splice(be,1),Ge.length===0&&It.reset(),!0}},addSpring:function(Ye,be,ge,Ke){if(!Ye||!be)throw new Error("Cannot add null spring to force simulator");typeof ge!="number"&&(ge=-1);var wt=new W(Ye,be,ge,Ke>=0?Ke:-1);return He.push(wt),wt},getTotalMovement:function(){return At},removeSpring:function(Ye){if(Ye){var be=He.indexOf(Ye);if(be>-1)return He.splice(be,1),!0}},getBestNewBodyPosition:function(Ye){return It.getBestNewPosition(Ye)},getBBox:gt,getBoundingBox:gt,invalidateBBox:function(){console.warn("invalidateBBox() is deprecated, bounds always recomputed on `getBBox()` call")},gravity:function(Ye){return Ye!==void 0?(P.gravity=Ye,vt.options({gravity:Ye}),this):P.gravity},theta:function(Ye){return Ye!==void 0?(P.theta=Ye,vt.options({theta:Ye}),this):P.theta},random:Se};return N(P,Fe),ie(Fe),Fe;function gt(){return It.update(),It.box}function Jt(Ye,be){if(Ot.has(Ye))throw new Error("Force "+Ye+" is already added");Ot.set(Ye,be),lt.push(be)}function Ze(Ye){var be=lt.indexOf(Ot.get(Ye));be<0||(lt.splice(be,1),Ot.delete(Ye))}function rt(){return Ot}function Mt(){if(Ge.length!==0){vt.insertBodies(Ge);for(var Ye=Ge.length;Ye--;){var be=Ge[Ye];be.isPinned||(be.reset(),vt.updateBodyForce(be),Yt.update(be))}}}function Ue(){for(var Ye=He.length;Ye--;)zt.update(He[Ye])}}function N(P,W){for(var Y in P)L(P,W,Y)}function L(P,W,Y){if(P.hasOwnProperty(Y)&&typeof W[Y]!="function"){var ie=Number.isFinite(P[Y]);ie?W[Y]=function(pe){if(pe!==void 0){if(!Number.isFinite(pe))throw new Error("Value of "+Y+" should be a valid number.");return P[Y]=pe,W}return P[Y]}:W[Y]=function(pe){return pe!==void 0?(P[Y]=pe,W):P[Y]}}}},68403:function(se){se.exports=ee;function ee(b,w,k,O){this.from=b,this.to=w,this.length=k,this.coefficient=O}},35510:function(se){se.exports=ee;function ee(b,w){var k;if(b||(b={}),w){for(k in w)if(w.hasOwnProperty(k)){var O=b.hasOwnProperty(k),R=typeof w[k],S=!O||typeof b[k]!==R;S?b[k]=w[k]:R==="object"&&(b[k]=ee(b[k],w[k]))}}return b}},78712:function(se){se.exports=ee,se.exports.random=ee,se.exports.randomIterator=C;function ee(x){var E=typeof x=="number"?x:+new Date;return new b(E)}function b(x){this.seed=x}b.prototype.next=S,b.prototype.nextDouble=R,b.prototype.uniform=R,b.prototype.gaussian=w,b.prototype.random=R;function w(){var x,E,N;do E=this.nextDouble()*2-1,N=this.nextDouble()*2-1,x=E*E+N*N;while(x>=1||x===0);return E*Math.sqrt(-2*Math.log(x)/x)}b.prototype.levy=k;function k(){var x=1.5,E=Math.pow(O(1+x)*Math.sin(Math.PI*x/2)/(O((1+x)/2)*x*Math.pow(2,(x-1)/2)),1/x);return this.gaussian()*E/Math.pow(Math.abs(this.gaussian()),1/x)}function O(x){return Math.sqrt(2*Math.PI/x)*Math.pow(1/Math.E*(x+1/(12*x-1/(10*x))),x)}function R(){var x=this.seed;return x=x+2127912214+(x<<12)&4294967295,x=(x^3345072700^x>>>19)&4294967295,x=x+374761393+(x<<5)&4294967295,x=(x+3550635116^x<<9)&4294967295,x=x+4251993797+(x<<3)&4294967295,x=(x^3042594569^x>>>16)&4294967295,this.seed=x,(x&268435455)/268435456}function S(x){return Math.floor(this.nextDouble()*x)}function C(x,E){var N=E||ee();if(typeof N.next!="function")throw new Error("customRandom does not match expected API: next() function is missing");return{forEach:P,shuffle:L};function L(){var W,Y,ie;for(W=x.length-1;W>0;--W)Y=N.next(W+1),ie=x[Y],x[Y]=x[W],x[W]=ie;return x}function P(W){var Y,ie,pe;for(Y=x.length-1;Y>0;--Y)ie=N.next(Y+1),pe=x[ie],x[ie]=x[Y],x[Y]=pe,W(pe);x.length&&W(x[0])}}},95860:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return Ne}});var w=b(87462),k=b(1413),O=b(4942),R=b(97685),S=b(45987),C=b(94184),x=b.n(C),E=b(67294);function N(Te){var _e=E.useRef();_e.current=Te;var Xe=E.useCallback(function(){for(var Se,Ge=arguments.length,He=new Array(Ge),vt=0;vt<Ge;vt++)He[vt]=arguments[vt];return(Se=_e.current)===null||Se===void 0?void 0:Se.call.apply(Se,[_e].concat(He))},[]);return Xe}function L(){return!!(typeof window!="undefined"&&window.document&&window.document.createElement)}var P=L()?E.useLayoutEffect:E.useEffect,W=function(_e,Xe){var Se=E.useRef(!0);P(function(){return _e(Se.current)},Xe),P(function(){return Se.current=!1,function(){Se.current=!0}},[])},Y=function(_e,Xe){W(function(Se){if(!Se)return _e()},Xe)},ie=null;function pe(Te){var _e=E.useRef(!1),Xe=E.useState(Te),Se=(0,R.Z)(Xe,2),Ge=Se[0],He=Se[1];E.useEffect(function(){return _e.current=!1,function(){_e.current=!0}},[]);function vt(It,zt){zt&&_e.current||He(It)}return[Ge,vt]}function fe(Te){return Te!==void 0}function ae(Te,_e){var Xe=_e||{},Se=Xe.defaultValue,Ge=Xe.value,He=Xe.onChange,vt=Xe.postState,It=pe(function(){return fe(Ge)?Ge:fe(Se)?typeof Se=="function"?Se():Se:typeof Te=="function"?Te():Te}),zt=(0,R.Z)(It,2),Yt=zt[0],At=zt[1],lt=Ge!==void 0?Ge:Yt,Ot=vt?vt(lt):lt,le=N(He),Fe=pe([lt]),gt=(0,R.Z)(Fe,2),Jt=gt[0],Ze=gt[1];Y(function(){var Mt=Jt[0];Yt!==Mt&&le(Yt,Mt)},[Jt]),Y(function(){fe(Ge)||At(Ge)},[Ge]);var rt=N(function(Mt,Ue){At(Mt,Ue),Ze([lt],Ue)});return[Ot,rt]}var ye=["prefixCls","className","style","checked","disabled","defaultChecked","type","title","onChange"],ue=(0,E.forwardRef)(function(Te,_e){var Xe,Se=Te.prefixCls,Ge=Se===void 0?"rc-checkbox":Se,He=Te.className,vt=Te.style,It=Te.checked,zt=Te.disabled,Yt=Te.defaultChecked,At=Yt===void 0?!1:Yt,lt=Te.type,Ot=lt===void 0?"checkbox":lt,le=Te.title,Fe=Te.onChange,gt=(0,S.Z)(Te,ye),Jt=(0,E.useRef)(null),Ze=ae(At,{value:It}),rt=(0,R.Z)(Ze,2),Mt=rt[0],Ue=rt[1];(0,E.useImperativeHandle)(_e,function(){return{focus:function(){var Ke;(Ke=Jt.current)===null||Ke===void 0||Ke.focus()},blur:function(){var Ke;(Ke=Jt.current)===null||Ke===void 0||Ke.blur()},input:Jt.current}});var Ye=x()(Ge,He,(Xe={},(0,O.Z)(Xe,"".concat(Ge,"-checked"),Mt),(0,O.Z)(Xe,"".concat(Ge,"-disabled"),zt),Xe)),be=function(Ke){zt||("checked"in Te||Ue(Ke.target.checked),Fe==null||Fe({target:(0,k.Z)((0,k.Z)({},Te),{},{type:Ot,checked:Ke.target.checked}),stopPropagation:function(){Ke.stopPropagation()},preventDefault:function(){Ke.preventDefault()},nativeEvent:Ke.nativeEvent}))};return E.createElement("span",{className:Ye,title:le,style:vt},E.createElement("input",(0,w.Z)({},gt,{className:"".concat(Ge,"-input"),ref:Jt,onChange:be,disabled:zt,checked:!!Mt,type:Ot})),E.createElement("span",{className:"".concat(Ge,"-inner")}))}),Ne=ue},86851:function(se,ee,b){"use strict";var w=b(89594),k=Array.prototype.concat,O=Array.prototype.slice,R=se.exports=function(C){for(var x=[],E=0,N=C.length;E<N;E++){var L=C[E];w(L)?x=k.call(x,O.call(L)):x.push(L)}return x};R.wrap=function(S){return function(){return S(R(arguments))}}},89594:function(se){se.exports=function(b){return!b||typeof b=="string"?!1:b instanceof Array||Array.isArray(b)||b.length>=0&&(b.splice instanceof Function||Object.getOwnPropertyDescriptor(b,b.length-1)&&b.constructor.name!=="String")}},77797:function(se){"use strict";function ee(k){w(k);const O=b(k);return k.on=O.on,k.off=O.off,k.fire=O.fire,k}function b(k){let O=Object.create(null);return{on:function(R,S,C){if(typeof S!="function")throw new Error("callback is expected to be a function");let x=O[R];return x||(x=O[R]=[]),x.push({callback:S,ctx:C}),k},off:function(R,S){if(typeof R>"u")return O=Object.create(null),k;if(O[R])if(typeof S!="function")delete O[R];else{const C=O[R];for(let x=0;x<C.length;++x)C[x].callback===S&&C.splice(x,1)}return k},fire:function(R){const S=O[R];if(!S)return k;let C;arguments.length>1&&(C=Array.prototype.slice.call(arguments,1));for(let x=0;x<S.length;++x){const E=S[x];E.callback.apply(E.ctx,C)}return k}}}function w(k){if(!k)throw new Error("Eventify cannot use falsy object as events subject");const O=["on","fire","off"];for(let R=0;R<O.length;++R)if(k.hasOwnProperty(O[R]))throw new Error("Subject cannot be eventified, since it already has property '"+O[R]+"'")}se.exports=ee},82309:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return gY}});const w="180",k={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},O={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},R=0,S=1,C=2,x=3,E=0,N=1,L=2,P=3,W=0,Y=1,ie=2,pe=0,fe=1,ae=2,ye=3,ue=4,Ne=5,Te=100,_e=101,Xe=102,Se=103,Ge=104,He=200,vt=201,It=202,zt=203,Yt=204,At=205,lt=206,Ot=207,le=208,Fe=209,gt=210,Jt=211,Ze=212,rt=213,Mt=214,Ue=0,Ye=1,be=2,ge=3,Ke=4,wt=5,Be=6,ut=7,Et=0,je=1,tt=2,yt=0,B=1,te=2,ot=3,_t=4,ct=5,qt=6,en=7,nn="attached",we="detached",Q=300,De=301,We=302,Ce=303,Re=304,qe=306,st=1e3,$e=1001,ft=1002,Ct=1003,jt=1004,Qt=1004,pn=1005,Wn=1005,Rn=1006,bi=1007,Dr=1007,Qn=1008,Vi=1008,Oi=1009,Gi=1010,ir=1011,gs=1012,Ls=1013,ls=1014,ys=1015,Gs=1016,Yl=1017,Zl=1018,Fa=1020,Fl=35902,su=35899,Bu=1021,Pe=1022,D=1023,U=1026,_=1027,F=1028,X=1029,Ie=1030,ke=1031,et=1032,nt=1033,Wt=33776,Tt=33777,on=33778,Un=33779,sn=35840,bn=35841,ti=35842,Bt=35843,$n=36196,ni=37492,Pi=37496,ui=37808,Lr=37809,yi=37810,vi=37811,Mr=37812,Zt=37813,Fn=37814,hi=37815,Xn=37816,ds=37817,qr=37818,vs=37819,kr=37820,Fs=37821,io=36492,ro=36494,To=36495,Eo=36283,Wr=36284,eo=36285,Ao=36286,so=2200,Yr=2201,ua=2202,Co=2300,sl=2301,ol=2302,ha=2400,Ba=2401,al=2402,wo=2500,Lc=2501,ox=0,hh=1,M0=2,rp=3200,sp=3201,S0=3202,Bm=3203,Xa=0,Jd=1,ea="",uo="srgb",ou="srgb-linear",dh="linear",Fi="srgb",a1=0,Kl=7680,Um=7681,Qd=7682,ax=7683,lx=34055,T0=34056,l1=5386,c1=512,u1=513,h1=514,cx=515,d1=516,f1=517,ux=518,Jh=519,km=512,ef=513,tf=514,op=515,E0=516,A0=517,C0=518,zm=519,Uu=35044,nf=35048,Vm=35040,fE=35045,Gm=35049,pE=35041,mE=35046,gE=35050,yE=35042,p1="100",R0="300 es",oo=2e3,qa=2001,fh={COMPUTE:"compute",RENDER:"render"},m1={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},g1={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};class Bl{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){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const s=n[e];if(s!==void 0){const o=s.indexOf(t);o!==-1&&s.splice(o,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const s=n.slice(0);for(let o=0,a=s.length;o<a;o++)s[o].call(this,e);e.target=null}}}const Ya=["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 ku=1234567;const uc=Math.PI/180,Ua=180/Math.PI;function xl(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Ya[i&255]+Ya[i>>8&255]+Ya[i>>16&255]+Ya[i>>24&255]+"-"+Ya[e&255]+Ya[e>>8&255]+"-"+Ya[e>>16&15|64]+Ya[e>>24&255]+"-"+Ya[t&63|128]+Ya[t>>8&255]+"-"+Ya[t>>16&255]+Ya[t>>24&255]+Ya[n&255]+Ya[n>>8&255]+Ya[n>>16&255]+Ya[n>>24&255]).toLowerCase()}function Sr(i,e,t){return Math.max(e,Math.min(t,i))}function ap(i,e){return(i%e+e)%e}function hx(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function Wm(i,e,t){return i!==e?(t-i)/(e-i):0}function _r(i,e,t){return(1-t)*i+t*e}function Xs(i,e,t,n){return _r(i,e,1-Math.exp(-t*n))}function Ul(i,e=1){return e-Math.abs(ap(i,e*2)-e)}function N0(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function zu(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function wa(i,e){return i+Math.floor(Math.random()*(e-i+1))}function P0(i,e){return i+Math.random()*(e-i)}function au(i){return i*(.5-Math.random())}function Vu(i){i!==void 0&&(ku=i);let e=ku+=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 El(i){return i*uc}function Br(i){return i*Ua}function lp(i){return(i&i-1)===0&&i!==0}function I0(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function L0(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Qh(i,e,t,n,s){const o=Math.cos,a=Math.sin,c=o(t/2),u=a(t/2),d=o((e+n)/2),p=a((e+n)/2),m=o((e-n)/2),y=a((e-n)/2),M=o((n-e)/2),T=a((n-e)/2);switch(s){case"XYX":i.set(c*p,u*m,u*y,c*d);break;case"YZY":i.set(u*y,c*p,u*m,c*d);break;case"ZXZ":i.set(u*m,u*y,c*p,c*d);break;case"XZX":i.set(c*p,u*T,u*M,c*d);break;case"YXY":i.set(u*M,c*p,u*T,c*d);break;case"ZYZ":i.set(u*T,u*M,c*p,c*d);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function Za(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function cs(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const ed={DEG2RAD:uc,RAD2DEG:Ua,generateUUID:xl,clamp:Sr,euclideanModulo:ap,mapLinear:hx,inverseLerp:Wm,lerp:_r,damp:Xs,pingpong:Ul,smoothstep:N0,smootherstep:zu,randInt:wa,randFloat:P0,randFloatSpread:au,seededRandom:Vu,degToRad:El,radToDeg:Br,isPowerOfTwo:lp,ceilPowerOfTwo:I0,floorPowerOfTwo:L0,setQuaternionFromProperEuler:Qh,normalize:cs,denormalize:Za};class yn{constructor(e=0,t=0){yn.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,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[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=Sr(this.x,e.x,t.x),this.y=Sr(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Sr(this.x,e,t),this.y=Sr(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Sr(n,e,t))}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=Math.trunc(this.x),this.y=Math.trunc(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(Sr(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),s=Math.sin(t),o=this.x-e.x,a=this.y-e.y;return this.x=o*n-a*s+e.x,this.y=o*s+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ta{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,o,a,c){let u=n[s+0],d=n[s+1],p=n[s+2],m=n[s+3];const y=o[a+0],M=o[a+1],T=o[a+2],G=o[a+3];if(c===0){e[t+0]=u,e[t+1]=d,e[t+2]=p,e[t+3]=m;return}if(c===1){e[t+0]=y,e[t+1]=M,e[t+2]=T,e[t+3]=G;return}if(m!==G||u!==y||d!==M||p!==T){let z=1-c;const I=u*y+d*M+p*T+m*G,J=I>=0?1:-1,K=1-I*I;if(K>Number.EPSILON){const ve=Math.sqrt(K),me=Math.atan2(ve,I*J);z=Math.sin(z*me)/ve,c=Math.sin(c*me)/ve}const re=c*J;if(u=u*z+y*re,d=d*z+M*re,p=p*z+T*re,m=m*z+G*re,z===1-c){const ve=1/Math.sqrt(u*u+d*d+p*p+m*m);u*=ve,d*=ve,p*=ve,m*=ve}}e[t]=u,e[t+1]=d,e[t+2]=p,e[t+3]=m}static multiplyQuaternionsFlat(e,t,n,s,o,a){const c=n[s],u=n[s+1],d=n[s+2],p=n[s+3],m=o[a],y=o[a+1],M=o[a+2],T=o[a+3];return e[t]=c*T+p*m+u*M-d*y,e[t+1]=u*T+p*y+d*m-c*M,e[t+2]=d*T+p*M+c*y-u*m,e[t+3]=p*T-c*m-u*y-d*M,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,s){return this._x=e,this._y=t,this._z=n,this._w=s,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=!0){const n=e._x,s=e._y,o=e._z,a=e._order,c=Math.cos,u=Math.sin,d=c(n/2),p=c(s/2),m=c(o/2),y=u(n/2),M=u(s/2),T=u(o/2);switch(a){case"XYZ":this._x=y*p*m+d*M*T,this._y=d*M*m-y*p*T,this._z=d*p*T+y*M*m,this._w=d*p*m-y*M*T;break;case"YXZ":this._x=y*p*m+d*M*T,this._y=d*M*m-y*p*T,this._z=d*p*T-y*M*m,this._w=d*p*m+y*M*T;break;case"ZXY":this._x=y*p*m-d*M*T,this._y=d*M*m+y*p*T,this._z=d*p*T+y*M*m,this._w=d*p*m-y*M*T;break;case"ZYX":this._x=y*p*m-d*M*T,this._y=d*M*m+y*p*T,this._z=d*p*T-y*M*m,this._w=d*p*m+y*M*T;break;case"YZX":this._x=y*p*m+d*M*T,this._y=d*M*m+y*p*T,this._z=d*p*T-y*M*m,this._w=d*p*m-y*M*T;break;case"XZY":this._x=y*p*m-d*M*T,this._y=d*M*m-y*p*T,this._z=d*p*T+y*M*m,this._w=d*p*m+y*M*T;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],s=t[4],o=t[8],a=t[1],c=t[5],u=t[9],d=t[2],p=t[6],m=t[10],y=n+c+m;if(y>0){const M=.5/Math.sqrt(y+1);this._w=.25/M,this._x=(p-u)*M,this._y=(o-d)*M,this._z=(a-s)*M}else if(n>c&&n>m){const M=2*Math.sqrt(1+n-c-m);this._w=(p-u)/M,this._x=.25*M,this._y=(s+a)/M,this._z=(o+d)/M}else if(c>m){const M=2*Math.sqrt(1+c-n-m);this._w=(o-d)/M,this._x=(s+a)/M,this._y=.25*M,this._z=(u+p)/M}else{const M=2*Math.sqrt(1+m-n-c);this._w=(a-s)/M,this._x=(o+d)/M,this._y=(u+p)/M,this._z=.25*M}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(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(Sr(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const s=Math.min(1,t/n);return this.slerp(e,s),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,s=e._y,o=e._z,a=e._w,c=t._x,u=t._y,d=t._z,p=t._w;return this._x=n*p+a*c+s*d-o*u,this._y=s*p+a*u+o*c-n*d,this._z=o*p+a*d+n*u-s*c,this._w=a*p-n*c-s*u-o*d,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,s=this._y,o=this._z,a=this._w;let c=a*e._w+n*e._x+s*e._y+o*e._z;if(c<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,c=-c):this.copy(e),c>=1)return this._w=a,this._x=n,this._y=s,this._z=o,this;const u=1-c*c;if(u<=Number.EPSILON){const M=1-t;return this._w=M*a+t*this._w,this._x=M*n+t*this._x,this._y=M*s+t*this._y,this._z=M*o+t*this._z,this.normalize(),this}const d=Math.sqrt(u),p=Math.atan2(d,c),m=Math.sin((1-t)*p)/d,y=Math.sin(t*p)/d;return this._w=a*m+this._w*y,this._x=n*m+this._x*y,this._y=s*m+this._y*y,this._z=o*m+this._z*y,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),o=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),o*Math.sin(t),o*Math.cos(t))}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._onChangeCallback(),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 it{constructor(e=0,t=0,n=0){it.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(Hm.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Hm.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,s=this.z,o=e.elements;return this.x=o[0]*t+o[3]*n+o[6]*s,this.y=o[1]*t+o[4]*n+o[7]*s,this.z=o[2]*t+o[5]*n+o[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,o=e.elements,a=1/(o[3]*t+o[7]*n+o[11]*s+o[15]);return this.x=(o[0]*t+o[4]*n+o[8]*s+o[12])*a,this.y=(o[1]*t+o[5]*n+o[9]*s+o[13])*a,this.z=(o[2]*t+o[6]*n+o[10]*s+o[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,s=this.z,o=e.x,a=e.y,c=e.z,u=e.w,d=2*(a*s-c*n),p=2*(c*t-o*s),m=2*(o*n-a*t);return this.x=t+u*d+a*m-c*p,this.y=n+u*p+c*d-o*m,this.z=s+u*m+o*p-a*d,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,s=this.z,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*s,this.y=o[1]*t+o[5]*n+o[9]*s,this.z=o[2]*t+o[6]*n+o[10]*s,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=Sr(this.x,e.x,t.x),this.y=Sr(this.y,e.y,t.y),this.z=Sr(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Sr(this.x,e,t),this.y=Sr(this.y,e,t),this.z=Sr(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Sr(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(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,s=e.y,o=e.z,a=t.x,c=t.y,u=t.z;return this.x=s*u-o*c,this.y=o*a-n*u,this.z=n*c-s*a,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 cp.copy(this).projectOnVector(e),this.sub(cp)}reflect(e){return this.sub(cp.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(Sr(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}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 s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*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(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,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()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const cp=new it,Hm=new ta;class jr{constructor(e,t,n,s,o,a,c,u,d){jr.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,o,a,c,u,d)}set(e,t,n,s,o,a,c,u,d){const p=this.elements;return p[0]=e,p[1]=s,p[2]=c,p[3]=t,p[4]=o,p[5]=u,p[6]=n,p[7]=a,p[8]=d,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,s=t.elements,o=this.elements,a=n[0],c=n[3],u=n[6],d=n[1],p=n[4],m=n[7],y=n[2],M=n[5],T=n[8],G=s[0],z=s[3],I=s[6],J=s[1],K=s[4],re=s[7],ve=s[2],me=s[5],Le=s[8];return o[0]=a*G+c*J+u*ve,o[3]=a*z+c*K+u*me,o[6]=a*I+c*re+u*Le,o[1]=d*G+p*J+m*ve,o[4]=d*z+p*K+m*me,o[7]=d*I+p*re+m*Le,o[2]=y*G+M*J+T*ve,o[5]=y*z+M*K+T*me,o[8]=y*I+M*re+T*Le,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],s=e[2],o=e[3],a=e[4],c=e[5],u=e[6],d=e[7],p=e[8];return t*a*p-t*c*d-n*o*p+n*c*u+s*o*d-s*a*u}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],o=e[3],a=e[4],c=e[5],u=e[6],d=e[7],p=e[8],m=p*a-c*d,y=c*u-p*o,M=d*o-a*u,T=t*m+n*y+s*M;if(T===0)return this.set(0,0,0,0,0,0,0,0,0);const G=1/T;return e[0]=m*G,e[1]=(s*d-p*n)*G,e[2]=(c*n-s*a)*G,e[3]=y*G,e[4]=(p*t-s*u)*G,e[5]=(s*o-c*t)*G,e[6]=M*G,e[7]=(n*u-d*t)*G,e[8]=(a*t-n*o)*G,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,s,o,a,c){const u=Math.cos(o),d=Math.sin(o);return this.set(n*u,n*d,-n*(u*a+d*c)+a+e,-s*d,s*u,-s*(-d*a+u*c)+c+t,0,0,1),this}scale(e,t){return this.premultiply(up.makeScale(e,t)),this}rotate(e){return this.premultiply(up.makeRotation(-e)),this}translate(e,t){return this.premultiply(up.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 s=0;s<9;s++)if(t[s]!==n[s])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 up=new jr;function hp(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}const D0={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function ph(i,e){return new D0[i](e)}function mh(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Ka(){const i=mh("canvas");return i.style.display="block",i}const is={};function ll(i){i in is||(is[i]=!0,console.warn(i))}function oi(i,e,t){return new Promise(function(n,s){function o(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(o,t);break;default:n()}}setTimeout(o,t)})}const _l=new jr().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Rt=new jr().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function rf(){const i={enabled:!0,workingColorSpace:ou,spaces:{},convert:function(s,o,a){return this.enabled===!1||o===a||!o||!a||(this.spaces[o].transfer===Fi&&(s.r=da(s.r),s.g=da(s.g),s.b=da(s.b)),this.spaces[o].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[o].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Fi&&(s.r=Gu(s.r),s.g=Gu(s.g),s.b=Gu(s.b))),s},workingToColorSpace:function(s,o){return this.convert(s,this.workingColorSpace,o)},colorSpaceToWorking:function(s,o){return this.convert(s,o,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===ea?dh:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,o=this.workingColorSpace){return s.fromArray(this.spaces[o].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,o,a){return s.copy(this.spaces[o].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,o){return ll("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,o)},toWorkingColorSpace:function(s,o){return ll("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,o)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[ou]:{primaries:e,whitePoint:n,transfer:dh,toXYZ:_l,fromXYZ:Rt,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:uo},outputColorSpaceConfig:{drawingBufferColorSpace:uo}},[uo]:{primaries:e,whitePoint:n,transfer:Fi,toXYZ:_l,fromXYZ:Rt,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:uo}}}),i}const Ki=rf();function da(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Gu(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let lu;class $m{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement=="undefined")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{lu===void 0&&(lu=mh("canvas")),lu.width=e.width,lu.height=e.height;const s=lu.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=lu}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap){const t=mh("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const s=n.getImageData(0,0,e.width,e.height),o=s.data;for(let a=0;a<o.length;a++)o[a]=da(o[a]/255)*255;return n.putImageData(s,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(da(t[n]/255)*255):t[n]=da(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 jm=0;class Mo{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:jm++}),this.uuid=xl(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement!="undefined"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}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:""},s=this.data;if(s!==null){let o;if(Array.isArray(s)){o=[];for(let a=0,c=s.length;a<c;a++)s[a].isDataTexture?o.push(kl(s[a].image)):o.push(kl(s[a]))}else o=kl(s);n.url=o}return t||(e.images[this.uuid]=n),n}}function kl(i){return typeof HTMLImageElement!="undefined"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&i instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&i instanceof ImageBitmap?$m.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Dc=0;const cu=new it;class Ho extends Bl{constructor(e=Ho.DEFAULT_IMAGE,t=Ho.DEFAULT_MAPPING,n=$e,s=$e,o=Rn,a=Qn,c=D,u=Oi,d=Ho.DEFAULT_ANISOTROPY,p=ea){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Dc++}),this.uuid=xl(),this.name="",this.source=new Mo(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=o,this.minFilter=a,this.anisotropy=d,this.format=c,this.internalFormat=null,this.type=u,this.offset=new yn(0,0),this.repeat=new yn(1,1),this.center=new yn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new jr,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=p,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(cu).x}get height(){return this.source.getSize(cu).y}get depth(){return this.source.getSize(cu).z}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)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}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.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}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.7,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!==Q)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case st:e.x=e.x-Math.floor(e.x);break;case $e:e.x=e.x<0?0:1;break;case ft: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 st:e.y=e.y-Math.floor(e.y);break;case $e:e.y=e.y<0?0:1;break;case ft: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)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Ho.DEFAULT_IMAGE=null,Ho.DEFAULT_MAPPING=Q,Ho.DEFAULT_ANISOTROPY=1;class mr{constructor(e=0,t=0,n=0,s=1){mr.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=s}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,s){return this.x=e,this.y=t,this.z=n,this.w=s,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,s=this.z,o=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*s+a[12]*o,this.y=a[1]*t+a[5]*n+a[9]*s+a[13]*o,this.z=a[2]*t+a[6]*n+a[10]*s+a[14]*o,this.w=a[3]*t+a[7]*n+a[11]*s+a[15]*o,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,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,s,o;const u=e.elements,d=u[0],p=u[4],m=u[8],y=u[1],M=u[5],T=u[9],G=u[2],z=u[6],I=u[10];if(Math.abs(p-y)<.01&&Math.abs(m-G)<.01&&Math.abs(T-z)<.01){if(Math.abs(p+y)<.1&&Math.abs(m+G)<.1&&Math.abs(T+z)<.1&&Math.abs(d+M+I-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const K=(d+1)/2,re=(M+1)/2,ve=(I+1)/2,me=(p+y)/4,Le=(m+G)/4,Ve=(T+z)/4;return K>re&&K>ve?K<.01?(n=0,s=.707106781,o=.707106781):(n=Math.sqrt(K),s=me/n,o=Le/n):re>ve?re<.01?(n=.707106781,s=0,o=.707106781):(s=Math.sqrt(re),n=me/s,o=Ve/s):ve<.01?(n=.707106781,s=.707106781,o=0):(o=Math.sqrt(ve),n=Le/o,s=Ve/o),this.set(n,s,o,t),this}let J=Math.sqrt((z-T)*(z-T)+(m-G)*(m-G)+(y-p)*(y-p));return Math.abs(J)<.001&&(J=1),this.x=(z-T)/J,this.y=(m-G)/J,this.z=(y-p)/J,this.w=Math.acos((d+M+I-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],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=Sr(this.x,e.x,t.x),this.y=Sr(this.y,e.y,t.y),this.z=Sr(this.z,e.z,t.z),this.w=Sr(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Sr(this.x,e,t),this.y=Sr(this.y,e,t),this.z=Sr(this.z,e,t),this.w=Sr(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Sr(n,e,t))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(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 Ja extends Bl{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Rn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new mr(0,0,e,t),this.scissorTest=!1,this.viewport=new mr(0,0,e,t);const s={width:e,height:t,depth:n.depth},o=new Ho(s);this.textures=[];const a=n.count;for(let c=0;c<a;c++)this.textures[c]=o.clone(),this.textures[c].isRenderTargetTexture=!0,this.textures[c].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){const t={minFilter:Rn,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}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 s=0,o=this.textures.length;s<o;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].image.depth=n,this.textures[s].isArrayTexture=this.textures[s].image.depth>1;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.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const s=Object.assign({},e.textures[t].image);this.textures[t].source=new Mo(s)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class hc extends Ja{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class sf extends Ho{constructor(e=null,t=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Ct,this.minFilter=Ct,this.wrapR=$e,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class dp extends null{constructor(e=1,t=1,n=1,s={}){super(e,t,s),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new sf(null,e,t,n),this._setTextureOptions(s),this.texture.isRenderTargetTexture=!0}}class bl extends Ho{constructor(e=null,t=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Ct,this.minFilter=Ct,this.wrapR=$e,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ka extends null{constructor(e=1,t=1,n=1,s={}){super(e,t,s),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new bl(null,e,t,n),this._setTextureOptions(s),this.texture.isRenderTargetTexture=!0}}class fa{constructor(e=new it(1/0,1/0,1/0),t=new it(-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(Ql.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Ql.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=Ql.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){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const o=n.getAttribute("position");if(t===!0&&o!==void 0&&e.isInstancedMesh!==!0)for(let a=0,c=o.count;a<c;a++)e.isMesh===!0?e.getVertexPosition(a,Ql):Ql.fromBufferAttribute(o,a),Ql.applyMatrix4(e.matrixWorld),this.expandByPoint(Ql);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),of.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),of.copy(n.boundingBox)),of.applyMatrix4(e.matrixWorld),this.union(of)}const s=e.children;for(let o=0,a=s.length;o<a;o++)this.expandByObject(s[o],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,Ql),Ql.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(fc),Oc.subVectors(this.max,fc),uu.subVectors(e.a,fc),gh.subVectors(e.b,fc),na.subVectors(e.c,fc),za.subVectors(gh,uu),Ma.subVectors(na,gh),dc.subVectors(uu,na);let t=[0,-za.z,za.y,0,-Ma.z,Ma.y,0,-dc.z,dc.y,za.z,0,-za.x,Ma.z,0,-Ma.x,dc.z,0,-dc.x,-za.y,za.x,0,-Ma.y,Ma.x,0,-dc.y,dc.x,0];return!ne(t,uu,gh,na,Oc)||(t=[1,0,0,0,1,0,0,0,1],!ne(t,uu,gh,na,Oc))?!1:(Fc.crossVectors(za,Ma),t=[Fc.x,Fc.y,Fc.z],ne(t,uu,gh,na,Oc))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ql).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ql).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:(Jl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Jl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Jl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Jl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Jl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Jl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Jl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Jl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Jl),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Jl=[new it,new it,new it,new it,new it,new it,new it,new it],Ql=new it,of=new fa,uu=new it,gh=new it,na=new it,za=new it,Ma=new it,dc=new it,fc=new it,Oc=new it,Fc=new it,Al=new it;function ne(i,e,t,n,s){for(let o=0,a=i.length-3;o<=a;o+=3){Al.fromArray(i,o);const c=s.x*Math.abs(Al.x)+s.y*Math.abs(Al.y)+s.z*Math.abs(Al.z),u=e.dot(Al),d=t.dot(Al),p=n.dot(Al);if(Math.max(-Math.max(u,d,p),Math.min(u,d,p))>c)return!1}return!0}const $=new fa,q=new it,oe=new it;class xe{constructor(e=new it,t=-1){this.isSphere=!0,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):$.setFromPoints(e).getCenter(n);let s=0;for(let o=0,a=e.length;o<a;o++)s=Math.max(s,n.distanceToSquared(e[o]));return this.radius=Math.sqrt(s),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;q.subVectors(e,this.center);const t=q.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(q,s/n),this.radius+=s}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):(oe.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(q.copy(e.center).add(oe)),this.expandByPoint(q.copy(e.center).sub(oe))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}const Ae=new it,ze=new it,xt=new it,St=new it,Lt=new it,Vt=new it,Ht=new it;class hn{constructor(e=new it,t=new it(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,Ae)),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=Ae.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ae.copy(this.origin).addScaledVector(this.direction,t),Ae.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){ze.copy(e).add(t).multiplyScalar(.5),xt.copy(t).sub(e).normalize(),St.copy(this.origin).sub(ze);const o=e.distanceTo(t)*.5,a=-this.direction.dot(xt),c=St.dot(this.direction),u=-St.dot(xt),d=St.lengthSq(),p=Math.abs(1-a*a);let m,y,M,T;if(p>0)if(m=a*u-c,y=a*c-u,T=o*p,m>=0)if(y>=-T)if(y<=T){const G=1/p;m*=G,y*=G,M=m*(m+a*y+2*c)+y*(a*m+y+2*u)+d}else y=o,m=Math.max(0,-(a*y+c)),M=-m*m+y*(y+2*u)+d;else y=-o,m=Math.max(0,-(a*y+c)),M=-m*m+y*(y+2*u)+d;else y<=-T?(m=Math.max(0,-(-a*o+c)),y=m>0?-o:Math.min(Math.max(-o,-u),o),M=-m*m+y*(y+2*u)+d):y<=T?(m=0,y=Math.min(Math.max(-o,-u),o),M=y*(y+2*u)+d):(m=Math.max(0,-(a*o+c)),y=m>0?o:Math.min(Math.max(-o,-u),o),M=-m*m+y*(y+2*u)+d);else y=a>0?-o:o,m=Math.max(0,-(a*y+c)),M=-m*m+y*(y+2*u)+d;return n&&n.copy(this.origin).addScaledVector(this.direction,m),s&&s.copy(ze).addScaledVector(xt,y),M}intersectSphere(e,t){Ae.subVectors(e.center,this.origin);const n=Ae.dot(this.direction),s=Ae.dot(Ae)-n*n,o=e.radius*e.radius;if(s>o)return null;const a=Math.sqrt(o-s),c=n-a,u=n+a;return u<0?null:c<0?this.at(u,t):this.at(c,t)}intersectsSphere(e){return e.radius<0?!1: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,s,o,a,c,u;const d=1/this.direction.x,p=1/this.direction.y,m=1/this.direction.z,y=this.origin;return d>=0?(n=(e.min.x-y.x)*d,s=(e.max.x-y.x)*d):(n=(e.max.x-y.x)*d,s=(e.min.x-y.x)*d),p>=0?(o=(e.min.y-y.y)*p,a=(e.max.y-y.y)*p):(o=(e.max.y-y.y)*p,a=(e.min.y-y.y)*p),n>a||o>s||((o>n||isNaN(n))&&(n=o),(a<s||isNaN(s))&&(s=a),m>=0?(c=(e.min.z-y.z)*m,u=(e.max.z-y.z)*m):(c=(e.max.z-y.z)*m,u=(e.min.z-y.z)*m),n>u||c>s)||((c>n||n!==n)&&(n=c),(u<s||s!==s)&&(s=u),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Ae)!==null}intersectTriangle(e,t,n,s,o){Lt.subVectors(t,e),Vt.subVectors(n,e),Ht.crossVectors(Lt,Vt);let a=this.direction.dot(Ht),c;if(a>0){if(s)return null;c=1}else if(a<0)c=-1,a=-a;else return null;St.subVectors(this.origin,e);const u=c*this.direction.dot(Vt.crossVectors(St,Vt));if(u<0)return null;const d=c*this.direction.dot(Lt.cross(St));if(d<0||u+d>a)return null;const p=-c*St.dot(Ht);return p<0?null:this.at(p/a,o)}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 Ft{constructor(e,t,n,s,o,a,c,u,d,p,m,y,M,T,G,z){Ft.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,s,o,a,c,u,d,p,m,y,M,T,G,z)}set(e,t,n,s,o,a,c,u,d,p,m,y,M,T,G,z){const I=this.elements;return I[0]=e,I[4]=t,I[8]=n,I[12]=s,I[1]=o,I[5]=a,I[9]=c,I[13]=u,I[2]=d,I[6]=p,I[10]=m,I[14]=y,I[3]=M,I[7]=T,I[11]=G,I[15]=z,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 Ft().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,s=1/_n.setFromMatrixColumn(e,0).length(),o=1/_n.setFromMatrixColumn(e,1).length(),a=1/_n.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t[3]=0,t[4]=n[4]*o,t[5]=n[5]*o,t[6]=n[6]*o,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,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,s=e.y,o=e.z,a=Math.cos(n),c=Math.sin(n),u=Math.cos(s),d=Math.sin(s),p=Math.cos(o),m=Math.sin(o);if(e.order==="XYZ"){const y=a*p,M=a*m,T=c*p,G=c*m;t[0]=u*p,t[4]=-u*m,t[8]=d,t[1]=M+T*d,t[5]=y-G*d,t[9]=-c*u,t[2]=G-y*d,t[6]=T+M*d,t[10]=a*u}else if(e.order==="YXZ"){const y=u*p,M=u*m,T=d*p,G=d*m;t[0]=y+G*c,t[4]=T*c-M,t[8]=a*d,t[1]=a*m,t[5]=a*p,t[9]=-c,t[2]=M*c-T,t[6]=G+y*c,t[10]=a*u}else if(e.order==="ZXY"){const y=u*p,M=u*m,T=d*p,G=d*m;t[0]=y-G*c,t[4]=-a*m,t[8]=T+M*c,t[1]=M+T*c,t[5]=a*p,t[9]=G-y*c,t[2]=-a*d,t[6]=c,t[10]=a*u}else if(e.order==="ZYX"){const y=a*p,M=a*m,T=c*p,G=c*m;t[0]=u*p,t[4]=T*d-M,t[8]=y*d+G,t[1]=u*m,t[5]=G*d+y,t[9]=M*d-T,t[2]=-d,t[6]=c*u,t[10]=a*u}else if(e.order==="YZX"){const y=a*u,M=a*d,T=c*u,G=c*d;t[0]=u*p,t[4]=G-y*m,t[8]=T*m+M,t[1]=m,t[5]=a*p,t[9]=-c*p,t[2]=-d*p,t[6]=M*m+T,t[10]=y-G*m}else if(e.order==="XZY"){const y=a*u,M=a*d,T=c*u,G=c*d;t[0]=u*p,t[4]=-m,t[8]=d*p,t[1]=y*m+G,t[5]=a*p,t[9]=M*m-T,t[2]=T*m-M,t[6]=c*p,t[10]=G*m+y}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(Pn,e,ei)}lookAt(e,t,n){const s=this.elements;return di.subVectors(e,t),di.lengthSq()===0&&(di.z=1),di.normalize(),ai.crossVectors(n,di),ai.lengthSq()===0&&(Math.abs(n.z)===1?di.x+=1e-4:di.z+=1e-4,di.normalize(),ai.crossVectors(n,di)),ai.normalize(),On.crossVectors(di,ai),s[0]=ai.x,s[4]=On.x,s[8]=di.x,s[1]=ai.y,s[5]=On.y,s[9]=di.y,s[2]=ai.z,s[6]=On.z,s[10]=di.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,o=this.elements,a=n[0],c=n[4],u=n[8],d=n[12],p=n[1],m=n[5],y=n[9],M=n[13],T=n[2],G=n[6],z=n[10],I=n[14],J=n[3],K=n[7],re=n[11],ve=n[15],me=s[0],Le=s[4],Ve=s[8],Ee=s[12],Oe=s[1],dt=s[5],Ut=s[9],tn=s[13],cn=s[2],vn=s[6],mn=s[10],Yn=s[14],xn=s[3],si=s[7],wn=s[11],Gn=s[15];return o[0]=a*me+c*Oe+u*cn+d*xn,o[4]=a*Le+c*dt+u*vn+d*si,o[8]=a*Ve+c*Ut+u*mn+d*wn,o[12]=a*Ee+c*tn+u*Yn+d*Gn,o[1]=p*me+m*Oe+y*cn+M*xn,o[5]=p*Le+m*dt+y*vn+M*si,o[9]=p*Ve+m*Ut+y*mn+M*wn,o[13]=p*Ee+m*tn+y*Yn+M*Gn,o[2]=T*me+G*Oe+z*cn+I*xn,o[6]=T*Le+G*dt+z*vn+I*si,o[10]=T*Ve+G*Ut+z*mn+I*wn,o[14]=T*Ee+G*tn+z*Yn+I*Gn,o[3]=J*me+K*Oe+re*cn+ve*xn,o[7]=J*Le+K*dt+re*vn+ve*si,o[11]=J*Ve+K*Ut+re*mn+ve*wn,o[15]=J*Ee+K*tn+re*Yn+ve*Gn,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],s=e[8],o=e[12],a=e[1],c=e[5],u=e[9],d=e[13],p=e[2],m=e[6],y=e[10],M=e[14],T=e[3],G=e[7],z=e[11],I=e[15];return T*(+o*u*m-s*d*m-o*c*y+n*d*y+s*c*M-n*u*M)+G*(+t*u*M-t*d*y+o*a*y-s*a*M+s*d*p-o*u*p)+z*(+t*d*m-t*c*M-o*a*m+n*a*M+o*c*p-n*d*p)+I*(-s*c*p-t*u*m+t*c*y+s*a*m-n*a*y+n*u*p)}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 s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],o=e[3],a=e[4],c=e[5],u=e[6],d=e[7],p=e[8],m=e[9],y=e[10],M=e[11],T=e[12],G=e[13],z=e[14],I=e[15],J=m*z*d-G*y*d+G*u*M-c*z*M-m*u*I+c*y*I,K=T*y*d-p*z*d-T*u*M+a*z*M+p*u*I-a*y*I,re=p*G*d-T*m*d+T*c*M-a*G*M-p*c*I+a*m*I,ve=T*m*u-p*G*u-T*c*y+a*G*y+p*c*z-a*m*z,me=t*J+n*K+s*re+o*ve;if(me===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const Le=1/me;return e[0]=J*Le,e[1]=(G*y*o-m*z*o-G*s*M+n*z*M+m*s*I-n*y*I)*Le,e[2]=(c*z*o-G*u*o+G*s*d-n*z*d-c*s*I+n*u*I)*Le,e[3]=(m*u*o-c*y*o-m*s*d+n*y*d+c*s*M-n*u*M)*Le,e[4]=K*Le,e[5]=(p*z*o-T*y*o+T*s*M-t*z*M-p*s*I+t*y*I)*Le,e[6]=(T*u*o-a*z*o-T*s*d+t*z*d+a*s*I-t*u*I)*Le,e[7]=(a*y*o-p*u*o+p*s*d-t*y*d-a*s*M+t*u*M)*Le,e[8]=re*Le,e[9]=(T*m*o-p*G*o-T*n*M+t*G*M+p*n*I-t*m*I)*Le,e[10]=(a*G*o-T*c*o+T*n*d-t*G*d-a*n*I+t*c*I)*Le,e[11]=(p*c*o-a*m*o-p*n*d+t*m*d+a*n*M-t*c*M)*Le,e[12]=ve*Le,e[13]=(p*G*s-T*m*s+T*n*y-t*G*y-p*n*z+t*m*z)*Le,e[14]=(T*c*s-a*G*s-T*n*u+t*G*u+a*n*z-t*c*z)*Le,e[15]=(a*m*s-p*c*s+p*n*u-t*m*u-a*n*y+t*c*y)*Le,this}scale(e){const t=this.elements,n=e.x,s=e.y,o=e.z;return t[0]*=n,t[4]*=s,t[8]*=o,t[1]*=n,t[5]*=s,t[9]*=o,t[2]*=n,t[6]*=s,t[10]*=o,t[3]*=n,t[7]*=s,t[11]*=o,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],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}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),s=Math.sin(t),o=1-n,a=e.x,c=e.y,u=e.z,d=o*a,p=o*c;return this.set(d*a+n,d*c-s*u,d*u+s*c,0,d*c+s*u,p*c+n,p*u-s*a,0,d*u-s*c,p*u+s*a,o*u*u+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,s,o,a){return this.set(1,n,o,0,e,1,a,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){const s=this.elements,o=t._x,a=t._y,c=t._z,u=t._w,d=o+o,p=a+a,m=c+c,y=o*d,M=o*p,T=o*m,G=a*p,z=a*m,I=c*m,J=u*d,K=u*p,re=u*m,ve=n.x,me=n.y,Le=n.z;return s[0]=(1-(G+I))*ve,s[1]=(M+re)*ve,s[2]=(T-K)*ve,s[3]=0,s[4]=(M-re)*me,s[5]=(1-(y+I))*me,s[6]=(z+J)*me,s[7]=0,s[8]=(T+K)*Le,s[9]=(z-J)*Le,s[10]=(1-(y+G))*Le,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){const s=this.elements;let o=_n.set(s[0],s[1],s[2]).length();const a=_n.set(s[4],s[5],s[6]).length(),c=_n.set(s[8],s[9],s[10]).length();this.determinant()<0&&(o=-o),e.x=s[12],e.y=s[13],e.z=s[14],Nn.copy(this);const d=1/o,p=1/a,m=1/c;return Nn.elements[0]*=d,Nn.elements[1]*=d,Nn.elements[2]*=d,Nn.elements[4]*=p,Nn.elements[5]*=p,Nn.elements[6]*=p,Nn.elements[8]*=m,Nn.elements[9]*=m,Nn.elements[10]*=m,t.setFromRotationMatrix(Nn),n.x=o,n.y=a,n.z=c,this}makePerspective(e,t,n,s,o,a,c=oo,u=!1){const d=this.elements,p=2*o/(t-e),m=2*o/(n-s),y=(t+e)/(t-e),M=(n+s)/(n-s);let T,G;if(u)T=o/(a-o),G=a*o/(a-o);else if(c===oo)T=-(a+o)/(a-o),G=-2*a*o/(a-o);else if(c===qa)T=-a/(a-o),G=-a*o/(a-o);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+c);return d[0]=p,d[4]=0,d[8]=y,d[12]=0,d[1]=0,d[5]=m,d[9]=M,d[13]=0,d[2]=0,d[6]=0,d[10]=T,d[14]=G,d[3]=0,d[7]=0,d[11]=-1,d[15]=0,this}makeOrthographic(e,t,n,s,o,a,c=oo,u=!1){const d=this.elements,p=2/(t-e),m=2/(n-s),y=-(t+e)/(t-e),M=-(n+s)/(n-s);let T,G;if(u)T=1/(a-o),G=a/(a-o);else if(c===oo)T=-2/(a-o),G=-(a+o)/(a-o);else if(c===qa)T=-1/(a-o),G=-o/(a-o);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+c);return d[0]=p,d[4]=0,d[8]=0,d[12]=y,d[1]=0,d[5]=m,d[9]=0,d[13]=M,d[2]=0,d[6]=0,d[10]=T,d[14]=G,d[3]=0,d[7]=0,d[11]=0,d[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])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 _n=new it,Nn=new Ft,Pn=new it(0,0,0),ei=new it(1,1,1),ai=new it,On=new it,di=new it,Ri=new Ft,ji=new ta;class Qi{constructor(e=0,t=0,n=0,s=Qi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}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,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,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 s=e.elements,o=s[0],a=s[4],c=s[8],u=s[1],d=s[5],p=s[9],m=s[2],y=s[6],M=s[10];switch(t){case"XYZ":this._y=Math.asin(Sr(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-p,M),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(y,d),this._z=0);break;case"YXZ":this._x=Math.asin(-Sr(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(c,M),this._z=Math.atan2(u,d)):(this._y=Math.atan2(-m,o),this._z=0);break;case"ZXY":this._x=Math.asin(Sr(y,-1,1)),Math.abs(y)<.9999999?(this._y=Math.atan2(-m,M),this._z=Math.atan2(-a,d)):(this._y=0,this._z=Math.atan2(u,o));break;case"ZYX":this._y=Math.asin(-Sr(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(y,M),this._z=Math.atan2(u,o)):(this._x=0,this._z=Math.atan2(-a,d));break;case"YZX":this._z=Math.asin(Sr(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-p,d),this._y=Math.atan2(-m,o)):(this._x=0,this._y=Math.atan2(c,M));break;case"XZY":this._z=Math.asin(-Sr(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(y,d),this._y=Math.atan2(c,o)):(this._x=Math.atan2(-p,M),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 Ri.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ri,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ji.setFromEuler(this),this.setFromQuaternion(ji,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}}Qi.DEFAULT_ORDER="XYZ";class er{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 gr=0;const yr=new it,Pr=new ta,Ji=new Ft,us=new it,fs=new it,As=new it,Ws=new ta,Cs=new it(1,0,0),hs=new it(0,1,0),Mi=new it(0,0,1),Xi={type:"added"},Ur={type:"removed"},zr={type:"childadded",child:null},Or={type:"childremoved",child:null};class Qr extends Bl{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:gr++}),this.uuid=xl(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Qr.DEFAULT_UP.clone();const e=new it,t=new Qi,n=new ta,s=new it(1,1,1);function o(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(o),n._onChange(a),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:s},modelViewMatrix:{value:new Ft},normalMatrix:{value:new jr}}),this.matrix=new Ft,this.matrixWorld=new Ft,this.matrixAutoUpdate=Qr.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Qr.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new er,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}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 Pr.setFromAxisAngle(e,t),this.quaternion.multiply(Pr),this}rotateOnWorldAxis(e,t){return Pr.setFromAxisAngle(e,t),this.quaternion.premultiply(Pr),this}rotateX(e){return this.rotateOnAxis(Cs,e)}rotateY(e){return this.rotateOnAxis(hs,e)}rotateZ(e){return this.rotateOnAxis(Mi,e)}translateOnAxis(e,t){return yr.copy(e).applyQuaternion(this.quaternion),this.position.add(yr.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Cs,e)}translateY(e){return this.translateOnAxis(hs,e)}translateZ(e){return this.translateOnAxis(Mi,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ji.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?us.copy(e):us.set(e,t,n);const s=this.parent;this.updateWorldMatrix(!0,!1),fs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ji.lookAt(fs,us,this.up):Ji.lookAt(us,fs,this.up),this.quaternion.setFromRotationMatrix(Ji),s&&(Ji.extractRotation(s.matrixWorld),Pr.setFromRotationMatrix(Ji),this.quaternion.premultiply(Pr.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.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Xi),zr.child=e,this.dispatchEvent(zr),zr.child=null):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(Ur),Or.child=e,this.dispatchEvent(Or),Or.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Ji.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ji.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ji),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Xi),zr.child=e,this.dispatchEvent(zr),zr.child=null,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,s=this.children.length;n<s;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const s=this.children;for(let o=0,a=s.length;o<a;o++)s[o].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(fs,e,As),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(fs,Ws,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,s=t.length;n<s;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,s=t.length;n<s;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.matrixWorldAutoUpdate===!0&&(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,s=t.length;n<s;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const s=this.children;for(let o=0,a=s.length;o<a;o++)s[o].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.7,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(c=>cc(Ys({},c),{boundingBox:c.boundingBox?c.boundingBox.toJSON():void 0,boundingSphere:c.boundingSphere?c.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(c=>Ys({},c)),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function o(c,u){return c[u.uuid]===void 0&&(c[u.uuid]=u.toJSON(e)),u.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=o(e.geometries,this.geometry);const c=this.geometry.parameters;if(c!==void 0&&c.shapes!==void 0){const u=c.shapes;if(Array.isArray(u))for(let d=0,p=u.length;d<p;d++){const m=u[d];o(e.shapes,m)}else o(e.shapes,u)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(o(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const c=[];for(let u=0,d=this.material.length;u<d;u++)c.push(o(e.materials,this.material[u]));s.material=c}else s.material=o(e.materials,this.material);if(this.children.length>0){s.children=[];for(let c=0;c<this.children.length;c++)s.children.push(this.children[c].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let c=0;c<this.animations.length;c++){const u=this.animations[c];s.animations.push(o(e.animations,u))}}if(t){const c=a(e.geometries),u=a(e.materials),d=a(e.textures),p=a(e.images),m=a(e.shapes),y=a(e.skeletons),M=a(e.animations),T=a(e.nodes);c.length>0&&(n.geometries=c),u.length>0&&(n.materials=u),d.length>0&&(n.textures=d),p.length>0&&(n.images=p),m.length>0&&(n.shapes=m),y.length>0&&(n.skeletons=y),M.length>0&&(n.animations=M),T.length>0&&(n.nodes=T)}return n.object=s,n;function a(c){const u=[];for(const d in c){const p=c[d];delete p.metadata,u.push(p)}return u}}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.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,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.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const s=e.children[n];this.add(s.clone())}return this}}Qr.DEFAULT_UP=new it(0,1,0),Qr.DEFAULT_MATRIX_AUTO_UPDATE=!0,Qr.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ds=new it,Do=new it,Qa=new it,ao=new it,cl=new it,_s=new it,pa=new it,Zs=new it,Bc=new it,Ro=new it,zl=new mr,$o=new mr,Sa=new mr;class ia{constructor(e=new it,t=new it,n=new it){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),Ds.subVectors(e,t),s.cross(Ds);const o=s.lengthSq();return o>0?s.multiplyScalar(1/Math.sqrt(o)):s.set(0,0,0)}static getBarycoord(e,t,n,s,o){Ds.subVectors(s,t),Do.subVectors(n,t),Qa.subVectors(e,t);const a=Ds.dot(Ds),c=Ds.dot(Do),u=Ds.dot(Qa),d=Do.dot(Do),p=Do.dot(Qa),m=a*d-c*c;if(m===0)return o.set(0,0,0),null;const y=1/m,M=(d*u-c*p)*y,T=(a*p-c*u)*y;return o.set(1-M-T,T,M)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,ao)===null?!1:ao.x>=0&&ao.y>=0&&ao.x+ao.y<=1}static getInterpolation(e,t,n,s,o,a,c,u){return this.getBarycoord(e,t,n,s,ao)===null?(u.x=0,u.y=0,"z"in u&&(u.z=0),"w"in u&&(u.w=0),null):(u.setScalar(0),u.addScaledVector(o,ao.x),u.addScaledVector(a,ao.y),u.addScaledVector(c,ao.z),u)}static getInterpolatedAttribute(e,t,n,s,o,a){return zl.setScalar(0),$o.setScalar(0),Sa.setScalar(0),zl.fromBufferAttribute(e,t),$o.fromBufferAttribute(e,n),Sa.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(zl,o.x),a.addScaledVector($o,o.y),a.addScaledVector(Sa,o.z),a}static isFrontFacing(e,t,n,s){return Ds.subVectors(n,t),Do.subVectors(e,t),Ds.cross(Do).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),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 Ds.subVectors(this.c,this.b),Do.subVectors(this.a,this.b),Ds.cross(Do).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ia.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return ia.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,o){return ia.getInterpolation(e,this.a,this.b,this.c,t,n,s,o)}containsPoint(e){return ia.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ia.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,s=this.b,o=this.c;let a,c;cl.subVectors(s,n),_s.subVectors(o,n),Zs.subVectors(e,n);const u=cl.dot(Zs),d=_s.dot(Zs);if(u<=0&&d<=0)return t.copy(n);Bc.subVectors(e,s);const p=cl.dot(Bc),m=_s.dot(Bc);if(p>=0&&m<=p)return t.copy(s);const y=u*m-p*d;if(y<=0&&u>=0&&p<=0)return a=u/(u-p),t.copy(n).addScaledVector(cl,a);Ro.subVectors(e,o);const M=cl.dot(Ro),T=_s.dot(Ro);if(T>=0&&M<=T)return t.copy(o);const G=M*d-u*T;if(G<=0&&d>=0&&T<=0)return c=d/(d-T),t.copy(n).addScaledVector(_s,c);const z=p*T-M*m;if(z<=0&&m-p>=0&&M-T>=0)return pa.subVectors(o,s),c=(m-p)/(m-p+(M-T)),t.copy(s).addScaledVector(pa,c);const I=1/(z+G+y);return a=G*I,c=y*I,t.copy(n).addScaledVector(cl,a).addScaledVector(_s,c)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const ul={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},ra={h:0,s:0,l:0},rs={h:0,s:0,l:0};function Us(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class jn{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 s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=uo){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ki.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=Ki.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ki.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=Ki.workingColorSpace){if(e=ap(e,1),t=Sr(t,0,1),n=Sr(n,0,1),t===0)this.r=this.g=this.b=n;else{const o=n<=.5?n*(1+t):n+t-n*t,a=2*n-o;this.r=Us(a,o,e+1/3),this.g=Us(a,o,e),this.b=Us(a,o,e-1/3)}return Ki.colorSpaceToWorking(this,s),this}setStyle(e,t=uo){function n(o){o!==void 0&&parseFloat(o)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let o;const a=s[1],c=s[2];switch(a){case"rgb":case"rgba":if(o=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(o[4]),this.setRGB(Math.min(255,parseInt(o[1],10))/255,Math.min(255,parseInt(o[2],10))/255,Math.min(255,parseInt(o[3],10))/255,t);if(o=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(o[4]),this.setRGB(Math.min(100,parseInt(o[1],10))/100,Math.min(100,parseInt(o[2],10))/100,Math.min(100,parseInt(o[3],10))/100,t);break;case"hsl":case"hsla":if(o=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(o[4]),this.setHSL(parseFloat(o[1])/360,parseFloat(o[2])/100,parseFloat(o[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const o=s[1],a=o.length;if(a===3)return this.setRGB(parseInt(o.charAt(0),16)/15,parseInt(o.charAt(1),16)/15,parseInt(o.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(o,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=uo){const n=ul[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=da(e.r),this.g=da(e.g),this.b=da(e.b),this}copyLinearToSRGB(e){return this.r=Gu(e.r),this.g=Gu(e.g),this.b=Gu(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=uo){return Ki.workingToColorSpace(br.copy(this),e),Math.round(Sr(br.r*255,0,255))*65536+Math.round(Sr(br.g*255,0,255))*256+Math.round(Sr(br.b*255,0,255))}getHexString(e=uo){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ki.workingColorSpace){Ki.workingToColorSpace(br.copy(this),t);const n=br.r,s=br.g,o=br.b,a=Math.max(n,s,o),c=Math.min(n,s,o);let u,d;const p=(c+a)/2;if(c===a)u=0,d=0;else{const m=a-c;switch(d=p<=.5?m/(a+c):m/(2-a-c),a){case n:u=(s-o)/m+(s<o?6:0);break;case s:u=(o-n)/m+2;break;case o:u=(n-s)/m+4;break}u/=6}return e.h=u,e.s=d,e.l=p,e}getRGB(e,t=Ki.workingColorSpace){return Ki.workingToColorSpace(br.copy(this),t),e.r=br.r,e.g=br.g,e.b=br.b,e}getStyle(e=uo){Ki.workingToColorSpace(br.copy(this),e);const t=br.r,n=br.g,s=br.b;return e!==uo?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(ra),this.setHSL(ra.h+e,ra.s+t,ra.l+n)}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(ra),e.getHSL(rs);const n=_r(ra.h,rs.h,t),s=_r(ra.s,rs.s,t),o=_r(ra.l,rs.l,t);return this.setHSL(n,s,o),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,s=this.b,o=e.elements;return this.r=o[0]*t+o[3]*n+o[6]*s,this.g=o[1]*t+o[4]*n+o[7]*s,this.b=o[2]*t+o[5]*n+o[8]*s,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 br=new jn;jn.NAMES=ul;let Oo=0;class Ei extends Bl{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Oo++}),this.uuid=xl(),this.name="",this.type="Material",this.blending=fe,this.side=W,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Yt,this.blendDst=At,this.blendEquation=Te,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new jn(0,0,0),this.blendAlpha=0,this.depthFunc=ge,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Jh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Kl,this.stencilZFail=Kl,this.stencilZPass=Kl,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.allowOverride=!0,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}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 s=this[t];if(s===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,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!==void 0&&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.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),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.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),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!==fe&&(n.blending=this.blending),this.side!==W&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Yt&&(n.blendSrc=this.blendSrc),this.blendDst!==At&&(n.blendDst=this.blendDst),this.blendEquation!==Te&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==ge&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Jh&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Kl&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Kl&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Kl&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),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=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),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=!0),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 s(o){const a=[];for(const c in o){const u=o[c];delete u.metadata,a.push(u)}return a}if(t){const o=s(e.textures),a=s(e.images);o.length>0&&(n.textures=o),a.length>0&&(n.images=a)}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.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,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 s=t.length;n=new Array(s);for(let o=0;o!==s;++o)n[o]=t[o].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++}}class Hr extends Ei{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new jn(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.envMapRotation=new Qi,this.combine=Et,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.envMapRotation.copy(e.envMapRotation),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 xs=ar();function ar(){const i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),s=new Uint32Array(512);for(let u=0;u<256;++u){const d=u-127;d<-27?(n[u]=0,n[u|256]=32768,s[u]=24,s[u|256]=24):d<-14?(n[u]=1024>>-d-14,n[u|256]=1024>>-d-14|32768,s[u]=-d-1,s[u|256]=-d-1):d<=15?(n[u]=d+15<<10,n[u|256]=d+15<<10|32768,s[u]=13,s[u|256]=13):d<128?(n[u]=31744,n[u|256]=64512,s[u]=24,s[u|256]=24):(n[u]=31744,n[u|256]=64512,s[u]=13,s[u|256]=13)}const o=new Uint32Array(2048),a=new Uint32Array(64),c=new Uint32Array(64);for(let u=1;u<1024;++u){let d=u<<13,p=0;for(;!(d&8388608);)d<<=1,p-=8388608;d&=-8388609,p+=947912704,o[u]=d|p}for(let u=1024;u<2048;++u)o[u]=939524096+(u-1024<<13);for(let u=1;u<31;++u)a[u]=u<<23;a[31]=1199570944,a[32]=2147483648;for(let u=33;u<63;++u)a[u]=2147483648+(u-32<<23);a[63]=3347054592;for(let u=1;u<64;++u)u!==32&&(c[u]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:s,mantissaTable:o,exponentTable:a,offsetTable:c}}function vr(i){Math.abs(i)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),i=Sr(i,-65504,65504),xs.floatView[0]=i;const e=xs.uint32View[0],t=e>>23&511;return xs.baseTable[t]+((e&8388607)>>xs.shiftTable[t])}function Rs(i){const e=i>>10;return xs.uint32View[0]=xs.mantissaTable[xs.offsetTable[e]+(i&1023)]+xs.exponentTable[e],xs.floatView[0]}class No{static toHalfFloat(e){return vr(e)}static fromHalfFloat(e){return Rs(e)}}const Ss=new it,Hs=new yn;let yh=0;class es{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:yh++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Uu,this.updateRanges=[],this.gpuType=ys,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}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 s=0,o=this.itemSize;s<o;s++)this.array[e+s]=t.array[n+s];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++)Hs.fromBufferAttribute(this,t),Hs.applyMatrix3(e),this.setXY(t,Hs.x,Hs.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Ss.fromBufferAttribute(this,t),Ss.applyMatrix3(e),this.setXYZ(t,Ss.x,Ss.y,Ss.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Ss.fromBufferAttribute(this,t),Ss.applyMatrix4(e),this.setXYZ(t,Ss.x,Ss.y,Ss.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Ss.fromBufferAttribute(this,t),Ss.applyNormalMatrix(e),this.setXYZ(t,Ss.x,Ss.y,Ss.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Ss.fromBufferAttribute(this,t),Ss.transformDirection(e),this.setXYZ(t,Ss.x,Ss.y,Ss.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Za(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=cs(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Za(t,this.array)),t}setX(e,t){return this.normalized&&(t=cs(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Za(t,this.array)),t}setY(e,t){return this.normalized&&(t=cs(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=Za(t,this.array)),t}setZ(e,t){return this.normalized&&(t=cs(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=Za(t,this.array)),t}setW(e,t){return this.normalized&&(t=cs(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=cs(t,this.array),n=cs(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=cs(t,this.array),n=cs(n,this.array),s=cs(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,o){return e*=this.itemSize,this.normalized&&(t=cs(t,this.array),n=cs(n,this.array),s=cs(s,this.array),o=cs(o,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this.array[e+3]=o,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!==Uu&&(e.usage=this.usage),e}}class Ta extends null{constructor(e,t,n){super(new Int8Array(e),t,n)}}class pc extends null{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class lo extends null{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class mc extends null{constructor(e,t,n){super(new Int16Array(e),t,n)}}class Va extends es{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class vo extends null{constructor(e,t,n){super(new Int32Array(e),t,n)}}class gc extends es{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Xm extends es{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=Rs(this.array[e*this.itemSize]);return this.normalized&&(t=Za(t,this.array)),t}setX(e,t){return this.normalized&&(t=cs(t,this.array)),this.array[e*this.itemSize]=vr(t),this}getY(e){let t=Rs(this.array[e*this.itemSize+1]);return this.normalized&&(t=Za(t,this.array)),t}setY(e,t){return this.normalized&&(t=cs(t,this.array)),this.array[e*this.itemSize+1]=vr(t),this}getZ(e){let t=Rs(this.array[e*this.itemSize+2]);return this.normalized&&(t=Za(t,this.array)),t}setZ(e,t){return this.normalized&&(t=cs(t,this.array)),this.array[e*this.itemSize+2]=vr(t),this}getW(e){let t=Rs(this.array[e*this.itemSize+3]);return this.normalized&&(t=Za(t,this.array)),t}setW(e,t){return this.normalized&&(t=cs(t,this.array)),this.array[e*this.itemSize+3]=vr(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=cs(t,this.array),n=cs(n,this.array)),this.array[e+0]=vr(t),this.array[e+1]=vr(n),this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=cs(t,this.array),n=cs(n,this.array),s=cs(s,this.array)),this.array[e+0]=vr(t),this.array[e+1]=vr(n),this.array[e+2]=vr(s),this}setXYZW(e,t,n,s,o){return e*=this.itemSize,this.normalized&&(t=cs(t,this.array),n=cs(n,this.array),s=cs(s,this.array),o=cs(o,this.array)),this.array[e+0]=vr(t),this.array[e+1]=vr(n),this.array[e+2]=vr(s),this.array[e+3]=vr(o),this}}class Zi extends es{constructor(e,t,n){super(new Float32Array(e),t,n)}}let dx=0;const Vl=new Ft,af=new Qr,Wu=new it,Gl=new fa,qi=new fa,Ea=new it;class xr extends Bl{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:dx++}),this.uuid=xl(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=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(hp(e)?gc:Va)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}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 o=new jr().getNormalMatrix(e);n.applyNormalMatrix(o),n.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Vl.makeRotationFromQuaternion(e),this.applyMatrix4(Vl),this}rotateX(e){return Vl.makeRotationX(e),this.applyMatrix4(Vl),this}rotateY(e){return Vl.makeRotationY(e),this.applyMatrix4(Vl),this}rotateZ(e){return Vl.makeRotationZ(e),this.applyMatrix4(Vl),this}translate(e,t,n){return Vl.makeTranslation(e,t,n),this.applyMatrix4(Vl),this}scale(e,t,n){return Vl.makeScale(e,t,n),this.applyMatrix4(Vl),this}lookAt(e){return af.lookAt(e),af.updateMatrix(),this.applyMatrix4(af.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Wu).negate(),this.translate(Wu.x,Wu.y,Wu.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let s=0,o=e.length;s<o;s++){const a=e[s];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Zi(n,3))}else{const n=Math.min(e.length,t.count);for(let s=0;s<n;s++){const o=e[s];t.setXYZ(s,o.x,o.y,o.z||0)}e.length>t.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new fa);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new it(-1/0,-1/0,-1/0),new it(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n<s;n++){const o=t[n];Gl.setFromBufferAttribute(o),this.morphTargetsRelative?(Ea.addVectors(this.boundingBox.min,Gl.min),this.boundingBox.expandByPoint(Ea),Ea.addVectors(this.boundingBox.max,Gl.max),this.boundingBox.expandByPoint(Ea)):(this.boundingBox.expandByPoint(Gl.min),this.boundingBox.expandByPoint(Gl.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 xe);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new it,1/0);return}if(e){const n=this.boundingSphere.center;if(Gl.setFromBufferAttribute(e),t)for(let o=0,a=t.length;o<a;o++){const c=t[o];qi.setFromBufferAttribute(c),this.morphTargetsRelative?(Ea.addVectors(Gl.min,qi.min),Gl.expandByPoint(Ea),Ea.addVectors(Gl.max,qi.max),Gl.expandByPoint(Ea)):(Gl.expandByPoint(qi.min),Gl.expandByPoint(qi.max))}Gl.getCenter(n);let s=0;for(let o=0,a=e.count;o<a;o++)Ea.fromBufferAttribute(e,o),s=Math.max(s,n.distanceToSquared(Ea));if(t)for(let o=0,a=t.length;o<a;o++){const c=t[o],u=this.morphTargetsRelative;for(let d=0,p=c.count;d<p;d++)Ea.fromBufferAttribute(c,d),u&&(Wu.fromBufferAttribute(e,d),Ea.add(Wu)),s=Math.max(s,n.distanceToSquared(Ea))}this.boundingSphere.radius=Math.sqrt(s),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=t.position,s=t.normal,o=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new es(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),c=[],u=[];for(let Ve=0;Ve<n.count;Ve++)c[Ve]=new it,u[Ve]=new it;const d=new it,p=new it,m=new it,y=new yn,M=new yn,T=new yn,G=new it,z=new it;function I(Ve,Ee,Oe){d.fromBufferAttribute(n,Ve),p.fromBufferAttribute(n,Ee),m.fromBufferAttribute(n,Oe),y.fromBufferAttribute(o,Ve),M.fromBufferAttribute(o,Ee),T.fromBufferAttribute(o,Oe),p.sub(d),m.sub(d),M.sub(y),T.sub(y);const dt=1/(M.x*T.y-T.x*M.y);isFinite(dt)&&(G.copy(p).multiplyScalar(T.y).addScaledVector(m,-M.y).multiplyScalar(dt),z.copy(m).multiplyScalar(M.x).addScaledVector(p,-T.x).multiplyScalar(dt),c[Ve].add(G),c[Ee].add(G),c[Oe].add(G),u[Ve].add(z),u[Ee].add(z),u[Oe].add(z))}let J=this.groups;J.length===0&&(J=[{start:0,count:e.count}]);for(let Ve=0,Ee=J.length;Ve<Ee;++Ve){const Oe=J[Ve],dt=Oe.start,Ut=Oe.count;for(let tn=dt,cn=dt+Ut;tn<cn;tn+=3)I(e.getX(tn+0),e.getX(tn+1),e.getX(tn+2))}const K=new it,re=new it,ve=new it,me=new it;function Le(Ve){ve.fromBufferAttribute(s,Ve),me.copy(ve);const Ee=c[Ve];K.copy(Ee),K.sub(ve.multiplyScalar(ve.dot(Ee))).normalize(),re.crossVectors(me,Ee);const dt=re.dot(u[Ve])<0?-1:1;a.setXYZW(Ve,K.x,K.y,K.z,dt)}for(let Ve=0,Ee=J.length;Ve<Ee;++Ve){const Oe=J[Ve],dt=Oe.start,Ut=Oe.count;for(let tn=dt,cn=dt+Ut;tn<cn;tn+=3)Le(e.getX(tn+0)),Le(e.getX(tn+1)),Le(e.getX(tn+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 es(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let y=0,M=n.count;y<M;y++)n.setXYZ(y,0,0,0);const s=new it,o=new it,a=new it,c=new it,u=new it,d=new it,p=new it,m=new it;if(e)for(let y=0,M=e.count;y<M;y+=3){const T=e.getX(y+0),G=e.getX(y+1),z=e.getX(y+2);s.fromBufferAttribute(t,T),o.fromBufferAttribute(t,G),a.fromBufferAttribute(t,z),p.subVectors(a,o),m.subVectors(s,o),p.cross(m),c.fromBufferAttribute(n,T),u.fromBufferAttribute(n,G),d.fromBufferAttribute(n,z),c.add(p),u.add(p),d.add(p),n.setXYZ(T,c.x,c.y,c.z),n.setXYZ(G,u.x,u.y,u.z),n.setXYZ(z,d.x,d.y,d.z)}else for(let y=0,M=t.count;y<M;y+=3)s.fromBufferAttribute(t,y+0),o.fromBufferAttribute(t,y+1),a.fromBufferAttribute(t,y+2),p.subVectors(a,o),m.subVectors(s,o),p.cross(m),n.setXYZ(y+0,p.x,p.y,p.z),n.setXYZ(y+1,p.x,p.y,p.z),n.setXYZ(y+2,p.x,p.y,p.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Ea.fromBufferAttribute(e,t),Ea.normalize(),e.setXYZ(t,Ea.x,Ea.y,Ea.z)}toNonIndexed(){function e(c,u){const d=c.array,p=c.itemSize,m=c.normalized,y=new d.constructor(u.length*p);let M=0,T=0;for(let G=0,z=u.length;G<z;G++){c.isInterleavedBufferAttribute?M=u[G]*c.data.stride+c.offset:M=u[G]*p;for(let I=0;I<p;I++)y[T++]=d[M++]}return new es(y,p,m)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new xr,n=this.index.array,s=this.attributes;for(const c in s){const u=s[c],d=e(u,n);t.setAttribute(c,d)}const o=this.morphAttributes;for(const c in o){const u=[],d=o[c];for(let p=0,m=d.length;p<m;p++){const y=d[p],M=e(y,n);u.push(M)}t.morphAttributes[c]=u}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let c=0,u=a.length;c<u;c++){const d=a[c];t.addGroup(d.start,d.count,d.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,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 u=this.parameters;for(const d in u)u[d]!==void 0&&(e[d]=u[d]);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 u in n){const d=n[u];e.data.attributes[u]=d.toJSON(e.data)}const s={};let o=!1;for(const u in this.morphAttributes){const d=this.morphAttributes[u],p=[];for(let m=0,y=d.length;m<y;m++){const M=d[m];p.push(M.toJSON(e.data))}p.length>0&&(s[u]=p,o=!0)}o&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const c=this.boundingSphere;return c!==null&&(e.data.boundingSphere=c.toJSON()),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());const s=e.attributes;for(const d in s){const p=s[d];this.setAttribute(d,p.clone(t))}const o=e.morphAttributes;for(const d in o){const p=[],m=o[d];for(let y=0,M=m.length;y<M;y++)p.push(m[y].clone(t));this.morphAttributes[d]=p}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let d=0,p=a.length;d<p;d++){const m=a[d];this.addGroup(m.start,m.count,m.materialIndex)}const c=e.boundingBox;c!==null&&(this.boundingBox=c.clone());const u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Wl=new Ft,hl=new hn,ps=new xe,Aa=new it,bs=new it,Fr=new it,ec=new it,yc=new it,hu=new it,td=new it,du=new it;class Ks extends Qr{constructor(e=new xr,t=new Hr){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,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=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=s.length;o<a;o++){const c=s[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=o}}}}getVertexPosition(e,t){const n=this.geometry,s=n.attributes.position,o=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(s,e);const c=this.morphTargetInfluences;if(o&&c){hu.set(0,0,0);for(let u=0,d=o.length;u<d;u++){const p=c[u],m=o[u];p!==0&&(yc.fromBufferAttribute(m,e),a?hu.addScaledVector(yc,p):hu.addScaledVector(yc.sub(t),p))}t.add(hu)}return t}raycast(e,t){const n=this.geometry,s=this.material,o=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),ps.copy(n.boundingSphere),ps.applyMatrix4(o),hl.copy(e.ray).recast(e.near),!(ps.containsPoint(hl.origin)===!1&&(hl.intersectSphere(ps,Aa)===null||hl.origin.distanceToSquared(Aa)>ip(e.far-e.near,2)))&&(Wl.copy(o).invert(),hl.copy(e.ray).applyMatrix4(Wl),!(n.boundingBox!==null&&hl.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,hl)))}_computeIntersections(e,t,n){let s;const o=this.geometry,a=this.material,c=o.index,u=o.attributes.position,d=o.attributes.uv,p=o.attributes.uv1,m=o.attributes.normal,y=o.groups,M=o.drawRange;if(c!==null)if(Array.isArray(a))for(let T=0,G=y.length;T<G;T++){const z=y[T],I=a[z.materialIndex],J=Math.max(z.start,M.start),K=Math.min(c.count,Math.min(z.start+z.count,M.start+M.count));for(let re=J,ve=K;re<ve;re+=3){const me=c.getX(re),Le=c.getX(re+1),Ve=c.getX(re+2);s=lf(this,I,e,n,d,p,m,me,Le,Ve),s&&(s.faceIndex=Math.floor(re/3),s.face.materialIndex=z.materialIndex,t.push(s))}}else{const T=Math.max(0,M.start),G=Math.min(c.count,M.start+M.count);for(let z=T,I=G;z<I;z+=3){const J=c.getX(z),K=c.getX(z+1),re=c.getX(z+2);s=lf(this,a,e,n,d,p,m,J,K,re),s&&(s.faceIndex=Math.floor(z/3),t.push(s))}}else if(u!==void 0)if(Array.isArray(a))for(let T=0,G=y.length;T<G;T++){const z=y[T],I=a[z.materialIndex],J=Math.max(z.start,M.start),K=Math.min(u.count,Math.min(z.start+z.count,M.start+M.count));for(let re=J,ve=K;re<ve;re+=3){const me=re,Le=re+1,Ve=re+2;s=lf(this,I,e,n,d,p,m,me,Le,Ve),s&&(s.faceIndex=Math.floor(re/3),s.face.materialIndex=z.materialIndex,t.push(s))}}else{const T=Math.max(0,M.start),G=Math.min(u.count,M.start+M.count);for(let z=T,I=G;z<I;z+=3){const J=z,K=z+1,re=z+2;s=lf(this,a,e,n,d,p,m,J,K,re),s&&(s.faceIndex=Math.floor(z/3),t.push(s))}}}}function nd(i,e,t,n,s,o,a,c){let u;if(e.side===Y?u=n.intersectTriangle(a,o,s,!0,c):u=n.intersectTriangle(s,o,a,e.side===W,c),u===null)return null;du.copy(c),du.applyMatrix4(i.matrixWorld);const d=t.ray.origin.distanceTo(du);return d<t.near||d>t.far?null:{distance:d,point:du.clone(),object:i}}function lf(i,e,t,n,s,o,a,c,u,d){i.getVertexPosition(c,bs),i.getVertexPosition(u,Fr),i.getVertexPosition(d,ec);const p=nd(i,e,t,n,bs,Fr,ec,td);if(p){const m=new it;ia.getBarycoord(td,bs,Fr,ec,m),s&&(p.uv=ia.getInterpolatedAttribute(s,c,u,d,m,new yn)),o&&(p.uv1=ia.getInterpolatedAttribute(o,c,u,d,m,new yn)),a&&(p.normal=ia.getInterpolatedAttribute(a,c,u,d,m,new it),p.normal.dot(n.direction)>0&&p.normal.multiplyScalar(-1));const y={a:c,b:u,c:d,normal:new it,materialIndex:0};ia.getNormal(bs,Fr,ec,y.normal),p.face=y,p.barycoord=m}return p}class Uc extends xr{constructor(e=1,t=1,n=1,s=1,o=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:o,depthSegments:a};const c=this;s=Math.floor(s),o=Math.floor(o),a=Math.floor(a);const u=[],d=[],p=[],m=[];let y=0,M=0;T("z","y","x",-1,-1,n,t,e,a,o,0),T("z","y","x",1,-1,n,t,-e,a,o,1),T("x","z","y",1,1,e,n,t,s,a,2),T("x","z","y",1,-1,e,n,-t,s,a,3),T("x","y","z",1,-1,e,t,n,s,o,4),T("x","y","z",-1,-1,e,t,-n,s,o,5),this.setIndex(u),this.setAttribute("position",new Zi(d,3)),this.setAttribute("normal",new Zi(p,3)),this.setAttribute("uv",new Zi(m,2));function T(G,z,I,J,K,re,ve,me,Le,Ve,Ee){const Oe=re/Le,dt=ve/Ve,Ut=re/2,tn=ve/2,cn=me/2,vn=Le+1,mn=Ve+1;let Yn=0,xn=0;const si=new it;for(let wn=0;wn<mn;wn++){const Gn=wn*dt-tn;for(let Si=0;Si<vn;Si++){const nr=Si*Oe-Ut;si[G]=nr*J,si[z]=Gn*K,si[I]=cn,d.push(si.x,si.y,si.z),si[G]=0,si[z]=0,si[I]=me>0?1:-1,p.push(si.x,si.y,si.z),m.push(Si/Le),m.push(1-wn/Ve),Yn+=1}}for(let wn=0;wn<Ve;wn++)for(let Gn=0;Gn<Le;Gn++){const Si=y+Gn+vn*wn,nr=y+Gn+vn*(wn+1),os=y+(Gn+1)+vn*(wn+1),Vn=y+(Gn+1)+vn*wn;u.push(Si,nr,Vn),u.push(nr,os,Vn),xn+=6}c.addGroup(M,xn,Ee),M+=xn,y+=Yn}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Uc(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function id(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const s=i[t][n];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=s.clone():Array.isArray(s)?e[t][n]=s.slice():e[t][n]=s}}return e}function el(i){const e={};for(let t=0;t<i.length;t++){const n=id(i[t]);for(const s in n)e[s]=n[s]}return e}function vh(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function fx(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ki.workingColorSpace}const fp={clone:id,merge:el};var qm=`void main() {
|
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
|
}`,Ym=`void main() {
|
|
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
|
}`;class kc extends Ei{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=qm,this.fragmentShader=Ym,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!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=id(e.uniforms),this.uniformsGroups=vh(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 s in this.uniforms){const a=this.uniforms[s].value;a&&a.isTexture?t.uniforms[s]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[s]={type:"m4",value:a.toArray()}:t.uniforms[s]={value:a}}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 s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Zm extends Qr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ft,this.projectionMatrix=new Ft,this.projectionMatrixInverse=new Ft,this.coordinateSystem=oo,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}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){return super.getWorldDirection(e).negate()}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)}}const rd=new it,y1=new yn,px=new yn;class ma extends Zm{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,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=Ua*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(uc*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Ua*2*Math.atan(Math.tan(uc*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){rd.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(rd.x,rd.y).multiplyScalar(-e/rd.z),rd.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(rd.x,rd.y).multiplyScalar(-e/rd.z)}getViewSize(e,t){return this.getViewBounds(e,y1,px),t.subVectors(px,y1)}setViewOffset(e,t,n,s,o,a){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=s,this.view.width=o,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(uc*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,o=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const u=a.fullWidth,d=a.fullHeight;o+=a.offsetX*s/u,t-=a.offsetY*n/d,s*=a.width/u,n*=a.height/d}const c=this.filmOffset;c!==0&&(o+=e*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(o,o+s,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),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 sd=-90,cf=1;class Hu extends Qr{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new ma(sd,cf,e,t);s.layers=this.layers,this.add(s);const o=new ma(sd,cf,e,t);o.layers=this.layers,this.add(o);const a=new ma(sd,cf,e,t);a.layers=this.layers,this.add(a);const c=new ma(sd,cf,e,t);c.layers=this.layers,this.add(c);const u=new ma(sd,cf,e,t);u.layers=this.layers,this.add(u);const d=new ma(sd,cf,e,t);d.layers=this.layers,this.add(d)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,s,o,a,c,u]=t;for(const d of t)this.remove(d);if(e===oo)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),o.up.set(0,0,-1),o.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),c.up.set(0,1,0),c.lookAt(0,0,1),u.up.set(0,1,0),u.lookAt(0,0,-1);else if(e===qa)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),o.up.set(0,0,1),o.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),c.up.set(0,-1,0),c.lookAt(0,0,1),u.up.set(0,-1,0),u.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const d of t)this.add(d),d.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[o,a,c,u,d,p]=this.children,m=e.getRenderTarget(),y=e.getActiveCubeFace(),M=e.getActiveMipmapLevel(),T=e.xr.enabled;e.xr.enabled=!1;const G=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,s),e.render(t,o),e.setRenderTarget(n,1,s),e.render(t,a),e.setRenderTarget(n,2,s),e.render(t,c),e.setRenderTarget(n,3,s),e.render(t,u),e.setRenderTarget(n,4,s),e.render(t,d),n.texture.generateMipmaps=G,e.setRenderTarget(n,5,s),e.render(t,p),e.setRenderTarget(m,y,M),e.xr.enabled=T,n.texture.needsPMREMUpdate=!0}}class xh extends Ho{constructor(e=[],t=De,n,s,o,a,c,u,d,p){super(e,t,n,s,o,a,c,u,d,p),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class O0 extends hc{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new xh(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}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 );
|
|
|
|
|
|
}
|
|
|
`},s=new Uc(5,5,5),o=new kc({name:"CubemapFromEquirect",uniforms:id(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Y,blending:pe});o.uniforms.tEquirect.value=t;const a=new Ks(s,o),c=t.minFilter;return t.minFilter===Qn&&(t.minFilter=Rn),new Hu(1,10,this).update(e,a),t.minFilter=c,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){const o=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,s);e.setRenderTarget(o)}}class dl extends Qr{constructor(){super(),this.isGroup=!0,this.type="Group"}}const uf={type:"move"};class $u{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new dl,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 dl,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new it,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new it),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new dl,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new it,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new it),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 s=null,o=null,a=null;const c=this._targetRay,u=this._grip,d=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(d&&e.hand){a=!0;for(const G of e.hand.values()){const z=t.getJointPose(G,n),I=this._getHandJoint(d,G);z!==null&&(I.matrix.fromArray(z.transform.matrix),I.matrix.decompose(I.position,I.rotation,I.scale),I.matrixWorldNeedsUpdate=!0,I.jointRadius=z.radius),I.visible=z!==null}const p=d.joints["index-finger-tip"],m=d.joints["thumb-tip"],y=p.position.distanceTo(m.position),M=.02,T=.005;d.inputState.pinching&&y>M+T?(d.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!d.inputState.pinching&&y<=M-T&&(d.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(o=t.getPose(e.gripSpace,n),o!==null&&(u.matrix.fromArray(o.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,o.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(o.linearVelocity)):u.hasLinearVelocity=!1,o.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(o.angularVelocity)):u.hasAngularVelocity=!1));c!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&o!==null&&(s=o),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,this.dispatchEvent(uf)))}return c!==null&&(c.visible=s!==null),u!==null&&(u.visible=o!==null),d!==null&&(d.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new dl;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class F0{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new jn(e),this.density=t}clone(){return new F0(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class pp{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new jn(e),this.near=t,this.far=n}clone(){return new pp(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Km extends Qr{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Qi,this.environmentIntensity=1,this.environmentRotation=new Qi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__!="undefined"&&__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,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),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.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class ju{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Uu,this.updateRanges=[],this.version=0,this.uuid=xl()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}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 s=0,o=this.stride;s<o;s++)this.array[e+s]=t.array[n+s];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=xl()),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=xl()),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 Cl=new it;class hf{constructor(e,t,n,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=s}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++)Cl.fromBufferAttribute(this,t),Cl.applyMatrix4(e),this.setXYZ(t,Cl.x,Cl.y,Cl.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Cl.fromBufferAttribute(this,t),Cl.applyNormalMatrix(e),this.setXYZ(t,Cl.x,Cl.y,Cl.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Cl.fromBufferAttribute(this,t),Cl.transformDirection(e),this.setXYZ(t,Cl.x,Cl.y,Cl.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Za(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=cs(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=cs(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=cs(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=cs(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=cs(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=Za(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Za(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Za(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Za(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=cs(t,this.array),n=cs(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=cs(t,this.array),n=cs(n,this.array),s=cs(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this}setXYZW(e,t,n,s,o){return e=e*this.data.stride+this.offset,this.normalized&&(t=cs(t,this.array),n=cs(n,this.array),s=cs(s,this.array),o=cs(o,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this.data.array[e+3]=o,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 s=n*this.data.stride+this.offset;for(let o=0;o<this.itemSize;o++)t.push(this.data.array[s+o])}return new es(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 hf(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 s=n*this.data.stride+this.offset;for(let o=0;o<this.itemSize;o++)t.push(this.data.array[s+o])}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 mp extends Ei{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new jn(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 _h;const gp=new it,od=new it,Ca=new it,zc=new yn,ad=new yn,ld=new Ft,bh=new it,fu=new it,Xu=new it,cd=new yn,ud=new yn,B0=new yn;class Jm extends null{constructor(e=new mp){if(super(),this.isSprite=!0,this.type="Sprite",_h===void 0){_h=new xr;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 ju(t,5);_h.setIndex([0,1,2,0,2,3]),_h.setAttribute("position",new hf(n,3,0,!1)),_h.setAttribute("uv",new hf(n,2,3,!1))}this.geometry=_h,this.material=e,this.center=new yn(.5,.5),this.count=1}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),od.setFromMatrixScale(this.matrixWorld),ld.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ca.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&od.multiplyScalar(-Ca.z);const n=this.material.rotation;let s,o;n!==0&&(o=Math.cos(n),s=Math.sin(n));const a=this.center;wh(bh.set(-.5,-.5,0),Ca,a,od,s,o),wh(fu.set(.5,-.5,0),Ca,a,od,s,o),wh(Xu.set(.5,.5,0),Ca,a,od,s,o),cd.set(0,0),ud.set(1,0),B0.set(1,1);let c=e.ray.intersectTriangle(bh,fu,Xu,!1,gp);if(c===null&&(wh(fu.set(-.5,.5,0),Ca,a,od,s,o),ud.set(0,1),c=e.ray.intersectTriangle(bh,Xu,fu,!1,gp),c===null))return;const u=e.ray.origin.distanceTo(gp);u<e.near||u>e.far||t.push({distance:u,point:gp.clone(),uv:ia.getInterpolation(gp,bh,fu,Xu,cd,ud,B0,new yn),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 wh(i,e,t,n,s,o){zc.subVectors(i,t).addScalar(.5).multiply(n),s!==void 0?(ad.x=o*zc.x-s*zc.y,ad.y=s*zc.x+o*zc.y):ad.copy(zc),i.copy(e),i.x+=ad.x,i.y+=ad.y,i.applyMatrix4(ld)}const hd=new it,U0=new it;class k0 extends null{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,s=t.length;n<s;n++){const o=t[n];this.addLevel(o.object.clone(),o.distance,o.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);const s=this.levels;let o;for(o=0;o<s.length&&!(t<s[o].distance);o++);return s.splice(o,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){const s=t.splice(n,1);return this.remove(s[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,s;for(n=1,s=t.length;n<s;n++){let o=t[n].distance;if(t[n].object.visible&&(o-=o*t[n].hysteresis),e<o)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){hd.setFromMatrixPosition(this.matrixWorld);const s=e.ray.origin.distanceTo(hd);this.getObjectForDistance(s).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){hd.setFromMatrixPosition(e.matrixWorld),U0.setFromMatrixPosition(this.matrixWorld);const n=hd.distanceTo(U0)/e.zoom;t[0].object.visible=!0;let s,o;for(s=1,o=t.length;s<o;s++){let a=t[s].distance;if(t[s].object.visible&&(a-=a*t[s].hysteresis),n>=a)t[s-1].object.visible=!1,t[s].object.visible=!0;else break}for(this._currentLevel=s-1;s<o;s++)t[s].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 s=0,o=n.length;s<o;s++){const a=n[s];t.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return t}}const z0=new it,V0=new mr,yp=new mr,Qm=new it,G0=new Ft,eg=new it,tg=new xe,W0=new Ft,ng=new hn;class v1 extends null{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=nn,this.bindMatrix=new Ft,this.bindMatrixInverse=new Ft,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new fa),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,eg),this.boundingBox.expandByPoint(eg)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new xe),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,eg),this.boundingSphere.expandByPoint(eg)}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,s=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),tg.copy(this.boundingSphere),tg.applyMatrix4(s),e.ray.intersectsSphere(tg)!==!1&&(W0.copy(s).invert(),ng.copy(e.ray).applyMatrix4(W0),!(this.boundingBox!==null&&ng.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,ng)))}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 mr,t=this.geometry.attributes.skinWeight;for(let n=0,s=t.count;n<s;n++){e.fromBufferAttribute(t,n);const o=1/e.manhattanLength();o!==1/0?e.multiplyScalar(o):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===nn?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===we?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,s=this.geometry;V0.fromBufferAttribute(s.attributes.skinIndex,e),yp.fromBufferAttribute(s.attributes.skinWeight,e),z0.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let o=0;o<4;o++){const a=yp.getComponent(o);if(a!==0){const c=V0.getComponent(o);G0.multiplyMatrices(n.bones[c].matrixWorld,n.boneInverses[c]),t.addScaledVector(Qm.copy(z0).applyMatrix4(G0),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class H0 extends null{constructor(){super(),this.isBone=!0,this.type="Bone"}}class tc extends Ho{constructor(e=null,t=1,n=1,s,o,a,c,u,d=Ct,p=Ct,m,y){super(null,a,c,u,d,p,s,o,m,y),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const ig=new Ft,mx=new Ft;class vp{constructor(e=[],t=[]){this.uuid=xl(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,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,s=this.bones.length;n<s;n++)this.boneInverses.push(new Ft)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Ft;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,s=this.boneTexture;for(let o=0,a=e.length;o<a;o++){const c=e[o]?e[o].matrixWorld:mx;ig.multiplyMatrices(c,t[o]),ig.toArray(n,o*16)}s!==null&&(s.needsUpdate=!0)}clone(){return new vp(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new tc(t,e,e,D,ys);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const s=this.bones[t];if(s.name===e)return s}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,s=e.bones.length;n<s;n++){const o=e.bones[n];let a=t[o];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",o),a=new H0),this.bones.push(a),this.boneInverses.push(new Ft().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let s=0,o=t.length;s<o;s++){const a=t[s];e.bones.push(a.uuid);const c=n[s];e.boneInverses.push(c.toArray())}return e}}class Vc extends es{constructor(e,t,n,s=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}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 dd=new Ft,pu=new Ft,xp=null,gx=new fa,$0=new Ft,qu=new Ks,mu=new xe;class yx extends null{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Vc(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let s=0;s<n;s++)this.setMatrixAt(s,$0)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new fa),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,dd),gx.copy(e.boundingBox).applyMatrix4(dd),this.boundingBox.union(gx)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new xe),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,dd),mu.copy(e.boundingSphere).applyMatrix4(dd),this.boundingSphere.union(mu)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),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)}getMorphAt(e,t){const n=t.morphTargetInfluences,s=this.morphTexture.source.data.data,o=n.length+1,a=e*o+1;for(let c=0;c<n.length;c++)n[c]=s[a+c]}raycast(e,t){const n=this.matrixWorld,s=this.count;if(qu.geometry=this.geometry,qu.material=this.material,qu.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),mu.copy(this.boundingSphere),mu.applyMatrix4(n),e.ray.intersectsSphere(mu)!==!1))for(let o=0;o<s;o++){this.getMatrixAt(o,dd),pu.multiplyMatrices(n,dd),qu.matrixWorld=pu,qu.raycast(e,xp);for(let a=0,c=xp.length;a<c;a++){const u=xp[a];u.instanceId=o,u.object=this,t.push(u)}xp.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Vc(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,s=n.length+1;this.morphTexture===null&&(this.morphTexture=new tc(new Float32Array(s*this.count),s,this.count,F,ys));const o=this.morphTexture.source.data.data;let a=0;for(let d=0;d<n.length;d++)a+=n[d];const c=this.geometry.morphTargetsRelative?1:1-a,u=s*e;o[u]=c,o.set(n,u+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const df=new it,vx=new it,x1=new jr;class Rl{constructor(e=new it(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,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const s=df.subVectors(n,t).cross(vx.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,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(df),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const o=-(e.start.dot(this.normal)+this.constant)/s;return o<0||o>1?null:t.copy(e.start).addScaledVector(n,o)}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||x1.getNormalMatrix(e),s=this.coplanarPoint(df).applyMatrix4(e),o=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(o),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 Gc=new xe,_1=new yn(.5,.5),ff=new it;class pf{constructor(e=new Rl,t=new Rl,n=new Rl,s=new Rl,o=new Rl,a=new Rl){this.planes=[e,t,n,s,o,a]}set(e,t,n,s,o,a){const c=this.planes;return c[0].copy(e),c[1].copy(t),c[2].copy(n),c[3].copy(s),c[4].copy(o),c[5].copy(a),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=oo,n=!1){const s=this.planes,o=e.elements,a=o[0],c=o[1],u=o[2],d=o[3],p=o[4],m=o[5],y=o[6],M=o[7],T=o[8],G=o[9],z=o[10],I=o[11],J=o[12],K=o[13],re=o[14],ve=o[15];if(s[0].setComponents(d-a,M-p,I-T,ve-J).normalize(),s[1].setComponents(d+a,M+p,I+T,ve+J).normalize(),s[2].setComponents(d+c,M+m,I+G,ve+K).normalize(),s[3].setComponents(d-c,M-m,I-G,ve-K).normalize(),n)s[4].setComponents(u,y,z,re).normalize(),s[5].setComponents(d-u,M-y,I-z,ve-re).normalize();else if(s[4].setComponents(d-u,M-y,I-z,ve-re).normalize(),t===oo)s[5].setComponents(d+u,M+y,I+z,ve+re).normalize();else if(t===qa)s[5].setComponents(u,y,z,re).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(),Gc.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Gc.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Gc)}intersectsSprite(e){Gc.center.set(0,0,0);const t=_1.distanceTo(e.center);return Gc.radius=.7071067811865476+t,Gc.applyMatrix4(e.matrixWorld),this.intersectsSphere(Gc)}intersectsSphere(e){const t=this.planes,n=e.center,s=-e.radius;for(let o=0;o<6;o++)if(t[o].distanceToPoint(n)<s)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const s=t[n];if(ff.x=s.normal.x>0?e.max.x:e.min.x,ff.y=s.normal.y>0?e.max.y:e.min.y,ff.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(ff)<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)}}const gu=new Ft,Nl=new pf;class yu{constructor(){this.coordinateSystem=oo}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const s=t.cameras[n];if(gu.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse),Nl.setFromProjectionMatrix(gu,s.coordinateSystem,s.reversedDepth),Nl.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const s=t.cameras[n];if(gu.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse),Nl.setFromProjectionMatrix(gu,s.coordinateSystem,s.reversedDepth),Nl.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const s=t.cameras[n];if(gu.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse),Nl.setFromProjectionMatrix(gu,s.coordinateSystem,s.reversedDepth),Nl.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const s=t.cameras[n];if(gu.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse),Nl.setFromProjectionMatrix(gu,s.coordinateSystem,s.reversedDepth),Nl.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const s=t.cameras[n];if(gu.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse),Nl.setFromProjectionMatrix(gu,s.coordinateSystem,s.reversedDepth),Nl.containsPoint(e))return!0}return!1}clone(){return new yu}}function j0(i,e){return i-e}function rg(i,e){return i.z-e.z}function X0(i,e){return e.z-i.z}class vu{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,s){const o=this.pool,a=this.list;this.index>=o.length&&o.push({start:-1,count:-1,z:-1,index:-1});const c=o[this.index];a.push(c),this.index++,c.start=e,c.count=t,c.z=n,c.index=s}reset(){this.list.length=0,this.index=0}}const jo=new Ft,q0=new jn(1,1,1),sg=new pf,b1=new yu,og=new fa,fd=new xe,tl=new it,xx=new it,_x=new it,Y0=new vu,Ga=new Ks,xu=null;function _p(i,e,t=0){const n=e.itemSize;if(i.isInterleavedBufferAttribute||i.array.constructor!==e.array.constructor){const s=i.count;for(let o=0;o<s;o++)for(let a=0;a<n;a++)e.setComponent(o+t,a,i.getComponent(o,a))}else e.array.set(i.array,t*n);e.needsUpdate=!0}function Mh(i,e){if(i.constructor!==e.constructor){const t=Math.min(i.length,e.length);for(let n=0;n<t;n++)e[n]=i[n]}else{const t=Math.min(i.length,e.length);e.set(new i.constructor(i.buffer,0,t))}}class w1 extends null{constructor(e,t,n=t*2,s){super(new xr,s),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),n=new tc(t,e,e,D,ys);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),n=new tc(t,e,e,X,ls);this._indirectTexture=n}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),n=new tc(t,e,e,D,ys);n.colorSpace=Ki.workingColorSpace,this._colorsTexture=n}_initializeGeometry(e){const t=this.geometry,n=this._maxVertexCount,s=this._maxIndexCount;if(this._geometryInitialized===!1){for(const o in e.attributes){const a=e.getAttribute(o),{array:c,itemSize:u,normalized:d}=a,p=new c.constructor(n*u),m=new es(p,u,d);t.setAttribute(o,m)}if(e.getIndex()!==null){const o=n>65535?new Uint32Array(s):new Uint16Array(s);t.setIndex(new es(o,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const s=e.getAttribute(n),o=t.getAttribute(n);if(s.itemSize!==o.itemSize||s.normalized!==o.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new fa);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,s=t.length;n<s;n++){if(t[n].active===!1)continue;const o=t[n].geometryIndex;this.getMatrixAt(n,jo),this.getBoundingBoxAt(o,og).applyMatrix4(jo),e.union(og)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new xe);const e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let n=0,s=t.length;n<s;n++){if(t[n].active===!1)continue;const o=t[n].geometryIndex;this.getMatrixAt(n,jo),this.getBoundingSphereAt(o,fd).applyMatrix4(jo),e.union(fd)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:e};let s=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(j0),s=this._availableInstanceIds.shift(),this._instanceInfo[s]=n):(s=this._instanceInfo.length,this._instanceInfo.push(n));const o=this._matricesTexture;jo.identity().toArray(o.image.data,s*16),o.needsUpdate=!0;const a=this._colorsTexture;return a&&(q0.toArray(a.image.data,s*4),a.needsUpdate=!0),this._visibilityChanged=!0,s}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);const s={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},o=this._geometryInfo;s.vertexStart=this._nextVertexStart,s.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const a=e.getIndex();if(a!==null&&(s.indexStart=this._nextIndexStart,s.reservedIndexCount=n===-1?a.count:n),s.indexStart!==-1&&s.indexStart+s.reservedIndexCount>this._maxIndexCount||s.vertexStart+s.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let u;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(j0),u=this._availableGeometryIds.shift(),o[u]=s):(u=this._geometryCount,this._geometryCount++,o.push(s)),this.setGeometryAt(u,e),this._nextIndexStart=s.indexStart+s.reservedIndexCount,this._nextVertexStart=s.vertexStart+s.reservedVertexCount,u}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,s=n.getIndex()!==null,o=n.getIndex(),a=t.getIndex(),c=this._geometryInfo[e];if(s&&a.count>c.reservedIndexCount||t.attributes.position.count>c.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const u=c.vertexStart,d=c.reservedVertexCount;c.vertexCount=t.getAttribute("position").count;for(const p in n.attributes){const m=t.getAttribute(p),y=n.getAttribute(p);_p(m,y,u);const M=m.itemSize;for(let T=m.count,G=d;T<G;T++){const z=u+T;for(let I=0;I<M;I++)y.setComponent(z,I,0)}y.needsUpdate=!0,y.addUpdateRange(u*M,d*M)}if(s){const p=c.indexStart,m=c.reservedIndexCount;c.indexCount=t.getIndex().count;for(let y=0;y<a.count;y++)o.setX(p+y,u+a.getX(y));for(let y=a.count,M=m;y<M;y++)o.setX(p+y,u);o.needsUpdate=!0,o.addUpdateRange(p,c.reservedIndexCount)}return c.start=s?c.indexStart:c.vertexStart,c.count=s?c.indexCount:c.vertexCount,c.boundingBox=null,t.boundingBox!==null&&(c.boundingBox=t.boundingBox.clone()),c.boundingSphere=null,t.boundingSphere!==null&&(c.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;const n=this._instanceInfo;for(let s=0,o=n.length;s<o;s++)n[s].active&&n[s].geometryIndex===e&&this.deleteInstance(s);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0;const n=this._geometryInfo,s=n.map((a,c)=>c).sort((a,c)=>n[a].vertexStart-n[c].vertexStart),o=this.geometry;for(let a=0,c=n.length;a<c;a++){const u=s[a],d=n[u];if(d.active!==!1){if(o.index!==null){if(d.indexStart!==t){const{indexStart:p,vertexStart:m,reservedIndexCount:y}=d,M=o.index,T=M.array,G=e-m;for(let z=p;z<p+y;z++)T[z]=T[z]+G;M.array.copyWithin(t,p,p+y),M.addUpdateRange(t,y),d.indexStart=t}t+=d.reservedIndexCount}if(d.vertexStart!==e){const{vertexStart:p,reservedVertexCount:m}=d,y=o.attributes;for(const M in y){const T=y[M],{array:G,itemSize:z}=T;G.copyWithin(e*z,p*z,(p+m)*z),T.addUpdateRange(e*z,m*z)}d.vertexStart=e}e+=d.reservedVertexCount,d.start=o.index?d.indexStart:d.vertexStart,this._nextIndexStart=o.index?d.indexStart+d.reservedIndexCount:0,this._nextVertexStart=d.vertexStart+d.reservedVertexCount}}return this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,s=this._geometryInfo[e];if(s.boundingBox===null){const o=new fa,a=n.index,c=n.attributes.position;for(let u=s.start,d=s.start+s.count;u<d;u++){let p=u;a&&(p=a.getX(p)),o.expandByPoint(tl.fromBufferAttribute(c,p))}s.boundingBox=o}return t.copy(s.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,s=this._geometryInfo[e];if(s.boundingSphere===null){const o=new xe;this.getBoundingBoxAt(e,og),og.getCenter(o.center);const a=n.index,c=n.attributes.position;let u=0;for(let d=s.start,p=s.start+s.count;d<p;d++){let m=d;a&&(m=a.getX(m)),tl.fromBufferAttribute(c,m),u=Math.max(u,o.center.distanceToSquared(tl))}o.radius=Math.sqrt(u),s.boundingSphere=o}return t.copy(s.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const n=this._matricesTexture,s=this._matricesTexture.image.data;return t.toArray(s,e*16),n.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);const n=this._geometryInfo[e];return t.vertexStart=n.vertexStart,t.vertexCount=n.vertexCount,t.reservedVertexCount=n.reservedVertexCount,t.indexStart=n.indexStart,t.indexCount=n.indexCount,t.reservedIndexCount=n.reservedIndexCount,t.start=n.start,t.count=n.count,t}setInstanceCount(e){const t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(j0);t[t.length-1]===n.length-1;)n.pop(),t.pop();if(e<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);const s=new Int32Array(e),o=new Int32Array(e);Mh(this._multiDrawCounts,s),Mh(this._multiDrawStarts,o),this._multiDrawCounts=s,this._multiDrawStarts=o,this._maxInstanceCount=e;const a=this._indirectTexture,c=this._matricesTexture,u=this._colorsTexture;a.dispose(),this._initIndirectTexture(),Mh(a.image.data,this._indirectTexture.image.data),c.dispose(),this._initMatricesTexture(),Mh(c.image.data,this._matricesTexture.image.data),u&&(u.dispose(),this._initColorsTexture(),Mh(u.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){const n=[...this._geometryInfo].filter(c=>c.active);if(Math.max(...n.map(c=>c.vertexStart+c.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(u=>u.indexStart+u.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const o=this.geometry;o.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new xr,this._initializeGeometry(o));const a=this.geometry;o.index&&Mh(o.index.array,a.index.array);for(const c in o.attributes)Mh(o.attributes[c].array,a.attributes[c].array)}raycast(e,t){const n=this._instanceInfo,s=this._geometryInfo,o=this.matrixWorld,a=this.geometry;Ga.material=this.material,Ga.geometry.index=a.index,Ga.geometry.attributes=a.attributes,Ga.geometry.boundingBox===null&&(Ga.geometry.boundingBox=new fa),Ga.geometry.boundingSphere===null&&(Ga.geometry.boundingSphere=new xe);for(let c=0,u=n.length;c<u;c++){if(!n[c].visible||!n[c].active)continue;const d=n[c].geometryIndex,p=s[d];Ga.geometry.setDrawRange(p.start,p.count),this.getMatrixAt(c,Ga.matrixWorld).premultiply(o),this.getBoundingBoxAt(d,Ga.geometry.boundingBox),this.getBoundingSphereAt(d,Ga.geometry.boundingSphere),Ga.raycast(e,xu);for(let m=0,y=xu.length;m<y;m++){const M=xu[m];M.object=this,M.batchId=c,t.push(M)}xu.length=0}Ga.material=null,Ga.geometry.index=null,Ga.geometry.attributes={},Ga.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>cc(Ys({},t),{boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>Ys({},t)),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,n,s,o){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=s.getIndex(),c=a===null?1:a.array.BYTES_PER_ELEMENT,u=this._instanceInfo,d=this._multiDrawStarts,p=this._multiDrawCounts,m=this._geometryInfo,y=this.perObjectFrustumCulled,M=this._indirectTexture,T=M.image.data,G=n.isArrayCamera?b1:sg;y&&!n.isArrayCamera&&(jo.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),sg.setFromProjectionMatrix(jo,n.coordinateSystem,n.reversedDepth));let z=0;if(this.sortObjects){jo.copy(this.matrixWorld).invert(),tl.setFromMatrixPosition(n.matrixWorld).applyMatrix4(jo),xx.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(jo);for(let K=0,re=u.length;K<re;K++)if(u[K].visible&&u[K].active){const ve=u[K].geometryIndex;this.getMatrixAt(K,jo),this.getBoundingSphereAt(ve,fd).applyMatrix4(jo);let me=!1;if(y&&(me=!G.intersectsSphere(fd,n)),!me){const Le=m[ve],Ve=_x.subVectors(fd.center,tl).dot(xx);Y0.push(Le.start,Le.count,Ve,K)}}const I=Y0.list,J=this.customSort;J===null?I.sort(o.transparent?X0:rg):J.call(this,I,n);for(let K=0,re=I.length;K<re;K++){const ve=I[K];d[z]=ve.start*c,p[z]=ve.count,T[z]=ve.index,z++}Y0.reset()}else for(let I=0,J=u.length;I<J;I++)if(u[I].visible&&u[I].active){const K=u[I].geometryIndex;let re=!1;if(y&&(this.getMatrixAt(I,jo),this.getBoundingSphereAt(K,fd).applyMatrix4(jo),re=!G.intersectsSphere(fd,n)),!re){const ve=m[K];d[z]=ve.start*c,p[z]=ve.count,T[z]=I,z++}}M.needsUpdate=!0,this._multiDrawCount=z,this._visibilityChanged=!1}onBeforeShadow(e,t,n,s,o,a){this.onBeforeRender(e,null,s,o,a)}}class nl extends Ei{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new jn(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 Wa=new it,pd=new it,bx=new Ft,Wc=new hn,ag=new xe,Pl=new it,bp=new it;class Sh extends Qr{constructor(e=new xr,t=new nl){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():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 s=1,o=t.count;s<o;s++)Wa.fromBufferAttribute(t,s-1),pd.fromBufferAttribute(t,s),n[s]=n[s-1],n[s]+=Wa.distanceTo(pd);e.setAttribute("lineDistance",new Zi(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,s=this.matrixWorld,o=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),ag.copy(n.boundingSphere),ag.applyMatrix4(s),ag.radius+=o,e.ray.intersectsSphere(ag)===!1)return;bx.copy(s).invert(),Wc.copy(e.ray).applyMatrix4(bx);const c=o/((this.scale.x+this.scale.y+this.scale.z)/3),u=c*c,d=this.isLineSegments?2:1,p=n.index,y=n.attributes.position;if(p!==null){const M=Math.max(0,a.start),T=Math.min(p.count,a.start+a.count);for(let G=M,z=T-1;G<z;G+=d){const I=p.getX(G),J=p.getX(G+1),K=wp(this,e,Wc,u,I,J,G);K&&t.push(K)}if(this.isLineLoop){const G=p.getX(T-1),z=p.getX(M),I=wp(this,e,Wc,u,G,z,T-1);I&&t.push(I)}}else{const M=Math.max(0,a.start),T=Math.min(y.count,a.start+a.count);for(let G=M,z=T-1;G<z;G+=d){const I=wp(this,e,Wc,u,G,G+1,G);I&&t.push(I)}if(this.isLineLoop){const G=wp(this,e,Wc,u,T-1,M,T-1);G&&t.push(G)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=s.length;o<a;o++){const c=s[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=o}}}}}function wp(i,e,t,n,s,o,a){const c=i.geometry.attributes.position;if(Wa.fromBufferAttribute(c,s),pd.fromBufferAttribute(c,o),t.distanceSqToSegment(Wa,pd,Pl,bp)>n)return;Pl.applyMatrix4(i.matrixWorld);const d=e.ray.origin.distanceTo(Pl);if(!(d<e.near||d>e.far))return{distance:d,point:bp.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}const mf=new it,Mp=new it;class lg extends null{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 s=0,o=t.count;s<o;s+=2)mf.fromBufferAttribute(t,s),Mp.fromBufferAttribute(t,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+mf.distanceTo(Mp);e.setAttribute("lineDistance",new Zi(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class wx extends null{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class gf extends Ei{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new jn(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 Sp=new Ft,cg=new hn,Tp=new xe,Ep=new it;class M1 extends null{constructor(e=new xr,t=new gf){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,s=this.matrixWorld,o=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Tp.copy(n.boundingSphere),Tp.applyMatrix4(s),Tp.radius+=o,e.ray.intersectsSphere(Tp)===!1)return;Sp.copy(s).invert(),cg.copy(e.ray).applyMatrix4(Sp);const c=o/((this.scale.x+this.scale.y+this.scale.z)/3),u=c*c,d=n.index,m=n.attributes.position;if(d!==null){const y=Math.max(0,a.start),M=Math.min(d.count,a.start+a.count);for(let T=y,G=M;T<G;T++){const z=d.getX(T);Ep.fromBufferAttribute(m,z),Z0(Ep,z,u,s,e,t,this)}}else{const y=Math.max(0,a.start),M=Math.min(m.count,a.start+a.count);for(let T=y,G=M;T<G;T++)Ep.fromBufferAttribute(m,T),Z0(Ep,T,u,s,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=s.length;o<a;o++){const c=s[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=o}}}}}function Z0(i,e,t,n,s,o,a){const c=cg.distanceSqToPoint(i);if(c<t){const u=new it;cg.closestPointToPoint(i,u),u.applyMatrix4(n);const d=s.ray.origin.distanceTo(u);if(d<s.near||d>s.far)return;o.push({distance:d,distanceToRay:Math.sqrt(c),point:u,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class S1 extends null{constructor(e,t,n,s,o=Rn,a=Rn,c,u,d){super(e,t,n,s,o,a,c,u,d),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const p=this;function m(){p.needsUpdate=!0,p._requestVideoFrameCallbackId=e.requestVideoFrameCallback(m)}"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(m))}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)}dispose(){this._requestVideoFrameCallbackId!==0&&this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),super.dispose()}}class Mx extends null{constructor(e,t,n,s,o,a,c,u){super({},e,t,n,s,o,a,c,u),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class Ap extends Ho{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Ct,this.minFilter=Ct,this.generateMipmaps=!1,this.needsUpdate=!0}}class ug extends null{constructor(e,t,n,s,o,a,c,u,d,p,m,y){super(null,a,c,u,d,p,s,o,m,y),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class vE extends null{constructor(e,t,n,s,o,a){super(e,t,n,o,a),this.isCompressedArrayTexture=!0,this.image.depth=s,this.wrapR=$e,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class T1 extends null{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,De),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class L3 extends null{constructor(e,t,n,s,o,a,c,u,d){super(e,t,n,s,o,a,c,u,d),this.isCanvasTexture=!0,this.needsUpdate=!0}}class vc extends Ho{constructor(e,t,n=ls,s,o,a,c=Ct,u=Ct,d,p=U,m=1){if(p!==U&&p!==_)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const y={width:e,height:t,depth:m};super(y,s,o,a,c,u,p,n,d),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Mo(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class E1 extends Ho{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class K0 extends xr{constructor(e=1,t=1,n=4,s=8,o=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:s,heightSegments:o},t=Math.max(0,t),n=Math.max(1,Math.floor(n)),s=Math.max(3,Math.floor(s)),o=Math.max(1,Math.floor(o));const a=[],c=[],u=[],d=[],p=t/2,m=Math.PI/2*e,y=t,M=2*m+y,T=n*2+o,G=s+1,z=new it,I=new it;for(let J=0;J<=T;J++){let K=0,re=0,ve=0,me=0;if(J<=n){const Ee=J/n,Oe=Ee*Math.PI/2;re=-p-e*Math.cos(Oe),ve=e*Math.sin(Oe),me=-e*Math.cos(Oe),K=Ee*m}else if(J<=n+o){const Ee=(J-n)/o;re=-p+Ee*t,ve=e,me=0,K=m+Ee*y}else{const Ee=(J-n-o)/n,Oe=Ee*Math.PI/2;re=p+e*Math.sin(Oe),ve=e*Math.cos(Oe),me=e*Math.sin(Oe),K=m+y+Ee*m}const Le=Math.max(0,Math.min(1,K/M));let Ve=0;J===0?Ve=.5/s:J===T&&(Ve=-.5/s);for(let Ee=0;Ee<=s;Ee++){const Oe=Ee/s,dt=Oe*Math.PI*2,Ut=Math.sin(dt),tn=Math.cos(dt);I.x=-ve*tn,I.y=re,I.z=ve*Ut,c.push(I.x,I.y,I.z),z.set(-ve*tn,me,ve*Ut),z.normalize(),u.push(z.x,z.y,z.z),d.push(Oe+Ve,Le)}if(J>0){const Ee=(J-1)*G;for(let Oe=0;Oe<s;Oe++){const dt=Ee+Oe,Ut=Ee+Oe+1,tn=J*G+Oe,cn=J*G+Oe+1;a.push(dt,Ut,tn),a.push(Ut,cn,tn)}}}this.setIndex(a),this.setAttribute("position",new Zi(c,3)),this.setAttribute("normal",new Zi(u,3)),this.setAttribute("uv",new Zi(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new K0(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class Sx extends xr{constructor(e=1,t=32,n=0,s=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:s},t=Math.max(3,t);const o=[],a=[],c=[],u=[],d=new it,p=new yn;a.push(0,0,0),c.push(0,0,1),u.push(.5,.5);for(let m=0,y=3;m<=t;m++,y+=3){const M=n+m/t*s;d.x=e*Math.cos(M),d.y=e*Math.sin(M),a.push(d.x,d.y,d.z),c.push(0,0,1),p.x=(a[y]/e+1)/2,p.y=(a[y+1]/e+1)/2,u.push(p.x,p.y)}for(let m=1;m<=t;m++)o.push(m,m+1,0);this.setIndex(o),this.setAttribute("position",new Zi(a,3)),this.setAttribute("normal",new Zi(c,3)),this.setAttribute("uv",new Zi(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Sx(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Cp extends xr{constructor(e=1,t=1,n=1,s=32,o=1,a=!1,c=0,u=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:s,heightSegments:o,openEnded:a,thetaStart:c,thetaLength:u};const d=this;s=Math.floor(s),o=Math.floor(o);const p=[],m=[],y=[],M=[];let T=0;const G=[],z=n/2;let I=0;J(),a===!1&&(e>0&&K(!0),t>0&&K(!1)),this.setIndex(p),this.setAttribute("position",new Zi(m,3)),this.setAttribute("normal",new Zi(y,3)),this.setAttribute("uv",new Zi(M,2));function J(){const re=new it,ve=new it;let me=0;const Le=(t-e)/n;for(let Ve=0;Ve<=o;Ve++){const Ee=[],Oe=Ve/o,dt=Oe*(t-e)+e;for(let Ut=0;Ut<=s;Ut++){const tn=Ut/s,cn=tn*u+c,vn=Math.sin(cn),mn=Math.cos(cn);ve.x=dt*vn,ve.y=-Oe*n+z,ve.z=dt*mn,m.push(ve.x,ve.y,ve.z),re.set(vn,Le,mn).normalize(),y.push(re.x,re.y,re.z),M.push(tn,1-Oe),Ee.push(T++)}G.push(Ee)}for(let Ve=0;Ve<s;Ve++)for(let Ee=0;Ee<o;Ee++){const Oe=G[Ee][Ve],dt=G[Ee+1][Ve],Ut=G[Ee+1][Ve+1],tn=G[Ee][Ve+1];(e>0||Ee!==0)&&(p.push(Oe,dt,tn),me+=3),(t>0||Ee!==o-1)&&(p.push(dt,Ut,tn),me+=3)}d.addGroup(I,me,0),I+=me}function K(re){const ve=T,me=new yn,Le=new it;let Ve=0;const Ee=re===!0?e:t,Oe=re===!0?1:-1;for(let Ut=1;Ut<=s;Ut++)m.push(0,z*Oe,0),y.push(0,Oe,0),M.push(.5,.5),T++;const dt=T;for(let Ut=0;Ut<=s;Ut++){const cn=Ut/s*u+c,vn=Math.cos(cn),mn=Math.sin(cn);Le.x=Ee*mn,Le.y=z*Oe,Le.z=Ee*vn,m.push(Le.x,Le.y,Le.z),y.push(0,Oe,0),me.x=vn*.5+.5,me.y=mn*.5*Oe+.5,M.push(me.x,me.y),T++}for(let Ut=0;Ut<s;Ut++){const tn=ve+Ut,cn=dt+Ut;re===!0?p.push(cn,cn+1,tn):p.push(cn+1,cn,tn),Ve+=3}d.addGroup(I,Ve,re===!0?1:2),I+=Ve}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Cp(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Rp extends Cp{constructor(e=1,t=1,n=32,s=1,o=!1,a=0,c=Math.PI*2){super(0,e,t,n,s,o,a,c),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:c}}static fromJSON(e){return new Rp(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class yf extends xr{constructor(e=[],t=[],n=1,s=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:s};const o=[],a=[];c(s),d(n),p(),this.setAttribute("position",new Zi(o,3)),this.setAttribute("normal",new Zi(o.slice(),3)),this.setAttribute("uv",new Zi(a,2)),s===0?this.computeVertexNormals():this.normalizeNormals();function c(J){const K=new it,re=new it,ve=new it;for(let me=0;me<t.length;me+=3)M(t[me+0],K),M(t[me+1],re),M(t[me+2],ve),u(K,re,ve,J)}function u(J,K,re,ve){const me=ve+1,Le=[];for(let Ve=0;Ve<=me;Ve++){Le[Ve]=[];const Ee=J.clone().lerp(re,Ve/me),Oe=K.clone().lerp(re,Ve/me),dt=me-Ve;for(let Ut=0;Ut<=dt;Ut++)Ut===0&&Ve===me?Le[Ve][Ut]=Ee:Le[Ve][Ut]=Ee.clone().lerp(Oe,Ut/dt)}for(let Ve=0;Ve<me;Ve++)for(let Ee=0;Ee<2*(me-Ve)-1;Ee++){const Oe=Math.floor(Ee/2);Ee%2===0?(y(Le[Ve][Oe+1]),y(Le[Ve+1][Oe]),y(Le[Ve][Oe])):(y(Le[Ve][Oe+1]),y(Le[Ve+1][Oe+1]),y(Le[Ve+1][Oe]))}}function d(J){const K=new it;for(let re=0;re<o.length;re+=3)K.x=o[re+0],K.y=o[re+1],K.z=o[re+2],K.normalize().multiplyScalar(J),o[re+0]=K.x,o[re+1]=K.y,o[re+2]=K.z}function p(){const J=new it;for(let K=0;K<o.length;K+=3){J.x=o[K+0],J.y=o[K+1],J.z=o[K+2];const re=z(J)/2/Math.PI+.5,ve=I(J)/Math.PI+.5;a.push(re,1-ve)}T(),m()}function m(){for(let J=0;J<a.length;J+=6){const K=a[J+0],re=a[J+2],ve=a[J+4],me=Math.max(K,re,ve),Le=Math.min(K,re,ve);me>.9&&Le<.1&&(K<.2&&(a[J+0]+=1),re<.2&&(a[J+2]+=1),ve<.2&&(a[J+4]+=1))}}function y(J){o.push(J.x,J.y,J.z)}function M(J,K){const re=J*3;K.x=e[re+0],K.y=e[re+1],K.z=e[re+2]}function T(){const J=new it,K=new it,re=new it,ve=new it,me=new yn,Le=new yn,Ve=new yn;for(let Ee=0,Oe=0;Ee<o.length;Ee+=9,Oe+=6){J.set(o[Ee+0],o[Ee+1],o[Ee+2]),K.set(o[Ee+3],o[Ee+4],o[Ee+5]),re.set(o[Ee+6],o[Ee+7],o[Ee+8]),me.set(a[Oe+0],a[Oe+1]),Le.set(a[Oe+2],a[Oe+3]),Ve.set(a[Oe+4],a[Oe+5]),ve.copy(J).add(K).add(re).divideScalar(3);const dt=z(ve);G(me,Oe+0,J,dt),G(Le,Oe+2,K,dt),G(Ve,Oe+4,re,dt)}}function G(J,K,re,ve){ve<0&&J.x===1&&(a[K]=J.x-1),re.x===0&&re.z===0&&(a[K]=ve/2/Math.PI+.5)}function z(J){return Math.atan2(J.z,-J.x)}function I(J){return Math.atan2(-J.y,Math.sqrt(J.x*J.x+J.z*J.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new yf(e.vertices,e.indices,e.radius,e.details)}}class Tx extends yf{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,s=1/n,o=[-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,-s,-n,0,-s,n,0,s,-n,0,s,n,-s,-n,0,-s,n,0,s,-n,0,s,n,0,-n,0,-s,n,0,-s,-n,0,s,n,0,s],a=[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(o,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Tx(e.radius,e.detail)}}const vf=new it,xf=new it,_f=new it,md=new ia;class gd extends xr{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const s=Math.pow(10,4),o=Math.cos(uc*t),a=e.getIndex(),c=e.getAttribute("position"),u=a?a.count:c.count,d=[0,0,0],p=["a","b","c"],m=new Array(3),y={},M=[];for(let T=0;T<u;T+=3){a?(d[0]=a.getX(T),d[1]=a.getX(T+1),d[2]=a.getX(T+2)):(d[0]=T,d[1]=T+1,d[2]=T+2);const{a:G,b:z,c:I}=md;if(G.fromBufferAttribute(c,d[0]),z.fromBufferAttribute(c,d[1]),I.fromBufferAttribute(c,d[2]),md.getNormal(_f),m[0]=`${Math.round(G.x*s)},${Math.round(G.y*s)},${Math.round(G.z*s)}`,m[1]=`${Math.round(z.x*s)},${Math.round(z.y*s)},${Math.round(z.z*s)}`,m[2]=`${Math.round(I.x*s)},${Math.round(I.y*s)},${Math.round(I.z*s)}`,!(m[0]===m[1]||m[1]===m[2]||m[2]===m[0]))for(let J=0;J<3;J++){const K=(J+1)%3,re=m[J],ve=m[K],me=md[p[J]],Le=md[p[K]],Ve=`${re}_${ve}`,Ee=`${ve}_${re}`;Ee in y&&y[Ee]?(_f.dot(y[Ee].normal)<=o&&(M.push(me.x,me.y,me.z),M.push(Le.x,Le.y,Le.z)),y[Ee]=null):Ve in y||(y[Ve]={index0:d[J],index1:d[K],normal:_f.clone()})}}for(const T in y)if(y[T]){const{index0:G,index1:z}=y[T];vf.fromBufferAttribute(c,G),xf.fromBufferAttribute(c,z),M.push(vf.x,vf.y,vf.z),M.push(xf.x,xf.y,xf.z)}this.setAttribute("position",new Zi(M,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class xc{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}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,s=this.getPoint(0),o=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),o+=n.distanceTo(s),t.push(o),s=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const n=this.getLengths();let s=0;const o=n.length;let a;t?a=t:a=e*n[o-1];let c=0,u=o-1,d;for(;c<=u;)if(s=Math.floor(c+(u-c)/2),d=n[s]-a,d<0)c=s+1;else if(d>0)u=s-1;else{u=s;break}if(s=u,n[s]===a)return s/(o-1);const p=n[s],y=n[s+1]-p,M=(a-p)/y;return(s+M)/(o-1)}getTangent(e,t){let s=e-1e-4,o=e+1e-4;s<0&&(s=0),o>1&&(o=1);const a=this.getPoint(s),c=this.getPoint(o),u=t||(a.isVector2?new yn:new it);return u.copy(c).sub(a).normalize(),u}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new it,s=[],o=[],a=[],c=new it,u=new Ft;for(let M=0;M<=e;M++){const T=M/e;s[M]=this.getTangentAt(T,new it)}o[0]=new it,a[0]=new it;let d=Number.MAX_VALUE;const p=Math.abs(s[0].x),m=Math.abs(s[0].y),y=Math.abs(s[0].z);p<=d&&(d=p,n.set(1,0,0)),m<=d&&(d=m,n.set(0,1,0)),y<=d&&n.set(0,0,1),c.crossVectors(s[0],n).normalize(),o[0].crossVectors(s[0],c),a[0].crossVectors(s[0],o[0]);for(let M=1;M<=e;M++){if(o[M]=o[M-1].clone(),a[M]=a[M-1].clone(),c.crossVectors(s[M-1],s[M]),c.length()>Number.EPSILON){c.normalize();const T=Math.acos(Sr(s[M-1].dot(s[M]),-1,1));o[M].applyMatrix4(u.makeRotationAxis(c,T))}a[M].crossVectors(s[M],o[M])}if(t===!0){let M=Math.acos(Sr(o[0].dot(o[e]),-1,1));M/=e,s[0].dot(c.crossVectors(o[0],o[e]))>0&&(M=-M);for(let T=1;T<=e;T++)o[T].applyMatrix4(u.makeRotationAxis(s[T],M*T)),a[T].crossVectors(s[T],o[T])}return{tangents:s,normals:o,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class bf extends xc{constructor(e=0,t=0,n=1,s=1,o=0,a=Math.PI*2,c=!1,u=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=s,this.aStartAngle=o,this.aEndAngle=a,this.aClockwise=c,this.aRotation=u}getPoint(e,t=new yn){const n=t,s=Math.PI*2;let o=this.aEndAngle-this.aStartAngle;const a=Math.abs(o)<Number.EPSILON;for(;o<0;)o+=s;for(;o>s;)o-=s;o<Number.EPSILON&&(a?o=0:o=s),this.aClockwise===!0&&!a&&(o===s?o=-s:o=o-s);const c=this.aStartAngle+e*o;let u=this.aX+this.xRadius*Math.cos(c),d=this.aY+this.yRadius*Math.sin(c);if(this.aRotation!==0){const p=Math.cos(this.aRotation),m=Math.sin(this.aRotation),y=u-this.aX,M=d-this.aY;u=y*p-M*m+this.aX,d=y*m+M*p+this.aY}return n.set(u,d)}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 hg extends bf{constructor(e,t,n,s,o,a){super(e,t,n,n,s,o,a),this.isArcCurve=!0,this.type="ArcCurve"}}function Np(){let i=0,e=0,t=0,n=0;function s(o,a,c,u){i=o,e=c,t=-3*o+3*a-2*c-u,n=2*o-2*a+c+u}return{initCatmullRom:function(o,a,c,u,d){s(a,c,d*(c-o),d*(u-a))},initNonuniformCatmullRom:function(o,a,c,u,d,p,m){let y=(a-o)/d-(c-o)/(d+p)+(c-a)/p,M=(c-a)/p-(u-a)/(p+m)+(u-c)/m;y*=p,M*=p,s(a,c,y,M)},calc:function(o){const a=o*o,c=a*o;return i+e*o+t*a+n*c}}}const yd=new it,J0=new Np,_c=new Np,Pp=new Np;class A1 extends xc{constructor(e=[],t=!1,n="centripetal",s=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=s}getPoint(e,t=new it){const n=t,s=this.points,o=s.length,a=(o-(this.closed?0:1))*e;let c=Math.floor(a),u=a-c;this.closed?c+=c>0?0:(Math.floor(Math.abs(c)/o)+1)*o:u===0&&c===o-1&&(c=o-2,u=1);let d,p;this.closed||c>0?d=s[(c-1)%o]:(yd.subVectors(s[0],s[1]).add(s[0]),d=yd);const m=s[c%o],y=s[(c+1)%o];if(this.closed||c+2<o?p=s[(c+2)%o]:(yd.subVectors(s[o-1],s[o-2]).add(s[o-1]),p=yd),this.curveType==="centripetal"||this.curveType==="chordal"){const M=this.curveType==="chordal"?.5:.25;let T=Math.pow(d.distanceToSquared(m),M),G=Math.pow(m.distanceToSquared(y),M),z=Math.pow(y.distanceToSquared(p),M);G<1e-4&&(G=1),T<1e-4&&(T=G),z<1e-4&&(z=G),J0.initNonuniformCatmullRom(d.x,m.x,y.x,p.x,T,G,z),_c.initNonuniformCatmullRom(d.y,m.y,y.y,p.y,T,G,z),Pp.initNonuniformCatmullRom(d.z,m.z,y.z,p.z,T,G,z)}else this.curveType==="catmullrom"&&(J0.initCatmullRom(d.x,m.x,y.x,p.x,this.tension),_c.initCatmullRom(d.y,m.y,y.y,p.y,this.tension),Pp.initCatmullRom(d.z,m.z,y.z,p.z,this.tension));return n.set(J0.calc(u),_c.calc(u),Pp.calc(u)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const s=e.points[t];this.points.push(s.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 s=this.points[t];e.points.push(s.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 s=e.points[t];this.points.push(new it().fromArray(s))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function dg(i,e,t,n,s){const o=(n-e)*.5,a=(s-t)*.5,c=i*i,u=i*c;return(2*t-2*n+o+a)*u+(-3*t+3*n-2*o-a)*c+o*i+t}function fg(i,e){const t=1-i;return t*t*e}function Q0(i,e){return 2*(1-i)*i*e}function ey(i,e){return i*i*e}function vd(i,e,t,n){return fg(i,e)+Q0(i,t)+ey(i,n)}function C1(i,e){const t=1-i;return t*t*t*e}function Ex(i,e){const t=1-i;return 3*t*t*i*e}function R1(i,e){return 3*(1-i)*i*i*e}function N1(i,e){return i*i*i*e}function Ip(i,e,t,n,s){return C1(i,e)+Ex(i,t)+R1(i,n)+N1(i,s)}class wf extends xc{constructor(e=new yn,t=new yn,n=new yn,s=new yn){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=s}getPoint(e,t=new yn){const n=t,s=this.v0,o=this.v1,a=this.v2,c=this.v3;return n.set(Ip(e,s.x,o.x,a.x,c.x),Ip(e,s.y,o.y,a.y,c.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 Ax extends xc{constructor(e=new it,t=new it,n=new it,s=new it){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=s}getPoint(e,t=new it){const n=t,s=this.v0,o=this.v1,a=this.v2,c=this.v3;return n.set(Ip(e,s.x,o.x,a.x,c.x),Ip(e,s.y,o.y,a.y,c.y),Ip(e,s.z,o.z,a.z,c.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 Cx extends xc{constructor(e=new yn,t=new yn){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new yn){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 yn){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 P1 extends xc{constructor(e=new it,t=new it){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new it){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 it){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 Rx extends xc{constructor(e=new yn,t=new yn,n=new yn){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new yn){const n=t,s=this.v0,o=this.v1,a=this.v2;return n.set(vd(e,s.x,o.x,a.x),vd(e,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}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 xd extends xc{constructor(e=new it,t=new it,n=new it){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new it){const n=t,s=this.v0,o=this.v1,a=this.v2;return n.set(vd(e,s.x,o.x,a.x),vd(e,s.y,o.y,a.y),vd(e,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}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 ty extends xc{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new yn){const n=t,s=this.points,o=(s.length-1)*e,a=Math.floor(o),c=o-a,u=s[a===0?a:a-1],d=s[a],p=s[a>s.length-2?s.length-1:a+1],m=s[a>s.length-3?s.length-1:a+2];return n.set(dg(c,u.x,d.x,p.x,m.x),dg(c,u.y,d.y,p.y,m.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const s=e.points[t];this.points.push(s.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const s=this.points[t];e.points.push(s.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const s=e.points[t];this.points.push(new yn().fromArray(s))}return this}}var pg=Object.freeze({__proto__:null,ArcCurve:hg,CatmullRomCurve3:A1,CubicBezierCurve:wf,CubicBezierCurve3:Ax,EllipseCurve:bf,LineCurve:Cx,LineCurve3:P1,QuadraticBezierCurve:Rx,QuadraticBezierCurve3:xd,SplineCurve:ty});class Nx extends xc{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);if(!e.equals(t)){const n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new pg[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),s=this.getCurveLengths();let o=0;for(;o<s.length;){if(s[o]>=n){const a=s[o]-n,c=this.curves[o],u=c.getLength(),d=u===0?0:1-a/u;return c.getPointAt(d,t)}o++}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,s=this.curves.length;n<s;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 s=0,o=this.curves;s<o.length;s++){const a=o[s],c=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,u=a.getPoints(c);for(let d=0;d<u.length;d++){const p=u[d];n&&n.equals(p)||(t.push(p),n=p)}}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 s=e.curves[t];this.curves.push(s.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 s=this.curves[t];e.curves.push(s.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 s=e.curves[t];this.curves.push(new pg[s.type]().fromJSON(s))}return this}}class ny extends Nx{constructor(e){super(),this.type="Path",this.currentPoint=new yn,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 Cx(this.currentPoint.clone(),new yn(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,s){const o=new Rx(this.currentPoint.clone(),new yn(e,t),new yn(n,s));return this.curves.push(o),this.currentPoint.set(n,s),this}bezierCurveTo(e,t,n,s,o,a){const c=new wf(this.currentPoint.clone(),new yn(e,t),new yn(n,s),new yn(o,a));return this.curves.push(c),this.currentPoint.set(o,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new ty(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,s,o,a){const c=this.currentPoint.x,u=this.currentPoint.y;return this.absarc(e+c,t+u,n,s,o,a),this}absarc(e,t,n,s,o,a){return this.absellipse(e,t,n,n,s,o,a),this}ellipse(e,t,n,s,o,a,c,u){const d=this.currentPoint.x,p=this.currentPoint.y;return this.absellipse(e+d,t+p,n,s,o,a,c,u),this}absellipse(e,t,n,s,o,a,c,u){const d=new bf(e,t,n,s,o,a,c,u);if(this.curves.length>0){const m=d.getPoint(0);m.equals(this.currentPoint)||this.lineTo(m.x,m.y)}this.curves.push(d);const p=d.getPoint(1);return this.currentPoint.copy(p),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 _d extends ny{constructor(e){super(e),this.uuid=xl(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,s=this.holes.length;n<s;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 s=e.holes[t];this.holes.push(s.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 s=this.holes[t];e.holes.push(s.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 s=e.holes[t];this.holes.push(new ny().fromJSON(s))}return this}}function Px(i,e,t=2){const n=e&&e.length,s=n?e[0]*t:i.length;let o=iy(i,0,s,t,!0);const a=[];if(!o||o.next===o.prev)return a;let c,u,d;if(n&&(o=bd(i,e,o,t)),i.length>80*t){c=1/0,u=1/0;let p=-1/0,m=-1/0;for(let y=t;y<s;y+=t){const M=i[y],T=i[y+1];M<c&&(c=M),T<u&&(u=T),M>p&&(p=M),T>m&&(m=T)}d=Math.max(p-c,m-u),d=d!==0?32767/d:0}return Lp(o,a,t,c,u,d,0),a}function iy(i,e,t,n,s){let o;if(s===Up(i,e,t,n)>0)for(let a=e;a<t;a+=n)o=Bp(a/n|0,i[a],i[a+1],o);else for(let a=t-n;a>=e;a-=n)o=Bp(a/n|0,i[a],i[a+1],o);return o&&Th(o,o.next)&&(Ah(o),o=o.next),o}function _u(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(Th(t,t.next)||Xo(t.prev,t,t.next)===0)){if(Ah(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Lp(i,e,t,n,s,o,a){if(!i)return;!a&&o&&F1(i,n,s,o);let c=i;for(;i.prev!==i.next;){const u=i.prev,d=i.next;if(o?Mf(i,n,s,o):ry(i)){e.push(u.i,i.i,d.i),Ah(i),i=d.next,c=d.next;continue}if(i=d,i===c){a?a===1?(i=I1(_u(i),e),Lp(i,e,t,n,s,o,2)):a===2&&Ix(i,e,t,n,s,o):Lp(_u(i),e,t,n,s,o,1);break}}}function ry(i){const e=i.prev,t=i,n=i.next;if(Xo(e,t,n)>=0)return!1;const s=e.x,o=t.x,a=n.x,c=e.y,u=t.y,d=n.y,p=Math.min(s,o,a),m=Math.min(c,u,d),y=Math.max(s,o,a),M=Math.max(c,u,d);let T=n.next;for(;T!==e;){if(T.x>=p&&T.x<=y&&T.y>=m&&T.y<=M&&Op(s,c,o,u,a,d,T.x,T.y)&&Xo(T.prev,T,T.next)>=0)return!1;T=T.next}return!0}function Mf(i,e,t,n){const s=i.prev,o=i,a=i.next;if(Xo(s,o,a)>=0)return!1;const c=s.x,u=o.x,d=a.x,p=s.y,m=o.y,y=a.y,M=Math.min(c,u,d),T=Math.min(p,m,y),G=Math.max(c,u,d),z=Math.max(p,m,y),I=sy(M,T,e,t,n),J=sy(G,z,e,t,n);let K=i.prevZ,re=i.nextZ;for(;K&&K.z>=I&&re&&re.z<=J;){if(K.x>=M&&K.x<=G&&K.y>=T&&K.y<=z&&K!==s&&K!==a&&Op(c,p,u,m,d,y,K.x,K.y)&&Xo(K.prev,K,K.next)>=0||(K=K.prevZ,re.x>=M&&re.x<=G&&re.y>=T&&re.y<=z&&re!==s&&re!==a&&Op(c,p,u,m,d,y,re.x,re.y)&&Xo(re.prev,re,re.next)>=0))return!1;re=re.nextZ}for(;K&&K.z>=I;){if(K.x>=M&&K.x<=G&&K.y>=T&&K.y<=z&&K!==s&&K!==a&&Op(c,p,u,m,d,y,K.x,K.y)&&Xo(K.prev,K,K.next)>=0)return!1;K=K.prevZ}for(;re&&re.z<=J;){if(re.x>=M&&re.x<=G&&re.y>=T&&re.y<=z&&re!==s&&re!==a&&Op(c,p,u,m,d,y,re.x,re.y)&&Xo(re.prev,re,re.next)>=0)return!1;re=re.nextZ}return!0}function I1(i,e){let t=i;do{const n=t.prev,s=t.next.next;!Th(n,s)&&Dx(n,t,t.next,s)&&So(n,s)&&So(s,n)&&(e.push(n.i,t.i,s.i),Ah(t),Ah(t.next),t=i=s),t=t.next}while(t!==i);return _u(t)}function Ix(i,e,t,n,s,o){let a=i;do{let c=a.next.next;for(;c!==a.prev;){if(a.i!==c.i&&k1(a,c)){let u=oy(a,c);a=_u(a,a.next),u=_u(u,u.next),Lp(a,e,t,n,s,o,0),Lp(u,e,t,n,s,o,0);return}c=c.next}a=a.next}while(a!==i)}function bd(i,e,t,n){const s=[];for(let o=0,a=e.length;o<a;o++){const c=e[o]*n,u=o<a-1?e[o+1]*n:i.length,d=iy(i,c,u,n,!1);d===d.next&&(d.steiner=!0),s.push(U1(d))}s.sort(Dp);for(let o=0;o<s.length;o++)t=L1(s[o],t);return t}function Dp(i,e){let t=i.x-e.x;if(t===0&&(t=i.y-e.y,t===0)){const n=(i.next.y-i.y)/(i.next.x-i.x),s=(e.next.y-e.y)/(e.next.x-e.x);t=n-s}return t}function L1(i,e){const t=D1(i,e);if(!t)return e;const n=oy(t,i);return _u(n,n.next),_u(t,t.next)}function D1(i,e){let t=e;const n=i.x,s=i.y;let o=-1/0,a;if(Th(i,t))return t;do{if(Th(i,t.next))return t.next;if(s<=t.y&&s>=t.next.y&&t.next.y!==t.y){const m=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(m<=n&&m>o&&(o=m,a=t.x<t.next.x?t:t.next,m===n))return a}t=t.next}while(t!==e);if(!a)return null;const c=a,u=a.x,d=a.y;let p=1/0;t=a;do{if(n>=t.x&&t.x>=u&&n!==t.x&&Lx(s<d?n:o,s,u,d,s<d?o:n,s,t.x,t.y)){const m=Math.abs(s-t.y)/(n-t.x);So(t,i)&&(m<p||m===p&&(t.x>a.x||t.x===a.x&&O1(a,t)))&&(a=t,p=m)}t=t.next}while(t!==c);return a}function O1(i,e){return Xo(i.prev,i,e.prev)<0&&Xo(e.next,i,i.next)<0}function F1(i,e,t,n){let s=i;do s.z===0&&(s.z=sy(s.x,s.y,e,t,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i);s.prevZ.nextZ=null,s.prevZ=null,B1(s)}function B1(i){let e,t=1;do{let n=i,s;i=null;let o=null;for(e=0;n;){e++;let a=n,c=0;for(let d=0;d<t&&(c++,a=a.nextZ,!!a);d++);let u=t;for(;c>0||u>0&&a;)c!==0&&(u===0||!a||n.z<=a.z)?(s=n,n=n.nextZ,c--):(s=a,a=a.nextZ,u--),o?o.nextZ=s:i=s,s.prevZ=o,o=s;n=a}o.nextZ=null,t*=2}while(e>1);return i}function sy(i,e,t,n,s){return i=(i-t)*s|0,e=(e-n)*s|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function U1(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function Lx(i,e,t,n,s,o,a,c){return(s-a)*(e-c)>=(i-a)*(o-c)&&(i-a)*(n-c)>=(t-a)*(e-c)&&(t-a)*(o-c)>=(s-a)*(n-c)}function Op(i,e,t,n,s,o,a,c){return!(i===a&&e===c)&&Lx(i,e,t,n,s,o,a,c)}function k1(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!z1(i,e)&&(So(i,e)&&So(e,i)&&Sf(i,e)&&(Xo(i.prev,i,e.prev)||Xo(i,e.prev,e))||Th(i,e)&&Xo(i.prev,i,i.next)>0&&Xo(e.prev,e,e.next)>0)}function Xo(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function Th(i,e){return i.x===e.x&&i.y===e.y}function Dx(i,e,t,n){const s=Eh(Xo(i,e,t)),o=Eh(Xo(i,e,n)),a=Eh(Xo(t,n,i)),c=Eh(Xo(t,n,e));return!!(s!==o&&a!==c||s===0&&Fp(i,t,e)||o===0&&Fp(i,n,e)||a===0&&Fp(t,i,n)||c===0&&Fp(t,e,n))}function Fp(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function Eh(i){return i>0?1:i<0?-1:0}function z1(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&Dx(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function So(i,e){return Xo(i.prev,i,i.next)<0?Xo(i,e,i.next)>=0&&Xo(i,i.prev,e)>=0:Xo(i,e,i.prev)<0||Xo(i,i.next,e)<0}function Sf(i,e){let t=i,n=!1;const s=(i.x+e.x)/2,o=(i.y+e.y)/2;do t.y>o!=t.next.y>o&&t.next.y!==t.y&&s<(t.next.x-t.x)*(o-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function oy(i,e){const t=ay(i.i,i.x,i.y),n=ay(e.i,e.x,e.y),s=i.next,o=e.prev;return i.next=e,e.prev=i,t.next=s,s.prev=t,n.next=t,t.prev=n,o.next=n,n.prev=o,n}function Bp(i,e,t,n){const s=ay(i,e,t);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function Ah(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function ay(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Up(i,e,t,n){let s=0;for(let o=e,a=t-n;o<t;o+=n)s+=(i[a]-i[o])*(i[o+1]+i[a+1]),a=o;return s}class V1{static triangulate(e,t,n=2){return Px(e,t,n)}}class Hc{static area(e){const t=e.length;let n=0;for(let s=t-1,o=0;o<t;s=o++)n+=e[s].x*e[o].y-e[o].x*e[s].y;return n*.5}static isClockWise(e){return Hc.area(e)<0}static triangulateShape(e,t){const n=[],s=[],o=[];ly(e),Tf(n,e);let a=e.length;t.forEach(ly);for(let u=0;u<t.length;u++)s.push(a),a+=t[u].length,Tf(n,t[u]);const c=V1.triangulate(n,s);for(let u=0;u<c.length;u+=3)o.push(c.slice(u,u+3));return o}}function ly(i){const e=i.length;e>2&&i[e-1].equals(i[0])&&i.pop()}function Tf(i,e){for(let t=0;t<e.length;t++)i.push(e[t].x),i.push(e[t].y)}class kp extends xr{constructor(e=new _d([new yn(.5,.5),new yn(-.5,.5),new yn(-.5,-.5),new yn(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,s=[],o=[];for(let c=0,u=e.length;c<u;c++){const d=e[c];a(d)}this.setAttribute("position",new Zi(s,3)),this.setAttribute("uv",new Zi(o,2)),this.computeVertexNormals();function a(c){const u=[],d=t.curveSegments!==void 0?t.curveSegments:12,p=t.steps!==void 0?t.steps:1,m=t.depth!==void 0?t.depth:1;let y=t.bevelEnabled!==void 0?t.bevelEnabled:!0,M=t.bevelThickness!==void 0?t.bevelThickness:.2,T=t.bevelSize!==void 0?t.bevelSize:M-.1,G=t.bevelOffset!==void 0?t.bevelOffset:0,z=t.bevelSegments!==void 0?t.bevelSegments:3;const I=t.extrudePath,J=t.UVGenerator!==void 0?t.UVGenerator:G1;let K,re=!1,ve,me,Le,Ve;I&&(K=I.getSpacedPoints(p),re=!0,y=!1,ve=I.computeFrenetFrames(p,!1),me=new it,Le=new it,Ve=new it),y||(z=0,M=0,T=0,G=0);const Ee=c.extractPoints(d);let Oe=Ee.shape;const dt=Ee.holes;if(!Hc.isClockWise(Oe)){Oe=Oe.reverse();for(let Kn=0,Zn=dt.length;Kn<Zn;Kn++){const qn=dt[Kn];Hc.isClockWise(qn)&&(dt[Kn]=qn.reverse())}}function tn(Kn){const qn=10000000000000001e-36;let Hn=Kn[0];for(let Ti=1;Ti<=Kn.length;Ti++){const pi=Ti%Kn.length,Ii=Kn[pi],ws=Ii.x-Hn.x,ms=Ii.y-Hn.y,bt=ws*ws+ms*ms,Qe=Math.max(Math.abs(Ii.x),Math.abs(Ii.y),Math.abs(Hn.x),Math.abs(Hn.y)),fn=qn*Qe*Qe;if(bt<=fn){Kn.splice(pi,1),Ti--;continue}Hn=Ii}}tn(Oe),dt.forEach(tn);const cn=dt.length,vn=Oe;for(let Kn=0;Kn<cn;Kn++){const Zn=dt[Kn];Oe=Oe.concat(Zn)}function mn(Kn,Zn,qn){return Zn||console.error("THREE.ExtrudeGeometry: vec does not exist"),Kn.clone().addScaledVector(Zn,qn)}const Yn=Oe.length;function xn(Kn,Zn,qn){let Hn,Ti,pi;const Ii=Kn.x-Zn.x,ws=Kn.y-Zn.y,ms=qn.x-Kn.x,bt=qn.y-Kn.y,Qe=Ii*Ii+ws*ws,fn=Ii*bt-ws*ms;if(Math.abs(fn)>Number.EPSILON){const Dn=Math.sqrt(Qe),ri=Math.sqrt(ms*ms+bt*bt),zn=Zn.x-ws/Dn,Rr=Zn.y+Ii/Dn,Ci=qn.x-bt/ri,Tr=qn.y+ms/ri,Er=((Ci-zn)*bt-(Tr-Rr)*ms)/(Ii*bt-ws*ms);Hn=zn+Ii*Er-Kn.x,Ti=Rr+ws*Er-Kn.y;const mi=Hn*Hn+Ti*Ti;if(mi<=2)return new yn(Hn,Ti);pi=Math.sqrt(mi/2)}else{let Dn=!1;Ii>Number.EPSILON?ms>Number.EPSILON&&(Dn=!0):Ii<-Number.EPSILON?ms<-Number.EPSILON&&(Dn=!0):Math.sign(ws)===Math.sign(bt)&&(Dn=!0),Dn?(Hn=-ws,Ti=Ii,pi=Math.sqrt(Qe)):(Hn=Ii,Ti=ws,pi=Math.sqrt(Qe/2))}return new yn(Hn/pi,Ti/pi)}const si=[];for(let Kn=0,Zn=vn.length,qn=Zn-1,Hn=Kn+1;Kn<Zn;Kn++,qn++,Hn++)qn===Zn&&(qn=0),Hn===Zn&&(Hn=0),si[Kn]=xn(vn[Kn],vn[qn],vn[Hn]);const wn=[];let Gn,Si=si.concat();for(let Kn=0,Zn=cn;Kn<Zn;Kn++){const qn=dt[Kn];Gn=[];for(let Hn=0,Ti=qn.length,pi=Ti-1,Ii=Hn+1;Hn<Ti;Hn++,pi++,Ii++)pi===Ti&&(pi=0),Ii===Ti&&(Ii=0),Gn[Hn]=xn(qn[Hn],qn[pi],qn[Ii]);wn.push(Gn),Si=Si.concat(Gn)}let nr;if(z===0)nr=Hc.triangulateShape(vn,dt);else{const Kn=[],Zn=[];for(let qn=0;qn<z;qn++){const Hn=qn/z,Ti=M*Math.cos(Hn*Math.PI/2),pi=T*Math.sin(Hn*Math.PI/2)+G;for(let Ii=0,ws=vn.length;Ii<ws;Ii++){const ms=mn(vn[Ii],si[Ii],pi);ki(ms.x,ms.y,-Ti),Hn===0&&Kn.push(ms)}for(let Ii=0,ws=cn;Ii<ws;Ii++){const ms=dt[Ii];Gn=wn[Ii];const bt=[];for(let Qe=0,fn=ms.length;Qe<fn;Qe++){const Dn=mn(ms[Qe],Gn[Qe],pi);ki(Dn.x,Dn.y,-Ti),Hn===0&&bt.push(Dn)}Hn===0&&Zn.push(bt)}}nr=Hc.triangulateShape(Kn,Zn)}const os=nr.length,Vn=T+G;for(let Kn=0;Kn<Yn;Kn++){const Zn=y?mn(Oe[Kn],Si[Kn],Vn):Oe[Kn];re?(Le.copy(ve.normals[0]).multiplyScalar(Zn.x),me.copy(ve.binormals[0]).multiplyScalar(Zn.y),Ve.copy(K[0]).add(Le).add(me),ki(Ve.x,Ve.y,Ve.z)):ki(Zn.x,Zn.y,0)}for(let Kn=1;Kn<=p;Kn++)for(let Zn=0;Zn<Yn;Zn++){const qn=y?mn(Oe[Zn],Si[Zn],Vn):Oe[Zn];re?(Le.copy(ve.normals[Kn]).multiplyScalar(qn.x),me.copy(ve.binormals[Kn]).multiplyScalar(qn.y),Ve.copy(K[Kn]).add(Le).add(me),ki(Ve.x,Ve.y,Ve.z)):ki(qn.x,qn.y,m/p*Kn)}for(let Kn=z-1;Kn>=0;Kn--){const Zn=Kn/z,qn=M*Math.cos(Zn*Math.PI/2),Hn=T*Math.sin(Zn*Math.PI/2)+G;for(let Ti=0,pi=vn.length;Ti<pi;Ti++){const Ii=mn(vn[Ti],si[Ti],Hn);ki(Ii.x,Ii.y,m+qn)}for(let Ti=0,pi=dt.length;Ti<pi;Ti++){const Ii=dt[Ti];Gn=wn[Ti];for(let ws=0,ms=Ii.length;ws<ms;ws++){const bt=mn(Ii[ws],Gn[ws],Hn);re?ki(bt.x,bt.y+K[p-1].y,K[p-1].x+qn):ki(bt.x,bt.y,m+qn)}}}un(),Mn();function un(){const Kn=s.length/3;if(y){let Zn=0,qn=Yn*Zn;for(let Hn=0;Hn<os;Hn++){const Ti=nr[Hn];Ni(Ti[2]+qn,Ti[1]+qn,Ti[0]+qn)}Zn=p+z*2,qn=Yn*Zn;for(let Hn=0;Hn<os;Hn++){const Ti=nr[Hn];Ni(Ti[0]+qn,Ti[1]+qn,Ti[2]+qn)}}else{for(let Zn=0;Zn<os;Zn++){const qn=nr[Zn];Ni(qn[2],qn[1],qn[0])}for(let Zn=0;Zn<os;Zn++){const qn=nr[Zn];Ni(qn[0]+Yn*p,qn[1]+Yn*p,qn[2]+Yn*p)}}n.addGroup(Kn,s.length/3-Kn,0)}function Mn(){const Kn=s.length/3;let Zn=0;fi(vn,Zn),Zn+=vn.length;for(let qn=0,Hn=dt.length;qn<Hn;qn++){const Ti=dt[qn];fi(Ti,Zn),Zn+=Ti.length}n.addGroup(Kn,s.length/3-Kn,1)}function fi(Kn,Zn){let qn=Kn.length;for(;--qn>=0;){const Hn=qn;let Ti=qn-1;Ti<0&&(Ti=Kn.length-1);for(let pi=0,Ii=p+z*2;pi<Ii;pi++){const ws=Yn*pi,ms=Yn*(pi+1),bt=Zn+Hn+ws,Qe=Zn+Ti+ws,fn=Zn+Ti+ms,Dn=Zn+Hn+ms;Cr(bt,Qe,fn,Dn)}}}function ki(Kn,Zn,qn){u.push(Kn),u.push(Zn),u.push(qn)}function Ni(Kn,Zn,qn){Vs(Kn),Vs(Zn),Vs(qn);const Hn=s.length/3,Ti=J.generateTopUV(n,s,Hn-3,Hn-2,Hn-1);kt(Ti[0]),kt(Ti[1]),kt(Ti[2])}function Cr(Kn,Zn,qn,Hn){Vs(Kn),Vs(Zn),Vs(Hn),Vs(Zn),Vs(qn),Vs(Hn);const Ti=s.length/3,pi=J.generateSideWallUV(n,s,Ti-6,Ti-3,Ti-2,Ti-1);kt(pi[0]),kt(pi[1]),kt(pi[3]),kt(pi[1]),kt(pi[2]),kt(pi[3])}function Vs(Kn){s.push(u[Kn*3+0]),s.push(u[Kn*3+1]),s.push(u[Kn*3+2])}function kt(Kn){o.push(Kn.x),o.push(Kn.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 W1(t,n,e)}static fromJSON(e,t){const n=[];for(let o=0,a=e.shapes.length;o<a;o++){const c=t[e.shapes[o]];n.push(c)}const s=e.options.extrudePath;return s!==void 0&&(e.options.extrudePath=new pg[s.type]().fromJSON(s)),new kp(n,e.options)}}const G1={generateTopUV:function(i,e,t,n,s){const o=e[t*3],a=e[t*3+1],c=e[n*3],u=e[n*3+1],d=e[s*3],p=e[s*3+1];return[new yn(o,a),new yn(c,u),new yn(d,p)]},generateSideWallUV:function(i,e,t,n,s,o){const a=e[t*3],c=e[t*3+1],u=e[t*3+2],d=e[n*3],p=e[n*3+1],m=e[n*3+2],y=e[s*3],M=e[s*3+1],T=e[s*3+2],G=e[o*3],z=e[o*3+1],I=e[o*3+2];return Math.abs(c-p)<Math.abs(a-d)?[new yn(a,1-u),new yn(d,1-m),new yn(y,1-T),new yn(G,1-I)]:[new yn(c,1-u),new yn(p,1-m),new yn(M,1-T),new yn(z,1-I)]}};function W1(i,e,t){if(t.shapes=[],Array.isArray(i))for(let n=0,s=i.length;n<s;n++){const o=i[n];t.shapes.push(o.uuid)}else t.shapes.push(i.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class bc extends yf{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,s=[-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],o=[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(s,o,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new bc(e.radius,e.detail)}}class mg extends xr{constructor(e=[new yn(0,-.5),new yn(.5,0),new yn(0,.5)],t=12,n=0,s=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:s},t=Math.floor(t),s=Sr(s,0,Math.PI*2);const o=[],a=[],c=[],u=[],d=[],p=1/t,m=new it,y=new yn,M=new it,T=new it,G=new it;let z=0,I=0;for(let J=0;J<=e.length-1;J++)switch(J){case 0:z=e[J+1].x-e[J].x,I=e[J+1].y-e[J].y,M.x=I*1,M.y=-z,M.z=I*0,G.copy(M),M.normalize(),u.push(M.x,M.y,M.z);break;case e.length-1:u.push(G.x,G.y,G.z);break;default:z=e[J+1].x-e[J].x,I=e[J+1].y-e[J].y,M.x=I*1,M.y=-z,M.z=I*0,T.copy(M),M.x+=G.x,M.y+=G.y,M.z+=G.z,M.normalize(),u.push(M.x,M.y,M.z),G.copy(T)}for(let J=0;J<=t;J++){const K=n+J*p*s,re=Math.sin(K),ve=Math.cos(K);for(let me=0;me<=e.length-1;me++){m.x=e[me].x*re,m.y=e[me].y,m.z=e[me].x*ve,a.push(m.x,m.y,m.z),y.x=J/t,y.y=me/(e.length-1),c.push(y.x,y.y);const Le=u[3*me+0]*re,Ve=u[3*me+1],Ee=u[3*me+0]*ve;d.push(Le,Ve,Ee)}}for(let J=0;J<t;J++)for(let K=0;K<e.length-1;K++){const re=K+J*e.length,ve=re,me=re+e.length,Le=re+e.length+1,Ve=re+1;o.push(ve,me,Ve),o.push(Le,Ve,me)}this.setIndex(o),this.setAttribute("position",new Zi(a,3)),this.setAttribute("uv",new Zi(c,2)),this.setAttribute("normal",new Zi(d,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mg(e.points,e.segments,e.phiStart,e.phiLength)}}class zp extends yf{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],s=[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,s,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new zp(e.radius,e.detail)}}class Ch extends xr{constructor(e=1,t=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:s};const o=e/2,a=t/2,c=Math.floor(n),u=Math.floor(s),d=c+1,p=u+1,m=e/c,y=t/u,M=[],T=[],G=[],z=[];for(let I=0;I<p;I++){const J=I*y-a;for(let K=0;K<d;K++){const re=K*m-o;T.push(re,-J,0),G.push(0,0,1),z.push(K/c),z.push(1-I/u)}}for(let I=0;I<u;I++)for(let J=0;J<c;J++){const K=J+d*I,re=J+d*(I+1),ve=J+1+d*(I+1),me=J+1+d*I;M.push(K,re,me),M.push(re,ve,me)}this.setIndex(M),this.setAttribute("position",new Zi(T,3)),this.setAttribute("normal",new Zi(G,3)),this.setAttribute("uv",new Zi(z,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ch(e.width,e.height,e.widthSegments,e.heightSegments)}}class cy extends xr{constructor(e=.5,t=1,n=32,s=1,o=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:s,thetaStart:o,thetaLength:a},n=Math.max(3,n),s=Math.max(1,s);const c=[],u=[],d=[],p=[];let m=e;const y=(t-e)/s,M=new it,T=new yn;for(let G=0;G<=s;G++){for(let z=0;z<=n;z++){const I=o+z/n*a;M.x=m*Math.cos(I),M.y=m*Math.sin(I),u.push(M.x,M.y,M.z),d.push(0,0,1),T.x=(M.x/t+1)/2,T.y=(M.y/t+1)/2,p.push(T.x,T.y)}m+=y}for(let G=0;G<s;G++){const z=G*(n+1);for(let I=0;I<n;I++){const J=I+z,K=J,re=J+n+1,ve=J+n+2,me=J+1;c.push(K,re,me),c.push(re,ve,me)}}this.setIndex(c),this.setAttribute("position",new Zi(u,3)),this.setAttribute("normal",new Zi(d,3)),this.setAttribute("uv",new Zi(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new cy(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class uy extends xr{constructor(e=new _d([new yn(0,.5),new yn(-.5,-.5),new yn(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],s=[],o=[],a=[];let c=0,u=0;if(Array.isArray(e)===!1)d(e);else for(let p=0;p<e.length;p++)d(e[p]),this.addGroup(c,u,p),c+=u,u=0;this.setIndex(n),this.setAttribute("position",new Zi(s,3)),this.setAttribute("normal",new Zi(o,3)),this.setAttribute("uv",new Zi(a,2));function d(p){const m=s.length/3,y=p.extractPoints(t);let M=y.shape;const T=y.holes;Hc.isClockWise(M)===!1&&(M=M.reverse());for(let z=0,I=T.length;z<I;z++){const J=T[z];Hc.isClockWise(J)===!0&&(T[z]=J.reverse())}const G=Hc.triangulateShape(M,T);for(let z=0,I=T.length;z<I;z++){const J=T[z];M=M.concat(J)}for(let z=0,I=M.length;z<I;z++){const J=M[z];s.push(J.x,J.y,0),o.push(0,0,1),a.push(J.x,J.y)}for(let z=0,I=G.length;z<I;z++){const J=G[z],K=J[0]+m,re=J[1]+m,ve=J[2]+m;n.push(K,re,ve),u+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return hy(t,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)}return new uy(n,e.curveSegments)}}function hy(i,e){if(e.shapes=[],Array.isArray(i))for(let t=0,n=i.length;t<n;t++){const s=i[t];e.shapes.push(s.uuid)}else e.shapes.push(i.uuid);return e}class Yu extends xr{constructor(e=1,t=32,n=16,s=0,o=Math.PI*2,a=0,c=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:s,phiLength:o,thetaStart:a,thetaLength:c},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const u=Math.min(a+c,Math.PI);let d=0;const p=[],m=new it,y=new it,M=[],T=[],G=[],z=[];for(let I=0;I<=n;I++){const J=[],K=I/n;let re=0;I===0&&a===0?re=.5/t:I===n&&u===Math.PI&&(re=-.5/t);for(let ve=0;ve<=t;ve++){const me=ve/t;m.x=-e*Math.cos(s+me*o)*Math.sin(a+K*c),m.y=e*Math.cos(a+K*c),m.z=e*Math.sin(s+me*o)*Math.sin(a+K*c),T.push(m.x,m.y,m.z),y.copy(m).normalize(),G.push(y.x,y.y,y.z),z.push(me+re,1-K),J.push(d++)}p.push(J)}for(let I=0;I<n;I++)for(let J=0;J<t;J++){const K=p[I][J+1],re=p[I][J],ve=p[I+1][J],me=p[I+1][J+1];(I!==0||a>0)&&M.push(K,re,me),(I!==n-1||u<Math.PI)&&M.push(re,ve,me)}this.setIndex(M),this.setAttribute("position",new Zi(T,3)),this.setAttribute("normal",new Zi(G,3)),this.setAttribute("uv",new Zi(z,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Yu(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Ef extends yf{constructor(e=1,t=0){const n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],s=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,s,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Ef(e.radius,e.detail)}}class Vp extends xr{constructor(e=1,t=.4,n=12,s=48,o=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:s,arc:o},n=Math.floor(n),s=Math.floor(s);const a=[],c=[],u=[],d=[],p=new it,m=new it,y=new it;for(let M=0;M<=n;M++)for(let T=0;T<=s;T++){const G=T/s*o,z=M/n*Math.PI*2;m.x=(e+t*Math.cos(z))*Math.cos(G),m.y=(e+t*Math.cos(z))*Math.sin(G),m.z=t*Math.sin(z),c.push(m.x,m.y,m.z),p.x=e*Math.cos(G),p.y=e*Math.sin(G),y.subVectors(m,p).normalize(),u.push(y.x,y.y,y.z),d.push(T/s),d.push(M/n)}for(let M=1;M<=n;M++)for(let T=1;T<=s;T++){const G=(s+1)*M+T-1,z=(s+1)*(M-1)+T-1,I=(s+1)*(M-1)+T,J=(s+1)*M+T;a.push(G,z,J),a.push(z,I,J)}this.setIndex(a),this.setAttribute("position",new Zi(c,3)),this.setAttribute("normal",new Zi(u,3)),this.setAttribute("uv",new Zi(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vp(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Gp extends xr{constructor(e=1,t=.4,n=64,s=8,o=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:s,p:o,q:a},n=Math.floor(n),s=Math.floor(s);const c=[],u=[],d=[],p=[],m=new it,y=new it,M=new it,T=new it,G=new it,z=new it,I=new it;for(let K=0;K<=n;++K){const re=K/n*o*Math.PI*2;J(re,o,a,e,M),J(re+.01,o,a,e,T),z.subVectors(T,M),I.addVectors(T,M),G.crossVectors(z,I),I.crossVectors(G,z),G.normalize(),I.normalize();for(let ve=0;ve<=s;++ve){const me=ve/s*Math.PI*2,Le=-t*Math.cos(me),Ve=t*Math.sin(me);m.x=M.x+(Le*I.x+Ve*G.x),m.y=M.y+(Le*I.y+Ve*G.y),m.z=M.z+(Le*I.z+Ve*G.z),u.push(m.x,m.y,m.z),y.subVectors(m,M).normalize(),d.push(y.x,y.y,y.z),p.push(K/n),p.push(ve/s)}}for(let K=1;K<=n;K++)for(let re=1;re<=s;re++){const ve=(s+1)*(K-1)+(re-1),me=(s+1)*K+(re-1),Le=(s+1)*K+re,Ve=(s+1)*(K-1)+re;c.push(ve,me,Ve),c.push(me,Le,Ve)}this.setIndex(c),this.setAttribute("position",new Zi(u,3)),this.setAttribute("normal",new Zi(d,3)),this.setAttribute("uv",new Zi(p,2));function J(K,re,ve,me,Le){const Ve=Math.cos(K),Ee=Math.sin(K),Oe=ve/re*K,dt=Math.cos(Oe);Le.x=me*(2+dt)*.5*Ve,Le.y=me*(2+dt)*Ee*.5,Le.z=me*Math.sin(Oe)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Gp(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Af extends xr{constructor(e=new xd(new it(-1,-1,0),new it(-1,1,0),new it(1,1,0)),t=64,n=1,s=8,o=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:s,closed:o};const a=e.computeFrenetFrames(t,o);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const c=new it,u=new it,d=new yn;let p=new it;const m=[],y=[],M=[],T=[];G(),this.setIndex(T),this.setAttribute("position",new Zi(m,3)),this.setAttribute("normal",new Zi(y,3)),this.setAttribute("uv",new Zi(M,2));function G(){for(let K=0;K<t;K++)z(K);z(o===!1?t:0),J(),I()}function z(K){p=e.getPointAt(K/t,p);const re=a.normals[K],ve=a.binormals[K];for(let me=0;me<=s;me++){const Le=me/s*Math.PI*2,Ve=Math.sin(Le),Ee=-Math.cos(Le);u.x=Ee*re.x+Ve*ve.x,u.y=Ee*re.y+Ve*ve.y,u.z=Ee*re.z+Ve*ve.z,u.normalize(),y.push(u.x,u.y,u.z),c.x=p.x+n*u.x,c.y=p.y+n*u.y,c.z=p.z+n*u.z,m.push(c.x,c.y,c.z)}}function I(){for(let K=1;K<=t;K++)for(let re=1;re<=s;re++){const ve=(s+1)*(K-1)+(re-1),me=(s+1)*K+(re-1),Le=(s+1)*K+re,Ve=(s+1)*(K-1)+re;T.push(ve,me,Ve),T.push(me,Le,Ve)}}function J(){for(let K=0;K<=t;K++)for(let re=0;re<=s;re++)d.x=K/t,d.y=re/s,M.push(d.x,d.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 Af(new pg[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class H1 extends xr{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,s=new it,o=new it;if(e.index!==null){const a=e.attributes.position,c=e.index;let u=e.groups;u.length===0&&(u=[{start:0,count:c.count,materialIndex:0}]);for(let d=0,p=u.length;d<p;++d){const m=u[d],y=m.start,M=m.count;for(let T=y,G=y+M;T<G;T+=3)for(let z=0;z<3;z++){const I=c.getX(T+z),J=c.getX(T+(z+1)%3);s.fromBufferAttribute(a,I),o.fromBufferAttribute(a,J),Cf(s,o,n)===!0&&(t.push(s.x,s.y,s.z),t.push(o.x,o.y,o.z))}}}else{const a=e.attributes.position;for(let c=0,u=a.count/3;c<u;c++)for(let d=0;d<3;d++){const p=3*c+d,m=3*c+(d+1)%3;s.fromBufferAttribute(a,p),o.fromBufferAttribute(a,m),Cf(s,o,n)===!0&&(t.push(s.x,s.y,s.z),t.push(o.x,o.y,o.z))}}this.setAttribute("position",new Zi(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Cf(i,e,t){const n=`${i.x},${i.y},${i.z}-${e.x},${e.y},${e.z}`,s=`${e.x},${e.y},${e.z}-${i.x},${i.y},${i.z}`;return t.has(n)===!0||t.has(s)===!0?!1:(t.add(n),t.add(s),!0)}var gg=Object.freeze({__proto__:null,BoxGeometry:Uc,CapsuleGeometry:K0,CircleGeometry:Sx,ConeGeometry:Rp,CylinderGeometry:Cp,DodecahedronGeometry:Tx,EdgesGeometry:gd,ExtrudeGeometry:kp,IcosahedronGeometry:bc,LatheGeometry:mg,OctahedronGeometry:zp,PlaneGeometry:Ch,PolyhedronGeometry:yf,RingGeometry:cy,ShapeGeometry:uy,SphereGeometry:Yu,TetrahedronGeometry:Ef,TorusGeometry:Vp,TorusKnotGeometry:Gp,TubeGeometry:Af,WireframeGeometry:H1});class yg extends Ei{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new jn(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 dy extends null{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Wp extends Ei{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new jn(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 jn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xa,this.normalScale=new yn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Qi,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.envMapRotation.copy(e.envMapRotation),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 Ox extends Wp{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 yn(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Sr(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 jn(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 jn(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new jn(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=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 dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=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.dispersion=e.dispersion,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 fy extends Ei{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new jn(16777215),this.specular=new jn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new jn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xa,this.normalScale=new yn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Qi,this.combine=Et,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.envMapRotation.copy(e.envMapRotation),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 py extends Ei{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new jn(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new jn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xa,this.normalScale=new yn(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 Fx extends Ei{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xa,this.normalScale=new yn(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 my extends Ei{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new jn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new jn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xa,this.normalScale=new yn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Qi,this.combine=Et,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.envMapRotation.copy(e.envMapRotation),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 Bx extends Ei{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=rp,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 Ux extends Ei{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}}class gy extends Ei{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new jn(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xa,this.normalScale=new yn(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 yy extends nl{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 wd(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function kx(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function zx(i){function e(s,o){return i[s]-i[o]}const t=i.length,n=new Array(t);for(let s=0;s!==t;++s)n[s]=s;return n.sort(e),n}function vy(i,e,t){const n=i.length,s=new i.constructor(n);for(let o=0,a=0;a!==n;++o){const c=t[o]*e;for(let u=0;u!==e;++u)s[a++]=i[c+u]}return s}function xy(i,e,t,n){let s=1,o=i[0];for(;o!==void 0&&o[n]===void 0;)o=i[s++];if(o===void 0)return;let a=o[n];if(a!==void 0)if(Array.isArray(a))do a=o[n],a!==void 0&&(e.push(o.time),t.push(...a)),o=i[s++];while(o!==void 0);else if(a.toArray!==void 0)do a=o[n],a!==void 0&&(e.push(o.time),a.toArray(t,t.length)),o=i[s++];while(o!==void 0);else do a=o[n],a!==void 0&&(e.push(o.time),t.push(a)),o=i[s++];while(o!==void 0)}function $1(i,e,t,n,s=30){const o=i.clone();o.name=e;const a=[];for(let u=0;u<o.tracks.length;++u){const d=o.tracks[u],p=d.getValueSize(),m=[],y=[];for(let M=0;M<d.times.length;++M){const T=d.times[M]*s;if(!(T<t||T>=n)){m.push(d.times[M]);for(let G=0;G<p;++G)y.push(d.values[M*p+G])}}m.length!==0&&(d.times=wd(m,d.times.constructor),d.values=wd(y,d.values.constructor),a.push(d))}o.tracks=a;let c=1/0;for(let u=0;u<o.tracks.length;++u)c>o.tracks[u].times[0]&&(c=o.tracks[u].times[0]);for(let u=0;u<o.tracks.length;++u)o.tracks[u].shift(-1*c);return o.resetDuration(),o}function Md(i,e=0,t=i,n=30){n<=0&&(n=30);const s=t.tracks.length,o=e/n;for(let a=0;a<s;++a){const c=t.tracks[a],u=c.ValueTypeName;if(u==="bool"||u==="string")continue;const d=i.tracks.find(function(I){return I.name===c.name&&I.ValueTypeName===u});if(d===void 0)continue;let p=0;const m=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(p=m/3);let y=0;const M=d.getValueSize();d.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(y=M/3);const T=c.times.length-1;let G;if(o<=c.times[0]){const I=p,J=m-p;G=c.values.slice(I,J)}else if(o>=c.times[T]){const I=T*m+p,J=I+m-p;G=c.values.slice(I,J)}else{const I=c.createInterpolant(),J=p,K=m-p;I.evaluate(o),G=I.resultBuffer.slice(J,K)}u==="quaternion"&&new ta().fromArray(G).normalize().conjugate().toArray(G);const z=d.times.length;for(let I=0;I<z;++I){const J=I*M+y;if(u==="quaternion")ta.multiplyQuaternionsFlat(d.values,J,G,0,d.values,J);else{const K=M-y*2;for(let re=0;re<K;++re)d.values[J+re]-=G[re]}}}return i.blendMode=Lc,i}class j1{static convertArray(e,t){return wd(e,t)}static isTypedArray(e){return kx(e)}static getKeyframeOrder(e){return zx(e)}static sortedArray(e,t,n){return vy(e,t,n)}static flattenJSON(e,t,n,s){xy(e,t,n,s)}static subclip(e,t,n,s,o=30){return $1(e,t,n,s,o)}static makeClipAdditive(e,t=0,n=e,s=30){return Md(e,t,n,s)}}class Hp{constructor(e,t,n,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=s!==void 0?s: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,s=t[n],o=t[n-1];e:{t:{let a;n:{i:if(!(e<s)){for(let c=n+2;;){if(s===void 0){if(e<o)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===c)break;if(o=s,s=t[++n],e<s)break t}a=t.length;break n}if(!(e>=o)){const c=t[1];e<c&&(n=2,o=c);for(let u=n-2;;){if(o===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===u)break;if(s=o,o=t[--n-1],e>=o)break t}a=n,n=0;break n}break e}for(;n<a;){const c=n+a>>>1;e<t[c]?a=c:n=c+1}if(s=t[n],o=t[n-1],o===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,o,s)}return this.interpolate_(n,o,e,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,o=e*s;for(let a=0;a!==s;++a)t[a]=n[o+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class _y extends Hp{constructor(e,t,n,s){super(e,t,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ha,endingEnd:ha}}intervalChanged_(e,t,n){const s=this.parameterPositions;let o=e-2,a=e+1,c=s[o],u=s[a];if(c===void 0)switch(this.getSettings_().endingStart){case Ba:o=e,c=2*t-n;break;case al:o=s.length-2,c=t+s[o]-s[o+1];break;default:o=e,c=n}if(u===void 0)switch(this.getSettings_().endingEnd){case Ba:a=e,u=2*n-t;break;case al:a=1,u=n+s[1]-s[0];break;default:a=e-1,u=t}const d=(n-t)*.5,p=this.valueSize;this._weightPrev=d/(t-c),this._weightNext=d/(u-n),this._offsetPrev=o*p,this._offsetNext=a*p}interpolate_(e,t,n,s){const o=this.resultBuffer,a=this.sampleValues,c=this.valueSize,u=e*c,d=u-c,p=this._offsetPrev,m=this._offsetNext,y=this._weightPrev,M=this._weightNext,T=(n-t)/(s-t),G=T*T,z=G*T,I=-y*z+2*y*G-y*T,J=(1+y)*z+(-1.5-2*y)*G+(-.5+y)*T+1,K=(-1-M)*z+(1.5+M)*G+.5*T,re=M*z-M*G;for(let ve=0;ve!==c;++ve)o[ve]=I*a[p+ve]+J*a[d+ve]+K*a[u+ve]+re*a[m+ve];return o}}class vg extends Hp{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){const o=this.resultBuffer,a=this.sampleValues,c=this.valueSize,u=e*c,d=u-c,p=(n-t)/(s-t),m=1-p;for(let y=0;y!==c;++y)o[y]=a[d+y]*m+a[u+y]*p;return o}}class X1 extends Hp{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e){return this.copySampleValue_(e-1)}}class $c{constructor(e,t,n,s){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=wd(t,this.TimeBufferType),this.values=wd(n,this.ValueBufferType),this.setInterpolation(s||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:wd(e.times,Array),values:wd(e.values,Array)};const s=e.getInterpolation();s!==e.DefaultInterpolation&&(n.interpolation=s)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new X1(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new vg(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new _y(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Co:t=this.InterpolantFactoryMethodDiscrete;break;case sl:t=this.InterpolantFactoryMethodLinear;break;case ol: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 Co;case this.InterpolantFactoryMethodLinear:return sl;case this.InterpolantFactoryMethodSmooth:return ol}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]*=e}return this}trim(e,t){const n=this.times,s=n.length;let o=0,a=s-1;for(;o!==s&&n[o]<e;)++o;for(;a!==-1&&n[a]>t;)--a;if(++a,o!==0||a!==s){o>=a&&(a=Math.max(a,1),o=a-1);const c=this.getValueSize();this.times=n.slice(o,a),this.values=this.values.slice(o*c,a*c)}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,s=this.values,o=n.length;o===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let c=0;c!==o;c++){const u=n[c];if(typeof u=="number"&&isNaN(u)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,c,u),e=!1;break}if(a!==null&&a>u){console.error("THREE.KeyframeTrack: Out of order keys.",this,c,u,a),e=!1;break}a=u}if(s!==void 0&&kx(s))for(let c=0,u=s.length;c!==u;++c){const d=s[c];if(isNaN(d)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,c,d),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===ol,o=e.length-1;let a=1;for(let c=1;c<o;++c){let u=!1;const d=e[c],p=e[c+1];if(d!==p&&(c!==1||d!==e[0]))if(s)u=!0;else{const m=c*n,y=m-n,M=m+n;for(let T=0;T!==n;++T){const G=t[m+T];if(G!==t[y+T]||G!==t[M+T]){u=!0;break}}}if(u){if(c!==a){e[a]=e[c];const m=c*n,y=a*n;for(let M=0;M!==n;++M)t[y+M]=t[m+M]}++a}}if(o>0){e[a]=e[o];for(let c=o*n,u=a*n,d=0;d!==n;++d)t[u+d]=t[c+d];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,s}}$c.prototype.ValueTypeName="",$c.prototype.TimeBufferType=Float32Array,$c.prototype.ValueBufferType=Float32Array,$c.prototype.DefaultInterpolation=sl;class $p extends $c{constructor(e,t,n){super(e,t,n)}}$p.prototype.ValueTypeName="bool",$p.prototype.ValueBufferType=Array,$p.prototype.DefaultInterpolation=Co,$p.prototype.InterpolantFactoryMethodLinear=void 0,$p.prototype.InterpolantFactoryMethodSmooth=void 0;class jp extends $c{constructor(e,t,n,s){super(e,t,n,s)}}jp.prototype.ValueTypeName="color";class xg extends $c{constructor(e,t,n,s){super(e,t,n,s)}}xg.prototype.ValueTypeName="number";class Vx extends Hp{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){const o=this.resultBuffer,a=this.sampleValues,c=this.valueSize,u=(n-t)/(s-t);let d=e*c;for(let p=d+c;d!==p;d+=4)ta.slerpFlat(o,0,a,d-c,a,d,u);return o}}class _g extends $c{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new Vx(this.times,this.values,this.getValueSize(),e)}}_g.prototype.ValueTypeName="quaternion",_g.prototype.InterpolantFactoryMethodSmooth=void 0;class wl extends $c{constructor(e,t,n){super(e,t,n)}}wl.prototype.ValueTypeName="string",wl.prototype.ValueBufferType=Array,wl.prototype.DefaultInterpolation=Co,wl.prototype.InterpolantFactoryMethodLinear=void 0,wl.prototype.InterpolantFactoryMethodSmooth=void 0;class Zu extends $c{constructor(e,t,n,s){super(e,t,n,s)}}Zu.prototype.ValueTypeName="vector";class Xp{constructor(e="",t=-1,n=[],s=wo){this.name=e,this.tracks=n,this.duration=t,this.blendMode=s,this.uuid=xl(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,s=1/(e.fps||1);for(let a=0,c=n.length;a!==c;++a)t.push(q1(n[a]).scale(s));const o=new this(e.name,e.duration,t,e.blendMode);return o.uuid=e.uuid,o.userData=JSON.parse(e.userData||"{}"),o}static toJSON(e){const t=[],n=e.tracks,s={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let o=0,a=n.length;o!==a;++o)t.push($c.toJSON(n[o]));return s}static CreateFromMorphTargetSequence(e,t,n,s){const o=t.length,a=[];for(let c=0;c<o;c++){let u=[],d=[];u.push((c+o-1)%o,c,(c+1)%o),d.push(0,1,0);const p=zx(u);u=vy(u,1,p),d=vy(d,1,p),!s&&u[0]===0&&(u.push(o),d.push(d[0])),a.push(new xg(".morphTargetInfluences["+t[c].name+"]",u,d).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const s=e;n=s.geometry&&s.geometry.animations||s.animations}for(let s=0;s<n.length;s++)if(n[s].name===t)return n[s];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const s={},o=/^([\w-]*?)([\d]+)$/;for(let c=0,u=e.length;c<u;c++){const d=e[c],p=d.name.match(o);if(p&&p.length>1){const m=p[1];let y=s[m];y||(s[m]=y=[]),y.push(d)}}const a=[];for(const c in s)a.push(this.CreateFromMorphTargetSequence(c,s[c],t,n));return a}static parseAnimation(e,t){if(console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(m,y,M,T,G){if(M.length!==0){const z=[],I=[];xy(M,z,I,T),z.length!==0&&G.push(new m(y,z,I))}},s=[],o=e.name||"default",a=e.fps||30,c=e.blendMode;let u=e.length||-1;const d=e.hierarchy||[];for(let m=0;m<d.length;m++){const y=d[m].keys;if(!(!y||y.length===0))if(y[0].morphTargets){const M={};let T;for(T=0;T<y.length;T++)if(y[T].morphTargets)for(let G=0;G<y[T].morphTargets.length;G++)M[y[T].morphTargets[G]]=-1;for(const G in M){const z=[],I=[];for(let J=0;J!==y[T].morphTargets.length;++J){const K=y[T];z.push(K.time),I.push(K.morphTarget===G?1:0)}s.push(new xg(".morphTargetInfluence["+G+"]",z,I))}u=M.length*a}else{const M=".bones["+t[m].name+"]";n(Zu,M+".position",y,"pos",s),n(_g,M+".quaternion",y,"rot",s),n(Zu,M+".scale",y,"scl",s)}}return s.length===0?null:new this(o,u,s,c)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,s=e.length;n!==s;++n){const o=this.tracks[n];t=Math.max(t,o.times[o.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 n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function bg(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return xg;case"vector":case"vector2":case"vector3":case"vector4":return Zu;case"color":return jp;case"quaternion":return _g;case"bool":case"boolean":return $p;case"string":return wl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function q1(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=bg(i.type);if(i.times===void 0){const t=[],n=[];xy(i.keys,t,n,"value"),i.times=t,i.values=n}return e.parse!==void 0?e.parse(i):new e(i.name,i.times,i.values,i.interpolation)}const wc={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class Sd{constructor(e,t,n){const s=this;let o=!1,a=0,c=0,u;const d=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.abortController=new AbortController,this.itemStart=function(p){c++,o===!1&&s.onStart!==void 0&&s.onStart(p,a,c),o=!0},this.itemEnd=function(p){a++,s.onProgress!==void 0&&s.onProgress(p,a,c),a===c&&(o=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(p){s.onError!==void 0&&s.onError(p)},this.resolveURL=function(p){return u?u(p):p},this.setURLModifier=function(p){return u=p,this},this.addHandler=function(p,m){return d.push(p,m),this},this.removeHandler=function(p){const m=d.indexOf(p);return m!==-1&&d.splice(m,2),this},this.getHandler=function(p){for(let m=0,y=d.length;m<y;m+=2){const M=d[m],T=d[m+1];if(M.global&&(M.lastIndex=0),M.test(p))return T}return null},this.abort=function(){return this.abortController.abort(),this.abortController=new AbortController,this}}}const wg=new Sd;class Rf{constructor(e){this.manager=e!==void 0?e:wg,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(s,o){n.load(e,s,t,o)})}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}abort(){return this}}Rf.DEFAULT_MATERIAL_NAME="__DEFAULT";const Ku={};class Y1 extends null{constructor(e,t){super(e),this.response=t}}class Ml extends null{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const o=wc.get(`file:${e}`);if(o!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(o),this.manager.itemEnd(e)},0),o;if(Ku[e]!==void 0){Ku[e].push({onLoad:t,onProgress:n,onError:s});return}Ku[e]=[],Ku[e].push({onLoad:t,onProgress:n,onError:s});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),c=this.mimeType,u=this.responseType;fetch(a).then(d=>{if(d.status===200||d.status===0){if(d.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream=="undefined"||d.body===void 0||d.body.getReader===void 0)return d;const p=Ku[e],m=d.body.getReader(),y=d.headers.get("X-File-Size")||d.headers.get("Content-Length"),M=y?parseInt(y):0,T=M!==0;let G=0;const z=new ReadableStream({start(I){J();function J(){m.read().then(({done:K,value:re})=>{if(K)I.close();else{G+=re.byteLength;const ve=new ProgressEvent("progress",{lengthComputable:T,loaded:G,total:M});for(let me=0,Le=p.length;me<Le;me++){const Ve=p[me];Ve.onProgress&&Ve.onProgress(ve)}I.enqueue(re),J()}},K=>{I.error(K)})}}});return new Response(z)}else throw new Y1(`fetch for "${d.url}" responded with ${d.status}: ${d.statusText}`,d)}).then(d=>{switch(u){case"arraybuffer":return d.arrayBuffer();case"blob":return d.blob();case"document":return d.text().then(p=>new DOMParser().parseFromString(p,c));case"json":return d.json();default:if(c==="")return d.text();{const m=/charset="?([^;"\s]*)"?/i.exec(c),y=m&&m[1]?m[1].toLowerCase():void 0,M=new TextDecoder(y);return d.arrayBuffer().then(T=>M.decode(T))}}}).then(d=>{wc.add(`file:${e}`,d);const p=Ku[e];delete Ku[e];for(let m=0,y=p.length;m<y;m++){const M=p[m];M.onLoad&&M.onLoad(d)}}).catch(d=>{const p=Ku[e];if(p===void 0)throw this.manager.itemError(e),d;delete Ku[e];for(let m=0,y=p.length;m<y;m++){const M=p[m];M.onError&&M.onError(d)}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}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class Z1 extends null{constructor(e){super(e)}load(e,t,n,s){const o=this,a=new Ml(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{t(o.parse(JSON.parse(c)))}catch(u){s?s(u):console.error(u),o.manager.itemError(e)}},n,s)}parse(e){const t=[];for(let n=0;n<e.length;n++){const s=Xp.parse(e[n]);t.push(s)}return t}}class xE extends null{constructor(e){super(e)}load(e,t,n,s){const o=this,a=[],c=new ug,u=new Ml(this.manager);u.setPath(this.path),u.setResponseType("arraybuffer"),u.setRequestHeader(this.requestHeader),u.setWithCredentials(o.withCredentials);let d=0;function p(m){u.load(e[m],function(y){const M=o.parse(y,!0);a[m]={width:M.width,height:M.height,format:M.format,mipmaps:M.mipmaps},d+=1,d===6&&(M.mipmapCount===1&&(c.minFilter=Rn),c.image=a,c.format=M.format,c.needsUpdate=!0,t&&t(c))},n,s)}if(Array.isArray(e))for(let m=0,y=e.length;m<y;++m)p(m);else u.load(e,function(m){const y=o.parse(m,!0);if(y.isCubemap){const M=y.mipmaps.length/y.mipmapCount;for(let T=0;T<M;T++){a[T]={mipmaps:[]};for(let G=0;G<y.mipmapCount;G++)a[T].mipmaps.push(y.mipmaps[T*y.mipmapCount+G]),a[T].format=y.format,a[T].width=y.width,a[T].height=y.height}c.image=a}else c.image.width=y.width,c.image.height=y.height,c.mipmaps=y.mipmaps;y.mipmapCount===1&&(c.minFilter=Rn),c.format=y.format,c.needsUpdate=!0,t&&t(c)},n,s);return c}}const Nf=new WeakMap;class Mc extends Rf{constructor(e){super(e)}load(e,t,n,s){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const o=this,a=wc.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)o.manager.itemStart(e),setTimeout(function(){t&&t(a),o.manager.itemEnd(e)},0);else{let m=Nf.get(a);m===void 0&&(m=[],Nf.set(a,m)),m.push({onLoad:t,onError:s})}return a}const c=mh("img");function u(){p(),t&&t(this);const m=Nf.get(this)||[];for(let y=0;y<m.length;y++){const M=m[y];M.onLoad&&M.onLoad(this)}Nf.delete(this),o.manager.itemEnd(e)}function d(m){p(),s&&s(m),wc.remove(`image:${e}`);const y=Nf.get(this)||[];for(let M=0;M<y.length;M++){const T=y[M];T.onError&&T.onError(m)}Nf.delete(this),o.manager.itemError(e),o.manager.itemEnd(e)}function p(){c.removeEventListener("load",u,!1),c.removeEventListener("error",d,!1)}return c.addEventListener("load",u,!1),c.addEventListener("error",d,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(c.crossOrigin=this.crossOrigin),wc.add(`image:${e}`,c),o.manager.itemStart(e),c.src=e,c}}class _E extends null{constructor(e){super(e)}load(e,t,n,s){const o=new xh;o.colorSpace=uo;const a=new Mc(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let c=0;function u(d){a.load(e[d],function(p){o.images[d]=p,c++,c===6&&(o.needsUpdate=!0,t&&t(o))},void 0,s)}for(let d=0;d<e.length;++d)u(d);return o}}class Td extends null{constructor(e){super(e)}load(e,t,n,s){const o=this,a=new tc,c=new Ml(this.manager);return c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setPath(this.path),c.setWithCredentials(o.withCredentials),c.load(e,function(u){let d;try{d=o.parse(u)}catch(p){if(s!==void 0)s(p);else{console.error(p);return}}d.image!==void 0?a.image=d.image:d.data!==void 0&&(a.image.width=d.width,a.image.height=d.height,a.image.data=d.data),a.wrapS=d.wrapS!==void 0?d.wrapS:$e,a.wrapT=d.wrapT!==void 0?d.wrapT:$e,a.magFilter=d.magFilter!==void 0?d.magFilter:Rn,a.minFilter=d.minFilter!==void 0?d.minFilter:Rn,a.anisotropy=d.anisotropy!==void 0?d.anisotropy:1,d.colorSpace!==void 0&&(a.colorSpace=d.colorSpace),d.flipY!==void 0&&(a.flipY=d.flipY),d.format!==void 0&&(a.format=d.format),d.type!==void 0&&(a.type=d.type),d.mipmaps!==void 0&&(a.mipmaps=d.mipmaps,a.minFilter=Qn),d.mipmapCount===1&&(a.minFilter=Rn),d.generateMipmaps!==void 0&&(a.generateMipmaps=d.generateMipmaps),a.needsUpdate=!0,t&&t(a,d)},n,s),a}}class bE extends Rf{constructor(e){super(e)}load(e,t,n,s){const o=new Ho,a=new Mc(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(c){o.image=c,o.needsUpdate=!0,t!==void 0&&t(o)},n,s),o}}class Pf extends Qr{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new jn(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()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class Ed extends Pf{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Qr.DEFAULT_UP),this.updateMatrix(),this.groundColor=new jn(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const If=new Ft,K1=new it,J1=new it;class Gx{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new yn(512,512),this.mapType=Oi,this.map=null,this.mapPass=null,this.matrix=new Ft,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new pf,this._frameExtents=new yn(1,1),this._viewportCount=1,this._viewports=[new mr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;K1.setFromMatrixPosition(e.matrixWorld),t.position.copy(K1),J1.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(J1),t.updateMatrixWorld(),If.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(If,t.coordinateSystem,t.reversedDepth),t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(If)}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.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),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 wE extends Gx{constructor(){super(new ma(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=Ua*2*e.angle*this.focus,s=this.mapSize.width/this.mapSize.height*this.aspect,o=e.distance||t.far;(n!==t.fov||s!==t.aspect||o!==t.far)&&(t.fov=n,t.aspect=s,t.far=o,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Mg extends Pf{constructor(e,t,n=0,s=Math.PI/3,o=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Qr.DEFAULT_UP),this.updateMatrix(),this.target=new Qr,this.distance=n,this.angle=s,this.penumbra=o,this.decay=a,this.map=null,this.shadow=new wE}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 Sg=new Ft,Lf=new it,Tg=new it;class ME extends Gx{constructor(){super(new ma(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new yn(4,2),this._viewportCount=6,this._viewports=[new mr(2,1,1,1),new mr(0,1,1,1),new mr(3,1,1,1),new mr(1,1,1,1),new mr(3,0,1,1),new mr(1,0,1,1)],this._cubeDirections=[new it(1,0,0),new it(-1,0,0),new it(0,0,1),new it(0,0,-1),new it(0,1,0),new it(0,-1,0)],this._cubeUps=[new it(0,1,0),new it(0,1,0),new it(0,1,0),new it(0,1,0),new it(0,0,1),new it(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,s=this.matrix,o=e.distance||n.far;o!==n.far&&(n.far=o,n.updateProjectionMatrix()),Lf.setFromMatrixPosition(e.matrixWorld),n.position.copy(Lf),Tg.copy(n.position),Tg.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Tg),n.updateMatrixWorld(),s.makeTranslation(-Lf.x,-Lf.y,-Lf.z),Sg.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Sg,n.coordinateSystem,n.reversedDepth)}}class Wx extends Pf{constructor(e,t,n=0,s=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=s,this.shadow=new ME}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 Df extends Zm{constructor(e=-1,t=1,n=1,s=-1,o=.1,a=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=s,this.near=o,this.far=a,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,s,o,a){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=s,this.view.width=o,this.view.height=a,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,s=(this.top+this.bottom)/2;let o=n-e,a=n+e,c=s+t,u=s-t;if(this.view!==null&&this.view.enabled){const d=(this.right-this.left)/this.view.fullWidth/this.zoom,p=(this.top-this.bottom)/this.view.fullHeight/this.zoom;o+=d*this.view.offsetX,a=o+d*this.view.width,c-=p*this.view.offsetY,u=c-p*this.view.height}this.projectionMatrix.makeOrthographic(o,a,c,u,this.near,this.far,this.coordinateSystem,this.reversedDepth),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}}class Hx extends Gx{constructor(){super(new Df(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Ad extends Pf{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Qr.DEFAULT_UP),this.updateMatrix(),this.target=new Qr,this.shadow=new Hx}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class qp extends Pf{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class $x extends Pf{constructor(e,t,n=10,s=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=s}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 Q1{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new it)}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,s=e.y,o=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*s),t.addScaledVector(a[2],.488603*o),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],1.092548*(n*s)),t.addScaledVector(a[5],1.092548*(s*o)),t.addScaledVector(a[6],.315392*(3*o*o-1)),t.addScaledVector(a[7],1.092548*(n*o)),t.addScaledVector(a[8],.546274*(n*n-s*s)),t}getIrradianceAt(e,t){const n=e.x,s=e.y,o=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*s),t.addScaledVector(a[2],2*.511664*o),t.addScaledVector(a[3],2*.511664*n),t.addScaledVector(a[4],2*.429043*n*s),t.addScaledVector(a[5],2*.429043*s*o),t.addScaledVector(a[6],.743125*o*o-.247708),t.addScaledVector(a[7],2*.429043*n*o),t.addScaledVector(a[8],.429043*(n*n-s*s)),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 s=0;s<9;s++)n[s].fromArray(e,t+s*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let s=0;s<9;s++)n[s].toArray(e,t+s*3);return e}static getBasisAt(e,t){const n=e.x,s=e.y,o=e.z;t[0]=.282095,t[1]=.488603*s,t[2]=.488603*o,t[3]=.488603*n,t[4]=1.092548*n*s,t[5]=1.092548*s*o,t[6]=.315392*(3*o*o-1),t[7]=1.092548*n*o,t[8]=.546274*(n*n-s*s)}}class by extends Pf{constructor(e=new Q1,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 wy extends null{constructor(e){super(e),this.textures={}}load(e,t,n,s){const o=this,a=new Ml(o.manager);a.setPath(o.path),a.setRequestHeader(o.requestHeader),a.setWithCredentials(o.withCredentials),a.load(e,function(c){try{t(o.parse(JSON.parse(c)))}catch(u){s?s(u):console.error(u),o.manager.itemError(e)}},n,s)}parse(e){const t=this.textures;function n(o){return t[o]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",o),t[o]}const s=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(s.uuid=e.uuid),e.name!==void 0&&(s.name=e.name),e.color!==void 0&&s.color!==void 0&&s.color.setHex(e.color),e.roughness!==void 0&&(s.roughness=e.roughness),e.metalness!==void 0&&(s.metalness=e.metalness),e.sheen!==void 0&&(s.sheen=e.sheen),e.sheenColor!==void 0&&(s.sheenColor=new jn().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(s.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&s.emissive!==void 0&&s.emissive.setHex(e.emissive),e.specular!==void 0&&s.specular!==void 0&&s.specular.setHex(e.specular),e.specularIntensity!==void 0&&(s.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&s.specularColor!==void 0&&s.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(s.shininess=e.shininess),e.clearcoat!==void 0&&(s.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(s.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(s.dispersion=e.dispersion),e.iridescence!==void 0&&(s.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(s.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(s.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(s.transmission=e.transmission),e.thickness!==void 0&&(s.thickness=e.thickness),e.attenuationDistance!==void 0&&(s.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&s.attenuationColor!==void 0&&s.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(s.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(s.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(s.fog=e.fog),e.flatShading!==void 0&&(s.flatShading=e.flatShading),e.blending!==void 0&&(s.blending=e.blending),e.combine!==void 0&&(s.combine=e.combine),e.side!==void 0&&(s.side=e.side),e.shadowSide!==void 0&&(s.shadowSide=e.shadowSide),e.opacity!==void 0&&(s.opacity=e.opacity),e.transparent!==void 0&&(s.transparent=e.transparent),e.alphaTest!==void 0&&(s.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(s.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(s.depthFunc=e.depthFunc),e.depthTest!==void 0&&(s.depthTest=e.depthTest),e.depthWrite!==void 0&&(s.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(s.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(s.blendSrc=e.blendSrc),e.blendDst!==void 0&&(s.blendDst=e.blendDst),e.blendEquation!==void 0&&(s.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(s.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(s.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(s.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&s.blendColor!==void 0&&s.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(s.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(s.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(s.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(s.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(s.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(s.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(s.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(s.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(s.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(s.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(s.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(s.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(s.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(s.rotation=e.rotation),e.linewidth!==void 0&&(s.linewidth=e.linewidth),e.dashSize!==void 0&&(s.dashSize=e.dashSize),e.gapSize!==void 0&&(s.gapSize=e.gapSize),e.scale!==void 0&&(s.scale=e.scale),e.polygonOffset!==void 0&&(s.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(s.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(s.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(s.dithering=e.dithering),e.alphaToCoverage!==void 0&&(s.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(s.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(s.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(s.visible=e.visible),e.toneMapped!==void 0&&(s.toneMapped=e.toneMapped),e.userData!==void 0&&(s.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?s.vertexColors=e.vertexColors>0:s.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const o in e.uniforms){const a=e.uniforms[o];switch(s.uniforms[o]={},a.type){case"t":s.uniforms[o].value=n(a.value);break;case"c":s.uniforms[o].value=new jn().setHex(a.value);break;case"v2":s.uniforms[o].value=new yn().fromArray(a.value);break;case"v3":s.uniforms[o].value=new it().fromArray(a.value);break;case"v4":s.uniforms[o].value=new mr().fromArray(a.value);break;case"m3":s.uniforms[o].value=new jr().fromArray(a.value);break;case"m4":s.uniforms[o].value=new Ft().fromArray(a.value);break;default:s.uniforms[o].value=a.value}}if(e.defines!==void 0&&(s.defines=e.defines),e.vertexShader!==void 0&&(s.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(s.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(s.glslVersion=e.glslVersion),e.extensions!==void 0)for(const o in e.extensions)s.extensions[o]=e.extensions[o];if(e.lights!==void 0&&(s.lights=e.lights),e.clipping!==void 0&&(s.clipping=e.clipping),e.size!==void 0&&(s.size=e.size),e.sizeAttenuation!==void 0&&(s.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(s.map=n(e.map)),e.matcap!==void 0&&(s.matcap=n(e.matcap)),e.alphaMap!==void 0&&(s.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(s.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(s.bumpScale=e.bumpScale),e.normalMap!==void 0&&(s.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(s.normalMapType=e.normalMapType),e.normalScale!==void 0){let o=e.normalScale;Array.isArray(o)===!1&&(o=[o,o]),s.normalScale=new yn().fromArray(o)}return e.displacementMap!==void 0&&(s.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(s.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(s.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(s.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(s.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(s.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(s.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(s.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(s.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(s.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(s.envMap=n(e.envMap)),e.envMapRotation!==void 0&&s.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(s.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(s.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(s.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(s.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(s.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(s.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(s.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(s.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(s.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(s.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(s.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(s.clearcoatNormalScale=new yn().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(s.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(s.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(s.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(s.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(s.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(s.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(s.sheenRoughnessMap=n(e.sheenRoughnessMap)),s}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return wy.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:yg,SpriteMaterial:mp,RawShaderMaterial:dy,ShaderMaterial:kc,PointsMaterial:gf,MeshPhysicalMaterial:Ox,MeshStandardMaterial:Wp,MeshPhongMaterial:fy,MeshToonMaterial:py,MeshNormalMaterial:Fx,MeshLambertMaterial:my,MeshDepthMaterial:Bx,MeshDistanceMaterial:Ux,MeshBasicMaterial:Hr,MeshMatcapMaterial:gy,LineDashedMaterial:yy,LineBasicMaterial:nl,Material:Ei};return new t[e]}}class jx{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 ew extends null{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 tw extends null{constructor(e){super(e)}load(e,t,n,s){const o=this,a=new Ml(o.manager);a.setPath(o.path),a.setRequestHeader(o.requestHeader),a.setWithCredentials(o.withCredentials),a.load(e,function(c){try{t(o.parse(JSON.parse(c)))}catch(u){s?s(u):console.error(u),o.manager.itemError(e)}},n,s)}parse(e){const t={},n={};function s(M,T){if(t[T]!==void 0)return t[T];const z=M.interleavedBuffers[T],I=o(M,z.buffer),J=ph(z.type,I),K=new ju(J,z.stride);return K.uuid=z.uuid,t[T]=K,K}function o(M,T){if(n[T]!==void 0)return n[T];const z=M.arrayBuffers[T],I=new Uint32Array(z).buffer;return n[T]=I,I}const a=e.isInstancedBufferGeometry?new ew:new xr,c=e.data.index;if(c!==void 0){const M=ph(c.type,c.array);a.setIndex(new es(M,1))}const u=e.data.attributes;for(const M in u){const T=u[M];let G;if(T.isInterleavedBufferAttribute){const z=s(e.data,T.data);G=new hf(z,T.itemSize,T.offset,T.normalized)}else{const z=ph(T.type,T.array),I=T.isInstancedBufferAttribute?Vc:es;G=new I(z,T.itemSize,T.normalized)}T.name!==void 0&&(G.name=T.name),T.usage!==void 0&&G.setUsage(T.usage),a.setAttribute(M,G)}const d=e.data.morphAttributes;if(d)for(const M in d){const T=d[M],G=[];for(let z=0,I=T.length;z<I;z++){const J=T[z];let K;if(J.isInterleavedBufferAttribute){const re=s(e.data,J.data);K=new hf(re,J.itemSize,J.offset,J.normalized)}else{const re=ph(J.type,J.array);K=new es(re,J.itemSize,J.normalized)}J.name!==void 0&&(K.name=J.name),G.push(K)}a.morphAttributes[M]=G}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);const m=e.data.groups||e.data.drawcalls||e.data.offsets;if(m!==void 0)for(let M=0,T=m.length;M!==T;++M){const G=m[M];a.addGroup(G.start,G.count,G.materialIndex)}const y=e.data.boundingSphere;return y!==void 0&&(a.boundingSphere=new xe().fromJSON(y)),e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class SE extends null{constructor(e){super(e)}load(e,t,n,s){const o=this,a=this.path===""?jx.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const c=new Ml(this.manager);c.setPath(this.path),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(u){let d=null;try{d=JSON.parse(u)}catch(m){s!==void 0&&s(m),console.error("THREE:ObjectLoader: Can't parse "+e+".",m.message);return}const p=d.metadata;if(p===void 0||p.type===void 0||p.type.toLowerCase()==="geometry"){s!==void 0&&s(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}o.parse(d,t)},n,s)}loadAsync(e,t){return hr(this,null,function*(){const n=this,s=this.path===""?jx.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||s;const o=new Ml(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials);const a=yield o.loadAsync(e,t),c=JSON.parse(a),u=c.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return yield n.parseAsync(c)})}parse(e,t){const n=this.parseAnimations(e.animations),s=this.parseShapes(e.shapes),o=this.parseGeometries(e.geometries,s),a=this.parseImages(e.images,function(){t!==void 0&&t(d)}),c=this.parseTextures(e.textures,a),u=this.parseMaterials(e.materials,c),d=this.parseObject(e.object,o,u,c,n),p=this.parseSkeletons(e.skeletons,d);if(this.bindSkeletons(d,p),this.bindLightTargets(d),t!==void 0){let m=!1;for(const y in a)if(a[y].data instanceof HTMLImageElement){m=!0;break}m===!1&&t(d)}return d}parseAsync(e){return hr(this,null,function*(){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,n),o=yield this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,o),c=this.parseMaterials(e.materials,a),u=this.parseObject(e.object,s,c,a,t),d=this.parseSkeletons(e.skeletons,u);return this.bindSkeletons(u,d),this.bindLightTargets(u),u})}parseShapes(e){const t={};if(e!==void 0)for(let n=0,s=e.length;n<s;n++){const o=new _d().fromJSON(e[n]);t[o.uuid]=o}return t}parseSkeletons(e,t){const n={},s={};if(t.traverse(function(o){o.isBone&&(s[o.uuid]=o)}),e!==void 0)for(let o=0,a=e.length;o<a;o++){const c=new vp().fromJSON(e[o],s);n[c.uuid]=c}return n}parseGeometries(e,t){const n={};if(e!==void 0){const s=new tw;for(let o=0,a=e.length;o<a;o++){let c;const u=e[o];switch(u.type){case"BufferGeometry":case"InstancedBufferGeometry":c=s.parse(u);break;default:u.type in gg?c=gg[u.type].fromJSON(u,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${u.type}"`)}c.uuid=u.uuid,u.name!==void 0&&(c.name=u.name),u.userData!==void 0&&(c.userData=u.userData),n[u.uuid]=c}}return n}parseMaterials(e,t){const n={},s={};if(e!==void 0){const o=new wy;o.setTextures(t);for(let a=0,c=e.length;a<c;a++){const u=e[a];n[u.uuid]===void 0&&(n[u.uuid]=o.parse(u)),s[u.uuid]=n[u.uuid]}}return s}parseAnimations(e){const t={};if(e!==void 0)for(let n=0;n<e.length;n++){const s=e[n],o=Xp.parse(s);t[o.uuid]=o}return t}parseImages(e,t){const n=this,s={};let o;function a(u){return n.manager.itemStart(u),o.load(u,function(){n.manager.itemEnd(u)},void 0,function(){n.manager.itemError(u),n.manager.itemEnd(u)})}function c(u){if(typeof u=="string"){const d=u,p=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(d)?d:n.resourcePath+d;return a(p)}else return u.data?{data:ph(u.type,u.data),width:u.width,height:u.height}:null}if(e!==void 0&&e.length>0){const u=new Sd(t);o=new Mc(u),o.setCrossOrigin(this.crossOrigin);for(let d=0,p=e.length;d<p;d++){const m=e[d],y=m.url;if(Array.isArray(y)){const M=[];for(let T=0,G=y.length;T<G;T++){const z=y[T],I=c(z);I!==null&&(I instanceof HTMLImageElement?M.push(I):M.push(new tc(I.data,I.width,I.height)))}s[m.uuid]=new Mo(M)}else{const M=c(m.url);s[m.uuid]=new Mo(M)}}}return s}parseImagesAsync(e){return hr(this,null,function*(){const t=this,n={};let s;function o(a){return hr(this,null,function*(){if(typeof a=="string"){const c=a,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:t.resourcePath+c;return yield s.loadAsync(u)}else return a.data?{data:ph(a.type,a.data),width:a.width,height:a.height}:null})}if(e!==void 0&&e.length>0){s=new Mc(this.manager),s.setCrossOrigin(this.crossOrigin);for(let a=0,c=e.length;a<c;a++){const u=e[a],d=u.url;if(Array.isArray(d)){const p=[];for(let m=0,y=d.length;m<y;m++){const M=d[m],T=yield o(M);T!==null&&(T instanceof HTMLImageElement?p.push(T):p.push(new tc(T.data,T.width,T.height)))}n[u.uuid]=new Mo(p)}else{const p=yield o(u.url);n[u.uuid]=new Mo(p)}}}return n})}parseTextures(e,t){function n(o,a){return typeof o=="number"?o:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",o),a[o])}const s={};if(e!==void 0)for(let o=0,a=e.length;o<a;o++){const c=e[o];c.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',c.uuid),t[c.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",c.image);const u=t[c.image],d=u.data;let p;Array.isArray(d)?(p=new xh,d.length===6&&(p.needsUpdate=!0)):(d&&d.data?p=new tc:p=new Ho,d&&(p.needsUpdate=!0)),p.source=u,p.uuid=c.uuid,c.name!==void 0&&(p.name=c.name),c.mapping!==void 0&&(p.mapping=n(c.mapping,nw)),c.channel!==void 0&&(p.channel=c.channel),c.offset!==void 0&&p.offset.fromArray(c.offset),c.repeat!==void 0&&p.repeat.fromArray(c.repeat),c.center!==void 0&&p.center.fromArray(c.center),c.rotation!==void 0&&(p.rotation=c.rotation),c.wrap!==void 0&&(p.wrapS=n(c.wrap[0],Eg),p.wrapT=n(c.wrap[1],Eg)),c.format!==void 0&&(p.format=c.format),c.internalFormat!==void 0&&(p.internalFormat=c.internalFormat),c.type!==void 0&&(p.type=c.type),c.colorSpace!==void 0&&(p.colorSpace=c.colorSpace),c.minFilter!==void 0&&(p.minFilter=n(c.minFilter,My)),c.magFilter!==void 0&&(p.magFilter=n(c.magFilter,My)),c.anisotropy!==void 0&&(p.anisotropy=c.anisotropy),c.flipY!==void 0&&(p.flipY=c.flipY),c.generateMipmaps!==void 0&&(p.generateMipmaps=c.generateMipmaps),c.premultiplyAlpha!==void 0&&(p.premultiplyAlpha=c.premultiplyAlpha),c.unpackAlignment!==void 0&&(p.unpackAlignment=c.unpackAlignment),c.compareFunction!==void 0&&(p.compareFunction=c.compareFunction),c.userData!==void 0&&(p.userData=c.userData),s[c.uuid]=p}return s}parseObject(e,t,n,s,o){let a;function c(y){return t[y]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",y),t[y]}function u(y){if(y!==void 0){if(Array.isArray(y)){const M=[];for(let T=0,G=y.length;T<G;T++){const z=y[T];n[z]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",z),M.push(n[z])}return M}return n[y]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",y),n[y]}}function d(y){return s[y]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",y),s[y]}let p,m;switch(e.type){case"Scene":a=new Km,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new jn(e.background):a.background=d(e.background)),e.environment!==void 0&&(a.environment=d(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?a.fog=new pp(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new F0(e.fog.color,e.fog.density)),e.fog.name!==""&&(a.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(a.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(a.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&a.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(a.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&a.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":a=new ma(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(a.focus=e.focus),e.zoom!==void 0&&(a.zoom=e.zoom),e.filmGauge!==void 0&&(a.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(a.filmOffset=e.filmOffset),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new Df(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(a.zoom=e.zoom),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new qp(e.color,e.intensity);break;case"DirectionalLight":a=new Ad(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new Wx(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new $x(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new Mg(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||"";break;case"HemisphereLight":a=new Ed(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=new by().fromJSON(e);break;case"SkinnedMesh":p=c(e.geometry),m=u(e.material),a=new v1(p,m),e.bindMode!==void 0&&(a.bindMode=e.bindMode),e.bindMatrix!==void 0&&a.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(a.skeleton=e.skeleton);break;case"Mesh":p=c(e.geometry),m=u(e.material),a=new Ks(p,m);break;case"InstancedMesh":p=c(e.geometry),m=u(e.material);const y=e.count,M=e.instanceMatrix,T=e.instanceColor;a=new yx(p,m,y),a.instanceMatrix=new Vc(new Float32Array(M.array),16),T!==void 0&&(a.instanceColor=new Vc(new Float32Array(T.array),T.itemSize));break;case"BatchedMesh":p=c(e.geometry),m=u(e.material),a=new w1(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,m),a.geometry=p,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._geometryInfo=e.geometryInfo.map(G=>{let z=null,I=null;return G.boundingBox!==void 0&&(z=new fa().fromJSON(G.boundingBox)),G.boundingSphere!==void 0&&(I=new xe().fromJSON(G.boundingSphere)),cc(Ys({},G),{boundingBox:z,boundingSphere:I})}),a._instanceInfo=e.instanceInfo,a._availableInstanceIds=e._availableInstanceIds,a._availableGeometryIds=e._availableGeometryIds,a._nextIndexStart=e.nextIndexStart,a._nextVertexStart=e.nextVertexStart,a._geometryCount=e.geometryCount,a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._matricesTexture=d(e.matricesTexture.uuid),a._indirectTexture=d(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=d(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(a.boundingSphere=new xe().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(a.boundingBox=new fa().fromJSON(e.boundingBox));break;case"LOD":a=new k0;break;case"Line":a=new Sh(c(e.geometry),u(e.material));break;case"LineLoop":a=new wx(c(e.geometry),u(e.material));break;case"LineSegments":a=new lg(c(e.geometry),u(e.material));break;case"PointCloud":case"Points":a=new M1(c(e.geometry),u(e.material));break;case"Sprite":a=new Jm(u(e.material));break;case"Group":a=new dl;break;case"Bone":a=new H0;break;default:a=new Qr}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const y=e.children;for(let M=0;M<y.length;M++)a.add(this.parseObject(y[M],t,n,s,o))}if(e.animations!==void 0){const y=e.animations;for(let M=0;M<y.length;M++){const T=y[M];a.animations.push(o[T])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);const y=e.levels;for(let M=0;M<y.length;M++){const T=y[M],G=a.getObjectByProperty("uuid",T.object);G!==void 0&&a.addLevel(G,T.distance,T.hysteresis)}}return a}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){const s=t[n.skeleton];s===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(s,n.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const n=t.target,s=e.getObjectByProperty("uuid",n);s!==void 0?t.target=s:t.target=new Qr}})}}const nw={UVMapping:Q,CubeReflectionMapping:De,CubeRefractionMapping:We,EquirectangularReflectionMapping:Ce,EquirectangularRefractionMapping:Re,CubeUVReflectionMapping:qe},Eg={RepeatWrapping:st,ClampToEdgeWrapping:$e,MirroredRepeatWrapping:ft},My={NearestFilter:Ct,NearestMipmapNearestFilter:jt,NearestMipmapLinearFilter:pn,LinearFilter:Rn,LinearMipmapNearestFilter:bi,LinearMipmapLinearFilter:Qn},Sy=new WeakMap;class TE extends null{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap=="undefined"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch=="undefined"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const o=this,a=wc.get(`image-bitmap:${e}`);if(a!==void 0){if(o.manager.itemStart(e),a.then){a.then(d=>{if(Sy.has(a)===!0)s&&s(Sy.get(a)),o.manager.itemError(e),o.manager.itemEnd(e);else return t&&t(d),o.manager.itemEnd(e),d});return}return setTimeout(function(){t&&t(a),o.manager.itemEnd(e)},0),a}const c={};c.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",c.headers=this.requestHeader,c.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const u=fetch(e,c).then(function(d){return d.blob()}).then(function(d){return createImageBitmap(d,Object.assign(o.options,{colorSpaceConversion:"none"}))}).then(function(d){return wc.add(`image-bitmap:${e}`,d),t&&t(d),o.manager.itemEnd(e),d}).catch(function(d){s&&s(d),Sy.set(u,d),wc.remove(`image-bitmap:${e}`),o.manager.itemError(e),o.manager.itemEnd(e)});wc.add(`image-bitmap:${e}`,u),o.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let Ty;class Xx{static getContext(){return Ty===void 0&&(Ty=new(window.AudioContext||window.webkitAudioContext)),Ty}static setContext(e){Ty=e}}class iw extends null{constructor(e){super(e)}load(e,t,n,s){const o=this,a=new Ml(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(u){try{const d=u.slice(0);Xx.getContext().decodeAudioData(d,function(m){t(m)}).catch(c)}catch(d){c(d)}},n,s);function c(u){s?s(u):console.error(u),o.manager.itemError(e)}}}const Ey=new Ft,Ag=new Ft,Of=new Ft;class Ay{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ma,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ma,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,Of.copy(e.projectionMatrix);const s=t.eyeSep/2,o=s*t.near/t.focus,a=t.near*Math.tan(uc*t.fov*.5)/t.zoom;let c,u;Ag.elements[12]=-s,Ey.elements[12]=s,c=-a*t.aspect+o,u=a*t.aspect+o,Of.elements[0]=2*t.near/(u-c),Of.elements[8]=(u+c)/(u-c),this.cameraL.projectionMatrix.copy(Of),c=-a*t.aspect-o,u=a*t.aspect-o,Of.elements[0]=2*t.near/(u-c),Of.elements[8]=(u+c)/(u-c),this.cameraR.projectionMatrix.copy(Of)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Ag),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Ey)}}class Cy extends ma{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class qx{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),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=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}const Rh=new it,Cg=new ta,Cd=new it,Ff=new it,Bf=new it;class EE extends null{constructor(){super(),this.type="AudioListener",this.context=Xx.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new qx}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;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Rh,Cg,Cd),Ff.set(0,0,-1).applyQuaternion(Cg),Bf.set(0,1,0).applyQuaternion(Cg),t.positionX){const n=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Rh.x,n),t.positionY.linearRampToValueAtTime(Rh.y,n),t.positionZ.linearRampToValueAtTime(Rh.z,n),t.forwardX.linearRampToValueAtTime(Ff.x,n),t.forwardY.linearRampToValueAtTime(Ff.y,n),t.forwardZ.linearRampToValueAtTime(Ff.z,n),t.upX.linearRampToValueAtTime(Bf.x,n),t.upY.linearRampToValueAtTime(Bf.y,n),t.upZ.linearRampToValueAtTime(Bf.z,n)}else t.setPosition(Rh.x,Rh.y,Rh.z),t.setOrientation(Ff.x,Ff.y,Ff.z,Bf.x,Bf.y,Bf.z)}}class Uf extends null{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(e=0){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.context.currentTime+e),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._connected!==!1){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){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 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,this._progress=0}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}copy(e,t){return super.copy(e,t),e.sourceType!=="buffer"?(console.warn("THREE.Audio: Audio source type cannot be copied."),this):(this.autoplay=e.autoplay,this.buffer=e.buffer,this.detune=e.detune,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.offset=e.offset,this.duration=e.duration,this.playbackRate=e.playbackRate,this.hasPlaybackControl=e.hasPlaybackControl,this.sourceType=e.sourceType,this.filters=e.filters.slice(),this)}clone(e){return new this.constructor(this.listener).copy(this,e)}}const Ju=new it,Yx=new ta,Rd=new it,nc=new it;class D3 extends null{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}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(Ju,Yx,Rd),nc.set(0,0,1).applyQuaternion(Yx);const t=this.panner;if(t.positionX){const n=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Ju.x,n),t.positionY.linearRampToValueAtTime(Ju.y,n),t.positionZ.linearRampToValueAtTime(Ju.z,n),t.orientationX.linearRampToValueAtTime(nc.x,n),t.orientationY.linearRampToValueAtTime(nc.y,n),t.orientationZ.linearRampToValueAtTime(nc.z,n)}else t.setPosition(Ju.x,Ju.y,Ju.z),t.setOrientation(nc.x,nc.y,nc.z)}}class O3{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 Nd{constructor(e,t,n){this.binding=e,this.valueSize=n;let s,o,a;switch(t){case"quaternion":s=this._slerp,o=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":s=this._select,o=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:s=this._lerp,o=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=s,this._mixBufferRegionAdditive=o,this._setIdentity=a,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,s=this.valueSize,o=e*s+s;let a=this.cumulativeWeight;if(a===0){for(let c=0;c!==s;++c)n[o+c]=n[c];a=t}else{a+=t;const c=t/a;this._mixBufferRegion(n,o,0,c,s)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,s=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,s,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,s=e*t+t,o=this.cumulativeWeight,a=this.cumulativeWeightAdditive,c=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,o<1){const u=t*this._origIndex;this._mixBufferRegion(n,s,u,1-o,t)}a>0&&this._mixBufferRegionAdditive(n,s,this._addIndex*t,1,t);for(let u=t,d=t+t;u!==d;++u)if(n[u]!==n[u+t]){c.setValue(n,s);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,s=n*this._origIndex;e.getValue(t,s);for(let o=n,a=s;o!==a;++o)t[o]=t[s+o%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,s,o){if(s>=.5)for(let a=0;a!==o;++a)e[t+a]=e[n+a]}_slerp(e,t,n,s){ta.slerpFlat(e,t,e,t,e,n,s)}_slerpAdditive(e,t,n,s,o){const a=this._workIndex*o;ta.multiplyQuaternionsFlat(e,a,e,t,e,n),ta.slerpFlat(e,t,e,t,e,a,s)}_lerp(e,t,n,s,o){const a=1-s;for(let c=0;c!==o;++c){const u=t+c;e[u]=e[u]*a+e[n+c]*s}}_lerpAdditive(e,t,n,s,o){for(let a=0;a!==o;++a){const c=t+a;e[c]=e[c]+e[n+a]*s}}}const Rg="\\[\\]\\.:\\/",rw=new RegExp("["+Rg+"]","g"),Qu="[^"+Rg+"]",AE="[^"+Rg.replace("\\.","")+"]",CE=/((?:WC+[\/:])*)/.source.replace("WC",Qu),sw=/(WCOD+)?/.source.replace("WCOD",AE),Ry=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Qu),ow=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Qu),Ny=new RegExp("^"+CE+sw+Ry+ow+"$"),aw=["material","materials","bones","map"];class lw{constructor(e,t,n){const s=n||Js.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,o=n.length;s!==o;++s)n[s].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 Js{constructor(e,t,n){this.path=t,this.parsedPath=n||Js.parseTrackName(t),this.node=Js.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 Js.Composite(e,t,n):new Js(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(rw,"")}static parseTrackName(e){const t=Ny.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]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){const o=n.nodeName.substring(s+1);aw.indexOf(o)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=o)}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(o){for(let a=0;a<o.length;a++){const c=o[a];if(c.name===t||c.uuid===t)return c;const u=n(c.children);if(u)return u}return null},s=n(e.children);if(s)return s}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 s=0,o=n.length;s!==o;++s)e[t++]=n[s]}_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 s=0,o=n.length;s!==o;++s)n[s]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let s=0,o=n.length;s!==o;++s)n[s]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let s=0,o=n.length;s!==o;++s)n[s]=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,s=t.propertyName;let o=t.propertyIndex;if(e||(e=Js.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let d=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 p=0;p<e.length;p++)if(e[p].name===d){d=p;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(d!==void 0){if(e[d]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[d]}}const a=e[s];if(a===void 0){const d=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+d+"."+s+" but it wasn't found.",e);return}let c=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?c=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(c=this.Versioning.MatrixWorldNeedsUpdate);let u=this.BindingType.Direct;if(o!==void 0){if(s==="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[o]!==void 0&&(o=e.morphTargetDictionary[o])}u=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=o}else a.fromArray!==void 0&&a.toArray!==void 0?(u=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(u=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=s;this.getValue=this.GetterByBindingType[u],this.setValue=this.SetterByBindingTypeAndVersioning[u][c]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Js.Composite=lw,Js.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Js.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Js.prototype.GetterByBindingType=[Js.prototype._getValue_direct,Js.prototype._getValue_array,Js.prototype._getValue_arrayElement,Js.prototype._getValue_toArray],Js.prototype.SetterByBindingTypeAndVersioning=[[Js.prototype._setValue_direct,Js.prototype._setValue_direct_setNeedsUpdate,Js.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Js.prototype._setValue_array,Js.prototype._setValue_array_setNeedsUpdate,Js.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Js.prototype._setValue_arrayElement,Js.prototype._setValue_arrayElement_setNeedsUpdate,Js.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Js.prototype._setValue_fromArray,Js.prototype._setValue_fromArray_setNeedsUpdate,Js.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class RE{constructor(){this.isAnimationObjectGroup=!0,this.uuid=xl(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let n=0,s=arguments.length;n!==s;++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,s=this._parsedPaths,o=this._bindings,a=o.length;let c,u=e.length,d=this.nCachedObjects_;for(let p=0,m=arguments.length;p!==m;++p){const y=arguments[p],M=y.uuid;let T=t[M];if(T===void 0){T=u++,t[M]=T,e.push(y);for(let G=0,z=a;G!==z;++G)o[G].push(new Js(y,n[G],s[G]))}else if(T<d){c=e[T];const G=--d,z=e[G];t[z.uuid]=T,e[T]=z,t[M]=G,e[G]=y;for(let I=0,J=a;I!==J;++I){const K=o[I],re=K[G];let ve=K[T];K[T]=re,ve===void 0&&(ve=new Js(y,n[I],s[I])),K[G]=ve}}else e[T]!==c&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=d}remove(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,s=n.length;let o=this.nCachedObjects_;for(let a=0,c=arguments.length;a!==c;++a){const u=arguments[a],d=u.uuid,p=t[d];if(p!==void 0&&p>=o){const m=o++,y=e[m];t[y.uuid]=p,e[p]=y,t[d]=m,e[m]=u;for(let M=0,T=s;M!==T;++M){const G=n[M],z=G[m],I=G[p];G[p]=z,G[m]=I}}}this.nCachedObjects_=o}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,s=n.length;let o=this.nCachedObjects_,a=e.length;for(let c=0,u=arguments.length;c!==u;++c){const d=arguments[c],p=d.uuid,m=t[p];if(m!==void 0)if(delete t[p],m<o){const y=--o,M=e[y],T=--a,G=e[T];t[M.uuid]=m,e[m]=M,t[G.uuid]=y,e[y]=G,e.pop();for(let z=0,I=s;z!==I;++z){const J=n[z],K=J[y],re=J[T];J[m]=K,J[y]=re,J.pop()}}else{const y=--a,M=e[y];y>0&&(t[M.uuid]=m),e[m]=M,e.pop();for(let T=0,G=s;T!==G;++T){const z=n[T];z[m]=z[y],z.pop()}}}this.nCachedObjects_=o}subscribe_(e,t){const n=this._bindingsIndicesByPath;let s=n[e];const o=this._bindings;if(s!==void 0)return o[s];const a=this._paths,c=this._parsedPaths,u=this._objects,d=u.length,p=this.nCachedObjects_,m=new Array(d);s=o.length,n[e]=s,a.push(e),c.push(t),o.push(m);for(let y=p,M=u.length;y!==M;++y){const T=u[y];m[y]=new Js(T,e,t)}return m}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const s=this._paths,o=this._parsedPaths,a=this._bindings,c=a.length-1,u=a[c],d=e[c];t[d]=n,a[n]=u,a.pop(),o[n]=o[c],o.pop(),s[n]=s[c],s.pop()}}}class cw{constructor(e,t,n=null,s=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=s;const o=t.tracks,a=o.length,c=new Array(a),u={endingStart:ha,endingEnd:ha};for(let d=0;d!==a;++d){const p=o[d].createInterpolant(null);c[d]=p,p.settings=u}this._interpolantSettings=u,this._interpolants=c,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Yr,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=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){const s=this._clip.duration,o=e._clip.duration,a=o/s,c=s/o;e.warp(1,a,t),this.warp(c,1,t)}return this}crossFadeTo(e,t,n=!1){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 s=this._mixer,o=s.time,a=this.timeScale;let c=this._timeScaleInterpolant;c===null&&(c=s._lendControlInterpolant(),this._timeScaleInterpolant=c);const u=c.parameterPositions,d=c.sampleValues;return u[0]=o,u[1]=o+n,d[0]=e/a,d[1]=t/a,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,s){if(!this.enabled){this._updateWeight(e);return}const o=this._startTime;if(o!==null){const u=(e-o)*n;u<0||n===0?t=0:(this._startTime=null,t=n*u)}t*=this._updateTimeScale(e);const a=this._updateTime(t),c=this._updateWeight(e);if(c>0){const u=this._interpolants,d=this._propertyBindings;switch(this.blendMode){case Lc:for(let p=0,m=u.length;p!==m;++p)u[p].evaluate(a),d[p].accumulateAdditive(c);break;case wo:default:for(let p=0,m=u.length;p!==m;++p)u[p].evaluate(a),d[p].accumulate(s,c)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const s=n.evaluate(e)[0];t*=s,e>n.parameterPositions[1]&&(this.stopFading(),s===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 s=n.evaluate(e)[0];t*=s,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 s=this.time+e,o=this._loopCount;const a=n===ua;if(e===0)return o===-1?s:a&&(o&1)===1?t-s:s;if(n===so){o===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(s>=t)s=t;else if(s<0)s=0;else{this.time=s;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(o===-1&&(e>=0?(o=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),s>=t||s<0){const c=Math.floor(s/t);s-=t*c,o+=Math.abs(c);const u=this.repetitions-o;if(u<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,s=e>0?t:0,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(u===1){const d=e<0;this._setEndings(d,!d,a)}else this._setEndings(!1,!1,a);this._loopCount=o,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:c})}}else this.time=s;if(a&&(o&1)===1)return t-s}return s}_setEndings(e,t,n){const s=this._interpolantSettings;n?(s.endingStart=Ba,s.endingEnd=Ba):(e?s.endingStart=this.zeroSlopeAtStart?Ba:ha:s.endingStart=al,t?s.endingEnd=this.zeroSlopeAtEnd?Ba:ha:s.endingEnd=al)}_scheduleFading(e,t,n){const s=this._mixer,o=s.time;let a=this._weightInterpolant;a===null&&(a=s._lendControlInterpolant(),this._weightInterpolant=a);const c=a.parameterPositions,u=a.sampleValues;return c[0]=o,u[0]=t,c[1]=o+e,u[1]=n,this}}const uw=new Float32Array(1);class NE extends null{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,s=e._clip.tracks,o=s.length,a=e._propertyBindings,c=e._interpolants,u=n.uuid,d=this._bindingsByRootAndName;let p=d[u];p===void 0&&(p={},d[u]=p);for(let m=0;m!==o;++m){const y=s[m],M=y.name;let T=p[M];if(T!==void 0)++T.referenceCount,a[m]=T;else{if(T=a[m],T!==void 0){T._cacheIndex===null&&(++T.referenceCount,this._addInactiveBinding(T,u,M));continue}const G=t&&t._propertyBindings[m].binding.parsedPath;T=new Nd(Js.create(n,M,G),y.ValueTypeName,y.getValueSize()),++T.referenceCount,this._addInactiveBinding(T,u,M),a[m]=T}c[m].resultBuffer=T.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,s=e._clip.uuid,o=this._actionsByClip[s];this._bindAction(e,o&&o.knownActions[0]),this._addInactiveAction(e,s,n)}const t=e._propertyBindings;for(let n=0,s=t.length;n!==s;++n){const o=t[n];o.useCount++===0&&(this._lendBinding(o),o.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,s=t.length;n!==s;++n){const o=t[n];--o.useCount===0&&(o.restoreOriginalState(),this._takeBackBinding(o))}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 s=this._actions,o=this._actionsByClip;let a=o[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,o[t]=a;else{const c=a.knownActions;e._byClipCacheIndex=c.length,c.push(e)}e._cacheIndex=s.length,s.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],s=e._cacheIndex;n._cacheIndex=s,t[s]=n,t.pop(),e._cacheIndex=null;const o=e._clip.uuid,a=this._actionsByClip,c=a[o],u=c.knownActions,d=u[u.length-1],p=e._byClipCacheIndex;d._byClipCacheIndex=p,u[p]=d,u.pop(),e._byClipCacheIndex=null;const m=c.actionByRoot,y=(e._localRoot||this._root).uuid;delete m[y],u.length===0&&delete a[o],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,s=t.length;n!==s;++n){const o=t[n];--o.referenceCount===0&&this._removeInactiveBinding(o)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,s=this._nActiveActions++,o=t[s];e._cacheIndex=s,t[s]=e,o._cacheIndex=n,t[n]=o}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,s=--this._nActiveActions,o=t[s];e._cacheIndex=s,t[s]=e,o._cacheIndex=n,t[n]=o}_addInactiveBinding(e,t,n){const s=this._bindingsByRootAndName,o=this._bindings;let a=s[t];a===void 0&&(a={},s[t]=a),a[n]=e,e._cacheIndex=o.length,o.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,s=n.rootNode.uuid,o=n.path,a=this._bindingsByRootAndName,c=a[s],u=t[t.length-1],d=e._cacheIndex;u._cacheIndex=d,t[d]=u,t.pop(),delete c[o],Object.keys(c).length===0&&delete a[s]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,s=this._nActiveBindings++,o=t[s];e._cacheIndex=s,t[s]=e,o._cacheIndex=n,t[n]=o}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,s=--this._nActiveBindings,o=t[s];e._cacheIndex=s,t[s]=e,o._cacheIndex=n,t[n]=o}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return n===void 0&&(n=new vg(new Float32Array(2),new Float32Array(2),1,uw),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,s=--this._nActiveControlInterpolants,o=t[s];e.__cacheIndex=s,t[s]=e,o.__cacheIndex=n,t[n]=o}clipAction(e,t,n){const s=t||this._root,o=s.uuid;let a=typeof e=="string"?Xp.findByName(s,e):e;const c=a!==null?a.uuid:e,u=this._actionsByClip[c];let d=null;if(n===void 0&&(a!==null?n=a.blendMode:n=wo),u!==void 0){const m=u.actionByRoot[o];if(m!==void 0&&m.blendMode===n)return m;d=u.knownActions[0],a===null&&(a=d._clip)}if(a===null)return null;const p=new cw(this,a,t,n);return this._bindAction(p,d),this._addInactiveAction(p,c,o),p}existingAction(e,t){const n=t||this._root,s=n.uuid,o=typeof e=="string"?Xp.findByName(n,e):e,a=o?o.uuid:e,c=this._actionsByClip[a];return c!==void 0&&c.actionByRoot[s]||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,s=this.time+=e,o=Math.sign(e),a=this._accuIndex^=1;for(let d=0;d!==n;++d)t[d]._update(s,e,o,a);const c=this._bindings,u=this._nActiveBindings;for(let d=0;d!==u;++d)c[d].apply(a);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,s=this._actionsByClip,o=s[n];if(o!==void 0){const a=o.knownActions;for(let c=0,u=a.length;c!==u;++c){const d=a[c];this._deactivateAction(d);const p=d._cacheIndex,m=t[t.length-1];d._cacheIndex=null,d._byClipCacheIndex=null,m._cacheIndex=p,t[p]=m,t.pop(),this._removeInactiveBindingsForAction(d)}delete s[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const a in n){const c=n[a].actionByRoot,u=c[t];u!==void 0&&(this._deactivateAction(u),this._removeInactiveAction(u))}const s=this._bindingsByRootAndName,o=s[t];if(o!==void 0)for(const a in o){const c=o[a];c.restoreOriginalState(),this._removeInactiveBinding(c)}}uncacheAction(e,t){const n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class PE extends null{constructor(e=1,t=1,n=1,s={}){super(e,t,s),this.isRenderTarget3D=!0,this.depth=n,this.texture=new bl(null,e,t,n),this._setTextureOptions(s),this.texture.isRenderTargetTexture=!0}}class qs{constructor(e){this.value=e}clone(){return new qs(this.value.clone===void 0?this.value:this.value.clone())}}let IE=0;class LE extends null{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:IE++}),this.name="",this.usage=Uu,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(){this.dispatchEvent({type:"dispose"})}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let n=0,s=t.length;n<s;n++){const o=Array.isArray(t[n])?t[n]:[t[n]];for(let a=0;a<o.length;a++)this.uniforms.push(o[a].clone())}return this}clone(){return new this.constructor().copy(this)}}class hw extends ju{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 F3{constructor(e,t,n,s,o,a=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=s,this.count=o,this.normalized=a,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}}const dw=new Ft;class Py{constructor(e,t,n=0,s=1/0){this.ray=new hn(e,t),this.near=n,this.far=s,this.camera=null,this.layers=new er,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)}setFromXRController(e){return dw.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(dw),this}intersectObject(e,t=!0,n=[]){return Kx(e,this,n,t),n.sort(Zx),n}intersectObjects(e,t=!0,n=[]){for(let s=0,o=e.length;s<o;s++)Kx(e[s],this,n,t);return n.sort(Zx),n}}function Zx(i,e){return i.distance-e.distance}function Kx(i,e,t,n){let s=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(s=!1),s===!0&&n===!0){const o=i.children;for(let a=0,c=o.length;a<c;a++)Kx(o[a],e,t,!0)}}class B3{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=DE.bind(this),e.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e!==void 0?e:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function DE(){this._document.hidden===!1&&this.reset()}class Iy{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}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=Sr(this.phi,1e-6,Math.PI-1e-6),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(Sr(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class U3{constructor(e=1,t=0,n=0){this.radius=e,this.theta=t,this.y=n}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)}}class Yp{constructor(e,t,n,s){Yp.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,s){const o=this.elements;return o[0]=e,o[2]=t,o[1]=n,o[3]=s,this}}const Ng=new yn;class k3{constructor(e=new yn(1/0,1/0),t=new yn(-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=Ng.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,Ng).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 Jx=new it,Ly=new it,Zp=new it,Pd=new it,Pg=new it,OE=new it,Qx=new it;class Dy{constructor(e=new it,t=new it){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){Jx.subVectors(e,this.start),Ly.subVectors(this.end,this.start);const n=Ly.dot(Ly);let o=Ly.dot(Jx)/n;return t&&(o=Sr(o,0,1)),o}closestPointToPoint(e,t,n){const s=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(s).add(this.start)}distanceSqToLine3(e,t=OE,n=Qx){const s=10000000000000001e-32;let o,a;const c=this.start,u=e.start,d=this.end,p=e.end;Zp.subVectors(d,c),Pd.subVectors(p,u),Pg.subVectors(c,u);const m=Zp.dot(Zp),y=Pd.dot(Pd),M=Pd.dot(Pg);if(m<=s&&y<=s)return t.copy(c),n.copy(u),t.sub(n),t.dot(t);if(m<=s)o=0,a=M/y,a=Sr(a,0,1);else{const T=Zp.dot(Pg);if(y<=s)a=0,o=Sr(-T/m,0,1);else{const G=Zp.dot(Pd),z=m*y-G*G;z!==0?o=Sr((G*M-T*y)/z,0,1):o=0,a=(G*o+M)/y,a<0?(a=0,o=Sr(-T/m,0,1)):a>1&&(a=1,o=Sr((G-T)/m,0,1))}}return t.copy(c).add(Zp.multiplyScalar(o)),n.copy(u).add(Pd.multiplyScalar(a)),t.sub(n),t.dot(t)}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 Id=new it;class Kp extends null{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new xr,s=[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 a=0,c=1,u=32;a<u;a++,c++){const d=a/u*Math.PI*2,p=c/u*Math.PI*2;s.push(Math.cos(d),Math.sin(d),1,Math.cos(p),Math.sin(p),1)}n.setAttribute("position",new Zi(s,3));const o=new nl({fog:!1,toneMapped:!1});this.cone=new lg(n,o),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),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Id.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Id),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const bu=new it,Ig=new Ft,Oy=new Ft;class z3 extends null{constructor(e){const t=Fy(e),n=new xr,s=[],o=[];for(let d=0;d<t.length;d++){const p=t[d];p.parent&&p.parent.isBone&&(s.push(0,0,0),s.push(0,0,0),o.push(0,0,0),o.push(0,0,0))}n.setAttribute("position",new Zi(s,3)),n.setAttribute("color",new Zi(o,3));const a=new nl({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,a),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1;const c=new jn(255),u=new jn(65280);this.setColors(c,u)}updateMatrixWorld(e){const t=this.bones,n=this.geometry,s=n.getAttribute("position");Oy.copy(this.root.matrixWorld).invert();for(let o=0,a=0;o<t.length;o++){const c=t[o];c.parent&&c.parent.isBone&&(Ig.multiplyMatrices(Oy,c.matrixWorld),bu.setFromMatrixPosition(Ig),s.setXYZ(a,bu.x,bu.y,bu.z),Ig.multiplyMatrices(Oy,c.parent.matrixWorld),bu.setFromMatrixPosition(Ig),s.setXYZ(a+1,bu.x,bu.y,bu.z),a+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}setColors(e,t){const s=this.geometry.getAttribute("color");for(let o=0;o<s.count;o+=2)s.setXYZ(o,e.r,e.g,e.b),s.setXYZ(o+1,t.r,t.g,t.b);return s.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}function Fy(i){const e=[];i.isBone===!0&&e.push(i);for(let t=0;t<i.children.length;t++)e.push(...Fy(i.children[t]));return e}class V3 extends null{constructor(e,t,n){const s=new Yu(t,4,2),o=new Hr({wireframe:!0,fog:!1,toneMapped:!1});super(s,o),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 Nh=new it,Jp=new jn,Lg=new jn;class G3 extends null{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const s=new zp(t);s.rotateY(Math.PI*.5),this.material=new Hr({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const o=s.getAttribute("position"),a=new Float32Array(o.count*3);s.setAttribute("color",new es(a,3)),this.add(new Ks(s,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");Jp.copy(this.light.color),Lg.copy(this.light.groundColor);for(let n=0,s=t.count;n<s;n++){const o=n<s/2?Jp:Lg;t.setXYZ(n,o.r,o.g,o.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(Nh.setFromMatrixPosition(this.light.matrixWorld).negate())}}class fw extends null{constructor(e=10,t=10,n=4473924,s=8947848){n=new jn(n),s=new jn(s);const o=t/2,a=e/t,c=e/2,u=[],d=[];for(let y=0,M=0,T=-c;y<=t;y++,T+=a){u.push(-c,0,T,c,0,T),u.push(T,0,-c,T,0,c);const G=y===o?n:s;G.toArray(d,M),M+=3,G.toArray(d,M),M+=3,G.toArray(d,M),M+=3,G.toArray(d,M),M+=3}const p=new xr;p.setAttribute("position",new Zi(u,3)),p.setAttribute("color",new Zi(d,3));const m=new nl({vertexColors:!0,toneMapped:!1});super(p,m),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class W3 extends null{constructor(e=10,t=16,n=8,s=64,o=4473924,a=8947848){o=new jn(o),a=new jn(a);const c=[],u=[];if(t>1)for(let m=0;m<t;m++){const y=m/t*(Math.PI*2),M=Math.sin(y)*e,T=Math.cos(y)*e;c.push(0,0,0),c.push(M,0,T);const G=m&1?o:a;u.push(G.r,G.g,G.b),u.push(G.r,G.g,G.b)}for(let m=0;m<n;m++){const y=m&1?o:a,M=e-e/n*m;for(let T=0;T<s;T++){let G=T/s*(Math.PI*2),z=Math.sin(G)*M,I=Math.cos(G)*M;c.push(z,0,I),u.push(y.r,y.g,y.b),G=(T+1)/s*(Math.PI*2),z=Math.sin(G)*M,I=Math.cos(G)*M,c.push(z,0,I),u.push(y.r,y.g,y.b)}}const d=new xr;d.setAttribute("position",new Zi(c,3)),d.setAttribute("color",new Zi(u,3));const p=new nl({vertexColors:!0,toneMapped:!1});super(d,p),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const e_=new it,Qp=new it,By=new it;class H3 extends null{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 s=new xr;s.setAttribute("position",new Zi([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const o=new nl({fog:!1,toneMapped:!1});this.lightPlane=new Sh(s,o),this.add(this.lightPlane),s=new xr,s.setAttribute("position",new Zi([0,0,0,0,0,1],3)),this.targetLine=new Sh(s,o),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),e_.setFromMatrixPosition(this.light.matrixWorld),Qp.setFromMatrixPosition(this.light.target.matrixWorld),By.subVectors(Qp,e_),this.lightPlane.lookAt(Qp),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(Qp),this.targetLine.scale.z=By.length()}}const Uy=new it,ga=new Zm;class pw extends null{constructor(e){const t=new xr,n=new nl({color:16777215,vertexColors:!0,toneMapped:!1}),s=[],o=[],a={};c("n1","n2"),c("n2","n4"),c("n4","n3"),c("n3","n1"),c("f1","f2"),c("f2","f4"),c("f4","f3"),c("f3","f1"),c("n1","f1"),c("n2","f2"),c("n3","f3"),c("n4","f4"),c("p","n1"),c("p","n2"),c("p","n3"),c("p","n4"),c("u1","u2"),c("u2","u3"),c("u3","u1"),c("c","t"),c("p","c"),c("cn1","cn2"),c("cn3","cn4"),c("cf1","cf2"),c("cf3","cf4");function c(T,G){u(T),u(G)}function u(T){s.push(0,0,0),o.push(0,0,0),a[T]===void 0&&(a[T]=[]),a[T].push(s.length/3-1)}t.setAttribute("position",new Zi(s,3)),t.setAttribute("color",new Zi(o,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=a,this.update();const d=new jn(16755200),p=new jn(16711680),m=new jn(43775),y=new jn(16777215),M=new jn(3355443);this.setColors(d,p,m,y,M)}setColors(e,t,n,s,o){const c=this.geometry.getAttribute("color");return c.setXYZ(0,e.r,e.g,e.b),c.setXYZ(1,e.r,e.g,e.b),c.setXYZ(2,e.r,e.g,e.b),c.setXYZ(3,e.r,e.g,e.b),c.setXYZ(4,e.r,e.g,e.b),c.setXYZ(5,e.r,e.g,e.b),c.setXYZ(6,e.r,e.g,e.b),c.setXYZ(7,e.r,e.g,e.b),c.setXYZ(8,e.r,e.g,e.b),c.setXYZ(9,e.r,e.g,e.b),c.setXYZ(10,e.r,e.g,e.b),c.setXYZ(11,e.r,e.g,e.b),c.setXYZ(12,e.r,e.g,e.b),c.setXYZ(13,e.r,e.g,e.b),c.setXYZ(14,e.r,e.g,e.b),c.setXYZ(15,e.r,e.g,e.b),c.setXYZ(16,e.r,e.g,e.b),c.setXYZ(17,e.r,e.g,e.b),c.setXYZ(18,e.r,e.g,e.b),c.setXYZ(19,e.r,e.g,e.b),c.setXYZ(20,e.r,e.g,e.b),c.setXYZ(21,e.r,e.g,e.b),c.setXYZ(22,e.r,e.g,e.b),c.setXYZ(23,e.r,e.g,e.b),c.setXYZ(24,t.r,t.g,t.b),c.setXYZ(25,t.r,t.g,t.b),c.setXYZ(26,t.r,t.g,t.b),c.setXYZ(27,t.r,t.g,t.b),c.setXYZ(28,t.r,t.g,t.b),c.setXYZ(29,t.r,t.g,t.b),c.setXYZ(30,t.r,t.g,t.b),c.setXYZ(31,t.r,t.g,t.b),c.setXYZ(32,n.r,n.g,n.b),c.setXYZ(33,n.r,n.g,n.b),c.setXYZ(34,n.r,n.g,n.b),c.setXYZ(35,n.r,n.g,n.b),c.setXYZ(36,n.r,n.g,n.b),c.setXYZ(37,n.r,n.g,n.b),c.setXYZ(38,s.r,s.g,s.b),c.setXYZ(39,s.r,s.g,s.b),c.setXYZ(40,o.r,o.g,o.b),c.setXYZ(41,o.r,o.g,o.b),c.setXYZ(42,o.r,o.g,o.b),c.setXYZ(43,o.r,o.g,o.b),c.setXYZ(44,o.r,o.g,o.b),c.setXYZ(45,o.r,o.g,o.b),c.setXYZ(46,o.r,o.g,o.b),c.setXYZ(47,o.r,o.g,o.b),c.setXYZ(48,o.r,o.g,o.b),c.setXYZ(49,o.r,o.g,o.b),c.needsUpdate=!0,this}update(){const e=this.geometry,t=this.pointMap,n=1,s=1;let o,a;if(ga.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)o=1,a=0;else if(this.camera.coordinateSystem===oo)o=-1,a=1;else if(this.camera.coordinateSystem===qa)o=0,a=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);ko("c",t,e,ga,0,0,o),ko("t",t,e,ga,0,0,a),ko("n1",t,e,ga,-n,-s,o),ko("n2",t,e,ga,n,-s,o),ko("n3",t,e,ga,-n,s,o),ko("n4",t,e,ga,n,s,o),ko("f1",t,e,ga,-n,-s,a),ko("f2",t,e,ga,n,-s,a),ko("f3",t,e,ga,-n,s,a),ko("f4",t,e,ga,n,s,a),ko("u1",t,e,ga,n*.7,s*1.1,o),ko("u2",t,e,ga,-n*.7,s*1.1,o),ko("u3",t,e,ga,0,s*2,o),ko("cf1",t,e,ga,-n,0,a),ko("cf2",t,e,ga,n,0,a),ko("cf3",t,e,ga,0,-s,a),ko("cf4",t,e,ga,0,s,a),ko("cn1",t,e,ga,-n,0,o),ko("cn2",t,e,ga,n,0,o),ko("cn3",t,e,ga,0,-s,o),ko("cn4",t,e,ga,0,s,o),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function ko(i,e,t,n,s,o,a){Uy.set(s,o,a).unproject(n);const c=e[i];if(c!==void 0){const u=t.getAttribute("position");for(let d=0,p=c.length;d<p;d++)u.setXYZ(c[d],Uy.x,Uy.y,Uy.z)}}const em=new fa;class $3 extends null{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]),s=new Float32Array(8*3),o=new xr;o.setIndex(new es(n,1)),o.setAttribute("position",new es(s,3)),super(o,new nl({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&em.setFromObject(this.object),em.isEmpty())return;const e=em.min,t=em.max,n=this.geometry.attributes.position,s=n.array;s[0]=t.x,s[1]=t.y,s[2]=t.z,s[3]=e.x,s[4]=t.y,s[5]=t.z,s[6]=e.x,s[7]=e.y,s[8]=t.z,s[9]=t.x,s[10]=e.y,s[11]=t.z,s[12]=t.x,s[13]=t.y,s[14]=e.z,s[15]=e.x,s[16]=t.y,s[17]=e.z,s[18]=e.x,s[19]=e.y,s[20]=e.z,s[21]=t.x,s[22]=e.y,s[23]=e.z,n.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 ky extends null{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]),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],o=new xr;o.setIndex(new es(n,1)),o.setAttribute("position",new Zi(s,3)),super(o,new nl({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 ya extends null{constructor(e,t=1,n=16776960){const s=n,o=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new xr;a.setAttribute("position",new Zi(o,3)),a.computeBoundingSphere(),super(a,new nl({color:s,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const c=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],u=new xr;u.setAttribute("position",new Zi(c,3)),u.computeBoundingSphere(),this.add(new Ks(u,new Hr({color:s,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 mw=new it;let zo,kf;class j3 extends null{constructor(e=new it(0,0,1),t=new it(0,0,0),n=1,s=16776960,o=n*.2,a=o*.2){super(),this.type="ArrowHelper",zo===void 0&&(zo=new xr,zo.setAttribute("position",new Zi([0,0,0,0,1,0],3)),kf=new Rp(.5,1,5,1),kf.translate(0,-.5,0)),this.position.copy(t),this.line=new Sh(zo,new nl({color:s,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ks(kf,new Hr({color:s,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,o,a)}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{mw.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(mw,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 X3 extends null{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],s=new xr;s.setAttribute("position",new Zi(t,3)),s.setAttribute("color",new Zi(n,3));const o=new nl({vertexColors:!0,toneMapped:!1});super(s,o),this.type="AxesHelper"}setColors(e,t,n){const s=new jn,o=this.geometry.attributes.color.array;return s.set(e),s.toArray(o,0),s.toArray(o,3),s.set(t),s.toArray(o,6),s.toArray(o,9),s.set(n),s.toArray(o,12),s.toArray(o,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class q3{constructor(){this.type="ShapePath",this.color=new jn,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new ny,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,s){return this.currentPath.quadraticCurveTo(e,t,n,s),this}bezierCurveTo(e,t,n,s,o,a){return this.currentPath.bezierCurveTo(e,t,n,s,o,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(I){const J=[];for(let K=0,re=I.length;K<re;K++){const ve=I[K],me=new _d;me.curves=ve.curves,J.push(me)}return J}function n(I,J){const K=J.length;let re=!1;for(let ve=K-1,me=0;me<K;ve=me++){let Le=J[ve],Ve=J[me],Ee=Ve.x-Le.x,Oe=Ve.y-Le.y;if(Math.abs(Oe)>Number.EPSILON){if(Oe<0&&(Le=J[me],Ee=-Ee,Ve=J[ve],Oe=-Oe),I.y<Le.y||I.y>Ve.y)continue;if(I.y===Le.y){if(I.x===Le.x)return!0}else{const dt=Oe*(I.x-Le.x)-Ee*(I.y-Le.y);if(dt===0)return!0;if(dt<0)continue;re=!re}}else{if(I.y!==Le.y)continue;if(Ve.x<=I.x&&I.x<=Le.x||Le.x<=I.x&&I.x<=Ve.x)return!0}}return re}const s=Hc.isClockWise,o=this.subPaths;if(o.length===0)return[];let a,c,u;const d=[];if(o.length===1)return c=o[0],u=new _d,u.curves=c.curves,d.push(u),d;let p=!s(o[0].getPoints());p=e?!p:p;const m=[],y=[];let M=[],T=0,G;y[T]=void 0,M[T]=[];for(let I=0,J=o.length;I<J;I++)c=o[I],G=c.getPoints(),a=s(G),a=e?!a:a,a?(!p&&y[T]&&T++,y[T]={s:new _d,p:G},y[T].s.curves=c.curves,p&&T++,M[T]=[]):M[T].push({h:c,p:G[0]});if(!y[0])return t(o);if(y.length>1){let I=!1,J=0;for(let K=0,re=y.length;K<re;K++)m[K]=[];for(let K=0,re=y.length;K<re;K++){const ve=M[K];for(let me=0;me<ve.length;me++){const Le=ve[me];let Ve=!0;for(let Ee=0;Ee<y.length;Ee++)n(Le.p,y[Ee].p)&&(K!==Ee&&J++,Ve?(Ve=!1,m[Ee].push(Le)):I=!0);Ve&&m[K].push(Le)}}J>0&&I===!1&&(M=m)}let z;for(let I=0,J=y.length;I<J;I++){u=y[I].s,d.push(u),z=M[I];for(let K=0,re=z.length;K<re;K++)u.holes.push(z[K].h)}return d}}class tm extends Bl{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){console.warn("THREE.Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function Dg(i,e){const t=i.image&&i.image.width?i.image.width/i.image.height:1;return t>e?(i.repeat.x=1,i.repeat.y=t/e,i.offset.x=0,i.offset.y=(1-i.repeat.y)/2):(i.repeat.x=e/t,i.repeat.y=1,i.offset.x=(1-i.repeat.x)/2,i.offset.y=0),i}function zy(i,e){const t=i.image&&i.image.width?i.image.width/i.image.height:1;return t>e?(i.repeat.x=e/t,i.repeat.y=1,i.offset.x=(1-i.repeat.x)/2,i.offset.y=0):(i.repeat.x=1,i.repeat.y=t/e,i.offset.x=0,i.offset.y=(1-i.repeat.y)/2),i}function FE(i){return i.repeat.x=1,i.repeat.y=1,i.offset.x=0,i.offset.y=0,i}function Vy(i,e,t,n){const s=BE(n);switch(t){case Bu:return i*e;case F:return i*e/s.components*s.byteLength;case X:return i*e/s.components*s.byteLength;case Ie:return i*e*2/s.components*s.byteLength;case ke:return i*e*2/s.components*s.byteLength;case Pe:return i*e*3/s.components*s.byteLength;case D:return i*e*4/s.components*s.byteLength;case nt:return i*e*4/s.components*s.byteLength;case Wt:case Tt:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case on:case Un:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case bn:case Bt:return Math.max(i,16)*Math.max(e,8)/4;case sn:case ti:return Math.max(i,8)*Math.max(e,8)/2;case $n:case ni:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Pi:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case ui:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Lr:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case yi:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case vi:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Mr:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Zt:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Fn:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case hi:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case Xn:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case ds:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case qr:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case vs:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case kr:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Fs:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case io:case ro:case To:return Math.ceil(i/4)*Math.ceil(e/4)*16;case Eo:case Wr:return Math.ceil(i/4)*Math.ceil(e/4)*8;case eo:case Ao:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function BE(i){switch(i){case Oi:case Gi:return{byteLength:1,components:1};case gs:case ir:case Gs:return{byteLength:2,components:1};case Yl:case Zl:return{byteLength:2,components:4};case ls:case Ls:case ys:return{byteLength:4,components:1};case Fl:case su:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}class Y3{static contain(e,t){return Dg(e,t)}static cover(e,t){return zy(e,t)}static fill(e){return FE(e)}static getByteLength(e,t,n,s){return Vy(e,t,n,s)}}typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:w}})),typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=w);const zf=new Rl,eh=new yn,t_=new it,Gy=new yn,Og=new yn,Wy=new it,j=new it,r=new Ft,l=new it,h=new it;let f=null,g=null;const v=[],A={NONE:-1,PAN:0,ROTATE:1};class V extends tm{constructor(e,t,n=null){super(t,n),this.objects=e,this.recursive=!0,this.transformGroup=!1,this.rotateSpeed=1,this.raycaster=new Py,this.mouseButtons={LEFT:k.PAN,MIDDLE:k.PAN,RIGHT:k.ROTATE},this.touches={ONE:O.PAN},this._onPointerMove=H.bind(this),this._onPointerDown=Z.bind(this),this._onPointerCancel=ce.bind(this),this._onContextMenu=he.bind(this),n!==null&&this.connect(n)}connect(e){super.connect(e),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointerup",this._onPointerCancel),this.domElement.addEventListener("pointerleave",this._onPointerCancel),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointerup",this._onPointerCancel),this.domElement.removeEventListener("pointerleave",this._onPointerCancel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="auto",this.domElement.style.cursor=""}dispose(){this.disconnect()}_updatePointer(e){const t=this.domElement.getBoundingClientRect();eh.x=(e.clientX-t.left)/t.width*2-1,eh.y=-(e.clientY-t.top)/t.height*2+1}_updateState(e){let t;if(e.pointerType==="touch")t=this.touches.ONE;else switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=null}switch(t){case k.PAN:case O.PAN:this.state=A.PAN;break;case k.ROTATE:case O.ROTATE:this.state=A.ROTATE;break;default:this.state=A.NONE}}}function H(i){const e=this.object,t=this.domElement,n=this.raycaster;if(this.enabled!==!1){if(this._updatePointer(i),n.setFromCamera(eh,e),f)this.state===A.PAN?n.ray.intersectPlane(zf,Wy)&&(f.position.copy(Wy.sub(t_).applyMatrix4(r)),this.dispatchEvent({type:"drag",object:f})):this.state===A.ROTATE&&(Gy.subVectors(eh,Og).multiplyScalar(this.rotateSpeed),f.rotateOnWorldAxis(l,Gy.x),f.rotateOnWorldAxis(h.normalize(),-Gy.y),this.dispatchEvent({type:"drag",object:f})),Og.copy(eh);else if(i.pointerType==="mouse"||i.pointerType==="pen")if(v.length=0,n.setFromCamera(eh,e),n.intersectObjects(this.objects,this.recursive,v),v.length>0){const s=v[0].object;zf.setFromNormalAndCoplanarPoint(e.getWorldDirection(zf.normal),j.setFromMatrixPosition(s.matrixWorld)),g!==s&&g!==null&&(this.dispatchEvent({type:"hoveroff",object:g}),t.style.cursor="auto",g=null),g!==s&&(this.dispatchEvent({type:"hoveron",object:s}),t.style.cursor="pointer",g=s)}else g!==null&&(this.dispatchEvent({type:"hoveroff",object:g}),t.style.cursor="auto",g=null);Og.copy(eh)}}function Z(i){const e=this.object,t=this.domElement,n=this.raycaster;this.enabled!==!1&&(this._updatePointer(i),this._updateState(i),v.length=0,n.setFromCamera(eh,e),n.intersectObjects(this.objects,this.recursive,v),v.length>0&&(this.transformGroup===!0?f=de(v[0].object):f=v[0].object,zf.setFromNormalAndCoplanarPoint(e.getWorldDirection(zf.normal),j.setFromMatrixPosition(f.matrixWorld)),n.ray.intersectPlane(zf,Wy)&&(this.state===A.PAN?(r.copy(f.parent.matrixWorld).invert(),t_.copy(Wy).sub(j.setFromMatrixPosition(f.matrixWorld)),t.style.cursor="move",this.dispatchEvent({type:"dragstart",object:f})):this.state===A.ROTATE&&(l.set(0,1,0).applyQuaternion(e.quaternion).normalize(),h.set(1,0,0).applyQuaternion(e.quaternion).normalize(),t.style.cursor="move",this.dispatchEvent({type:"dragstart",object:f})))),Og.copy(eh))}function ce(){this.enabled!==!1&&(f&&(this.dispatchEvent({type:"dragend",object:f}),f=null),this.domElement.style.cursor=g?"pointer":"auto",this.state=A.NONE)}function he(i){this.enabled!==!1&&i.preventDefault()}function de(i,e=null){return i.isGroup&&(e=i),i.parent===null?e:de(i.parent,e)}var Me={value:()=>{}};function Je(){for(var i=0,e=arguments.length,t={},n;i<e;++i){if(!(n=arguments[i]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new mt(t)}function mt(i){this._=i}function pt(i,e){return i.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");if(s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}mt.prototype=Je.prototype={constructor:mt,on:function(i,e){var t=this._,n=pt(i+"",t),s,o=-1,a=n.length;if(arguments.length<2){for(;++o<a;)if((s=(i=n[o]).type)&&(s=Nt(t[s],i.name)))return s;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<a;)if(s=(i=n[o]).type)t[s]=Pt(t[s],i.name,e);else if(e==null)for(s in t)t[s]=Pt(t[s],i.name,null);return this},copy:function(){var i={},e=this._;for(var t in e)i[t]=e[t].slice();return new mt(i)},call:function(i,e){if((s=arguments.length-2)>0)for(var t=new Array(s),n=0,s,o;n<s;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(i))throw new Error("unknown type: "+i);for(o=this._[i],n=0,s=o.length;n<s;++n)o[n].value.apply(e,t)},apply:function(i,e,t){if(!this._.hasOwnProperty(i))throw new Error("unknown type: "+i);for(var n=this._[i],s=0,o=n.length;s<o;++s)n[s].value.apply(e,t)}};function Nt(i,e){for(var t=0,n=i.length,s;t<n;++t)if((s=i[t]).name===e)return s.value}function Pt(i,e,t){for(var n=0,s=i.length;n<s;++n)if(i[n].name===e){i[n]=Me,i=i.slice(0,n).concat(i.slice(n+1));break}return t!=null&&i.push({name:e,value:t}),i}var Gt=Je,gn=0,Sn=0,kn=0,In=1e3,ii,li,dr=0,Zr=0,Ts=0,to=typeof performance=="object"&&performance.now?performance:Date,ho=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(i){setTimeout(i,17)};function Ra(){return Zr||(ho(fl),Zr=to.now()+Ts)}function fl(){Zr=0}function ic(){this._call=this._time=this._next=null}ic.prototype=qo.prototype={constructor:ic,restart:function(i,e,t){if(typeof i!="function")throw new TypeError("callback is not a function");t=(t==null?Ra():+t)+(e==null?0:+e),!this._next&&li!==this&&(li?li._next=this:ii=this,li=this),this._call=i,this._time=t,Ph()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ph())}};function qo(i,e,t){var n=new ic;return n.restart(i,e,t),n}function Na(){Ra(),++gn;for(var i=ii,e;i;)(e=Zr-i._time)>=0&&i._call.call(void 0,e),i=i._next;--gn}function Yo(){Zr=(dr=to.now())+Ts,gn=Sn=0;try{Na()}finally{gn=0,Sc(),Zr=0}}function jc(){var i=to.now(),e=i-dr;e>In&&(Ts-=e,dr=i)}function Sc(){for(var i,e=ii,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),i=e,e=e._next):(t=e._next,e._next=null,e=i?i._next=t:ii=t);li=i,Ph(n)}function Ph(i){if(!gn){Sn&&(Sn=clearTimeout(Sn));var e=i-Zr;e>24?(i<1/0&&(Sn=setTimeout(Yo,i-to.now()-Ts)),kn&&(kn=clearInterval(kn))):(kn||(dr=to.now(),kn=setInterval(jc,In)),gn=1,ho(Yo))}}const nm=1664525,gw=1013904223,n_=4294967296;function i_(){let i=1;return()=>(i=(nm*i+gw)%n_)/n_}var wu=3;function Vf(i){return i.x}function r_(i){return i.y}function th(i){return i.z}var nh=10,Ui=Math.PI*(3-Math.sqrt(5)),tr=Math.PI*20/(9+Math.sqrt(221));function rr(i,e){e=e||2;var t=Math.min(wu,Math.max(1,Math.round(e))),n,s=1,o=.001,a=1-Math.pow(o,1/300),c=0,u=.6,d=new Map,p=qo(M),m=Gt("tick","end"),y=i_();i==null&&(i=[]);function M(){T(),m.call("tick",n),s<o&&(p.stop(),m.call("end",n))}function T(I){var J,K=i.length,re;I===void 0&&(I=1);for(var ve=0;ve<I;++ve)for(s+=(c-s)*a,d.forEach(function(me){me(s)}),J=0;J<K;++J)re=i[J],re.fx==null?re.x+=re.vx*=u:(re.x=re.fx,re.vx=0),t>1&&(re.fy==null?re.y+=re.vy*=u:(re.y=re.fy,re.vy=0)),t>2&&(re.fz==null?re.z+=re.vz*=u:(re.z=re.fz,re.vz=0));return n}function G(){for(var I=0,J=i.length,K;I<J;++I){if(K=i[I],K.index=I,K.fx!=null&&(K.x=K.fx),K.fy!=null&&(K.y=K.fy),K.fz!=null&&(K.z=K.fz),isNaN(K.x)||t>1&&isNaN(K.y)||t>2&&isNaN(K.z)){var re=nh*(t>2?Math.cbrt(.5+I):t>1?Math.sqrt(.5+I):I),ve=I*Ui,me=I*tr;t===1?K.x=re:t===2?(K.x=re*Math.cos(ve),K.y=re*Math.sin(ve)):(K.x=re*Math.sin(ve)*Math.cos(me),K.y=re*Math.cos(ve),K.z=re*Math.sin(ve)*Math.sin(me))}(isNaN(K.vx)||t>1&&isNaN(K.vy)||t>2&&isNaN(K.vz))&&(K.vx=0,t>1&&(K.vy=0),t>2&&(K.vz=0))}}function z(I){return I.initialize&&I.initialize(i,y,t),I}return G(),n={tick:T,restart:function(){return p.restart(M),n},stop:function(){return p.stop(),n},numDimensions:function(I){return arguments.length?(t=Math.min(wu,Math.max(1,Math.round(I))),d.forEach(z),n):t},nodes:function(I){return arguments.length?(i=I,G(),d.forEach(z),n):i},alpha:function(I){return arguments.length?(s=+I,n):s},alphaMin:function(I){return arguments.length?(o=+I,n):o},alphaDecay:function(I){return arguments.length?(a=+I,n):+a},alphaTarget:function(I){return arguments.length?(c=+I,n):c},velocityDecay:function(I){return arguments.length?(u=1-I,n):1-u},randomSource:function(I){return arguments.length?(y=I,d.forEach(z),n):y},force:function(I,J){return arguments.length>1?(J==null?d.delete(I):d.set(I,z(J)),n):d.get(I)},find:function(){var I=Array.prototype.slice.call(arguments),J=I.shift()||0,K=(t>1?I.shift():null)||0,re=(t>2?I.shift():null)||0,ve=I.shift()||1/0,me=0,Le=i.length,Ve,Ee,Oe,dt,Ut,tn;for(ve*=ve,me=0;me<Le;++me)Ut=i[me],Ve=J-Ut.x,Ee=K-(Ut.y||0),Oe=re-(Ut.z||0),dt=Ve*Ve+Ee*Ee+Oe*Oe,dt<ve&&(tn=Ut,ve=dt);return tn},on:function(I,J){return arguments.length>1?(m.on(I,J),n):m.on(I)}}}function fr(i){return function(){return i}}function lr(i){return(i()-.5)*1e-6}function Qs(i){return i.index}function Es(i,e){var t=i.get(e);if(!t)throw new Error("node not found: "+e);return t}function Vo(i){var e=Qs,t=y,n,s=fr(30),o,a,c,u,d,p,m=1;i==null&&(i=[]);function y(I){return 1/Math.min(u[I.source.index],u[I.target.index])}function M(I){for(var J=0,K=i.length;J<m;++J)for(var re=0,ve,me,Le,Ve=0,Ee=0,Oe=0,dt,Ut;re<K;++re)ve=i[re],me=ve.source,Le=ve.target,Ve=Le.x+Le.vx-me.x-me.vx||lr(p),c>1&&(Ee=Le.y+Le.vy-me.y-me.vy||lr(p)),c>2&&(Oe=Le.z+Le.vz-me.z-me.vz||lr(p)),dt=Math.sqrt(Ve*Ve+Ee*Ee+Oe*Oe),dt=(dt-o[re])/dt*I*n[re],Ve*=dt,Ee*=dt,Oe*=dt,Le.vx-=Ve*(Ut=d[re]),c>1&&(Le.vy-=Ee*Ut),c>2&&(Le.vz-=Oe*Ut),me.vx+=Ve*(Ut=1-Ut),c>1&&(me.vy+=Ee*Ut),c>2&&(me.vz+=Oe*Ut)}function T(){if(a){var I,J=a.length,K=i.length,re=new Map(a.map((me,Le)=>[e(me,Le,a),me])),ve;for(I=0,u=new Array(J);I<K;++I)ve=i[I],ve.index=I,typeof ve.source!="object"&&(ve.source=Es(re,ve.source)),typeof ve.target!="object"&&(ve.target=Es(re,ve.target)),u[ve.source.index]=(u[ve.source.index]||0)+1,u[ve.target.index]=(u[ve.target.index]||0)+1;for(I=0,d=new Array(K);I<K;++I)ve=i[I],d[I]=u[ve.source.index]/(u[ve.source.index]+u[ve.target.index]);n=new Array(K),G(),o=new Array(K),z()}}function G(){if(a)for(var I=0,J=i.length;I<J;++I)n[I]=+t(i[I],I,i)}function z(){if(a)for(var I=0,J=i.length;I<J;++I)o[I]=+s(i[I],I,i)}return M.initialize=function(I,...J){a=I,p=J.find(K=>typeof K=="function")||Math.random,c=J.find(K=>[1,2,3].includes(K))||2,T()},M.links=function(I){return arguments.length?(i=I,T(),M):i},M.id=function(I){return arguments.length?(e=I,M):e},M.iterations=function(I){return arguments.length?(m=+I,M):m},M.strength=function(I){return arguments.length?(t=typeof I=="function"?I:fr(+I),G(),M):t},M.distance=function(I){return arguments.length?(s=typeof I=="function"?I:fr(+I),z(),M):s},M}var Zo=b(20928),Ha=b(46632),rc=b(67217);function Ld(){var i,e,t,n,s,o=fr(-30),a,c=1,u=1/0,d=.81;function p(T){var G,z=i.length,I=(e===1?(0,Zo.Z)(i,Vf):e===2?(0,Ha.Z)(i,Vf,r_):e===3?(0,rc.Z)(i,Vf,r_,th):null).visitAfter(y);for(s=T,G=0;G<z;++G)t=i[G],I.visit(M)}function m(){if(i){var T,G=i.length,z;for(a=new Array(G),T=0;T<G;++T)z=i[T],a[z.index]=+o(z,T,i)}}function y(T){var G=0,z,I,J=0,K,re,ve,me,Le=T.length;if(Le){for(K=re=ve=me=0;me<Le;++me)(z=T[me])&&(I=Math.abs(z.value))&&(G+=z.value,J+=I,K+=I*(z.x||0),re+=I*(z.y||0),ve+=I*(z.z||0));G*=Math.sqrt(4/Le),T.x=K/J,e>1&&(T.y=re/J),e>2&&(T.z=ve/J)}else{z=T,z.x=z.data.x,e>1&&(z.y=z.data.y),e>2&&(z.z=z.data.z);do G+=a[z.data.index];while(z=z.next)}T.value=G}function M(T,G,z,I,J){if(!T.value)return!0;var K=[z,I,J][e-1],re=T.x-t.x,ve=e>1?T.y-t.y:0,me=e>2?T.z-t.z:0,Le=K-G,Ve=re*re+ve*ve+me*me;if(Le*Le/d<Ve)return Ve<u&&(re===0&&(re=lr(n),Ve+=re*re),e>1&&ve===0&&(ve=lr(n),Ve+=ve*ve),e>2&&me===0&&(me=lr(n),Ve+=me*me),Ve<c&&(Ve=Math.sqrt(c*Ve)),t.vx+=re*T.value*s/Ve,e>1&&(t.vy+=ve*T.value*s/Ve),e>2&&(t.vz+=me*T.value*s/Ve)),!0;if(T.length||Ve>=u)return;(T.data!==t||T.next)&&(re===0&&(re=lr(n),Ve+=re*re),e>1&&ve===0&&(ve=lr(n),Ve+=ve*ve),e>2&&me===0&&(me=lr(n),Ve+=me*me),Ve<c&&(Ve=Math.sqrt(c*Ve)));do T.data!==t&&(Le=a[T.data.index]*s/Ve,t.vx+=re*Le,e>1&&(t.vy+=ve*Le),e>2&&(t.vz+=me*Le));while(T=T.next)}return p.initialize=function(T,...G){i=T,n=G.find(z=>typeof z=="function")||Math.random,e=G.find(z=>[1,2,3].includes(z))||2,m()},p.strength=function(T){return arguments.length?(o=typeof T=="function"?T:fr(+T),m(),p):o},p.distanceMin=function(T){return arguments.length?(c=T*T,p):Math.sqrt(c)},p.distanceMax=function(T){return arguments.length?(u=T*T,p):Math.sqrt(u)},p.theta=function(T){return arguments.length?(d=T*T,p):Math.sqrt(d)},p}function sc(i,e,t){var n,s=1;i==null&&(i=0),e==null&&(e=0),t==null&&(t=0);function o(){var a,c=n.length,u,d=0,p=0,m=0;for(a=0;a<c;++a)u=n[a],d+=u.x||0,p+=u.y||0,m+=u.z||0;for(d=(d/c-i)*s,p=(p/c-e)*s,m=(m/c-t)*s,a=0;a<c;++a)u=n[a],d&&(u.x-=d),p&&(u.y-=p),m&&(u.z-=m)}return o.initialize=function(a){n=a},o.x=function(a){return arguments.length?(i=+a,o):i},o.y=function(a){return arguments.length?(e=+a,o):e},o.z=function(a){return arguments.length?(t=+a,o):t},o.strength=function(a){return arguments.length?(s=+a,o):s},o}function s_(i,e,t,n){var s,o,a=fr(.1),c,u;typeof i!="function"&&(i=fr(+i)),e==null&&(e=0),t==null&&(t=0),n==null&&(n=0);function d(m){for(var y=0,M=s.length;y<M;++y){var T=s[y],G=T.x-e||1e-6,z=(T.y||0)-t||1e-6,I=(T.z||0)-n||1e-6,J=Math.sqrt(G*G+z*z+I*I),K=(u[y]-J)*c[y]*m/J;T.vx+=G*K,o>1&&(T.vy+=z*K),o>2&&(T.vz+=I*K)}}function p(){if(s){var m,y=s.length;for(c=new Array(y),u=new Array(y),m=0;m<y;++m)u[m]=+i(s[m],m,s),c[m]=isNaN(u[m])?0:+a(s[m],m,s)}}return d.initialize=function(m,...y){s=m,o=y.find(M=>[1,2,3].includes(M))||2,p()},d.strength=function(m){return arguments.length?(a=typeof m=="function"?m:fr(+m),p(),d):a},d.radius=function(m){return arguments.length?(i=typeof m=="function"?m:fr(+m),p(),d):i},d.x=function(m){return arguments.length?(e=+m,d):e},d.y=function(m){return arguments.length?(t=+m,d):t},d.z=function(m){return arguments.length?(n=+m,d):n},d}function o_(i){yw(i);const e=a_(i);return i.on=e.on,i.off=e.off,i.fire=e.fire,i}function a_(i){let e=Object.create(null);return{on:function(t,n,s){if(typeof n!="function")throw new Error("callback is expected to be a function");let o=e[t];return o||(o=e[t]=[]),o.push({callback:n,ctx:s}),i},off:function(t,n){if(typeof t=="undefined")return e=Object.create(null),i;if(e[t])if(typeof n!="function")delete e[t];else{const a=e[t];for(let c=0;c<a.length;++c)a[c].callback===n&&a.splice(c,1)}return i},fire:function(t){const n=e[t];if(!n)return i;let s;arguments.length>1&&(s=Array.prototype.slice.call(arguments,1));for(let o=0;o<n.length;++o){const a=n[o];a.callback.apply(a.ctx,s)}return i}}}function yw(i){if(!i)throw new Error("Eventify cannot use falsy object as events subject");const e=["on","fire","off"];for(let t=0;t<e.length;++t)if(i.hasOwnProperty(e[t]))throw new Error("Subject cannot be eventified, since it already has property '"+e[t]+"'")}var vw=l_;function l_(i){if(i=i||{},"uniqueLinkId"in i&&(console.warn("ngraph.graph: Starting from version 0.14 `uniqueLinkId` is deprecated.\nUse `multigraph` option instead\n",`
|
|
|
`,`Note: there is also change in default behavior: From now on each graph
|
|
|
is considered to be not a multigraph by default (each edge is unique).`),i.multigraph=i.uniqueLinkId),i.multigraph===void 0&&(i.multigraph=!1),typeof Map!="function")throw new Error("ngraph.graph requires `Map` to be defined. Please polyfill it before using ngraph");var e=new Map,t=new Map,n={},s=0,o=i.multigraph?re:K,a=[],c=mn,u=mn,d=mn,p=mn,m={version:20,addNode:G,addLink:J,removeLink:Ve,removeNode:I,getNode:z,getNodeCount:ve,getLinkCount:me,getEdgeCount:me,getLinksCount:me,getNodesCount:ve,getLinks:Le,forEachNode:si,forEachLinkedNode:tn,forEachLink:Ut,beginUpdate:d,endUpdate:p,clear:dt,hasLink:Oe,hasNode:z,getLink:Oe};return o_(m),y(),m;function y(){var wn=m.on;m.on=Gn;function Gn(){return m.beginUpdate=d=Yn,m.endUpdate=p=xn,c=M,u=T,m.on=wn,wn.apply(m,arguments)}}function M(wn,Gn){a.push({link:wn,changeType:Gn})}function T(wn,Gn){a.push({node:wn,changeType:Gn})}function G(wn,Gn){if(wn===void 0)throw new Error("Invalid node identifier");d();var Si=z(wn);return Si?(Si.data=Gn,u(Si,"update")):(Si=new c_(wn,Gn),u(Si,"add")),e.set(wn,Si),p(),Si}function z(wn){return e.get(wn)}function I(wn){var Gn=z(wn);if(!Gn)return!1;d();var Si=Gn.links;return Si&&(Si.forEach(Ee),Gn.links=null),e.delete(wn),u(Gn,"remove"),p(),!0}function J(wn,Gn,Si){d();var nr=z(wn)||G(wn),os=z(Gn)||G(Gn),Vn=o(wn,Gn,Si),un=t.has(Vn.id);return t.set(Vn.id,Vn),UE(nr,Vn),wn!==Gn&&UE(os,Vn),c(Vn,un?"update":"add"),p(),Vn}function K(wn,Gn,Si){var nr=u_(wn,Gn),os=t.get(nr);return os?(os.data=Si,os):new kE(wn,Gn,Si,nr)}function re(wn,Gn,Si){var nr=u_(wn,Gn),os=n.hasOwnProperty(nr);if(os||Oe(wn,Gn)){os||(n[nr]=0);var Vn="@"+ ++n[nr];nr=u_(wn+Vn,Gn+Vn)}return new kE(wn,Gn,Si,nr)}function ve(){return e.size}function me(){return t.size}function Le(wn){var Gn=z(wn);return Gn?Gn.links:null}function Ve(wn,Gn){return Gn!==void 0&&(wn=Oe(wn,Gn)),Ee(wn)}function Ee(wn){if(!wn||!t.get(wn.id))return!1;d(),t.delete(wn.id);var Gn=z(wn.fromId),Si=z(wn.toId);return Gn&&Gn.links.delete(wn),Si&&Si.links.delete(wn),c(wn,"remove"),p(),!0}function Oe(wn,Gn){if(!(wn===void 0||Gn===void 0))return t.get(u_(wn,Gn))}function dt(){d(),si(function(wn){I(wn.id)}),p()}function Ut(wn){if(typeof wn=="function")for(var Gn=t.values(),Si=Gn.next();!Si.done;){if(wn(Si.value))return!0;Si=Gn.next()}}function tn(wn,Gn,Si){var nr=z(wn);if(nr&&nr.links&&typeof Gn=="function")return Si?vn(nr.links,wn,Gn):cn(nr.links,wn,Gn)}function cn(wn,Gn,Si){for(var nr,os=wn.values(),Vn=os.next();!Vn.done;){var un=Vn.value,Mn=un.fromId===Gn?un.toId:un.fromId;if(nr=Si(e.get(Mn),un),nr)return!0;Vn=os.next()}}function vn(wn,Gn,Si){for(var nr,os=wn.values(),Vn=os.next();!Vn.done;){var un=Vn.value;if(un.fromId===Gn&&(nr=Si(e.get(un.toId),un),nr))return!0;Vn=os.next()}}function mn(){}function Yn(){s+=1}function xn(){s-=1,s===0&&a.length>0&&(m.fire("changed",a),a.length=0)}function si(wn){if(typeof wn!="function")throw new Error("Function is expected to iterate over graph nodes. You passed "+wn);for(var Gn=e.values(),Si=Gn.next();!Si.done;){if(wn(Si.value))return!0;Si=Gn.next()}}}function c_(i,e){this.id=i,this.links=null,this.data=e}function UE(i,e){i.links?i.links.add(e):i.links=new Set([e])}function kE(i,e,t,n){this.fromId=i,this.toId=e,this.data=t,this.id=n}function u_(i,e){return i.toString()+"\u{1F449} "+e.toString()}var Z3=b(16505);function K3(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}var xw=K3,J3=typeof global=="object"&&global&&global.Object===Object&&global,Q3=J3,eD=typeof self=="object"&&self&&self.Object===Object&&self,tD=Q3||eD||Function("return this")(),zE=tD,nD=function(){return zE.Date.now()},_w=nD,iD=/\s/;function rD(i){for(var e=i.length;e--&&iD.test(i.charAt(e)););return e}var sD=rD,oD=/^\s+/;function aD(i){return i&&i.slice(0,sD(i)+1).replace(oD,"")}var lD=aD,cD=zE.Symbol,h_=cD,VE=Object.prototype,uD=VE.hasOwnProperty,hD=VE.toString,Hy=h_?h_.toStringTag:void 0;function dD(i){var e=uD.call(i,Hy),t=i[Hy];try{i[Hy]=void 0;var n=!0}catch(o){}var s=hD.call(i);return n&&(e?i[Hy]=t:delete i[Hy]),s}var fD=dD,pD=Object.prototype,mD=pD.toString;function gD(i){return mD.call(i)}var yD=gD,vD="[object Null]",xD="[object Undefined]",GE=h_?h_.toStringTag:void 0;function _D(i){return i==null?i===void 0?xD:vD:GE&&GE in Object(i)?fD(i):yD(i)}var bD=_D;function wD(i){return i!=null&&typeof i=="object"}var MD=wD,SD="[object Symbol]";function TD(i){return typeof i=="symbol"||MD(i)&&bD(i)==SD}var ED=TD,WE=NaN,AD=/^[-+]0x[0-9a-f]+$/i,CD=/^0b[01]+$/i,RD=/^0o[0-7]+$/i,ND=parseInt;function PD(i){if(typeof i=="number")return i;if(ED(i))return WE;if(xw(i)){var e=typeof i.valueOf=="function"?i.valueOf():i;i=xw(e)?e+"":e}if(typeof i!="string")return i===0?i:+i;i=lD(i);var t=CD.test(i);return t||RD.test(i)?ND(i.slice(2),t?2:8):AD.test(i)?WE:+i}var HE=PD,ID="Expected a function",LD=Math.max,DD=Math.min;function OD(i,e,t){var n,s,o,a,c,u,d=0,p=!1,m=!1,y=!0;if(typeof i!="function")throw new TypeError(ID);e=HE(e)||0,xw(t)&&(p=!!t.leading,m="maxWait"in t,o=m?LD(HE(t.maxWait)||0,e):o,y="trailing"in t?!!t.trailing:y);function M(me){var Le=n,Ve=s;return n=s=void 0,d=me,a=i.apply(Ve,Le),a}function T(me){return d=me,c=setTimeout(I,e),p?M(me):a}function G(me){var Le=me-u,Ve=me-d,Ee=e-Le;return m?DD(Ee,o-Ve):Ee}function z(me){var Le=me-u,Ve=me-d;return u===void 0||Le>=e||Le<0||m&&Ve>=o}function I(){var me=_w();if(z(me))return J(me);c=setTimeout(I,G(me))}function J(me){return c=void 0,y&&n?M(me):(n=s=void 0,a)}function K(){c!==void 0&&clearTimeout(c),d=0,n=u=s=c=void 0}function re(){return c===void 0?a:J(_w())}function ve(){var me=_w(),Le=z(me);if(n=arguments,s=this,u=me,Le){if(c===void 0)return T(u);if(m)return clearTimeout(c),c=setTimeout(I,e),M(u)}return c===void 0&&(c=setTimeout(I,e)),a}return ve.cancel=K,ve.flush=re,ve}var FD=OD;function $E(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function BD(i){if(Array.isArray(i))return i}function UD(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function kD(i,e,t){return Object.defineProperty(i,"prototype",{writable:!1}),i}function zD(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,s,o,a,c=[],u=!0,d=!1;try{if(o=(t=t.call(i)).next,e!==0)for(;!(u=(n=o.call(t)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(p){d=!0,s=p}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(d)throw s}}return c}}function VD(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function GD(i,e){return BD(i)||zD(i,e)||WD(i,e)||VD()}function WD(i,e){if(i){if(typeof i=="string")return $E(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?$E(i,e):void 0}}var HD=kD(function i(e,t){var n=t.default,s=n===void 0?null:n,o=t.triggerUpdate,a=o===void 0?!0:o,c=t.onChange,u=c===void 0?function(d,p){}:c;UD(this,i),this.name=e,this.defaultVal=s,this.triggerUpdate=a,this.onChange=u});function d_(i){var e=i.stateInit,t=e===void 0?function(){return{}}:e,n=i.props,s=n===void 0?{}:n,o=i.methods,a=o===void 0?{}:o,c=i.aliases,u=c===void 0?{}:c,d=i.init,p=d===void 0?function(){}:d,m=i.update,y=m===void 0?function(){}:m,M=Object.keys(s).map(function(T){return new HD(T,s[T])});return function T(){for(var G=arguments.length,z=new Array(G),I=0;I<G;I++)z[I]=arguments[I];var J=!!(this instanceof T&&this.constructor),K=J?z.shift():void 0,re=z[0],ve=re===void 0?{}:re,me=Object.assign({},t instanceof Function?t(ve):t,{initialised:!1}),Le={};function Ve(dt){return Ee(dt,ve),Oe(),Ve}var Ee=function(Ut,tn){p.call(Ve,Ut,me,tn),me.initialised=!0},Oe=FD(function(){me.initialised&&(y.call(Ve,me,Le),Le={})},1);return M.forEach(function(dt){Ve[dt.name]=Ut(dt);function Ut(tn){var cn=tn.name,vn=tn.triggerUpdate,mn=vn===void 0?!1:vn,Yn=tn.onChange,xn=Yn===void 0?function(Gn,Si){}:Yn,si=tn.defaultVal,wn=si===void 0?null:si;return function(Gn){var Si=me[cn];if(!arguments.length)return Si;var nr=Gn===void 0?wn:Gn;return me[cn]=nr,xn.call(Ve,nr,me,Si),!Le.hasOwnProperty(cn)&&(Le[cn]=Si),mn&&Oe(),Ve}}}),Object.keys(a).forEach(function(dt){Ve[dt]=function(){for(var Ut,tn=arguments.length,cn=new Array(tn),vn=0;vn<tn;vn++)cn[vn]=arguments[vn];return(Ut=a[dt]).call.apply(Ut,[Ve,me].concat(cn))}}),Object.entries(u).forEach(function(dt){var Ut=GD(dt,2),tn=Ut[0],cn=Ut[1];return Ve[tn]=Ve[cn]}),Ve.resetProps=function(){return M.forEach(function(dt){Ve[dt.name](dt.defaultVal)}),Ve},Ve.resetProps(),me._rerender=Oe,J&&K&&Ve(K),Ve}}var ks=function(i){return typeof i=="function"?i:typeof i=="string"?function(e){return e[i]}:function(e){return i}};function $D(i,e){let t;if(e===void 0)for(const n of i)n!=null&&(t>n||t===void 0&&n>=n)&&(t=n);else{let n=-1;for(let s of i)(s=e(s,++n,i))!=null&&(t>s||t===void 0&&s>=s)&&(t=s)}return t}function jD(i,e){let t;if(e===void 0)for(const n of i)n!=null&&(t<n||t===void 0&&n>=n)&&(t=n);else{let n=-1;for(let s of i)(s=e(s,++n,i))!=null&&(t<s||t===void 0&&s>=s)&&(t=s)}return t}function bw(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function XD(i){if(Array.isArray(i))return i}function qD(i){if(Array.isArray(i))return bw(i)}function jE(i,e,t){if(typeof i=="function"?i===e:i.has(e))return arguments.length<3?e:t;throw new TypeError("Private element is not present on this object")}function YD(i,e){if(e.has(i))throw new TypeError("Cannot initialize the same private elements twice on an object")}function ZD(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function Hl(i,e){return i.get(jE(i,e))}function Fg(i,e,t){YD(i,e),e.set(i,t)}function f_(i,e,t){return i.set(jE(i,e),t),t}function KD(i,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(i,oO(n.key),n)}}function JD(i,e,t){return e&&KD(i.prototype,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function QD(i){if(typeof Symbol!="undefined"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function eO(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,s,o,a,c=[],u=!0,d=!1;try{if(o=(t=t.call(i)).next,e!==0)for(;!(u=(n=o.call(t)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(p){d=!0,s=p}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(d)throw s}}return c}}function tO(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function nO(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function iO(i,e){return XD(i)||eO(i,e)||XE(i,e)||tO()}function rO(i){return qD(i)||QD(i)||XE(i)||nO()}function sO(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(i)}function oO(i){var e=sO(i,"string");return typeof e=="symbol"?e:e+""}function XE(i,e){if(i){if(typeof i=="string")return bw(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?bw(i,e):void 0}}var Bg=new WeakMap,$y=new WeakMap,Ug=new WeakMap,ww=new WeakMap,Mw=new WeakMap,Sw=new WeakMap,aO=function(){function i(){ZD(this,i),Fg(this,Bg,new Map),Fg(this,$y,new Map),Fg(this,Ug,function(e){return e}),Fg(this,ww,function(){return{}}),Fg(this,Mw,function(){}),Fg(this,Sw,function(){})}return JD(i,[{key:"getObj",value:function(t){return Hl(Bg,this).get(Hl(Ug,this).call(this,t))}},{key:"getData",value:function(t){return Hl($y,this).get(t)}},{key:"entries",value:function(){return rO(Hl($y,this).entries()).map(function(t){var n=iO(t,2),s=n[0],o=n[1];return[o,s]})}},{key:"id",value:function(t){return f_(Ug,this,ks(t)),this}},{key:"onCreateObj",value:function(t){return f_(ww,this,t),this}},{key:"onUpdateObj",value:function(t){return f_(Mw,this,t),this}},{key:"onRemoveObj",value:function(t){return f_(Sw,this,t),this}},{key:"digest",value:function(t){var n=this;t.filter(function(o){return!Hl(Bg,n).has(Hl(Ug,n).call(n,o))}).forEach(function(o){var a=Hl(ww,n).call(n,o);Hl(Bg,n).set(Hl(Ug,n).call(n,o),a),Hl($y,n).set(a,o)});var s=new Map(t.map(function(o){return[Hl(Ug,n).call(n,o),o]}));return Hl(Bg,this).forEach(function(o,a){s.has(a)?Hl(Mw,n).call(n,o,s.get(a)):(Hl(Sw,n).call(n,o,a),Hl(Bg,n).delete(a),Hl($y,n).delete(o))}),this}},{key:"clear",value:function(){return this.digest([]),this}}])}();class qE extends Map{constructor(e,t=KE){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(const[n,s]of e)this.set(n,s)}get(e){return super.get(Tw(this,e))}has(e){return super.has(Tw(this,e))}set(e,t){return super.set(YE(this,e),t)}delete(e){return super.delete(ZE(this,e))}}class NY extends null{constructor(e,t=KE){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(const n of e)this.add(n)}has(e){return super.has(Tw(this,e))}add(e){return super.add(YE(this,e))}delete(e){return super.delete(ZE(this,e))}}function Tw({_intern:i,_key:e},t){const n=e(t);return i.has(n)?i.get(n):t}function YE({_intern:i,_key:e},t){const n=e(t);return i.has(n)?i.get(n):(i.set(n,t),t)}function ZE({_intern:i,_key:e},t){const n=e(t);return i.has(n)&&(t=i.get(n),i.delete(n)),t}function KE(i){return i!==null&&typeof i=="object"?i.valueOf():i}function lO(i,e){switch(arguments.length){case 0:break;case 1:this.range(i);break;default:this.range(e).domain(i);break}return this}function PY(i,e){switch(arguments.length){case 0:break;case 1:{typeof i=="function"?this.interpolator(i):this.range(i);break}default:{this.domain(i),typeof e=="function"?this.interpolator(e):this.range(e);break}}return this}const JE=Symbol("implicit");function QE(){var i=new qE,e=[],t=[],n=JE;function s(o){let a=i.get(o);if(a===void 0){if(n!==JE)return n;i.set(o,a=e.push(o)-1)}return t[a%t.length]}return s.domain=function(o){if(!arguments.length)return e.slice();e=[],i=new qE;for(const a of o)i.has(a)||i.set(a,e.push(a)-1);return s},s.range=function(o){return arguments.length?(t=Array.from(o),s):t.slice()},s.unknown=function(o){return arguments.length?(n=o,s):n},s.copy=function(){return QE(e,t).unknown(n)},lO.apply(s,arguments),s}function cO(i){for(var e=i.length/6|0,t=new Array(e),n=0;n<e;)t[n]="#"+i.slice(n*6,++n*6);return t}var uO=cO("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928");function p_(i){"@babel/helpers - typeof";return p_=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p_(i)}var hO=/^\s+/,dO=/\s+$/;function Nr(i,e){if(i=i||"",e=e||{},i instanceof Nr)return i;if(!(this instanceof Nr))return new Nr(i,e);var t=fO(i);this._originalInput=i,this._r=t.r,this._g=t.g,this._b=t.b,this._a=t.a,this._roundA=Math.round(100*this._a)/100,this._format=e.format||t.format,this._gradientType=e.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=t.ok}Nr.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),t,n,s,o,a,c;return t=e.r/255,n=e.g/255,s=e.b/255,t<=.03928?o=t/12.92:o=Math.pow((t+.055)/1.055,2.4),n<=.03928?a=n/12.92:a=Math.pow((n+.055)/1.055,2.4),s<=.03928?c=s/12.92:c=Math.pow((s+.055)/1.055,2.4),.2126*o+.7152*a+.0722*c},setAlpha:function(e){return this._a=sA(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=tA(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=tA(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),s=Math.round(e.v*100);return this._a==1?"hsv("+t+", "+n+"%, "+s+"%)":"hsva("+t+", "+n+"%, "+s+"%, "+this._roundA+")"},toHsl:function(){var e=eA(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=eA(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),s=Math.round(e.l*100);return this._a==1?"hsl("+t+", "+n+"%, "+s+"%)":"hsla("+t+", "+n+"%, "+s+"%, "+this._roundA+")"},toHex:function(e){return nA(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return yO(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(sa(this._r,255)*100)+"%",g:Math.round(sa(this._g,255)*100)+"%",b:Math.round(sa(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(sa(this._r,255)*100)+"%, "+Math.round(sa(this._g,255)*100)+"%, "+Math.round(sa(this._b,255)*100)+"%)":"rgba("+Math.round(sa(this._r,255)*100)+"%, "+Math.round(sa(this._g,255)*100)+"%, "+Math.round(sa(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:RO[nA(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t="#"+iA(this._r,this._g,this._b,this._a),n=t,s=this._gradientType?"GradientType = 1, ":"";if(e){var o=Nr(e);n="#"+iA(o._r,o._g,o._b,o._a)}return"progid:DXImageTransform.Microsoft.gradient("+s+"startColorstr="+t+",endColorstr="+n+")"},toString:function(e){var t=!!e;e=e||this._format;var n=!1,s=this._a<1&&this._a>=0,o=!t&&s&&(e==="hex"||e==="hex6"||e==="hex3"||e==="hex4"||e==="hex8"||e==="name");return o?e==="name"&&this._a===0?this.toName():this.toRgbString():(e==="rgb"&&(n=this.toRgbString()),e==="prgb"&&(n=this.toPercentageRgbString()),(e==="hex"||e==="hex6")&&(n=this.toHexString()),e==="hex3"&&(n=this.toHexString(!0)),e==="hex4"&&(n=this.toHex8String(!0)),e==="hex8"&&(n=this.toHex8String()),e==="name"&&(n=this.toName()),e==="hsl"&&(n=this.toHslString()),e==="hsv"&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return Nr(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(bO,arguments)},brighten:function(){return this._applyModification(wO,arguments)},darken:function(){return this._applyModification(MO,arguments)},desaturate:function(){return this._applyModification(vO,arguments)},saturate:function(){return this._applyModification(xO,arguments)},greyscale:function(){return this._applyModification(_O,arguments)},spin:function(){return this._applyModification(SO,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(AO,arguments)},complement:function(){return this._applyCombination(TO,arguments)},monochromatic:function(){return this._applyCombination(CO,arguments)},splitcomplement:function(){return this._applyCombination(EO,arguments)},triad:function(){return this._applyCombination(rA,[3])},tetrad:function(){return this._applyCombination(rA,[4])}},Nr.fromRatio=function(i,e){if(p_(i)=="object"){var t={};for(var n in i)i.hasOwnProperty(n)&&(n==="a"?t[n]=i[n]:t[n]=jy(i[n]));i=t}return Nr(i,e)};function fO(i){var e={r:0,g:0,b:0},t=1,n=null,s=null,o=null,a=!1,c=!1;return typeof i=="string"&&(i=LO(i)),p_(i)=="object"&&(Dd(i.r)&&Dd(i.g)&&Dd(i.b)?(e=pO(i.r,i.g,i.b),a=!0,c=String(i.r).substr(-1)==="%"?"prgb":"rgb"):Dd(i.h)&&Dd(i.s)&&Dd(i.v)?(n=jy(i.s),s=jy(i.v),e=gO(i.h,n,s),a=!0,c="hsv"):Dd(i.h)&&Dd(i.s)&&Dd(i.l)&&(n=jy(i.s),o=jy(i.l),e=mO(i.h,n,o),a=!0,c="hsl"),i.hasOwnProperty("a")&&(t=i.a)),t=sA(t),{ok:a,format:i.format||c,r:Math.min(255,Math.max(e.r,0)),g:Math.min(255,Math.max(e.g,0)),b:Math.min(255,Math.max(e.b,0)),a:t}}function pO(i,e,t){return{r:sa(i,255)*255,g:sa(e,255)*255,b:sa(t,255)*255}}function eA(i,e,t){i=sa(i,255),e=sa(e,255),t=sa(t,255);var n=Math.max(i,e,t),s=Math.min(i,e,t),o,a,c=(n+s)/2;if(n==s)o=a=0;else{var u=n-s;switch(a=c>.5?u/(2-n-s):u/(n+s),n){case i:o=(e-t)/u+(e<t?6:0);break;case e:o=(t-i)/u+2;break;case t:o=(i-e)/u+4;break}o/=6}return{h:o,s:a,l:c}}function mO(i,e,t){var n,s,o;i=sa(i,360),e=sa(e,100),t=sa(t,100);function a(d,p,m){return m<0&&(m+=1),m>1&&(m-=1),m<1/6?d+(p-d)*6*m:m<1/2?p:m<2/3?d+(p-d)*(2/3-m)*6:d}if(e===0)n=s=o=t;else{var c=t<.5?t*(1+e):t+e-t*e,u=2*t-c;n=a(u,c,i+1/3),s=a(u,c,i),o=a(u,c,i-1/3)}return{r:n*255,g:s*255,b:o*255}}function tA(i,e,t){i=sa(i,255),e=sa(e,255),t=sa(t,255);var n=Math.max(i,e,t),s=Math.min(i,e,t),o,a,c=n,u=n-s;if(a=n===0?0:u/n,n==s)o=0;else{switch(n){case i:o=(e-t)/u+(e<t?6:0);break;case e:o=(t-i)/u+2;break;case t:o=(i-e)/u+4;break}o/=6}return{h:o,s:a,v:c}}function gO(i,e,t){i=sa(i,360)*6,e=sa(e,100),t=sa(t,100);var n=Math.floor(i),s=i-n,o=t*(1-e),a=t*(1-s*e),c=t*(1-(1-s)*e),u=n%6,d=[t,a,o,o,c,t][u],p=[c,t,t,a,o,o][u],m=[o,o,c,t,t,a][u];return{r:d*255,g:p*255,b:m*255}}function nA(i,e,t,n){var s=[ih(Math.round(i).toString(16)),ih(Math.round(e).toString(16)),ih(Math.round(t).toString(16))];return n&&s[0].charAt(0)==s[0].charAt(1)&&s[1].charAt(0)==s[1].charAt(1)&&s[2].charAt(0)==s[2].charAt(1)?s[0].charAt(0)+s[1].charAt(0)+s[2].charAt(0):s.join("")}function yO(i,e,t,n,s){var o=[ih(Math.round(i).toString(16)),ih(Math.round(e).toString(16)),ih(Math.round(t).toString(16)),ih(oA(n))];return s&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1)?o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0):o.join("")}function iA(i,e,t,n){var s=[ih(oA(n)),ih(Math.round(i).toString(16)),ih(Math.round(e).toString(16)),ih(Math.round(t).toString(16))];return s.join("")}Nr.equals=function(i,e){return!i||!e?!1:Nr(i).toRgbString()==Nr(e).toRgbString()},Nr.random=function(){return Nr.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function vO(i,e){e=e===0?0:e||10;var t=Nr(i).toHsl();return t.s-=e/100,t.s=m_(t.s),Nr(t)}function xO(i,e){e=e===0?0:e||10;var t=Nr(i).toHsl();return t.s+=e/100,t.s=m_(t.s),Nr(t)}function _O(i){return Nr(i).desaturate(100)}function bO(i,e){e=e===0?0:e||10;var t=Nr(i).toHsl();return t.l+=e/100,t.l=m_(t.l),Nr(t)}function wO(i,e){e=e===0?0:e||10;var t=Nr(i).toRgb();return t.r=Math.max(0,Math.min(255,t.r-Math.round(255*-(e/100)))),t.g=Math.max(0,Math.min(255,t.g-Math.round(255*-(e/100)))),t.b=Math.max(0,Math.min(255,t.b-Math.round(255*-(e/100)))),Nr(t)}function MO(i,e){e=e===0?0:e||10;var t=Nr(i).toHsl();return t.l-=e/100,t.l=m_(t.l),Nr(t)}function SO(i,e){var t=Nr(i).toHsl(),n=(t.h+e)%360;return t.h=n<0?360+n:n,Nr(t)}function TO(i){var e=Nr(i).toHsl();return e.h=(e.h+180)%360,Nr(e)}function rA(i,e){if(isNaN(e)||e<=0)throw new Error("Argument to polyad must be a positive number");for(var t=Nr(i).toHsl(),n=[Nr(i)],s=360/e,o=1;o<e;o++)n.push(Nr({h:(t.h+o*s)%360,s:t.s,l:t.l}));return n}function EO(i){var e=Nr(i).toHsl(),t=e.h;return[Nr(i),Nr({h:(t+72)%360,s:e.s,l:e.l}),Nr({h:(t+216)%360,s:e.s,l:e.l})]}function AO(i,e,t){e=e||6,t=t||30;var n=Nr(i).toHsl(),s=360/t,o=[Nr(i)];for(n.h=(n.h-(s*e>>1)+720)%360;--e;)n.h=(n.h+s)%360,o.push(Nr(n));return o}function CO(i,e){e=e||6;for(var t=Nr(i).toHsv(),n=t.h,s=t.s,o=t.v,a=[],c=1/e;e--;)a.push(Nr({h:n,s,v:o})),o=(o+c)%1;return a}Nr.mix=function(i,e,t){t=t===0?0:t||50;var n=Nr(i).toRgb(),s=Nr(e).toRgb(),o=t/100,a={r:(s.r-n.r)*o+n.r,g:(s.g-n.g)*o+n.g,b:(s.b-n.b)*o+n.b,a:(s.a-n.a)*o+n.a};return Nr(a)},Nr.readability=function(i,e){var t=Nr(i),n=Nr(e);return(Math.max(t.getLuminance(),n.getLuminance())+.05)/(Math.min(t.getLuminance(),n.getLuminance())+.05)},Nr.isReadable=function(i,e,t){var n=Nr.readability(i,e),s,o;switch(o=!1,s=DO(t),s.level+s.size){case"AAsmall":case"AAAlarge":o=n>=4.5;break;case"AAlarge":o=n>=3;break;case"AAAsmall":o=n>=7;break}return o},Nr.mostReadable=function(i,e,t){var n=null,s=0,o,a,c,u;t=t||{},a=t.includeFallbackColors,c=t.level,u=t.size;for(var d=0;d<e.length;d++)o=Nr.readability(i,e[d]),o>s&&(s=o,n=Nr(e[d]));return Nr.isReadable(i,n,{level:c,size:u})||!a?n:(t.includeFallbackColors=!1,Nr.mostReadable(i,["#fff","#000"],t))};var Ew=Nr.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},RO=Nr.hexNames=NO(Ew);function NO(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function sA(i){return i=parseFloat(i),(isNaN(i)||i<0||i>1)&&(i=1),i}function sa(i,e){PO(i)&&(i="100%");var t=IO(i);return i=Math.min(e,Math.max(0,parseFloat(i))),t&&(i=parseInt(i*e,10)/100),Math.abs(i-e)<1e-6?1:i%e/parseFloat(e)}function m_(i){return Math.min(1,Math.max(0,i))}function Xc(i){return parseInt(i,16)}function PO(i){return typeof i=="string"&&i.indexOf(".")!=-1&&parseFloat(i)===1}function IO(i){return typeof i=="string"&&i.indexOf("%")!=-1}function ih(i){return i.length==1?"0"+i:""+i}function jy(i){return i<=1&&(i=i*100+"%"),i}function oA(i){return Math.round(parseFloat(i)*255).toString(16)}function aA(i){return Xc(i)/255}var rh=function(){var i="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",t="(?:"+e+")|(?:"+i+")",n="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",s="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?";return{CSS_UNIT:new RegExp(t),rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+s),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+s),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+s),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function Dd(i){return!!rh.CSS_UNIT.exec(i)}function LO(i){i=i.replace(hO,"").replace(dO,"").toLowerCase();var e=!1;if(Ew[i])i=Ew[i],e=!0;else if(i=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var t;return(t=rh.rgb.exec(i))?{r:t[1],g:t[2],b:t[3]}:(t=rh.rgba.exec(i))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=rh.hsl.exec(i))?{h:t[1],s:t[2],l:t[3]}:(t=rh.hsla.exec(i))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=rh.hsv.exec(i))?{h:t[1],s:t[2],v:t[3]}:(t=rh.hsva.exec(i))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=rh.hex8.exec(i))?{r:Xc(t[1]),g:Xc(t[2]),b:Xc(t[3]),a:aA(t[4]),format:e?"name":"hex8"}:(t=rh.hex6.exec(i))?{r:Xc(t[1]),g:Xc(t[2]),b:Xc(t[3]),format:e?"name":"hex"}:(t=rh.hex4.exec(i))?{r:Xc(t[1]+""+t[1]),g:Xc(t[2]+""+t[2]),b:Xc(t[3]+""+t[3]),a:aA(t[4]+""+t[4]),format:e?"name":"hex8"}:(t=rh.hex3.exec(i))?{r:Xc(t[1]+""+t[1]),g:Xc(t[2]+""+t[2]),b:Xc(t[3]+""+t[3]),format:e?"name":"hex"}:!1}function DO(i){var e,t;return i=i||{level:"AA",size:"small"},e=(i.level||"AA").toUpperCase(),t=(i.size||"small").toLowerCase(),e!=="AA"&&e!=="AAA"&&(e="AA"),t!=="small"&&t!=="large"&&(t="small"),{level:e,size:t}}function Aw(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function OO(i){if(Array.isArray(i))return i}function FO(i){if(Array.isArray(i))return Aw(i)}function lA(i,e,t){if(typeof i=="function"?i===e:i.has(e))return arguments.length<3?e:t;throw new TypeError("Private element is not present on this object")}function BO(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function cA(i,e,t){return e=kg(e),$O(i,Nw()?Reflect.construct(e,t||[],kg(i).constructor):e.apply(i,t))}function UO(i,e){if(e.has(i))throw new TypeError("Cannot initialize the same private elements twice on an object")}function uA(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function Cw(i,e){return i.get(lA(i,e))}function hA(i,e,t){UO(i,e),e.set(i,t)}function dA(i,e,t){return i.set(lA(i,e),t),t}function fA(i,e,t){if(Nw())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var s=new(i.bind.apply(i,n));return s}function kO(i,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(i,yA(n.key),n)}}function pA(i,e,t){return e&&kO(i.prototype,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function g_(i,e,t){return(e=yA(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Rw(){return Rw=typeof Reflect!="undefined"&&Reflect.get?Reflect.get.bind():function(i,e,t){var n=jO(i,e);if(n){var s=Object.getOwnPropertyDescriptor(n,e);return s.get?s.get.call(arguments.length<3?i:t):s.value}},Rw.apply(null,arguments)}function kg(i){return kg=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},kg(i)}function mA(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),e&&Pw(i,e)}function Nw(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Nw=function(){return!!i})()}function zO(i){if(typeof Symbol!="undefined"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function VO(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,s,o,a,c=[],u=!0,d=!1;try{if(o=(t=t.call(i)).next,e!==0)for(;!(u=(n=o.call(t)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(p){d=!0,s=p}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(d)throw s}}return c}}function GO(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function WO(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function gA(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,n)}return t}function HO(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?gA(Object(t),!0).forEach(function(n){g_(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):gA(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function $O(i,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return BO(i)}function Pw(i,e){return Pw=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},Pw(i,e)}function Xy(i,e){return OO(i)||VO(i,e)||vA(i,e)||GO()}function jO(i,e){for(;!{}.hasOwnProperty.call(i,e)&&(i=kg(i))!==null;);return i}function Iw(i,e,t,n){var s=Rw(kg(i.prototype),e,t);return typeof s=="function"?function(o){return s.apply(t,o)}:s}function sh(i){return FO(i)||zO(i)||vA(i)||WO()}function XO(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function yA(i){var e=XO(i,"string");return typeof e=="symbol"?e:e+""}function Lw(i){"@babel/helpers - typeof";return Lw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Lw(i)}function vA(i,e){if(i){if(typeof i=="string")return Aw(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Aw(i,e):void 0}}var xA=function(e){e instanceof Array?e.forEach(xA):(e.map&&e.map.dispose(),e.dispose())},_A=function(e){e.geometry&&e.geometry.dispose(),e.material&&xA(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(_A)},Dw=function(e){for(;e.children.length;){var t=e.children[0];e.remove(t),_A(t)}},Ow=new WeakMap,y_=new WeakMap,qy=function(i){function e(t){var n,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=s.dataBindAttr,a=o===void 0?"__data":o,c=s.objBindAttr,u=c===void 0?"__threeObj":c;return uA(this,e),n=cA(this,e),g_(n,"scene",void 0),hA(n,Ow,void 0),hA(n,y_,void 0),n.scene=t,dA(Ow,n,a),dA(y_,n,u),n.onRemoveObj(function(){}),n}return mA(e,i),pA(e,[{key:"onCreateObj",value:function(n){var s=this;return Iw(e,"onCreateObj",this)([function(o){var a=n(o);return o[Cw(y_,s)]=a,a[Cw(Ow,s)]=o,s.scene.add(a),a}]),this}},{key:"onRemoveObj",value:function(n){var s=this;return Iw(e,"onRemoveObj",this)([function(o,a){var c=Iw(e,"getData",s)([o]);n(o,a),s.scene.remove(o),Dw(o),delete c[Cw(y_,s)]}]),this}}])}(aO),Yy=function(e){return isNaN(e)?parseInt(Nr(e).toHex(),16):e},Fw=function(e){return isNaN(e)?Nr(e).getAlpha():1},qO=QE(uO);function bA(i,e,t){!e||typeof t!="string"||i.filter(function(n){return!n[t]}).forEach(function(n){n[t]=qO(e(n))})}function YO(i,e){var t=i.nodes,n=i.links,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=s.nodeFilter,a=o===void 0?function(){return!0}:o,c=s.onLoopError,u=c===void 0?function(M){throw"Invalid DAG structure! Found cycle in node path: ".concat(M.join(" -> "),".")}:c,d={};t.forEach(function(M){return d[e(M)]={data:M,out:[],depth:-1,skip:!a(M)}}),n.forEach(function(M){var T=M.source,G=M.target,z=re(T),I=re(G);if(!d.hasOwnProperty(z))throw"Missing source node with id: ".concat(z);if(!d.hasOwnProperty(I))throw"Missing target node with id: ".concat(I);var J=d[z],K=d[I];J.out.push(K);function re(ve){return Lw(ve)==="object"?e(ve):ve}});var p=[];y(Object.values(d));var m=Object.assign.apply(Object,[{}].concat(sh(Object.entries(d).filter(function(M){var T=Xy(M,2),G=T[1];return!G.skip}).map(function(M){var T=Xy(M,2),G=T[0],z=T[1];return g_({},G,z.depth)}))));return m;function y(M){for(var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,z=function(){var re=M[I];if(T.indexOf(re)!==-1){var ve=[].concat(sh(T.slice(T.indexOf(re))),[re]).map(function(me){return e(me.data)});return p.some(function(me){return me.length===ve.length&&me.every(function(Le,Ve){return Le===ve[Ve]})})||(p.push(ve),u(ve)),1}G>re.depth&&(re.depth=G,y(re.out,[].concat(sh(T),[re]),G+(re.skip?0:1)))},I=0,J=M.length;I<J;I++)z()}}var Kr=window.THREE?window.THREE:{Group:dl,Mesh:Ks,MeshLambertMaterial:my,Color:jn,BufferGeometry:xr,BufferAttribute:es,Matrix4:Ft,Vector3:it,SphereGeometry:Yu,CylinderGeometry:Cp,TubeGeometry:Af,ConeGeometry:Rp,Line:Sh,LineBasicMaterial:nl,QuadraticBezierCurve3:xd,CubicBezierCurve3:Ax,Box3:fa},wA={graph:vw,forcelayout:Z3},ZO=2,Bw=new Kr.BufferGeometry().setAttribute?"setAttribute":"addAttribute",v_=new Kr.BufferGeometry().applyMatrix4?"applyMatrix4":"applyMatrix",KO=d_({props:{jsonUrl:{onChange:function(e,t){var n=this;e&&!t.fetchingJson&&(t.fetchingJson=!0,t.onLoading(),fetch(e).then(function(s){return s.json()}).then(function(s){t.fetchingJson=!1,t.onFinishLoading(s),n.graphData(s)}))},triggerUpdate:!1},graphData:{default:{nodes:[],links:[]},onChange:function(e,t){t.engineRunning=!1}},numDimensions:{default:3,onChange:function(e,t){var n=t.d3ForceLayout.force("charge");n&&n.strength(e>2?-60:-30),e<3&&s(t.graphData.nodes,"z"),e<2&&s(t.graphData.nodes,"y");function s(o,a){o.forEach(function(c){delete c[a],delete c["v".concat(a)]})}}},dagMode:{onChange:function(e,t){!e&&t.forceEngine==="d3"&&(t.graphData.nodes||[]).forEach(function(n){return n.fx=n.fy=n.fz=void 0})}},dagLevelDistance:{},dagNodeFilter:{default:function(e){return!0}},onDagError:{triggerUpdate:!1},nodeRelSize:{default:4},nodeId:{default:"id"},nodeVal:{default:"val"},nodeResolution:{default:8},nodeColor:{default:"color"},nodeAutoColorBy:{},nodeOpacity:{default:.75},nodeVisibility:{default:!0},nodeThreeObject:{},nodeThreeObjectExtend:{default:!1},nodePositionUpdate:{triggerUpdate:!1},linkSource:{default:"source"},linkTarget:{default:"target"},linkVisibility:{default:!0},linkColor:{default:"color"},linkAutoColorBy:{},linkOpacity:{default:.2},linkWidth:{},linkResolution:{default:6},linkCurvature:{default:0,triggerUpdate:!1},linkCurveRotation:{default:0,triggerUpdate:!1},linkMaterial:{},linkThreeObject:{},linkThreeObjectExtend:{default:!1},linkPositionUpdate:{triggerUpdate:!1},linkDirectionalArrowLength:{default:0},linkDirectionalArrowColor:{},linkDirectionalArrowRelPos:{default:.5,triggerUpdate:!1},linkDirectionalArrowResolution:{default:8},linkDirectionalParticles:{default:0},linkDirectionalParticleSpeed:{default:.01,triggerUpdate:!1},linkDirectionalParticleOffset:{default:0,triggerUpdate:!1},linkDirectionalParticleWidth:{default:.5},linkDirectionalParticleColor:{},linkDirectionalParticleResolution:{default:4},linkDirectionalParticleThreeObject:{},forceEngine:{default:"d3"},d3AlphaMin:{default:0},d3AlphaDecay:{default:.0228,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.alphaDecay(e)}},d3AlphaTarget:{default:0,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.alphaTarget(e)}},d3VelocityDecay:{default:.4,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.velocityDecay(e)}},ngraphPhysics:{default:{timeStep:20,gravity:-1.2,theta:.8,springLength:30,springCoefficient:8e-4,dragCoefficient:.02}},warmupTicks:{default:0,triggerUpdate:!1},cooldownTicks:{default:1/0,triggerUpdate:!1},cooldownTime:{default:15e3,triggerUpdate:!1},onLoading:{default:function(){},triggerUpdate:!1},onFinishLoading:{default:function(){},triggerUpdate:!1},onUpdate:{default:function(){},triggerUpdate:!1},onFinishUpdate:{default:function(){},triggerUpdate:!1},onEngineTick:{default:function(){},triggerUpdate:!1},onEngineStop:{default:function(){},triggerUpdate:!1}},methods:{refresh:function(e){return e._flushObjects=!0,e._rerender(),this},d3Force:function(e,t,n){return n===void 0?e.d3ForceLayout.force(t):(e.d3ForceLayout.force(t,n),this)},d3ReheatSimulation:function(e){return e.d3ForceLayout.alpha(1),this.resetCountdown(),this},resetCountdown:function(e){return e.cntTicks=0,e.startTickTime=new Date,e.engineRunning=!0,this},tickFrame:function(e){var t=e.forceEngine!=="ngraph";return e.engineRunning&&n(),s(),o(),this;function n(){++e.cntTicks>e.cooldownTicks||new Date-e.startTickTime>e.cooldownTime||t&&e.d3AlphaMin>0&&e.d3ForceLayout.alpha()<e.d3AlphaMin?(e.engineRunning=!1,e.onEngineStop()):(e.layout[t?"tick":"step"](),e.onEngineTick());var a=ks(e.nodeThreeObjectExtend);e.nodeDataMapper.entries().forEach(function(y){var M=Xy(y,2),T=M[0],G=M[1];if(G){var z=t?T:e.layout.getNodePosition(T[e.nodeId]),I=a(T);(!e.nodePositionUpdate||!e.nodePositionUpdate(I?G.children[0]:G,{x:z.x,y:z.y,z:z.z},T)||I)&&(G.position.x=z.x,G.position.y=z.y||0,G.position.z=z.z||0)}});var c=ks(e.linkWidth),u=ks(e.linkCurvature),d=ks(e.linkCurveRotation),p=ks(e.linkThreeObjectExtend);e.linkDataMapper.entries().forEach(function(y){var M=Xy(y,2),T=M[0],G=M[1];if(G){var z=t?T:e.layout.getLinkPosition(e.layout.graph.getLink(T.source,T.target).id),I=z[t?"source":"from"],J=z[t?"target":"to"];if(!(!I||!J||!I.hasOwnProperty("x")||!J.hasOwnProperty("x"))){m(T);var K=p(T);if(!(e.linkPositionUpdate&&e.linkPositionUpdate(K?G.children[1]:G,{start:{x:I.x,y:I.y,z:I.z},end:{x:J.x,y:J.y,z:J.z}},T)&&!K)){var re=30,ve=T.__curve,me=G.children.length?G.children[0]:G;if(me.type==="Line"){if(ve){var Ve=ve.getPoints(re);me.geometry.getAttribute("position").array.length!==Ve.length*3&&me.geometry[Bw]("position",new Kr.BufferAttribute(new Float32Array(Ve.length*3),3)),me.geometry.setFromPoints(Ve)}else{var Le=me.geometry.getAttribute("position");(!Le||!Le.array||Le.array.length!==6)&&me.geometry[Bw]("position",Le=new Kr.BufferAttribute(new Float32Array(2*3),3)),Le.array[0]=I.x,Le.array[1]=I.y||0,Le.array[2]=I.z||0,Le.array[3]=J.x,Le.array[4]=J.y||0,Le.array[5]=J.z||0,Le.needsUpdate=!0}me.geometry.computeBoundingSphere()}else if(me.type==="Mesh")if(ve){me.geometry.type.match(/^Tube(Buffer)?Geometry$/)||(me.position.set(0,0,0),me.rotation.set(0,0,0),me.scale.set(1,1,1));var vn=Math.ceil(c(T)*10)/10,mn=vn/2,Yn=new Kr.TubeGeometry(ve,re,mn,e.linkResolution,!1);me.geometry.dispose(),me.geometry=Yn}else{if(!me.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)){var Ee=Math.ceil(c(T)*10)/10,Oe=Ee/2,dt=new Kr.CylinderGeometry(Oe,Oe,1,e.linkResolution,1,!1);dt[v_](new Kr.Matrix4().makeTranslation(0,1/2,0)),dt[v_](new Kr.Matrix4().makeRotationX(Math.PI/2)),me.geometry.dispose(),me.geometry=dt}var Ut=new Kr.Vector3(I.x,I.y||0,I.z||0),tn=new Kr.Vector3(J.x,J.y||0,J.z||0),cn=Ut.distanceTo(tn);me.position.x=Ut.x,me.position.y=Ut.y,me.position.z=Ut.z,me.scale.z=cn,me.parent.localToWorld(tn),me.lookAt(tn)}}}}});function m(y){var M=t?y:e.layout.getLinkPosition(e.layout.graph.getLink(y.source,y.target).id),T=M[t?"source":"from"],G=M[t?"target":"to"];if(!(!T||!G||!T.hasOwnProperty("x")||!G.hasOwnProperty("x"))){var z=u(y);if(!z)y.__curve=null;else{var I=new Kr.Vector3(T.x,T.y||0,T.z||0),J=new Kr.Vector3(G.x,G.y||0,G.z||0),K=I.distanceTo(J),re,ve=d(y);if(K>0){var me=G.x-T.x,Le=G.y-T.y||0,Ve=new Kr.Vector3().subVectors(J,I),Ee=Ve.clone().multiplyScalar(z).cross(me!==0||Le!==0?new Kr.Vector3(0,0,1):new Kr.Vector3(0,1,0)).applyAxisAngle(Ve.normalize(),ve).add(new Kr.Vector3().addVectors(I,J).divideScalar(2));re=new Kr.QuadraticBezierCurve3(I,Ee,J)}else{var Oe=z*70,dt=-ve,Ut=dt+Math.PI/2;re=new Kr.CubicBezierCurve3(I,new Kr.Vector3(Oe*Math.cos(Ut),Oe*Math.sin(Ut),0).add(I),new Kr.Vector3(Oe*Math.cos(dt),Oe*Math.sin(dt),0).add(I),J)}y.__curve=re}}}}function s(){var a=ks(e.linkDirectionalArrowRelPos),c=ks(e.linkDirectionalArrowLength),u=ks(e.nodeVal);e.arrowDataMapper.entries().forEach(function(d){var p=Xy(d,2),m=p[0],y=p[1];if(y){var M=t?m:e.layout.getLinkPosition(e.layout.graph.getLink(m.source,m.target).id),T=M[t?"source":"from"],G=M[t?"target":"to"];if(!(!T||!G||!T.hasOwnProperty("x")||!G.hasOwnProperty("x"))){var z=Math.cbrt(Math.max(0,u(T)||1))*e.nodeRelSize,I=Math.cbrt(Math.max(0,u(G)||1))*e.nodeRelSize,J=c(m),K=a(m),re=m.__curve?function(Oe){return m.__curve.getPoint(Oe)}:function(Oe){var dt=function(tn,cn,vn,mn){return cn[tn]+(vn[tn]-cn[tn])*mn||0};return{x:dt("x",T,G,Oe),y:dt("y",T,G,Oe),z:dt("z",T,G,Oe)}},ve=m.__curve?m.__curve.getLength():Math.sqrt(["x","y","z"].map(function(Oe){return Math.pow((G[Oe]||0)-(T[Oe]||0),2)}).reduce(function(Oe,dt){return Oe+dt},0)),me=z+J+(ve-z-I-J)*K,Le=re(me/ve),Ve=re((me-J)/ve);["x","y","z"].forEach(function(Oe){return y.position[Oe]=Ve[Oe]});var Ee=fA(Kr.Vector3,sh(["x","y","z"].map(function(Oe){return Le[Oe]})));y.parent.localToWorld(Ee),y.lookAt(Ee)}}})}function o(){var a=ks(e.linkDirectionalParticleSpeed),c=ks(e.linkDirectionalParticleOffset);e.graphData.links.forEach(function(u){var d=e.particlesDataMapper.getObj(u),p=d&&d.children,m=u.__singleHopPhotonsObj&&u.__singleHopPhotonsObj.children;if(!((!m||!m.length)&&(!p||!p.length))){var y=t?u:e.layout.getLinkPosition(e.layout.graph.getLink(u.source,u.target).id),M=y[t?"source":"from"],T=y[t?"target":"to"];if(!(!M||!T||!M.hasOwnProperty("x")||!T.hasOwnProperty("x"))){var G=a(u),z=Math.abs(c(u)),I=u.__curve?function(K){return u.__curve.getPoint(K)}:function(K){var re=function(me,Le,Ve,Ee){return Le[me]+(Ve[me]-Le[me])*Ee||0};return{x:re("x",M,T,K),y:re("y",M,T,K),z:re("z",M,T,K)}},J=[].concat(sh(p||[]),sh(m||[]));J.forEach(function(K,re){var ve=K.parent.__linkThreeObjType==="singleHopPhotons";if(K.hasOwnProperty("__progressRatio")||(K.__progressRatio=ve?0:(re+z)/p.length),K.__progressRatio+=G,K.__progressRatio>=1)if(!ve)K.__progressRatio=K.__progressRatio%1;else{K.parent.remove(K),Dw(K);return}var me=K.__progressRatio,Le=I(me);K.geometry.type!=="SphereGeometry"&&K.lookAt(Le.x,Le.y,Le.z),["x","y","z"].forEach(function(Ve){return K.position[Ve]=Le[Ve]})})}}})}},emitParticle:function(e,t){if(t&&e.graphData.links.includes(t)){if(!t.__singleHopPhotonsObj){var n=new Kr.Group;n.__linkThreeObjType="singleHopPhotons",t.__singleHopPhotonsObj=n,e.graphScene.add(n)}var s=ks(e.linkDirectionalParticleThreeObject)(t);if(s&&e.linkDirectionalParticleThreeObject===s&&(s=s.clone()),!s){var o=ks(e.linkDirectionalParticleWidth),a=Math.ceil(o(t)*10)/10/2,c=e.linkDirectionalParticleResolution,u=new Kr.SphereGeometry(a,c,c),d=ks(e.linkColor),p=ks(e.linkDirectionalParticleColor),m=p(t)||d(t)||"#f0f0f0",y=new Kr.Color(Yy(m)),M=e.linkOpacity*3,T=new Kr.MeshLambertMaterial({color:y,transparent:!0,opacity:M});s=new Kr.Mesh(u,T)}t.__singleHopPhotonsObj.add(s)}return this},getGraphBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0};if(!e.initialised)return null;var n=function s(o){var a=[];if(o.geometry){o.geometry.computeBoundingBox();var c=new Kr.Box3;c.copy(o.geometry.boundingBox).applyMatrix4(o.matrixWorld),a.push(c)}return a.concat.apply(a,sh((o.children||[]).filter(function(u){return!u.hasOwnProperty("__graphObjType")||u.__graphObjType==="node"&&t(u.__data)}).map(s)))}(e.graphScene);return n.length?Object.assign.apply(Object,sh(["x","y","z"].map(function(s){return g_({},s,[$D(n,function(o){return o.min[s]}),jD(n,function(o){return o.max[s]})])}))):null}},stateInit:function(){return{d3ForceLayout:rr().force("link",Vo()).force("charge",Ld()).force("center",sc()).force("dagRadial",null).stop(),engineRunning:!1}},init:function(e,t){t.graphScene=e,t.nodeDataMapper=new qy(e,{objBindAttr:"__threeObj"}),t.linkDataMapper=new qy(e,{objBindAttr:"__lineObj"}),t.arrowDataMapper=new qy(e,{objBindAttr:"__arrowObj"}),t.particlesDataMapper=new qy(e,{objBindAttr:"__photonsObj"})},update:function(e,t){var n=function(un){return un.some(function(Mn){return t.hasOwnProperty(Mn)})};if(e.engineRunning=!1,typeof e.onUpdate=="function"&&e.onUpdate(),e.nodeAutoColorBy!==null&&n(["nodeAutoColorBy","graphData","nodeColor"])&&bA(e.graphData.nodes,ks(e.nodeAutoColorBy),e.nodeColor),e.linkAutoColorBy!==null&&n(["linkAutoColorBy","graphData","linkColor"])&&bA(e.graphData.links,ks(e.linkAutoColorBy),e.linkColor),e._flushObjects||n(["graphData","nodeThreeObject","nodeThreeObjectExtend","nodeVal","nodeColor","nodeVisibility","nodeRelSize","nodeResolution","nodeOpacity"])){var s=ks(e.nodeThreeObject),o=ks(e.nodeThreeObjectExtend),a=ks(e.nodeVal),c=ks(e.nodeColor),u=ks(e.nodeVisibility),d={},p={};(e._flushObjects||n(["nodeThreeObject","nodeThreeObjectExtend"]))&&e.nodeDataMapper.clear(),e.nodeDataMapper.onCreateObj(function(Vn){var un=s(Vn),Mn=o(Vn);un&&e.nodeThreeObject===un&&(un=un.clone());var fi;return un&&!Mn?fi=un:(fi=new Kr.Mesh,fi.__graphDefaultObj=!0,un&&Mn&&fi.add(un)),fi.__graphObjType="node",fi}).onUpdateObj(function(Vn,un){if(Vn.__graphDefaultObj){var Mn=a(un)||1,fi=Math.cbrt(Mn)*e.nodeRelSize,ki=e.nodeResolution;(!Vn.geometry.type.match(/^Sphere(Buffer)?Geometry$/)||Vn.geometry.parameters.radius!==fi||Vn.geometry.parameters.widthSegments!==ki)&&(d.hasOwnProperty(Mn)||(d[Mn]=new Kr.SphereGeometry(fi,ki,ki)),Vn.geometry.dispose(),Vn.geometry=d[Mn]);var Ni=c(un),Cr=new Kr.Color(Yy(Ni||"#ffffaa")),Vs=e.nodeOpacity*Fw(Ni);(Vn.material.type!=="MeshLambertMaterial"||!Vn.material.color.equals(Cr)||Vn.material.opacity!==Vs)&&(p.hasOwnProperty(Ni)||(p[Ni]=new Kr.MeshLambertMaterial({color:Cr,transparent:!0,opacity:Vs})),Vn.material.dispose(),Vn.material=p[Ni])}}).digest(e.graphData.nodes.filter(u))}if(e._flushObjects||n(["graphData","linkThreeObject","linkThreeObjectExtend","linkMaterial","linkColor","linkWidth","linkVisibility","linkResolution","linkOpacity","linkDirectionalArrowLength","linkDirectionalArrowColor","linkDirectionalArrowResolution","linkDirectionalParticles","linkDirectionalParticleWidth","linkDirectionalParticleColor","linkDirectionalParticleResolution","linkDirectionalParticleThreeObject"])){var m=ks(e.linkThreeObject),y=ks(e.linkThreeObjectExtend),M=ks(e.linkMaterial),T=ks(e.linkVisibility),G=ks(e.linkColor),z=ks(e.linkWidth),I={},J={},K={},re=e.graphData.links.filter(T);if((e._flushObjects||n(["linkThreeObject","linkThreeObjectExtend","linkWidth"]))&&e.linkDataMapper.clear(),e.linkDataMapper.onRemoveObj(function(Vn){var un=Vn.__data&&Vn.__data.__singleHopPhotonsObj;un&&(un.parent.remove(un),Dw(un),delete Vn.__data.__singleHopPhotonsObj)}).onCreateObj(function(Vn){var un=m(Vn),Mn=y(Vn);un&&e.linkThreeObject===un&&(un=un.clone());var fi;if(!un||Mn){var ki=!!z(Vn);if(ki)fi=new Kr.Mesh;else{var Ni=new Kr.BufferGeometry;Ni[Bw]("position",new Kr.BufferAttribute(new Float32Array(2*3),3)),fi=new Kr.Line(Ni)}}var Cr;return un?Mn?(Cr=new Kr.Group,Cr.__graphDefaultObj=!0,Cr.add(fi),Cr.add(un)):Cr=un:(Cr=fi,Cr.__graphDefaultObj=!0),Cr.renderOrder=10,Cr.__graphObjType="link",Cr}).onUpdateObj(function(Vn,un){if(Vn.__graphDefaultObj){var Mn=Vn.children.length?Vn.children[0]:Vn,fi=Math.ceil(z(un)*10)/10,ki=!!fi;if(ki){var Ni=fi/2,Cr=e.linkResolution;if(!Mn.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)||Mn.geometry.parameters.radiusTop!==Ni||Mn.geometry.parameters.radialSegments!==Cr){if(!I.hasOwnProperty(fi)){var Vs=new Kr.CylinderGeometry(Ni,Ni,1,Cr,1,!1);Vs[v_](new Kr.Matrix4().makeTranslation(0,1/2,0)),Vs[v_](new Kr.Matrix4().makeRotationX(Math.PI/2)),I[fi]=Vs}Mn.geometry.dispose(),Mn.geometry=I[fi]}}var kt=M(un);if(kt)Mn.material=kt;else{var Kn=G(un),Zn=new Kr.Color(Yy(Kn||"#f0f0f0")),qn=e.linkOpacity*Fw(Kn),Hn=ki?"MeshLambertMaterial":"LineBasicMaterial";if(Mn.material.type!==Hn||!Mn.material.color.equals(Zn)||Mn.material.opacity!==qn){var Ti=ki?J:K;Ti.hasOwnProperty(Kn)||(Ti[Kn]=new Kr[Hn]({color:Zn,transparent:qn<1,opacity:qn,depthWrite:qn>=1})),Mn.material.dispose(),Mn.material=Ti[Kn]}}}}).digest(re),e.linkDirectionalArrowLength||t.hasOwnProperty("linkDirectionalArrowLength")){var ve=ks(e.linkDirectionalArrowLength),me=ks(e.linkDirectionalArrowColor);e.arrowDataMapper.onCreateObj(function(){var Vn=new Kr.Mesh(void 0,new Kr.MeshLambertMaterial({transparent:!0}));return Vn.__linkThreeObjType="arrow",Vn}).onUpdateObj(function(Vn,un){var Mn=ve(un),fi=e.linkDirectionalArrowResolution;if(!Vn.geometry.type.match(/^Cone(Buffer)?Geometry$/)||Vn.geometry.parameters.height!==Mn||Vn.geometry.parameters.radialSegments!==fi){var ki=new Kr.ConeGeometry(Mn*.25,Mn,fi);ki.translate(0,Mn/2,0),ki.rotateX(Math.PI/2),Vn.geometry.dispose(),Vn.geometry=ki}var Ni=me(un)||G(un)||"#f0f0f0";Vn.material.color=new Kr.Color(Yy(Ni)),Vn.material.opacity=e.linkOpacity*3*Fw(Ni)}).digest(re.filter(ve))}if(e.linkDirectionalParticles||t.hasOwnProperty("linkDirectionalParticles")){var Le=ks(e.linkDirectionalParticles),Ve=ks(e.linkDirectionalParticleWidth),Ee=ks(e.linkDirectionalParticleColor),Oe=ks(e.linkDirectionalParticleThreeObject),dt={},Ut={};e.particlesDataMapper.onCreateObj(function(){var Vn=new Kr.Group;return Vn.__linkThreeObjType="photons",Vn.__photonDataMapper=new qy(Vn),Vn}).onUpdateObj(function(Vn,un){var Mn=!!Vn.children.length&&Vn.children[0],fi=Oe(un),ki,Ni;if(fi)ki=fi.geometry,Ni=fi.material;else{var Cr=Math.ceil(Ve(un)*10)/10/2,Vs=e.linkDirectionalParticleResolution;Mn&&Mn.geometry.parameters.radius===Cr&&Mn.geometry.parameters.widthSegments===Vs?ki=Mn.geometry:(Ut.hasOwnProperty(Cr)||(Ut[Cr]=new Kr.SphereGeometry(Cr,Vs,Vs)),ki=Ut[Cr]);var kt=Ee(un)||G(un)||"#f0f0f0",Kn=new Kr.Color(Yy(kt)),Zn=e.linkOpacity*3;Mn&&Mn.material.color.equals(Kn)&&Mn.material.opacity===Zn?Ni=Mn.material:(dt.hasOwnProperty(kt)||(dt[kt]=new Kr.MeshLambertMaterial({color:Kn,transparent:!0,opacity:Zn})),Ni=dt[kt])}Mn&&(Mn.geometry!==ki&&Mn.geometry.dispose(),Mn.material!==Ni&&Mn.material.dispose());var qn=Math.round(Math.abs(Le(un)));Vn.__photonDataMapper.id(function(Hn){return Hn.idx}).onCreateObj(function(){return new Kr.Mesh(ki,Ni)}).onUpdateObj(function(Hn){Hn.geometry=ki,Hn.material=Ni}).digest(sh(new Array(qn)).map(function(Hn,Ti){return{idx:Ti}}))}).digest(re.filter(Le))}}if(e._flushObjects=!1,n(["graphData","nodeId","linkSource","linkTarget","numDimensions","forceEngine","dagMode","dagNodeFilter","dagLevelDistance"])){e.engineRunning=!1,e.graphData.links.forEach(function(Vn){Vn.source=Vn[e.linkSource],Vn.target=Vn[e.linkTarget]});var tn=e.forceEngine!=="ngraph",cn;if(tn){(cn=e.d3ForceLayout).stop().alpha(1).numDimensions(e.numDimensions).nodes(e.graphData.nodes);var vn=e.d3ForceLayout.force("link");vn&&vn.id(function(Vn){return Vn[e.nodeId]}).links(e.graphData.links);var mn=e.dagMode&&YO(e.graphData,function(Vn){return Vn[e.nodeId]},{nodeFilter:e.dagNodeFilter,onLoopError:e.onDagError||void 0}),Yn=Math.max.apply(Math,sh(Object.values(mn||[]))),xn=e.dagLevelDistance||e.graphData.nodes.length/(Yn||1)*ZO*(["radialin","radialout"].indexOf(e.dagMode)!==-1?.7:1);if(["lr","rl","td","bu","zin","zout"].includes(t.dagMode)){var si=["lr","rl"].includes(t.dagMode)?"fx":["td","bu"].includes(t.dagMode)?"fy":"fz";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(Vn){return delete Vn[si]})}if(["lr","rl","td","bu","zin","zout"].includes(e.dagMode)){var wn=["rl","td","zout"].includes(e.dagMode),Gn=function(un){return(mn[un[e.nodeId]]-Yn/2)*xn*(wn?-1:1)},Si=["lr","rl"].includes(e.dagMode)?"fx":["td","bu"].includes(e.dagMode)?"fy":"fz";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(Vn){return Vn[Si]=Gn(Vn)})}e.d3ForceLayout.force("dagRadial",["radialin","radialout"].indexOf(e.dagMode)!==-1?s_(function(Vn){var un=mn[Vn[e.nodeId]]||-1;return(e.dagMode==="radialin"?Yn-un:un)*xn}).strength(function(Vn){return e.dagNodeFilter(Vn)?1:0}):null)}else{var nr=wA.graph();e.graphData.nodes.forEach(function(Vn){nr.addNode(Vn[e.nodeId])}),e.graphData.links.forEach(function(Vn){nr.addLink(Vn.source,Vn.target)}),cn=wA.forcelayout(nr,HO({dimensions:e.numDimensions},e.ngraphPhysics)),cn.graph=nr}for(var os=0;os<e.warmupTicks&&!(tn&&e.d3AlphaMin>0&&e.d3ForceLayout.alpha()<e.d3AlphaMin);os++)cn[tn?"tick":"step"]();e.layout=cn,this.resetCountdown()}e.engineRunning=!0,e.onFinishUpdate()}});function JO(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Object,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=function(s){function o(){var a;uA(this,o);for(var c=arguments.length,u=new Array(c),d=0;d<c;d++)u[d]=arguments[d];return a=cA(this,o,[].concat(u)),a.__kapsuleInstance=fA(i,[].concat(sh(t?[a]:[]),u)),a}return mA(o,s),pA(o)}(e);return Object.keys(i()).forEach(function(s){return n.prototype[s]=function(){var o,a=(o=this.__kapsuleInstance)[s].apply(o,arguments);return a===this.__kapsuleInstance?this:a}}),n}var QO=window.THREE?window.THREE:{Group:dl},MA=JO(KO,QO.Group,!0);function SA(){let i=null,e=!1,t=null,n=null;function s(o,a){t(o,a),n=i.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(s),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(o){t=o},setContext:function(o){i=o}}}function eF(i){const e=new WeakMap;function t(c,u){const d=c.array,p=c.usage,m=d.byteLength,y=i.createBuffer();i.bindBuffer(u,y),i.bufferData(u,d,p),c.onUploadCallback();let M;if(d instanceof Float32Array)M=i.FLOAT;else if(typeof Float16Array!="undefined"&&d instanceof Float16Array)M=i.HALF_FLOAT;else if(d instanceof Uint16Array)c.isFloat16BufferAttribute?M=i.HALF_FLOAT:M=i.UNSIGNED_SHORT;else if(d instanceof Int16Array)M=i.SHORT;else if(d instanceof Uint32Array)M=i.UNSIGNED_INT;else if(d instanceof Int32Array)M=i.INT;else if(d instanceof Int8Array)M=i.BYTE;else if(d instanceof Uint8Array)M=i.UNSIGNED_BYTE;else if(d instanceof Uint8ClampedArray)M=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+d);return{buffer:y,type:M,bytesPerElement:d.BYTES_PER_ELEMENT,version:c.version,size:m}}function n(c,u,d){const p=u.array,m=u.updateRanges;if(i.bindBuffer(d,c),m.length===0)i.bufferSubData(d,0,p);else{m.sort((M,T)=>M.start-T.start);let y=0;for(let M=1;M<m.length;M++){const T=m[y],G=m[M];G.start<=T.start+T.count+1?T.count=Math.max(T.count,G.start+G.count-T.start):(++y,m[y]=G)}m.length=y+1;for(let M=0,T=m.length;M<T;M++){const G=m[M];i.bufferSubData(d,G.start*p.BYTES_PER_ELEMENT,p,G.start,G.count)}u.clearUpdateRanges()}u.onUploadCallback()}function s(c){return c.isInterleavedBufferAttribute&&(c=c.data),e.get(c)}function o(c){c.isInterleavedBufferAttribute&&(c=c.data);const u=e.get(c);u&&(i.deleteBuffer(u.buffer),e.delete(c))}function a(c,u){if(c.isInterleavedBufferAttribute&&(c=c.data),c.isGLBufferAttribute){const p=e.get(c);(!p||p.version<c.version)&&e.set(c,{buffer:c.buffer,type:c.type,bytesPerElement:c.elementSize,version:c.version});return}const d=e.get(c);if(d===void 0)e.set(c,t(c,u));else if(d.version<c.version){if(d.size!==c.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(d.buffer,c,u),d.version=c.version}}return{get:s,remove:o,update:a}}var tF=`#ifdef USE_ALPHAHASH
|
|
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
|
#endif`,nF=`#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`,iF=`#ifdef USE_ALPHAMAP
|
|
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
|
#endif`,rF=`#ifdef USE_ALPHAMAP
|
|
|
uniform sampler2D alphaMap;
|
|
|
#endif`,sF=`#ifdef USE_ALPHATEST
|
|
|
#ifdef ALPHA_TO_COVERAGE
|
|
|
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
|
|
|
if ( diffuseColor.a == 0.0 ) discard;
|
|
|
#else
|
|
|
if ( diffuseColor.a < alphaTest ) discard;
|
|
|
#endif
|
|
|
#endif`,oF=`#ifdef USE_ALPHATEST
|
|
|
uniform float alphaTest;
|
|
|
#endif`,aF=`#ifdef USE_AOMAP
|
|
|
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
|
#if defined( USE_CLEARCOAT )
|
|
|
clearcoatSpecularIndirect *= ambientOcclusion;
|
|
|
#endif
|
|
|
#if defined( USE_SHEEN )
|
|
|
sheenSpecularIndirect *= ambientOcclusion;
|
|
|
#endif
|
|
|
#if defined( USE_ENVMAP ) && defined( STANDARD )
|
|
|
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
|
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
|
#endif
|
|
|
#endif`,lF=`#ifdef USE_AOMAP
|
|
|
uniform sampler2D aoMap;
|
|
|
uniform float aoMapIntensity;
|
|
|
#endif`,cF=`#ifdef USE_BATCHING
|
|
|
#if ! defined( GL_ANGLE_multi_draw )
|
|
|
#define gl_DrawID _gl_DrawID
|
|
|
uniform int _gl_DrawID;
|
|
|
#endif
|
|
|
uniform highp sampler2D batchingTexture;
|
|
|
uniform highp usampler2D batchingIdTexture;
|
|
|
mat4 getBatchingMatrix( const in float i ) {
|
|
|
int size = textureSize( batchingTexture, 0 ).x;
|
|
|
int j = int( i ) * 4;
|
|
|
int x = j % size;
|
|
|
int y = j / size;
|
|
|
vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
|
|
|
vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
|
|
|
vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
|
|
|
vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
|
|
|
return mat4( v1, v2, v3, v4 );
|
|
|
}
|
|
|
float getIndirectIndex( const in int i ) {
|
|
|
int size = textureSize( batchingIdTexture, 0 ).x;
|
|
|
int x = i % size;
|
|
|
int y = i / size;
|
|
|
return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
|
|
|
}
|
|
|
#endif
|
|
|
#ifdef USE_BATCHING_COLOR
|
|
|
uniform sampler2D batchingColorTexture;
|
|
|
vec3 getBatchingColor( const in float i ) {
|
|
|
int size = textureSize( batchingColorTexture, 0 ).x;
|
|
|
int j = int( i );
|
|
|
int x = j % size;
|
|
|
int y = j / size;
|
|
|
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
|
|
|
}
|
|
|
#endif`,uF=`#ifdef USE_BATCHING
|
|
|
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
|
|
#endif`,hF=`vec3 transformed = vec3( position );
|
|
|
#ifdef USE_ALPHAHASH
|
|
|
vPosition = vec3( position );
|
|
|
#endif`,dF=`vec3 objectNormal = vec3( normal );
|
|
|
#ifdef USE_TANGENT
|
|
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
|
#endif`,fF=`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`,pF=`#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 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`,mF=`#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 = normalize( dFdx( surf_pos.xyz ) );
|
|
|
vec3 vSigmaY = normalize( 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`,gF=`#if NUM_CLIPPING_PLANES > 0
|
|
|
vec4 plane;
|
|
|
#ifdef ALPHA_TO_COVERAGE
|
|
|
float distanceToPlane, distanceGradient;
|
|
|
float clipOpacity = 1.0;
|
|
|
#pragma unroll_loop_start
|
|
|
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
|
|
plane = clippingPlanes[ i ];
|
|
|
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
|
|
|
distanceGradient = fwidth( distanceToPlane ) / 2.0;
|
|
|
clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
|
|
|
if ( clipOpacity == 0.0 ) discard;
|
|
|
}
|
|
|
#pragma unroll_loop_end
|
|
|
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
|
|
float unionClipOpacity = 1.0;
|
|
|
#pragma unroll_loop_start
|
|
|
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
|
|
plane = clippingPlanes[ i ];
|
|
|
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
|
|
|
distanceGradient = fwidth( distanceToPlane ) / 2.0;
|
|
|
unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
|
|
|
}
|
|
|
#pragma unroll_loop_end
|
|
|
clipOpacity *= 1.0 - unionClipOpacity;
|
|
|
#endif
|
|
|
diffuseColor.a *= clipOpacity;
|
|
|
if ( diffuseColor.a == 0.0 ) discard;
|
|
|
#else
|
|
|
#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
|
|
|
#endif`,yF=`#if NUM_CLIPPING_PLANES > 0
|
|
|
varying vec3 vClipPosition;
|
|
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
|
#endif`,vF=`#if NUM_CLIPPING_PLANES > 0
|
|
|
varying vec3 vClipPosition;
|
|
|
#endif`,xF=`#if NUM_CLIPPING_PLANES > 0
|
|
|
vClipPosition = - mvPosition.xyz;
|
|
|
#endif`,_F=`#if defined( USE_COLOR_ALPHA )
|
|
|
diffuseColor *= vColor;
|
|
|
#elif defined( USE_COLOR )
|
|
|
diffuseColor.rgb *= vColor;
|
|
|
#endif`,bF=`#if defined( USE_COLOR_ALPHA )
|
|
|
varying vec4 vColor;
|
|
|
#elif defined( USE_COLOR )
|
|
|
varying vec3 vColor;
|
|
|
#endif`,wF=`#if defined( USE_COLOR_ALPHA )
|
|
|
varying vec4 vColor;
|
|
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
|
varying vec3 vColor;
|
|
|
#endif`,MF=`#if defined( USE_COLOR_ALPHA )
|
|
|
vColor = vec4( 1.0 );
|
|
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
|
vColor = vec3( 1.0 );
|
|
|
#endif
|
|
|
#ifdef USE_COLOR
|
|
|
vColor *= color;
|
|
|
#endif
|
|
|
#ifdef USE_INSTANCING_COLOR
|
|
|
vColor.xyz *= instanceColor.xyz;
|
|
|
#endif
|
|
|
#ifdef USE_BATCHING_COLOR
|
|
|
vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
|
|
|
vColor.xyz *= batchingColor.xyz;
|
|
|
#endif`,SF=`#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;
|
|
|
};
|
|
|
#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;
|
|
|
}
|
|
|
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`,TF=`#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_m0 - 2.0
|
|
|
#define cubeUV_r1 0.8
|
|
|
#define cubeUV_m1 - 1.0
|
|
|
#define cubeUV_r4 0.4
|
|
|
#define cubeUV_m4 2.0
|
|
|
#define cubeUV_r5 0.305
|
|
|
#define cubeUV_m5 3.0
|
|
|
#define cubeUV_r6 0.21
|
|
|
#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`,EF=`vec3 transformedNormal = objectNormal;
|
|
|
#ifdef USE_TANGENT
|
|
|
vec3 transformedTangent = objectTangent;
|
|
|
#endif
|
|
|
#ifdef USE_BATCHING
|
|
|
mat3 bm = mat3( batchingMatrix );
|
|
|
transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
|
|
|
transformedNormal = bm * transformedNormal;
|
|
|
#ifdef USE_TANGENT
|
|
|
transformedTangent = bm * transformedTangent;
|
|
|
#endif
|
|
|
#endif
|
|
|
#ifdef USE_INSTANCING
|
|
|
mat3 im = mat3( instanceMatrix );
|
|
|
transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
|
|
|
transformedNormal = im * transformedNormal;
|
|
|
#ifdef USE_TANGENT
|
|
|
transformedTangent = im * transformedTangent;
|
|
|
#endif
|
|
|
#endif
|
|
|
transformedNormal = normalMatrix * transformedNormal;
|
|
|
#ifdef FLIP_SIDED
|
|
|
transformedNormal = - transformedNormal;
|
|
|
#endif
|
|
|
#ifdef USE_TANGENT
|
|
|
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
|
|
#ifdef FLIP_SIDED
|
|
|
transformedTangent = - transformedTangent;
|
|
|
#endif
|
|
|
#endif`,AF=`#ifdef USE_DISPLACEMENTMAP
|
|
|
uniform sampler2D displacementMap;
|
|
|
uniform float displacementScale;
|
|
|
uniform float displacementBias;
|
|
|
#endif`,CF=`#ifdef USE_DISPLACEMENTMAP
|
|
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
|
#endif`,RF=`#ifdef USE_EMISSIVEMAP
|
|
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
|
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
|
|
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
|
|
#endif
|
|
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
|
#endif`,NF=`#ifdef USE_EMISSIVEMAP
|
|
|
uniform sampler2D emissiveMap;
|
|
|
#endif`,PF="gl_FragColor = linearToOutputTexel( gl_FragColor );",IF=`vec4 LinearTransferOETF( in vec4 value ) {
|
|
|
return value;
|
|
|
}
|
|
|
vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
|
return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
|
|
|
}
|
|
|
vec4 sRGBTransferOETF( 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 );
|
|
|
}`,LF=`#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, envMapRotation * 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`,DF=`#ifdef USE_ENVMAP
|
|
|
uniform float envMapIntensity;
|
|
|
uniform float flipEnvMap;
|
|
|
uniform mat3 envMapRotation;
|
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|
|
uniform samplerCube envMap;
|
|
|
#else
|
|
|
uniform sampler2D envMap;
|
|
|
#endif
|
|
|
|
|
|
#endif`,OF=`#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`,FF=`#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`,BF=`#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`,UF=`#ifdef USE_FOG
|
|
|
vFogDepth = - mvPosition.z;
|
|
|
#endif`,kF=`#ifdef USE_FOG
|
|
|
varying float vFogDepth;
|
|
|
#endif`,zF=`#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`,VF=`#ifdef USE_FOG
|
|
|
uniform vec3 fogColor;
|
|
|
varying float vFogDepth;
|
|
|
#ifdef FOG_EXP2
|
|
|
uniform float fogDensity;
|
|
|
#else
|
|
|
uniform float fogNear;
|
|
|
uniform float fogFar;
|
|
|
#endif
|
|
|
#endif`,GF=`#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
|
|
|
}`,WF=`#ifdef USE_LIGHTMAP
|
|
|
uniform sampler2D lightMap;
|
|
|
uniform float lightMapIntensity;
|
|
|
#endif`,HF=`LambertMaterial material;
|
|
|
material.diffuseColor = diffuseColor.rgb;
|
|
|
material.specularStrength = specularStrength;`,$F=`varying vec3 vViewPosition;
|
|
|
struct LambertMaterial {
|
|
|
vec3 diffuseColor;
|
|
|
float specularStrength;
|
|
|
};
|
|
|
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
|
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
|
}
|
|
|
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, 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`,jF=`uniform bool receiveShadow;
|
|
|
uniform vec3 ambientLightColor;
|
|
|
#if defined( USE_LIGHT_PROBES )
|
|
|
uniform vec3 lightProbe[ 9 ];
|
|
|
#endif
|
|
|
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 ) {
|
|
|
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
|
|
|
if ( cutoffDistance > 0.0 ) {
|
|
|
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
|
|
|
}
|
|
|
return distanceFalloff;
|
|
|
}
|
|
|
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, 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 vec3 geometryPosition, out IncidentLight light ) {
|
|
|
vec3 lVector = pointLight.position - geometryPosition;
|
|
|
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 vec3 geometryPosition, out IncidentLight light ) {
|
|
|
vec3 lVector = spotLight.position - geometryPosition;
|
|
|
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`,XF=`#ifdef USE_ENVMAP
|
|
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
|
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * 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, envMapRotation * 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`,qF=`ToonMaterial material;
|
|
|
material.diffuseColor = diffuseColor.rgb;`,YF=`varying vec3 vViewPosition;
|
|
|
struct ToonMaterial {
|
|
|
vec3 diffuseColor;
|
|
|
};
|
|
|
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
|
|
vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
|
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
|
}
|
|
|
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, 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`,ZF=`BlinnPhongMaterial material;
|
|
|
material.diffuseColor = diffuseColor.rgb;
|
|
|
material.specularColor = specular;
|
|
|
material.specularShininess = shininess;
|
|
|
material.specularStrength = specularStrength;`,KF=`varying vec3 vViewPosition;
|
|
|
struct BlinnPhongMaterial {
|
|
|
vec3 diffuseColor;
|
|
|
vec3 specularColor;
|
|
|
float specularShininess;
|
|
|
float specularStrength;
|
|
|
};
|
|
|
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
|
|
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
|
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
|
|
|
}
|
|
|
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, 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`,JF=`PhysicalMaterial material;
|
|
|
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
|
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
|
|
|
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_DISPERSION
|
|
|
material.dispersion = dispersion;
|
|
|
#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 );
|
|
|
if( material.anisotropy == 0.0 ) {
|
|
|
anisotropyV = vec2( 1.0, 0.0 );
|
|
|
} else {
|
|
|
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`,QF=`struct PhysicalMaterial {
|
|
|
vec3 diffuseColor;
|
|
|
float roughness;
|
|
|
vec3 specularColor;
|
|
|
float specularF90;
|
|
|
float dispersion;
|
|
|
#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 clearcoatSpecularDirect = vec3( 0.0 );
|
|
|
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
|
|
|
vec3 sheenSpecularDirect = vec3( 0.0 );
|
|
|
vec3 sheenSpecularIndirect = 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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
|
vec3 normal = geometryNormal;
|
|
|
vec3 viewDir = geometryViewDir;
|
|
|
vec3 position = geometryPosition;
|
|
|
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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
|
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
|
#ifdef USE_CLEARCOAT
|
|
|
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
|
|
|
vec3 ccIrradiance = dotNLcc * directLight.color;
|
|
|
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
|
|
|
#endif
|
|
|
#ifdef USE_SHEEN
|
|
|
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
|
|
|
#endif
|
|
|
reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
|
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
|
}
|
|
|
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, 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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
|
|
|
#ifdef USE_CLEARCOAT
|
|
|
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
|
|
#endif
|
|
|
#ifdef USE_SHEEN
|
|
|
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
|
|
#endif
|
|
|
vec3 singleScattering = vec3( 0.0 );
|
|
|
vec3 multiScattering = vec3( 0.0 );
|
|
|
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
|
|
#ifdef USE_IRIDESCENCE
|
|
|
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
|
|
|
#else
|
|
|
computeMultiscattering( geometryNormal, geometryViewDir, 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 );
|
|
|
}`,eB=`
|
|
|
vec3 geometryPosition = - vViewPosition;
|
|
|
vec3 geometryNormal = normal;
|
|
|
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
|
vec3 geometryClearcoatNormal = vec3( 0.0 );
|
|
|
#ifdef USE_CLEARCOAT
|
|
|
geometryClearcoatNormal = clearcoatNormal;
|
|
|
#endif
|
|
|
#ifdef USE_IRIDESCENCE
|
|
|
float dotNVi = saturate( dot( normal, geometryViewDir ) );
|
|
|
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, geometryPosition, 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.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
|
|
|
#endif
|
|
|
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, 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, geometryPosition, 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.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
|
#endif
|
|
|
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, 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, 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.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
|
#endif
|
|
|
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, 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, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
|
}
|
|
|
#pragma unroll_loop_end
|
|
|
#endif
|
|
|
#if defined( RE_IndirectDiffuse )
|
|
|
vec3 iblIrradiance = vec3( 0.0 );
|
|
|
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
|
|
|
#if defined( USE_LIGHT_PROBES )
|
|
|
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
|
|
|
#endif
|
|
|
#if ( NUM_HEMI_LIGHTS > 0 )
|
|
|
#pragma unroll_loop_start
|
|
|
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
|
|
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
|
|
|
}
|
|
|
#pragma unroll_loop_end
|
|
|
#endif
|
|
|
#endif
|
|
|
#if defined( RE_IndirectSpecular )
|
|
|
vec3 radiance = vec3( 0.0 );
|
|
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
|
#endif`,tB=`#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( geometryNormal );
|
|
|
#endif
|
|
|
#endif
|
|
|
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
|
|
|
#ifdef USE_ANISOTROPY
|
|
|
radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
|
|
|
#else
|
|
|
radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
|
|
|
#endif
|
|
|
#ifdef USE_CLEARCOAT
|
|
|
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|
|
#endif
|
|
|
#endif`,nB=`#if defined( RE_IndirectDiffuse )
|
|
|
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
|
#endif
|
|
|
#if defined( RE_IndirectSpecular )
|
|
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
|
#endif`,iB=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
|
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
|
#endif`,rB=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
|
uniform float logDepthBufFC;
|
|
|
varying float vFragDepth;
|
|
|
varying float vIsPerspective;
|
|
|
#endif`,sB=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
|
varying float vFragDepth;
|
|
|
varying float vIsPerspective;
|
|
|
#endif`,oB=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
|
vFragDepth = 1.0 + gl_Position.w;
|
|
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
|
#endif`,aB=`#ifdef USE_MAP
|
|
|
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
|
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
|
|
#endif
|
|
|
diffuseColor *= sampledDiffuseColor;
|
|
|
#endif`,lB=`#ifdef USE_MAP
|
|
|
uniform sampler2D map;
|
|
|
#endif`,cB=`#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`,uB=`#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`,hB=`float metalnessFactor = metalness;
|
|
|
#ifdef USE_METALNESSMAP
|
|
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
|
metalnessFactor *= texelMetalness.b;
|
|
|
#endif`,dB=`#ifdef USE_METALNESSMAP
|
|
|
uniform sampler2D metalnessMap;
|
|
|
#endif`,fB=`#ifdef USE_INSTANCING_MORPH
|
|
|
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
|
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
|
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
|
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
|
|
|
}
|
|
|
#endif`,pB=`#if defined( USE_MORPHCOLORS )
|
|
|
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`,mB=`#ifdef USE_MORPHNORMALS
|
|
|
objectNormal *= morphTargetBaseInfluence;
|
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
|
}
|
|
|
#endif`,gB=`#ifdef USE_MORPHTARGETS
|
|
|
#ifndef USE_INSTANCING_MORPH
|
|
|
uniform float morphTargetBaseInfluence;
|
|
|
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
|
#endif
|
|
|
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 );
|
|
|
}
|
|
|
#endif`,yB=`#ifdef USE_MORPHTARGETS
|
|
|
transformed *= morphTargetBaseInfluence;
|
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
|
}
|
|
|
#endif`,vB=`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 nonPerturbedNormal = normal;`,xB=`#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`,_B=`#ifndef FLAT_SHADED
|
|
|
varying vec3 vNormal;
|
|
|
#ifdef USE_TANGENT
|
|
|
varying vec3 vTangent;
|
|
|
varying vec3 vBitangent;
|
|
|
#endif
|
|
|
#endif`,bB=`#ifndef FLAT_SHADED
|
|
|
varying vec3 vNormal;
|
|
|
#ifdef USE_TANGENT
|
|
|
varying vec3 vTangent;
|
|
|
varying vec3 vBitangent;
|
|
|
#endif
|
|
|
#endif`,wB=`#ifndef FLAT_SHADED
|
|
|
vNormal = normalize( transformedNormal );
|
|
|
#ifdef USE_TANGENT
|
|
|
vTangent = normalize( transformedTangent );
|
|
|
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
|
|
#endif
|
|
|
#endif`,MB=`#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`,SB=`#ifdef USE_CLEARCOAT
|
|
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
|
#endif`,TB=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
|
#endif`,EB=`#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`,AB=`#ifdef USE_IRIDESCENCEMAP
|
|
|
uniform sampler2D iridescenceMap;
|
|
|
#endif
|
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
|
uniform sampler2D iridescenceThicknessMap;
|
|
|
#endif`,CB=`#ifdef OPAQUE
|
|
|
diffuseColor.a = 1.0;
|
|
|
#endif
|
|
|
#ifdef USE_TRANSMISSION
|
|
|
diffuseColor.a *= material.transmissionAlpha;
|
|
|
#endif
|
|
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,RB=`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 float ShiftRight8 = 1. / 256.;
|
|
|
const float Inv255 = 1. / 255.;
|
|
|
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
|
|
|
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
|
|
|
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
|
|
|
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
|
|
|
vec4 packDepthToRGBA( const in float v ) {
|
|
|
if( v <= 0.0 )
|
|
|
return vec4( 0., 0., 0., 0. );
|
|
|
if( v >= 1.0 )
|
|
|
return vec4( 1., 1., 1., 1. );
|
|
|
float vuf;
|
|
|
float af = modf( v * PackFactors.a, vuf );
|
|
|
float bf = modf( vuf * ShiftRight8, vuf );
|
|
|
float gf = modf( vuf * ShiftRight8, vuf );
|
|
|
return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
|
|
|
}
|
|
|
vec3 packDepthToRGB( const in float v ) {
|
|
|
if( v <= 0.0 )
|
|
|
return vec3( 0., 0., 0. );
|
|
|
if( v >= 1.0 )
|
|
|
return vec3( 1., 1., 1. );
|
|
|
float vuf;
|
|
|
float bf = modf( v * PackFactors.b, vuf );
|
|
|
float gf = modf( vuf * ShiftRight8, vuf );
|
|
|
return vec3( vuf * Inv255, gf * PackUpscale, bf );
|
|
|
}
|
|
|
vec2 packDepthToRG( const in float v ) {
|
|
|
if( v <= 0.0 )
|
|
|
return vec2( 0., 0. );
|
|
|
if( v >= 1.0 )
|
|
|
return vec2( 1., 1. );
|
|
|
float vuf;
|
|
|
float gf = modf( v * 256., vuf );
|
|
|
return vec2( vuf * Inv255, gf );
|
|
|
}
|
|
|
float unpackRGBAToDepth( const in vec4 v ) {
|
|
|
return dot( v, UnpackFactors4 );
|
|
|
}
|
|
|
float unpackRGBToDepth( const in vec3 v ) {
|
|
|
return dot( v, UnpackFactors3 );
|
|
|
}
|
|
|
float unpackRGToDepth( const in vec2 v ) {
|
|
|
return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
|
|
|
}
|
|
|
vec4 pack2HalfToRGBA( const in 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( const in 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 );
|
|
|
}`,NB=`#ifdef PREMULTIPLIED_ALPHA
|
|
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
|
#endif`,PB=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
|
#ifdef USE_BATCHING
|
|
|
mvPosition = batchingMatrix * mvPosition;
|
|
|
#endif
|
|
|
#ifdef USE_INSTANCING
|
|
|
mvPosition = instanceMatrix * mvPosition;
|
|
|
#endif
|
|
|
mvPosition = modelViewMatrix * mvPosition;
|
|
|
gl_Position = projectionMatrix * mvPosition;`,IB=`#ifdef DITHERING
|
|
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
|
#endif`,LB=`#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`,DB=`float roughnessFactor = roughness;
|
|
|
#ifdef USE_ROUGHNESSMAP
|
|
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
|
roughnessFactor *= texelRoughness.g;
|
|
|
#endif`,OB=`#ifdef USE_ROUGHNESSMAP
|
|
|
uniform sampler2D roughnessMap;
|
|
|
#endif`,FB=`#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 shadowIntensity;
|
|
|
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 shadowIntensity;
|
|
|
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 shadowIntensity;
|
|
|
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 ) {
|
|
|
float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
|
|
|
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
|
return step( depth, compare );
|
|
|
#else
|
|
|
return step( compare, depth );
|
|
|
#endif
|
|
|
}
|
|
|
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 );
|
|
|
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
|
float hard_shadow = step( distribution.x, compare );
|
|
|
#else
|
|
|
float hard_shadow = step( compare, distribution.x );
|
|
|
#endif
|
|
|
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 shadowIntensity, 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 mix( 1.0, shadow, shadowIntensity );
|
|
|
}
|
|
|
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 shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
|
|
float shadow = 1.0;
|
|
|
vec3 lightToPosition = shadowCoord.xyz;
|
|
|
|
|
|
float lightToPositionLength = length( lightToPosition );
|
|
|
if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
|
|
|
float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
|
|
|
vec3 bd3D = normalize( lightToPosition );
|
|
|
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
|
|
|
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
|
|
|
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
|
|
|
shadow = (
|
|
|
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
|
|
|
shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
|
|
|
#endif
|
|
|
}
|
|
|
return mix( 1.0, shadow, shadowIntensity );
|
|
|
}
|
|
|
#endif`,BB=`#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 shadowIntensity;
|
|
|
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 shadowIntensity;
|
|
|
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 shadowIntensity;
|
|
|
float shadowBias;
|
|
|
float shadowNormalBias;
|
|
|
float shadowRadius;
|
|
|
vec2 shadowMapSize;
|
|
|
float shadowCameraNear;
|
|
|
float shadowCameraFar;
|
|
|
};
|
|
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
|
#endif
|
|
|
#endif`,UB=`#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`,kB=`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.shadowIntensity, 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.shadowIntensity, 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.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
|
|
|
}
|
|
|
#pragma unroll_loop_end
|
|
|
#endif
|
|
|
#endif
|
|
|
return shadow;
|
|
|
}`,zB=`#ifdef USE_SKINNING
|
|
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
|
#endif`,VB=`#ifdef USE_SKINNING
|
|
|
uniform mat4 bindMatrix;
|
|
|
uniform mat4 bindMatrixInverse;
|
|
|
uniform highp sampler2D boneTexture;
|
|
|
mat4 getBoneMatrix( const in float i ) {
|
|
|
int size = textureSize( boneTexture, 0 ).x;
|
|
|
int j = int( i ) * 4;
|
|
|
int x = j % size;
|
|
|
int y = j / size;
|
|
|
vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
|
|
|
vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
|
|
|
vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
|
|
|
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
|
return mat4( v1, v2, v3, v4 );
|
|
|
}
|
|
|
#endif`,GB=`#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`,WB=`#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`,HB=`float specularStrength;
|
|
|
#ifdef USE_SPECULARMAP
|
|
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
|
specularStrength = texelSpecular.r;
|
|
|
#else
|
|
|
specularStrength = 1.0;
|
|
|
#endif`,$B=`#ifdef USE_SPECULARMAP
|
|
|
uniform sampler2D specularMap;
|
|
|
#endif`,jB=`#if defined( TONE_MAPPING )
|
|
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
|
#endif`,XB=`#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 CineonToneMapping( 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 );
|
|
|
}
|
|
|
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
|
|
|
vec3( 1.6605, - 0.1246, - 0.0182 ),
|
|
|
vec3( - 0.5876, 1.1329, - 0.1006 ),
|
|
|
vec3( - 0.0728, - 0.0083, 1.1187 )
|
|
|
);
|
|
|
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
|
|
|
vec3( 0.6274, 0.0691, 0.0164 ),
|
|
|
vec3( 0.3293, 0.9195, 0.0880 ),
|
|
|
vec3( 0.0433, 0.0113, 0.8956 )
|
|
|
);
|
|
|
vec3 agxDefaultContrastApprox( vec3 x ) {
|
|
|
vec3 x2 = x * x;
|
|
|
vec3 x4 = x2 * x2;
|
|
|
return + 15.5 * x4 * x2
|
|
|
- 40.14 * x4 * x
|
|
|
+ 31.96 * x4
|
|
|
- 6.868 * x2 * x
|
|
|
+ 0.4298 * x2
|
|
|
+ 0.1191 * x
|
|
|
- 0.00232;
|
|
|
}
|
|
|
vec3 AgXToneMapping( vec3 color ) {
|
|
|
const mat3 AgXInsetMatrix = mat3(
|
|
|
vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
|
|
|
vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
|
|
|
vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
|
|
|
);
|
|
|
const mat3 AgXOutsetMatrix = mat3(
|
|
|
vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
|
|
|
vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
|
|
|
vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
|
|
|
);
|
|
|
const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
|
|
|
color *= toneMappingExposure;
|
|
|
color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
|
|
|
color = AgXInsetMatrix * color;
|
|
|
color = max( color, 1e-10 ); color = log2( color );
|
|
|
color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
|
|
|
color = clamp( color, 0.0, 1.0 );
|
|
|
color = agxDefaultContrastApprox( color );
|
|
|
color = AgXOutsetMatrix * color;
|
|
|
color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
|
|
|
color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
|
|
|
color = clamp( color, 0.0, 1.0 );
|
|
|
return color;
|
|
|
}
|
|
|
vec3 NeutralToneMapping( vec3 color ) {
|
|
|
const float StartCompression = 0.8 - 0.04;
|
|
|
const float Desaturation = 0.15;
|
|
|
color *= toneMappingExposure;
|
|
|
float x = min( color.r, min( color.g, color.b ) );
|
|
|
float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
|
|
|
color -= offset;
|
|
|
float peak = max( color.r, max( color.g, color.b ) );
|
|
|
if ( peak < StartCompression ) return color;
|
|
|
float d = 1. - StartCompression;
|
|
|
float newPeak = 1. - d * d / ( peak + d - StartCompression );
|
|
|
color *= newPeak / peak;
|
|
|
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
|
|
return mix( color, vec3( newPeak ), g );
|
|
|
}
|
|
|
vec3 CustomToneMapping( vec3 color ) { return color; }`,qB=`#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.dispersion, 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`,YB=`#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 dispersion, const in float ior, const in float thickness,
|
|
|
const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
|
vec4 transmittedLight;
|
|
|
vec3 transmittance;
|
|
|
#ifdef USE_DISPERSION
|
|
|
float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
|
|
|
vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
|
|
|
for ( int i = 0; i < 3; i ++ ) {
|
|
|
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], 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 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
|
|
|
transmittedLight[ i ] = transmissionSample[ i ];
|
|
|
transmittedLight.a += transmissionSample.a;
|
|
|
transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
|
|
|
}
|
|
|
transmittedLight.a /= 3.0;
|
|
|
#else
|
|
|
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;
|
|
|
transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
|
|
|
transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
|
|
|
#endif
|
|
|
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`,ZB=`#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`,KB=`#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`,JB=`#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`,QB=`#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_BATCHING
|
|
|
worldPosition = batchingMatrix * worldPosition;
|
|
|
#endif
|
|
|
#ifdef USE_INSTANCING
|
|
|
worldPosition = instanceMatrix * worldPosition;
|
|
|
#endif
|
|
|
worldPosition = modelMatrix * worldPosition;
|
|
|
#endif`;const Ps={alphahash_fragment:tF,alphahash_pars_fragment:nF,alphamap_fragment:iF,alphamap_pars_fragment:rF,alphatest_fragment:sF,alphatest_pars_fragment:oF,aomap_fragment:aF,aomap_pars_fragment:lF,batching_pars_vertex:cF,batching_vertex:uF,begin_vertex:hF,beginnormal_vertex:dF,bsdfs:fF,iridescence_fragment:pF,bumpmap_pars_fragment:mF,clipping_planes_fragment:gF,clipping_planes_pars_fragment:yF,clipping_planes_pars_vertex:vF,clipping_planes_vertex:xF,color_fragment:_F,color_pars_fragment:bF,color_pars_vertex:wF,color_vertex:MF,common:SF,cube_uv_reflection_fragment:TF,defaultnormal_vertex:EF,displacementmap_pars_vertex:AF,displacementmap_vertex:CF,emissivemap_fragment:RF,emissivemap_pars_fragment:NF,colorspace_fragment:PF,colorspace_pars_fragment:IF,envmap_fragment:LF,envmap_common_pars_fragment:DF,envmap_pars_fragment:OF,envmap_pars_vertex:FF,envmap_physical_pars_fragment:XF,envmap_vertex:BF,fog_vertex:UF,fog_pars_vertex:kF,fog_fragment:zF,fog_pars_fragment:VF,gradientmap_pars_fragment:GF,lightmap_pars_fragment:WF,lights_lambert_fragment:HF,lights_lambert_pars_fragment:$F,lights_pars_begin:jF,lights_toon_fragment:qF,lights_toon_pars_fragment:YF,lights_phong_fragment:ZF,lights_phong_pars_fragment:KF,lights_physical_fragment:JF,lights_physical_pars_fragment:QF,lights_fragment_begin:eB,lights_fragment_maps:tB,lights_fragment_end:nB,logdepthbuf_fragment:iB,logdepthbuf_pars_fragment:rB,logdepthbuf_pars_vertex:sB,logdepthbuf_vertex:oB,map_fragment:aB,map_pars_fragment:lB,map_particle_fragment:cB,map_particle_pars_fragment:uB,metalnessmap_fragment:hB,metalnessmap_pars_fragment:dB,morphinstance_vertex:fB,morphcolor_vertex:pB,morphnormal_vertex:mB,morphtarget_pars_vertex:gB,morphtarget_vertex:yB,normal_fragment_begin:vB,normal_fragment_maps:xB,normal_pars_fragment:_B,normal_pars_vertex:bB,normal_vertex:wB,normalmap_pars_fragment:MB,clearcoat_normal_fragment_begin:SB,clearcoat_normal_fragment_maps:TB,clearcoat_pars_fragment:EB,iridescence_pars_fragment:AB,opaque_fragment:CB,packing:RB,premultiplied_alpha_fragment:NB,project_vertex:PB,dithering_fragment:IB,dithering_pars_fragment:LB,roughnessmap_fragment:DB,roughnessmap_pars_fragment:OB,shadowmap_pars_fragment:FB,shadowmap_pars_vertex:BB,shadowmap_vertex:UB,shadowmask_pars_fragment:kB,skinbase_vertex:zB,skinning_pars_vertex:VB,skinning_vertex:GB,skinnormal_vertex:WB,specularmap_fragment:HB,specularmap_pars_fragment:$B,tonemapping_fragment:jB,tonemapping_pars_fragment:XB,transmission_fragment:qB,transmission_pars_fragment:YB,uv_pars_fragment:ZB,uv_pars_vertex:KB,uv_vertex:JB,worldpos_vertex:QB,background_vert:`varying vec2 vUv;
|
|
|
uniform mat3 uvTransform;
|
|
|
void main() {
|
|
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
|
}`,background_frag:`uniform sampler2D t2D;
|
|
|
uniform float backgroundIntensity;
|
|
|
varying vec2 vUv;
|
|
|
void main() {
|
|
|
vec4 texColor = texture2D( t2D, vUv );
|
|
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
|
texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
|
|
|
#endif
|
|
|
texColor.rgb *= backgroundIntensity;
|
|
|
gl_FragColor = texColor;
|
|
|
#include <tonemapping_fragment>
|
|
|
#include <colorspace_fragment>
|
|
|
}`,backgroundCube_vert:`varying vec3 vWorldDirection;
|
|
|
#include <common>
|
|
|
void main() {
|
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
|
#include <begin_vertex>
|
|
|
#include <project_vertex>
|
|
|
gl_Position.z = gl_Position.w;
|
|
|
}`,backgroundCube_frag:`#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;
|
|
|
uniform mat3 backgroundRotation;
|
|
|
varying vec3 vWorldDirection;
|
|
|
#include <cube_uv_reflection_fragment>
|
|
|
void main() {
|
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|
|
vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
|
|
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
|
vec4 texColor = textureCubeUV( envMap, backgroundRotation * 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>
|
|
|
}`,cube_vert:`varying vec3 vWorldDirection;
|
|
|
#include <common>
|
|
|
void main() {
|
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
|
#include <begin_vertex>
|
|
|
#include <project_vertex>
|
|
|
gl_Position.z = gl_Position.w;
|
|
|
}`,cube_frag:`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>
|
|
|
}`,depth_vert:`#include <common>
|
|
|
#include <batching_pars_vertex>
|
|
|
#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 <batching_vertex>
|
|
|
#include <skinbase_vertex>
|
|
|
#include <morphinstance_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;
|
|
|
}`,depth_frag:`#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() {
|
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|
|
#include <clipping_planes_fragment>
|
|
|
#if DEPTH_PACKING == 3200
|
|
|
diffuseColor.a = opacity;
|
|
|
#endif
|
|
|
#include <map_fragment>
|
|
|
#include <alphamap_fragment>
|
|
|
#include <alphatest_fragment>
|
|
|
#include <alphahash_fragment>
|
|
|
#include <logdepthbuf_fragment>
|
|
|
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
|
float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
|
|
|
#else
|
|
|
float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
|
|
|
#endif
|
|
|
#if DEPTH_PACKING == 3200
|
|
|
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
|
|
|
#elif DEPTH_PACKING == 3201
|
|
|
gl_FragColor = packDepthToRGBA( fragCoordZ );
|
|
|
#elif DEPTH_PACKING == 3202
|
|
|
gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
|
|
|
#elif DEPTH_PACKING == 3203
|
|
|
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|
|
#endif
|
|
|
}`,distanceRGBA_vert:`#define DISTANCE
|
|
|
varying vec3 vWorldPosition;
|
|
|
#include <common>
|
|
|
#include <batching_pars_vertex>
|
|
|
#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 <batching_vertex>
|
|
|
#include <skinbase_vertex>
|
|
|
#include <morphinstance_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;
|
|
|
}`,distanceRGBA_frag:`#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 () {
|
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|
|
#include <clipping_planes_fragment>
|
|
|
#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 );
|
|
|
}`,equirect_vert:`varying vec3 vWorldDirection;
|
|
|
#include <common>
|
|
|
void main() {
|
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
|
#include <begin_vertex>
|
|
|
#include <project_vertex>
|
|
|
}`,equirect_frag:`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>
|
|
|
}`,linedashed_vert:`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 <morphinstance_vertex>
|
|
|
#include <morphcolor_vertex>
|
|
|
#include <begin_vertex>
|
|
|
#include <morphtarget_vertex>
|
|
|
#include <project_vertex>
|
|
|
#include <logdepthbuf_vertex>
|
|
|
#include <clipping_planes_vertex>
|
|
|
#include <fog_vertex>
|
|
|
}`,linedashed_frag:`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() {
|
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
|
#include <clipping_planes_fragment>
|
|
|
if ( mod( vLineDistance, totalSize ) > dashSize ) {
|
|
|
discard;
|
|
|
}
|
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
|
#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>
|
|
|
}`,meshbasic_vert:`#include <common>
|
|
|
#include <batching_pars_vertex>
|
|
|
#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 <morphinstance_vertex>
|
|
|
#include <morphcolor_vertex>
|
|
|
#include <batching_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>
|
|
|
}`,meshbasic_frag:`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() {
|
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
|
#include <clipping_planes_fragment>
|
|
|
#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>
|
|
|
}`,meshlambert_vert:`#define LAMBERT
|
|
|
varying vec3 vViewPosition;
|
|
|
#include <common>
|
|
|
#include <batching_pars_vertex>
|
|
|
#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 <morphinstance_vertex>
|
|
|
#include <morphcolor_vertex>
|
|
|
#include <batching_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>
|
|
|
}`,meshlambert_frag:`#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() {
|
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
|
#include <clipping_planes_fragment>
|
|
|
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>
|
|
|
}`,meshmatcap_vert:`#define MATCAP
|
|
|
varying vec3 vViewPosition;
|
|
|
#include <common>
|
|
|
#include <batching_pars_vertex>
|
|
|
#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 <morphinstance_vertex>
|
|
|
#include <morphcolor_vertex>
|
|
|
#include <batching_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;
|
|
|
}`,meshmatcap_frag:`#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() {
|
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
|
#include <clipping_planes_fragment>
|
|
|
#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>
|
|
|
}`,meshnormal_vert:`#define NORMAL
|
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
|
varying vec3 vViewPosition;
|
|
|
#endif
|
|
|
#include <common>
|
|
|
#include <batching_pars_vertex>
|
|
|
#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 <batching_vertex>
|
|
|
#include <beginnormal_vertex>
|
|
|
#include <morphinstance_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
|
|
|
}`,meshnormal_frag:`#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() {
|
|
|
vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
|
|
|
#include <clipping_planes_fragment>
|
|
|
#include <logdepthbuf_fragment>
|
|
|
#include <normal_fragment_begin>
|
|
|
#include <normal_fragment_maps>
|
|
|
gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
|
|
|
#ifdef OPAQUE
|
|
|
gl_FragColor.a = 1.0;
|
|
|
#endif
|
|
|
}`,meshphong_vert:`#define PHONG
|
|
|
varying vec3 vViewPosition;
|
|
|
#include <common>
|
|
|
#include <batching_pars_vertex>
|
|
|
#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 <batching_vertex>
|
|
|
#include <beginnormal_vertex>
|
|
|
#include <morphinstance_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>
|
|
|
}`,meshphong_frag:`#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() {
|
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
|
#include <clipping_planes_fragment>
|
|
|
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>
|
|
|
}`,meshphysical_vert:`#define STANDARD
|
|
|
varying vec3 vViewPosition;
|
|
|
#ifdef USE_TRANSMISSION
|
|
|
varying vec3 vWorldPosition;
|
|
|
#endif
|
|
|
#include <common>
|
|
|
#include <batching_pars_vertex>
|
|
|
#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 <morphinstance_vertex>
|
|
|
#include <morphcolor_vertex>
|
|
|
#include <batching_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
|
|
|
}`,meshphysical_frag:`#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_DISPERSION
|
|
|
uniform float dispersion;
|
|
|
#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() {
|
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
|
#include <clipping_planes_fragment>
|
|
|
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 + sheenSpecularDirect + sheenSpecularIndirect;
|
|
|
#endif
|
|
|
#ifdef USE_CLEARCOAT
|
|
|
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
|
|
|
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
|
|
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
|
|
|
#endif
|
|
|
#include <opaque_fragment>
|
|
|
#include <tonemapping_fragment>
|
|
|
#include <colorspace_fragment>
|
|
|
#include <fog_fragment>
|
|
|
#include <premultiplied_alpha_fragment>
|
|
|
#include <dithering_fragment>
|
|
|
}`,meshtoon_vert:`#define TOON
|
|
|
varying vec3 vViewPosition;
|
|
|
#include <common>
|
|
|
#include <batching_pars_vertex>
|
|
|
#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 <morphinstance_vertex>
|
|
|
#include <morphcolor_vertex>
|
|
|
#include <batching_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>
|
|
|
}`,meshtoon_frag:`#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() {
|
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
|
#include <clipping_planes_fragment>
|
|
|
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>
|
|
|
}`,points_vert:`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 <morphinstance_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>
|
|
|
}`,points_frag:`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() {
|
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
|
#include <clipping_planes_fragment>
|
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
|
#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>
|
|
|
}`,shadow_vert:`#include <common>
|
|
|
#include <batching_pars_vertex>
|
|
|
#include <fog_pars_vertex>
|
|
|
#include <morphtarget_pars_vertex>
|
|
|
#include <skinning_pars_vertex>
|
|
|
#include <logdepthbuf_pars_vertex>
|
|
|
#include <shadowmap_pars_vertex>
|
|
|
void main() {
|
|
|
#include <batching_vertex>
|
|
|
#include <beginnormal_vertex>
|
|
|
#include <morphinstance_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>
|
|
|
}`,shadow_frag:`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>
|
|
|
}`,sprite_vert:`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[ 3 ];
|
|
|
vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
|
|
|
#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>
|
|
|
}`,sprite_frag:`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() {
|
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
|
#include <clipping_planes_fragment>
|
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
|
#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>
|
|
|
}`},zi={common:{diffuse:{value:new jn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new jr},alphaMap:{value:null},alphaMapTransform:{value:new jr},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new jr}},envmap:{envMap:{value:null},envMapRotation:{value:new jr},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new jr}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new jr}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new jr},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new jr},normalScale:{value:new yn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new jr},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new jr}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new jr}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new jr}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new jn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,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 jn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new jr},alphaTest:{value:0},uvTransform:{value:new jr}},sprite:{diffuse:{value:new jn(16777215)},opacity:{value:1},center:{value:new yn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new jr},alphaMap:{value:null},alphaMapTransform:{value:new jr},alphaTest:{value:0}}},Ih={basic:{uniforms:el([zi.common,zi.specularmap,zi.envmap,zi.aomap,zi.lightmap,zi.fog]),vertexShader:Ps.meshbasic_vert,fragmentShader:Ps.meshbasic_frag},lambert:{uniforms:el([zi.common,zi.specularmap,zi.envmap,zi.aomap,zi.lightmap,zi.emissivemap,zi.bumpmap,zi.normalmap,zi.displacementmap,zi.fog,zi.lights,{emissive:{value:new jn(0)}}]),vertexShader:Ps.meshlambert_vert,fragmentShader:Ps.meshlambert_frag},phong:{uniforms:el([zi.common,zi.specularmap,zi.envmap,zi.aomap,zi.lightmap,zi.emissivemap,zi.bumpmap,zi.normalmap,zi.displacementmap,zi.fog,zi.lights,{emissive:{value:new jn(0)},specular:{value:new jn(1118481)},shininess:{value:30}}]),vertexShader:Ps.meshphong_vert,fragmentShader:Ps.meshphong_frag},standard:{uniforms:el([zi.common,zi.envmap,zi.aomap,zi.lightmap,zi.emissivemap,zi.bumpmap,zi.normalmap,zi.displacementmap,zi.roughnessmap,zi.metalnessmap,zi.fog,zi.lights,{emissive:{value:new jn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ps.meshphysical_vert,fragmentShader:Ps.meshphysical_frag},toon:{uniforms:el([zi.common,zi.aomap,zi.lightmap,zi.emissivemap,zi.bumpmap,zi.normalmap,zi.displacementmap,zi.gradientmap,zi.fog,zi.lights,{emissive:{value:new jn(0)}}]),vertexShader:Ps.meshtoon_vert,fragmentShader:Ps.meshtoon_frag},matcap:{uniforms:el([zi.common,zi.bumpmap,zi.normalmap,zi.displacementmap,zi.fog,{matcap:{value:null}}]),vertexShader:Ps.meshmatcap_vert,fragmentShader:Ps.meshmatcap_frag},points:{uniforms:el([zi.points,zi.fog]),vertexShader:Ps.points_vert,fragmentShader:Ps.points_frag},dashed:{uniforms:el([zi.common,zi.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ps.linedashed_vert,fragmentShader:Ps.linedashed_frag},depth:{uniforms:el([zi.common,zi.displacementmap]),vertexShader:Ps.depth_vert,fragmentShader:Ps.depth_frag},normal:{uniforms:el([zi.common,zi.bumpmap,zi.normalmap,zi.displacementmap,{opacity:{value:1}}]),vertexShader:Ps.meshnormal_vert,fragmentShader:Ps.meshnormal_frag},sprite:{uniforms:el([zi.sprite,zi.fog]),vertexShader:Ps.sprite_vert,fragmentShader:Ps.sprite_frag},background:{uniforms:{uvTransform:{value:new jr},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ps.background_vert,fragmentShader:Ps.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new jr}},vertexShader:Ps.backgroundCube_vert,fragmentShader:Ps.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ps.cube_vert,fragmentShader:Ps.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ps.equirect_vert,fragmentShader:Ps.equirect_frag},distanceRGBA:{uniforms:el([zi.common,zi.displacementmap,{referencePosition:{value:new it},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ps.distanceRGBA_vert,fragmentShader:Ps.distanceRGBA_frag},shadow:{uniforms:el([zi.lights,zi.fog,{color:{value:new jn(0)},opacity:{value:1}}]),vertexShader:Ps.shadow_vert,fragmentShader:Ps.shadow_frag}};Ih.physical={uniforms:el([Ih.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new jr},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new jr},clearcoatNormalScale:{value:new yn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new jr},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new jr},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new jr},sheen:{value:0},sheenColor:{value:new jn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new jr},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new jr},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new jr},transmissionSamplerSize:{value:new yn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new jr},attenuationDistance:{value:0},attenuationColor:{value:new jn(0)},specularColor:{value:new jn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new jr},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new jr},anisotropyVector:{value:new yn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new jr}}]),vertexShader:Ps.meshphysical_vert,fragmentShader:Ps.meshphysical_frag};const x_={r:0,b:0,g:0},im=new Qi,eU=new Ft;function tU(i,e,t,n,s,o,a){const c=new jn(0);let u=o===!0?0:1,d,p,m=null,y=0,M=null;function T(K){let re=K.isScene===!0?K.background:null;return re&&re.isTexture&&(re=(K.backgroundBlurriness>0?t:e).get(re)),re}function G(K){let re=!1;const ve=T(K);ve===null?I(c,u):ve&&ve.isColor&&(I(ve,1),re=!0);const me=i.xr.getEnvironmentBlendMode();me==="additive"?n.buffers.color.setClear(0,0,0,1,a):me==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||re)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function z(K,re){const ve=T(re);ve&&(ve.isCubeTexture||ve.mapping===qe)?(p===void 0&&(p=new Ks(new Uc(1,1,1),new kc({name:"BackgroundCubeMaterial",uniforms:id(Ih.backgroundCube.uniforms),vertexShader:Ih.backgroundCube.vertexShader,fragmentShader:Ih.backgroundCube.fragmentShader,side:Y,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),p.geometry.deleteAttribute("normal"),p.geometry.deleteAttribute("uv"),p.onBeforeRender=function(me,Le,Ve){this.matrixWorld.copyPosition(Ve.matrixWorld)},Object.defineProperty(p.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(p)),im.copy(re.backgroundRotation),im.x*=-1,im.y*=-1,im.z*=-1,ve.isCubeTexture&&ve.isRenderTargetTexture===!1&&(im.y*=-1,im.z*=-1),p.material.uniforms.envMap.value=ve,p.material.uniforms.flipEnvMap.value=ve.isCubeTexture&&ve.isRenderTargetTexture===!1?-1:1,p.material.uniforms.backgroundBlurriness.value=re.backgroundBlurriness,p.material.uniforms.backgroundIntensity.value=re.backgroundIntensity,p.material.uniforms.backgroundRotation.value.setFromMatrix4(eU.makeRotationFromEuler(im)),p.material.toneMapped=Ki.getTransfer(ve.colorSpace)!==Fi,(m!==ve||y!==ve.version||M!==i.toneMapping)&&(p.material.needsUpdate=!0,m=ve,y=ve.version,M=i.toneMapping),p.layers.enableAll(),K.unshift(p,p.geometry,p.material,0,0,null)):ve&&ve.isTexture&&(d===void 0&&(d=new Ks(new Ch(2,2),new kc({name:"BackgroundMaterial",uniforms:id(Ih.background.uniforms),vertexShader:Ih.background.vertexShader,fragmentShader:Ih.background.fragmentShader,side:W,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),Object.defineProperty(d.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(d)),d.material.uniforms.t2D.value=ve,d.material.uniforms.backgroundIntensity.value=re.backgroundIntensity,d.material.toneMapped=Ki.getTransfer(ve.colorSpace)!==Fi,ve.matrixAutoUpdate===!0&&ve.updateMatrix(),d.material.uniforms.uvTransform.value.copy(ve.matrix),(m!==ve||y!==ve.version||M!==i.toneMapping)&&(d.material.needsUpdate=!0,m=ve,y=ve.version,M=i.toneMapping),d.layers.enableAll(),K.unshift(d,d.geometry,d.material,0,0,null))}function I(K,re){K.getRGB(x_,fx(i)),n.buffers.color.setClear(x_.r,x_.g,x_.b,re,a)}function J(){p!==void 0&&(p.geometry.dispose(),p.material.dispose(),p=void 0),d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0)}return{getClearColor:function(){return c},setClearColor:function(K,re=1){c.set(K),u=re,I(c,u)},getClearAlpha:function(){return u},setClearAlpha:function(K){u=K,I(c,u)},render:G,addToRenderList:z,dispose:J}}function nU(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=y(null);let o=s,a=!1;function c(Oe,dt,Ut,tn,cn){let vn=!1;const mn=m(tn,Ut,dt);o!==mn&&(o=mn,d(o.object)),vn=M(Oe,tn,Ut,cn),vn&&T(Oe,tn,Ut,cn),cn!==null&&e.update(cn,i.ELEMENT_ARRAY_BUFFER),(vn||a)&&(a=!1,re(Oe,dt,Ut,tn),cn!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(cn).buffer))}function u(){return i.createVertexArray()}function d(Oe){return i.bindVertexArray(Oe)}function p(Oe){return i.deleteVertexArray(Oe)}function m(Oe,dt,Ut){const tn=Ut.wireframe===!0;let cn=n[Oe.id];cn===void 0&&(cn={},n[Oe.id]=cn);let vn=cn[dt.id];vn===void 0&&(vn={},cn[dt.id]=vn);let mn=vn[tn];return mn===void 0&&(mn=y(u()),vn[tn]=mn),mn}function y(Oe){const dt=[],Ut=[],tn=[];for(let cn=0;cn<t;cn++)dt[cn]=0,Ut[cn]=0,tn[cn]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:dt,enabledAttributes:Ut,attributeDivisors:tn,object:Oe,attributes:{},index:null}}function M(Oe,dt,Ut,tn){const cn=o.attributes,vn=dt.attributes;let mn=0;const Yn=Ut.getAttributes();for(const xn in Yn)if(Yn[xn].location>=0){const wn=cn[xn];let Gn=vn[xn];if(Gn===void 0&&(xn==="instanceMatrix"&&Oe.instanceMatrix&&(Gn=Oe.instanceMatrix),xn==="instanceColor"&&Oe.instanceColor&&(Gn=Oe.instanceColor)),wn===void 0||wn.attribute!==Gn||Gn&&wn.data!==Gn.data)return!0;mn++}return o.attributesNum!==mn||o.index!==tn}function T(Oe,dt,Ut,tn){const cn={},vn=dt.attributes;let mn=0;const Yn=Ut.getAttributes();for(const xn in Yn)if(Yn[xn].location>=0){let wn=vn[xn];wn===void 0&&(xn==="instanceMatrix"&&Oe.instanceMatrix&&(wn=Oe.instanceMatrix),xn==="instanceColor"&&Oe.instanceColor&&(wn=Oe.instanceColor));const Gn={};Gn.attribute=wn,wn&&wn.data&&(Gn.data=wn.data),cn[xn]=Gn,mn++}o.attributes=cn,o.attributesNum=mn,o.index=tn}function G(){const Oe=o.newAttributes;for(let dt=0,Ut=Oe.length;dt<Ut;dt++)Oe[dt]=0}function z(Oe){I(Oe,0)}function I(Oe,dt){const Ut=o.newAttributes,tn=o.enabledAttributes,cn=o.attributeDivisors;Ut[Oe]=1,tn[Oe]===0&&(i.enableVertexAttribArray(Oe),tn[Oe]=1),cn[Oe]!==dt&&(i.vertexAttribDivisor(Oe,dt),cn[Oe]=dt)}function J(){const Oe=o.newAttributes,dt=o.enabledAttributes;for(let Ut=0,tn=dt.length;Ut<tn;Ut++)dt[Ut]!==Oe[Ut]&&(i.disableVertexAttribArray(Ut),dt[Ut]=0)}function K(Oe,dt,Ut,tn,cn,vn,mn){mn===!0?i.vertexAttribIPointer(Oe,dt,Ut,cn,vn):i.vertexAttribPointer(Oe,dt,Ut,tn,cn,vn)}function re(Oe,dt,Ut,tn){G();const cn=tn.attributes,vn=Ut.getAttributes(),mn=dt.defaultAttributeValues;for(const Yn in vn){const xn=vn[Yn];if(xn.location>=0){let si=cn[Yn];if(si===void 0&&(Yn==="instanceMatrix"&&Oe.instanceMatrix&&(si=Oe.instanceMatrix),Yn==="instanceColor"&&Oe.instanceColor&&(si=Oe.instanceColor)),si!==void 0){const wn=si.normalized,Gn=si.itemSize,Si=e.get(si);if(Si===void 0)continue;const nr=Si.buffer,os=Si.type,Vn=Si.bytesPerElement,un=os===i.INT||os===i.UNSIGNED_INT||si.gpuType===Ls;if(si.isInterleavedBufferAttribute){const Mn=si.data,fi=Mn.stride,ki=si.offset;if(Mn.isInstancedInterleavedBuffer){for(let Ni=0;Ni<xn.locationSize;Ni++)I(xn.location+Ni,Mn.meshPerAttribute);Oe.isInstancedMesh!==!0&&tn._maxInstanceCount===void 0&&(tn._maxInstanceCount=Mn.meshPerAttribute*Mn.count)}else for(let Ni=0;Ni<xn.locationSize;Ni++)z(xn.location+Ni);i.bindBuffer(i.ARRAY_BUFFER,nr);for(let Ni=0;Ni<xn.locationSize;Ni++)K(xn.location+Ni,Gn/xn.locationSize,os,wn,fi*Vn,(ki+Gn/xn.locationSize*Ni)*Vn,un)}else{if(si.isInstancedBufferAttribute){for(let Mn=0;Mn<xn.locationSize;Mn++)I(xn.location+Mn,si.meshPerAttribute);Oe.isInstancedMesh!==!0&&tn._maxInstanceCount===void 0&&(tn._maxInstanceCount=si.meshPerAttribute*si.count)}else for(let Mn=0;Mn<xn.locationSize;Mn++)z(xn.location+Mn);i.bindBuffer(i.ARRAY_BUFFER,nr);for(let Mn=0;Mn<xn.locationSize;Mn++)K(xn.location+Mn,Gn/xn.locationSize,os,wn,Gn*Vn,Gn/xn.locationSize*Mn*Vn,un)}}else if(mn!==void 0){const wn=mn[Yn];if(wn!==void 0)switch(wn.length){case 2:i.vertexAttrib2fv(xn.location,wn);break;case 3:i.vertexAttrib3fv(xn.location,wn);break;case 4:i.vertexAttrib4fv(xn.location,wn);break;default:i.vertexAttrib1fv(xn.location,wn)}}}}J()}function ve(){Ve();for(const Oe in n){const dt=n[Oe];for(const Ut in dt){const tn=dt[Ut];for(const cn in tn)p(tn[cn].object),delete tn[cn];delete dt[Ut]}delete n[Oe]}}function me(Oe){if(n[Oe.id]===void 0)return;const dt=n[Oe.id];for(const Ut in dt){const tn=dt[Ut];for(const cn in tn)p(tn[cn].object),delete tn[cn];delete dt[Ut]}delete n[Oe.id]}function Le(Oe){for(const dt in n){const Ut=n[dt];if(Ut[Oe.id]===void 0)continue;const tn=Ut[Oe.id];for(const cn in tn)p(tn[cn].object),delete tn[cn];delete Ut[Oe.id]}}function Ve(){Ee(),a=!0,o!==s&&(o=s,d(o.object))}function Ee(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:c,reset:Ve,resetDefaultState:Ee,dispose:ve,releaseStatesOfGeometry:me,releaseStatesOfProgram:Le,initAttributes:G,enableAttribute:z,disableUnusedAttributes:J}}function iU(i,e,t){let n;function s(d){n=d}function o(d,p){i.drawArrays(n,d,p),t.update(p,n,1)}function a(d,p,m){m!==0&&(i.drawArraysInstanced(n,d,p,m),t.update(p,n,m))}function c(d,p,m){if(m===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,d,0,p,0,m);let M=0;for(let T=0;T<m;T++)M+=p[T];t.update(M,n,1)}function u(d,p,m,y){if(m===0)return;const M=e.get("WEBGL_multi_draw");if(M===null)for(let T=0;T<d.length;T++)a(d[T],p[T],y[T]);else{M.multiDrawArraysInstancedWEBGL(n,d,0,p,0,y,0,m);let T=0;for(let G=0;G<m;G++)T+=p[G]*y[G];t.update(T,n,1)}}this.setMode=s,this.render=o,this.renderInstances=a,this.renderMultiDraw=c,this.renderMultiDrawInstances=u}function rU(i,e,t,n){let s;function o(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){const Le=e.get("EXT_texture_filter_anisotropic");s=i.getParameter(Le.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(Le){return!(Le!==D&&n.convert(Le)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function c(Le){const Ve=Le===Gs&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(Le!==Oi&&n.convert(Le)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&Le!==ys&&!Ve)}function u(Le){if(Le==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";Le="mediump"}return Le==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let d=t.precision!==void 0?t.precision:"highp";const p=u(d);p!==d&&(console.warn("THREE.WebGLRenderer:",d,"not supported, using",p,"instead."),d=p);const m=t.logarithmicDepthBuffer===!0,y=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),M=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),T=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),G=i.getParameter(i.MAX_TEXTURE_SIZE),z=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),I=i.getParameter(i.MAX_VERTEX_ATTRIBS),J=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),K=i.getParameter(i.MAX_VARYING_VECTORS),re=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),ve=T>0,me=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:o,getMaxPrecision:u,textureFormatReadable:a,textureTypeReadable:c,precision:d,logarithmicDepthBuffer:m,reversedDepthBuffer:y,maxTextures:M,maxVertexTextures:T,maxTextureSize:G,maxCubemapSize:z,maxAttributes:I,maxVertexUniforms:J,maxVaryings:K,maxFragmentUniforms:re,vertexTextures:ve,maxSamples:me}}function sU(i){const e=this;let t=null,n=0,s=!1,o=!1;const a=new Rl,c=new jr,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(m,y){const M=m.length!==0||y||n!==0||s;return s=y,n=m.length,M},this.beginShadows=function(){o=!0,p(null)},this.endShadows=function(){o=!1},this.setGlobalState=function(m,y){t=p(m,y,0)},this.setState=function(m,y,M){const T=m.clippingPlanes,G=m.clipIntersection,z=m.clipShadows,I=i.get(m);if(!s||T===null||T.length===0||o&&!z)o?p(null):d();else{const J=o?0:n,K=J*4;let re=I.clippingState||null;u.value=re,re=p(T,y,K,M);for(let ve=0;ve!==K;++ve)re[ve]=t[ve];I.clippingState=re,this.numIntersection=G?this.numPlanes:0,this.numPlanes+=J}};function d(){u.value!==t&&(u.value=t,u.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function p(m,y,M,T){const G=m!==null?m.length:0;let z=null;if(G!==0){if(z=u.value,T!==!0||z===null){const I=M+G*4,J=y.matrixWorldInverse;c.getNormalMatrix(J),(z===null||z.length<I)&&(z=new Float32Array(I));for(let K=0,re=M;K!==G;++K,re+=4)a.copy(m[K]).applyMatrix4(J,c),a.normal.toArray(z,re),z[re+3]=a.constant}u.value=z,u.needsUpdate=!0}return e.numPlanes=G,e.numIntersection=0,z}}function oU(i){let e=new WeakMap;function t(a,c){return c===Ce?a.mapping=De:c===Re&&(a.mapping=We),a}function n(a){if(a&&a.isTexture){const c=a.mapping;if(c===Ce||c===Re)if(e.has(a)){const u=e.get(a).texture;return t(u,a.mapping)}else{const u=a.image;if(u&&u.height>0){const d=new O0(u.height);return d.fromEquirectangularTexture(i,a),e.set(a,d),a.addEventListener("dispose",s),t(d.texture,a.mapping)}else return null}}return a}function s(a){const c=a.target;c.removeEventListener("dispose",s);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function o(){e=new WeakMap}return{get:n,dispose:o}}const zg=4,TA=[.125,.215,.35,.446,.526,.582],rm=20,Uw=new Df,EA=new jn;let kw=null,zw=0,Vw=0,Gw=!1;const sm=(1+Math.sqrt(5))/2,Vg=1/sm,AA=[new it(-sm,Vg,0),new it(sm,Vg,0),new it(-Vg,0,sm),new it(Vg,0,sm),new it(0,sm,-Vg),new it(0,sm,Vg),new it(-1,1,-1),new it(1,1,-1),new it(-1,1,1),new it(1,1,1)],aU=new it;class CA{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,s=100,o={}){const{size:a=256,position:c=aU}=o;kw=this._renderer.getRenderTarget(),zw=this._renderer.getActiveCubeFace(),Vw=this._renderer.getActiveMipmapLevel(),Gw=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const u=this._allocateTargets();return u.depthBuffer=!0,this._sceneToCubeUV(e,n,s,u,c),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=PA(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=NA(),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(kw,zw,Vw),this._renderer.xr.enabled=Gw,e.scissorTest=!1,__(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===De||e.mapping===We?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),kw=this._renderer.getRenderTarget(),zw=this._renderer.getActiveCubeFace(),Vw=this._renderer.getActiveMipmapLevel(),Gw=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;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:Rn,minFilter:Rn,generateMipmaps:!1,type:Gs,format:D,colorSpace:ou,depthBuffer:!1},s=RA(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=RA(e,t,n);const{_lodMax:o}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=lU(o)),this._blurMaterial=cU(o,e,t)}return s}_compileMaterial(e){const t=new Ks(this._lodPlanes[0],e);this._renderer.compile(t,Uw)}_sceneToCubeUV(e,t,n,s,o){const u=new ma(90,1,t,n),d=[1,-1,1,1,1,1],p=[1,1,1,-1,-1,-1],m=this._renderer,y=m.autoClear,M=m.toneMapping;m.getClearColor(EA),m.toneMapping=yt,m.autoClear=!1,m.state.buffers.depth.getReversed()&&(m.setRenderTarget(s),m.clearDepth(),m.setRenderTarget(null));const G=new Hr({name:"PMREM.Background",side:Y,depthWrite:!1,depthTest:!1}),z=new Ks(new Uc,G);let I=!1;const J=e.background;J?J.isColor&&(G.color.copy(J),e.background=null,I=!0):(G.color.copy(EA),I=!0);for(let K=0;K<6;K++){const re=K%3;re===0?(u.up.set(0,d[K],0),u.position.set(o.x,o.y,o.z),u.lookAt(o.x+p[K],o.y,o.z)):re===1?(u.up.set(0,0,d[K]),u.position.set(o.x,o.y,o.z),u.lookAt(o.x,o.y+p[K],o.z)):(u.up.set(0,d[K],0),u.position.set(o.x,o.y,o.z),u.lookAt(o.x,o.y,o.z+p[K]));const ve=this._cubeSize;__(s,re*ve,K>2?ve:0,ve,ve),m.setRenderTarget(s),I&&m.render(z,u),m.render(e,u)}z.geometry.dispose(),z.material.dispose(),m.toneMapping=M,m.autoClear=y,e.background=J}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===De||e.mapping===We;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=PA()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=NA());const o=s?this._cubemapMaterial:this._equirectMaterial,a=new Ks(this._lodPlanes[0],o),c=o.uniforms;c.envMap.value=e;const u=this._cubeSize;__(t,0,0,3*u,2*u),n.setRenderTarget(t),n.render(a,Uw)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const s=this._lodPlanes.length;for(let o=1;o<s;o++){const a=Math.sqrt(this._sigmas[o]*this._sigmas[o]-this._sigmas[o-1]*this._sigmas[o-1]),c=AA[(s-o-1)%AA.length];this._blur(e,o-1,o,a,c)}t.autoClear=n}_blur(e,t,n,s,o){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,s,"latitudinal",o),this._halfBlur(a,e,n,n,s,"longitudinal",o)}_halfBlur(e,t,n,s,o,a,c){const u=this._renderer,d=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const p=3,m=new Ks(this._lodPlanes[s],d),y=d.uniforms,M=this._sizeLods[n]-1,T=isFinite(o)?Math.PI/(2*M):2*Math.PI/(2*rm-1),G=o/T,z=isFinite(o)?1+Math.floor(p*G):rm;z>rm&&console.warn(`sigmaRadians, ${o}, is too large and will clip, as it requested ${z} samples when the maximum is set to ${rm}`);const I=[];let J=0;for(let Le=0;Le<rm;++Le){const Ve=Le/G,Ee=Math.exp(-Ve*Ve/2);I.push(Ee),Le===0?J+=Ee:Le<z&&(J+=2*Ee)}for(let Le=0;Le<I.length;Le++)I[Le]=I[Le]/J;y.envMap.value=e.texture,y.samples.value=z,y.weights.value=I,y.latitudinal.value=a==="latitudinal",c&&(y.poleAxis.value=c);const{_lodMax:K}=this;y.dTheta.value=T,y.mipInt.value=K-n;const re=this._sizeLods[s],ve=3*re*(s>K-zg?s-K+zg:0),me=4*(this._cubeSize-re);__(t,ve,me,3*re,2*re),u.setRenderTarget(t),u.render(m,Uw)}}function lU(i){const e=[],t=[],n=[];let s=i;const o=i-zg+1+TA.length;for(let a=0;a<o;a++){const c=Math.pow(2,s);t.push(c);let u=1/c;a>i-zg?u=TA[a-i+zg-1]:a===0&&(u=0),n.push(u);const d=1/(c-2),p=-d,m=1+d,y=[p,p,m,p,m,m,p,p,m,m,p,m],M=6,T=6,G=3,z=2,I=1,J=new Float32Array(G*T*M),K=new Float32Array(z*T*M),re=new Float32Array(I*T*M);for(let me=0;me<M;me++){const Le=me%3*2/3-1,Ve=me>2?0:-1,Ee=[Le,Ve,0,Le+2/3,Ve,0,Le+2/3,Ve+1,0,Le,Ve,0,Le+2/3,Ve+1,0,Le,Ve+1,0];J.set(Ee,G*T*me),K.set(y,z*T*me);const Oe=[me,me,me,me,me,me];re.set(Oe,I*T*me)}const ve=new xr;ve.setAttribute("position",new es(J,G)),ve.setAttribute("uv",new es(K,z)),ve.setAttribute("faceIndex",new es(re,I)),e.push(ve),s>zg&&s--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function RA(i,e,t){const n=new hc(i,e,t);return n.texture.mapping=qe,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function __(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function cU(i,e,t){const n=new Float32Array(rm),s=new it(0,1,0);return new kc({name:"SphericalGaussianBlur",defines:{n:rm,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Ww(),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:pe,depthTest:!1,depthWrite:!1})}function NA(){return new kc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ww(),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:pe,depthTest:!1,depthWrite:!1})}function PA(){return new kc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ww(),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:pe,depthTest:!1,depthWrite:!1})}function Ww(){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 uU(i){let e=new WeakMap,t=null;function n(c){if(c&&c.isTexture){const u=c.mapping,d=u===Ce||u===Re,p=u===De||u===We;if(d||p){let m=e.get(c);const y=m!==void 0?m.texture.pmremVersion:0;if(c.isRenderTargetTexture&&c.pmremVersion!==y)return t===null&&(t=new CA(i)),m=d?t.fromEquirectangular(c,m):t.fromCubemap(c,m),m.texture.pmremVersion=c.pmremVersion,e.set(c,m),m.texture;if(m!==void 0)return m.texture;{const M=c.image;return d&&M&&M.height>0||p&&M&&s(M)?(t===null&&(t=new CA(i)),m=d?t.fromEquirectangular(c):t.fromCubemap(c),m.texture.pmremVersion=c.pmremVersion,e.set(c,m),c.addEventListener("dispose",o),m.texture):null}}}return c}function s(c){let u=0;const d=6;for(let p=0;p<d;p++)c[p]!==void 0&&u++;return u===d}function o(c){const u=c.target;u.removeEventListener("dispose",o);const d=e.get(u);d!==void 0&&(e.delete(u),d.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function hU(i){const e={};function t(n){if(e[n]!==void 0)return e[n];let s;switch(n){case"WEBGL_depth_texture":s=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=i.getExtension(n)}return e[n]=s,s}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const s=t(n);return s===null&&ll("THREE.WebGLRenderer: "+n+" extension not supported."),s}}}function dU(i,e,t,n){const s={},o=new WeakMap;function a(m){const y=m.target;y.index!==null&&e.remove(y.index);for(const T in y.attributes)e.remove(y.attributes[T]);y.removeEventListener("dispose",a),delete s[y.id];const M=o.get(y);M&&(e.remove(M),o.delete(y)),n.releaseStatesOfGeometry(y),y.isInstancedBufferGeometry===!0&&delete y._maxInstanceCount,t.memory.geometries--}function c(m,y){return s[y.id]===!0||(y.addEventListener("dispose",a),s[y.id]=!0,t.memory.geometries++),y}function u(m){const y=m.attributes;for(const M in y)e.update(y[M],i.ARRAY_BUFFER)}function d(m){const y=[],M=m.index,T=m.attributes.position;let G=0;if(M!==null){const J=M.array;G=M.version;for(let K=0,re=J.length;K<re;K+=3){const ve=J[K+0],me=J[K+1],Le=J[K+2];y.push(ve,me,me,Le,Le,ve)}}else if(T!==void 0){const J=T.array;G=T.version;for(let K=0,re=J.length/3-1;K<re;K+=3){const ve=K+0,me=K+1,Le=K+2;y.push(ve,me,me,Le,Le,ve)}}else return;const z=new(hp(y)?gc:Va)(y,1);z.version=G;const I=o.get(m);I&&e.remove(I),o.set(m,z)}function p(m){const y=o.get(m);if(y){const M=m.index;M!==null&&y.version<M.version&&d(m)}else d(m);return o.get(m)}return{get:c,update:u,getWireframeAttribute:p}}function fU(i,e,t){let n;function s(y){n=y}let o,a;function c(y){o=y.type,a=y.bytesPerElement}function u(y,M){i.drawElements(n,M,o,y*a),t.update(M,n,1)}function d(y,M,T){T!==0&&(i.drawElementsInstanced(n,M,o,y*a,T),t.update(M,n,T))}function p(y,M,T){if(T===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,M,0,o,y,0,T);let z=0;for(let I=0;I<T;I++)z+=M[I];t.update(z,n,1)}function m(y,M,T,G){if(T===0)return;const z=e.get("WEBGL_multi_draw");if(z===null)for(let I=0;I<y.length;I++)d(y[I]/a,M[I],G[I]);else{z.multiDrawElementsInstancedWEBGL(n,M,0,o,y,0,G,0,T);let I=0;for(let J=0;J<T;J++)I+=M[J]*G[J];t.update(I,n,1)}}this.setMode=s,this.setIndex=c,this.render=u,this.renderInstances=d,this.renderMultiDraw=p,this.renderMultiDrawInstances=m}function pU(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(o,a,c){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=c*(o/3);break;case i.LINES:t.lines+=c*(o/2);break;case i.LINE_STRIP:t.lines+=c*(o-1);break;case i.LINE_LOOP:t.lines+=c*o;break;case i.POINTS:t.points+=c*o;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:n}}function mU(i,e,t){const n=new WeakMap,s=new mr;function o(a,c,u){const d=a.morphTargetInfluences,p=c.morphAttributes.position||c.morphAttributes.normal||c.morphAttributes.color,m=p!==void 0?p.length:0;let y=n.get(c);if(y===void 0||y.count!==m){let Ee=function(){Le.dispose(),n.delete(c),c.removeEventListener("dispose",Ee)};y!==void 0&&y.texture.dispose();const M=c.morphAttributes.position!==void 0,T=c.morphAttributes.normal!==void 0,G=c.morphAttributes.color!==void 0,z=c.morphAttributes.position||[],I=c.morphAttributes.normal||[],J=c.morphAttributes.color||[];let K=0;M===!0&&(K=1),T===!0&&(K=2),G===!0&&(K=3);let re=c.attributes.position.count*K,ve=1;re>e.maxTextureSize&&(ve=Math.ceil(re/e.maxTextureSize),re=e.maxTextureSize);const me=new Float32Array(re*ve*4*m),Le=new sf(me,re,ve,m);Le.type=ys,Le.needsUpdate=!0;const Ve=K*4;for(let Oe=0;Oe<m;Oe++){const dt=z[Oe],Ut=I[Oe],tn=J[Oe],cn=re*ve*4*Oe;for(let vn=0;vn<dt.count;vn++){const mn=vn*Ve;M===!0&&(s.fromBufferAttribute(dt,vn),me[cn+mn+0]=s.x,me[cn+mn+1]=s.y,me[cn+mn+2]=s.z,me[cn+mn+3]=0),T===!0&&(s.fromBufferAttribute(Ut,vn),me[cn+mn+4]=s.x,me[cn+mn+5]=s.y,me[cn+mn+6]=s.z,me[cn+mn+7]=0),G===!0&&(s.fromBufferAttribute(tn,vn),me[cn+mn+8]=s.x,me[cn+mn+9]=s.y,me[cn+mn+10]=s.z,me[cn+mn+11]=tn.itemSize===4?s.w:1)}}y={count:m,texture:Le,size:new yn(re,ve)},n.set(c,y),c.addEventListener("dispose",Ee)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)u.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let M=0;for(let G=0;G<d.length;G++)M+=d[G];const T=c.morphTargetsRelative?1:1-M;u.getUniforms().setValue(i,"morphTargetBaseInfluence",T),u.getUniforms().setValue(i,"morphTargetInfluences",d)}u.getUniforms().setValue(i,"morphTargetsTexture",y.texture,t),u.getUniforms().setValue(i,"morphTargetsTextureSize",y.size)}return{update:o}}function gU(i,e,t,n){let s=new WeakMap;function o(u){const d=n.render.frame,p=u.geometry,m=e.get(u,p);if(s.get(m)!==d&&(e.update(m),s.set(m,d)),u.isInstancedMesh&&(u.hasEventListener("dispose",c)===!1&&u.addEventListener("dispose",c),s.get(u)!==d&&(t.update(u.instanceMatrix,i.ARRAY_BUFFER),u.instanceColor!==null&&t.update(u.instanceColor,i.ARRAY_BUFFER),s.set(u,d))),u.isSkinnedMesh){const y=u.skeleton;s.get(y)!==d&&(y.update(),s.set(y,d))}return m}function a(){s=new WeakMap}function c(u){const d=u.target;d.removeEventListener("dispose",c),t.remove(d.instanceMatrix),d.instanceColor!==null&&t.remove(d.instanceColor)}return{update:o,dispose:a}}const IA=new Ho,LA=new vc(1,1),DA=new sf,OA=new bl,FA=new xh,BA=[],UA=[],kA=new Float32Array(16),zA=new Float32Array(9),VA=new Float32Array(4);function Gg(i,e,t){const n=i[0];if(n<=0||n>0)return i;const s=e*t;let o=BA[s];if(o===void 0&&(o=new Float32Array(s),BA[s]=o),e!==0){n.toArray(o,0);for(let a=1,c=0;a!==e;++a)c+=t,i[a].toArray(o,c)}return o}function pl(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function ml(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function b_(i,e){let t=UA[e];t===void 0&&(t=new Int32Array(e),UA[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function yU(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function vU(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(pl(t,e))return;i.uniform2fv(this.addr,e),ml(t,e)}}function xU(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.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)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(pl(t,e))return;i.uniform3fv(this.addr,e),ml(t,e)}}function _U(i,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)&&(i.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(pl(t,e))return;i.uniform4fv(this.addr,e),ml(t,e)}}function bU(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(pl(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),ml(t,e)}else{if(pl(t,n))return;VA.set(n),i.uniformMatrix2fv(this.addr,!1,VA),ml(t,n)}}function wU(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(pl(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),ml(t,e)}else{if(pl(t,n))return;zA.set(n),i.uniformMatrix3fv(this.addr,!1,zA),ml(t,n)}}function MU(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(pl(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),ml(t,e)}else{if(pl(t,n))return;kA.set(n),i.uniformMatrix4fv(this.addr,!1,kA),ml(t,n)}}function SU(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function TU(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(pl(t,e))return;i.uniform2iv(this.addr,e),ml(t,e)}}function EU(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(pl(t,e))return;i.uniform3iv(this.addr,e),ml(t,e)}}function AU(i,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)&&(i.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(pl(t,e))return;i.uniform4iv(this.addr,e),ml(t,e)}}function CU(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function RU(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(pl(t,e))return;i.uniform2uiv(this.addr,e),ml(t,e)}}function NU(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(pl(t,e))return;i.uniform3uiv(this.addr,e),ml(t,e)}}function PU(i,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)&&(i.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(pl(t,e))return;i.uniform4uiv(this.addr,e),ml(t,e)}}function IU(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let o;this.type===i.SAMPLER_2D_SHADOW?(LA.compareFunction=op,o=LA):o=IA,t.setTexture2D(e||o,s)}function LU(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||OA,s)}function DU(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTextureCube(e||FA,s)}function OU(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||DA,s)}function FU(i){switch(i){case 5126:return yU;case 35664:return vU;case 35665:return xU;case 35666:return _U;case 35674:return bU;case 35675:return wU;case 35676:return MU;case 5124:case 35670:return SU;case 35667:case 35671:return TU;case 35668:case 35672:return EU;case 35669:case 35673:return AU;case 5125:return CU;case 36294:return RU;case 36295:return NU;case 36296:return PU;case 35678:case 36198:case 36298:case 36306:case 35682:return IU;case 35679:case 36299:case 36307:return LU;case 35680:case 36300:case 36308:case 36293:return DU;case 36289:case 36303:case 36311:case 36292:return OU}}function BU(i,e){i.uniform1fv(this.addr,e)}function UU(i,e){const t=Gg(e,this.size,2);i.uniform2fv(this.addr,t)}function kU(i,e){const t=Gg(e,this.size,3);i.uniform3fv(this.addr,t)}function zU(i,e){const t=Gg(e,this.size,4);i.uniform4fv(this.addr,t)}function VU(i,e){const t=Gg(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function GU(i,e){const t=Gg(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function WU(i,e){const t=Gg(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function HU(i,e){i.uniform1iv(this.addr,e)}function $U(i,e){i.uniform2iv(this.addr,e)}function jU(i,e){i.uniform3iv(this.addr,e)}function XU(i,e){i.uniform4iv(this.addr,e)}function qU(i,e){i.uniform1uiv(this.addr,e)}function YU(i,e){i.uniform2uiv(this.addr,e)}function ZU(i,e){i.uniform3uiv(this.addr,e)}function KU(i,e){i.uniform4uiv(this.addr,e)}function JU(i,e,t){const n=this.cache,s=e.length,o=b_(t,s);pl(n,o)||(i.uniform1iv(this.addr,o),ml(n,o));for(let a=0;a!==s;++a)t.setTexture2D(e[a]||IA,o[a])}function QU(i,e,t){const n=this.cache,s=e.length,o=b_(t,s);pl(n,o)||(i.uniform1iv(this.addr,o),ml(n,o));for(let a=0;a!==s;++a)t.setTexture3D(e[a]||OA,o[a])}function ek(i,e,t){const n=this.cache,s=e.length,o=b_(t,s);pl(n,o)||(i.uniform1iv(this.addr,o),ml(n,o));for(let a=0;a!==s;++a)t.setTextureCube(e[a]||FA,o[a])}function tk(i,e,t){const n=this.cache,s=e.length,o=b_(t,s);pl(n,o)||(i.uniform1iv(this.addr,o),ml(n,o));for(let a=0;a!==s;++a)t.setTexture2DArray(e[a]||DA,o[a])}function nk(i){switch(i){case 5126:return BU;case 35664:return UU;case 35665:return kU;case 35666:return zU;case 35674:return VU;case 35675:return GU;case 35676:return WU;case 5124:case 35670:return HU;case 35667:case 35671:return $U;case 35668:case 35672:return jU;case 35669:case 35673:return XU;case 5125:return qU;case 36294:return YU;case 36295:return ZU;case 36296:return KU;case 35678:case 36198:case 36298:case 36306:case 35682:return JU;case 35679:case 36299:case 36307:return QU;case 35680:case 36300:case 36308:case 36293:return ek;case 36289:case 36303:case 36311:case 36292:return tk}}class ik{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=FU(t.type)}}class rk{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=nk(t.type)}}class sk{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const s=this.seq;for(let o=0,a=s.length;o!==a;++o){const c=s[o];c.setValue(e,t[c.id],n)}}}const Hw=/(\w+)(\])?(\[|\.)?/g;function GA(i,e){i.seq.push(e),i.map[e.id]=e}function ok(i,e,t){const n=i.name,s=n.length;for(Hw.lastIndex=0;;){const o=Hw.exec(n),a=Hw.lastIndex;let c=o[1];const u=o[2]==="]",d=o[3];if(u&&(c=c|0),d===void 0||d==="["&&a+2===s){GA(t,d===void 0?new ik(c,i,e):new rk(c,i,e));break}else{let m=t.map[c];m===void 0&&(m=new sk(c),GA(t,m)),t=m}}}class w_{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){const o=e.getActiveUniform(t,s),a=e.getUniformLocation(t,o.name);ok(o,a,this)}}setValue(e,t,n,s){const o=this.map[t];o!==void 0&&o.setValue(e,n,s)}setOptional(e,t,n){const s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let o=0,a=t.length;o!==a;++o){const c=t[o],u=n[c.id];u.needsUpdate!==!1&&c.setValue(e,u.value,s)}}static seqWithValue(e,t){const n=[];for(let s=0,o=e.length;s!==o;++s){const a=e[s];a.id in t&&n.push(a)}return n}}function WA(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const ak=37297;let lk=0;function ck(i,e){const t=i.split(`
|
|
|
`),n=[],s=Math.max(e-6,0),o=Math.min(e+6,t.length);for(let a=s;a<o;a++){const c=a+1;n.push(`${c===e?">":" "} ${c}: ${t[a]}`)}return n.join(`
|
|
|
`)}const HA=new jr;function uk(i){Ki._getMatrix(HA,Ki.workingColorSpace,i);const e=`mat3( ${HA.elements.map(t=>t.toFixed(4))} )`;switch(Ki.getTransfer(i)){case dh:return[e,"LinearTransferOETF"];case Fi:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function $A(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),o=(i.getShaderInfoLog(e)||"").trim();if(n&&o==="")return"";const a=/ERROR: 0:(\d+)/.exec(o);if(a){const c=parseInt(a[1]);return t.toUpperCase()+`
|
|
|
|
|
|
`+o+`
|
|
|
|
|
|
`+ck(i.getShaderSource(e),c)}else return o}function hk(i,e){const t=uk(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
|
|
`)}function dk(i,e){let t;switch(e){case B:t="Linear";break;case te:t="Reinhard";break;case ot:t="Cineon";break;case _t:t="ACESFilmic";break;case qt:t="AgX";break;case en:t="Neutral";break;case ct:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const M_=new it;function fk(){Ki.getLuminanceCoefficients(M_);const i=M_.x.toFixed(4),e=M_.y.toFixed(4),t=M_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
|
|
`)}function pk(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Zy).join(`
|
|
|
`)}function mk(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
|
|
|
`)}function gk(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){const o=i.getActiveAttrib(e,s),a=o.name;let c=1;o.type===i.FLOAT_MAT2&&(c=2),o.type===i.FLOAT_MAT3&&(c=3),o.type===i.FLOAT_MAT4&&(c=4),t[a]={type:o.type,location:i.getAttribLocation(e,a),locationSize:c}}return t}function Zy(i){return i!==""}function jA(i,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.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 XA(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const yk=/^[ \t]*#include +<([\w\d./]+)>/gm;function $w(i){return i.replace(yk,xk)}const vk=new Map;function xk(i,e){let t=Ps[e];if(t===void 0){const n=vk.get(e);if(n!==void 0)t=Ps[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 $w(t)}const _k=/#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 qA(i){return i.replace(_k,bk)}function bk(i,e,t,n){let s="";for(let o=parseInt(e);o<parseInt(t);o++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+o+" ]").replace(/UNROLLED_LOOP_INDEX/g,o);return s}function YA(i){let e=`precision ${i.precision} float;
|
|
|
precision ${i.precision} int;
|
|
|
precision ${i.precision} sampler2D;
|
|
|
precision ${i.precision} samplerCube;
|
|
|
precision ${i.precision} sampler3D;
|
|
|
precision ${i.precision} sampler2DArray;
|
|
|
precision ${i.precision} sampler2DShadow;
|
|
|
precision ${i.precision} samplerCubeShadow;
|
|
|
precision ${i.precision} sampler2DArrayShadow;
|
|
|
precision ${i.precision} isampler2D;
|
|
|
precision ${i.precision} isampler3D;
|
|
|
precision ${i.precision} isamplerCube;
|
|
|
precision ${i.precision} isampler2DArray;
|
|
|
precision ${i.precision} usampler2D;
|
|
|
precision ${i.precision} usampler3D;
|
|
|
precision ${i.precision} usamplerCube;
|
|
|
precision ${i.precision} usampler2DArray;
|
|
|
`;return i.precision==="highp"?e+=`
|
|
|
#define HIGH_PRECISION`:i.precision==="mediump"?e+=`
|
|
|
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
|
|
|
#define LOW_PRECISION`),e}function wk(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===N?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===L?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===P&&(e="SHADOWMAP_TYPE_VSM"),e}function Mk(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case De:case We:e="ENVMAP_TYPE_CUBE";break;case qe:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Sk(i){let e="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case We:e="ENVMAP_MODE_REFRACTION";break}return e}function Tk(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case Et:e="ENVMAP_BLENDING_MULTIPLY";break;case je:e="ENVMAP_BLENDING_MIX";break;case tt:e="ENVMAP_BLENDING_ADD";break}return e}function Ek(i){const e=i.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),7*16)),texelHeight:n,maxMip:t}}function Ak(i,e,t,n){const s=i.getContext(),o=t.defines;let a=t.vertexShader,c=t.fragmentShader;const u=wk(t),d=Mk(t),p=Sk(t),m=Tk(t),y=Ek(t),M=pk(t),T=mk(o),G=s.createProgram();let z,I,J=t.glslVersion?"#version "+t.glslVersion+`
|
|
|
`:"";t.isRawShaderMaterial?(z=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T].filter(Zy).join(`
|
|
|
`),z.length>0&&(z+=`
|
|
|
`),I=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T].filter(Zy).join(`
|
|
|
`),I.length>0&&(I+=`
|
|
|
`)):(z=[YA(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",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 "+p:"",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.anisotropy?"#define USE_ANISOTROPY":"",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?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+u:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","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","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#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","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
|
|
|
`].filter(Zy).join(`
|
|
|
`),I=[YA(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+d:"",t.envMap?"#define "+p:"",t.envMap?"#define "+m:"",y?"#define CUBEUV_TEXEL_WIDTH "+y.texelWidth:"",y?"#define CUBEUV_TEXEL_HEIGHT "+y.texelHeight:"",y?"#define CUBEUV_MAX_MIP "+y.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.dispersion?"#define USE_DISPERSION":"",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||t.batchingColor?"#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 "+u:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==yt?"#define TONE_MAPPING":"",t.toneMapping!==yt?Ps.tonemapping_pars_fragment:"",t.toneMapping!==yt?dk("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ps.colorspace_pars_fragment,hk("linearToOutputTexel",t.outputColorSpace),fk(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
|
`].filter(Zy).join(`
|
|
|
`)),a=$w(a),a=jA(a,t),a=XA(a,t),c=$w(c),c=jA(c,t),c=XA(c,t),a=qA(a),c=qA(c),t.isRawShaderMaterial!==!0&&(J=`#version 300 es
|
|
|
`,z=[M,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
|
`)+`
|
|
|
`+z,I=["#define varying in",t.glslVersion===R0?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===R0?"":"#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(`
|
|
|
`)+`
|
|
|
`+I);const K=J+z+a,re=J+I+c,ve=WA(s,s.VERTEX_SHADER,K),me=WA(s,s.FRAGMENT_SHADER,re);s.attachShader(G,ve),s.attachShader(G,me),t.index0AttributeName!==void 0?s.bindAttribLocation(G,0,t.index0AttributeName):t.morphTargets===!0&&s.bindAttribLocation(G,0,"position"),s.linkProgram(G);function Le(dt){if(i.debug.checkShaderErrors){const Ut=s.getProgramInfoLog(G)||"",tn=s.getShaderInfoLog(ve)||"",cn=s.getShaderInfoLog(me)||"",vn=Ut.trim(),mn=tn.trim(),Yn=cn.trim();let xn=!0,si=!0;if(s.getProgramParameter(G,s.LINK_STATUS)===!1)if(xn=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,G,ve,me);else{const wn=$A(s,ve,"vertex"),Gn=$A(s,me,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(G,s.VALIDATE_STATUS)+`
|
|
|
|
|
|
Material Name: `+dt.name+`
|
|
|
Material Type: `+dt.type+`
|
|
|
|
|
|
Program Info Log: `+vn+`
|
|
|
`+wn+`
|
|
|
`+Gn)}else vn!==""?console.warn("THREE.WebGLProgram: Program Info Log:",vn):(mn===""||Yn==="")&&(si=!1);si&&(dt.diagnostics={runnable:xn,programLog:vn,vertexShader:{log:mn,prefix:z},fragmentShader:{log:Yn,prefix:I}})}s.deleteShader(ve),s.deleteShader(me),Ve=new w_(s,G),Ee=gk(s,G)}let Ve;this.getUniforms=function(){return Ve===void 0&&Le(this),Ve};let Ee;this.getAttributes=function(){return Ee===void 0&&Le(this),Ee};let Oe=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return Oe===!1&&(Oe=s.getProgramParameter(G,ak)),Oe},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(G),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=lk++,this.cacheKey=e,this.usedTimes=1,this.program=G,this.vertexShader=ve,this.fragmentShader=me,this}let Ck=0;class Rk{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,s=this._getShaderStage(t),o=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(s)===!1&&(a.add(s),s.usedTimes++),a.has(o)===!1&&(a.add(o),o.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 Nk(e),t.set(e,n)),n}}class Nk{constructor(e){this.id=Ck++,this.code=e,this.usedTimes=0}}function Pk(i,e,t,n,s,o,a){const c=new er,u=new Rk,d=new Set,p=[],m=s.logarithmicDepthBuffer,y=s.vertexTextures;let M=s.precision;const T={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 G(Ee){return d.add(Ee),Ee===0?"uv":`uv${Ee}`}function z(Ee,Oe,dt,Ut,tn){const cn=Ut.fog,vn=tn.geometry,mn=Ee.isMeshStandardMaterial?Ut.environment:null,Yn=(Ee.isMeshStandardMaterial?t:e).get(Ee.envMap||mn),xn=Yn&&Yn.mapping===qe?Yn.image.height:null,si=T[Ee.type];Ee.precision!==null&&(M=s.getMaxPrecision(Ee.precision),M!==Ee.precision&&console.warn("THREE.WebGLProgram.getParameters:",Ee.precision,"not supported, using",M,"instead."));const wn=vn.morphAttributes.position||vn.morphAttributes.normal||vn.morphAttributes.color,Gn=wn!==void 0?wn.length:0;let Si=0;vn.morphAttributes.position!==void 0&&(Si=1),vn.morphAttributes.normal!==void 0&&(Si=2),vn.morphAttributes.color!==void 0&&(Si=3);let nr,os,Vn,un;if(si){const bo=Ih[si];nr=bo.vertexShader,os=bo.fragmentShader}else nr=Ee.vertexShader,os=Ee.fragmentShader,u.update(Ee),Vn=u.getVertexShaderID(Ee),un=u.getFragmentShaderID(Ee);const Mn=i.getRenderTarget(),fi=i.state.buffers.depth.getReversed(),ki=tn.isInstancedMesh===!0,Ni=tn.isBatchedMesh===!0,Cr=!!Ee.map,Vs=!!Ee.matcap,kt=!!Yn,Kn=!!Ee.aoMap,Zn=!!Ee.lightMap,qn=!!Ee.bumpMap,Hn=!!Ee.normalMap,Ti=!!Ee.displacementMap,pi=!!Ee.emissiveMap,Ii=!!Ee.metalnessMap,ws=!!Ee.roughnessMap,ms=Ee.anisotropy>0,bt=Ee.clearcoat>0,Qe=Ee.dispersion>0,fn=Ee.iridescence>0,Dn=Ee.sheen>0,ri=Ee.transmission>0,zn=ms&&!!Ee.anisotropyMap,Rr=bt&&!!Ee.clearcoatMap,Ci=bt&&!!Ee.clearcoatNormalMap,Tr=bt&&!!Ee.clearcoatRoughnessMap,Er=fn&&!!Ee.iridescenceMap,mi=fn&&!!Ee.iridescenceThicknessMap,Yi=Dn&&!!Ee.sheenColorMap,ns=Dn&&!!Ee.sheenRoughnessMap,Ir=!!Ee.specularMap,Hi=!!Ee.specularColorMap,Ns=!!Ee.specularIntensityMap,rn=ri&&!!Ee.transmissionMap,wi=ri&&!!Ee.thicknessMap,Di=!!Ee.gradientMap,pr=!!Ee.alphaMap,gi=Ee.alphaTest>0,Jn=!!Ee.alphaHash,Ar=!!Ee.extensions;let Ms=yt;Ee.toneMapped&&(Mn===null||Mn.isXRRenderTarget===!0)&&(Ms=i.toneMapping);const Wo={shaderID:si,shaderType:Ee.type,shaderName:Ee.name,vertexShader:nr,fragmentShader:os,defines:Ee.defines,customVertexShaderID:Vn,customFragmentShaderID:un,isRawShaderMaterial:Ee.isRawShaderMaterial===!0,glslVersion:Ee.glslVersion,precision:M,batching:Ni,batchingColor:Ni&&tn._colorsTexture!==null,instancing:ki,instancingColor:ki&&tn.instanceColor!==null,instancingMorph:ki&&tn.morphTexture!==null,supportsVertexTextures:y,outputColorSpace:Mn===null?i.outputColorSpace:Mn.isXRRenderTarget===!0?Mn.texture.colorSpace:ou,alphaToCoverage:!!Ee.alphaToCoverage,map:Cr,matcap:Vs,envMap:kt,envMapMode:kt&&Yn.mapping,envMapCubeUVHeight:xn,aoMap:Kn,lightMap:Zn,bumpMap:qn,normalMap:Hn,displacementMap:y&&Ti,emissiveMap:pi,normalMapObjectSpace:Hn&&Ee.normalMapType===Jd,normalMapTangentSpace:Hn&&Ee.normalMapType===Xa,metalnessMap:Ii,roughnessMap:ws,anisotropy:ms,anisotropyMap:zn,clearcoat:bt,clearcoatMap:Rr,clearcoatNormalMap:Ci,clearcoatRoughnessMap:Tr,dispersion:Qe,iridescence:fn,iridescenceMap:Er,iridescenceThicknessMap:mi,sheen:Dn,sheenColorMap:Yi,sheenRoughnessMap:ns,specularMap:Ir,specularColorMap:Hi,specularIntensityMap:Ns,transmission:ri,transmissionMap:rn,thicknessMap:wi,gradientMap:Di,opaque:Ee.transparent===!1&&Ee.blending===fe&&Ee.alphaToCoverage===!1,alphaMap:pr,alphaTest:gi,alphaHash:Jn,combine:Ee.combine,mapUv:Cr&&G(Ee.map.channel),aoMapUv:Kn&&G(Ee.aoMap.channel),lightMapUv:Zn&&G(Ee.lightMap.channel),bumpMapUv:qn&&G(Ee.bumpMap.channel),normalMapUv:Hn&&G(Ee.normalMap.channel),displacementMapUv:Ti&&G(Ee.displacementMap.channel),emissiveMapUv:pi&&G(Ee.emissiveMap.channel),metalnessMapUv:Ii&&G(Ee.metalnessMap.channel),roughnessMapUv:ws&&G(Ee.roughnessMap.channel),anisotropyMapUv:zn&&G(Ee.anisotropyMap.channel),clearcoatMapUv:Rr&&G(Ee.clearcoatMap.channel),clearcoatNormalMapUv:Ci&&G(Ee.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Tr&&G(Ee.clearcoatRoughnessMap.channel),iridescenceMapUv:Er&&G(Ee.iridescenceMap.channel),iridescenceThicknessMapUv:mi&&G(Ee.iridescenceThicknessMap.channel),sheenColorMapUv:Yi&&G(Ee.sheenColorMap.channel),sheenRoughnessMapUv:ns&&G(Ee.sheenRoughnessMap.channel),specularMapUv:Ir&&G(Ee.specularMap.channel),specularColorMapUv:Hi&&G(Ee.specularColorMap.channel),specularIntensityMapUv:Ns&&G(Ee.specularIntensityMap.channel),transmissionMapUv:rn&&G(Ee.transmissionMap.channel),thicknessMapUv:wi&&G(Ee.thicknessMap.channel),alphaMapUv:pr&&G(Ee.alphaMap.channel),vertexTangents:!!vn.attributes.tangent&&(Hn||ms),vertexColors:Ee.vertexColors,vertexAlphas:Ee.vertexColors===!0&&!!vn.attributes.color&&vn.attributes.color.itemSize===4,pointsUvs:tn.isPoints===!0&&!!vn.attributes.uv&&(Cr||pr),fog:!!cn,useFog:Ee.fog===!0,fogExp2:!!cn&&cn.isFogExp2,flatShading:Ee.flatShading===!0&&Ee.wireframe===!1,sizeAttenuation:Ee.sizeAttenuation===!0,logarithmicDepthBuffer:m,reversedDepthBuffer:fi,skinning:tn.isSkinnedMesh===!0,morphTargets:vn.morphAttributes.position!==void 0,morphNormals:vn.morphAttributes.normal!==void 0,morphColors:vn.morphAttributes.color!==void 0,morphTargetsCount:Gn,morphTextureStride:Si,numDirLights:Oe.directional.length,numPointLights:Oe.point.length,numSpotLights:Oe.spot.length,numSpotLightMaps:Oe.spotLightMap.length,numRectAreaLights:Oe.rectArea.length,numHemiLights:Oe.hemi.length,numDirLightShadows:Oe.directionalShadowMap.length,numPointLightShadows:Oe.pointShadowMap.length,numSpotLightShadows:Oe.spotShadowMap.length,numSpotLightShadowsWithMaps:Oe.numSpotLightShadowsWithMaps,numLightProbes:Oe.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:Ee.dithering,shadowMapEnabled:i.shadowMap.enabled&&dt.length>0,shadowMapType:i.shadowMap.type,toneMapping:Ms,decodeVideoTexture:Cr&&Ee.map.isVideoTexture===!0&&Ki.getTransfer(Ee.map.colorSpace)===Fi,decodeVideoTextureEmissive:pi&&Ee.emissiveMap.isVideoTexture===!0&&Ki.getTransfer(Ee.emissiveMap.colorSpace)===Fi,premultipliedAlpha:Ee.premultipliedAlpha,doubleSided:Ee.side===ie,flipSided:Ee.side===Y,useDepthPacking:Ee.depthPacking>=0,depthPacking:Ee.depthPacking||0,index0AttributeName:Ee.index0AttributeName,extensionClipCullDistance:Ar&&Ee.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ar&&Ee.extensions.multiDraw===!0||Ni)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:Ee.customProgramCacheKey()};return Wo.vertexUv1s=d.has(1),Wo.vertexUv2s=d.has(2),Wo.vertexUv3s=d.has(3),d.clear(),Wo}function I(Ee){const Oe=[];if(Ee.shaderID?Oe.push(Ee.shaderID):(Oe.push(Ee.customVertexShaderID),Oe.push(Ee.customFragmentShaderID)),Ee.defines!==void 0)for(const dt in Ee.defines)Oe.push(dt),Oe.push(Ee.defines[dt]);return Ee.isRawShaderMaterial===!1&&(J(Oe,Ee),K(Oe,Ee),Oe.push(i.outputColorSpace)),Oe.push(Ee.customProgramCacheKey),Oe.join()}function J(Ee,Oe){Ee.push(Oe.precision),Ee.push(Oe.outputColorSpace),Ee.push(Oe.envMapMode),Ee.push(Oe.envMapCubeUVHeight),Ee.push(Oe.mapUv),Ee.push(Oe.alphaMapUv),Ee.push(Oe.lightMapUv),Ee.push(Oe.aoMapUv),Ee.push(Oe.bumpMapUv),Ee.push(Oe.normalMapUv),Ee.push(Oe.displacementMapUv),Ee.push(Oe.emissiveMapUv),Ee.push(Oe.metalnessMapUv),Ee.push(Oe.roughnessMapUv),Ee.push(Oe.anisotropyMapUv),Ee.push(Oe.clearcoatMapUv),Ee.push(Oe.clearcoatNormalMapUv),Ee.push(Oe.clearcoatRoughnessMapUv),Ee.push(Oe.iridescenceMapUv),Ee.push(Oe.iridescenceThicknessMapUv),Ee.push(Oe.sheenColorMapUv),Ee.push(Oe.sheenRoughnessMapUv),Ee.push(Oe.specularMapUv),Ee.push(Oe.specularColorMapUv),Ee.push(Oe.specularIntensityMapUv),Ee.push(Oe.transmissionMapUv),Ee.push(Oe.thicknessMapUv),Ee.push(Oe.combine),Ee.push(Oe.fogExp2),Ee.push(Oe.sizeAttenuation),Ee.push(Oe.morphTargetsCount),Ee.push(Oe.morphAttributeCount),Ee.push(Oe.numDirLights),Ee.push(Oe.numPointLights),Ee.push(Oe.numSpotLights),Ee.push(Oe.numSpotLightMaps),Ee.push(Oe.numHemiLights),Ee.push(Oe.numRectAreaLights),Ee.push(Oe.numDirLightShadows),Ee.push(Oe.numPointLightShadows),Ee.push(Oe.numSpotLightShadows),Ee.push(Oe.numSpotLightShadowsWithMaps),Ee.push(Oe.numLightProbes),Ee.push(Oe.shadowMapType),Ee.push(Oe.toneMapping),Ee.push(Oe.numClippingPlanes),Ee.push(Oe.numClipIntersection),Ee.push(Oe.depthPacking)}function K(Ee,Oe){c.disableAll(),Oe.supportsVertexTextures&&c.enable(0),Oe.instancing&&c.enable(1),Oe.instancingColor&&c.enable(2),Oe.instancingMorph&&c.enable(3),Oe.matcap&&c.enable(4),Oe.envMap&&c.enable(5),Oe.normalMapObjectSpace&&c.enable(6),Oe.normalMapTangentSpace&&c.enable(7),Oe.clearcoat&&c.enable(8),Oe.iridescence&&c.enable(9),Oe.alphaTest&&c.enable(10),Oe.vertexColors&&c.enable(11),Oe.vertexAlphas&&c.enable(12),Oe.vertexUv1s&&c.enable(13),Oe.vertexUv2s&&c.enable(14),Oe.vertexUv3s&&c.enable(15),Oe.vertexTangents&&c.enable(16),Oe.anisotropy&&c.enable(17),Oe.alphaHash&&c.enable(18),Oe.batching&&c.enable(19),Oe.dispersion&&c.enable(20),Oe.batchingColor&&c.enable(21),Oe.gradientMap&&c.enable(22),Ee.push(c.mask),c.disableAll(),Oe.fog&&c.enable(0),Oe.useFog&&c.enable(1),Oe.flatShading&&c.enable(2),Oe.logarithmicDepthBuffer&&c.enable(3),Oe.reversedDepthBuffer&&c.enable(4),Oe.skinning&&c.enable(5),Oe.morphTargets&&c.enable(6),Oe.morphNormals&&c.enable(7),Oe.morphColors&&c.enable(8),Oe.premultipliedAlpha&&c.enable(9),Oe.shadowMapEnabled&&c.enable(10),Oe.doubleSided&&c.enable(11),Oe.flipSided&&c.enable(12),Oe.useDepthPacking&&c.enable(13),Oe.dithering&&c.enable(14),Oe.transmission&&c.enable(15),Oe.sheen&&c.enable(16),Oe.opaque&&c.enable(17),Oe.pointsUvs&&c.enable(18),Oe.decodeVideoTexture&&c.enable(19),Oe.decodeVideoTextureEmissive&&c.enable(20),Oe.alphaToCoverage&&c.enable(21),Ee.push(c.mask)}function re(Ee){const Oe=T[Ee.type];let dt;if(Oe){const Ut=Ih[Oe];dt=fp.clone(Ut.uniforms)}else dt=Ee.uniforms;return dt}function ve(Ee,Oe){let dt;for(let Ut=0,tn=p.length;Ut<tn;Ut++){const cn=p[Ut];if(cn.cacheKey===Oe){dt=cn,++dt.usedTimes;break}}return dt===void 0&&(dt=new Ak(i,Oe,Ee,o),p.push(dt)),dt}function me(Ee){if(--Ee.usedTimes===0){const Oe=p.indexOf(Ee);p[Oe]=p[p.length-1],p.pop(),Ee.destroy()}}function Le(Ee){u.remove(Ee)}function Ve(){u.dispose()}return{getParameters:z,getProgramCacheKey:I,getUniforms:re,acquireProgram:ve,releaseProgram:me,releaseShaderCache:Le,programs:p,dispose:Ve}}function Ik(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let c=i.get(a);return c===void 0&&(c={},i.set(a,c)),c}function n(a){i.delete(a)}function s(a,c,u){i.get(a)[c]=u}function o(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:o}}function Lk(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function ZA(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function KA(){const i=[];let e=0;const t=[],n=[],s=[];function o(){e=0,t.length=0,n.length=0,s.length=0}function a(m,y,M,T,G,z){let I=i[e];return I===void 0?(I={id:m.id,object:m,geometry:y,material:M,groupOrder:T,renderOrder:m.renderOrder,z:G,group:z},i[e]=I):(I.id=m.id,I.object=m,I.geometry=y,I.material=M,I.groupOrder=T,I.renderOrder=m.renderOrder,I.z=G,I.group=z),e++,I}function c(m,y,M,T,G,z){const I=a(m,y,M,T,G,z);M.transmission>0?n.push(I):M.transparent===!0?s.push(I):t.push(I)}function u(m,y,M,T,G,z){const I=a(m,y,M,T,G,z);M.transmission>0?n.unshift(I):M.transparent===!0?s.unshift(I):t.unshift(I)}function d(m,y){t.length>1&&t.sort(m||Lk),n.length>1&&n.sort(y||ZA),s.length>1&&s.sort(y||ZA)}function p(){for(let m=e,y=i.length;m<y;m++){const M=i[m];if(M.id===null)break;M.id=null,M.object=null,M.geometry=null,M.material=null,M.group=null}}return{opaque:t,transmissive:n,transparent:s,init:o,push:c,unshift:u,finish:p,sort:d}}function Dk(){let i=new WeakMap;function e(n,s){const o=i.get(n);let a;return o===void 0?(a=new KA,i.set(n,[a])):s>=o.length?(a=new KA,o.push(a)):a=o[s],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function Ok(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new it,color:new jn};break;case"SpotLight":t={position:new it,direction:new it,color:new jn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new it,color:new jn,distance:0,decay:0};break;case"HemisphereLight":t={direction:new it,skyColor:new jn,groundColor:new jn};break;case"RectAreaLight":t={color:new jn,position:new it,halfWidth:new it,halfHeight:new it};break}return i[e.id]=t,t}}}function Fk(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new yn};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new yn};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new yn,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let Bk=0;function Uk(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function kk(i){const e=new Ok,t=Fk(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-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,numLightProbes:0};for(let d=0;d<9;d++)n.probe.push(new it);const s=new it,o=new Ft,a=new Ft;function c(d){let p=0,m=0,y=0;for(let Ee=0;Ee<9;Ee++)n.probe[Ee].set(0,0,0);let M=0,T=0,G=0,z=0,I=0,J=0,K=0,re=0,ve=0,me=0,Le=0;d.sort(Uk);for(let Ee=0,Oe=d.length;Ee<Oe;Ee++){const dt=d[Ee],Ut=dt.color,tn=dt.intensity,cn=dt.distance,vn=dt.shadow&&dt.shadow.map?dt.shadow.map.texture:null;if(dt.isAmbientLight)p+=Ut.r*tn,m+=Ut.g*tn,y+=Ut.b*tn;else if(dt.isLightProbe){for(let mn=0;mn<9;mn++)n.probe[mn].addScaledVector(dt.sh.coefficients[mn],tn);Le++}else if(dt.isDirectionalLight){const mn=e.get(dt);if(mn.color.copy(dt.color).multiplyScalar(dt.intensity),dt.castShadow){const Yn=dt.shadow,xn=t.get(dt);xn.shadowIntensity=Yn.intensity,xn.shadowBias=Yn.bias,xn.shadowNormalBias=Yn.normalBias,xn.shadowRadius=Yn.radius,xn.shadowMapSize=Yn.mapSize,n.directionalShadow[M]=xn,n.directionalShadowMap[M]=vn,n.directionalShadowMatrix[M]=dt.shadow.matrix,J++}n.directional[M]=mn,M++}else if(dt.isSpotLight){const mn=e.get(dt);mn.position.setFromMatrixPosition(dt.matrixWorld),mn.color.copy(Ut).multiplyScalar(tn),mn.distance=cn,mn.coneCos=Math.cos(dt.angle),mn.penumbraCos=Math.cos(dt.angle*(1-dt.penumbra)),mn.decay=dt.decay,n.spot[G]=mn;const Yn=dt.shadow;if(dt.map&&(n.spotLightMap[ve]=dt.map,ve++,Yn.updateMatrices(dt),dt.castShadow&&me++),n.spotLightMatrix[G]=Yn.matrix,dt.castShadow){const xn=t.get(dt);xn.shadowIntensity=Yn.intensity,xn.shadowBias=Yn.bias,xn.shadowNormalBias=Yn.normalBias,xn.shadowRadius=Yn.radius,xn.shadowMapSize=Yn.mapSize,n.spotShadow[G]=xn,n.spotShadowMap[G]=vn,re++}G++}else if(dt.isRectAreaLight){const mn=e.get(dt);mn.color.copy(Ut).multiplyScalar(tn),mn.halfWidth.set(dt.width*.5,0,0),mn.halfHeight.set(0,dt.height*.5,0),n.rectArea[z]=mn,z++}else if(dt.isPointLight){const mn=e.get(dt);if(mn.color.copy(dt.color).multiplyScalar(dt.intensity),mn.distance=dt.distance,mn.decay=dt.decay,dt.castShadow){const Yn=dt.shadow,xn=t.get(dt);xn.shadowIntensity=Yn.intensity,xn.shadowBias=Yn.bias,xn.shadowNormalBias=Yn.normalBias,xn.shadowRadius=Yn.radius,xn.shadowMapSize=Yn.mapSize,xn.shadowCameraNear=Yn.camera.near,xn.shadowCameraFar=Yn.camera.far,n.pointShadow[T]=xn,n.pointShadowMap[T]=vn,n.pointShadowMatrix[T]=dt.shadow.matrix,K++}n.point[T]=mn,T++}else if(dt.isHemisphereLight){const mn=e.get(dt);mn.skyColor.copy(dt.color).multiplyScalar(tn),mn.groundColor.copy(dt.groundColor).multiplyScalar(tn),n.hemi[I]=mn,I++}}z>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=zi.LTC_FLOAT_1,n.rectAreaLTC2=zi.LTC_FLOAT_2):(n.rectAreaLTC1=zi.LTC_HALF_1,n.rectAreaLTC2=zi.LTC_HALF_2)),n.ambient[0]=p,n.ambient[1]=m,n.ambient[2]=y;const Ve=n.hash;(Ve.directionalLength!==M||Ve.pointLength!==T||Ve.spotLength!==G||Ve.rectAreaLength!==z||Ve.hemiLength!==I||Ve.numDirectionalShadows!==J||Ve.numPointShadows!==K||Ve.numSpotShadows!==re||Ve.numSpotMaps!==ve||Ve.numLightProbes!==Le)&&(n.directional.length=M,n.spot.length=G,n.rectArea.length=z,n.point.length=T,n.hemi.length=I,n.directionalShadow.length=J,n.directionalShadowMap.length=J,n.pointShadow.length=K,n.pointShadowMap.length=K,n.spotShadow.length=re,n.spotShadowMap.length=re,n.directionalShadowMatrix.length=J,n.pointShadowMatrix.length=K,n.spotLightMatrix.length=re+ve-me,n.spotLightMap.length=ve,n.numSpotLightShadowsWithMaps=me,n.numLightProbes=Le,Ve.directionalLength=M,Ve.pointLength=T,Ve.spotLength=G,Ve.rectAreaLength=z,Ve.hemiLength=I,Ve.numDirectionalShadows=J,Ve.numPointShadows=K,Ve.numSpotShadows=re,Ve.numSpotMaps=ve,Ve.numLightProbes=Le,n.version=Bk++)}function u(d,p){let m=0,y=0,M=0,T=0,G=0;const z=p.matrixWorldInverse;for(let I=0,J=d.length;I<J;I++){const K=d[I];if(K.isDirectionalLight){const re=n.directional[m];re.direction.setFromMatrixPosition(K.matrixWorld),s.setFromMatrixPosition(K.target.matrixWorld),re.direction.sub(s),re.direction.transformDirection(z),m++}else if(K.isSpotLight){const re=n.spot[M];re.position.setFromMatrixPosition(K.matrixWorld),re.position.applyMatrix4(z),re.direction.setFromMatrixPosition(K.matrixWorld),s.setFromMatrixPosition(K.target.matrixWorld),re.direction.sub(s),re.direction.transformDirection(z),M++}else if(K.isRectAreaLight){const re=n.rectArea[T];re.position.setFromMatrixPosition(K.matrixWorld),re.position.applyMatrix4(z),a.identity(),o.copy(K.matrixWorld),o.premultiply(z),a.extractRotation(o),re.halfWidth.set(K.width*.5,0,0),re.halfHeight.set(0,K.height*.5,0),re.halfWidth.applyMatrix4(a),re.halfHeight.applyMatrix4(a),T++}else if(K.isPointLight){const re=n.point[y];re.position.setFromMatrixPosition(K.matrixWorld),re.position.applyMatrix4(z),y++}else if(K.isHemisphereLight){const re=n.hemi[G];re.direction.setFromMatrixPosition(K.matrixWorld),re.direction.transformDirection(z),G++}}}return{setup:c,setupView:u,state:n}}function JA(i){const e=new kk(i),t=[],n=[];function s(p){d.camera=p,t.length=0,n.length=0}function o(p){t.push(p)}function a(p){n.push(p)}function c(){e.setup(t)}function u(p){e.setupView(t,p)}const d={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:s,state:d,setupLights:c,setupLightsView:u,pushLight:o,pushShadow:a}}function zk(i){let e=new WeakMap;function t(s,o=0){const a=e.get(s);let c;return a===void 0?(c=new JA(i),e.set(s,[c])):o>=a.length?(c=new JA(i),a.push(c)):c=a[o],c}function n(){e=new WeakMap}return{get:t,dispose:n}}const Vk=`void main() {
|
|
|
gl_Position = vec4( position, 1.0 );
|
|
|
}`,Gk=`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 Wk(i,e,t){let n=new pf;const s=new yn,o=new yn,a=new mr,c=new Bx({depthPacking:sp}),u=new Ux,d={},p=t.maxTextureSize,m={[W]:Y,[Y]:W,[ie]:ie},y=new kc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new yn},radius:{value:4}},vertexShader:Vk,fragmentShader:Gk}),M=y.clone();M.defines.HORIZONTAL_PASS=1;const T=new xr;T.setAttribute("position",new es(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const G=new Ks(T,y),z=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=N;let I=this.type;this.render=function(me,Le,Ve){if(z.enabled===!1||z.autoUpdate===!1&&z.needsUpdate===!1||me.length===0)return;const Ee=i.getRenderTarget(),Oe=i.getActiveCubeFace(),dt=i.getActiveMipmapLevel(),Ut=i.state;Ut.setBlending(pe),Ut.buffers.depth.getReversed()===!0?Ut.buffers.color.setClear(0,0,0,0):Ut.buffers.color.setClear(1,1,1,1),Ut.buffers.depth.setTest(!0),Ut.setScissorTest(!1);const tn=I!==P&&this.type===P,cn=I===P&&this.type!==P;for(let vn=0,mn=me.length;vn<mn;vn++){const Yn=me[vn],xn=Yn.shadow;if(xn===void 0){console.warn("THREE.WebGLShadowMap:",Yn,"has no shadow.");continue}if(xn.autoUpdate===!1&&xn.needsUpdate===!1)continue;s.copy(xn.mapSize);const si=xn.getFrameExtents();if(s.multiply(si),o.copy(xn.mapSize),(s.x>p||s.y>p)&&(s.x>p&&(o.x=Math.floor(p/si.x),s.x=o.x*si.x,xn.mapSize.x=o.x),s.y>p&&(o.y=Math.floor(p/si.y),s.y=o.y*si.y,xn.mapSize.y=o.y)),xn.map===null||tn===!0||cn===!0){const Gn=this.type!==P?{minFilter:Ct,magFilter:Ct}:{};xn.map!==null&&xn.map.dispose(),xn.map=new hc(s.x,s.y,Gn),xn.map.texture.name=Yn.name+".shadowMap",xn.camera.updateProjectionMatrix()}i.setRenderTarget(xn.map),i.clear();const wn=xn.getViewportCount();for(let Gn=0;Gn<wn;Gn++){const Si=xn.getViewport(Gn);a.set(o.x*Si.x,o.y*Si.y,o.x*Si.z,o.y*Si.w),Ut.viewport(a),xn.updateMatrices(Yn,Gn),n=xn.getFrustum(),re(Le,Ve,xn.camera,Yn,this.type)}xn.isPointLightShadow!==!0&&this.type===P&&J(xn,Ve),xn.needsUpdate=!1}I=this.type,z.needsUpdate=!1,i.setRenderTarget(Ee,Oe,dt)};function J(me,Le){const Ve=e.update(G);y.defines.VSM_SAMPLES!==me.blurSamples&&(y.defines.VSM_SAMPLES=me.blurSamples,M.defines.VSM_SAMPLES=me.blurSamples,y.needsUpdate=!0,M.needsUpdate=!0),me.mapPass===null&&(me.mapPass=new hc(s.x,s.y)),y.uniforms.shadow_pass.value=me.map.texture,y.uniforms.resolution.value=me.mapSize,y.uniforms.radius.value=me.radius,i.setRenderTarget(me.mapPass),i.clear(),i.renderBufferDirect(Le,null,Ve,y,G,null),M.uniforms.shadow_pass.value=me.mapPass.texture,M.uniforms.resolution.value=me.mapSize,M.uniforms.radius.value=me.radius,i.setRenderTarget(me.map),i.clear(),i.renderBufferDirect(Le,null,Ve,M,G,null)}function K(me,Le,Ve,Ee){let Oe=null;const dt=Ve.isPointLight===!0?me.customDistanceMaterial:me.customDepthMaterial;if(dt!==void 0)Oe=dt;else if(Oe=Ve.isPointLight===!0?u:c,i.localClippingEnabled&&Le.clipShadows===!0&&Array.isArray(Le.clippingPlanes)&&Le.clippingPlanes.length!==0||Le.displacementMap&&Le.displacementScale!==0||Le.alphaMap&&Le.alphaTest>0||Le.map&&Le.alphaTest>0||Le.alphaToCoverage===!0){const Ut=Oe.uuid,tn=Le.uuid;let cn=d[Ut];cn===void 0&&(cn={},d[Ut]=cn);let vn=cn[tn];vn===void 0&&(vn=Oe.clone(),cn[tn]=vn,Le.addEventListener("dispose",ve)),Oe=vn}if(Oe.visible=Le.visible,Oe.wireframe=Le.wireframe,Ee===P?Oe.side=Le.shadowSide!==null?Le.shadowSide:Le.side:Oe.side=Le.shadowSide!==null?Le.shadowSide:m[Le.side],Oe.alphaMap=Le.alphaMap,Oe.alphaTest=Le.alphaToCoverage===!0?.5:Le.alphaTest,Oe.map=Le.map,Oe.clipShadows=Le.clipShadows,Oe.clippingPlanes=Le.clippingPlanes,Oe.clipIntersection=Le.clipIntersection,Oe.displacementMap=Le.displacementMap,Oe.displacementScale=Le.displacementScale,Oe.displacementBias=Le.displacementBias,Oe.wireframeLinewidth=Le.wireframeLinewidth,Oe.linewidth=Le.linewidth,Ve.isPointLight===!0&&Oe.isMeshDistanceMaterial===!0){const Ut=i.properties.get(Oe);Ut.light=Ve}return Oe}function re(me,Le,Ve,Ee,Oe){if(me.visible===!1)return;if(me.layers.test(Le.layers)&&(me.isMesh||me.isLine||me.isPoints)&&(me.castShadow||me.receiveShadow&&Oe===P)&&(!me.frustumCulled||n.intersectsObject(me))){me.modelViewMatrix.multiplyMatrices(Ve.matrixWorldInverse,me.matrixWorld);const tn=e.update(me),cn=me.material;if(Array.isArray(cn)){const vn=tn.groups;for(let mn=0,Yn=vn.length;mn<Yn;mn++){const xn=vn[mn],si=cn[xn.materialIndex];if(si&&si.visible){const wn=K(me,si,Ee,Oe);me.onBeforeShadow(i,me,Le,Ve,tn,wn,xn),i.renderBufferDirect(Ve,null,tn,wn,me,xn),me.onAfterShadow(i,me,Le,Ve,tn,wn,xn)}}}else if(cn.visible){const vn=K(me,cn,Ee,Oe);me.onBeforeShadow(i,me,Le,Ve,tn,vn,null),i.renderBufferDirect(Ve,null,tn,vn,me,null),me.onAfterShadow(i,me,Le,Ve,tn,vn,null)}}const Ut=me.children;for(let tn=0,cn=Ut.length;tn<cn;tn++)re(Ut[tn],Le,Ve,Ee,Oe)}function ve(me){me.target.removeEventListener("dispose",ve);for(const Ve in d){const Ee=d[Ve],Oe=me.target.uuid;Oe in Ee&&(Ee[Oe].dispose(),delete Ee[Oe])}}}const Hk={[Ue]:Ye,[be]:Be,[Ke]:ut,[ge]:wt,[Ye]:Ue,[Be]:be,[ut]:Ke,[wt]:ge};function $k(i,e){function t(){let rn=!1;const wi=new mr;let Di=null;const pr=new mr(0,0,0,0);return{setMask:function(gi){Di!==gi&&!rn&&(i.colorMask(gi,gi,gi,gi),Di=gi)},setLocked:function(gi){rn=gi},setClear:function(gi,Jn,Ar,Ms,Wo){Wo===!0&&(gi*=Ms,Jn*=Ms,Ar*=Ms),wi.set(gi,Jn,Ar,Ms),pr.equals(wi)===!1&&(i.clearColor(gi,Jn,Ar,Ms),pr.copy(wi))},reset:function(){rn=!1,Di=null,pr.set(-1,0,0,0)}}}function n(){let rn=!1,wi=!1,Di=null,pr=null,gi=null;return{setReversed:function(Jn){if(wi!==Jn){const Ar=e.get("EXT_clip_control");Jn?Ar.clipControlEXT(Ar.LOWER_LEFT_EXT,Ar.ZERO_TO_ONE_EXT):Ar.clipControlEXT(Ar.LOWER_LEFT_EXT,Ar.NEGATIVE_ONE_TO_ONE_EXT),wi=Jn;const Ms=gi;gi=null,this.setClear(Ms)}},getReversed:function(){return wi},setTest:function(Jn){Jn?Mn(i.DEPTH_TEST):fi(i.DEPTH_TEST)},setMask:function(Jn){Di!==Jn&&!rn&&(i.depthMask(Jn),Di=Jn)},setFunc:function(Jn){if(wi&&(Jn=Hk[Jn]),pr!==Jn){switch(Jn){case Ue:i.depthFunc(i.NEVER);break;case Ye:i.depthFunc(i.ALWAYS);break;case be:i.depthFunc(i.LESS);break;case ge:i.depthFunc(i.LEQUAL);break;case Ke:i.depthFunc(i.EQUAL);break;case wt:i.depthFunc(i.GEQUAL);break;case Be:i.depthFunc(i.GREATER);break;case ut:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}pr=Jn}},setLocked:function(Jn){rn=Jn},setClear:function(Jn){gi!==Jn&&(wi&&(Jn=1-Jn),i.clearDepth(Jn),gi=Jn)},reset:function(){rn=!1,Di=null,pr=null,gi=null,wi=!1}}}function s(){let rn=!1,wi=null,Di=null,pr=null,gi=null,Jn=null,Ar=null,Ms=null,Wo=null;return{setTest:function(bo){rn||(bo?Mn(i.STENCIL_TEST):fi(i.STENCIL_TEST))},setMask:function(bo){wi!==bo&&!rn&&(i.stencilMask(bo),wi=bo)},setFunc:function(bo,Kd,Kh){(Di!==bo||pr!==Kd||gi!==Kh)&&(i.stencilFunc(bo,Kd,Kh),Di=bo,pr=Kd,gi=Kh)},setOp:function(bo,Kd,Kh){(Jn!==bo||Ar!==Kd||Ms!==Kh)&&(i.stencilOp(bo,Kd,Kh),Jn=bo,Ar=Kd,Ms=Kh)},setLocked:function(bo){rn=bo},setClear:function(bo){Wo!==bo&&(i.clearStencil(bo),Wo=bo)},reset:function(){rn=!1,wi=null,Di=null,pr=null,gi=null,Jn=null,Ar=null,Ms=null,Wo=null}}}const o=new t,a=new n,c=new s,u=new WeakMap,d=new WeakMap;let p={},m={},y=new WeakMap,M=[],T=null,G=!1,z=null,I=null,J=null,K=null,re=null,ve=null,me=null,Le=new jn(0,0,0),Ve=0,Ee=!1,Oe=null,dt=null,Ut=null,tn=null,cn=null;const vn=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let mn=!1,Yn=0;const xn=i.getParameter(i.VERSION);xn.indexOf("WebGL")!==-1?(Yn=parseFloat(/^WebGL (\d)/.exec(xn)[1]),mn=Yn>=1):xn.indexOf("OpenGL ES")!==-1&&(Yn=parseFloat(/^OpenGL ES (\d)/.exec(xn)[1]),mn=Yn>=2);let si=null,wn={};const Gn=i.getParameter(i.SCISSOR_BOX),Si=i.getParameter(i.VIEWPORT),nr=new mr().fromArray(Gn),os=new mr().fromArray(Si);function Vn(rn,wi,Di,pr){const gi=new Uint8Array(4),Jn=i.createTexture();i.bindTexture(rn,Jn),i.texParameteri(rn,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(rn,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Ar=0;Ar<Di;Ar++)rn===i.TEXTURE_3D||rn===i.TEXTURE_2D_ARRAY?i.texImage3D(wi,0,i.RGBA,1,1,pr,0,i.RGBA,i.UNSIGNED_BYTE,gi):i.texImage2D(wi+Ar,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,gi);return Jn}const un={};un[i.TEXTURE_2D]=Vn(i.TEXTURE_2D,i.TEXTURE_2D,1),un[i.TEXTURE_CUBE_MAP]=Vn(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),un[i.TEXTURE_2D_ARRAY]=Vn(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),un[i.TEXTURE_3D]=Vn(i.TEXTURE_3D,i.TEXTURE_3D,1,1),o.setClear(0,0,0,1),a.setClear(1),c.setClear(0),Mn(i.DEPTH_TEST),a.setFunc(ge),qn(!1),Hn(S),Mn(i.CULL_FACE),Kn(pe);function Mn(rn){p[rn]!==!0&&(i.enable(rn),p[rn]=!0)}function fi(rn){p[rn]!==!1&&(i.disable(rn),p[rn]=!1)}function ki(rn,wi){return m[rn]!==wi?(i.bindFramebuffer(rn,wi),m[rn]=wi,rn===i.DRAW_FRAMEBUFFER&&(m[i.FRAMEBUFFER]=wi),rn===i.FRAMEBUFFER&&(m[i.DRAW_FRAMEBUFFER]=wi),!0):!1}function Ni(rn,wi){let Di=M,pr=!1;if(rn){Di=y.get(wi),Di===void 0&&(Di=[],y.set(wi,Di));const gi=rn.textures;if(Di.length!==gi.length||Di[0]!==i.COLOR_ATTACHMENT0){for(let Jn=0,Ar=gi.length;Jn<Ar;Jn++)Di[Jn]=i.COLOR_ATTACHMENT0+Jn;Di.length=gi.length,pr=!0}}else Di[0]!==i.BACK&&(Di[0]=i.BACK,pr=!0);pr&&i.drawBuffers(Di)}function Cr(rn){return T!==rn?(i.useProgram(rn),T=rn,!0):!1}const Vs={[Te]:i.FUNC_ADD,[_e]:i.FUNC_SUBTRACT,[Xe]:i.FUNC_REVERSE_SUBTRACT};Vs[Se]=i.MIN,Vs[Ge]=i.MAX;const kt={[He]:i.ZERO,[vt]:i.ONE,[It]:i.SRC_COLOR,[Yt]:i.SRC_ALPHA,[gt]:i.SRC_ALPHA_SATURATE,[le]:i.DST_COLOR,[lt]:i.DST_ALPHA,[zt]:i.ONE_MINUS_SRC_COLOR,[At]:i.ONE_MINUS_SRC_ALPHA,[Fe]:i.ONE_MINUS_DST_COLOR,[Ot]:i.ONE_MINUS_DST_ALPHA,[Jt]:i.CONSTANT_COLOR,[Ze]:i.ONE_MINUS_CONSTANT_COLOR,[rt]:i.CONSTANT_ALPHA,[Mt]:i.ONE_MINUS_CONSTANT_ALPHA};function Kn(rn,wi,Di,pr,gi,Jn,Ar,Ms,Wo,bo){if(rn===pe){G===!0&&(fi(i.BLEND),G=!1);return}if(G===!1&&(Mn(i.BLEND),G=!0),rn!==Ne){if(rn!==z||bo!==Ee){if((I!==Te||re!==Te)&&(i.blendEquation(i.FUNC_ADD),I=Te,re=Te),bo)switch(rn){case fe:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ae:i.blendFunc(i.ONE,i.ONE);break;case ye:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case ue:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",rn);break}else switch(rn){case fe:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ae:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case ye:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case ue:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",rn);break}J=null,K=null,ve=null,me=null,Le.set(0,0,0),Ve=0,z=rn,Ee=bo}return}gi=gi||wi,Jn=Jn||Di,Ar=Ar||pr,(wi!==I||gi!==re)&&(i.blendEquationSeparate(Vs[wi],Vs[gi]),I=wi,re=gi),(Di!==J||pr!==K||Jn!==ve||Ar!==me)&&(i.blendFuncSeparate(kt[Di],kt[pr],kt[Jn],kt[Ar]),J=Di,K=pr,ve=Jn,me=Ar),(Ms.equals(Le)===!1||Wo!==Ve)&&(i.blendColor(Ms.r,Ms.g,Ms.b,Wo),Le.copy(Ms),Ve=Wo),z=rn,Ee=!1}function Zn(rn,wi){rn.side===ie?fi(i.CULL_FACE):Mn(i.CULL_FACE);let Di=rn.side===Y;wi&&(Di=!Di),qn(Di),rn.blending===fe&&rn.transparent===!1?Kn(pe):Kn(rn.blending,rn.blendEquation,rn.blendSrc,rn.blendDst,rn.blendEquationAlpha,rn.blendSrcAlpha,rn.blendDstAlpha,rn.blendColor,rn.blendAlpha,rn.premultipliedAlpha),a.setFunc(rn.depthFunc),a.setTest(rn.depthTest),a.setMask(rn.depthWrite),o.setMask(rn.colorWrite);const pr=rn.stencilWrite;c.setTest(pr),pr&&(c.setMask(rn.stencilWriteMask),c.setFunc(rn.stencilFunc,rn.stencilRef,rn.stencilFuncMask),c.setOp(rn.stencilFail,rn.stencilZFail,rn.stencilZPass)),pi(rn.polygonOffset,rn.polygonOffsetFactor,rn.polygonOffsetUnits),rn.alphaToCoverage===!0?Mn(i.SAMPLE_ALPHA_TO_COVERAGE):fi(i.SAMPLE_ALPHA_TO_COVERAGE)}function qn(rn){Oe!==rn&&(rn?i.frontFace(i.CW):i.frontFace(i.CCW),Oe=rn)}function Hn(rn){rn!==R?(Mn(i.CULL_FACE),rn!==dt&&(rn===S?i.cullFace(i.BACK):rn===C?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):fi(i.CULL_FACE),dt=rn}function Ti(rn){rn!==Ut&&(mn&&i.lineWidth(rn),Ut=rn)}function pi(rn,wi,Di){rn?(Mn(i.POLYGON_OFFSET_FILL),(tn!==wi||cn!==Di)&&(i.polygonOffset(wi,Di),tn=wi,cn=Di)):fi(i.POLYGON_OFFSET_FILL)}function Ii(rn){rn?Mn(i.SCISSOR_TEST):fi(i.SCISSOR_TEST)}function ws(rn){rn===void 0&&(rn=i.TEXTURE0+vn-1),si!==rn&&(i.activeTexture(rn),si=rn)}function ms(rn,wi,Di){Di===void 0&&(si===null?Di=i.TEXTURE0+vn-1:Di=si);let pr=wn[Di];pr===void 0&&(pr={type:void 0,texture:void 0},wn[Di]=pr),(pr.type!==rn||pr.texture!==wi)&&(si!==Di&&(i.activeTexture(Di),si=Di),i.bindTexture(rn,wi||un[rn]),pr.type=rn,pr.texture=wi)}function bt(){const rn=wn[si];rn!==void 0&&rn.type!==void 0&&(i.bindTexture(rn.type,null),rn.type=void 0,rn.texture=void 0)}function Qe(){try{i.compressedTexImage2D(...arguments)}catch(rn){console.error("THREE.WebGLState:",rn)}}function fn(){try{i.compressedTexImage3D(...arguments)}catch(rn){console.error("THREE.WebGLState:",rn)}}function Dn(){try{i.texSubImage2D(...arguments)}catch(rn){console.error("THREE.WebGLState:",rn)}}function ri(){try{i.texSubImage3D(...arguments)}catch(rn){console.error("THREE.WebGLState:",rn)}}function zn(){try{i.compressedTexSubImage2D(...arguments)}catch(rn){console.error("THREE.WebGLState:",rn)}}function Rr(){try{i.compressedTexSubImage3D(...arguments)}catch(rn){console.error("THREE.WebGLState:",rn)}}function Ci(){try{i.texStorage2D(...arguments)}catch(rn){console.error("THREE.WebGLState:",rn)}}function Tr(){try{i.texStorage3D(...arguments)}catch(rn){console.error("THREE.WebGLState:",rn)}}function Er(){try{i.texImage2D(...arguments)}catch(rn){console.error("THREE.WebGLState:",rn)}}function mi(){try{i.texImage3D(...arguments)}catch(rn){console.error("THREE.WebGLState:",rn)}}function Yi(rn){nr.equals(rn)===!1&&(i.scissor(rn.x,rn.y,rn.z,rn.w),nr.copy(rn))}function ns(rn){os.equals(rn)===!1&&(i.viewport(rn.x,rn.y,rn.z,rn.w),os.copy(rn))}function Ir(rn,wi){let Di=d.get(wi);Di===void 0&&(Di=new WeakMap,d.set(wi,Di));let pr=Di.get(rn);pr===void 0&&(pr=i.getUniformBlockIndex(wi,rn.name),Di.set(rn,pr))}function Hi(rn,wi){const pr=d.get(wi).get(rn);u.get(wi)!==pr&&(i.uniformBlockBinding(wi,pr,rn.__bindingPointIndex),u.set(wi,pr))}function Ns(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),p={},si=null,wn={},m={},y=new WeakMap,M=[],T=null,G=!1,z=null,I=null,J=null,K=null,re=null,ve=null,me=null,Le=new jn(0,0,0),Ve=0,Ee=!1,Oe=null,dt=null,Ut=null,tn=null,cn=null,nr.set(0,0,i.canvas.width,i.canvas.height),os.set(0,0,i.canvas.width,i.canvas.height),o.reset(),a.reset(),c.reset()}return{buffers:{color:o,depth:a,stencil:c},enable:Mn,disable:fi,bindFramebuffer:ki,drawBuffers:Ni,useProgram:Cr,setBlending:Kn,setMaterial:Zn,setFlipSided:qn,setCullFace:Hn,setLineWidth:Ti,setPolygonOffset:pi,setScissorTest:Ii,activeTexture:ws,bindTexture:ms,unbindTexture:bt,compressedTexImage2D:Qe,compressedTexImage3D:fn,texImage2D:Er,texImage3D:mi,updateUBOMapping:Ir,uniformBlockBinding:Hi,texStorage2D:Ci,texStorage3D:Tr,texSubImage2D:Dn,texSubImage3D:ri,compressedTexSubImage2D:zn,compressedTexSubImage3D:Rr,scissor:Yi,viewport:ns,reset:Ns}}function jk(i,e,t,n,s,o,a){const c=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,u=typeof navigator=="undefined"?!1:/OculusBrowser/g.test(navigator.userAgent),d=new yn,p=new WeakMap;let m;const y=new WeakMap;let M=!1;try{M=typeof OffscreenCanvas!="undefined"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(bt){}function T(bt,Qe){return M?new OffscreenCanvas(bt,Qe):mh("canvas")}function G(bt,Qe,fn){let Dn=1;const ri=ms(bt);if((ri.width>fn||ri.height>fn)&&(Dn=fn/Math.max(ri.width,ri.height)),Dn<1)if(typeof HTMLImageElement!="undefined"&&bt instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&bt instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&bt instanceof ImageBitmap||typeof VideoFrame!="undefined"&&bt instanceof VideoFrame){const zn=Math.floor(Dn*ri.width),Rr=Math.floor(Dn*ri.height);m===void 0&&(m=T(zn,Rr));const Ci=Qe?T(zn,Rr):m;return Ci.width=zn,Ci.height=Rr,Ci.getContext("2d").drawImage(bt,0,0,zn,Rr),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+ri.width+"x"+ri.height+") to ("+zn+"x"+Rr+")."),Ci}else return"data"in bt&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+ri.width+"x"+ri.height+")."),bt;return bt}function z(bt){return bt.generateMipmaps}function I(bt){i.generateMipmap(bt)}function J(bt){return bt.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:bt.isWebGL3DRenderTarget?i.TEXTURE_3D:bt.isWebGLArrayRenderTarget||bt.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function K(bt,Qe,fn,Dn,ri=!1){if(bt!==null){if(i[bt]!==void 0)return i[bt];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+bt+"'")}let zn=Qe;if(Qe===i.RED&&(fn===i.FLOAT&&(zn=i.R32F),fn===i.HALF_FLOAT&&(zn=i.R16F),fn===i.UNSIGNED_BYTE&&(zn=i.R8)),Qe===i.RED_INTEGER&&(fn===i.UNSIGNED_BYTE&&(zn=i.R8UI),fn===i.UNSIGNED_SHORT&&(zn=i.R16UI),fn===i.UNSIGNED_INT&&(zn=i.R32UI),fn===i.BYTE&&(zn=i.R8I),fn===i.SHORT&&(zn=i.R16I),fn===i.INT&&(zn=i.R32I)),Qe===i.RG&&(fn===i.FLOAT&&(zn=i.RG32F),fn===i.HALF_FLOAT&&(zn=i.RG16F),fn===i.UNSIGNED_BYTE&&(zn=i.RG8)),Qe===i.RG_INTEGER&&(fn===i.UNSIGNED_BYTE&&(zn=i.RG8UI),fn===i.UNSIGNED_SHORT&&(zn=i.RG16UI),fn===i.UNSIGNED_INT&&(zn=i.RG32UI),fn===i.BYTE&&(zn=i.RG8I),fn===i.SHORT&&(zn=i.RG16I),fn===i.INT&&(zn=i.RG32I)),Qe===i.RGB_INTEGER&&(fn===i.UNSIGNED_BYTE&&(zn=i.RGB8UI),fn===i.UNSIGNED_SHORT&&(zn=i.RGB16UI),fn===i.UNSIGNED_INT&&(zn=i.RGB32UI),fn===i.BYTE&&(zn=i.RGB8I),fn===i.SHORT&&(zn=i.RGB16I),fn===i.INT&&(zn=i.RGB32I)),Qe===i.RGBA_INTEGER&&(fn===i.UNSIGNED_BYTE&&(zn=i.RGBA8UI),fn===i.UNSIGNED_SHORT&&(zn=i.RGBA16UI),fn===i.UNSIGNED_INT&&(zn=i.RGBA32UI),fn===i.BYTE&&(zn=i.RGBA8I),fn===i.SHORT&&(zn=i.RGBA16I),fn===i.INT&&(zn=i.RGBA32I)),Qe===i.RGB&&(fn===i.UNSIGNED_INT_5_9_9_9_REV&&(zn=i.RGB9_E5),fn===i.UNSIGNED_INT_10F_11F_11F_REV&&(zn=i.R11F_G11F_B10F)),Qe===i.RGBA){const Rr=ri?dh:Ki.getTransfer(Dn);fn===i.FLOAT&&(zn=i.RGBA32F),fn===i.HALF_FLOAT&&(zn=i.RGBA16F),fn===i.UNSIGNED_BYTE&&(zn=Rr===Fi?i.SRGB8_ALPHA8:i.RGBA8),fn===i.UNSIGNED_SHORT_4_4_4_4&&(zn=i.RGBA4),fn===i.UNSIGNED_SHORT_5_5_5_1&&(zn=i.RGB5_A1)}return(zn===i.R16F||zn===i.R32F||zn===i.RG16F||zn===i.RG32F||zn===i.RGBA16F||zn===i.RGBA32F)&&e.get("EXT_color_buffer_float"),zn}function re(bt,Qe){let fn;return bt?Qe===null||Qe===ls||Qe===Fa?fn=i.DEPTH24_STENCIL8:Qe===ys?fn=i.DEPTH32F_STENCIL8:Qe===gs&&(fn=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):Qe===null||Qe===ls||Qe===Fa?fn=i.DEPTH_COMPONENT24:Qe===ys?fn=i.DEPTH_COMPONENT32F:Qe===gs&&(fn=i.DEPTH_COMPONENT16),fn}function ve(bt,Qe){return z(bt)===!0||bt.isFramebufferTexture&&bt.minFilter!==Ct&&bt.minFilter!==Rn?Math.log2(Math.max(Qe.width,Qe.height))+1:bt.mipmaps!==void 0&&bt.mipmaps.length>0?bt.mipmaps.length:bt.isCompressedTexture&&Array.isArray(bt.image)?Qe.mipmaps.length:1}function me(bt){const Qe=bt.target;Qe.removeEventListener("dispose",me),Ve(Qe),Qe.isVideoTexture&&p.delete(Qe)}function Le(bt){const Qe=bt.target;Qe.removeEventListener("dispose",Le),Oe(Qe)}function Ve(bt){const Qe=n.get(bt);if(Qe.__webglInit===void 0)return;const fn=bt.source,Dn=y.get(fn);if(Dn){const ri=Dn[Qe.__cacheKey];ri.usedTimes--,ri.usedTimes===0&&Ee(bt),Object.keys(Dn).length===0&&y.delete(fn)}n.remove(bt)}function Ee(bt){const Qe=n.get(bt);i.deleteTexture(Qe.__webglTexture);const fn=bt.source,Dn=y.get(fn);delete Dn[Qe.__cacheKey],a.memory.textures--}function Oe(bt){const Qe=n.get(bt);if(bt.depthTexture&&(bt.depthTexture.dispose(),n.remove(bt.depthTexture)),bt.isWebGLCubeRenderTarget)for(let Dn=0;Dn<6;Dn++){if(Array.isArray(Qe.__webglFramebuffer[Dn]))for(let ri=0;ri<Qe.__webglFramebuffer[Dn].length;ri++)i.deleteFramebuffer(Qe.__webglFramebuffer[Dn][ri]);else i.deleteFramebuffer(Qe.__webglFramebuffer[Dn]);Qe.__webglDepthbuffer&&i.deleteRenderbuffer(Qe.__webglDepthbuffer[Dn])}else{if(Array.isArray(Qe.__webglFramebuffer))for(let Dn=0;Dn<Qe.__webglFramebuffer.length;Dn++)i.deleteFramebuffer(Qe.__webglFramebuffer[Dn]);else i.deleteFramebuffer(Qe.__webglFramebuffer);if(Qe.__webglDepthbuffer&&i.deleteRenderbuffer(Qe.__webglDepthbuffer),Qe.__webglMultisampledFramebuffer&&i.deleteFramebuffer(Qe.__webglMultisampledFramebuffer),Qe.__webglColorRenderbuffer)for(let Dn=0;Dn<Qe.__webglColorRenderbuffer.length;Dn++)Qe.__webglColorRenderbuffer[Dn]&&i.deleteRenderbuffer(Qe.__webglColorRenderbuffer[Dn]);Qe.__webglDepthRenderbuffer&&i.deleteRenderbuffer(Qe.__webglDepthRenderbuffer)}const fn=bt.textures;for(let Dn=0,ri=fn.length;Dn<ri;Dn++){const zn=n.get(fn[Dn]);zn.__webglTexture&&(i.deleteTexture(zn.__webglTexture),a.memory.textures--),n.remove(fn[Dn])}n.remove(bt)}let dt=0;function Ut(){dt=0}function tn(){const bt=dt;return bt>=s.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+bt+" texture units while this GPU supports only "+s.maxTextures),dt+=1,bt}function cn(bt){const Qe=[];return Qe.push(bt.wrapS),Qe.push(bt.wrapT),Qe.push(bt.wrapR||0),Qe.push(bt.magFilter),Qe.push(bt.minFilter),Qe.push(bt.anisotropy),Qe.push(bt.internalFormat),Qe.push(bt.format),Qe.push(bt.type),Qe.push(bt.generateMipmaps),Qe.push(bt.premultiplyAlpha),Qe.push(bt.flipY),Qe.push(bt.unpackAlignment),Qe.push(bt.colorSpace),Qe.join()}function vn(bt,Qe){const fn=n.get(bt);if(bt.isVideoTexture&&Ii(bt),bt.isRenderTargetTexture===!1&&bt.isExternalTexture!==!0&&bt.version>0&&fn.__version!==bt.version){const Dn=bt.image;if(Dn===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Dn.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{un(fn,bt,Qe);return}}else bt.isExternalTexture&&(fn.__webglTexture=bt.sourceTexture?bt.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,fn.__webglTexture,i.TEXTURE0+Qe)}function mn(bt,Qe){const fn=n.get(bt);if(bt.isRenderTargetTexture===!1&&bt.version>0&&fn.__version!==bt.version){un(fn,bt,Qe);return}t.bindTexture(i.TEXTURE_2D_ARRAY,fn.__webglTexture,i.TEXTURE0+Qe)}function Yn(bt,Qe){const fn=n.get(bt);if(bt.isRenderTargetTexture===!1&&bt.version>0&&fn.__version!==bt.version){un(fn,bt,Qe);return}t.bindTexture(i.TEXTURE_3D,fn.__webglTexture,i.TEXTURE0+Qe)}function xn(bt,Qe){const fn=n.get(bt);if(bt.version>0&&fn.__version!==bt.version){Mn(fn,bt,Qe);return}t.bindTexture(i.TEXTURE_CUBE_MAP,fn.__webglTexture,i.TEXTURE0+Qe)}const si={[st]:i.REPEAT,[$e]:i.CLAMP_TO_EDGE,[ft]:i.MIRRORED_REPEAT},wn={[Ct]:i.NEAREST,[jt]:i.NEAREST_MIPMAP_NEAREST,[pn]:i.NEAREST_MIPMAP_LINEAR,[Rn]:i.LINEAR,[bi]:i.LINEAR_MIPMAP_NEAREST,[Qn]:i.LINEAR_MIPMAP_LINEAR},Gn={[km]:i.NEVER,[zm]:i.ALWAYS,[ef]:i.LESS,[op]:i.LEQUAL,[tf]:i.EQUAL,[C0]:i.GEQUAL,[E0]:i.GREATER,[A0]:i.NOTEQUAL};function Si(bt,Qe){if(Qe.type===ys&&e.has("OES_texture_float_linear")===!1&&(Qe.magFilter===Rn||Qe.magFilter===bi||Qe.magFilter===pn||Qe.magFilter===Qn||Qe.minFilter===Rn||Qe.minFilter===bi||Qe.minFilter===pn||Qe.minFilter===Qn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(bt,i.TEXTURE_WRAP_S,si[Qe.wrapS]),i.texParameteri(bt,i.TEXTURE_WRAP_T,si[Qe.wrapT]),(bt===i.TEXTURE_3D||bt===i.TEXTURE_2D_ARRAY)&&i.texParameteri(bt,i.TEXTURE_WRAP_R,si[Qe.wrapR]),i.texParameteri(bt,i.TEXTURE_MAG_FILTER,wn[Qe.magFilter]),i.texParameteri(bt,i.TEXTURE_MIN_FILTER,wn[Qe.minFilter]),Qe.compareFunction&&(i.texParameteri(bt,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(bt,i.TEXTURE_COMPARE_FUNC,Gn[Qe.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(Qe.magFilter===Ct||Qe.minFilter!==pn&&Qe.minFilter!==Qn||Qe.type===ys&&e.has("OES_texture_float_linear")===!1)return;if(Qe.anisotropy>1||n.get(Qe).__currentAnisotropy){const fn=e.get("EXT_texture_filter_anisotropic");i.texParameterf(bt,fn.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(Qe.anisotropy,s.getMaxAnisotropy())),n.get(Qe).__currentAnisotropy=Qe.anisotropy}}}function nr(bt,Qe){let fn=!1;bt.__webglInit===void 0&&(bt.__webglInit=!0,Qe.addEventListener("dispose",me));const Dn=Qe.source;let ri=y.get(Dn);ri===void 0&&(ri={},y.set(Dn,ri));const zn=cn(Qe);if(zn!==bt.__cacheKey){ri[zn]===void 0&&(ri[zn]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,fn=!0),ri[zn].usedTimes++;const Rr=ri[bt.__cacheKey];Rr!==void 0&&(ri[bt.__cacheKey].usedTimes--,Rr.usedTimes===0&&Ee(Qe)),bt.__cacheKey=zn,bt.__webglTexture=ri[zn].texture}return fn}function os(bt,Qe,fn){return Math.floor(Math.floor(bt/fn)/Qe)}function Vn(bt,Qe,fn,Dn){const zn=bt.updateRanges;if(zn.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,Qe.width,Qe.height,fn,Dn,Qe.data);else{zn.sort((mi,Yi)=>mi.start-Yi.start);let Rr=0;for(let mi=1;mi<zn.length;mi++){const Yi=zn[Rr],ns=zn[mi],Ir=Yi.start+Yi.count,Hi=os(ns.start,Qe.width,4),Ns=os(Yi.start,Qe.width,4);ns.start<=Ir+1&&Hi===Ns&&os(ns.start+ns.count-1,Qe.width,4)===Hi?Yi.count=Math.max(Yi.count,ns.start+ns.count-Yi.start):(++Rr,zn[Rr]=ns)}zn.length=Rr+1;const Ci=i.getParameter(i.UNPACK_ROW_LENGTH),Tr=i.getParameter(i.UNPACK_SKIP_PIXELS),Er=i.getParameter(i.UNPACK_SKIP_ROWS);i.pixelStorei(i.UNPACK_ROW_LENGTH,Qe.width);for(let mi=0,Yi=zn.length;mi<Yi;mi++){const ns=zn[mi],Ir=Math.floor(ns.start/4),Hi=Math.ceil(ns.count/4),Ns=Ir%Qe.width,rn=Math.floor(Ir/Qe.width),wi=Hi,Di=1;i.pixelStorei(i.UNPACK_SKIP_PIXELS,Ns),i.pixelStorei(i.UNPACK_SKIP_ROWS,rn),t.texSubImage2D(i.TEXTURE_2D,0,Ns,rn,wi,Di,fn,Dn,Qe.data)}bt.clearUpdateRanges(),i.pixelStorei(i.UNPACK_ROW_LENGTH,Ci),i.pixelStorei(i.UNPACK_SKIP_PIXELS,Tr),i.pixelStorei(i.UNPACK_SKIP_ROWS,Er)}}function un(bt,Qe,fn){let Dn=i.TEXTURE_2D;(Qe.isDataArrayTexture||Qe.isCompressedArrayTexture)&&(Dn=i.TEXTURE_2D_ARRAY),Qe.isData3DTexture&&(Dn=i.TEXTURE_3D);const ri=nr(bt,Qe),zn=Qe.source;t.bindTexture(Dn,bt.__webglTexture,i.TEXTURE0+fn);const Rr=n.get(zn);if(zn.version!==Rr.__version||ri===!0){t.activeTexture(i.TEXTURE0+fn);const Ci=Ki.getPrimaries(Ki.workingColorSpace),Tr=Qe.colorSpace===ea?null:Ki.getPrimaries(Qe.colorSpace),Er=Qe.colorSpace===ea||Ci===Tr?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,Qe.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Qe.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,Qe.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Er);let mi=G(Qe.image,!1,s.maxTextureSize);mi=ws(Qe,mi);const Yi=o.convert(Qe.format,Qe.colorSpace),ns=o.convert(Qe.type);let Ir=K(Qe.internalFormat,Yi,ns,Qe.colorSpace,Qe.isVideoTexture);Si(Dn,Qe);let Hi;const Ns=Qe.mipmaps,rn=Qe.isVideoTexture!==!0,wi=Rr.__version===void 0||ri===!0,Di=zn.dataReady,pr=ve(Qe,mi);if(Qe.isDepthTexture)Ir=re(Qe.format===_,Qe.type),wi&&(rn?t.texStorage2D(i.TEXTURE_2D,1,Ir,mi.width,mi.height):t.texImage2D(i.TEXTURE_2D,0,Ir,mi.width,mi.height,0,Yi,ns,null));else if(Qe.isDataTexture)if(Ns.length>0){rn&&wi&&t.texStorage2D(i.TEXTURE_2D,pr,Ir,Ns[0].width,Ns[0].height);for(let gi=0,Jn=Ns.length;gi<Jn;gi++)Hi=Ns[gi],rn?Di&&t.texSubImage2D(i.TEXTURE_2D,gi,0,0,Hi.width,Hi.height,Yi,ns,Hi.data):t.texImage2D(i.TEXTURE_2D,gi,Ir,Hi.width,Hi.height,0,Yi,ns,Hi.data);Qe.generateMipmaps=!1}else rn?(wi&&t.texStorage2D(i.TEXTURE_2D,pr,Ir,mi.width,mi.height),Di&&Vn(Qe,mi,Yi,ns)):t.texImage2D(i.TEXTURE_2D,0,Ir,mi.width,mi.height,0,Yi,ns,mi.data);else if(Qe.isCompressedTexture)if(Qe.isCompressedArrayTexture){rn&&wi&&t.texStorage3D(i.TEXTURE_2D_ARRAY,pr,Ir,Ns[0].width,Ns[0].height,mi.depth);for(let gi=0,Jn=Ns.length;gi<Jn;gi++)if(Hi=Ns[gi],Qe.format!==D)if(Yi!==null)if(rn){if(Di)if(Qe.layerUpdates.size>0){const Ar=Vy(Hi.width,Hi.height,Qe.format,Qe.type);for(const Ms of Qe.layerUpdates){const Wo=Hi.data.subarray(Ms*Ar/Hi.data.BYTES_PER_ELEMENT,(Ms+1)*Ar/Hi.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,gi,0,0,Ms,Hi.width,Hi.height,1,Yi,Wo)}Qe.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,gi,0,0,0,Hi.width,Hi.height,mi.depth,Yi,Hi.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,gi,Ir,Hi.width,Hi.height,mi.depth,0,Hi.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else rn?Di&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,gi,0,0,0,Hi.width,Hi.height,mi.depth,Yi,ns,Hi.data):t.texImage3D(i.TEXTURE_2D_ARRAY,gi,Ir,Hi.width,Hi.height,mi.depth,0,Yi,ns,Hi.data)}else{rn&&wi&&t.texStorage2D(i.TEXTURE_2D,pr,Ir,Ns[0].width,Ns[0].height);for(let gi=0,Jn=Ns.length;gi<Jn;gi++)Hi=Ns[gi],Qe.format!==D?Yi!==null?rn?Di&&t.compressedTexSubImage2D(i.TEXTURE_2D,gi,0,0,Hi.width,Hi.height,Yi,Hi.data):t.compressedTexImage2D(i.TEXTURE_2D,gi,Ir,Hi.width,Hi.height,0,Hi.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):rn?Di&&t.texSubImage2D(i.TEXTURE_2D,gi,0,0,Hi.width,Hi.height,Yi,ns,Hi.data):t.texImage2D(i.TEXTURE_2D,gi,Ir,Hi.width,Hi.height,0,Yi,ns,Hi.data)}else if(Qe.isDataArrayTexture)if(rn){if(wi&&t.texStorage3D(i.TEXTURE_2D_ARRAY,pr,Ir,mi.width,mi.height,mi.depth),Di)if(Qe.layerUpdates.size>0){const gi=Vy(mi.width,mi.height,Qe.format,Qe.type);for(const Jn of Qe.layerUpdates){const Ar=mi.data.subarray(Jn*gi/mi.data.BYTES_PER_ELEMENT,(Jn+1)*gi/mi.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,Jn,mi.width,mi.height,1,Yi,ns,Ar)}Qe.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,mi.width,mi.height,mi.depth,Yi,ns,mi.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,Ir,mi.width,mi.height,mi.depth,0,Yi,ns,mi.data);else if(Qe.isData3DTexture)rn?(wi&&t.texStorage3D(i.TEXTURE_3D,pr,Ir,mi.width,mi.height,mi.depth),Di&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,mi.width,mi.height,mi.depth,Yi,ns,mi.data)):t.texImage3D(i.TEXTURE_3D,0,Ir,mi.width,mi.height,mi.depth,0,Yi,ns,mi.data);else if(Qe.isFramebufferTexture){if(wi)if(rn)t.texStorage2D(i.TEXTURE_2D,pr,Ir,mi.width,mi.height);else{let gi=mi.width,Jn=mi.height;for(let Ar=0;Ar<pr;Ar++)t.texImage2D(i.TEXTURE_2D,Ar,Ir,gi,Jn,0,Yi,ns,null),gi>>=1,Jn>>=1}}else if(Ns.length>0){if(rn&&wi){const gi=ms(Ns[0]);t.texStorage2D(i.TEXTURE_2D,pr,Ir,gi.width,gi.height)}for(let gi=0,Jn=Ns.length;gi<Jn;gi++)Hi=Ns[gi],rn?Di&&t.texSubImage2D(i.TEXTURE_2D,gi,0,0,Yi,ns,Hi):t.texImage2D(i.TEXTURE_2D,gi,Ir,Yi,ns,Hi);Qe.generateMipmaps=!1}else if(rn){if(wi){const gi=ms(mi);t.texStorage2D(i.TEXTURE_2D,pr,Ir,gi.width,gi.height)}Di&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,Yi,ns,mi)}else t.texImage2D(i.TEXTURE_2D,0,Ir,Yi,ns,mi);z(Qe)&&I(Dn),Rr.__version=zn.version,Qe.onUpdate&&Qe.onUpdate(Qe)}bt.__version=Qe.version}function Mn(bt,Qe,fn){if(Qe.image.length!==6)return;const Dn=nr(bt,Qe),ri=Qe.source;t.bindTexture(i.TEXTURE_CUBE_MAP,bt.__webglTexture,i.TEXTURE0+fn);const zn=n.get(ri);if(ri.version!==zn.__version||Dn===!0){t.activeTexture(i.TEXTURE0+fn);const Rr=Ki.getPrimaries(Ki.workingColorSpace),Ci=Qe.colorSpace===ea?null:Ki.getPrimaries(Qe.colorSpace),Tr=Qe.colorSpace===ea||Rr===Ci?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,Qe.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Qe.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,Qe.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Tr);const Er=Qe.isCompressedTexture||Qe.image[0].isCompressedTexture,mi=Qe.image[0]&&Qe.image[0].isDataTexture,Yi=[];for(let Jn=0;Jn<6;Jn++)!Er&&!mi?Yi[Jn]=G(Qe.image[Jn],!0,s.maxCubemapSize):Yi[Jn]=mi?Qe.image[Jn].image:Qe.image[Jn],Yi[Jn]=ws(Qe,Yi[Jn]);const ns=Yi[0],Ir=o.convert(Qe.format,Qe.colorSpace),Hi=o.convert(Qe.type),Ns=K(Qe.internalFormat,Ir,Hi,Qe.colorSpace),rn=Qe.isVideoTexture!==!0,wi=zn.__version===void 0||Dn===!0,Di=ri.dataReady;let pr=ve(Qe,ns);Si(i.TEXTURE_CUBE_MAP,Qe);let gi;if(Er){rn&&wi&&t.texStorage2D(i.TEXTURE_CUBE_MAP,pr,Ns,ns.width,ns.height);for(let Jn=0;Jn<6;Jn++){gi=Yi[Jn].mipmaps;for(let Ar=0;Ar<gi.length;Ar++){const Ms=gi[Ar];Qe.format!==D?Ir!==null?rn?Di&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,Ar,0,0,Ms.width,Ms.height,Ir,Ms.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,Ar,Ns,Ms.width,Ms.height,0,Ms.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):rn?Di&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,Ar,0,0,Ms.width,Ms.height,Ir,Hi,Ms.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,Ar,Ns,Ms.width,Ms.height,0,Ir,Hi,Ms.data)}}}else{if(gi=Qe.mipmaps,rn&&wi){gi.length>0&&pr++;const Jn=ms(Yi[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,pr,Ns,Jn.width,Jn.height)}for(let Jn=0;Jn<6;Jn++)if(mi){rn?Di&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,0,0,0,Yi[Jn].width,Yi[Jn].height,Ir,Hi,Yi[Jn].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,0,Ns,Yi[Jn].width,Yi[Jn].height,0,Ir,Hi,Yi[Jn].data);for(let Ar=0;Ar<gi.length;Ar++){const Wo=gi[Ar].image[Jn].image;rn?Di&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,Ar+1,0,0,Wo.width,Wo.height,Ir,Hi,Wo.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,Ar+1,Ns,Wo.width,Wo.height,0,Ir,Hi,Wo.data)}}else{rn?Di&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,0,0,0,Ir,Hi,Yi[Jn]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,0,Ns,Ir,Hi,Yi[Jn]);for(let Ar=0;Ar<gi.length;Ar++){const Ms=gi[Ar];rn?Di&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,Ar+1,0,0,Ir,Hi,Ms.image[Jn]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,Ar+1,Ns,Ir,Hi,Ms.image[Jn])}}}z(Qe)&&I(i.TEXTURE_CUBE_MAP),zn.__version=ri.version,Qe.onUpdate&&Qe.onUpdate(Qe)}bt.__version=Qe.version}function fi(bt,Qe,fn,Dn,ri,zn){const Rr=o.convert(fn.format,fn.colorSpace),Ci=o.convert(fn.type),Tr=K(fn.internalFormat,Rr,Ci,fn.colorSpace),Er=n.get(Qe),mi=n.get(fn);if(mi.__renderTarget=Qe,!Er.__hasExternalTextures){const Yi=Math.max(1,Qe.width>>zn),ns=Math.max(1,Qe.height>>zn);ri===i.TEXTURE_3D||ri===i.TEXTURE_2D_ARRAY?t.texImage3D(ri,zn,Tr,Yi,ns,Qe.depth,0,Rr,Ci,null):t.texImage2D(ri,zn,Tr,Yi,ns,0,Rr,Ci,null)}t.bindFramebuffer(i.FRAMEBUFFER,bt),pi(Qe)?c.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Dn,ri,mi.__webglTexture,0,Ti(Qe)):(ri===i.TEXTURE_2D||ri>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&ri<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Dn,ri,mi.__webglTexture,zn),t.bindFramebuffer(i.FRAMEBUFFER,null)}function ki(bt,Qe,fn){if(i.bindRenderbuffer(i.RENDERBUFFER,bt),Qe.depthBuffer){const Dn=Qe.depthTexture,ri=Dn&&Dn.isDepthTexture?Dn.type:null,zn=re(Qe.stencilBuffer,ri),Rr=Qe.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ci=Ti(Qe);pi(Qe)?c.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Ci,zn,Qe.width,Qe.height):fn?i.renderbufferStorageMultisample(i.RENDERBUFFER,Ci,zn,Qe.width,Qe.height):i.renderbufferStorage(i.RENDERBUFFER,zn,Qe.width,Qe.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,Rr,i.RENDERBUFFER,bt)}else{const Dn=Qe.textures;for(let ri=0;ri<Dn.length;ri++){const zn=Dn[ri],Rr=o.convert(zn.format,zn.colorSpace),Ci=o.convert(zn.type),Tr=K(zn.internalFormat,Rr,Ci,zn.colorSpace),Er=Ti(Qe);fn&&pi(Qe)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,Er,Tr,Qe.width,Qe.height):pi(Qe)?c.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Er,Tr,Qe.width,Qe.height):i.renderbufferStorage(i.RENDERBUFFER,Tr,Qe.width,Qe.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Ni(bt,Qe){if(Qe&&Qe.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(i.FRAMEBUFFER,bt),!(Qe.depthTexture&&Qe.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const Dn=n.get(Qe.depthTexture);Dn.__renderTarget=Qe,(!Dn.__webglTexture||Qe.depthTexture.image.width!==Qe.width||Qe.depthTexture.image.height!==Qe.height)&&(Qe.depthTexture.image.width=Qe.width,Qe.depthTexture.image.height=Qe.height,Qe.depthTexture.needsUpdate=!0),vn(Qe.depthTexture,0);const ri=Dn.__webglTexture,zn=Ti(Qe);if(Qe.depthTexture.format===U)pi(Qe)?c.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,ri,0,zn):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,ri,0);else if(Qe.depthTexture.format===_)pi(Qe)?c.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,ri,0,zn):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,ri,0);else throw new Error("Unknown depthTexture format")}function Cr(bt){const Qe=n.get(bt),fn=bt.isWebGLCubeRenderTarget===!0;if(Qe.__boundDepthTexture!==bt.depthTexture){const Dn=bt.depthTexture;if(Qe.__depthDisposeCallback&&Qe.__depthDisposeCallback(),Dn){const ri=()=>{delete Qe.__boundDepthTexture,delete Qe.__depthDisposeCallback,Dn.removeEventListener("dispose",ri)};Dn.addEventListener("dispose",ri),Qe.__depthDisposeCallback=ri}Qe.__boundDepthTexture=Dn}if(bt.depthTexture&&!Qe.__autoAllocateDepthBuffer){if(fn)throw new Error("target.depthTexture not supported in Cube render targets");const Dn=bt.texture.mipmaps;Dn&&Dn.length>0?Ni(Qe.__webglFramebuffer[0],bt):Ni(Qe.__webglFramebuffer,bt)}else if(fn){Qe.__webglDepthbuffer=[];for(let Dn=0;Dn<6;Dn++)if(t.bindFramebuffer(i.FRAMEBUFFER,Qe.__webglFramebuffer[Dn]),Qe.__webglDepthbuffer[Dn]===void 0)Qe.__webglDepthbuffer[Dn]=i.createRenderbuffer(),ki(Qe.__webglDepthbuffer[Dn],bt,!1);else{const ri=bt.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,zn=Qe.__webglDepthbuffer[Dn];i.bindRenderbuffer(i.RENDERBUFFER,zn),i.framebufferRenderbuffer(i.FRAMEBUFFER,ri,i.RENDERBUFFER,zn)}}else{const Dn=bt.texture.mipmaps;if(Dn&&Dn.length>0?t.bindFramebuffer(i.FRAMEBUFFER,Qe.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,Qe.__webglFramebuffer),Qe.__webglDepthbuffer===void 0)Qe.__webglDepthbuffer=i.createRenderbuffer(),ki(Qe.__webglDepthbuffer,bt,!1);else{const ri=bt.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,zn=Qe.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,zn),i.framebufferRenderbuffer(i.FRAMEBUFFER,ri,i.RENDERBUFFER,zn)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function Vs(bt,Qe,fn){const Dn=n.get(bt);Qe!==void 0&&fi(Dn.__webglFramebuffer,bt,bt.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),fn!==void 0&&Cr(bt)}function kt(bt){const Qe=bt.texture,fn=n.get(bt),Dn=n.get(Qe);bt.addEventListener("dispose",Le);const ri=bt.textures,zn=bt.isWebGLCubeRenderTarget===!0,Rr=ri.length>1;if(Rr||(Dn.__webglTexture===void 0&&(Dn.__webglTexture=i.createTexture()),Dn.__version=Qe.version,a.memory.textures++),zn){fn.__webglFramebuffer=[];for(let Ci=0;Ci<6;Ci++)if(Qe.mipmaps&&Qe.mipmaps.length>0){fn.__webglFramebuffer[Ci]=[];for(let Tr=0;Tr<Qe.mipmaps.length;Tr++)fn.__webglFramebuffer[Ci][Tr]=i.createFramebuffer()}else fn.__webglFramebuffer[Ci]=i.createFramebuffer()}else{if(Qe.mipmaps&&Qe.mipmaps.length>0){fn.__webglFramebuffer=[];for(let Ci=0;Ci<Qe.mipmaps.length;Ci++)fn.__webglFramebuffer[Ci]=i.createFramebuffer()}else fn.__webglFramebuffer=i.createFramebuffer();if(Rr)for(let Ci=0,Tr=ri.length;Ci<Tr;Ci++){const Er=n.get(ri[Ci]);Er.__webglTexture===void 0&&(Er.__webglTexture=i.createTexture(),a.memory.textures++)}if(bt.samples>0&&pi(bt)===!1){fn.__webglMultisampledFramebuffer=i.createFramebuffer(),fn.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,fn.__webglMultisampledFramebuffer);for(let Ci=0;Ci<ri.length;Ci++){const Tr=ri[Ci];fn.__webglColorRenderbuffer[Ci]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,fn.__webglColorRenderbuffer[Ci]);const Er=o.convert(Tr.format,Tr.colorSpace),mi=o.convert(Tr.type),Yi=K(Tr.internalFormat,Er,mi,Tr.colorSpace,bt.isXRRenderTarget===!0),ns=Ti(bt);i.renderbufferStorageMultisample(i.RENDERBUFFER,ns,Yi,bt.width,bt.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Ci,i.RENDERBUFFER,fn.__webglColorRenderbuffer[Ci])}i.bindRenderbuffer(i.RENDERBUFFER,null),bt.depthBuffer&&(fn.__webglDepthRenderbuffer=i.createRenderbuffer(),ki(fn.__webglDepthRenderbuffer,bt,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(zn){t.bindTexture(i.TEXTURE_CUBE_MAP,Dn.__webglTexture),Si(i.TEXTURE_CUBE_MAP,Qe);for(let Ci=0;Ci<6;Ci++)if(Qe.mipmaps&&Qe.mipmaps.length>0)for(let Tr=0;Tr<Qe.mipmaps.length;Tr++)fi(fn.__webglFramebuffer[Ci][Tr],bt,Qe,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Ci,Tr);else fi(fn.__webglFramebuffer[Ci],bt,Qe,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Ci,0);z(Qe)&&I(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Rr){for(let Ci=0,Tr=ri.length;Ci<Tr;Ci++){const Er=ri[Ci],mi=n.get(Er);let Yi=i.TEXTURE_2D;(bt.isWebGL3DRenderTarget||bt.isWebGLArrayRenderTarget)&&(Yi=bt.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(Yi,mi.__webglTexture),Si(Yi,Er),fi(fn.__webglFramebuffer,bt,Er,i.COLOR_ATTACHMENT0+Ci,Yi,0),z(Er)&&I(Yi)}t.unbindTexture()}else{let Ci=i.TEXTURE_2D;if((bt.isWebGL3DRenderTarget||bt.isWebGLArrayRenderTarget)&&(Ci=bt.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(Ci,Dn.__webglTexture),Si(Ci,Qe),Qe.mipmaps&&Qe.mipmaps.length>0)for(let Tr=0;Tr<Qe.mipmaps.length;Tr++)fi(fn.__webglFramebuffer[Tr],bt,Qe,i.COLOR_ATTACHMENT0,Ci,Tr);else fi(fn.__webglFramebuffer,bt,Qe,i.COLOR_ATTACHMENT0,Ci,0);z(Qe)&&I(Ci),t.unbindTexture()}bt.depthBuffer&&Cr(bt)}function Kn(bt){const Qe=bt.textures;for(let fn=0,Dn=Qe.length;fn<Dn;fn++){const ri=Qe[fn];if(z(ri)){const zn=J(bt),Rr=n.get(ri).__webglTexture;t.bindTexture(zn,Rr),I(zn),t.unbindTexture()}}}const Zn=[],qn=[];function Hn(bt){if(bt.samples>0){if(pi(bt)===!1){const Qe=bt.textures,fn=bt.width,Dn=bt.height;let ri=i.COLOR_BUFFER_BIT;const zn=bt.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Rr=n.get(bt),Ci=Qe.length>1;if(Ci)for(let Er=0;Er<Qe.length;Er++)t.bindFramebuffer(i.FRAMEBUFFER,Rr.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Er,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,Rr.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Er,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,Rr.__webglMultisampledFramebuffer);const Tr=bt.texture.mipmaps;Tr&&Tr.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Rr.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Rr.__webglFramebuffer);for(let Er=0;Er<Qe.length;Er++){if(bt.resolveDepthBuffer&&(bt.depthBuffer&&(ri|=i.DEPTH_BUFFER_BIT),bt.stencilBuffer&&bt.resolveStencilBuffer&&(ri|=i.STENCIL_BUFFER_BIT)),Ci){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,Rr.__webglColorRenderbuffer[Er]);const mi=n.get(Qe[Er]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,mi,0)}i.blitFramebuffer(0,0,fn,Dn,0,0,fn,Dn,ri,i.NEAREST),u===!0&&(Zn.length=0,qn.length=0,Zn.push(i.COLOR_ATTACHMENT0+Er),bt.depthBuffer&&bt.resolveDepthBuffer===!1&&(Zn.push(zn),qn.push(zn),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,qn)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,Zn))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),Ci)for(let Er=0;Er<Qe.length;Er++){t.bindFramebuffer(i.FRAMEBUFFER,Rr.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Er,i.RENDERBUFFER,Rr.__webglColorRenderbuffer[Er]);const mi=n.get(Qe[Er]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,Rr.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Er,i.TEXTURE_2D,mi,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Rr.__webglMultisampledFramebuffer)}else if(bt.depthBuffer&&bt.resolveDepthBuffer===!1&&u){const Qe=bt.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[Qe])}}}function Ti(bt){return Math.min(s.maxSamples,bt.samples)}function pi(bt){const Qe=n.get(bt);return bt.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&Qe.__useRenderToTexture!==!1}function Ii(bt){const Qe=a.render.frame;p.get(bt)!==Qe&&(p.set(bt,Qe),bt.update())}function ws(bt,Qe){const fn=bt.colorSpace,Dn=bt.format,ri=bt.type;return bt.isCompressedTexture===!0||bt.isVideoTexture===!0||fn!==ou&&fn!==ea&&(Ki.getTransfer(fn)===Fi?(Dn!==D||ri!==Oi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",fn)),Qe}function ms(bt){return typeof HTMLImageElement!="undefined"&&bt instanceof HTMLImageElement?(d.width=bt.naturalWidth||bt.width,d.height=bt.naturalHeight||bt.height):typeof VideoFrame!="undefined"&&bt instanceof VideoFrame?(d.width=bt.displayWidth,d.height=bt.displayHeight):(d.width=bt.width,d.height=bt.height),d}this.allocateTextureUnit=tn,this.resetTextureUnits=Ut,this.setTexture2D=vn,this.setTexture2DArray=mn,this.setTexture3D=Yn,this.setTextureCube=xn,this.rebindTextures=Vs,this.setupRenderTarget=kt,this.updateRenderTargetMipmap=Kn,this.updateMultisampleRenderTarget=Hn,this.setupDepthRenderbuffer=Cr,this.setupFrameBufferTexture=fi,this.useMultisampledRTT=pi}function Xk(i,e){function t(n,s=ea){let o;const a=Ki.getTransfer(s);if(n===Oi)return i.UNSIGNED_BYTE;if(n===Yl)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Zl)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Fl)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===su)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Gi)return i.BYTE;if(n===ir)return i.SHORT;if(n===gs)return i.UNSIGNED_SHORT;if(n===Ls)return i.INT;if(n===ls)return i.UNSIGNED_INT;if(n===ys)return i.FLOAT;if(n===Gs)return i.HALF_FLOAT;if(n===Bu)return i.ALPHA;if(n===Pe)return i.RGB;if(n===D)return i.RGBA;if(n===U)return i.DEPTH_COMPONENT;if(n===_)return i.DEPTH_STENCIL;if(n===F)return i.RED;if(n===X)return i.RED_INTEGER;if(n===Ie)return i.RG;if(n===ke)return i.RG_INTEGER;if(n===nt)return i.RGBA_INTEGER;if(n===Wt||n===Tt||n===on||n===Un)if(a===Fi)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(n===Wt)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Tt)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===on)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Un)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(n===Wt)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Tt)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===on)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Un)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===sn||n===bn||n===ti||n===Bt)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(n===sn)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===bn)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===ti)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Bt)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===$n||n===ni||n===Pi)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(n===$n||n===ni)return a===Fi?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===Pi)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===ui||n===Lr||n===yi||n===vi||n===Mr||n===Zt||n===Fn||n===hi||n===Xn||n===ds||n===qr||n===vs||n===kr||n===Fs)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(n===ui)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Lr)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===yi)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===vi)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Mr)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Zt)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Fn)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===hi)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Xn)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===ds)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===qr)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===vs)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===kr)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Fs)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===io||n===ro||n===To)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(n===io)return a===Fi?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ro)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===To)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Eo||n===Wr||n===eo||n===Ao)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(n===Eo)return o.COMPRESSED_RED_RGTC1_EXT;if(n===Wr)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===eo)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Ao)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Fa?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const qk=`
|
|
|
void main() {
|
|
|
|
|
|
gl_Position = vec4( position, 1.0 );
|
|
|
|
|
|
}`,Yk=`
|
|
|
uniform sampler2DArray depthColor;
|
|
|
uniform float depthWidth;
|
|
|
uniform float depthHeight;
|
|
|
|
|
|
void main() {
|
|
|
|
|
|
vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
|
|
|
|
|
|
if ( coord.x >= 1.0 ) {
|
|
|
|
|
|
gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
|
|
|
|
|
|
}
|
|
|
|
|
|
}`;class Zk{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new E1(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new kc({vertexShader:qk,fragmentShader:Yk,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ks(new Ch(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Kk extends Bl{constructor(e,t){super();const n=this;let s=null,o=1,a=null,c="local-floor",u=1,d=null,p=null,m=null,y=null,M=null,T=null;const G=typeof XRWebGLBinding!="undefined",z=new Zk,I={},J=t.getContextAttributes();let K=null,re=null;const ve=[],me=[],Le=new yn;let Ve=null;const Ee=new ma;Ee.viewport=new mr;const Oe=new ma;Oe.viewport=new mr;const dt=[Ee,Oe],Ut=new Cy;let tn=null,cn=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(un){let Mn=ve[un];return Mn===void 0&&(Mn=new $u,ve[un]=Mn),Mn.getTargetRaySpace()},this.getControllerGrip=function(un){let Mn=ve[un];return Mn===void 0&&(Mn=new $u,ve[un]=Mn),Mn.getGripSpace()},this.getHand=function(un){let Mn=ve[un];return Mn===void 0&&(Mn=new $u,ve[un]=Mn),Mn.getHandSpace()};function vn(un){const Mn=me.indexOf(un.inputSource);if(Mn===-1)return;const fi=ve[Mn];fi!==void 0&&(fi.update(un.inputSource,un.frame,d||a),fi.dispatchEvent({type:un.type,data:un.inputSource}))}function mn(){s.removeEventListener("select",vn),s.removeEventListener("selectstart",vn),s.removeEventListener("selectend",vn),s.removeEventListener("squeeze",vn),s.removeEventListener("squeezestart",vn),s.removeEventListener("squeezeend",vn),s.removeEventListener("end",mn),s.removeEventListener("inputsourceschange",Yn);for(let un=0;un<ve.length;un++){const Mn=me[un];Mn!==null&&(me[un]=null,ve[un].disconnect(Mn))}tn=null,cn=null,z.reset();for(const un in I)delete I[un];e.setRenderTarget(K),M=null,y=null,m=null,s=null,re=null,Vn.stop(),n.isPresenting=!1,e.setPixelRatio(Ve),e.setSize(Le.width,Le.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(un){o=un,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(un){c=un,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return d||a},this.setReferenceSpace=function(un){d=un},this.getBaseLayer=function(){return y!==null?y:M},this.getBinding=function(){return m===null&&G&&(m=new XRWebGLBinding(s,t)),m},this.getFrame=function(){return T},this.getSession=function(){return s},this.setSession=function(un){return hr(this,null,function*(){if(s=un,s!==null){if(K=e.getRenderTarget(),s.addEventListener("select",vn),s.addEventListener("selectstart",vn),s.addEventListener("selectend",vn),s.addEventListener("squeeze",vn),s.addEventListener("squeezestart",vn),s.addEventListener("squeezeend",vn),s.addEventListener("end",mn),s.addEventListener("inputsourceschange",Yn),J.xrCompatible!==!0&&(yield t.makeXRCompatible()),Ve=e.getPixelRatio(),e.getSize(Le),G&&"createProjectionLayer"in XRWebGLBinding.prototype){let fi=null,ki=null,Ni=null;J.depth&&(Ni=J.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,fi=J.stencil?_:U,ki=J.stencil?Fa:ls);const Cr={colorFormat:t.RGBA8,depthFormat:Ni,scaleFactor:o};m=this.getBinding(),y=m.createProjectionLayer(Cr),s.updateRenderState({layers:[y]}),e.setPixelRatio(1),e.setSize(y.textureWidth,y.textureHeight,!1),re=new hc(y.textureWidth,y.textureHeight,{format:D,type:Oi,depthTexture:new vc(y.textureWidth,y.textureHeight,ki,void 0,void 0,void 0,void 0,void 0,void 0,fi),stencilBuffer:J.stencil,colorSpace:e.outputColorSpace,samples:J.antialias?4:0,resolveDepthBuffer:y.ignoreDepthValues===!1,resolveStencilBuffer:y.ignoreDepthValues===!1})}else{const fi={antialias:J.antialias,alpha:!0,depth:J.depth,stencil:J.stencil,framebufferScaleFactor:o};M=new XRWebGLLayer(s,t,fi),s.updateRenderState({baseLayer:M}),e.setPixelRatio(1),e.setSize(M.framebufferWidth,M.framebufferHeight,!1),re=new hc(M.framebufferWidth,M.framebufferHeight,{format:D,type:Oi,colorSpace:e.outputColorSpace,stencilBuffer:J.stencil,resolveDepthBuffer:M.ignoreDepthValues===!1,resolveStencilBuffer:M.ignoreDepthValues===!1})}re.isXRRenderTarget=!0,this.setFoveation(u),d=null,a=yield s.requestReferenceSpace(c),Vn.setContext(s),Vn.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}})},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return z.getDepthTexture()};function Yn(un){for(let Mn=0;Mn<un.removed.length;Mn++){const fi=un.removed[Mn],ki=me.indexOf(fi);ki>=0&&(me[ki]=null,ve[ki].disconnect(fi))}for(let Mn=0;Mn<un.added.length;Mn++){const fi=un.added[Mn];let ki=me.indexOf(fi);if(ki===-1){for(let Cr=0;Cr<ve.length;Cr++)if(Cr>=me.length){me.push(fi),ki=Cr;break}else if(me[Cr]===null){me[Cr]=fi,ki=Cr;break}if(ki===-1)break}const Ni=ve[ki];Ni&&Ni.connect(fi)}}const xn=new it,si=new it;function wn(un,Mn,fi){xn.setFromMatrixPosition(Mn.matrixWorld),si.setFromMatrixPosition(fi.matrixWorld);const ki=xn.distanceTo(si),Ni=Mn.projectionMatrix.elements,Cr=fi.projectionMatrix.elements,Vs=Ni[14]/(Ni[10]-1),kt=Ni[14]/(Ni[10]+1),Kn=(Ni[9]+1)/Ni[5],Zn=(Ni[9]-1)/Ni[5],qn=(Ni[8]-1)/Ni[0],Hn=(Cr[8]+1)/Cr[0],Ti=Vs*qn,pi=Vs*Hn,Ii=ki/(-qn+Hn),ws=Ii*-qn;if(Mn.matrixWorld.decompose(un.position,un.quaternion,un.scale),un.translateX(ws),un.translateZ(Ii),un.matrixWorld.compose(un.position,un.quaternion,un.scale),un.matrixWorldInverse.copy(un.matrixWorld).invert(),Ni[10]===-1)un.projectionMatrix.copy(Mn.projectionMatrix),un.projectionMatrixInverse.copy(Mn.projectionMatrixInverse);else{const ms=Vs+Ii,bt=kt+Ii,Qe=Ti-ws,fn=pi+(ki-ws),Dn=Kn*kt/bt*ms,ri=Zn*kt/bt*ms;un.projectionMatrix.makePerspective(Qe,fn,Dn,ri,ms,bt),un.projectionMatrixInverse.copy(un.projectionMatrix).invert()}}function Gn(un,Mn){Mn===null?un.matrixWorld.copy(un.matrix):un.matrixWorld.multiplyMatrices(Mn.matrixWorld,un.matrix),un.matrixWorldInverse.copy(un.matrixWorld).invert()}this.updateCamera=function(un){if(s===null)return;let Mn=un.near,fi=un.far;z.texture!==null&&(z.depthNear>0&&(Mn=z.depthNear),z.depthFar>0&&(fi=z.depthFar)),Ut.near=Oe.near=Ee.near=Mn,Ut.far=Oe.far=Ee.far=fi,(tn!==Ut.near||cn!==Ut.far)&&(s.updateRenderState({depthNear:Ut.near,depthFar:Ut.far}),tn=Ut.near,cn=Ut.far),Ut.layers.mask=un.layers.mask|6,Ee.layers.mask=Ut.layers.mask&3,Oe.layers.mask=Ut.layers.mask&5;const ki=un.parent,Ni=Ut.cameras;Gn(Ut,ki);for(let Cr=0;Cr<Ni.length;Cr++)Gn(Ni[Cr],ki);Ni.length===2?wn(Ut,Ee,Oe):Ut.projectionMatrix.copy(Ee.projectionMatrix),Si(un,Ut,ki)};function Si(un,Mn,fi){fi===null?un.matrix.copy(Mn.matrixWorld):(un.matrix.copy(fi.matrixWorld),un.matrix.invert(),un.matrix.multiply(Mn.matrixWorld)),un.matrix.decompose(un.position,un.quaternion,un.scale),un.updateMatrixWorld(!0),un.projectionMatrix.copy(Mn.projectionMatrix),un.projectionMatrixInverse.copy(Mn.projectionMatrixInverse),un.isPerspectiveCamera&&(un.fov=Ua*2*Math.atan(1/un.projectionMatrix.elements[5]),un.zoom=1)}this.getCamera=function(){return Ut},this.getFoveation=function(){if(!(y===null&&M===null))return u},this.setFoveation=function(un){u=un,y!==null&&(y.fixedFoveation=un),M!==null&&M.fixedFoveation!==void 0&&(M.fixedFoveation=un)},this.hasDepthSensing=function(){return z.texture!==null},this.getDepthSensingMesh=function(){return z.getMesh(Ut)},this.getCameraTexture=function(un){return I[un]};let nr=null;function os(un,Mn){if(p=Mn.getViewerPose(d||a),T=Mn,p!==null){const fi=p.views;M!==null&&(e.setRenderTargetFramebuffer(re,M.framebuffer),e.setRenderTarget(re));let ki=!1;fi.length!==Ut.cameras.length&&(Ut.cameras.length=0,ki=!0);for(let kt=0;kt<fi.length;kt++){const Kn=fi[kt];let Zn=null;if(M!==null)Zn=M.getViewport(Kn);else{const Hn=m.getViewSubImage(y,Kn);Zn=Hn.viewport,kt===0&&(e.setRenderTargetTextures(re,Hn.colorTexture,Hn.depthStencilTexture),e.setRenderTarget(re))}let qn=dt[kt];qn===void 0&&(qn=new ma,qn.layers.enable(kt),qn.viewport=new mr,dt[kt]=qn),qn.matrix.fromArray(Kn.transform.matrix),qn.matrix.decompose(qn.position,qn.quaternion,qn.scale),qn.projectionMatrix.fromArray(Kn.projectionMatrix),qn.projectionMatrixInverse.copy(qn.projectionMatrix).invert(),qn.viewport.set(Zn.x,Zn.y,Zn.width,Zn.height),kt===0&&(Ut.matrix.copy(qn.matrix),Ut.matrix.decompose(Ut.position,Ut.quaternion,Ut.scale)),ki===!0&&Ut.cameras.push(qn)}const Ni=s.enabledFeatures;if(Ni&&Ni.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&G){m=n.getBinding();const kt=m.getDepthInformation(fi[0]);kt&&kt.isValid&&kt.texture&&z.init(kt,s.renderState)}if(Ni&&Ni.includes("camera-access")&&G){e.state.unbindTexture(),m=n.getBinding();for(let kt=0;kt<fi.length;kt++){const Kn=fi[kt].camera;if(Kn){let Zn=I[Kn];Zn||(Zn=new E1,I[Kn]=Zn);const qn=m.getCameraImage(Kn);Zn.sourceTexture=qn}}}}for(let fi=0;fi<ve.length;fi++){const ki=me[fi],Ni=ve[fi];ki!==null&&Ni!==void 0&&Ni.update(ki,Mn,d||a)}nr&&nr(un,Mn),Mn.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:Mn}),T=null}const Vn=new SA;Vn.setAnimationLoop(os),this.setAnimationLoop=function(un){nr=un},this.dispose=function(){}}}const om=new Qi,Jk=new Ft;function Qk(i,e){function t(z,I){z.matrixAutoUpdate===!0&&z.updateMatrix(),I.value.copy(z.matrix)}function n(z,I){I.color.getRGB(z.fogColor.value,fx(i)),I.isFog?(z.fogNear.value=I.near,z.fogFar.value=I.far):I.isFogExp2&&(z.fogDensity.value=I.density)}function s(z,I,J,K,re){I.isMeshBasicMaterial||I.isMeshLambertMaterial?o(z,I):I.isMeshToonMaterial?(o(z,I),m(z,I)):I.isMeshPhongMaterial?(o(z,I),p(z,I)):I.isMeshStandardMaterial?(o(z,I),y(z,I),I.isMeshPhysicalMaterial&&M(z,I,re)):I.isMeshMatcapMaterial?(o(z,I),T(z,I)):I.isMeshDepthMaterial?o(z,I):I.isMeshDistanceMaterial?(o(z,I),G(z,I)):I.isMeshNormalMaterial?o(z,I):I.isLineBasicMaterial?(a(z,I),I.isLineDashedMaterial&&c(z,I)):I.isPointsMaterial?u(z,I,J,K):I.isSpriteMaterial?d(z,I):I.isShadowMaterial?(z.color.value.copy(I.color),z.opacity.value=I.opacity):I.isShaderMaterial&&(I.uniformsNeedUpdate=!1)}function o(z,I){z.opacity.value=I.opacity,I.color&&z.diffuse.value.copy(I.color),I.emissive&&z.emissive.value.copy(I.emissive).multiplyScalar(I.emissiveIntensity),I.map&&(z.map.value=I.map,t(I.map,z.mapTransform)),I.alphaMap&&(z.alphaMap.value=I.alphaMap,t(I.alphaMap,z.alphaMapTransform)),I.bumpMap&&(z.bumpMap.value=I.bumpMap,t(I.bumpMap,z.bumpMapTransform),z.bumpScale.value=I.bumpScale,I.side===Y&&(z.bumpScale.value*=-1)),I.normalMap&&(z.normalMap.value=I.normalMap,t(I.normalMap,z.normalMapTransform),z.normalScale.value.copy(I.normalScale),I.side===Y&&z.normalScale.value.negate()),I.displacementMap&&(z.displacementMap.value=I.displacementMap,t(I.displacementMap,z.displacementMapTransform),z.displacementScale.value=I.displacementScale,z.displacementBias.value=I.displacementBias),I.emissiveMap&&(z.emissiveMap.value=I.emissiveMap,t(I.emissiveMap,z.emissiveMapTransform)),I.specularMap&&(z.specularMap.value=I.specularMap,t(I.specularMap,z.specularMapTransform)),I.alphaTest>0&&(z.alphaTest.value=I.alphaTest);const J=e.get(I),K=J.envMap,re=J.envMapRotation;K&&(z.envMap.value=K,om.copy(re),om.x*=-1,om.y*=-1,om.z*=-1,K.isCubeTexture&&K.isRenderTargetTexture===!1&&(om.y*=-1,om.z*=-1),z.envMapRotation.value.setFromMatrix4(Jk.makeRotationFromEuler(om)),z.flipEnvMap.value=K.isCubeTexture&&K.isRenderTargetTexture===!1?-1:1,z.reflectivity.value=I.reflectivity,z.ior.value=I.ior,z.refractionRatio.value=I.refractionRatio),I.lightMap&&(z.lightMap.value=I.lightMap,z.lightMapIntensity.value=I.lightMapIntensity,t(I.lightMap,z.lightMapTransform)),I.aoMap&&(z.aoMap.value=I.aoMap,z.aoMapIntensity.value=I.aoMapIntensity,t(I.aoMap,z.aoMapTransform))}function a(z,I){z.diffuse.value.copy(I.color),z.opacity.value=I.opacity,I.map&&(z.map.value=I.map,t(I.map,z.mapTransform))}function c(z,I){z.dashSize.value=I.dashSize,z.totalSize.value=I.dashSize+I.gapSize,z.scale.value=I.scale}function u(z,I,J,K){z.diffuse.value.copy(I.color),z.opacity.value=I.opacity,z.size.value=I.size*J,z.scale.value=K*.5,I.map&&(z.map.value=I.map,t(I.map,z.uvTransform)),I.alphaMap&&(z.alphaMap.value=I.alphaMap,t(I.alphaMap,z.alphaMapTransform)),I.alphaTest>0&&(z.alphaTest.value=I.alphaTest)}function d(z,I){z.diffuse.value.copy(I.color),z.opacity.value=I.opacity,z.rotation.value=I.rotation,I.map&&(z.map.value=I.map,t(I.map,z.mapTransform)),I.alphaMap&&(z.alphaMap.value=I.alphaMap,t(I.alphaMap,z.alphaMapTransform)),I.alphaTest>0&&(z.alphaTest.value=I.alphaTest)}function p(z,I){z.specular.value.copy(I.specular),z.shininess.value=Math.max(I.shininess,1e-4)}function m(z,I){I.gradientMap&&(z.gradientMap.value=I.gradientMap)}function y(z,I){z.metalness.value=I.metalness,I.metalnessMap&&(z.metalnessMap.value=I.metalnessMap,t(I.metalnessMap,z.metalnessMapTransform)),z.roughness.value=I.roughness,I.roughnessMap&&(z.roughnessMap.value=I.roughnessMap,t(I.roughnessMap,z.roughnessMapTransform)),I.envMap&&(z.envMapIntensity.value=I.envMapIntensity)}function M(z,I,J){z.ior.value=I.ior,I.sheen>0&&(z.sheenColor.value.copy(I.sheenColor).multiplyScalar(I.sheen),z.sheenRoughness.value=I.sheenRoughness,I.sheenColorMap&&(z.sheenColorMap.value=I.sheenColorMap,t(I.sheenColorMap,z.sheenColorMapTransform)),I.sheenRoughnessMap&&(z.sheenRoughnessMap.value=I.sheenRoughnessMap,t(I.sheenRoughnessMap,z.sheenRoughnessMapTransform))),I.clearcoat>0&&(z.clearcoat.value=I.clearcoat,z.clearcoatRoughness.value=I.clearcoatRoughness,I.clearcoatMap&&(z.clearcoatMap.value=I.clearcoatMap,t(I.clearcoatMap,z.clearcoatMapTransform)),I.clearcoatRoughnessMap&&(z.clearcoatRoughnessMap.value=I.clearcoatRoughnessMap,t(I.clearcoatRoughnessMap,z.clearcoatRoughnessMapTransform)),I.clearcoatNormalMap&&(z.clearcoatNormalMap.value=I.clearcoatNormalMap,t(I.clearcoatNormalMap,z.clearcoatNormalMapTransform),z.clearcoatNormalScale.value.copy(I.clearcoatNormalScale),I.side===Y&&z.clearcoatNormalScale.value.negate())),I.dispersion>0&&(z.dispersion.value=I.dispersion),I.iridescence>0&&(z.iridescence.value=I.iridescence,z.iridescenceIOR.value=I.iridescenceIOR,z.iridescenceThicknessMinimum.value=I.iridescenceThicknessRange[0],z.iridescenceThicknessMaximum.value=I.iridescenceThicknessRange[1],I.iridescenceMap&&(z.iridescenceMap.value=I.iridescenceMap,t(I.iridescenceMap,z.iridescenceMapTransform)),I.iridescenceThicknessMap&&(z.iridescenceThicknessMap.value=I.iridescenceThicknessMap,t(I.iridescenceThicknessMap,z.iridescenceThicknessMapTransform))),I.transmission>0&&(z.transmission.value=I.transmission,z.transmissionSamplerMap.value=J.texture,z.transmissionSamplerSize.value.set(J.width,J.height),I.transmissionMap&&(z.transmissionMap.value=I.transmissionMap,t(I.transmissionMap,z.transmissionMapTransform)),z.thickness.value=I.thickness,I.thicknessMap&&(z.thicknessMap.value=I.thicknessMap,t(I.thicknessMap,z.thicknessMapTransform)),z.attenuationDistance.value=I.attenuationDistance,z.attenuationColor.value.copy(I.attenuationColor)),I.anisotropy>0&&(z.anisotropyVector.value.set(I.anisotropy*Math.cos(I.anisotropyRotation),I.anisotropy*Math.sin(I.anisotropyRotation)),I.anisotropyMap&&(z.anisotropyMap.value=I.anisotropyMap,t(I.anisotropyMap,z.anisotropyMapTransform))),z.specularIntensity.value=I.specularIntensity,z.specularColor.value.copy(I.specularColor),I.specularColorMap&&(z.specularColorMap.value=I.specularColorMap,t(I.specularColorMap,z.specularColorMapTransform)),I.specularIntensityMap&&(z.specularIntensityMap.value=I.specularIntensityMap,t(I.specularIntensityMap,z.specularIntensityMapTransform))}function T(z,I){I.matcap&&(z.matcap.value=I.matcap)}function G(z,I){const J=e.get(I).light;z.referencePosition.value.setFromMatrixPosition(J.matrixWorld),z.nearDistance.value=J.shadow.camera.near,z.farDistance.value=J.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function ez(i,e,t,n){let s={},o={},a=[];const c=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function u(J,K){const re=K.program;n.uniformBlockBinding(J,re)}function d(J,K){let re=s[J.id];re===void 0&&(T(J),re=p(J),s[J.id]=re,J.addEventListener("dispose",z));const ve=K.program;n.updateUBOMapping(J,ve);const me=e.render.frame;o[J.id]!==me&&(y(J),o[J.id]=me)}function p(J){const K=m();J.__bindingPointIndex=K;const re=i.createBuffer(),ve=J.__size,me=J.usage;return i.bindBuffer(i.UNIFORM_BUFFER,re),i.bufferData(i.UNIFORM_BUFFER,ve,me),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,K,re),re}function m(){for(let J=0;J<c;J++)if(a.indexOf(J)===-1)return a.push(J),J;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function y(J){const K=s[J.id],re=J.uniforms,ve=J.__cache;i.bindBuffer(i.UNIFORM_BUFFER,K);for(let me=0,Le=re.length;me<Le;me++){const Ve=Array.isArray(re[me])?re[me]:[re[me]];for(let Ee=0,Oe=Ve.length;Ee<Oe;Ee++){const dt=Ve[Ee];if(M(dt,me,Ee,ve)===!0){const Ut=dt.__offset,tn=Array.isArray(dt.value)?dt.value:[dt.value];let cn=0;for(let vn=0;vn<tn.length;vn++){const mn=tn[vn],Yn=G(mn);typeof mn=="number"||typeof mn=="boolean"?(dt.__data[0]=mn,i.bufferSubData(i.UNIFORM_BUFFER,Ut+cn,dt.__data)):mn.isMatrix3?(dt.__data[0]=mn.elements[0],dt.__data[1]=mn.elements[1],dt.__data[2]=mn.elements[2],dt.__data[3]=0,dt.__data[4]=mn.elements[3],dt.__data[5]=mn.elements[4],dt.__data[6]=mn.elements[5],dt.__data[7]=0,dt.__data[8]=mn.elements[6],dt.__data[9]=mn.elements[7],dt.__data[10]=mn.elements[8],dt.__data[11]=0):(mn.toArray(dt.__data,cn),cn+=Yn.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,Ut,dt.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function M(J,K,re,ve){const me=J.value,Le=K+"_"+re;if(ve[Le]===void 0)return typeof me=="number"||typeof me=="boolean"?ve[Le]=me:ve[Le]=me.clone(),!0;{const Ve=ve[Le];if(typeof me=="number"||typeof me=="boolean"){if(Ve!==me)return ve[Le]=me,!0}else if(Ve.equals(me)===!1)return Ve.copy(me),!0}return!1}function T(J){const K=J.uniforms;let re=0;const ve=16;for(let Le=0,Ve=K.length;Le<Ve;Le++){const Ee=Array.isArray(K[Le])?K[Le]:[K[Le]];for(let Oe=0,dt=Ee.length;Oe<dt;Oe++){const Ut=Ee[Oe],tn=Array.isArray(Ut.value)?Ut.value:[Ut.value];for(let cn=0,vn=tn.length;cn<vn;cn++){const mn=tn[cn],Yn=G(mn),xn=re%ve,si=xn%Yn.boundary,wn=xn+si;re+=si,wn!==0&&ve-wn<Yn.storage&&(re+=ve-wn),Ut.__data=new Float32Array(Yn.storage/Float32Array.BYTES_PER_ELEMENT),Ut.__offset=re,re+=Yn.storage}}}const me=re%ve;return me>0&&(re+=ve-me),J.__size=re,J.__cache={},this}function G(J){const K={boundary:0,storage:0};return typeof J=="number"||typeof J=="boolean"?(K.boundary=4,K.storage=4):J.isVector2?(K.boundary=8,K.storage=8):J.isVector3||J.isColor?(K.boundary=16,K.storage=12):J.isVector4?(K.boundary=16,K.storage=16):J.isMatrix3?(K.boundary=48,K.storage=48):J.isMatrix4?(K.boundary=64,K.storage=64):J.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",J),K}function z(J){const K=J.target;K.removeEventListener("dispose",z);const re=a.indexOf(K.__bindingPointIndex);a.splice(re,1),i.deleteBuffer(s[K.id]),delete s[K.id],delete o[K.id]}function I(){for(const J in s)i.deleteBuffer(s[J]);a=[],s={},o={}}return{bind:u,update:d,dispose:I}}class tz{constructor(e={}){const{canvas:t=Ka(),context:n=null,depth:s=!0,stencil:o=!1,alpha:a=!1,antialias:c=!1,premultipliedAlpha:u=!0,preserveDrawingBuffer:d=!1,powerPreference:p="default",failIfMajorPerformanceCaveat:m=!1,reversedDepthBuffer:y=!1}=e;this.isWebGLRenderer=!0;let M;if(n!==null){if(typeof WebGLRenderingContext!="undefined"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");M=n.getContextAttributes().alpha}else M=a;const T=new Uint32Array(4),G=new Int32Array(4);let z=null,I=null;const J=[],K=[];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.toneMapping=yt,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const re=this;let ve=!1;this._outputColorSpace=uo;let me=0,Le=0,Ve=null,Ee=-1,Oe=null;const dt=new mr,Ut=new mr;let tn=null;const cn=new jn(0);let vn=0,mn=t.width,Yn=t.height,xn=1,si=null,wn=null;const Gn=new mr(0,0,mn,Yn),Si=new mr(0,0,mn,Yn);let nr=!1;const os=new pf;let Vn=!1,un=!1;const Mn=new Ft,fi=new it,ki=new mr,Ni={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Cr=!1;function Vs(){return Ve===null?xn:1}let kt=n;function Kn(ht,ln){return t.getContext(ht,ln)}try{const ht={alpha:!0,depth:s,stencil:o,antialias:c,premultipliedAlpha:u,preserveDrawingBuffer:d,powerPreference:p,failIfMajorPerformanceCaveat:m};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${w}`),t.addEventListener("webglcontextlost",Di,!1),t.addEventListener("webglcontextrestored",pr,!1),t.addEventListener("webglcontextcreationerror",gi,!1),kt===null){const ln="webgl2";if(kt=Kn(ln,ht),kt===null)throw Kn(ln)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(ht){throw console.error("THREE.WebGLRenderer: "+ht.message),ht}let Zn,qn,Hn,Ti,pi,Ii,ws,ms,bt,Qe,fn,Dn,ri,zn,Rr,Ci,Tr,Er,mi,Yi,ns,Ir,Hi,Ns;function rn(){Zn=new hU(kt),Zn.init(),Ir=new Xk(kt,Zn),qn=new rU(kt,Zn,e,Ir),Hn=new $k(kt,Zn),qn.reversedDepthBuffer&&y&&Hn.buffers.depth.setReversed(!0),Ti=new pU(kt),pi=new Ik,Ii=new jk(kt,Zn,Hn,pi,qn,Ir,Ti),ws=new oU(re),ms=new uU(re),bt=new eF(kt),Hi=new nU(kt,bt),Qe=new dU(kt,bt,Ti,Hi),fn=new gU(kt,Qe,bt,Ti),mi=new mU(kt,qn,Ii),Ci=new sU(pi),Dn=new Pk(re,ws,ms,Zn,qn,Hi,Ci),ri=new Qk(re,pi),zn=new Dk,Rr=new zk(Zn),Er=new tU(re,ws,ms,Hn,fn,M,u),Tr=new Wk(re,fn,qn),Ns=new ez(kt,Ti,qn,Hn),Yi=new iU(kt,Zn,Ti),ns=new fU(kt,Zn,Ti),Ti.programs=Dn.programs,re.capabilities=qn,re.extensions=Zn,re.properties=pi,re.renderLists=zn,re.shadowMap=Tr,re.state=Hn,re.info=Ti}rn();const wi=new Kk(re,kt);this.xr=wi,this.getContext=function(){return kt},this.getContextAttributes=function(){return kt.getContextAttributes()},this.forceContextLoss=function(){const ht=Zn.get("WEBGL_lose_context");ht&&ht.loseContext()},this.forceContextRestore=function(){const ht=Zn.get("WEBGL_lose_context");ht&&ht.restoreContext()},this.getPixelRatio=function(){return xn},this.setPixelRatio=function(ht){ht!==void 0&&(xn=ht,this.setSize(mn,Yn,!1))},this.getSize=function(ht){return ht.set(mn,Yn)},this.setSize=function(ht,ln,Tn=!0){if(wi.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}mn=ht,Yn=ln,t.width=Math.floor(ht*xn),t.height=Math.floor(ln*xn),Tn===!0&&(t.style.width=ht+"px",t.style.height=ln+"px"),this.setViewport(0,0,ht,ln)},this.getDrawingBufferSize=function(ht){return ht.set(mn*xn,Yn*xn).floor()},this.setDrawingBufferSize=function(ht,ln,Tn){mn=ht,Yn=ln,xn=Tn,t.width=Math.floor(ht*Tn),t.height=Math.floor(ln*Tn),this.setViewport(0,0,ht,ln)},this.getCurrentViewport=function(ht){return ht.copy(dt)},this.getViewport=function(ht){return ht.copy(Gn)},this.setViewport=function(ht,ln,Tn,En){ht.isVector4?Gn.set(ht.x,ht.y,ht.z,ht.w):Gn.set(ht,ln,Tn,En),Hn.viewport(dt.copy(Gn).multiplyScalar(xn).round())},this.getScissor=function(ht){return ht.copy(Si)},this.setScissor=function(ht,ln,Tn,En){ht.isVector4?Si.set(ht.x,ht.y,ht.z,ht.w):Si.set(ht,ln,Tn,En),Hn.scissor(Ut.copy(Si).multiplyScalar(xn).round())},this.getScissorTest=function(){return nr},this.setScissorTest=function(ht){Hn.setScissorTest(nr=ht)},this.setOpaqueSort=function(ht){si=ht},this.setTransparentSort=function(ht){wn=ht},this.getClearColor=function(ht){return ht.copy(Er.getClearColor())},this.setClearColor=function(){Er.setClearColor(...arguments)},this.getClearAlpha=function(){return Er.getClearAlpha()},this.setClearAlpha=function(){Er.setClearAlpha(...arguments)},this.clear=function(ht=!0,ln=!0,Tn=!0){let En=0;if(ht){let dn=!1;if(Ve!==null){const _i=Ve.texture.format;dn=_i===nt||_i===ke||_i===X}if(dn){const _i=Ve.texture.type,$i=_i===Oi||_i===ls||_i===gs||_i===Fa||_i===Yl||_i===Zl,wr=Er.getClearColor(),ur=Er.getClearAlpha(),ts=wr.r,as=wr.g,Gr=wr.b;$i?(T[0]=ts,T[1]=as,T[2]=Gr,T[3]=ur,kt.clearBufferuiv(kt.COLOR,0,T)):(G[0]=ts,G[1]=as,G[2]=Gr,G[3]=ur,kt.clearBufferiv(kt.COLOR,0,G))}else En|=kt.COLOR_BUFFER_BIT}ln&&(En|=kt.DEPTH_BUFFER_BIT),Tn&&(En|=kt.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),kt.clear(En)},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",Di,!1),t.removeEventListener("webglcontextrestored",pr,!1),t.removeEventListener("webglcontextcreationerror",gi,!1),Er.dispose(),zn.dispose(),Rr.dispose(),pi.dispose(),ws.dispose(),ms.dispose(),fn.dispose(),Hi.dispose(),Ns.dispose(),Dn.dispose(),wi.dispose(),wi.removeEventListener("sessionstart",Kh),wi.removeEventListener("sessionend",T3),Om.stop()};function Di(ht){ht.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),ve=!0}function pr(){console.log("THREE.WebGLRenderer: Context Restored."),ve=!1;const ht=Ti.autoReset,ln=Tr.enabled,Tn=Tr.autoUpdate,En=Tr.needsUpdate,dn=Tr.type;rn(),Ti.autoReset=ht,Tr.enabled=ln,Tr.autoUpdate=Tn,Tr.needsUpdate=En,Tr.type=dn}function gi(ht){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",ht.statusMessage)}function Jn(ht){const ln=ht.target;ln.removeEventListener("dispose",Jn),Ar(ln)}function Ar(ht){Ms(ht),pi.remove(ht)}function Ms(ht){const ln=pi.get(ht).programs;ln!==void 0&&(ln.forEach(function(Tn){Dn.releaseProgram(Tn)}),ht.isShaderMaterial&&Dn.releaseShaderCache(ht))}this.renderBufferDirect=function(ht,ln,Tn,En,dn,_i){ln===null&&(ln=Ni);const $i=dn.isMesh&&dn.matrixWorld.determinant()<0,wr=yY(ht,ln,Tn,En,dn);Hn.setMaterial(En,$i);let ur=Tn.index,ts=1;if(En.wireframe===!0){if(ur=Qe.getWireframeAttribute(Tn),ur===void 0)return;ts=2}const as=Tn.drawRange,Gr=Tn.attributes.position;let js=as.start*ts,Lo=(as.start+as.count)*ts;_i!==null&&(js=Math.max(js,_i.start*ts),Lo=Math.min(Lo,(_i.start+_i.count)*ts)),ur!==null?(js=Math.max(js,0),Lo=Math.min(Lo,ur.count)):Gr!=null&&(js=Math.max(js,0),Lo=Math.min(Lo,Gr.count));const Oa=Lo-js;if(Oa<0||Oa===1/0)return;Hi.setup(dn,En,wr,Tn,ur);let Qo,Uo=Yi;if(ur!==null&&(Qo=bt.get(ur),Uo=ns,Uo.setIndex(Qo)),dn.isMesh)En.wireframe===!0?(Hn.setLineWidth(En.wireframeLinewidth*Vs()),Uo.setMode(kt.LINES)):Uo.setMode(kt.TRIANGLES);else if(dn.isLine){let Xr=En.linewidth;Xr===void 0&&(Xr=1),Hn.setLineWidth(Xr*Vs()),dn.isLineSegments?Uo.setMode(kt.LINES):dn.isLineLoop?Uo.setMode(kt.LINE_LOOP):Uo.setMode(kt.LINE_STRIP)}else dn.isPoints?Uo.setMode(kt.POINTS):dn.isSprite&&Uo.setMode(kt.TRIANGLES);if(dn.isBatchedMesh)if(dn._multiDrawInstances!==null)ll("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Uo.renderMultiDrawInstances(dn._multiDrawStarts,dn._multiDrawCounts,dn._multiDrawCount,dn._multiDrawInstances);else if(Zn.get("WEBGL_multi_draw"))Uo.renderMultiDraw(dn._multiDrawStarts,dn._multiDrawCounts,dn._multiDrawCount);else{const Xr=dn._multiDrawStarts,_a=dn._multiDrawCounts,co=dn._multiDrawCount,iu=ur?bt.get(ur).bytesPerElement:1,w0=pi.get(En).currentProgram.getUniforms();for(let ru=0;ru<co;ru++)w0.setValue(kt,"_gl_DrawID",ru),Uo.render(Xr[ru]/iu,_a[ru])}else if(dn.isInstancedMesh)Uo.renderInstances(js,Oa,dn.count);else if(Tn.isInstancedBufferGeometry){const Xr=Tn._maxInstanceCount!==void 0?Tn._maxInstanceCount:1/0,_a=Math.min(Tn.instanceCount,Xr);Uo.renderInstances(js,Oa,_a)}else Uo.render(js,Oa)};function Wo(ht,ln,Tn){ht.transparent===!0&&ht.side===ie&&ht.forceSinglePass===!1?(ht.side=Y,ht.needsUpdate=!0,o1(ht,ln,Tn),ht.side=W,ht.needsUpdate=!0,o1(ht,ln,Tn),ht.side=ie):o1(ht,ln,Tn)}this.compile=function(ht,ln,Tn=null){Tn===null&&(Tn=ht),I=Rr.get(Tn),I.init(ln),K.push(I),Tn.traverseVisible(function(dn){dn.isLight&&dn.layers.test(ln.layers)&&(I.pushLight(dn),dn.castShadow&&I.pushShadow(dn))}),ht!==Tn&&ht.traverseVisible(function(dn){dn.isLight&&dn.layers.test(ln.layers)&&(I.pushLight(dn),dn.castShadow&&I.pushShadow(dn))}),I.setupLights();const En=new Set;return ht.traverse(function(dn){if(!(dn.isMesh||dn.isPoints||dn.isLine||dn.isSprite))return;const _i=dn.material;if(_i)if(Array.isArray(_i))for(let $i=0;$i<_i.length;$i++){const wr=_i[$i];Wo(wr,Tn,dn),En.add(wr)}else Wo(_i,Tn,dn),En.add(_i)}),I=K.pop(),En},this.compileAsync=function(ht,ln,Tn=null){const En=this.compile(ht,ln,Tn);return new Promise(dn=>{function _i(){if(En.forEach(function($i){pi.get($i).currentProgram.isReady()&&En.delete($i)}),En.size===0){dn(ht);return}setTimeout(_i,10)}Zn.get("KHR_parallel_shader_compile")!==null?_i():setTimeout(_i,10)})};let bo=null;function Kd(ht){bo&&bo(ht)}function Kh(){Om.stop()}function T3(){Om.start()}const Om=new SA;Om.setAnimationLoop(Kd),typeof self!="undefined"&&Om.setContext(self),this.setAnimationLoop=function(ht){bo=ht,wi.setAnimationLoop(ht),ht===null?Om.stop():Om.start()},wi.addEventListener("sessionstart",Kh),wi.addEventListener("sessionend",T3),this.render=function(ht,ln){if(ln!==void 0&&ln.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(ve===!0)return;if(ht.matrixWorldAutoUpdate===!0&&ht.updateMatrixWorld(),ln.parent===null&&ln.matrixWorldAutoUpdate===!0&&ln.updateMatrixWorld(),wi.enabled===!0&&wi.isPresenting===!0&&(wi.cameraAutoUpdate===!0&&wi.updateCamera(ln),ln=wi.getCamera()),ht.isScene===!0&&ht.onBeforeRender(re,ht,ln,Ve),I=Rr.get(ht,K.length),I.init(ln),K.push(I),Mn.multiplyMatrices(ln.projectionMatrix,ln.matrixWorldInverse),os.setFromProjectionMatrix(Mn,oo,ln.reversedDepth),un=this.localClippingEnabled,Vn=Ci.init(this.clippingPlanes,un),z=zn.get(ht,J.length),z.init(),J.push(z),wi.enabled===!0&&wi.isPresenting===!0){const _i=re.xr.getDepthSensingMesh();_i!==null&&lE(_i,ln,-1/0,re.sortObjects)}lE(ht,ln,0,re.sortObjects),z.finish(),re.sortObjects===!0&&z.sort(si,wn),Cr=wi.enabled===!1||wi.isPresenting===!1||wi.hasDepthSensing()===!1,Cr&&Er.addToRenderList(z,ht),this.info.render.frame++,Vn===!0&&Ci.beginShadows();const Tn=I.state.shadowsArray;Tr.render(Tn,ht,ln),Vn===!0&&Ci.endShadows(),this.info.autoReset===!0&&this.info.reset();const En=z.opaque,dn=z.transmissive;if(I.setupLights(),ln.isArrayCamera){const _i=ln.cameras;if(dn.length>0)for(let $i=0,wr=_i.length;$i<wr;$i++){const ur=_i[$i];A3(En,dn,ht,ur)}Cr&&Er.render(ht);for(let $i=0,wr=_i.length;$i<wr;$i++){const ur=_i[$i];E3(z,ht,ur,ur.viewport)}}else dn.length>0&&A3(En,dn,ht,ln),Cr&&Er.render(ht),E3(z,ht,ln);Ve!==null&&Le===0&&(Ii.updateMultisampleRenderTarget(Ve),Ii.updateRenderTargetMipmap(Ve)),ht.isScene===!0&&ht.onAfterRender(re,ht,ln),Hi.resetDefaultState(),Ee=-1,Oe=null,K.pop(),K.length>0?(I=K[K.length-1],Vn===!0&&Ci.setGlobalState(re.clippingPlanes,I.state.camera)):I=null,J.pop(),J.length>0?z=J[J.length-1]:z=null};function lE(ht,ln,Tn,En){if(ht.visible===!1)return;if(ht.layers.test(ln.layers)){if(ht.isGroup)Tn=ht.renderOrder;else if(ht.isLOD)ht.autoUpdate===!0&&ht.update(ln);else if(ht.isLight)I.pushLight(ht),ht.castShadow&&I.pushShadow(ht);else if(ht.isSprite){if(!ht.frustumCulled||os.intersectsSprite(ht)){En&&ki.setFromMatrixPosition(ht.matrixWorld).applyMatrix4(Mn);const $i=fn.update(ht),wr=ht.material;wr.visible&&z.push(ht,$i,wr,Tn,ki.z,null)}}else if((ht.isMesh||ht.isLine||ht.isPoints)&&(!ht.frustumCulled||os.intersectsObject(ht))){const $i=fn.update(ht),wr=ht.material;if(En&&(ht.boundingSphere!==void 0?(ht.boundingSphere===null&&ht.computeBoundingSphere(),ki.copy(ht.boundingSphere.center)):($i.boundingSphere===null&&$i.computeBoundingSphere(),ki.copy($i.boundingSphere.center)),ki.applyMatrix4(ht.matrixWorld).applyMatrix4(Mn)),Array.isArray(wr)){const ur=$i.groups;for(let ts=0,as=ur.length;ts<as;ts++){const Gr=ur[ts],js=wr[Gr.materialIndex];js&&js.visible&&z.push(ht,$i,js,Tn,ki.z,Gr)}}else wr.visible&&z.push(ht,$i,wr,Tn,ki.z,null)}}const _i=ht.children;for(let $i=0,wr=_i.length;$i<wr;$i++)lE(_i[$i],ln,Tn,En)}function E3(ht,ln,Tn,En){const dn=ht.opaque,_i=ht.transmissive,$i=ht.transparent;I.setupLightsView(Tn),Vn===!0&&Ci.setGlobalState(re.clippingPlanes,Tn),En&&Hn.viewport(dt.copy(En)),dn.length>0&&s1(dn,ln,Tn),_i.length>0&&s1(_i,ln,Tn),$i.length>0&&s1($i,ln,Tn),Hn.buffers.depth.setTest(!0),Hn.buffers.depth.setMask(!0),Hn.buffers.color.setMask(!0),Hn.setPolygonOffset(!1)}function A3(ht,ln,Tn,En){if((Tn.isScene===!0?Tn.overrideMaterial:null)!==null)return;I.state.transmissionRenderTarget[En.id]===void 0&&(I.state.transmissionRenderTarget[En.id]=new hc(1,1,{generateMipmaps:!0,type:Zn.has("EXT_color_buffer_half_float")||Zn.has("EXT_color_buffer_float")?Gs:Oi,minFilter:Qn,samples:4,stencilBuffer:o,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ki.workingColorSpace}));const _i=I.state.transmissionRenderTarget[En.id],$i=En.viewport||dt;_i.setSize($i.z*re.transmissionResolutionScale,$i.w*re.transmissionResolutionScale);const wr=re.getRenderTarget(),ur=re.getActiveCubeFace(),ts=re.getActiveMipmapLevel();re.setRenderTarget(_i),re.getClearColor(cn),vn=re.getClearAlpha(),vn<1&&re.setClearColor(16777215,.5),re.clear(),Cr&&Er.render(Tn);const as=re.toneMapping;re.toneMapping=yt;const Gr=En.viewport;if(En.viewport!==void 0&&(En.viewport=void 0),I.setupLightsView(En),Vn===!0&&Ci.setGlobalState(re.clippingPlanes,En),s1(ht,Tn,En),Ii.updateMultisampleRenderTarget(_i),Ii.updateRenderTargetMipmap(_i),Zn.has("WEBGL_multisampled_render_to_texture")===!1){let js=!1;for(let Lo=0,Oa=ln.length;Lo<Oa;Lo++){const Qo=ln[Lo],Uo=Qo.object,Xr=Qo.geometry,_a=Qo.material,co=Qo.group;if(_a.side===ie&&Uo.layers.test(En.layers)){const iu=_a.side;_a.side=Y,_a.needsUpdate=!0,C3(Uo,Tn,En,Xr,_a,co),_a.side=iu,_a.needsUpdate=!0,js=!0}}js===!0&&(Ii.updateMultisampleRenderTarget(_i),Ii.updateRenderTargetMipmap(_i))}re.setRenderTarget(wr,ur,ts),re.setClearColor(cn,vn),Gr!==void 0&&(En.viewport=Gr),re.toneMapping=as}function s1(ht,ln,Tn){const En=ln.isScene===!0?ln.overrideMaterial:null;for(let dn=0,_i=ht.length;dn<_i;dn++){const $i=ht[dn],wr=$i.object,ur=$i.geometry,ts=$i.group;let as=$i.material;as.allowOverride===!0&&En!==null&&(as=En),wr.layers.test(Tn.layers)&&C3(wr,ln,Tn,ur,as,ts)}}function C3(ht,ln,Tn,En,dn,_i){ht.onBeforeRender(re,ln,Tn,En,dn,_i),ht.modelViewMatrix.multiplyMatrices(Tn.matrixWorldInverse,ht.matrixWorld),ht.normalMatrix.getNormalMatrix(ht.modelViewMatrix),dn.onBeforeRender(re,ln,Tn,En,ht,_i),dn.transparent===!0&&dn.side===ie&&dn.forceSinglePass===!1?(dn.side=Y,dn.needsUpdate=!0,re.renderBufferDirect(Tn,ln,En,dn,ht,_i),dn.side=W,dn.needsUpdate=!0,re.renderBufferDirect(Tn,ln,En,dn,ht,_i),dn.side=ie):re.renderBufferDirect(Tn,ln,En,dn,ht,_i),ht.onAfterRender(re,ln,Tn,En,dn,_i)}function o1(ht,ln,Tn){ln.isScene!==!0&&(ln=Ni);const En=pi.get(ht),dn=I.state.lights,_i=I.state.shadowsArray,$i=dn.state.version,wr=Dn.getParameters(ht,dn.state,_i,ln,Tn),ur=Dn.getProgramCacheKey(wr);let ts=En.programs;En.environment=ht.isMeshStandardMaterial?ln.environment:null,En.fog=ln.fog,En.envMap=(ht.isMeshStandardMaterial?ms:ws).get(ht.envMap||En.environment),En.envMapRotation=En.environment!==null&&ht.envMap===null?ln.environmentRotation:ht.envMapRotation,ts===void 0&&(ht.addEventListener("dispose",Jn),ts=new Map,En.programs=ts);let as=ts.get(ur);if(as!==void 0){if(En.currentProgram===as&&En.lightsStateVersion===$i)return N3(ht,wr),as}else wr.uniforms=Dn.getUniforms(ht),ht.onBeforeCompile(wr,re),as=Dn.acquireProgram(wr,ur),ts.set(ur,as),En.uniforms=wr.uniforms;const Gr=En.uniforms;return(!ht.isShaderMaterial&&!ht.isRawShaderMaterial||ht.clipping===!0)&&(Gr.clippingPlanes=Ci.uniform),N3(ht,wr),En.needsLights=xY(ht),En.lightsStateVersion=$i,En.needsLights&&(Gr.ambientLightColor.value=dn.state.ambient,Gr.lightProbe.value=dn.state.probe,Gr.directionalLights.value=dn.state.directional,Gr.directionalLightShadows.value=dn.state.directionalShadow,Gr.spotLights.value=dn.state.spot,Gr.spotLightShadows.value=dn.state.spotShadow,Gr.rectAreaLights.value=dn.state.rectArea,Gr.ltc_1.value=dn.state.rectAreaLTC1,Gr.ltc_2.value=dn.state.rectAreaLTC2,Gr.pointLights.value=dn.state.point,Gr.pointLightShadows.value=dn.state.pointShadow,Gr.hemisphereLights.value=dn.state.hemi,Gr.directionalShadowMap.value=dn.state.directionalShadowMap,Gr.directionalShadowMatrix.value=dn.state.directionalShadowMatrix,Gr.spotShadowMap.value=dn.state.spotShadowMap,Gr.spotLightMatrix.value=dn.state.spotLightMatrix,Gr.spotLightMap.value=dn.state.spotLightMap,Gr.pointShadowMap.value=dn.state.pointShadowMap,Gr.pointShadowMatrix.value=dn.state.pointShadowMatrix),En.currentProgram=as,En.uniformsList=null,as}function R3(ht){if(ht.uniformsList===null){const ln=ht.currentProgram.getUniforms();ht.uniformsList=w_.seqWithValue(ln.seq,ht.uniforms)}return ht.uniformsList}function N3(ht,ln){const Tn=pi.get(ht);Tn.outputColorSpace=ln.outputColorSpace,Tn.batching=ln.batching,Tn.batchingColor=ln.batchingColor,Tn.instancing=ln.instancing,Tn.instancingColor=ln.instancingColor,Tn.instancingMorph=ln.instancingMorph,Tn.skinning=ln.skinning,Tn.morphTargets=ln.morphTargets,Tn.morphNormals=ln.morphNormals,Tn.morphColors=ln.morphColors,Tn.morphTargetsCount=ln.morphTargetsCount,Tn.numClippingPlanes=ln.numClippingPlanes,Tn.numIntersection=ln.numClipIntersection,Tn.vertexAlphas=ln.vertexAlphas,Tn.vertexTangents=ln.vertexTangents,Tn.toneMapping=ln.toneMapping}function yY(ht,ln,Tn,En,dn){ln.isScene!==!0&&(ln=Ni),Ii.resetTextureUnits();const _i=ln.fog,$i=En.isMeshStandardMaterial?ln.environment:null,wr=Ve===null?re.outputColorSpace:Ve.isXRRenderTarget===!0?Ve.texture.colorSpace:ou,ur=(En.isMeshStandardMaterial?ms:ws).get(En.envMap||$i),ts=En.vertexColors===!0&&!!Tn.attributes.color&&Tn.attributes.color.itemSize===4,as=!!Tn.attributes.tangent&&(!!En.normalMap||En.anisotropy>0),Gr=!!Tn.morphAttributes.position,js=!!Tn.morphAttributes.normal,Lo=!!Tn.morphAttributes.color;let Oa=yt;En.toneMapped&&(Ve===null||Ve.isXRRenderTarget===!0)&&(Oa=re.toneMapping);const Qo=Tn.morphAttributes.position||Tn.morphAttributes.normal||Tn.morphAttributes.color,Uo=Qo!==void 0?Qo.length:0,Xr=pi.get(En),_a=I.state.lights;if(Vn===!0&&(un===!0||ht!==Oe)){const lc=ht===Oe&&En.id===Ee;Ci.setState(En,ht,lc)}let co=!1;En.version===Xr.__version?(Xr.needsLights&&Xr.lightsStateVersion!==_a.state.version||Xr.outputColorSpace!==wr||dn.isBatchedMesh&&Xr.batching===!1||!dn.isBatchedMesh&&Xr.batching===!0||dn.isBatchedMesh&&Xr.batchingColor===!0&&dn.colorTexture===null||dn.isBatchedMesh&&Xr.batchingColor===!1&&dn.colorTexture!==null||dn.isInstancedMesh&&Xr.instancing===!1||!dn.isInstancedMesh&&Xr.instancing===!0||dn.isSkinnedMesh&&Xr.skinning===!1||!dn.isSkinnedMesh&&Xr.skinning===!0||dn.isInstancedMesh&&Xr.instancingColor===!0&&dn.instanceColor===null||dn.isInstancedMesh&&Xr.instancingColor===!1&&dn.instanceColor!==null||dn.isInstancedMesh&&Xr.instancingMorph===!0&&dn.morphTexture===null||dn.isInstancedMesh&&Xr.instancingMorph===!1&&dn.morphTexture!==null||Xr.envMap!==ur||En.fog===!0&&Xr.fog!==_i||Xr.numClippingPlanes!==void 0&&(Xr.numClippingPlanes!==Ci.numPlanes||Xr.numIntersection!==Ci.numIntersection)||Xr.vertexAlphas!==ts||Xr.vertexTangents!==as||Xr.morphTargets!==Gr||Xr.morphNormals!==js||Xr.morphColors!==Lo||Xr.toneMapping!==Oa||Xr.morphTargetsCount!==Uo)&&(co=!0):(co=!0,Xr.__version=En.version);let iu=Xr.currentProgram;co===!0&&(iu=o1(En,ln,dn));let w0=!1,ru=!1,sx=!1;const ba=iu.getUniforms(),Ou=Xr.uniforms;if(Hn.useProgram(iu.program)&&(w0=!0,ru=!0,sx=!0),En.id!==Ee&&(Ee=En.id,ru=!0),w0||Oe!==ht){Hn.buffers.depth.getReversed()&&ht.reversedDepth!==!0&&(ht._reversedDepth=!0,ht.updateProjectionMatrix()),ba.setValue(kt,"projectionMatrix",ht.projectionMatrix),ba.setValue(kt,"viewMatrix",ht.matrixWorldInverse);const Ic=ba.map.cameraPosition;Ic!==void 0&&Ic.setValue(kt,fi.setFromMatrixPosition(ht.matrixWorld)),qn.logarithmicDepthBuffer&&ba.setValue(kt,"logDepthBufFC",2/(Math.log(ht.far+1)/Math.LN2)),(En.isMeshPhongMaterial||En.isMeshToonMaterial||En.isMeshLambertMaterial||En.isMeshBasicMaterial||En.isMeshStandardMaterial||En.isShaderMaterial)&&ba.setValue(kt,"isOrthographic",ht.isOrthographicCamera===!0),Oe!==ht&&(Oe=ht,ru=!0,sx=!0)}if(dn.isSkinnedMesh){ba.setOptional(kt,dn,"bindMatrix"),ba.setOptional(kt,dn,"bindMatrixInverse");const lc=dn.skeleton;lc&&(lc.boneTexture===null&&lc.computeBoneTexture(),ba.setValue(kt,"boneTexture",lc.boneTexture,Ii))}dn.isBatchedMesh&&(ba.setOptional(kt,dn,"batchingTexture"),ba.setValue(kt,"batchingTexture",dn._matricesTexture,Ii),ba.setOptional(kt,dn,"batchingIdTexture"),ba.setValue(kt,"batchingIdTexture",dn._indirectTexture,Ii),ba.setOptional(kt,dn,"batchingColorTexture"),dn._colorsTexture!==null&&ba.setValue(kt,"batchingColorTexture",dn._colorsTexture,Ii));const Fu=Tn.morphAttributes;if((Fu.position!==void 0||Fu.normal!==void 0||Fu.color!==void 0)&&mi.update(dn,Tn,iu),(ru||Xr.receiveShadow!==dn.receiveShadow)&&(Xr.receiveShadow=dn.receiveShadow,ba.setValue(kt,"receiveShadow",dn.receiveShadow)),En.isMeshGouraudMaterial&&En.envMap!==null&&(Ou.envMap.value=ur,Ou.flipEnvMap.value=ur.isCubeTexture&&ur.isRenderTargetTexture===!1?-1:1),En.isMeshStandardMaterial&&En.envMap===null&&ln.environment!==null&&(Ou.envMapIntensity.value=ln.environmentIntensity),ru&&(ba.setValue(kt,"toneMappingExposure",re.toneMappingExposure),Xr.needsLights&&vY(Ou,sx),_i&&En.fog===!0&&ri.refreshFogUniforms(Ou,_i),ri.refreshMaterialUniforms(Ou,En,xn,Yn,I.state.transmissionRenderTarget[ht.id]),w_.upload(kt,R3(Xr),Ou,Ii)),En.isShaderMaterial&&En.uniformsNeedUpdate===!0&&(w_.upload(kt,R3(Xr),Ou,Ii),En.uniformsNeedUpdate=!1),En.isSpriteMaterial&&ba.setValue(kt,"center",dn.center),ba.setValue(kt,"modelViewMatrix",dn.modelViewMatrix),ba.setValue(kt,"normalMatrix",dn.normalMatrix),ba.setValue(kt,"modelMatrix",dn.matrixWorld),En.isShaderMaterial||En.isRawShaderMaterial){const lc=En.uniformsGroups;for(let Ic=0,cE=lc.length;Ic<cE;Ic++){const Fm=lc[Ic];Ns.update(Fm,iu),Ns.bind(Fm,iu)}}return iu}function vY(ht,ln){ht.ambientLightColor.needsUpdate=ln,ht.lightProbe.needsUpdate=ln,ht.directionalLights.needsUpdate=ln,ht.directionalLightShadows.needsUpdate=ln,ht.pointLights.needsUpdate=ln,ht.pointLightShadows.needsUpdate=ln,ht.spotLights.needsUpdate=ln,ht.spotLightShadows.needsUpdate=ln,ht.rectAreaLights.needsUpdate=ln,ht.hemisphereLights.needsUpdate=ln}function xY(ht){return ht.isMeshLambertMaterial||ht.isMeshToonMaterial||ht.isMeshPhongMaterial||ht.isMeshStandardMaterial||ht.isShadowMaterial||ht.isShaderMaterial&&ht.lights===!0}this.getActiveCubeFace=function(){return me},this.getActiveMipmapLevel=function(){return Le},this.getRenderTarget=function(){return Ve},this.setRenderTargetTextures=function(ht,ln,Tn){const En=pi.get(ht);En.__autoAllocateDepthBuffer=ht.resolveDepthBuffer===!1,En.__autoAllocateDepthBuffer===!1&&(En.__useRenderToTexture=!1),pi.get(ht.texture).__webglTexture=ln,pi.get(ht.depthTexture).__webglTexture=En.__autoAllocateDepthBuffer?void 0:Tn,En.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(ht,ln){const Tn=pi.get(ht);Tn.__webglFramebuffer=ln,Tn.__useDefaultFramebuffer=ln===void 0};const _Y=kt.createFramebuffer();this.setRenderTarget=function(ht,ln=0,Tn=0){Ve=ht,me=ln,Le=Tn;let En=!0,dn=null,_i=!1,$i=!1;if(ht){const ur=pi.get(ht);if(ur.__useDefaultFramebuffer!==void 0)Hn.bindFramebuffer(kt.FRAMEBUFFER,null),En=!1;else if(ur.__webglFramebuffer===void 0)Ii.setupRenderTarget(ht);else if(ur.__hasExternalTextures)Ii.rebindTextures(ht,pi.get(ht.texture).__webglTexture,pi.get(ht.depthTexture).__webglTexture);else if(ht.depthBuffer){const Gr=ht.depthTexture;if(ur.__boundDepthTexture!==Gr){if(Gr!==null&&pi.has(Gr)&&(ht.width!==Gr.image.width||ht.height!==Gr.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Ii.setupDepthRenderbuffer(ht)}}const ts=ht.texture;(ts.isData3DTexture||ts.isDataArrayTexture||ts.isCompressedArrayTexture)&&($i=!0);const as=pi.get(ht).__webglFramebuffer;ht.isWebGLCubeRenderTarget?(Array.isArray(as[ln])?dn=as[ln][Tn]:dn=as[ln],_i=!0):ht.samples>0&&Ii.useMultisampledRTT(ht)===!1?dn=pi.get(ht).__webglMultisampledFramebuffer:Array.isArray(as)?dn=as[Tn]:dn=as,dt.copy(ht.viewport),Ut.copy(ht.scissor),tn=ht.scissorTest}else dt.copy(Gn).multiplyScalar(xn).floor(),Ut.copy(Si).multiplyScalar(xn).floor(),tn=nr;if(Tn!==0&&(dn=_Y),Hn.bindFramebuffer(kt.FRAMEBUFFER,dn)&&En&&Hn.drawBuffers(ht,dn),Hn.viewport(dt),Hn.scissor(Ut),Hn.setScissorTest(tn),_i){const ur=pi.get(ht.texture);kt.framebufferTexture2D(kt.FRAMEBUFFER,kt.COLOR_ATTACHMENT0,kt.TEXTURE_CUBE_MAP_POSITIVE_X+ln,ur.__webglTexture,Tn)}else if($i){const ur=ln;for(let ts=0;ts<ht.textures.length;ts++){const as=pi.get(ht.textures[ts]);kt.framebufferTextureLayer(kt.FRAMEBUFFER,kt.COLOR_ATTACHMENT0+ts,as.__webglTexture,Tn,ur)}}else if(ht!==null&&Tn!==0){const ur=pi.get(ht.texture);kt.framebufferTexture2D(kt.FRAMEBUFFER,kt.COLOR_ATTACHMENT0,kt.TEXTURE_2D,ur.__webglTexture,Tn)}Ee=-1},this.readRenderTargetPixels=function(ht,ln,Tn,En,dn,_i,$i,wr=0){if(!(ht&&ht.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ur=pi.get(ht).__webglFramebuffer;if(ht.isWebGLCubeRenderTarget&&$i!==void 0&&(ur=ur[$i]),ur){Hn.bindFramebuffer(kt.FRAMEBUFFER,ur);try{const ts=ht.textures[wr],as=ts.format,Gr=ts.type;if(!qn.textureFormatReadable(as)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!qn.textureTypeReadable(Gr)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ln>=0&&ln<=ht.width-En&&Tn>=0&&Tn<=ht.height-dn&&(ht.textures.length>1&&kt.readBuffer(kt.COLOR_ATTACHMENT0+wr),kt.readPixels(ln,Tn,En,dn,Ir.convert(as),Ir.convert(Gr),_i))}finally{const ts=Ve!==null?pi.get(Ve).__webglFramebuffer:null;Hn.bindFramebuffer(kt.FRAMEBUFFER,ts)}}},this.readRenderTargetPixelsAsync=function(ht,ln,Tn,En,dn,_i,$i,wr=0){return hr(this,null,function*(){if(!(ht&&ht.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ur=pi.get(ht).__webglFramebuffer;if(ht.isWebGLCubeRenderTarget&&$i!==void 0&&(ur=ur[$i]),ur)if(ln>=0&&ln<=ht.width-En&&Tn>=0&&Tn<=ht.height-dn){Hn.bindFramebuffer(kt.FRAMEBUFFER,ur);const ts=ht.textures[wr],as=ts.format,Gr=ts.type;if(!qn.textureFormatReadable(as))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!qn.textureTypeReadable(Gr))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const js=kt.createBuffer();kt.bindBuffer(kt.PIXEL_PACK_BUFFER,js),kt.bufferData(kt.PIXEL_PACK_BUFFER,_i.byteLength,kt.STREAM_READ),ht.textures.length>1&&kt.readBuffer(kt.COLOR_ATTACHMENT0+wr),kt.readPixels(ln,Tn,En,dn,Ir.convert(as),Ir.convert(Gr),0);const Lo=Ve!==null?pi.get(Ve).__webglFramebuffer:null;Hn.bindFramebuffer(kt.FRAMEBUFFER,Lo);const Oa=kt.fenceSync(kt.SYNC_GPU_COMMANDS_COMPLETE,0);return kt.flush(),yield oi(kt,Oa,4),kt.bindBuffer(kt.PIXEL_PACK_BUFFER,js),kt.getBufferSubData(kt.PIXEL_PACK_BUFFER,0,_i),kt.deleteBuffer(js),kt.deleteSync(Oa),_i}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")})},this.copyFramebufferToTexture=function(ht,ln=null,Tn=0){const En=Math.pow(2,-Tn),dn=Math.floor(ht.image.width*En),_i=Math.floor(ht.image.height*En),$i=ln!==null?ln.x:0,wr=ln!==null?ln.y:0;Ii.setTexture2D(ht,0),kt.copyTexSubImage2D(kt.TEXTURE_2D,Tn,0,0,$i,wr,dn,_i),Hn.unbindTexture()};const bY=kt.createFramebuffer(),wY=kt.createFramebuffer();this.copyTextureToTexture=function(ht,ln,Tn=null,En=null,dn=0,_i=null){_i===null&&(dn!==0?(ll("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),_i=dn,dn=0):_i=0);let $i,wr,ur,ts,as,Gr,js,Lo,Oa;const Qo=ht.isCompressedTexture?ht.mipmaps[_i]:ht.image;if(Tn!==null)$i=Tn.max.x-Tn.min.x,wr=Tn.max.y-Tn.min.y,ur=Tn.isBox3?Tn.max.z-Tn.min.z:1,ts=Tn.min.x,as=Tn.min.y,Gr=Tn.isBox3?Tn.min.z:0;else{const Fu=Math.pow(2,-dn);$i=Math.floor(Qo.width*Fu),wr=Math.floor(Qo.height*Fu),ht.isDataArrayTexture?ur=Qo.depth:ht.isData3DTexture?ur=Math.floor(Qo.depth*Fu):ur=1,ts=0,as=0,Gr=0}En!==null?(js=En.x,Lo=En.y,Oa=En.z):(js=0,Lo=0,Oa=0);const Uo=Ir.convert(ln.format),Xr=Ir.convert(ln.type);let _a;ln.isData3DTexture?(Ii.setTexture3D(ln,0),_a=kt.TEXTURE_3D):ln.isDataArrayTexture||ln.isCompressedArrayTexture?(Ii.setTexture2DArray(ln,0),_a=kt.TEXTURE_2D_ARRAY):(Ii.setTexture2D(ln,0),_a=kt.TEXTURE_2D),kt.pixelStorei(kt.UNPACK_FLIP_Y_WEBGL,ln.flipY),kt.pixelStorei(kt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ln.premultiplyAlpha),kt.pixelStorei(kt.UNPACK_ALIGNMENT,ln.unpackAlignment);const co=kt.getParameter(kt.UNPACK_ROW_LENGTH),iu=kt.getParameter(kt.UNPACK_IMAGE_HEIGHT),w0=kt.getParameter(kt.UNPACK_SKIP_PIXELS),ru=kt.getParameter(kt.UNPACK_SKIP_ROWS),sx=kt.getParameter(kt.UNPACK_SKIP_IMAGES);kt.pixelStorei(kt.UNPACK_ROW_LENGTH,Qo.width),kt.pixelStorei(kt.UNPACK_IMAGE_HEIGHT,Qo.height),kt.pixelStorei(kt.UNPACK_SKIP_PIXELS,ts),kt.pixelStorei(kt.UNPACK_SKIP_ROWS,as),kt.pixelStorei(kt.UNPACK_SKIP_IMAGES,Gr);const ba=ht.isDataArrayTexture||ht.isData3DTexture,Ou=ln.isDataArrayTexture||ln.isData3DTexture;if(ht.isDepthTexture){const Fu=pi.get(ht),lc=pi.get(ln),Ic=pi.get(Fu.__renderTarget),cE=pi.get(lc.__renderTarget);Hn.bindFramebuffer(kt.READ_FRAMEBUFFER,Ic.__webglFramebuffer),Hn.bindFramebuffer(kt.DRAW_FRAMEBUFFER,cE.__webglFramebuffer);for(let Fm=0;Fm<ur;Fm++)ba&&(kt.framebufferTextureLayer(kt.READ_FRAMEBUFFER,kt.COLOR_ATTACHMENT0,pi.get(ht).__webglTexture,dn,Gr+Fm),kt.framebufferTextureLayer(kt.DRAW_FRAMEBUFFER,kt.COLOR_ATTACHMENT0,pi.get(ln).__webglTexture,_i,Oa+Fm)),kt.blitFramebuffer(ts,as,$i,wr,js,Lo,$i,wr,kt.DEPTH_BUFFER_BIT,kt.NEAREST);Hn.bindFramebuffer(kt.READ_FRAMEBUFFER,null),Hn.bindFramebuffer(kt.DRAW_FRAMEBUFFER,null)}else if(dn!==0||ht.isRenderTargetTexture||pi.has(ht)){const Fu=pi.get(ht),lc=pi.get(ln);Hn.bindFramebuffer(kt.READ_FRAMEBUFFER,bY),Hn.bindFramebuffer(kt.DRAW_FRAMEBUFFER,wY);for(let Ic=0;Ic<ur;Ic++)ba?kt.framebufferTextureLayer(kt.READ_FRAMEBUFFER,kt.COLOR_ATTACHMENT0,Fu.__webglTexture,dn,Gr+Ic):kt.framebufferTexture2D(kt.READ_FRAMEBUFFER,kt.COLOR_ATTACHMENT0,kt.TEXTURE_2D,Fu.__webglTexture,dn),Ou?kt.framebufferTextureLayer(kt.DRAW_FRAMEBUFFER,kt.COLOR_ATTACHMENT0,lc.__webglTexture,_i,Oa+Ic):kt.framebufferTexture2D(kt.DRAW_FRAMEBUFFER,kt.COLOR_ATTACHMENT0,kt.TEXTURE_2D,lc.__webglTexture,_i),dn!==0?kt.blitFramebuffer(ts,as,$i,wr,js,Lo,$i,wr,kt.COLOR_BUFFER_BIT,kt.NEAREST):Ou?kt.copyTexSubImage3D(_a,_i,js,Lo,Oa+Ic,ts,as,$i,wr):kt.copyTexSubImage2D(_a,_i,js,Lo,ts,as,$i,wr);Hn.bindFramebuffer(kt.READ_FRAMEBUFFER,null),Hn.bindFramebuffer(kt.DRAW_FRAMEBUFFER,null)}else Ou?ht.isDataTexture||ht.isData3DTexture?kt.texSubImage3D(_a,_i,js,Lo,Oa,$i,wr,ur,Uo,Xr,Qo.data):ln.isCompressedArrayTexture?kt.compressedTexSubImage3D(_a,_i,js,Lo,Oa,$i,wr,ur,Uo,Qo.data):kt.texSubImage3D(_a,_i,js,Lo,Oa,$i,wr,ur,Uo,Xr,Qo):ht.isDataTexture?kt.texSubImage2D(kt.TEXTURE_2D,_i,js,Lo,$i,wr,Uo,Xr,Qo.data):ht.isCompressedTexture?kt.compressedTexSubImage2D(kt.TEXTURE_2D,_i,js,Lo,Qo.width,Qo.height,Uo,Qo.data):kt.texSubImage2D(kt.TEXTURE_2D,_i,js,Lo,$i,wr,Uo,Xr,Qo);kt.pixelStorei(kt.UNPACK_ROW_LENGTH,co),kt.pixelStorei(kt.UNPACK_IMAGE_HEIGHT,iu),kt.pixelStorei(kt.UNPACK_SKIP_PIXELS,w0),kt.pixelStorei(kt.UNPACK_SKIP_ROWS,ru),kt.pixelStorei(kt.UNPACK_SKIP_IMAGES,sx),_i===0&&ln.generateMipmaps&&kt.generateMipmap(_a),Hn.unbindTexture()},this.initRenderTarget=function(ht){pi.get(ht).__webglFramebuffer===void 0&&Ii.setupRenderTarget(ht)},this.initTexture=function(ht){ht.isCubeTexture?Ii.setTextureCube(ht,0):ht.isData3DTexture?Ii.setTexture3D(ht,0):ht.isDataArrayTexture||ht.isCompressedArrayTexture?Ii.setTexture2DArray(ht,0):Ii.setTexture2D(ht,0),Hn.unbindTexture()},this.resetState=function(){me=0,Le=0,Ve=null,Hn.reset(),Hi.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return oo}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Ki._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ki._getUnpackColorSpace()}}const nz=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"],jw=new WeakMap;class iz{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=nz,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}needsVelocity(e){const t=e.getMRT();return t!==null&&t.has("velocity")}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){const{geometry:n,material:s,object:o}=e;if(t={material:this.getMaterialData(s),geometry:{id:n.id,attributes:this.getAttributesData(n.attributes),indexVersion:n.index?n.index.version:null,drawRange:{start:n.drawRange.start,count:n.drawRange.count}},worldMatrix:o.matrixWorld.clone()},o.center&&(t.center=o.center.clone()),o.morphTargetInfluences&&(t.morphTargetInfluences=o.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){const{width:a,height:c}=e.context;t.bufferWidth=a,t.bufferHeight=c}t.lights=this.getLightsData(e.lightsNode.getLights()),this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const n in e){const s=e[n];t[n]={version:s.version}}return t}containsNode(e){const t=e.material;for(const n in t)if(t[n]&&t[n].isNode)return!0;return e.renderer.overrideNodes.modelViewMatrix!==null||e.renderer.overrideNodes.modelNormalViewMatrix!==null}getMaterialData(e){const t={};for(const n of this.refreshUniforms){const s=e[n];s!=null&&(typeof s=="object"&&s.clone!==void 0?s.isTexture===!0?t[n]={id:s.id,version:s.version}:t[n]=s.clone():t[n]=s)}return t}equals(e,t){const{object:n,material:s,geometry:o}=e,a=this.getRenderObjectData(e);if(a.worldMatrix.equals(n.matrixWorld)!==!0)return a.worldMatrix.copy(n.matrixWorld),!1;const c=a.material;for(const z in c){const I=c[z],J=s[z];if(I.equals!==void 0){if(I.equals(J)===!1)return I.copy(J),!1}else if(J.isTexture===!0){if(I.id!==J.id||I.version!==J.version)return I.id=J.id,I.version=J.version,!1}else if(I!==J)return c[z]=J,!1}if(c.transmission>0){const{width:z,height:I}=e.context;if(a.bufferWidth!==z||a.bufferHeight!==I)return a.bufferWidth=z,a.bufferHeight=I,!1}const u=a.geometry,d=o.attributes,p=u.attributes,m=Object.keys(p),y=Object.keys(d);if(u.id!==o.id)return u.id=o.id,!1;if(m.length!==y.length)return a.geometry.attributes=this.getAttributesData(d),!1;for(const z of m){const I=p[z],J=d[z];if(J===void 0)return delete p[z],!1;if(I.version!==J.version)return I.version=J.version,!1}const M=o.index,T=u.indexVersion,G=M?M.version:null;if(T!==G)return u.indexVersion=G,!1;if(u.drawRange.start!==o.drawRange.start||u.drawRange.count!==o.drawRange.count)return u.drawRange.start=o.drawRange.start,u.drawRange.count=o.drawRange.count,!1;if(a.morphTargetInfluences){let z=!1;for(let I=0;I<a.morphTargetInfluences.length;I++)a.morphTargetInfluences[I]!==n.morphTargetInfluences[I]&&(z=!0);if(z)return!0}if(a.lights){for(let z=0;z<t.length;z++)if(a.lights[z].map!==t[z].map)return!1}return a.center&&a.center.equals(n.center)===!1?(a.center.copy(n.center),!0):(e.bundle!==null&&(a.version=e.bundle.version),!0)}getLightsData(e){const t=[];for(const n of e)n.isSpotLight===!0&&n.map!==null&&t.push({map:n.map.version});return t}getLights(e,t){if(jw.has(e)){const s=jw.get(e);if(s.renderId===t)return s.lightsData}const n=this.getLightsData(e.getLights());return jw.set(e,{renderId:t,lightsData:n}),n}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;const{renderId:n}=t;if(this.renderId!==n)return this.renderId=n,!0;const s=e.object.static===!0,o=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;if(s||o)return!1;const a=this.getLights(e.lightsNode,n);return this.equals(e,a)!==!0}}function Ky(i,e=0){let t=3735928559^e,n=1103547991^e;if(i instanceof Array)for(let s=0,o;s<i.length;s++)o=i[s],t=Math.imul(t^o,2654435761),n=Math.imul(n^o,1597334677);else for(let s=0,o;s<i.length;s++)o=i.charCodeAt(s),t=Math.imul(t^o,2654435761),n=Math.imul(n^o,1597334677);return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}const Xw=i=>Ky(i),Jy=i=>Ky(i),Qy=(...i)=>Ky(i);function qw(i,e=!1){const t=[];i.isNode===!0&&t.push(i.id);for(const{property:n,childNode:s}of ev(i))t.push(Ky(n.slice(0,-4)),s.getCacheKey(e));return Ky(t)}function*ev(i,e=!1){for(const t of Object.getOwnPropertyNames(i)){if(t.startsWith("_")===!0)continue;const n=i[t];if(Array.isArray(n)===!0)for(let s=0;s<n.length;s++){const o=n[s];o&&(o.isNode===!0||e&&typeof o.toJSON=="function")&&(yield{property:t,index:s,childNode:o})}else if(n&&n.isNode===!0)yield{property:t,childNode:n};else if(n&&Object.getPrototypeOf(n)===Object.prototype)for(const s in n){if(s.startsWith("_")===!0)continue;const o=n[s];o&&(o.isNode===!0||e&&typeof o.toJSON=="function")&&(yield{property:t,index:s,childNode:o})}}}const rz=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),QA=new WeakMap;function Yw(i){return rz.get(i)}function tv(i){if(/[iu]?vec\d/.test(i))return i.startsWith("ivec")?Int32Array:i.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(i)||/float/.test(i))return Float32Array;if(/uint/.test(i))return Uint32Array;if(/int/.test(i))return Int32Array;throw new Error(`THREE.NodeUtils: Unsupported type: ${i}`)}function Zw(i){if(/float|int|uint/.test(i))return 1;if(/vec2/.test(i))return 2;if(/vec3/.test(i))return 3;if(/vec4/.test(i)||/mat2/.test(i))return 4;if(/mat3/.test(i))return 9;if(/mat4/.test(i))return 16;console.error("THREE.TSL: Unsupported type:",i)}function eC(i){if(/float|int|uint/.test(i))return 1;if(/vec2/.test(i))return 2;if(/vec3/.test(i))return 3;if(/vec4/.test(i)||/mat2/.test(i))return 4;if(/mat3/.test(i))return 12;if(/mat4/.test(i))return 16;console.error("THREE.TSL: Unsupported type:",i)}function tC(i){if(/float|int|uint/.test(i))return 4;if(/vec2/.test(i))return 8;if(/vec3/.test(i)||/vec4/.test(i))return 16;if(/mat2/.test(i))return 8;if(/mat3/.test(i))return 48;if(/mat4/.test(i))return 64;console.error("THREE.TSL: Unsupported type:",i)}function Od(i){if(i==null)return null;const e=typeof i;return i.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":i.isVector2===!0?"vec2":i.isVector3===!0?"vec3":i.isVector4===!0?"vec4":i.isMatrix2===!0?"mat2":i.isMatrix3===!0?"mat3":i.isMatrix4===!0?"mat4":i.isColor===!0?"color":i instanceof ArrayBuffer?"ArrayBuffer":null}function S_(i,...e){const t=i?i.slice(-4):void 0;return e.length===1&&(t==="vec2"?e=[e[0],e[0]]:t==="vec3"?e=[e[0],e[0],e[0]]:t==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),i==="color"?new jn(...e):t==="vec2"?new yn(...e):t==="vec3"?new it(...e):t==="vec4"?new mr(...e):t==="mat2"?new Yp(...e):t==="mat3"?new jr(...e):t==="mat4"?new Ft(...e):i==="bool"?e[0]||!1:i==="float"||i==="int"||i==="uint"?e[0]||0:i==="string"?e[0]||"":i==="ArrayBuffer"?Qw(e[0]):null}function Kw(i){let e=QA.get(i);return e===void 0&&(e={},QA.set(i,e)),e}function Jw(i){let e="";const t=new Uint8Array(i);for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function Qw(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0)).buffer}var dZ=Object.freeze({__proto__:null,arrayBufferToBase64:Jw,base64ToArrayBuffer:Qw,getByteBoundaryFromType:tC,getCacheKey:qw,getDataFromObject:Kw,getLengthFromType:Zw,getMemoryLengthFromType:eC,getNodeChildren:ev,getTypeFromLength:Yw,getTypedArrayFromType:tv,getValueFromType:S_,getValueType:Od,hash:Qy,hashArray:Jy,hashString:Xw});const nv={VERTEX:"vertex",FRAGMENT:"fragment"},ss={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},sz={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Il={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},nC=["fragment","vertex"],eM=["setup","analyze","generate"],tM=[...nC,"compute"],am=["x","y","z","w"],oz={analyze:"setup",generate:"analyze"};let az=0;class Wi extends Bl{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=ss.NONE,this.updateBeforeType=ss.NONE,this.updateAfterType=ss.NONE,this.uuid=ed.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:az++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this),this}onFrameUpdate(e){return this.onUpdate(e,ss.FRAME)}onRenderUpdate(e){return this.onUpdate(e,ss.RENDER)}onObjectUpdate(e){return this.onUpdate(e,ss.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of ev(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=Qy(qw(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}getArrayCount(){return null}setup(e){const t=e.getNodeProperties(this);let n=0;for(const s of this.getChildren())t["node"+n++]=s;return t.outputNode||null}analyze(e,t=null){const n=e.increaseUsage(this);if(this.parents===!0){const s=e.getDataFromNode(this,"any");s.stages=s.stages||{},s.stages[e.shaderStage]=s.stages[e.shaderStage]||[],s.stages[e.shaderStage].push(t)}if(n===1){const s=e.getNodeProperties(this);for(const o of Object.values(s))o&&o.isNode===!0&&o.build(e,this)}}generate(e,t){const{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const n=this.getShared(e);if(this!==n)return n.build(e,t);const s=e.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[e.buildStage]=!0;const o=oz[e.buildStage];if(o&&s.buildStages[o]!==!0){const u=e.getBuildStage();e.setBuildStage(o),this.build(e),e.setBuildStage(u)}e.addNode(this),e.addChain(this);let a=null;const c=e.getBuildStage();if(c==="setup"){this.updateReference(e);const u=e.getNodeProperties(this);if(u.initialized!==!0){u.initialized=!0,u.outputNode=this.setup(e)||u.outputNode||null;for(const d of Object.values(u))if(d&&d.isNode===!0){if(d.parents===!0){const p=e.getNodeProperties(d);p.parents=p.parents||[],p.parents.push(this)}d.build(e)}}a=u.outputNode}else if(c==="analyze")this.analyze(e,t);else if(c==="generate"){if(this.generate.length===1){const d=this.getNodeType(e),p=e.getDataFromNode(this);a=p.snippet,a===void 0?p.generated===void 0?(p.generated=!0,a=this.generate(e)||"",p.snippet=a):(console.warn("THREE.Node: Recursion detected.",this),a="/* Recursion detected. */"):p.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,d,t)}else a=this.generate(e,t)||"";a===""&&t!==null&&t!=="void"&&t!=="OutputType"&&(console.error(`THREE.TSL: Invalid generated code, expected a "${t}".`),a=e.generateConst(t))}return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return ev(this)}serialize(e){const t=this.getSerializeChildren(),n={};for(const{property:s,index:o,childNode:a}of t)o!==void 0?(n[s]===void 0&&(n[s]=Number.isInteger(o)?[]:{}),n[s][o]=a.toJSON(e.meta).uuid):n[s]=a.toJSON(e.meta).uuid;Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){const s=[];for(const o of e.inputNodes[n])s.push(t[o]);this[n]=s}else if(typeof e.inputNodes[n]=="object"){const s={};for(const o in e.inputNodes[n]){const a=e.inputNodes[n][o];s[o]=t[a]}this[n]=s}else{const s=e.inputNodes[n];this[n]=t[s]}}}toJSON(e){const{uuid:t,type:n}=this,s=e===void 0||typeof e=="string";s&&(e={textures:{},images:{},nodes:{}});let o=e.nodes[t];o===void 0&&(o={uuid:t,type:n,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},s!==!0&&(e.nodes[o.uuid]=o),this.serialize(o),delete o.meta);function a(c){const u=[];for(const d in c){const p=c[d];delete p.metadata,u.push(p)}return u}if(s){const c=a(e.textures),u=a(e.images),d=a(e.nodes);c.length>0&&(o.textures=c),u.length>0&&(o.images=u),d.length>0&&(o.nodes=d)}return o}}class lm extends Wi{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.indexNode.getNodeType(e),n=this.node.build(e),s=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint");return`${n}[ ${s} ]`}}class iC extends Wi{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let n=null;for(const s of this.convertTo.split("|"))(n===null||e.getTypeLength(t)===e.getTypeLength(s))&&(n=s);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const n=this.node,s=this.getNodeType(e),o=n.build(e,s);return e.format(o,s,t)}}class Pa extends Wi{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const s=e.getVectorType(this.getNodeType(e,t)),o=e.getDataFromNode(this);if(o.propertyName!==void 0)return e.format(o.propertyName,s,t);if(s!=="void"&&t!=="void"&&this.hasDependencies(e)){const a=super.build(e,s),c=e.getVarFromNode(this,null,s),u=e.getPropertyName(c);return e.addLineFlowCode(`${u} = ${a}`,this),o.snippet=a,o.propertyName=u,e.format(o.propertyName,s,t)}}return super.build(e,t)}}class lz extends Pa{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0))}generate(e,t){const n=this.getNodeType(e),s=e.getTypeLength(n),o=this.nodes,a=e.getComponentType(n),c=[];let u=0;for(const p of o){if(u>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let m=p.getNodeType(e),y=e.getTypeLength(m),M;if(u+y>s&&(console.error(`THREE.TSL: Length of '${n}()' data exceeds maximum length of output type.`),y=s-u,m=e.getTypeFromLength(y)),u+=y,M=p.build(e,m),e.getComponentType(m)!==a){const G=e.getTypeFromLength(y,a);M=e.format(M,m,G)}c.push(M)}const d=`${e.getType(n)}( ${c.join(", ")} )`;return e.format(d,n,t)}}const cz=am.join("");class rC extends Wi{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(am.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}getScope(){return this.node.getScope()}generate(e,t){const n=this.node,s=e.getTypeLength(n.getNodeType(e));let o=null;if(s>1){let a=null;this.getVectorLength()>=s&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const u=n.build(e,a);this.components.length===s&&this.components===cz.slice(0,this.components.length)?o=e.format(u,a,t):o=e.format(`${u}.${this.components}`,this.getNodeType(e),t)}else o=n.build(e,t);return o}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class uz extends Pa{static get type(){return"SetNode"}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:n,targetNode:s}=this,o=this.getNodeType(e),a=e.getComponentType(s.getNodeType(e)),c=e.getTypeFromLength(n.length,a),u=s.build(e,c),d=t.build(e,o),p=e.getTypeLength(o),m=[];for(let y=0;y<p;y++){const M=am[y];M===n[0]?(m.push(u),y+=n.length-1):m.push(d+"."+M)}return`${e.getType(o)}( ${m.join(", ")} )`}}class hz extends Pa{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{components:t,sourceNode:n}=this,s=this.getNodeType(e),o=n.build(e),a=e.getVarFromNode(this),c=e.getPropertyName(a);e.addLineFlowCode(c+" = "+o,this);const u=e.getTypeLength(s),d=[];let p=0;for(let m=0;m<u;m++){const y=am[m];y===t[p]?(d.push("1.0 - "+(c+"."+y)),p++):d.push(c+"."+y)}return`${e.getType(s)}( ${d.join(", ")} )`}}class nM extends Wi{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?Od(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Od(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=Jw(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?S_(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn("Abstract function.")}}const sC=/float|u?int/;class Mu extends nM{static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){const n=this.getNodeType(e);return sC.test(n)&&sC.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}}class dz extends Wi{static get type(){return"MemberNode"}constructor(e,t){super(),this.structNode=e,this.property=t,this.isMemberNode=!0}hasMember(e){return this.structNode.isMemberNode&&this.structNode.hasMember(e)===!1?!1:this.structNode.getMemberType(e,this.property)!=="void"}getNodeType(e){return this.hasMember(e)===!1?"float":this.structNode.getMemberType(e,this.property)}getMemberType(e,t){if(this.hasMember(e)===!1)return"float";const n=this.getNodeType(e);return e.getStructTypeNode(n).getMemberType(e,t)}generate(e){if(this.hasMember(e)===!1){console.warn(`THREE.TSL: Member "${this.property}" does not exist in struct.`);const n=this.getNodeType(e);return e.generateConst(n)}return this.structNode.build(e)+"."+this.property}}let Gf=null;const iM=new Map;function An(i,e){if(iM.has(i)){console.warn(`THREE.TSL: Redefinition of method chaining '${i}'.`);return}if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${i} is not a function`);iM.set(i,e),i!=="assign"&&(Wi.prototype[i]=function(...t){return this.isStackNode?this.add(e(...t)):e(this,...t)},Wi.prototype[i+"Assign"]=function(...t){return this.isStackNode?this.assign(t[0],e(...t)):this.assign(e(this,...t))})}const fz=i=>i.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),oC=i=>fz(i).split("").sort().join("");Wi.prototype.assign=function(...i){if(this.isStackNode!==!0)return Gf!==null?Gf.assign(this,...i):console.error("THREE.TSL: No stack defined for assign operation. Make sure the assign is inside a Fn()."),this;{const e=iM.get("assign");return this.add(e(...i))}},Wi.prototype.toVarIntent=function(){return this},Wi.prototype.get=function(i){return new dz(this,i)};const iv={};function T_(i,e,t){iv[i]=iv[e]=iv[t]={get(){this._cache=this._cache||{};let a=this._cache[i];return a===void 0&&(a=new rC(this,i),this._cache[i]=a),a},set(a){this[i].assign(Cn(a))}};const n=i.toUpperCase(),s=e.toUpperCase(),o=t.toUpperCase();Wi.prototype["set"+n]=Wi.prototype["set"+s]=Wi.prototype["set"+o]=function(a){const c=oC(i);return new uz(this,c,Cn(a))},Wi.prototype["flip"+n]=Wi.prototype["flip"+s]=Wi.prototype["flip"+o]=function(){const a=oC(i);return new hz(this,a)}}const Lh=["x","y","z","w"],Dh=["r","g","b","a"],Oh=["s","t","p","q"];for(let i=0;i<4;i++){let e=Lh[i],t=Dh[i],n=Oh[i];T_(e,t,n);for(let s=0;s<4;s++){e=Lh[i]+Lh[s],t=Dh[i]+Dh[s],n=Oh[i]+Oh[s],T_(e,t,n);for(let o=0;o<4;o++){e=Lh[i]+Lh[s]+Lh[o],t=Dh[i]+Dh[s]+Dh[o],n=Oh[i]+Oh[s]+Oh[o],T_(e,t,n);for(let a=0;a<4;a++)e=Lh[i]+Lh[s]+Lh[o]+Lh[a],t=Dh[i]+Dh[s]+Dh[o]+Dh[a],n=Oh[i]+Oh[s]+Oh[o]+Oh[a],T_(e,t,n)}}}for(let i=0;i<32;i++)iv[i]={get(){this._cache=this._cache||{};let e=this._cache[i];return e===void 0&&(e=new lm(this,new Mu(i,"uint")),this._cache[i]=e),e},set(e){this[i].assign(Cn(e))}};Object.defineProperties(Wi.prototype,iv);const aC=new WeakMap,pz=function(i,e=null){const t=Od(i);return t==="node"?i:e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string"?Cn(aM(i,e)):t==="shader"?i.isFn?i:Kt(i):i},mz=function(i,e=null){for(const t in i)i[t]=Cn(i[t],e);return i},gz=function(i,e=null){const t=i.length;for(let n=0;n<t;n++)i[n]=Cn(i[n],e);return i},lC=function(i,e=null,t=null,n=null){function s(p){return n!==null?(p=Cn(Object.assign(p,n)),n.intent===!0&&(p=p.toVarIntent())):p=Cn(p),p}let o,a=e,c,u;function d(p){let m;return a?m=/[a-z]/i.test(a)?a+"()":a:m=i.type,c!==void 0&&p.length<c?(console.error(`THREE.TSL: "${m}" parameter length is less than minimum required.`),p.concat(new Array(c-p.length).fill(0))):u!==void 0&&p.length>u?(console.error(`THREE.TSL: "${m}" parameter length exceeds limit.`),p.slice(0,u)):p}return e===null?o=(...p)=>s(new i(...cm(d(p)))):t!==null?(t=Cn(t),o=(...p)=>s(new i(e,...cm(d(p)),t))):o=(...p)=>s(new i(e,...cm(d(p)))),o.setParameterLength=(...p)=>(p.length===1?c=u=p[0]:p.length===2&&([c,u]=p),o),o.setName=p=>(a=p,o),o},yz=function(i,...e){return Cn(new i(...cm(e)))};class vz extends Wi{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,rawInputs:n}=this,s=e.getNodeProperties(t),o=e.getClosestSubBuild(t.subBuilds)||"",a=o||"default";if(s[a])return s[a];const c=e.subBuildFn;e.subBuildFn=o;let u=null;if(t.layout){let d=aC.get(e.constructor);d===void 0&&(d=new WeakMap,aC.set(e.constructor,d));let p=d.get(t);p===void 0&&(p=Cn(e.buildFunctionNode(t)),d.set(t,p)),e.addInclude(p);const m=n?xz(n):null;u=Cn(p.call(m))}else{const d=new Proxy(e,{get:(T,G,z)=>{let I;return Symbol.iterator===G?I=function*(){yield void 0}:I=Reflect.get(T,G,z),I}}),p=n?_z(n):null,m=Array.isArray(n)?n.length>0:n!==null,y=t.jsFunc,M=m||y.length>1?y(p,d):y(d);u=Cn(M)}return e.subBuildFn=c,t.once&&(s[a]=u),u}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),n=e.getSubBuildOutput(this);return t[n]=t[n]||this.setupOutput(e),t[n].subBuild=e.getClosestSubBuild(this),t[n]}build(e,t=null){let n=null;const s=e.getBuildStage(),o=e.getNodeProperties(this),a=e.getSubBuildOutput(this),c=this.getOutputNode(e);if(s==="setup"){const u=e.getSubBuildProperty("initialized",this);if(o[u]!==!0&&(o[u]=!0,o[a]=this.getOutputNode(e),o[a].build(e),this.shaderNode.subBuilds))for(const d of e.chaining){const p=e.getDataFromNode(d,"any");p.subBuilds=p.subBuilds||new Set;for(const m of this.shaderNode.subBuilds)p.subBuilds.add(m)}n=o[a]}else s==="analyze"?c.build(e,t):s==="generate"&&(n=c.build(e,t)||"");return n}}function xz(i){let e;return C_(i),i[0]&&(i[0].isNode||Object.getPrototypeOf(i[0])!==Object.prototype)?e=[...i]:e=i[0],e}function _z(i){let e=0;return C_(i),new Proxy(i,{get:(t,n,s)=>{let o;if(n==="length")return o=i.length,o;if(Symbol.iterator===n)o=function*(){for(const a of i)yield Cn(a)};else{if(i.length>0)if(Object.getPrototypeOf(i[0])===Object.prototype){const a=i[0];a[n]===void 0?o=a[e++]:o=Reflect.get(a,n,s)}else i[0]instanceof Wi&&(i[n]===void 0?o=i[e++]:o=Reflect.get(i,n,s));else o=Reflect.get(t,n,s);o=Cn(o)}return o}})}class bz extends Wi{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return Cn(new vz(this,e))}setup(){return this.call()}}const wz=[!1,!0],Mz=[0,1,2,3],Sz=[-1,-2],cC=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],rM=new Map;for(const i of wz)rM.set(i,new Mu(i));const sM=new Map;for(const i of Mz)sM.set(i,new Mu(i,"uint"));const oM=new Map([...sM].map(i=>new Mu(i.value,"int")));for(const i of Sz)oM.set(i,new Mu(i,"int"));const E_=new Map([...oM].map(i=>new Mu(i.value)));for(const i of cC)E_.set(i,new Mu(i));for(const i of cC)E_.set(-i,new Mu(-i));const A_={bool:rM,uint:sM,ints:oM,float:E_},uC=new Map([...rM,...E_]),aM=(i,e)=>uC.has(i)?uC.get(i):i.isNode===!0?i:new Mu(i,e),il=function(i,e=null){return(...t)=>{for(const s of t)if(s===void 0)return console.error(`THREE.TSL: Invalid parameter for the type "${i}".`),Cn(new Mu(0,i));if((t.length===0||!["bool","float","int","uint"].includes(i)&&t.every(s=>{const o=typeof s;return o!=="object"&&o!=="function"}))&&(t=[S_(i,...t)]),t.length===1&&e!==null&&e.has(t[0]))return sv(e.get(t[0]));if(t.length===1){const s=aM(t[0],i);return s.nodeType===i?sv(s):sv(new iC(s,i))}const n=t.map(s=>aM(s));return sv(new lz(n,i))}},rv=i=>typeof i=="object"&&i!==null?i.value:i,hC=i=>i!=null?i.nodeType||i.convertTo||(typeof i=="string"?i:null):null;function Wg(i,e){return new bz(i,e)}const Cn=(i,e=null)=>pz(i,e),sv=(i,e=null)=>Cn(i,e).toVarIntent(),C_=(i,e=null)=>new mz(i,e),cm=(i,e=null)=>new gz(i,e),Vr=(i,e=null,t=null,n=null)=>new lC(i,e,t,n),xi=(i,...e)=>new yz(i,...e),ci=(i,e=null,t=null,n={})=>new lC(i,e,t,Ys({intent:!0},n));let Tz=0;class Ez extends Wi{constructor(e,t=null){super();let n=null;t!==null&&(typeof t=="object"?n=t.return:(typeof t=="string"?n=t:console.error("THREE.TSL: Invalid layout type."),t=null)),this.shaderNode=new Wg(e,n),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){const t=this.shaderNode.nodeType;if(typeof e.inputs!="object"){const n={name:"fn"+Tz++,type:t,inputs:[]};for(const s in e)s!=="return"&&n.inputs.push({name:s,type:e[s]});e=n}return this.shaderNode.setLayout(e),this}getNodeType(e){return this.shaderNode.getNodeType(e)||"float"}call(...e){const t=this.shaderNode.call(e);return this.shaderNode.nodeType==="void"&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){const t=this.getNodeType(e);return console.error('THREE.TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".'),e.generateConst(t)}}function Kt(i,e=null){const t=new Ez(i,e);return new Proxy(()=>{},{apply(n,s,o){return t.call(...o)},get(n,s,o){return Reflect.get(t,s,o)},set(n,s,o,a){return Reflect.set(t,s,o,a)}})}const ov=i=>{Gf=i},R_=()=>Gf,sr=(...i)=>Gf.If(...i),Az=(...i)=>Gf.Switch(...i);function N_(i){return Gf&&Gf.add(i),i}An("toStack",N_);const dC=new il("color"),at=new il("float",A_.float),Dt=new il("int",A_.ints),Li=new il("uint",A_.uint),Su=new il("bool",A_.bool),Bn=new il("vec2"),gl=new il("ivec2"),fC=new il("uvec2"),pC=new il("bvec2"),Xt=new il("vec3"),mC=new il("ivec3"),Hg=new il("uvec3"),lM=new il("bvec3"),Bi=new il("vec4"),gC=new il("ivec4"),yC=new il("uvec4"),vC=new il("bvec4"),P_=new il("mat2"),$l=new il("mat3"),um=new il("mat4"),Cz=(i="")=>Cn(new Mu(i,"string")),Rz=i=>Cn(new Mu(i,"ArrayBuffer"));An("toColor",dC),An("toFloat",at),An("toInt",Dt),An("toUint",Li),An("toBool",Su),An("toVec2",Bn),An("toIVec2",gl),An("toUVec2",fC),An("toBVec2",pC),An("toVec3",Xt),An("toIVec3",mC),An("toUVec3",Hg),An("toBVec3",lM),An("toVec4",Bi),An("toIVec4",gC),An("toUVec4",yC),An("toBVec4",vC),An("toMat2",P_),An("toMat3",$l),An("toMat4",um);const xC=Vr(lm).setParameterLength(2),_C=(i,e)=>Cn(new iC(Cn(i),e)),Nz=(i,e)=>Cn(new rC(Cn(i),e));An("element",xC),An("convert",_C);const Pz=i=>(console.warn("THREE.TSL: append() has been renamed to Stack()."),N_(i));An("append",i=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),N_(i)));class fo extends Wi{static get type(){return"PropertyNode"}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const oh=(i,e)=>Cn(new fo(i,e)),qc=(i,e)=>Cn(new fo(i,e,!0)),no=xi(fo,"vec4","DiffuseColor"),cM=xi(fo,"vec3","EmissiveColor"),Fh=xi(fo,"float","Roughness"),av=xi(fo,"float","Metalness"),I_=xi(fo,"float","Clearcoat"),lv=xi(fo,"float","ClearcoatRoughness"),hm=xi(fo,"vec3","Sheen"),L_=xi(fo,"float","SheenRoughness"),D_=xi(fo,"float","Iridescence"),uM=xi(fo,"float","IridescenceIOR"),hM=xi(fo,"float","IridescenceThickness"),O_=xi(fo,"float","AlphaT"),Wf=xi(fo,"float","Anisotropy"),cv=xi(fo,"vec3","AnisotropyT"),dm=xi(fo,"vec3","AnisotropyB"),Tc=xi(fo,"color","SpecularColor"),uv=xi(fo,"float","SpecularF90"),F_=xi(fo,"float","Shininess"),$g=xi(fo,"vec4","Output"),fm=xi(fo,"float","dashSize"),hv=xi(fo,"float","gapSize"),Iz=xi(fo,"float","pointWidth"),dv=xi(fo,"float","IOR"),B_=xi(fo,"float","Transmission"),dM=xi(fo,"float","Thickness"),fM=xi(fo,"float","AttenuationDistance"),pM=xi(fo,"color","AttenuationColor"),mM=xi(fo,"float","Dispersion");class bC extends Wi{static get type(){return"UniformGroupNode"}constructor(e,t=!1,n=1){super("string"),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const wC=i=>new bC(i),U_=(i,e=0)=>new bC(i,!0,e),MC=U_("frame"),or=U_("render"),gM=wC("object");class fv extends nM{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=gM}setName(e){return this.name=e,this}label(e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(n=>{const s=e(n,this);s!==void 0&&(this.value=s)},t)}getInputType(e){let t=super.getInputType(e);return t==="bool"&&(t="uint"),t}generate(e,t){const n=this.getNodeType(e),s=this.getUniformHash(e);let o=e.getNodeFromHash(s);o===void 0&&(e.setHashNode(this,s),o=this);const a=o.getInputType(e),c=e.getUniformFromNode(o,a,e.shaderStage,this.name||e.context.nodeName),u=e.getPropertyName(c);e.context.nodeName!==void 0&&delete e.context.nodeName;let d=u;if(n==="bool"){const p=e.getDataFromNode(this);let m=p.propertyName;if(m===void 0){const y=e.getVarFromNode(this,null,"bool");m=e.getPropertyName(y),p.propertyName=m,d=e.format(u,a,n),e.addLineFlowCode(`${m} = ${d}`,this)}d=m}return e.format(d,n,t)}}const cr=(i,e)=>{const t=hC(e||i);return t===i&&(i=S_(t)),i=i&&i.isNode===!0?i.node&&i.node.value||i.value:i,Cn(new fv(i,t))};class SC extends Pa{static get type(){return"ArrayNode"}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getArrayCount(){return this.count}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const TC=(...i)=>{let e;if(i.length===1){const t=i[0];e=new SC(null,t.length,t)}else{const t=i[0],n=i[1];e=new SC(t,n)}return Cn(e)};An("toArray",(i,e)=>TC(Array(e).fill(i)));class Lz extends Pa{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const n=e.getTypeLength(t.node.getNodeType(e));return am.join("").slice(0,n)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:n}=this,s=t.getScope(),o=e.getNodeProperties(s);o.assign=!0;const a=e.getNodeProperties(this);a.sourceNode=n,a.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:n,sourceNode:s}=e.getNodeProperties(this),o=this.needsSplitAssign(e),a=n.build(e),c=n.getNodeType(e),u=s.build(e,c),d=s.getNodeType(e),p=e.getDataFromNode(this);let m;if(p.initialized===!0)t!=="void"&&(m=a);else if(o){const y=e.getVarFromNode(this,null,c),M=e.getPropertyName(y);e.addLineFlowCode(`${M} = ${u}`,this);const T=n.node,z=T.node.context({assign:!0}).build(e);for(let I=0;I<T.components.length;I++){const J=T.components[I];e.addLineFlowCode(`${z}.${J} = ${M}[ ${I} ]`,this)}t!=="void"&&(m=a)}else m=`${a} = ${u}`,(t==="void"||d==="void")&&(e.addLineFlowCode(m,this),t!=="void"&&(m=a));return p.initialized=!0,e.format(m,c,t)}}const EC=Vr(Lz).setParameterLength(2);An("assign",EC);class Dz extends Pa{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}getMemberType(e,t){return this.functionNode.getMemberType(e,t)}generate(e){const t=[],n=this.functionNode,s=n.getInputs(e),o=this.parameters,a=(u,d)=>{const p=d.type,m=p==="pointer";let y;return m?y="&"+u.build(e):y=u.build(e,p),y};if(Array.isArray(o)){if(o.length>s.length)console.error("THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),o.length=s.length;else if(o.length<s.length)for(console.error("THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");o.length<s.length;)o.push(at(0));for(let u=0;u<o.length;u++)t.push(a(o[u],s[u]))}else for(const u of s){const d=o[u.name];d!==void 0?t.push(a(d,u)):(console.error(`THREE.TSL: Input '${u.name}' not found in 'Fn()'.`),t.push(a(at(0),u)))}return`${n.build(e,"property")}( ${t.join(", ")} )`}}const AC=(i,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?cm(e):C_(e[0]),Cn(new Dz(Cn(i),e)));An("call",AC);const Oz={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class oa extends Pa{static get type(){return"OperatorNode"}constructor(e,t,n,...s){if(super(),s.length>0){let o=new oa(e,t,n);for(let a=0;a<s.length-1;a++)o=new oa(e,o,s[a]);t=o,n=s[s.length-1]}this.op=e,this.aNode=t,this.bNode=n,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(Oz[this.op],t)}getNodeType(e,t=null){const n=this.op,s=this.aNode,o=this.bNode,a=s.getNodeType(e),c=o?o.getNodeType(e):null;if(a==="void"||c==="void")return t||"void";if(n==="%")return a;if(n==="~"||n==="&"||n==="|"||n==="^"||n===">>"||n==="<<")return e.getIntegerType(a);if(n==="!"||n==="&&"||n==="||"||n==="^^")return"bool";if(n==="=="||n==="!="||n==="<"||n===">"||n==="<="||n===">="){const u=Math.max(e.getTypeLength(a),e.getTypeLength(c));return u>1?`bvec${u}`:"bool"}else{if(e.isMatrix(a)){if(c==="float")return a;if(e.isVector(c))return e.getVectorFromMatrix(a);if(e.isMatrix(c))return a}else if(e.isMatrix(c)){if(a==="float")return c;if(e.isVector(a))return e.getVectorFromMatrix(c)}return e.getTypeLength(c)>e.getTypeLength(a)?c:a}}generate(e,t){const n=this.op,{aNode:s,bNode:o}=this,a=this.getNodeType(e,t);let c=null,u=null;a!=="void"?(c=s.getNodeType(e),u=o?o.getNodeType(e):null,n==="<"||n===">"||n==="<="||n===">="||n==="=="||n==="!="?e.isVector(c)?u=c:e.isVector(u)?c=u:c!==u&&(c=u="float"):n===">>"||n==="<<"?(c=a,u=e.changeComponentType(u,"uint")):n==="%"?(c=a,u=e.isInteger(c)&&e.isInteger(u)?u:c):e.isMatrix(c)?u==="float"?u="float":e.isVector(u)?u=e.getVectorFromMatrix(c):e.isMatrix(u)||(c=u=a):e.isMatrix(u)?c==="float"?c="float":e.isVector(c)?c=e.getVectorFromMatrix(u):c=u=a:c=u=a):c=u=a;const d=s.build(e,c),p=o?o.build(e,u):null,m=e.getFunctionOperator(n);if(t!=="void"){const y=e.renderer.coordinateSystem===oo;if(n==="=="||n==="!="||n==="<"||n===">"||n==="<="||n===">=")return y?e.isVector(c)?e.format(`${this.getOperatorMethod(e,t)}( ${d}, ${p} )`,a,t):e.format(`( ${d} ${n} ${p} )`,a,t):e.format(`( ${d} ${n} ${p} )`,a,t);if(n==="%")return e.isInteger(u)?e.format(`( ${d} % ${p} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${d}, ${p} )`,a,t);if(n==="!"||n==="~")return e.format(`(${n}${d})`,c,t);if(m)return e.format(`${m}( ${d}, ${p} )`,a,t);if(e.isMatrix(c)&&u==="float")return e.format(`( ${p} ${n} ${d} )`,a,t);if(c==="float"&&e.isMatrix(u))return e.format(`${d} ${n} ${p}`,a,t);{let M=`( ${d} ${n} ${p} )`;return!y&&a==="bool"&&e.isVector(c)&&e.isVector(u)&&(M=`all${M}`),e.format(M,a,t)}}else if(c!=="void")return m?e.format(`${m}( ${d}, ${p} )`,a,t):e.isMatrix(c)&&u==="float"?e.format(`${p} ${n} ${d}`,a,t):e.format(`${d} ${n} ${p}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const $a=ci(oa,"+").setParameterLength(2,1/0).setName("add"),Os=ci(oa,"-").setParameterLength(2,1/0).setName("sub"),Jr=ci(oa,"*").setParameterLength(2,1/0).setName("mul"),Yc=ci(oa,"/").setParameterLength(2,1/0).setName("div"),pv=ci(oa,"%").setParameterLength(2).setName("mod"),yM=ci(oa,"==").setParameterLength(2).setName("equal"),CC=ci(oa,"!=").setParameterLength(2).setName("notEqual"),RC=ci(oa,"<").setParameterLength(2).setName("lessThan"),vM=ci(oa,">").setParameterLength(2).setName("greaterThan"),NC=ci(oa,"<=").setParameterLength(2).setName("lessThanEqual"),PC=ci(oa,">=").setParameterLength(2).setName("greaterThanEqual"),IC=ci(oa,"&&").setParameterLength(2,1/0).setName("and"),LC=ci(oa,"||").setParameterLength(2,1/0).setName("or"),DC=ci(oa,"!").setParameterLength(1).setName("not"),OC=ci(oa,"^^").setParameterLength(2).setName("xor"),FC=ci(oa,"&").setParameterLength(2).setName("bitAnd"),BC=ci(oa,"~").setParameterLength(2).setName("bitNot"),UC=ci(oa,"|").setParameterLength(2).setName("bitOr"),kC=ci(oa,"^").setParameterLength(2).setName("bitXor"),zC=ci(oa,"<<").setParameterLength(2).setName("shiftLeft"),VC=ci(oa,">>").setParameterLength(2).setName("shiftRight"),GC=Kt(([i])=>(i.addAssign(1),i)),WC=Kt(([i])=>(i.subAssign(1),i)),HC=Kt(([i])=>{const e=Dt(i).toConst();return i.addAssign(1),e}),$C=Kt(([i])=>{const e=Dt(i).toConst();return i.subAssign(1),e});An("add",$a),An("sub",Os),An("mul",Jr),An("div",Yc),An("mod",pv),An("equal",yM),An("notEqual",CC),An("lessThan",RC),An("greaterThan",vM),An("lessThanEqual",NC),An("greaterThanEqual",PC),An("and",IC),An("or",LC),An("not",DC),An("xor",OC),An("bitAnd",FC),An("bitNot",BC),An("bitOr",UC),An("bitXor",kC),An("shiftLeft",zC),An("shiftRight",VC),An("incrementBefore",GC),An("decrementBefore",WC),An("increment",HC),An("decrement",$C);const jC=(i,e)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),pv(Dt(i),Dt(e)));An("modInt",jC);class an extends Pa{static get type(){return"MathNode"}constructor(e,t,n=null,s=null){if(super(),(e===an.MAX||e===an.MIN)&&arguments.length>3){let o=new an(e,t,n);for(let a=2;a<arguments.length-1;a++)o=new an(e,o,arguments[a]);t=o,n=arguments[arguments.length-1],s=null}this.method=e,this.aNode=t,this.bNode=n,this.cNode=s,this.isMathNode=!0}getInputType(e){const t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,s=this.cNode?this.cNode.getNodeType(e):null,o=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),c=e.isMatrix(s)?0:e.getTypeLength(s);return o>a&&o>c?t:a>c?n:c>o?s:t}getNodeType(e){const t=this.method;return t===an.LENGTH||t===an.DISTANCE||t===an.DOT?"float":t===an.CROSS?"vec3":t===an.ALL||t===an.ANY?"bool":t===an.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:n,method:s}=this;let o=null;if(s===an.ONE_MINUS)o=Os(1,t);else if(s===an.RECIPROCAL)o=Yc(1,t);else if(s===an.DIFFERENCE)o=Fo(Os(t,n));else if(s===an.TRANSFORM_DIRECTION){let a=t,c=n;e.isMatrix(a.getNodeType(e))?c=Bi(Xt(c),0):a=Bi(Xt(a),0);const u=Jr(a,c).xyz;o=Fd(u)}return o!==null?o:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let s=this.method;const o=this.getNodeType(e),a=this.getInputType(e),c=this.aNode,u=this.bNode,d=this.cNode,p=e.renderer.coordinateSystem;if(s===an.NEGATE)return e.format("( - "+c.build(e,a)+" )",o,t);{const m=[];return s===an.CROSS?m.push(c.build(e,o),u.build(e,o)):p===oo&&s===an.STEP?m.push(c.build(e,e.getTypeLength(c.getNodeType(e))===1?"float":a),u.build(e,a)):p===oo&&(s===an.MIN||s===an.MAX)?m.push(c.build(e,a),u.build(e,e.getTypeLength(u.getNodeType(e))===1?"float":a)):s===an.REFRACT?m.push(c.build(e,a),u.build(e,a),d.build(e,"float")):s===an.MIX?m.push(c.build(e,a),u.build(e,a),d.build(e,e.getTypeLength(d.getNodeType(e))===1?"float":a)):(p===qa&&s===an.ATAN&&u!==null&&(s="atan2"),e.shaderStage!=="fragment"&&(s===an.DFDX||s===an.DFDY)&&(console.warn(`THREE.TSL: '${s}' is not supported in the ${e.shaderStage} stage.`),s="/*"+s+"*/"),m.push(c.build(e,a)),u!==null&&m.push(u.build(e,a)),d!==null&&m.push(d.build(e,a))),e.format(`${e.getMethod(s,o)}( ${m.join(", ")} )`,o,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}an.ALL="all",an.ANY="any",an.RADIANS="radians",an.DEGREES="degrees",an.EXP="exp",an.EXP2="exp2",an.LOG="log",an.LOG2="log2",an.SQRT="sqrt",an.INVERSE_SQRT="inversesqrt",an.FLOOR="floor",an.CEIL="ceil",an.NORMALIZE="normalize",an.FRACT="fract",an.SIN="sin",an.COS="cos",an.TAN="tan",an.ASIN="asin",an.ACOS="acos",an.ATAN="atan",an.ABS="abs",an.SIGN="sign",an.LENGTH="length",an.NEGATE="negate",an.ONE_MINUS="oneMinus",an.DFDX="dFdx",an.DFDY="dFdy",an.ROUND="round",an.RECIPROCAL="reciprocal",an.TRUNC="trunc",an.FWIDTH="fwidth",an.TRANSPOSE="transpose",an.DETERMINANT="determinant",an.INVERSE="inverse",an.EQUALS="equals",an.MIN="min",an.MAX="max",an.STEP="step",an.REFLECT="reflect",an.DISTANCE="distance",an.DIFFERENCE="difference",an.DOT="dot",an.CROSS="cross",an.POW="pow",an.TRANSFORM_DIRECTION="transformDirection",an.MIX="mix",an.CLAMP="clamp",an.REFRACT="refract",an.SMOOTHSTEP="smoothstep",an.FACEFORWARD="faceforward";const XC=at(1e-6),Fz=at(1e6),k_=at(Math.PI),Bz=at(Math.PI*2),qC=ci(an,an.ALL).setParameterLength(1),YC=ci(an,an.ANY).setParameterLength(1),ZC=ci(an,an.RADIANS).setParameterLength(1),KC=ci(an,an.DEGREES).setParameterLength(1),xM=ci(an,an.EXP).setParameterLength(1),jg=ci(an,an.EXP2).setParameterLength(1),z_=ci(an,an.LOG).setParameterLength(1),Bh=ci(an,an.LOG2).setParameterLength(1),Uh=ci(an,an.SQRT).setParameterLength(1),_M=ci(an,an.INVERSE_SQRT).setParameterLength(1),kh=ci(an,an.FLOOR).setParameterLength(1),V_=ci(an,an.CEIL).setParameterLength(1),Fd=ci(an,an.NORMALIZE).setParameterLength(1),Bd=ci(an,an.FRACT).setParameterLength(1),Zc=ci(an,an.SIN).setParameterLength(1),Ud=ci(an,an.COS).setParameterLength(1),JC=ci(an,an.TAN).setParameterLength(1),QC=ci(an,an.ASIN).setParameterLength(1),bM=ci(an,an.ACOS).setParameterLength(1),G_=ci(an,an.ATAN).setParameterLength(1,2),Fo=ci(an,an.ABS).setParameterLength(1),mv=ci(an,an.SIGN).setParameterLength(1),zh=ci(an,an.LENGTH).setParameterLength(1),eR=ci(an,an.NEGATE).setParameterLength(1),tR=ci(an,an.ONE_MINUS).setParameterLength(1),wM=ci(an,an.DFDX).setParameterLength(1),MM=ci(an,an.DFDY).setParameterLength(1),nR=ci(an,an.ROUND).setParameterLength(1),iR=ci(an,an.RECIPROCAL).setParameterLength(1),SM=ci(an,an.TRUNC).setParameterLength(1),rR=ci(an,an.FWIDTH).setParameterLength(1),sR=ci(an,an.TRANSPOSE).setParameterLength(1),oR=ci(an,an.DETERMINANT).setParameterLength(1),aR=ci(an,an.INVERSE).setParameterLength(1),lR=(i,e)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),yM(i,e)),Ec=ci(an,an.MIN).setParameterLength(2,1/0),va=ci(an,an.MAX).setParameterLength(2,1/0),W_=ci(an,an.STEP).setParameterLength(2),cR=ci(an,an.REFLECT).setParameterLength(2),uR=ci(an,an.DISTANCE).setParameterLength(2),hR=ci(an,an.DIFFERENCE).setParameterLength(2),Hf=ci(an,an.DOT).setParameterLength(2),H_=ci(an,an.CROSS).setParameterLength(2),Tu=ci(an,an.POW).setParameterLength(2),TM=i=>Jr(i,i),dR=i=>Jr(i,i,i),fR=i=>Jr(i,i,i,i),pR=ci(an,an.TRANSFORM_DIRECTION).setParameterLength(2),mR=i=>Jr(mv(i),Tu(Fo(i),1/3)),EM=i=>Hf(i,i),$s=ci(an,an.MIX).setParameterLength(3),Eu=(i,e=0,t=1)=>Cn(new an(an.CLAMP,Cn(i),Cn(e),Cn(t))),AM=i=>Eu(i),CM=ci(an,an.REFRACT).setParameterLength(3),Au=ci(an,an.SMOOTHSTEP).setParameterLength(3),RM=ci(an,an.FACEFORWARD).setParameterLength(3),gR=Kt(([i])=>{const n=43758.5453,s=Hf(i.xy,Bn(12.9898,78.233)),o=pv(s,k_);return Bd(Zc(o).mul(n))}),yR=(i,e,t)=>$s(e,t,i),vR=(i,e,t)=>Au(e,t,i),xR=(i,e)=>W_(e,i),_R=(i,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),G_(i,e)),Uz=RM,kz=_M;An("all",qC),An("any",YC),An("equals",lR),An("radians",ZC),An("degrees",KC),An("exp",xM),An("exp2",jg),An("log",z_),An("log2",Bh),An("sqrt",Uh),An("inverseSqrt",_M),An("floor",kh),An("ceil",V_),An("normalize",Fd),An("fract",Bd),An("sin",Zc),An("cos",Ud),An("tan",JC),An("asin",QC),An("acos",bM),An("atan",G_),An("abs",Fo),An("sign",mv),An("length",zh),An("lengthSq",EM),An("negate",eR),An("oneMinus",tR),An("dFdx",wM),An("dFdy",MM),An("round",nR),An("reciprocal",iR),An("trunc",SM),An("fwidth",rR),An("atan2",_R),An("min",Ec),An("max",va),An("step",xR),An("reflect",cR),An("distance",uR),An("dot",Hf),An("cross",H_),An("pow",Tu),An("pow2",TM),An("pow3",dR),An("pow4",fR),An("transformDirection",pR),An("mix",yR),An("clamp",Eu),An("refract",CM),An("smoothstep",vR),An("faceForward",RM),An("difference",hR),An("saturate",AM),An("cbrt",mR),An("transpose",sR),An("determinant",oR),An("inverse",aR),An("rand",gR);class zz extends Wi{static get type(){return"ConditionalNode"}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){const{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,"setup"),this.getNodeType(e);const s=t.getNodeType(e);if(n!==null){const o=n.getNodeType(e);if(e.getTypeLength(o)>e.getTypeLength(s))return o}return s}setup(e){const t=this.condNode.cache(),n=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,o=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=o,s!==null&&(e.getDataFromNode(s).parentNodeBlock=o);const a=e.context.uniformFlow,c=e.getNodeProperties(this);c.condNode=t,c.ifNode=a?n:n.context({nodeBlock:n}),c.elseNode=s?a?s:s.context({nodeBlock:s}):null}generate(e,t){const n=this.getNodeType(e),s=e.getDataFromNode(this);if(s.nodeProperty!==void 0)return s.nodeProperty;const{condNode:o,ifNode:a,elseNode:c}=e.getNodeProperties(this),u=e.currentFunctionNode,d=t!=="void",p=d?oh(n).build(e):"";s.nodeProperty=p;const m=o.build(e,"bool");if(e.context.uniformFlow&&c!==null){const T=a.build(e,n),G=c.build(e,n),z=e.getTernary(m,T,G);return e.format(z,n,t)}e.addFlowCode(`
|
|
|
${e.tab}if ( ${m} ) {
|
|
|
|
|
|
`).addFlowTab();let M=a.build(e,n);if(M&&(d?M=p+" = "+M+";":(M="return "+M+";",u===null&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),M="// "+M))),e.removeFlowTab().addFlowCode(e.tab+" "+M+`
|
|
|
|
|
|
`+e.tab+"}"),c!==null){e.addFlowCode(` else {
|
|
|
|
|
|
`).addFlowTab();let T=c.build(e,n);T&&(d?T=p+" = "+T+";":(T="return "+T+";",u===null&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),T="// "+T))),e.removeFlowTab().addFlowCode(e.tab+" "+T+`
|
|
|
|
|
|
`+e.tab+`}
|
|
|
|
|
|
`)}else e.addFlowCode(`
|
|
|
|
|
|
`);return e.format(p,n,t)}}const Sl=Vr(zz).setParameterLength(2,3);An("select",Sl);class bR extends Wi{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){const t=e.getContext();e.setContext(Ys(Ys({},e.context),this.value)),this.node.build(e),e.setContext(t)}setup(e){const t=e.getContext();e.setContext(Ys(Ys({},e.context),this.value)),this.node.build(e),e.setContext(t)}generate(e,t){const n=e.getContext();e.setContext(Ys(Ys({},e.context),this.value));const s=this.node.build(e,t);return e.setContext(n),s}}const gv=Vr(bR).setParameterLength(1,2),wR=i=>gv(i,{uniformFlow:!0}),NM=(i,e)=>gv(i,{nodeName:e});function MR(i,e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),NM(i,e)}An("context",gv),An("label",MR),An("uniformFlow",wR),An("setName",NM);class $_ extends Wi{static get type(){return"VarNode"}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}build(...e){return this.intent===!0&&e[0].getNodeProperties(this).assign!==!0?this.node.build(...e):super.build(...e)}generate(e){const{node:t,name:n,readOnly:s}=this,{renderer:o}=e,a=o.backend.isWebGPUBackend===!0;let c=!1,u=!1;s&&(c=e.isDeterministic(t),u=a?s:c);const d=e.getVectorType(this.getNodeType(e)),p=t.build(e,d),m=e.getVarFromNode(this,n,d,void 0,u),y=e.getPropertyName(m);let M=y;if(u)if(a)M=c?`const ${y}`:`let ${y}`;else{const T=t.getArrayCount(e);M=`const ${e.getVar(m.type,y,T)}`}return e.addLineFlowCode(`${M} = ${p}`,this),y}}const PM=Vr($_),SR=(i,e=null)=>PM(i,e).toStack(),TR=(i,e=null)=>PM(i,e,!0).toStack(),ER=i=>R_()===null?i:PM(i).setIntent(!0).toStack();An("toVar",SR),An("toConst",TR),An("toVarIntent",ER);class Vz extends Wi{static get type(){return"SubBuild"}constructor(e,t,n=null){super(n),this.node=e,this.name=t,this.isSubBuildNode=!0}getNodeType(e){if(this.nodeType!==null)return this.nodeType;e.addSubBuild(this.name);const t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);const n=this.node.build(e,...t);return e.removeSubBuild(),n}}const Xg=(i,e,t=null)=>Cn(new Vz(Cn(i),e,t));class Gz extends Wi{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let n=t.varying;if(n===void 0){const s=this.name,o=this.getNodeType(e),a=this.interpolationType,c=this.interpolationSampling;t.varying=n=e.getVaryingFromNode(this,s,o,a,c),t.node=Xg(this.node,"VERTEX")}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage==="fragment"),n}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(nv.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(nv.VERTEX,this.node)}generate(e){const t=e.getSubBuildProperty("property",e.currentStack),n=e.getNodeProperties(this),s=this.setupVarying(e);if(n[t]===void 0){const o=this.getNodeType(e),a=e.getPropertyName(s,nv.VERTEX);e.flowNodeFromShaderStage(nv.VERTEX,n.node,o,a),n[t]=a}return e.getPropertyName(s)}}const Vh=Vr(Gz).setParameterLength(1,2),AR=i=>Vh(i);An("toVarying",Vh),An("toVertexStage",AR),An("varying",(...i)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),Vh(...i))),An("vertexStage",(...i)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),Vh(...i)));const CR=Kt(([i])=>{const e=i.mul(.9478672986).add(.0521327014).pow(2.4),t=i.mul(.0773993808),n=i.lessThanEqual(.04045);return $s(e,t,n)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),RR=Kt(([i])=>{const e=i.pow(.41666).mul(1.055).sub(.055),t=i.mul(12.92),n=i.lessThanEqual(.0031308);return $s(e,t,n)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),IM="WorkingColorSpace",Wz="OutputColorSpace";class LM extends Pa{static get type(){return"ColorSpaceNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===IM?Ki.workingColorSpace:t===Wz?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),s=this.resolveColorSpace(e,this.target);let o=t;return Ki.enabled===!1||n===s||!n||!s||(Ki.getTransfer(n)===Fi&&(o=Bi(CR(o.rgb),o.a)),Ki.getPrimaries(n)!==Ki.getPrimaries(s)&&(o=Bi($l(Ki._getMatrix(new jr,n,s)).mul(o.rgb),o.a)),Ki.getTransfer(s)===Fi&&(o=Bi(RR(o.rgb),o.a))),o}}const NR=(i,e)=>Cn(new LM(Cn(i),IM,e)),j_=(i,e)=>Cn(new LM(Cn(i),e,IM)),Hz=(i,e,t)=>Cn(new LM(Cn(i),e,t));An("workingToColorSpace",NR),An("colorSpaceToWorking",j_);let $z=class extends lm{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,n,s)}};class PR extends Wi{static get type(){return"ReferenceBaseNode"}constructor(e,t,n=null,s=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=s,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.updateType=ss.OBJECT}setGroup(e){return this.group=e,this}element(e){return Cn(new $z(this,Cn(e)))}setNodeType(e){const t=cr(null,e);this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let s=1;s<t.length;s++)n=n[t[s]];return n}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const jz=(i,e,t)=>Cn(new PR(i,e,t));class Xz extends PR{static get type(){return"RendererReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(or)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const IR=(i,e,t=null)=>Cn(new Xz(i,e,t));class qz extends Pa{static get type(){return"ToneMappingNode"}constructor(e,t=DR,n=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return Qy(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,n=this.toneMapping;if(n===yt)return t;let s=null;const o=e.renderer.library.getToneMappingFunction(n);return o!==null?s=Bi(o(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",n),s=t),s}}const LR=(i,e,t)=>Cn(new qz(i,Cn(e),Cn(t))),DR=IR("toneMappingExposure","float");An("toneMapping",(i,e,t)=>LR(e,t,i));class Yz extends nM{static get type(){return"BufferAttributeNode"}constructor(e,t=null,n=0,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=s,this.usage=Uu,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),n=this.value,s=e.getTypeLength(t),o=this.bufferStride||s,a=this.bufferOffset,c=n.isInterleavedBuffer===!0?n:new ju(n,o),u=new hf(c,s,a);c.setUsage(this.usage),this.attribute=u,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),s=e.getPropertyName(n);let o=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=s,o=s):o=Vh(this).build(e,t),o}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const yv=(i,e=null,t=0,n=0)=>Cn(new Yz(i,e,t,n)),OR=(i,e=null,t=0,n=0)=>yv(i,e,t,n).setUsage(nf),X_=(i,e=null,t=0,n=0)=>yv(i,e,t,n).setInstanced(!0),DM=(i,e=null,t=0,n=0)=>OR(i,e,t,n).setInstanced(!0);An("toAttribute",i=>yv(i.value));class Zz extends Wi{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.version=1,this.name="",this.updateBeforeType=ss.OBJECT,this.onInitFunction=null}setCount(e){return this.count=e,this}getCount(){return this.count}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){const t=this.computeNode.build(e);if(t){const n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){const{shaderStage:n}=e;if(n==="compute"){const s=this.computeNode.build(e,"void");s!==""&&e.addLineFlowCode(s,this)}else{const o=e.getNodeProperties(this).outputComputeNode;if(o)return o.build(e,t)}}}const OM=(i,e=[64])=>{(e.length===0||e.length>3)&&console.error("THREE.TSL: compute() workgroupSize must have 1, 2, or 3 elements");for(let t=0;t<e.length;t++){const n=e[t];(typeof n!="number"||n<=0||!Number.isInteger(n))&&console.error(`THREE.TSL: compute() workgroupSize element at index [ ${t} ] must be a positive integer`)}for(;e.length<3;)e.push(1);return Cn(new Zz(Cn(i),e))},FR=(i,e,t)=>OM(i,t).setCount(e);An("compute",FR),An("computeKernel",OM);class Kz extends Wi{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){const t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);const s=this.node.getNodeType(e);return e.setCache(t),s}build(e,...t){const n=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const o=this.node.build(e,...t);return e.setCache(n),o}}const vv=(i,e)=>Cn(new Kz(Cn(i),e));An("cache",vv);class Jz extends Wi{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const BR=Vr(Jz).setParameterLength(2);An("bypass",BR);class UR extends Wi{static get type(){return"RemapNode"}constructor(e,t,n,s=at(0),o=at(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=s,this.outHighNode=o,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:n,outLowNode:s,outHighNode:o,doClamp:a}=this;let c=e.sub(t).div(n.sub(t));return a===!0&&(c=c.clamp()),c.mul(o.sub(s)).add(s)}}const kR=Vr(UR,null,null,{doClamp:!1}).setParameterLength(3,5),zR=Vr(UR).setParameterLength(3,5);An("remap",kR),An("remapClamp",zR);class q_ extends Wi{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const n=this.getNodeType(e),s=this.snippet;if(n==="void")e.addLineFlowCode(s,this);else return e.format(s,n,t)}}const kd=Vr(q_).setParameterLength(1,2),VR=i=>(i?Sl(i,kd("discard")):kd("discard")).toStack(),Qz=()=>kd("return").toStack();An("discard",VR);class e4 extends Pa{static get type(){return"RenderOutputNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const n=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||yt,s=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||ea;return n!==yt&&(t=t.toneMapping(n)),s!==ea&&s!==Ki.workingColorSpace&&(t=t.workingToColorSpace(s)),t}}const FM=(i,e=null,t=null)=>Cn(new e4(Cn(i),e,t));An("renderOutput",FM);class t4 extends Pa{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,n=this.node.build(e),s="--- TSL debug - "+e.shaderStage+" shader ---",o="-".repeat(s.length);let a="";return a+="// #"+s+`#
|
|
|
`,a+=e.flow.code.replace(/^\t/mg,"")+`
|
|
|
`,a+="/* ... */ "+n+` /* ... */
|
|
|
`,a+="// #"+o+`#
|
|
|
`,t!==null?t(e,a):console.log(a),n}}const GR=(i,e=null)=>Cn(new t4(Cn(i),e)).toStack();An("debug",GR);function n4(i){console.warn("THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",i)}class WR extends Wi{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){const n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){const s=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(s)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const o=e.geometry.getAttribute(t),a=e.getTypeFromAttribute(o),c=e.getAttribute(t,a);return e.shaderStage==="vertex"?e.format(c.name,a,n):Vh(this).build(e,n)}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const oc=(i,e=null)=>Cn(new WR(i,e)),xo=(i=0)=>oc("uv"+(i>0?i:""),"vec2");class i4 extends Wi{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const n=this.textureNode.build(e,"property"),s=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${n}, ${s} )`,this.getNodeType(e),t)}}const $f=Vr(i4).setParameterLength(1,2);class r4 extends fv{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=ss.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){const{width:s,height:o}=n;this.value=Math.log2(Math.max(s,o))}}}const BM=Vr(r4).setParameterLength(1),UM=new Ho;class Gh extends fv{static get type(){return"TextureNode"}constructor(e=UM,t=null,n=null,s=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=ss.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===ls?"uvec4":this.value.type===Ls?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return xo(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=cr(this.value.matrix)),this._matrixUniform.mul(Xt(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?ss.OBJECT:ss.NONE,this}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.image instanceof ImageBitmap&&n.flipY===!0||n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0||n.isDepthTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(Dt($f(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const n=this.value;if(!n||n.isTexture!==!0)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let s=this.uvNode;(s===null||e.context.forceUVContext===!0)&&e.context.getUV&&(s=e.context.getUV(this,e)),s||(s=this.getDefaultUV()),this.updateMatrix===!0&&(s=this.getTransformedUV(s)),s=this.setupUV(e,s);let o=this.levelNode;o===null&&e.context.getTextureLevel&&(o=e.context.getTextureLevel(this)),t.uvNode=s,t.levelNode=o,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateOffset(e,t){return t.build(e,"ivec2")}generateSnippet(e,t,n,s,o,a,c,u,d){const p=this.value;let m;return s?m=e.generateTextureLevel(p,t,n,s,a,d):o?m=e.generateTextureBias(p,t,n,o,a,d):u?m=e.generateTextureGrad(p,t,n,u,a,d):c?m=e.generateTextureCompare(p,t,n,c,a,d):this.sampler===!1?m=e.generateTextureLoad(p,t,n,a,d):m=e.generateTexture(p,t,n,a,d),m}generate(e,t){const n=this.value,s=e.getNodeProperties(this),o=super.generate(e,"property");if(/^sampler/.test(t))return o+"_sampler";if(e.isReference(t))return o;{const a=e.getDataFromNode(this);let c=a.propertyName;if(c===void 0){const{uvNode:p,levelNode:m,biasNode:y,compareNode:M,depthNode:T,gradNode:G,offsetNode:z}=s,I=this.generateUV(e,p),J=m?m.build(e,"float"):null,K=y?y.build(e,"float"):null,re=T?T.build(e,"int"):null,ve=M?M.build(e,"float"):null,me=G?[G[0].build(e,"vec2"),G[1].build(e,"vec2")]:null,Le=z?this.generateOffset(e,z):null,Ve=e.getVarFromNode(this);c=e.getPropertyName(Ve);const Ee=this.generateSnippet(e,o,I,J,K,re,ve,me,Le);e.addLineFlowCode(`${c} = ${Ee}`,this),a.snippet=Ee,a.propertyName=c}let u=c;const d=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(u=j_(kd(u,d),n.colorSpace).setup(e).build(e,d)),e.format(u,d,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=Cn(e),t.referenceNode=this.getBase(),Cn(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){const t=this.clone();t.biasNode=Cn(e).mul(BM(t)),t.referenceNode=this.getBase();const n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===Ct||n.magFilter===Ct)&&(console.warn("THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),Cn(t)}level(e){const t=this.clone();return t.levelNode=Cn(e),t.referenceNode=this.getBase(),Cn(t)}size(e){return $f(this,e)}bias(e){const t=this.clone();return t.biasNode=Cn(e),t.referenceNode=this.getBase(),Cn(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){const t=this.clone();return t.compareNode=Cn(e),t.referenceNode=this.getBase(),Cn(t)}grad(e,t){const n=this.clone();return n.gradNode=[Cn(e),Cn(t)],n.referenceNode=this.getBase(),Cn(n)}depth(e){const t=this.clone();return t.depthNode=Cn(e),t.referenceNode=this.getBase(),Cn(t)}offset(e){const t=this.clone();return t.offsetNode=Cn(e),t.referenceNode=this.getBase(),Cn(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e}}const s4=Vr(Gh).setParameterLength(1,4).setName("texture"),Is=(i=UM,e=null,t=null,n=null)=>{let s;return i&&i.isTextureNode===!0?(s=Cn(i.clone()),s.referenceNode=i.getBase(),e!==null&&(s.uvNode=Cn(e)),t!==null&&(s.levelNode=Cn(t)),n!==null&&(s.biasNode=Cn(n))):s=s4(i,e,t,n),s},o4=(i=UM)=>Is(i),Ia=(...i)=>Is(...i).setSampler(!1),a4=i=>(i.isNode===!0?i:Is(i)).convert("sampler"),l4=i=>(i.isNode===!0?i:Is(i)).convert("samplerComparison");class kM extends fv{static get type(){return"BufferNode"}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const xv=(i,e,t)=>Cn(new kM(i,e,t));class c4 extends lm{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),n=this.getNodeType(),s=this.node.getPaddedType();return e.format(t,s,n)}}class u4 extends kM{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?Od(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=ss.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return e==="mat2"?t="mat2":/mat/.test(e)===!0?t="mat4":e.charAt(0)==="i"?t="ivec4":e.charAt(0)==="u"&&(t="uvec4"),t}update(){const{array:e,value:t}=this,n=this.elementType;if(n==="float"||n==="int"||n==="uint")for(let s=0;s<e.length;s++){const o=s*4;t[o]=e[s]}else if(n==="color")for(let s=0;s<e.length;s++){const o=s*4,a=e[s];t[o]=a.r,t[o+1]=a.g,t[o+2]=a.b||0}else if(n==="mat2")for(let s=0;s<e.length;s++){const o=s*4,a=e[s];t[o]=a.elements[0],t[o+1]=a.elements[1],t[o+2]=a.elements[2],t[o+3]=a.elements[3]}else if(n==="mat3")for(let s=0;s<e.length;s++){const o=s*16,a=e[s];t[o]=a.elements[0],t[o+1]=a.elements[1],t[o+2]=a.elements[2],t[o+4]=a.elements[3],t[o+5]=a.elements[4],t[o+6]=a.elements[5],t[o+8]=a.elements[6],t[o+9]=a.elements[7],t[o+10]=a.elements[8],t[o+15]=1}else if(n==="mat4")for(let s=0;s<e.length;s++){const o=s*16,a=e[s];for(let c=0;c<a.elements.length;c++)t[o+c]=a.elements[c]}else for(let s=0;s<e.length;s++){const o=s*4,a=e[s];t[o]=a.x,t[o+1]=a.y,t[o+2]=a.z||0,t[o+3]=a.w||0}}setup(e){const t=this.array.length,n=this.elementType;let s=Float32Array;const o=this.paddedType,a=e.getTypeLength(o);return n.charAt(0)==="i"&&(s=Int32Array),n.charAt(0)==="u"&&(s=Uint32Array),this.value=new s(t*a),this.bufferCount=t,this.bufferType=o,super.setup(e)}element(e){return Cn(new c4(this,Cn(e)))}}const jl=(i,e)=>Cn(new u4(i,e));class h4 extends Wi{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const zd=Vr(h4).setParameterLength(1);let _v,bv;class Bo extends Wi{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}getNodeType(){return this.scope===Bo.DPR?"float":this.scope===Bo.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=ss.NONE;return(this.scope===Bo.SIZE||this.scope===Bo.VIEWPORT||this.scope===Bo.DPR)&&(e=ss.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===Bo.VIEWPORT?t!==null?bv.copy(t.viewport):(e.getViewport(bv),bv.multiplyScalar(e.getPixelRatio())):this.scope===Bo.DPR?this._output.value=e.getPixelRatio():t!==null?(_v.width=t.width,_v.height=t.height):e.getDrawingBufferSize(_v)}setup(){const e=this.scope;let t=null;return e===Bo.SIZE?t=cr(_v||(_v=new yn)):e===Bo.VIEWPORT?t=cr(bv||(bv=new mr)):e===Bo.DPR?t=cr(1):t=Bn(wv.div(pm)),this._output=t,t}generate(e){if(this.scope===Bo.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const n=e.getNodeProperties(pm).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${n}.y - ${t}.y )`}return t}return super.generate(e)}}Bo.COORDINATE="coordinate",Bo.VIEWPORT="viewport",Bo.SIZE="size",Bo.UV="uv",Bo.DPR="dpr";const HR=xi(Bo,Bo.DPR),Vd=xi(Bo,Bo.UV),pm=xi(Bo,Bo.SIZE),wv=xi(Bo,Bo.COORDINATE),qg=xi(Bo,Bo.VIEWPORT),zM=qg.zw,$R=wv.sub(qg.xy),d4=$R.div(zM),f4=Kt(()=>(console.warn('THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),pm),"vec2").once()(),jf=cr(0,"uint").setName("u_cameraIndex").setGroup(U_("cameraIndex")).toVarying("v_cameraIndex"),Gd=cr("float").setName("cameraNear").setGroup(or).onRenderUpdate(({camera:i})=>i.near),Wd=cr("float").setName("cameraFar").setGroup(or).onRenderUpdate(({camera:i})=>i.far),Cu=Kt(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const s of i.cameras)t.push(s.projectionMatrix);e=jl(t).setGroup(or).setName("cameraProjectionMatrices").element(i.isMultiViewCamera?zd("gl_ViewID_OVR"):jf).toConst("cameraProjectionMatrix")}else e=cr("mat4").setName("cameraProjectionMatrix").setGroup(or).onRenderUpdate(({camera:t})=>t.projectionMatrix);return e}).once()(),p4=Kt(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const s of i.cameras)t.push(s.projectionMatrixInverse);e=jl(t).setGroup(or).setName("cameraProjectionMatricesInverse").element(i.isMultiViewCamera?zd("gl_ViewID_OVR"):jf).toConst("cameraProjectionMatrixInverse")}else e=cr("mat4").setName("cameraProjectionMatrixInverse").setGroup(or).onRenderUpdate(({camera:t})=>t.projectionMatrixInverse);return e}).once()(),Kc=Kt(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const s of i.cameras)t.push(s.matrixWorldInverse);e=jl(t).setGroup(or).setName("cameraViewMatrices").element(i.isMultiViewCamera?zd("gl_ViewID_OVR"):jf).toConst("cameraViewMatrix")}else e=cr("mat4").setName("cameraViewMatrix").setGroup(or).onRenderUpdate(({camera:t})=>t.matrixWorldInverse);return e}).once()(),m4=Kt(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const s of i.cameras)t.push(s.matrixWorld);e=jl(t).setGroup(or).setName("cameraWorldMatrices").element(i.isMultiViewCamera?zd("gl_ViewID_OVR"):jf).toConst("cameraWorldMatrix")}else e=cr("mat4").setName("cameraWorldMatrix").setGroup(or).onRenderUpdate(({camera:t})=>t.matrixWorld);return e}).once()(),g4=Kt(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const s of i.cameras)t.push(s.normalMatrix);e=jl(t).setGroup(or).setName("cameraNormalMatrices").element(i.isMultiViewCamera?zd("gl_ViewID_OVR"):jf).toConst("cameraNormalMatrix")}else e=cr("mat3").setName("cameraNormalMatrix").setGroup(or).onRenderUpdate(({camera:t})=>t.normalMatrix);return e}).once()(),Mv=Kt(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(let s=0,o=i.cameras.length;s<o;s++)t.push(new it);e=jl(t).setGroup(or).setName("cameraPositions").onRenderUpdate(({camera:s},o)=>{const a=s.cameras,c=o.array;for(let u=0,d=a.length;u<d;u++)c[u].setFromMatrixPosition(a[u].matrixWorld)}).element(i.isMultiViewCamera?zd("gl_ViewID_OVR"):jf).toConst("cameraPosition")}else e=cr(new it).setName("cameraPosition").setGroup(or).onRenderUpdate(({camera:t},n)=>n.value.setFromMatrixPosition(t.matrixWorld));return e}).once()(),y4=Kt(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const s of i.cameras)t.push(s.viewport);e=jl(t,"vec4").setGroup(or).setName("cameraViewports").element(jf).toConst("cameraViewport")}else e=Bi(0,0,pm.x,pm.y).toConst("cameraViewport");return e}).once()(),jR=new xe;class Bs extends Wi{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=ss.OBJECT,this.uniformNode=new fv(null)}getNodeType(){const e=this.scope;if(e===Bs.WORLD_MATRIX)return"mat4";if(e===Bs.POSITION||e===Bs.VIEW_POSITION||e===Bs.DIRECTION||e===Bs.SCALE)return"vec3";if(e===Bs.RADIUS)return"float"}update(e){const t=this.object3d,n=this.uniformNode,s=this.scope;if(s===Bs.WORLD_MATRIX)n.value=t.matrixWorld;else if(s===Bs.POSITION)n.value=n.value||new it,n.value.setFromMatrixPosition(t.matrixWorld);else if(s===Bs.SCALE)n.value=n.value||new it,n.value.setFromMatrixScale(t.matrixWorld);else if(s===Bs.DIRECTION)n.value=n.value||new it,t.getWorldDirection(n.value);else if(s===Bs.VIEW_POSITION){const o=e.camera;n.value=n.value||new it,n.value.setFromMatrixPosition(t.matrixWorld),n.value.applyMatrix4(o.matrixWorldInverse)}else if(s===Bs.RADIUS){const o=e.object.geometry;o.boundingSphere===null&&o.computeBoundingSphere(),jR.copy(o.boundingSphere).applyMatrix4(t.matrixWorld),n.value=jR.radius}}generate(e){const t=this.scope;return t===Bs.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===Bs.POSITION||t===Bs.VIEW_POSITION||t===Bs.DIRECTION||t===Bs.SCALE?this.uniformNode.nodeType="vec3":t===Bs.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}Bs.WORLD_MATRIX="worldMatrix",Bs.POSITION="position",Bs.SCALE="scale",Bs.VIEW_POSITION="viewPosition",Bs.DIRECTION="direction",Bs.RADIUS="radius";const v4=Vr(Bs,Bs.DIRECTION).setParameterLength(1),x4=Vr(Bs,Bs.WORLD_MATRIX).setParameterLength(1),XR=Vr(Bs,Bs.POSITION).setParameterLength(1),_4=Vr(Bs,Bs.SCALE).setParameterLength(1),b4=Vr(Bs,Bs.VIEW_POSITION).setParameterLength(1),w4=Vr(Bs,Bs.RADIUS).setParameterLength(1);class Ru extends Bs{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const M4=xi(Ru,Ru.DIRECTION),Nu=xi(Ru,Ru.WORLD_MATRIX),S4=xi(Ru,Ru.POSITION),T4=xi(Ru,Ru.SCALE),E4=xi(Ru,Ru.VIEW_POSITION),qR=xi(Ru,Ru.RADIUS),YR=cr(new jr).onObjectUpdate(({object:i},e)=>e.value.getNormalMatrix(i.matrixWorld)),A4=cr(new Ft).onObjectUpdate(({object:i},e)=>e.value.copy(i.matrixWorld).invert()),Hd=Kt(i=>i.renderer.overrideNodes.modelViewMatrix||ZR).once()().toVar("modelViewMatrix"),ZR=Kc.mul(Nu),VM=Kt(i=>(i.context.isHighPrecisionModelViewMatrix=!0,cr("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),GM=Kt(i=>{const e=i.context.isHighPrecisionModelViewMatrix;return cr("mat3").onObjectUpdate(({object:t,camera:n})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),Ll=oc("position","vec3"),La=Ll.toVarying("positionLocal"),Y_=Ll.toVarying("positionPrevious"),Jc=Kt(i=>Nu.mul(La).xyz.toVarying(i.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),WM=Kt(()=>La.transformDirection(Nu).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),Da=Kt(i=>i.context.setupPositionView().toVarying("v_positionView"),"vec3").once(["POSITION"])(),Go=Da.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection");class C4 extends Wi{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!=="fragment")return"true";const{material:t}=e;return t.side===Y?"false":e.getFrontFacing()}}const KR=xi(C4),HM=at(KR).mul(2).sub(1),Yg=Kt(([i],{material:e})=>{const t=e.side;return t===Y?i=i.mul(-1):t===ie&&(i=i.mul(HM)),i}),Z_=oc("normal","vec3"),Ac=Kt(i=>i.geometry.hasAttribute("normal")===!1?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),Xt(0,1,0)):Z_,"vec3").once()().toVar("normalLocal"),JR=Da.dFdx().cross(Da.dFdy()).normalize().toVar("normalFlat"),Zg=Kt(i=>{let e;return i.material.flatShading===!0?e=JR:e=$M(Ac).toVarying("v_normalViewGeometry").normalize(),e},"vec3").once()().toVar("normalViewGeometry"),QR=Kt(i=>{let e=Zg.transformDirection(Kc);return i.material.flatShading!==!0&&(e=e.toVarying("v_normalWorldGeometry")),e.normalize().toVar("normalWorldGeometry")},"vec3").once()(),po=Kt(({subBuildFn:i,material:e,context:t})=>{let n;return i==="NORMAL"||i==="VERTEX"?(n=Zg,e.flatShading!==!0&&(n=Yg(n))):n=t.setupNormal().context({getUV:null}),n},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),Xf=po.transformDirection(Kc).toVar("normalWorld"),mm=Kt(({subBuildFn:i,context:e})=>{let t;return i==="NORMAL"||i==="VERTEX"?t=po:t=e.setupClearcoatNormal().context({getUV:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),e2=Kt(([i,e=Nu])=>{const t=$l(e),n=i.div(Xt(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(n).xyz}),$M=Kt(([i],e)=>{const t=e.renderer.overrideNodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(i);const n=YR.mul(i);return Kc.transformDirection(n)}),R4=Kt(()=>(console.warn('THREE.TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),po)).once(["NORMAL","VERTEX"])(),N4=Kt(()=>(console.warn('THREE.TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),Xf)).once(["NORMAL","VERTEX"])(),P4=Kt(()=>(console.warn('THREE.TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),mm)).once(["NORMAL","VERTEX"])(),t2=new Qi,jM=new Ft,n2=cr(0).onReference(({material:i})=>i).onObjectUpdate(({material:i})=>i.refractionRatio),K_=cr(1).onReference(({material:i})=>i).onObjectUpdate(function({material:i,scene:e}){return i.envMap?i.envMapIntensity:e.environmentIntensity}),XM=cr(new Ft).onReference(function(i){return i.material}).onObjectUpdate(function({material:i,scene:e}){const t=e.environment!==null&&i.envMap===null?e.environmentRotation:i.envMapRotation;return t?(t2.copy(t),jM.makeRotationFromEuler(t2)):jM.identity(),jM}),i2=Go.negate().reflect(po),r2=Go.negate().refract(po,n2),s2=i2.transformDirection(Kc).toVar("reflectVector"),o2=r2.transformDirection(Kc).toVar("reflectVector"),a2=new xh;class I4 extends Gh{static get type(){return"CubeTextureNode"}constructor(e,t=null,n=null,s=null){super(e,t,n,s),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===De?s2:e.mapping===We?o2:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),Xt(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return(e.renderer.coordinateSystem===qa||!n.isRenderTargetTexture)&&(t=Xt(t.x.negate(),t.yz)),XM.mul(t)}generateUV(e,t){return t.build(e,"vec3")}}const qM=Vr(I4).setParameterLength(1,4).setName("cubeTexture"),Kg=(i=a2,e=null,t=null,n=null)=>{let s;return i&&i.isCubeTextureNode===!0?(s=Cn(i.clone()),s.referenceNode=i,e!==null&&(s.uvNode=Cn(e)),t!==null&&(s.levelNode=Cn(t)),n!==null&&(s.biasNode=Cn(n))):s=qM(i,e,t,n),s},L4=(i=a2)=>qM(i);class D4 extends lm{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,n,s)}}class J_ extends Wi{static get type(){return"ReferenceNode"}constructor(e,t,n=null,s=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=s,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=ss.OBJECT}element(e){return Cn(new D4(this,Cn(e)))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;this.count!==null?t=xv(null,e,this.count):Array.isArray(this.getValueFromReference())?t=jl(null,e):e==="texture"?t=Is(null):e==="cubeTexture"?t=Kg(null):t=cr(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.setName(this.name),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let s=1;s<t.length;s++)n=n[t[s]];return n}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const Po=(i,e,t)=>Cn(new J_(i,e,t)),YM=(i,e,t,n)=>Cn(new J_(i,e,n,t));class O4 extends J_{static get type(){return"MaterialReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const $d=(i,e,t=null)=>Cn(new O4(i,e,t)),l2=xo(),F4=Da.dFdx(),B4=Da.dFdy(),c2=l2.dFdx(),u2=l2.dFdy(),h2=po,d2=B4.cross(h2),f2=h2.cross(F4),ZM=d2.mul(c2.x).add(f2.mul(u2.x)),KM=d2.mul(c2.y).add(f2.mul(u2.y)),p2=ZM.dot(ZM).max(KM.dot(KM)),m2=p2.equal(0).select(0,p2.inverseSqrt()),U4=ZM.mul(m2).toVar("tangentViewFrame"),k4=KM.mul(m2).toVar("bitangentViewFrame"),Q_=Kt(i=>(i.geometry.hasAttribute("tangent")===!1&&i.geometry.computeTangents(),oc("tangent","vec4")))(),Sv=Q_.xyz.toVar("tangentLocal"),eb=Kt(({subBuildFn:i,geometry:e,material:t})=>{let n;return i==="VERTEX"||e.hasAttribute("tangent")?n=Hd.mul(Bi(Sv,0)).xyz.toVarying("v_tangentView").normalize():n=U4,t.flatShading!==!0&&(n=Yg(n)),n},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),g2=eb.transformDirection(Kc).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),tb=Kt(([i,e],{subBuildFn:t,material:n})=>{let s=i.mul(Q_.w).xyz;return t==="NORMAL"&&n.flatShading!==!0&&(s=s.toVarying(e)),s}).once(["NORMAL"]),z4=tb(Z_.cross(Q_),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),V4=tb(Ac.cross(Sv),"v_bitangentLocal").normalize().toVar("bitangentLocal"),y2=Kt(({subBuildFn:i,geometry:e,material:t})=>{let n;return i==="VERTEX"||e.hasAttribute("tangent")?n=tb(po.cross(eb),"v_bitangentView").normalize():n=k4,t.flatShading!==!0&&(n=Yg(n)),n},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),G4=tb(Xf.cross(g2),"v_bitangentWorld").normalize().toVar("bitangentWorld"),gm=$l(eb,y2,po).toVar("TBNViewMatrix"),v2=Go.mul(gm),W4=(i,e)=>i.sub(v2.mul(e)),x2=Kt(()=>{let i=dm.cross(Go);return i=i.cross(dm).normalize(),i=$s(i,po,Wf.mul(Fh.oneMinus()).oneMinus().pow2().pow2()).normalize(),i}).once()();class H4 extends Pa{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=Xa}setup({material:e}){const{normalMapType:t,scaleNode:n}=this;let s=this.node.mul(2).sub(1);if(n!==null){let a=n;e.flatShading===!0&&(a=Yg(a)),s=Xt(s.xy.mul(a),s.z)}let o=null;return t===Jd?o=$M(s):t===Xa?o=gm.mul(s).normalize():(console.error(`THREE.NodeMaterial: Unsupported normal map type: ${t}`),o=po),o}}const JM=Vr(H4).setParameterLength(1,2),$4=Kt(({textureNode:i,bumpScale:e})=>{const t=s=>i.cache().context({getUV:o=>s(o.uvNode||xo()),forceUVContext:!0}),n=at(t(s=>s));return Bn(at(t(s=>s.add(s.dFdx()))).sub(n),at(t(s=>s.add(s.dFdy()))).sub(n)).mul(e)}),j4=Kt(i=>{const{surf_pos:e,surf_norm:t,dHdxy:n}=i,s=e.dFdx().normalize(),o=e.dFdy().normalize(),a=t,c=o.cross(a),u=a.cross(s),d=s.dot(c).mul(HM),p=d.sign().mul(n.x.mul(c).add(n.y.mul(u)));return d.abs().mul(t).sub(p).normalize()});class X4 extends Pa{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=this.scaleNode!==null?this.scaleNode:1,t=$4({textureNode:this.textureNode,bumpScale:e});return j4({surf_pos:Da,surf_norm:po,dHdxy:t})}}const QM=Vr(X4).setParameterLength(1,2),_2=new Map;class Ln extends Wi{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let n=_2.get(e);return n===void 0&&(n=$d(e,t),_2.set(e,n)),n}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,n=this.scope;let s=null;if(n===Ln.COLOR){const o=t.color!==void 0?this.getColor(n):Xt();t.map&&t.map.isTexture===!0?s=o.mul(this.getTexture("map")):s=o}else if(n===Ln.OPACITY){const o=this.getFloat(n);t.alphaMap&&t.alphaMap.isTexture===!0?s=o.mul(this.getTexture("alpha")):s=o}else if(n===Ln.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?s=this.getTexture("specular").r:s=at(1);else if(n===Ln.SPECULAR_INTENSITY){const o=this.getFloat(n);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?s=o.mul(this.getTexture(n).a):s=o}else if(n===Ln.SPECULAR_COLOR){const o=this.getColor(n);t.specularColorMap&&t.specularColorMap.isTexture===!0?s=o.mul(this.getTexture(n).rgb):s=o}else if(n===Ln.ROUGHNESS){const o=this.getFloat(n);t.roughnessMap&&t.roughnessMap.isTexture===!0?s=o.mul(this.getTexture(n).g):s=o}else if(n===Ln.METALNESS){const o=this.getFloat(n);t.metalnessMap&&t.metalnessMap.isTexture===!0?s=o.mul(this.getTexture(n).b):s=o}else if(n===Ln.EMISSIVE){const o=this.getFloat("emissiveIntensity"),a=this.getColor(n).mul(o);t.emissiveMap&&t.emissiveMap.isTexture===!0?s=a.mul(this.getTexture(n)):s=a}else if(n===Ln.NORMAL)t.normalMap?(s=JM(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=t.normalMapType):t.bumpMap?s=QM(this.getTexture("bump").r,this.getFloat("bumpScale")):s=po;else if(n===Ln.CLEARCOAT){const o=this.getFloat(n);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?s=o.mul(this.getTexture(n).r):s=o}else if(n===Ln.CLEARCOAT_ROUGHNESS){const o=this.getFloat(n);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?s=o.mul(this.getTexture(n).r):s=o}else if(n===Ln.CLEARCOAT_NORMAL)t.clearcoatNormalMap?s=JM(this.getTexture(n),this.getCache(n+"Scale","vec2")):s=po;else if(n===Ln.SHEEN){const o=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?s=o.mul(this.getTexture("sheenColor").rgb):s=o}else if(n===Ln.SHEEN_ROUGHNESS){const o=this.getFloat(n);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?s=o.mul(this.getTexture(n).a):s=o,s=s.clamp(.07,1)}else if(n===Ln.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const o=this.getTexture(n);s=P_(Jg.x,Jg.y,Jg.y.negate(),Jg.x).mul(o.rg.mul(2).sub(Bn(1)).normalize().mul(o.b))}else s=Jg;else if(n===Ln.IRIDESCENCE_THICKNESS){const o=Po("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const a=Po("0","float",t.iridescenceThicknessRange);s=o.sub(a).mul(this.getTexture(n).g).add(a)}else s=o}else if(n===Ln.TRANSMISSION){const o=this.getFloat(n);t.transmissionMap?s=o.mul(this.getTexture(n).r):s=o}else if(n===Ln.THICKNESS){const o=this.getFloat(n);t.thicknessMap?s=o.mul(this.getTexture(n).g):s=o}else if(n===Ln.IOR)s=this.getFloat(n);else if(n===Ln.LIGHT_MAP)s=this.getTexture(n).rgb.mul(this.getFloat("lightMapIntensity"));else if(n===Ln.AO)s=this.getTexture(n).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(n===Ln.LINE_DASH_OFFSET)s=t.dashOffset?this.getFloat(n):at(0);else{const o=this.getNodeType(e);s=this.getCache(n,o)}return s}}Ln.ALPHA_TEST="alphaTest",Ln.COLOR="color",Ln.OPACITY="opacity",Ln.SHININESS="shininess",Ln.SPECULAR="specular",Ln.SPECULAR_STRENGTH="specularStrength",Ln.SPECULAR_INTENSITY="specularIntensity",Ln.SPECULAR_COLOR="specularColor",Ln.REFLECTIVITY="reflectivity",Ln.ROUGHNESS="roughness",Ln.METALNESS="metalness",Ln.NORMAL="normal",Ln.CLEARCOAT="clearcoat",Ln.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Ln.CLEARCOAT_NORMAL="clearcoatNormal",Ln.EMISSIVE="emissive",Ln.ROTATION="rotation",Ln.SHEEN="sheen",Ln.SHEEN_ROUGHNESS="sheenRoughness",Ln.ANISOTROPY="anisotropy",Ln.IRIDESCENCE="iridescence",Ln.IRIDESCENCE_IOR="iridescenceIOR",Ln.IRIDESCENCE_THICKNESS="iridescenceThickness",Ln.IOR="ior",Ln.TRANSMISSION="transmission",Ln.THICKNESS="thickness",Ln.ATTENUATION_DISTANCE="attenuationDistance",Ln.ATTENUATION_COLOR="attenuationColor",Ln.LINE_SCALE="scale",Ln.LINE_DASH_SIZE="dashSize",Ln.LINE_GAP_SIZE="gapSize",Ln.LINE_WIDTH="linewidth",Ln.LINE_DASH_OFFSET="dashOffset",Ln.POINT_SIZE="size",Ln.DISPERSION="dispersion",Ln.LIGHT_MAP="light",Ln.AO="ao";const b2=xi(Ln,Ln.ALPHA_TEST),nb=xi(Ln,Ln.COLOR),w2=xi(Ln,Ln.SHININESS),M2=xi(Ln,Ln.EMISSIVE),ib=xi(Ln,Ln.OPACITY),S2=xi(Ln,Ln.SPECULAR),eS=xi(Ln,Ln.SPECULAR_INTENSITY),T2=xi(Ln,Ln.SPECULAR_COLOR),Tv=xi(Ln,Ln.SPECULAR_STRENGTH),rb=xi(Ln,Ln.REFLECTIVITY),E2=xi(Ln,Ln.ROUGHNESS),A2=xi(Ln,Ln.METALNESS),C2=xi(Ln,Ln.NORMAL),R2=xi(Ln,Ln.CLEARCOAT),N2=xi(Ln,Ln.CLEARCOAT_ROUGHNESS),P2=xi(Ln,Ln.CLEARCOAT_NORMAL),I2=xi(Ln,Ln.ROTATION),L2=xi(Ln,Ln.SHEEN),D2=xi(Ln,Ln.SHEEN_ROUGHNESS),O2=xi(Ln,Ln.ANISOTROPY),F2=xi(Ln,Ln.IRIDESCENCE),B2=xi(Ln,Ln.IRIDESCENCE_IOR),U2=xi(Ln,Ln.IRIDESCENCE_THICKNESS),k2=xi(Ln,Ln.TRANSMISSION),z2=xi(Ln,Ln.THICKNESS),V2=xi(Ln,Ln.IOR),G2=xi(Ln,Ln.ATTENUATION_DISTANCE),W2=xi(Ln,Ln.ATTENUATION_COLOR),tS=xi(Ln,Ln.LINE_SCALE),nS=xi(Ln,Ln.LINE_DASH_SIZE),iS=xi(Ln,Ln.LINE_GAP_SIZE),sb=xi(Ln,Ln.LINE_WIDTH),rS=xi(Ln,Ln.LINE_DASH_OFFSET),H2=xi(Ln,Ln.POINT_SIZE),$2=xi(Ln,Ln.DISPERSION),sS=xi(Ln,Ln.LIGHT_MAP),j2=xi(Ln,Ln.AO),Jg=cr(new yn).onReference(function(i){return i.material}).onRenderUpdate(function({material:i}){this.value.set(i.anisotropy*Math.cos(i.anisotropyRotation),i.anisotropy*Math.sin(i.anisotropyRotation))}),oS=Kt(i=>i.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class Ko extends Wi{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),n=this.scope;let s;if(n===Ko.VERTEX)s=e.getVertexIndex();else if(n===Ko.INSTANCE)s=e.getInstanceIndex();else if(n===Ko.DRAW)s=e.getDrawIndex();else if(n===Ko.INVOCATION_LOCAL)s=e.getInvocationLocalIndex();else if(n===Ko.INVOCATION_SUBGROUP)s=e.getInvocationSubgroupIndex();else if(n===Ko.SUBGROUP)s=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+n);let o;return e.shaderStage==="vertex"||e.shaderStage==="compute"?o=s:o=Vh(this).build(e,t),o}}Ko.VERTEX="vertex",Ko.INSTANCE="instance",Ko.SUBGROUP="subgroup",Ko.INVOCATION_LOCAL="invocationLocal",Ko.INVOCATION_SUBGROUP="invocationSubgroup",Ko.DRAW="draw";const X2=xi(Ko,Ko.VERTEX),qf=xi(Ko,Ko.INSTANCE),q4=xi(Ko,Ko.SUBGROUP),Y4=xi(Ko,Ko.INVOCATION_SUBGROUP),Z4=xi(Ko,Ko.INVOCATION_LOCAL),q2=xi(Ko,Ko.DRAW);class Y2 extends Wi{static get type(){return"InstanceNode"}constructor(e,t,n=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=ss.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{instanceMatrix:t,instanceColor:n}=this,{count:s}=t;let{instanceMatrixNode:o,instanceColorNode:a}=this;if(o===null){if(s<=1e3)o=xv(t.array,"mat4",Math.max(s,1)).element(qf);else{const u=new hw(t.array,16,1);this.buffer=u;const d=t.usage===nf?DM:X_,p=[d(u,"vec4",16,0),d(u,"vec4",16,4),d(u,"vec4",16,8),d(u,"vec4",16,12)];o=um(...p)}this.instanceMatrixNode=o}if(n&&a===null){const u=new Vc(n.array,3),d=n.usage===nf?DM:X_;this.bufferColor=u,a=Xt(d(u,"vec3",3,0)),this.instanceColorNode=a}const c=o.mul(La).xyz;if(La.assign(c),e.hasGeometryAttribute("normal")){const u=e2(Ac,o);Ac.assign(u)}this.instanceColorNode!==null&&qc("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==nf&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==nf&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const K4=Vr(Y2).setParameterLength(2,3);class J4 extends Y2{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:n,instanceColor:s}=e;super(t,n,s),this.instancedMesh=e}}const Z2=Vr(J4).setParameterLength(1);class Q4 extends Wi{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=qf:this.batchingIdNode=q2);const n=Kt(([T])=>{const G=Dt($f(Ia(this.batchMesh._indirectTexture),0).x),z=Dt(T).mod(G),I=Dt(T).div(G);return Ia(this.batchMesh._indirectTexture,gl(z,I)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(Dt(this.batchingIdNode)),s=this.batchMesh._matricesTexture,o=Dt($f(Ia(s),0).x),a=at(n).mul(4).toInt().toVar(),c=a.mod(o),u=a.div(o),d=um(Ia(s,gl(c,u)),Ia(s,gl(c.add(1),u)),Ia(s,gl(c.add(2),u)),Ia(s,gl(c.add(3),u))),p=this.batchMesh._colorsTexture;if(p!==null){const G=Kt(([z])=>{const I=Dt($f(Ia(p),0).x),J=z,K=J.mod(I),re=J.div(I);return Ia(p,gl(K,re)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(n);qc("vec3","vBatchColor").assign(G)}const m=$l(d);La.assign(d.mul(La));const y=Ac.div(Xt(m[0].dot(m[0]),m[1].dot(m[1]),m[2].dot(m[2]))),M=m.mul(y).xyz;Ac.assign(M),e.hasGeometryAttribute("tangent")&&Sv.mulAssign(m)}}const K2=Vr(Q4).setParameterLength(1);class eV extends lm{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const n=this.storageBufferNode.structTypeNode;return n?n.getMemberType(e,t):"void"}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n;const s=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&s!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?n=e.generatePBO(this):n=this.node.build(e):n=super.generate(e),s!==!0){const o=this.getNodeType(e);n=e.format(n,o,t)}return n}}const tV=Vr(eV).setParameterLength(2);class nV extends kM{static get type(){return"StorageBufferNode"}constructor(e,t=null,n=0){let s,o=null;t&&t.isStruct?(s="struct",o=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(n=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(s=Yw(e.itemSize),n=e.count):s=t,super(e,s,n),this.isStorageBufferNode=!0,this.structTypeNode=o,this.access=Il.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return tV(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Il.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=yv(this.value),this._varying=Vh(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode!==null?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:n}=this.getAttributeData(),s=n.build(e);return e.registerTransform(s,t),s}}const ym=(i,e=null,t=0)=>Cn(new nV(i,e,t)),iV=(i,e,t)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),ym(i,e,t).setPBO(!0)),J2=new WeakMap;class Q2 extends Wi{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=ss.OBJECT,this.skinIndexNode=oc("skinIndex","uvec4"),this.skinWeightNode=oc("skinWeight","vec4"),this.bindMatrixNode=Po("bindMatrix","mat4"),this.bindMatrixInverseNode=Po("bindMatrixInverse","mat4"),this.boneMatricesNode=YM("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=La,this.toPositionNode=La,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:n,skinWeightNode:s,bindMatrixNode:o,bindMatrixInverseNode:a}=this,c=e.element(n.x),u=e.element(n.y),d=e.element(n.z),p=e.element(n.w),m=o.mul(t),y=$a(c.mul(s.x).mul(m),u.mul(s.y).mul(m),d.mul(s.z).mul(m),p.mul(s.w).mul(m));return a.mul(y).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=Ac){const{skinIndexNode:n,skinWeightNode:s,bindMatrixNode:o,bindMatrixInverseNode:a}=this,c=e.element(n.x),u=e.element(n.y),d=e.element(n.z),p=e.element(n.w);let m=$a(s.x.mul(c),s.y.mul(u),s.z.mul(d),s.w.mul(p));return m=a.mul(m).mul(o),m.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=YM("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Y_)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||Kw(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&Y_.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const n=this.getSkinnedNormal();Ac.assign(n),e.hasGeometryAttribute("tangent")&&Sv.assign(n)}return t}generate(e,t){if(t!=="void")return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;J2.get(t)!==e.frameId&&(J2.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const eN=i=>Cn(new Q2(i)),rV=(i,e=null)=>{const t=new Q2(i);return t.positionNode=ym(new Vc(i.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(qf).toVar(),t.skinIndexNode=ym(new Vc(new Uint32Array(i.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(qf).toVar(),t.skinWeightNode=ym(new Vc(i.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(qf).toVar(),t.bindMatrixNode=cr(i.bindMatrix,"mat4"),t.bindMatrixInverseNode=cr(i.bindMatrixInverse,"mat4"),t.boneMatricesNode=xv(i.skeleton.boneMatrices,"mat4",i.skeleton.bones.length),t.toPositionNode=e,Cn(t)};class sV extends Wi{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const n={};for(let a=0,c=this.params.length-1;a<c;a++){const u=this.params[a],d=u.isNode!==!0&&u.name||this.getVarName(a),p=u.isNode!==!0&&u.type||"int";n[d]=kd(d,p)}const s=e.addStack();t.returnsNode=this.params[this.params.length-1](n,e),t.stackNode=s;const o=this.params[0];return o.isNode!==!0&&typeof o.update=="function"&&(t.updateNode=Kt(this.params[0].update)(n)),e.removeStack(),t}getNodeType(e){const{returnsNode:t}=this.getProperties(e);return t?t.getNodeType(e):"void"}setup(e){this.getProperties(e)}generate(e){const t=this.getProperties(e),n=this.params,s=t.stackNode;for(let c=0,u=n.length-1;c<u;c++){const d=n[c];let p=!1,m=null,y=null,M=null,T=null,G=null,z=null;d.isNode?d.getNodeType(e)==="bool"?(p=!0,T="bool",y=d.build(e,T)):(T="int",M=this.getVarName(c),m="0",y=d.build(e,T),G="<"):(T=d.type||"int",M=d.name||this.getVarName(c),m=d.start,y=d.end,G=d.condition,z=d.update,typeof m=="number"?m=e.generateConst(T,m):m&&m.isNode&&(m=m.build(e,T)),typeof y=="number"?y=e.generateConst(T,y):y&&y.isNode&&(y=y.build(e,T)),m!==void 0&&y===void 0?(m=m+" - 1",y="0",G=">="):y!==void 0&&m===void 0&&(m="0",G="<"),G===void 0&&(Number(m)>Number(y)?G=">=":G="<"));let I;if(p)I=`while ( ${y} )`;else{const J={start:m,end:y},K=J.start,re=J.end;let ve;const me=()=>G.includes("<")?"+=":"-=";if(z!=null)switch(typeof z){case"function":ve=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":ve=M+" "+me()+" "+e.generateConst(T,z);break;case"string":ve=M+" "+z;break;default:z.isNode?ve=M+" "+me()+" "+z.build(e):(console.error("THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number."),ve="break /* invalid update */")}else T==="int"||T==="uint"?z=G.includes("<")?"++":"--":z=me()+" 1.",ve=M+" "+z;const Le=e.getVar(T,M)+" = "+K,Ve=M+" "+G+" "+re;I=`for ( ${Le}; ${Ve}; ${ve} )`}e.addFlowCode((c===0?`
|
|
|
`:"")+e.tab+I+` {
|
|
|
|
|
|
`).addFlowTab()}const o=s.build(e,"void"),a=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode(`
|
|
|
`+e.tab+o);for(let c=0,u=this.params.length-1;c<u;c++)e.addFlowCode((c===0?"":e.tab)+`}
|
|
|
|
|
|
`).removeFlowTab();return e.addFlowTab(),a}}const mo=(...i)=>Cn(new sV(cm(i,"int"))).toStack(),oV=()=>kd("continue").toStack(),tN=()=>kd("break").toStack(),aS=new WeakMap,Qc=new mr,nN=Kt(({bufferMap:i,influence:e,stride:t,width:n,depth:s,offset:o})=>{const a=Dt(X2).mul(t).add(o),c=a.div(n),u=a.sub(c.mul(n));return Ia(i,gl(u,c)).depth(s).xyz.mul(e)});function aV(i){const e=i.morphAttributes.position!==void 0,t=i.morphAttributes.normal!==void 0,n=i.morphAttributes.color!==void 0,s=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,o=s!==void 0?s.length:0;let a=aS.get(i);if(a===void 0||a.count!==o){let I=function(){G.dispose(),aS.delete(i),i.removeEventListener("dispose",I)};a!==void 0&&a.texture.dispose();const c=i.morphAttributes.position||[],u=i.morphAttributes.normal||[],d=i.morphAttributes.color||[];let p=0;e===!0&&(p=1),t===!0&&(p=2),n===!0&&(p=3);let m=i.attributes.position.count*p,y=1;const M=4096;m>M&&(y=Math.ceil(m/M),m=M);const T=new Float32Array(m*y*4*o),G=new sf(T,m,y,o);G.type=ys,G.needsUpdate=!0;const z=p*4;for(let J=0;J<o;J++){const K=c[J],re=u[J],ve=d[J],me=m*y*4*J;for(let Le=0;Le<K.count;Le++){const Ve=Le*z;e===!0&&(Qc.fromBufferAttribute(K,Le),T[me+Ve+0]=Qc.x,T[me+Ve+1]=Qc.y,T[me+Ve+2]=Qc.z,T[me+Ve+3]=0),t===!0&&(Qc.fromBufferAttribute(re,Le),T[me+Ve+4]=Qc.x,T[me+Ve+5]=Qc.y,T[me+Ve+6]=Qc.z,T[me+Ve+7]=0),n===!0&&(Qc.fromBufferAttribute(ve,Le),T[me+Ve+8]=Qc.x,T[me+Ve+9]=Qc.y,T[me+Ve+10]=Qc.z,T[me+Ve+11]=ve.itemSize===4?Qc.w:1)}}a={count:o,texture:G,stride:p,size:new yn(m,y)},aS.set(i,a),i.addEventListener("dispose",I)}return a}class lV extends Wi{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=cr(1),this.updateType=ss.OBJECT}setup(e){const{geometry:t}=e,n=t.morphAttributes.position!==void 0,s=t.hasAttribute("normal")&&t.morphAttributes.normal!==void 0,o=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=o!==void 0?o.length:0,{texture:c,stride:u,size:d}=aV(t);n===!0&&La.mulAssign(this.morphBaseInfluence),s===!0&&Ac.mulAssign(this.morphBaseInfluence);const p=Dt(d.width);mo(a,({i:m})=>{const y=at(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?y.assign(Ia(this.mesh.morphTexture,gl(Dt(m).add(1),Dt(qf))).r):y.assign(Po("morphTargetInfluences","float").element(m).toVar()),sr(y.notEqual(0),()=>{n===!0&&La.addAssign(nN({bufferMap:c,influence:y,stride:u,width:p,depth:m,offset:Dt(0)})),s===!0&&Ac.addAssign(nN({bufferMap:c,influence:y,stride:u,width:p,depth:m,offset:Dt(1)}))})})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,n)=>t+n,0)}}const iN=Vr(lV).setParameterLength(1);class Qg extends Wi{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class cV extends Qg{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class uV extends bR{static get type(){return"LightingContextNode"}constructor(e,t=null,n=null,s=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=s,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,n=Xt().toVar("directDiffuse"),s=Xt().toVar("directSpecular"),o=Xt().toVar("indirectDiffuse"),a=Xt().toVar("indirectSpecular"),c={directDiffuse:n,directSpecular:s,indirectDiffuse:o,indirectSpecular:a};return{radiance:Xt().toVar("radiance"),irradiance:Xt().toVar("irradiance"),iblIrradiance:Xt().toVar("iblIrradiance"),ambientOcclusion:at(1).toVar("ambientOcclusion"),reflectedLight:c,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const rN=Vr(uV);class hV extends Qg{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}const e0=new yn;class ob extends Gh{static get type(){return"ViewportTextureNode"}constructor(e=Vd,t=null,n=null){let s=null;n===null?(s=new Ap,s.minFilter=Qn,n=s):s=n,super(n,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=s,this.isOutputTextureNode=!0,this.updateBeforeType=ss.FRAME,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,n;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,n=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,n=this._cacheTextures),e===null)return t;if(n.has(e)===!1){const s=t.clone();n.set(e,s)}return n.get(e)}updateReference(e){const t=e.renderer.getRenderTarget();return this.value=this.getTextureForReference(t),this.value}updateBefore(e){const t=e.renderer,n=t.getRenderTarget();n===null?t.getDrawingBufferSize(e0):e0.set(n.width,n.height);const s=this.getTextureForReference(n);(s.image.width!==e0.width||s.image.height!==e0.height)&&(s.image.width=e0.width,s.image.height=e0.height,s.needsUpdate=!0);const o=s.generateMipmaps;s.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(s),s.generateMipmaps=o}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const dV=Vr(ob).setParameterLength(0,3),lS=Vr(ob,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let ab=null;class fV extends ob{static get type(){return"ViewportDepthTextureNode"}constructor(e=Vd,t=null){ab===null&&(ab=new vc),super(e,t,ab)}getTextureForReference(){return ab}}const cS=Vr(fV).setParameterLength(0,2);class Cc extends Wi{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===Cc.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,n=this.valueNode;let s=null;if(t===Cc.DEPTH_BASE)n!==null&&(s=sN().assign(n));else if(t===Cc.DEPTH)e.isPerspectiveCamera?s=uS(Da.z,Gd,Wd):s=t0(Da.z,Gd,Wd);else if(t===Cc.LINEAR_DEPTH)if(n!==null)if(e.isPerspectiveCamera){const o=hS(n,Gd,Wd);s=t0(o,Gd,Wd)}else s=n;else s=t0(Da.z,Gd,Wd);return s}}Cc.DEPTH_BASE="depthBase",Cc.DEPTH="depth",Cc.LINEAR_DEPTH="linearDepth";const t0=(i,e,t)=>i.add(e).div(e.sub(t)),pV=(i,e,t)=>e.sub(t).mul(i).sub(e),uS=(i,e,t)=>e.add(i).mul(t).div(t.sub(e).mul(i)),hS=(i,e,t)=>e.mul(t).div(t.sub(e).mul(i).sub(t)),dS=(i,e,t)=>{e=e.max(1e-6).toVar();const n=Bh(i.negate().div(e)),s=Bh(t.div(e));return n.div(s)},mV=(i,e,t)=>{const n=i.mul(z_(t.div(e)));return at(Math.E).pow(n).mul(e).negate()},sN=Vr(Cc,Cc.DEPTH_BASE),fS=xi(Cc,Cc.DEPTH),n0=Vr(Cc,Cc.LINEAR_DEPTH).setParameterLength(0,1),gV=n0(cS());fS.assign=i=>sN(i);class Pu extends Wi{static get type(){return"ClippingNode"}constructor(e=Pu.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:n,unionPlanes:s}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===Pu.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,s):this.scope===Pu.HARDWARE?this.setupHardwareClipping(s,e):this.setupDefault(n,s)}setupAlphaToCoverage(e,t){return Kt(()=>{const n=at().toVar("distanceToPlane"),s=at().toVar("distanceToGradient"),o=at(1).toVar("clipOpacity"),a=t.length;if(this.hardwareClipping===!1&&a>0){const u=jl(t).setGroup(or);mo(a,({i:d})=>{const p=u.element(d);n.assign(Da.dot(p.xyz).negate().add(p.w)),s.assign(n.fwidth().div(2)),o.mulAssign(Au(s.negate(),s,n))})}const c=e.length;if(c>0){const u=jl(e).setGroup(or),d=at(1).toVar("intersectionClipOpacity");mo(c,({i:p})=>{const m=u.element(p);n.assign(Da.dot(m.xyz).negate().add(m.w)),s.assign(n.fwidth().div(2)),d.mulAssign(Au(s.negate(),s,n).oneMinus())}),o.mulAssign(d.oneMinus())}no.a.mulAssign(o),no.a.equal(0).discard()})()}setupDefault(e,t){return Kt(()=>{const n=t.length;if(this.hardwareClipping===!1&&n>0){const o=jl(t).setGroup(or);mo(n,({i:a})=>{const c=o.element(a);Da.dot(c.xyz).greaterThan(c.w).discard()})}const s=e.length;if(s>0){const o=jl(e).setGroup(or),a=Su(!0).toVar("clipped");mo(s,({i:c})=>{const u=o.element(c);a.assign(Da.dot(u.xyz).greaterThan(u.w).and(a))}),a.discard()}})()}setupHardwareClipping(e,t){const n=e.length;return t.enableHardwareClipping(n),Kt(()=>{const s=jl(e).setGroup(or),o=zd(t.getClipDistance());mo(n,({i:a})=>{const c=s.element(a),u=Da.dot(c.xyz).sub(c.w).negate();o.element(a).assign(u)})})()}}Pu.ALPHA_TO_COVERAGE="alphaToCoverage",Pu.DEFAULT="default",Pu.HARDWARE="hardware";const yV=()=>Cn(new Pu),vV=()=>Cn(new Pu(Pu.ALPHA_TO_COVERAGE)),xV=()=>Cn(new Pu(Pu.HARDWARE)),_V=.05,oN=Kt(([i])=>Bd(Jr(1e4,Zc(Jr(17,i.x).add(Jr(.1,i.y)))).mul($a(.1,Fo(Zc(Jr(13,i.y).add(i.x))))))),aN=Kt(([i])=>oN(Bn(oN(i.xy),i.z))),bV=Kt(([i])=>{const e=va(zh(wM(i.xyz)),zh(MM(i.xyz))),t=at(1).div(at(_V).mul(e)).toVar("pixScale"),n=Bn(jg(kh(Bh(t))),jg(V_(Bh(t)))),s=Bn(aN(kh(n.x.mul(i.xyz))),aN(kh(n.y.mul(i.xyz)))),o=Bd(Bh(t)),a=$a(Jr(o.oneMinus(),s.x),Jr(o,s.y)),c=Ec(o,o.oneMinus()),u=Xt(a.mul(a).div(Jr(2,c).mul(Os(1,c))),a.sub(Jr(.5,c)).div(Os(1,c)),Os(1,Os(1,a).mul(Os(1,a)).div(Jr(2,c).mul(Os(1,c))))),d=a.lessThan(c.oneMinus()).select(a.lessThan(c).select(u.x,u.y),u.z);return Eu(d,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class wV extends WR{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e),n=e.hasGeometryAttribute(t);let s;return n===!0?s=super.generate(e):s=e.generateConst(this.nodeType,new mr(1,1,1,1)),s}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const lN=(i=0)=>Cn(new wV(i)),cN=Kt(([i,e])=>Ec(1,i.oneMinus().div(e)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),uN=Kt(([i,e])=>Ec(i.div(e.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),hN=Kt(([i,e])=>i.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),dN=Kt(([i,e])=>$s(i.mul(2).mul(e),i.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),W_(.5,i))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),MV=Kt(([i,e])=>{const t=e.a.add(i.a.mul(e.a.oneMinus()));return Bi(e.rgb.mul(e.a).add(i.rgb.mul(i.a).mul(e.a.oneMinus())).div(t),t)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),fN=Kt(([i])=>Bi(i.rgb.mul(i.a),i.a),{color:"vec4",return:"vec4"}),SV=Kt(([i])=>(sr(i.a.equal(0),()=>Bi(0)),Bi(i.rgb.div(i.a),i.a)),{color:"vec4",return:"vec4"}),TV=(...i)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),cN(i)),EV=(...i)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),uN(i)),AV=(...i)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),hN(i)),CV=(...i)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),dN(i));class xa extends Ei{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,"shadowPositionNode",{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn('THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+qw(this)}build(e){this.setup(e)}setupObserver(e){return new iz(e)}setup(e){e.context.setupNormal=()=>Xg(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,n=t.getRenderTarget();e.addStack();const s=Xg(this.setupVertex(e),"VERTEX"),o=this.vertexNode||s;e.stack.outputNode=o,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let a;const c=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n!==null?n.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const u=this.setupLighting(e);c!==null&&e.stack.add(c);const d=Bi(u,no.a).max(0);a=this.setupOutput(e,d),$g.assign(a);const p=this.outputNode!==null;if(p&&(a=this.outputNode),n!==null){const m=t.getMRT(),y=this.mrtNode;m!==null?(p&&$g.assign(a),a=m,y!==null&&(a=m.merge(y))):y!==null&&(a=y)}}else{let u=this.fragmentNode;u.isOutputStructNode!==!0&&(u=Bi(u)),a=this.setupOutput(e,u)}e.stack.outputNode=a,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:t,intersectionPlanes:n}=e.clippingContext;let s=null;if(t.length>0||n.length>0){const o=e.renderer.samples;this.alphaToCoverage&&o>1?s=vV():e.stack.add(yV())}return s}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(xV()),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:n}=e;let s=this.depthNode;if(s===null){const o=t.getMRT();o&&o.has("depth")?s=o.get("depth"):t.logarithmicDepthBuffer===!0&&(n.isPerspectiveCamera?s=dS(Da.z,Gd,Wd):s=t0(Da.z,Gd,Wd))}s!==null&&fS.assign(s).toStack()}setupPositionView(){return Hd.mul(La).xyz}setupModelViewProjection(){return Cu.mul(Da)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),oS}setupPosition(e){const{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&iN(t).toStack(),t.isSkinnedMesh===!0&&eN(t).toStack(),this.displacementMap){const s=$d("displacementMap","texture"),o=$d("displacementScale","float"),a=$d("displacementBias","float");La.addAssign(Ac.normalize().mul(s.x.mul(o).add(a)))}return t.isBatchedMesh&&K2(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&Z2(t).toStack(),this.positionNode!==null&&La.assign(Xg(this.positionNode,"POSITION","vec3")),La}setupDiffuseColor({object:e,geometry:t}){this.maskNode!==null&&Su(this.maskNode).not().discard();let n=this.colorNode?Bi(this.colorNode):nb;this.vertexColors===!0&&t.hasAttribute("color")&&(n=n.mul(lN())),e.instanceColor&&(n=qc("vec3","vInstanceColor").mul(n)),e.isBatchedMesh&&e._colorsTexture&&(n=qc("vec3","vBatchColor").mul(n)),no.assign(n);const s=this.opacityNode?at(this.opacityNode):ib;no.a.assign(no.a.mul(s));let o=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(o=this.alphaTestNode!==null?at(this.alphaTestNode):b2,no.a.lessThanEqual(o).discard()),this.alphaHash===!0&&no.a.lessThan(bV(La)).discard(),this.transparent===!1&&this.blending===fe&&this.alphaToCoverage===!1?no.a.assign(1):o===null&&no.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return this.lights===!0?Xt(0):no.rgb}setupNormal(){return this.normalNode?Xt(this.normalNode):C2}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?$d("envMap","cubeTexture"):$d("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new hV(sS)),t}setupLights(e){const t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);const s=this.setupLightMap(e);if(s&&s.isLightingNode&&t.push(s),this.aoNode!==null||e.material.aoMap){const a=this.aoNode!==null?this.aoNode:j2;t.push(new cV(a))}let o=this.lightsNode||e.lightsNode;return t.length>0&&(o=e.renderer.lighting.createNode([...o.getLights(),...t])),o}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:n,backdropAlphaNode:s,emissiveNode:o}=this,c=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let u=this.setupOutgoingLight(e);if(c&&c.getScope().hasLights){const d=this.setupLightingModel(e)||null;u=rN(c,d,n,s)}else n!==null&&(u=Xt(s!==null?$s(u,n,s):n));return(o&&o.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(cM.assign(Xt(o||M2)),u=u.add(cM)),u}setupFog(e,t){const n=e.fogNode;return n&&($g.assign(t),t=Bi(n.toVar())),t}setupPremultipliedAlpha(e,t){return fN(t)}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),this.premultipliedAlpha===!0&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(const n in e){const s=e[n];this[n]===void 0&&(this[n]=s,s&&s.clone&&(this[n]=s.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const n in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,n)===void 0&&t[n].get!==void 0&&Object.defineProperty(this.constructor.prototype,n,t[n])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const n=Ei.prototype.toJSON.call(this,e),s=ev(this);n.inputNodes={};for(const{property:a,childNode:c}of s)n.inputNodes[a]=c.toJSON(e).uuid;function o(a){const c=[];for(const u in a){const d=a[u];delete d.metadata,c.push(d)}return c}if(t){const a=o(e.textures),c=o(e.images),u=o(e.nodes);a.length>0&&(n.textures=a),c.length>0&&(n.images=c),u.length>0&&(n.nodes=u)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const RV=new nl;class NV extends xa{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(RV),this.setValues(e)}}const PV=new yy;class IV extends xa{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(PV),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?at(this.offsetNode):rS,t=this.dashScaleNode?at(this.dashScaleNode):tS,n=this.dashSizeNode?at(this.dashSizeNode):nS,s=this.gapSizeNode?at(this.gapSizeNode):iS;fm.assign(n),hv.assign(s);const o=Vh(oc("lineDistance").mul(t));(e?o.add(e):o).mod(fm.add(hv)).greaterThan(fm).discard()}}let lb=null;class LV extends ob{static get type(){return"ViewportSharedTextureNode"}constructor(e=Vd,t=null){lb===null&&(lb=new Ap),super(e,t,lb)}getTextureForReference(){return lb}updateReference(){return this}}const pN=Vr(LV).setParameterLength(0,2),DV=new yy;class fZ extends null{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(DV),this.useColor=e.vertexColors,this.dashOffset=0,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.blending=NoBlending,this._useDash=e.dashed,this._useAlphaToCoverage=!0,this._useWorldUnits=!1,this.setValues(e)}setup(e){const{renderer:t}=e,n=this._useAlphaToCoverage,s=this.useColor,o=this._useDash,a=this._useWorldUnits,c=Kt(({start:d,end:p})=>{const m=Cu.element(2).element(2),T=Cu.element(3).element(2).mul(-.5).div(m).sub(d.z).div(p.z.sub(d.z));return Bi($s(d.xyz,p.xyz,T),p.w)}).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=Kt(()=>{const d=oc("instanceStart"),p=oc("instanceEnd"),m=Bi(Hd.mul(Bi(d,1))).toVar("start"),y=Bi(Hd.mul(Bi(p,1))).toVar("end");if(o){const ve=this.dashScaleNode?at(this.dashScaleNode):tS,me=this.offsetNode?at(this.offsetNode):rS,Le=oc("instanceDistanceStart"),Ve=oc("instanceDistanceEnd");let Ee=Ll.y.lessThan(.5).select(ve.mul(Le),ve.mul(Ve));Ee=Ee.add(me),qc("float","lineDistance").assign(Ee)}a&&(qc("vec3","worldStart").assign(m.xyz),qc("vec3","worldEnd").assign(y.xyz));const M=qg.z.div(qg.w),T=Cu.element(2).element(3).equal(-1);sr(T,()=>{sr(m.z.lessThan(0).and(y.z.greaterThan(0)),()=>{y.assign(c({start:m,end:y}))}).ElseIf(y.z.lessThan(0).and(m.z.greaterThanEqual(0)),()=>{m.assign(c({start:y,end:m}))})});const G=Cu.mul(m),z=Cu.mul(y),I=G.xyz.div(G.w),J=z.xyz.div(z.w),K=J.xy.sub(I.xy).toVar();K.x.assign(K.x.mul(M)),K.assign(K.normalize());const re=Bi().toVar();if(a){const ve=y.xyz.sub(m.xyz).normalize(),me=$s(m.xyz,y.xyz,.5).normalize(),Le=ve.cross(me).normalize(),Ve=ve.cross(Le),Ee=qc("vec4","worldPos");Ee.assign(Ll.y.lessThan(.5).select(m,y));const Oe=sb.mul(.5);Ee.addAssign(Bi(Ll.x.lessThan(0).select(Le.mul(Oe),Le.mul(Oe).negate()),0)),o||(Ee.addAssign(Bi(Ll.y.lessThan(.5).select(ve.mul(Oe).negate(),ve.mul(Oe)),0)),Ee.addAssign(Bi(Ve.mul(Oe),0)),sr(Ll.y.greaterThan(1).or(Ll.y.lessThan(0)),()=>{Ee.subAssign(Bi(Ve.mul(2).mul(Oe),0))})),re.assign(Cu.mul(Ee));const dt=Xt().toVar();dt.assign(Ll.y.lessThan(.5).select(I,J)),re.z.assign(dt.z.mul(re.w))}else{const ve=Bn(K.y,K.x.negate()).toVar("offset");K.x.assign(K.x.div(M)),ve.x.assign(ve.x.div(M)),ve.assign(Ll.x.lessThan(0).select(ve.negate(),ve)),sr(Ll.y.lessThan(0),()=>{ve.assign(ve.sub(K))}).ElseIf(Ll.y.greaterThan(1),()=>{ve.assign(ve.add(K))}),ve.assign(ve.mul(sb)),ve.assign(ve.div(qg.w)),re.assign(Ll.y.lessThan(.5).select(G,z)),ve.assign(ve.mul(re.w)),re.assign(re.add(Bi(ve,0,0)))}return re})();const u=Kt(({p1:d,p2:p,p3:m,p4:y})=>{const M=d.sub(m),T=y.sub(m),G=p.sub(d),z=M.dot(T),I=T.dot(G),J=M.dot(G),K=T.dot(T),ve=G.dot(G).mul(K).sub(I.mul(I)),Le=z.mul(I).sub(J.mul(K)).div(ve).clamp(),Ve=z.add(I.mul(Le)).div(K).clamp();return Bn(Le,Ve)});if(this.colorNode=Kt(()=>{const d=xo();if(o){const y=this.dashSizeNode?at(this.dashSizeNode):nS,M=this.gapSizeNode?at(this.gapSizeNode):iS;fm.assign(y),hv.assign(M);const T=qc("float","lineDistance");d.y.lessThan(-1).or(d.y.greaterThan(1)).discard(),T.mod(fm.add(hv)).greaterThan(fm).discard()}const p=at(1).toVar("alpha");if(a){const y=qc("vec3","worldStart"),M=qc("vec3","worldEnd"),T=qc("vec4","worldPos").xyz.normalize().mul(1e5),G=M.sub(y),z=u({p1:y,p2:M,p3:Xt(0,0,0),p4:T}),I=y.add(G.mul(z.x)),J=T.mul(z.y),ve=I.sub(J).length().div(sb);if(!o)if(n&&t.samples>1){const me=ve.fwidth();p.assign(Au(me.negate().add(.5),me.add(.5),ve).oneMinus())}else ve.greaterThan(.5).discard()}else if(n&&t.samples>1){const y=d.x,M=d.y.greaterThan(0).select(d.y.sub(1),d.y.add(1)),T=y.mul(y).add(M.mul(M)),G=at(T.fwidth()).toVar("dlen");sr(d.y.abs().greaterThan(1),()=>{p.assign(Au(G.oneMinus(),G.add(1),T).oneMinus())})}else sr(d.y.abs().greaterThan(1),()=>{const y=d.x,M=d.y.greaterThan(0).select(d.y.sub(1),d.y.add(1));y.mul(y).add(M.mul(M)).greaterThan(1).discard()});let m;if(this.lineColorNode)m=this.lineColorNode;else if(s){const y=oc("instanceColorStart"),M=oc("instanceColorEnd");m=Ll.y.lessThan(.5).select(y,M).mul(nb)}else m=nb;return Bi(m,p)})(),this.transparent){const d=this.opacityNode?at(this.opacityNode):ib;this.outputNode=Bi(this.colorNode.rgb.mul(d).add(pN().rgb.mul(d.oneMinus())),this.colorNode.a)}super.setup(e)}get worldUnits(){return this._useWorldUnits}set worldUnits(e){this._useWorldUnits!==e&&(this._useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this._useDash}set dashed(e){this._useDash!==e&&(this._useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const mN=i=>Cn(i).mul(.5).add(.5),OV=i=>Cn(i).mul(2).sub(1),FV=new Fx;class BV extends xa{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(FV),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?at(this.opacityNode):ib;no.assign(j_(Bi(mN(po),e),uo))}}const pS=Kt(([i=WM])=>{const e=i.z.atan(i.x).mul(1/(Math.PI*2)).add(.5),t=i.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Bn(e,t)});class gN extends O0{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const n=t.minFilter,s=t.generateMipmaps;t.generateMipmaps=!0,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 o=new Uc(5,5,5),a=pS(WM),c=new xa;c.colorNode=Is(t,a,0),c.side=Y,c.blending=pe;const u=new Ks(o,c),d=new Km;d.add(u),t.minFilter===Qn&&(t.minFilter=Rn);const p=new Hu(1,10,this),m=e.getMRT();return e.setMRT(null),p.update(e,d),e.setMRT(m),t.minFilter=n,t.currentGenerateMipmaps=s,u.geometry.dispose(),u.material.dispose(),this}}const Ev=new WeakMap;class UV extends Pa{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=Kg(null);const t=new xh;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=ss.RENDER}updateBefore(e){const{renderer:t,material:n}=e,s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const o=s.isTextureNode?s.value:n[s.property];if(o&&o.isTexture){const a=o.mapping;if(a===Ce||a===Re){if(Ev.has(o)){const c=Ev.get(o);vN(c,o.mapping),this._cubeTexture=c}else{const c=o.image;if(kV(c)){const u=new gN(c.height);u.fromEquirectangularTexture(t,o),vN(u.texture,o.mapping),this._cubeTexture=u.texture,Ev.set(o,u.texture),o.addEventListener("dispose",yN)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function kV(i){return i==null?!1:i.height>0}function yN(i){const e=i.target;e.removeEventListener("dispose",yN);const t=Ev.get(e);t!==void 0&&(Ev.delete(e),t.dispose())}function vN(i,e){e===Ce?i.mapping=De:e===Re&&(i.mapping=We)}const xN=Vr(UV).setParameterLength(1);class mS extends Qg{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=xN(this.envNode)}}class zV extends Qg{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=at(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class cb{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class _N extends cb{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,n=e.reflectedLight,s=e.irradianceLightMap;n.indirectDiffuse.assign(Bi(0)),s?n.indirectDiffuse.addAssign(s):n.indirectDiffuse.addAssign(Bi(1,1,1,0)),n.indirectDiffuse.mulAssign(t),n.indirectDiffuse.mulAssign(no.rgb)}finish(e){const{material:t,context:n}=e,s=n.outgoingLight,o=e.context.environment;if(o)switch(t.combine){case Et:s.rgb.assign($s(s.rgb,s.rgb.mul(o.rgb),Tv.mul(rb)));break;case je:s.rgb.assign($s(s.rgb,o.rgb,Tv.mul(rb)));break;case tt:s.rgb.addAssign(o.rgb.mul(Tv.mul(rb)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",t.combine);break}}}const VV=new Hr;class GV extends xa{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(VV),this.setValues(e)}setupNormal(){return Yg(Zg)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new mS(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new zV(sS)),t}setupOutgoingLight(){return no.rgb}setupLightingModel(){return new _N}}const i0=Kt(({f0:i,f90:e,dotVH:t})=>{const n=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return i.mul(n.oneMinus()).add(e.mul(n))}),vm=Kt(i=>i.diffuseColor.mul(1/Math.PI)),WV=()=>at(.25),HV=Kt(({dotNH:i})=>F_.mul(at(.5)).add(1).mul(at(1/Math.PI)).mul(i.pow(F_))),$V=Kt(({lightDirection:i})=>{const e=i.add(Go).normalize(),t=po.dot(e).clamp(),n=Go.dot(e).clamp(),s=i0({f0:Tc,f90:1,dotVH:n}),o=WV(),a=HV({dotNH:t});return s.mul(o).mul(a)});class bN extends _N{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const o=po.dot(e).clamp().mul(t);n.directDiffuse.addAssign(o.mul(vm({diffuseColor:no.rgb}))),this.specular===!0&&n.directSpecular.addAssign(o.mul($V({lightDirection:e})).mul(Tv))}indirect(e){const{ambientOcclusion:t,irradiance:n,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(n.mul(vm({diffuseColor:no}))),s.indirectDiffuse.mulAssign(t)}}const jV=new my;class XV extends xa{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(jV),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new mS(t):null}setupLightingModel(){return new bN(!1)}}const qV=new fy;class YV extends xa{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(qV),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new mS(t):null}setupLightingModel(){return new bN}setupVariants(){const e=(this.shininessNode?at(this.shininessNode):w2).max(1e-4);F_.assign(e);const t=this.specularNode||S2;Tc.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const wN=Kt(i=>{if(i.geometry.hasAttribute("normal")===!1)return at(0);const e=Zg.dFdx().abs().max(Zg.dFdy().abs());return e.x.max(e.y).max(e.z)}),gS=Kt(i=>{const{roughness:e}=i,t=wN();let n=e.max(.0525);return n=n.add(t),n=n.min(1),n}),MN=Kt(({alpha:i,dotNL:e,dotNV:t})=>{const n=i.pow2(),s=e.mul(n.add(n.oneMinus().mul(t.pow2())).sqrt()),o=t.mul(n.add(n.oneMinus().mul(e.pow2())).sqrt());return Yc(.5,s.add(o).max(XC))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),ZV=Kt(({alphaT:i,alphaB:e,dotTV:t,dotBV:n,dotTL:s,dotBL:o,dotNV:a,dotNL:c})=>{const u=c.mul(Xt(i.mul(t),e.mul(n),a).length()),d=a.mul(Xt(i.mul(s),e.mul(o),c).length());return Yc(.5,u.add(d)).saturate()}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),SN=Kt(({alpha:i,dotNH:e})=>{const t=i.pow2(),n=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(n.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),KV=at(1/Math.PI),JV=Kt(({alphaT:i,alphaB:e,dotNH:t,dotTH:n,dotBH:s})=>{const o=i.mul(e),a=Xt(e.mul(n),i.mul(s),o.mul(t)),c=a.dot(a),u=o.div(c);return KV.mul(o.mul(u.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),yS=Kt(({lightDirection:i,f0:e,f90:t,roughness:n,f:s,normalView:o=po,USE_IRIDESCENCE:a,USE_ANISOTROPY:c})=>{const u=n.pow2(),d=i.add(Go).normalize(),p=o.dot(i).clamp(),m=o.dot(Go).clamp(),y=o.dot(d).clamp(),M=Go.dot(d).clamp();let T=i0({f0:e,f90:t,dotVH:M}),G,z;if(rv(a)&&(T=D_.mix(T,s)),rv(c)){const I=cv.dot(i),J=cv.dot(Go),K=cv.dot(d),re=dm.dot(i),ve=dm.dot(Go),me=dm.dot(d);G=ZV({alphaT:O_,alphaB:u,dotTV:J,dotBV:ve,dotTL:I,dotBL:re,dotNV:m,dotNL:p}),z=JV({alphaT:O_,alphaB:u,dotNH:y,dotTH:K,dotBH:me})}else G=MN({alpha:u,dotNL:p,dotNV:m}),z=SN({alpha:u,dotNH:y});return T.mul(G).mul(z)}),vS=Kt(({roughness:i,dotNV:e})=>{const t=Bi(-1,-.0275,-.572,.022),n=Bi(1,.0425,1.04,-.04),s=i.mul(t).add(n),o=s.x.mul(s.x).min(e.mul(-9.28).exp2()).mul(s.x).add(s.y);return Bn(-1.04,1.04).mul(o).add(s.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),TN=Kt(i=>{const{dotNV:e,specularColor:t,specularF90:n,roughness:s}=i,o=vS({dotNV:e,roughness:s});return t.mul(o.x).add(n.mul(o.y))}),EN=Kt(({f:i,f90:e,dotVH:t})=>{const n=t.oneMinus().saturate(),s=n.mul(n),o=n.mul(s,s).clamp(0,.9999);return i.sub(Xt(e).mul(o)).div(o.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),QV=Kt(({roughness:i,dotNH:e})=>{const t=i.pow2(),n=at(1).div(t),o=e.pow2().oneMinus().max(.0078125);return at(2).add(n).mul(o.pow(n.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),e5=Kt(({dotNV:i,dotNL:e})=>at(1).div(at(4).mul(e.add(i).sub(e.mul(i))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),t5=Kt(({lightDirection:i})=>{const e=i.add(Go).normalize(),t=po.dot(i).clamp(),n=po.dot(Go).clamp(),s=po.dot(e).clamp(),o=QV({roughness:L_,dotNH:s}),a=e5({dotNV:n,dotNL:t});return hm.mul(o).mul(a)}),n5=Kt(({N:i,V:e,roughness:t})=>{const o=.0078125,a=i.dot(e).saturate(),c=Bn(t,a.oneMinus().sqrt());return c.assign(c.mul(.984375).add(o)),c}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),AN=Kt(({f:i})=>{const e=i.length();return va(e.mul(e).add(i.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),Yf=Kt(({v1:i,v2:e})=>{const t=i.dot(e),n=t.abs().toVar(),s=n.mul(.0145206).add(.4965155).mul(n).add(.8543985).toVar(),o=n.add(4.1616724).mul(n).add(3.417594).toVar(),a=s.div(o),c=t.greaterThan(0).select(a,va(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return i.cross(e).mul(c)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),CN=Kt(({N:i,V:e,P:t,mInv:n,p0:s,p1:o,p2:a,p3:c})=>{const u=o.sub(s).toVar(),d=c.sub(s).toVar(),p=u.cross(d),m=Xt().toVar();return sr(p.dot(t.sub(s)).greaterThanEqual(0),()=>{const y=e.sub(i.mul(e.dot(i))).normalize(),M=i.cross(y).negate(),T=n.mul($l(y,M,i).transpose()).toVar(),G=T.mul(s.sub(t)).normalize().toVar(),z=T.mul(o.sub(t)).normalize().toVar(),I=T.mul(a.sub(t)).normalize().toVar(),J=T.mul(c.sub(t)).normalize().toVar(),K=Xt(0).toVar();K.addAssign(Yf({v1:G,v2:z})),K.addAssign(Yf({v1:z,v2:I})),K.addAssign(Yf({v1:I,v2:J})),K.addAssign(Yf({v1:J,v2:G})),m.assign(Xt(AN({f:K})))}),m}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),i5=Kt(({P:i,p0:e,p1:t,p2:n,p3:s})=>{const o=t.sub(e).toVar(),a=s.sub(e).toVar(),c=o.cross(a),u=Xt().toVar();return sr(c.dot(i.sub(e)).greaterThanEqual(0),()=>{const d=e.sub(i).normalize().toVar(),p=t.sub(i).normalize().toVar(),m=n.sub(i).normalize().toVar(),y=s.sub(i).normalize().toVar(),M=Xt(0).toVar();M.addAssign(Yf({v1:d,v2:p})),M.addAssign(Yf({v1:p,v2:m})),M.addAssign(Yf({v1:m,v2:y})),M.addAssign(Yf({v1:y,v2:d})),u.assign(Xt(AN({f:M.abs()})))}),u}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"P",type:"vec3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),ub=1/6,RN=i=>Jr(ub,Jr(i,Jr(i,i.negate().add(3)).sub(3)).add(1)),xS=i=>Jr(ub,Jr(i,Jr(i,Jr(3,i).sub(6))).add(4)),NN=i=>Jr(ub,Jr(i,Jr(i,Jr(-3,i).add(3)).add(3)).add(1)),_S=i=>Jr(ub,Tu(i,3)),PN=i=>RN(i).add(xS(i)),IN=i=>NN(i).add(_S(i)),LN=i=>$a(-1,xS(i).div(RN(i).add(xS(i)))),DN=i=>$a(1,_S(i).div(NN(i).add(_S(i)))),ON=(i,e,t)=>{const n=i.uvNode,s=Jr(n,e.zw).add(.5),o=kh(s),a=Bd(s),c=PN(a.x),u=IN(a.x),d=LN(a.x),p=DN(a.x),m=LN(a.y),y=DN(a.y),M=Bn(o.x.add(d),o.y.add(m)).sub(.5).mul(e.xy),T=Bn(o.x.add(p),o.y.add(m)).sub(.5).mul(e.xy),G=Bn(o.x.add(d),o.y.add(y)).sub(.5).mul(e.xy),z=Bn(o.x.add(p),o.y.add(y)).sub(.5).mul(e.xy),I=PN(a.y).mul($a(c.mul(i.sample(M).level(t)),u.mul(i.sample(T).level(t)))),J=IN(a.y).mul($a(c.mul(i.sample(G).level(t)),u.mul(i.sample(z).level(t))));return I.add(J)},bS=Kt(([i,e])=>{const t=Bn(i.size(Dt(e))),n=Bn(i.size(Dt(e.add(1)))),s=Yc(1,t),o=Yc(1,n),a=ON(i,Bi(s,t),kh(e)),c=ON(i,Bi(o,n),V_(e));return Bd(e).mix(a,c)}),r5=Kt(([i,e])=>{const t=e.mul(BM(i));return bS(i,t)}),FN=Kt(([i,e,t,n,s])=>{const o=Xt(CM(e.negate(),Fd(i),Yc(1,n))),a=Xt(zh(s[0].xyz),zh(s[1].xyz),zh(s[2].xyz));return Fd(o).mul(t.mul(a))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),s5=Kt(([i,e])=>i.mul(Eu(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),o5=lS(),a5=lS(),BN=Kt(([i,e,t],{material:n})=>{const o=(n.side===Y?o5:a5).sample(i),a=Bh(pm.x).mul(s5(e,t));return bS(o,a)}),UN=Kt(([i,e,t])=>(sr(t.notEqual(0),()=>{const n=z_(e).negate().div(t);return xM(n.negate().mul(i))}),Xt(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),l5=Kt(([i,e,t,n,s,o,a,c,u,d,p,m,y,M,T])=>{let G,z;if(T){G=Bi().toVar(),z=Xt().toVar();const ve=p.sub(1).mul(T.mul(.025)),me=Xt(p.sub(ve),p,p.add(ve));mo({start:0,end:3},({i:Le})=>{const Ve=me.element(Le),Ee=FN(i,e,m,Ve,c),Oe=a.add(Ee),dt=d.mul(u.mul(Bi(Oe,1))),Ut=Bn(dt.xy.div(dt.w)).toVar();Ut.addAssign(1),Ut.divAssign(2),Ut.assign(Bn(Ut.x,Ut.y.oneMinus()));const tn=BN(Ut,t,Ve);G.element(Le).assign(tn.element(Le)),G.a.addAssign(tn.a),z.element(Le).assign(n.element(Le).mul(UN(zh(Ee),y,M).element(Le)))}),G.a.divAssign(3)}else{const ve=FN(i,e,m,p,c),me=a.add(ve),Le=d.mul(u.mul(Bi(me,1))),Ve=Bn(Le.xy.div(Le.w)).toVar();Ve.addAssign(1),Ve.divAssign(2),Ve.assign(Bn(Ve.x,Ve.y.oneMinus())),G=BN(Ve,t,p),z=n.mul(UN(zh(ve),y,M))}const I=z.rgb.mul(G.rgb),J=i.dot(e).clamp(),K=Xt(TN({dotNV:J,specularColor:s,specularF90:o,roughness:t})),re=z.r.add(z.g,z.b).div(3);return Bi(K.oneMinus().mul(I),G.a.oneMinus().mul(re).oneMinus())}),c5=$l(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),u5=i=>{const e=i.sqrt();return Xt(1).add(e).div(Xt(1).sub(e))},kN=(i,e)=>i.sub(e).div(i.add(e)).pow2(),h5=(i,e)=>{const t=i.mul(2*Math.PI*1e-9),n=Xt(54856e-17,44201e-17,52481e-17),s=Xt(1681e3,1795300,2208400),o=Xt(43278e5,93046e5,66121e5),a=at(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let c=n.mul(o.mul(2*Math.PI).sqrt()).mul(s.mul(t).add(e).cos()).mul(t.pow2().negate().mul(o).exp());return c=Xt(c.x.add(a),c.y,c.z).div(10685e-11),c5.mul(c)},d5=Kt(({outsideIOR:i,eta2:e,cosTheta1:t,thinFilmThickness:n,baseF0:s})=>{const o=$s(i,e,Au(0,.03,n)),c=i.div(o).pow2().mul(t.pow2().oneMinus()).oneMinus();sr(c.lessThan(0),()=>Xt(1));const u=c.sqrt(),d=kN(o,i),p=i0({f0:d,f90:1,dotVH:t}),m=p.oneMinus(),y=o.lessThan(i).select(Math.PI,0),M=at(Math.PI).sub(y),T=u5(s.clamp(0,.9999)),G=kN(T,o.toVec3()),z=i0({f0:G,f90:1,dotVH:u}),I=Xt(T.x.lessThan(o).select(Math.PI,0),T.y.lessThan(o).select(Math.PI,0),T.z.lessThan(o).select(Math.PI,0)),J=o.mul(n,u,2),K=Xt(M).add(I),re=p.mul(z).clamp(1e-5,.9999),ve=re.sqrt(),me=m.pow2().mul(z).div(Xt(1).sub(re)),Ve=p.add(me).toVar(),Ee=me.sub(m).toVar();return mo({start:1,end:2,condition:"<=",name:"m"},({m:Oe})=>{Ee.mulAssign(ve);const dt=h5(at(Oe).mul(J),at(Oe).mul(K)).mul(2);Ve.addAssign(Ee.mul(dt))}),Ve.max(Xt(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),f5=Kt(({normal:i,viewDir:e,roughness:t})=>{const n=i.dot(e).saturate(),s=t.pow2(),o=Sl(t.lessThan(.25),at(-339.2).mul(s).add(at(161.4).mul(t)).sub(25.9),at(-8.48).mul(s).add(at(14.3).mul(t)).sub(9.95)),a=Sl(t.lessThan(.25),at(44).mul(s).sub(at(23.7).mul(t)).add(3.26),at(1.97).mul(s).sub(at(3.27).mul(t)).add(.72));return Sl(t.lessThan(.25),0,at(.1).mul(t).sub(.025)).add(o.mul(n).add(a).exp()).mul(1/Math.PI).saturate()}),wS=Xt(.04),MS=at(1);class zN extends cb{constructor(e=!1,t=!1,n=!1,s=!1,o=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=s,this.transmission=o,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=Xt().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=Xt().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=Xt().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=Xt().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=Xt().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=po.dot(Go).clamp();this.iridescenceFresnel=d5({outsideIOR:at(1),eta2:uM,cosTheta1:t,thinFilmThickness:hM,baseF0:Tc}),this.iridescenceF0=EN({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=Jc,n=Mv.sub(Jc).normalize(),s=Xf,o=e.context;o.backdrop=l5(s,n,Fh,no,Tc,uv,t,Nu,Kc,Cu,dv,dM,pM,fM,this.dispersion?mM:null),o.backdropAlpha=B_,no.a.mulAssign($s(1,o.backdrop.a,B_))}super.start(e)}computeMultiscattering(e,t,n){const s=po.dot(Go).clamp(),o=vS({roughness:Fh,dotNV:s}),c=(this.iridescenceF0?D_.mix(Tc,this.iridescenceF0):Tc).mul(o.x).add(n.mul(o.y)),d=o.x.add(o.y).oneMinus(),p=Tc.add(Tc.oneMinus().mul(.047619)),m=c.mul(p).div(d.mul(p).oneMinus());e.addAssign(c),t.addAssign(m.mul(d))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const o=po.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(o.mul(t5({lightDirection:e}))),this.clearcoat===!0){const c=mm.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(c.mul(yS({lightDirection:e,f0:wS,f90:MS,roughness:lv,normalView:mm})))}n.directDiffuse.addAssign(o.mul(vm({diffuseColor:no.rgb}))),n.directSpecular.addAssign(o.mul(yS({lightDirection:e,f0:Tc,f90:1,roughness:Fh,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:s,reflectedLight:o,ltc_1:a,ltc_2:c}){const u=t.add(n).sub(s),d=t.sub(n).sub(s),p=t.sub(n).add(s),m=t.add(n).add(s),y=po,M=Go,T=Da.toVar(),G=n5({N:y,V:M,roughness:Fh}),z=a.sample(G).toVar(),I=c.sample(G).toVar(),J=$l(Xt(z.x,0,z.y),Xt(0,1,0),Xt(z.z,0,z.w)).toVar(),K=Tc.mul(I.x).add(Tc.oneMinus().mul(I.y)).toVar();o.directSpecular.addAssign(e.mul(K).mul(CN({N:y,V:M,P:T,mInv:J,p0:u,p1:d,p2:p,p3:m}))),o.directDiffuse.addAssign(e.mul(no).mul(CN({N:y,V:M,P:T,mInv:$l(1,0,0,0,1,0,0,0,1),p0:u,p1:d,p2:p,p3:m})))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:n}=e.context;n.indirectDiffuse.addAssign(t.mul(vm({diffuseColor:no})))}indirectSpecular(e){const{radiance:t,iblIrradiance:n,reflectedLight:s}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(n.mul(hm,f5({normal:po,viewDir:Go,roughness:L_}))),this.clearcoat===!0){const p=mm.dot(Go).clamp(),m=TN({dotNV:p,specularColor:wS,specularF90:MS,roughness:lv});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(m))}const o=Xt().toVar("singleScattering"),a=Xt().toVar("multiScattering"),c=n.mul(1/Math.PI);this.computeMultiscattering(o,a,uv);const u=o.add(a),d=no.mul(u.r.max(u.g).max(u.b).oneMinus());s.indirectSpecular.addAssign(t.mul(o)),s.indirectSpecular.addAssign(a.mul(c)),s.indirectDiffuse.addAssign(d.mul(c))}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:n}=e.context,o=po.dot(Go).clamp().add(t),a=Fh.mul(-16).oneMinus().negate().exp2(),c=t.sub(o.pow(a).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(t),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(t),n.indirectDiffuse.mulAssign(t),n.indirectSpecular.mulAssign(c)}finish({context:e}){const{outgoingLight:t}=e;if(this.clearcoat===!0){const n=mm.dot(Go).clamp(),s=i0({dotVH:n,f0:wS,f90:MS}),o=t.mul(I_.mul(s).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(I_));t.assign(o)}if(this.sheen===!0){const n=hm.r.max(hm.g).max(hm.b).mul(.157).oneMinus(),s=t.mul(n).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(s)}}}const VN=at(1),SS=at(-2),hb=at(.8),TS=at(-1),db=at(.4),ES=at(2),fb=at(.305),AS=at(3),GN=at(.21),p5=at(4),WN=at(4),m5=at(16),g5=Kt(([i])=>{const e=Xt(Fo(i)).toVar(),t=at(-1).toVar();return sr(e.x.greaterThan(e.z),()=>{sr(e.x.greaterThan(e.y),()=>{t.assign(Sl(i.x.greaterThan(0),0,3))}).Else(()=>{t.assign(Sl(i.y.greaterThan(0),1,4))})}).Else(()=>{sr(e.z.greaterThan(e.y),()=>{t.assign(Sl(i.z.greaterThan(0),2,5))}).Else(()=>{t.assign(Sl(i.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),y5=Kt(([i,e])=>{const t=Bn().toVar();return sr(e.equal(0),()=>{t.assign(Bn(i.z,i.y).div(Fo(i.x)))}).ElseIf(e.equal(1),()=>{t.assign(Bn(i.x.negate(),i.z.negate()).div(Fo(i.y)))}).ElseIf(e.equal(2),()=>{t.assign(Bn(i.x.negate(),i.y).div(Fo(i.z)))}).ElseIf(e.equal(3),()=>{t.assign(Bn(i.z.negate(),i.y).div(Fo(i.x)))}).ElseIf(e.equal(4),()=>{t.assign(Bn(i.x.negate(),i.z).div(Fo(i.y)))}).Else(()=>{t.assign(Bn(i.x,i.y).div(Fo(i.z)))}),Jr(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),v5=Kt(([i])=>{const e=at(0).toVar();return sr(i.greaterThanEqual(hb),()=>{e.assign(VN.sub(i).mul(TS.sub(SS)).div(VN.sub(hb)).add(SS))}).ElseIf(i.greaterThanEqual(db),()=>{e.assign(hb.sub(i).mul(ES.sub(TS)).div(hb.sub(db)).add(TS))}).ElseIf(i.greaterThanEqual(fb),()=>{e.assign(db.sub(i).mul(AS.sub(ES)).div(db.sub(fb)).add(ES))}).ElseIf(i.greaterThanEqual(GN),()=>{e.assign(fb.sub(i).mul(p5.sub(AS)).div(fb.sub(GN)).add(AS))}).Else(()=>{e.assign(at(-2).mul(Bh(Jr(1.16,i))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),HN=Kt(([i,e])=>{const t=i.toVar();t.assign(Jr(2,t).sub(1));const n=Xt(t,1).toVar();return sr(e.equal(0),()=>{n.assign(n.zyx)}).ElseIf(e.equal(1),()=>{n.assign(n.xzy),n.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{n.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{n.assign(n.zyx),n.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{n.assign(n.xzy),n.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{n.z.mulAssign(-1)}),n}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),$N=Kt(([i,e,t,n,s,o])=>{const a=at(t),c=Xt(e),u=Eu(v5(a),SS,o),d=Bd(u),p=kh(u),m=Xt(CS(i,c,p,n,s,o)).toVar();return sr(d.notEqual(0),()=>{const y=Xt(CS(i,c,p.add(1),n,s,o)).toVar();m.assign($s(m,y,d))}),m}),CS=Kt(([i,e,t,n,s,o])=>{const a=at(t).toVar(),c=Xt(e),u=at(g5(c)).toVar(),d=at(va(WN.sub(a),0)).toVar();a.assign(va(a,WN));const p=at(jg(a)).toVar(),m=Bn(y5(c,u).mul(p.sub(2)).add(1)).toVar();return sr(u.greaterThan(2),()=>{m.y.addAssign(p),u.subAssign(3)}),m.x.addAssign(u.mul(p)),m.x.addAssign(d.mul(Jr(3,m5))),m.y.addAssign(Jr(4,jg(o).sub(p))),m.x.mulAssign(n),m.y.mulAssign(s),i.sample(m).grad(Bn(),Bn())}),RS=Kt(({envMap:i,mipInt:e,outputDirection:t,theta:n,axis:s,CUBEUV_TEXEL_WIDTH:o,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:c})=>{const u=Ud(n),d=t.mul(u).add(s.cross(t).mul(Zc(n))).add(s.mul(s.dot(t).mul(u.oneMinus())));return CS(i,d,e,o,a,c)}),jN=Kt(({n:i,latitudinal:e,poleAxis:t,outputDirection:n,weights:s,samples:o,dTheta:a,mipInt:c,envMap:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:m})=>{const y=Xt(Sl(e,t,H_(t,n))).toVar();sr(y.equal(Xt(0)),()=>{y.assign(Xt(n.z,0,n.x.negate()))}),y.assign(Fd(y));const M=Xt().toVar();return M.addAssign(s.element(0).mul(RS({theta:0,axis:y,outputDirection:n,mipInt:c,envMap:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:m}))),mo({start:Dt(1),end:i},({i:T})=>{sr(T.greaterThanEqual(o),()=>{tN()});const G=at(a.mul(at(T))).toVar();M.addAssign(s.element(T).mul(RS({theta:G.mul(-1),axis:y,outputDirection:n,mipInt:c,envMap:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:m}))),M.addAssign(s.element(T).mul(RS({theta:G,axis:y,outputDirection:n,mipInt:c,envMap:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:m})))}),Bi(M,1)}),r0=4,XN=[.125,.215,.35,.446,.526,.582],xm=20,NS=new Df(-1,1,1,-1,0,1),x5=new ma(90,1),qN=new jn;let PS=null,IS=0,LS=0;const _m=(1+Math.sqrt(5))/2,s0=1/_m,YN=[new it(-_m,s0,0),new it(_m,s0,0),new it(-s0,0,_m),new it(s0,0,_m),new it(0,_m,-s0),new it(0,_m,s0),new it(-1,1,-1),new it(1,1,-1),new it(-1,1,1),new it(1,1,1)],_5=new it,ZN=new WeakMap,b5=[3,1,5,0,4,2],DS=HN(xo(),oc("faceIndex")).normalize(),OS=Xt(DS.x,DS.y,DS.z);class w5{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,s=100,o={}){const{size:a=256,position:c=_5,renderTarget:u=null}=o;if(this._setSize(a),this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const p=u||this._allocateTarget();return o.renderTarget=p,this.fromSceneAsync(e,t,n,s,o),p}PS=this._renderer.getRenderTarget(),IS=this._renderer.getActiveCubeFace(),LS=this._renderer.getActiveMipmapLevel();const d=u||this._allocateTarget();return d.depthBuffer=!0,this._init(d),this._sceneToCubeUV(e,n,s,d,c),t>0&&this._blur(d,0,0,t),this._applyPMREM(d),this._cleanup(d),d}fromSceneAsync(a){return hr(this,arguments,function*(e,t=0,n=.1,s=100,o={}){return this._hasInitialized===!1&&(yield this._renderer.init()),this.fromScene(e,t,n,s,o)})}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTarget();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}fromEquirectangularAsync(e,t=null){return hr(this,null,function*(){return this._hasInitialized===!1&&(yield this._renderer.init()),this._fromTexture(e,t)})}fromCubemap(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTarget();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}fromCubemapAsync(e,t=null){return hr(this,null,function*(){return this._hasInitialized===!1&&(yield this._renderer.init()),this._fromTexture(e,t)})}compileCubemapShader(){return hr(this,null,function*(){this._cubemapMaterial===null&&(this._cubemapMaterial=JN(),yield this._compileMaterial(this._cubemapMaterial))})}compileEquirectangularShader(){return hr(this,null,function*(){this._equirectMaterial===null&&(this._equirectMaterial=QN(),yield this._compileMaterial(this._equirectMaterial))})}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===De||e.mapping===We?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_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(PS,IS,LS),e.scissorTest=!1,pb(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),PS=this._renderer.getRenderTarget(),IS=this._renderer.getActiveCubeFace(),LS=this._renderer.getActiveMipmapLevel();const n=t||this._allocateTarget();return this._init(n),this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTarget(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize;return KN(e,t)}_init(e){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=KN(e.width,e.height);const{_lodMax:t}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=M5(t)),this._blurMaterial=S5(t,e.width,e.height)}}_compileMaterial(e){return hr(this,null,function*(){const t=new Ks(this._lodPlanes[0],e);yield this._renderer.compile(t,NS)})}_sceneToCubeUV(e,t,n,s,o){const a=x5;a.near=t,a.far=n;const c=[1,1,1,1,-1,1],u=[1,-1,1,-1,1,-1],d=this._renderer,p=d.autoClear;d.getClearColor(qN),d.autoClear=!1;let m=this._backgroundBox;if(m===null){const T=new Hr({name:"PMREM.Background",side:Y,depthWrite:!1,depthTest:!1});m=new Ks(new Uc,T)}let y=!1;const M=e.background;M?M.isColor&&(m.material.color.copy(M),e.background=null,y=!0):(m.material.color.copy(qN),y=!0),d.setRenderTarget(s),d.clear(),y&&d.render(m,a);for(let T=0;T<6;T++){const G=T%3;G===0?(a.up.set(0,c[T],0),a.position.set(o.x,o.y,o.z),a.lookAt(o.x+u[T],o.y,o.z)):G===1?(a.up.set(0,0,c[T]),a.position.set(o.x,o.y,o.z),a.lookAt(o.x,o.y+u[T],o.z)):(a.up.set(0,c[T],0),a.position.set(o.x,o.y,o.z),a.lookAt(o.x,o.y,o.z+u[T]));const z=this._cubeSize;pb(s,G*z,T>2?z:0,z,z),d.render(e,a)}d.autoClear=p,e.background=M}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===De||e.mapping===We;s?this._cubemapMaterial===null&&(this._cubemapMaterial=JN(e)):this._equirectMaterial===null&&(this._equirectMaterial=QN(e));const o=s?this._cubemapMaterial:this._equirectMaterial;o.fragmentNode.value=e;const a=this._lodMeshes[0];a.material=o;const c=this._cubeSize;pb(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,NS)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const s=this._lodPlanes.length;for(let o=1;o<s;o++){const a=Math.sqrt(this._sigmas[o]*this._sigmas[o]-this._sigmas[o-1]*this._sigmas[o-1]),c=YN[(s-o-1)%YN.length];this._blur(e,o-1,o,a,c)}t.autoClear=n}_blur(e,t,n,s,o){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,s,"latitudinal",o),this._halfBlur(a,e,n,n,s,"longitudinal",o)}_halfBlur(e,t,n,s,o,a,c){const u=this._renderer,d=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const p=3,m=this._lodMeshes[s];m.material=d;const y=ZN.get(d),M=this._sizeLods[n]-1,T=isFinite(o)?Math.PI/(2*M):2*Math.PI/(2*xm-1),G=o/T,z=isFinite(o)?1+Math.floor(p*G):xm;z>xm&&console.warn(`sigmaRadians, ${o}, is too large and will clip, as it requested ${z} samples when the maximum is set to ${xm}`);const I=[];let J=0;for(let Le=0;Le<xm;++Le){const Ve=Le/G,Ee=Math.exp(-Ve*Ve/2);I.push(Ee),Le===0?J+=Ee:Le<z&&(J+=2*Ee)}for(let Le=0;Le<I.length;Le++)I[Le]=I[Le]/J;e.texture.frame=(e.texture.frame||0)+1,y.envMap.value=e.texture,y.samples.value=z,y.weights.array=I,y.latitudinal.value=a==="latitudinal"?1:0,c&&(y.poleAxis.value=c);const{_lodMax:K}=this;y.dTheta.value=T,y.mipInt.value=K-n;const re=this._sizeLods[s],ve=3*re*(s>K-r0?s-K+r0:0),me=4*(this._cubeSize-re);pb(t,ve,me,3*re,2*re),u.setRenderTarget(t),u.render(m,NS)}}function M5(i){const e=[],t=[],n=[],s=[];let o=i;const a=i-r0+1+XN.length;for(let c=0;c<a;c++){const u=Math.pow(2,o);t.push(u);let d=1/u;c>i-r0?d=XN[c-i+r0-1]:c===0&&(d=0),n.push(d);const p=1/(u-2),m=-p,y=1+p,M=[m,m,y,m,y,y,m,m,y,y,m,y],T=6,G=6,z=3,I=2,J=1,K=new Float32Array(z*G*T),re=new Float32Array(I*G*T),ve=new Float32Array(J*G*T);for(let Le=0;Le<T;Le++){const Ve=Le%3*2/3-1,Ee=Le>2?0:-1,Oe=[Ve,Ee,0,Ve+2/3,Ee,0,Ve+2/3,Ee+1,0,Ve,Ee,0,Ve+2/3,Ee+1,0,Ve,Ee+1,0],dt=b5[Le];K.set(Oe,z*G*dt),re.set(M,I*G*dt);const Ut=[dt,dt,dt,dt,dt,dt];ve.set(Ut,J*G*dt)}const me=new xr;me.setAttribute("position",new es(K,z)),me.setAttribute("uv",new es(re,I)),me.setAttribute("faceIndex",new es(ve,J)),e.push(me),s.push(new Ks(me,null)),o>r0&&o--}return{lodPlanes:e,sizeLods:t,sigmas:n,lodMeshes:s}}function KN(i,e){const t={magFilter:Rn,minFilter:Rn,generateMipmaps:!1,type:Gs,format:D,colorSpace:ou},n=new Ja(i,e,t);return n.texture.mapping=qe,n.texture.name="PMREM.cubeUv",n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function pb(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function FS(i){const e=new xa;return e.depthTest=!1,e.depthWrite=!1,e.blending=pe,e.name=`PMREM_${i}`,e}function S5(i,e,t){const n=jl(new Array(xm).fill(0)),s=cr(new it(0,1,0)),o=cr(0),a=at(xm),c=cr(0),u=cr(1),d=Is(null),p=cr(0),m=at(1/e),y=at(1/t),M=at(i),T={n:a,latitudinal:c,weights:n,poleAxis:s,outputDirection:OS,dTheta:o,samples:u,envMap:d,mipInt:p,CUBEUV_TEXEL_WIDTH:m,CUBEUV_TEXEL_HEIGHT:y,CUBEUV_MAX_MIP:M},G=FS("blur");return G.fragmentNode=jN(cc(Ys({},T),{latitudinal:c.equal(1)})),ZN.set(G,T),G}function JN(i){const e=FS("cubemap");return e.fragmentNode=Kg(i,OS),e}function QN(i){const e=FS("equirect");return e.fragmentNode=Is(i,pS(OS),0),e}const eP=new WeakMap;function T5(i){const e=Math.log2(i)-2,t=1/i;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:t,maxMip:e}}function E5(i,e,t){const n=A5(e);let s=n.get(i);if((s!==void 0?s.pmremVersion:-1)!==i.pmremVersion){const a=i.image;if(i.isCubeTexture)if(R5(a))s=t.fromCubemap(i,s);else return null;else if(N5(a))s=t.fromEquirectangular(i,s);else return null;s.pmremVersion=i.pmremVersion,n.set(i,s)}return s.texture}function A5(i){let e=eP.get(i);return e===void 0&&(e=new WeakMap,eP.set(i,e)),e}class C5 extends Pa{static get type(){return"PMREMNode"}constructor(e,t=null,n=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;const s=new Ho;s.isRenderTargetTexture=!0,this._texture=Is(s),this._width=cr(0),this._height=cr(0),this._maxMip=cr(0),this.updateBeforeType=ss.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=T5(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const n=t?t.pmremVersion:-1,s=this._value;n!==s.pmremVersion&&(s.isPMREMTexture===!0?t=s:t=E5(s,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new w5(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this)),t=XM.mul(Xt(t.x,t.y.negate(),t.z));let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),$N(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}}function R5(i){if(i==null)return!1;let e=0;const t=6;for(let n=0;n<t;n++)i[n]!==void 0&&e++;return e===t}function N5(i){return i==null?!1:i.height>0}const BS=Vr(C5).setParameterLength(1,3),tP=new WeakMap;class P5 extends Qg{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){const m=n.isTextureNode?n.value:t[n.property];let y=tP.get(m);y===void 0&&(y=BS(m),tP.set(m,y)),n=y}const o=t.useAnisotropy===!0||t.anisotropy>0?x2:po,a=n.context(nP(Fh,o)).mul(K_),c=n.context(I5(Xf)).mul(Math.PI).mul(K_),u=vv(a),d=vv(c);e.context.radiance.addAssign(u),e.context.iblIrradiance.addAssign(d);const p=e.context.lightingModel.clearcoatRadiance;if(p){const m=n.context(nP(lv,mm)).mul(K_),y=vv(m);p.addAssign(y)}}}const nP=(i,e)=>{let t=null;return{getUV:()=>(t===null&&(t=Go.negate().reflect(e),t=i.mul(i).mix(t,e).normalize(),t=t.transformDirection(Kc)),t),getTextureLevel:()=>i}},I5=i=>({getUV:()=>i,getTextureLevel:()=>at(1)}),L5=new Wp;class iP extends xa{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(L5),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new P5(t):null}setupLightingModel(){return new zN}setupSpecular(){const e=$s(Xt(.04),no.rgb,av);Tc.assign(e),uv.assign(1)}setupVariants(){const e=this.metalnessNode?at(this.metalnessNode):A2;av.assign(e);let t=this.roughnessNode?at(this.roughnessNode):E2;t=gS({roughness:t}),Fh.assign(t),this.setupSpecular(),no.assign(Bi(no.rgb.mul(e.oneMinus()),no.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const D5=new Ox;class O5 extends iP{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(D5),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?at(this.iorNode):V2;dv.assign(e),Tc.assign($s(Ec(TM(dv.sub(1).div(dv.add(1))).mul(T2),Xt(1)).mul(eS),no.rgb,av)),uv.assign($s(eS,1,av))}setupLightingModel(){return new zN(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?at(this.clearcoatNode):R2,n=this.clearcoatRoughnessNode?at(this.clearcoatRoughnessNode):N2;I_.assign(t),lv.assign(gS({roughness:n}))}if(this.useSheen){const t=this.sheenNode?Xt(this.sheenNode):L2,n=this.sheenRoughnessNode?at(this.sheenRoughnessNode):D2;hm.assign(t),L_.assign(n)}if(this.useIridescence){const t=this.iridescenceNode?at(this.iridescenceNode):F2,n=this.iridescenceIORNode?at(this.iridescenceIORNode):B2,s=this.iridescenceThicknessNode?at(this.iridescenceThicknessNode):U2;D_.assign(t),uM.assign(n),hM.assign(s)}if(this.useAnisotropy){const t=(this.anisotropyNode?Bn(this.anisotropyNode):O2).toVar();Wf.assign(t.length()),sr(Wf.equal(0),()=>{t.assign(Bn(1,0))}).Else(()=>{t.divAssign(Bn(Wf)),Wf.assign(Wf.saturate())}),O_.assign(Wf.pow2().mix(Fh.pow2(),1)),cv.assign(gm[0].mul(t.x).add(gm[1].mul(t.y))),dm.assign(gm[1].mul(t.x).sub(gm[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?at(this.transmissionNode):k2,n=this.thicknessNode?at(this.thicknessNode):z2,s=this.attenuationDistanceNode?at(this.attenuationDistanceNode):G2,o=this.attenuationColorNode?Xt(this.attenuationColorNode):W2;if(B_.assign(t),dM.assign(n),fM.assign(s),pM.assign(o),this.useDispersion){const a=this.dispersionNode?at(this.dispersionNode):$2;mM.assign(a)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?Xt(this.clearcoatNormalNode):P2}setup(e){e.context.setupClearcoatNormal=()=>Xg(this.setupClearcoatNormal(e),"NORMAL","vec3"),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class F5 extends null{constructor(e=!1,t=!1,n=!1,s=!1,o=!1,a=!1,c=!1){super(e,t,n,s,o,a),this.useSSS=c}direct({lightDirection:e,lightColor:t,reflectedLight:n},s){if(this.useSSS===!0){const o=s.material,{thicknessColorNode:a,thicknessDistortionNode:c,thicknessAmbientNode:u,thicknessAttenuationNode:d,thicknessPowerNode:p,thicknessScaleNode:m}=o,y=e.add(po.mul(c)).normalize(),M=at(Go.dot(y.negate()).saturate().pow(p).mul(m)),T=Xt(M.add(u).mul(a));n.directDiffuse.addAssign(T.mul(d.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:n},s)}}class pZ extends null{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=at(.1),this.thicknessAmbientNode=at(0),this.thicknessAttenuationNode=at(.1),this.thicknessPowerNode=at(2),this.thicknessScaleNode=at(10)}get useSSS(){return this.thicknessColorNode!==null}setupLightingModel(){return new F5(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const B5=Kt(({normal:i,lightDirection:e,builder:t})=>{const n=i.dot(e),s=Bn(n.mul(.5).add(.5),0);if(t.material.gradientMap){const o=$d("gradientMap","texture").context({getUV:()=>s});return Xt(o.r)}else{const o=s.fwidth().mul(.5);return $s(Xt(.7),Xt(1),Au(at(.7).sub(o.x),at(.7).add(o.x),s.x))}});class U5 extends cb{direct({lightDirection:e,lightColor:t,reflectedLight:n},s){const o=B5({normal:Z_,lightDirection:e,builder:s}).mul(t);n.directDiffuse.addAssign(o.mul(vm({diffuseColor:no.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:n,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(n.mul(vm({diffuseColor:no}))),s.indirectDiffuse.mulAssign(t)}}const k5=new py;class z5 extends xa{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(k5),this.setValues(e)}setupLightingModel(){return new U5}}const rP=Kt(()=>{const i=Xt(Go.z,0,Go.x.negate()).normalize(),e=Go.cross(i);return Bn(i.dot(po),e.dot(po)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),V5=new gy;class G5 extends xa{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(V5),this.setValues(e)}setupVariants(e){const t=rP;let n;e.material.matcap?n=$d("matcap","texture").context({getUV:()=>t}):n=Xt($s(.2,.8,t.y)),no.rgb.mulAssign(n.rgb)}}class W5 extends Pa{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:n}=this;if(this.getNodeType(e)==="vec2"){const o=t.cos(),a=t.sin();return P_(o,a,a.negate(),o).mul(n)}else{const o=t,a=um(Bi(1,0,0,0),Bi(0,Ud(o.x),Zc(o.x).negate(),0),Bi(0,Zc(o.x),Ud(o.x),0),Bi(0,0,0,1)),c=um(Bi(Ud(o.y),0,Zc(o.y),0),Bi(0,1,0,0),Bi(Zc(o.y).negate(),0,Ud(o.y),0),Bi(0,0,0,1)),u=um(Bi(Ud(o.z),Zc(o.z).negate(),0,0),Bi(Zc(o.z),Ud(o.z),0,0),Bi(0,0,1,0),Bi(0,0,0,1));return a.mul(c).mul(u).mul(Bi(n,1)).xyz}}}const Av=Vr(W5).setParameterLength(2),H5=new mp;class sP extends xa{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(H5),this.setValues(e)}setupPositionView(e){const{object:t,camera:n}=e,{positionNode:s,rotationNode:o,scaleNode:a,sizeAttenuation:c}=this,u=Hd.mul(Xt(s||0));let d=Bn(Nu[0].xyz.length(),Nu[1].xyz.length());a!==null&&(d=d.mul(Bn(a))),n.isPerspectiveCamera&&c===!1&&(d=d.mul(u.z.negate()));let p=Ll.xy;if(t.center&&t.center.isVector2===!0){const M=jz("center","vec2",t);p=p.sub(M.sub(.5))}p=p.mul(d);const m=at(o||I2),y=Av(p,m);return Bi(u.xy.add(y),u.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const $5=new gf,j5=new yn;class X5 extends sP{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues($5),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return Hd.mul(Xt(e||La)).xyz}setupVertexSprite(e){const{material:t,camera:n}=e,{rotationNode:s,scaleNode:o,sizeNode:a,sizeAttenuation:c}=this;let u=super.setupVertex(e);if(t.isNodeMaterial!==!0)return u;let d=a!==null?Bn(a):H2;d=d.mul(HR),n.isPerspectiveCamera&&c===!0&&(d=d.mul(q5.div(Da.z.negate()))),o&&o.isNode&&(d=d.mul(Bn(o)));let p=Ll.xy;if(s&&s.isNode){const m=at(s);p=Av(p,m)}return p=p.mul(d),p=p.div(zM.div(2)),p=p.mul(u.w),u=u.add(Bi(p,0,0)),u}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const q5=cr(1).onFrameUpdate(function({renderer:i}){const e=i.getSize(j5);this.value=.5*e.y});class Y5 extends cb{constructor(){super(),this.shadowNode=at(1).toVar("shadowMask")}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){no.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(no.rgb)}}const Z5=new yg;class K5 extends xa{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(Z5),this.setValues(e)}setupLightingModel(){return new Y5}}const Cv=oh("vec3"),oP=oh("vec3"),aP=oh("vec3");class J5 extends null{constructor(){super()}start(e){const{material:t,context:n}=e,s=oh("vec3"),o=oh("vec3");sr(Mv.sub(Jc).length().greaterThan(qR.mul(2)),()=>{s.assign(Mv),o.assign(Jc)}).Else(()=>{s.assign(Jc),o.assign(Mv)});const a=o.sub(s),c=cr("int").onRenderUpdate(({material:y})=>y.steps),u=a.length().div(c).toVar(),d=a.normalize().toVar(),p=at(0).toVar(),m=Xt(1).toVar();t.offsetNode&&p.addAssign(t.offsetNode.mul(u)),mo(c,()=>{const y=s.add(d.mul(p)),M=Kc.mul(Bi(y,1)).xyz;t.depthNode!==null&&(oP.assign(n0(uS(M.z,Gd,Wd))),n.sceneDepthNode=n0(t.depthNode).toVar()),n.positionWorld=y,n.shadowPositionWorld=y,n.positionView=M,Cv.assign(0);let T;t.scatteringNode&&(T=t.scatteringNode({positionRay:y})),super.start(e),T&&Cv.mulAssign(T);const G=Cv.mul(.01).negate().mul(u).exp();m.mulAssign(G),p.addAssign(u)}),aP.addAssign(m.saturate().oneMinus())}scatteringLight(e,t){const n=t.context.sceneDepthNode;n?sr(n.greaterThanEqual(oP),()=>{Cv.addAssign(e)}):Cv.addAssign(e)}direct({lightNode:e,lightColor:t},n){if(e.light.distance===void 0)return;const s=t.xyz.toVar();s.mulAssign(e.shadowNode),this.scatteringLight(s,n)}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:s},o){const a=t.add(n).sub(s),c=t.sub(n).sub(s),u=t.sub(n).add(s),d=t.add(n).add(s),p=o.context.positionView,m=e.xyz.mul(i5({P:p,p0:a,p1:c,p2:u,p3:d})).pow(1.5);this.scatteringLight(m,o)}finish(e){e.context.outgoingLight.assign(aP)}}class mZ extends null{static get type(){return"VolumeNodeMaterial"}constructor(e){super(),this.isVolumeNodeMaterial=!0,this.steps=25,this.offsetNode=null,this.scatteringNode=null,this.lights=!0,this.transparent=!0,this.side=BackSide,this.depthTest=!1,this.depthWrite=!1,this.setValues(e)}setupLightingModel(){return new J5}}class Q5{constructor(e,t){this.nodes=e,this.info=t,this._context=typeof self!="undefined"?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,n)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this._animationLoop!==null&&this._animationLoop(t,n)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class ah{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let n=this.weakMap;for(let s=0;s<e.length-1;s++){const o=e[s];n.has(o)===!1&&n.set(o,new WeakMap),n=n.get(o)}return n.set(e[e.length-1],t),this}delete(e){let t=this.weakMap;for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return!1;return t.delete(e[e.length-1])}}let eG=0;function tG(i){const e=Object.keys(i);let t=Object.getPrototypeOf(i);for(;t;){const n=Object.getOwnPropertyDescriptors(t);for(const s in n)if(n[s]!==void 0){const o=n[s];o&&typeof o.get=="function"&&e.push(s)}t=Object.getPrototypeOf(t)}return e}class nG{constructor(e,t,n,s,o,a,c,u,d,p){this.id=eG++,this._nodes=e,this._geometries=t,this.renderer=n,this.object=s,this.material=o,this.scene=a,this.camera=c,this.lightsNode=u,this.context=d,this.geometry=s.geometry,this.version=o.version,this.drawRange=null,this.attributes=null,this.attributesId=null,this.pipeline=null,this.group=null,this.vertexBuffers=null,this.drawParams=null,this.bundle=null,this.clippingContext=p,this.clippingContextCacheKey=p!==null?p.cacheKey:"",this.initialNodesCacheKey=this.getDynamicCacheKey(),this.initialCacheKey=this.getCacheKey(),this._nodeBuilderState=null,this._bindings=null,this._monitor=null,this.onDispose=null,this.isRenderObject=!0,this.onMaterialDispose=()=>{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener("dispose",this.onMaterialDispose),this.geometry.addEventListener("dispose",this.onGeometryDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.material.hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(this.attributes!==null)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,n=[],s=new Set,o={};for(const a of e){let c;if(a.node&&a.node.attribute?c=a.node.attribute:(c=t.getAttribute(a.name),o[a.name]=c.version),c===void 0)continue;n.push(c);const u=c.isInterleavedBufferAttribute?c.data:c;s.add(u)}return this.attributes=n,this.attributesId=o,this.vertexBuffers=Array.from(s.values()),n}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:n,group:s,drawRange:o}=this,a=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),c=this.getIndex(),u=c!==null;let d=1;if(n.isInstancedBufferGeometry===!0?d=n.instanceCount:e.count!==void 0&&(d=Math.max(0,e.count)),d===0)return null;if(a.instanceCount=d,e.isBatchedMesh===!0)return a;let p=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(p=2);let m=o.start*p,y=(o.start+o.count)*p;s!==null&&(m=Math.max(m,s.start*p),y=Math.min(y,(s.start+s.count)*p));const M=n.attributes.position;let T=1/0;u?T=c.count:M!=null&&(T=M.count),m=Math.max(m,0),y=Math.min(y,T);const G=y-m;return G<0||G===1/0?null:(a.vertexCount=G,a.firstVertex=m,a)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const n of Object.keys(e.attributes).sort()){const s=e.attributes[n];t+=n+",",s.data&&(t+=s.data.stride+","),s.offset&&(t+=s.offset+","),s.itemSize&&(t+=s.itemSize+","),s.normalized&&(t+="n,")}for(const n of Object.keys(e.morphAttributes).sort()){const s=e.morphAttributes[n];t+="morph-"+n+",";for(let o=0,a=s.length;o<a;o++){const c=s[o];t+=c.id+","}}return e.index&&(t+="index,"),t}getMaterialCacheKey(){const{object:e,material:t,renderer:n}=this;let s=t.customProgramCacheKey();for(const o of tG(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(o))continue;const a=t[o];let c;if(a!==null){const u=typeof a;u==="number"?c=a!==0?"1":"0":u==="object"?(c="{",a.isTexture&&(c+=a.mapping,n.backend.isWebGPUBackend===!0&&(c+=a.magFilter,c+=a.minFilter,c+=a.wrapS,c+=a.wrapT,c+=a.wrapR)),c+="}"):c=String(a)}else c=String(a);s+=c+","}return s+=this.clippingContextCacheKey+",",e.geometry&&(s+=this.getGeometryCacheKey()),e.skeleton&&(s+=e.skeleton.bones.length+","),e.isBatchedMesh&&(s+=e._matricesTexture.uuid+",",e._colorsTexture!==null&&(s+=e._colorsTexture.uuid+",")),(e.isInstancedMesh||e.count>1)&&(s+=e.uuid+","),s+=e.receiveShadow+",",Xw(s)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(this.attributes!==null){const e=this.attributesId;for(const t in e){const n=this.geometry.getAttribute(t);if(n===void 0||e[t]!==n.id)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return this.material.isShadowPassMaterial!==!0&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=Qy(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Qy(e,1)),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this.onDispose()}}const bm=[];class iG{constructor(e,t,n,s,o,a){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=s,this.bindings=o,this.info=a,this.chainMaps={}}get(e,t,n,s,o,a,c,u){const d=this.getChainMap(u);bm[0]=e,bm[1]=t,bm[2]=a,bm[3]=o;let p=d.get(bm);return p===void 0?(p=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,s,o,a,c,u),d.set(bm,p)):(p.updateClipping(c),p.needsGeometryUpdate&&p.setGeometry(e.geometry),(p.version!==t.version||p.needsUpdate)&&(p.initialCacheKey!==p.getCacheKey()?(p.dispose(),p=this.get(e,t,n,s,o,a,c,u)):p.version=t.version)),bm.length=0,p}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new ah)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,s,o,a,c,u,d,p,m){const y=this.getChainMap(m),M=new nG(e,t,n,s,o,a,c,u,d,p);return M.onDispose=()=>{this.pipelines.delete(M),this.bindings.delete(M),this.nodes.delete(M),y.delete(M.getChainArray())},M}}class Zf{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const Iu={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},Kf=16,rG=211,sG=212;class oG extends Zf{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return t!==null&&this.backend.destroyAttribute(e),t}update(e,t){const n=this.get(e);if(n.version===void 0)t===Iu.VERTEX?this.backend.createAttribute(e):t===Iu.INDEX?this.backend.createIndexAttribute(e):t===Iu.STORAGE?this.backend.createStorageAttribute(e):t===Iu.INDIRECT&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{const s=this._getBufferAttribute(e);(n.version<s.version||s.usage===nf)&&(this.backend.updateAttribute(e),n.version=s.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}function lP(i){return i.index!==null?i.index.version:i.attributes.position.version}function cP(i){const e=[],t=i.index,n=i.attributes.position;if(t!==null){const o=t.array;for(let a=0,c=o.length;a<c;a+=3){const u=o[a+0],d=o[a+1],p=o[a+2];e.push(u,d,d,p,p,u)}}else{const o=n.array;for(let a=0,c=o.length/3-1;a<c;a+=3){const u=a+0,d=a+1,p=a+2;e.push(u,d,d,p,p,u)}}const s=new(hp(e)?gc:Va)(e,1);return s.version=lP(i),s}class aG extends Zf{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap}has(e){const t=e.geometry;return super.has(t)&&this.get(t).initialized===!0}updateForRender(e){this.has(e)===!1&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){const t=e.geometry,n=this.get(t);n.initialized=!0,this.info.memory.geometries++;const s=()=>{this.info.memory.geometries--;const o=t.index,a=e.getAttributes();o!==null&&this.attributes.delete(o);for(const u of a)this.attributes.delete(u);const c=this.wireframes.get(t);c!==void 0&&this.attributes.delete(c),t.removeEventListener("dispose",s)};t.addEventListener("dispose",s)}updateAttributes(e){const t=e.getAttributes();for(const o of t)o.isStorageBufferAttribute||o.isStorageInstancedBufferAttribute?this.updateAttribute(o,Iu.STORAGE):this.updateAttribute(o,Iu.VERTEX);const n=this.getIndex(e);n!==null&&this.updateAttribute(n,Iu.INDEX);const s=e.geometry.indirect;s!==null&&this.updateAttribute(s,Iu.INDIRECT)}updateAttribute(e,t){const n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:n}=e;let s=t.index;if(n.wireframe===!0){const o=this.wireframes;let a=o.get(t);a===void 0?(a=cP(t),o.set(t,a)):a.version!==lP(t)&&(this.attributes.delete(a),a=cP(t),o.set(t,a)),s=a}return s}}class lG{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=n*(t/3):e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=n*(t/2):e.isLine?this.render.lines+=n*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class uP{constructor(e){this.cacheKey=e,this.usedTimes=0}}class cG extends uP{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}}class uG extends uP{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let hG=0;class US{constructor(e,t,n,s=null,o=null){this.id=hG++,this.code=e,this.stage=t,this.name=n,this.transforms=s,this.attributes=o,this.usedTimes=0}}class dG extends Zf{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:n}=this,s=this.get(e);if(this._needsComputeUpdate(e)){const o=s.pipeline;o&&(o.usedTimes--,o.computeProgram.usedTimes--);const a=this.nodes.getForCompute(e);let c=this.programs.compute.get(a.computeShader);c===void 0&&(o&&o.computeProgram.usedTimes===0&&this._releaseProgram(o.computeProgram),c=new US(a.computeShader,"compute",e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,c),n.createProgram(c));const u=this._getComputeCacheKey(e,c);let d=this.caches.get(u);d===void 0&&(o&&o.usedTimes===0&&this._releasePipeline(o),d=this._getComputePipeline(e,c,u,t)),d.usedTimes++,c.usedTimes++,s.version=e.version,s.pipeline=d}return s.pipeline}getForRender(e,t=null){const{backend:n}=this,s=this.get(e);if(this._needsRenderUpdate(e)){const o=s.pipeline;o&&(o.usedTimes--,o.vertexProgram.usedTimes--,o.fragmentProgram.usedTimes--);const a=e.getNodeBuilderState(),c=e.material?e.material.name:"";let u=this.programs.vertex.get(a.vertexShader);u===void 0&&(o&&o.vertexProgram.usedTimes===0&&this._releaseProgram(o.vertexProgram),u=new US(a.vertexShader,"vertex",c),this.programs.vertex.set(a.vertexShader,u),n.createProgram(u));let d=this.programs.fragment.get(a.fragmentShader);d===void 0&&(o&&o.fragmentProgram.usedTimes===0&&this._releaseProgram(o.fragmentProgram),d=new US(a.fragmentShader,"fragment",c),this.programs.fragment.set(a.fragmentShader,d),n.createProgram(d));const p=this._getRenderCacheKey(e,u,d);let m=this.caches.get(p);m===void 0?(o&&o.usedTimes===0&&this._releasePipeline(o),m=this._getRenderPipeline(e,u,d,p,t)):e.pipeline=m,m.usedTimes++,u.usedTimes++,d.usedTimes++,s.pipeline=m}return s.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,n,s){n=n||this._getComputeCacheKey(e,t);let o=this.caches.get(n);return o===void 0&&(o=new uG(n,t),this.caches.set(n,o),this.backend.createComputePipeline(o,s)),o}_getRenderPipeline(e,t,n,s,o){s=s||this._getRenderCacheKey(e,t,n);let a=this.caches.get(s);return a===void 0&&(a=new cG(s,t,n),this.caches.set(s,a),e.pipeline=a,this.backend.createRenderPipeline(e,o)),a}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,n){return t.id+","+n.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,n=e.stage;this.programs[n].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}}class fG extends Zf{constructor(e,t,n,s,o,a){super(),this.backend=e,this.textures=n,this.pipelines=o,this.attributes=s,this.nodes=t,this.info=a,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const n of t){const s=this.get(n);s.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),s.bindGroup=n)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const n of t){const s=this.get(n);s.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),s.bindGroup=n)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const n=t.attribute,s=n.isIndirectStorageBufferAttribute?Iu.INDIRECT:Iu.STORAGE;this.attributes.update(n,s)}}_update(e,t){const{backend:n}=this;let s=!1,o=!0,a=0,c=0;for(const u of e.bindings)if(!(u.isNodeUniformsGroup&&this.nodes.updateGroup(u)===!1)){if(u.isStorageBuffer){const d=u.attribute,p=d.isIndirectStorageBufferAttribute?Iu.INDIRECT:Iu.STORAGE;this.attributes.update(d,p)}if(u.isUniformBuffer)u.update()&&n.updateBinding(u);else if(u.isSampledTexture){const d=u.update(),p=u.texture,m=this.textures.get(p);if(d&&(this.textures.updateTexture(p),u.generation!==m.generation&&(u.generation=m.generation,s=!0,o=!1)),n.get(p).externalTexture!==void 0||m.isDefaultTexture?o=!1:(a=a*10+p.id,c+=p.version),p.isStorageTexture===!0){const M=this.get(p);u.store===!0?M.needsMipmap=!0:this.textures.needsMipmaps(p)&&M.needsMipmap===!0&&(this.backend.generateMipmaps(p),M.needsMipmap=!1)}}else u.isSampler&&u.update()}s===!0&&this.backend.updateBindings(e,t,o?a:0,c)}}function pG(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?i.z-e.z:i.id-e.id}function hP(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function dP(i){return(i.transmission>0||i.transmissionNode)&&i.side===ie&&i.forceSinglePass===!1}class mG{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,n),this.lightsArray=[],this.scene=t,this.camera=n,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,n,s,o,a,c){let u=this.renderItems[this.renderItemsIndex];return u===void 0?(u={id:e.id,object:e,geometry:t,material:n,groupOrder:s,renderOrder:e.renderOrder,z:o,group:a,clippingContext:c},this.renderItems[this.renderItemsIndex]=u):(u.id=e.id,u.object=e,u.geometry=t,u.material=n,u.groupOrder=s,u.renderOrder=e.renderOrder,u.z=o,u.group=a,u.clippingContext=c),this.renderItemsIndex++,u}push(e,t,n,s,o,a,c){const u=this.getNextRenderItem(e,t,n,s,o,a,c);e.occlusionTest===!0&&this.occlusionQueryCount++,n.transparent===!0||n.transmission>0?(dP(n)&&this.transparentDoublePass.push(u),this.transparent.push(u)):this.opaque.push(u)}unshift(e,t,n,s,o,a,c){const u=this.getNextRenderItem(e,t,n,s,o,a,c);n.transparent===!0||n.transmission>0?(dP(n)&&this.transparentDoublePass.unshift(u),this.transparent.unshift(u)):this.opaque.unshift(u)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||pG),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||hP),this.transparent.length>1&&this.transparent.sort(t||hP)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e<t;e++){const n=this.renderItems[e];if(n.id===null)break;n.id=null,n.object=null,n.geometry=null,n.material=null,n.groupOrder=null,n.renderOrder=null,n.z=null,n.group=null,n.clippingContext=null}}}const Rv=[];class gG{constructor(e){this.lighting=e,this.lists=new ah}get(e,t){const n=this.lists;Rv[0]=e,Rv[1]=t;let s=n.get(Rv);return s===void 0&&(s=new mG(this.lighting,e,t),n.set(Rv,s)),Rv.length=0,s}dispose(){this.lists=new ah}}let yG=0;class vG{constructor(){this.id=yG++,this.color=!0,this.clearColor=!0,this.clearColorValue={r:0,g:0,b:0,a:1},this.depth=!0,this.clearDepth=!0,this.clearDepthValue=1,this.stencil=!1,this.clearStencil=!0,this.clearStencilValue=1,this.viewport=!1,this.viewportValue=new mr,this.scissor=!1,this.scissorValue=new mr,this.renderTarget=null,this.textures=null,this.depthTexture=null,this.activeCubeFace=0,this.activeMipmapLevel=0,this.sampleCount=1,this.width=0,this.height=0,this.occlusionQueryCount=0,this.clippingContext=null,this.isRenderContext=!0}getCacheKey(){return fP(this)}}function fP(i){const{textures:e,activeCubeFace:t,activeMipmapLevel:n}=i,s=[t,n];for(const o of e)s.push(o.id);return Jy(s)}const Nv=[],xG=new Km,_G=new Zm;class bG{constructor(){this.chainMaps={}}get(e,t,n=null){Nv[0]=e,Nv[1]=t;let s;if(n===null)s="default";else{const c=n.texture.format;s=`${n.textures.length}:${c}:${n.samples}:${n.depthBuffer}:${n.stencilBuffer}`}const o=this._getChainMap(s);let a=o.get(Nv);return a===void 0&&(a=new vG,o.set(Nv,a)),Nv.length=0,n!==null&&(a.sampleCount=n.samples===0?1:n.samples),a}getForClear(e=null){return this.get(xG,_G,e)}_getChainMap(e){return this.chainMaps[e]||(this.chainMaps[e]=new ah)}dispose(){this.chainMaps={}}}const wG=new it;class MG extends Zf{constructor(e,t,n){super(),this.renderer=e,this.backend=t,this.info=n}updateRenderTarget(e,t=0){const n=this.get(e),s=e.samples===0?1:e.samples,o=n.depthTextureMips||(n.depthTextureMips={}),a=e.textures,c=this.getSize(a[0]),u=c.width>>t,d=c.height>>t;let p=e.depthTexture||o[t];const m=e.depthBuffer===!0||e.stencilBuffer===!0;let y=!1;p===void 0&&m&&(p=new vc,p.format=e.stencilBuffer?_:U,p.type=e.stencilBuffer?Fa:ls,p.image.width=u,p.image.height=d,p.image.depth=c.depth,p.isArrayTexture=e.multiview===!0&&c.depth>1,o[t]=p),(n.width!==c.width||c.height!==n.height)&&(y=!0,p&&(p.needsUpdate=!0,p.image.width=u,p.image.height=d,p.image.depth=p.isArrayTexture?p.image.depth:1)),n.width=c.width,n.height=c.height,n.textures=a,n.depthTexture=p||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==s&&(y=!0,p&&(p.needsUpdate=!0),n.sampleCount=s);const M={sampleCount:s};if(e.isXRRenderTarget!==!0){for(let T=0;T<a.length;T++){const G=a[T];y&&(G.needsUpdate=!0),this.updateTexture(G,M)}p&&this.updateTexture(p,M)}if(n.initialized!==!0){n.initialized=!0;const T=()=>{e.removeEventListener("dispose",T);for(let G=0;G<a.length;G++)this._destroyTexture(a[G]);p&&this._destroyTexture(p),this.delete(e),this.backend.delete(e)};e.addEventListener("dispose",T)}}updateTexture(e,t={}){const n=this.get(e);if(n.initialized===!0&&n.version===e.version)return;const s=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,o=this.backend;if(s&&n.initialized===!0&&(o.destroySampler(e),o.destroyTexture(e)),e.isFramebufferTexture){const d=this.renderer.getRenderTarget();d?e.type=d.texture.type:e.type=Oi}const{width:a,height:c,depth:u}=this.getSize(e);if(t.width=a,t.height=c,t.depth=u,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,a,c):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,s||e.isStorageTexture===!0||e.isExternalTexture===!0)o.createSampler(e),o.createTexture(e,t),n.generation=e.version;else if(n.initialized!==!0&&o.createSampler(e),e.version>0){const p=e.image;if(p===void 0)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(p.complete===!1)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const m=[];for(const y of e.images)m.push(y);t.images=m}else t.image=p;(n.isDefaultTexture===void 0||n.isDefaultTexture===!0)&&(o.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&o.updateTexture(e,t),t.needsMipmaps&&e.mipmaps.length===0&&o.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else o.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;if(n.initialized!==!0){n.initialized=!0,n.generation=e.version,this.info.memory.textures++,e.isVideoTexture&&Ki.getTransfer(e.colorSpace)!==Fi&&console.warn("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace.");const d=()=>{e.removeEventListener("dispose",d),this._destroyTexture(e)};e.addEventListener("dispose",d)}n.version=e.version}getSize(e,t=wG){let n=e.images?e.images[0]:e.image;return n?(n.image!==void 0&&(n=n.image),typeof HTMLVideoElement!="undefined"&&n instanceof HTMLVideoElement?(t.width=n.videoWidth||1,t.height=n.videoHeight||1,t.depth=1):n instanceof VideoFrame?(t.width=n.displayWidth||1,t.height=n.displayHeight||1,t.depth=1):(t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let s;return e.mipmaps.length>0?s=e.mipmaps.length:e.isCompressedTexture===!0?s=1:s=Math.floor(Math.log2(Math.max(t,n)))+1,s}needsMipmaps(e){return e.generateMipmaps===!0||e.mipmaps.length>0}_destroyTexture(e){this.has(e)===!0&&(this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e),this.info.memory.textures--)}}class kS extends jn{constructor(e,t,n,s=1){super(e,t,n),this.a=s}set(e,t,n,s=1){return this.a=s,super.set(e,t,n)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class pP extends fo{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const SG=(i,e)=>Cn(new pP(i,e));class TG extends Wi{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.hasOutput?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.hasOutput?this.outputNode.getMemberType(e,t):"void"}add(e){return e.isNode!==!0?(console.error("THREE.TSL: Invalid node added to stack."),this):(this.nodes.push(e),this)}If(e,t){const n=new Wg(t);return this._currentCond=Sl(e,n),this.add(this._currentCond)}ElseIf(e,t){const n=new Wg(t),s=Sl(e,n);return this._currentCond.elseNode=s,this._currentCond=s,this}Else(e){return this._currentCond.elseNode=new Wg(e),this}Switch(e){return this._expressionNode=Cn(e),this}Case(...e){const t=[];if(e.length>=2)for(let c=0;c<e.length-1;c++)t.push(this._expressionNode.equal(Cn(e[c])));else console.error("THREE.TSL: Invalid parameter length. Case() requires at least two parameters.");const n=e[e.length-1],s=new Wg(n);let o=t[0];for(let c=1;c<t.length;c++)o=o.or(t[c]);const a=Sl(o,s);return this._currentCond===null?(this._currentCond=a,this.add(this._currentCond)):(this._currentCond.elseNode=a,this._currentCond=a,this)}Default(e){return this.Else(e),this}setup(e){const t=e.getNodeProperties(this);let n=0;for(const s of this.getChildren())s.isVarNode&&s.intent===!0&&e.getNodeProperties(s).assign!==!0||(t["node"+n++]=s);return t.outputNode||null}get hasOutput(){return this.outputNode&&this.outputNode.isNode}build(e,...t){const n=e.currentStack,s=R_();ov(this),e.currentStack=this;const o=e.buildStage;for(const c of this.nodes)if(!(c.isVarNode&&c.intent===!0&&e.getNodeProperties(c).assign!==!0)){if(o==="setup")c.build(e);else if(o==="analyze")c.build(e,this);else if(o==="generate"){const u=e.getDataFromNode(c,"any").stages,d=u&&u[e.shaderStage];if(c.isVarNode&&d&&d.length===1&&d[0]&&d[0].isStackNode)continue;c.build(e,"void")}}let a;return this.hasOutput?a=this.outputNode.build(e,...t):a=super.build(e,...t),ov(s),e.currentStack=n,a}}const mb=Vr(TG).setParameterLength(0,1);function EG(i){return Object.entries(i).map(([e,t])=>typeof t=="string"?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})}class AG extends Wi{static get type(){return"StructTypeNode"}constructor(e,t=null){super("struct"),this.membersLayout=EG(e),this.name=t,this.isStructLayoutNode=!0}getLength(){const t=Float32Array.BYTES_PER_ELEMENT;let n=0;for(const s of this.membersLayout){const o=s.type,a=eC(o)*t,c=tC(o),u=n%8,d=u%c,p=u+d;n+=d,p!==0&&8-p<a&&(n+=8-p),n+=a}return Math.ceil(n/8)*8/t}getMemberType(e,t){const n=this.membersLayout.find(s=>s.name===t);return n?n.type:"void"}getNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}generate(e){return this.getNodeType(e)}}class CG extends Wi{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structTypeNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structTypeNode.getNodeType(e)}getMemberType(e,t){return this.structTypeNode.getMemberType(e,t)}generate(e){const t=e.getVarFromNode(this),n=t.type,s=e.getPropertyName(t);return e.addLineFlowCode(`${s} = ${e.generateStruct(n,this.structTypeNode.membersLayout,this.values)}`,this),t.name}}const RG=(i,e=null)=>{const t=new AG(i,e),n=(...s)=>{let o=null;if(s.length>0)if(s[0].isNode){o={};const a=Object.keys(i);for(let c=0;c<s.length;c++)o[a[c]]=s[c]}else o=s[0];return Cn(new CG(t,o))};return n.layout=t,n.isStruct=!0,n};class mP extends Wi{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(e){const t=e.getNodeProperties(this);if(t.membersLayout===void 0){const n=this.members,s=[];for(let o=0;o<n.length;o++){const a="m"+o,c=n[o].getNodeType(e);s.push({name:a,type:c,index:o})}t.membersLayout=s,t.structType=e.getOutputStructTypeFromNode(this,t.membersLayout)}return t.structType.name}generate(e){const t=e.getOutputStructName(),n=this.members,s=t!==""?t+".":"";for(let o=0;o<n.length;o++){const a=n[o].build(e);e.addLineFlowCode(`${s}m${o} = ${a}`,this)}return t}}const NG=Vr(mP);function gP(i,e){for(let t=0;t<i.length;t++)if(i[t].name===e)return t;return-1}class PG extends mP{static get type(){return"MRTNode"}constructor(e){super(),this.outputNodes=e,this.isMRTNode=!0}has(e){return this.outputNodes[e]!==void 0}get(e){return this.outputNodes[e]}merge(e){const t=Ys(Ys({},this.outputNodes),e.outputNodes);return yP(t)}setup(e){const t=this.outputNodes,n=e.renderer.getRenderTarget(),s=[],o=n.textures;for(const a in t){const c=gP(o,a);s[c]=Bi(t[a])}return this.members=s,super.setup(e)}}const yP=Vr(PG);class Pv extends Pa{static get type(){return"BitcastNode"}constructor(e,t,n=null){super(),this.valueNode=e,this.conversionType=t,this.inputType=n,this.isBitcastNode=!0}getNodeType(e){if(this.inputType!==null){const t=this.valueNode.getNodeType(e),n=e.getTypeLength(t);return e.getTypeFromLength(n,this.conversionType)}return this.conversionType}generate(e){const t=this.getNodeType(e);let n="";if(this.inputType!==null){const s=this.valueNode.getNodeType(e);n=e.getTypeLength(s)===1?this.inputType:e.changeComponentType(s,this.inputType)}else n=this.valueNode.getNodeType(e);return`${e.getBitcastMethod(t,n)}( ${this.valueNode.build(e,n)} )`}}const IG=ci(Pv).setParameterLength(2),LG=i=>new Pv(i,"int","float"),DG=i=>new Pv(i,"uint","float"),OG=i=>new Pv(i,"float","int"),FG=i=>new Pv(i,"float","uint"),BG=Kt(([i])=>{const e=i.toUint().mul(747796405).add(2891336453),t=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return t.shiftRight(22).bitXor(t).toFloat().mul(1/ip(2,32))}),zS=(i,e)=>Tu(Jr(4,i.mul(Os(1,i))),e),UG=(i,e)=>i.lessThan(.5)?zS(i.mul(2),e).div(2):Os(1,zS(Jr(Os(1,i),2),e).div(2)),kG=(i,e,t)=>Tu(Yc(Tu(i,e),$a(Tu(i,e),Tu(Os(1,i),t))),1/e),zG=(i,e)=>Zc(k_.mul(e.mul(i).sub(1))).div(k_.mul(e.mul(i).sub(1))),jd=Kt(([i])=>i.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),VG=Kt(([i])=>Xt(jd(i.z.add(jd(i.y.mul(1)))),jd(i.z.add(jd(i.x.mul(1)))),jd(i.y.add(jd(i.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),GG=Kt(([i,e,t])=>{const n=Xt(i).toVar(),s=at(1.4).toVar(),o=at(0).toVar(),a=Xt(n).toVar();return mo({start:at(0),end:at(3),type:"float",condition:"<="},()=>{const c=Xt(VG(a.mul(2))).toVar();n.addAssign(c.add(t.mul(at(.1).mul(e)))),a.mulAssign(1.8),s.mulAssign(1.5),n.mulAssign(1.2);const u=at(jd(n.z.add(jd(n.x.add(jd(n.y)))))).toVar();o.addAssign(u.div(s)),a.addAssign(.14)}),o}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class WG extends Wi{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let n=this._candidateFnCall;if(n===null){let s=null,o=-1;for(const a of this.functionNodes){const u=a.shaderNode.layout;if(u===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const d=u.inputs;if(t.length===d.length){let p=0;for(let m=0;m<t.length;m++){const y=t[m],M=d[m];y.getNodeType(e)===M.type?p++:p=0}p>o&&(s=a,o=p)}}this._candidateFnCall=n=s(...t)}return n}}const HG=Vr(WG),Dl=i=>(...e)=>HG(i,...e),o0=cr(0).setGroup(or).onRenderUpdate(i=>i.time),$G=cr(0).setGroup(or).onRenderUpdate(i=>i.deltaTime),vP=cr(0,"uint").setGroup(or).onRenderUpdate(i=>i.frameId),jG=(i=o0)=>i.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),XG=(i=o0)=>i.fract().round(),qG=(i=o0)=>i.add(.5).fract().mul(2).sub(1).abs(),YG=(i=o0)=>i.fract(),ZG=Kt(([i,e,t=Bn(.5)])=>Av(i.sub(t),e).add(t)),KG=Kt(([i,e,t=Bn(.5)])=>{const n=i.sub(t),s=n.dot(n),a=s.mul(s).mul(e);return i.add(n.mul(a))}),JG=Kt(({position:i=null,horizontal:e=!0,vertical:t=!1})=>{let n;i!==null?(n=Nu.toVar(),n[3][0]=i.x,n[3][1]=i.y,n[3][2]=i.z):n=Nu;const s=Kc.mul(n);return rv(e)&&(s[0][0]=Nu[0].length(),s[0][1]=0,s[0][2]=0),rv(t)&&(s[1][0]=0,s[1][1]=Nu[1].length(),s[1][2]=0),s[2][0]=0,s[2][1]=0,s[2][2]=1,Cu.mul(s).mul(La)}),QG=Kt(([i=null])=>{const e=n0();return n0(cS(i)).sub(e).lessThan(0).select(Vd,i)});class e6 extends Wi{static get type(){return"SpriteSheetUVNode"}constructor(e,t=xo(),n=at(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=n}setup(){const{frameNode:e,uvNode:t,countNode:n}=this,{width:s,height:o}=n,a=e.mod(s.mul(o)).floor(),c=a.mod(s),u=o.sub(a.add(1).div(s).ceil()),d=n.reciprocal(),p=Bn(c,u);return t.add(p).mul(d)}}const t6=Vr(e6).setParameterLength(3),xP=Kt(([i,e=null,t=null,n=at(1),s=La,o=Ac])=>{let a=o.abs().normalize();a=a.div(a.dot(Xt(1)));const c=s.yz.mul(n),u=s.zx.mul(n),d=s.xy.mul(n),p=i.value,m=e!==null?e.value:p,y=t!==null?t.value:p,M=Is(p,c).mul(a.x),T=Is(m,u).mul(a.y),G=Is(y,d).mul(a.z);return $a(M,T,G)}),n6=(...i)=>xP(...i),a0=new Rl,wm=new it,l0=new it,VS=new it,Iv=new Ft,gb=new it(0,0,-1),Wh=new mr,Lv=new it,yb=new it,Dv=new mr,vb=new yn,xb=new Ja,i6=Vd.flipX();xb.depthTexture=new vc(1,1);let _b=!1;class GS extends Gh{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||xb.texture,i6),this._reflectorBaseNode=e.reflector||new r6(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=Cn(new GS({defaultTexture:xb.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class r6 extends Wi{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:n=new Qr,resolutionScale:s=1,generateMipmaps:o=!1,bounces:a=!0,depth:c=!1,samples:u=0}=t;this.textureNode=e,this.target=n,this.resolutionScale=s,t.resolution!==void 0&&(ll('THREE.ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".'),this.resolutionScale=t.resolution),this.generateMipmaps=o,this.bounces=a,this.depth=c,this.samples=u,this.updateBeforeType=a?ss.RENDER:ss.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const n=this.resolutionScale;t.getDrawingBufferSize(vb),e.setSize(Math.round(vb.width*n),Math.round(vb.height*n))}setup(e){return this._updateResolution(xb,e.renderer),super.setup(e)}dispose(){super.dispose();for(const e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new Ja(0,0,{type:Gs,samples:this.samples}),this.generateMipmaps===!0&&(t.texture.minFilter=Vi,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new vc),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&_b)return!1;_b=!0;const{scene:t,camera:n,renderer:s,material:o}=e,{target:a}=this,c=this.getVirtualCamera(n),u=this.getRenderTarget(c);s.getDrawingBufferSize(vb),this._updateResolution(u,s),l0.setFromMatrixPosition(a.matrixWorld),VS.setFromMatrixPosition(n.matrixWorld),Iv.extractRotation(a.matrixWorld),wm.set(0,0,1),wm.applyMatrix4(Iv),Lv.subVectors(l0,VS);const d=Lv.dot(wm)>0;let p=!1;if(d===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){_b=!1;return}p=!0}Lv.reflect(wm).negate(),Lv.add(l0),Iv.extractRotation(n.matrixWorld),gb.set(0,0,-1),gb.applyMatrix4(Iv),gb.add(VS),yb.subVectors(l0,gb),yb.reflect(wm).negate(),yb.add(l0),c.coordinateSystem=n.coordinateSystem,c.position.copy(Lv),c.up.set(0,1,0),c.up.applyMatrix4(Iv),c.up.reflect(wm),c.lookAt(yb),c.near=n.near,c.far=n.far,c.updateMatrixWorld(),c.projectionMatrix.copy(n.projectionMatrix),a0.setFromNormalAndCoplanarPoint(wm,l0),a0.applyMatrix4(c.matrixWorldInverse),Wh.set(a0.normal.x,a0.normal.y,a0.normal.z,a0.constant);const m=c.projectionMatrix;Dv.x=(Math.sign(Wh.x)+m.elements[8])/m.elements[0],Dv.y=(Math.sign(Wh.y)+m.elements[9])/m.elements[5],Dv.z=-1,Dv.w=(1+m.elements[10])/m.elements[14],Wh.multiplyScalar(1/Wh.dot(Dv));const y=0;m.elements[2]=Wh.x,m.elements[6]=Wh.y,m.elements[10]=s.coordinateSystem===qa?Wh.z-y:Wh.z+1-y,m.elements[14]=Wh.w,this.textureNode.value=u.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=u.depthTexture),o.visible=!1;const M=s.getRenderTarget(),T=s.getMRT(),G=s.autoClear;s.setMRT(null),s.setRenderTarget(u),s.autoClear=!0,p?(s.clear(),this.hasOutput=!1):(s.render(t,c),this.hasOutput=!0),s.setMRT(T),s.setRenderTarget(M),s.autoClear=G,o.visible=!0,_b=!1,this.forceUpdate=!1}get resolution(){return ll('THREE.ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale}set resolution(e){ll('THREE.ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}}const s6=i=>Cn(new GS(i)),WS=new Df(-1,1,1,-1,0,1);class o6 extends xr{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Zi([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Zi(t,2))}}const a6=new o6;class Ov extends Ks{constructor(e=null){super(a6,e),this.camera=WS,this.isQuadMesh=!0}renderAsync(e){return hr(this,null,function*(){return e.renderAsync(this,WS)})}render(e){e.render(this,WS)}}const l6=new yn;class c6 extends Gh{static get type(){return"RTTNode"}constructor(e,t=null,n=null,s={type:Gs}){const o=new Ja(t,n,s);super(o.texture,xo()),this.isRTTNode=!0,this.node=e,this.width=t,this.height=n,this.pixelRatio=1,this.renderTarget=o,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new Ov(new xa),this.updateBeforeType=ss.RENDER}get autoResize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const n=e*this.pixelRatio,s=t*this.pixelRatio;this.renderTarget.setSize(n,s),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoResize===!0){const n=e.getPixelRatio(),s=e.getSize(l6),o=s.width*n,a=s.height*n;(o!==this.renderTarget.width||a!==this.renderTarget.height)&&(this.renderTarget.setSize(o,a),this.textureNeedsUpdate=!0)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new Gh(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const _P=(i,...e)=>Cn(new c6(Cn(i),...e)),u6=(i,...e)=>i.isSampleNode||i.isTextureNode?i:i.isPassNode?i.getTextureNode():_P(i,...e),c0=Kt(([i,e,t],n)=>{let s;n.renderer.coordinateSystem===qa?(i=Bn(i.x,i.y.oneMinus()).mul(2).sub(1),s=Bi(Xt(i,e),1)):s=Bi(Xt(i.x,i.y.oneMinus(),e).mul(2).sub(1),1);const o=Bi(t.mul(s));return o.xyz.div(o.w)}),h6=Kt(([i,e])=>{const t=e.mul(Bi(i,1)),n=t.xy.div(t.w).mul(.5).add(.5).toVar();return Bn(n.x,n.y.oneMinus())}),d6=Kt(([i,e,t])=>{const n=$f(Ia(e)),s=gl(i.mul(n)).toVar(),o=Ia(e,s).toVar(),a=Ia(e,s.sub(gl(2,0))).toVar(),c=Ia(e,s.sub(gl(1,0))).toVar(),u=Ia(e,s.add(gl(1,0))).toVar(),d=Ia(e,s.add(gl(2,0))).toVar(),p=Ia(e,s.add(gl(0,2))).toVar(),m=Ia(e,s.add(gl(0,1))).toVar(),y=Ia(e,s.sub(gl(0,1))).toVar(),M=Ia(e,s.sub(gl(0,2))).toVar(),T=Fo(Os(at(2).mul(c).sub(a),o)).toVar(),G=Fo(Os(at(2).mul(u).sub(d),o)).toVar(),z=Fo(Os(at(2).mul(m).sub(p),o)).toVar(),I=Fo(Os(at(2).mul(y).sub(M),o)).toVar(),J=c0(i,o,t).toVar(),K=T.lessThan(G).select(J.sub(c0(i.sub(Bn(at(1).div(n.x),0)),c,t)),J.negate().add(c0(i.add(Bn(at(1).div(n.x),0)),u,t))),re=z.lessThan(I).select(J.sub(c0(i.add(Bn(0,at(1).div(n.y))),m,t)),J.negate().add(c0(i.sub(Bn(0,at(1).div(n.y))),y,t)));return Fd(H_(K,re))});class f6 extends Wi{static get type(){return"SampleNode"}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(xo())}sample(e){return this.callback(e)}}const p6=(i,e=null)=>Cn(new f6(i,Cn(e)));class Jf extends Wi{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===Jf.OBJECT?this.updateType=ss.OBJECT:e===Jf.MATERIAL&&(this.updateType=ss.RENDER)}update(e){this.callback(e)}}Jf.OBJECT="object",Jf.MATERIAL="material";const bP=(i,e)=>Cn(new Jf(i,e)).toStack(),m6=i=>bP(Jf.OBJECT,i),g6=i=>bP(Jf.MATERIAL,i);class y6 extends Vc{constructor(e,t,n=Float32Array){const s=ArrayBuffer.isView(e)?e:new n(e*t);super(s,t),this.isStorageInstancedBufferAttribute=!0}}class v6 extends es{constructor(e,t,n=Float32Array){const s=ArrayBuffer.isView(e)?e:new n(e*t);super(s,t),this.isStorageBufferAttribute=!0}}const x6=(i,e="float")=>{let t,n;e.isStruct===!0?(t=e.layout.getLength(),n=tv("float")):(t=Zw(e),n=tv(e));const s=new v6(i,t,n);return ym(s,e,i)},_6=(i,e="float")=>{let t,n;e.isStruct===!0?(t=e.layout.getLength(),n=tv("float")):(t=Zw(e),n=tv(e));const s=new y6(i,t,n);return ym(s,e,i)};class b6 extends Wi{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const w6=xi(b6),Fv=new Qi,HS=new Ft;class Rc extends Wi{static get type(){return"SceneNode"}constructor(e=Rc.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,n=this.scene!==null?this.scene:e.scene;let s;return t===Rc.BACKGROUND_BLURRINESS?s=Po("backgroundBlurriness","float",n):t===Rc.BACKGROUND_INTENSITY?s=Po("backgroundIntensity","float",n):t===Rc.BACKGROUND_ROTATION?s=cr("mat4").setName("backgroundRotation").setGroup(or).onRenderUpdate(()=>{const o=n.background;return o!==null&&o.isTexture&&o.mapping!==Q?(Fv.copy(n.backgroundRotation),Fv.x*=-1,Fv.y*=-1,Fv.z*=-1,HS.makeRotationFromEuler(Fv)):HS.identity(),HS}):console.error("THREE.SceneNode: Unknown scope:",t),s}}Rc.BACKGROUND_BLURRINESS="backgroundBlurriness",Rc.BACKGROUND_INTENSITY="backgroundIntensity",Rc.BACKGROUND_ROTATION="backgroundRotation";const wP=xi(Rc,Rc.BACKGROUND_BLURRINESS),$S=xi(Rc,Rc.BACKGROUND_INTENSITY),MP=xi(Rc,Rc.BACKGROUND_ROTATION);class M6 extends Gh{static get type(){return"StorageTextureNode"}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=Il.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}generate(e,t){let n;return this.storeNode!==null?n=this.generateStore(e):n=super.generate(e,t),n}toReadWrite(){return this.setAccess(Il.READ_WRITE)}toReadOnly(){return this.setAccess(Il.READ_ONLY)}toWriteOnly(){return this.setAccess(Il.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:n,storeNode:s,depthNode:o}=t,a=super.generate(e,"property"),c=n.build(e,this.value.is3DTexture===!0?"uvec3":"uvec2"),u=s.build(e,"vec4"),d=o?o.build(e,"int"):null,p=e.generateTextureStore(e,a,c,d,u);e.addLineFlowCode(p,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e}}const SP=Vr(M6).setParameterLength(1,3),S6=(i,e,t)=>{const n=SP(i,e,t);return t!==null&&n.toStack(),n},T6=Kt(({texture:i,uv:e})=>{const n=Xt().toVar();return sr(e.x.lessThan(1e-4),()=>{n.assign(Xt(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{n.assign(Xt(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{n.assign(Xt(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{n.assign(Xt(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{n.assign(Xt(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{n.assign(Xt(0,0,-1))}).Else(()=>{const o=i.sample(e.add(Xt(-.01,0,0))).r.sub(i.sample(e.add(Xt(.01,0,0))).r),a=i.sample(e.add(Xt(0,-.01,0))).r.sub(i.sample(e.add(Xt(0,.01,0))).r),c=i.sample(e.add(Xt(0,0,-.01))).r.sub(i.sample(e.add(Xt(0,0,.01))).r);n.assign(Xt(o,a,c))}),n.normalize()});class E6 extends Gh{static get type(){return"Texture3DNode"}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return Xt(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(Dt($f(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}generateOffset(e,t){return t.build(e,"ivec3")}normal(e){return T6({texture:this,uv:e})}}const TP=Vr(E6).setParameterLength(1,3);class A6 extends J_{static get type(){return"UserDataNode"}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const C6=(i,e,t)=>Cn(new A6(i,e,t)),EP=new WeakMap;class R6 extends Pa{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=ss.OBJECT,this.updateAfterType=ss.OBJECT,this.previousModelWorldMatrix=cr(new Ft),this.previousProjectionMatrix=cr(new Ft).setGroup(or),this.previousCameraViewMatrix=cr(new Ft)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){const s=CP(n);this.previousModelWorldMatrix.value.copy(s);const o=AP(t);o.frameId!==e&&(o.frameId=e,o.previousProjectionMatrix===void 0?(o.previousProjectionMatrix=new Ft,o.previousCameraViewMatrix=new Ft,o.currentProjectionMatrix=new Ft,o.currentCameraViewMatrix=new Ft,o.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),o.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(o.previousProjectionMatrix.copy(o.currentProjectionMatrix),o.previousCameraViewMatrix.copy(o.currentCameraViewMatrix)),o.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),o.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(o.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(o.previousCameraViewMatrix))}updateAfter({object:e}){CP(e).copy(e.matrixWorld)}setup(){const e=this.projectionMatrix===null?Cu:cr(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(Hd).mul(La),s=this.previousProjectionMatrix.mul(t).mul(Y_),o=n.xy.div(n.w),a=s.xy.div(s.w);return Os(o,a)}}function AP(i){let e=EP.get(i);return e===void 0&&(e={},EP.set(i,e)),e}function CP(i,e=0){const t=AP(i);let n=t[e];return n===void 0&&(t[e]=n=new Ft,t[e].copy(i.matrixWorld)),n}const N6=xi(R6),P6=Kt(([i])=>jS(i.rgb)),I6=Kt(([i,e=at(1)])=>e.mix(jS(i.rgb),i.rgb)),L6=Kt(([i,e=at(1)])=>{const t=$a(i.r,i.g,i.b).div(3),n=i.r.max(i.g.max(i.b)),s=n.sub(t).mul(e).mul(-3);return $s(i.rgb,n,s)}),D6=Kt(([i,e=at(1)])=>{const t=Xt(.57735,.57735,.57735),n=e.cos();return Xt(i.rgb.mul(n).add(t.cross(i.rgb).mul(e.sin()).add(t.mul(Hf(t,i.rgb).mul(n.oneMinus())))))}),jS=(i,e=Xt(Ki.getLuminanceCoefficients(new it)))=>Hf(i,e),O6=Kt(([i,e=Xt(1),t=Xt(0),n=Xt(1),s=at(1),o=Xt(Ki.getLuminanceCoefficients(new it,ou))])=>{const a=i.rgb.dot(Xt(o)),c=va(i.rgb.mul(e).add(t),0).toVar(),u=c.pow(n).toVar();return sr(c.r.greaterThan(0),()=>{c.r.assign(u.r)}),sr(c.g.greaterThan(0),()=>{c.g.assign(u.g)}),sr(c.b.greaterThan(0),()=>{c.b.assign(u.b)}),c.assign(a.add(c.sub(a).mul(s))),Bi(c.rgb,i.a)});class F6 extends Pa{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const B6=Vr(F6).setParameterLength(2),bb=new yn;class RP extends Gh{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class NP extends RP{static get type(){return"PassMultipleTextureNode"}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){const e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}}class Hh extends Pa{static get type(){return"PassNode"}constructor(e,t,n,s={}){super("vec4"),this.scope=e,this.scene=t,this.camera=n,this.options=s,this._pixelRatio=1,this._width=1,this._height=1;const o=new vc;o.isRenderTargetTexture=!0,o.name="depth";const a=new Ja(this._width*this._pixelRatio,this._height*this._pixelRatio,Ys({type:Gs},s));a.texture.name="output",a.depthTexture=o,this.renderTarget=a,this._textures={output:a.texture,depth:o},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=cr(0),this._cameraFar=cr(0),this._mrt=null,this._layers=null,this._resolution=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=ss.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const n=this._textures[e],s=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[s]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(t=Cn(new NP(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=Cn(new NP(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const n=this._cameraNear,s=this._cameraFar;this._viewZNodes[e]=t=hS(this.getTextureNode(e),n,s)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const n=this._cameraNear,s=this._cameraFar,o=this.getViewZNode(e);this._linearDepthNodes[e]=t=t0(o,n,s)}return t}compileAsync(e){return hr(this,null,function*(){const t=e.getRenderTarget(),n=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),yield e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(n)})}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,this.renderTarget.texture.type=e.getColorBufferType(),this.scope===Hh.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:n}=this;let s,o;const a=t.getOutputRenderTarget();a&&a.isXRRenderTarget===!0?(o=1,s=t.xr.getCamera(),t.xr.updateCamera(s),bb.set(a.width,a.height)):(s=this.camera,o=t.getPixelRatio(),t.getSize(bb)),this._pixelRatio=o,this.setSize(bb.width,bb.height);const c=t.getRenderTarget(),u=t.getMRT(),d=s.layers.mask;this._cameraNear.value=s.near,this._cameraFar.value=s.far,this._layers!==null&&(s.layers.mask=this._layers.mask);for(const p in this._previousTextures)this.toggleTexture(p);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(n,s),t.setRenderTarget(c),t.setMRT(u),s.layers.mask=d}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio*this._resolution,s=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(n,s),this._scissor!==null&&this.renderTarget.scissor.copy(this._scissor),this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport)}setScissor(e,t,n,s){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new mr),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,n,s),this._scissor.multiplyScalar(this._pixelRatio*this._resolution).floor())}setViewport(e,t,n,s){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new mr),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,n,s),this._viewport.multiplyScalar(this._pixelRatio*this._resolution).floor())}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}Hh.COLOR="color",Hh.DEPTH="depth";const U6=(i,e,t)=>Cn(new Hh(Hh.COLOR,i,e,t)),k6=(i,e)=>Cn(new RP(i,e)),z6=(i,e,t)=>Cn(new Hh(Hh.DEPTH,i,e,t));class V6 extends Hh{static get type(){return"ToonOutlinePassNode"}constructor(e,t,n,s,o){super(Hh.COLOR,e,t),this.colorNode=n,this.thicknessNode=s,this.alphaNode=o,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((s,o,a,c,u,d,p,m)=>{if((u.isMeshToonMaterial||u.isMeshToonNodeMaterial)&&u.wireframe===!1){const y=this._getOutlineMaterial(u);t.renderObject(s,o,a,c,y,d,p,m)}t.renderObject(s,o,a,c,u,d,p,m)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){const e=new xa;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=Y;const t=Ac.negate(),n=Cu.mul(Hd),s=at(1),o=n.mul(Bi(La,1)),a=n.mul(Bi(La.add(t),1)),c=Fd(o.sub(a));return e.vertexNode=o.add(c.mul(this.thicknessNode).mul(o.w).mul(s)),e.colorNode=Bi(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const G6=(i,e,t=new jn(0,0,0),n=.003,s=1)=>Cn(new V6(i,e,Cn(t),Cn(n),Cn(s))),PP=Kt(([i,e])=>i.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),IP=Kt(([i,e])=>(i=i.mul(e),i.div(i.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),LP=Kt(([i,e])=>{i=i.mul(e),i=i.sub(.004).max(0);const t=i.mul(i.mul(6.2).add(.5)),n=i.mul(i.mul(6.2).add(1.7)).add(.06);return t.div(n).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),W6=Kt(([i])=>{const e=i.mul(i.add(.0245786)).sub(90537e-9),t=i.mul(i.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),DP=Kt(([i,e])=>{const t=$l(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),n=$l(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return i=i.mul(e).div(.6),i=t.mul(i),i=W6(i),i=n.mul(i),i.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),H6=$l(Xt(1.6605,-.1246,-.0182),Xt(-.5876,1.1329,-.1006),Xt(-.0728,-.0083,1.1187)),$6=$l(Xt(.6274,.0691,.0164),Xt(.3293,.9195,.088),Xt(.0433,.0113,.8956)),j6=Kt(([i])=>{const e=Xt(i).toVar(),t=Xt(e.mul(e)).toVar(),n=Xt(t.mul(t)).toVar();return at(15.5).mul(n.mul(t)).sub(Jr(40.14,n.mul(e))).add(Jr(31.96,n).sub(Jr(6.868,t.mul(e))).add(Jr(.4298,t).add(Jr(.1191,e).sub(.00232))))}),OP=Kt(([i,e])=>{const t=Xt(i).toVar(),n=$l(Xt(.856627153315983,.137318972929847,.11189821299995),Xt(.0951212405381588,.761241990602591,.0767994186031903),Xt(.0482516061458583,.101439036467562,.811302368396859)),s=$l(Xt(1.1271005818144368,-.1413297634984383,-.14132976349843826),Xt(-.11060664309660323,1.157823702216272,-.11060664309660294),Xt(-.016493938717834573,-.016493938717834257,1.2519364065950405)),o=at(-12.47393),a=at(4.026069);return t.mulAssign(e),t.assign($6.mul(t)),t.assign(n.mul(t)),t.assign(va(t,1e-10)),t.assign(Bh(t)),t.assign(t.sub(o).div(a.sub(o))),t.assign(Eu(t,0,1)),t.assign(j6(t)),t.assign(s.mul(t)),t.assign(Tu(va(Xt(0),t),Xt(2.2))),t.assign(H6.mul(t)),t.assign(Eu(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),FP=Kt(([i,e])=>{const t=at(.76),n=at(.15);i=i.mul(e);const s=Ec(i.r,Ec(i.g,i.b)),o=Sl(s.lessThan(.08),s.sub(Jr(6.25,s.mul(s))),.04);i.subAssign(o);const a=va(i.r,va(i.g,i.b));sr(a.lessThan(t),()=>i);const c=Os(1,t),u=Os(1,c.mul(c).div(a.add(c.sub(t))));i.mulAssign(u.div(a));const d=Os(1,Yc(1,n.mul(a.sub(u)).add(1)));return $s(i,Xt(u),d)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class Xl extends Wi{static get type(){return"CodeNode"}constructor(e="",t=[],n=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=n}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const s of t)s.build(e);const n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const wb=Vr(Xl).setParameterLength(1,3),X6=(i,e)=>wb(i,e,"js"),q6=(i,e)=>wb(i,e,"wgsl"),Y6=(i,e)=>wb(i,e,"glsl");class BP extends Xl{static get type(){return"FunctionNode"}constructor(e="",t=[],n=""){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){const n=this.getNodeType(e);return e.getStructTypeNode(n).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);const n=this.getNodeFunction(e),s=n.name,o=n.type,a=e.getCodeFromNode(this,o);s!==""&&(a.name=s);const c=e.getPropertyName(a),u=this.getNodeFunction(e).getCode(c);return a.code=u+`
|
|
|
`,t==="property"?c:e.format(`${c}()`,o,t)}}const UP=(i,e=[],t="")=>{for(let o=0;o<e.length;o++){const a=e[o];typeof a=="function"&&(e[o]=a.functionNode)}const n=Cn(new BP(i,e,t)),s=(...o)=>n.call(...o);return s.functionNode=n,s},Z6=(i,e)=>UP(i,e,"glsl"),K6=(i,e)=>UP(i,e,"wgsl");class J6 extends Wi{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new Bl,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType==="URL"&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&this._cache===null&&this.inputType==="URL"&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof e.value=="string"||this.inputType==="Number"&&typeof e.value=="number"||this.inputType==="Vector2"&&e.value.isVector2||this.inputType==="Vector3"&&e.value.isVector3||this.inputType==="Vector4"&&e.value.isVector4||this.inputType==="Color"&&e.value.isColor||this.inputType==="Matrix3"&&e.value.isMatrix3||this.inputType==="Matrix4"&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:at()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=Jw(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(e.inputType==="ArrayBuffer"?t=Qw(e.value):e.inputType==="Texture"?t=e.meta.textures[e.value]:t=e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const Mb=Vr(J6).setParameterLength(1);class kP extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){const s=t(...n);return this.set(e,s),s}}}class Q6{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const Sb=new kP;class e8 extends Wi{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new kP,this._output=Mb(null),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const n=this._outputs;return n[e]===void 0?n[e]=Mb(t):n[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const n=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),n[e]=t,n[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),n[e]=t,n[e].events.addEventListener("refresh",this.onRefresh)):n[e]===void 0?(n[e]=Mb(t),n[e].events.addEventListener("refresh",this.onRefresh)):n[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const s=this.getObject()[e];if(typeof s=="function")return s(...t)}callAsync(e,...t){return hr(this,null,function*(){const s=this.getObject()[e];if(typeof s=="function")return s.constructor.name==="AsyncFunction"?yield s(...t):s(...t)})}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e!==null?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;const e=()=>this.refresh(),t=(d,p)=>this.setOutput(d,p),n=new Q6(this),s=Sb.get("THREE"),o=Sb.get("TSL"),a=this.getMethod(),c=[n,this._local,Sb,e,t,s,o];this._object=a(...c);const u=this._object.layout;if(u&&(u.cache===!1&&this._local.clear(),this._output.outputType=u.outputType||null,Array.isArray(u.elements)))for(const d of u.elements){const p=d.id||d.name;d.inputType&&(this.getParameter(p)===void 0&&this.setParameter(p,null),this.getParameter(p).inputType=d.inputType),d.outputType&&(this.getOutput(p)===void 0&&this.setOutput(p,null),this.getOutput(p).outputType=d.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const t in this.parameters){let n=this.parameters[t];n.isScriptableNode&&(n=n.getDefaultOutput()),n.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:at()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;const e=["parameters","local","global","refresh","setOutput","THREE","TSL"],n=["layout","init","main","dispose"].join(", "),s="var "+n+`; var output = {};
|
|
|
`,o=`
|
|
|
return { ...output, `+n+" };",a=s+this.codeNode.code+o;return this._method=new Function(...e,a),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose=="function"&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[Xw(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return Jy(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const t8=Vr(e8).setParameterLength(1,2);function zP(i){let e;const t=i.context.getViewZ;return t!==void 0&&(e=t(this)),(e||Da.z).negate()}const XS=Kt(([i,e],t)=>{const n=zP(t);return Au(i,e,n)}),qS=Kt(([i],e)=>{const t=zP(e);return i.mul(i,t,t).negate().exp().oneMinus()}),Bv=Kt(([i,e])=>Bi(e.toFloat().mix($g.rgb,i.toVec3()),$g.a));function n8(i,e,t){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),Bv(i,XS(e,t))}function i8(i,e){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),Bv(i,qS(e))}let Mm=null,Sm=null;class r8 extends Wi{static get type(){return"RangeNode"}constructor(e=at(),t=at()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Od(this.minNode.value)),n=e.getTypeLength(Od(this.maxNode.value));return t>n?t:n}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let n=null;if(t.count>1){const s=this.minNode.value,o=this.maxNode.value,a=e.getTypeLength(Od(s)),c=e.getTypeLength(Od(o));Mm=Mm||new mr,Sm=Sm||new mr,Mm.setScalar(0),Sm.setScalar(0),a===1?Mm.setScalar(s):s.isColor?Mm.set(s.r,s.g,s.b,1):Mm.set(s.x,s.y,s.z||0,s.w||0),c===1?Sm.setScalar(o):o.isColor?Sm.set(o.r,o.g,o.b,1):Sm.set(o.x,o.y,o.z||0,o.w||0);const u=4,d=u*t.count,p=new Float32Array(d);for(let y=0;y<d;y++){const M=y%u,T=Mm.getComponent(M),G=Sm.getComponent(M);p[y]=ed.lerp(T,G,Math.random())}const m=this.getNodeType(e);if(t.count<=4096)n=xv(p,"vec4",t.count).element(qf).convert(m);else{const y=new Vc(p,4);e.geometry.setAttribute("__range"+this.id,y),n=X_(y).convert(m)}}else n=at(0);return n}}const s8=Vr(r8).setParameterLength(2);class o8 extends Wi{static get type(){return"ComputeBuiltinNode"}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}getNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){return e.hasBuiltin(this._builtinName)}generate(e,t){const n=this.getBuiltinName(e),s=this.getNodeType(e);return e.shaderStage==="compute"?e.format(n,s,t):(console.warn(`ComputeBuiltinNode: Compute built-in value ${n} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(s))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}}const Uv=(i,e)=>Cn(new o8(i,e)),a8=Uv("numWorkgroups","uvec3"),l8=Uv("workgroupId","uvec3"),c8=Uv("globalId","uvec3"),u8=Uv("localId","uvec3"),h8=Uv("subgroupSize","uint");class d8 extends Wi{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier
|
|
|
`):e.addLineFlowCode(`${t}Barrier()`,this)}}const YS=Vr(d8),f8=()=>YS("workgroup").toStack(),p8=()=>YS("storage").toStack(),m8=()=>YS("texture").toStack();class g8 extends lm{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n;const s=e.context.assign;if(n=super.generate(e),s!==!0){const o=this.getNodeType(e);n=e.format(n,o,t)}return n}}class y8 extends Wi{constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=""}setName(e){return this.name=e,this}label(e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return Cn(new g8(this,e))}generate(e){const t=this.name!==""?this.name:`${this.scope}Array_${this.id}`;return e.getScopedArray(t,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const v8=(i,e)=>Cn(new y8("Workgroup",i,e));class yl extends Wi{static get type(){return"AtomicFunctionNode"}constructor(e,t,n){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=n,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),n=t.parents,s=this.method,o=this.getNodeType(e),a=this.getInputType(e),c=this.pointerNode,u=this.valueNode,d=[];d.push(`&${c.build(e,a)}`),u!==null&&d.push(u.build(e,a));const p=`${e.getMethod(s,o)}( ${d.join(", ")} )`;if(n?n.length===1&&n[0].isStackNode===!0:!1)e.addLineFlowCode(p,this);else return t.constNode===void 0&&(t.constNode=kd(p,o).toConst()),t.constNode.build(e)}}yl.ATOMIC_LOAD="atomicLoad",yl.ATOMIC_STORE="atomicStore",yl.ATOMIC_ADD="atomicAdd",yl.ATOMIC_SUB="atomicSub",yl.ATOMIC_MAX="atomicMax",yl.ATOMIC_MIN="atomicMin",yl.ATOMIC_AND="atomicAnd",yl.ATOMIC_OR="atomicOr",yl.ATOMIC_XOR="atomicXor";const x8=Vr(yl),$h=(i,e,t)=>x8(i,e,t).toStack(),_8=i=>$h(yl.ATOMIC_LOAD,i,null),b8=(i,e)=>$h(yl.ATOMIC_STORE,i,e),w8=(i,e)=>$h(yl.ATOMIC_ADD,i,e),M8=(i,e)=>$h(yl.ATOMIC_SUB,i,e),S8=(i,e)=>$h(yl.ATOMIC_MAX,i,e),T8=(i,e)=>$h(yl.ATOMIC_MIN,i,e),E8=(i,e)=>$h(yl.ATOMIC_AND,i,e),A8=(i,e)=>$h(yl.ATOMIC_OR,i,e),C8=(i,e)=>$h(yl.ATOMIC_XOR,i,e);class Ai extends Pa{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,n=null){super(),this.method=e,this.aNode=t,this.bNode=n}getInputType(e){const t=this.aNode?this.aNode.getNodeType(e):null,n=this.bNode?this.bNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),o=e.isMatrix(n)?0:e.getTypeLength(n);return s>o?t:n}getNodeType(e){const t=this.method;return t===Ai.SUBGROUP_ELECT?"bool":t===Ai.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){const n=this.method,s=this.getNodeType(e),o=this.getInputType(e),a=this.aNode,c=this.bNode,u=[];if(n===Ai.SUBGROUP_BROADCAST||n===Ai.SUBGROUP_SHUFFLE||n===Ai.QUAD_BROADCAST){const p=c.getNodeType(e);u.push(a.build(e,s),c.build(e,p==="float"?"int":s))}else n===Ai.SUBGROUP_SHUFFLE_XOR||n===Ai.SUBGROUP_SHUFFLE_DOWN||n===Ai.SUBGROUP_SHUFFLE_UP?u.push(a.build(e,s),c.build(e,"uint")):(a!==null&&u.push(a.build(e,o)),c!==null&&u.push(c.build(e,o)));const d=u.length===0?"()":`( ${u.join(", ")} )`;return e.format(`${e.getMethod(n,s)}${d}`,s,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Ai.SUBGROUP_ELECT="subgroupElect",Ai.SUBGROUP_BALLOT="subgroupBallot",Ai.SUBGROUP_ADD="subgroupAdd",Ai.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd",Ai.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd",Ai.SUBGROUP_MUL="subgroupMul",Ai.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul",Ai.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul",Ai.SUBGROUP_AND="subgroupAnd",Ai.SUBGROUP_OR="subgroupOr",Ai.SUBGROUP_XOR="subgroupXor",Ai.SUBGROUP_MIN="subgroupMin",Ai.SUBGROUP_MAX="subgroupMax",Ai.SUBGROUP_ALL="subgroupAll",Ai.SUBGROUP_ANY="subgroupAny",Ai.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst",Ai.QUAD_SWAP_X="quadSwapX",Ai.QUAD_SWAP_Y="quadSwapY",Ai.QUAD_SWAP_DIAGONAL="quadSwapDiagonal",Ai.SUBGROUP_BROADCAST="subgroupBroadcast",Ai.SUBGROUP_SHUFFLE="subgroupShuffle",Ai.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor",Ai.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp",Ai.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown",Ai.QUAD_BROADCAST="quadBroadcast";const R8=ci(Ai,Ai.SUBGROUP_ELECT).setParameterLength(0),N8=ci(Ai,Ai.SUBGROUP_BALLOT).setParameterLength(1),P8=ci(Ai,Ai.SUBGROUP_ADD).setParameterLength(1),I8=ci(Ai,Ai.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),L8=ci(Ai,Ai.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),D8=ci(Ai,Ai.SUBGROUP_MUL).setParameterLength(1),O8=ci(Ai,Ai.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),F8=ci(Ai,Ai.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),B8=ci(Ai,Ai.SUBGROUP_AND).setParameterLength(1),U8=ci(Ai,Ai.SUBGROUP_OR).setParameterLength(1),k8=ci(Ai,Ai.SUBGROUP_XOR).setParameterLength(1),z8=ci(Ai,Ai.SUBGROUP_MIN).setParameterLength(1),V8=ci(Ai,Ai.SUBGROUP_MAX).setParameterLength(1),G8=ci(Ai,Ai.SUBGROUP_ALL).setParameterLength(0),W8=ci(Ai,Ai.SUBGROUP_ANY).setParameterLength(0),H8=ci(Ai,Ai.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),$8=ci(Ai,Ai.QUAD_SWAP_X).setParameterLength(1),j8=ci(Ai,Ai.QUAD_SWAP_Y).setParameterLength(1),X8=ci(Ai,Ai.QUAD_SWAP_DIAGONAL).setParameterLength(1),q8=ci(Ai,Ai.SUBGROUP_BROADCAST).setParameterLength(2),Y8=ci(Ai,Ai.SUBGROUP_SHUFFLE).setParameterLength(2),Z8=ci(Ai,Ai.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),K8=ci(Ai,Ai.SUBGROUP_SHUFFLE_UP).setParameterLength(2),J8=ci(Ai,Ai.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),Q8=ci(Ai,Ai.QUAD_BROADCAST).setParameterLength(1);let Tb;function Eb(i){Tb=Tb||new WeakMap;let e=Tb.get(i);return e===void 0&&Tb.set(i,e={}),e}function Ab(i){const e=Eb(i);return e.shadowMatrix||(e.shadowMatrix=cr("mat4").setGroup(or).onRenderUpdate(t=>((i.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&i.shadow.updateMatrices(i),i.shadow.matrix)))}function VP(i,e=Jc){const t=Ab(i).mul(e);return t.xyz.div(t.w)}function ZS(i){const e=Eb(i);return e.position||(e.position=cr(new it).setGroup(or).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.matrixWorld)))}function GP(i){const e=Eb(i);return e.targetPosition||(e.targetPosition=cr(new it).setGroup(or).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.target.matrixWorld)))}function KS(i){const e=Eb(i);return e.viewPosition||(e.viewPosition=cr(new it).setGroup(or).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new it,n.value.setFromMatrixPosition(i.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)}))}const JS=i=>Kc.transformDirection(ZS(i).sub(GP(i))),eW=i=>i.sort((e,t)=>e.id-t.id),tW=(i,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===i)return t;return null},QS=new WeakMap,kv=[];class eT extends Wi{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=oh("vec3","totalDiffuse"),this.totalSpecularNode=oh("vec3","totalSpecular"),this.outgoingLightNode=oh("vec3","outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let n=0;n<e.length;n++){const s=e[n];if(kv.push(s.id),kv.push(s.castShadow?1:0),s.isSpotLight===!0){const o=s.map!==null?s.map.id:-1,a=s.colorNode?s.colorNode.getCacheKey():-1;kv.push(o,a)}}const t=Jy(kv);return kv.length=0,t}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);const t=[];for(const n of this._lightNodes)t.push(n.getHash());this._lightNodesHash="lights-"+t.join(",")}return this._lightNodesHash}analyze(e){const t=e.getNodeProperties(this);for(const n of t.nodes)n.build(e);t.outputNode.build(e)}setupLightsNode(e){const t=[],n=this._lightNodes,s=eW(this._lights),o=e.renderer.library;for(const a of s)if(a.isNode)t.push(Cn(a));else{let c=null;if(n!==null&&(c=tW(a.id,n)),c===null){const u=o.getLightNodeClass(a.constructor);if(u===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${a.constructor.name}`);continue}let d=null;QS.has(a)?d=QS.get(a):(d=Cn(new u(a)),QS.set(a,d)),t.push(d)}}this._lightNodes=t}setupDirectLight(e,t,n){const{lightingModel:s,reflectedLight:o}=e.context;s.direct(cc(Ys({},n),{lightNode:t,reflectedLight:o}),e)}setupDirectRectAreaLight(e,t,n){const{lightingModel:s,reflectedLight:o}=e.context;s.directRectArea(cc(Ys({},n),{lightNode:t,reflectedLight:o}),e)}setupLights(e,t){for(const n of t)n.build(e)}getLightNodes(e){return this._lightNodes===null&&this.setupLightsNode(e),this._lightNodes}setup(e){const t=e.lightsNode;e.lightsNode=this;let n=this.outgoingLightNode;const s=e.context,o=s.lightingModel,a=e.getNodeProperties(this);if(o){const{totalDiffuseNode:c,totalSpecularNode:u}=this;s.outgoingLight=n;const d=e.addStack();a.nodes=d.nodes,o.start(e);const{backdrop:p,backdropAlpha:m}=s,{directDiffuse:y,directSpecular:M,indirectDiffuse:T,indirectSpecular:G}=s.reflectedLight;let z=y.add(T);p!==null&&(m!==null?z=Xt(m.mix(z,p)):z=Xt(p),s.material.transparent=!0),c.assign(z),u.assign(M.add(G)),n.assign(c.add(u)),o.finish(e),n=n.bypass(e.removeStack())}else a.nodes=[];return e.lightsNode=t,n}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}const nW=(i=[])=>Cn(new eT).setLights(i);class iW extends Wi{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=ss.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){tT.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||Jc)}}const tT=oh("vec3","shadowPositionWorld");function nT(i,e={}){return e.toneMapping=i.toneMapping,e.toneMappingExposure=i.toneMappingExposure,e.outputColorSpace=i.outputColorSpace,e.renderTarget=i.getRenderTarget(),e.activeCubeFace=i.getActiveCubeFace(),e.activeMipmapLevel=i.getActiveMipmapLevel(),e.renderObjectFunction=i.getRenderObjectFunction(),e.pixelRatio=i.getPixelRatio(),e.mrt=i.getMRT(),e.clearColor=i.getClearColor(e.clearColor||new jn),e.clearAlpha=i.getClearAlpha(),e.autoClear=i.autoClear,e.scissorTest=i.getScissorTest(),e}function WP(i,e){return e=nT(i,e),i.setMRT(null),i.setRenderObjectFunction(null),i.setClearColor(0,1),i.autoClear=!0,e}function HP(i,e){i.toneMapping=e.toneMapping,i.toneMappingExposure=e.toneMappingExposure,i.outputColorSpace=e.outputColorSpace,i.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),i.setRenderObjectFunction(e.renderObjectFunction),i.setPixelRatio(e.pixelRatio),i.setMRT(e.mrt),i.setClearColor(e.clearColor,e.clearAlpha),i.autoClear=e.autoClear,i.setScissorTest(e.scissorTest)}function iT(i,e={}){return e.background=i.background,e.backgroundNode=i.backgroundNode,e.overrideMaterial=i.overrideMaterial,e}function $P(i,e){return e=iT(i,e),i.background=null,i.backgroundNode=null,i.overrideMaterial=null,e}function jP(i,e){i.background=e.background,i.backgroundNode=e.backgroundNode,i.overrideMaterial=e.overrideMaterial}function rW(i,e,t={}){return t=nT(i,t),t=iT(e,t),t}function XP(i,e,t){return t=WP(i,t),t=$P(e,t),t}function qP(i,e,t){HP(i,t),jP(e,t)}var gZ=Object.freeze({__proto__:null,resetRendererAndSceneState:XP,resetRendererState:WP,resetSceneState:$P,restoreRendererAndSceneState:qP,restoreRendererState:HP,restoreSceneState:jP,saveRendererAndSceneState:rW,saveRendererState:nT,saveSceneState:iT});const YP=new WeakMap,ZP=Kt(({depthTexture:i,shadowCoord:e,depthLayer:t})=>{let n=Is(i,e.xy).setName("t_basic");return i.isArrayTexture&&(n=n.depth(t)),n.compare(e.z)}),KP=Kt(({depthTexture:i,shadowCoord:e,shadow:t,depthLayer:n})=>{const s=(z,I)=>{let J=Is(i,z);return i.isArrayTexture&&(J=J.depth(n)),J.compare(I)},o=Po("mapSize","vec2",t).setGroup(or),a=Po("radius","float",t).setGroup(or),c=Bn(1).div(o),u=c.x.negate().mul(a),d=c.y.negate().mul(a),p=c.x.mul(a),m=c.y.mul(a),y=u.div(2),M=d.div(2),T=p.div(2),G=m.div(2);return $a(s(e.xy.add(Bn(u,d)),e.z),s(e.xy.add(Bn(0,d)),e.z),s(e.xy.add(Bn(p,d)),e.z),s(e.xy.add(Bn(y,M)),e.z),s(e.xy.add(Bn(0,M)),e.z),s(e.xy.add(Bn(T,M)),e.z),s(e.xy.add(Bn(u,0)),e.z),s(e.xy.add(Bn(y,0)),e.z),s(e.xy,e.z),s(e.xy.add(Bn(T,0)),e.z),s(e.xy.add(Bn(p,0)),e.z),s(e.xy.add(Bn(y,G)),e.z),s(e.xy.add(Bn(0,G)),e.z),s(e.xy.add(Bn(T,G)),e.z),s(e.xy.add(Bn(u,m)),e.z),s(e.xy.add(Bn(0,m)),e.z),s(e.xy.add(Bn(p,m)),e.z)).mul(1/17)}),JP=Kt(({depthTexture:i,shadowCoord:e,shadow:t,depthLayer:n})=>{const s=(m,y)=>{let M=Is(i,m);return i.isArrayTexture&&(M=M.depth(n)),M.compare(y)},o=Po("mapSize","vec2",t).setGroup(or),a=Bn(1).div(o),c=a.x,u=a.y,d=e.xy,p=Bd(d.mul(o).add(.5));return d.subAssign(p.mul(a)),$a(s(d,e.z),s(d.add(Bn(c,0)),e.z),s(d.add(Bn(0,u)),e.z),s(d.add(a),e.z),$s(s(d.add(Bn(c.negate(),0)),e.z),s(d.add(Bn(c.mul(2),0)),e.z),p.x),$s(s(d.add(Bn(c.negate(),u)),e.z),s(d.add(Bn(c.mul(2),u)),e.z),p.x),$s(s(d.add(Bn(0,u.negate())),e.z),s(d.add(Bn(0,u.mul(2))),e.z),p.y),$s(s(d.add(Bn(c,u.negate())),e.z),s(d.add(Bn(c,u.mul(2))),e.z),p.y),$s($s(s(d.add(Bn(c.negate(),u.negate())),e.z),s(d.add(Bn(c.mul(2),u.negate())),e.z),p.x),$s(s(d.add(Bn(c.negate(),u.mul(2))),e.z),s(d.add(Bn(c.mul(2),u.mul(2))),e.z),p.x),p.y)).mul(1/9)}),QP=Kt(({depthTexture:i,shadowCoord:e,depthLayer:t})=>{const n=at(1).toVar();let s=Is(i).sample(e.xy);i.isArrayTexture&&(s=s.depth(t)),s=s.rg;const o=W_(e.z,s.x);return sr(o.notEqual(at(1)),()=>{const a=e.z.sub(s.x),c=va(0,s.y.mul(s.y));let u=c.div(c.add(a.mul(a)));u=Eu(Os(u,.3).div(.95-.3)),n.assign(Eu(va(o,u)))}),n}),sW=Kt(([i,e,t])=>{let n=Jc.sub(i).length();return n=n.sub(e).div(t.sub(e)),n=n.saturate(),n}),oW=i=>{const e=i.shadow.camera,t=Po("near","float",e).setGroup(or),n=Po("far","float",e).setGroup(or),s=XR(i);return sW(s,t,n)},eI=i=>{let e=YP.get(i);if(e===void 0){const t=i.isPointLight?oW(i):null;e=new xa,e.colorNode=Bi(0,0,0,1),e.depthNode=t,e.isShadowPassMaterial=!0,e.name="ShadowMaterial",e.fog=!1,YP.set(i,e)}return e},tI=new ah,u0=[],nI=(i,e,t,n)=>{u0[0]=i,u0[1]=e;let s=tI.get(u0);return(s===void 0||s.shadowType!==t||s.useVelocity!==n)&&(s=(o,a,c,u,d,p,...m)=>{(o.castShadow===!0||o.receiveShadow&&t===P)&&(n&&(Kw(o).useVelocity=!0),o.onBeforeShadow(i,o,c,e.camera,u,a.overrideMaterial,p),i.renderObject(o,a,c,u,d,p,...m),o.onAfterShadow(i,o,c,e.camera,u,a.overrideMaterial,p))},s.shadowType=t,s.useVelocity=n,tI.set(u0,s)),u0[0]=null,u0[1]=null,s},aW=Kt(({samples:i,radius:e,size:t,shadowPass:n,depthLayer:s})=>{const o=at(0).toVar("meanVertical"),a=at(0).toVar("squareMeanVertical"),c=i.lessThanEqual(at(1)).select(at(0),at(2).div(i.sub(1))),u=i.lessThanEqual(at(1)).select(at(0),at(-1));mo({start:Dt(0),end:Dt(i),type:"int",condition:"<"},({i:p})=>{const m=u.add(at(p).mul(c));let y=n.sample($a(wv.xy,Bn(0,m).mul(e)).div(t));n.value.isArrayTexture&&(y=y.depth(s)),y=y.x,o.addAssign(y),a.addAssign(y.mul(y))}),o.divAssign(i),a.divAssign(i);const d=Uh(a.sub(o.mul(o)));return Bn(o,d)}),lW=Kt(({samples:i,radius:e,size:t,shadowPass:n,depthLayer:s})=>{const o=at(0).toVar("meanHorizontal"),a=at(0).toVar("squareMeanHorizontal"),c=i.lessThanEqual(at(1)).select(at(0),at(2).div(i.sub(1))),u=i.lessThanEqual(at(1)).select(at(0),at(-1));mo({start:Dt(0),end:Dt(i),type:"int",condition:"<"},({i:p})=>{const m=u.add(at(p).mul(c));let y=n.sample($a(wv.xy,Bn(m,0).mul(e)).div(t));n.value.isArrayTexture&&(y=y.depth(s)),o.addAssign(y.x),a.addAssign($a(y.y.mul(y.y),y.x.mul(y.x)))}),o.divAssign(i),a.divAssign(i);const d=Uh(a.sub(o.mul(o)));return Bn(o,d)}),cW=[ZP,KP,JP,QP];let rT;const Cb=new Ov;class iI extends iW{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:s,shadow:o,depthLayer:a}){const c=s.x.greaterThanEqual(0).and(s.x.lessThanEqual(1)).and(s.y.greaterThanEqual(0)).and(s.y.lessThanEqual(1)).and(s.z.lessThanEqual(1)),u=t({depthTexture:n,shadowCoord:s,shadow:o,depthLayer:a});return c.select(u,at(1))}setupShadowCoord(e,t){const{shadow:n}=this,{renderer:s}=e,o=Po("bias","float",n).setGroup(or);let a=t,c;if(n.camera.isOrthographicCamera||s.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),c=a.z,s.coordinateSystem===qa&&(c=c.mul(2).sub(1));else{const u=a.w;a=a.xy.div(u);const d=Po("near","float",n.camera).setGroup(or),p=Po("far","float",n.camera).setGroup(or);c=dS(u.negate(),d,p)}return a=Xt(a.x,a.y.oneMinus(),c.add(o)),a}getShadowFilterFn(e){return cW[e]}setupRenderTarget(e,t){const n=new vc(e.mapSize.width,e.mapSize.height);n.name="ShadowDepthTexture",n.compareFunction=ef;const s=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=e.mapType,s.depthTexture=n,{shadowMap:s,depthTexture:n}}setupShadow(e){const{renderer:t}=e,{light:n,shadow:s}=this,o=t.shadowMap.type,{depthTexture:a,shadowMap:c}=this.setupRenderTarget(s,e);if(s.camera.updateProjectionMatrix(),o===P&&s.isPointLightShadow!==!0){a.compareFunction=null,c.depth>1?(c._vsmShadowMapVertical||(c._vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ie,type:Gs,depth:c.depth,depthBuffer:!1}),c._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=c._vsmShadowMapVertical,c._vsmShadowMapHorizontal||(c._vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ie,type:Gs,depth:c.depth,depthBuffer:!1}),c._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=c._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ie,type:Gs,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Ie,type:Gs,depthBuffer:!1}));let I=Is(a);a.isArrayTexture&&(I=I.depth(this.depthLayer));let J=Is(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(J=J.depth(this.depthLayer));const K=Po("blurSamples","float",s).setGroup(or),re=Po("radius","float",s).setGroup(or),ve=Po("mapSize","vec2",s).setGroup(or);let me=this.vsmMaterialVertical||(this.vsmMaterialVertical=new xa);me.fragmentNode=aW({samples:K,radius:re,size:ve,shadowPass:I,depthLayer:this.depthLayer}).context(e.getSharedContext()),me.name="VSMVertical",me=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new xa),me.fragmentNode=lW({samples:K,radius:re,size:ve,shadowPass:J,depthLayer:this.depthLayer}).context(e.getSharedContext()),me.name="VSMHorizontal"}const u=Po("intensity","float",s).setGroup(or),d=Po("normalBias","float",s).setGroup(or),p=Ab(n).mul(tT.add(Xf.mul(d))),m=this.setupShadowCoord(e,p),y=s.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(y===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const M=o===P&&s.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,T=this.setupShadowFilter(e,{filterFn:y,shadowTexture:c.texture,depthTexture:M,shadowCoord:m,shadow:s,depthLayer:this.depthLayer});let G=Is(c.texture,m);a.isArrayTexture&&(G=G.depth(this.depthLayer));const z=$s(1,T.rgb.mix(G,1),u.mul(G.a)).toVar();return this.shadowMap=c,this.shadow.map=c,z}setup(e){if(e.renderer.shadowMap.enabled!==!1)return Kt(()=>{let t=this._node;return this.setupShadowPosition(e),t===null&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t})()}renderShadow(e){const{shadow:t,shadowMap:n,light:s}=this,{renderer:o,scene:a}=e;t.updateMatrices(s),n.setSize(t.mapSize.width,t.mapSize.height,n.depth),o.render(a,t.camera)}updateShadow(e){const{shadowMap:t,light:n,shadow:s}=this,{renderer:o,scene:a,camera:c}=e,u=o.shadowMap.type,d=t.depthTexture.version;this._depthVersionCached=d;const p=s.camera.layers.mask;s.camera.layers.mask&4294967294||(s.camera.layers.mask=c.layers.mask);const m=o.getRenderObjectFunction(),y=o.getMRT(),M=y?y.has("velocity"):!1;rT=XP(o,a,rT),a.overrideMaterial=eI(n),o.setRenderObjectFunction(nI(o,s,u,M)),o.setClearColor(0,0),o.setRenderTarget(t),this.renderShadow(e),o.setRenderObjectFunction(m),u===P&&s.isPointLightShadow!==!0&&this.vsmPass(o),s.camera.layers.mask=p,qP(o,a,rT)}vsmPass(e){const{shadow:t}=this,n=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,n),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,n),e.setRenderTarget(this.vsmShadowMapVertical),Cb.material=this.vsmMaterialVertical,Cb.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Cb.material=this.vsmMaterialHorizontal,Cb.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:t}=this;let n=t.needsUpdate||t.autoUpdate;n&&(this._cameraFrameId[e.camera]===e.frameId&&(n=!1),this._cameraFrameId[e.camera]=e.frameId),n&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const rI=(i,e)=>Cn(new iI(i,e)),uW=new jn,lh=Kt(([i,e])=>{const t=i.toVar(),n=Fo(t),s=Yc(1,va(n.x,va(n.y,n.z)));n.mulAssign(s),t.mulAssign(s.mul(e.mul(2).oneMinus()));const o=Bn(t.xy).toVar(),c=e.mul(1.5).oneMinus();return sr(n.z.greaterThanEqual(c),()=>{sr(t.z.greaterThan(0),()=>{o.x.assign(Os(4,t.x))})}).ElseIf(n.x.greaterThanEqual(c),()=>{const u=mv(t.x);o.x.assign(t.z.mul(u).add(u.mul(2)))}).ElseIf(n.y.greaterThanEqual(c),()=>{const u=mv(t.y);o.x.assign(t.x.add(u.mul(2)).add(2)),o.y.assign(t.z.mul(u).sub(2))}),Bn(.125,.25).mul(o).add(Bn(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),sI=Kt(({depthTexture:i,bd3D:e,dp:t,texelSize:n})=>Is(i,lh(e,n.y)).compare(t)),oI=Kt(({depthTexture:i,bd3D:e,dp:t,texelSize:n,shadow:s})=>{const o=Po("radius","float",s).setGroup(or),a=Bn(-1,1).mul(o).mul(n.y);return Is(i,lh(e.add(a.xyy),n.y)).compare(t).add(Is(i,lh(e.add(a.yyy),n.y)).compare(t)).add(Is(i,lh(e.add(a.xyx),n.y)).compare(t)).add(Is(i,lh(e.add(a.yyx),n.y)).compare(t)).add(Is(i,lh(e,n.y)).compare(t)).add(Is(i,lh(e.add(a.xxy),n.y)).compare(t)).add(Is(i,lh(e.add(a.yxy),n.y)).compare(t)).add(Is(i,lh(e.add(a.xxx),n.y)).compare(t)).add(Is(i,lh(e.add(a.yxx),n.y)).compare(t)).mul(1/9)}),hW=Kt(({filterFn:i,depthTexture:e,shadowCoord:t,shadow:n})=>{const s=t.xyz.toVar(),o=s.length(),a=cr("float").setGroup(or).onRenderUpdate(()=>n.camera.near),c=cr("float").setGroup(or).onRenderUpdate(()=>n.camera.far),u=Po("bias","float",n).setGroup(or),d=cr(n.mapSize).setGroup(or),p=at(1).toVar();return sr(o.sub(c).lessThanEqual(0).and(o.sub(a).greaterThanEqual(0)),()=>{const m=o.sub(a).div(c.sub(a)).toVar();m.addAssign(u);const y=s.normalize(),M=Bn(1).div(d.mul(Bn(4,2)));p.assign(i({depthTexture:e,bd3D:y,dp:m,texelSize:M,shadow:n}))}),p}),aI=new mr,h0=new yn,zv=new yn;class dW extends iI{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===E?sI:oI}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:n,depthTexture:s,shadowCoord:o,shadow:a}){return hW({filterFn:t,shadowTexture:n,depthTexture:s,shadowCoord:o,shadow:a})}renderShadow(e){const{shadow:t,shadowMap:n,light:s}=this,{renderer:o,scene:a}=e,c=t.getFrameExtents();zv.copy(t.mapSize),zv.multiply(c),n.setSize(zv.width,zv.height),h0.copy(t.mapSize);const u=o.autoClear,d=o.getClearColor(uW),p=o.getClearAlpha();o.autoClear=!1,o.setClearColor(t.clearColor,t.clearAlpha),o.clear();const m=t.getViewportCount();for(let y=0;y<m;y++){const M=t.getViewport(y),T=h0.x*M.x,G=zv.y-h0.y-h0.y*M.y;aI.set(T,G,h0.x*M.z,h0.y*M.w),n.viewport.copy(aI),t.updateMatrices(s,y),o.render(a,t.camera)}o.autoClear=u,o.setClearColor(d,p)}}const lI=(i,e)=>Cn(new dW(i,e));class Tm extends Qg{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new jn,this.colorNode=e&&e.colorNode||cr(this.color).setGroup(or),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=ss.FRAME}getHash(){return this.light.uuid}getLightVector(e){return KS(this.light).sub(e.context.positionView||Da)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return rI(this.light)}setupShadow(e){const{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let n=this.shadowColorNode;if(n===null){const s=this.light.shadow.shadowNode;let o;s!==void 0?o=Cn(s):o=this.setupShadowNode(),this.shadowNode=o,this.shadowColorNode=n=this.colorNode.mul(o),this.baseColorNode=this.colorNode}this.colorNode=n}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),n=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),n&&e.lightsNode.setupDirectRectAreaLight(e,this,n)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const sT=Kt(({lightDistance:i,cutoffDistance:e,decayExponent:t})=>{const n=i.pow(t).max(.01).reciprocal();return e.greaterThan(0).select(n.mul(i.div(e).pow4().oneMinus().clamp().pow2()),n)}),cI=({color:i,lightVector:e,cutoffDistance:t,decayExponent:n})=>{const s=e.normalize(),o=e.length(),a=sT({lightDistance:o,cutoffDistance:t,decayExponent:n}),c=i.mul(a);return{lightDirection:s,lightColor:c}};class fW extends Tm{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=cr(0).setGroup(or),this.decayExponentNode=cr(2).setGroup(or)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return lI(this.light)}setupDirect(e){return cI({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const pW=Kt(([i=xo()])=>{const e=i.mul(2),t=e.x.floor(),n=e.y.floor();return t.add(n).mod(2).sign()}),mW=Kt(([i=xo()],{renderer:e,material:t})=>{const n=EM(i.mul(2).sub(1));let s;if(t.alphaToCoverage&&e.samples>1){const o=at(n.fwidth()).toVar();s=Au(o.oneMinus(),o.add(1),n).oneMinus()}else s=Sl(n.greaterThan(1),0,1);return s}),Vv=Kt(([i,e,t])=>{const n=at(t).toVar(),s=at(e).toVar(),o=Su(i).toVar();return Sl(o,s,n)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),Rb=Kt(([i,e])=>{const t=Su(e).toVar(),n=at(i).toVar();return Sl(t,n.negate(),n)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),ja=Kt(([i])=>{const e=at(i).toVar();return Dt(kh(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),Jo=Kt(([i,e])=>{const t=at(i).toVar();return e.assign(ja(t)),t.sub(at(e))}),uI=Dl([Kt(([i,e,t,n,s,o])=>{const a=at(o).toVar(),c=at(s).toVar(),u=at(n).toVar(),d=at(t).toVar(),p=at(e).toVar(),m=at(i).toVar(),y=at(Os(1,c)).toVar();return Os(1,a).mul(m.mul(y).add(p.mul(c))).add(a.mul(d.mul(y).add(u.mul(c))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),Kt(([i,e,t,n,s,o])=>{const a=at(o).toVar(),c=at(s).toVar(),u=Xt(n).toVar(),d=Xt(t).toVar(),p=Xt(e).toVar(),m=Xt(i).toVar(),y=at(Os(1,c)).toVar();return Os(1,a).mul(m.mul(y).add(p.mul(c))).add(a.mul(d.mul(y).add(u.mul(c))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]})]),hI=Dl([Kt(([i,e,t,n,s,o,a,c,u,d,p])=>{const m=at(p).toVar(),y=at(d).toVar(),M=at(u).toVar(),T=at(c).toVar(),G=at(a).toVar(),z=at(o).toVar(),I=at(s).toVar(),J=at(n).toVar(),K=at(t).toVar(),re=at(e).toVar(),ve=at(i).toVar(),me=at(Os(1,M)).toVar(),Le=at(Os(1,y)).toVar();return at(Os(1,m)).toVar().mul(Le.mul(ve.mul(me).add(re.mul(M))).add(y.mul(K.mul(me).add(J.mul(M))))).add(m.mul(Le.mul(I.mul(me).add(z.mul(M))).add(y.mul(G.mul(me).add(T.mul(M))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),Kt(([i,e,t,n,s,o,a,c,u,d,p])=>{const m=at(p).toVar(),y=at(d).toVar(),M=at(u).toVar(),T=Xt(c).toVar(),G=Xt(a).toVar(),z=Xt(o).toVar(),I=Xt(s).toVar(),J=Xt(n).toVar(),K=Xt(t).toVar(),re=Xt(e).toVar(),ve=Xt(i).toVar(),me=at(Os(1,M)).toVar(),Le=at(Os(1,y)).toVar();return at(Os(1,m)).toVar().mul(Le.mul(ve.mul(me).add(re.mul(M))).add(y.mul(K.mul(me).add(J.mul(M))))).add(m.mul(Le.mul(I.mul(me).add(z.mul(M))).add(y.mul(G.mul(me).add(T.mul(M))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]})]),Tl=Dl([Kt(([i,e,t])=>{const n=at(t).toVar(),s=at(e).toVar(),o=Li(i).toVar(),a=Li(o.bitAnd(Li(7))).toVar(),c=at(Vv(a.lessThan(Li(4)),s,n)).toVar(),u=at(Jr(2,Vv(a.lessThan(Li(4)),n,s))).toVar();return Rb(c,Su(a.bitAnd(Li(1)))).add(Rb(u,Su(a.bitAnd(Li(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),Kt(([i,e,t,n])=>{const s=at(n).toVar(),o=at(t).toVar(),a=at(e).toVar(),c=Li(i).toVar(),u=Li(c.bitAnd(Li(15))).toVar(),d=at(Vv(u.lessThan(Li(8)),a,o)).toVar(),p=at(Vv(u.lessThan(Li(4)),o,Vv(u.equal(Li(12)).or(u.equal(Li(14))),a,s))).toVar();return Rb(d,Su(u.bitAnd(Li(1)))).add(Rb(p,Su(u.bitAnd(Li(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]})]),Lu=Dl([Kt(([i,e,t])=>{const n=at(t).toVar(),s=at(e).toVar(),o=Hg(i).toVar();return Xt(Tl(o.x,s,n),Tl(o.y,s,n),Tl(o.z,s,n))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),Kt(([i,e,t,n])=>{const s=at(n).toVar(),o=at(t).toVar(),a=at(e).toVar(),c=Hg(i).toVar();return Xt(Tl(c.x,a,o,s),Tl(c.y,a,o,s),Tl(c.z,a,o,s))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]})]),gW=Kt(([i])=>{const e=at(i).toVar();return Jr(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),yW=Kt(([i])=>{const e=at(i).toVar();return Jr(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),dI=Dl([gW,Kt(([i])=>{const e=Xt(i).toVar();return Jr(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),fI=Dl([yW,Kt(([i])=>{const e=Xt(i).toVar();return Jr(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),eu=Kt(([i,e])=>{const t=Dt(e).toVar(),n=Li(i).toVar();return n.shiftLeft(t).bitOr(n.shiftRight(Dt(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),pI=Kt(([i,e,t])=>{i.subAssign(t),i.bitXorAssign(eu(t,Dt(4))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(eu(i,Dt(6))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(eu(e,Dt(8))),e.addAssign(i),i.subAssign(t),i.bitXorAssign(eu(t,Dt(16))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(eu(i,Dt(19))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(eu(e,Dt(4))),e.addAssign(i)}),Gv=Kt(([i,e,t])=>{const n=Li(t).toVar(),s=Li(e).toVar(),o=Li(i).toVar();return n.bitXorAssign(s),n.subAssign(eu(s,Dt(14))),o.bitXorAssign(n),o.subAssign(eu(n,Dt(11))),s.bitXorAssign(o),s.subAssign(eu(o,Dt(25))),n.bitXorAssign(s),n.subAssign(eu(s,Dt(16))),o.bitXorAssign(n),o.subAssign(eu(n,Dt(4))),s.bitXorAssign(o),s.subAssign(eu(o,Dt(14))),n.bitXorAssign(s),n.subAssign(eu(s,Dt(24))),n}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),ql=Kt(([i])=>{const e=Li(i).toVar();return at(e).div(at(Li(Dt(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),jh=Kt(([i])=>{const e=at(i).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),_o=Dl([Kt(([i])=>{const e=Dt(i).toVar(),t=Li(Li(1)).toVar(),n=Li(Li(Dt(3735928559)).add(t.shiftLeft(Li(2))).add(Li(13))).toVar();return Gv(n.add(Li(e)),n,n)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),Kt(([i,e])=>{const t=Dt(e).toVar(),n=Dt(i).toVar(),s=Li(Li(2)).toVar(),o=Li().toVar(),a=Li().toVar(),c=Li().toVar();return o.assign(a.assign(c.assign(Li(Dt(3735928559)).add(s.shiftLeft(Li(2))).add(Li(13))))),o.addAssign(Li(n)),a.addAssign(Li(t)),Gv(o,a,c)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),Kt(([i,e,t])=>{const n=Dt(t).toVar(),s=Dt(e).toVar(),o=Dt(i).toVar(),a=Li(Li(3)).toVar(),c=Li().toVar(),u=Li().toVar(),d=Li().toVar();return c.assign(u.assign(d.assign(Li(Dt(3735928559)).add(a.shiftLeft(Li(2))).add(Li(13))))),c.addAssign(Li(o)),u.addAssign(Li(s)),d.addAssign(Li(n)),Gv(c,u,d)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),Kt(([i,e,t,n])=>{const s=Dt(n).toVar(),o=Dt(t).toVar(),a=Dt(e).toVar(),c=Dt(i).toVar(),u=Li(Li(4)).toVar(),d=Li().toVar(),p=Li().toVar(),m=Li().toVar();return d.assign(p.assign(m.assign(Li(Dt(3735928559)).add(u.shiftLeft(Li(2))).add(Li(13))))),d.addAssign(Li(c)),p.addAssign(Li(a)),m.addAssign(Li(o)),pI(d,p,m),d.addAssign(Li(s)),Gv(d,p,m)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),Kt(([i,e,t,n,s])=>{const o=Dt(s).toVar(),a=Dt(n).toVar(),c=Dt(t).toVar(),u=Dt(e).toVar(),d=Dt(i).toVar(),p=Li(Li(5)).toVar(),m=Li().toVar(),y=Li().toVar(),M=Li().toVar();return m.assign(y.assign(M.assign(Li(Dt(3735928559)).add(p.shiftLeft(Li(2))).add(Li(13))))),m.addAssign(Li(d)),y.addAssign(Li(u)),M.addAssign(Li(c)),pI(m,y,M),m.addAssign(Li(a)),y.addAssign(Li(o)),Gv(m,y,M)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]})]),Du=Dl([Kt(([i,e])=>{const t=Dt(e).toVar(),n=Dt(i).toVar(),s=Li(_o(n,t)).toVar(),o=Hg().toVar();return o.x.assign(s.bitAnd(Dt(255))),o.y.assign(s.shiftRight(Dt(8)).bitAnd(Dt(255))),o.z.assign(s.shiftRight(Dt(16)).bitAnd(Dt(255))),o}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),Kt(([i,e,t])=>{const n=Dt(t).toVar(),s=Dt(e).toVar(),o=Dt(i).toVar(),a=Li(_o(o,s,n)).toVar(),c=Hg().toVar();return c.x.assign(a.bitAnd(Dt(255))),c.y.assign(a.shiftRight(Dt(8)).bitAnd(Dt(255))),c.z.assign(a.shiftRight(Dt(16)).bitAnd(Dt(255))),c}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),oT=Dl([Kt(([i])=>{const e=Bn(i).toVar(),t=Dt().toVar(),n=Dt().toVar(),s=at(Jo(e.x,t)).toVar(),o=at(Jo(e.y,n)).toVar(),a=at(jh(s)).toVar(),c=at(jh(o)).toVar(),u=at(uI(Tl(_o(t,n),s,o),Tl(_o(t.add(Dt(1)),n),s.sub(1),o),Tl(_o(t,n.add(Dt(1))),s,o.sub(1)),Tl(_o(t.add(Dt(1)),n.add(Dt(1))),s.sub(1),o.sub(1)),a,c)).toVar();return dI(u)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),Kt(([i])=>{const e=Xt(i).toVar(),t=Dt().toVar(),n=Dt().toVar(),s=Dt().toVar(),o=at(Jo(e.x,t)).toVar(),a=at(Jo(e.y,n)).toVar(),c=at(Jo(e.z,s)).toVar(),u=at(jh(o)).toVar(),d=at(jh(a)).toVar(),p=at(jh(c)).toVar(),m=at(hI(Tl(_o(t,n,s),o,a,c),Tl(_o(t.add(Dt(1)),n,s),o.sub(1),a,c),Tl(_o(t,n.add(Dt(1)),s),o,a.sub(1),c),Tl(_o(t.add(Dt(1)),n.add(Dt(1)),s),o.sub(1),a.sub(1),c),Tl(_o(t,n,s.add(Dt(1))),o,a,c.sub(1)),Tl(_o(t.add(Dt(1)),n,s.add(Dt(1))),o.sub(1),a,c.sub(1)),Tl(_o(t,n.add(Dt(1)),s.add(Dt(1))),o,a.sub(1),c.sub(1)),Tl(_o(t.add(Dt(1)),n.add(Dt(1)),s.add(Dt(1))),o.sub(1),a.sub(1),c.sub(1)),u,d,p)).toVar();return fI(m)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),Wv=Dl([Kt(([i])=>{const e=Bn(i).toVar(),t=Dt().toVar(),n=Dt().toVar(),s=at(Jo(e.x,t)).toVar(),o=at(Jo(e.y,n)).toVar(),a=at(jh(s)).toVar(),c=at(jh(o)).toVar(),u=Xt(uI(Lu(Du(t,n),s,o),Lu(Du(t.add(Dt(1)),n),s.sub(1),o),Lu(Du(t,n.add(Dt(1))),s,o.sub(1)),Lu(Du(t.add(Dt(1)),n.add(Dt(1))),s.sub(1),o.sub(1)),a,c)).toVar();return dI(u)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),Kt(([i])=>{const e=Xt(i).toVar(),t=Dt().toVar(),n=Dt().toVar(),s=Dt().toVar(),o=at(Jo(e.x,t)).toVar(),a=at(Jo(e.y,n)).toVar(),c=at(Jo(e.z,s)).toVar(),u=at(jh(o)).toVar(),d=at(jh(a)).toVar(),p=at(jh(c)).toVar(),m=Xt(hI(Lu(Du(t,n,s),o,a,c),Lu(Du(t.add(Dt(1)),n,s),o.sub(1),a,c),Lu(Du(t,n.add(Dt(1)),s),o,a.sub(1),c),Lu(Du(t.add(Dt(1)),n.add(Dt(1)),s),o.sub(1),a.sub(1),c),Lu(Du(t,n,s.add(Dt(1))),o,a,c.sub(1)),Lu(Du(t.add(Dt(1)),n,s.add(Dt(1))),o.sub(1),a,c.sub(1)),Lu(Du(t,n.add(Dt(1)),s.add(Dt(1))),o,a.sub(1),c.sub(1)),Lu(Du(t.add(Dt(1)),n.add(Dt(1)),s.add(Dt(1))),o.sub(1),a.sub(1),c.sub(1)),u,d,p)).toVar();return fI(m)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),vW=Dl([Kt(([i])=>{const e=at(i).toVar(),t=Dt(ja(e)).toVar();return ql(_o(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),Kt(([i])=>{const e=Bn(i).toVar(),t=Dt(ja(e.x)).toVar(),n=Dt(ja(e.y)).toVar();return ql(_o(t,n))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),Kt(([i])=>{const e=Xt(i).toVar(),t=Dt(ja(e.x)).toVar(),n=Dt(ja(e.y)).toVar(),s=Dt(ja(e.z)).toVar();return ql(_o(t,n,s))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),Kt(([i])=>{const e=Bi(i).toVar(),t=Dt(ja(e.x)).toVar(),n=Dt(ja(e.y)).toVar(),s=Dt(ja(e.z)).toVar(),o=Dt(ja(e.w)).toVar();return ql(_o(t,n,s,o))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),Nb=Dl([Kt(([i])=>{const e=at(i).toVar(),t=Dt(ja(e)).toVar();return Xt(ql(_o(t,Dt(0))),ql(_o(t,Dt(1))),ql(_o(t,Dt(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),Kt(([i])=>{const e=Bn(i).toVar(),t=Dt(ja(e.x)).toVar(),n=Dt(ja(e.y)).toVar();return Xt(ql(_o(t,n,Dt(0))),ql(_o(t,n,Dt(1))),ql(_o(t,n,Dt(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),Kt(([i])=>{const e=Xt(i).toVar(),t=Dt(ja(e.x)).toVar(),n=Dt(ja(e.y)).toVar(),s=Dt(ja(e.z)).toVar();return Xt(ql(_o(t,n,s,Dt(0))),ql(_o(t,n,s,Dt(1))),ql(_o(t,n,s,Dt(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Kt(([i])=>{const e=Bi(i).toVar(),t=Dt(ja(e.x)).toVar(),n=Dt(ja(e.y)).toVar(),s=Dt(ja(e.z)).toVar(),o=Dt(ja(e.w)).toVar();return Xt(ql(_o(t,n,s,o,Dt(0))),ql(_o(t,n,s,o,Dt(1))),ql(_o(t,n,s,o,Dt(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),Pb=Kt(([i,e,t,n])=>{const s=at(n).toVar(),o=at(t).toVar(),a=Dt(e).toVar(),c=Xt(i).toVar(),u=at(0).toVar(),d=at(1).toVar();return mo(a,()=>{u.addAssign(d.mul(oT(c))),d.mulAssign(s),c.mulAssign(o)}),u}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Ib=Kt(([i,e,t,n])=>{const s=at(n).toVar(),o=at(t).toVar(),a=Dt(e).toVar(),c=Xt(i).toVar(),u=Xt(0).toVar(),d=at(1).toVar();return mo(a,()=>{u.addAssign(d.mul(Wv(c))),d.mulAssign(s),c.mulAssign(o)}),u}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),xW=Kt(([i,e,t,n])=>{const s=at(n).toVar(),o=at(t).toVar(),a=Dt(e).toVar(),c=Xt(i).toVar();return Bn(Pb(c,a,o,s),Pb(c.add(Xt(Dt(19),Dt(193),Dt(17))),a,o,s))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),_W=Kt(([i,e,t,n])=>{const s=at(n).toVar(),o=at(t).toVar(),a=Dt(e).toVar(),c=Xt(i).toVar(),u=Xt(Ib(c,a,o,s)).toVar(),d=at(Pb(c.add(Xt(Dt(19),Dt(193),Dt(17))),a,o,s)).toVar();return Bi(u,d)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),d0=Dl([Kt(([i,e,t,n,s,o,a])=>{const c=Dt(a).toVar(),u=at(o).toVar(),d=Dt(s).toVar(),p=Dt(n).toVar(),m=Dt(t).toVar(),y=Dt(e).toVar(),M=Bn(i).toVar(),T=Xt(Nb(Bn(y.add(p),m.add(d)))).toVar(),G=Bn(T.x,T.y).toVar();G.subAssign(.5),G.mulAssign(u),G.addAssign(.5);const z=Bn(Bn(at(y),at(m)).add(G)).toVar(),I=Bn(z.sub(M)).toVar();return sr(c.equal(Dt(2)),()=>Fo(I.x).add(Fo(I.y))),sr(c.equal(Dt(3)),()=>va(Fo(I.x),Fo(I.y))),Hf(I,I)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Kt(([i,e,t,n,s,o,a,c,u])=>{const d=Dt(u).toVar(),p=at(c).toVar(),m=Dt(a).toVar(),y=Dt(o).toVar(),M=Dt(s).toVar(),T=Dt(n).toVar(),G=Dt(t).toVar(),z=Dt(e).toVar(),I=Xt(i).toVar(),J=Xt(Nb(Xt(z.add(M),G.add(y),T.add(m)))).toVar();J.subAssign(.5),J.mulAssign(p),J.addAssign(.5);const K=Xt(Xt(at(z),at(G),at(T)).add(J)).toVar(),re=Xt(K.sub(I)).toVar();return sr(d.equal(Dt(2)),()=>Fo(re.x).add(Fo(re.y)).add(Fo(re.z))),sr(d.equal(Dt(3)),()=>va(Fo(re.x),Fo(re.y),Fo(re.z))),Hf(re,re)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),bW=Kt(([i,e,t])=>{const n=Dt(t).toVar(),s=at(e).toVar(),o=Bn(i).toVar(),a=Dt().toVar(),c=Dt().toVar(),u=Bn(Jo(o.x,a),Jo(o.y,c)).toVar(),d=at(1e6).toVar();return mo({start:-1,end:Dt(1),name:"x",condition:"<="},({x:p})=>{mo({start:-1,end:Dt(1),name:"y",condition:"<="},({y:m})=>{const y=at(d0(u,p,m,a,c,s,n)).toVar();d.assign(Ec(d,y))})}),sr(n.equal(Dt(0)),()=>{d.assign(Uh(d))}),d}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),wW=Kt(([i,e,t])=>{const n=Dt(t).toVar(),s=at(e).toVar(),o=Bn(i).toVar(),a=Dt().toVar(),c=Dt().toVar(),u=Bn(Jo(o.x,a),Jo(o.y,c)).toVar(),d=Bn(1e6,1e6).toVar();return mo({start:-1,end:Dt(1),name:"x",condition:"<="},({x:p})=>{mo({start:-1,end:Dt(1),name:"y",condition:"<="},({y:m})=>{const y=at(d0(u,p,m,a,c,s,n)).toVar();sr(y.lessThan(d.x),()=>{d.y.assign(d.x),d.x.assign(y)}).ElseIf(y.lessThan(d.y),()=>{d.y.assign(y)})})}),sr(n.equal(Dt(0)),()=>{d.assign(Uh(d))}),d}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),MW=Kt(([i,e,t])=>{const n=Dt(t).toVar(),s=at(e).toVar(),o=Bn(i).toVar(),a=Dt().toVar(),c=Dt().toVar(),u=Bn(Jo(o.x,a),Jo(o.y,c)).toVar(),d=Xt(1e6,1e6,1e6).toVar();return mo({start:-1,end:Dt(1),name:"x",condition:"<="},({x:p})=>{mo({start:-1,end:Dt(1),name:"y",condition:"<="},({y:m})=>{const y=at(d0(u,p,m,a,c,s,n)).toVar();sr(y.lessThan(d.x),()=>{d.z.assign(d.y),d.y.assign(d.x),d.x.assign(y)}).ElseIf(y.lessThan(d.y),()=>{d.z.assign(d.y),d.y.assign(y)}).ElseIf(y.lessThan(d.z),()=>{d.z.assign(y)})})}),sr(n.equal(Dt(0)),()=>{d.assign(Uh(d))}),d}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),SW=Dl([bW,Kt(([i,e,t])=>{const n=Dt(t).toVar(),s=at(e).toVar(),o=Xt(i).toVar(),a=Dt().toVar(),c=Dt().toVar(),u=Dt().toVar(),d=Xt(Jo(o.x,a),Jo(o.y,c),Jo(o.z,u)).toVar(),p=at(1e6).toVar();return mo({start:-1,end:Dt(1),name:"x",condition:"<="},({x:m})=>{mo({start:-1,end:Dt(1),name:"y",condition:"<="},({y})=>{mo({start:-1,end:Dt(1),name:"z",condition:"<="},({z:M})=>{const T=at(d0(d,m,y,M,a,c,u,s,n)).toVar();p.assign(Ec(p,T))})})}),sr(n.equal(Dt(0)),()=>{p.assign(Uh(p))}),p}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),TW=Dl([wW,Kt(([i,e,t])=>{const n=Dt(t).toVar(),s=at(e).toVar(),o=Xt(i).toVar(),a=Dt().toVar(),c=Dt().toVar(),u=Dt().toVar(),d=Xt(Jo(o.x,a),Jo(o.y,c),Jo(o.z,u)).toVar(),p=Bn(1e6,1e6).toVar();return mo({start:-1,end:Dt(1),name:"x",condition:"<="},({x:m})=>{mo({start:-1,end:Dt(1),name:"y",condition:"<="},({y})=>{mo({start:-1,end:Dt(1),name:"z",condition:"<="},({z:M})=>{const T=at(d0(d,m,y,M,a,c,u,s,n)).toVar();sr(T.lessThan(p.x),()=>{p.y.assign(p.x),p.x.assign(T)}).ElseIf(T.lessThan(p.y),()=>{p.y.assign(T)})})})}),sr(n.equal(Dt(0)),()=>{p.assign(Uh(p))}),p}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),aT=Dl([MW,Kt(([i,e,t])=>{const n=Dt(t).toVar(),s=at(e).toVar(),o=Xt(i).toVar(),a=Dt().toVar(),c=Dt().toVar(),u=Dt().toVar(),d=Xt(Jo(o.x,a),Jo(o.y,c),Jo(o.z,u)).toVar(),p=Xt(1e6,1e6,1e6).toVar();return mo({start:-1,end:Dt(1),name:"x",condition:"<="},({x:m})=>{mo({start:-1,end:Dt(1),name:"y",condition:"<="},({y})=>{mo({start:-1,end:Dt(1),name:"z",condition:"<="},({z:M})=>{const T=at(d0(d,m,y,M,a,c,u,s,n)).toVar();sr(T.lessThan(p.x),()=>{p.z.assign(p.y),p.y.assign(p.x),p.x.assign(T)}).ElseIf(T.lessThan(p.y),()=>{p.z.assign(p.y),p.y.assign(T)}).ElseIf(T.lessThan(p.z),()=>{p.z.assign(T)})})})}),sr(n.equal(Dt(0)),()=>{p.assign(Uh(p))}),p}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),EW=Kt(([i,e,t,n,s,o,a,c,u,d,p])=>{const m=Dt(i).toVar(),y=Bn(e).toVar(),M=Bn(t).toVar(),T=Bn(n).toVar(),G=at(s).toVar(),z=at(o).toVar(),I=at(a).toVar(),J=Su(c).toVar(),K=Dt(u).toVar(),re=at(d).toVar(),ve=at(p).toVar(),me=y.mul(M).add(T),Le=at(0).toVar();return sr(m.equal(Dt(0)),()=>{Le.assign(Wv(me))}),sr(m.equal(Dt(1)),()=>{Le.assign(Nb(me))}),sr(m.equal(Dt(2)),()=>{Le.assign(aT(me,G,Dt(0)))}),sr(m.equal(Dt(3)),()=>{Le.assign(Ib(Xt(me,0),K,re,ve))}),Le.assign(Le.mul(I.sub(z)).add(z)),sr(J,()=>{Le.assign(Eu(Le,z,I))}),Le}).setLayout({name:"mx_unifiednoise2d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"texcoord",type:"vec2"},{name:"freq",type:"vec2"},{name:"offset",type:"vec2"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),AW=Kt(([i,e,t,n,s,o,a,c,u,d,p])=>{const m=Dt(i).toVar(),y=Xt(e).toVar(),M=Xt(t).toVar(),T=Xt(n).toVar(),G=at(s).toVar(),z=at(o).toVar(),I=at(a).toVar(),J=Su(c).toVar(),K=Dt(u).toVar(),re=at(d).toVar(),ve=at(p).toVar(),me=y.mul(M).add(T),Le=at(0).toVar();return sr(m.equal(Dt(0)),()=>{Le.assign(Wv(me))}),sr(m.equal(Dt(1)),()=>{Le.assign(Nb(me))}),sr(m.equal(Dt(2)),()=>{Le.assign(aT(me,G,Dt(0)))}),sr(m.equal(Dt(3)),()=>{Le.assign(Ib(me,K,re,ve))}),Le.assign(Le.mul(I.sub(z)).add(z)),sr(J,()=>{Le.assign(Eu(Le,z,I))}),Le}).setLayout({name:"mx_unifiednoise3d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"position",type:"vec3"},{name:"freq",type:"vec3"},{name:"offset",type:"vec3"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),CW=Kt(([i])=>{const e=i.y,t=i.z,n=Xt().toVar();return sr(e.lessThan(1e-4),()=>{n.assign(Xt(t,t,t))}).Else(()=>{let s=i.x;s=s.sub(kh(s)).mul(6).toVar();const o=Dt(SM(s)),a=s.sub(at(o)),c=t.mul(e.oneMinus()),u=t.mul(e.mul(a).oneMinus()),d=t.mul(e.mul(a.oneMinus()).oneMinus());sr(o.equal(Dt(0)),()=>{n.assign(Xt(t,d,c))}).ElseIf(o.equal(Dt(1)),()=>{n.assign(Xt(u,t,c))}).ElseIf(o.equal(Dt(2)),()=>{n.assign(Xt(c,t,d))}).ElseIf(o.equal(Dt(3)),()=>{n.assign(Xt(c,u,t))}).ElseIf(o.equal(Dt(4)),()=>{n.assign(Xt(d,c,t))}).Else(()=>{n.assign(Xt(t,c,u))})}),n}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),RW=Kt(([i])=>{const e=Xt(i).toVar(),t=at(e.x).toVar(),n=at(e.y).toVar(),s=at(e.z).toVar(),o=at(Ec(t,Ec(n,s))).toVar(),a=at(va(t,va(n,s))).toVar(),c=at(a.sub(o)).toVar(),u=at().toVar(),d=at().toVar(),p=at().toVar();return p.assign(a),sr(a.greaterThan(0),()=>{d.assign(c.div(a))}).Else(()=>{d.assign(0)}),sr(d.lessThanEqual(0),()=>{u.assign(0)}).Else(()=>{sr(t.greaterThanEqual(a),()=>{u.assign(n.sub(s).div(c))}).ElseIf(n.greaterThanEqual(a),()=>{u.assign($a(2,s.sub(t).div(c)))}).Else(()=>{u.assign($a(4,t.sub(n).div(c)))}),u.mulAssign(1/6),sr(u.lessThan(0),()=>{u.addAssign(1)})}),Xt(u,d,p)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),NW=Kt(([i])=>{const e=Xt(i).toVar(),t=lM(vM(e,Xt(.04045))).toVar(),n=Xt(e.div(12.92)).toVar(),s=Xt(Tu(va(e.add(Xt(.055)),Xt(0)).div(1.055),Xt(2.4))).toVar();return $s(n,s,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),mI=(i,e)=>{i=at(i),e=at(e);const t=Bn(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return Au(i.sub(t),i.add(t),e)},gI=(i,e,t,n)=>$s(i,e,t[n].clamp()),PW=(i,e,t=xo())=>gI(i,e,t,"x"),IW=(i,e,t=xo())=>gI(i,e,t,"y"),LW=(i,e,t,n,s=xo())=>{const o=s.x.clamp(),a=s.y.clamp(),c=$s(i,e,o),u=$s(t,n,o);return $s(c,u,a)},yI=(i,e,t,n,s)=>$s(i,e,mI(t,n[s])),DW=(i,e,t,n=xo())=>yI(i,e,t,n,"x"),OW=(i,e,t,n=xo())=>yI(i,e,t,n,"y"),FW=(i=1,e=0,t=xo())=>t.mul(i).add(e),BW=(i,e=1)=>(i=at(i),i.abs().pow(e).mul(i.sign())),UW=(i,e=1,t=.5)=>at(i).sub(t).mul(e).add(t),kW=(i=xo(),e=1,t=0)=>oT(i.convert("vec2|vec3")).mul(e).add(t),zW=(i=xo(),e=1,t=0)=>Wv(i.convert("vec2|vec3")).mul(e).add(t),VW=(i=xo(),e=1,t=0)=>(i=i.convert("vec2|vec3"),Bi(Wv(i),oT(i.add(Bn(19,73)))).mul(e).add(t)),GW=(i,e=xo(),t=Bn(1,1),n=Bn(0,0),s=1,o=0,a=1,c=!1,u=1,d=2,p=.5)=>EW(i,e.convert("vec2|vec3"),t,n,s,o,a,c,u,d,p),WW=(i,e=xo(),t=Bn(1,1),n=Bn(0,0),s=1,o=0,a=1,c=!1,u=1,d=2,p=.5)=>AW(i,e.convert("vec2|vec3"),t,n,s,o,a,c,u,d,p),HW=(i=xo(),e=1)=>SW(i.convert("vec2|vec3"),e,Dt(1)),$W=(i=xo(),e=1)=>TW(i.convert("vec2|vec3"),e,Dt(1)),jW=(i=xo(),e=1)=>aT(i.convert("vec2|vec3"),e,Dt(1)),XW=(i=xo())=>vW(i.convert("vec2|vec3")),qW=(i=xo(),e=3,t=2,n=.5,s=1)=>Pb(i,Dt(e),t,n).mul(s),YW=(i=xo(),e=3,t=2,n=.5,s=1)=>xW(i,Dt(e),t,n).mul(s),ZW=(i=xo(),e=3,t=2,n=.5,s=1)=>Ib(i,Dt(e),t,n).mul(s),KW=(i=xo(),e=3,t=2,n=.5,s=1)=>_W(i,Dt(e),t,n).mul(s),JW=(i,e=at(0))=>$a(i,e),QW=(i,e=at(0))=>Os(i,e),eH=(i,e=at(1))=>Jr(i,e),tH=(i,e=at(1))=>Yc(i,e),nH=(i,e=at(1))=>pv(i,e),iH=(i,e=at(1))=>Tu(i,e),rH=(i=at(0),e=at(1))=>G_(i,e),sH=()=>o0,oH=()=>vP,aH=(i,e=at(1))=>Os(e,i),lH=(i,e,t,n)=>i.greaterThan(e).mix(t,n),cH=(i,e,t,n)=>i.greaterThanEqual(e).mix(t,n),uH=(i,e,t,n)=>i.equal(e).mix(t,n),hH=(i,e=null)=>{if(typeof e=="string"){const t={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},n=e.replace(/^out/,"").toLowerCase();if(t[n]!==void 0)return i.element(t[n])}if(typeof e=="number")return i.element(e);if(typeof e=="string"&&e.length===1){const t={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(t[e]!==void 0)return i.element(t[e])}return i},dH=(i,e=Bn(.5,.5),t=Bn(1,1),n=at(0),s=Bn(0,0))=>{let o=i;if(e&&(o=o.sub(e)),t&&(o=o.mul(t)),n){const a=n.mul(Math.PI/180),c=a.cos(),u=a.sin();o=Bn(o.x.mul(c).sub(o.y.mul(u)),o.x.mul(u).add(o.y.mul(c)))}return e&&(o=o.add(e)),s&&(o=o.add(s)),o},fH=(i,e)=>{i=Bn(i),e=at(e);const t=e.mul(Math.PI/180);return Av(i,t)},pH=(i,e,t)=>{i=Xt(i),e=at(e),t=Xt(t);const n=e.mul(Math.PI/180),s=t.normalize(),o=n.cos(),a=n.sin(),c=at(1).sub(o);return i.mul(o).add(s.cross(i).mul(a)).add(s.mul(s.dot(i)).mul(c))},mH=(i,e)=>(i=Xt(i),e=at(e),QM(i,e)),gH=Kt(([i,e,t])=>{const n=Fd(i).toVar(),s=Os(at(.5).mul(e.sub(t)),Jc).div(n).toVar(),o=Os(at(-.5).mul(e.sub(t)),Jc).div(n).toVar(),a=Xt().toVar();a.x=n.x.greaterThan(at(0)).select(s.x,o.x),a.y=n.y.greaterThan(at(0)).select(s.y,o.y),a.z=n.z.greaterThan(at(0)).select(s.z,o.z);const c=Ec(a.x,a.y,a.z).toVar();return Jc.add(n.mul(c)).toVar().sub(t)}),vI=Kt(([i,e])=>{const t=i.x,n=i.y,s=i.z;let o=e.element(0).mul(.886227);return o=o.add(e.element(1).mul(2*.511664).mul(n)),o=o.add(e.element(2).mul(2*.511664).mul(s)),o=o.add(e.element(3).mul(2*.511664).mul(t)),o=o.add(e.element(4).mul(2*.429043).mul(t).mul(n)),o=o.add(e.element(5).mul(2*.429043).mul(n).mul(s)),o=o.add(e.element(6).mul(s.mul(s).mul(.743125).sub(.247708))),o=o.add(e.element(7).mul(2*.429043).mul(t).mul(s)),o=o.add(e.element(8).mul(.429043).mul(Jr(t,t).sub(Jr(n,n)))),o});var KZ=Object.freeze({__proto__:null,BRDF_GGX:yS,BRDF_Lambert:vm,BasicPointShadowFilter:sI,BasicShadowFilter:ZP,Break:tN,Const:TR,Continue:oV,DFGApprox:vS,D_GGX:SN,Discard:VR,EPSILON:XC,F_Schlick:i0,Fn:Kt,INFINITY:Fz,If:sr,Loop:mo,NodeAccess:Il,NodeShaderStage:nv,NodeType:sz,NodeUpdateType:ss,OnMaterialUpdate:g6,OnObjectUpdate:m6,PCFShadowFilter:KP,PCFSoftShadowFilter:JP,PI:k_,PI2:Bz,PointShadowFilter:oI,Return:Qz,Schlick_to_F0:EN,ScriptableNodeResources:Sb,ShaderNode:Wg,Stack:N_,Switch:Az,TBNViewMatrix:gm,VSMShadowFilter:QP,V_GGX_SmithCorrelated:MN,Var:SR,VarIntent:ER,abs:Fo,acesFilmicToneMapping:DP,acos:bM,add:$a,addMethodChaining:An,addNodeElement:n4,agxToneMapping:OP,all:qC,alphaT:O_,and:IC,anisotropy:Wf,anisotropyB:dm,anisotropyT:cv,any:YC,append:Pz,array:TC,arrayBuffer:Rz,asin:QC,assign:EC,atan:G_,atan2:_R,atomicAdd:w8,atomicAnd:E8,atomicFunc:$h,atomicLoad:_8,atomicMax:S8,atomicMin:T8,atomicOr:A8,atomicStore:b8,atomicSub:M8,atomicXor:C8,attenuationColor:pM,attenuationDistance:fM,attribute:oc,attributeArray:x6,backgroundBlurriness:wP,backgroundIntensity:$S,backgroundRotation:MP,batch:K2,bentNormalView:x2,billboarding:JG,bitAnd:FC,bitNot:BC,bitOr:UC,bitXor:kC,bitangentGeometry:z4,bitangentLocal:V4,bitangentView:y2,bitangentWorld:G4,bitcast:IG,blendBurn:cN,blendColor:MV,blendDodge:uN,blendOverlay:dN,blendScreen:hN,blur:jN,bool:Su,buffer:xv,bufferAttribute:yv,builtin:zd,bumpMap:QM,burn:TV,bvec2:pC,bvec3:lM,bvec4:vC,bypass:BR,cache:vv,call:AC,cameraFar:Wd,cameraIndex:jf,cameraNear:Gd,cameraNormalMatrix:g4,cameraPosition:Mv,cameraProjectionMatrix:Cu,cameraProjectionMatrixInverse:p4,cameraViewMatrix:Kc,cameraViewport:y4,cameraWorldMatrix:m4,cbrt:mR,cdl:O6,ceil:V_,checker:pW,cineonToneMapping:LP,clamp:Eu,clearcoat:I_,clearcoatNormalView:mm,clearcoatRoughness:lv,code:wb,color:dC,colorSpaceToWorking:j_,colorToDirection:OV,compute:FR,computeKernel:OM,computeSkinning:rV,context:gv,convert:_C,convertColorSpace:Hz,convertToTexture:u6,cos:Ud,cross:H_,cubeTexture:Kg,cubeTextureBase:qM,cubeToUV:lh,dFdx:wM,dFdy:MM,dashSize:fm,debug:GR,decrement:$C,decrementBefore:WC,defaultBuildStages:eM,defaultShaderStages:nC,defined:rv,degrees:KC,deltaTime:$G,densityFog:i8,densityFogFactor:qS,depth:fS,depthPass:z6,determinant:oR,difference:hR,diffuseColor:no,directPointLight:cI,directionToColor:mN,directionToFaceDirection:Yg,dispersion:mM,distance:uR,div:Yc,dodge:EV,dot:Hf,drawIndex:q2,dynamicBufferAttribute:OR,element:xC,emissive:cM,equal:yM,equals:lR,equirectUV:pS,exp:xM,exp2:jg,expression:kd,faceDirection:HM,faceForward:RM,faceforward:Uz,float:at,floatBitsToInt:LG,floatBitsToUint:DG,floor:kh,fog:Bv,fract:Bd,frameGroup:MC,frameId:vP,frontFacing:KR,fwidth:rR,gain:UG,gapSize:hv,getConstNodeType:hC,getCurrentStack:R_,getDirection:HN,getDistanceAttenuation:sT,getGeometryRoughness:wN,getNormalFromDepth:d6,getParallaxCorrectNormal:gH,getRoughness:gS,getScreenPosition:h6,getShIrradianceAt:vI,getShadowMaterial:eI,getShadowRenderObjectFunction:nI,getTextureIndex:gP,getViewPosition:c0,globalId:c8,glsl:Y6,glslFn:Z6,grayscale:P6,greaterThan:vM,greaterThanEqual:PC,hash:BG,highpModelNormalViewMatrix:GM,highpModelViewMatrix:VM,hue:D6,increment:HC,incrementBefore:GC,instance:K4,instanceIndex:qf,instancedArray:_6,instancedBufferAttribute:X_,instancedDynamicBufferAttribute:DM,instancedMesh:Z2,int:Dt,intBitsToFloat:OG,inverse:aR,inverseSqrt:_M,inversesqrt:kz,invocationLocalIndex:Z4,invocationSubgroupIndex:Y4,ior:dv,iridescence:D_,iridescenceIOR:uM,iridescenceThickness:hM,ivec2:gl,ivec3:mC,ivec4:gC,js:X6,label:MR,length:zh,lengthSq:EM,lessThan:RC,lessThanEqual:NC,lightPosition:ZS,lightProjectionUV:VP,lightShadowMatrix:Ab,lightTargetDirection:JS,lightTargetPosition:GP,lightViewPosition:KS,lightingContext:rN,lights:nW,linearDepth:n0,linearToneMapping:PP,localId:u8,log:z_,log2:Bh,logarithmicDepthToViewZ:mV,luminance:jS,mat2:P_,mat3:$l,mat4:um,matcapUV:rP,materialAO:j2,materialAlphaTest:b2,materialAnisotropy:O2,materialAnisotropyVector:Jg,materialAttenuationColor:W2,materialAttenuationDistance:G2,materialClearcoat:R2,materialClearcoatNormal:P2,materialClearcoatRoughness:N2,materialColor:nb,materialDispersion:$2,materialEmissive:M2,materialEnvIntensity:K_,materialEnvRotation:XM,materialIOR:V2,materialIridescence:F2,materialIridescenceIOR:B2,materialIridescenceThickness:U2,materialLightMap:sS,materialLineDashOffset:rS,materialLineDashSize:nS,materialLineGapSize:iS,materialLineScale:tS,materialLineWidth:sb,materialMetalness:A2,materialNormal:C2,materialOpacity:ib,materialPointSize:H2,materialReference:$d,materialReflectivity:rb,materialRefractionRatio:n2,materialRotation:I2,materialRoughness:E2,materialSheen:L2,materialSheenRoughness:D2,materialShininess:w2,materialSpecular:S2,materialSpecularColor:T2,materialSpecularIntensity:eS,materialSpecularStrength:Tv,materialThickness:z2,materialTransmission:k2,max:va,maxMipLevel:BM,mediumpModelViewMatrix:ZR,metalness:av,min:Ec,mix:$s,mixElement:yR,mod:pv,modInt:jC,modelDirection:M4,modelNormalMatrix:YR,modelPosition:S4,modelRadius:qR,modelScale:T4,modelViewMatrix:Hd,modelViewPosition:E4,modelViewProjection:oS,modelWorldMatrix:Nu,modelWorldMatrixInverse:A4,morphReference:iN,mrt:yP,mul:Jr,mx_aastep:mI,mx_add:JW,mx_atan2:rH,mx_cell_noise_float:XW,mx_contrast:UW,mx_divide:tH,mx_fractal_noise_float:qW,mx_fractal_noise_vec2:YW,mx_fractal_noise_vec3:ZW,mx_fractal_noise_vec4:KW,mx_frame:oH,mx_heighttonormal:mH,mx_hsvtorgb:CW,mx_ifequal:uH,mx_ifgreater:lH,mx_ifgreatereq:cH,mx_invert:aH,mx_modulo:nH,mx_multiply:eH,mx_noise_float:kW,mx_noise_vec3:zW,mx_noise_vec4:VW,mx_place2d:dH,mx_power:iH,mx_ramp4:LW,mx_ramplr:PW,mx_ramptb:IW,mx_rgbtohsv:RW,mx_rotate2d:fH,mx_rotate3d:pH,mx_safepower:BW,mx_separate:hH,mx_splitlr:DW,mx_splittb:OW,mx_srgb_texture_to_lin_rec709:NW,mx_subtract:QW,mx_timer:sH,mx_transform_uv:FW,mx_unifiednoise2d:GW,mx_unifiednoise3d:WW,mx_worley_noise_float:HW,mx_worley_noise_vec2:$W,mx_worley_noise_vec3:jW,negate:eR,neutralToneMapping:FP,nodeArray:cm,nodeImmutable:xi,nodeObject:Cn,nodeObjectIntent:sv,nodeObjects:C_,nodeProxy:Vr,nodeProxyIntent:ci,normalFlat:JR,normalGeometry:Z_,normalLocal:Ac,normalMap:JM,normalView:po,normalViewGeometry:Zg,normalWorld:Xf,normalWorldGeometry:QR,normalize:Fd,not:DC,notEqual:CC,numWorkgroups:a8,objectDirection:v4,objectGroup:gM,objectPosition:XR,objectRadius:w4,objectScale:_4,objectViewPosition:b4,objectWorldMatrix:x4,oneMinus:tR,or:LC,orthographicDepthToViewZ:pV,oscSawtooth:YG,oscSine:jG,oscSquare:XG,oscTriangle:qG,output:$g,outputStruct:NG,overlay:CV,overloadingFn:Dl,parabola:zS,parallaxDirection:v2,parallaxUV:W4,parameter:SG,pass:U6,passTexture:k6,pcurve:kG,perspectiveDepthToViewZ:hS,pmremTexture:BS,pointShadow:lI,pointUV:w6,pointWidth:Iz,positionGeometry:Ll,positionLocal:La,positionPrevious:Y_,positionView:Da,positionViewDirection:Go,positionWorld:Jc,positionWorldDirection:WM,posterize:B6,pow:Tu,pow2:TM,pow3:dR,pow4:fR,premultiplyAlpha:fN,property:oh,quadBroadcast:Q8,quadSwapDiagonal:X8,quadSwapX:$8,quadSwapY:j8,radians:ZC,rand:gR,range:s8,rangeFog:n8,rangeFogFactor:XS,reciprocal:iR,reference:Po,referenceBuffer:YM,reflect:cR,reflectVector:s2,reflectView:i2,reflector:s6,refract:CM,refractVector:o2,refractView:r2,reinhardToneMapping:IP,remap:kR,remapClamp:zR,renderGroup:or,renderOutput:FM,rendererReference:IR,rotate:Av,rotateUV:ZG,roughness:Fh,round:nR,rtt:_P,sRGBTransferEOTF:CR,sRGBTransferOETF:RR,sample:p6,sampler:a4,samplerComparison:l4,saturate:AM,saturation:I6,screen:AV,screenCoordinate:wv,screenDPR:HR,screenSize:pm,screenUV:Vd,scriptable:t8,scriptableValue:Mb,select:Sl,setCurrentStack:ov,setName:NM,shaderStages:tM,shadow:rI,shadowPositionWorld:tT,shapeCircle:mW,sharedUniformGroup:U_,sheen:hm,sheenRoughness:L_,shiftLeft:zC,shiftRight:VC,shininess:F_,sign:mv,sin:Zc,sinc:zG,skinning:eN,smoothstep:Au,smoothstepElement:vR,specularColor:Tc,specularF90:uv,spherizeUV:KG,split:Nz,spritesheetUV:t6,sqrt:Uh,stack:mb,step:W_,stepElement:xR,storage:ym,storageBarrier:p8,storageObject:iV,storageTexture:SP,string:Cz,struct:RG,sub:Os,subBuild:Xg,subgroupAdd:P8,subgroupAll:G8,subgroupAnd:B8,subgroupAny:W8,subgroupBallot:N8,subgroupBroadcast:q8,subgroupBroadcastFirst:H8,subgroupElect:R8,subgroupExclusiveAdd:L8,subgroupExclusiveMul:F8,subgroupInclusiveAdd:I8,subgroupInclusiveMul:O8,subgroupIndex:q4,subgroupMax:V8,subgroupMin:z8,subgroupMul:D8,subgroupOr:U8,subgroupShuffle:Y8,subgroupShuffleDown:J8,subgroupShuffleUp:K8,subgroupShuffleXor:Z8,subgroupSize:h8,subgroupXor:k8,tan:JC,tangentGeometry:Q_,tangentLocal:Sv,tangentView:eb,tangentWorld:g2,texture:Is,texture3D:TP,textureBarrier:m8,textureBicubic:r5,textureBicubicLevel:bS,textureCubeUV:$N,textureLoad:Ia,textureSize:$f,textureStore:S6,thickness:dM,time:o0,toneMapping:LR,toneMappingExposure:DR,toonOutlinePass:G6,transformDirection:pR,transformNormal:e2,transformNormalToView:$M,transformedClearcoatNormalView:P4,transformedNormalView:R4,transformedNormalWorld:N4,transmission:B_,transpose:sR,triNoise3D:GG,triplanarTexture:n6,triplanarTextures:xP,trunc:SM,uint:Li,uintBitsToFloat:FG,uniform:cr,uniformArray:jl,uniformCubeTexture:L4,uniformFlow:wR,uniformGroup:wC,uniformTexture:o4,unpremultiplyAlpha:SV,userData:C6,uv:xo,uvec2:fC,uvec3:Hg,uvec4:yC,varying:Vh,varyingProperty:qc,vec2:Bn,vec3:Xt,vec4:Bi,vectorComponents:am,velocity:N6,vertexColor:lN,vertexIndex:X2,vertexStage:AR,vibrance:L6,viewZToLogarithmicDepth:dS,viewZToOrthographicDepth:t0,viewZToPerspectiveDepth:uS,viewport:qg,viewportCoordinate:$R,viewportDepthTexture:cS,viewportLinearDepth:gV,viewportMipTexture:lS,viewportResolution:f4,viewportSafeUV:QG,viewportSharedTexture:pN,viewportSize:zM,viewportTexture:dV,viewportUV:d4,wgsl:q6,wgslFn:K6,workgroupArray:v8,workgroupBarrier:f8,workgroupId:l8,workingToColorSpace:NR,xor:OC});const ch=new kS;class yH extends Zf{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,n){const s=this.renderer,o=this.nodes.getBackgroundNode(e)||e.background;let a=!1;if(o===null)s._clearColor.getRGB(ch),ch.a=s._clearColor.a;else if(o.isColor===!0)o.getRGB(ch),ch.a=1,a=!0;else if(o.isNode===!0){const u=this.get(e),d=o;ch.copy(s._clearColor);let p=u.backgroundMesh;if(p===void 0){let G=function(){o.removeEventListener("dispose",G),p.material.dispose(),p.geometry.dispose()};const y=gv(Bi(d).mul($S),{getUV:()=>MP.mul(QR),getTextureLevel:()=>wP});let M=oS;M=M.setZ(M.w);const T=new xa;T.name="Background.material",T.side=Y,T.depthTest=!1,T.depthWrite=!1,T.allowOverride=!1,T.fog=!1,T.lights=!1,T.vertexNode=M,T.colorNode=y,u.backgroundMeshNode=y,u.backgroundMesh=p=new Ks(new Yu(1,32,32),T),p.frustumCulled=!1,p.name="Background.mesh",p.onBeforeRender=function(z,I,J){this.matrixWorld.copyPosition(J.matrixWorld)},o.addEventListener("dispose",G)}const m=d.getCacheKey();u.backgroundCacheKey!==m&&(u.backgroundMeshNode.node=Bi(d).mul($S),u.backgroundMeshNode.needsUpdate=!0,p.material.needsUpdate=!0,u.backgroundCacheKey=m),t.unshift(p,p.geometry,p.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",o);const c=s.xr.getEnvironmentBlendMode();if(c==="additive"?ch.set(0,0,0,1):c==="alpha-blend"&&ch.set(0,0,0,0),s.autoClear===!0||a===!0){const u=n.clearColorValue;u.r=ch.r,u.g=ch.g,u.b=ch.b,u.a=ch.a,(s.backend.isWebGLBackend===!0||s.alpha===!0)&&(u.r*=u.a,u.g*=u.a,u.b*=u.a),n.depthClearValue=s._clearDepth,n.stencilClearValue=s._clearStencil,n.clearColor=s.autoClearColor===!0,n.clearDepth=s.autoClearDepth===!0,n.clearStencil=s.autoClearStencil===!0}else n.clearColor=!1,n.clearDepth=!1,n.clearStencil=!1}}let vH=0;class lT{constructor(e="",t=[],n=0,s=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=s,this.id=vH++}}class xH{constructor(e,t,n,s,o,a,c,u,d,p=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=n,this.transforms=p,this.nodeAttributes=s,this.bindings=o,this.updateNodes=a,this.updateBeforeNodes=c,this.updateAfterNodes=u,this.observer=d,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){const s=new lT(t.name,[],t.index,t.bindingsReference);e.push(s);for(const o of t.bindings)s.bindings.push(o.clone())}else e.push(t);return e}}class xI{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}}class _H{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class _I{constructor(e,t,n=!1,s=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=n,this.count=s}}class bH extends _I{constructor(e,t,n=null,s=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=n,this.interpolationSampling=s}}class wH{constructor(e,t,n=""){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}}let MH=0;class cT{constructor(e=null){this.id=MH++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class SH{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class Qf{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class TH extends Qf{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class EH extends Qf{constructor(e,t=new yn){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class AH extends Qf{constructor(e,t=new it){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class CH extends Qf{constructor(e,t=new mr){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class RH extends Qf{constructor(e,t=new jn){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class NH extends Qf{constructor(e,t=new Yp){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class PH extends Qf{constructor(e,t=new jr){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class IH extends Qf{constructor(e,t=new Ft){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class LH extends TH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class DH extends EH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class OH extends AH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class FH extends CH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class BH extends RH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class UH extends NH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class kH extends PH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class zH extends IH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const bI=new WeakMap,VH=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),Lb=i=>/e/g.test(i)?String(i).replace(/\+/g,""):(i=Number(i),i+(i%1?"":".0"));class wI{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=mb(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new cT,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.currentStack=null,this.subBuildFn=null}getBindGroupsCache(){let e=bI.get(this.renderer);return e===void 0&&(e=new ah,bI.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new Ja(e,t,n)}createCubeRenderTarget(e,t){return new gN(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){const n=this.getBindGroupsCache(),s=[];let o=!0;for(const c of t)s.push(c),o=o&&c.groupNode.shared!==!0;let a;return o?(a=n.get(s),a===void 0&&(a=new lT(e,s,this.bindingsIndexes[e].group,s),n.set(s,a))):a=new lT(e,s,this.bindingsIndexes[e].group,s),a}getBindGroupArray(e,t){const n=this.bindings[t];let s=n[e];return s===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=s=[]),s}getBindings(){let e=this.bindGroups;if(e===null){const t={},n=this.bindings;for(const s of tM)for(const o in n[s]){const a=n[s][o];(t[o]||(t[o]=[])).push(...a)}e=[];for(const s in t){const o=t[s],a=this._getBindGroup(s,o);e.push(a)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,n)=>t.bindings[0].groupNode.order-n.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){const n=e[t];this.bindingsIndexes[n.name].group=t,n.index=t}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){this.nodes.includes(e)===!1&&(this.nodes.push(e),this.setHashNode(e,e.getHash(this)))}addSequentialNode(e){this.sequentialNodes.includes(e)===!1&&this.sequentialNodes.push(e)}buildUpdateNodes(){for(const e of this.nodes)e.getUpdateType()!==ss.NONE&&this.updateNodes.push(e);for(const e of this.sequentialNodes){const t=e.getUpdateBeforeType(),n=e.getUpdateAfterType();t!==ss.NONE&&this.updateBeforeNodes.push(e),n!==ss.NONE&&this.updateAfterNodes.push(e)}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===Rn||e.magFilter===bi||e.magFilter===pn||e.magFilter===Qn||e.minFilter===Rn||e.minFilter===bi||e.minFilter===pn||e.minFilter===Qn}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw new Error("NodeBuilder: Invalid node chaining!")}getMethod(e){return e}getTernary(){return null}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}getSharedContext(){return Ys({},this.context),this.context}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){const n=this.getDataFromNode(e);return n.cache===void 0&&(n.cache=new cT(t?this.getCache():null)),n.cache}isAvailable(){return!1}getVertexIndex(){console.warn("Abstract function.")}getInstanceIndex(){console.warn("Abstract function.")}getDrawIndex(){console.warn("Abstract function.")}getFrontFacing(){console.warn("Abstract function.")}getFragCoord(){console.warn("Abstract function.")}isFlipY(){return!1}increaseUsage(e){const t=this.getDataFromNode(e);return t.usageCount=t.usageCount===void 0?1:t.usageCount+1,t.usageCount}generateTexture(){console.warn("Abstract function.")}generateTextureLod(){console.warn("Abstract function.")}generateArrayDeclaration(e,t){return this.getType(e)+"[ "+t+" ]"}generateArray(e,t,n=null){let s=this.generateArrayDeclaration(e,t)+"( ";for(let o=0;o<t;o++){const a=n?n[o]:null;a!==null?s+=a.build(this,e):s+=this.generateConst(e),o<t-1&&(s+=", ")}return s+=" )",s}generateStruct(e,t,n=null){const s=[];for(const o of t){const{name:a,type:c}=o;n&&n[a]&&n[a].isNode?s.push(n[a].build(this,c)):s.push(this.generateConst(c))}return e+"( "+s.join(", ")+" )"}generateConst(e,t=null){if(t===null&&(e==="float"||e==="int"||e==="uint"?t=0:e==="bool"?t=!1:e==="color"?t=new jn:e==="vec2"?t=new yn:e==="vec3"?t=new it:e==="vec4"&&(t=new mr)),e==="float")return Lb(t);if(e==="int")return`${Math.round(t)}`;if(e==="uint")return t>=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${Lb(t.r)}, ${Lb(t.g)}, ${Lb(t.b)} )`;const n=this.getTypeLength(e),s=this.getComponentType(e),o=a=>this.generateConst(s,a);if(n===2)return`${this.getType(e)}( ${o(t.x)}, ${o(t.y)} )`;if(n===3)return`${this.getType(e)}( ${o(t.x)}, ${o(t.y)}, ${o(t.z)} )`;if(n===4&&e!=="mat2")return`${this.getType(e)}( ${o(t.x)}, ${o(t.y)}, ${o(t.z)}, ${o(t.w)} )`;if(n>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(o).join(", ")} )`;if(n>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const n=this.attributes;for(const o of n)if(o.name===e)return o;const s=new xI(e,t);return this.registerDeclaration(s),n.push(s),s}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="samplerComparison"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===Ls)return"int";if(t===ls)return"uint"}return"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;let n=Yw(e);const s=t==="float"?"":t[0];return/mat2/.test(t)===!0&&(n=n.replace("vec","mat")),s+n}getTypeFromArray(e){return VH.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const n=t.array,s=e.itemSize,o=e.normalized;let a;return!(e instanceof Xm)&&o!==!0&&(a=this.getTypeFromArray(n)),this.getTypeFromLength(s,a)}getTypeLength(e){const t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n!==null?Number(n[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}addStack(){this.stack=mb(this.stack);const e=R_();return this.stacks.push(e),ov(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,ov(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let s=n.getData(e);s===void 0&&(s={},n.setData(e,s)),s[t]===void 0&&(s[t]={});let o=s[t];const a=s.any?s.any.subBuilds:null,c=this.getClosestSubBuild(a);return c&&(o.subBuildsCache===void 0&&(o.subBuildsCache={}),o=o.subBuildsCache[c]||(o.subBuildsCache[c]={}),o.subBuilds=a),o}getNodeProperties(e,t="any"){const n=this.getDataFromNode(e,t);return n.properties||(n.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const n=this.getDataFromNode(e);let s=n.bufferAttribute;if(s===void 0){const o=this.uniforms.index++;s=new xI("nodeAttribute"+o,t,e),this.bufferAttributes.push(s),n.bufferAttribute=s}return s}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,n=null,s=this.shaderStage){const o=this.getDataFromNode(e,s,this.globalCache);let a=o.structType;if(a===void 0){const c=this.structs.index++;n===null&&(n="StructType"+c),a=new SH(n,t),this.structs[s].push(a),this.types[s][n]=e,o.structType=a}return a}getOutputStructTypeFromNode(e,t){const n=this.getStructTypeFromNode(e,t,"OutputType","fragment");return n.output=!0,n}getUniformFromNode(e,t,n=this.shaderStage,s=null){const o=this.getDataFromNode(e,n,this.globalCache);let a=o.uniform;if(a===void 0){const c=this.uniforms.index++;a=new _H(s||"nodeUniform"+c,t,e),this.uniforms[n].push(a),this.registerDeclaration(a),o.uniform=a}return a}getVarFromNode(e,t=null,n=e.getNodeType(this),s=this.shaderStage,o=!1){const a=this.getDataFromNode(e,s),c=this.getSubBuildProperty("variable",a.subBuilds);let u=a[c];if(u===void 0){const d=o?"_const":"_var",p=this.vars[s]||(this.vars[s]=[]),m=this.vars[d]||(this.vars[d]=0);t===null&&(t=(o?"nodeConst":"nodeVar")+m,this.vars[d]++),c!=="variable"&&(t=this.getSubBuildProperty(t,a.subBuilds));const y=e.getArrayCount(this);u=new _I(t,n,o,y),o||p.push(u),this.registerDeclaration(u),a[c]=u}return u}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0)&&(e.cNode?this.isDeterministic(e.cNode):!0);if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0);if(e.isArrayNode){if(e.values!==null){for(const t of e.values)if(!this.isDeterministic(t))return!1}return!0}else if(e.isConstNode)return!0;return!1}getVaryingFromNode(e,t=null,n=e.getNodeType(this),s=null,o=null){const a=this.getDataFromNode(e,"any"),c=this.getSubBuildProperty("varying",a.subBuilds);let u=a[c];if(u===void 0){const d=this.varyings,p=d.length;t===null&&(t="nodeVarying"+p),c!=="varying"&&(t=this.getSubBuildProperty(t,a.subBuilds)),u=new bH(t,n,s,o),d.push(u),this.registerDeclaration(u),a[c]=u}return u}registerDeclaration(e){const t=this.shaderStage,n=this.declarations[t]||(this.declarations[t]={}),s=this.getPropertyName(e);let o=1,a=s;for(;n[a]!==void 0;)a=s+"_"+o++;o>1&&(e.name=a,console.warn(`THREE.TSL: Declaration name '${s}' of '${e.type}' already in use. Renamed to '${a}'.`)),n[a]=e}getCodeFromNode(e,t,n=this.shaderStage){const s=this.getDataFromNode(e);let o=s.code;if(o===void 0){const a=this.codes[n]||(this.codes[n]=[]),c=a.length;o=new wH("nodeCode"+c,t),a.push(o),s.code=o}return o}addFlowCodeHierarchy(e,t){const{flowCodes:n,flowCodeBlock:s}=this.getDataFromNode(e);let o=!0,a=t;for(;a;){if(s.get(a)===!0){o=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(o)for(const c of n)this.addLineFlowCode(c)}addLineFlowCodeBlock(e,t,n){const s=this.getDataFromNode(e),o=s.flowCodes||(s.flowCodes=[]),a=s.flowCodeBlock||(s.flowCodeBlock=new WeakMap);o.push(t),a.set(n,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`;
|
|
|
`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=" ",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),n=this.flowChildNode(e,t);return this.flowsData.set(e,n),n}addInclude(e){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=new BP,n=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=n,t}flowShaderNode(e){const t=e.layout,n={[Symbol.iterator](){let a=0;const c=Object.values(this);return{next:()=>({value:c[a],done:a++>=c.length})}}};for(const a of t.inputs)n[a.name]=new pP(a.type,a.name);e.layout=null;const s=e.call(n),o=this.flowStagesNode(s,t.type);return e.layout=t,o}flowBuildStage(e,t,n=null){const s=this.getBuildStage();this.setBuildStage(t);const o=e.build(this,n);return this.setBuildStage(s),o}flowStagesNode(e,t=null){const n=this.flow,s=this.vars,o=this.declarations,a=this.cache,c=this.buildStage,u=this.stack,d={code:""};this.flow=d,this.vars={},this.declarations={},this.cache=new cT,this.stack=mb();for(const p of eM)this.setBuildStage(p),d.result=e.build(this,t);return d.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=s,this.declarations=o,this.cache=a,this.stack=u,this.setBuildStage(c),d}getFunctionOperator(){return null}buildFunctionCode(){console.warn("Abstract function.")}flowChildNode(e,t=null){const n=this.flow,s={code:""};return this.flow=s,s.result=e.build(this,t),this.flow=n,s}flowNodeFromShaderStage(e,t,n=null,s=null){const o=this.tab,a=this.cache,c=this.shaderStage,u=this.context;this.setShaderStage(e);const d=Ys({},this.context);delete d.nodeBlock,this.cache=this.globalCache,this.tab=" ",this.context=d;let p=null;if(this.buildStage==="generate"){const m=this.flowChildNode(t,n);s!==null&&(m.code+=`${this.tab+s} = ${m.result};
|
|
|
`),this.flowCode[e]=this.flowCode[e]+m.code,p=m}else p=t.build(this);return this.setShaderStage(c),this.cache=a,this.tab=o,this.context=u,p}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t,n=null){return`${n!==null?this.generateArrayDeclaration(e,n):this.getType(e)} ${t}`}getVars(e){let t="";const n=this.vars[e];if(n!==void 0)for(const s of n)t+=`${this.getVar(s.type,s.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let n="";if(t!==void 0)for(const s of t)n+=s.code+`
|
|
|
`;return n}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(e&&e.isNode?e.isShaderCallNodeInternal?t=e.shaderNode.subBuilds:e.isStackNode?t=[e.subBuild]:t=this.getDataFromNode(e,"any").subBuilds:e instanceof Set?t=[...e]:t=e,!t)return null;const n=this.subBuildLayers;for(let s=t.length-1;s>=0;s--){const o=t[s];if(n.includes(o))return o}return null}getSubBuildOutput(e){return this.getSubBuildProperty("outputNode",e)}getSubBuildProperty(e="",t=null){let n;t!==null?n=this.getClosestSubBuild(t):n=this.subBuildFn;let s;return n?s=e?n+"_"+e:n:s=e,s}build(){const{object:e,material:t,renderer:n}=this;if(t!==null){let s=n.library.fromMaterial(t);s===null&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),s=new xa),s.build(this)}else this.addFlow("compute",e);for(const s of eM){this.setBuildStage(s),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const o of tM){this.setShaderStage(o);const a=this.flowNodes[o];for(const c of a)s==="generate"?this.flowNode(c):c.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if(t==="float"||t==="int"||t==="uint")return new LH(e);if(t==="vec2"||t==="ivec2"||t==="uvec2")return new DH(e);if(t==="vec3"||t==="ivec3"||t==="uvec3")return new OH(e);if(t==="vec4"||t==="ivec4"||t==="uvec4")return new FH(e);if(t==="color")return new BH(e);if(t==="mat2")return new UH(e);if(t==="mat3")return new kH(e);if(t==="mat4")return new zH(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,n){if(t=this.getVectorType(t),n=this.getVectorType(n),t===n||n===null||this.isReference(n))return e;const s=this.getTypeLength(t),o=this.getTypeLength(n);return s===16&&o===9?`${this.getType(n)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:s===9&&o===4?`${this.getType(n)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:s>4||o>4||o===0?e:s===o?`${this.getType(n)}( ${e} )`:s>o?(e=n==="bool"?`all( ${e} )`:`${e}.${"xyz".slice(0,o)}`,this.format(e,this.getTypeFromLength(o,this.getComponentType(t)),n)):o===4&&s>1?`${this.getType(n)}( ${this.format(e,t,"vec3")}, 1.0 )`:s===2?`${this.getType(n)}( ${this.format(e,t,"vec2")}, 0.0 )`:(s===1&&o>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r${w} - Node System
|
|
|
`}}class MI{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let n=e.get(t);return n===void 0&&(n={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,n)),n}updateBeforeNode(e){const t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===ss.FRAME){const{frameMap:s}=this._getMaps(this.updateBeforeMap,n);s.get(n)!==this.frameId&&e.updateBefore(this)!==!1&&s.set(n,this.frameId)}else if(t===ss.RENDER){const{renderMap:s}=this._getMaps(this.updateBeforeMap,n);s.get(n)!==this.renderId&&e.updateBefore(this)!==!1&&s.set(n,this.renderId)}else t===ss.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===ss.FRAME){const{frameMap:s}=this._getMaps(this.updateAfterMap,n);s.get(n)!==this.frameId&&e.updateAfter(this)!==!1&&s.set(n,this.frameId)}else if(t===ss.RENDER){const{renderMap:s}=this._getMaps(this.updateAfterMap,n);s.get(n)!==this.renderId&&e.updateAfter(this)!==!1&&s.set(n,this.renderId)}else t===ss.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),n=e.updateReference(this);if(t===ss.FRAME){const{frameMap:s}=this._getMaps(this.updateMap,n);s.get(n)!==this.frameId&&e.update(this)!==!1&&s.set(n,this.frameId)}else if(t===ss.RENDER){const{renderMap:s}=this._getMaps(this.updateMap,n);s.get(n)!==this.renderId&&e.update(this)!==!1&&s.set(n,this.renderId)}else t===ss.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class uT{constructor(e,t,n=null,s="",o=!1){this.type=e,this.name=t,this.count=n,this.qualifier=s,this.isConst=o}}uT.isNodeFunctionInput=!0;class GH extends Tm{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:JS(this.light),lightColor:e}}}const hT=new Ft,Db=new Ft;let Hv=null;class WH extends Tm{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=cr(new it).setGroup(or),this.halfWidth=cr(new it).setGroup(or),this.updateType=ss.RENDER}update(e){super.update(e);const{light:t}=this,n=e.camera.matrixWorldInverse;Db.identity(),hT.copy(t.matrixWorld),hT.premultiply(n),Db.extractRotation(hT),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(Db),this.halfHeight.value.applyMatrix4(Db)}setupDirectRectArea(e){let t,n;e.isAvailable("float32Filterable")?(t=Is(Hv.LTC_FLOAT_1),n=Is(Hv.LTC_FLOAT_2)):(t=Is(Hv.LTC_HALF_1),n=Is(Hv.LTC_HALF_2));const{colorNode:s,light:o}=this,a=KS(o);return{lightColor:s,lightPosition:a,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:n}}static setLTC(e){Hv=e}}class dT extends Tm{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=cr(0).setGroup(or),this.penumbraCosNode=cr(0).setGroup(or),this.cutoffDistanceNode=cr(0).setGroup(or),this.decayExponentNode=cr(0).setGroup(or),this.colorNode=cr(this.color).setGroup(or)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:n,penumbraCosNode:s}=this;return Au(n,s,t)}getLightCoord(e){const t=e.getNodeProperties(this);let n=t.projectionUV;return n===void 0&&(n=VP(this.light,e.context.positionWorld),t.projectionUV=n),n}setupDirect(e){const{colorNode:t,cutoffDistanceNode:n,decayExponentNode:s,light:o}=this,a=this.getLightVector(e),c=a.normalize(),u=c.dot(JS(o)),d=this.getSpotAttenuation(e,u),p=a.length(),m=sT({lightDistance:p,cutoffDistance:n,decayExponent:s});let y=t.mul(d).mul(m),M,T;return o.colorNode?(T=this.getLightCoord(e),M=o.colorNode(T)):o.map&&(T=this.getLightCoord(e),M=Is(o.map,T.xy).onRenderUpdate(()=>o.map)),M&&(y=T.mul(2).sub(1).abs().lessThan(1).all().select(y.mul(M),y)),{lightColor:y,lightDirection:c}}}class HH extends dT{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){const n=this.light.iesMap;let s=null;if(n&&n.isTexture===!0){const o=t.acos().mul(1/Math.PI);s=Is(n,Bn(o,0),0).r}else s=super.getSpotAttenuation(t);return s}}const $H=Kt(([i,e])=>{const t=i.abs().sub(e);return zh(va(t,0)).add(Ec(va(t.x,t.y),0))});class jH extends dT{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),t.aspect===null){let n=1;t.map!==null&&(n=t.map.width/t.map.height),t.shadow.aspect=n}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=at(0),n=this.penumbraCosNode,s=Ab(this.light).mul(e.context.positionWorld||Jc);return sr(s.w.greaterThan(0),()=>{const o=s.xyz.div(s.w),a=$H(o.xy.sub(Bn(.5)),Bn(.5)),c=Yc(-1,Os(1,bM(n)).sub(1));t.assign(AM(a.mul(-2).mul(c)))}),t}}class XH extends Tm{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class qH extends Tm{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=ZS(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=cr(new jn).setGroup(or)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:n,lightDirectionNode:s}=this,a=Xf.dot(s).mul(.5).add(.5),c=$s(n,t,a);e.context.irradiance.addAssign(c)}}class YH extends Tm{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let n=0;n<9;n++)t.push(new it);this.lightProbe=jl(t)}update(e){const{light:t}=this;super.update(e);for(let n=0;n<9;n++)this.lightProbe.array[n].copy(t.sh.coefficients[n]).multiplyScalar(t.intensity)}setup(e){const t=vI(Xf,this.lightProbe);e.context.irradiance.addAssign(t)}}class SI{parseFunction(){console.warn("Abstract function.")}}class fT{constructor(e,t,n="",s=""){this.type=e,this.inputs=t,this.name=n,this.precision=s}getCode(){console.warn("Abstract function.")}}fT.isNodeFunction=!0;const ZH=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,KH=/[a-z_0-9]+/ig,TI="#pragma main",JH=i=>{i=i.trim();const e=i.indexOf(TI),t=e!==-1?i.slice(e+TI.length):i,n=t.match(ZH);if(n!==null&&n.length===5){const s=n[4],o=[];let a=null;for(;(a=KH.exec(s))!==null;)o.push(a);const c=[];let u=0;for(;u<o.length;){const T=o[u][0]==="const";T===!0&&u++;let G=o[u][0];G==="in"||G==="out"||G==="inout"?u++:G="";const z=o[u++][0];let I=Number.parseInt(o[u][0]);Number.isNaN(I)===!1?u++:I=null;const J=o[u++][0];c.push(new uT(z,J,I,G,T))}const d=t.substring(n[0].length),p=n[3]!==void 0?n[3]:"",m=n[2],y=n[1]!==void 0?n[1]:"",M=e!==-1?i.slice(0,e):"";return{type:m,inputs:c,name:p,precision:y,inputsCode:s,blockCode:d,headerCode:M}}else throw new Error("FunctionNode: Function is not a GLSL code.")};class QH extends fT{constructor(e){const{type:t,inputs:n,name:s,precision:o,inputsCode:a,blockCode:c,headerCode:u}=JH(e);super(t,n,s,o),this.inputsCode=a,this.blockCode=c,this.headerCode=u}getCode(e=this.name){let t;const n=this.blockCode;if(n!==""){const{type:s,inputsCode:o,headerCode:a,precision:c}=this;let u=`${s} ${e} ( ${o.trim()} )`;c!==""&&(u=`${c} ${u}`),t=a+u+n}else t="";return t}}class e9 extends SI{parseFunction(e){return new QH(e)}}const EI=new WeakMap,Xh=[],Em=[];class t9 extends Zf{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new MI,this.nodeBuilderCache=new Map,this.callHashCache=new ah,this.groupsData=new ah,this.cacheLib={}}updateGroup(e){const t=e.groupNode,n=t.name;if(n===gM.name)return!0;if(n===or.name){const o=this.get(e),a=this.nodeFrame.renderId;return o.renderId!==a?(o.renderId=a,!0):!1}if(n===MC.name){const o=this.get(e),a=this.nodeFrame.frameId;return o.frameId!==a?(o.frameId=a,!0):!1}Xh[0]=t,Xh[1]=e;let s=this.groupsData.get(Xh);return s===void 0&&this.groupsData.set(Xh,s={}),Xh.length=0,s.version!==t.version?(s.version=t.version,!0):!1}getForRenderCacheKey(e){return e.initialCacheKey}getForRender(e){const t=this.get(e);let n=t.nodeBuilderState;if(n===void 0){const{nodeBuilderCache:s}=this,o=this.getForRenderCacheKey(e);if(n=s.get(o),n===void 0){const a=this.backend.createNodeBuilder(e.object,this.renderer);a.scene=e.scene,a.material=e.material,a.camera=e.camera,a.context.material=e.material,a.lightsNode=e.lightsNode,a.environmentNode=this.getEnvironmentNode(e.scene),a.fogNode=this.getFogNode(e.scene),a.clippingContext=e.clippingContext,this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview&&a.enableMultiview(),a.build(),n=this._createNodeBuilderState(a),s.set(o,n)}n.usedTimes++,t.nodeBuilderState=n}return n}delete(e){if(e.isRenderObject){const t=this.get(e).nodeBuilderState;t.usedTimes--,t.usedTimes===0&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e))}return super.delete(e)}getForCompute(e){const t=this.get(e);let n=t.nodeBuilderState;if(n===void 0){const s=this.backend.createNodeBuilder(e,this.renderer);s.build(),n=this._createNodeBuilderState(s),t.nodeBuilderState=n}return n}_createNodeBuilderState(e){return new xH(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.transforms)}getEnvironmentNode(e){this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{const n=this.get(e);n.environmentNode&&(t=n.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{const n=this.get(e);n.backgroundNode&&(t=n.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){Xh[0]=e,Xh[1]=t;const n=this.renderer.info.calls,s=this.callHashCache.get(Xh)||{};if(s.callId!==n){const o=this.getEnvironmentNode(e),a=this.getFogNode(e);t&&Em.push(t.getCacheKey(!0)),o&&Em.push(o.getCacheKey()),a&&Em.push(a.getCacheKey()),Em.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),Em.push(this.renderer.shadowMap.enabled?1:0),s.callId=n,s.cacheKey=Jy(Em),this.callHashCache.set(Xh,s),Em.length=0}return Xh.length=0,s.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){const t=this.get(e),n=e.background;if(n){const s=e.backgroundBlurriness===0&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==n||s){const o=this.getCacheNode("background",n,()=>{if(n.isCubeTexture===!0||n.mapping===Ce||n.mapping===Re||n.mapping===qe){if(e.backgroundBlurriness>0||n.mapping===qe)return BS(n);{let a;return n.isCubeTexture===!0?a=Kg(n):a=Is(n),xN(a)}}else{if(n.isTexture===!0)return Is(n,Vd.flipY()).setUpdateMatrix(!0);n.isColor!==!0&&console.error("WebGPUNodes: Unsupported background configuration.",n)}},s);t.backgroundNode=o,t.background=n,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,n,s=!1){const o=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let a=o.get(t);return(a===void 0||s)&&(a=n(),o.set(t,a)),a}updateFog(e){const t=this.get(e),n=e.fog;if(n){if(t.fog!==n){const s=this.getCacheNode("fog",n,()=>{if(n.isFogExp2){const o=Po("color","color",n).setGroup(or),a=Po("density","float",n).setGroup(or);return Bv(o,qS(a))}else if(n.isFog){const o=Po("color","color",n).setGroup(or),a=Po("near","float",n).setGroup(or),c=Po("far","float",n).setGroup(or);return Bv(o,XS(a,c))}else console.error("THREE.Renderer: Unsupported fog configuration.",n)});t.fogNode=s,t.fog=n}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),n=e.environment;if(n){if(t.environment!==n){const s=this.getCacheNode("environment",n,()=>{if(n.isCubeTexture===!0)return Kg(n);if(n.isTexture===!0)return Is(n);console.error("Nodes: Unsupported environment configuration.",n)});t.environmentNode=s,t.environment=n}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,n=null,s=null,o=null){const a=this.nodeFrame;return a.renderer=e,a.scene=t,a.object=n,a.camera=s,a.material=o,a}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}hasOutputChange(e){return EI.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,n=this.getOutputCacheKey(),s=e.isArrayTexture?TP(e,Xt(Vd,zd("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):Is(e,Vd).renderOutput(t.toneMapping,t.currentColorSpace);return EI.set(e,n),s}updateBefore(e){const t=e.getNodeBuilderState();for(const n of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(n)}updateAfter(e){const t=e.getNodeBuilderState();for(const n of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(n)}updateForCompute(e){const t=this.getNodeFrame(),n=this.getForCompute(e);for(const s of n.updateNodes)t.updateNode(s)}updateForRender(e){const t=this.getNodeFrameForRender(e),n=e.getNodeBuilderState();for(const s of n.updateNodes)t.updateNode(s)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new MI,this.nodeBuilderCache=new Map,this.cacheLib={}}}const pT=new Rl;class Ob{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new jr,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,n){const s=e.length;for(let o=0;o<s;o++){pT.copy(e[o]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);const a=t[n+o],c=pT.normal;a.x=-c.x,a.y=-c.y,a.z=-c.z,a.w=pT.constant}}updateGlobal(e,t){this.shadowPass=e.overrideMaterial!==null&&e.overrideMaterial.isShadowPassMaterial,this.viewMatrix=t.matrixWorldInverse,this.viewNormalMatrix.getNormalMatrix(this.viewMatrix)}update(e,t){let n=!1;e.version!==this.parentVersion&&(this.intersectionPlanes=Array.from(e.intersectionPlanes),this.unionPlanes=Array.from(e.unionPlanes),this.parentVersion=e.version),this.clipIntersection!==t.clipIntersection&&(this.clipIntersection=t.clipIntersection,this.clipIntersection?this.unionPlanes.length=e.unionPlanes.length:this.intersectionPlanes.length=e.intersectionPlanes.length);const s=t.clippingPlanes,o=s.length;let a,c;if(this.clipIntersection?(a=this.intersectionPlanes,c=e.intersectionPlanes.length):(a=this.unionPlanes,c=e.unionPlanes.length),a.length!==c+o){a.length=c+o;for(let u=0;u<o;u++)a[c+u]=new mr;n=!0}this.projectPlanes(s,a,c),n&&(this.version++,this.cacheKey=`${this.intersectionPlanes.length}:${this.unionPlanes.length}`)}getGroupContext(e){if(this.shadowPass&&!e.clipShadows)return this;let t=this.clippingGroupContexts.get(e);return t===void 0&&(t=new Ob(this),this.clippingGroupContexts.set(e,t)),t.update(this,e),t}get unionClippingCount(){return this.unionPlanes.length}}class n9{constructor(e,t){this.bundleGroup=e,this.camera=t}}const $v=[];class i9{constructor(){this.bundles=new ah}get(e,t){const n=this.bundles;$v[0]=e,$v[1]=t;let s=n.get($v);return s===void 0&&(s=new n9(e,t),n.set($v,s)),$v.length=0,s}dispose(){this.bundles=new ah}}class AI{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null;const n=this.getMaterialNodeClass(e.type);if(n!==null){t=new n;for(const s in e)t[s]=e[s]}return t}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,n){if(n.has(t)){console.warn(`Redefinition of node ${t}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t=="function"||typeof t=="object")throw new Error(`Base class ${t} is not a class.`);n.set(t,e)}addClass(e,t,n){if(n.has(t)){console.warn(`Redefinition of node ${t.name}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t!="function")throw new Error(`Base class ${t.name} is not a class.`);n.set(t,e)}}const r9=new eT,jv=[];class s9 extends ah{constructor(){super()}createNode(e=[]){return new eT().setLights(e)}getNode(e,t){if(e.isQuadMesh)return r9;jv[0]=e,jv[1]=t;let n=this.get(jv);return n===void 0&&(n=this.createNode(),this.set(jv,n)),jv.length=0,n}}class Xv extends Ja{constructor(e=1,t=1,n={}){super(e,t,n),this.isXRRenderTarget=!0,this._hasExternalTextures=!1,this._autoAllocateDepthBuffer=!0,this._isOpaqueFramebuffer=!1}copy(e){return super.copy(e),this._hasExternalTextures=e._hasExternalTextures,this._autoAllocateDepthBuffer=e._autoAllocateDepthBuffer,this._isOpaqueFramebuffer=e._isOpaqueFramebuffer,this}}const CI=new it,RI=new it;class o9 extends Bl{constructor(e,t=!1){super(),this.enabled=!1,this.isPresenting=!1,this.cameraAutoUpdate=!0,this._renderer=e,this._cameraL=new ma,this._cameraL.viewport=new mr,this._cameraR=new ma,this._cameraR.viewport=new mr,this._cameras=[this._cameraL,this._cameraR],this._cameraXR=new Cy,this._currentDepthNear=null,this._currentDepthFar=null,this._controllers=[],this._controllerInputSources=[],this._xrRenderTarget=null,this._layers=[],this._sessionUsesLayers=!1,this._supportsGlBinding=typeof XRWebGLBinding!="undefined",this._frameBufferTargets=null,this._createXRLayer=d9.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSize=new yn,this._onSessionEvent=c9.bind(this),this._onSessionEnd=u9.bind(this),this._onInputSourcesChange=h9.bind(this),this._onAnimationFrame=f9.bind(this),this._referenceSpace=null,this._referenceSpaceType="local-floor",this._customReferenceSpace=null,this._framebufferScaleFactor=1,this._foveation=1,this._session=null,this._glBaseLayer=null,this._glBinding=null,this._glProjLayer=null,this._xrFrame=null,this._supportsLayers=this._supportsGlBinding&&"createProjectionLayer"in XRWebGLBinding.prototype,this._useMultiviewIfPossible=t,this._useMultiview=!1}getController(e){return this._getController(e).getTargetRaySpace()}getControllerGrip(e){return this._getController(e).getGripSpace()}getHand(e){return this._getController(e).getHandSpace()}getFoveation(){if(!(this._glProjLayer===null&&this._glBaseLayer===null))return this._foveation}setFoveation(e){this._foveation=e,this._glProjLayer!==null&&(this._glProjLayer.fixedFoveation=e),this._glBaseLayer!==null&&this._glBaseLayer.fixedFoveation!==void 0&&(this._glBaseLayer.fixedFoveation=e)}getFramebufferScaleFactor(){return this._framebufferScaleFactor}setFramebufferScaleFactor(e){this._framebufferScaleFactor=e,this.isPresenting===!0&&console.warn("THREE.XRManager: Cannot change framebuffer scale while presenting.")}getReferenceSpaceType(){return this._referenceSpaceType}setReferenceSpaceType(e){this._referenceSpaceType=e,this.isPresenting===!0&&console.warn("THREE.XRManager: Cannot change reference space type while presenting.")}getReferenceSpace(){return this._customReferenceSpace||this._referenceSpace}setReferenceSpace(e){this._customReferenceSpace=e}getCamera(){return this._cameraXR}getEnvironmentBlendMode(){if(this._session!==null)return this._session.environmentBlendMode}getBinding(){return this._glBinding===null&&this._supportsGlBinding&&(this._glBinding=new XRWebGLBinding(this._session,this._gl)),this._glBinding}getFrame(){return this._xrFrame}useMultiview(){return this._useMultiview}createQuadLayer(e,t,n,s,o,a,c,u={}){const d=new Ch(e,t),p=new Xv(o,a,{format:D,type:Oi,depthTexture:new vc(o,a,u.stencil?Fa:ls,void 0,void 0,void 0,void 0,void 0,void 0,u.stencil?_:U),stencilBuffer:u.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});p._autoAllocateDepthBuffer=!0;const m=new Hr({color:16777215,side:W});m.map=p.texture,m.map.offset.y=1,m.map.repeat.y=-1;const y=new Ks(d,m);y.position.copy(n),y.quaternion.copy(s);const M={type:"quad",width:e,height:t,translation:n,quaternion:s,pixelwidth:o,pixelheight:a,plane:y,material:m,rendercall:c,renderTarget:p};if(this._layers.push(M),this._session!==null){M.plane.material=new Hr({color:16777215,side:W}),M.plane.material.blending=Ne,M.plane.material.blendEquation=Te,M.plane.material.blendSrc=He,M.plane.material.blendDst=He,M.xrlayer=this._createXRLayer(M);const T=this._session.renderState.layers;T.unshift(M.xrlayer),this._session.updateRenderState({layers:T})}else p.isXRRenderTarget=!1;return y}createCylinderLayer(e,t,n,s,o,a,c,u,d={}){const p=new Cp(e,e,e*t/n,64,64,!0,Math.PI-t/2,t),m=new Xv(a,c,{format:D,type:Oi,depthTexture:new vc(a,c,d.stencil?Fa:ls,void 0,void 0,void 0,void 0,void 0,void 0,d.stencil?_:U),stencilBuffer:d.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});m._autoAllocateDepthBuffer=!0;const y=new Hr({color:16777215,side:Y});y.map=m.texture,y.map.offset.y=1,y.map.repeat.y=-1;const M=new Ks(p,y);M.position.copy(s),M.quaternion.copy(o);const T={type:"cylinder",radius:e,centralAngle:t,aspectratio:n,translation:s,quaternion:o,pixelwidth:a,pixelheight:c,plane:M,material:y,rendercall:u,renderTarget:m};if(this._layers.push(T),this._session!==null){T.plane.material=new Hr({color:16777215,side:Y}),T.plane.material.blending=Ne,T.plane.material.blendEquation=Te,T.plane.material.blendSrc=He,T.plane.material.blendDst=He,T.xrlayer=this._createXRLayer(T);const G=this._session.renderState.layers;G.unshift(T.xrlayer),this._session.updateRenderState({layers:G})}else m.isXRRenderTarget=!1;return M}renderLayers(){const e=new it,t=new ta,n=this._renderer,s=this.isPresenting,o=n.getOutputRenderTarget(),a=n._frameBufferTarget;this.isPresenting=!1;const c=new yn;n.getSize(c);const u=n._quad;for(const d of this._layers)if(d.renderTarget.isXRRenderTarget=this._session!==null,d.renderTarget._hasExternalTextures=d.renderTarget.isXRRenderTarget,d.renderTarget.isXRRenderTarget&&this._sessionUsesLayers){d.xrlayer.transform=new XRRigidTransform(d.plane.getWorldPosition(e),d.plane.getWorldQuaternion(t));const p=this._glBinding.getSubImage(d.xrlayer,this._xrFrame);n.backend.setXRRenderTargetTextures(d.renderTarget,p.colorTexture,void 0),n._setXRLayerSize(d.renderTarget.width,d.renderTarget.height),n.setOutputRenderTarget(d.renderTarget),n.setRenderTarget(null),n._frameBufferTarget=null,this._frameBufferTargets||(this._frameBufferTargets=new WeakMap);const{frameBufferTarget:m,quad:y}=this._frameBufferTargets.get(d.renderTarget)||{frameBufferTarget:null,quad:null};m?(n._frameBufferTarget=m,n._quad=y):(n._quad=new Ov(new xa),this._frameBufferTargets.set(d.renderTarget,{frameBufferTarget:n._getFrameBufferTarget(),quad:n._quad})),d.rendercall(),n._frameBufferTarget=null}else n.setRenderTarget(d.renderTarget),d.rendercall();n.setRenderTarget(null),n.setOutputRenderTarget(o),n._frameBufferTarget=a,n._setXRLayerSize(c.x,c.y),n._quad=u,this.isPresenting=s}getSession(){return this._session}setSession(e){return hr(this,null,function*(){const t=this._renderer,n=t.backend;this._gl=t.getContext();const s=this._gl,o=s.getContextAttributes();if(this._session=e,e!==null){if(n.isWebGPUBackend===!0)throw new Error('THREE.XRManager: XR is currently not supported with a WebGPU backend. Use WebGL by passing "{ forceWebGL: true }" to the constructor of the renderer.');if(e.addEventListener("select",this._onSessionEvent),e.addEventListener("selectstart",this._onSessionEvent),e.addEventListener("selectend",this._onSessionEvent),e.addEventListener("squeeze",this._onSessionEvent),e.addEventListener("squeezestart",this._onSessionEvent),e.addEventListener("squeezeend",this._onSessionEvent),e.addEventListener("end",this._onSessionEnd),e.addEventListener("inputsourceschange",this._onInputSourcesChange),yield n.makeXRCompatible(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._supportsLayers===!0){let a=null,c=null,u=null;t.depth&&(u=t.stencil?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24,a=t.stencil?_:U,c=t.stencil?Fa:ls);const d={colorFormat:s.RGBA8,depthFormat:u,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature("OVR_multiview2")&&(d.textureType="texture-array",this._useMultiview=!0),this._glBinding=this.getBinding();const p=this._glBinding.createProjectionLayer(d),m=[p];this._glProjLayer=p,t.setPixelRatio(1),t._setXRLayerSize(p.textureWidth,p.textureHeight);const y=this._useMultiview?2:1,M=new vc(p.textureWidth,p.textureHeight,c,void 0,void 0,void 0,void 0,void 0,void 0,a,y);if(this._xrRenderTarget=new Xv(p.textureWidth,p.textureHeight,{format:D,type:Oi,colorSpace:t.outputColorSpace,depthTexture:M,stencilBuffer:t.stencil,samples:o.antialias?4:0,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._sessionUsesLayers=e.enabledFeatures.includes("layers"),this._referenceSpace=yield e.requestReferenceSpace(this.getReferenceSpaceType()),this._sessionUsesLayers)for(const T of this._layers)T.plane.material=new Hr({color:16777215,side:T.type==="cylinder"?Y:W}),T.plane.material.blending=Ne,T.plane.material.blendEquation=Te,T.plane.material.blendSrc=He,T.plane.material.blendDst=He,T.xrlayer=this._createXRLayer(T),m.unshift(T.xrlayer);e.updateRenderState({layers:m})}else{const a={antialias:t.samples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},c=new XRWebGLLayer(e,s,a);this._glBaseLayer=c,e.updateRenderState({baseLayer:c}),t.setPixelRatio(1),t._setXRLayerSize(c.framebufferWidth,c.framebufferHeight),this._xrRenderTarget=new Xv(c.framebufferWidth,c.framebufferHeight,{format:D,type:Oi,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:c.ignoreDepthValues===!1,resolveStencilBuffer:c.ignoreDepthValues===!1}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=yield e.requestReferenceSpace(this.getReferenceSpaceType())}this.setFoveation(this.getFoveation()),t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}})}updateCamera(e){const t=this._session;if(t===null)return;const n=e.near,s=e.far,o=this._cameraXR,a=this._cameraL,c=this._cameraR;o.near=c.near=a.near=n,o.far=c.far=a.far=s,o.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==o.near||this._currentDepthFar!==o.far)&&(t.updateRenderState({depthNear:o.near,depthFar:o.far}),this._currentDepthNear=o.near,this._currentDepthFar=o.far),o.layers.mask=e.layers.mask|6,a.layers.mask=o.layers.mask&3,c.layers.mask=o.layers.mask&5;const u=e.parent,d=o.cameras;NI(o,u);for(let p=0;p<d.length;p++)NI(d[p],u);d.length===2?a9(o,a,c):o.projectionMatrix.copy(a.projectionMatrix),l9(e,o,u)}_getController(e){let t=this._controllers[e];return t===void 0&&(t=new $u,this._controllers[e]=t),t}}function a9(i,e,t){CI.setFromMatrixPosition(e.matrixWorld),RI.setFromMatrixPosition(t.matrixWorld);const n=CI.distanceTo(RI),s=e.projectionMatrix.elements,o=t.projectionMatrix.elements,a=s[14]/(s[10]-1),c=s[14]/(s[10]+1),u=(s[9]+1)/s[5],d=(s[9]-1)/s[5],p=(s[8]-1)/s[0],m=(o[8]+1)/o[0],y=a*p,M=a*m,T=n/(-p+m),G=T*-p;if(e.matrixWorld.decompose(i.position,i.quaternion,i.scale),i.translateX(G),i.translateZ(T),i.matrixWorld.compose(i.position,i.quaternion,i.scale),i.matrixWorldInverse.copy(i.matrixWorld).invert(),s[10]===-1)i.projectionMatrix.copy(e.projectionMatrix),i.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const z=a+T,I=c+T,J=y-G,K=M+(n-G),re=u*c/I*z,ve=d*c/I*z;i.projectionMatrix.makePerspective(J,K,re,ve,z,I),i.projectionMatrixInverse.copy(i.projectionMatrix).invert()}}function NI(i,e){e===null?i.matrixWorld.copy(i.matrix):i.matrixWorld.multiplyMatrices(e.matrixWorld,i.matrix),i.matrixWorldInverse.copy(i.matrixWorld).invert()}function l9(i,e,t){t===null?i.matrix.copy(e.matrixWorld):(i.matrix.copy(t.matrixWorld),i.matrix.invert(),i.matrix.multiply(e.matrixWorld)),i.matrix.decompose(i.position,i.quaternion,i.scale),i.updateMatrixWorld(!0),i.projectionMatrix.copy(e.projectionMatrix),i.projectionMatrixInverse.copy(e.projectionMatrixInverse),i.isPerspectiveCamera&&(i.fov=Ua*2*Math.atan(1/i.projectionMatrix.elements[5]),i.zoom=1)}function c9(i){const e=this._controllerInputSources.indexOf(i.inputSource);if(e===-1)return;const t=this._controllers[e];if(t!==void 0){const n=this.getReferenceSpace();t.update(i.inputSource,i.frame,n),t.dispatchEvent({type:i.type,data:i.inputSource})}}function u9(){const i=this._session,e=this._renderer;i.removeEventListener("select",this._onSessionEvent),i.removeEventListener("selectstart",this._onSessionEvent),i.removeEventListener("selectend",this._onSessionEvent),i.removeEventListener("squeeze",this._onSessionEvent),i.removeEventListener("squeezestart",this._onSessionEvent),i.removeEventListener("squeezeend",this._onSessionEvent),i.removeEventListener("end",this._onSessionEnd),i.removeEventListener("inputsourceschange",this._onInputSourcesChange);for(let t=0;t<this._controllers.length;t++){const n=this._controllerInputSources[t];n!==null&&(this._controllerInputSources[t]=null,this._controllers[t].disconnect(n))}if(this._currentDepthNear=null,this._currentDepthFar=null,e._resetXRState(),this._session=null,this._xrRenderTarget=null,this._sessionUsesLayers===!0)for(const t of this._layers)t.renderTarget=new Xv(t.pixelwidth,t.pixelheight,{format:D,type:Oi,depthTexture:new vc(t.pixelwidth,t.pixelheight,t.stencilBuffer?Fa:ls,void 0,void 0,void 0,void 0,void 0,void 0,t.stencilBuffer?_:U),stencilBuffer:t.stencilBuffer,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),t.renderTarget.isXRRenderTarget=!1,t.plane.material=t.material,t.material.map=t.renderTarget.texture,t.material.map.offset.y=1,t.material.map.repeat.y=-1,delete t.xrlayer;this.isPresenting=!1,this._useMultiview=!1,e._animation.stop(),e._animation.setAnimationLoop(this._currentAnimationLoop),e._animation.setContext(this._currentAnimationContext),e._animation.start(),e.setPixelRatio(this._currentPixelRatio),e.setSize(this._currentSize.width,this._currentSize.height,!1),this.dispatchEvent({type:"sessionend"})}function h9(i){const e=this._controllers,t=this._controllerInputSources;for(let n=0;n<i.removed.length;n++){const s=i.removed[n],o=t.indexOf(s);o>=0&&(t[o]=null,e[o].disconnect(s))}for(let n=0;n<i.added.length;n++){const s=i.added[n];let o=t.indexOf(s);if(o===-1){for(let c=0;c<e.length;c++)if(c>=t.length){t.push(s),o=c;break}else if(t[c]===null){t[c]=s,o=c;break}if(o===-1)break}const a=e[o];a&&a.connect(s)}}function d9(i){return i.type==="quad"?this._glBinding.createQuadLayer({transform:new XRRigidTransform(i.translation,i.quaternion),width:i.width/2,height:i.height/2,space:this._referenceSpace,viewPixelWidth:i.pixelwidth,viewPixelHeight:i.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(i.translation,i.quaternion),radius:i.radius,centralAngle:i.centralAngle,aspectRatio:i.aspectRatio,space:this._referenceSpace,viewPixelWidth:i.pixelwidth,viewPixelHeight:i.pixelheight,clearOnAccess:!1})}function f9(i,e){if(e===void 0)return;const t=this._cameraXR,n=this._renderer,s=n.backend,o=this._glBaseLayer,a=this.getReferenceSpace(),c=e.getViewerPose(a);if(this._xrFrame=e,c!==null){const u=c.views;this._glBaseLayer!==null&&s.setXRTarget(o.framebuffer);let d=!1;u.length!==t.cameras.length&&(t.cameras.length=0,d=!0);for(let p=0;p<u.length;p++){const m=u[p];let y;if(this._supportsLayers===!0){const T=this._glBinding.getViewSubImage(this._glProjLayer,m);y=T.viewport,p===0&&s.setXRRenderTargetTextures(this._xrRenderTarget,T.colorTexture,this._glProjLayer.ignoreDepthValues&&!this._useMultiview?void 0:T.depthStencilTexture)}else y=o.getViewport(m);let M=this._cameras[p];M===void 0&&(M=new ma,M.layers.enable(p),M.viewport=new mr,this._cameras[p]=M),M.matrix.fromArray(m.transform.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale),M.projectionMatrix.fromArray(m.projectionMatrix),M.projectionMatrixInverse.copy(M.projectionMatrix).invert(),M.viewport.set(y.x,y.y,y.width,y.height),p===0&&(t.matrix.copy(M.matrix),t.matrix.decompose(t.position,t.quaternion,t.scale)),d===!0&&t.cameras.push(M)}n.setOutputRenderTarget(this._xrRenderTarget)}for(let u=0;u<this._controllers.length;u++){const d=this._controllerInputSources[u],p=this._controllers[u];d!==null&&p!==void 0&&p.update(d,e,a)}this._currentAnimationLoop&&this._currentAnimationLoop(i,e),e.detectedPlanes&&this.dispatchEvent({type:"planesdetected",data:e}),this._xrFrame=null}const PI=new Km,f0=new yn,mT=new mr,gT=new pf,yT=new yu,Fb=new Ft,Xd=new mr;class p9{constructor(e,t={}){this.isRenderer=!0;const{logarithmicDepthBuffer:n=!1,alpha:s=!0,depth:o=!0,stencil:a=!1,antialias:c=!1,samples:u=0,getFallback:d=null,colorBufferType:p=Gs,multiview:m=!1}=t;this.domElement=e.getDomElement(),this.backend=e,this.samples=u||c===!0?4:0,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.alpha=s,this.logarithmicDepthBuffer=n,this.outputColorSpace=uo,this.toneMapping=yt,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=o,this.stencil=a,this.info=new lG,this.overrideNodes={modelViewMatrix:null,modelNormalViewMatrix:null},this.library=new AI,this.lighting=new s9,this._getFallback=d,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new mr(0,0,this._width,this._height),this._scissor=new mr(0,0,this._width,this._height),this._scissorTest=!1,this._attributes=null,this._geometries=null,this._nodes=null,this._animation=null,this._bindings=null,this._objects=null,this._pipelines=null,this._bundles=null,this._renderLists=null,this._renderContexts=null,this._textures=null,this._background=null,this._quad=new Ov(new xa),this._quad.material.name="Renderer_output",this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTarget=null;const y=this.alpha===!0?0:1;this._clearColor=new kS(0,0,0,y),this._clearDepth=1,this._clearStencil=0,this._renderTarget=null,this._activeCubeFace=0,this._activeMipmapLevel=0,this._outputRenderTarget=null,this._mrt=null,this._renderObjectFunction=null,this._currentRenderObjectFunction=null,this._currentRenderBundle=null,this._handleObjectFunction=this._renderObjectDirect,this._isDeviceLost=!1,this.onDeviceLost=this._onDeviceLost,this._colorBufferType=p,this._initialized=!1,this._initPromise=null,this._compilationPromises=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,type:N},this.xr=new o9(this,m),this.debug={checkShaderErrors:!0,onShaderError:null,getShaderAsync:(M,T,G)=>hr(this,null,function*(){yield this.compileAsync(M,T);const z=this._renderLists.get(M,T),I=this._renderContexts.get(M,T,this._renderTarget),J=M.overrideMaterial||G.material,K=this._objects.get(G,J,M,T,z.lightsNode,I,I.clippingContext),{fragmentShader:re,vertexShader:ve}=K.getNodeBuilderState();return{fragmentShader:re,vertexShader:ve}})}}init(){return hr(this,null,function*(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise((e,t)=>hr(this,null,function*(){let n=this.backend;try{yield n.init(this)}catch(s){if(this._getFallback!==null)try{this.backend=n=this._getFallback(s),yield n.init(this)}catch(o){t(o);return}else{t(s);return}}this._nodes=new t9(this,n),this._animation=new Q5(this._nodes,this.info),this._attributes=new oG(n),this._background=new yH(this,this._nodes),this._geometries=new aG(this._attributes,this.info),this._textures=new MG(this,n,this.info),this._pipelines=new dG(n,this._nodes),this._bindings=new fG(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new iG(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new gG(this.lighting),this._bundles=new i9,this._renderContexts=new bG,this._animation.start(),this._initialized=!0,e(this)})),this._initPromise)})}get coordinateSystem(){return this.backend.coordinateSystem}compileAsync(e,t,n=null){return hr(this,null,function*(){if(this._isDeviceLost===!0)return;this._initialized===!1&&(yield this.init());const s=this._nodes.nodeFrame,o=s.renderId,a=this._currentRenderContext,c=this._currentRenderObjectFunction,u=this._compilationPromises,d=e.isScene===!0?e:PI;n===null&&(n=e);const p=this._renderTarget,m=this._renderContexts.get(n,t,p),y=this._activeMipmapLevel,M=[];this._currentRenderContext=m,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=M,s.renderId++,s.update(),m.depth=this.depth,m.stencil=this.stencil,m.clippingContext||(m.clippingContext=new Ob),m.clippingContext.updateGlobal(d,t),d.onBeforeRender(this,e,t,p);const T=this._renderLists.get(e,t);if(T.begin(),this._projectObject(e,t,0,T,m.clippingContext),n!==e&&n.traverseVisible(function(K){K.isLight&&K.layers.test(t.layers)&&T.pushLight(K)}),T.finish(),p!==null){this._textures.updateRenderTarget(p,y);const K=this._textures.get(p);m.textures=K.textures,m.depthTexture=K.depthTexture}else m.textures=null,m.depthTexture=null;this._background.update(d,T,m);const G=T.opaque,z=T.transparent,I=T.transparentDoublePass,J=T.lightsNode;this.opaque===!0&&G.length>0&&this._renderObjects(G,t,d,J),this.transparent===!0&&z.length>0&&this._renderTransparents(z,I,t,d,J),s.renderId=o,this._currentRenderContext=a,this._currentRenderObjectFunction=c,this._compilationPromises=u,this._handleObjectFunction=this._renderObjectDirect,yield Promise.all(M)})}renderAsync(e,t){return hr(this,null,function*(){this._initialized===!1&&(yield this.init()),this._renderScene(e,t)})}waitForGPU(){return hr(this,null,function*(){yield this.backend.waitForGPU()})}set highPrecision(e){e===!0?(this.overrideNodes.modelViewMatrix=VM,this.overrideNodes.modelNormalViewMatrix=GM):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===VM&&this.overrideNodes.modelNormalViewMatrix===GM}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getColorBufferType(){return this._colorBufferType}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:
|
|
|
|
|
|
Message: ${e.message}`;e.reason&&(t+=`
|
|
|
Reason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,n){const{bundleGroup:s,camera:o,renderList:a}=e,c=this._currentRenderContext,u=this._bundles.get(s,o),d=this.backend.get(u);d.renderContexts===void 0&&(d.renderContexts=new Set);const p=s.version!==d.version,m=d.renderContexts.has(c)===!1||p;if(d.renderContexts.add(c),m){this.backend.beginBundle(c),(d.renderObjects===void 0||p)&&(d.renderObjects=[]),this._currentRenderBundle=u;const{transparentDoublePass:y,transparent:M,opaque:T}=a;this.opaque===!0&&T.length>0&&this._renderObjects(T,o,t,n),this.transparent===!0&&M.length>0&&this._renderTransparents(M,y,o,t,n),this._currentRenderBundle=null,this.backend.finishBundle(c,u),d.version=s.version}else{const{renderObjects:y}=d;for(let M=0,T=y.length;M<T;M++){const G=y[M];this._nodes.needsRefresh(G)&&(this._nodes.updateBefore(G),this._nodes.updateForRender(G),this._bindings.updateForRender(G),this._nodes.updateAfter(G))}}this.backend.addBundle(c,u)}render(e,t){if(this._initialized===!1)return console.warn("THREE.Renderer: .render() called before the backend is initialized. Try using .renderAsync() instead."),this.renderAsync(e,t);this._renderScene(e,t)}_getFrameBufferTarget(){const{currentToneMapping:e,currentColorSpace:t}=this,n=e!==yt,s=t!==Ki.workingColorSpace;if(n===!1&&s===!1)return null;const{width:o,height:a}=this.getDrawingBufferSize(f0),{depth:c,stencil:u}=this;let d=this._frameBufferTarget;d===null&&(d=new Ja(o,a,{depthBuffer:c,stencilBuffer:u,type:this._colorBufferType,format:D,colorSpace:Ki.workingColorSpace,generateMipmaps:!1,minFilter:Rn,magFilter:Rn,samples:this.samples}),d.isPostProcessingRenderTarget=!0,this._frameBufferTarget=d);const p=this.getOutputRenderTarget();return d.depthBuffer=c,d.stencilBuffer=u,p!==null?d.setSize(p.width,p.height,p.depth):d.setSize(o,a,1),d.viewport.copy(this._viewport),d.scissor.copy(this._scissor),d.viewport.multiplyScalar(this._pixelRatio),d.scissor.multiplyScalar(this._pixelRatio),d.scissorTest=this._scissorTest,d.multiview=p!==null?p.multiview:!1,d.resolveDepthBuffer=p!==null?p.resolveDepthBuffer:!0,d._autoAllocateDepthBuffer=p!==null?p._autoAllocateDepthBuffer:!1,d}_renderScene(e,t,n=!0){if(this._isDeviceLost===!0)return;const s=n?this._getFrameBufferTarget():null,o=this._nodes.nodeFrame,a=o.renderId,c=this._currentRenderContext,u=this._currentRenderObjectFunction,d=e.isScene===!0?e:PI,p=this._renderTarget||this._outputRenderTarget,m=this._activeCubeFace,y=this._activeMipmapLevel;let M;s!==null?(M=s,this.setRenderTarget(M)):M=p;const T=this._renderContexts.get(e,t,M);this._currentRenderContext=T,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,o.renderId=this.info.calls;const G=this.coordinateSystem,z=this.xr;if(t.coordinateSystem!==G&&z.isPresenting===!1&&(t.coordinateSystem=G,t.updateProjectionMatrix(),t.isArrayCamera))for(const tn of t.cameras)tn.coordinateSystem=G,tn.updateProjectionMatrix();e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),z.enabled===!0&&z.isPresenting===!0&&(z.cameraAutoUpdate===!0&&z.updateCamera(t),t=z.getCamera());let I=this._viewport,J=this._scissor,K=this._pixelRatio;M!==null&&(I=M.viewport,J=M.scissor,K=1),this.getDrawingBufferSize(f0),mT.set(0,0,f0.width,f0.height);const re=I.minDepth===void 0?0:I.minDepth,ve=I.maxDepth===void 0?1:I.maxDepth;T.viewportValue.copy(I).multiplyScalar(K).floor(),T.viewportValue.width>>=y,T.viewportValue.height>>=y,T.viewportValue.minDepth=re,T.viewportValue.maxDepth=ve,T.viewport=T.viewportValue.equals(mT)===!1,T.scissorValue.copy(J).multiplyScalar(K).floor(),T.scissor=this._scissorTest&&T.scissorValue.equals(mT)===!1,T.scissorValue.width>>=y,T.scissorValue.height>>=y,T.clippingContext||(T.clippingContext=new Ob),T.clippingContext.updateGlobal(d,t),d.onBeforeRender(this,e,t,M);const me=t.isArrayCamera?yT:gT;t.isArrayCamera||(Fb.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),me.setFromProjectionMatrix(Fb,t.coordinateSystem,t.reversedDepth));const Le=this._renderLists.get(e,t);if(Le.begin(),this._projectObject(e,t,0,Le,T.clippingContext),Le.finish(),this.sortObjects===!0&&Le.sort(this._opaqueSort,this._transparentSort),M!==null){this._textures.updateRenderTarget(M,y);const tn=this._textures.get(M);T.textures=tn.textures,T.depthTexture=tn.depthTexture,T.width=tn.width,T.height=tn.height,T.renderTarget=M,T.depth=M.depthBuffer,T.stencil=M.stencilBuffer}else T.textures=null,T.depthTexture=null,T.width=f0.width,T.height=f0.height,T.depth=this.depth,T.stencil=this.stencil;T.width>>=y,T.height>>=y,T.activeCubeFace=m,T.activeMipmapLevel=y,T.occlusionQueryCount=Le.occlusionQueryCount,T.scissorValue.max(Xd.set(0,0,0,0)),T.scissorValue.x+T.scissorValue.width>T.width&&(T.scissorValue.width=Math.max(T.width-T.scissorValue.x,0)),T.scissorValue.y+T.scissorValue.height>T.height&&(T.scissorValue.height=Math.max(T.height-T.scissorValue.y,0)),this._background.update(d,Le,T),T.camera=t,this.backend.beginRender(T);const{bundles:Ve,lightsNode:Ee,transparentDoublePass:Oe,transparent:dt,opaque:Ut}=Le;return Ve.length>0&&this._renderBundles(Ve,d,Ee),this.opaque===!0&&Ut.length>0&&this._renderObjects(Ut,t,d,Ee),this.transparent===!0&&dt.length>0&&this._renderTransparents(dt,Oe,t,d,Ee),this.backend.finishRender(T),o.renderId=a,this._currentRenderContext=c,this._currentRenderObjectFunction=u,s!==null&&(this.setRenderTarget(p,m,y),this._renderOutput(M)),d.onAfterRender(this,e,t,M),T}_setXRLayerSize(e,t){this._width=e,this._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);const n=this.autoClear,s=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=n,this.xr.enabled=s}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}setAnimationLoop(e){return hr(this,null,function*(){this._initialized===!1&&(yield this.init()),this._animation.setAnimationLoop(e)})}getArrayBufferAsync(e){return hr(this,null,function*(){return yield this.backend.getArrayBufferAsync(e)})}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,n){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=n,this.domElement.width=Math.floor(e*n),this.domElement.height=Math.floor(t*n),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setSize(e,t,n=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),n===!0&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,n,s){const o=this._scissor;e.isVector4?o.copy(e):o.set(e,t,n,s)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,n,s,o=0,a=1){const c=this._viewport;e.isVector4?c.copy(e):c.set(e,t,n,s),c.minDepth=o,c.maxDepth=a}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,n=!0){if(this._initialized===!1)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,n);const s=this._renderTarget||this._getFrameBufferTarget();let o=null;if(s!==null){this._textures.updateRenderTarget(s);const a=this._textures.get(s);o=this._renderContexts.getForClear(s),o.textures=a.textures,o.depthTexture=a.depthTexture,o.width=a.width,o.height=a.height,o.renderTarget=s,o.depth=s.depthBuffer,o.stencil=s.stencilBuffer,o.clearColorValue=this.backend.getClearColor(),o.activeCubeFace=this.getActiveCubeFace(),o.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,n,o),s!==null&&this._renderTarget===null&&this._renderOutput(s)}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}clearAsync(e=!0,t=!0,n=!0){return hr(this,null,function*(){this._initialized===!1&&(yield this.init()),this.clear(e,t,n)})}clearColorAsync(){return hr(this,null,function*(){this.clearAsync(!0,!1,!1)})}clearDepthAsync(){return hr(this,null,function*(){this.clearAsync(!1,!0,!1)})}clearStencilAsync(){return hr(this,null,function*(){this.clearAsync(!1,!1,!0)})}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:yt}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:Ki.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||this._renderTarget===null}dispose(){this._initialized===!0&&(this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),this._frameBufferTarget!==null&&this._frameBufferTarget.dispose(),Object.values(this.backend.timestampQueryPool).forEach(e=>{e!==null&&e.dispose()})),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,n=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=n}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null),this._frameBufferTarget.dispose(),this._frameBufferTarget=null}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(this._isDeviceLost===!0)return;if(this._initialized===!1)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);const n=this._nodes.nodeFrame,s=n.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,n.renderId=this.info.calls;const o=this.backend,a=this._pipelines,c=this._bindings,u=this._nodes,d=Array.isArray(e)?e:[e];if(d[0]===void 0||d[0].isComputeNode!==!0)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");o.beginCompute(e);for(const p of d){if(a.has(p)===!1){const M=()=>{p.removeEventListener("dispose",M),a.delete(p),c.delete(p),u.delete(p)};p.addEventListener("dispose",M);const T=p.onInitFunction;T!==null&&T.call(p,{renderer:this})}u.updateForCompute(p),c.updateForCompute(p);const m=c.getForCompute(p),y=a.getForCompute(p,m);o.compute(e,p,m,y,t)}o.finishCompute(e),n.renderId=s}computeAsync(e,t=null){return hr(this,null,function*(){this._initialized===!1&&(yield this.init()),this.compute(e,t)})}hasFeatureAsync(e){return hr(this,null,function*(){return this._initialized===!1&&(yield this.init()),this.backend.hasFeature(e)})}resolveTimestampsAsync(e="render"){return hr(this,null,function*(){return this._initialized===!1&&(yield this.init()),this.backend.resolveTimestampsAsync(e)})}hasFeature(e){return this._initialized===!1?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}initTextureAsync(e){return hr(this,null,function*(){this._initialized===!1&&(yield this.init()),this._textures.updateTexture(e)})}initTexture(e){this._initialized===!1&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=Xd.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=Xd.copy(t).floor();else{console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=Xd.set(0,0,e.image.width,e.image.height);let n=this._currentRenderContext,s;n!==null?s=n.renderTarget:(s=this._renderTarget||this._getFrameBufferTarget(),s!==null&&(this._textures.updateRenderTarget(s),n=this._textures.get(s))),this._textures.updateTexture(e,{renderTarget:s}),this.backend.copyFramebufferToTexture(e,n,t)}copyTextureToTexture(e,t,n=null,s=null,o=0,a=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,n,s,o,a)}readRenderTargetPixelsAsync(e,t,n,s,o,a=0,c=0){return hr(this,null,function*(){return this.backend.copyTextureToBuffer(e.textures[a],t,n,s,o,c)})}_projectObject(e,t,n,s,o){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder,e.isClippingGroup&&e.enabled&&(o=o.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)s.pushLight(e);else if(e.isSprite){const u=t.isArrayCamera?yT:gT;if(!e.frustumCulled||u.intersectsSprite(e,t)){this.sortObjects===!0&&Xd.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Fb);const{geometry:d,material:p}=e;p.visible&&s.push(e,d,p,n,Xd.z,null,o)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const u=t.isArrayCamera?yT:gT;if(!e.frustumCulled||u.intersectsObject(e,t)){const{geometry:d,material:p}=e;if(this.sortObjects===!0&&(d.boundingSphere===null&&d.computeBoundingSphere(),Xd.copy(d.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(Fb)),Array.isArray(p)){const m=d.groups;for(let y=0,M=m.length;y<M;y++){const T=m[y],G=p[T.materialIndex];G&&G.visible&&s.push(e,d,G,n,Xd.z,T,o)}}else p.visible&&s.push(e,d,p,n,Xd.z,null,o)}}}if(e.isBundleGroup===!0&&this.backend.beginBundle!==void 0){const u=s;s=this._renderLists.get(e,t),s.begin(),u.pushBundle({bundleGroup:e,camera:t,renderList:s}),s.finish()}const c=e.children;for(let u=0,d=c.length;u<d;u++)this._projectObject(c[u],t,n,s,o)}_renderBundles(e,t,n){for(const s of e)this._renderBundle(s,t,n)}_renderTransparents(e,t,n,s,o){if(t.length>0){for(const{material:a}of t)a.side=Y;this._renderObjects(t,n,s,o,"backSide");for(const{material:a}of t)a.side=W;this._renderObjects(e,n,s,o);for(const{material:a}of t)a.side=ie}else this._renderObjects(e,n,s,o)}_renderObjects(e,t,n,s,o=null){for(let a=0,c=e.length;a<c;a++){const{object:u,geometry:d,material:p,group:m,clippingContext:y}=e[a];this._currentRenderObjectFunction(u,n,t,d,p,m,s,y,o)}}renderObject(e,t,n,s,o,a,c,u=null,d=null){let p,m,y;if(e.onBeforeRender(this,t,n,s,o,a),o.allowOverride===!0&&t.overrideMaterial!==null){const M=t.overrideMaterial;o.positionNode&&o.positionNode.isNode&&(p=M.positionNode,M.positionNode=o.positionNode),M.alphaTest=o.alphaTest,M.alphaMap=o.alphaMap,M.transparent=o.transparent||o.transmission>0,M.isShadowPassMaterial&&(M.side=o.shadowSide===null?o.side:o.shadowSide,o.depthNode&&o.depthNode.isNode&&(y=M.depthNode,M.depthNode=o.depthNode),o.castShadowNode&&o.castShadowNode.isNode&&(m=M.colorNode,M.colorNode=o.castShadowNode),o.castShadowPositionNode&&o.castShadowPositionNode.isNode&&(p=M.positionNode,M.positionNode=o.castShadowPositionNode)),o=M}o.transparent===!0&&o.side===ie&&o.forceSinglePass===!1?(o.side=Y,this._handleObjectFunction(e,o,t,n,c,a,u,"backSide"),o.side=W,this._handleObjectFunction(e,o,t,n,c,a,u,d),o.side=ie):this._handleObjectFunction(e,o,t,n,c,a,u,d),p!==void 0&&(t.overrideMaterial.positionNode=p),y!==void 0&&(t.overrideMaterial.depthNode=y),m!==void 0&&(t.overrideMaterial.colorNode=m),e.onAfterRender(this,t,n,s,o,a)}_renderObjectDirect(e,t,n,s,o,a,c,u){const d=this._objects.get(e,t,n,s,o,this._currentRenderContext,c,u);d.drawRange=e.geometry.drawRange,d.group=a;const p=this._nodes.needsRefresh(d);p&&(this._nodes.updateBefore(d),this._geometries.updateForRender(d),this._nodes.updateForRender(d),this._bindings.updateForRender(d)),this._pipelines.updateForRender(d),this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(d),d.bundle=this._currentRenderBundle.bundleGroup),this.backend.draw(d,this.info),p&&this._nodes.updateAfter(d)}_createObjectPipeline(e,t,n,s,o,a,c,u){const d=this._objects.get(e,t,n,s,o,this._currentRenderContext,c,u);d.drawRange=e.geometry.drawRange,d.group=a,this._nodes.updateBefore(d),this._geometries.updateForRender(d),this._nodes.updateForRender(d),this._bindings.updateForRender(d),this._pipelines.getForRender(d,this._compilationPromises),this._nodes.updateAfter(d)}get compile(){return this.compileAsync}}class II{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}function m9(i){return i+(Kf-i%Kf)%Kf}class LI extends II{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return m9(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}}class DI extends LI{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let g9=0;class OI extends DI{constructor(e,t){super("UniformBuffer_"+g9++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class y9 extends DI{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let n=0,s=this.uniforms.length;n<s;n++){const o=this.uniforms[n],a=o.boundary,c=o.itemSize*e,u=t%Kf,d=u%a,p=u+d;t+=d,p!==0&&Kf-p<c&&(t+=Kf-p),o.offset=t/e,t+=c}return Math.ceil(t/Kf)*Kf}update(){let e=!1;for(const t of this.uniforms)this.updateByType(t)===!0&&(e=!0);return e}updateByType(e){if(e.isNumberUniform)return this.updateNumber(e);if(e.isVector2Uniform)return this.updateVector2(e);if(e.isVector3Uniform)return this.updateVector3(e);if(e.isVector4Uniform)return this.updateVector4(e);if(e.isColorUniform)return this.updateColor(e);if(e.isMatrix3Uniform)return this.updateMatrix3(e);if(e.isMatrix4Uniform)return this.updateMatrix4(e);console.error("THREE.WebGPUUniformsGroup: Unsupported uniform type.",e)}updateNumber(e){let t=!1;const n=this.values,s=e.getValue(),o=e.offset,a=e.getType();if(n[o]!==s){const c=this._getBufferForType(a);c[o]=n[o]=s,t=!0}return t}updateVector2(e){let t=!1;const n=this.values,s=e.getValue(),o=e.offset,a=e.getType();if(n[o+0]!==s.x||n[o+1]!==s.y){const c=this._getBufferForType(a);c[o+0]=n[o+0]=s.x,c[o+1]=n[o+1]=s.y,t=!0}return t}updateVector3(e){let t=!1;const n=this.values,s=e.getValue(),o=e.offset,a=e.getType();if(n[o+0]!==s.x||n[o+1]!==s.y||n[o+2]!==s.z){const c=this._getBufferForType(a);c[o+0]=n[o+0]=s.x,c[o+1]=n[o+1]=s.y,c[o+2]=n[o+2]=s.z,t=!0}return t}updateVector4(e){let t=!1;const n=this.values,s=e.getValue(),o=e.offset,a=e.getType();if(n[o+0]!==s.x||n[o+1]!==s.y||n[o+2]!==s.z||n[o+4]!==s.w){const c=this._getBufferForType(a);c[o+0]=n[o+0]=s.x,c[o+1]=n[o+1]=s.y,c[o+2]=n[o+2]=s.z,c[o+3]=n[o+3]=s.w,t=!0}return t}updateColor(e){let t=!1;const n=this.values,s=e.getValue(),o=e.offset;if(n[o+0]!==s.r||n[o+1]!==s.g||n[o+2]!==s.b){const a=this.buffer;a[o+0]=n[o+0]=s.r,a[o+1]=n[o+1]=s.g,a[o+2]=n[o+2]=s.b,t=!0}return t}updateMatrix3(e){let t=!1;const n=this.values,s=e.getValue().elements,o=e.offset;if(n[o+0]!==s[0]||n[o+1]!==s[1]||n[o+2]!==s[2]||n[o+4]!==s[3]||n[o+5]!==s[4]||n[o+6]!==s[5]||n[o+8]!==s[6]||n[o+9]!==s[7]||n[o+10]!==s[8]){const a=this.buffer;a[o+0]=n[o+0]=s[0],a[o+1]=n[o+1]=s[1],a[o+2]=n[o+2]=s[2],a[o+4]=n[o+4]=s[3],a[o+5]=n[o+5]=s[4],a[o+6]=n[o+6]=s[5],a[o+8]=n[o+8]=s[6],a[o+9]=n[o+9]=s[7],a[o+10]=n[o+10]=s[8],t=!0}return t}updateMatrix4(e){let t=!1;const n=this.values,s=e.getValue().elements,o=e.offset;return x9(n,s,o)===!1&&(this.buffer.set(s,o),v9(n,s,o),t=!0),t}_getBufferForType(e){return e==="int"||e==="ivec2"||e==="ivec3"||e==="ivec4"?new Int32Array(this.buffer.buffer):e==="uint"||e==="uvec2"||e==="uvec3"||e==="uvec4"?new Uint32Array(this.buffer.buffer):this.buffer}}function v9(i,e,t){for(let n=0,s=e.length;n<s;n++)i[t+n]=e[n]}function x9(i,e,t){for(let n=0,s=e.length;n<s;n++)if(i[t+n]!==e[n])return!1;return!0}let _9=0;class FI extends y9{constructor(e,t){super(e),this.id=_9++,this.groupNode=t,this.isNodeUniformsGroup=!0}}class BI extends II{constructor(e,t){super(e),this.texture=t,this.version=t?t.version:0,this.generation=null,this.isSampler=!0}set texture(e){if(this._texture===e)return;const t=()=>{this._texture=null,this.generation=null,this.version=0};this._texture&&this._texture.removeEventListener("dispose",t),this._texture=e,this.generation=null,this.version=0,this._texture&&this._texture.addEventListener("dispose",t)}get texture(){return this._texture}update(){const{texture:e,version:t}=this;return t!==e.version?(this.version=e.version,!0):!1}clone(){const e=super.clone();return e._texture=null,e.texture=this.texture,e}}let b9=0;class w9 extends BI{constructor(e,t){super(e,t),this.id=b9++,this.store=!1,this.isSampledTexture=!0}}class Bb extends w9{constructor(e,t,n,s=null){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n,this.access=s}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class UI extends Bb{constructor(e,t,n,s=null){super(e,t,n,s),this.isSampledCubeTexture=!0}}class vT extends Bb{constructor(e,t,n,s=null){super(e,t,n,s),this.isSampledTexture3D=!0}}const kI={textureDimensions:"textureSize",equals:"equal",bitcast_float_int:"floatBitsToInt",bitcast_int_float:"intBitsToFloat",bitcast_uint_float:"uintBitsToFloat",bitcast_float_uint:"floatBitsToUint"},M9={low:"lowp",medium:"mediump",high:"highp"},zI={swizzleAssign:!0,storageBuffer:!1},VI={perspective:"smooth",linear:"noperspective"},GI={centroid:"centroid"},WI=`
|
|
|
precision highp float;
|
|
|
precision highp int;
|
|
|
precision highp sampler2D;
|
|
|
precision highp sampler3D;
|
|
|
precision highp samplerCube;
|
|
|
precision highp sampler2DArray;
|
|
|
|
|
|
precision highp usampler2D;
|
|
|
precision highp usampler3D;
|
|
|
precision highp usamplerCube;
|
|
|
precision highp usampler2DArray;
|
|
|
|
|
|
precision highp isampler2D;
|
|
|
precision highp isampler3D;
|
|
|
precision highp isamplerCube;
|
|
|
precision highp isampler2DArray;
|
|
|
|
|
|
precision lowp sampler2DShadow;
|
|
|
precision lowp sampler2DArrayShadow;
|
|
|
precision lowp samplerCubeShadow;
|
|
|
`;class S9 extends wI{constructor(e,t){super(e,t,new e9),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==ea}getMethod(e){return kI[e]||e}getBitcastMethod(e,t){return kI[`bitcast_${t}_${e}`]}getTernary(e,t,n){return`${e} ? ${t} : ${n}`}getOutputStructName(){return""}buildFunctionCode(e){const t=e.layout,n=this.flowShaderNode(e),s=[];for(const a of t.inputs)s.push(this.getType(a.type)+" "+a.name);return`${this.getType(t.type)} ${t.name}( ${s.join(", ")} ) {
|
|
|
|
|
|
${n.vars}
|
|
|
|
|
|
${n.code}
|
|
|
return ${n.result};
|
|
|
|
|
|
}`}setupPBO(e){const t=e.value;if(t.pbo===void 0){const n=t.array,s=t.count*t.itemSize,{itemSize:o}=t,a=t.array.constructor.name.toLowerCase().includes("int");let c=a?X:F;o===2?c=a?ke:Ie:o===3?c=a?et:Pe:o===4&&(c=a?nt:D);const u={Float32Array:ys,Uint8Array:Oi,Uint16Array:gs,Uint32Array:ls,Int8Array:Gi,Int16Array:ir,Int32Array:Ls,Uint8ClampedArray:Oi},d=Math.pow(2,Math.ceil(Math.log2(Math.sqrt(s/o))));let p=Math.ceil(s/o/d);d*p*o<s&&p++;const m=d*p*o,y=new n.constructor(m);y.set(n,0),t.array=y;const M=new tc(t.array,d,p,c,u[t.array.constructor.name]||ys);M.needsUpdate=!0,M.isPBOTexture=!0;const T=new Gh(M,null,null);T.setPrecision("high"),t.pboNode=T,t.pbo=T.value,this.getUniformFromNode(t.pboNode,"texture",this.shaderStage,this.context.nodeName)}}getPropertyName(e,t=this.shaderStage){return e.isNodeUniform&&e.node.isTextureNode!==!0&&e.node.isBufferNode!==!0?t.charAt(0)+"_"+e.name:super.getPropertyName(e,t)}generatePBO(e){const{node:t,indexNode:n}=e,s=t.value;if(this.renderer.backend.has(s)){const p=this.renderer.backend.get(s);p.pbo=s.pbo}const o=this.getUniformFromNode(s.pboNode,"texture",this.shaderStage,this.context.nodeName),a=this.getPropertyName(o);this.increaseUsage(n);const c=n.build(this,"uint"),u=this.getDataFromNode(e);let d=u.propertyName;if(d===void 0){const p=this.getVarFromNode(e);d=this.getPropertyName(p);const m=this.getDataFromNode(t);let y=m.propertySizeName;y===void 0&&(y=d+"Size",this.getVarFromNode(t,y,"uint"),this.addLineFlowCode(`${y} = uint( textureSize( ${a}, 0 ).x )`,e),m.propertySizeName=y);const{itemSize:M}=s,T="."+am.join("").slice(0,M),G=`ivec2(${c} % ${y}, ${c} / ${y})`,z=this.generateTextureLoad(null,a,G,null,null,"0");let I="vec4";s.pbo.type===ls?I="uvec4":s.pbo.type===Ls&&(I="ivec4"),this.addLineFlowCode(`${d} = ${I}(${z})${T}`,e),u.propertyName=d}return d}generateTextureLoad(e,t,n,s,o,a="0"){let c;return s?o?c=`texelFetchOffset( ${t}, ivec3( ${n}, ${s} ), ${a}, ${o} )`:c=`texelFetch( ${t}, ivec3( ${n}, ${s} ), ${a} )`:o?c=`texelFetchOffset( ${t}, ${n}, ${a}, ${o} )`:c=`texelFetch( ${t}, ${n}, ${a} )`,e!==null&&e.isDepthTexture&&(c+=".x"),c}generateTexture(e,t,n,s,o){return s&&(n=`vec3( ${n}, ${s} )`),e.isDepthTexture?o?`textureOffset( ${t}, ${n}, ${o} ).x`:`texture( ${t}, ${n} ).x`:o?`textureOffset( ${t}, ${n}, ${o} )`:`texture( ${t}, ${n} )`}generateTextureLevel(e,t,n,s,o){return o?`textureLodOffset( ${t}, ${n}, ${s}, ${o} )`:`textureLod( ${t}, ${n}, ${s} )`}generateTextureBias(e,t,n,s,o){return o?`textureOffset( ${t}, ${n}, ${o}, ${s} )`:`texture( ${t}, ${n}, ${s} )`}generateTextureGrad(e,t,n,s,o){return o?`textureGradOffset( ${t}, ${n}, ${s[0]}, ${s[1]}, ${o} )`:`textureGrad( ${t}, ${n}, ${s[0]}, ${s[1]} )`}generateTextureCompare(e,t,n,s,o,a,c=this.shaderStage){if(c==="fragment")return o?a?`textureOffset( ${t}, vec4( ${n}, ${o}, ${s} ), ${a} )`:`texture( ${t}, vec4( ${n}, ${o}, ${s} ) )`:a?`textureOffset( ${t}, vec3( ${n}, ${s} ), ${a} )`:`texture( ${t}, vec3( ${n}, ${s} ) )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${c} shader.`)}getVars(e){const t=[],n=this.vars[e];if(n!==void 0)for(const s of n)t.push(`${this.getVar(s.type,s.name,s.count)};`);return t.join(`
|
|
|
`)}getUniforms(e){const t=this.uniforms[e],n=[],s={};for(const a of t){let c=null,u=!1;if(a.type==="texture"||a.type==="texture3D"){const p=a.node.value;let m="";(p.isDataTexture===!0||p.isData3DTexture===!0)&&(p.type===ls?m="u":p.type===Ls&&(m="i")),a.type==="texture3D"&&p.isArrayTexture===!1?c=`${m}sampler3D ${a.name};`:p.compareFunction?p.isArrayTexture===!0?c=`sampler2DArrayShadow ${a.name};`:c=`sampler2DShadow ${a.name};`:p.isArrayTexture===!0||p.isDataArrayTexture===!0||p.isCompressedArrayTexture===!0?c=`${m}sampler2DArray ${a.name};`:c=`${m}sampler2D ${a.name};`}else if(a.type==="cubeTexture")c=`samplerCube ${a.name};`;else if(a.type==="buffer"){const p=a.node,m=this.getType(p.bufferType),y=p.bufferCount,M=y>0?y:"";c=`${p.name} {
|
|
|
${m} ${a.name}[${M}];
|
|
|
};
|
|
|
`}else c=`${this.getVectorType(a.type)} ${this.getPropertyName(a,e)};`,u=!0;const d=a.node.precision;if(d!==null&&(c=M9[d]+" "+c),u){c=" "+c;const p=a.groupNode.name;(s[p]||(s[p]=[])).push(c)}else c="uniform "+c,n.push(c)}let o="";for(const a in s){const c=s[a];o+=this._getGLSLUniformStruct(e+"_"+a,c.join(`
|
|
|
`))+`
|
|
|
`}return o+=n.join(`
|
|
|
`),o}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==Ls){let n=e;e.isInterleavedBufferAttribute&&(n=e.data);const s=n.array;s instanceof Uint32Array||s instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){const n=this.getAttributesArray();let s=0;for(const o of n)t+=`layout( location = ${s++} ) in ${o.type} ${o.name};
|
|
|
`}return t}getStructMembers(e){const t=[];for(const n of e.members)t.push(` ${n.type} ${n.name};`);return t.join(`
|
|
|
`)}getStructs(e){const t=[],n=this.structs[e],s=[];for(const o of n)if(o.output)for(const a of o.members)s.push(`layout( location = ${a.index} ) out ${a.type} ${a.name};`);else{let a="struct "+o.name+` {
|
|
|
`;a+=this.getStructMembers(o),a+=`
|
|
|
};
|
|
|
`,t.push(a)}return s.length===0&&s.push("layout( location = 0 ) out vec4 fragColor;"),`
|
|
|
`+s.join(`
|
|
|
`)+`
|
|
|
|
|
|
`+t.join(`
|
|
|
`)}getVaryings(e){let t="";const n=this.varyings;if(e==="vertex"||e==="compute")for(const s of n){e==="compute"&&(s.needsInterpolation=!0);const o=this.getType(s.type);if(s.needsInterpolation)if(s.interpolationType){const a=VI[s.interpolationType]||s.interpolationType,c=GI[s.interpolationSampling]||"";t+=`${a} ${c} out ${o} ${s.name};
|
|
|
`}else{const a=o.includes("int")||o.includes("uv")||o.includes("iv")?"flat ":"";t+=`${a}out ${o} ${s.name};
|
|
|
`}else t+=`${o} ${s.name};
|
|
|
`}else if(e==="fragment"){for(const s of n)if(s.needsInterpolation){const o=this.getType(s.type);if(s.interpolationType){const a=VI[s.interpolationType]||s.interpolationType,c=GI[s.interpolationSampling]||"";t+=`${a} ${c} in ${o} ${s.name};
|
|
|
`}else{const a=o.includes("int")||o.includes("uv")||o.includes("iv")?"flat ":"";t+=`${a}in ${o} ${s.name};
|
|
|
`}}}for(const s of this.builtins[e])t+=`${s};
|
|
|
`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((n,s)=>n*s,1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,n=this.shaderStage){const s=this.extensions[n]||(this.extensions[n]=new Map);s.has(e)===!1&&s.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if(e==="vertex"){const s=this.renderer.backend.extensions;this.object.isBatchedMesh&&s.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const n=this.extensions[e];if(n!==void 0)for(const{name:s,behavior:o}of n.values())t.push(`#extension ${s} : ${o}`);return t.join(`
|
|
|
`)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=zI[e];if(t===void 0){let n;switch(t=!1,e){case"float32Filterable":n="OES_texture_float_linear";break;case"clipDistance":n="WEBGL_clip_cull_distance";break}if(n!==void 0){const s=this.renderer.backend.extensions;s.has(n)&&(s.get(n),t=!0)}zI[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let n=0;n<e.length;n++){const s=e[n],o=this.getPropertyName(s.attributeNode);o&&(t+=`${s.varyingName} = ${o};
|
|
|
`)}return t}_getGLSLUniformStruct(e,t){return`
|
|
|
layout( std140 ) uniform ${e} {
|
|
|
${t}
|
|
|
};`}_getGLSLVertexCode(e){return`#version 300 es
|
|
|
|
|
|
${this.getSignature()}
|
|
|
|
|
|
// extensions
|
|
|
${e.extensions}
|
|
|
|
|
|
// precision
|
|
|
${WI}
|
|
|
|
|
|
// uniforms
|
|
|
${e.uniforms}
|
|
|
|
|
|
// varyings
|
|
|
${e.varyings}
|
|
|
|
|
|
// attributes
|
|
|
${e.attributes}
|
|
|
|
|
|
// codes
|
|
|
${e.codes}
|
|
|
|
|
|
void main() {
|
|
|
|
|
|
// vars
|
|
|
${e.vars}
|
|
|
|
|
|
// transforms
|
|
|
${e.transforms}
|
|
|
|
|
|
// flow
|
|
|
${e.flow}
|
|
|
|
|
|
gl_PointSize = 1.0;
|
|
|
|
|
|
}
|
|
|
`}_getGLSLFragmentCode(e){return`#version 300 es
|
|
|
|
|
|
${this.getSignature()}
|
|
|
|
|
|
// extensions
|
|
|
${e.extensions}
|
|
|
|
|
|
// precision
|
|
|
${WI}
|
|
|
|
|
|
// uniforms
|
|
|
${e.uniforms}
|
|
|
|
|
|
// varyings
|
|
|
${e.varyings}
|
|
|
|
|
|
// codes
|
|
|
${e.codes}
|
|
|
|
|
|
// structs
|
|
|
${e.structs}
|
|
|
|
|
|
void main() {
|
|
|
|
|
|
// vars
|
|
|
${e.vars}
|
|
|
|
|
|
// flow
|
|
|
${e.flow}
|
|
|
|
|
|
}
|
|
|
`}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){let n=`// code
|
|
|
|
|
|
`;n+=this.flowCode[t];const s=this.flowNodes[t],o=s[s.length-1];for(const c of s){const u=this.getFlowData(c),d=c.name;d&&(n.length>0&&(n+=`
|
|
|
`),n+=` // flow -> ${d}
|
|
|
`),n+=`${u.code}
|
|
|
`,c===o&&t!=="compute"&&(n+=`// result
|
|
|
`,t==="vertex"?(n+="gl_Position = ",n+=`${u.result};`):t==="fragment"&&(c.outputNode.isOutputStructNode||(n+="fragColor = ",n+=`${u.result};`)))}const a=e[t];a.extensions=this.getExtensions(t),a.uniforms=this.getUniforms(t),a.attributes=this.getAttributes(t),a.varyings=this.getVaryings(t),a.vars=this.getVars(t),a.structs=this.getStructs(t),a.codes=this.getCodes(t),a.transforms=this.getTransforms(t),a.flow=n}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,n,s=null){const o=super.getUniformFromNode(e,t,n,s),a=this.getDataFromNode(e,n,this.globalCache);let c=a.uniformGPU;if(c===void 0){const u=e.groupNode,d=u.name,p=this.getBindGroupArray(d,n);if(t==="texture")c=new Bb(o.name,o.node,u),p.push(c);else if(t==="cubeTexture")c=new UI(o.name,o.node,u),p.push(c);else if(t==="texture3D")c=new vT(o.name,o.node,u),p.push(c);else if(t==="buffer"){e.name=`NodeBuffer_${e.id}`,o.name=`buffer${e.id}`;const m=new OI(e,u);m.name=e.name,p.push(m),c=m}else{const m=this.uniformGroups[n]||(this.uniformGroups[n]={});let y=m[d];y===void 0&&(y=new FI(n+"_"+d,u),m[d]=y,p.push(y)),c=this.getNodeUniform(o,t),y.addUniform(c)}a.uniformGPU=c}return o}}let xT=null,p0=null;class HI{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={render:null,compute:null},this.trackTimestamp=e.trackTimestamp===!0}init(e){return hr(this,null,function*(){this.renderer=e})}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}copyTextureToBuffer(){return hr(this,null,function*(){})}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}getTimestampUID(e){const t=this.get(e);let n=e.isComputeNode===!0?"c":"r";return n+=":"+t.frameCalls+":"+e.id,n}isOccluded(){}resolveTimestampsAsync(e="render"){return hr(this,null,function*(){if(!this.trackTimestamp){ll("WebGPURenderer: Timestamp tracking is disabled.");return}const t=this.timestampQueryPool[e];if(!t){ll(`WebGPURenderer: No timestamp query pool for type '${e}' found.`);return}const n=yield t.resolveQueriesAsync();return this.renderer.info[e].timestamp=n,n})}waitForGPU(){return hr(this,null,function*(){})}getArrayBufferAsync(){return hr(this,null,function*(){})}hasFeatureAsync(){return hr(this,null,function*(){})}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return xT=xT||new yn,this.renderer.getDrawingBufferSize(xT)}setScissorTest(){}getClearColor(){const e=this.renderer;return p0=p0||new kS,e.getClearColor(p0),p0.getRGB(p0),p0}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:Ka(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${w} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let T9=0;class E9{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}}class A9{constructor(e){this.backend=e}createAttribute(e,t){const n=this.backend,{gl:s}=n,o=e.array,a=e.usage||s.STATIC_DRAW,c=e.isInterleavedBufferAttribute?e.data:e,u=n.get(c);let d=u.bufferGPU;d===void 0&&(d=this._createBuffer(s,t,o,a),u.bufferGPU=d,u.bufferType=t,u.version=c.version);let p;if(o instanceof Float32Array)p=s.FLOAT;else if(typeof Float16Array!="undefined"&&o instanceof Float16Array)p=s.HALF_FLOAT;else if(o instanceof Uint16Array)e.isFloat16BufferAttribute?p=s.HALF_FLOAT:p=s.UNSIGNED_SHORT;else if(o instanceof Int16Array)p=s.SHORT;else if(o instanceof Uint32Array)p=s.UNSIGNED_INT;else if(o instanceof Int32Array)p=s.INT;else if(o instanceof Int8Array)p=s.BYTE;else if(o instanceof Uint8Array)p=s.UNSIGNED_BYTE;else if(o instanceof Uint8ClampedArray)p=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+o);let m={bufferGPU:d,bufferType:t,type:p,byteLength:o.byteLength,bytesPerElement:o.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:p===s.INT||p===s.UNSIGNED_INT||e.gpuType===Ls,id:T9++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const y=this._createBuffer(s,t,o,a);m=new E9(m,y)}n.set(e,m)}updateAttribute(e){const t=this.backend,{gl:n}=t,s=e.array,o=e.isInterleavedBufferAttribute?e.data:e,a=t.get(o),c=a.bufferType,u=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(n.bindBuffer(c,a.bufferGPU),u.length===0)n.bufferSubData(c,0,s);else{for(let d=0,p=u.length;d<p;d++){const m=u[d];n.bufferSubData(c,m.start*s.BYTES_PER_ELEMENT,s,m.start,m.count)}o.clearUpdateRanges()}n.bindBuffer(c,null),a.version=o.version}destroyAttribute(e){const t=this.backend,{gl:n}=t;e.isInterleavedBufferAttribute&&t.delete(e.data);const s=t.get(e);n.deleteBuffer(s.bufferGPU),t.delete(e)}getArrayBufferAsync(e){return hr(this,null,function*(){const t=this.backend,{gl:n}=t,s=e.isInterleavedBufferAttribute?e.data:e,{bufferGPU:o}=t.get(s),a=e.array,c=a.byteLength;n.bindBuffer(n.COPY_READ_BUFFER,o);const u=n.createBuffer();n.bindBuffer(n.COPY_WRITE_BUFFER,u),n.bufferData(n.COPY_WRITE_BUFFER,c,n.STREAM_READ),n.copyBufferSubData(n.COPY_READ_BUFFER,n.COPY_WRITE_BUFFER,0,0,c),yield t.utils._clientWaitAsync();const d=new e.array.constructor(a.length);return n.bindBuffer(n.COPY_WRITE_BUFFER,u),n.getBufferSubData(n.COPY_WRITE_BUFFER,0,d),n.deleteBuffer(u),n.bindBuffer(n.COPY_READ_BUFFER,null),n.bindBuffer(n.COPY_WRITE_BUFFER,null),d.buffer})}_createBuffer(e,t,n,s){const o=e.createBuffer();return e.bindBuffer(t,o),e.bufferData(t,n,s),e.bindBuffer(t,null),o}}let _T,qv;class C9{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){const e=this.gl;_T={[Te]:e.FUNC_ADD,[_e]:e.FUNC_SUBTRACT,[Xe]:e.FUNC_REVERSE_SUBTRACT},qv={[He]:e.ZERO,[vt]:e.ONE,[It]:e.SRC_COLOR,[Yt]:e.SRC_ALPHA,[gt]:e.SRC_ALPHA_SATURATE,[le]:e.DST_COLOR,[lt]:e.DST_ALPHA,[zt]:e.ONE_MINUS_SRC_COLOR,[At]:e.ONE_MINUS_SRC_ALPHA,[Fe]:e.ONE_MINUS_DST_COLOR,[Ot]:e.ONE_MINUS_DST_ALPHA};const t=e.getParameter(e.SCISSOR_BOX),n=e.getParameter(e.VIEWPORT);this.currentScissor=new mr().fromArray(t),this.currentViewport=new mr().fromArray(n),this._tempVec4=new mr}enable(e){const{enabled:t}=this;t[e]!==!0&&(this.gl.enable(e),t[e]=!0)}disable(e){const{enabled:t}=this;t[e]!==!1&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){const{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){const{gl:t}=this;e!==R?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===S?t.cullFace(t.BACK):e===C?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):this.disable(t.CULL_FACE),this.currentCullFace=e}setLineWidth(e){const{currentLineWidth:t,gl:n}=this;e!==t&&(n.lineWidth(e),this.currentLineWidth=e)}setBlending(e,t,n,s,o,a,c,u){const{gl:d}=this;if(e===pe){this.currentBlendingEnabled===!0&&(this.disable(d.BLEND),this.currentBlendingEnabled=!1);return}if(this.currentBlendingEnabled===!1&&(this.enable(d.BLEND),this.currentBlendingEnabled=!0),e!==Ne){if(e!==this.currentBlending||u!==this.currentPremultipledAlpha){if((this.currentBlendEquation!==Te||this.currentBlendEquationAlpha!==Te)&&(d.blendEquation(d.FUNC_ADD),this.currentBlendEquation=Te,this.currentBlendEquationAlpha=Te),u)switch(e){case fe:d.blendFuncSeparate(d.ONE,d.ONE_MINUS_SRC_ALPHA,d.ONE,d.ONE_MINUS_SRC_ALPHA);break;case ae:d.blendFunc(d.ONE,d.ONE);break;case ye:d.blendFuncSeparate(d.ZERO,d.ONE_MINUS_SRC_COLOR,d.ZERO,d.ONE);break;case ue:d.blendFuncSeparate(d.DST_COLOR,d.ONE_MINUS_SRC_ALPHA,d.ZERO,d.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",e);break}else switch(e){case fe:d.blendFuncSeparate(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA,d.ONE,d.ONE_MINUS_SRC_ALPHA);break;case ae:d.blendFuncSeparate(d.SRC_ALPHA,d.ONE,d.ONE,d.ONE);break;case ye:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case ue:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",e);break}this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentBlending=e,this.currentPremultipledAlpha=u}return}o=o||t,a=a||n,c=c||s,(t!==this.currentBlendEquation||o!==this.currentBlendEquationAlpha)&&(d.blendEquationSeparate(_T[t],_T[o]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=o),(n!==this.currentBlendSrc||s!==this.currentBlendDst||a!==this.currentBlendSrcAlpha||c!==this.currentBlendDstAlpha)&&(d.blendFuncSeparate(qv[n],qv[s],qv[a],qv[c]),this.currentBlendSrc=n,this.currentBlendDst=s,this.currentBlendSrcAlpha=a,this.currentBlendDstAlpha=c),this.currentBlending=e,this.currentPremultipledAlpha=!1}setColorMask(e){this.currentColorMask!==e&&(this.gl.colorMask(e,e,e,e),this.currentColorMask=e)}setDepthTest(e){const{gl:t}=this;e?this.enable(t.DEPTH_TEST):this.disable(t.DEPTH_TEST)}setDepthMask(e){this.currentDepthMask!==e&&(this.gl.depthMask(e),this.currentDepthMask=e)}setDepthFunc(e){if(this.currentDepthFunc!==e){const{gl:t}=this;switch(e){case Ue:t.depthFunc(t.NEVER);break;case Ye:t.depthFunc(t.ALWAYS);break;case be:t.depthFunc(t.LESS);break;case ge:t.depthFunc(t.LEQUAL);break;case Ke:t.depthFunc(t.EQUAL);break;case wt:t.depthFunc(t.GEQUAL);break;case Be:t.depthFunc(t.GREATER);break;case ut:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}this.currentDepthFunc=e}}scissor(e,t,n,s){const o=this._tempVec4.set(e,t,n,s);if(this.currentScissor.equals(o)===!1){const{gl:a}=this;a.scissor(o.x,o.y,o.z,o.w),this.currentScissor.copy(o)}}viewport(e,t,n,s){const o=this._tempVec4.set(e,t,n,s);if(this.currentViewport.equals(o)===!1){const{gl:a}=this;a.viewport(o.x,o.y,o.z,o.w),this.currentViewport.copy(o)}}setScissorTest(e){const t=this.gl;e?t.enable(t.SCISSOR_TEST):t.disable(t.SCISSOR_TEST)}setStencilTest(e){const{gl:t}=this;e?this.enable(t.STENCIL_TEST):this.disable(t.STENCIL_TEST)}setStencilMask(e){this.currentStencilMask!==e&&(this.gl.stencilMask(e),this.currentStencilMask=e)}setStencilFunc(e,t,n){(this.currentStencilFunc!==e||this.currentStencilRef!==t||this.currentStencilFuncMask!==n)&&(this.gl.stencilFunc(e,t,n),this.currentStencilFunc=e,this.currentStencilRef=t,this.currentStencilFuncMask=n)}setStencilOp(e,t,n){(this.currentStencilFail!==e||this.currentStencilZFail!==t||this.currentStencilZPass!==n)&&(this.gl.stencilOp(e,t,n),this.currentStencilFail=e,this.currentStencilZFail=t,this.currentStencilZPass=n)}setMaterial(e,t,n){const{gl:s}=this;e.side===ie?this.disable(s.CULL_FACE):this.enable(s.CULL_FACE);let o=e.side===Y;t&&(o=!o),this.setFlipSided(o),e.blending===fe&&e.transparent===!1?this.setBlending(pe):this.setBlending(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),this.setDepthFunc(e.depthFunc),this.setDepthTest(e.depthTest),this.setDepthMask(e.depthWrite),this.setColorMask(e.colorWrite);const a=e.stencilWrite;if(this.setStencilTest(a),a&&(this.setStencilMask(e.stencilWriteMask),this.setStencilFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),this.setStencilOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),this.setPolygonOffset(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),e.alphaToCoverage===!0&&this.backend.renderer.samples>1?this.enable(s.SAMPLE_ALPHA_TO_COVERAGE):this.disable(s.SAMPLE_ALPHA_TO_COVERAGE),n>0&&this.currentClippingPlanes!==n)for(let u=0;u<8;u++)u<n?this.enable(12288+u):this.disable(12288+u)}setPolygonOffset(e,t,n){const{gl:s}=this;e?(this.enable(s.POLYGON_OFFSET_FILL),(this.currentPolygonOffsetFactor!==t||this.currentPolygonOffsetUnits!==n)&&(s.polygonOffset(t,n),this.currentPolygonOffsetFactor=t,this.currentPolygonOffsetUnits=n)):this.disable(s.POLYGON_OFFSET_FILL)}useProgram(e){return this.currentProgram!==e?(this.gl.useProgram(e),this.currentProgram=e,!0):!1}setVertexState(e,t=null){const n=this.gl;return this.currentVAO!==e||this.currentIndex!==t?(n.bindVertexArray(e),t!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t),this.currentVAO=e,this.currentIndex=t,!0):!1}resetVertexState(){const e=this.gl;e.bindVertexArray(null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),this.currentVAO=null,this.currentIndex=null}bindFramebuffer(e,t){const{gl:n,currentBoundFramebuffers:s}=this;return s[e]!==t?(n.bindFramebuffer(e,t),s[e]=t,e===n.DRAW_FRAMEBUFFER&&(s[n.FRAMEBUFFER]=t),e===n.FRAMEBUFFER&&(s[n.DRAW_FRAMEBUFFER]=t),!0):!1}drawBuffers(e,t){const{gl:n}=this;let s=[],o=!1;if(e.textures!==null){s=this.currentDrawbuffers.get(t),s===void 0&&(s=[],this.currentDrawbuffers.set(t,s));const a=e.textures;if(s.length!==a.length||s[0]!==n.COLOR_ATTACHMENT0){for(let c=0,u=a.length;c<u;c++)s[c]=n.COLOR_ATTACHMENT0+c;s.length=a.length,o=!0}}else s[0]!==n.BACK&&(s[0]=n.BACK,o=!0);o&&n.drawBuffers(s)}activeTexture(e){const{gl:t,currentTextureSlot:n,maxTextures:s}=this;e===void 0&&(e=t.TEXTURE0+s-1),n!==e&&(t.activeTexture(e),this.currentTextureSlot=e)}bindTexture(e,t,n){const{gl:s,currentTextureSlot:o,currentBoundTextures:a,maxTextures:c}=this;n===void 0&&(o===null?n=s.TEXTURE0+c-1:n=o);let u=a[n];u===void 0&&(u={type:void 0,texture:void 0},a[n]=u),(u.type!==e||u.texture!==t)&&(o!==n&&(s.activeTexture(n),this.currentTextureSlot=n),s.bindTexture(e,t),u.type=e,u.texture=t)}bindBufferBase(e,t,n){const{gl:s}=this,o=`${e}-${t}`;return this.currentBoundBufferBases[o]!==n?(s.bindBufferBase(e,t,n),this.currentBoundBufferBases[o]=n,!0):!1}unbindTexture(){const{gl:e,currentTextureSlot:t,currentBoundTextures:n}=this,s=n[t];s!==void 0&&s.type!==void 0&&(e.bindTexture(s.type,null),s.type=void 0,s.texture=void 0)}}class R9{constructor(e){this.backend=e,this.gl=this.backend.gl,this.extensions=e.extensions}convert(e,t=ea){const{gl:n,extensions:s}=this;let o;const a=Ki.getTransfer(t);if(e===Oi)return n.UNSIGNED_BYTE;if(e===Yl)return n.UNSIGNED_SHORT_4_4_4_4;if(e===Zl)return n.UNSIGNED_SHORT_5_5_5_1;if(e===Fl)return n.UNSIGNED_INT_5_9_9_9_REV;if(e===su)return n.UNSIGNED_INT_10F_11F_11F_REV;if(e===Gi)return n.BYTE;if(e===ir)return n.SHORT;if(e===gs)return n.UNSIGNED_SHORT;if(e===Ls)return n.INT;if(e===ls)return n.UNSIGNED_INT;if(e===ys)return n.FLOAT;if(e===Gs)return n.HALF_FLOAT;if(e===Bu)return n.ALPHA;if(e===Pe)return n.RGB;if(e===D)return n.RGBA;if(e===U)return n.DEPTH_COMPONENT;if(e===_)return n.DEPTH_STENCIL;if(e===F)return n.RED;if(e===X)return n.RED_INTEGER;if(e===Ie)return n.RG;if(e===ke)return n.RG_INTEGER;if(e===nt)return n.RGBA_INTEGER;if(e===Wt||e===Tt||e===on||e===Un)if(a===Fi)if(o=s.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(e===Wt)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(e===Tt)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(e===on)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(e===Un)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=s.get("WEBGL_compressed_texture_s3tc"),o!==null){if(e===Wt)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===Tt)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===on)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===Un)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(e===sn||e===bn||e===ti||e===Bt)if(o=s.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(e===sn)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===bn)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===ti)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===Bt)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(e===$n||e===ni||e===Pi)if(o=s.get("WEBGL_compressed_texture_etc"),o!==null){if(e===$n||e===ni)return a===Fi?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(e===Pi)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(e===ui||e===Lr||e===yi||e===vi||e===Mr||e===Zt||e===Fn||e===hi||e===Xn||e===ds||e===qr||e===vs||e===kr||e===Fs)if(o=s.get("WEBGL_compressed_texture_astc"),o!==null){if(e===ui)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(e===Lr)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(e===yi)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(e===vi)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(e===Mr)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(e===Zt)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(e===Fn)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(e===hi)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(e===Xn)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(e===ds)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===qr)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===vs)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===kr)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===Fs)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(e===io)if(o=s.get("EXT_texture_compression_bptc"),o!==null){if(e===io)return a===Fi?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(e===Eo||e===Wr||e===eo||e===Ao)if(o=s.get("EXT_texture_compression_rgtc"),o!==null){if(e===Eo)return o.COMPRESSED_RED_RGTC1_EXT;if(e===Wr)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(e===eo)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(e===Ao)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return e===Fa?n.UNSIGNED_INT_24_8:n[e]!==void 0?n[e]:null}_clientWaitAsync(){const{gl:e}=this,t=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),new Promise((n,s)=>{function o(){const a=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(a===e.WAIT_FAILED){e.deleteSync(t),s();return}if(a===e.TIMEOUT_EXPIRED){requestAnimationFrame(o);return}e.deleteSync(t),n()}o()})}}let $I=!1,Ub,bT,jI;class N9{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},$I===!1&&(this._init(),$I=!0)}_init(){const e=this.gl;Ub={[st]:e.REPEAT,[$e]:e.CLAMP_TO_EDGE,[ft]:e.MIRRORED_REPEAT},bT={[Ct]:e.NEAREST,[jt]:e.NEAREST_MIPMAP_NEAREST,[pn]:e.NEAREST_MIPMAP_LINEAR,[Rn]:e.LINEAR,[bi]:e.LINEAR_MIPMAP_NEAREST,[Qn]:e.LINEAR_MIPMAP_LINEAR},jI={[km]:e.NEVER,[zm]:e.ALWAYS,[ef]:e.LESS,[op]:e.LEQUAL,[tf]:e.EQUAL,[C0]:e.GEQUAL,[E0]:e.GREATER,[A0]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let n;return e.isCubeTexture===!0?n=t.TEXTURE_CUBE_MAP:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?n=t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?n=t.TEXTURE_3D:n=t.TEXTURE_2D,n}getInternalFormat(e,t,n,s,o=!1){const{gl:a,extensions:c}=this;if(e!==null){if(a[e]!==void 0)return a[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let u=t;if(t===a.RED&&(n===a.FLOAT&&(u=a.R32F),n===a.HALF_FLOAT&&(u=a.R16F),n===a.UNSIGNED_BYTE&&(u=a.R8),n===a.UNSIGNED_SHORT&&(u=a.R16),n===a.UNSIGNED_INT&&(u=a.R32UI),n===a.BYTE&&(u=a.R8I),n===a.SHORT&&(u=a.R16I),n===a.INT&&(u=a.R32I)),t===a.RED_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.R8UI),n===a.UNSIGNED_SHORT&&(u=a.R16UI),n===a.UNSIGNED_INT&&(u=a.R32UI),n===a.BYTE&&(u=a.R8I),n===a.SHORT&&(u=a.R16I),n===a.INT&&(u=a.R32I)),t===a.RG&&(n===a.FLOAT&&(u=a.RG32F),n===a.HALF_FLOAT&&(u=a.RG16F),n===a.UNSIGNED_BYTE&&(u=a.RG8),n===a.UNSIGNED_SHORT&&(u=a.RG16),n===a.UNSIGNED_INT&&(u=a.RG32UI),n===a.BYTE&&(u=a.RG8I),n===a.SHORT&&(u=a.RG16I),n===a.INT&&(u=a.RG32I)),t===a.RG_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RG8UI),n===a.UNSIGNED_SHORT&&(u=a.RG16UI),n===a.UNSIGNED_INT&&(u=a.RG32UI),n===a.BYTE&&(u=a.RG8I),n===a.SHORT&&(u=a.RG16I),n===a.INT&&(u=a.RG32I)),t===a.RGB){const d=o?dh:Ki.getTransfer(s);n===a.FLOAT&&(u=a.RGB32F),n===a.HALF_FLOAT&&(u=a.RGB16F),n===a.UNSIGNED_BYTE&&(u=a.RGB8),n===a.UNSIGNED_SHORT&&(u=a.RGB16),n===a.UNSIGNED_INT&&(u=a.RGB32UI),n===a.BYTE&&(u=a.RGB8I),n===a.SHORT&&(u=a.RGB16I),n===a.INT&&(u=a.RGB32I),n===a.UNSIGNED_BYTE&&(u=d===Fi?a.SRGB8:a.RGB8),n===a.UNSIGNED_SHORT_5_6_5&&(u=a.RGB565),n===a.UNSIGNED_SHORT_5_5_5_1&&(u=a.RGB5_A1),n===a.UNSIGNED_SHORT_4_4_4_4&&(u=a.RGB4),n===a.UNSIGNED_INT_5_9_9_9_REV&&(u=a.RGB9_E5),n===a.UNSIGNED_INT_10F_11F_11F_REV&&(u=a.R11F_G11F_B10F)}if(t===a.RGB_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RGB8UI),n===a.UNSIGNED_SHORT&&(u=a.RGB16UI),n===a.UNSIGNED_INT&&(u=a.RGB32UI),n===a.BYTE&&(u=a.RGB8I),n===a.SHORT&&(u=a.RGB16I),n===a.INT&&(u=a.RGB32I)),t===a.RGBA){const d=o?dh:Ki.getTransfer(s);n===a.FLOAT&&(u=a.RGBA32F),n===a.HALF_FLOAT&&(u=a.RGBA16F),n===a.UNSIGNED_BYTE&&(u=a.RGBA8),n===a.UNSIGNED_SHORT&&(u=a.RGBA16),n===a.UNSIGNED_INT&&(u=a.RGBA32UI),n===a.BYTE&&(u=a.RGBA8I),n===a.SHORT&&(u=a.RGBA16I),n===a.INT&&(u=a.RGBA32I),n===a.UNSIGNED_BYTE&&(u=d===Fi?a.SRGB8_ALPHA8:a.RGBA8),n===a.UNSIGNED_SHORT_4_4_4_4&&(u=a.RGBA4),n===a.UNSIGNED_SHORT_5_5_5_1&&(u=a.RGB5_A1)}return t===a.RGBA_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RGBA8UI),n===a.UNSIGNED_SHORT&&(u=a.RGBA16UI),n===a.UNSIGNED_INT&&(u=a.RGBA32UI),n===a.BYTE&&(u=a.RGBA8I),n===a.SHORT&&(u=a.RGBA16I),n===a.INT&&(u=a.RGBA32I)),t===a.DEPTH_COMPONENT&&(n===a.UNSIGNED_SHORT&&(u=a.DEPTH_COMPONENT16),n===a.UNSIGNED_INT&&(u=a.DEPTH_COMPONENT24),n===a.FLOAT&&(u=a.DEPTH_COMPONENT32F)),t===a.DEPTH_STENCIL&&n===a.UNSIGNED_INT_24_8&&(u=a.DEPTH24_STENCIL8),(u===a.R16F||u===a.R32F||u===a.RG16F||u===a.RG32F||u===a.RGBA16F||u===a.RGBA32F)&&c.get("EXT_color_buffer_float"),u}setTextureParameters(e,t){const{gl:n,extensions:s,backend:o}=this,a=Ki.getPrimaries(Ki.workingColorSpace),c=t.colorSpace===ea?null:Ki.getPrimaries(t.colorSpace),u=t.colorSpace===ea||a===c?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,u),n.texParameteri(e,n.TEXTURE_WRAP_S,Ub[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,Ub[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||n.texParameteri(e,n.TEXTURE_WRAP_R,Ub[t.wrapR])),n.texParameteri(e,n.TEXTURE_MAG_FILTER,bT[t.magFilter]);const d=t.mipmaps!==void 0&&t.mipmaps.length>0,p=t.minFilter===Rn&&d?Qn:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,bT[p]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,jI[t.compareFunction])),s.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===Ct||t.minFilter!==pn&&t.minFilter!==Qn||t.type===ys&&s.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){const m=s.get("EXT_texture_filter_anisotropic");n.texParameterf(e,m.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,o.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:n,defaultTextures:s}=this,o=this.getGLTextureType(e);let a=s[o];a===void 0&&(a=t.createTexture(),n.state.bindTexture(o,a),t.texParameteri(o,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(o,t.TEXTURE_MAG_FILTER,t.NEAREST),s[o]=a),n.set(e,{textureGPU:a,glTextureType:o,isDefault:!0})}createTexture(e,t){const{gl:n,backend:s}=this,{levels:o,width:a,height:c,depth:u}=t,d=s.utils.convert(e.format,e.colorSpace),p=s.utils.convert(e.type),m=this.getInternalFormat(e.internalFormat,d,p,e.colorSpace,e.isVideoTexture),y=n.createTexture(),M=this.getGLTextureType(e);s.state.bindTexture(M,y),this.setTextureParameters(M,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?n.texStorage3D(n.TEXTURE_2D_ARRAY,o,m,a,c,u):e.isData3DTexture?n.texStorage3D(n.TEXTURE_3D,o,m,a,c,u):e.isVideoTexture||n.texStorage2D(M,o,m,a,c),s.set(e,{textureGPU:y,glTextureType:M,glFormat:d,glType:p,glInternalFormat:m})}copyBufferToTexture(e,t){const{gl:n,backend:s}=this,{textureGPU:o,glTextureType:a,glFormat:c,glType:u}=s.get(t),{width:d,height:p}=t.source.data;n.bindBuffer(n.PIXEL_UNPACK_BUFFER,e),s.state.bindTexture(a,o),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.texSubImage2D(a,0,0,0,d,p,c,u,0),n.bindBuffer(n.PIXEL_UNPACK_BUFFER,null),s.state.unbindTexture()}updateTexture(e,t){const{gl:n}=this,{width:s,height:o}=t,{textureGPU:a,glTextureType:c,glFormat:u,glType:d,glInternalFormat:p}=this.backend.get(e);if(!(e.isRenderTargetTexture||a===void 0))if(this.backend.state.bindTexture(c,a),this.setTextureParameters(c,e),e.isCompressedTexture){const m=e.mipmaps,y=t.image;for(let M=0;M<m.length;M++){const T=m[M];e.isCompressedArrayTexture?e.format!==n.RGBA?u!==null?n.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,M,0,0,0,T.width,T.height,y.depth,u,T.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texSubImage3D(n.TEXTURE_2D_ARRAY,M,0,0,0,T.width,T.height,y.depth,u,d,T.data):u!==null?n.compressedTexSubImage2D(n.TEXTURE_2D,M,0,0,T.width,T.height,u,T.data):console.warn("Unsupported compressed texture format")}}else if(e.isCubeTexture){const m=t.images,y=e.mipmaps;for(let M=0;M<6;M++){const T=kb(m[M]);n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+M,0,0,0,s,o,u,d,T);for(let G=0;G<y.length;G++){const z=y[G],I=kb(z.images[M]);n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+M,G+1,0,0,I.width,I.height,u,d,I)}}}else if(e.isDataArrayTexture||e.isArrayTexture){const m=t.image;if(e.layerUpdates.size>0){const y=Vy(m.width,m.height,e.format,e.type);for(const M of e.layerUpdates){const T=m.data.subarray(M*y/m.data.BYTES_PER_ELEMENT,(M+1)*y/m.data.BYTES_PER_ELEMENT);n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,M,m.width,m.height,1,u,d,T)}e.clearLayerUpdates()}else n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,m.width,m.height,m.depth,u,d,m.data)}else if(e.isData3DTexture){const m=t.image;n.texSubImage3D(n.TEXTURE_3D,0,0,0,0,m.width,m.height,m.depth,u,d,m.data)}else if(e.isVideoTexture)e.update(),n.texImage2D(c,0,p,u,d,t.image);else{const m=e.mipmaps;if(m.length>0)for(let y=0,M=m.length;y<M;y++){const T=m[y],G=kb(T);n.texSubImage2D(c,y,0,0,T.width,T.height,u,d,G)}else{const y=kb(t.image);n.texSubImage2D(c,0,0,0,s,o,u,d,y)}}}generateMipmaps(e){const{gl:t,backend:n}=this,{textureGPU:s,glTextureType:o}=n.get(e);n.state.bindTexture(o,s),t.generateMipmap(o)}deallocateRenderBuffers(e){const{gl:t,backend:n}=this;if(e){const s=n.get(e);if(s.renderBufferStorageSetup=void 0,s.framebuffers){for(const o in s.framebuffers)t.deleteFramebuffer(s.framebuffers[o]);delete s.framebuffers}if(s.depthRenderbuffer&&(t.deleteRenderbuffer(s.depthRenderbuffer),delete s.depthRenderbuffer),s.stencilRenderbuffer&&(t.deleteRenderbuffer(s.stencilRenderbuffer),delete s.stencilRenderbuffer),s.msaaFrameBuffer&&(t.deleteFramebuffer(s.msaaFrameBuffer),delete s.msaaFrameBuffer),s.msaaRenderbuffers){for(let o=0;o<s.msaaRenderbuffers.length;o++)t.deleteRenderbuffer(s.msaaRenderbuffers[o]);delete s.msaaRenderbuffers}}}destroyTexture(e){const{gl:t,backend:n}=this,{textureGPU:s,renderTarget:o}=n.get(e);this.deallocateRenderBuffers(o),t.deleteTexture(s),n.delete(e)}copyTextureToTexture(e,t,n=null,s=null,o=0,a=0){const{gl:c,backend:u}=this,{state:d}=this.backend,{textureGPU:p,glTextureType:m,glType:y,glFormat:M}=u.get(t);d.bindTexture(m,p);let T,G,z,I,J,K,re,ve,me;const Le=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)T=n.max.x-n.min.x,G=n.max.y-n.min.y,z=n.isBox3?n.max.z-n.min.z:1,I=n.min.x,J=n.min.y,K=n.isBox3?n.min.z:0;else{const cn=Math.pow(2,-o);T=Math.floor(Le.width*cn),G=Math.floor(Le.height*cn),e.isDataArrayTexture||e.isArrayTexture?z=Le.depth:e.isData3DTexture?z=Math.floor(Le.depth*cn):z=1,I=0,J=0,K=0}s!==null?(re=s.x,ve=s.y,me=s.z):(re=0,ve=0,me=0),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,t.flipY),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),c.pixelStorei(c.UNPACK_ALIGNMENT,t.unpackAlignment);const Ve=c.getParameter(c.UNPACK_ROW_LENGTH),Ee=c.getParameter(c.UNPACK_IMAGE_HEIGHT),Oe=c.getParameter(c.UNPACK_SKIP_PIXELS),dt=c.getParameter(c.UNPACK_SKIP_ROWS),Ut=c.getParameter(c.UNPACK_SKIP_IMAGES);c.pixelStorei(c.UNPACK_ROW_LENGTH,Le.width),c.pixelStorei(c.UNPACK_IMAGE_HEIGHT,Le.height),c.pixelStorei(c.UNPACK_SKIP_PIXELS,I),c.pixelStorei(c.UNPACK_SKIP_ROWS,J),c.pixelStorei(c.UNPACK_SKIP_IMAGES,K);const tn=t.isDataArrayTexture||t.isData3DTexture||t.isArrayTexture;if(e.isRenderTargetTexture||e.isDepthTexture){const cn=u.get(e),vn=u.get(t),mn=u.get(cn.renderTarget),Yn=u.get(vn.renderTarget),xn=mn.framebuffers[cn.cacheKey],si=Yn.framebuffers[vn.cacheKey];d.bindFramebuffer(c.READ_FRAMEBUFFER,xn),d.bindFramebuffer(c.DRAW_FRAMEBUFFER,si);let wn=c.COLOR_BUFFER_BIT;e.isDepthTexture&&(wn=c.DEPTH_BUFFER_BIT),c.blitFramebuffer(I,J,T,G,re,ve,T,G,wn,c.NEAREST),d.bindFramebuffer(c.READ_FRAMEBUFFER,null),d.bindFramebuffer(c.DRAW_FRAMEBUFFER,null)}else tn?e.isDataTexture||e.isData3DTexture?c.texSubImage3D(m,a,re,ve,me,T,G,z,M,y,Le.data):t.isCompressedArrayTexture?c.compressedTexSubImage3D(m,a,re,ve,me,T,G,z,M,Le.data):c.texSubImage3D(m,a,re,ve,me,T,G,z,M,y,Le):e.isDataTexture?c.texSubImage2D(m,a,re,ve,T,G,M,y,Le.data):e.isCompressedTexture?c.compressedTexSubImage2D(m,a,re,ve,Le.width,Le.height,M,Le.data):c.texSubImage2D(m,a,re,ve,T,G,M,y,Le);c.pixelStorei(c.UNPACK_ROW_LENGTH,Ve),c.pixelStorei(c.UNPACK_IMAGE_HEIGHT,Ee),c.pixelStorei(c.UNPACK_SKIP_PIXELS,Oe),c.pixelStorei(c.UNPACK_SKIP_ROWS,dt),c.pixelStorei(c.UNPACK_SKIP_IMAGES,Ut),a===0&&t.generateMipmaps&&c.generateMipmap(m),d.unbindTexture()}copyFramebufferToTexture(e,t,n){const{gl:s}=this,{state:o}=this.backend,{textureGPU:a}=this.backend.get(e),{x:c,y:u,z:d,w:p}=n,m=e.isDepthTexture===!0||t.renderTarget&&t.renderTarget.samples>0,y=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(m){const M=c!==0||u!==0;let T,G;if(e.isDepthTexture===!0?(T=s.DEPTH_BUFFER_BIT,G=s.DEPTH_ATTACHMENT,t.stencil&&(T|=s.STENCIL_BUFFER_BIT)):(T=s.COLOR_BUFFER_BIT,G=s.COLOR_ATTACHMENT0),M){const z=this.backend.get(t.renderTarget),I=z.framebuffers[t.getCacheKey()],J=z.msaaFrameBuffer;o.bindFramebuffer(s.DRAW_FRAMEBUFFER,I),o.bindFramebuffer(s.READ_FRAMEBUFFER,J);const K=y-u-p;s.blitFramebuffer(c,K,c+d,K+p,c,K,c+d,K+p,T,s.NEAREST),o.bindFramebuffer(s.READ_FRAMEBUFFER,I),o.bindTexture(s.TEXTURE_2D,a),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,c,K,d,p),o.unbindTexture()}else{const z=s.createFramebuffer();o.bindFramebuffer(s.DRAW_FRAMEBUFFER,z),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,G,s.TEXTURE_2D,a,0),s.blitFramebuffer(0,0,d,p,0,0,d,p,T,s.NEAREST),s.deleteFramebuffer(z)}}else o.bindTexture(s.TEXTURE_2D,a),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,c,y-p-u,d,p),o.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,n,s=!1){const{gl:o}=this,a=t.renderTarget,{depthTexture:c,depthBuffer:u,stencilBuffer:d,width:p,height:m}=a;if(o.bindRenderbuffer(o.RENDERBUFFER,e),u&&!d){let y=o.DEPTH_COMPONENT24;s===!0?this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(o.RENDERBUFFER,a.samples,y,p,m):n>0?(c&&c.isDepthTexture&&c.type===o.FLOAT&&(y=o.DEPTH_COMPONENT32F),o.renderbufferStorageMultisample(o.RENDERBUFFER,n,y,p,m)):o.renderbufferStorage(o.RENDERBUFFER,y,p,m),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.RENDERBUFFER,e)}else u&&d&&(n>0?o.renderbufferStorageMultisample(o.RENDERBUFFER,n,o.DEPTH24_STENCIL8,p,m):o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_STENCIL,p,m),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.RENDERBUFFER,e));o.bindRenderbuffer(o.RENDERBUFFER,null)}copyTextureToBuffer(e,t,n,s,o,a){return hr(this,null,function*(){const{backend:c,gl:u}=this,{textureGPU:d,glFormat:p,glType:m}=this.backend.get(e),y=u.createFramebuffer();u.bindFramebuffer(u.READ_FRAMEBUFFER,y);const M=e.isCubeTexture?u.TEXTURE_CUBE_MAP_POSITIVE_X+a:u.TEXTURE_2D;u.framebufferTexture2D(u.READ_FRAMEBUFFER,u.COLOR_ATTACHMENT0,M,d,0);const T=this._getTypedArrayType(m),G=this._getBytesPerTexel(m,p),I=s*o*G,J=u.createBuffer();u.bindBuffer(u.PIXEL_PACK_BUFFER,J),u.bufferData(u.PIXEL_PACK_BUFFER,I,u.STREAM_READ),u.readPixels(t,n,s,o,p,m,0),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),yield c.utils._clientWaitAsync();const K=new T(I/T.BYTES_PER_ELEMENT);return u.bindBuffer(u.PIXEL_PACK_BUFFER,J),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,K),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),u.deleteFramebuffer(y),K})}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:n}=this;let s=0;if(e===n.UNSIGNED_BYTE&&(s=1),(e===n.UNSIGNED_SHORT_4_4_4_4||e===n.UNSIGNED_SHORT_5_5_5_1||e===n.UNSIGNED_SHORT_5_6_5||e===n.UNSIGNED_SHORT||e===n.HALF_FLOAT)&&(s=2),(e===n.UNSIGNED_INT||e===n.FLOAT)&&(s=4),t===n.RGBA)return s*4;if(t===n.RGB)return s*3;if(t===n.ALPHA)return s}}function kb(i){return i.isDataTexture?i.image.data:typeof HTMLImageElement!="undefined"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&i instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&i instanceof ImageBitmap||typeof OffscreenCanvas!="undefined"&&i instanceof OffscreenCanvas?i:i.data}class P9{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class I9{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(t.has("EXT_texture_filter_anisotropic")===!0){const n=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const XI={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class L9{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:n,mode:s,object:o,type:a,info:c,index:u}=this;u!==0?n.drawElements(s,t,a,e):n.drawArrays(s,e,t),c.update(o,t,1)}renderInstances(e,t,n){const{gl:s,mode:o,type:a,index:c,object:u,info:d}=this;n!==0&&(c!==0?s.drawElementsInstanced(o,t,a,e,n):s.drawArraysInstanced(o,e,t,n),d.update(u,t,n))}renderMultiDraw(e,t,n){const{extensions:s,mode:o,object:a,info:c}=this;if(n===0)return;const u=s.get("WEBGL_multi_draw");if(u===null)for(let d=0;d<n;d++)this.render(e[d],t[d]);else{this.index!==0?u.multiDrawElementsWEBGL(o,t,0,this.type,e,0,n):u.multiDrawArraysWEBGL(o,e,0,t,0,n);let d=0;for(let p=0;p<n;p++)d+=t[p];c.update(a,d,1)}}renderMultiDrawInstances(e,t,n,s){const{extensions:o,mode:a,object:c,info:u}=this;if(n===0)return;const d=o.get("WEBGL_multi_draw");if(d===null)for(let p=0;p<n;p++)this.renderInstances(e[p],t[p],s[p]);else{this.index!==0?d.multiDrawElementsInstancedWEBGL(a,t,0,this.type,e,0,s,0,n):d.multiDrawArraysInstancedWEBGL(a,e,0,t,0,s,0,n);let p=0;for(let m=0;m<n;m++)p+=t[m]*s[m];u.update(c,p,1)}}}class qI{constructor(e=256){this.trackTimestamp=!0,this.maxQueries=e,this.currentQueryIndex=0,this.queryOffsets=new Map,this.isDisposed=!1,this.lastValue=0,this.pendingResolve=!1}allocateQueriesForContext(){}resolveQueriesAsync(){return hr(this,null,function*(){})}dispose(){}}class D9 extends qI{constructor(e,t,n=2048){if(super(n),this.gl=e,this.type=t,this.ext=e.getExtension("EXT_disjoint_timer_query_webgl2")||e.getExtension("EXT_disjoint_timer_query"),!this.ext){console.warn("EXT_disjoint_timer_query not supported; timestamps will be disabled."),this.trackTimestamp=!1;return}this.queries=[];for(let s=0;s<this.maxQueries;s++)this.queries.push(e.createQuery());this.activeQuery=null,this.queryStates=new Map}allocateQueriesForContext(e){if(!this.trackTimestamp)return null;if(this.currentQueryIndex+2>this.maxQueries)return ll(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(t==null||this.activeQuery!==null)return;const n=this.queries[t];if(n)try{this.queryStates.get(t)==="inactive"&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,n),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(s){console.error("Error in beginQuery:",s),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(t!=null&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(n){console.error("Error in endQuery:",n),this.queryStates.set(t,"inactive"),this.activeQuery=null}}resolveQueriesAsync(){return hr(this,null,function*(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=[];for(const[s,o]of this.queryStates)if(o==="ended"){const a=this.queries[s];e.push(this.resolveQuery(a))}if(e.length===0)return this.lastValue;const n=(yield Promise.all(e)).reduce((s,o)=>s+o,0);return this.lastValue=n,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,n}catch(e){return console.error("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}})}resolveQuery(e){return hr(this,null,function*(){return new Promise(t=>{if(this.isDisposed){t(this.lastValue);return}let n,s=!1;const o=()=>{n&&(clearTimeout(n),n=null)},a=u=>{s||(s=!0,o(),t(u))},c=()=>{if(this.isDisposed){a(this.lastValue);return}try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT)){a(this.lastValue);return}if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE)){n=setTimeout(c,1);return}const p=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(p)/1e6)}catch(u){console.error("Error checking query:",u),t(this.lastValue)}};c()})})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,!!this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}class YI extends HI{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer=typeof navigator=="undefined"?!1:/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,n={antialias:e.samples>0,alpha:!0,depth:e.depth,stencil:e.stencil},s=t.context!==void 0?t.context:e.domElement.getContext("webgl2",n);function o(a){a.preventDefault();const c={api:"WebGL",message:a.statusMessage||"Unknown reason",reason:null,originalEvent:a};e.onDeviceLost(c)}this._onContextLost=o,e.domElement.addEventListener("webglcontextlost",o,!1),this.gl=s,this.extensions=new P9(this),this.capabilities=new I9(this),this.attributeUtils=new A9(this),this.textureUtils=new N9(this),this.bufferRenderer=new L9(this),this.state=new C9(this),this.utils=new R9(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile")}get coordinateSystem(){return oo}getArrayBufferAsync(e){return hr(this,null,function*(){return yield this.attributeUtils.getArrayBufferAsync(e)})}waitForGPU(){return hr(this,null,function*(){yield this.utils._clientWaitAsync()})}makeXRCompatible(){return hr(this,null,function*(){this.gl.getContextAttributes().xrCompatible!==!0&&(yield this.gl.makeXRCompatible())})}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,n=null){const s=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:s.RGBA8}),n!==null){const o=e.stencilBuffer?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:n,glInternalFormat:o}),this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer===!0&&e.multiview===!1&&console.warn("THREE.WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new D9(this.gl,e,2048));const n=this.timestampQueryPool[e];n.allocateQueriesForContext(t)!==null&&n.beginQuery(t)}prepareTimestampBuffer(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){const{state:t}=this,n=this.get(e);if(n.frameCalls=this.renderer.info.render.frameCalls,e.viewport)this.updateViewport(e);else{const{width:o,height:a}=this.getDrawingBufferSize();t.viewport(0,0,o,a)}if(e.scissor){const{x:o,y:a,width:c,height:u}=e.scissorValue;t.scissor(o,e.height-u-a,c,u)}this.initTimestampQuery(fh.RENDER,this.getTimestampUID(e)),n.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const s=e.occlusionQueryCount;s>0&&(n.currentOcclusionQueries=n.occlusionQueries,n.currentOcclusionQueryObjects=n.occlusionQueryObjects,n.lastOcclusionObject=null,n.occlusionQueries=new Array(s),n.occlusionQueryObjects=new Array(s),n.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:n}=this,s=this.get(e),o=s.previousContext;n.resetVertexState();const a=e.occlusionQueryCount;a>0&&(a>s.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const c=e.textures;if(c!==null)for(let u=0;u<c.length;u++){const d=c[u];d.generateMipmaps&&this.generateMipmaps(d)}if(this._currentContext=o,this._resolveRenderTarget(e),o!==null)if(this._setFramebuffer(o),o.viewport)this.updateViewport(o);else{const{width:u,height:d}=this.getDrawingBufferSize();n.viewport(0,0,u,d)}this.prepareTimestampBuffer(fh.RENDER,this.getTimestampUID(e))}resolveOccludedAsync(e){const t=this.get(e),{currentOcclusionQueries:n,currentOcclusionQueryObjects:s}=t;if(n&&s){const o=new WeakSet,{gl:a}=this;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueries=null;const c=()=>{let u=0;for(let d=0;d<n.length;d++){const p=n[d];p!==null&&a.getQueryParameter(p,a.QUERY_RESULT_AVAILABLE)&&(a.getQueryParameter(p,a.QUERY_RESULT)===0&&o.add(s[d]),n[d]=null,a.deleteQuery(p),u++)}u<n.length?requestAnimationFrame(c):t.occluded=o};c()}}isOccluded(e,t){const n=this.get(e);return n.occluded&&n.occluded.has(t)}updateViewport(e){const{state:t}=this,{x:n,y:s,width:o,height:a}=e.viewportValue;t.viewport(n,e.height-a-s,o,a)}setScissorTest(e){this.state.setScissorTest(e)}getClearColor(){const e=super.getClearColor();return e.r*=e.a,e.g*=e.a,e.b*=e.a,e}clear(e,t,n,s=null,o=!0,a=!0){const{gl:c,renderer:u}=this;s===null&&(s={textures:null,clearColorValue:this.getClearColor()});let d=0;if(e&&(d|=c.COLOR_BUFFER_BIT),t&&(d|=c.DEPTH_BUFFER_BIT),n&&(d|=c.STENCIL_BUFFER_BIT),d!==0){let p;s.clearColorValue?p=s.clearColorValue:p=this.getClearColor();const m=u.getClearDepth(),y=u.getClearStencil();if(t&&this.state.setDepthMask(!0),s.textures===null)c.clearColor(p.r,p.g,p.b,p.a),c.clear(d);else{if(o&&this._setFramebuffer(s),e)for(let M=0;M<s.textures.length;M++)M===0?c.clearBufferfv(c.COLOR,M,[p.r,p.g,p.b,p.a]):c.clearBufferfv(c.COLOR,M,[0,0,0,1]);t&&n?c.clearBufferfi(c.DEPTH_STENCIL,0,m,y):t?c.clearBufferfv(c.DEPTH,0,[m]):n&&c.clearBufferiv(c.STENCIL,0,[y]),o&&a&&this._resolveRenderTarget(s)}}}beginCompute(e){const{state:t,gl:n}=this,s=this.get(e);s.frameCalls=this.renderer.info.compute.frameCalls,t.bindFramebuffer(n.FRAMEBUFFER,null),this.initTimestampQuery(fh.COMPUTE,this.getTimestampUID(e))}compute(e,t,n,s,o=null){const{state:a,gl:c}=this;this.discard===!1&&(c.enable(c.RASTERIZER_DISCARD),this.discard=!0);const{programGPU:u,transformBuffers:d,attributes:p}=this.get(s),m=this._getVaoKey(p),y=this.vaoCache[m];y===void 0?this.vaoCache[m]=this._createVao(p):a.setVertexState(y),a.useProgram(u),this._bindUniforms(n);const M=this._getTransformFeedback(d);c.bindTransformFeedback(c.TRANSFORM_FEEDBACK,M),c.beginTransformFeedback(c.POINTS),o=o!==null?o:t.count,Array.isArray(o)&&(ll("WebGLBackend.compute(): The count parameter must be a single number, not an array."),o=o[0]),p[0].isStorageInstancedBufferAttribute?c.drawArraysInstanced(c.POINTS,0,1,o):c.drawArrays(c.POINTS,0,o),c.endTransformFeedback(),c.bindTransformFeedback(c.TRANSFORM_FEEDBACK,null);for(let T=0;T<d.length;T++){const G=d[T];G.pbo&&this.has(G.pbo)&&this.textureUtils.copyBufferToTexture(G.transformBuffer,G.pbo),G.switchBuffers()}}finishCompute(e){const t=this.gl;this.discard=!1,t.disable(t.RASTERIZER_DISCARD),this.prepareTimestampBuffer(fh.COMPUTE,this.getTimestampUID(e)),this._currentContext&&this._setFramebuffer(this._currentContext)}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.isArrayTexture&&e.camera.isArrayCamera}draw(e){const{object:t,pipeline:n,material:s,context:o,hardwareClippingPlanes:a}=e,{programGPU:c}=this.get(n),{gl:u,state:d}=this,p=this.get(o),m=e.getDrawParameters();if(m===null)return;this._bindUniforms(e.getBindings());const y=t.isMesh&&t.matrixWorld.determinant()<0;d.setMaterial(s,y,a),d.useProgram(c);const M=e.getAttributes(),T=this.get(M);let G=T.vaoGPU;if(G===void 0){const Ve=this._getVaoKey(M);G=this.vaoCache[Ve],G===void 0&&(G=this._createVao(M),this.vaoCache[Ve]=G,T.vaoGPU=G)}const z=e.getIndex(),I=z!==null?this.get(z).bufferGPU:null;d.setVertexState(G,I);const J=p.lastOcclusionObject;if(J!==t&&J!==void 0){if(J!==null&&J.occlusionTest===!0&&(u.endQuery(u.ANY_SAMPLES_PASSED),p.occlusionQueryIndex++),t.occlusionTest===!0){const Ve=u.createQuery();u.beginQuery(u.ANY_SAMPLES_PASSED,Ve),p.occlusionQueries[p.occlusionQueryIndex]=Ve,p.occlusionQueryObjects[p.occlusionQueryIndex]=t}p.lastOcclusionObject=t}const K=this.bufferRenderer;t.isPoints?K.mode=u.POINTS:t.isLineSegments?K.mode=u.LINES:t.isLine?K.mode=u.LINE_STRIP:t.isLineLoop?K.mode=u.LINE_LOOP:s.wireframe===!0?(d.setLineWidth(s.wireframeLinewidth*this.renderer.getPixelRatio()),K.mode=u.LINES):K.mode=u.TRIANGLES;const{vertexCount:re,instanceCount:ve}=m;let{firstVertex:me}=m;if(K.object=t,z!==null){me*=z.array.BYTES_PER_ELEMENT;const Ve=this.get(z);K.index=z.count,K.type=Ve.type}else K.index=0;const Le=()=>{t.isBatchedMesh?t._multiDrawInstances!==null?(ll("THREE.WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),K.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?K.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):ll("THREE.WebGLRenderer: WEBGL_multi_draw not supported."):ve>1?K.renderInstances(me,re,ve):K.render(me,re)};if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){const Ve=this.get(e.camera),Ee=e.camera.cameras,Oe=e.getBindingGroup("cameraIndex").bindings[0];if(Ve.indexesGPU===void 0||Ve.indexesGPU.length!==Ee.length){const mn=new Uint32Array([0,0,0,0]),Yn=[];for(let xn=0,si=Ee.length;xn<si;xn++){const wn=u.createBuffer();mn[0]=xn,u.bindBuffer(u.UNIFORM_BUFFER,wn),u.bufferData(u.UNIFORM_BUFFER,mn,u.STATIC_DRAW),Yn.push(wn)}Ve.indexesGPU=Yn}const dt=this.get(Oe),Ut=this.renderer.getPixelRatio(),tn=this._currentContext.renderTarget,cn=this._isRenderCameraDepthArray(this._currentContext),vn=this._currentContext.activeCubeFace;if(cn){const mn=this.get(tn.depthTexture);if(mn.clearedRenderId!==this.renderer._nodes.nodeFrame.renderId){mn.clearedRenderId=this.renderer._nodes.nodeFrame.renderId;const{stencilBuffer:Yn}=tn;for(let xn=0,si=Ee.length;xn<si;xn++)this.renderer._activeCubeFace=xn,this._currentContext.activeCubeFace=xn,this._setFramebuffer(this._currentContext),this.clear(!1,!0,Yn,this._currentContext,!1,!1);this.renderer._activeCubeFace=vn,this._currentContext.activeCubeFace=vn}}for(let mn=0,Yn=Ee.length;mn<Yn;mn++){const xn=Ee[mn];if(t.layers.test(xn.layers)){cn&&(this.renderer._activeCubeFace=mn,this._currentContext.activeCubeFace=mn,this._setFramebuffer(this._currentContext));const si=xn.viewport;if(si!==void 0){const wn=si.x*Ut,Gn=si.y*Ut,Si=si.width*Ut,nr=si.height*Ut;d.viewport(Math.floor(wn),Math.floor(e.context.height-nr-Gn),Math.floor(Si),Math.floor(nr))}d.bindBufferBase(u.UNIFORM_BUFFER,dt.index,Ve.indexesGPU[mn]),Le()}this._currentContext.activeCubeFace=vn,this.renderer._activeCubeFace=vn}}else Le()}needsRenderUpdate(){return!1}getRenderCacheKey(){return""}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,n,s,o,a){return hr(this,null,function*(){return this.textureUtils.copyTextureToBuffer(e,t,n,s,o,a)})}createSampler(){}destroySampler(){}createNodeBuilder(e,t){return new S9(e,t)}createProgram(e){const t=this.gl,{stage:n,code:s}=e,o=n==="fragment"?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(o,s),t.compileShader(o),this.set(e,{shaderGPU:o})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){const n=this.gl,s=e.pipeline,{fragmentProgram:o,vertexProgram:a}=s,c=n.createProgram(),u=this.get(o).shaderGPU,d=this.get(a).shaderGPU;if(n.attachShader(c,u),n.attachShader(c,d),n.linkProgram(c),this.set(s,{programGPU:c,fragmentShader:u,vertexShader:d}),t!==null&&this.parallel){const p=new Promise(m=>{const y=this.parallel,M=()=>{n.getProgramParameter(c,y.COMPLETION_STATUS_KHR)?(this._completeCompile(e,s),m()):requestAnimationFrame(M)};M()});t.push(p);return}this._completeCompile(e,s)}_handleSource(e,t){const n=e.split(`
|
|
|
`),s=[],o=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let c=o;c<a;c++){const u=c+1;s.push(`${u===t?">":" "} ${u}: ${n[c]}`)}return s.join(`
|
|
|
`)}_getShaderErrors(e,t,n){const s=e.getShaderParameter(t,e.COMPILE_STATUS),a=(e.getShaderInfoLog(t)||"").trim();if(s&&a==="")return"";const c=/ERROR: 0:(\d+)/.exec(a);if(c){const u=parseInt(c[1]);return n.toUpperCase()+`
|
|
|
|
|
|
`+a+`
|
|
|
|
|
|
`+this._handleSource(e.getShaderSource(t),u)}else return a}_logProgramError(e,t,n){if(this.renderer.debug.checkShaderErrors){const s=this.gl,a=(s.getProgramInfoLog(e)||"").trim();if(s.getProgramParameter(e,s.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(s,e,n,t);else{const c=this._getShaderErrors(s,n,"vertex"),u=this._getShaderErrors(s,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(e,s.VALIDATE_STATUS)+`
|
|
|
|
|
|
Program Info Log: `+a+`
|
|
|
`+c+`
|
|
|
`+u)}else a!==""&&console.warn("THREE.WebGLProgram: Program Info Log:",a)}}_completeCompile(e,t){const{state:n,gl:s}=this,o=this.get(t),{programGPU:a,fragmentShader:c,vertexShader:u}=o;s.getProgramParameter(a,s.LINK_STATUS)===!1&&this._logProgramError(a,c,u),n.useProgram(a);const d=e.getBindings();this._setupBindings(d,a),this.set(t,{programGPU:a})}createComputePipeline(e,t){const{state:n,gl:s}=this,o={stage:"fragment",code:`#version 300 es
|
|
|
precision highp float;
|
|
|
void main() {}`};this.createProgram(o);const{computeProgram:a}=e,c=s.createProgram(),u=this.get(o).shaderGPU,d=this.get(a).shaderGPU,p=a.transforms,m=[],y=[];for(let z=0;z<p.length;z++){const I=p[z];m.push(I.varyingName),y.push(I.attributeNode)}s.attachShader(c,u),s.attachShader(c,d),s.transformFeedbackVaryings(c,m,s.SEPARATE_ATTRIBS),s.linkProgram(c),s.getProgramParameter(c,s.LINK_STATUS)===!1&&this._logProgramError(c,u,d),n.useProgram(c),this._setupBindings(t,c);const M=a.attributes,T=[],G=[];for(let z=0;z<M.length;z++){const I=M[z].node.attribute;T.push(I),this.has(I)||this.attributeUtils.createAttribute(I,s.ARRAY_BUFFER)}for(let z=0;z<y.length;z++){const I=y[z].attribute;this.has(I)||this.attributeUtils.createAttribute(I,s.ARRAY_BUFFER);const J=this.get(I);G.push(J)}this.set(e,{programGPU:c,transformBuffers:G,attributes:T})}createBindings(e,t){if(this._knownBindings.has(t)===!1){this._knownBindings.add(t);let n=0,s=0;for(const o of t){this.set(o,{textures:s,uniformBuffers:n});for(const a of o.bindings)a.isUniformBuffer&&n++,a.isSampledTexture&&s++}}this.updateBindings(e,t)}updateBindings(e){const{gl:t}=this,n=this.get(e);let s=n.uniformBuffers,o=n.textures;for(const a of e.bindings){const c=this.get(a);if(a.isUniformsGroup||a.isUniformBuffer){const u=a.buffer;let{bufferGPU:d}=this.get(u);d===void 0?(d=t.createBuffer(),t.bindBuffer(t.UNIFORM_BUFFER,d),t.bufferData(t.UNIFORM_BUFFER,u,t.DYNAMIC_DRAW),this.set(u,{bufferGPU:d})):(t.bindBuffer(t.UNIFORM_BUFFER,d),t.bufferSubData(t.UNIFORM_BUFFER,0,u)),c.index=s++,c.bufferGPU=d,this.set(a,c)}else if(a.isSampledTexture){const{textureGPU:u,glTextureType:d}=this.get(a.texture);c.index=o++,c.textureGPU=u,c.glTextureType=d,this.set(a,c)}}}updateBinding(e){const t=this.gl;if(e.isUniformsGroup||e.isUniformBuffer){const s=this.get(e).bufferGPU,o=e.buffer;t.bindBuffer(t.UNIFORM_BUFFER,s),t.bufferData(t.UNIFORM_BUFFER,o,t.DYNAMIC_DRAW)}}createIndexAttribute(e){const t=this.gl;this.attributeUtils.createAttribute(e,t.ELEMENT_ARRAY_BUFFER)}createAttribute(e){if(this.has(e))return;const t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}createStorageAttribute(e){if(this.has(e))return;const t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}hasFeature(e){const t=Object.keys(XI).filter(s=>XI[s]===e),n=this.extensions;for(let s=0;s<t.length;s++)if(n.has(t[s]))return!0;return!1}getMaxAnisotropy(){return this.capabilities.getMaxAnisotropy()}copyTextureToTexture(e,t,n=null,s=null,o=0,a=0){this.textureUtils.copyTextureToTexture(e,t,n,s,o,a)}copyFramebufferToTexture(e,t,n){this.textureUtils.copyFramebufferToTexture(e,t,n)}_setFramebuffer(e){const{gl:t,state:n}=this;let s=null;if(e.textures!==null){const o=e.renderTarget,a=this.get(o),{samples:c,depthBuffer:u,stencilBuffer:d}=o,p=o.isWebGLCubeRenderTarget===!0,m=o.isRenderTarget3D===!0,y=o.depth>1,M=o.isXRRenderTarget===!0,T=M===!0&&o._hasExternalTextures===!0;let G=a.msaaFrameBuffer,z=a.depthRenderbuffer;const I=this.extensions.get("WEBGL_multisampled_render_to_texture"),J=this.extensions.get("OVR_multiview2"),K=this._useMultisampledExtension(o),re=fP(e);let ve;if(p?(a.cubeFramebuffers||(a.cubeFramebuffers={}),ve=a.cubeFramebuffers[re]):M&&T===!1?ve=this._xrFramebuffer:(a.framebuffers||(a.framebuffers={}),ve=a.framebuffers[re]),ve===void 0){ve=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,ve);const me=e.textures,Le=[];if(p){a.cubeFramebuffers[re]=ve;const{textureGPU:Ee}=this.get(me[0]),Oe=this.renderer._activeCubeFace,dt=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Oe,Ee,dt)}else{a.framebuffers[re]=ve;for(let Ee=0;Ee<me.length;Ee++){const Oe=me[Ee],dt=this.get(Oe);dt.renderTarget=e.renderTarget,dt.cacheKey=re;const Ut=t.COLOR_ATTACHMENT0+Ee;if(o.multiview)J.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,Ut,dt.textureGPU,0,c,0,2);else if(m||y){const tn=this.renderer._activeCubeFace,cn=this.renderer._activeMipmapLevel;t.framebufferTextureLayer(t.FRAMEBUFFER,Ut,dt.textureGPU,cn,tn)}else if(K)I.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,Ut,t.TEXTURE_2D,dt.textureGPU,0,c);else{const tn=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,Ut,t.TEXTURE_2D,dt.textureGPU,tn)}}}const Ve=d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(o._autoAllocateDepthBuffer===!0){const Ee=t.createRenderbuffer();this.textureUtils.setupRenderBufferStorage(Ee,e,0,K),a.xrDepthRenderbuffer=Ee,Le.push(d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT),t.bindRenderbuffer(t.RENDERBUFFER,Ee),t.framebufferRenderbuffer(t.FRAMEBUFFER,Ve,t.RENDERBUFFER,Ee)}else if(e.depthTexture!==null){Le.push(d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT);const Ee=this.get(e.depthTexture);if(Ee.renderTarget=e.renderTarget,Ee.cacheKey=re,o.multiview)J.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,Ve,Ee.textureGPU,0,c,0,2);else if(T&&K)I.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,Ve,t.TEXTURE_2D,Ee.textureGPU,0,c);else if(e.depthTexture.isArrayTexture){const Oe=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,Ve,Ee.textureGPU,0,Oe)}else t.framebufferTexture2D(t.FRAMEBUFFER,Ve,t.TEXTURE_2D,Ee.textureGPU,0)}a.depthInvalidationArray=Le}else{if(this._isRenderCameraDepthArray(e)){n.bindFramebuffer(t.FRAMEBUFFER,ve);const Le=this.renderer._activeCubeFace,Ve=this.get(e.depthTexture),Ee=d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.framebufferTextureLayer(t.FRAMEBUFFER,Ee,Ve.textureGPU,0,Le)}if((M||K||o.multiview)&&o._isOpaqueFramebuffer!==!0){n.bindFramebuffer(t.FRAMEBUFFER,ve);const Le=this.get(e.textures[0]);o.multiview?J.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,Le.textureGPU,0,c,0,2):K?I.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Le.textureGPU,0,c):t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Le.textureGPU,0);const Ve=d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(o._autoAllocateDepthBuffer===!0){const Ee=a.xrDepthRenderbuffer;t.bindRenderbuffer(t.RENDERBUFFER,Ee),t.framebufferRenderbuffer(t.FRAMEBUFFER,Ve,t.RENDERBUFFER,Ee)}else{const Ee=this.get(e.depthTexture);o.multiview?J.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,Ve,Ee.textureGPU,0,c,0,2):K?I.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,Ve,t.TEXTURE_2D,Ee.textureGPU,0,c):t.framebufferTexture2D(t.FRAMEBUFFER,Ve,t.TEXTURE_2D,Ee.textureGPU,0)}}}if(c>0&&K===!1&&!o.multiview){if(G===void 0){const me=[];G=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,G);const Le=[],Ve=e.textures;for(let Ee=0;Ee<Ve.length;Ee++){Le[Ee]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,Le[Ee]),me.push(t.COLOR_ATTACHMENT0+Ee);const Oe=e.textures[Ee],dt=this.get(Oe);t.renderbufferStorageMultisample(t.RENDERBUFFER,c,dt.glInternalFormat,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ee,t.RENDERBUFFER,Le[Ee])}if(t.bindRenderbuffer(t.RENDERBUFFER,null),a.msaaFrameBuffer=G,a.msaaRenderbuffers=Le,u&&z===void 0){z=t.createRenderbuffer(),this.textureUtils.setupRenderBufferStorage(z,e,c),a.depthRenderbuffer=z;const Ee=d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;me.push(Ee)}a.invalidationArray=me}s=a.msaaFrameBuffer}else s=ve;n.drawBuffers(e,ve)}n.bindFramebuffer(t.FRAMEBUFFER,s)}_getVaoKey(e){let t="";for(let n=0;n<e.length;n++){const s=this.get(e[n]);t+=":"+s.id}return t}_createVao(e){const{gl:t}=this,n=t.createVertexArray();t.bindVertexArray(n);for(let s=0;s<e.length;s++){const o=e[s],a=this.get(o);t.bindBuffer(t.ARRAY_BUFFER,a.bufferGPU),t.enableVertexAttribArray(s);let c,u;o.isInterleavedBufferAttribute===!0?(c=o.data.stride*a.bytesPerElement,u=o.offset*a.bytesPerElement):(c=0,u=0),a.isInteger?t.vertexAttribIPointer(s,o.itemSize,a.type,c,u):t.vertexAttribPointer(s,o.itemSize,a.type,o.normalized,c,u),o.isInstancedBufferAttribute&&!o.isInterleavedBufferAttribute?t.vertexAttribDivisor(s,o.meshPerAttribute):o.isInterleavedBufferAttribute&&o.data.isInstancedInterleavedBuffer&&t.vertexAttribDivisor(s,o.data.meshPerAttribute)}return t.bindBuffer(t.ARRAY_BUFFER,null),n}_getTransformFeedback(e){let t="";for(let o=0;o<e.length;o++)t+=":"+e[o].id;let n=this.transformFeedbackCache[t];if(n!==void 0)return n;const{gl:s}=this;n=s.createTransformFeedback(),s.bindTransformFeedback(s.TRANSFORM_FEEDBACK,n);for(let o=0;o<e.length;o++){const a=e[o];s.bindBufferBase(s.TRANSFORM_FEEDBACK_BUFFER,o,a.transformBuffer)}return s.bindTransformFeedback(s.TRANSFORM_FEEDBACK,null),this.transformFeedbackCache[t]=n,n}_setupBindings(e,t){const n=this.gl;for(const s of e)for(const o of s.bindings){const c=this.get(o).index;if(o.isUniformsGroup||o.isUniformBuffer){const u=n.getUniformBlockIndex(t,o.name);n.uniformBlockBinding(t,u,c)}else if(o.isSampledTexture){const u=n.getUniformLocation(t,o.name);n.uniform1i(u,c)}}}_bindUniforms(e){const{gl:t,state:n}=this;for(const s of e)for(const o of s.bindings){const a=this.get(o),c=a.index;o.isUniformsGroup||o.isUniformBuffer?n.bindBufferBase(t.UNIFORM_BUFFER,c,a.bufferGPU):o.isSampledTexture&&n.bindTexture(a.glTextureType,a.textureGPU,t.TEXTURE0+c)}}_resolveRenderTarget(e){const{gl:t,state:n}=this,s=e.renderTarget;if(e.textures!==null&&s){const o=this.get(s);if(s.samples>0&&this._useMultisampledExtension(s)===!1){const a=o.framebuffers[e.getCacheKey()];let c=t.COLOR_BUFFER_BIT;s.resolveDepthBuffer&&(s.depthBuffer&&(c|=t.DEPTH_BUFFER_BIT),s.stencilBuffer&&s.resolveStencilBuffer&&(c|=t.STENCIL_BUFFER_BIT));const u=o.msaaFrameBuffer,d=o.msaaRenderbuffers,p=e.textures,m=p.length>1;if(n.bindFramebuffer(t.READ_FRAMEBUFFER,u),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,a),m)for(let y=0;y<p.length;y++)t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+y,t.RENDERBUFFER,null),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+y,t.TEXTURE_2D,null,0);for(let y=0;y<p.length;y++){if(m){const{textureGPU:M}=this.get(p[y]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,d[y]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,M,0)}if(e.scissor){const{x:M,y:T,width:G,height:z}=e.scissorValue,I=e.height-z-T;t.blitFramebuffer(M,I,M+G,I+z,M,I,M+G,I+z,c,t.NEAREST)}else t.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,c,t.NEAREST)}if(m)for(let y=0;y<p.length;y++){const{textureGPU:M}=this.get(p[y]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+y,t.RENDERBUFFER,d[y]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+y,t.TEXTURE_2D,M,0)}this._supportsInvalidateFramebuffer===!0&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,o.invalidationArray)}else if(s.resolveDepthBuffer===!1&&o.framebuffers){const a=o.framebuffers[e.getCacheKey()];n.bindFramebuffer(t.DRAW_FRAMEBUFFER,a),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,o.depthInvalidationArray)}}}_useMultisampledExtension(e){return e.multiview===!0?!0:e.samples>0&&this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer!==!1}dispose(){const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const m0={PointList:"point-list",LineList:"line-list",LineStrip:"line-strip",TriangleList:"triangle-list",TriangleStrip:"triangle-strip"},Ol={Never:"never",Less:"less",Equal:"equal",LessEqual:"less-equal",Greater:"greater",NotEqual:"not-equal",GreaterEqual:"greater-equal",Always:"always"},ac={Store:"store"},go={Load:"load",Clear:"clear"},ZI={CCW:"ccw",CW:"cw"},KI={None:"none",Back:"back"},g0={Uint16:"uint16",Uint32:"uint32"},$t={R8Unorm:"r8unorm",R8Snorm:"r8snorm",R8Uint:"r8uint",R8Sint:"r8sint",R16Uint:"r16uint",R16Sint:"r16sint",R16Float:"r16float",RG8Unorm:"rg8unorm",RG8Snorm:"rg8snorm",RG8Uint:"rg8uint",RG8Sint:"rg8sint",R32Uint:"r32uint",R32Sint:"r32sint",R32Float:"r32float",RG16Uint:"rg16uint",RG16Sint:"rg16sint",RG16Float:"rg16float",RGBA8Unorm:"rgba8unorm",RGBA8UnormSRGB:"rgba8unorm-srgb",RGBA8Snorm:"rgba8snorm",RGBA8Uint:"rgba8uint",RGBA8Sint:"rgba8sint",BGRA8Unorm:"bgra8unorm",BGRA8UnormSRGB:"bgra8unorm-srgb",RGB9E5UFloat:"rgb9e5ufloat",RGB10A2Unorm:"rgb10a2unorm",RG11B10UFloat:"rg11b10ufloat",RG32Uint:"rg32uint",RG32Sint:"rg32sint",RG32Float:"rg32float",RGBA16Uint:"rgba16uint",RGBA16Sint:"rgba16sint",RGBA16Float:"rgba16float",RGBA32Uint:"rgba32uint",RGBA32Sint:"rgba32sint",RGBA32Float:"rgba32float",Depth16Unorm:"depth16unorm",Depth24Plus:"depth24plus",Depth24PlusStencil8:"depth24plus-stencil8",Depth32Float:"depth32float",Depth32FloatStencil8:"depth32float-stencil8",BC1RGBAUnorm:"bc1-rgba-unorm",BC1RGBAUnormSRGB:"bc1-rgba-unorm-srgb",BC2RGBAUnorm:"bc2-rgba-unorm",BC2RGBAUnormSRGB:"bc2-rgba-unorm-srgb",BC3RGBAUnorm:"bc3-rgba-unorm",BC3RGBAUnormSRGB:"bc3-rgba-unorm-srgb",BC4RUnorm:"bc4-r-unorm",BC4RSnorm:"bc4-r-snorm",BC5RGUnorm:"bc5-rg-unorm",BC5RGSnorm:"bc5-rg-snorm",BC6HRGBUFloat:"bc6h-rgb-ufloat",BC6HRGBFloat:"bc6h-rgb-float",BC7RGBAUnorm:"bc7-rgba-unorm",BC7RGBAUnormSRGB:"bc7-rgba-unorm-srgb",ETC2RGB8Unorm:"etc2-rgb8unorm",ETC2RGB8UnormSRGB:"etc2-rgb8unorm-srgb",ETC2RGB8A1Unorm:"etc2-rgb8a1unorm",ETC2RGB8A1UnormSRGB:"etc2-rgb8a1unorm-srgb",ETC2RGBA8Unorm:"etc2-rgba8unorm",ETC2RGBA8UnormSRGB:"etc2-rgba8unorm-srgb",EACR11Unorm:"eac-r11unorm",EACR11Snorm:"eac-r11snorm",EACRG11Unorm:"eac-rg11unorm",EACRG11Snorm:"eac-rg11snorm",ASTC4x4Unorm:"astc-4x4-unorm",ASTC4x4UnormSRGB:"astc-4x4-unorm-srgb",ASTC5x4Unorm:"astc-5x4-unorm",ASTC5x4UnormSRGB:"astc-5x4-unorm-srgb",ASTC5x5Unorm:"astc-5x5-unorm",ASTC5x5UnormSRGB:"astc-5x5-unorm-srgb",ASTC6x5Unorm:"astc-6x5-unorm",ASTC6x5UnormSRGB:"astc-6x5-unorm-srgb",ASTC6x6Unorm:"astc-6x6-unorm",ASTC6x6UnormSRGB:"astc-6x6-unorm-srgb",ASTC8x5Unorm:"astc-8x5-unorm",ASTC8x5UnormSRGB:"astc-8x5-unorm-srgb",ASTC8x6Unorm:"astc-8x6-unorm",ASTC8x6UnormSRGB:"astc-8x6-unorm-srgb",ASTC8x8Unorm:"astc-8x8-unorm",ASTC8x8UnormSRGB:"astc-8x8-unorm-srgb",ASTC10x5Unorm:"astc-10x5-unorm",ASTC10x5UnormSRGB:"astc-10x5-unorm-srgb",ASTC10x6Unorm:"astc-10x6-unorm",ASTC10x6UnormSRGB:"astc-10x6-unorm-srgb",ASTC10x8Unorm:"astc-10x8-unorm",ASTC10x8UnormSRGB:"astc-10x8-unorm-srgb",ASTC10x10Unorm:"astc-10x10-unorm",ASTC10x10UnormSRGB:"astc-10x10-unorm-srgb",ASTC12x10Unorm:"astc-12x10-unorm",ASTC12x10UnormSRGB:"astc-12x10-unorm-srgb",ASTC12x12Unorm:"astc-12x12-unorm",ASTC12x12UnormSRGB:"astc-12x12-unorm-srgb"},wT={ClampToEdge:"clamp-to-edge",Repeat:"repeat",MirrorRepeat:"mirror-repeat"},Am={Linear:"linear",Nearest:"nearest"},zs={Zero:"zero",One:"one",Src:"src",OneMinusSrc:"one-minus-src",SrcAlpha:"src-alpha",OneMinusSrcAlpha:"one-minus-src-alpha",Dst:"dst",OneMinusDst:"one-minus-dst",DstAlpha:"dst-alpha",OneMinusDstAlpha:"one-minus-dst-alpha",SrcAlphaSaturated:"src-alpha-saturated",Constant:"constant",OneMinusConstant:"one-minus-constant"},Cm={Add:"add",Subtract:"subtract",ReverseSubtract:"reverse-subtract",Min:"min",Max:"max"},JI={None:0,All:15},ep={Keep:"keep",Zero:"zero",Replace:"replace",Invert:"invert",IncrementClamp:"increment-clamp",DecrementClamp:"decrement-clamp",IncrementWrap:"increment-wrap",DecrementWrap:"decrement-wrap"},MT={Storage:"storage",ReadOnlyStorage:"read-only-storage"},ST={WriteOnly:"write-only",ReadOnly:"read-only",ReadWrite:"read-write"},QI={NonFiltering:"non-filtering",Comparison:"comparison"},Rm={Float:"float",UnfilterableFloat:"unfilterable-float",Depth:"depth",SInt:"sint",UInt:"uint"},eL={TwoD:"2d",ThreeD:"3d"},rl={TwoD:"2d",TwoDArray:"2d-array",Cube:"cube",ThreeD:"3d"},O9={All:"all"},zb={Vertex:"vertex",Instance:"instance"},TT={CoreFeaturesAndLimits:"core-features-and-limits",DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionBCSliced3D:"texture-compression-bc-sliced-3d",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TextureCompressionASTCSliced3D:"texture-compression-astc-sliced-3d",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",Float32Blendable:"float32-blendable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups",TextureFormatsTier1:"texture-formats-tier1",TextureFormatsTier2:"texture-formats-tier2"};class F9 extends BI{constructor(e,t,n){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n}update(){this.texture=this.textureNode.value}}class B9 extends LI{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}let U9=0;class k9 extends B9{constructor(e,t){super("StorageBuffer_"+U9++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:Il.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class z9 extends Zf{constructor(e){super(),this.device=e;const t=`
|
|
|
struct VarysStruct {
|
|
|
@builtin( position ) Position: vec4<f32>,
|
|
|
@location( 0 ) vTex : vec2<f32>
|
|
|
};
|
|
|
|
|
|
@vertex
|
|
|
fn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {
|
|
|
|
|
|
var Varys : VarysStruct;
|
|
|
|
|
|
var pos = array< vec2<f32>, 4 >(
|
|
|
vec2<f32>( -1.0, 1.0 ),
|
|
|
vec2<f32>( 1.0, 1.0 ),
|
|
|
vec2<f32>( -1.0, -1.0 ),
|
|
|
vec2<f32>( 1.0, -1.0 )
|
|
|
);
|
|
|
|
|
|
var tex = array< vec2<f32>, 4 >(
|
|
|
vec2<f32>( 0.0, 0.0 ),
|
|
|
vec2<f32>( 1.0, 0.0 ),
|
|
|
vec2<f32>( 0.0, 1.0 ),
|
|
|
vec2<f32>( 1.0, 1.0 )
|
|
|
);
|
|
|
|
|
|
Varys.vTex = tex[ vertexIndex ];
|
|
|
Varys.Position = vec4<f32>( pos[ vertexIndex ], 0.0, 1.0 );
|
|
|
|
|
|
return Varys;
|
|
|
|
|
|
}
|
|
|
`,n=`
|
|
|
@group( 0 ) @binding( 0 )
|
|
|
var imgSampler : sampler;
|
|
|
|
|
|
@group( 0 ) @binding( 1 )
|
|
|
var img : texture_2d<f32>;
|
|
|
|
|
|
@fragment
|
|
|
fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
|
|
|
|
|
|
return textureSample( img, imgSampler, vTex );
|
|
|
|
|
|
}
|
|
|
`,s=`
|
|
|
@group( 0 ) @binding( 0 )
|
|
|
var imgSampler : sampler;
|
|
|
|
|
|
@group( 0 ) @binding( 1 )
|
|
|
var img : texture_2d<f32>;
|
|
|
|
|
|
@fragment
|
|
|
fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
|
|
|
|
|
|
return textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) );
|
|
|
|
|
|
}
|
|
|
`;this.mipmapSampler=e.createSampler({minFilter:Am.Linear}),this.flipYSampler=e.createSampler({minFilter:Am.Nearest}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:t}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:n}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:s})}getTransferPipeline(e){let t=this.transferPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:m0.TriangleStrip,stripIndexFormat:g0.Uint32},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:m0.TriangleStrip,stripIndexFormat:g0.Uint32},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,n=0){const s=t.format,{width:o,height:a}=t.size,c=this.getTransferPipeline(s),u=this.getFlipYPipeline(s),d=this.device.createTexture({size:{width:o,height:a,depthOrArrayLayers:1},format:s,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),p=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:rl.TwoD,baseArrayLayer:n}),m=d.createView({baseMipLevel:0,mipLevelCount:1,dimension:rl.TwoD,baseArrayLayer:0}),y=this.device.createCommandEncoder({}),M=(T,G,z)=>{const I=T.getBindGroupLayout(0),J=this.device.createBindGroup({layout:I,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:G}]}),K=y.beginRenderPass({colorAttachments:[{view:z,loadOp:go.Clear,storeOp:ac.Store,clearValue:[0,0,0,0]}]});K.setPipeline(T),K.setBindGroup(0,J),K.draw(4,1,0,0),K.end()};M(c,p,m),M(u,m,p),this.device.queue.submit([y.finish()]),d.destroy()}generateMipmaps(e,t,n=0){const s=this.get(e);s.useCount===void 0&&(s.useCount=0,s.layers=[]);const o=s.layers[n]||this._mipmapCreateBundles(e,t,n),a=this.device.createCommandEncoder({});this._mipmapRunBundles(a,o),this.device.queue.submit([a.finish()]),s.useCount!==0&&(s.layers[n]=o),s.useCount++}_mipmapCreateBundles(e,t,n){const s=this.getTransferPipeline(t.format),o=s.getBindGroupLayout(0);let a=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:rl.TwoD,baseArrayLayer:n});const c=[];for(let u=1;u<t.mipLevelCount;u++){const d=this.device.createBindGroup({layout:o,entries:[{binding:0,resource:this.mipmapSampler},{binding:1,resource:a}]}),p=e.createView({baseMipLevel:u,mipLevelCount:1,dimension:rl.TwoD,baseArrayLayer:n}),m={colorAttachments:[{view:p,loadOp:go.Clear,storeOp:ac.Store,clearValue:[0,0,0,0]}]},y=this.device.createRenderBundleEncoder({colorFormats:[t.format]});y.setPipeline(s),y.setBindGroup(0,d),y.draw(4,1,0,0),c.push({renderBundles:[y.finish()],passDescriptor:m}),a=p}return c}_mipmapRunBundles(e,t){const n=t.length;for(let s=0;s<n;s++){const o=t[s],a=e.beginRenderPass(o.passDescriptor);a.executeBundles(o.renderBundles),a.end()}}}const V9={[km]:"never",[ef]:"less",[tf]:"equal",[op]:"less-equal",[E0]:"greater",[C0]:"greater-equal",[zm]:"always",[A0]:"not-equal"},G9=[0,1,3,2,4,5];class W9{constructor(e){this.backend=e,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this.colorBuffer=null,this.depthTexture=new vc,this.depthTexture.name="depthBuffer"}createSampler(e){const t=this.backend,n=t.device,s=t.get(e),o={addressModeU:this._convertAddressMode(e.wrapS),addressModeV:this._convertAddressMode(e.wrapT),addressModeW:this._convertAddressMode(e.wrapR),magFilter:this._convertFilterMode(e.magFilter),minFilter:this._convertFilterMode(e.minFilter),mipmapFilter:this._convertFilterMode(e.minFilter),maxAnisotropy:1};o.magFilter===Am.Linear&&o.minFilter===Am.Linear&&o.mipmapFilter===Am.Linear&&(o.maxAnisotropy=e.anisotropy),e.isDepthTexture&&e.compareFunction!==null&&(o.compare=V9[e.compareFunction]),s.sampler=n.createSampler(o)}createDefaultTexture(e){let t;const n=ET(e);e.isCubeTexture?t=this._getDefaultCubeTextureGPU(n):t=this._getDefaultTextureGPU(n),this.backend.get(e).texture=t}createTexture(e,t={}){const n=this.backend,s=n.get(e);if(s.initialized)throw new Error("WebGPUTextureUtils: Texture already initialized.");if(e.isExternalTexture){s.texture=e.sourceTexture,s.initialized=!0;return}t.needsMipmaps===void 0&&(t.needsMipmaps=!1),t.levels===void 0&&(t.levels=1),t.depth===void 0&&(t.depth=1);const{width:o,height:a,depth:c,levels:u}=t;e.isFramebufferTexture&&(t.renderTarget?t.format=this.backend.utils.getCurrentColorFormat(t.renderTarget):t.format=this.backend.utils.getPreferredCanvasFormat());const d=this._getDimension(e),p=e.internalFormat||t.format||ET(e,n.device);s.format=p;const{samples:m,primarySamples:y,isMSAA:M}=n.utils.getTextureSampleData(e);let T=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;e.isStorageTexture===!0&&(T|=GPUTextureUsage.STORAGE_BINDING),e.isCompressedTexture!==!0&&e.isCompressedArrayTexture!==!0&&p!==$t.RGB9E5UFloat&&(T|=GPUTextureUsage.RENDER_ATTACHMENT);const G={label:e.name,size:{width:o,height:a,depthOrArrayLayers:c},mipLevelCount:u,sampleCount:y,dimension:d,format:p,usage:T};if(p===void 0){console.warn("WebGPURenderer: Texture format not supported."),this.createDefaultTexture(e);return}if(e.isCubeTexture&&(G.textureBindingViewDimension=rl.Cube),s.texture=n.device.createTexture(G),M){const z=Object.assign({},G);z.label=z.label+"-msaa",z.sampleCount=m,z.mipLevelCount=1,s.msaaTexture=n.device.createTexture(z)}s.initialized=!0,s.textureDescriptorGPU=G}destroyTexture(e){const t=this.backend,n=t.get(e);n.texture!==void 0&&n.texture.destroy(),n.msaaTexture!==void 0&&n.msaaTexture.destroy(),t.delete(e)}destroySampler(e){const n=this.backend.get(e);delete n.sampler}generateMipmaps(e){const t=this.backend.get(e);if(e.isCubeTexture)for(let n=0;n<6;n++)this._generateMipmaps(t.texture,t.textureDescriptorGPU,n);else{const n=e.image.depth||1;for(let s=0;s<n;s++)this._generateMipmaps(t.texture,t.textureDescriptorGPU,s)}}getColorBuffer(){this.colorBuffer&&this.colorBuffer.destroy();const e=this.backend,{width:t,height:n}=e.getDrawingBufferSize();return this.colorBuffer=e.device.createTexture({label:"colorBuffer",size:{width:t,height:n,depthOrArrayLayers:1},sampleCount:e.utils.getSampleCount(e.renderer.samples),format:e.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC}),this.colorBuffer}getDepthBuffer(e=!0,t=!1){const n=this.backend,{width:s,height:o}=n.getDrawingBufferSize(),a=this.depthTexture,c=n.get(a).texture;let u,d;if(t?(u=_,d=Fa):e&&(u=U,d=ls),c!==void 0){if(a.image.width===s&&a.image.height===o&&a.format===u&&a.type===d)return c;this.destroyTexture(a)}return a.name="depthBuffer",a.format=u,a.type=d,a.image.width=s,a.image.height=o,this.createTexture(a,{width:s,height:o}),n.get(a).texture}updateTexture(e,t){const n=this.backend.get(e),s=e.mipmaps,{textureDescriptorGPU:o}=n;if(!(e.isRenderTargetTexture||o===void 0)){if(e.isDataTexture)if(s.length>0)for(let a=0,c=s.length;a<c;a++){const u=s[a];this._copyBufferToTexture(u,n.texture,o,0,e.flipY,0,a)}else this._copyBufferToTexture(t.image,n.texture,o,0,e.flipY);else if(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)for(let a=0;a<t.image.depth;a++)this._copyBufferToTexture(t.image,n.texture,o,a,e.flipY,a);else if(e.isCompressedTexture||e.isCompressedArrayTexture)this._copyCompressedBufferToTexture(e.mipmaps,n.texture,o);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,n.texture,o);else if(s.length>0)for(let a=0,c=s.length;a<c;a++){const u=s[a];this._copyImageToTexture(u,n.texture,o,0,e.flipY,e.premultiplyAlpha,a)}else this._copyImageToTexture(t.image,n.texture,o,0,e.flipY,e.premultiplyAlpha);n.version=e.version}}copyTextureToBuffer(e,t,n,s,o,a){return hr(this,null,function*(){const c=this.backend.device,u=this.backend.get(e),d=u.texture,p=u.textureDescriptorGPU.format,m=this._getBytesPerTexel(p);let y=s*m;y=Math.ceil(y/256)*256;const M=c.createBuffer({size:(o-1)*y+s*m,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),T=c.createCommandEncoder();T.copyTextureToBuffer({texture:d,origin:{x:t,y:n,z:a}},{buffer:M,bytesPerRow:y},{width:s,height:o});const G=this._getTypedArrayType(p);c.queue.submit([T.finish()]),yield M.mapAsync(GPUMapMode.READ);const z=M.getMappedRange();return new G(z)})}_getDefaultTextureGPU(e){let t=this.defaultTexture[e];if(t===void 0){const n=new Ho;n.minFilter=Ct,n.magFilter=Ct,this.createTexture(n,{width:1,height:1,format:e}),this.defaultTexture[e]=t=n}return this.backend.get(t).texture}_getDefaultCubeTextureGPU(e){let t=this.defaultTexture[e];if(t===void 0){const n=new xh;n.minFilter=Ct,n.magFilter=Ct,this.createTexture(n,{width:1,height:1,depth:6}),this.defaultCubeTexture[e]=t=n}return this.backend.get(t).texture}_copyCubeMapToTexture(e,t,n){const s=e.images,o=e.mipmaps;for(let a=0;a<6;a++){const c=s[a],u=e.flipY===!0?G9[a]:a;c.isDataTexture?this._copyBufferToTexture(c.image,t,n,u,e.flipY):this._copyImageToTexture(c,t,n,u,e.flipY,e.premultiplyAlpha);for(let d=0;d<o.length;d++){const m=o[d].images[a];m.isDataTexture?this._copyBufferToTexture(m.image,t,n,u,e.flipY,0,d+1):this._copyImageToTexture(m,t,n,u,e.flipY,e.premultiplyAlpha,d+1)}}}_copyImageToTexture(e,t,n,s,o,a,c=0){const u=this.backend.device,d=c>0?e.width:n.size.width,p=c>0?e.height:n.size.height;u.queue.copyExternalImageToTexture({source:e,flipY:o},{texture:t,mipLevel:c,origin:{x:0,y:0,z:s},premultipliedAlpha:a},{width:d,height:p,depthOrArrayLayers:1})}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new z9(this.backend.device)),e}_generateMipmaps(e,t,n=0){this._getPassUtils().generateMipmaps(e,t,n)}_flipY(e,t,n=0){this._getPassUtils().flipY(e,t,n)}_copyBufferToTexture(e,t,n,s,o,a=0,c=0){const u=this.backend.device,d=e.data,p=this._getBytesPerTexel(n.format),m=e.width*p;u.queue.writeTexture({texture:t,mipLevel:c,origin:{x:0,y:0,z:s}},d,{offset:e.width*e.height*p*a,bytesPerRow:m},{width:e.width,height:e.height,depthOrArrayLayers:1}),o===!0&&this._flipY(t,n,s)}_copyCompressedBufferToTexture(e,t,n){const s=this.backend.device,o=this._getBlockData(n.format),a=n.size.depthOrArrayLayers>1;for(let c=0;c<e.length;c++){const u=e[c],d=u.width,p=u.height,m=a?n.size.depthOrArrayLayers:1,y=Math.ceil(d/o.width)*o.byteLength,M=y*Math.ceil(p/o.height);for(let T=0;T<m;T++)s.queue.writeTexture({texture:t,mipLevel:c,origin:{x:0,y:0,z:T}},u.data,{offset:T*M,bytesPerRow:y,rowsPerImage:Math.ceil(p/o.height)},{width:Math.ceil(d/o.width)*o.width,height:Math.ceil(p/o.height)*o.height,depthOrArrayLayers:1})}}_getBlockData(e){if(e===$t.BC1RGBAUnorm||e===$t.BC1RGBAUnormSRGB)return{byteLength:8,width:4,height:4};if(e===$t.BC2RGBAUnorm||e===$t.BC2RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===$t.BC3RGBAUnorm||e===$t.BC3RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===$t.BC4RUnorm||e===$t.BC4RSnorm)return{byteLength:8,width:4,height:4};if(e===$t.BC5RGUnorm||e===$t.BC5RGSnorm)return{byteLength:16,width:4,height:4};if(e===$t.BC6HRGBUFloat||e===$t.BC6HRGBFloat)return{byteLength:16,width:4,height:4};if(e===$t.BC7RGBAUnorm||e===$t.BC7RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===$t.ETC2RGB8Unorm||e===$t.ETC2RGB8UnormSRGB)return{byteLength:8,width:4,height:4};if(e===$t.ETC2RGB8A1Unorm||e===$t.ETC2RGB8A1UnormSRGB)return{byteLength:8,width:4,height:4};if(e===$t.ETC2RGBA8Unorm||e===$t.ETC2RGBA8UnormSRGB)return{byteLength:16,width:4,height:4};if(e===$t.EACR11Unorm)return{byteLength:8,width:4,height:4};if(e===$t.EACR11Snorm)return{byteLength:8,width:4,height:4};if(e===$t.EACRG11Unorm)return{byteLength:16,width:4,height:4};if(e===$t.EACRG11Snorm)return{byteLength:16,width:4,height:4};if(e===$t.ASTC4x4Unorm||e===$t.ASTC4x4UnormSRGB)return{byteLength:16,width:4,height:4};if(e===$t.ASTC5x4Unorm||e===$t.ASTC5x4UnormSRGB)return{byteLength:16,width:5,height:4};if(e===$t.ASTC5x5Unorm||e===$t.ASTC5x5UnormSRGB)return{byteLength:16,width:5,height:5};if(e===$t.ASTC6x5Unorm||e===$t.ASTC6x5UnormSRGB)return{byteLength:16,width:6,height:5};if(e===$t.ASTC6x6Unorm||e===$t.ASTC6x6UnormSRGB)return{byteLength:16,width:6,height:6};if(e===$t.ASTC8x5Unorm||e===$t.ASTC8x5UnormSRGB)return{byteLength:16,width:8,height:5};if(e===$t.ASTC8x6Unorm||e===$t.ASTC8x6UnormSRGB)return{byteLength:16,width:8,height:6};if(e===$t.ASTC8x8Unorm||e===$t.ASTC8x8UnormSRGB)return{byteLength:16,width:8,height:8};if(e===$t.ASTC10x5Unorm||e===$t.ASTC10x5UnormSRGB)return{byteLength:16,width:10,height:5};if(e===$t.ASTC10x6Unorm||e===$t.ASTC10x6UnormSRGB)return{byteLength:16,width:10,height:6};if(e===$t.ASTC10x8Unorm||e===$t.ASTC10x8UnormSRGB)return{byteLength:16,width:10,height:8};if(e===$t.ASTC10x10Unorm||e===$t.ASTC10x10UnormSRGB)return{byteLength:16,width:10,height:10};if(e===$t.ASTC12x10Unorm||e===$t.ASTC12x10UnormSRGB)return{byteLength:16,width:12,height:10};if(e===$t.ASTC12x12Unorm||e===$t.ASTC12x12UnormSRGB)return{byteLength:16,width:12,height:12}}_convertAddressMode(e){let t=wT.ClampToEdge;return e===st?t=wT.Repeat:e===ft&&(t=wT.MirrorRepeat),t}_convertFilterMode(e){let t=Am.Linear;return(e===Ct||e===jt||e===pn)&&(t=Am.Nearest),t}_getBytesPerTexel(e){if(e===$t.R8Unorm||e===$t.R8Snorm||e===$t.R8Uint||e===$t.R8Sint)return 1;if(e===$t.R16Uint||e===$t.R16Sint||e===$t.R16Float||e===$t.RG8Unorm||e===$t.RG8Snorm||e===$t.RG8Uint||e===$t.RG8Sint)return 2;if(e===$t.R32Uint||e===$t.R32Sint||e===$t.R32Float||e===$t.RG16Uint||e===$t.RG16Sint||e===$t.RG16Float||e===$t.RGBA8Unorm||e===$t.RGBA8UnormSRGB||e===$t.RGBA8Snorm||e===$t.RGBA8Uint||e===$t.RGBA8Sint||e===$t.BGRA8Unorm||e===$t.BGRA8UnormSRGB||e===$t.RGB9E5UFloat||e===$t.RGB10A2Unorm||e===$t.RG11B10UFloat||e===$t.Depth32Float||e===$t.Depth24Plus||e===$t.Depth24PlusStencil8||e===$t.Depth32FloatStencil8)return 4;if(e===$t.RG32Uint||e===$t.RG32Sint||e===$t.RG32Float||e===$t.RGBA16Uint||e===$t.RGBA16Sint||e===$t.RGBA16Float)return 8;if(e===$t.RGBA32Uint||e===$t.RGBA32Sint||e===$t.RGBA32Float)return 16}_getTypedArrayType(e){if(e===$t.R8Uint)return Uint8Array;if(e===$t.R8Sint)return Int8Array;if(e===$t.R8Unorm)return Uint8Array;if(e===$t.R8Snorm)return Int8Array;if(e===$t.RG8Uint)return Uint8Array;if(e===$t.RG8Sint)return Int8Array;if(e===$t.RG8Unorm)return Uint8Array;if(e===$t.RG8Snorm)return Int8Array;if(e===$t.RGBA8Uint)return Uint8Array;if(e===$t.RGBA8Sint)return Int8Array;if(e===$t.RGBA8Unorm||e===$t.RGBA8UnormSRGB)return Uint8Array;if(e===$t.RGBA8Snorm)return Int8Array;if(e===$t.R16Uint)return Uint16Array;if(e===$t.R16Sint)return Int16Array;if(e===$t.RG16Uint)return Uint16Array;if(e===$t.RG16Sint)return Int16Array;if(e===$t.RGBA16Uint)return Uint16Array;if(e===$t.RGBA16Sint)return Int16Array;if(e===$t.R16Float||e===$t.RG16Float||e===$t.RGBA16Float)return Uint16Array;if(e===$t.R32Uint)return Uint32Array;if(e===$t.R32Sint)return Int32Array;if(e===$t.R32Float)return Float32Array;if(e===$t.RG32Uint)return Uint32Array;if(e===$t.RG32Sint)return Int32Array;if(e===$t.RG32Float)return Float32Array;if(e===$t.RGBA32Uint)return Uint32Array;if(e===$t.RGBA32Sint)return Int32Array;if(e===$t.RGBA32Float)return Float32Array;if(e===$t.BGRA8Unorm||e===$t.BGRA8UnormSRGB)return Uint8Array;if(e===$t.RGB10A2Unorm||e===$t.RGB9E5UFloat||e===$t.RG11B10UFloat)return Uint32Array;if(e===$t.Depth32Float)return Float32Array;if(e===$t.Depth24Plus||e===$t.Depth24PlusStencil8)return Uint32Array;if(e===$t.Depth32FloatStencil8)return Float32Array}_getDimension(e){let t;return e.is3DTexture||e.isData3DTexture?t=eL.ThreeD:t=eL.TwoD,t}}function ET(i,e=null){const t=i.format,n=i.type,s=i.colorSpace,o=Ki.getTransfer(s);let a;if(i.isCompressedTexture===!0||i.isCompressedArrayTexture===!0)switch(t){case Wt:case Tt:a=o===Fi?$t.BC1RGBAUnormSRGB:$t.BC1RGBAUnorm;break;case on:a=o===Fi?$t.BC2RGBAUnormSRGB:$t.BC2RGBAUnorm;break;case Un:a=o===Fi?$t.BC3RGBAUnormSRGB:$t.BC3RGBAUnorm;break;case Eo:a=$t.BC4RUnorm;break;case Wr:a=$t.BC4RSnorm;break;case eo:a=$t.BC5RGUnorm;break;case Ao:a=$t.BC5RGSnorm;break;case io:a=o===Fi?$t.BC7RGBAUnormSRGB:$t.BC7RGBAUnorm;break;case ni:case $n:a=o===Fi?$t.ETC2RGB8UnormSRGB:$t.ETC2RGB8Unorm;break;case Pi:a=o===Fi?$t.ETC2RGBA8UnormSRGB:$t.ETC2RGBA8Unorm;break;case ui:a=o===Fi?$t.ASTC4x4UnormSRGB:$t.ASTC4x4Unorm;break;case Lr:a=o===Fi?$t.ASTC5x4UnormSRGB:$t.ASTC5x4Unorm;break;case yi:a=o===Fi?$t.ASTC5x5UnormSRGB:$t.ASTC5x5Unorm;break;case vi:a=o===Fi?$t.ASTC6x5UnormSRGB:$t.ASTC6x5Unorm;break;case Mr:a=o===Fi?$t.ASTC6x6UnormSRGB:$t.ASTC6x6Unorm;break;case Zt:a=o===Fi?$t.ASTC8x5UnormSRGB:$t.ASTC8x5Unorm;break;case Fn:a=o===Fi?$t.ASTC8x6UnormSRGB:$t.ASTC8x6Unorm;break;case hi:a=o===Fi?$t.ASTC8x8UnormSRGB:$t.ASTC8x8Unorm;break;case Xn:a=o===Fi?$t.ASTC10x5UnormSRGB:$t.ASTC10x5Unorm;break;case ds:a=o===Fi?$t.ASTC10x6UnormSRGB:$t.ASTC10x6Unorm;break;case qr:a=o===Fi?$t.ASTC10x8UnormSRGB:$t.ASTC10x8Unorm;break;case vs:a=o===Fi?$t.ASTC10x10UnormSRGB:$t.ASTC10x10Unorm;break;case kr:a=o===Fi?$t.ASTC12x10UnormSRGB:$t.ASTC12x10Unorm;break;case Fs:a=o===Fi?$t.ASTC12x12UnormSRGB:$t.ASTC12x12Unorm;break;case D:a=o===Fi?$t.RGBA8UnormSRGB:$t.RGBA8Unorm;break;default:console.error("WebGPURenderer: Unsupported texture format.",t)}else switch(t){case D:switch(n){case Gi:a=$t.RGBA8Snorm;break;case ir:a=$t.RGBA16Sint;break;case gs:a=$t.RGBA16Uint;break;case ls:a=$t.RGBA32Uint;break;case Ls:a=$t.RGBA32Sint;break;case Oi:a=o===Fi?$t.RGBA8UnormSRGB:$t.RGBA8Unorm;break;case Gs:a=$t.RGBA16Float;break;case ys:a=$t.RGBA32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBAFormat.",n)}break;case Pe:switch(n){case Fl:a=$t.RGB9E5UFloat;break;case su:a=$t.RG11B10UFloat;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBFormat.",n)}break;case F:switch(n){case Gi:a=$t.R8Snorm;break;case ir:a=$t.R16Sint;break;case gs:a=$t.R16Uint;break;case ls:a=$t.R32Uint;break;case Ls:a=$t.R32Sint;break;case Oi:a=$t.R8Unorm;break;case Gs:a=$t.R16Float;break;case ys:a=$t.R32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with RedFormat.",n)}break;case Ie:switch(n){case Gi:a=$t.RG8Snorm;break;case ir:a=$t.RG16Sint;break;case gs:a=$t.RG16Uint;break;case ls:a=$t.RG32Uint;break;case Ls:a=$t.RG32Sint;break;case Oi:a=$t.RG8Unorm;break;case Gs:a=$t.RG16Float;break;case ys:a=$t.RG32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with RGFormat.",n)}break;case U:switch(n){case gs:a=$t.Depth16Unorm;break;case ls:a=$t.Depth24Plus;break;case ys:a=$t.Depth32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with DepthFormat.",n)}break;case _:switch(n){case Fa:a=$t.Depth24PlusStencil8;break;case ys:e&&e.features.has(TT.Depth32FloatStencil8)===!1&&console.error('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),a=$t.Depth32FloatStencil8;break;default:console.error("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",n)}break;case X:switch(n){case Ls:a=$t.R32Sint;break;case ls:a=$t.R32Uint;break;default:console.error("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",n)}break;case ke:switch(n){case Ls:a=$t.RG32Sint;break;case ls:a=$t.RG32Uint;break;default:console.error("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",n)}break;case nt:switch(n){case Ls:a=$t.RGBA32Sint;break;case ls:a=$t.RGBA32Uint;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",n)}break;default:console.error("WebGPURenderer: Unsupported texture format.",t)}return a}const H9=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,$9=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,tL={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2<f32>":"vec2","vec2<i32>":"ivec2","vec2<u32>":"uvec2","vec2<bool>":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3<f32>":"vec3","vec3<i32>":"ivec3","vec3<u32>":"uvec3","vec3<bool>":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4<f32>":"vec4","vec4<i32>":"ivec4","vec4<u32>":"uvec4","vec4<bool>":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2<f32>":"mat2",mat2x2f:"mat2","mat3x3<f32>":"mat3",mat3x3f:"mat3","mat4x4<f32>":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"},j9=i=>{i=i.trim();const e=i.match(H9);if(e!==null&&e.length===4){const t=e[2],n=[];let s=null;for(;(s=$9.exec(t))!==null;)n.push({name:s[1],type:s[2]});const o=[];for(let p=0;p<n.length;p++){const{name:m,type:y}=n[p];let M=y;M.startsWith("ptr")?M="pointer":(M.startsWith("texture")&&(M=y.split("<")[0]),M=tL[M]),o.push(new uT(M,m))}const a=i.substring(e[0].length),c=e[3]||"void",u=e[1]!==void 0?e[1]:"";return{type:tL[c]||c,inputs:o,name:u,inputsCode:t,blockCode:a,outputType:c}}else throw new Error("FunctionNode: Function is not a WGSL code.")};class X9 extends fT{constructor(e){const{type:t,inputs:n,name:s,inputsCode:o,blockCode:a,outputType:c}=j9(e);super(t,n,s),this.inputsCode=o,this.blockCode=a,this.outputType=c}getCode(e=this.name){const t=this.outputType!=="void"?"-> "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class q9 extends SI{parseFunction(e){return new X9(e)}}const y0=typeof self!="undefined"?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},Y9={[Il.READ_ONLY]:"read",[Il.WRITE_ONLY]:"write",[Il.READ_WRITE]:"read_write"},nL={[st]:"repeat",[$e]:"clamp",[ft]:"mirror"},Vb={vertex:y0?y0.VERTEX:1,fragment:y0?y0.FRAGMENT:2,compute:y0?y0.COMPUTE:4},iL={instance:!0,swizzleAssign:!1,storageBuffer:!0},Z9={"^^":"tsl_xor"},K9={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3<f32>",vec2:"vec2<f32>",ivec2:"vec2<i32>",uvec2:"vec2<u32>",bvec2:"vec2<bool>",vec3:"vec3<f32>",ivec3:"vec3<i32>",uvec3:"vec3<u32>",bvec3:"vec3<bool>",vec4:"vec4<f32>",ivec4:"vec4<i32>",uvec4:"vec4<u32>",bvec4:"vec4<bool>",mat2:"mat2x2<f32>",mat3:"mat3x3<f32>",mat4:"mat4x4<f32>"},rL={},Yv={tsl_xor:new Xl("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new Xl("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new Xl("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new Xl("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new Xl("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new Xl("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new Xl("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new Xl("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new Xl("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new Xl("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new Xl("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new Xl("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new Xl(`
|
|
|
fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
|
|
|
|
|
|
let res = vec2f( iRes );
|
|
|
|
|
|
let uvScaled = coord * res;
|
|
|
let uvWrapping = ( ( uvScaled % res ) + res ) % res;
|
|
|
|
|
|
// https://www.shadertoy.com/view/WtyXRy
|
|
|
|
|
|
let uv = uvWrapping - 0.5;
|
|
|
let iuv = floor( uv );
|
|
|
let f = fract( uv );
|
|
|
|
|
|
let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );
|
|
|
let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );
|
|
|
let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );
|
|
|
let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );
|
|
|
|
|
|
return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
|
|
|
|
|
|
}
|
|
|
`)},J9={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast<f32>"};let sL="";(typeof navigator!="undefined"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(sL+=`diagnostic( off, derivative_uniformity );
|
|
|
`);class Q9 extends wI{constructor(e,t){super(e,t,new q9),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}_generateTextureSample(e,t,n,s,o,a=this.shaderStage){return a==="fragment"?s?o?`textureSample( ${t}, ${t}_sampler, ${n}, ${s}, ${o} )`:`textureSample( ${t}, ${t}_sampler, ${n}, ${s} )`:o?`textureSample( ${t}, ${t}_sampler, ${n}, ${o} )`:`textureSample( ${t}, ${t}_sampler, ${n} )`:this.generateTextureSampleLevel(e,t,n,"0",s)}generateTextureSampleLevel(e,t,n,s,o,a){return this.isUnfilterable(e)===!1?a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${s}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,a,s):this.generateTextureLod(e,t,n,o,a,s)}generateWrapFunction(e){const t=`tsl_coord_${nL[e.wrapS]}S_${nL[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let n=rL[t];if(n===void 0){const s=[],o=e.isData3DTexture?"vec3f":"vec2f";let a=`fn ${t}( coord : ${o} ) -> ${o} {
|
|
|
|
|
|
return ${o}(
|
|
|
`;const c=(u,d)=>{u===st?(s.push(Yv.repeatWrapping_float),a+=` tsl_repeatWrapping_float( coord.${d} )`):u===$e?(s.push(Yv.clampWrapping_float),a+=` tsl_clampWrapping_float( coord.${d} )`):u===ft?(s.push(Yv.mirrorWrapping_float),a+=` tsl_mirrorWrapping_float( coord.${d} )`):(a+=` coord.${d}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${u}" for vertex shader.`))};c(e.wrapS,"x"),a+=`,
|
|
|
`,c(e.wrapT,"y"),e.isData3DTexture&&(a+=`,
|
|
|
`,c(e.wrapR,"z")),a+=`
|
|
|
);
|
|
|
|
|
|
}
|
|
|
`,rL[t]=n=new Xl(a,s)}return n.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,n){const s=this.getDataFromNode(e,this.shaderStage,this.globalCache);s.dimensionsSnippet===void 0&&(s.dimensionsSnippet={});let o=s.dimensionsSnippet[n];if(s.dimensionsSnippet[n]===void 0){let a,c;const{primarySamples:u}=this.renderer.backend.utils.getTextureSampleData(e),d=u>1;e.isData3DTexture?c="vec3<u32>":c="vec2<u32>",d||e.isStorageTexture?a=t:a=`${t}${n?`, u32( ${n} )`:""}`,o=new $_(new q_(`textureDimensions( ${a} )`,c)),s.dimensionsSnippet[n]=o,(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)&&(s.arrayLayerCount=new $_(new q_(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(s.cubeFaceCount=new $_(new q_("6u","u32")))}return o.build(this)}generateFilteredTexture(e,t,n,s,o="0u"){this._include("biquadraticTexture");const a=this.generateWrapFunction(e),c=this.generateTextureDimension(e,t,o);return s&&(n=`${n} + vec2<f32>(${s}) / ${c}`),`tsl_biquadraticTexture( ${t}, ${a}( ${n} ), ${c}, u32( ${o} ) )`}generateTextureLod(e,t,n,s,o,a="0u"){const c=this.generateWrapFunction(e),u=this.generateTextureDimension(e,t,a),d=e.isData3DTexture?"vec3":"vec2";o&&(n=`${n} + ${d}<f32>(${o}) / ${d}<f32>( ${u} )`);const p=`${d}<u32>( ${c}( ${n} ) * ${d}<f32>( ${u} ) )`;return this.generateTextureLoad(e,t,p,s,null,a)}generateTextureLoad(e,t,n,s,o,a="0u"){let c;return o&&(n=`${n} + ${o}`),s?c=`textureLoad( ${t}, ${n}, ${s}, u32( ${a} ) )`:(c=`textureLoad( ${t}, ${n}, u32( ${a} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(c+=".x")),c}generateTextureStore(e,t,n,s,o){let a;return s?a=`textureStore( ${t}, ${n}, ${s}, ${o} )`:a=`textureStore( ${t}, ${n}, ${o} )`,a}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.isDataTexture===!0&&e.type===ys||this.isSampleCompare(e)===!1&&e.minFilter===Ct&&e.magFilter===Ct||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,n,s,o,a=this.shaderStage){let c=null;return this.isUnfilterable(e)?c=this.generateTextureLod(e,t,n,s,o,"0",a):c=this._generateTextureSample(e,t,n,s,o,a),c}generateTextureGrad(e,t,n,s,o,a,c=this.shaderStage){if(c==="fragment")return a?`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${s[0]}, ${s[1]}, ${a} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${s[0]}, ${s[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${c} shader.`)}generateTextureCompare(e,t,n,s,o,a,c=this.shaderStage){if(c==="fragment")return e.isDepthTexture===!0&&e.isArrayTexture===!0?a?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${o}, ${s}, ${a} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${o}, ${s} )`:a?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${s}, ${a} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${s} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${c} shader.`)}generateTextureLevel(e,t,n,s,o,a){return this.isUnfilterable(e)===!1?a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${s}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,a,s):this.generateTextureLod(e,t,n,o,a,s)}generateTextureBias(e,t,n,s,o,a,c=this.shaderStage){if(c==="fragment")return a?`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${s}, ${a} )`:`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${s} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${c} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t==="vertex")return`varyings.${e.name}`}else if(e.isNodeUniform===!0){const n=e.name,s=e.type;return s==="texture"||s==="cubeTexture"||s==="storageTexture"||s==="texture3D"?n:s==="buffer"||s==="storageBuffer"||s==="indirectStorageBuffer"?this.isCustomStruct(e)?n:n+".value":e.groupNode.name+"."+n}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=Z9[e];return t!==void 0?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?e.isAtomic===!0?(console.warn("WebGPURenderer: Atomic operations are only supported in compute shaders."),Il.READ_WRITE):Il.READ_ONLY:e.access}getStorageAccess(e,t){return Y9[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,n,s=null){const o=super.getUniformFromNode(e,t,n,s),a=this.getDataFromNode(e,n,this.globalCache);if(a.uniformGPU===void 0){let c;const u=e.groupNode,d=u.name,p=this.getBindGroupArray(d,n);if(t==="texture"||t==="cubeTexture"||t==="storageTexture"||t==="texture3D"){let m=null;const y=this.getNodeAccess(e,n);if(t==="texture"||t==="storageTexture"?e.value.is3DTexture===!0?m=new vT(o.name,o.node,u,y):m=new Bb(o.name,o.node,u,y):t==="cubeTexture"?m=new UI(o.name,o.node,u,y):t==="texture3D"&&(m=new vT(o.name,o.node,u,y)),m.store=e.isStorageTextureNode===!0,m.setVisibility(Vb[n]),this.isUnfilterable(e.value)===!1&&m.store===!1){const M=new F9(`${o.name}_sampler`,o.node,u);M.setVisibility(Vb[n]),p.push(M,m),c=[M,m]}else p.push(m),c=[m]}else if(t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"){const m=t==="buffer"?OI:k9,y=new m(e,u);y.setVisibility(Vb[n]),p.push(y),c=y,o.name=s||"NodeBuffer_"+o.id}else{const m=this.uniformGroups[n]||(this.uniformGroups[n]={});let y=m[d];y===void 0&&(y=new FI(d,u),y.setVisibility(Vb[n]),m[d]=y,p.push(y)),c=this.getNodeUniform(o,t),y.addUniform(c)}a.uniformGPU=c}return o}getBuiltin(e,t,n,s=this.shaderStage){const o=this.builtins[s]||(this.builtins[s]=new Map);return o.has(e)===!1&&o.set(e,{name:e,property:t,type:n}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage==="vertex"?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,n=this.flowShaderNode(e),s=[];for(const a of t.inputs)s.push(a.name+" : "+this.getType(a.type));let o=`fn ${t.name}( ${s.join(", ")} ) -> ${this.getType(t.type)} {
|
|
|
${n.vars}
|
|
|
${n.code}
|
|
|
`;return n.result&&(o+=` return ${n.result};
|
|
|
`),o+=`
|
|
|
}
|
|
|
`,o}getInstanceIndex(){return this.shaderStage==="vertex"?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4<f32>")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],n=this.directives[e];if(n!==void 0)for(const s of n)t.push(`enable ${s};`);return t.join(`
|
|
|
`)}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array<f32, ${e} >`,"vertex")}getBuiltins(e){const t=[],n=this.builtins[e];if(n!==void 0)for(const{name:s,property:o,type:a}of n.values())t.push(`@builtin( ${s} ) ${o} : ${a}`);return t.join(`,
|
|
|
`)}getScopedArray(e,t,n,s){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:n,bufferCount:s}),e}getScopedArrays(e){if(e!=="compute")return;const t=[];for(const{name:n,scope:s,bufferType:o,bufferCount:a}of this.scopedArrays.values()){const c=this.getType(o);t.push(`var<${s}> ${n}: array< ${c}, ${a} >;`)}return t.join(`
|
|
|
`)}getAttributes(e){const t=[];if(e==="compute"&&(this.getBuiltin("global_invocation_id","globalId","vec3<u32>","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3<u32>","attribute"),this.getBuiltin("local_invocation_id","localId","vec3<u32>","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3<u32>","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),e==="vertex"||e==="compute"){const n=this.getBuiltins("attribute");n&&t.push(n);const s=this.getAttributesArray();for(let o=0,a=s.length;o<a;o++){const c=s[o],u=c.name,d=this.getType(c.type);t.push(`@location( ${o} ) ${u} : ${d}`)}}return t.join(`,
|
|
|
`)}getStructMembers(e){const t=[];for(const n of e.members){const s=e.output?"@location( "+n.index+" ) ":"";let o=this.getType(n.type);n.atomic&&(o="atomic< "+o+" >"),t.push(` ${s+n.name} : ${o}`)}return e.output&&t.push(` ${this.getBuiltins("output")}`),t.join(`,
|
|
|
`)}getStructs(e){let t="";const n=this.structs[e];if(n.length>0){const s=[];for(const o of n){let a=`struct ${o.name} {
|
|
|
`;a+=this.getStructMembers(o),a+=`
|
|
|
};`,s.push(a)}t=`
|
|
|
`+s.join(`
|
|
|
|
|
|
`)+`
|
|
|
`}return t}getVar(e,t,n=null){let s=`var ${t} : `;return n!==null?s+=this.generateArrayDeclaration(e,n):s+=this.getType(e),s}getVars(e){const t=[],n=this.vars[e];if(n!==void 0)for(const s of n)t.push(` ${this.getVar(s.type,s.name,s.count)};`);return`
|
|
|
${t.join(`
|
|
|
`)}
|
|
|
`}getVaryings(e){const t=[];if(e==="vertex"&&this.getBuiltin("position","Vertex","vec4<f32>","vertex"),e==="vertex"||e==="fragment"){const o=this.varyings,a=this.vars[e];for(let c=0;c<o.length;c++){const u=o[c];if(u.needsInterpolation){let d=`@location( ${c} )`;if(u.interpolationType){const p=u.interpolationSampling!==null?`, ${u.interpolationSampling} )`:" )";d+=` @interpolate( ${u.interpolationType}${p}`}else/^(int|uint|ivec|uvec)/.test(u.type)&&(d+=` @interpolate( ${this.renderer.backend.compatibilityMode?"flat, either":"flat"} )`);t.push(`${d} ${u.name} : ${this.getType(u.type)}`)}else e==="vertex"&&a.includes(u)===!1&&a.push(u)}}const n=this.getBuiltins(e);n&&t.push(n);const s=t.join(`,
|
|
|
`);return e==="vertex"?this._getWGSLStruct("VaryingsStruct"," "+s):s}isCustomStruct(e){const t=e.value,n=e.node,s=(t.isBufferAttribute||t.isInstancedBufferAttribute)&&n.structTypeNode!==null,o=n.value&&n.value.array&&typeof n.value.itemSize=="number"&&n.value.array.length>n.value.itemSize;return s&&!o}getUniforms(e){const t=this.uniforms[e],n=[],s=[],o=[],a={};for(const u of t){const d=u.groupNode.name,p=this.bindingsIndexes[d];if(u.type==="texture"||u.type==="cubeTexture"||u.type==="storageTexture"||u.type==="texture3D"){const m=u.node.value;this.isUnfilterable(m)===!1&&u.node.isStorageTextureNode!==!0&&(this.isSampleCompare(m)?n.push(`@binding( ${p.binding++} ) @group( ${p.group} ) var ${u.name}_sampler : sampler_comparison;`):n.push(`@binding( ${p.binding++} ) @group( ${p.group} ) var ${u.name}_sampler : sampler;`));let y,M="";const{primarySamples:T}=this.renderer.backend.utils.getTextureSampleData(m);if(T>1&&(M="_multisampled"),m.isCubeTexture===!0)y="texture_cube<f32>";else if(m.isDepthTexture===!0)this.renderer.backend.compatibilityMode&&m.compareFunction===null?y=`texture${M}_2d<f32>`:y=`texture_depth${M}_2d${m.isArrayTexture===!0?"_array":""}`;else if(u.node.isStorageTextureNode===!0){const G=ET(m),z=this.getStorageAccess(u.node,e),I=u.node.value.is3DTexture,J=u.node.value.isArrayTexture;y=`texture_storage_${I?"3d":`2d${J?"_array":""}`}<${G}, ${z}>`}else if(m.isArrayTexture===!0||m.isDataArrayTexture===!0||m.isCompressedArrayTexture===!0)y="texture_2d_array<f32>";else if(m.is3DTexture===!0||m.isData3DTexture===!0)y="texture_3d<f32>";else{const G=this.getComponentTypeFromTexture(m).charAt(0);y=`texture${M}_2d<${G}32>`}n.push(`@binding( ${p.binding++} ) @group( ${p.group} ) var ${u.name} : ${y};`)}else if(u.type==="buffer"||u.type==="storageBuffer"||u.type==="indirectStorageBuffer"){const m=u.node,y=this.getType(m.getNodeType(this)),M=m.bufferCount,T=M>0&&u.type==="buffer"?", "+M:"",G=m.isStorageBufferNode?`storage, ${this.getStorageAccess(m,e)}`:"uniform";if(this.isCustomStruct(u))s.push(`@binding( ${p.binding++} ) @group( ${p.group} ) var<${G}> ${u.name} : ${y};`);else{const I=` value : array< ${m.isAtomic?`atomic<${y}>`:`${y}`}${T} >`;s.push(this._getWGSLStructBinding(u.name,I,G,p.binding++,p.group))}}else{const m=this.getType(this.getVectorType(u.type)),y=u.groupNode.name;(a[y]||(a[y]={index:p.binding++,id:p.group,snippets:[]})).snippets.push(` ${u.name} : ${m}`)}}for(const u in a){const d=a[u];o.push(this._getWGSLStructBinding(u,d.snippets.join(`,
|
|
|
`),"uniform",d.index,d.id))}let c=n.join(`
|
|
|
`);return c+=s.join(`
|
|
|
`),c+=o.join(`
|
|
|
`),c}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const n=e[t];n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.structs=this.getStructs(t),n.vars=this.getVars(t),n.codes=this.getCodes(t),n.directives=this.getDirectives(t),n.scopedArrays=this.getScopedArrays(t);let s=`// code
|
|
|
|
|
|
`;s+=this.flowCode[t];const o=this.flowNodes[t],a=o[o.length-1],c=a.outputNode,u=c!==void 0&&c.isOutputStructNode===!0;for(const d of o){const p=this.getFlowData(d),m=d.name;if(m&&(s.length>0&&(s+=`
|
|
|
`),s+=` // flow -> ${m}
|
|
|
`),s+=`${p.code}
|
|
|
`,d===a&&t!=="compute"){if(s+=`// result
|
|
|
|
|
|
`,t==="vertex")s+=`varyings.Vertex = ${p.result};`;else if(t==="fragment")if(u)n.returnType=c.getNodeType(this),n.structs+="var<private> output : "+n.returnType+";",s+=`return ${p.result};`;else{let y=" @location(0) color: vec4<f32>";const M=this.getBuiltins("output");M&&(y+=`,
|
|
|
`+M),n.returnType="OutputStruct",n.structs+=this._getWGSLStruct("OutputStruct",y),n.structs+=`
|
|
|
var<private> output : OutputStruct;`,s+=`output.color = ${p.result};
|
|
|
|
|
|
return output;`}}}n.flow=s}if(this.shaderStage=null,this.material!==null)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{const t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let n;return t!==null&&(n=this._getWGSLMethod(e+"_"+t)),n===void 0&&(n=this._getWGSLMethod(e)),n||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getTernary(e,t,n){return`select( ${n}, ${t}, ${e} )`}getType(e){return K9[e]||e}isAvailable(e){let t=iL[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),iL[e]=t),t}_getWGSLMethod(e){return Yv[e]!==void 0&&this._include(e),J9[e]}_include(e){const t=Yv[e];return t.build(this),this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}
|
|
|
// directives
|
|
|
${e.directives}
|
|
|
|
|
|
// structs
|
|
|
${e.structs}
|
|
|
|
|
|
// uniforms
|
|
|
${e.uniforms}
|
|
|
|
|
|
// varyings
|
|
|
${e.varyings}
|
|
|
var<private> varyings : VaryingsStruct;
|
|
|
|
|
|
// codes
|
|
|
${e.codes}
|
|
|
|
|
|
@vertex
|
|
|
fn main( ${e.attributes} ) -> VaryingsStruct {
|
|
|
|
|
|
// vars
|
|
|
${e.vars}
|
|
|
|
|
|
// flow
|
|
|
${e.flow}
|
|
|
|
|
|
return varyings;
|
|
|
|
|
|
}
|
|
|
`}_getWGSLFragmentCode(e){return`${this.getSignature()}
|
|
|
// global
|
|
|
${sL}
|
|
|
|
|
|
// structs
|
|
|
${e.structs}
|
|
|
|
|
|
// uniforms
|
|
|
${e.uniforms}
|
|
|
|
|
|
// codes
|
|
|
${e.codes}
|
|
|
|
|
|
@fragment
|
|
|
fn main( ${e.varyings} ) -> ${e.returnType} {
|
|
|
|
|
|
// vars
|
|
|
${e.vars}
|
|
|
|
|
|
// flow
|
|
|
${e.flow}
|
|
|
|
|
|
}
|
|
|
`}_getWGSLComputeCode(e,t){const[n,s,o]=t;return`${this.getSignature()}
|
|
|
// directives
|
|
|
${e.directives}
|
|
|
|
|
|
// system
|
|
|
var<private> instanceIndex : u32;
|
|
|
|
|
|
// locals
|
|
|
${e.scopedArrays}
|
|
|
|
|
|
// structs
|
|
|
${e.structs}
|
|
|
|
|
|
// uniforms
|
|
|
${e.uniforms}
|
|
|
|
|
|
// codes
|
|
|
${e.codes}
|
|
|
|
|
|
@compute @workgroup_size( ${n}, ${s}, ${o} )
|
|
|
fn main( ${e.attributes} ) {
|
|
|
|
|
|
// system
|
|
|
instanceIndex = globalId.x
|
|
|
+ globalId.y * ( ${n} * numWorkgroups.x )
|
|
|
+ globalId.z * ( ${n} * numWorkgroups.x ) * ( ${s} * numWorkgroups.y );
|
|
|
|
|
|
// vars
|
|
|
${e.vars}
|
|
|
|
|
|
// flow
|
|
|
${e.flow}
|
|
|
|
|
|
}
|
|
|
`}_getWGSLStruct(e,t){return`
|
|
|
struct ${e} {
|
|
|
${t}
|
|
|
};`}_getWGSLStructBinding(e,t,n,s=0,o=0){const a=e+"Struct";return`${this._getWGSLStruct(a,t)}
|
|
|
@binding( ${s} ) @group( ${o} )
|
|
|
var<${n}> ${e} : ${a};`}}class e7{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=$t.Depth24PlusStencil8:e.depth&&(t=$t.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const o=this.backend.renderer,a=o.getRenderTarget();t=a?a.samples:o.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:n?1:t,isMSAA:n}}getCurrentColorFormat(e){let t;return e.textures!==null?t=this.getTextureFormatGPU(e.textures[0]):t=this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return e.textures!==null?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return m0.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return m0.LineList;if(e.isLine)return m0.LineStrip;if(e.isMesh)return m0.TriangleList}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return e.textures!==null?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){const e=this.backend.parameters.outputType;if(e===void 0)return navigator.gpu.getPreferredCanvasFormat();if(e===Oi)return $t.BGRA8Unorm;if(e===Gs)return $t.RGBA16Float;throw new Error("Unsupported outputType")}}const oL=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]);typeof Float16Array!="undefined"&&oL.set(Float16Array,["float16"]);const t7=new Map([[Xm,["float16"]]]),n7=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class i7{constructor(e){this.backend=e}createAttribute(e,t){const n=this._getBufferAttribute(e),s=this.backend,o=s.get(n);let a=o.buffer;if(a===void 0){const c=s.device;let u=n.array;if(e.normalized===!1){if(u.constructor===Int16Array||u.constructor===Int8Array)u=new Int32Array(u);else if((u.constructor===Uint16Array||u.constructor===Uint8Array)&&(u=new Uint32Array(u),t&GPUBufferUsage.INDEX))for(let m=0;m<u.length;m++)u[m]===65535&&(u[m]=4294967295)}if(n.array=u,(n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute)&&n.itemSize===3){u=new u.constructor(n.count*4);for(let m=0;m<n.count;m++)u.set(n.array.subarray(m*3,m*3+3),m*4);n.itemSize=4,n.array=u,o._force3to4BytesAlignment=!0}const d=u.byteLength,p=d+(4-d%4)%4;a=c.createBuffer({label:n.name,size:p,usage:t,mappedAtCreation:!0}),new u.constructor(a.getMappedRange()).set(u),a.unmap(),o.buffer=a}}updateAttribute(e){const t=this._getBufferAttribute(e),n=this.backend,s=n.device,o=n.get(t),a=n.get(t).buffer;let c=t.array;if(o._force3to4BytesAlignment===!0){c=new c.constructor(t.count*4);for(let p=0;p<t.count;p++)c.set(t.array.subarray(p*3,p*3+3),p*4);t.array=c}const u=this._isTypedArray(c),d=t.updateRanges;if(d.length===0)s.queue.writeBuffer(a,0,c,0);else{const p=u?1:c.BYTES_PER_ELEMENT;for(let m=0,y=d.length;m<y;m++){const M=d[m];let T,G;if(o._force3to4BytesAlignment===!0){const I=Math.floor(M.start/3),J=Math.ceil(M.count/3);T=I*4*p,G=J*4*p}else T=M.start*p,G=M.count*p;const z=T*(u?c.BYTES_PER_ELEMENT:1);s.queue.writeBuffer(a,z,c,T,G)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){const t=e.getAttributes(),n=new Map;for(let s=0;s<t.length;s++){const o=t[s],a=o.array.BYTES_PER_ELEMENT,c=this._getBufferAttribute(o);let u=n.get(c);if(u===void 0){let m,y;o.isInterleavedBufferAttribute===!0?(m=o.data.stride*a,y=o.data.isInstancedInterleavedBuffer?zb.Instance:zb.Vertex):(m=o.itemSize*a,y=o.isInstancedBufferAttribute?zb.Instance:zb.Vertex),o.normalized===!1&&(o.array.constructor===Int16Array||o.array.constructor===Uint16Array)&&(m=4),u={arrayStride:m,attributes:[],stepMode:y},n.set(c,u)}const d=this._getVertexFormat(o),p=o.isInterleavedBufferAttribute===!0?o.offset*a:0;u.attributes.push({shaderLocation:s,offset:p,format:d})}return Array.from(n.values())}destroyAttribute(e){const t=this.backend;t.get(this._getBufferAttribute(e)).buffer.destroy(),t.delete(e)}getArrayBufferAsync(e){return hr(this,null,function*(){const t=this.backend,n=t.device,o=t.get(this._getBufferAttribute(e)).buffer,a=o.size,c=n.createBuffer({label:`${e.name}_readback`,size:a,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),u=n.createCommandEncoder({label:`readback_encoder_${e.name}`});u.copyBufferToBuffer(o,0,c,0,a);const d=u.finish();n.queue.submit([d]),yield c.mapAsync(GPUMapMode.READ);const p=c.getMappedRange(),m=new e.array.constructor(p.slice(0));return c.unmap(),m.buffer})}_getVertexFormat(e){const{itemSize:t,normalized:n}=e,s=e.array.constructor,o=e.constructor;let a;if(t===1)a=n7.get(s);else{const u=(t7.get(o)||oL.get(s))[n?1:0];if(u){const d=s.BYTES_PER_ELEMENT*t,m=Math.floor((d+3)/4)*4/s.BYTES_PER_ELEMENT;if(m%1)throw new Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");a=`${u}x${m}`}}return a||console.error("THREE.WebGPUAttributeUtils: Vertex format not supported yet."),a}_isTypedArray(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}class r7{constructor(e){this.backend=e,this.bindGroupLayoutCache=new WeakMap}createBindingsLayout(e){const t=this.backend,n=t.device,s=[];let o=0;for(const a of e.bindings){const c={binding:o++,visibility:a.visibility};if(a.isUniformBuffer||a.isStorageBuffer){const u={};a.isStorageBuffer&&(a.visibility&4&&(a.access===Il.READ_WRITE||a.access===Il.WRITE_ONLY)?u.type=MT.Storage:u.type=MT.ReadOnlyStorage),c.buffer=u}else if(a.isSampledTexture&&a.store){const u={};u.format=this.backend.get(a.texture).texture.format;const d=a.access;d===Il.READ_WRITE?u.access=ST.ReadWrite:d===Il.WRITE_ONLY?u.access=ST.WriteOnly:u.access=ST.ReadOnly,a.texture.isArrayTexture?u.viewDimension=rl.TwoDArray:a.texture.is3DTexture&&(u.viewDimension=rl.ThreeD),c.storageTexture=u}else if(a.isSampledTexture){const u={},{primarySamples:d}=t.utils.getTextureSampleData(a.texture);if(d>1&&(u.multisampled=!0,a.texture.isDepthTexture||(u.sampleType=Rm.UnfilterableFloat)),a.texture.isDepthTexture)t.compatibilityMode&&a.texture.compareFunction===null?u.sampleType=Rm.UnfilterableFloat:u.sampleType=Rm.Depth;else if(a.texture.isDataTexture||a.texture.isDataArrayTexture||a.texture.isData3DTexture){const p=a.texture.type;p===Ls?u.sampleType=Rm.SInt:p===ls?u.sampleType=Rm.UInt:p===ys&&(this.backend.hasFeature("float32-filterable")?u.sampleType=Rm.Float:u.sampleType=Rm.UnfilterableFloat)}a.isSampledCubeTexture?u.viewDimension=rl.Cube:a.texture.isArrayTexture||a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?u.viewDimension=rl.TwoDArray:a.isSampledTexture3D&&(u.viewDimension=rl.ThreeD),c.texture=u}else if(a.isSampler){const u={};a.texture.isDepthTexture&&(a.texture.compareFunction!==null?u.type=QI.Comparison:t.compatibilityMode&&(u.type=QI.NonFiltering)),c.sampler=u}else console.error(`WebGPUBindingUtils: Unsupported binding "${a}".`);s.push(c)}return n.createBindGroupLayout({entries:s})}createBindings(e,t,n,s=0){const{backend:o,bindGroupLayoutCache:a}=this,c=o.get(e);let u=a.get(e.bindingsReference);u===void 0&&(u=this.createBindingsLayout(e),a.set(e.bindingsReference,u));let d;n>0&&(c.groups===void 0&&(c.groups=[],c.versions=[]),c.versions[n]===s&&(d=c.groups[n])),d===void 0&&(d=this.createBindGroup(e,u),n>0&&(c.groups[n]=d,c.versions[n]=s)),c.group=d,c.layout=u}updateBinding(e){const t=this.backend,n=t.device,s=e.buffer,o=t.get(e).buffer;n.queue.writeBuffer(o,0,s,0)}createBindGroupIndex(e,t){const s=this.backend.device,o=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,a=e[0],c=s.createBuffer({label:"bindingCameraIndex_"+a,size:16,usage:o});s.queue.writeBuffer(c,0,e,0);const u=[{binding:0,resource:{buffer:c}}];return s.createBindGroup({label:"bindGroupCameraIndex_"+a,layout:t,entries:u})}createBindGroup(e,t){const n=this.backend,s=n.device;let o=0;const a=[];for(const c of e.bindings){if(c.isUniformBuffer){const u=n.get(c);if(u.buffer===void 0){const d=c.byteLength,p=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,m=s.createBuffer({label:"bindingBuffer_"+c.name,size:d,usage:p});u.buffer=m}a.push({binding:o,resource:{buffer:u.buffer}})}else if(c.isStorageBuffer){const u=n.get(c);if(u.buffer===void 0){const d=c.attribute;u.buffer=n.get(d).buffer}a.push({binding:o,resource:{buffer:u.buffer}})}else if(c.isSampledTexture){const u=n.get(c.texture);let d;if(u.externalTexture!==void 0)d=s.importExternalTexture({source:u.externalTexture});else{const p=c.store?1:u.texture.mipLevelCount;let m=`view-${u.texture.width}-${u.texture.height}`;if(u.texture.depthOrArrayLayers>1&&(m+=`-${u.texture.depthOrArrayLayers}`),m+=`-${p}`,d=u[m],d===void 0){const y=O9.All;let M;c.isSampledCubeTexture?M=rl.Cube:c.isSampledTexture3D?M=rl.ThreeD:c.texture.isArrayTexture||c.texture.isDataArrayTexture||c.texture.isCompressedArrayTexture?M=rl.TwoDArray:M=rl.TwoD,d=u[m]=u.texture.createView({aspect:y,dimension:M,mipLevelCount:p})}}a.push({binding:o,resource:d})}else if(c.isSampler){const u=n.get(c.texture);a.push({binding:o,resource:u.sampler})}o++}return s.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:a})}}class s7{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:n,material:s,geometry:o,pipeline:a}=e,{vertexProgram:c,fragmentProgram:u}=a,d=this.backend,p=d.device,m=d.utils,y=d.get(a),M=[];for(const tn of e.getBindings()){const cn=d.get(tn);M.push(cn.layout)}const T=d.attributeUtils.createShaderVertexBuffers(e);let G;s.blending!==pe&&(s.blending!==fe||s.transparent!==!1)&&(G=this._getBlending(s));let z={};s.stencilWrite===!0&&(z={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});const I=this._getColorWriteMask(s),J=[];if(e.context.textures!==null){const tn=e.context.textures;for(let cn=0;cn<tn.length;cn++){const vn=m.getTextureFormatGPU(tn[cn]);J.push({format:vn,blend:G,writeMask:I})}}else{const tn=m.getCurrentColorFormat(e.context);J.push({format:tn,blend:G,writeMask:I})}const K=d.get(c).module,re=d.get(u).module,ve=this._getPrimitiveState(n,o,s),me=this._getDepthCompare(s),Le=m.getCurrentDepthStencilFormat(e.context),Ve=this._getSampleCount(e.context),Ee={label:`renderPipeline_${s.name||s.type}_${s.id}`,vertex:Object.assign({},K,{buffers:T}),fragment:Object.assign({},re,{targets:J}),primitive:ve,multisample:{count:Ve,alphaToCoverageEnabled:s.alphaToCoverage&&Ve>1},layout:p.createPipelineLayout({bindGroupLayouts:M})},Oe={},dt=e.context.depth,Ut=e.context.stencil;if((dt===!0||Ut===!0)&&(dt===!0&&(Oe.format=Le,Oe.depthWriteEnabled=s.depthWrite,Oe.depthCompare=me),Ut===!0&&(Oe.stencilFront=z,Oe.stencilBack={},Oe.stencilReadMask=s.stencilFuncMask,Oe.stencilWriteMask=s.stencilWriteMask),s.polygonOffset===!0&&(Oe.depthBias=s.polygonOffsetUnits,Oe.depthBiasSlopeScale=s.polygonOffsetFactor,Oe.depthBiasClamp=0),Ee.depthStencil=Oe),t===null)y.pipeline=p.createRenderPipeline(Ee);else{const tn=new Promise(cn=>{p.createRenderPipelineAsync(Ee).then(vn=>{y.pipeline=vn,cn()})});t.push(tn)}}createBundleEncoder(e,t="renderBundleEncoder"){const n=this.backend,{utils:s,device:o}=n,a=s.getCurrentDepthStencilFormat(e),c=s.getCurrentColorFormat(e),u=this._getSampleCount(e),d={label:t,colorFormats:[c],depthStencilFormat:a,sampleCount:u};return o.createRenderBundleEncoder(d)}createComputePipeline(e,t){const n=this.backend,s=n.device,o=n.get(e.computeProgram).module,a=n.get(e),c=[];for(const u of t){const d=n.get(u);c.push(d.layout)}a.pipeline=s.createComputePipeline({compute:o,layout:s.createPipelineLayout({bindGroupLayouts:c})})}_getBlending(e){let t,n;const s=e.blending,o=e.blendSrc,a=e.blendDst,c=e.blendEquation;if(s===Ne){const u=e.blendSrcAlpha!==null?e.blendSrcAlpha:o,d=e.blendDstAlpha!==null?e.blendDstAlpha:a,p=e.blendEquationAlpha!==null?e.blendEquationAlpha:c;t={srcFactor:this._getBlendFactor(o),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(c)},n={srcFactor:this._getBlendFactor(u),dstFactor:this._getBlendFactor(d),operation:this._getBlendOperation(p)}}else{const u=e.premultipliedAlpha,d=(p,m,y,M)=>{t={srcFactor:p,dstFactor:m,operation:Cm.Add},n={srcFactor:y,dstFactor:M,operation:Cm.Add}};if(u)switch(s){case fe:d(zs.One,zs.OneMinusSrcAlpha,zs.One,zs.OneMinusSrcAlpha);break;case ae:d(zs.One,zs.One,zs.One,zs.One);break;case ye:d(zs.Zero,zs.OneMinusSrc,zs.Zero,zs.One);break;case ue:d(zs.Dst,zs.OneMinusSrcAlpha,zs.Zero,zs.One);break}else switch(s){case fe:d(zs.SrcAlpha,zs.OneMinusSrcAlpha,zs.One,zs.OneMinusSrcAlpha);break;case ae:d(zs.SrcAlpha,zs.One,zs.One,zs.One);break;case ye:console.error("THREE.WebGPURenderer: SubtractiveBlending requires material.premultipliedAlpha = true");break;case ue:console.error("THREE.WebGPURenderer: MultiplyBlending requires material.premultipliedAlpha = true");break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};console.error("THREE.WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(e){let t;switch(e){case He:t=zs.Zero;break;case vt:t=zs.One;break;case It:t=zs.Src;break;case zt:t=zs.OneMinusSrc;break;case Yt:t=zs.SrcAlpha;break;case At:t=zs.OneMinusSrcAlpha;break;case le:t=zs.Dst;break;case Fe:t=zs.OneMinusDst;break;case lt:t=zs.DstAlpha;break;case Ot:t=zs.OneMinusDstAlpha;break;case gt:t=zs.SrcAlphaSaturated;break;case rG:t=zs.Constant;break;case sG:t=zs.OneMinusConstant;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const n=e.stencilFunc;switch(n){case c1:t=Ol.Never;break;case Jh:t=Ol.Always;break;case u1:t=Ol.Less;break;case cx:t=Ol.LessEqual;break;case h1:t=Ol.Equal;break;case ux:t=Ol.GreaterEqual;break;case d1:t=Ol.Greater;break;case f1:t=Ol.NotEqual;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",n)}return t}_getStencilOperation(e){let t;switch(e){case Kl:t=ep.Keep;break;case a1:t=ep.Zero;break;case Um:t=ep.Replace;break;case l1:t=ep.Invert;break;case Qd:t=ep.IncrementClamp;break;case ax:t=ep.DecrementClamp;break;case lx:t=ep.IncrementWrap;break;case T0:t=ep.DecrementWrap;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Te:t=Cm.Add;break;case _e:t=Cm.Subtract;break;case Xe:t=Cm.ReverseSubtract;break;case Se:t=Cm.Min;break;case Ge:t=Cm.Max;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,n){const s={},o=this.backend.utils;s.topology=o.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(s.stripIndexFormat=t.index.array instanceof Uint16Array?g0.Uint16:g0.Uint32);let a=n.side===Y;return e.isMesh&&e.matrixWorld.determinant()<0&&(a=!a),s.frontFace=a===!0?ZI.CW:ZI.CCW,s.cullMode=n.side===ie?KI.None:KI.Back,s}_getColorWriteMask(e){return e.colorWrite===!0?JI.All:JI.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=Ol.Always;else{const n=e.depthFunc;switch(n){case Ue:t=Ol.Never;break;case Ye:t=Ol.Always;break;case be:t=Ol.Less;break;case ge:t=Ol.LessEqual;break;case Ke:t=Ol.Equal;break;case wt:t=Ol.GreaterEqual;break;case Be:t=Ol.Greater;break;case ut:t=Ol.NotEqual;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",n)}}return t}}class o7 extends qI{constructor(e,t,n=2048){super(n),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${t}`});const s=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return ll(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}resolveQueriesAsync(){return hr(this,null,function*(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return yield this.pendingResolve}finally{this.pendingResolve=null}})}_resolveQueries(){return hr(this,null,function*(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!=="unmapped")return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,n=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();const s=this.device.createCommandEncoder();s.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,n);const o=s.finish();if(this.device.queue.submit([o]),this.resultBuffer.mapState!=="unmapped")return this.lastValue;if(yield this.resultBuffer.mapAsync(GPUMapMode.READ,0,n),this.isDisposed)return this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue;const a=new BigUint64Array(this.resultBuffer.getMappedRange(0,n));let c=0;for(const[,u]of e){const d=a[u],p=a[u+1],m=Number(p-d)/1e6;c+=m}return this.resultBuffer.unmap(),this.lastValue=c,c}catch(e){return console.error("Error resolving queries:",e),this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue}})}dispose(){return hr(this,null,function*(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{yield this.pendingResolve}catch(e){console.error("Error waiting for pending resolve:",e)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(e){console.error("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}})}}class AT extends HI{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.compatibilityMode=e.compatibilityMode===void 0?!1:e.compatibilityMode,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new e7(this),this.attributeUtils=new i7(this),this.bindingUtils=new r7(this),this.pipelineUtils=new s7(this),this.textureUtils=new W9(this),this.occludedResolveCache=new Map}init(e){return hr(this,null,function*(){yield I3(AT.prototype,this,"init").call(this,e);const t=this.parameters;let n;if(t.device===void 0){const c={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?"compatibility":void 0},u=typeof navigator!="undefined"?yield navigator.gpu.requestAdapter(c):null;if(u===null)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const d=Object.values(TT),p=[];for(const y of d)u.features.has(y)&&p.push(y);const m={requiredFeatures:p,requiredLimits:t.requiredLimits};n=yield u.requestDevice(m)}else n=t.device;n.lost.then(c=>{const u={api:"WebGPU",message:c.message||"Unknown reason",reason:c.reason||null,originalEvent:c};e.onDeviceLost(u)});const s=t.context!==void 0?t.context:e.domElement.getContext("webgpu");this.device=n,this.context=s;const o=t.alpha?"premultiplied":"opaque",a=Ki.getToneMappingMode(this.renderer.outputColorSpace);this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:o,toneMapping:{mode:a}}),this.trackTimestamp=this.trackTimestamp&&this.hasFeature(TT.TimestampQuery),this.updateSize()})}get coordinateSystem(){return qa}getArrayBufferAsync(e){return hr(this,null,function*(){return yield this.attributeUtils.getArrayBufferAsync(e)})}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(e===null){const n=this.renderer;e={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(n.depth,n.stencil).createView()});const s=e.colorAttachments[0];this.renderer.samples>0?s.view=this.colorBuffer.createView():s.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){const n=e.renderTarget,s=this.get(n);let o=s.descriptors;(o===void 0||s.width!==n.width||s.height!==n.height||s.samples!==n.samples)&&(o={},s.descriptors=o);const a=e.getCacheKey();let c=o[a];if(c===void 0){const d=e.textures,p=[];let m;const y=this._isRenderCameraDepthArray(e);for(let M=0;M<d.length;M++){const T=this.get(d[M]),G={label:`colorAttachment_${M}`,baseMipLevel:e.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1,dimension:rl.TwoD};if(n.isRenderTarget3D)m=e.activeCubeFace,G.baseArrayLayer=0,G.dimension=rl.ThreeD,G.depthOrArrayLayers=d[M].image.depth;else if(n.isRenderTarget&&d[M].image.depth>1)if(y===!0){const z=e.camera.cameras;for(let I=0;I<z.length;I++){const J=cc(Ys({},G),{baseArrayLayer:I,arrayLayerCount:1,dimension:rl.TwoD}),K=T.texture.createView(J);p.push({view:K,resolveTarget:void 0,depthSlice:void 0})}}else G.dimension=rl.TwoDArray,G.depthOrArrayLayers=d[M].image.depth;if(y!==!0){const z=T.texture.createView(G);let I,J;T.msaaTexture!==void 0?(I=T.msaaTexture.createView(),J=z):(I=z,J=void 0),p.push({view:I,resolveTarget:J,depthSlice:m})}}if(c={textureViews:p},e.depth){const M=this.get(e.depthTexture),T={};e.depthTexture.isArrayTexture&&(T.dimension=rl.TwoD,T.arrayLayerCount=1,T.baseArrayLayer=e.activeCubeFace),c.depthStencilView=M.texture.createView(T)}o[a]=c,s.width=n.width,s.height=n.height,s.samples=n.samples,s.activeMipmapLevel=e.activeMipmapLevel,s.activeCubeFace=e.activeCubeFace}const u={colorAttachments:[]};for(let d=0;d<c.textureViews.length;d++){const p=c.textureViews[d];let m={r:0,g:0,b:0,a:1};d===0&&t.clearValue&&(m=t.clearValue),u.colorAttachments.push({view:p.view,depthSlice:p.depthSlice,resolveTarget:p.resolveTarget,loadOp:t.loadOp||go.Load,storeOp:t.storeOp||ac.Store,clearValue:m})}return c.depthStencilView&&(u.depthStencilAttachment={view:c.depthStencilView}),u}beginRender(e){const t=this.get(e);t.frameCalls=this.renderer.info.render.frameCalls;const n=this.device,s=e.occlusionQueryCount;let o;s>0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,o=n.createQuerySet({type:"occlusion",count:s,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=o,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(s),t.lastOcclusionObject=null);let a;e.textures===null?a=this._getDefaultRenderPassDescriptor():a=this._getRenderPassDescriptor(e,{loadOp:go.Load}),this.initTimestampQuery(fh.RENDER,this.getTimestampUID(e),a),a.occlusionQuerySet=o;const c=a.depthStencilAttachment;if(e.textures!==null){const d=a.colorAttachments;for(let p=0;p<d.length;p++){const m=d[p];e.clearColor?(m.clearValue=p===0?e.clearColorValue:{r:0,g:0,b:0,a:1},m.loadOp=go.Clear):m.loadOp=go.Load,m.storeOp=ac.Store}}else{const d=a.colorAttachments[0];e.clearColor?(d.clearValue=e.clearColorValue,d.loadOp=go.Clear):d.loadOp=go.Load,d.storeOp=ac.Store}e.depth&&(e.clearDepth?(c.depthClearValue=e.clearDepthValue,c.depthLoadOp=go.Clear):c.depthLoadOp=go.Load,c.depthStoreOp=ac.Store),e.stencil&&(e.clearStencil?(c.stencilClearValue=e.clearStencilValue,c.stencilLoadOp=go.Clear):c.stencilLoadOp=go.Load,c.stencilStoreOp=ac.Store);const u=n.createCommandEncoder({label:"renderContext_"+e.id});if(this._isRenderCameraDepthArray(e)===!0){const d=e.camera.cameras;!t.layerDescriptors||t.layerDescriptors.length!==d.length?this._createDepthLayerDescriptors(e,t,a,d):this._updateDepthLayerDescriptors(e,t,d),t.bundleEncoders=[],t.bundleSets=[];for(let p=0;p<d.length;p++){const m=this.pipelineUtils.createBundleEncoder(e,"renderBundleArrayCamera_"+p),y={attributes:{},bindingGroups:[],pipeline:null,index:null};t.bundleEncoders.push(m),t.bundleSets.push(y)}t.currentPass=null}else{const d=u.beginRenderPass(a);if(t.currentPass=d,e.viewport&&this.updateViewport(e),e.scissor){const{x:p,y:m,width:y,height:M}=e.scissorValue;d.setScissorRect(p,m,y,M)}}t.descriptor=a,t.encoder=u,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.renderBundles=[]}_createDepthLayerDescriptors(e,t,n,s){const o=n.depthStencilAttachment;t.layerDescriptors=[];const a=this.get(e.depthTexture);a.viewCache||(a.viewCache=[]);for(let c=0;c<s.length;c++){const u=cc(Ys({},n),{colorAttachments:[cc(Ys({},n.colorAttachments[0]),{view:n.colorAttachments[c].view})]});if(n.depthStencilAttachment){const d=c;a.viewCache[d]||(a.viewCache[d]=a.texture.createView({dimension:rl.TwoD,baseArrayLayer:c,arrayLayerCount:1})),u.depthStencilAttachment={view:a.viewCache[d],depthLoadOp:o.depthLoadOp||go.Clear,depthStoreOp:o.depthStoreOp||ac.Store,depthClearValue:o.depthClearValue||1},e.stencil&&(u.depthStencilAttachment.stencilLoadOp=o.stencilLoadOp,u.depthStencilAttachment.stencilStoreOp=o.stencilStoreOp,u.depthStencilAttachment.stencilClearValue=o.stencilClearValue)}else u.depthStencilAttachment=Ys({},o);t.layerDescriptors.push(u)}}_updateDepthLayerDescriptors(e,t,n){for(let s=0;s<n.length;s++){const o=t.layerDescriptors[s];if(o.depthStencilAttachment){const a=o.depthStencilAttachment;e.depth&&(e.clearDepth?(a.depthClearValue=e.clearDepthValue,a.depthLoadOp=go.Clear):a.depthLoadOp=go.Load),e.stencil&&(e.clearStencil?(a.stencilClearValue=e.clearStencilValue,a.stencilLoadOp=go.Clear):a.stencilLoadOp=go.Load)}}}finishRender(e){const t=this.get(e),n=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const s=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){const o=[];for(let a=0;a<t.bundleEncoders.length;a++){const c=t.bundleEncoders[a];o.push(c.finish())}for(let a=0;a<t.layerDescriptors.length;a++)if(a<o.length){const c=t.layerDescriptors[a],u=s.beginRenderPass(c);if(e.viewport){const{x:d,y:p,width:m,height:y,minDepth:M,maxDepth:T}=e.viewportValue;u.setViewport(d,p,m,y,M,T)}if(e.scissor){const{x:d,y:p,width:m,height:y}=e.scissorValue;u.setScissorRect(d,p,m,y)}u.executeBundles([o[a]]),u.end()}}else t.currentPass&&t.currentPass.end();if(n>0){const o=n*8;let a=this.occludedResolveCache.get(o);a===void 0&&(a=this.device.createBuffer({size:o,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(o,a));const c=this.device.createBuffer({size:o,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,a,0),t.encoder.copyBufferToBuffer(a,0,c,0,o),t.occlusionQueryBuffer=c,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),e.textures!==null){const o=e.textures;for(let a=0;a<o.length;a++){const c=o[a];c.generateMipmaps===!0&&this.textureUtils.generateMipmaps(c)}}}isOccluded(e,t){const n=this.get(e);return n.occluded&&n.occluded.has(t)}resolveOccludedAsync(e){return hr(this,null,function*(){const t=this.get(e),{currentOcclusionQueryBuffer:n,currentOcclusionQueryObjects:s}=t;if(n&&s){const o=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,yield n.mapAsync(GPUMapMode.READ);const a=n.getMappedRange(),c=new BigUint64Array(a);for(let u=0;u<s.length;u++)c[u]===BigInt(0)&&o.add(s[u]);n.destroy(),t.occluded=o}})}updateViewport(e){const{currentPass:t}=this.get(e),{x:n,y:s,width:o,height:a,minDepth:c,maxDepth:u}=e.viewportValue;t.setViewport(n,s,o,a,c,u)}getClearColor(){const e=super.getClearColor();return this.renderer.alpha===!0&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,n,s=null){const o=this.device,a=this.renderer;let c=[],u,d,p,m;if(e){const T=this.getClearColor();d={r:T.r,g:T.g,b:T.b,a:T.a}}if(s===null){p=a.depth,m=a.stencil;const T=this._getDefaultRenderPassDescriptor();if(e){c=T.colorAttachments;const G=c[0];G.clearValue=d,G.loadOp=go.Clear,G.storeOp=ac.Store}(p||m)&&(u=T.depthStencilAttachment)}else{p=s.depth,m=s.stencil;const T={loadOp:e?go.Clear:go.Load,clearValue:e?d:void 0};p&&(T.depthLoadOp=t?go.Clear:go.Load,T.depthClearValue=t?a.getClearDepth():void 0,T.depthStoreOp=ac.Store),m&&(T.stencilLoadOp=n?go.Clear:go.Load,T.stencilClearValue=n?a.getClearStencil():void 0,T.stencilStoreOp=ac.Store);const G=this._getRenderPassDescriptor(s,T);c=G.colorAttachments,u=G.depthStencilAttachment}p&&u&&(t?(u.depthLoadOp=go.Clear,u.depthClearValue=a.getClearDepth(),u.depthStoreOp=ac.Store):(u.depthLoadOp=go.Load,u.depthStoreOp=ac.Store)),m&&u&&(n?(u.stencilLoadOp=go.Clear,u.stencilClearValue=a.getClearStencil(),u.stencilStoreOp=ac.Store):(u.stencilLoadOp=go.Load,u.stencilStoreOp=ac.Store));const y=o.createCommandEncoder({label:"clear"});y.beginRenderPass({colorAttachments:c,depthStencilAttachment:u}).end(),o.queue.submit([y.finish()])}beginCompute(e){const t=this.get(e);t.frameCalls=this.renderer.info.compute.frameCalls;const n={label:"computeGroup_"+e.id};this.initTimestampQuery(fh.COMPUTE,this.getTimestampUID(e),n),t.cmdEncoderGPU=this.device.createCommandEncoder({label:"computeGroup_"+e.id}),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(n)}compute(e,t,n,s,o=null){const a=this.get(t),{passEncoderGPU:c}=this.get(e),u=this.get(s).pipeline;this.pipelineUtils.setPipeline(c,u);for(let p=0,m=n.length;p<m;p++){const y=n[p],M=this.get(y);c.setBindGroup(p,M.group)}let d;if(o===null&&(o=t.count),typeof o=="number"){const p=o;if(a.dispatchSize===void 0||a.count!==p){a.dispatchSize=[0,1,1],a.count=p;const m=t.workgroupSize;let y=m[0];for(let G=1;G<m.length;G++)y*=m[G];const M=Math.ceil(p/y),T=this.device.limits.maxComputeWorkgroupsPerDimension;d=[M,1,1],M>T&&(d[0]=Math.min(M,T),d[1]=Math.ceil(M/T)),a.dispatchSize=d}d=a.dispatchSize}else d=o;c.dispatchWorkgroups(d[0],d[1]||1,d[2]||1)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}waitForGPU(){return hr(this,null,function*(){yield this.device.queue.onSubmittedWorkDone()})}draw(e,t){const{object:n,material:s,context:o,pipeline:a}=e,c=e.getBindings(),u=this.get(o),d=this.get(a).pipeline,p=e.getIndex(),m=p!==null,y=e.getDrawParameters();if(y===null)return;const M=(G,z)=>{this.pipelineUtils.setPipeline(G,d),z.pipeline=d;const I=z.bindingGroups;for(let K=0,re=c.length;K<re;K++){const ve=c[K],me=this.get(ve);I[ve.index]!==ve.id&&(G.setBindGroup(ve.index,me.group),I[ve.index]=ve.id)}if(m===!0&&z.index!==p){const K=this.get(p).buffer,re=p.array instanceof Uint16Array?g0.Uint16:g0.Uint32;G.setIndexBuffer(K,re),z.index=p}const J=e.getVertexBuffers();for(let K=0,re=J.length;K<re;K++){const ve=J[K];if(z.attributes[K]!==ve){const me=this.get(ve).buffer;G.setVertexBuffer(K,me),z.attributes[K]=ve}}o.stencil===!0&&s.stencilWrite===!0&&u.currentStencilRef!==s.stencilRef&&(G.setStencilReference(s.stencilRef),u.currentStencilRef=s.stencilRef)},T=(G,z)=>{if(M(G,z),n.isBatchedMesh===!0){const I=n._multiDrawStarts,J=n._multiDrawCounts,K=n._multiDrawCount,re=n._multiDrawInstances;re!==null&&ll("THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let ve=0;ve<K;ve++){const me=re?re[ve]:1,Le=me>1?0:ve;m===!0?G.drawIndexed(J[ve],me,I[ve]/p.array.BYTES_PER_ELEMENT,0,Le):G.draw(J[ve],me,I[ve],Le),t.update(n,J[ve],me)}}else if(m===!0){const{vertexCount:I,instanceCount:J,firstVertex:K}=y,re=e.getIndirect();if(re!==null){const ve=this.get(re).buffer;G.drawIndexedIndirect(ve,0)}else G.drawIndexed(I,J,K,0,0);t.update(n,I,J)}else{const{vertexCount:I,instanceCount:J,firstVertex:K}=y,re=e.getIndirect();if(re!==null){const ve=this.get(re).buffer;G.drawIndirect(ve,0)}else G.draw(I,J,K,0);t.update(n,I,J)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){const G=this.get(e.camera),z=e.camera.cameras,I=e.getBindingGroup("cameraIndex");if(G.indexesGPU===void 0||G.indexesGPU.length!==z.length){const K=this.get(I),re=[],ve=new Uint32Array([0,0,0,0]);for(let me=0,Le=z.length;me<Le;me++){ve[0]=me;const Ve=this.bindingUtils.createBindGroupIndex(ve,K.layout);re.push(Ve)}G.indexesGPU=re}const J=this.renderer.getPixelRatio();for(let K=0,re=z.length;K<re;K++){const ve=z[K];if(n.layers.test(ve.layers)){const me=ve.viewport;let Le=u.currentPass,Ve=u.currentSets;if(u.bundleEncoders){const Ee=u.bundleEncoders[K],Oe=u.bundleSets[K];Le=Ee,Ve=Oe}me&&Le.setViewport(Math.floor(me.x*J),Math.floor(me.y*J),Math.floor(me.width*J),Math.floor(me.height*J),o.viewportValue.minDepth,o.viewportValue.maxDepth),I&&G.indexesGPU&&(Le.setBindGroup(I.index,G.indexesGPU[K]),Ve.bindingGroups[I.index]=I.id),T(Le,Ve)}}}else if(u.currentPass){if(u.occlusionQuerySet!==void 0){const G=u.lastOcclusionObject;G!==n&&(G!==null&&G.occlusionTest===!0&&(u.currentPass.endOcclusionQuery(),u.occlusionQueryIndex++),n.occlusionTest===!0&&(u.currentPass.beginOcclusionQuery(u.occlusionQueryIndex),u.occlusionQueryObjects[u.occlusionQueryIndex]=n),u.lastOcclusionObject=n)}T(u.currentPass,u.currentSets)}}needsRenderUpdate(e){const t=this.get(e),{object:n,material:s}=e,o=this.utils,a=o.getSampleCountRenderContext(e.context),c=o.getCurrentColorSpace(e.context),u=o.getCurrentColorFormat(e.context),d=o.getCurrentDepthStencilFormat(e.context),p=o.getPrimitiveTopology(n,s);let m=!1;return(t.material!==s||t.materialVersion!==s.version||t.transparent!==s.transparent||t.blending!==s.blending||t.premultipliedAlpha!==s.premultipliedAlpha||t.blendSrc!==s.blendSrc||t.blendDst!==s.blendDst||t.blendEquation!==s.blendEquation||t.blendSrcAlpha!==s.blendSrcAlpha||t.blendDstAlpha!==s.blendDstAlpha||t.blendEquationAlpha!==s.blendEquationAlpha||t.colorWrite!==s.colorWrite||t.depthWrite!==s.depthWrite||t.depthTest!==s.depthTest||t.depthFunc!==s.depthFunc||t.stencilWrite!==s.stencilWrite||t.stencilFunc!==s.stencilFunc||t.stencilFail!==s.stencilFail||t.stencilZFail!==s.stencilZFail||t.stencilZPass!==s.stencilZPass||t.stencilFuncMask!==s.stencilFuncMask||t.stencilWriteMask!==s.stencilWriteMask||t.side!==s.side||t.alphaToCoverage!==s.alphaToCoverage||t.sampleCount!==a||t.colorSpace!==c||t.colorFormat!==u||t.depthStencilFormat!==d||t.primitiveTopology!==p||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=s,t.materialVersion=s.version,t.transparent=s.transparent,t.blending=s.blending,t.premultipliedAlpha=s.premultipliedAlpha,t.blendSrc=s.blendSrc,t.blendDst=s.blendDst,t.blendEquation=s.blendEquation,t.blendSrcAlpha=s.blendSrcAlpha,t.blendDstAlpha=s.blendDstAlpha,t.blendEquationAlpha=s.blendEquationAlpha,t.colorWrite=s.colorWrite,t.depthWrite=s.depthWrite,t.depthTest=s.depthTest,t.depthFunc=s.depthFunc,t.stencilWrite=s.stencilWrite,t.stencilFunc=s.stencilFunc,t.stencilFail=s.stencilFail,t.stencilZFail=s.stencilZFail,t.stencilZPass=s.stencilZPass,t.stencilFuncMask=s.stencilFuncMask,t.stencilWriteMask=s.stencilWriteMask,t.side=s.side,t.alphaToCoverage=s.alphaToCoverage,t.sampleCount=a,t.colorSpace=c,t.colorFormat=u,t.depthStencilFormat=d,t.primitiveTopology=p,t.clippingContextCacheKey=e.clippingContextCacheKey,m=!0),m}getRenderCacheKey(e){const{object:t,material:n}=e,s=this.utils,o=e.context,a=t.isMesh&&t.matrixWorld.determinant()<0;return[n.transparent,n.blending,n.premultipliedAlpha,n.blendSrc,n.blendDst,n.blendEquation,n.blendSrcAlpha,n.blendDstAlpha,n.blendEquationAlpha,n.colorWrite,n.depthWrite,n.depthTest,n.depthFunc,n.stencilWrite,n.stencilFunc,n.stencilFail,n.stencilZFail,n.stencilZPass,n.stencilFuncMask,n.stencilWriteMask,n.side,a,s.getSampleCountRenderContext(o),s.getCurrentColorSpace(o),s.getCurrentColorFormat(o),s.getCurrentDepthStencilFormat(o),s.getPrimitiveTopology(t,n),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,n,s,o,a){return hr(this,null,function*(){return this.textureUtils.copyTextureToBuffer(e,t,n,s,o,a)})}initTimestampQuery(e,t,n){if(!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new o7(this.device,e,2048));const s=this.timestampQueryPool[e],o=s.allocateQueriesForContext(t);n.timestampWrites={querySet:s.querySet,beginningOfPassWriteIndex:o,endOfPassWriteIndex:o+1}}createNodeBuilder(e,t){return new Q9(e,t)}createProgram(e){const t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name!==""?`_${e.name}`:"")}),entryPoint:"main"}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){const t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){const n=this.get(e),o=n.currentPass.finish();this.get(t).bundleGPU=o,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,n,s){this.bindingUtils.createBindings(e,t,n,s)}updateBindings(e,t,n,s){this.bindingUtils.createBindings(e,t,n,s)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){let t=GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST;(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t|=GPUBufferUsage.STORAGE),this.attributeUtils.createAttribute(e,t)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return this.device.features.has(e)}copyTextureToTexture(e,t,n=null,s=null,o=0,a=0){let c=0,u=0,d=0,p=0,m=0,y=0,M=e.image.width,T=e.image.height,G=1;n!==null&&(n.isBox3===!0?(p=n.min.x,m=n.min.y,y=n.min.z,M=n.max.x-n.min.x,T=n.max.y-n.min.y,G=n.max.z-n.min.z):(p=n.min.x,m=n.min.y,M=n.max.x-n.min.x,T=n.max.y-n.min.y,G=1)),s!==null&&(c=s.x,u=s.y,d=s.z||0);const z=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),I=this.get(e).texture,J=this.get(t).texture;z.copyTextureToTexture({texture:I,mipLevel:o,origin:{x:p,y:m,z:y}},{texture:J,mipLevel:a,origin:{x:c,y:u,z:d}},[M,T,G]),this.device.queue.submit([z.finish()]),a===0&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,n){const s=this.get(t);let o=null;t.renderTarget?e.isDepthTexture?o=this.get(t.depthTexture).texture:o=this.get(t.textures[0]).texture:e.isDepthTexture?o=this.textureUtils.getDepthBuffer(t.depth,t.stencil):o=this.context.getCurrentTexture();const a=this.get(e).texture;if(o.format!==a.format){console.error("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",o.format,a.format);return}let c;if(s.currentPass?(s.currentPass.end(),c=s.encoder):c=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+e.id}),c.copyTextureToTexture({texture:o,origin:[n.x,n.y,0]},{texture:a},[n.z,n.w]),s.currentPass){const{descriptor:u}=s;for(let d=0;d<u.colorAttachments.length;d++)u.colorAttachments[d].loadOp=go.Load;if(t.depth&&(u.depthStencilAttachment.depthLoadOp=go.Load),t.stencil&&(u.depthStencilAttachment.stencilLoadOp=go.Load),s.currentPass=c.beginRenderPass(u),s.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor){const{x:d,y:p,width:m,height:y}=t.scissorValue;s.currentPass.setScissorRect(d,p,m,y)}}else this.device.queue.submit([c.finish()]);e.generateMipmaps&&this.textureUtils.generateMipmaps(e)}}class a7 extends Mg{constructor(e,t,n,s,o,a){super(e,t,n,s,o,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}}class l7 extends Mg{constructor(e,t,n,s,o,a){super(e,t,n,s,o,a),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}}class c7 extends AI{constructor(){super(),this.addMaterial(YV,"MeshPhongMaterial"),this.addMaterial(iP,"MeshStandardMaterial"),this.addMaterial(O5,"MeshPhysicalMaterial"),this.addMaterial(z5,"MeshToonMaterial"),this.addMaterial(GV,"MeshBasicMaterial"),this.addMaterial(XV,"MeshLambertMaterial"),this.addMaterial(BV,"MeshNormalMaterial"),this.addMaterial(G5,"MeshMatcapMaterial"),this.addMaterial(NV,"LineBasicMaterial"),this.addMaterial(IV,"LineDashedMaterial"),this.addMaterial(X5,"PointsMaterial"),this.addMaterial(sP,"SpriteMaterial"),this.addMaterial(K5,"ShadowMaterial"),this.addLight(fW,Wx),this.addLight(GH,Ad),this.addLight(WH,$x),this.addLight(dT,Mg),this.addLight(XH,qp),this.addLight(qH,Ed),this.addLight(YH,by),this.addLight(HH,a7),this.addLight(jH,l7),this.addToneMapping(PP,B),this.addToneMapping(IP,te),this.addToneMapping(LP,ot),this.addToneMapping(DP,_t),this.addToneMapping(OP,qt),this.addToneMapping(FP,en)}}class u7 extends p9{constructor(e={}){let t;e.forceWebGL?t=YI:(t=AT,e.getFallback=()=>(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new YI(e)));const n=new t(e);super(n,e),this.library=new c7,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}class JZ extends null{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}}class QZ{constructor(e,t=Bi(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;const n=new xa;n.name="PostProcessing",this._quadMesh=new Ov(n),this._context=null}render(){const e=this.renderer;this._update(),this._context.onBeforePostProcessing!==null&&this._context.onBeforePostProcessing();const t=e.toneMapping,n=e.outputColorSpace;e.toneMapping=NoToneMapping,e.outputColorSpace=ColorManagement.workingColorSpace;const s=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=n,this._context.onAfterPostProcessing!==null&&this._context.onAfterPostProcessing()}get context(){return this._context}dispose(){this._quadMesh.material.dispose()}_update(){if(this.needsUpdate===!0){const e=this.renderer,t=e.toneMapping,n=e.outputColorSpace,s={postProcessing:this,onBeforePostProcessing:null,onAfterPostProcessing:null};let o=this.outputNode;this.outputColorTransform===!0?(o=o.context(s),o=FM(o,t,n)):(s.toneMapping=t,s.outputColorSpace=n,o=o.context(s)),this._context=s,this._quadMesh.material.fragmentNode=o,this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}renderAsync(){return hr(this,null,function*(){this._update(),this._context.onBeforePostProcessing!==null&&this._context.onBeforePostProcessing();const e=this.renderer,t=e.toneMapping,n=e.outputColorSpace;e.toneMapping=NoToneMapping,e.outputColorSpace=ColorManagement.workingColorSpace;const s=e.xr.enabled;e.xr.enabled=!1,yield this._quadMesh.renderAsync(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=n,this._context.onAfterPostProcessing!==null&&this._context.onAfterPostProcessing()})}}class eK extends null{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=LinearFilter,this.minFilter=LinearFilter,this.isStorageTexture=!0}setSize(e,t){(this.image.width!==e||this.image.height!==t)&&(this.image.width=e,this.image.height=t,this.dispose())}}class tK extends null{constructor(e=1,t=1,n=1){super(),this.isArrayTexture=!1,this.image={width:e,height:t,depth:n},this.magFilter=LinearFilter,this.minFilter=LinearFilter,this.wrapR=ClampToEdgeWrapping,this.isStorageTexture=!0,this.is3DTexture=!0}setSize(e,t,n){(this.image.width!==e||this.image.height!==t||this.image.depth!==n)&&(this.image.width=e,this.image.height=t,this.image.depth=n,this.dispose())}}class nK extends null{constructor(e=1,t=1,n=1){super(),this.isArrayTexture=!0,this.image={width:e,height:t,depth:n},this.magFilter=LinearFilter,this.minFilter=LinearFilter,this.isStorageTexture=!0}setSize(e,t,n){(this.image.width!==e||this.image.height!==t||this.image.depth!==n)&&(this.image.width=e,this.image.height=t,this.image.depth=n,this.dispose())}}class iK extends null{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}}class h7 extends null{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,n,s){const o=new FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,a=>{try{t(this.parse(JSON.parse(a)))}catch(c){s?s(c):console.error(c),this.manager.itemError(e)}},n,s)}parseNodes(e){const t={};if(e!==void 0){for(const s of e){const{uuid:o,type:a}=s;t[o]=this.createNodeFromType(a),t[o].uuid=o}const n={nodes:t,textures:this.textures};for(const s of e)s.meta=n,t[s.uuid].deserialize(s),delete s.meta}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const s={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=s,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return this.nodes[e]===void 0?(console.error("THREE.NodeLoader: Node type not found:",e),at()):Cn(new this.nodes[e])}}class d7 extends null{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),n=this.nodes,s=e.inputNodes;for(const o in s){const a=s[o];t[o]=n[a]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return t!==void 0?new t:super.createMaterialFromType(e)}}class rK extends null{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const n=super.parse(e,t);return this._nodesJSON=null,n}parseNodes(e,t){if(e!==void 0){const n=new h7;return n.setNodes(this.nodes),n.setTextures(t),n.parseNodes(e)}return{}}parseMaterials(e,t){const n={};if(e!==void 0){const s=this.parseNodes(this._nodesJSON,t),o=new d7;o.setTextures(t),o.setNodes(s),o.setNodeMaterials(this.nodeMaterials);for(let a=0,c=e.length;a<c;a++){const u=e[a];n[u.uuid]=o.parse(u)}}return n}}class sK extends null{constructor(){super(),this.isClippingGroup=!0,this.clippingPlanes=[],this.enabled=!0,this.clipIntersection=!1,this.clipShadows=!1}}const CT={type:"change"},RT={type:"start"},NT={type:"end"},aL=1e-6,yo={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4},Gb=new yn,tp=new yn,f7=new it,Wb=new it,PT=new it,v0=new ta,lL=new it,Hb=new it,IT=new it,$b=new it;class p7 extends tm{constructor(e,t=null){super(e,t),this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.keys=["KeyA","KeyS","KeyD"],this.mouseButtons={LEFT:k.ROTATE,MIDDLE:k.DOLLY,RIGHT:k.PAN},this.target=new it,this.state=yo.NONE,this.keyState=yo.NONE,this._lastPosition=new it,this._lastZoom=1,this._touchZoomDistanceStart=0,this._touchZoomDistanceEnd=0,this._lastAngle=0,this._eye=new it,this._movePrev=new yn,this._moveCurr=new yn,this._lastAxis=new it,this._zoomStart=new yn,this._zoomEnd=new yn,this._panStart=new yn,this._panEnd=new yn,this._pointers=[],this._pointerPositions={},this._onPointerMove=g7.bind(this),this._onPointerDown=m7.bind(this),this._onPointerUp=y7.bind(this),this._onPointerCancel=v7.bind(this),this._onContextMenu=T7.bind(this),this._onMouseWheel=S7.bind(this),this._onKeyDown=_7.bind(this),this._onKeyUp=x7.bind(this),this._onTouchStart=E7.bind(this),this._onTouchMove=A7.bind(this),this._onTouchEnd=C7.bind(this),this._onMouseDown=b7.bind(this),this._onMouseMove=w7.bind(this),this._onMouseUp=M7.bind(this),this._target0=this.target.clone(),this._position0=this.object.position.clone(),this._up0=this.object.up.clone(),this._zoom0=this.object.zoom,t!==null&&(this.connect(t),this.handleResize()),this.update()}connect(e){super.connect(e),window.addEventListener("keydown",this._onKeyDown),window.addEventListener("keyup",this._onKeyUp),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerCancel),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="none"}disconnect(){window.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("keyup",this._onKeyUp),this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerCancel),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}handleResize(){const e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}update(){this._eye.subVectors(this.object.position,this.target),this.noRotate||this._rotateCamera(),this.noZoom||this._zoomCamera(),this.noPan||this._panCamera(),this.object.position.addVectors(this.target,this._eye),this.object.isPerspectiveCamera?(this._checkDistances(),this.object.lookAt(this.target),this._lastPosition.distanceToSquared(this.object.position)>aL&&(this.dispatchEvent(CT),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>aL||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(CT),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=yo.NONE,this.keyState=yo.NONE,this.target.copy(this._target0),this.object.position.copy(this._position0),this.object.up.copy(this._up0),this.object.zoom=this._zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(CT),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(tp.copy(this._panEnd).sub(this._panStart),tp.lengthSq()){if(this.object.isOrthographicCamera){const e=(this.object.right-this.object.left)/this.object.zoom/this.domElement.clientWidth,t=(this.object.top-this.object.bottom)/this.object.zoom/this.domElement.clientWidth;tp.x*=e,tp.y*=t}tp.multiplyScalar(this._eye.length()*this.panSpeed),Wb.copy(this._eye).cross(this.object.up).setLength(tp.x),Wb.add(f7.copy(this.object.up).setLength(tp.y)),this.object.position.add(Wb),this.target.add(Wb),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(tp.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){$b.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=$b.length();e?(this._eye.copy(this.object.position).sub(this.target),lL.copy(this._eye).normalize(),Hb.copy(this.object.up).normalize(),IT.crossVectors(Hb,lL).normalize(),Hb.setLength(this._moveCurr.y-this._movePrev.y),IT.setLength(this._moveCurr.x-this._movePrev.x),$b.copy(Hb.add(IT)),PT.crossVectors($b,this._eye).normalize(),e*=this.rotateSpeed,v0.setFromAxisAngle(PT,e),this._eye.applyQuaternion(v0),this.object.up.applyQuaternion(v0),this._lastAxis.copy(PT),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),v0.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(v0),this.object.up.applyQuaternion(v0)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===yo.TOUCH_ZOOM_PAN?(e=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=ed.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")):(e=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,e!==1&&e>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=ed.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor)}_getMouseOnScreen(e,t){return Gb.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),Gb}_getMouseOnCircle(e,t){return Gb.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),Gb}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t].pointerId==e.pointerId){this._pointers.splice(t,1);return}}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new yn,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0].pointerId?this._pointers[1]:this._pointers[0];return this._pointerPositions[t.pointerId]}_checkDistances(){(!this.noZoom||!this.noPan)&&(this._eye.lengthSq()>this.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()<this.minDistance*this.minDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.minDistance)),this._zoomStart.copy(this._zoomEnd)))}}function m7(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i))}function g7(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function y7(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchEnd(i):this._onMouseUp(),this._removePointer(i),this._pointers.length===0&&(this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp)))}function v7(i){this._removePointer(i)}function x7(){this.enabled!==!1&&(this.keyState=yo.NONE,window.addEventListener("keydown",this._onKeyDown))}function _7(i){this.enabled!==!1&&(window.removeEventListener("keydown",this._onKeyDown),this.keyState===yo.NONE&&(i.code===this.keys[yo.ROTATE]&&!this.noRotate?this.keyState=yo.ROTATE:i.code===this.keys[yo.ZOOM]&&!this.noZoom?this.keyState=yo.ZOOM:i.code===this.keys[yo.PAN]&&!this.noPan&&(this.keyState=yo.PAN)))}function b7(i){let e;switch(i.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case k.DOLLY:this.state=yo.ZOOM;break;case k.ROTATE:this.state=yo.ROTATE;break;case k.PAN:this.state=yo.PAN;break;default:this.state=yo.NONE}const t=this.keyState!==yo.NONE?this.keyState:this.state;t===yo.ROTATE&&!this.noRotate?(this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY)),this._movePrev.copy(this._moveCurr)):t===yo.ZOOM&&!this.noZoom?(this._zoomStart.copy(this._getMouseOnScreen(i.pageX,i.pageY)),this._zoomEnd.copy(this._zoomStart)):t===yo.PAN&&!this.noPan&&(this._panStart.copy(this._getMouseOnScreen(i.pageX,i.pageY)),this._panEnd.copy(this._panStart)),this.dispatchEvent(RT)}function w7(i){const e=this.keyState!==yo.NONE?this.keyState:this.state;e===yo.ROTATE&&!this.noRotate?(this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY))):e===yo.ZOOM&&!this.noZoom?this._zoomEnd.copy(this._getMouseOnScreen(i.pageX,i.pageY)):e===yo.PAN&&!this.noPan&&this._panEnd.copy(this._getMouseOnScreen(i.pageX,i.pageY))}function M7(){this.state=yo.NONE,this.dispatchEvent(NT)}function S7(i){if(this.enabled!==!1&&this.noZoom!==!0){switch(i.preventDefault(),i.deltaMode){case 2:this._zoomStart.y-=i.deltaY*.025;break;case 1:this._zoomStart.y-=i.deltaY*.01;break;default:this._zoomStart.y-=i.deltaY*25e-5;break}this.dispatchEvent(RT),this.dispatchEvent(NT)}}function T7(i){this.enabled!==!1&&i.preventDefault()}function E7(i){switch(this._trackPointer(i),this._pointers.length){case 1:this.state=yo.TOUCH_ROTATE,this._moveCurr.copy(this._getMouseOnCircle(this._pointers[0].pageX,this._pointers[0].pageY)),this._movePrev.copy(this._moveCurr);break;default:this.state=yo.TOUCH_ZOOM_PAN;const e=this._pointers[0].pageX-this._pointers[1].pageX,t=this._pointers[0].pageY-this._pointers[1].pageY;this._touchZoomDistanceEnd=this._touchZoomDistanceStart=Math.sqrt(e*e+t*t);const n=(this._pointers[0].pageX+this._pointers[1].pageX)/2,s=(this._pointers[0].pageY+this._pointers[1].pageY)/2;this._panStart.copy(this._getMouseOnScreen(n,s)),this._panEnd.copy(this._panStart);break}this.dispatchEvent(RT)}function A7(i){switch(this._trackPointer(i),this._pointers.length){case 1:this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY));break;default:const e=this._getSecondPointerPosition(i),t=i.pageX-e.x,n=i.pageY-e.y;this._touchZoomDistanceEnd=Math.sqrt(t*t+n*n);const s=(i.pageX+e.x)/2,o=(i.pageY+e.y)/2;this._panEnd.copy(this._getMouseOnScreen(s,o));break}}function C7(i){switch(this._pointers.length){case 0:this.state=yo.NONE;break;case 1:this.state=yo.TOUCH_ROTATE,this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY)),this._movePrev.copy(this._moveCurr);break;case 2:this.state=yo.TOUCH_ZOOM_PAN;for(let e=0;e<this._pointers.length;e++)if(this._pointers[e].pointerId!==i.pointerId){const t=this._pointerPositions[this._pointers[e].pointerId];this._moveCurr.copy(this._getMouseOnCircle(t.x,t.y)),this._movePrev.copy(this._moveCurr);break}break}this.dispatchEvent(NT)}const cL={type:"change"},LT={type:"start"},uL={type:"end"},jb=new hn,hL=new Rl,R7=Math.cos(70*ed.DEG2RAD),vl=new it,Nc=2*Math.PI,Io={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},DT=1e-6;class N7 extends tm{constructor(e,t=null){super(e,t),this.state=Io.NONE,this.target=new it,this.cursor=new it,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:k.ROTATE,MIDDLE:k.DOLLY,RIGHT:k.PAN},this.touches={ONE:O.ROTATE,TWO:O.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new it,this._lastQuaternion=new ta,this._lastTargetPosition=new it,this._quat=new ta().setFromUnitVectors(e.up,new it(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Iy,this._sphericalDelta=new Iy,this._scale=1,this._panOffset=new it,this._rotateStart=new yn,this._rotateEnd=new yn,this._rotateDelta=new yn,this._panStart=new yn,this._panEnd=new yn,this._panDelta=new yn,this._dollyStart=new yn,this._dollyEnd=new yn,this._dollyDelta=new yn,this._dollyDirection=new it,this._mouse=new yn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=I7.bind(this),this._onPointerDown=P7.bind(this),this._onPointerUp=L7.bind(this),this._onContextMenu=z7.bind(this),this._onMouseWheel=F7.bind(this),this._onKeyDown=B7.bind(this),this._onTouchStart=U7.bind(this),this._onTouchMove=k7.bind(this),this._onMouseDown=D7.bind(this),this._onMouseMove=O7.bind(this),this._interceptControlDown=V7.bind(this),this._interceptControlUp=G7.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(cL),this.update(),this.state=Io.NONE}update(e=null){const t=this.object.position;vl.copy(t).sub(this.target),vl.applyQuaternion(this._quat),this._spherical.setFromVector3(vl),this.autoRotate&&this.state===Io.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=Nc:n>Math.PI&&(n-=Nc),s<-Math.PI?s+=Nc:s>Math.PI&&(s-=Nc),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let o=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),o=a!=this._spherical.radius}if(vl.setFromSpherical(this._spherical),vl.applyQuaternion(this._quatInverse),t.copy(this.target).add(vl),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const c=vl.length();a=this._clampDistance(c*this._scale);const u=c-a;this.object.position.addScaledVector(this._dollyDirection,u),this.object.updateMatrixWorld(),o=!!u}else if(this.object.isOrthographicCamera){const c=new it(this._mouse.x,this._mouse.y,0);c.unproject(this.object);const u=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),o=u!==this.object.zoom;const d=new it(this._mouse.x,this._mouse.y,0);d.unproject(this.object),this.object.position.sub(d).add(c),this.object.updateMatrixWorld(),a=vl.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(jb.origin.copy(this.object.position),jb.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(jb.direction))<R7?this.object.lookAt(this.target):(hL.setFromNormalAndCoplanarPoint(this.object.up,this.target),jb.intersectPlane(hL,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),o=!0)}return this._scale=1,this._performCursorZoom=!1,o||this._lastPosition.distanceToSquared(this.object.position)>DT||8*(1-this._lastQuaternion.dot(this.object.quaternion))>DT||this._lastTargetPosition.distanceToSquared(this.target)>DT?(this.dispatchEvent(cL),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Nc/60*this.autoRotateSpeed*e:Nc/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){vl.setFromMatrixColumn(t,0),vl.multiplyScalar(-e),this._panOffset.add(vl)}_panUp(e,t){this.screenSpacePanning===!0?vl.setFromMatrixColumn(t,1):(vl.setFromMatrixColumn(t,0),vl.crossVectors(this.object.up,vl)),vl.multiplyScalar(e),this._panOffset.add(vl)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;vl.copy(s).sub(this.target);let o=vl.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*o/n.clientHeight,this.object.matrix),this._panUp(2*t*o/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),s=e-n.left,o=t-n.top,a=n.width,c=n.height;this._mouse.x=s/a*2-1,this._mouse.y=-(o/c)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Nc*this._rotateDelta.x/t.clientHeight),this._rotateUp(Nc*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Nc*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Nc*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Nc*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Nc*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,o=Math.sqrt(n*n+s*s);this._dollyStart.set(0,o)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),o=.5*(e.pageY+n.y);this._rotateEnd.set(s,o)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Nc*this._rotateDelta.x/t.clientHeight),this._rotateUp(Nc*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,o=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,o),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,c=(e.pageY+t.y)*.5;this._updateZoomParameters(a,c)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new yn,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function P7(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function I7(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function L7(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(uL),this.state=Io.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function D7(i){let e;switch(i.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case k.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=Io.DOLLY;break;case k.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Io.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Io.ROTATE}break;case k.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Io.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Io.PAN}break;default:this.state=Io.NONE}this.state!==Io.NONE&&this.dispatchEvent(LT)}function O7(i){switch(this.state){case Io.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case Io.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case Io.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function F7(i){this.enabled===!1||this.enableZoom===!1||this.state!==Io.NONE||(i.preventDefault(),this.dispatchEvent(LT),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(uL))}function B7(i){this.enabled!==!1&&this._handleKeyDown(i)}function U7(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case O.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=Io.TOUCH_ROTATE;break;case O.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=Io.TOUCH_PAN;break;default:this.state=Io.NONE}break;case 2:switch(this.touches.TWO){case O.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=Io.TOUCH_DOLLY_PAN;break;case O.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=Io.TOUCH_DOLLY_ROTATE;break;default:this.state=Io.NONE}break;default:this.state=Io.NONE}this.state!==Io.NONE&&this.dispatchEvent(LT)}function k7(i){switch(this._trackPointer(i),this.state){case Io.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case Io.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case Io.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case Io.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=Io.NONE}}function z7(i){this.enabled!==!1&&i.preventDefault()}function V7(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function G7(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const W7={type:"change"},dL=1e-6,fL=new ta;class H7 extends tm{constructor(e,t=null){super(e,t),this.movementSpeed=1,this.rollSpeed=.005,this.dragToLook=!1,this.autoForward=!1,this._moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0},this._moveVector=new it(0,0,0),this._rotationVector=new it(0,0,0),this._lastQuaternion=new ta,this._lastPosition=new it,this._status=0,this._onKeyDown=$7.bind(this),this._onKeyUp=j7.bind(this),this._onPointerMove=q7.bind(this),this._onPointerDown=X7.bind(this),this._onPointerUp=Y7.bind(this),this._onPointerCancel=Z7.bind(this),this._onContextMenu=K7.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),window.addEventListener("keydown",this._onKeyDown),window.addEventListener("keyup",this._onKeyUp),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.addEventListener("pointercancel",this._onPointerCancel),this.domElement.addEventListener("contextmenu",this._onContextMenu)}disconnect(){window.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("keyup",this._onKeyUp),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerCancel),this.domElement.removeEventListener("contextmenu",this._onContextMenu)}dispose(){this.disconnect()}update(e){if(this.enabled===!1)return;const t=this.object,n=e*this.movementSpeed,s=e*this.rollSpeed;t.translateX(this._moveVector.x*n),t.translateY(this._moveVector.y*n),t.translateZ(this._moveVector.z*n),fL.set(this._rotationVector.x*s,this._rotationVector.y*s,this._rotationVector.z*s,1).normalize(),t.quaternion.multiply(fL),(this._lastPosition.distanceToSquared(t.position)>dL||8*(1-this._lastQuaternion.dot(t.quaternion))>dL)&&(this.dispatchEvent(W7),this._lastQuaternion.copy(t.quaternion),this._lastPosition.copy(t.position))}_updateMovementVector(){const e=this._moveState.forward||this.autoForward&&!this._moveState.back?1:0;this._moveVector.x=-this._moveState.left+this._moveState.right,this._moveVector.y=-this._moveState.down+this._moveState.up,this._moveVector.z=-e+this._moveState.back}_updateRotationVector(){this._rotationVector.x=-this._moveState.pitchDown+this._moveState.pitchUp,this._rotationVector.y=-this._moveState.yawRight+this._moveState.yawLeft,this._rotationVector.z=-this._moveState.rollRight+this._moveState.rollLeft}_getContainerDimensions(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}}}function $7(i){if(!(i.altKey||this.enabled===!1)){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this._moveState.forward=1;break;case"KeyS":this._moveState.back=1;break;case"KeyA":this._moveState.left=1;break;case"KeyD":this._moveState.right=1;break;case"KeyR":this._moveState.up=1;break;case"KeyF":this._moveState.down=1;break;case"ArrowUp":this._moveState.pitchUp=1;break;case"ArrowDown":this._moveState.pitchDown=1;break;case"ArrowLeft":this._moveState.yawLeft=1;break;case"ArrowRight":this._moveState.yawRight=1;break;case"KeyQ":this._moveState.rollLeft=1;break;case"KeyE":this._moveState.rollRight=1;break}this._updateMovementVector(),this._updateRotationVector()}}function j7(i){if(this.enabled!==!1){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this._moveState.forward=0;break;case"KeyS":this._moveState.back=0;break;case"KeyA":this._moveState.left=0;break;case"KeyD":this._moveState.right=0;break;case"KeyR":this._moveState.up=0;break;case"KeyF":this._moveState.down=0;break;case"ArrowUp":this._moveState.pitchUp=0;break;case"ArrowDown":this._moveState.pitchDown=0;break;case"ArrowLeft":this._moveState.yawLeft=0;break;case"ArrowRight":this._moveState.yawRight=0;break;case"KeyQ":this._moveState.rollLeft=0;break;case"KeyE":this._moveState.rollRight=0;break}this._updateMovementVector(),this._updateRotationVector()}}function X7(i){if(this.enabled!==!1)if(this.dragToLook)this._status++;else{switch(i.button){case 0:this._moveState.forward=1;break;case 2:this._moveState.back=1;break}this._updateMovementVector()}}function q7(i){if(this.enabled!==!1&&(!this.dragToLook||this._status>0)){const e=this._getContainerDimensions(),t=e.size[0]/2,n=e.size[1]/2;this._moveState.yawLeft=-(i.pageX-e.offset[0]-t)/t,this._moveState.pitchDown=(i.pageY-e.offset[1]-n)/n,this._updateRotationVector()}}function Y7(i){if(this.enabled!==!1){if(this.dragToLook)this._status--,this._moveState.yawLeft=this._moveState.pitchDown=0;else{switch(i.button){case 0:this._moveState.forward=0;break;case 2:this._moveState.back=0;break}this._updateMovementVector()}this._updateRotationVector()}}function Z7(){this.enabled!==!1&&(this.dragToLook?(this._status=0,this._moveState.yawLeft=this._moveState.pitchDown=0):(this._moveState.forward=0,this._moveState.back=0,this._updateMovementVector()),this._updateRotationVector())}function K7(i){this.enabled!==!1&&i.preventDefault()}const J7={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
|
|
|
|
|
|
varying vec2 vUv;
|
|
|
|
|
|
void main() {
|
|
|
|
|
|
vUv = uv;
|
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
|
|
|
|
}`,fragmentShader:`
|
|
|
|
|
|
uniform float opacity;
|
|
|
|
|
|
uniform sampler2D tDiffuse;
|
|
|
|
|
|
varying vec2 vUv;
|
|
|
|
|
|
void main() {
|
|
|
|
|
|
vec4 texel = texture2D( tDiffuse, vUv );
|
|
|
gl_FragColor = opacity * texel;
|
|
|
|
|
|
|
|
|
}`};class Xb{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const Q7=new Df(-1,1,1,-1,0,1);class e$ extends xr{constructor(){super(),this.setAttribute("position",new Zi([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Zi([0,2,0,0,2,0],2))}}const t$=new e$;class n${constructor(e){this._mesh=new Ks(t$,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Q7)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class i$ extends Xb{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof kc?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=fp.clone(e.uniforms),this.material=new kc({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new n$(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class pL extends Xb{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const s=e.getContext(),o=e.state;o.buffers.color.setMask(!1),o.buffers.depth.setMask(!1),o.buffers.color.setLocked(!0),o.buffers.depth.setLocked(!0);let a,c;this.inverse?(a=0,c=1):(a=1,c=0),o.buffers.stencil.setTest(!0),o.buffers.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),o.buffers.stencil.setFunc(s.ALWAYS,a,4294967295),o.buffers.stencil.setClear(c),o.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),o.buffers.color.setLocked(!1),o.buffers.depth.setLocked(!1),o.buffers.color.setMask(!0),o.buffers.depth.setMask(!0),o.buffers.stencil.setLocked(!1),o.buffers.stencil.setFunc(s.EQUAL,1,4294967295),o.buffers.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),o.buffers.stencil.setLocked(!0)}}class r$ extends Xb{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class s${constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new yn);this._width=n.width,this._height=n.height,t=new hc(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Gs}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new i$(J7),this.copyPass.material.blending=pe,this.clock=new qx}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){e===void 0&&(e=this.clock.getDelta());const t=this.renderer.getRenderTarget();let n=!1;for(let s=0,o=this.passes.length;s<o;s++){const a=this.passes[s];if(a.enabled!==!1){if(a.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(s),a.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),a.needsSwap){if(n){const c=this.renderer.getContext(),u=this.renderer.state.buffers.stencil;u.setFunc(c.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),u.setFunc(c.EQUAL,1,4294967295)}this.swapBuffers()}pL!==void 0&&(a instanceof pL?n=!0:a instanceof r$&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new yn);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,s=this._height*this._pixelRatio;this.renderTarget1.setSize(n,s),this.renderTarget2.setSize(n,s);for(let o=0;o<this.passes.length;o++)this.passes[o].setSize(n,s)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class o$ extends Xb{constructor(e,t,n=null,s=null,o=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=s,this.clearAlpha=o,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new jn}render(e,t,n){const s=e.autoClear;e.autoClear=!1;let o,a;this.overrideMaterial!==null&&(a=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(o=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(o),this.overrideMaterial!==null&&(this.scene.overrideMaterial=a),e.autoClear=s}}function Pc(){return Pc=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},Pc.apply(null,arguments)}function a$(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function Zv(i,e){return Zv=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},Zv(i,e)}function l$(i,e){i.prototype=Object.create(e.prototype),i.prototype.constructor=i,Zv(i,e)}function OT(i){return OT=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},OT(i)}function c$(i){try{return Function.toString.call(i).indexOf("[native code]")!==-1}catch(e){return typeof i=="function"}}function mL(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(mL=function(){return!!i})()}function u$(i,e,t){if(mL())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var s=new(i.bind.apply(i,n));return t&&Zv(s,t.prototype),s}function FT(i){var e=typeof Map=="function"?new Map:void 0;return FT=function(n){if(n===null||!c$(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(e!==void 0){if(e.has(n))return e.get(n);e.set(n,s)}function s(){return u$(n,arguments,OT(this).constructor)}return s.prototype=Object.create(n.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),Zv(s,n)},FT(i)}function gL(){var i;return i=arguments.length-1,i<0||arguments.length<=i?void 0:arguments[i]}function h$(i){return-i}function d$(i,e){return i+e}function f$(i,e){return i-e}function p$(i,e){return i*e}function m$(i,e){return i/e}function g$(){return Math.max.apply(Math,arguments)}function y$(){return Math.min.apply(Math,arguments)}function v$(){return Array.of.apply(Array,arguments)}var oK={symbols:{"*":{infix:{symbol:"*",f:p$,notation:"infix",precedence:4,rightToLeft:0,argCount:2},symbol:"*",regSymbol:"\\*"},"/":{infix:{symbol:"/",f:m$,notation:"infix",precedence:4,rightToLeft:0,argCount:2},symbol:"/",regSymbol:"/"},"+":{infix:{symbol:"+",f:d$,notation:"infix",precedence:2,rightToLeft:0,argCount:2},prefix:{symbol:"+",f:gL,notation:"prefix",precedence:3,rightToLeft:0,argCount:1},symbol:"+",regSymbol:"\\+"},"-":{infix:{symbol:"-",f:f$,notation:"infix",precedence:2,rightToLeft:0,argCount:2},prefix:{symbol:"-",f:h$,notation:"prefix",precedence:3,rightToLeft:0,argCount:1},symbol:"-",regSymbol:"-"},",":{infix:{symbol:",",f:v$,notation:"infix",precedence:1,rightToLeft:0,argCount:2},symbol:",",regSymbol:","},"(":{prefix:{symbol:"(",f:gL,notation:"prefix",precedence:0,rightToLeft:0,argCount:1},symbol:"(",regSymbol:"\\("},")":{postfix:{symbol:")",f:void 0,notation:"postfix",precedence:0,rightToLeft:0,argCount:1},symbol:")",regSymbol:"\\)"},min:{func:{symbol:"min",f:y$,notation:"func",precedence:0,rightToLeft:0,argCount:1},symbol:"min",regSymbol:"min\\b"},max:{func:{symbol:"max",f:g$,notation:"func",precedence:0,rightToLeft:0,argCount:1},symbol:"max",regSymbol:"max\\b"}}},yL=null,aK={1:`Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).
|
|
|
|
|
|
`,2:`Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).
|
|
|
|
|
|
`,3:`Passed an incorrect argument to a color function, please pass a string representation of a color.
|
|
|
|
|
|
`,4:`Couldn't generate valid rgb string from %s, it returned %s.
|
|
|
|
|
|
`,5:`Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.
|
|
|
|
|
|
`,6:`Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).
|
|
|
|
|
|
`,7:`Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).
|
|
|
|
|
|
`,8:`Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.
|
|
|
|
|
|
`,9:`Please provide a number of steps to the modularScale helper.
|
|
|
|
|
|
`,10:`Please pass a number or one of the predefined scales to the modularScale helper as the ratio.
|
|
|
|
|
|
`,11:`Invalid value passed as base to modularScale, expected number or em string but got "%s"
|
|
|
|
|
|
`,12:`Expected a string ending in "px" or a number passed as the first argument to %s(), got "%s" instead.
|
|
|
|
|
|
`,13:`Expected a string ending in "px" or a number passed as the second argument to %s(), got "%s" instead.
|
|
|
|
|
|
`,14:`Passed invalid pixel value ("%s") to %s(), please pass a value like "12px" or 12.
|
|
|
|
|
|
`,15:`Passed invalid base value ("%s") to %s(), please pass a value like "12px" or 12.
|
|
|
|
|
|
`,16:`You must provide a template to this method.
|
|
|
|
|
|
`,17:`You passed an unsupported selector state to this method.
|
|
|
|
|
|
`,18:`minScreen and maxScreen must be provided as stringified numbers with the same units.
|
|
|
|
|
|
`,19:`fromSize and toSize must be provided as stringified numbers with the same units.
|
|
|
|
|
|
`,20:`expects either an array of objects or a single object with the properties prop, fromSize, and toSize.
|
|
|
|
|
|
`,21:"expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",22:"expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",23:`fontFace expects a name of a font-family.
|
|
|
|
|
|
`,24:`fontFace expects either the path to the font file(s) or a name of a local copy.
|
|
|
|
|
|
`,25:`fontFace expects localFonts to be an array.
|
|
|
|
|
|
`,26:`fontFace expects fileFormats to be an array.
|
|
|
|
|
|
`,27:`radialGradient requries at least 2 color-stops to properly render.
|
|
|
|
|
|
`,28:`Please supply a filename to retinaImage() as the first argument.
|
|
|
|
|
|
`,29:`Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.
|
|
|
|
|
|
`,30:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",31:`The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation
|
|
|
|
|
|
`,32:`To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])
|
|
|
To pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')
|
|
|
|
|
|
`,33:`The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation
|
|
|
|
|
|
`,34:`borderRadius expects a radius value as a string or number as the second argument.
|
|
|
|
|
|
`,35:`borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.
|
|
|
|
|
|
`,36:`Property must be a string value.
|
|
|
|
|
|
`,37:`Syntax Error at %s.
|
|
|
|
|
|
`,38:`Formula contains a function that needs parentheses at %s.
|
|
|
|
|
|
`,39:`Formula is missing closing parenthesis at %s.
|
|
|
|
|
|
`,40:`Formula has too many closing parentheses at %s.
|
|
|
|
|
|
`,41:`All values in a formula must have the same unit or be unitless.
|
|
|
|
|
|
`,42:`Please provide a number of steps to the modularScale helper.
|
|
|
|
|
|
`,43:`Please pass a number or one of the predefined scales to the modularScale helper as the ratio.
|
|
|
|
|
|
`,44:`Invalid value passed as base to modularScale, expected number or em/rem string but got %s.
|
|
|
|
|
|
`,45:`Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.
|
|
|
|
|
|
`,46:`Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.
|
|
|
|
|
|
`,47:`minScreen and maxScreen must be provided as stringified numbers with the same units.
|
|
|
|
|
|
`,48:`fromSize and toSize must be provided as stringified numbers with the same units.
|
|
|
|
|
|
`,49:`Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.
|
|
|
|
|
|
`,50:`Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.
|
|
|
|
|
|
`,51:`Expects the first argument object to have the properties prop, fromSize, and toSize.
|
|
|
|
|
|
`,52:`fontFace expects either the path to the font file(s) or a name of a local copy.
|
|
|
|
|
|
`,53:`fontFace expects localFonts to be an array.
|
|
|
|
|
|
`,54:`fontFace expects fileFormats to be an array.
|
|
|
|
|
|
`,55:`fontFace expects a name of a font-family.
|
|
|
|
|
|
`,56:`linearGradient requries at least 2 color-stops to properly render.
|
|
|
|
|
|
`,57:`radialGradient requries at least 2 color-stops to properly render.
|
|
|
|
|
|
`,58:`Please supply a filename to retinaImage() as the first argument.
|
|
|
|
|
|
`,59:`Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.
|
|
|
|
|
|
`,60:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",61:`Property must be a string value.
|
|
|
|
|
|
`,62:`borderRadius expects a radius value as a string or number as the second argument.
|
|
|
|
|
|
`,63:`borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.
|
|
|
|
|
|
`,64:`The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.
|
|
|
|
|
|
`,65:`To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').
|
|
|
|
|
|
`,66:`The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.
|
|
|
|
|
|
`,67:`You must provide a template to this method.
|
|
|
|
|
|
`,68:`You passed an unsupported selector state to this method.
|
|
|
|
|
|
`,69:`Expected a string ending in "px" or a number passed as the first argument to %s(), got %s instead.
|
|
|
|
|
|
`,70:`Expected a string ending in "px" or a number passed as the second argument to %s(), got %s instead.
|
|
|
|
|
|
`,71:`Passed invalid pixel value %s to %s(), please pass a value like "12px" or 12.
|
|
|
|
|
|
`,72:`Passed invalid base value %s to %s(), please pass a value like "12px" or 12.
|
|
|
|
|
|
`,73:`Please provide a valid CSS variable.
|
|
|
|
|
|
`,74:`CSS variable not found and no default was provided.
|
|
|
|
|
|
`,75:`important requires a valid style object, got a %s instead.
|
|
|
|
|
|
`,76:`fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.
|
|
|
|
|
|
`,77:`remToPx expects a value in "rem" but you provided it in "%s".
|
|
|
|
|
|
`,78:`base must be set in "px" or "%" but you set it in "%s".
|
|
|
`};function lK(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];var n=e[0],s=[],o;for(o=1;o<e.length;o+=1)s.push(e[o]);return s.forEach(function(a){n=n.replace(/%[a-z]/,a)}),n}var $r=function(i){l$(e,i);function e(t){var n;if(1)n=i.call(this,"An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#"+t+" for more information.")||this;else var s,o,a;return a$(n)}return e}(FT(Error)),vL=/((?!\w)a|na|hc|mc|dg|me[r]?|xe|ni(?![a-zA-Z])|mm|cp|tp|xp|q(?!s)|hv|xamv|nimv|wv|sm|s(?!\D|$)|ged|darg?|nrut)/g;function x$(i){var e={};return e.symbols=i?_extends({},yL.symbols,i.symbols):_extends({},yL.symbols),e}function xL(i,e){var t,n=i.pop();return e.push(n.f.apply(n,(t=[]).concat.apply(t,e.splice(-n.argCount)))),n.precedence}function _$(i,e){var t=x$(e),n,s=[t.symbols["("].prefix],o=[],a=new RegExp("\\d+(?:\\.\\d+)?|"+Object.keys(t.symbols).map(function(z){return t.symbols[z]}).sort(function(z,I){return I.symbol.length-z.symbol.length}).map(function(z){return z.regSymbol}).join("|")+"|(\\S)","g");a.lastIndex=0;var c=!1;do{n=a.exec(i);var u=n||[")",void 0],d=u[0],p=u[1],m=t.symbols[d],y=m&&!m.prefix&&!m.func,M=!m||!m.postfix&&!m.infix;if(p||(c?M:y))throw new $r(37,n?n.index:i.length,i);if(c){var T=m.postfix||m.infix;do{var G=s[s.length-1];if((T.precedence-G.precedence||G.rightToLeft)>0)break}while(xL(s,o));c=T.notation==="postfix",T.symbol!==")"&&(s.push(T),c&&xL(s,o))}else if(m){if(s.push(m.prefix||m.func),m.func&&(n=a.exec(i),!n||n[0]!=="("))throw new $r(38,n?n.index:i.length,i)}else o.push(+d),c=!0}while(n&&s.length);if(s.length)throw new $r(39,n?n.index:i.length,i);if(n)throw new $r(40,n?n.index:i.length,i);return o.pop()}function BT(i){return i.split("").reverse().join("")}function cK(i,e){var t=BT(i),n=t.match(vL);if(n&&!n.every(function(o){return o===n[0]}))throw new $r(41);var s=BT(t.replace(vL,""));return""+_$(s,e)+(n?BT(n[0]):"")}var b$=/--[\S]*/g;function uK(i,e){if(!i||!i.match(b$))throw new $r(73);var t;if(typeof document!="undefined"&&document.documentElement!==null&&(t=getComputedStyle(document.documentElement).getPropertyValue(i)),t)return t.trim();if(e)return e;throw new $r(74)}function Kv(i){return i.charAt(0).toUpperCase()+i.slice(1)}var w$=null;function M$(i,e){if(!i)return e.toLowerCase();var t=i.split("-");if(t.length>1)return t.splice(1,0,e),t.reduce(function(s,o){return""+s+Kv(o)});var n=i.replace(/([a-z])([A-Z])/g,"$1"+e+"$2");return i===n?""+i+e:n}function S$(i,e){for(var t={},n=0;n<e.length;n+=1)(e[n]||e[n]===0)&&(t[M$(i,w$[n])]=e[n]);return t}function Nm(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];var s=t[0],o=t[1],a=o===void 0?s:o,c=t[2],u=c===void 0?s:c,d=t[3],p=d===void 0?a:d,m=[s,a,u,p];return S$(i,m)}function _L(i,e){return i.substr(-e.length)===e}var T$=/^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;function bL(i){if(typeof i!="string")return i;var e=i.match(T$);return e?parseFloat(i):i}var E$=function(e){return function(t,n){n===void 0&&(n="16px");var s=t,o=n;if(typeof t=="string"){if(!_L(t,"px"))throw new $r(69,e,t);s=bL(t)}if(typeof n=="string"){if(!_L(n,"px"))throw new $r(70,e,n);o=bL(n)}if(typeof s=="string")throw new $r(71,t,e);if(typeof o=="string")throw new $r(72,n,e);return""+s/o+e}},wL=E$,hK=wL("em"),dK=null,A$=/^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;function qd(i){if(typeof i!="string")return[i,""];var e=i.match(A$);return e?[parseFloat(i),e[2]]:[i,void 0]}function C$(i,e){if(typeof i!="object"||i===null)throw new $r(75,typeof i);var t={};return Object.keys(i).forEach(function(n){typeof i[n]=="object"&&i[n]!==null?t[n]=C$(i[n],e):!e||e&&(e===n||e.indexOf(n)>=0)?t[n]=i[n]+" !important":t[n]=i[n]}),t}var ML={minorSecond:1.067,majorSecond:1.125,minorThird:1.2,majorThird:1.25,perfectFourth:1.333,augFourth:1.414,perfectFifth:1.5,minorSixth:1.6,goldenSection:1.618,majorSixth:1.667,minorSeventh:1.778,majorSeventh:1.875,octave:2,majorTenth:2.5,majorEleventh:2.667,majorTwelfth:3,doubleOctave:4};function R$(i){return ML[i]}function fK(i,e,t){if(e===void 0&&(e="1em"),t===void 0&&(t=1.333),typeof i!="number")throw new $r(42);if(typeof t=="string"&&!ML[t])throw new $r(43);var n=typeof e=="string"?qd(e):[e,""],s=n[0],o=n[1],a=typeof t=="string"?R$(t):t;if(typeof s=="string")throw new $r(44,e);return""+s*Math.pow(a,i)+(o||"")}var pK=wL("rem"),mK=null,UT=16;function SL(i){var e=qd(i);if(e[1]==="px")return parseFloat(i);if(e[1]==="%")return parseFloat(i)/100*UT;throw new $r(78,e[1])}function N$(){if(typeof document!="undefined"&&document.documentElement!==null){var i=getComputedStyle(document.documentElement).fontSize;return i?SL(i):UT}return UT}function gK(i,e){var t=qd(i);if(t[1]!=="rem"&&t[1]!=="")throw new $r(77,t[1]);var n=e?SL(e):N$();return t[0]*n+"px"}var P$={back:"cubic-bezier(0.600, -0.280, 0.735, 0.045)",circ:"cubic-bezier(0.600, 0.040, 0.980, 0.335)",cubic:"cubic-bezier(0.550, 0.055, 0.675, 0.190)",expo:"cubic-bezier(0.950, 0.050, 0.795, 0.035)",quad:"cubic-bezier(0.550, 0.085, 0.680, 0.530)",quart:"cubic-bezier(0.895, 0.030, 0.685, 0.220)",quint:"cubic-bezier(0.755, 0.050, 0.855, 0.060)",sine:"cubic-bezier(0.470, 0.000, 0.745, 0.715)"};function yK(i){return P$[i.toLowerCase().trim()]}var I$={back:"cubic-bezier(0.680, -0.550, 0.265, 1.550)",circ:"cubic-bezier(0.785, 0.135, 0.150, 0.860)",cubic:"cubic-bezier(0.645, 0.045, 0.355, 1.000)",expo:"cubic-bezier(1.000, 0.000, 0.000, 1.000)",quad:"cubic-bezier(0.455, 0.030, 0.515, 0.955)",quart:"cubic-bezier(0.770, 0.000, 0.175, 1.000)",quint:"cubic-bezier(0.860, 0.000, 0.070, 1.000)",sine:"cubic-bezier(0.445, 0.050, 0.550, 0.950)"};function vK(i){return I$[i.toLowerCase().trim()]}var L$={back:"cubic-bezier(0.175, 0.885, 0.320, 1.275)",cubic:"cubic-bezier(0.215, 0.610, 0.355, 1.000)",circ:"cubic-bezier(0.075, 0.820, 0.165, 1.000)",expo:"cubic-bezier(0.190, 1.000, 0.220, 1.000)",quad:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",quart:"cubic-bezier(0.165, 0.840, 0.440, 1.000)",quint:"cubic-bezier(0.230, 1.000, 0.320, 1.000)",sine:"cubic-bezier(0.390, 0.575, 0.565, 1.000)"};function xK(i){return L$[i.toLowerCase().trim()]}function TL(i,e,t,n){t===void 0&&(t="320px"),n===void 0&&(n="1200px");var s=qd(i),o=s[0],a=s[1],c=qd(e),u=c[0],d=c[1],p=qd(t),m=p[0],y=p[1],M=qd(n),T=M[0],G=M[1];if(typeof m!="number"||typeof T!="number"||!y||!G||y!==G)throw new $r(47);if(typeof o!="number"||typeof u!="number"||a!==d)throw new $r(48);if(a!==y||d!==G)throw new $r(76);var z=(o-u)/(m-T),I=u-z*T;return"calc("+I.toFixed(2)+(a||"")+" + "+(100*z).toFixed(2)+"vw)"}function _K(i){var e;i===void 0&&(i="&");var t=i+"::after";return e={},e[t]={clear:"both",content:'""',display:"table"},e}function bK(i){return i===void 0&&(i=0),{position:"absolute",top:i,right:i,bottom:i,left:i}}function wK(i,e){e===void 0&&(e=1);var t={display:"inline-block",maxWidth:i||"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",wordWrap:"normal"};return e>1?_extends({},t,{WebkitBoxOrient:"vertical",WebkitLineClamp:e,display:"-webkit-box",whiteSpace:"normal"}):t}function D$(i,e){var t=typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t)return(t=t.call(i)).next.bind(t);if(Array.isArray(i)||(t=O$(i))||e&&i&&typeof i.length=="number"){t&&(i=t);var n=0;return function(){return n>=i.length?{done:!0}:{done:!1,value:i[n++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function O$(i,e){if(i){if(typeof i=="string")return EL(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(i);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return EL(i,e)}}function EL(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=i[t];return n}function MK(i,e,t){if(e===void 0&&(e="320px"),t===void 0&&(t="1200px"),!Array.isArray(i)&&typeof i!="object"||i===null)throw new $r(49);if(Array.isArray(i)){for(var n={},s={},o=D$(i),a;!(a=o()).done;){var c,u,d=a.value;if(!d.prop||!d.fromSize||!d.toSize)throw new $r(50);s[d.prop]=d.fromSize,n["@media (min-width: "+e+")"]=_extends({},n["@media (min-width: "+e+")"],(c={},c[d.prop]=TL(d.fromSize,d.toSize,e,t),c)),n["@media (min-width: "+t+")"]=_extends({},n["@media (min-width: "+t+")"],(u={},u[d.prop]=d.toSize,u))}return _extends({},s,n)}else{var p,m,y;if(!i.prop||!i.fromSize||!i.toSize)throw new $r(51);return y={},y[i.prop]=i.fromSize,y["@media (min-width: "+e+")"]=(p={},p[i.prop]=TL(i.fromSize,i.toSize,e,t),p),y["@media (min-width: "+t+")"]=(m={},m[i.prop]=i.toSize,m),y}}var F$=/^\s*data:([a-z]+\/[a-z-]+(;[a-z-]+=[a-z-]+)?)?(;charset=[a-z0-9-]+)?(;base64)?,[a-z0-9!$&',()*+,;=\-._~:@/?%\s]*\s*$/i,B$={woff:"woff",woff2:"woff2",ttf:"truetype",otf:"opentype",eot:"embedded-opentype",svg:"svg",svgz:"svg"};function AL(i,e){return e?' format("'+B$[i]+'")':""}function U$(i){return!!i.replace(/\s+/g," ").match(F$)}function k$(i,e,t){if(U$(i))return'url("'+i+'")'+AL(e[0],t);var n=e.map(function(s){return'url("'+i+"."+s+'")'+AL(s,t)});return n.join(", ")}function z$(i){var e=i.map(function(t){return'local("'+t+'")'});return e.join(", ")}function V$(i,e,t,n){var s=[];return e&&s.push(z$(e)),i&&s.push(k$(i,t,n)),s.join(", ")}function SK(i){var e=i.fontFamily,t=i.fontFilePath,n=i.fontStretch,s=i.fontStyle,o=i.fontVariant,a=i.fontWeight,c=i.fileFormats,u=c===void 0?["eot","woff2","woff","ttf","svg"]:c,d=i.formatHint,p=d===void 0?!1:d,m=i.localFonts,y=m===void 0?[e]:m,M=i.unicodeRange,T=i.fontDisplay,G=i.fontVariationSettings,z=i.fontFeatureSettings;if(!e)throw new $r(55);if(!t&&!y)throw new $r(52);if(y&&!Array.isArray(y))throw new $r(53);if(!Array.isArray(u))throw new $r(54);var I={"@font-face":{fontFamily:e,src:V$(t,y,u,p),unicodeRange:M,fontStretch:n,fontStyle:s,fontVariant:o,fontWeight:a,fontDisplay:T,fontVariationSettings:G,fontFeatureSettings:z}};return JSON.parse(JSON.stringify(I))}function TK(){return{textIndent:"101%",overflow:"hidden",whiteSpace:"nowrap"}}function EK(){return{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",whiteSpace:"nowrap",width:"1px"}}function G$(i){return i===void 0&&(i=1.3),`
|
|
|
@media only screen and (-webkit-min-device-pixel-ratio: `+i+`),
|
|
|
only screen and (min--moz-device-pixel-ratio: `+i+`),
|
|
|
only screen and (-o-min-device-pixel-ratio: `+i+`/1),
|
|
|
only screen and (min-resolution: `+Math.round(i*96)+`dpi),
|
|
|
only screen and (min-resolution: `+i+`dppx)
|
|
|
`}function CL(i){for(var e="",t=arguments.length,n=new Array(t>1?t-1:0),s=1;s<t;s++)n[s-1]=arguments[s];for(var o=0;o<i.length;o+=1)if(e+=i[o],o===n.length-1&&n[o]){var a=n.filter(function(c){return!!c});a.length>1?(e=e.slice(0,-1),e+=", "+n[o]):a.length===1&&(e+=""+n[o])}else n[o]&&(e+=n[o]+" ");return e.trim()}var RL;function AK(i){var e=i.colorStops,t=i.fallback,n=i.toDirection,s=n===void 0?"":n;if(!e||e.length<2)throw new $r(56);return{backgroundColor:t||e[0].replace(/,\s+/g,",").split(" ")[0].replace(/,(?=\S)/g,", "),backgroundImage:CL(RL||(RL=_taggedTemplateLiteralLoose(["linear-gradient(","",")"])),s,e.join(", ").replace(/,(?=\S)/g,", "))}}function CK(){var i;return[(i={html:{lineHeight:"1.15",textSizeAdjust:"100%"},body:{margin:"0"},main:{display:"block"},h1:{fontSize:"2em",margin:"0.67em 0"},hr:{boxSizing:"content-box",height:"0",overflow:"visible"},pre:{fontFamily:"monospace, monospace",fontSize:"1em"},a:{backgroundColor:"transparent"},"abbr[title]":{borderBottom:"none",textDecoration:"underline"}},i[`b,
|
|
|
strong`]={fontWeight:"bolder"},i[`code,
|
|
|
kbd,
|
|
|
samp`]={fontFamily:"monospace, monospace",fontSize:"1em"},i.small={fontSize:"80%"},i[`sub,
|
|
|
sup`]={fontSize:"75%",lineHeight:"0",position:"relative",verticalAlign:"baseline"},i.sub={bottom:"-0.25em"},i.sup={top:"-0.5em"},i.img={borderStyle:"none"},i[`button,
|
|
|
input,
|
|
|
optgroup,
|
|
|
select,
|
|
|
textarea`]={fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15",margin:"0"},i[`button,
|
|
|
input`]={overflow:"visible"},i[`button,
|
|
|
select`]={textTransform:"none"},i[`button,
|
|
|
html [type="button"],
|
|
|
[type="reset"],
|
|
|
[type="submit"]`]={WebkitAppearance:"button"},i[`button::-moz-focus-inner,
|
|
|
[type="button"]::-moz-focus-inner,
|
|
|
[type="reset"]::-moz-focus-inner,
|
|
|
[type="submit"]::-moz-focus-inner`]={borderStyle:"none",padding:"0"},i[`button:-moz-focusring,
|
|
|
[type="button"]:-moz-focusring,
|
|
|
[type="reset"]:-moz-focusring,
|
|
|
[type="submit"]:-moz-focusring`]={outline:"1px dotted ButtonText"},i.fieldset={padding:"0.35em 0.625em 0.75em"},i.legend={boxSizing:"border-box",color:"inherit",display:"table",maxWidth:"100%",padding:"0",whiteSpace:"normal"},i.progress={verticalAlign:"baseline"},i.textarea={overflow:"auto"},i[`[type="checkbox"],
|
|
|
[type="radio"]`]={boxSizing:"border-box",padding:"0"},i[`[type="number"]::-webkit-inner-spin-button,
|
|
|
[type="number"]::-webkit-outer-spin-button`]={height:"auto"},i['[type="search"]']={WebkitAppearance:"textfield",outlineOffset:"-2px"},i['[type="search"]::-webkit-search-decoration']={WebkitAppearance:"none"},i["::-webkit-file-upload-button"]={WebkitAppearance:"button",font:"inherit"},i.details={display:"block"},i.summary={display:"list-item"},i.template={display:"none"},i["[hidden]"]={display:"none"},i),{"abbr[title]":{textDecoration:"underline dotted"}}]}var NL;function RK(i){var e=i.colorStops,t=i.extent,n=t===void 0?"":t,s=i.fallback,o=i.position,a=o===void 0?"":o,c=i.shape,u=c===void 0?"":c;if(!e||e.length<2)throw new $r(57);return{backgroundColor:s||e[0].split(" ")[0],backgroundImage:CL(NL||(NL=_taggedTemplateLiteralLoose(["radial-gradient(","","","",")"])),a,u,n,e.join(", "))}}function NK(i,e,t,n,s){var o;if(t===void 0&&(t="png"),s===void 0&&(s="_2x"),!i)throw new $r(58);var a=t.replace(/^\./,""),c=n?n+"."+a:""+i+s+"."+a;return o={backgroundImage:"url("+i+"."+a+")"},o[G$()]=_extends({backgroundImage:"url("+c+")"},e?{backgroundSize:e}:{}),o}var W$={easeInBack:"cubic-bezier(0.600, -0.280, 0.735, 0.045)",easeInCirc:"cubic-bezier(0.600, 0.040, 0.980, 0.335)",easeInCubic:"cubic-bezier(0.550, 0.055, 0.675, 0.190)",easeInExpo:"cubic-bezier(0.950, 0.050, 0.795, 0.035)",easeInQuad:"cubic-bezier(0.550, 0.085, 0.680, 0.530)",easeInQuart:"cubic-bezier(0.895, 0.030, 0.685, 0.220)",easeInQuint:"cubic-bezier(0.755, 0.050, 0.855, 0.060)",easeInSine:"cubic-bezier(0.470, 0.000, 0.745, 0.715)",easeOutBack:"cubic-bezier(0.175, 0.885, 0.320, 1.275)",easeOutCubic:"cubic-bezier(0.215, 0.610, 0.355, 1.000)",easeOutCirc:"cubic-bezier(0.075, 0.820, 0.165, 1.000)",easeOutExpo:"cubic-bezier(0.190, 1.000, 0.220, 1.000)",easeOutQuad:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",easeOutQuart:"cubic-bezier(0.165, 0.840, 0.440, 1.000)",easeOutQuint:"cubic-bezier(0.230, 1.000, 0.320, 1.000)",easeOutSine:"cubic-bezier(0.390, 0.575, 0.565, 1.000)",easeInOutBack:"cubic-bezier(0.680, -0.550, 0.265, 1.550)",easeInOutCirc:"cubic-bezier(0.785, 0.135, 0.150, 0.860)",easeInOutCubic:"cubic-bezier(0.645, 0.045, 0.355, 1.000)",easeInOutExpo:"cubic-bezier(1.000, 0.000, 0.000, 1.000)",easeInOutQuad:"cubic-bezier(0.455, 0.030, 0.515, 0.955)",easeInOutQuart:"cubic-bezier(0.770, 0.000, 0.175, 1.000)",easeInOutQuint:"cubic-bezier(0.860, 0.000, 0.070, 1.000)",easeInOutSine:"cubic-bezier(0.445, 0.050, 0.550, 0.950)"};function H$(i){return W$[i]}function PK(i){return H$(i)}var $$=function(e,t,n){var s=""+n[0]+(n[1]||""),o=""+n[0]/2+(n[1]||""),a=""+t[0]+(t[1]||""),c=""+t[0]/2+(t[1]||"");switch(e){case"top":return"0 "+o+" "+a+" "+o;case"topLeft":return s+" "+a+" 0 0";case"left":return c+" "+s+" "+c+" 0";case"bottomLeft":return s+" 0 0 "+a;case"bottom":return a+" "+o+" 0 "+o;case"bottomRight":return"0 0 "+s+" "+a;case"right":return c+" 0 "+c+" "+s;case"topRight":default:return"0 "+s+" "+a+" 0"}},j$=function(e,t){switch(e){case"top":case"bottomRight":return{borderBottomColor:t};case"right":case"bottomLeft":return{borderLeftColor:t};case"bottom":case"topLeft":return{borderTopColor:t};case"left":case"topRight":return{borderRightColor:t};default:throw new $r(59)}};function IK(i){var e=i.pointingDirection,t=i.height,n=i.width,s=i.foregroundColor,o=i.backgroundColor,a=o===void 0?"transparent":o,c=qd(n),u=qd(t);if(isNaN(u[0])||isNaN(c[0]))throw new $r(60);return _extends({width:"0",height:"0",borderColor:a},j$(e,s),{borderStyle:"solid",borderWidth:$$(e,u,c)})}function LK(i){i===void 0&&(i="break-word");var e=i==="break-word"?"break-all":i;return{overflowWrap:i,wordWrap:i,wordBreak:e}}function kT(i){return Math.round(i*255)}function X$(i,e,t){return kT(i)+","+kT(e)+","+kT(t)}function Jv(i,e,t,n){if(n===void 0&&(n=X$),e===0)return n(t,t,t);var s=(i%360+360)%360/60,o=(1-Math.abs(2*t-1))*e,a=o*(1-Math.abs(s%2-1)),c=0,u=0,d=0;s>=0&&s<1?(c=o,u=a):s>=1&&s<2?(c=a,u=o):s>=2&&s<3?(u=o,d=a):s>=3&&s<4?(u=a,d=o):s>=4&&s<5?(c=a,d=o):s>=5&&s<6&&(c=o,d=a);var p=t-o/2,m=c+p,y=u+p,M=d+p;return n(m,y,M)}var PL={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};function q$(i){if(typeof i!="string")return i;var e=i.toLowerCase();return PL[e]?"#"+PL[e]:i}var Y$=/^#[a-fA-F0-9]{6}$/,Z$=/^#[a-fA-F0-9]{8}$/,K$=/^#[a-fA-F0-9]{3}$/,J$=/^#[a-fA-F0-9]{4}$/,zT=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,Q$=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,ej=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,tj=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function Yd(i){if(typeof i!="string")throw new $r(3);var e=q$(i);if(e.match(Y$))return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16)};if(e.match(Z$)){var t=parseFloat((parseInt(""+e[7]+e[8],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16),alpha:t}}if(e.match(K$))return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16)};if(e.match(J$)){var n=parseFloat((parseInt(""+e[4]+e[4],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16),alpha:n}}var s=zT.exec(e);if(s)return{red:parseInt(""+s[1],10),green:parseInt(""+s[2],10),blue:parseInt(""+s[3],10)};var o=Q$.exec(e.substring(0,50));if(o)return{red:parseInt(""+o[1],10),green:parseInt(""+o[2],10),blue:parseInt(""+o[3],10),alpha:parseFloat(""+o[4])>1?parseFloat(""+o[4])/100:parseFloat(""+o[4])};var a=ej.exec(e);if(a){var c=parseInt(""+a[1],10),u=parseInt(""+a[2],10)/100,d=parseInt(""+a[3],10)/100,p="rgb("+Jv(c,u,d)+")",m=zT.exec(p);if(!m)throw new $r(4,e,p);return{red:parseInt(""+m[1],10),green:parseInt(""+m[2],10),blue:parseInt(""+m[3],10)}}var y=tj.exec(e.substring(0,50));if(y){var M=parseInt(""+y[1],10),T=parseInt(""+y[2],10)/100,G=parseInt(""+y[3],10)/100,z="rgb("+Jv(M,T,G)+")",I=zT.exec(z);if(!I)throw new $r(4,e,z);return{red:parseInt(""+I[1],10),green:parseInt(""+I[2],10),blue:parseInt(""+I[3],10),alpha:parseFloat(""+y[4])>1?parseFloat(""+y[4])/100:parseFloat(""+y[4])}}throw new $r(5)}function nj(i){var e=i.red/255,t=i.green/255,n=i.blue/255,s=Math.max(e,t,n),o=Math.min(e,t,n),a=(s+o)/2;if(s===o)return i.alpha!==void 0?{hue:0,saturation:0,lightness:a,alpha:i.alpha}:{hue:0,saturation:0,lightness:a};var c,u=s-o,d=a>.5?u/(2-s-o):u/(s+o);switch(s){case e:c=(t-n)/u+(t<n?6:0);break;case t:c=(n-e)/u+2;break;default:c=(e-t)/u+4;break}return c*=60,i.alpha!==void 0?{hue:c,saturation:d,lightness:a,alpha:i.alpha}:{hue:c,saturation:d,lightness:a}}function qh(i){return nj(Yd(i))}var ij=function(e){return e.length===7&&e[1]===e[2]&&e[3]===e[4]&&e[5]===e[6]?"#"+e[1]+e[3]+e[5]:e},VT=ij;function Pm(i){var e=i.toString(16);return e.length===1?"0"+e:e}function GT(i){return Pm(Math.round(i*255))}function rj(i,e,t){return VT("#"+GT(i)+GT(e)+GT(t))}function qb(i,e,t){return Jv(i,e,t,rj)}function IL(i,e,t){if(typeof i=="number"&&typeof e=="number"&&typeof t=="number")return qb(i,e,t);if(typeof i=="object"&&e===void 0&&t===void 0)return qb(i.hue,i.saturation,i.lightness);throw new $r(1)}function LL(i,e,t,n){if(typeof i=="number"&&typeof e=="number"&&typeof t=="number"&&typeof n=="number")return n>=1?qb(i,e,t):"rgba("+Jv(i,e,t)+","+n+")";if(typeof i=="object"&&e===void 0&&t===void 0&&n===void 0)return i.alpha>=1?qb(i.hue,i.saturation,i.lightness):"rgba("+Jv(i.hue,i.saturation,i.lightness)+","+i.alpha+")";throw new $r(2)}function Yb(i,e,t){if(typeof i=="number"&&typeof e=="number"&&typeof t=="number")return VT("#"+Pm(i)+Pm(e)+Pm(t));if(typeof i=="object"&&e===void 0&&t===void 0)return VT("#"+Pm(i.red)+Pm(i.green)+Pm(i.blue));throw new $r(6)}function Qv(i,e,t,n){if(typeof i=="string"&&typeof e=="number"){var s=Yd(i);return"rgba("+s.red+","+s.green+","+s.blue+","+e+")"}else{if(typeof i=="number"&&typeof e=="number"&&typeof t=="number"&&typeof n=="number")return n>=1?Yb(i,e,t):"rgba("+i+","+e+","+t+","+n+")";if(typeof i=="object"&&e===void 0&&t===void 0&&n===void 0)return i.alpha>=1?Yb(i.red,i.green,i.blue):"rgba("+i.red+","+i.green+","+i.blue+","+i.alpha+")"}throw new $r(7)}var sj=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&(typeof e.alpha!="number"||typeof e.alpha=="undefined")},oj=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&typeof e.alpha=="number"},aj=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&(typeof e.alpha!="number"||typeof e.alpha=="undefined")},lj=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&typeof e.alpha=="number"};function uh(i){if(typeof i!="object")throw new $r(8);if(oj(i))return Qv(i);if(sj(i))return Yb(i);if(lj(i))return LL(i);if(aj(i))return IL(i);throw new $r(8)}function DL(i,e,t){return function(){var s=t.concat(Array.prototype.slice.call(arguments));return s.length>=e?i.apply(this,s):DL(i,e,s)}}function tu(i){return DL(i,i.length,[])}function cj(i,e){if(e==="transparent")return e;var t=qh(e);return uh(Pc({},t,{hue:t.hue+parseFloat(i)}))}var DK=tu(cj),OK=null;function FK(i){if(i==="transparent")return i;var e=qh(i);return uh(_extends({},e,{hue:(e.hue+180)%360}))}function x0(i,e,t){return Math.max(i,Math.min(e,t))}function uj(i,e){if(e==="transparent")return e;var t=qh(e);return uh(Pc({},t,{lightness:x0(0,1,t.lightness-parseFloat(i))}))}var BK=tu(uj),UK=null;function hj(i,e){if(e==="transparent")return e;var t=qh(e);return uh(Pc({},t,{saturation:x0(0,1,t.saturation-parseFloat(i))}))}var kK=tu(hj),zK=null;function WT(i){if(i==="transparent")return 0;var e=Yd(i),t=Object.keys(e).map(function(a){var c=e[a]/255;return c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4)}),n=t[0],s=t[1],o=t[2];return parseFloat((.2126*n+.7152*s+.0722*o).toFixed(3))}function OL(i,e){var t=WT(i),n=WT(e);return parseFloat((t>n?(t+.05)/(n+.05):(n+.05)/(t+.05)).toFixed(2))}function VK(i){return i==="transparent"?i:uh(_extends({},qh(i),{saturation:0}))}function GK(i){if(typeof i=="object"&&typeof i.hue=="number"&&typeof i.saturation=="number"&&typeof i.lightness=="number")return i.alpha&&typeof i.alpha=="number"?LL({hue:i.hue,saturation:i.saturation,lightness:i.lightness,alpha:i.alpha}):IL({hue:i.hue,saturation:i.saturation,lightness:i.lightness});throw new $r(45)}function WK(i){if(i==="transparent")return i;var e=Yd(i);return uh(_extends({},e,{red:255-e.red,green:255-e.green,blue:255-e.blue}))}function dj(i,e){if(e==="transparent")return e;var t=qh(e);return uh(Pc({},t,{lightness:x0(0,1,t.lightness+parseFloat(i))}))}var HK=tu(dj),$K=null;function jK(i,e){var t=OL(i,e);return{AA:t>=4.5,AALarge:t>=3,AAA:t>=7,AAALarge:t>=4.5}}function fj(i,e,t){if(e==="transparent")return t;if(t==="transparent")return e;if(i===0)return t;var n=Yd(e),s=Pc({},n,{alpha:typeof n.alpha=="number"?n.alpha:1}),o=Yd(t),a=Pc({},o,{alpha:typeof o.alpha=="number"?o.alpha:1}),c=s.alpha-a.alpha,u=parseFloat(i)*2-1,d=u*c===-1?u:u+c,p=1+u*c,m=(d/p+1)/2,y=1-m,M={red:Math.floor(s.red*m+a.red*y),green:Math.floor(s.green*m+a.green*y),blue:Math.floor(s.blue*m+a.blue*y),alpha:s.alpha*parseFloat(i)+a.alpha*(1-parseFloat(i))};return Qv(M)}var pj=tu(fj),FL=pj;function mj(i,e){if(e==="transparent")return e;var t=Yd(e),n=typeof t.alpha=="number"?t.alpha:1,s=Pc({},t,{alpha:x0(0,1,(n*100+parseFloat(i)*100)/100)});return Qv(s)}var gj=tu(mj),yj=gj,BL="#000",UL="#fff";function XK(i,e,t,n){e===void 0&&(e=BL),t===void 0&&(t=UL),n===void 0&&(n=!0);var s=WT(i)>.179,o=s?e:t;return!n||OL(i,o)>=4.5?o:s?BL:UL}function qK(i){if(typeof i=="object"&&typeof i.red=="number"&&typeof i.green=="number"&&typeof i.blue=="number")return typeof i.alpha=="number"?Qv({red:i.red,green:i.green,blue:i.blue,alpha:i.alpha}):Yb({red:i.red,green:i.green,blue:i.blue});throw new $r(46)}function vj(i,e){if(e==="transparent")return e;var t=qh(e);return uh(Pc({},t,{saturation:x0(0,1,t.saturation+parseFloat(i))}))}var YK=tu(vj),ZK=null;function xj(i,e){return e==="transparent"?e:uh(Pc({},qh(e),{hue:parseFloat(i)}))}var KK=tu(xj),JK=null;function _j(i,e){return e==="transparent"?e:uh(Pc({},qh(e),{lightness:parseFloat(i)}))}var QK=tu(_j),eJ=null;function bj(i,e){return e==="transparent"?e:uh(Pc({},qh(e),{saturation:parseFloat(i)}))}var tJ=tu(bj),nJ=null;function wj(i,e){return e==="transparent"?e:FL(parseFloat(i),"rgb(0, 0, 0)",e)}var iJ=tu(wj),rJ=null;function Mj(i,e){return e==="transparent"?e:FL(parseFloat(i),"rgb(255, 255, 255)",e)}var sJ=tu(Mj),oJ=null;function Sj(i,e){if(e==="transparent")return e;var t=Yd(e),n=typeof t.alpha=="number"?t.alpha:1,s=Pc({},t,{alpha:x0(0,1,+(n*100-parseFloat(i)*100).toFixed(2)/100)});return Qv(s)}var aJ=tu(Sj),lJ=null;function cJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];var n=Array.isArray(e[0]);if(!n&&e.length>8)throw new $r(64);var s=e.map(function(o){if(n&&!Array.isArray(o)||!n&&Array.isArray(o))throw new $r(65);if(Array.isArray(o)&&o.length>8)throw new $r(66);return Array.isArray(o)?o.join(" "):o}).join(", ");return{animation:s}}function uJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return{backgroundImage:e.join(", ")}}function hJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return{background:e.join(", ")}}var Tj=null;function dJ(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];if(typeof i=="string"&&Tj.indexOf(i)>=0){var s;return s={},s["border"+Kv(i)+"Width"]=t[0],s["border"+Kv(i)+"Style"]=t[1],s["border"+Kv(i)+"Color"]=t[2],s}else return t.unshift(i),{borderWidth:t[0],borderStyle:t[1],borderColor:t[2]}}function fJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return Nm.apply(void 0,["borderColor"].concat(e))}function pJ(i,e){var t=Kv(i);if(!e&&e!==0)throw new $r(62);if(t==="Top"||t==="Bottom"){var n;return n={},n["border"+t+"RightRadius"]=e,n["border"+t+"LeftRadius"]=e,n}if(t==="Left"||t==="Right"){var s;return s={},s["borderTop"+t+"Radius"]=e,s["borderBottom"+t+"Radius"]=e,s}throw new $r(63)}function mJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return Nm.apply(void 0,["borderStyle"].concat(e))}function gJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return Nm.apply(void 0,["borderWidth"].concat(e))}function kL(i,e){var t=e?":"+e:"";return i(t)}function zL(i,e,t){if(!e)throw new $r(67);if(i.length===0)return kL(e,null);for(var n=[],s=0;s<i.length;s+=1){if(t&&t.indexOf(i[s])<0)throw new $r(68);n.push(kL(e,i[s]))}return n=n.join(","),n}var Ej=null;function Aj(i){return"button"+i+`,
|
|
|
input[type="button"]`+i+`,
|
|
|
input[type="reset"]`+i+`,
|
|
|
input[type="submit"]`+i}function yJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return zL(e,Aj,Ej)}function vJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return Nm.apply(void 0,["margin"].concat(e))}function xJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return Nm.apply(void 0,["padding"].concat(e))}var Cj=null;function _J(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];return Cj.indexOf(i)>=0&&i?_extends({},Nm.apply(void 0,[""].concat(t)),{position:i}):Nm.apply(void 0,["",i].concat(t))}function bJ(i,e){return e===void 0&&(e=i),{height:i,width:e}}var Rj=null;function Nj(i){return'input[type="color"]'+i+`,
|
|
|
input[type="date"]`+i+`,
|
|
|
input[type="datetime"]`+i+`,
|
|
|
input[type="datetime-local"]`+i+`,
|
|
|
input[type="email"]`+i+`,
|
|
|
input[type="month"]`+i+`,
|
|
|
input[type="number"]`+i+`,
|
|
|
input[type="password"]`+i+`,
|
|
|
input[type="search"]`+i+`,
|
|
|
input[type="tel"]`+i+`,
|
|
|
input[type="text"]`+i+`,
|
|
|
input[type="time"]`+i+`,
|
|
|
input[type="url"]`+i+`,
|
|
|
input[type="week"]`+i+`,
|
|
|
input:not([type])`+i+`,
|
|
|
textarea`+i}function wJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return zL(e,Nj,Rj)}function MJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];if(Array.isArray(e[0])&&e.length===2){var n=e[1];if(typeof n!="string")throw new $r(61);var s=e[0].map(function(o){return o+" "+n}).join(", ");return{transition:s}}else return{transition:e.join(", ")}}var np=Object.freeze({Linear:Object.freeze({None:function(i){return i},In:function(i){return i},Out:function(i){return i},InOut:function(i){return i}}),Quadratic:Object.freeze({In:function(i){return i*i},Out:function(i){return i*(2-i)},InOut:function(i){return(i*=2)<1?.5*i*i:-.5*(--i*(i-2)-1)}}),Cubic:Object.freeze({In:function(i){return i*i*i},Out:function(i){return--i*i*i+1},InOut:function(i){return(i*=2)<1?.5*i*i*i:.5*((i-=2)*i*i+2)}}),Quartic:Object.freeze({In:function(i){return i*i*i*i},Out:function(i){return 1- --i*i*i*i},InOut:function(i){return(i*=2)<1?.5*i*i*i*i:-.5*((i-=2)*i*i*i-2)}}),Quintic:Object.freeze({In:function(i){return i*i*i*i*i},Out:function(i){return--i*i*i*i*i+1},InOut:function(i){return(i*=2)<1?.5*i*i*i*i*i:.5*((i-=2)*i*i*i*i+2)}}),Sinusoidal:Object.freeze({In:function(i){return 1-Math.sin((1-i)*Math.PI/2)},Out:function(i){return Math.sin(i*Math.PI/2)},InOut:function(i){return .5*(1-Math.sin(Math.PI*(.5-i)))}}),Exponential:Object.freeze({In:function(i){return i===0?0:Math.pow(1024,i-1)},Out:function(i){return i===1?1:1-Math.pow(2,-10*i)},InOut:function(i){return i===0?0:i===1?1:(i*=2)<1?.5*Math.pow(1024,i-1):.5*(-Math.pow(2,-10*(i-1))+2)}}),Circular:Object.freeze({In:function(i){return 1-Math.sqrt(1-i*i)},Out:function(i){return Math.sqrt(1- --i*i)},InOut:function(i){return(i*=2)<1?-.5*(Math.sqrt(1-i*i)-1):.5*(Math.sqrt(1-(i-=2)*i)+1)}}),Elastic:Object.freeze({In:function(i){return i===0?0:i===1?1:-Math.pow(2,10*(i-1))*Math.sin((i-1.1)*5*Math.PI)},Out:function(i){return i===0?0:i===1?1:Math.pow(2,-10*i)*Math.sin((i-.1)*5*Math.PI)+1},InOut:function(i){return i===0?0:i===1?1:(i*=2,i<1?-.5*Math.pow(2,10*(i-1))*Math.sin((i-1.1)*5*Math.PI):.5*Math.pow(2,-10*(i-1))*Math.sin((i-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(i){var e=1.70158;return i===1?1:i*i*((e+1)*i-e)},Out:function(i){var e=1.70158;return i===0?0:--i*i*((e+1)*i+e)+1},InOut:function(i){var e=2.5949095;return(i*=2)<1?.5*(i*i*((e+1)*i-e)):.5*((i-=2)*i*((e+1)*i+e)+2)}}),Bounce:Object.freeze({In:function(i){return 1-np.Bounce.Out(1-i)},Out:function(i){return i<1/2.75?7.5625*i*i:i<2/2.75?7.5625*(i-=1.5/2.75)*i+.75:i<2.5/2.75?7.5625*(i-=2.25/2.75)*i+.9375:7.5625*(i-=2.625/2.75)*i+.984375},InOut:function(i){return i<.5?np.Bounce.In(i*2)*.5:np.Bounce.Out(i*2-1)*.5+.5}}),generatePow:function(i){return i===void 0&&(i=4),i=i<Number.EPSILON?Number.EPSILON:i,i=i>1e4?1e4:i,{In:function(e){return Math.pow(e,i)},Out:function(e){return 1-Math.pow(1-e,i)},InOut:function(e){return e<.5?Math.pow(e*2,i)/2:(1-Math.pow(2-e*2,i))/2+.5}}}}),_0=function(){return performance.now()},HT=function(){function i(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._tweens={},this._tweensAddedDuringUpdate={},this.add.apply(this,e)}return i.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},i.prototype.removeAll=function(){this._tweens={}},i.prototype.add=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var s=0,o=t;s<o.length;s++){var a=o[s];(e=a._group)===null||e===void 0||e.remove(a),a._group=this,this._tweens[a.getId()]=a,this._tweensAddedDuringUpdate[a.getId()]=a}},i.prototype.remove=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=0,s=e;n<s.length;n++){var o=s[n];o._group=void 0,delete this._tweens[o.getId()],delete this._tweensAddedDuringUpdate[o.getId()]}},i.prototype.allStopped=function(){return this.getAll().every(function(e){return!e.isPlaying()})},i.prototype.update=function(e,t){e===void 0&&(e=_0()),t===void 0&&(t=!0);var n=Object.keys(this._tweens);if(n.length!==0)for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var s=0;s<n.length;s++){var o=this._tweens[n[s]],a=!t;o&&o.update(e,a)===!1&&!t&&this.remove(o)}n=Object.keys(this._tweensAddedDuringUpdate)}},i}(),Im={Linear:function(i,e){var t=i.length-1,n=t*e,s=Math.floor(n),o=Im.Utils.Linear;return e<0?o(i[0],i[1],n):e>1?o(i[t],i[t-1],t-n):o(i[s],i[s+1>t?t:s+1],n-s)},Bezier:function(i,e){for(var t=0,n=i.length-1,s=Math.pow,o=Im.Utils.Bernstein,a=0;a<=n;a++)t+=s(1-e,n-a)*s(e,a)*i[a]*o(n,a);return t},CatmullRom:function(i,e){var t=i.length-1,n=t*e,s=Math.floor(n),o=Im.Utils.CatmullRom;return i[0]===i[t]?(e<0&&(s=Math.floor(n=t*(1+e))),o(i[(s-1+t)%t],i[s],i[(s+1)%t],i[(s+2)%t],n-s)):e<0?i[0]-(o(i[0],i[0],i[1],i[1],-n)-i[0]):e>1?i[t]-(o(i[t],i[t],i[t-1],i[t-1],n-t)-i[t]):o(i[s?s-1:0],i[s],i[t<s+1?t:s+1],i[t<s+2?t:s+2],n-s)},Utils:{Linear:function(i,e,t){return(e-i)*t+i},Bernstein:function(i,e){var t=Im.Utils.Factorial;return t(i)/t(e)/t(i-e)},Factorial:function(){var i=[1];return function(e){var t=1;if(i[e])return i[e];for(var n=e;n>1;n--)t*=n;return i[e]=t,t}}(),CatmullRom:function(i,e,t,n,s){var o=(t-i)*.5,a=(n-e)*.5,c=s*s,u=s*c;return(2*e-2*t+o+a)*u+(-3*e+3*t-2*o-a)*c+o*s+e}}},$T=function(){function i(){}return i.nextId=function(){return i._nextId++},i._nextId=0,i}(),jT=new HT,XT=function(){function i(e,t){this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=np.Linear.None,this._interpolationFunction=Im.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=$T.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1,this._object=e,typeof t=="object"?(this._group=t,t.add(this)):t===!0&&(this._group=jT,jT.add(this))}return i.prototype.getId=function(){return this._id},i.prototype.isPlaying=function(){return this._isPlaying},i.prototype.isPaused=function(){return this._isPaused},i.prototype.getDuration=function(){return this._duration},i.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},i.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},i.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},i.prototype.start=function(e,t){if(e===void 0&&(e=_0()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var s={};for(var o in this._valuesEnd)s[o]=this._valuesEnd[o];this._valuesEnd=s}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},i.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},i.prototype._setupProperties=function(e,t,n,s,o){for(var a in n){var c=e[a],u=Array.isArray(c),d=u?"array":typeof c,p=!u&&Array.isArray(n[a]);if(!(d==="undefined"||d==="function")){if(p){var m=n[a];if(m.length===0)continue;for(var y=[c],M=0,T=m.length;M<T;M+=1){var G=this._handleRelativeValue(c,m[M]);if(isNaN(G)){p=!1,console.warn("Found invalid interpolation list. Skipping.");break}y.push(G)}p&&(n[a]=y)}if((d==="object"||u)&&c&&!p){t[a]=u?[]:{};var z=c;for(var I in z)t[a][I]=z[I];s[a]=u?[]:{};var m=n[a];if(!this._isDynamic){var J={};for(var I in m)J[I]=m[I];n[a]=m=J}this._setupProperties(z,t[a],m,s[a],o)}else(typeof t[a]=="undefined"||o)&&(t[a]=c),u||(t[a]*=1),p?s[a]=n[a].slice().reverse():s[a]=t[a]||0}}},i.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},i.prototype.end=function(){return this._goToEnd=!0,this.update(this._startTime+this._duration),this},i.prototype.pause=function(e){return e===void 0&&(e=_0()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this)},i.prototype.resume=function(e){return e===void 0&&(e=_0()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this)},i.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},i.prototype.group=function(e){return e?(e.add(this),this):(console.warn("tween.group() without args has been removed, use group.add(tween) instead."),this)},i.prototype.remove=function(){var e;return(e=this._group)===null||e===void 0||e.remove(this),this},i.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},i.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},i.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},i.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},i.prototype.easing=function(e){return e===void 0&&(e=np.Linear.None),this._easingFunction=e,this},i.prototype.interpolation=function(e){return e===void 0&&(e=Im.Linear),this._interpolationFunction=e,this},i.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},i.prototype.onStart=function(e){return this._onStartCallback=e,this},i.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},i.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},i.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},i.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},i.prototype.onStop=function(e){return this._onStopCallback=e,this},i.prototype.update=function(e,t){var n=this,s;if(e===void 0&&(e=_0()),t===void 0&&(t=i.autoStartOnUpdate),this._isPaused)return!0;var o;if(!this._goToEnd&&!this._isPlaying)if(t)this.start(e,!0);else return!1;if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=e-this._startTime,c=this._duration+((s=this._repeatDelayTime)!==null&&s!==void 0?s:this._delayTime),u=this._duration+this._repeat*c,d=function(){if(n._duration===0||a>u)return 1;var G=Math.trunc(a/c),z=a-G*c,I=Math.min(z/n._duration,1);return I===0&&a===n._duration?1:I},p=d(),m=this._easingFunction(p);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,m),this._onUpdateCallback&&this._onUpdateCallback(this._object,p),this._duration===0||a>=this._duration)if(this._repeat>0){var y=Math.min(Math.trunc((a-this._duration)/c)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=y);for(o in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[o]=="string"&&(this._valuesStartRepeat[o]=this._valuesStartRepeat[o]+parseFloat(this._valuesEnd[o])),this._yoyo&&this._swapEndStartRepeatValues(o),this._valuesStart[o]=this._valuesStartRepeat[o];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=c*y,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var M=0,T=this._chainedTweens.length;M<T;M++)this._chainedTweens[M].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},i.prototype._updateProperties=function(e,t,n,s){for(var o in n)if(t[o]!==void 0){var a=t[o]||0,c=n[o],u=Array.isArray(e[o]),d=Array.isArray(c),p=!u&&d;p?e[o]=this._interpolationFunction(c,s):typeof c=="object"&&c?this._updateProperties(e[o],a,c,s):(c=this._handleRelativeValue(a,c),typeof c=="number"&&(e[o]=a+(c-a)*s))}},i.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},i.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];typeof n=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(n):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},i.autoStartOnUpdate=!1,i}(),Pj="25.0.0",Ij=$T.nextId,Yh=jT,Lj=Yh.getAll.bind(Yh),Dj=Yh.removeAll.bind(Yh),Oj=Yh.add.bind(Yh),Fj=Yh.remove.bind(Yh),Bj=Yh.update.bind(Yh),SJ={Easing:np,Group:HT,Interpolation:Im,now:_0,Sequence:$T,nextId:Ij,Tween:XT,VERSION:Pj,getAll:Lj,removeAll:Dj,add:Oj,remove:Fj,update:Bj};function Uj(){}function VL(i){return i==null?Uj:function(){return this.querySelector(i)}}function kj(i){typeof i!="function"&&(i=VL(i));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var o=e[s],a=o.length,c=n[s]=new Array(a),u,d,p=0;p<a;++p)(u=o[p])&&(d=i.call(u,u.__data__,p,o))&&("__data__"in u&&(d.__data__=u.__data__),c[p]=d);return new nu(n,this._parents)}function zj(i){return i==null?[]:Array.isArray(i)?i:Array.from(i)}function Vj(){return[]}function Gj(i){return i==null?Vj:function(){return this.querySelectorAll(i)}}function Wj(i){return function(){return zj(i.apply(this,arguments))}}function Hj(i){typeof i=="function"?i=Wj(i):i=Gj(i);for(var e=this._groups,t=e.length,n=[],s=[],o=0;o<t;++o)for(var a=e[o],c=a.length,u,d=0;d<c;++d)(u=a[d])&&(n.push(i.call(u,u.__data__,d,a)),s.push(u));return new nu(n,s)}function $j(i){return function(){return this.matches(i)}}function GL(i){return function(e){return e.matches(i)}}var jj=Array.prototype.find;function Xj(i){return function(){return jj.call(this.children,i)}}function qj(){return this.firstElementChild}function Yj(i){return this.select(i==null?qj:Xj(typeof i=="function"?i:GL(i)))}var Zj=Array.prototype.filter;function Kj(){return Array.from(this.children)}function Jj(i){return function(){return Zj.call(this.children,i)}}function Qj(i){return this.selectAll(i==null?Kj:Jj(typeof i=="function"?i:GL(i)))}function eX(i){typeof i!="function"&&(i=$j(i));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var o=e[s],a=o.length,c=n[s]=[],u,d=0;d<a;++d)(u=o[d])&&i.call(u,u.__data__,d,o)&&c.push(u);return new nu(n,this._parents)}function WL(i){return new Array(i.length)}function tX(){return new nu(this._enter||this._groups.map(WL),this._parents)}function Zb(i,e){this.ownerDocument=i.ownerDocument,this.namespaceURI=i.namespaceURI,this._next=null,this._parent=i,this.__data__=e}Zb.prototype={constructor:Zb,appendChild:function(i){return this._parent.insertBefore(i,this._next)},insertBefore:function(i,e){return this._parent.insertBefore(i,e)},querySelector:function(i){return this._parent.querySelector(i)},querySelectorAll:function(i){return this._parent.querySelectorAll(i)}};function nX(i){return function(){return i}}function iX(i,e,t,n,s,o){for(var a=0,c,u=e.length,d=o.length;a<d;++a)(c=e[a])?(c.__data__=o[a],n[a]=c):t[a]=new Zb(i,o[a]);for(;a<u;++a)(c=e[a])&&(s[a]=c)}function rX(i,e,t,n,s,o,a){var c,u,d=new Map,p=e.length,m=o.length,y=new Array(p),M;for(c=0;c<p;++c)(u=e[c])&&(y[c]=M=a.call(u,u.__data__,c,e)+"",d.has(M)?s[c]=u:d.set(M,u));for(c=0;c<m;++c)M=a.call(i,o[c],c,o)+"",(u=d.get(M))?(n[c]=u,u.__data__=o[c],d.delete(M)):t[c]=new Zb(i,o[c]);for(c=0;c<p;++c)(u=e[c])&&d.get(y[c])===u&&(s[c]=u)}function sX(i){return i.__data__}function oX(i,e){if(!arguments.length)return Array.from(this,sX);var t=e?rX:iX,n=this._parents,s=this._groups;typeof i!="function"&&(i=nX(i));for(var o=s.length,a=new Array(o),c=new Array(o),u=new Array(o),d=0;d<o;++d){var p=n[d],m=s[d],y=m.length,M=aX(i.call(p,p&&p.__data__,d,n)),T=M.length,G=c[d]=new Array(T),z=a[d]=new Array(T),I=u[d]=new Array(y);t(p,m,G,z,I,M,e);for(var J=0,K=0,re,ve;J<T;++J)if(re=G[J]){for(J>=K&&(K=J+1);!(ve=z[K])&&++K<T;);re._next=ve||null}}return a=new nu(a,n),a._enter=c,a._exit=u,a}function aX(i){return typeof i=="object"&&"length"in i?i:Array.from(i)}function lX(){return new nu(this._exit||this._groups.map(WL),this._parents)}function cX(i,e,t){var n=this.enter(),s=this,o=this.exit();return typeof i=="function"?(n=i(n),n&&(n=n.selection())):n=n.append(i+""),e!=null&&(s=e(s),s&&(s=s.selection())),t==null?o.remove():t(o),n&&s?n.merge(s).order():s}function uX(i){for(var e=i.selection?i.selection():i,t=this._groups,n=e._groups,s=t.length,o=n.length,a=Math.min(s,o),c=new Array(s),u=0;u<a;++u)for(var d=t[u],p=n[u],m=d.length,y=c[u]=new Array(m),M,T=0;T<m;++T)(M=d[T]||p[T])&&(y[T]=M);for(;u<s;++u)c[u]=t[u];return new nu(c,this._parents)}function hX(){for(var i=this._groups,e=-1,t=i.length;++e<t;)for(var n=i[e],s=n.length-1,o=n[s],a;--s>=0;)(a=n[s])&&(o&&a.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(a,o),o=a);return this}function dX(i){i||(i=fX);function e(m,y){return m&&y?i(m.__data__,y.__data__):!m-!y}for(var t=this._groups,n=t.length,s=new Array(n),o=0;o<n;++o){for(var a=t[o],c=a.length,u=s[o]=new Array(c),d,p=0;p<c;++p)(d=a[p])&&(u[p]=d);u.sort(e)}return new nu(s,this._parents).order()}function fX(i,e){return i<e?-1:i>e?1:i>=e?0:NaN}function pX(){var i=arguments[0];return arguments[0]=this,i.apply(null,arguments),this}function mX(){return Array.from(this)}function gX(){for(var i=this._groups,e=0,t=i.length;e<t;++e)for(var n=i[e],s=0,o=n.length;s<o;++s){var a=n[s];if(a)return a}return null}function yX(){let i=0;for(const e of this)++i;return i}function vX(){return!this.node()}function xX(i){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],o=0,a=s.length,c;o<a;++o)(c=s[o])&&i.call(c,c.__data__,o,s);return this}var qT="http://www.w3.org/1999/xhtml",HL={svg:"http://www.w3.org/2000/svg",xhtml:qT,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function $L(i){var e=i+="",t=e.indexOf(":");return t>=0&&(e=i.slice(0,t))!=="xmlns"&&(i=i.slice(t+1)),HL.hasOwnProperty(e)?{space:HL[e],local:i}:i}function _X(i){return function(){this.removeAttribute(i)}}function bX(i){return function(){this.removeAttributeNS(i.space,i.local)}}function wX(i,e){return function(){this.setAttribute(i,e)}}function MX(i,e){return function(){this.setAttributeNS(i.space,i.local,e)}}function SX(i,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(i):this.setAttribute(i,t)}}function TX(i,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(i.space,i.local):this.setAttributeNS(i.space,i.local,t)}}function EX(i,e){var t=$L(i);if(arguments.length<2){var n=this.node();return t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}return this.each((e==null?t.local?bX:_X:typeof e=="function"?t.local?TX:SX:t.local?MX:wX)(t,e))}function jL(i){return i.ownerDocument&&i.ownerDocument.defaultView||i.document&&i||i.defaultView}function AX(i){return function(){this.style.removeProperty(i)}}function CX(i,e,t){return function(){this.style.setProperty(i,e,t)}}function RX(i,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(i):this.style.setProperty(i,n,t)}}function NX(i,e,t){return arguments.length>1?this.each((e==null?AX:typeof e=="function"?RX:CX)(i,e,t==null?"":t)):PX(this.node(),i)}function PX(i,e){return i.style.getPropertyValue(e)||jL(i).getComputedStyle(i,null).getPropertyValue(e)}function IX(i){return function(){delete this[i]}}function LX(i,e){return function(){this[i]=e}}function DX(i,e){return function(){var t=e.apply(this,arguments);t==null?delete this[i]:this[i]=t}}function OX(i,e){return arguments.length>1?this.each((e==null?IX:typeof e=="function"?DX:LX)(i,e)):this.node()[i]}function XL(i){return i.trim().split(/^|\s+/)}function YT(i){return i.classList||new qL(i)}function qL(i){this._node=i,this._names=XL(i.getAttribute("class")||"")}qL.prototype={add:function(i){var e=this._names.indexOf(i);e<0&&(this._names.push(i),this._node.setAttribute("class",this._names.join(" ")))},remove:function(i){var e=this._names.indexOf(i);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(i){return this._names.indexOf(i)>=0}};function YL(i,e){for(var t=YT(i),n=-1,s=e.length;++n<s;)t.add(e[n])}function ZL(i,e){for(var t=YT(i),n=-1,s=e.length;++n<s;)t.remove(e[n])}function FX(i){return function(){YL(this,i)}}function BX(i){return function(){ZL(this,i)}}function UX(i,e){return function(){(e.apply(this,arguments)?YL:ZL)(this,i)}}function kX(i,e){var t=XL(i+"");if(arguments.length<2){for(var n=YT(this.node()),s=-1,o=t.length;++s<o;)if(!n.contains(t[s]))return!1;return!0}return this.each((typeof e=="function"?UX:e?FX:BX)(t,e))}function zX(){this.textContent=""}function VX(i){return function(){this.textContent=i}}function GX(i){return function(){var e=i.apply(this,arguments);this.textContent=e==null?"":e}}function WX(i){return arguments.length?this.each(i==null?zX:(typeof i=="function"?GX:VX)(i)):this.node().textContent}function HX(){this.innerHTML=""}function $X(i){return function(){this.innerHTML=i}}function jX(i){return function(){var e=i.apply(this,arguments);this.innerHTML=e==null?"":e}}function XX(i){return arguments.length?this.each(i==null?HX:(typeof i=="function"?jX:$X)(i)):this.node().innerHTML}function qX(){this.nextSibling&&this.parentNode.appendChild(this)}function YX(){return this.each(qX)}function ZX(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function KX(){return this.each(ZX)}function JX(i){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===qT&&e.documentElement.namespaceURI===qT?e.createElement(i):e.createElementNS(t,i)}}function QX(i){return function(){return this.ownerDocument.createElementNS(i.space,i.local)}}function KL(i){var e=$L(i);return(e.local?QX:JX)(e)}function eq(i){var e=typeof i=="function"?i:KL(i);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function tq(){return null}function nq(i,e){var t=typeof i=="function"?i:KL(i),n=e==null?tq:typeof e=="function"?e:VL(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function iq(){var i=this.parentNode;i&&i.removeChild(this)}function rq(){return this.each(iq)}function sq(){var i=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(i,this.nextSibling):i}function oq(){var i=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(i,this.nextSibling):i}function aq(i){return this.select(i?oq:sq)}function lq(i){return arguments.length?this.property("__data__",i):this.node().__data__}function cq(i){return function(e){i.call(this,e,this.__data__)}}function uq(i){return i.trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function hq(i){return function(){var e=this.__on;if(e){for(var t=0,n=-1,s=e.length,o;t<s;++t)o=e[t],(!i.type||o.type===i.type)&&o.name===i.name?this.removeEventListener(o.type,o.listener,o.options):e[++n]=o;++n?e.length=n:delete this.__on}}}function dq(i,e,t){return function(){var n=this.__on,s,o=cq(e);if(n){for(var a=0,c=n.length;a<c;++a)if((s=n[a]).type===i.type&&s.name===i.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=o,s.options=t),s.value=e;return}}this.addEventListener(i.type,o,t),s={type:i.type,name:i.name,value:e,listener:o,options:t},n?n.push(s):this.__on=[s]}}function fq(i,e,t){var n=uq(i+""),s,o=n.length,a;if(arguments.length<2){var c=this.node().__on;if(c){for(var u=0,d=c.length,p;u<d;++u)for(s=0,p=c[u];s<o;++s)if((a=n[s]).type===p.type&&a.name===p.name)return p.value}return}for(c=e?dq:hq,s=0;s<o;++s)this.each(c(n[s],e,t));return this}function JL(i,e,t){var n=jL(i),s=n.CustomEvent;typeof s=="function"?s=new s(e,t):(s=n.document.createEvent("Event"),t?(s.initEvent(e,t.bubbles,t.cancelable),s.detail=t.detail):s.initEvent(e,!1,!1)),i.dispatchEvent(s)}function pq(i,e){return function(){return JL(this,i,e)}}function mq(i,e){return function(){return JL(this,i,e.apply(this,arguments))}}function gq(i,e){return this.each((typeof e=="function"?mq:pq)(i,e))}function*yq(){for(var i=this._groups,e=0,t=i.length;e<t;++e)for(var n=i[e],s=0,o=n.length,a;s<o;++s)(a=n[s])&&(yield a)}var QL=[null];function nu(i,e){this._groups=i,this._parents=e}function vq(){return new nu([[document.documentElement]],QL)}function xq(){return this}nu.prototype=vq.prototype={constructor:nu,select:kj,selectAll:Hj,selectChild:Yj,selectChildren:Qj,filter:eX,data:oX,enter:tX,exit:lX,join:cX,merge:uX,selection:xq,order:hX,sort:dX,call:pX,nodes:mX,node:gX,size:yX,empty:vX,each:xX,attr:EX,style:NX,property:OX,classed:kX,text:WX,html:XX,raise:YX,lower:KX,append:eq,insert:nq,remove:rq,clone:aq,datum:lq,on:fq,dispatch:gq,[Symbol.iterator]:yq};var TJ=null;function _q(i){return typeof i=="string"?new nu([[document.querySelector(i)]],[document.documentElement]):new nu([[i]],QL)}function bq(i){let e;for(;e=i.sourceEvent;)i=e;return i}function wq(i,e){if(i=bq(i),e===void 0&&(e=i.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var n=t.createSVGPoint();return n.x=i.clientX,n.y=i.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var s=e.getBoundingClientRect();return[i.clientX-s.left-e.clientLeft,i.clientY-s.top-e.clientTop]}}return[i.pageX,i.pageY]}var ex,aa,e3,t3,Lm,n3,i3,r3,s3,ZT,KT,JT,o3,tx={},a3=[],Mq=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,nx=Array.isArray;function Zh(i,e){for(var t in e)i[t]=e[t];return i}function QT(i){i&&i.parentNode&&i.parentNode.removeChild(i)}function Sq(i,e,t){var n,s,o,a={};for(o in e)o=="key"?n=e[o]:o=="ref"?s=e[o]:a[o]=e[o];if(arguments.length>2&&(a.children=arguments.length>3?ex.call(arguments,2):t),typeof i=="function"&&i.defaultProps!=null)for(o in i.defaultProps)a[o]===void 0&&(a[o]=i.defaultProps[o]);return ix(i,a,n,s,null)}function ix(i,e,t,n,s){var o={type:i,props:e,key:t,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s==null?++e3:s,__i:-1,__u:0};return s==null&&aa.vnode!=null&&aa.vnode(o),o}function EJ(){return{current:null}}function Kb(i){return i.children}function Jb(i,e){this.props=i,this.context=e}function b0(i,e){if(e==null)return i.__?b0(i.__,i.__i+1):null;for(var t;e<i.__k.length;e++)if((t=i.__k[e])!=null&&t.__e!=null)return t.__e;return typeof i.type=="function"?b0(i):null}function l3(i){var e,t;if((i=i.__)!=null&&i.__c!=null){for(i.__e=i.__c.base=null,e=0;e<i.__k.length;e++)if((t=i.__k[e])!=null&&t.__e!=null){i.__e=i.__c.base=t.__e;break}return l3(i)}}function eE(i){(!i.__d&&(i.__d=!0)&&Lm.push(i)&&!Qb.__r++||n3!=aa.debounceRendering)&&((n3=aa.debounceRendering)||i3)(Qb)}function Qb(){for(var i,e,t,n,s,o,a,c=1;Lm.length;)Lm.length>c&&Lm.sort(r3),i=Lm.shift(),c=Lm.length,i.__d&&(t=void 0,n=void 0,s=(n=(e=i).__v).__e,o=[],a=[],e.__P&&((t=Zh({},n)).__v=n.__v+1,aa.vnode&&aa.vnode(t),tE(e.__P,t,n,e.__n,e.__P.namespaceURI,32&n.__u?[s]:null,o,s==null?b0(n):s,!!(32&n.__u),a),t.__v=n.__v,t.__.__k[t.__i]=t,f3(o,t,a),n.__e=n.__=null,t.__e!=s&&l3(t)));Qb.__r=0}function c3(i,e,t,n,s,o,a,c,u,d,p){var m,y,M,T,G,z,I,J=n&&n.__k||a3,K=e.length;for(u=Tq(t,e,J,u,K),m=0;m<K;m++)(M=t.__k[m])!=null&&(y=M.__i==-1?tx:J[M.__i]||tx,M.__i=m,z=tE(i,M,y,s,o,a,c,u,d,p),T=M.__e,M.ref&&y.ref!=M.ref&&(y.ref&&iE(y.ref,null,M),p.push(M.ref,M.__c||T,M)),G==null&&T!=null&&(G=T),(I=!!(4&M.__u))||y.__k===M.__k?u=u3(M,u,i,I):typeof M.type=="function"&&z!==void 0?u=z:T&&(u=T.nextSibling),M.__u&=-7);return t.__e=G,u}function Tq(i,e,t,n,s){var o,a,c,u,d,p=t.length,m=p,y=0;for(i.__k=new Array(s),o=0;o<s;o++)(a=e[o])!=null&&typeof a!="boolean"&&typeof a!="function"?(u=o+y,(a=i.__k[o]=typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?ix(null,a,null,null,null):nx(a)?ix(Kb,{children:a},null,null,null):a.constructor==null&&a.__b>0?ix(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=i,a.__b=i.__b+1,c=null,(d=a.__i=Aq(a,t,u,m))!=-1&&(m--,(c=t[d])&&(c.__u|=2)),c==null||c.__v==null?(d==-1&&(s>p?y--:s<p&&y++),typeof a.type!="function"&&(a.__u|=4)):d!=u&&(d==u-1?y--:d==u+1?y++:(d>u?y--:y++,a.__u|=4))):i.__k[o]=null;if(m)for(o=0;o<p;o++)(c=t[o])!=null&&!(2&c.__u)&&(c.__e==n&&(n=b0(c)),m3(c,c));return n}function u3(i,e,t,n){var s,o;if(typeof i.type=="function"){for(s=i.__k,o=0;s&&o<s.length;o++)s[o]&&(s[o].__=i,e=u3(s[o],e,t,n));return e}i.__e!=e&&(n&&(e&&i.type&&!e.parentNode&&(e=b0(i)),t.insertBefore(i.__e,e||null)),e=i.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function Eq(i,e){return e=e||[],i==null||typeof i=="boolean"||(nx(i)?i.some(function(t){Eq(t,e)}):e.push(i)),e}function Aq(i,e,t,n){var s,o,a,c=i.key,u=i.type,d=e[t],p=d!=null&&(2&d.__u)==0;if(d===null&&i.key==null||p&&c==d.key&&u==d.type)return t;if(n>(p?1:0)){for(s=t-1,o=t+1;s>=0||o<e.length;)if((d=e[a=s>=0?s--:o++])!=null&&!(2&d.__u)&&c==d.key&&u==d.type)return a}return-1}function h3(i,e,t){e[0]=="-"?i.setProperty(e,t==null?"":t):i[e]=t==null?"":typeof t!="number"||Mq.test(e)?t:t+"px"}function e1(i,e,t,n,s){var o,a;e:if(e=="style")if(typeof t=="string")i.style.cssText=t;else{if(typeof n=="string"&&(i.style.cssText=n=""),n)for(e in n)t&&e in t||h3(i.style,e,"");if(t)for(e in t)n&&t[e]==n[e]||h3(i.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(s3,"$1")),a=e.toLowerCase(),e=a in i||e=="onFocusOut"||e=="onFocusIn"?a.slice(2):e.slice(2),i.l||(i.l={}),i.l[e+o]=t,t?n?t.u=n.u:(t.u=ZT,i.addEventListener(e,o?JT:KT,o)):i.removeEventListener(e,o?JT:KT,o);else{if(s=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in i)try{i[e]=t==null?"":t;break e}catch(c){}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?i.removeAttribute(e):i.setAttribute(e,e=="popover"&&t==1?"":t))}}function d3(i){return function(e){if(this.l){var t=this.l[e.type+i];if(e.t==null)e.t=ZT++;else if(e.t<t.u)return;return t(aa.event?aa.event(e):e)}}}function tE(i,e,t,n,s,o,a,c,u,d){var p,m,y,M,T,G,z,I,J,K,re,ve,me,Le,Ve,Ee,Oe,dt=e.type;if(e.constructor!=null)return null;128&t.__u&&(u=!!(32&t.__u),o=[c=e.__e=t.__e]),(p=aa.__b)&&p(e);e:if(typeof dt=="function")try{if(I=e.props,J="prototype"in dt&&dt.prototype.render,K=(p=dt.contextType)&&n[p.__c],re=p?K?K.props.value:p.__:n,t.__c?z=(m=e.__c=t.__c).__=m.__E:(J?e.__c=m=new dt(I,re):(e.__c=m=new Jb(I,re),m.constructor=dt,m.render=Rq),K&&K.sub(m),m.props=I,m.state||(m.state={}),m.context=re,m.__n=n,y=m.__d=!0,m.__h=[],m._sb=[]),J&&m.__s==null&&(m.__s=m.state),J&&dt.getDerivedStateFromProps!=null&&(m.__s==m.state&&(m.__s=Zh({},m.__s)),Zh(m.__s,dt.getDerivedStateFromProps(I,m.__s))),M=m.props,T=m.state,m.__v=e,y)J&&dt.getDerivedStateFromProps==null&&m.componentWillMount!=null&&m.componentWillMount(),J&&m.componentDidMount!=null&&m.__h.push(m.componentDidMount);else{if(J&&dt.getDerivedStateFromProps==null&&I!==M&&m.componentWillReceiveProps!=null&&m.componentWillReceiveProps(I,re),!m.__e&&m.shouldComponentUpdate!=null&&m.shouldComponentUpdate(I,m.__s,re)===!1||e.__v==t.__v){for(e.__v!=t.__v&&(m.props=I,m.state=m.__s,m.__d=!1),e.__e=t.__e,e.__k=t.__k,e.__k.some(function(Ut){Ut&&(Ut.__=e)}),ve=0;ve<m._sb.length;ve++)m.__h.push(m._sb[ve]);m._sb=[],m.__h.length&&a.push(m);break e}m.componentWillUpdate!=null&&m.componentWillUpdate(I,m.__s,re),J&&m.componentDidUpdate!=null&&m.__h.push(function(){m.componentDidUpdate(M,T,G)})}if(m.context=re,m.props=I,m.__P=i,m.__e=!1,me=aa.__r,Le=0,J){for(m.state=m.__s,m.__d=!1,me&&me(e),p=m.render(m.props,m.state,m.context),Ve=0;Ve<m._sb.length;Ve++)m.__h.push(m._sb[Ve]);m._sb=[]}else do m.__d=!1,me&&me(e),p=m.render(m.props,m.state,m.context),m.state=m.__s;while(m.__d&&++Le<25);m.state=m.__s,m.getChildContext!=null&&(n=Zh(Zh({},n),m.getChildContext())),J&&!y&&m.getSnapshotBeforeUpdate!=null&&(G=m.getSnapshotBeforeUpdate(M,T)),Ee=p,p!=null&&p.type===Kb&&p.key==null&&(Ee=p3(p.props.children)),c=c3(i,nx(Ee)?Ee:[Ee],e,t,n,s,o,a,c,u,d),m.base=e.__e,e.__u&=-161,m.__h.length&&a.push(m),z&&(m.__E=m.__=null)}catch(Ut){if(e.__v=null,u||o!=null)if(Ut.then){for(e.__u|=u?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o[o.indexOf(c)]=null,e.__e=c}else{for(Oe=o.length;Oe--;)QT(o[Oe]);nE(e)}else e.__e=t.__e,e.__k=t.__k,Ut.then||nE(e);aa.__e(Ut,e,t)}else o==null&&e.__v==t.__v?(e.__k=t.__k,e.__e=t.__e):c=e.__e=Cq(t.__e,e,t,n,s,o,a,u,d);return(p=aa.diffed)&&p(e),128&e.__u?void 0:c}function nE(i){i&&i.__c&&(i.__c.__e=!0),i&&i.__k&&i.__k.forEach(nE)}function f3(i,e,t){for(var n=0;n<t.length;n++)iE(t[n],t[++n],t[++n]);aa.__c&&aa.__c(e,i),i.some(function(s){try{i=s.__h,s.__h=[],i.some(function(o){o.call(s)})}catch(o){aa.__e(o,s.__v)}})}function p3(i){return typeof i!="object"||i==null||i.__b&&i.__b>0?i:nx(i)?i.map(p3):Zh({},i)}function Cq(i,e,t,n,s,o,a,c,u){var d,p,m,y,M,T,G,z=t.props,I=e.props,J=e.type;if(J=="svg"?s="http://www.w3.org/2000/svg":J=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),o!=null){for(d=0;d<o.length;d++)if((M=o[d])&&"setAttribute"in M==!!J&&(J?M.localName==J:M.nodeType==3)){i=M,o[d]=null;break}}if(i==null){if(J==null)return document.createTextNode(I);i=document.createElementNS(s,J,I.is&&I),c&&(aa.__m&&aa.__m(e,o),c=!1),o=null}if(J==null)z===I||c&&i.data==I||(i.data=I);else{if(o=o&&ex.call(i.childNodes),z=t.props||tx,!c&&o!=null)for(z={},d=0;d<i.attributes.length;d++)z[(M=i.attributes[d]).name]=M.value;for(d in z)if(M=z[d],d!="children"){if(d=="dangerouslySetInnerHTML")m=M;else if(!(d in I)){if(d=="value"&&"defaultValue"in I||d=="checked"&&"defaultChecked"in I)continue;e1(i,d,null,M,s)}}for(d in I)M=I[d],d=="children"?y=M:d=="dangerouslySetInnerHTML"?p=M:d=="value"?T=M:d=="checked"?G=M:c&&typeof M!="function"||z[d]===M||e1(i,d,M,z[d],s);if(p)c||m&&(p.__html==m.__html||p.__html==i.innerHTML)||(i.innerHTML=p.__html),e.__k=[];else if(m&&(i.innerHTML=""),c3(e.type=="template"?i.content:i,nx(y)?y:[y],e,t,n,J=="foreignObject"?"http://www.w3.org/1999/xhtml":s,o,a,o?o[0]:t.__k&&b0(t,0),c,u),o!=null)for(d=o.length;d--;)QT(o[d]);c||(d="value",J=="progress"&&T==null?i.removeAttribute("value"):T!=null&&(T!==i[d]||J=="progress"&&!T||J=="option"&&T!=z[d])&&e1(i,d,T,z[d],s),d="checked",G!=null&&G!=i[d]&&e1(i,d,G,z[d],s))}return i}function iE(i,e,t){try{if(typeof i=="function"){var n=typeof i.__u=="function";n&&i.__u(),n&&e==null||(i.__u=i(e))}else i.current=e}catch(s){aa.__e(s,t)}}function m3(i,e,t){var n,s;if(aa.unmount&&aa.unmount(i),(n=i.ref)&&(n.current&&n.current!=i.__e||iE(n,null,e)),(n=i.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(o){aa.__e(o,e)}n.base=n.__P=null}if(n=i.__k)for(s=0;s<n.length;s++)n[s]&&m3(n[s],e,t||typeof i.type!="function");t||QT(i.__e),i.__c=i.__=i.__e=void 0}function Rq(i,e,t){return this.constructor(i,t)}function g3(i,e,t){var n,s,o,a;e==document&&(e=document.documentElement),aa.__&&aa.__(i,e),s=(n=typeof t=="function")?null:t&&t.__k||e.__k,o=[],a=[],tE(e,i=(!n&&t||e).__k=Sq(Kb,null,[i]),s||tx,tx,e.namespaceURI,!n&&t?[t]:s?null:e.firstChild?ex.call(e.childNodes):null,o,!n&&t?t:s?s.__e:e.firstChild,n,a),f3(o,i,a)}function Nq(i,e){g3(i,e,Nq)}function y3(i,e,t){var n,s,o,a,c=Zh({},i.props);for(o in i.type&&i.type.defaultProps&&(a=i.type.defaultProps),e)o=="key"?n=e[o]:o=="ref"?s=e[o]:c[o]=e[o]===void 0&&a!=null?a[o]:e[o];return arguments.length>2&&(c.children=arguments.length>3?ex.call(arguments,2):t),ix(i.type,c,n||i.key,s||i.ref,null)}function AJ(i){function e(t){var n,s;return this.getChildContext||(n=new Set,(s={})[e.__c]=this,this.getChildContext=function(){return s},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(o){this.props.value!=o.value&&n.forEach(function(a){a.__e=!0,eE(a)})},this.sub=function(o){n.add(o);var a=o.componentWillUnmount;o.componentWillUnmount=function(){n&&n.delete(o),a&&a.call(o)}}),t.children}return e.__c="__cC"+o3++,e.__=i,e.Provider=e.__l=(e.Consumer=function(t,n){return t.children(n)}).contextType=e,e}ex=a3.slice,aa={__e:function(i,e,t,n){for(var s,o,a;e=e.__;)if((s=e.__c)&&!s.__)try{if((o=s.constructor)&&o.getDerivedStateFromError!=null&&(s.setState(o.getDerivedStateFromError(i)),a=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(i,n||{}),a=s.__d),a)return s.__E=s}catch(c){i=c}throw i}},e3=0,t3=function(i){return i!=null&&i.constructor==null},Jb.prototype.setState=function(i,e){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Zh({},this.state),typeof i=="function"&&(i=i(Zh({},t),this.props)),i&&Zh(t,i),i!=null&&this.__v&&(e&&this._sb.push(e),eE(this))},Jb.prototype.forceUpdate=function(i){this.__v&&(this.__e=!0,i&&this.__h.push(i),eE(this))},Jb.prototype.render=Kb,Lm=[],i3=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,r3=function(i,e){return i.__v.__b-e.__v.__b},Qb.__r=0,s3=/(PointerCapture)$|Capture$/i,ZT=0,KT=d3(!1),JT=d3(!0),o3=0;function v3(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function Pq(i){if(Array.isArray(i))return i}function Iq(i,e,t){return(e=Uq(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Lq(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,s,o,a,c=[],u=!0,d=!1;try{if(o=(t=t.call(i)).next,e!==0)for(;!(u=(n=o.call(t)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(p){d=!0,s=p}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(d)throw s}}return c}}function Dq(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function x3(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,n)}return t}function Oq(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?x3(Object(t),!0).forEach(function(n){Iq(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):x3(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function Fq(i,e){return Pq(i)||Lq(i,e)||kq(i,e)||Dq()}function Bq(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function Uq(i){var e=Bq(i,"string");return typeof e=="symbol"?e:e+""}function t1(i){"@babel/helpers - typeof";return t1=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t1(i)}function kq(i,e){if(i){if(typeof i=="string")return v3(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?v3(i,e):void 0}}var rE=function(e){if(t1(e)!=="object")return e;var t=y3(e);if(t.props){var n;t.props=Oq({},t.props),t!=null&&(n=t.props)!==null&&n!==void 0&&n.children&&(t.props.children=Array.isArray(t.props.children)?t.props.children.map(rE):rE(t.props.children))}return t},zq=function(e){return t3(y3(e))},Vq=function(e,t){delete t.__k,g3(rE(e),t)};function Gq(i,e){e===void 0&&(e={});var t=e.insertAt;if(typeof document!="undefined"){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",t==="top"&&n.firstChild?n.insertBefore(s,n.firstChild):n.appendChild(s),s.styleSheet?s.styleSheet.cssText=i:s.appendChild(document.createTextNode(i))}}var Wq=`.float-tooltip-kap {
|
|
|
position: absolute;
|
|
|
width: max-content; /* prevent shrinking near right edge */
|
|
|
max-width: max(50%, 150px);
|
|
|
padding: 3px 5px;
|
|
|
border-radius: 3px;
|
|
|
font: 12px sans-serif;
|
|
|
color: #eee;
|
|
|
background: rgba(0,0,0,0.6);
|
|
|
pointer-events: none;
|
|
|
}
|
|
|
`;Gq(Wq);var Hq=d_({props:{content:{default:!1},offsetX:{triggerUpdate:!1},offsetY:{triggerUpdate:!1}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=n.style,o=s===void 0?{}:s,a=!!e&&t1(e)==="object"&&!!e.node&&typeof e.node=="function",c=_q(a?e.node():e);c.style("position")==="static"&&c.style("position","relative"),t.tooltipEl=c.append("div").attr("class","float-tooltip-kap"),Object.entries(o).forEach(function(d){var p=Fq(d,2),m=p[0],y=p[1];return t.tooltipEl.style(m,y)}),t.tooltipEl.style("left","-10000px").style("display","none");var u="tooltip-".concat(Math.round(Math.random()*1e12));t.mouseInside=!1,c.on("mousemove.".concat(u),function(d){t.mouseInside=!0;var p=wq(d),m=c.node(),y=m.offsetWidth,M=m.offsetHeight,T=[t.offsetX===null||t.offsetX===void 0?"-".concat(p[0]/y*100,"%"):typeof t.offsetX=="number"?"calc(-50% + ".concat(t.offsetX,"px)"):t.offsetX,t.offsetY===null||t.offsetY===void 0?M>130&&M-p[1]<100?"calc(-100% - 6px)":"21px":typeof t.offsetY=="number"?t.offsetY<0?"calc(-100% - ".concat(Math.abs(t.offsetY),"px)"):"".concat(t.offsetY,"px"):t.offsetY];t.tooltipEl.style("left",p[0]+"px").style("top",p[1]+"px").style("transform","translate(".concat(T.join(","),")")),t.content&&t.tooltipEl.style("display","inline")}),c.on("mouseover.".concat(u),function(){t.mouseInside=!0,t.content&&t.tooltipEl.style("display","inline")}),c.on("mouseout.".concat(u),function(){t.mouseInside=!1,t.tooltipEl.style("display","none")})},update:function(e){e.tooltipEl.style("display",e.content&&e.mouseInside?"inline":"none"),e.content?e.content instanceof HTMLElement?(e.tooltipEl.text(""),e.tooltipEl.append(function(){return e.content})):typeof e.content=="string"?e.tooltipEl.html(e.content):zq(e.content)?(e.tooltipEl.text(""),Vq(e.content,e.tooltipEl.node())):(e.tooltipEl.style("display","none"),console.warn("Tooltip content is invalid, skipping.",e.content,e.content.toString())):e.tooltipEl.text("")}});function $q(i,e){e===void 0&&(e={});var t=e.insertAt;if(typeof document!="undefined"){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",t==="top"&&n.firstChild?n.insertBefore(s,n.firstChild):n.appendChild(s),s.styleSheet?s.styleSheet.cssText=i:s.appendChild(document.createTextNode(i))}}var jq=`.scene-nav-info {
|
|
|
position: absolute;
|
|
|
bottom: 5px;
|
|
|
width: 100%;
|
|
|
text-align: center;
|
|
|
color: slategrey;
|
|
|
opacity: 0.7;
|
|
|
font-size: 10px;
|
|
|
font-family: sans-serif;
|
|
|
pointer-events: none;
|
|
|
user-select: none;
|
|
|
}
|
|
|
|
|
|
.scene-container canvas:focus {
|
|
|
outline: none;
|
|
|
}`;$q(jq);function sE(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function Xq(i){if(Array.isArray(i))return i}function qq(i){if(Array.isArray(i))return sE(i)}function Yq(i,e,t){return(e=nY(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Zq(i){if(typeof Symbol!="undefined"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function Kq(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,s,o,a,c=[],u=!0,d=!1;try{if(o=(t=t.call(i)).next,e!==0)for(;!(u=(n=o.call(t)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(p){d=!0,s=p}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(d)throw s}}return c}}function Jq(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Qq(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function eY(i,e){return Xq(i)||Kq(i,e)||_3(i,e)||Jq()}function Dm(i){return qq(i)||Zq(i)||_3(i)||Qq()}function tY(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function nY(i){var e=tY(i,"string");return typeof e=="symbol"?e:e+""}function _3(i,e){if(i){if(typeof i=="string")return sE(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?sE(i,e):void 0}}var la=window.THREE?window.THREE:{WebGLRenderer:tz,Scene:Km,PerspectiveCamera:ma,Raycaster:Py,SRGBColorSpace:uo,TextureLoader:bE,Vector2:yn,Vector3:it,Box3:fa,Color:jn,Mesh:Ks,SphereGeometry:Yu,MeshBasicMaterial:Hr,BackSide:Y,Clock:qx},b3=d_({props:{width:{default:window.innerWidth,onChange:function(e,t,n){isNaN(e)&&(t.width=n)}},height:{default:window.innerHeight,onChange:function(e,t,n){isNaN(e)&&(t.height=n)}},viewOffset:{default:[0,0]},backgroundColor:{default:"#000011"},backgroundImageUrl:{},onBackgroundImageLoaded:{},showNavInfo:{default:!0},skyRadius:{default:5e4},objects:{default:[]},lights:{default:[]},enablePointerInteraction:{default:!0,onChange:function(e,t){t.hoverObj=null,t.tooltip&&t.tooltip.content(null)},triggerUpdate:!1},pointerRaycasterThrottleMs:{default:50,triggerUpdate:!1},lineHoverPrecision:{default:1,triggerUpdate:!1},pointsHoverPrecision:{default:1,triggerUpdate:!1},hoverOrderComparator:{triggerUpdate:!1},hoverFilter:{default:function(){return!0},triggerUpdate:!1},tooltipContent:{triggerUpdate:!1},hoverDuringDrag:{default:!1,triggerUpdate:!1},clickAfterDrag:{default:!1,triggerUpdate:!1},onHover:{default:function(){},triggerUpdate:!1},onClick:{default:function(){},triggerUpdate:!1},onRightClick:{triggerUpdate:!1}},methods:{tick:function(e){if(e.initialised){e.controls.enabled&&e.controls.update&&e.controls.update(Math.min(1,e.clock.getDelta())),e.postProcessingComposer?e.postProcessingComposer.render():e.renderer.render(e.scene,e.camera),e.extraRenderers.forEach(function(a){return a.render(e.scene,e.camera)});var t=+new Date;if(e.enablePointerInteraction&&t-e.lastRaycasterCheck>=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var n=null;if(e.hoverDuringDrag||!e.isPointerDragging){var s=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&s.sort(function(a,c){return e.hoverOrderComparator(a.object,c.object)});var o=s.find(function(a){return e.hoverFilter(a.object)})||null;n=o?o.object:null,e.intersection=o||null}n!==e.hoverObj&&(e.onHover(n,e.hoverObj,e.intersection),e.tooltip.content(n&&ks(e.tooltipContent)(n,e.intersection)||null),e.hoverObj=n)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos,n=t.x,s=t.y;return{x:n,y:s}},cameraPosition:function(e,t,n,s){var o=e.camera;if(t&&e.initialised){var a=t,c=n||{x:0,y:0,z:0};if(!s)p(a),m(c);else{var u=Object.assign({},o.position),d=y();e.tweenGroup.add(new XT(u).to(a,s).easing(np.Quadratic.Out).onUpdate(p).start()),e.tweenGroup.add(new XT(d).to(c,s/3).easing(np.Quadratic.Out).onUpdate(m).start())}return this}return Object.assign({},o.position,{lookAt:y()});function p(M){var T=M.x,G=M.y,z=M.z;T!==void 0&&(o.position.x=T),G!==void 0&&(o.position.y=G),z!==void 0&&(o.position.z=z)}function m(M){var T=new la.Vector3(M.x,M.y,M.z);e.controls.enabled&&e.controls.target?e.controls.target=T:o.lookAt(T)}function y(){return Object.assign(new la.Vector3(0,0,-1e3).applyQuaternion(o.quaternion).add(o.position))}},zoomToFit:function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,s=arguments.length,o=new Array(s>3?s-3:0),a=3;a<s;a++)o[a-3]=arguments[a];return this.fitToBbox(this.getBbox.apply(this,o),t,n)},fitToBbox:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:10,o=e.camera;if(t){var a=new la.Vector3(0,0,0),c=Math.max.apply(Math,Dm(Object.entries(t).map(function(M){var T=eY(M,2),G=T[0],z=T[1];return Math.max.apply(Math,Dm(z.map(function(I){return Math.abs(a[G]-I)})))})))*2,u=(1-s*2/e.height)*o.fov,d=c/Math.atan(u*Math.PI/180),p=d/o.aspect,m=Math.max(d,p);if(m>0){var y=a.clone().sub(o.position).normalize().multiplyScalar(-m);this.cameraPosition(y,a,n)}}return this},getBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},n=new la.Box3(new la.Vector3(0,0,0),new la.Vector3(0,0,0)),s=e.objects.filter(t);return s.length?(s.forEach(function(o){return n.expandByObject(o)}),Object.assign.apply(Object,Dm(["x","y","z"].map(function(o){return Yq({},o,[n.min[o],n.max[o]])})))):null},getScreenCoords:function(e,t,n,s){var o=new la.Vector3(t,n,s);return o.project(this.camera()),{x:(o.x+1)*e.width/2,y:-(o.y-1)*e.height/2}},getSceneCoords:function(e,t,n){var s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,o=new la.Vector2(t/e.width*2-1,-(n/e.height)*2+1),a=new la.Raycaster;return a.setFromCamera(o,e.camera),Object.assign({},a.ray.at(s,new la.Vector3))},intersectingObjects:function(e,t,n){var s=new la.Vector2(t/e.width*2-1,-(n/e.height)*2+1),o=new la.Raycaster;return o.params.Line.threshold=e.lineHoverPrecision,o.params.Points.threshold=e.pointsHoverPrecision,o.setFromCamera(s,e.camera),o.intersectObjects(e.objects,!0)},renderer:function(e){return e.renderer},scene:function(e){return e.scene},camera:function(e){return e.camera},postProcessingComposer:function(e){return e.postProcessingComposer},controls:function(e){return e.controls},tbControls:function(e){return e.controls}},stateInit:function(){return{scene:new la.Scene,camera:new la.PerspectiveCamera,clock:new la.Clock,tweenGroup:new HT,lastRaycasterCheck:0}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=n.controlType,o=s===void 0?"trackball":s,a=n.useWebGPU,c=a===void 0?!1:a,u=n.rendererConfig,d=u===void 0?{}:u,p=n.extraRenderers,m=p===void 0?[]:p,y=n.waitForLoadComplete,M=y===void 0?!0:y;e.innerHTML="",e.appendChild(t.container=document.createElement("div")),t.container.className="scene-container",t.container.style.position="relative",t.container.appendChild(t.navInfo=document.createElement("div")),t.navInfo.className="scene-nav-info",t.navInfo.textContent={orbit:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",trackball:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",fly:"WASD: move, R|F: up | down, Q|E: roll, up|down: pitch, left|right: yaw"}[o]||"",t.navInfo.style.display=t.showNavInfo?null:"none",t.tooltip=new Hq(t.container),t.pointerPos=new la.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,["pointermove","pointerdown"].forEach(function(T){return t.container.addEventListener(T,function(G){if(T==="pointerdown"&&(t.isPointerPressed=!0),!t.isPointerDragging&&G.type==="pointermove"&&(G.pressure>0||t.isPointerPressed)&&(G.pointerType==="mouse"||G.movementX===void 0||[G.movementX,G.movementY].some(function(J){return Math.abs(J)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var z=I(t.container);t.pointerPos.x=G.pageX-z.left,t.pointerPos.y=G.pageY-z.top}function I(J){var K=J.getBoundingClientRect(),re=window.pageXOffset||document.documentElement.scrollLeft,ve=window.pageYOffset||document.documentElement.scrollTop;return{top:K.top+ve,left:K.left+re}}},{passive:!0})}),t.container.addEventListener("pointerup",function(T){t.isPointerPressed&&(t.isPointerPressed=!1,!(t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag))&&requestAnimationFrame(function(){T.button===0&&t.onClick(t.hoverObj||null,T,t.intersection),T.button===2&&t.onRightClick&&t.onRightClick(t.hoverObj||null,T,t.intersection)}))},{passive:!0,capture:!0}),t.container.addEventListener("contextmenu",function(T){t.onRightClick&&T.preventDefault()}),t.renderer=new(c?u7:la.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},d)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=m,t.extraRenderers.forEach(function(T){T.domElement.style.position="absolute",T.domElement.style.top="0px",T.domElement.style.pointerEvents="none",t.container.appendChild(T.domElement)}),t.postProcessingComposer=new s$(t.renderer),t.postProcessingComposer.addPass(new o$(t.scene,t.camera)),t.controls=new{trackball:p7,orbit:N7,fly:H7}[o](t.camera,t.renderer.domElement),o==="fly"&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),(o==="trackball"||o==="orbit")&&(t.controls.minDistance=.1,t.controls.maxDistance=t.skyRadius,t.controls.addEventListener("start",function(){t.controlsEngaged=!0}),t.controls.addEventListener("change",function(){t.controlsEngaged&&(t.controlsDragging=!0)}),t.controls.addEventListener("end",function(){t.controlsEngaged=!1,t.controlsDragging=!1})),[t.renderer,t.postProcessingComposer].concat(Dm(t.extraRenderers)).forEach(function(T){return T.setSize(t.width,t.height)}),t.camera.aspect=t.width/t.height,t.camera.updateProjectionMatrix(),t.camera.position.z=1e3,t.scene.add(t.skysphere=new la.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!M,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty("width")||t.hasOwnProperty("height"))){var n,s=e.width,o=e.height;e.container.style.width="".concat(s,"px"),e.container.style.height="".concat(o,"px"),[e.renderer,e.postProcessingComposer].concat(Dm(e.extraRenderers)).forEach(function(M){return M.setSize(s,o)}),e.camera.aspect=s/o;var a=e.viewOffset.slice(0,2);a.some(function(M){return M})&&(n=e.camera).setViewOffset.apply(n,[s,o].concat(Dm(a),[s,o])),e.camera.updateProjectionMatrix()}if(t.hasOwnProperty("viewOffset")){var c,u=e.width,d=e.height,p=e.viewOffset.slice(0,2);p.some(function(M){return M})?(c=e.camera).setViewOffset.apply(c,[u,d].concat(Dm(p),[u,d])):e.camera.clearViewOffset()}if(t.hasOwnProperty("skyRadius")&&e.skyRadius&&(e.controls.hasOwnProperty("maxDistance")&&t.skyRadius&&(e.controls.maxDistance=Math.min(e.controls.maxDistance,e.skyRadius)),e.camera.far=e.skyRadius*2.5,e.camera.updateProjectionMatrix(),e.skysphere.geometry=new la.SphereGeometry(e.skyRadius)),t.hasOwnProperty("backgroundColor")){var m=Yd(e.backgroundColor).alpha;m===void 0&&(m=1),e.renderer.setClearColor(new la.Color(yj(1,e.backgroundColor)),m)}t.hasOwnProperty("backgroundImageUrl")&&(e.backgroundImageUrl?new la.TextureLoader().load(e.backgroundImageUrl,function(M){M.colorSpace=la.SRGBColorSpace,e.skysphere.material=new la.MeshBasicMaterial({map:M,side:la.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&y()}):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&y())),t.hasOwnProperty("showNavInfo")&&(e.navInfo.style.display=e.showNavInfo?null:"none"),t.hasOwnProperty("lights")&&((t.lights||[]).forEach(function(M){return e.scene.remove(M)}),e.lights.forEach(function(M){return e.scene.add(M)})),t.hasOwnProperty("objects")&&((t.objects||[]).forEach(function(M){return e.scene.remove(M)}),e.objects.forEach(function(M){return e.scene.add(M)}));function y(){e.loadComplete=e.scene.visible=!0}}});function iY(i,e){e===void 0&&(e={});var t=e.insertAt;if(typeof document!="undefined"){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",t==="top"&&n.firstChild?n.insertBefore(s,n.firstChild):n.appendChild(s),s.styleSheet?s.styleSheet.cssText=i:s.appendChild(document.createTextNode(i))}}var rY=`.graph-info-msg {
|
|
|
top: 50%;
|
|
|
width: 100%;
|
|
|
text-align: center;
|
|
|
color: lavender;
|
|
|
opacity: 0.7;
|
|
|
font-size: 22px;
|
|
|
position: absolute;
|
|
|
font-family: Sans-serif;
|
|
|
}
|
|
|
|
|
|
.scene-container .clickable {
|
|
|
cursor: pointer;
|
|
|
}
|
|
|
|
|
|
.scene-container .grabbable {
|
|
|
cursor: move;
|
|
|
cursor: grab;
|
|
|
cursor: -moz-grab;
|
|
|
cursor: -webkit-grab;
|
|
|
}
|
|
|
|
|
|
.scene-container .grabbable:active {
|
|
|
cursor: grabbing;
|
|
|
cursor: -moz-grabbing;
|
|
|
cursor: -webkit-grabbing;
|
|
|
}`;iY(rY);function oE(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function sY(i){if(Array.isArray(i))return oE(i)}function rx(i,e,t){return(e=cY(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function oY(i){if(typeof Symbol!="undefined"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function aY(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function w3(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,n)}return t}function n1(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?w3(Object(t),!0).forEach(function(n){rx(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):w3(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function i1(i){return sY(i)||oY(i)||uY(i)||aY()}function lY(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function cY(i){var e=lY(i,"string");return typeof e=="symbol"?e:e+""}function uY(i,e){if(i){if(typeof i=="string")return oE(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?oE(i,e):void 0}}function M3(i,e){var t=new e;return t._destructor&&t._destructor(),{linkProp:function(s){return{default:t[s](),onChange:function(a,c){c[i][s](a)},triggerUpdate:!1}},linkMethod:function(s){return function(o){for(var a=o[i],c=arguments.length,u=new Array(c>1?c-1:0),d=1;d<c;d++)u[d-1]=arguments[d];var p=a[s].apply(a,u);return p===a?this:p}}}}var aE=window.THREE?window.THREE:{AmbientLight:qp,DirectionalLight:Ad,REVISION:w},hY=170,S3=M3("forceGraph",MA),dY=Object.assign.apply(Object,i1(["jsonUrl","graphData","numDimensions","dagMode","dagLevelDistance","dagNodeFilter","onDagError","nodeRelSize","nodeId","nodeVal","nodeResolution","nodeColor","nodeAutoColorBy","nodeOpacity","nodeVisibility","nodeThreeObject","nodeThreeObjectExtend","nodePositionUpdate","linkSource","linkTarget","linkVisibility","linkColor","linkAutoColorBy","linkOpacity","linkWidth","linkResolution","linkCurvature","linkCurveRotation","linkMaterial","linkThreeObject","linkThreeObjectExtend","linkPositionUpdate","linkDirectionalArrowLength","linkDirectionalArrowColor","linkDirectionalArrowRelPos","linkDirectionalArrowResolution","linkDirectionalParticles","linkDirectionalParticleSpeed","linkDirectionalParticleOffset","linkDirectionalParticleWidth","linkDirectionalParticleColor","linkDirectionalParticleResolution","linkDirectionalParticleThreeObject","forceEngine","d3AlphaDecay","d3VelocityDecay","d3AlphaMin","ngraphPhysics","warmupTicks","cooldownTicks","cooldownTime","onEngineTick","onEngineStop"].map(function(i){return rx({},i,S3.linkProp(i))}))),fY=Object.assign.apply(Object,i1(["refresh","getGraphBbox","d3Force","d3ReheatSimulation","emitParticle"].map(function(i){return rx({},i,S3.linkMethod(i))}))),r1=M3("renderObjs",b3),pY=Object.assign.apply(Object,i1(["width","height","backgroundColor","showNavInfo","enablePointerInteraction"].map(function(i){return rx({},i,r1.linkProp(i))}))),mY=Object.assign.apply(Object,i1(["lights","cameraPosition","postProcessingComposer"].map(function(i){return rx({},i,r1.linkMethod(i))})).concat([{graph2ScreenCoords:r1.linkMethod("getScreenCoords"),screen2GraphCoords:r1.linkMethod("getSceneCoords")}])),gY=d_({props:n1(n1({nodeLabel:{default:"name",triggerUpdate:!1},linkLabel:{default:"name",triggerUpdate:!1},linkHoverPrecision:{default:1,onChange:function(e,t){return t.renderObjs.lineHoverPrecision(e)},triggerUpdate:!1},enableNavigationControls:{default:!0,onChange:function(e,t){var n=t.renderObjs.controls();n&&(n.enabled=e,e&&n.domElement&&n.domElement.dispatchEvent(new PointerEvent("pointerup")))},triggerUpdate:!1},enableNodeDrag:{default:!0,triggerUpdate:!1},onNodeDrag:{default:function(){},triggerUpdate:!1},onNodeDragEnd:{default:function(){},triggerUpdate:!1},onNodeClick:{triggerUpdate:!1},onNodeRightClick:{triggerUpdate:!1},onNodeHover:{triggerUpdate:!1},onLinkClick:{triggerUpdate:!1},onLinkRightClick:{triggerUpdate:!1},onLinkHover:{triggerUpdate:!1},onBackgroundClick:{triggerUpdate:!1},onBackgroundRightClick:{triggerUpdate:!1},showPointerCursor:{default:!0,triggerUpdate:!1}},dY),pY),methods:n1(n1({zoomToFit:function(e,t,n){for(var s,o=arguments.length,a=new Array(o>3?o-3:0),c=3;c<o;c++)a[c-3]=arguments[c];return e.renderObjs.fitToBbox((s=e.forceGraph).getGraphBbox.apply(s,a),t,n),this},pauseAnimation:function(e){return e.animationFrameRequestId!==null&&(cancelAnimationFrame(e.animationFrameRequestId),e.animationFrameRequestId=null),this},resumeAnimation:function(e){return e.animationFrameRequestId===null&&this._animationCycle(),this},_animationCycle:function(e){e.enablePointerInteraction&&(this.renderer().domElement.style.cursor=null),e.forceGraph.tickFrame(),e.renderObjs.tick(),e.animationFrameRequestId=requestAnimationFrame(this._animationCycle)},scene:function(e){return e.renderObjs.scene()},camera:function(e){return e.renderObjs.camera()},renderer:function(e){return e.renderObjs.renderer()},controls:function(e){return e.renderObjs.controls()},tbControls:function(e){return e.renderObjs.tbControls()},_destructor:function(){this.pauseAnimation(),this.graphData({nodes:[],links:[]})}},fY),mY),stateInit:function(e){var t=e.controlType,n=e.rendererConfig,s=e.extraRenderers,o=new MA;return{forceGraph:o,renderObjs:b3({controlType:t,rendererConfig:n,extraRenderers:s}).objects([o]).lights([new aE.AmbientLight(13421772,Math.PI),new aE.DirectionalLight(16777215,.6*Math.PI)])}},init:function(e,t){e.innerHTML="",e.appendChild(t.container=document.createElement("div")),t.container.style.position="relative";var n=document.createElement("div");t.container.appendChild(n),t.renderObjs(n);var s=t.renderObjs.camera(),o=t.renderObjs.renderer(),a=t.renderObjs.controls();a.enabled=!!t.enableNavigationControls,t.lastSetCameraZ=s.position.z;var c;t.container.appendChild(c=document.createElement("div")),c.className="graph-info-msg",c.textContent="",t.forceGraph.onLoading(function(){c.textContent="Loading..."}).onFinishLoading(function(){c.textContent=""}).onUpdate(function(){t.graphData=t.forceGraph.graphData(),s.position.x===0&&s.position.y===0&&s.position.z===t.lastSetCameraZ&&t.graphData.nodes.length&&(s.lookAt(t.forceGraph.position),t.lastSetCameraZ=s.position.z=Math.cbrt(t.graphData.nodes.length)*hY)}).onFinishUpdate(function(){if(t._dragControls){var u=t.graphData.nodes.find(function(p){return p.__initialFixedPos&&!p.__disposeControlsAfterDrag});u?u.__disposeControlsAfterDrag=!0:t._dragControls.dispose(),t._dragControls=void 0}if(t.enableNodeDrag&&t.enablePointerInteraction&&t.forceEngine==="d3"){var d=t._dragControls=new V(t.graphData.nodes.map(function(p){return p.__threeObj}).filter(function(p){return p}),s,o.domElement);d.addEventListener("dragstart",function(p){var m=Zd(p.object);if(m){a.enabled=!1,p.object.__initialPos=p.object.position.clone(),p.object.__prevPos=p.object.position.clone();var y=m.__data;!y.__initialFixedPos&&(y.__initialFixedPos={fx:y.fx,fy:y.fy,fz:y.fz}),!y.__initialPos&&(y.__initialPos={x:y.x,y:y.y,z:y.z}),["x","y","z"].forEach(function(M){return y["f".concat(M)]=y[M]}),o.domElement.classList.add("grabbable")}}),d.addEventListener("drag",function(p){var m=Zd(p.object);if(m){if(!p.object.hasOwnProperty("__graphObjType")){var y=p.object.__initialPos,M=p.object.__prevPos,T=p.object.position;m.position.add(T.clone().sub(M)),M.copy(T),T.copy(y)}var G=m.__data,z=m.position,I={x:z.x-G.x,y:z.y-G.y,z:z.z-G.z};["x","y","z"].forEach(function(J){return G["f".concat(J)]=G[J]=z[J]}),t.forceGraph.d3AlphaTarget(.3).resetCountdown(),G.__dragged=!0,t.onNodeDrag(G,I)}}),d.addEventListener("dragend",function(p){var m=Zd(p.object);if(m){delete p.object.__initialPos,delete p.object.__prevPos;var y=m.__data;y.__disposeControlsAfterDrag&&(d.dispose(),delete y.__disposeControlsAfterDrag);var M=y.__initialFixedPos,T=y.__initialPos,G={x:T.x-y.x,y:T.y-y.y,z:T.z-y.z};if(M&&(["x","y","z"].forEach(function(I){var J="f".concat(I);M[J]===void 0&&delete y[J]}),delete y.__initialFixedPos,delete y.__initialPos,y.__dragged&&(delete y.__dragged,t.onNodeDragEnd(y,G))),t.forceGraph.d3AlphaTarget(0).resetCountdown(),t.enableNavigationControls){var z;a.enabled=!0,a._status&&((z=a._onPointerCancel)===null||z===void 0||z.call(a)),a.domElement&&a.domElement.ownerDocument&&a.domElement.ownerDocument.dispatchEvent(new PointerEvent("pointerup",{pointerType:"touch"}))}o.domElement.classList.remove("grabbable")}})}}),aE.REVISION<155&&(t.renderObjs.renderer().useLegacyLights=!1),t.renderObjs.hoverOrderComparator(function(u,d){var p=Zd(u);if(!p)return 1;var m=Zd(d);if(!m)return-1;var y=function(T){return T.__graphObjType==="node"};return y(m)-y(p)}).tooltipContent(function(u){var d=Zd(u);return d&&ks(t["".concat(d.__graphObjType,"Label")])(d.__data)||""}).hoverDuringDrag(!1).onHover(function(u){var d=Zd(u);if(d!==t.hoverObj){var p=t.hoverObj?t.hoverObj.__graphObjType:null,m=t.hoverObj?t.hoverObj.__data:null,y=d?d.__graphObjType:null,M=d?d.__data:null;if(p&&p!==y){var T=t["on".concat(p==="node"?"Node":"Link","Hover")];T&&T(null,m)}if(y){var G=t["on".concat(y==="node"?"Node":"Link","Hover")];G&&G(M,p===y?m:null)}o.domElement.classList[(d&&t["on".concat(y==="node"?"Node":"Link","Click")]||!d&&t.onBackgroundClick)&&ks(t.showPointerCursor)(M)?"add":"remove"]("clickable"),t.hoverObj=d}}).clickAfterDrag(!1).onClick(function(u,d){var p=Zd(u);if(p){var m=t["on".concat(p.__graphObjType==="node"?"Node":"Link","Click")];m&&m(p.__data,d)}else t.onBackgroundClick&&t.onBackgroundClick(d)}).onRightClick(function(u,d){var p=Zd(u);if(p){var m=t["on".concat(p.__graphObjType==="node"?"Node":"Link","RightClick")];m&&m(p.__data,d)}else t.onBackgroundRightClick&&t.onBackgroundRightClick(d)}),this._animationCycle()}});function Zd(i){for(var e=i;e&&!e.hasOwnProperty("__graphObjType");)e=e.parent;return e}},94660:function(se,ee){"use strict";var b={value:()=>{}};function w(){for(var C=0,x=arguments.length,E={},N;C<x;++C){if(!(N=arguments[C]+"")||N in E||/[\s.]/.test(N))throw new Error("illegal type: "+N);E[N]=[]}return new k(E)}function k(C){this._=C}function O(C,x){return C.trim().split(/^|\s+/).map(function(E){var N="",L=E.indexOf(".");if(L>=0&&(N=E.slice(L+1),E=E.slice(0,L)),E&&!x.hasOwnProperty(E))throw new Error("unknown type: "+E);return{type:E,name:N}})}k.prototype=w.prototype={constructor:k,on:function(C,x){var E=this._,N=O(C+"",E),L,P=-1,W=N.length;if(arguments.length<2){for(;++P<W;)if((L=(C=N[P]).type)&&(L=R(E[L],C.name)))return L;return}if(x!=null&&typeof x!="function")throw new Error("invalid callback: "+x);for(;++P<W;)if(L=(C=N[P]).type)E[L]=S(E[L],C.name,x);else if(x==null)for(L in E)E[L]=S(E[L],C.name,null);return this},copy:function(){var C={},x=this._;for(var E in x)C[E]=x[E].slice();return new k(C)},call:function(C,x){if((L=arguments.length-2)>0)for(var E=new Array(L),N=0,L,P;N<L;++N)E[N]=arguments[N+2];if(!this._.hasOwnProperty(C))throw new Error("unknown type: "+C);for(P=this._[C],N=0,L=P.length;N<L;++N)P[N].value.apply(x,E)},apply:function(C,x,E){if(!this._.hasOwnProperty(C))throw new Error("unknown type: "+C);for(var N=this._[C],L=0,P=N.length;L<P;++L)N[L].value.apply(x,E)}};function R(C,x){for(var E=0,N=C.length,L;E<N;++E)if((L=C[E]).name===x)return L.value}function S(C,x,E){for(var N=0,L=C.length;N<L;++N)if(C[N].name===x){C[N]=b,C=C.slice(0,N).concat(C.slice(N+1));break}return E!=null&&C.push({name:x,value:E}),C}ee.Z=w},92770:function(se,ee,b){"use strict";b.d(ee,{Sc:function(){return Ge},y3:function(){return L}});var w=b(48202);const k=w.XA,O=w.a_,R=w.yQ,S=w.Hs,C=w.Ec,x=w.dx,E=w.LU,N=w.Rm,L=w.y3,P=w.qK,W=w.pb,Y=w.j,ie=w.sO,pe=w.BZ,fe=w.EK,ae=w.Db,ye=w.Fx,ue=w.tU,Ne=w.Ym,Te=w.rs,_e=w.QR,Xe=w.TB,Se=w.oH,Ge=w.Sc,He=w.BN,vt=w.it,It=w.$r,zt=w.QM,Yt=w.AV;var At=(w.y3,w.y3);const lt=w.GH,Ot=w.SO,le=w.uZ,Fe=w.yU,gt=w.F1,Jt=w.re},54375:function(se,ee,b){"use strict";b.d(ee,{Ud:function(){return ie},Yy:function(){return O}});const w=Symbol("Comlink.proxy"),k=Symbol("Comlink.endpoint"),O=Symbol("Comlink.releaseProxy"),R=Symbol("Comlink.finalizer"),S=Symbol("Comlink.thrown"),C=lt=>typeof lt=="object"&<!==null||typeof lt=="function",x={canHandle:lt=>C(lt)&<[w],serialize(lt){const{port1:Ot,port2:le}=new MessageChannel;return P(lt,Ot),[le,[le]]},deserialize(lt){return lt.start(),ie(lt)}},E={canHandle:lt=>C(lt)&&S in lt,serialize({value:lt}){let Ot;return lt instanceof Error?Ot={isError:!0,value:{message:lt.message,name:lt.name,stack:lt.stack}}:Ot={isError:!1,value:lt},[Ot,[]]},deserialize(lt){throw lt.isError?Object.assign(new Error(lt.value.message),lt.value):lt.value}},N=new Map([["proxy",x],["throw",E]]);function L(lt,Ot){for(const le of lt)if(Ot===le||le==="*"||le instanceof RegExp&&le.test(Ot))return!0;return!1}function P(lt,Ot=globalThis,le=["*"]){Ot.addEventListener("message",function Fe(gt){if(!gt||!gt.data)return;if(!L(le,gt.origin)){console.warn(`Invalid origin '${gt.origin}' for comlink proxy`);return}const{id:Jt,type:Ze,path:rt}=Object.assign({path:[]},gt.data),Mt=(gt.data.argumentList||[]).map(zt);let Ue;try{const Ye=rt.slice(0,-1).reduce((ge,Ke)=>ge[Ke],lt),be=rt.reduce((ge,Ke)=>ge[Ke],lt);switch(Ze){case"GET":Ue=be;break;case"SET":Ye[rt.slice(-1)[0]]=zt(gt.data.value),Ue=!0;break;case"APPLY":Ue=be.apply(Ye,Mt);break;case"CONSTRUCT":{const ge=new be(...Mt);Ue=He(ge)}break;case"ENDPOINT":{const{port1:ge,port2:Ke}=new MessageChannel;P(lt,Ke),Ue=Ge(ge,[ge])}break;case"RELEASE":Ue=void 0;break;default:return}}catch(Ye){Ue={value:Ye,[S]:0}}Promise.resolve(Ue).catch(Ye=>({value:Ye,[S]:0})).then(Ye=>{const[be,ge]=It(Ye);Ot.postMessage(Object.assign(Object.assign({},be),{id:Jt}),ge),Ze==="RELEASE"&&(Ot.removeEventListener("message",Fe),Y(Ot),R in lt&&typeof lt[R]=="function"&<[R]())}).catch(Ye=>{const[be,ge]=It({value:new TypeError("Unserializable return value"),[S]:0});Ot.postMessage(Object.assign(Object.assign({},be),{id:Jt}),ge)})}),Ot.start&&Ot.start()}function W(lt){return lt.constructor.name==="MessagePort"}function Y(lt){W(lt)&<.close()}function ie(lt,Ot){return Te(lt,[],Ot)}function pe(lt){if(lt)throw new Error("Proxy has been released and is not useable")}function fe(lt){return Yt(lt,{type:"RELEASE"}).then(()=>{Y(lt)})}const ae=new WeakMap,ye="FinalizationRegistry"in globalThis&&new FinalizationRegistry(lt=>{const Ot=(ae.get(lt)||0)-1;ae.set(lt,Ot),Ot===0&&fe(lt)});function ue(lt,Ot){const le=(ae.get(Ot)||0)+1;ae.set(Ot,le),ye&&ye.register(lt,Ot,lt)}function Ne(lt){ye&&ye.unregister(lt)}function Te(lt,Ot=[],le=function(){}){let Fe=!1;const gt=new Proxy(le,{get(Jt,Ze){if(pe(Fe),Ze===O)return()=>{Ne(gt),fe(lt),Fe=!0};if(Ze==="then"){if(Ot.length===0)return{then:()=>gt};const rt=Yt(lt,{type:"GET",path:Ot.map(Mt=>Mt.toString())}).then(zt);return rt.then.bind(rt)}return Te(lt,[...Ot,Ze])},set(Jt,Ze,rt){pe(Fe);const[Mt,Ue]=It(rt);return Yt(lt,{type:"SET",path:[...Ot,Ze].map(Ye=>Ye.toString()),value:Mt},Ue).then(zt)},apply(Jt,Ze,rt){pe(Fe);const Mt=Ot[Ot.length-1];if(Mt===k)return Yt(lt,{type:"ENDPOINT"}).then(zt);if(Mt==="bind")return Te(lt,Ot.slice(0,-1));const[Ue,Ye]=Xe(rt);return Yt(lt,{type:"APPLY",path:Ot.map(be=>be.toString()),argumentList:Ue},Ye).then(zt)},construct(Jt,Ze){pe(Fe);const[rt,Mt]=Xe(Ze);return Yt(lt,{type:"CONSTRUCT",path:Ot.map(Ue=>Ue.toString()),argumentList:rt},Mt).then(zt)}});return ue(gt,lt),gt}function _e(lt){return Array.prototype.concat.apply([],lt)}function Xe(lt){const Ot=lt.map(It);return[Ot.map(le=>le[0]),_e(Ot.map(le=>le[1]))]}const Se=new WeakMap;function Ge(lt,Ot){return Se.set(lt,Ot),lt}function He(lt){return Object.assign(lt,{[w]:!0})}function vt(lt,Ot=globalThis,le="*"){return{postMessage:(Fe,gt)=>lt.postMessage(Fe,le,gt),addEventListener:Ot.addEventListener.bind(Ot),removeEventListener:Ot.removeEventListener.bind(Ot)}}function It(lt){for(const[Ot,le]of N)if(le.canHandle(lt)){const[Fe,gt]=le.serialize(lt);return[{type:"HANDLER",name:Ot,value:Fe},gt]}return[{type:"RAW",value:lt},Se.get(lt)||[]]}function zt(lt){switch(lt.type){case"HANDLER":return N.get(lt.name).deserialize(lt.value);case"RAW":return lt.value}}function Yt(lt,Ot,le){return new Promise(Fe=>{const gt=At();lt.addEventListener("message",function Jt(Ze){!Ze.data||!Ze.data.id||Ze.data.id!==gt||(lt.removeEventListener("message",Jt),Fe(Ze.data))}),lt.start&<.start(),lt.postMessage(Object.assign({id:gt},Ot),le)})}function At(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}},51598:function(se,ee,b){"use strict";b.d(ee,{H:function(){return O},Z:function(){return w}});function w(R){const S=+this._x.call(null,R);return k(this.cover(S),S,R)}function k(R,S,C){if(isNaN(S))return R;var x,E=R._root,N={data:C},L=R._x0,P=R._x1,W,Y,ie,pe,fe;if(!E)return R._root=N,R;for(;E.length;)if((ie=S>=(W=(L+P)/2))?L=W:P=W,x=E,!(E=E[pe=+ie]))return x[pe]=N,R;if(Y=+R._x.call(null,E.data),S===Y)return N.next=E,x?x[pe]=N:R._root=N,R;do x=x?x[pe]=new Array(2):R._root=new Array(2),(ie=S>=(W=(L+P)/2))?L=W:P=W;while((pe=+ie)==(fe=+(Y>=W)));return x[fe]=E,x[pe]=N,R}function O(R){Array.isArray(R)||(R=Array.from(R));const S=R.length,C=new Float64Array(S);let x=1/0,E=-1/0;for(let N=0,L;N<S;++N)isNaN(L=+this._x.call(null,R[N]))||(C[N]=L,L<x&&(x=L),L>E&&(E=L));if(x>E)return this;this.cover(x).cover(E);for(let N=0;N<S;++N)k(this,C[N],R[N]);return this}},20928:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return W}});var w=b(51598),k=b(50654),O=b(97164),R=b(7138),S=b(8779),C=b(5115),x=b(42308),E=b(57670),N=b(60972),L=b(46032),P=b(83402);function W(fe,ae){var ye=new Y(ae==null?P.P:ae,NaN,NaN);return fe==null?ye:ye.addAll(fe)}function Y(fe,ae,ye){this._x=fe,this._x0=ae,this._x1=ye,this._root=void 0}function ie(fe){for(var ae={data:fe.data},ye=ae;fe=fe.next;)ye=ye.next={data:fe.data};return ae}var pe=W.prototype=Y.prototype;pe.copy=function(){var fe=new Y(this._x,this._x0,this._x1),ae=this._root,ye,ue;if(!ae)return fe;if(!ae.length)return fe._root=ie(ae),fe;for(ye=[{source:ae,target:fe._root=new Array(2)}];ae=ye.pop();)for(var Ne=0;Ne<2;++Ne)(ue=ae.source[Ne])&&(ue.length?ye.push({source:ue,target:ae.target[Ne]=new Array(2)}):ae.target[Ne]=ie(ue));return fe},pe.add=w.Z,pe.addAll=w.H,pe.cover=k.Z,pe.data=O.Z,pe.extent=R.Z,pe.find=S.Z,pe.remove=C.Z,pe.removeAll=C.x,pe.root=x.Z,pe.size=E.Z,pe.visit=N.Z,pe.visitAfter=L.Z,pe.x=P.Z},50654:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(k){if(isNaN(k=+k))return this;var O=this._x0,R=this._x1;if(isNaN(O))R=(O=Math.floor(k))+1;else{for(var S=R-O||1,C=this._root,x,E;O>k||k>=R;)switch(E=+(k<O),x=new Array(2),x[E]=C,C=x,S*=2,E){case 0:R=O+S;break;case 1:O=R-S;break}this._root&&this._root.length&&(this._root=C)}return this._x0=O,this._x1=R,this}},97164:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(){var k=[];return this.visit(function(O){if(!O.length)do k.push(O.data);while(O=O.next)}),k}},7138:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(k){return arguments.length?this.cover(+k[0][0]).cover(+k[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}},8779:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return k}});var w=b(66519);function k(O,R){var S,C=this._x0,x,E,N=this._x1,L=[],P=this._root,W,Y;for(P&&L.push(new w.Z(P,C,N)),R==null?R=1/0:(C=O-R,N=O+R);W=L.pop();)if(!(!(P=W.node)||(x=W.x0)>N||(E=W.x1)<C))if(P.length){var ie=(x+E)/2;L.push(new w.Z(P[1],ie,E),new w.Z(P[0],x,ie)),(Y=+(O>=ie))&&(W=L[L.length-1],L[L.length-1]=L[L.length-1-Y],L[L.length-1-Y]=W)}else{var pe=Math.abs(O-+this._x.call(null,P.data));pe<R&&(R=pe,C=O-pe,N=O+pe,S=P.data)}return S}},66519:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(k,O,R){this.node=k,this.x0=O,this.x1=R}},5115:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w},x:function(){return k}});function w(O){if(isNaN(P=+this._x.call(null,O)))return this;var R,S=this._root,C,x,E,N=this._x0,L=this._x1,P,W,Y,ie,pe;if(!S)return this;if(S.length)for(;;){if((Y=P>=(W=(N+L)/2))?N=W:L=W,R=S,!(S=S[ie=+Y]))return this;if(!S.length)break;R[ie+1&1]&&(C=R,pe=ie)}for(;S.data!==O;)if(x=S,!(S=S.next))return this;return(E=S.next)&&delete S.next,x?(E?x.next=E:delete x.next,this):R?(E?R[ie]=E:delete R[ie],(S=R[0]||R[1])&&S===(R[1]||R[0])&&!S.length&&(C?C[pe]=S:this._root=S),this):(this._root=E,this)}function k(O){for(var R=0,S=O.length;R<S;++R)this.remove(O[R]);return this}},42308:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(){return this._root}},57670:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(){var k=0;return this.visit(function(O){if(!O.length)do++k;while(O=O.next)}),k}},60972:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return k}});var w=b(66519);function k(O){var R=[],S,C=this._root,x,E,N;for(C&&R.push(new w.Z(C,this._x0,this._x1));S=R.pop();)if(!O(C=S.node,E=S.x0,N=S.x1)&&C.length){var L=(E+N)/2;(x=C[1])&&R.push(new w.Z(x,L,N)),(x=C[0])&&R.push(new w.Z(x,E,L))}return this}},46032:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return k}});var w=b(66519);function k(O){var R=[],S=[],C;for(this._root&&R.push(new w.Z(this._root,this._x0,this._x1));C=R.pop();){var x=C.node;if(x.length){var E,N=C.x0,L=C.x1,P=(N+L)/2;(E=x[0])&&R.push(new w.Z(E,N,P)),(E=x[1])&&R.push(new w.Z(E,P,L))}S.push(C)}for(;C=S.pop();)O(C.node,C.x0,C.x1);return this}},83402:function(se,ee,b){"use strict";b.d(ee,{P:function(){return w},Z:function(){return k}});function w(O){return O[0]}function k(O){return arguments.length?(this._x=O,this):this._x}},45736:function(se,ee,b){"use strict";b.d(ee,{HT:function(){return pe}});var w=0,k=0,O=0,R=1e3,S,C,x=0,E=0,N=0,L=typeof performance=="object"&&performance.now?performance:Date,P=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(Te){setTimeout(Te,17)};function W(){return E||(P(Y),E=L.now()+N)}function Y(){E=0}function ie(){this._call=this._time=this._next=null}ie.prototype=pe.prototype={constructor:ie,restart:function(Te,_e,Xe){if(typeof Te!="function")throw new TypeError("callback is not a function");Xe=(Xe==null?W():+Xe)+(_e==null?0:+_e),!this._next&&C!==this&&(C?C._next=this:S=this,C=this),this._call=Te,this._time=Xe,Ne()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ne())}};function pe(Te,_e,Xe){var Se=new ie;return Se.restart(Te,_e,Xe),Se}function fe(){W(),++w;for(var Te=S,_e;Te;)(_e=E-Te._time)>=0&&Te._call.call(void 0,_e),Te=Te._next;--w}function ae(){E=(x=L.now())+N,w=k=0;try{fe()}finally{w=0,ue(),E=0}}function ye(){var Te=L.now(),_e=Te-x;_e>R&&(N-=_e,x=Te)}function ue(){for(var Te,_e=S,Xe,Se=1/0;_e;)_e._call?(Se>_e._time&&(Se=_e._time),Te=_e,_e=_e._next):(Xe=_e._next,_e._next=null,_e=Te?Te._next=Xe:S=Xe);C=Te,Ne(Se)}function Ne(Te){if(!w){k&&(k=clearTimeout(k));var _e=Te-E;_e>24?(Te<1/0&&(k=setTimeout(ae,Te-L.now()-N)),O&&(O=clearInterval(O))):(O||(x=L.now(),O=setInterval(ye,R)),w=1,P(ae))}}},46846:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(k,O){var R,S=1;k==null&&(k=0),O==null&&(O=0);function C(){var x,E=R.length,N,L=0,P=0;for(x=0;x<E;++x)N=R[x],L+=N.x,P+=N.y;for(L=(L/E-k)*S,P=(P/E-O)*S,x=0;x<E;++x)N=R[x],N.x-=L,N.y-=P}return C.initialize=function(x){R=x},C.x=function(x){return arguments.length?(k=+x,C):k},C.y=function(x){return arguments.length?(O=+x,C):O},C.strength=function(x){return arguments.length?(S=+x,C):S},C}},89281:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return C}});var w=b(46632),k=b(13548),O=b(79778);function R(x){return x.x+x.vx}function S(x){return x.y+x.vy}function C(x){var E,N,L,P=1,W=1;typeof x!="function"&&(x=(0,k.Z)(x==null?1:+x));function Y(){for(var fe,ae=E.length,ye,ue,Ne,Te,_e,Xe,Se=0;Se<W;++Se)for(ye=(0,w.Z)(E,R,S).visitAfter(ie),fe=0;fe<ae;++fe)ue=E[fe],_e=N[ue.index],Xe=_e*_e,Ne=ue.x+ue.vx,Te=ue.y+ue.vy,ye.visit(Ge);function Ge(He,vt,It,zt,Yt){var At=He.data,lt=He.r,Ot=_e+lt;if(At){if(At.index>ue.index){var le=Ne-At.x-At.vx,Fe=Te-At.y-At.vy,gt=le*le+Fe*Fe;gt<Ot*Ot&&(le===0&&(le=(0,O.Z)(L),gt+=le*le),Fe===0&&(Fe=(0,O.Z)(L),gt+=Fe*Fe),gt=(Ot-(gt=Math.sqrt(gt)))/gt*P,ue.vx+=(le*=gt)*(Ot=(lt*=lt)/(Xe+lt)),ue.vy+=(Fe*=gt)*Ot,At.vx-=le*(Ot=1-Ot),At.vy-=Fe*Ot)}return}return vt>Ne+Ot||zt<Ne-Ot||It>Te+Ot||Yt<Te-Ot}}function ie(fe){if(fe.data)return fe.r=N[fe.data.index];for(var ae=fe.r=0;ae<4;++ae)fe[ae]&&fe[ae].r>fe.r&&(fe.r=fe[ae].r)}function pe(){if(E){var fe,ae=E.length,ye;for(N=new Array(ae),fe=0;fe<ae;++fe)ye=E[fe],N[ye.index]=+x(ye,fe,E)}}return Y.initialize=function(fe,ae){E=fe,L=ae,pe()},Y.iterations=function(fe){return arguments.length?(W=+fe,Y):W},Y.strength=function(fe){return arguments.length?(P=+fe,Y):P},Y.radius=function(fe){return arguments.length?(x=typeof fe=="function"?fe:(0,k.Z)(+fe),pe(),Y):x},Y}},13548:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(k){return function(){return k}}},79778:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(k){return(k()-.5)*1e-6}},3168:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return R}});const w=1664525,k=1013904223,O=4294967296;function R(){let S=1;return()=>(S=(w*S+k)%O)/O}},56561:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return S}});var w=b(13548),k=b(79778);function O(C){return C.index}function R(C,x){var E=C.get(x);if(!E)throw new Error("node not found: "+x);return E}function S(C){var x=O,E=ae,N,L=(0,w.Z)(30),P,W,Y,ie,pe,fe=1;C==null&&(C=[]);function ae(_e){return 1/Math.min(Y[_e.source.index],Y[_e.target.index])}function ye(_e){for(var Xe=0,Se=C.length;Xe<fe;++Xe)for(var Ge=0,He,vt,It,zt,Yt,At,lt;Ge<Se;++Ge)He=C[Ge],vt=He.source,It=He.target,zt=It.x+It.vx-vt.x-vt.vx||(0,k.Z)(pe),Yt=It.y+It.vy-vt.y-vt.vy||(0,k.Z)(pe),At=Math.sqrt(zt*zt+Yt*Yt),At=(At-P[Ge])/At*_e*N[Ge],zt*=At,Yt*=At,It.vx-=zt*(lt=ie[Ge]),It.vy-=Yt*lt,vt.vx+=zt*(lt=1-lt),vt.vy+=Yt*lt}function ue(){if(W){var _e,Xe=W.length,Se=C.length,Ge=new Map(W.map((vt,It)=>[x(vt,It,W),vt])),He;for(_e=0,Y=new Array(Xe);_e<Se;++_e)He=C[_e],He.index=_e,typeof He.source!="object"&&(He.source=R(Ge,He.source)),typeof He.target!="object"&&(He.target=R(Ge,He.target)),Y[He.source.index]=(Y[He.source.index]||0)+1,Y[He.target.index]=(Y[He.target.index]||0)+1;for(_e=0,ie=new Array(Se);_e<Se;++_e)He=C[_e],ie[_e]=Y[He.source.index]/(Y[He.source.index]+Y[He.target.index]);N=new Array(Se),Ne(),P=new Array(Se),Te()}}function Ne(){if(W)for(var _e=0,Xe=C.length;_e<Xe;++_e)N[_e]=+E(C[_e],_e,C)}function Te(){if(W)for(var _e=0,Xe=C.length;_e<Xe;++_e)P[_e]=+L(C[_e],_e,C)}return ye.initialize=function(_e,Xe){W=_e,pe=Xe,ue()},ye.links=function(_e){return arguments.length?(C=_e,ue(),ye):C},ye.id=function(_e){return arguments.length?(x=_e,ye):x},ye.iterations=function(_e){return arguments.length?(fe=+_e,ye):fe},ye.strength=function(_e){return arguments.length?(E=typeof _e=="function"?_e:(0,w.Z)(+_e),Ne(),ye):E},ye.distance=function(_e){return arguments.length?(L=typeof _e=="function"?_e:(0,w.Z)(+_e),Te(),ye):L},ye}},65475:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return S}});var w=b(46632),k=b(13548),O=b(79778),R=b(80616);function S(){var C,x,E,N,L=(0,k.Z)(-30),P,W=1,Y=1/0,ie=.81;function pe(ue){var Ne,Te=C.length,_e=(0,w.Z)(C,R.x,R.y).visitAfter(ae);for(N=ue,Ne=0;Ne<Te;++Ne)x=C[Ne],_e.visit(ye)}function fe(){if(C){var ue,Ne=C.length,Te;for(P=new Array(Ne),ue=0;ue<Ne;++ue)Te=C[ue],P[Te.index]=+L(Te,ue,C)}}function ae(ue){var Ne=0,Te,_e,Xe=0,Se,Ge,He;if(ue.length){for(Se=Ge=He=0;He<4;++He)(Te=ue[He])&&(_e=Math.abs(Te.value))&&(Ne+=Te.value,Xe+=_e,Se+=_e*Te.x,Ge+=_e*Te.y);ue.x=Se/Xe,ue.y=Ge/Xe}else{Te=ue,Te.x=Te.data.x,Te.y=Te.data.y;do Ne+=P[Te.data.index];while(Te=Te.next)}ue.value=Ne}function ye(ue,Ne,Te,_e){if(!ue.value)return!0;var Xe=ue.x-x.x,Se=ue.y-x.y,Ge=_e-Ne,He=Xe*Xe+Se*Se;if(Ge*Ge/ie<He)return He<Y&&(Xe===0&&(Xe=(0,O.Z)(E),He+=Xe*Xe),Se===0&&(Se=(0,O.Z)(E),He+=Se*Se),He<W&&(He=Math.sqrt(W*He)),x.vx+=Xe*ue.value*N/He,x.vy+=Se*ue.value*N/He),!0;if(ue.length||He>=Y)return;(ue.data!==x||ue.next)&&(Xe===0&&(Xe=(0,O.Z)(E),He+=Xe*Xe),Se===0&&(Se=(0,O.Z)(E),He+=Se*Se),He<W&&(He=Math.sqrt(W*He)));do ue.data!==x&&(Ge=P[ue.data.index]*N/He,x.vx+=Xe*Ge,x.vy+=Se*Ge);while(ue=ue.next)}return pe.initialize=function(ue,Ne){C=ue,E=Ne,fe()},pe.strength=function(ue){return arguments.length?(L=typeof ue=="function"?ue:(0,k.Z)(+ue),fe(),pe):L},pe.distanceMin=function(ue){return arguments.length?(W=ue*ue,pe):Math.sqrt(W)},pe.distanceMax=function(ue){return arguments.length?(Y=ue*ue,pe):Math.sqrt(Y)},pe.theta=function(ue){return arguments.length?(ie=ue*ue,pe):Math.sqrt(ie)},pe}},61217:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return k}});var w=b(13548);function k(O,R,S){var C,x=(0,w.Z)(.1),E,N;typeof O!="function"&&(O=(0,w.Z)(+O)),R==null&&(R=0),S==null&&(S=0);function L(W){for(var Y=0,ie=C.length;Y<ie;++Y){var pe=C[Y],fe=pe.x-R||1e-6,ae=pe.y-S||1e-6,ye=Math.sqrt(fe*fe+ae*ae),ue=(N[Y]-ye)*E[Y]*W/ye;pe.vx+=fe*ue,pe.vy+=ae*ue}}function P(){if(C){var W,Y=C.length;for(E=new Array(Y),N=new Array(Y),W=0;W<Y;++W)N[W]=+O(C[W],W,C),E[W]=isNaN(N[W])?0:+x(C[W],W,C)}}return L.initialize=function(W){C=W,P()},L.strength=function(W){return arguments.length?(x=typeof W=="function"?W:(0,w.Z)(+W),P(),L):x},L.radius=function(W){return arguments.length?(O=typeof W=="function"?W:(0,w.Z)(+W),P(),L):O},L.x=function(W){return arguments.length?(R=+W,L):R},L.y=function(W){return arguments.length?(S=+W,L):S},L}},80616:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return E},x:function(){return R},y:function(){return S}});var w=b(94660),k=b(45736),O=b(3168);function R(N){return N.x}function S(N){return N.y}var C=10,x=Math.PI*(3-Math.sqrt(5));function E(N){var L,P=1,W=.001,Y=1-Math.pow(W,1/300),ie=0,pe=.6,fe=new Map,ae=(0,k.HT)(Ne),ye=(0,w.Z)("tick","end"),ue=(0,O.Z)();N==null&&(N=[]);function Ne(){Te(),ye.call("tick",L),P<W&&(ae.stop(),ye.call("end",L))}function Te(Se){var Ge,He=N.length,vt;Se===void 0&&(Se=1);for(var It=0;It<Se;++It)for(P+=(ie-P)*Y,fe.forEach(function(zt){zt(P)}),Ge=0;Ge<He;++Ge)vt=N[Ge],vt.fx==null?vt.x+=vt.vx*=pe:(vt.x=vt.fx,vt.vx=0),vt.fy==null?vt.y+=vt.vy*=pe:(vt.y=vt.fy,vt.vy=0);return L}function _e(){for(var Se=0,Ge=N.length,He;Se<Ge;++Se){if(He=N[Se],He.index=Se,He.fx!=null&&(He.x=He.fx),He.fy!=null&&(He.y=He.fy),isNaN(He.x)||isNaN(He.y)){var vt=C*Math.sqrt(.5+Se),It=Se*x;He.x=vt*Math.cos(It),He.y=vt*Math.sin(It)}(isNaN(He.vx)||isNaN(He.vy))&&(He.vx=He.vy=0)}}function Xe(Se){return Se.initialize&&Se.initialize(N,ue),Se}return _e(),L={tick:Te,restart:function(){return ae.restart(Ne),L},stop:function(){return ae.stop(),L},nodes:function(Se){return arguments.length?(N=Se,_e(),fe.forEach(Xe),L):N},alpha:function(Se){return arguments.length?(P=+Se,L):P},alphaMin:function(Se){return arguments.length?(W=+Se,L):W},alphaDecay:function(Se){return arguments.length?(Y=+Se,L):+Y},alphaTarget:function(Se){return arguments.length?(ie=+Se,L):ie},velocityDecay:function(Se){return arguments.length?(pe=1-Se,L):1-pe},randomSource:function(Se){return arguments.length?(ue=Se,fe.forEach(Xe),L):ue},force:function(Se,Ge){return arguments.length>1?(Ge==null?fe.delete(Se):fe.set(Se,Xe(Ge)),L):fe.get(Se)},find:function(Se,Ge,He){var vt=0,It=N.length,zt,Yt,At,lt,Ot;for(He==null?He=1/0:He*=He,vt=0;vt<It;++vt)lt=N[vt],zt=Se-lt.x,Yt=Ge-lt.y,At=zt*zt+Yt*Yt,At<He&&(Ot=lt,He=At);return Ot},on:function(Se,Ge){return arguments.length>1?(ye.on(Se,Ge),L):ye.on(Se)}}}},70341:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return k}});var w=b(13548);function k(O){var R=(0,w.Z)(.1),S,C,x;typeof O!="function"&&(O=(0,w.Z)(O==null?0:+O));function E(L){for(var P=0,W=S.length,Y;P<W;++P)Y=S[P],Y.vx+=(x[P]-Y.x)*C[P]*L}function N(){if(S){var L,P=S.length;for(C=new Array(P),x=new Array(P),L=0;L<P;++L)C[L]=isNaN(x[L]=+O(S[L],L,S))?0:+R(S[L],L,S)}}return E.initialize=function(L){S=L,N()},E.strength=function(L){return arguments.length?(R=typeof L=="function"?L:(0,w.Z)(+L),N(),E):R},E.x=function(L){return arguments.length?(O=typeof L=="function"?L:(0,w.Z)(+L),N(),E):O},E}},12688:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return k}});var w=b(13548);function k(O){var R=(0,w.Z)(.1),S,C,x;typeof O!="function"&&(O=(0,w.Z)(O==null?0:+O));function E(L){for(var P=0,W=S.length,Y;P<W;++P)Y=S[P],Y.vy+=(x[P]-Y.y)*C[P]*L}function N(){if(S){var L,P=S.length;for(C=new Array(P),x=new Array(P),L=0;L<P;++L)C[L]=isNaN(x[L]=+O(S[L],L,S))?0:+R(S[L],L,S)}}return E.initialize=function(L){S=L,N()},E.strength=function(L){return arguments.length?(R=typeof L=="function"?L:(0,w.Z)(+L),N(),E):R},E.y=function(L){return arguments.length?(O=typeof L=="function"?L:(0,w.Z)(+L),N(),E):O},E}},23473:function(se,ee,b){"use strict";b.d(ee,{H:function(){return O},Z:function(){return w}});function w(R){const S=+this._x.call(null,R),C=+this._y.call(null,R),x=+this._z.call(null,R);return k(this.cover(S,C,x),S,C,x,R)}function k(R,S,C,x,E){if(isNaN(S)||isNaN(C)||isNaN(x))return R;var N,L=R._root,P={data:E},W=R._x0,Y=R._y0,ie=R._z0,pe=R._x1,fe=R._y1,ae=R._z1,ye,ue,Ne,Te,_e,Xe,Se,Ge,He,vt,It;if(!L)return R._root=P,R;for(;L.length;)if((Se=S>=(ye=(W+pe)/2))?W=ye:pe=ye,(Ge=C>=(ue=(Y+fe)/2))?Y=ue:fe=ue,(He=x>=(Ne=(ie+ae)/2))?ie=Ne:ae=Ne,N=L,!(L=L[vt=He<<2|Ge<<1|Se]))return N[vt]=P,R;if(Te=+R._x.call(null,L.data),_e=+R._y.call(null,L.data),Xe=+R._z.call(null,L.data),S===Te&&C===_e&&x===Xe)return P.next=L,N?N[vt]=P:R._root=P,R;do N=N?N[vt]=new Array(8):R._root=new Array(8),(Se=S>=(ye=(W+pe)/2))?W=ye:pe=ye,(Ge=C>=(ue=(Y+fe)/2))?Y=ue:fe=ue,(He=x>=(Ne=(ie+ae)/2))?ie=Ne:ae=Ne;while((vt=He<<2|Ge<<1|Se)===(It=(Xe>=Ne)<<2|(_e>=ue)<<1|Te>=ye));return N[It]=L,N[vt]=P,R}function O(R){Array.isArray(R)||(R=Array.from(R));const S=R.length,C=new Float64Array(S),x=new Float64Array(S),E=new Float64Array(S);let N=1/0,L=1/0,P=1/0,W=-1/0,Y=-1/0,ie=-1/0;for(let pe=0,fe,ae,ye,ue;pe<S;++pe)isNaN(ae=+this._x.call(null,fe=R[pe]))||isNaN(ye=+this._y.call(null,fe))||isNaN(ue=+this._z.call(null,fe))||(C[pe]=ae,x[pe]=ye,E[pe]=ue,ae<N&&(N=ae),ae>W&&(W=ae),ye<L&&(L=ye),ye>Y&&(Y=ye),ue<P&&(P=ue),ue>ie&&(ie=ue));if(N>W||L>Y||P>ie)return this;this.cover(N,L,P).cover(W,Y,ie);for(let pe=0;pe<S;++pe)k(this,C[pe],x[pe],E[pe],R[pe]);return this}},55802:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(k,O,R){if(isNaN(k=+k)||isNaN(O=+O)||isNaN(R=+R))return this;var S=this._x0,C=this._y0,x=this._z0,E=this._x1,N=this._y1,L=this._z1;if(isNaN(S))E=(S=Math.floor(k))+1,N=(C=Math.floor(O))+1,L=(x=Math.floor(R))+1;else{for(var P=E-S||1,W=this._root,Y,ie;S>k||k>=E||C>O||O>=N||x>R||R>=L;)switch(ie=(R<x)<<2|(O<C)<<1|k<S,Y=new Array(8),Y[ie]=W,W=Y,P*=2,ie){case 0:E=S+P,N=C+P,L=x+P;break;case 1:S=E-P,N=C+P,L=x+P;break;case 2:E=S+P,C=N-P,L=x+P;break;case 3:S=E-P,C=N-P,L=x+P;break;case 4:E=S+P,N=C+P,x=L-P;break;case 5:S=E-P,N=C+P,x=L-P;break;case 6:E=S+P,C=N-P,x=L-P;break;case 7:S=E-P,C=N-P,x=L-P;break}this._root&&this._root.length&&(this._root=W)}return this._x0=S,this._y0=C,this._z0=x,this._x1=E,this._y1=N,this._z1=L,this}},65587:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(){var k=[];return this.visit(function(O){if(!O.length)do k.push(O.data);while(O=O.next)}),k}},31756:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(k){return arguments.length?this.cover(+k[0][0],+k[0][1],+k[0][2]).cover(+k[1][0],+k[1][1],+k[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}},60444:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return k}});var w=b(14086);function k(O,R,S,C){var x,E=this._x0,N=this._y0,L=this._z0,P,W,Y,ie,pe,fe,ae=this._x1,ye=this._y1,ue=this._z1,Ne=[],Te=this._root,_e,Xe;for(Te&&Ne.push(new w.Z(Te,E,N,L,ae,ye,ue)),C==null?C=1/0:(E=O-C,N=R-C,L=S-C,ae=O+C,ye=R+C,ue=S+C,C*=C);_e=Ne.pop();)if(!(!(Te=_e.node)||(P=_e.x0)>ae||(W=_e.y0)>ye||(Y=_e.z0)>ue||(ie=_e.x1)<E||(pe=_e.y1)<N||(fe=_e.z1)<L))if(Te.length){var Se=(P+ie)/2,Ge=(W+pe)/2,He=(Y+fe)/2;Ne.push(new w.Z(Te[7],Se,Ge,He,ie,pe,fe),new w.Z(Te[6],P,Ge,He,Se,pe,fe),new w.Z(Te[5],Se,W,He,ie,Ge,fe),new w.Z(Te[4],P,W,He,Se,Ge,fe),new w.Z(Te[3],Se,Ge,Y,ie,pe,He),new w.Z(Te[2],P,Ge,Y,Se,pe,He),new w.Z(Te[1],Se,W,Y,ie,Ge,He),new w.Z(Te[0],P,W,Y,Se,Ge,He)),(Xe=(S>=He)<<2|(R>=Ge)<<1|O>=Se)&&(_e=Ne[Ne.length-1],Ne[Ne.length-1]=Ne[Ne.length-1-Xe],Ne[Ne.length-1-Xe]=_e)}else{var vt=O-+this._x.call(null,Te.data),It=R-+this._y.call(null,Te.data),zt=S-+this._z.call(null,Te.data),Yt=vt*vt+It*It+zt*zt;if(Yt<C){var At=Math.sqrt(C=Yt);E=O-At,N=R-At,L=S-At,ae=O+At,ye=R+At,ue=S+At,x=Te.data}}return x}},14086:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(k,O,R,S,C,x,E){this.node=k,this.x0=O,this.y0=R,this.z0=S,this.x1=C,this.y1=x,this.z1=E}},67217:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return ie}});var w=b(23473),k=b(55802),O=b(65587),R=b(31756),S=b(60444),C=b(44576),x=b(76077),E=b(53212),N=b(56173),L=b(36427),P=b(79853),W=b(79840),Y=b(87325);function ie(ye,ue,Ne,Te){var _e=new pe(ue==null?P.P:ue,Ne==null?W.q:Ne,Te==null?Y.i:Te,NaN,NaN,NaN,NaN,NaN,NaN);return ye==null?_e:_e.addAll(ye)}function pe(ye,ue,Ne,Te,_e,Xe,Se,Ge,He){this._x=ye,this._y=ue,this._z=Ne,this._x0=Te,this._y0=_e,this._z0=Xe,this._x1=Se,this._y1=Ge,this._z1=He,this._root=void 0}function fe(ye){for(var ue={data:ye.data},Ne=ue;ye=ye.next;)Ne=Ne.next={data:ye.data};return ue}var ae=ie.prototype=pe.prototype;ae.copy=function(){var ye=new pe(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),ue=this._root,Ne,Te;if(!ue)return ye;if(!ue.length)return ye._root=fe(ue),ye;for(Ne=[{source:ue,target:ye._root=new Array(8)}];ue=Ne.pop();)for(var _e=0;_e<8;++_e)(Te=ue.source[_e])&&(Te.length?Ne.push({source:Te,target:ue.target[_e]=new Array(8)}):ue.target[_e]=fe(Te));return ye},ae.add=w.Z,ae.addAll=w.H,ae.cover=k.Z,ae.data=O.Z,ae.extent=R.Z,ae.find=S.Z,ae.remove=C.Z,ae.removeAll=C.x,ae.root=x.Z,ae.size=E.Z,ae.visit=N.Z,ae.visitAfter=L.Z,ae.x=P.Z,ae.y=W.Z,ae.z=Y.Z},44576:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w},x:function(){return k}});function w(O){if(isNaN(pe=+this._x.call(null,O))||isNaN(fe=+this._y.call(null,O))||isNaN(ae=+this._z.call(null,O)))return this;var R,S=this._root,C,x,E,N=this._x0,L=this._y0,P=this._z0,W=this._x1,Y=this._y1,ie=this._z1,pe,fe,ae,ye,ue,Ne,Te,_e,Xe,Se,Ge;if(!S)return this;if(S.length)for(;;){if((Te=pe>=(ye=(N+W)/2))?N=ye:W=ye,(_e=fe>=(ue=(L+Y)/2))?L=ue:Y=ue,(Xe=ae>=(Ne=(P+ie)/2))?P=Ne:ie=Ne,R=S,!(S=S[Se=Xe<<2|_e<<1|Te]))return this;if(!S.length)break;(R[Se+1&7]||R[Se+2&7]||R[Se+3&7]||R[Se+4&7]||R[Se+5&7]||R[Se+6&7]||R[Se+7&7])&&(C=R,Ge=Se)}for(;S.data!==O;)if(x=S,!(S=S.next))return this;return(E=S.next)&&delete S.next,x?(E?x.next=E:delete x.next,this):R?(E?R[Se]=E:delete R[Se],(S=R[0]||R[1]||R[2]||R[3]||R[4]||R[5]||R[6]||R[7])&&S===(R[7]||R[6]||R[5]||R[4]||R[3]||R[2]||R[1]||R[0])&&!S.length&&(C?C[Ge]=S:this._root=S),this):(this._root=E,this)}function k(O){for(var R=0,S=O.length;R<S;++R)this.remove(O[R]);return this}},76077:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(){return this._root}},53212:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(){var k=0;return this.visit(function(O){if(!O.length)do++k;while(O=O.next)}),k}},56173:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return k}});var w=b(14086);function k(O){var R=[],S,C=this._root,x,E,N,L,P,W,Y;for(C&&R.push(new w.Z(C,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));S=R.pop();)if(!O(C=S.node,E=S.x0,N=S.y0,L=S.z0,P=S.x1,W=S.y1,Y=S.z1)&&C.length){var ie=(E+P)/2,pe=(N+W)/2,fe=(L+Y)/2;(x=C[7])&&R.push(new w.Z(x,ie,pe,fe,P,W,Y)),(x=C[6])&&R.push(new w.Z(x,E,pe,fe,ie,W,Y)),(x=C[5])&&R.push(new w.Z(x,ie,N,fe,P,pe,Y)),(x=C[4])&&R.push(new w.Z(x,E,N,fe,ie,pe,Y)),(x=C[3])&&R.push(new w.Z(x,ie,pe,L,P,W,fe)),(x=C[2])&&R.push(new w.Z(x,E,pe,L,ie,W,fe)),(x=C[1])&&R.push(new w.Z(x,ie,N,L,P,pe,fe)),(x=C[0])&&R.push(new w.Z(x,E,N,L,ie,pe,fe))}return this}},36427:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return k}});var w=b(14086);function k(O){var R=[],S=[],C;for(this._root&&R.push(new w.Z(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));C=R.pop();){var x=C.node;if(x.length){var E,N=C.x0,L=C.y0,P=C.z0,W=C.x1,Y=C.y1,ie=C.z1,pe=(N+W)/2,fe=(L+Y)/2,ae=(P+ie)/2;(E=x[0])&&R.push(new w.Z(E,N,L,P,pe,fe,ae)),(E=x[1])&&R.push(new w.Z(E,pe,L,P,W,fe,ae)),(E=x[2])&&R.push(new w.Z(E,N,fe,P,pe,Y,ae)),(E=x[3])&&R.push(new w.Z(E,pe,fe,P,W,Y,ae)),(E=x[4])&&R.push(new w.Z(E,N,L,ae,pe,fe,ie)),(E=x[5])&&R.push(new w.Z(E,pe,L,ae,W,fe,ie)),(E=x[6])&&R.push(new w.Z(E,N,fe,ae,pe,Y,ie)),(E=x[7])&&R.push(new w.Z(E,pe,fe,ae,W,Y,ie))}S.push(C)}for(;C=S.pop();)O(C.node,C.x0,C.y0,C.z0,C.x1,C.y1,C.z1);return this}},79853:function(se,ee,b){"use strict";b.d(ee,{P:function(){return w},Z:function(){return k}});function w(O){return O[0]}function k(O){return arguments.length?(this._x=O,this):this._x}},79840:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return k},q:function(){return w}});function w(O){return O[1]}function k(O){return arguments.length?(this._y=O,this):this._y}},87325:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return k},i:function(){return w}});function w(O){return O[2]}function k(O){return arguments.length?(this._z=O,this):this._z}},59715:function(se,ee,b){"use strict";b.d(ee,{H:function(){return O},Z:function(){return w}});function w(R){const S=+this._x.call(null,R),C=+this._y.call(null,R);return k(this.cover(S,C),S,C,R)}function k(R,S,C,x){if(isNaN(S)||isNaN(C))return R;var E,N=R._root,L={data:x},P=R._x0,W=R._y0,Y=R._x1,ie=R._y1,pe,fe,ae,ye,ue,Ne,Te,_e;if(!N)return R._root=L,R;for(;N.length;)if((ue=S>=(pe=(P+Y)/2))?P=pe:Y=pe,(Ne=C>=(fe=(W+ie)/2))?W=fe:ie=fe,E=N,!(N=N[Te=Ne<<1|ue]))return E[Te]=L,R;if(ae=+R._x.call(null,N.data),ye=+R._y.call(null,N.data),S===ae&&C===ye)return L.next=N,E?E[Te]=L:R._root=L,R;do E=E?E[Te]=new Array(4):R._root=new Array(4),(ue=S>=(pe=(P+Y)/2))?P=pe:Y=pe,(Ne=C>=(fe=(W+ie)/2))?W=fe:ie=fe;while((Te=Ne<<1|ue)===(_e=(ye>=fe)<<1|ae>=pe));return E[_e]=N,E[Te]=L,R}function O(R){var S,C,x=R.length,E,N,L=new Array(x),P=new Array(x),W=1/0,Y=1/0,ie=-1/0,pe=-1/0;for(C=0;C<x;++C)isNaN(E=+this._x.call(null,S=R[C]))||isNaN(N=+this._y.call(null,S))||(L[C]=E,P[C]=N,E<W&&(W=E),E>ie&&(ie=E),N<Y&&(Y=N),N>pe&&(pe=N));if(W>ie||Y>pe)return this;for(this.cover(W,Y).cover(ie,pe),C=0;C<x;++C)k(this,L[C],P[C],R[C]);return this}},86290:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(k,O){if(isNaN(k=+k)||isNaN(O=+O))return this;var R=this._x0,S=this._y0,C=this._x1,x=this._y1;if(isNaN(R))C=(R=Math.floor(k))+1,x=(S=Math.floor(O))+1;else{for(var E=C-R||1,N=this._root,L,P;R>k||k>=C||S>O||O>=x;)switch(P=(O<S)<<1|k<R,L=new Array(4),L[P]=N,N=L,E*=2,P){case 0:C=R+E,x=S+E;break;case 1:R=C-E,x=S+E;break;case 2:C=R+E,S=x-E;break;case 3:R=C-E,S=x-E;break}this._root&&this._root.length&&(this._root=N)}return this._x0=R,this._y0=S,this._x1=C,this._y1=x,this}},11145:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(){var k=[];return this.visit(function(O){if(!O.length)do k.push(O.data);while(O=O.next)}),k}},57059:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(k){return arguments.length?this.cover(+k[0][0],+k[0][1]).cover(+k[1][0],+k[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}},13297:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return k}});var w=b(92936);function k(O,R,S){var C,x=this._x0,E=this._y0,N,L,P,W,Y=this._x1,ie=this._y1,pe=[],fe=this._root,ae,ye;for(fe&&pe.push(new w.Z(fe,x,E,Y,ie)),S==null?S=1/0:(x=O-S,E=R-S,Y=O+S,ie=R+S,S*=S);ae=pe.pop();)if(!(!(fe=ae.node)||(N=ae.x0)>Y||(L=ae.y0)>ie||(P=ae.x1)<x||(W=ae.y1)<E))if(fe.length){var ue=(N+P)/2,Ne=(L+W)/2;pe.push(new w.Z(fe[3],ue,Ne,P,W),new w.Z(fe[2],N,Ne,ue,W),new w.Z(fe[1],ue,L,P,Ne),new w.Z(fe[0],N,L,ue,Ne)),(ye=(R>=Ne)<<1|O>=ue)&&(ae=pe[pe.length-1],pe[pe.length-1]=pe[pe.length-1-ye],pe[pe.length-1-ye]=ae)}else{var Te=O-+this._x.call(null,fe.data),_e=R-+this._y.call(null,fe.data),Xe=Te*Te+_e*_e;if(Xe<S){var Se=Math.sqrt(S=Xe);x=O-Se,E=R-Se,Y=O+Se,ie=R+Se,C=fe.data}}return C}},92936:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(k,O,R,S,C){this.node=k,this.x0=O,this.y0=R,this.x1=S,this.y1=C}},46632:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return Y}});var w=b(59715),k=b(86290),O=b(11145),R=b(57059),S=b(13297),C=b(85854),x=b(39033),E=b(56590),N=b(61034),L=b(88020),P=b(40220),W=b(88792);function Y(ae,ye,ue){var Ne=new ie(ye==null?P.P:ye,ue==null?W.q:ue,NaN,NaN,NaN,NaN);return ae==null?Ne:Ne.addAll(ae)}function ie(ae,ye,ue,Ne,Te,_e){this._x=ae,this._y=ye,this._x0=ue,this._y0=Ne,this._x1=Te,this._y1=_e,this._root=void 0}function pe(ae){for(var ye={data:ae.data},ue=ye;ae=ae.next;)ue=ue.next={data:ae.data};return ye}var fe=Y.prototype=ie.prototype;fe.copy=function(){var ae=new ie(this._x,this._y,this._x0,this._y0,this._x1,this._y1),ye=this._root,ue,Ne;if(!ye)return ae;if(!ye.length)return ae._root=pe(ye),ae;for(ue=[{source:ye,target:ae._root=new Array(4)}];ye=ue.pop();)for(var Te=0;Te<4;++Te)(Ne=ye.source[Te])&&(Ne.length?ue.push({source:Ne,target:ye.target[Te]=new Array(4)}):ye.target[Te]=pe(Ne));return ae},fe.add=w.Z,fe.addAll=w.H,fe.cover=k.Z,fe.data=O.Z,fe.extent=R.Z,fe.find=S.Z,fe.remove=C.Z,fe.removeAll=C.x,fe.root=x.Z,fe.size=E.Z,fe.visit=N.Z,fe.visitAfter=L.Z,fe.x=P.Z,fe.y=W.Z},85854:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w},x:function(){return k}});function w(O){if(isNaN(Y=+this._x.call(null,O))||isNaN(ie=+this._y.call(null,O)))return this;var R,S=this._root,C,x,E,N=this._x0,L=this._y0,P=this._x1,W=this._y1,Y,ie,pe,fe,ae,ye,ue,Ne;if(!S)return this;if(S.length)for(;;){if((ae=Y>=(pe=(N+P)/2))?N=pe:P=pe,(ye=ie>=(fe=(L+W)/2))?L=fe:W=fe,R=S,!(S=S[ue=ye<<1|ae]))return this;if(!S.length)break;(R[ue+1&3]||R[ue+2&3]||R[ue+3&3])&&(C=R,Ne=ue)}for(;S.data!==O;)if(x=S,!(S=S.next))return this;return(E=S.next)&&delete S.next,x?(E?x.next=E:delete x.next,this):R?(E?R[ue]=E:delete R[ue],(S=R[0]||R[1]||R[2]||R[3])&&S===(R[3]||R[2]||R[1]||R[0])&&!S.length&&(C?C[Ne]=S:this._root=S),this):(this._root=E,this)}function k(O){for(var R=0,S=O.length;R<S;++R)this.remove(O[R]);return this}},39033:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(){return this._root}},56590:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return w}});function w(){var k=0;return this.visit(function(O){if(!O.length)do++k;while(O=O.next)}),k}},61034:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return k}});var w=b(92936);function k(O){var R=[],S,C=this._root,x,E,N,L,P;for(C&&R.push(new w.Z(C,this._x0,this._y0,this._x1,this._y1));S=R.pop();)if(!O(C=S.node,E=S.x0,N=S.y0,L=S.x1,P=S.y1)&&C.length){var W=(E+L)/2,Y=(N+P)/2;(x=C[3])&&R.push(new w.Z(x,W,Y,L,P)),(x=C[2])&&R.push(new w.Z(x,E,Y,W,P)),(x=C[1])&&R.push(new w.Z(x,W,N,L,Y)),(x=C[0])&&R.push(new w.Z(x,E,N,W,Y))}return this}},88020:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return k}});var w=b(92936);function k(O){var R=[],S=[],C;for(this._root&&R.push(new w.Z(this._root,this._x0,this._y0,this._x1,this._y1));C=R.pop();){var x=C.node;if(x.length){var E,N=C.x0,L=C.y0,P=C.x1,W=C.y1,Y=(N+P)/2,ie=(L+W)/2;(E=x[0])&&R.push(new w.Z(E,N,L,Y,ie)),(E=x[1])&&R.push(new w.Z(E,Y,L,P,ie)),(E=x[2])&&R.push(new w.Z(E,N,ie,Y,W)),(E=x[3])&&R.push(new w.Z(E,Y,ie,P,W))}S.push(C)}for(;C=S.pop();)O(C.node,C.x0,C.y0,C.x1,C.y1);return this}},40220:function(se,ee,b){"use strict";b.d(ee,{P:function(){return w},Z:function(){return k}});function w(O){return O[0]}function k(O){return arguments.length?(this._x=O,this):this._x}},88792:function(se,ee,b){"use strict";b.d(ee,{Z:function(){return k},q:function(){return w}});function w(O){return O[1]}function k(O){return arguments.length?(this._y=O,this):this._y}},54146:function(se,ee,b){"use strict";var w=b(26729);ee.Z=w},38870:function(se,ee,b){"use strict";b.d(ee,{KI_:function(){return uo},Kj0:function(){return vh},ROQ:function(){return Rp},TlE:function(){return vo},ZAu:function(){return ju},ehD:function(){return ie},jyi:function(){return V0},u9r:function(){return Fr},vBJ:function(){return Ss},xeV:function(){return ad},xo$:function(){return Cf},xoR:function(){return gy}});const w="181",k={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},O={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},R=0,S=1,C=2,x=3,E=0,N=1,L=2,P=3,W=0,Y=1,ie=2,pe=0,fe=1,ae=2,ye=3,ue=4,Ne=5,Te=100,_e=101,Xe=102,Se=103,Ge=104,He=200,vt=201,It=202,zt=203,Yt=204,At=205,lt=206,Ot=207,le=208,Fe=209,gt=210,Jt=211,Ze=212,rt=213,Mt=214,Ue=0,Ye=1,be=2,ge=3,Ke=4,wt=5,Be=6,ut=7,Et=0,je=1,tt=2,yt=0,B=1,te=2,ot=3,_t=4,ct=5,qt=6,en=7,nn="attached",we="detached",Q=300,De=301,We=302,Ce=303,Re=304,qe=306,st=1e3,$e=1001,ft=1002,Ct=1003,jt=1004,Qt=1004,pn=1005,Wn=1005,Rn=1006,bi=1007,Dr=1007,Qn=1008,Vi=1008,Oi=1009,Gi=1010,ir=1011,gs=1012,Ls=1013,ls=1014,ys=1015,Gs=1016,Yl=1017,Zl=1018,Fa=1020,Fl=35902,su=35899,Bu=1021,Pe=1022,D=1023,U=1026,_=1027,F=1028,X=1029,Ie=1030,ke=1031,et=1032,nt=1033,Wt=33776,Tt=33777,on=33778,Un=33779,sn=35840,bn=35841,ti=35842,Bt=35843,$n=36196,ni=37492,Pi=37496,ui=37808,Lr=37809,yi=37810,vi=37811,Mr=37812,Zt=37813,Fn=37814,hi=37815,Xn=37816,ds=37817,qr=37818,vs=37819,kr=37820,Fs=37821,io=36492,ro=36494,To=36495,Eo=36283,Wr=36284,eo=36285,Ao=36286,so=2200,Yr=2201,ua=2202,Co=2300,sl=2301,ol=2302,ha=2400,Ba=2401,al=2402,wo=2500,Lc=2501,ox=0,hh=1,M0=2,rp=3200,sp=3201,S0=3202,Bm=3203,Xa=0,Jd=1,ea="",uo="srgb",ou="srgb-linear",dh="linear",Fi="srgb",a1=0,Kl=7680,Um=7681,Qd=7682,ax=7683,lx=34055,T0=34056,l1=5386,c1=512,u1=513,h1=514,cx=515,d1=516,f1=517,ux=518,Jh=519,km=512,ef=513,tf=514,op=515,E0=516,A0=517,C0=518,zm=519,Uu=35044,nf=35048,Vm=35040,fE=35045,Gm=35049,pE=35041,mE=35046,gE=35050,yE=35042,p1="100",R0="300 es",oo=2e3,qa=2001,fh={COMPUTE:"compute",RENDER:"render"},m1={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},g1={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};function Bl(j){for(let r=j.length-1;r>=0;--r)if(j[r]>=65535)return!0;return!1}const Ya={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function ku(j,r){return new Ya[j](r)}function uc(j){return document.createElementNS("http://www.w3.org/1999/xhtml",j)}function Ua(){const j=uc("canvas");return j.style.display="block",j}const xl={};let Sr=null;function ap(j){Sr=j}function hx(){return Sr}function Wm(...j){const r="THREE."+j.shift();Sr?Sr("log",r,...j):console.log(r,...j)}function _r(...j){const r="THREE."+j.shift();Sr?Sr("warn",r,...j):console.warn(r,...j)}function Xs(...j){const r="THREE."+j.shift();Sr?Sr("error",r,...j):console.error(r,...j)}function Ul(...j){const r=j.join(" ");r in xl||(xl[r]=!0,_r(...j))}function N0(j,r,l){return new Promise(function(h,f){function g(){switch(j.clientWaitSync(r,j.SYNC_FLUSH_COMMANDS_BIT,0)){case j.WAIT_FAILED:f();break;case j.TIMEOUT_EXPIRED:setTimeout(g,l);break;default:h()}}setTimeout(g,l)})}class zu{addEventListener(r,l){this._listeners===void 0&&(this._listeners={});const h=this._listeners;h[r]===void 0&&(h[r]=[]),h[r].indexOf(l)===-1&&h[r].push(l)}hasEventListener(r,l){const h=this._listeners;return h===void 0?!1:h[r]!==void 0&&h[r].indexOf(l)!==-1}removeEventListener(r,l){const h=this._listeners;if(h===void 0)return;const f=h[r];if(f!==void 0){const g=f.indexOf(l);g!==-1&&f.splice(g,1)}}dispatchEvent(r){const l=this._listeners;if(l===void 0)return;const h=l[r.type];if(h!==void 0){r.target=this;const f=h.slice(0);for(let g=0,v=f.length;g<v;g++)f[g].call(this,r);r.target=null}}}const wa=["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 P0=1234567;const au=Math.PI/180,Vu=180/Math.PI;function El(){const j=Math.random()*4294967295|0,r=Math.random()*4294967295|0,l=Math.random()*4294967295|0,h=Math.random()*4294967295|0;return(wa[j&255]+wa[j>>8&255]+wa[j>>16&255]+wa[j>>24&255]+"-"+wa[r&255]+wa[r>>8&255]+"-"+wa[r>>16&15|64]+wa[r>>24&255]+"-"+wa[l&63|128]+wa[l>>8&255]+"-"+wa[l>>16&255]+wa[l>>24&255]+wa[h&255]+wa[h>>8&255]+wa[h>>16&255]+wa[h>>24&255]).toLowerCase()}function Br(j,r,l){return Math.max(r,Math.min(l,j))}function lp(j,r){return(j%r+r)%r}function I0(j,r,l,h,f){return h+(j-r)*(f-h)/(l-r)}function L0(j,r,l){return j!==r?(l-j)/(r-j):0}function Qh(j,r,l){return(1-l)*j+l*r}function Za(j,r,l,h){return Qh(j,r,1-Math.exp(-l*h))}function cs(j,r=1){return r-Math.abs(lp(j,r*2)-r)}function ed(j,r,l){return j<=r?0:j>=l?1:(j=(j-r)/(l-r),j*j*(3-2*j))}function yn(j,r,l){return j<=r?0:j>=l?1:(j=(j-r)/(l-r),j*j*j*(j*(j*6-15)+10))}function ta(j,r){return j+Math.floor(Math.random()*(r-j+1))}function it(j,r){return j+Math.random()*(r-j)}function cp(j){return j*(.5-Math.random())}function Hm(j){j!==void 0&&(P0=j);let r=P0+=1831565813;return r=Math.imul(r^r>>>15,r|1),r^=r+Math.imul(r^r>>>7,r|61),((r^r>>>14)>>>0)/4294967296}function jr(j){return j*au}function up(j){return j*Vu}function hp(j){return(j&j-1)===0&&j!==0}function D0(j){return Math.pow(2,Math.ceil(Math.log(j)/Math.LN2))}function ph(j){return Math.pow(2,Math.floor(Math.log(j)/Math.LN2))}function mh(j,r,l,h,f){const g=Math.cos,v=Math.sin,A=g(l/2),V=v(l/2),H=g((r+h)/2),Z=v((r+h)/2),ce=g((r-h)/2),he=v((r-h)/2),de=g((h-r)/2),Me=v((h-r)/2);switch(f){case"XYX":j.set(A*Z,V*ce,V*he,A*H);break;case"YZY":j.set(V*he,A*Z,V*ce,A*H);break;case"ZXZ":j.set(V*ce,V*he,A*Z,A*H);break;case"XZX":j.set(A*Z,V*Me,V*de,A*H);break;case"YXY":j.set(V*de,A*Z,V*Me,A*H);break;case"ZYZ":j.set(V*Me,V*de,A*Z,A*H);break;default:_r("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+f)}}function Ka(j,r){switch(r.constructor){case Float32Array:return j;case Uint32Array:return j/4294967295;case Uint16Array:return j/65535;case Uint8Array:return j/255;case Int32Array:return Math.max(j/2147483647,-1);case Int16Array:return Math.max(j/32767,-1);case Int8Array:return Math.max(j/127,-1);default:throw new Error("Invalid component type.")}}function is(j,r){switch(r.constructor){case Float32Array:return j;case Uint32Array:return Math.round(j*4294967295);case Uint16Array:return Math.round(j*65535);case Uint8Array:return Math.round(j*255);case Int32Array:return Math.round(j*2147483647);case Int16Array:return Math.round(j*32767);case Int8Array:return Math.round(j*127);default:throw new Error("Invalid component type.")}}const ll={DEG2RAD:au,RAD2DEG:Vu,generateUUID:El,clamp:Br,euclideanModulo:lp,mapLinear:I0,inverseLerp:L0,lerp:Qh,damp:Za,pingpong:cs,smoothstep:ed,smootherstep:yn,randInt:ta,randFloat:it,randFloatSpread:cp,seededRandom:Hm,degToRad:jr,radToDeg:up,isPowerOfTwo:hp,ceilPowerOfTwo:D0,floorPowerOfTwo:ph,setQuaternionFromProperEuler:mh,normalize:is,denormalize:Ka};class oi{constructor(r=0,l=0){oi.prototype.isVector2=!0,this.x=r,this.y=l}get width(){return this.x}set width(r){this.x=r}get height(){return this.y}set height(r){this.y=r}set(r,l){return this.x=r,this.y=l,this}setScalar(r){return this.x=r,this.y=r,this}setX(r){return this.x=r,this}setY(r){return this.y=r,this}setComponent(r,l){switch(r){case 0:this.x=l;break;case 1:this.y=l;break;default:throw new Error("index is out of range: "+r)}return this}getComponent(r){switch(r){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+r)}}clone(){return new this.constructor(this.x,this.y)}copy(r){return this.x=r.x,this.y=r.y,this}add(r){return this.x+=r.x,this.y+=r.y,this}addScalar(r){return this.x+=r,this.y+=r,this}addVectors(r,l){return this.x=r.x+l.x,this.y=r.y+l.y,this}addScaledVector(r,l){return this.x+=r.x*l,this.y+=r.y*l,this}sub(r){return this.x-=r.x,this.y-=r.y,this}subScalar(r){return this.x-=r,this.y-=r,this}subVectors(r,l){return this.x=r.x-l.x,this.y=r.y-l.y,this}multiply(r){return this.x*=r.x,this.y*=r.y,this}multiplyScalar(r){return this.x*=r,this.y*=r,this}divide(r){return this.x/=r.x,this.y/=r.y,this}divideScalar(r){return this.multiplyScalar(1/r)}applyMatrix3(r){const l=this.x,h=this.y,f=r.elements;return this.x=f[0]*l+f[3]*h+f[6],this.y=f[1]*l+f[4]*h+f[7],this}min(r){return this.x=Math.min(this.x,r.x),this.y=Math.min(this.y,r.y),this}max(r){return this.x=Math.max(this.x,r.x),this.y=Math.max(this.y,r.y),this}clamp(r,l){return this.x=Br(this.x,r.x,l.x),this.y=Br(this.y,r.y,l.y),this}clampScalar(r,l){return this.x=Br(this.x,r,l),this.y=Br(this.y,r,l),this}clampLength(r,l){const h=this.length();return this.divideScalar(h||1).multiplyScalar(Br(h,r,l))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(r){return this.x*r.x+this.y*r.y}cross(r){return this.x*r.y-this.y*r.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(r){const l=Math.sqrt(this.lengthSq()*r.lengthSq());if(l===0)return Math.PI/2;const h=this.dot(r)/l;return Math.acos(Br(h,-1,1))}distanceTo(r){return Math.sqrt(this.distanceToSquared(r))}distanceToSquared(r){const l=this.x-r.x,h=this.y-r.y;return l*l+h*h}manhattanDistanceTo(r){return Math.abs(this.x-r.x)+Math.abs(this.y-r.y)}setLength(r){return this.normalize().multiplyScalar(r)}lerp(r,l){return this.x+=(r.x-this.x)*l,this.y+=(r.y-this.y)*l,this}lerpVectors(r,l,h){return this.x=r.x+(l.x-r.x)*h,this.y=r.y+(l.y-r.y)*h,this}equals(r){return r.x===this.x&&r.y===this.y}fromArray(r,l=0){return this.x=r[l],this.y=r[l+1],this}toArray(r=[],l=0){return r[l]=this.x,r[l+1]=this.y,r}fromBufferAttribute(r,l){return this.x=r.getX(l),this.y=r.getY(l),this}rotateAround(r,l){const h=Math.cos(l),f=Math.sin(l),g=this.x-r.x,v=this.y-r.y;return this.x=g*h-v*f+r.x,this.y=g*f+v*h+r.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class _l{constructor(r=0,l=0,h=0,f=1){this.isQuaternion=!0,this._x=r,this._y=l,this._z=h,this._w=f}static slerpFlat(r,l,h,f,g,v,A){let V=h[f+0],H=h[f+1],Z=h[f+2],ce=h[f+3],he=g[v+0],de=g[v+1],Me=g[v+2],Je=g[v+3];if(A<=0){r[l+0]=V,r[l+1]=H,r[l+2]=Z,r[l+3]=ce;return}if(A>=1){r[l+0]=he,r[l+1]=de,r[l+2]=Me,r[l+3]=Je;return}if(ce!==Je||V!==he||H!==de||Z!==Me){let mt=V*he+H*de+Z*Me+ce*Je;mt<0&&(he=-he,de=-de,Me=-Me,Je=-Je,mt=-mt);let pt=1-A;if(mt<.9995){const Nt=Math.acos(mt),Pt=Math.sin(Nt);pt=Math.sin(pt*Nt)/Pt,A=Math.sin(A*Nt)/Pt,V=V*pt+he*A,H=H*pt+de*A,Z=Z*pt+Me*A,ce=ce*pt+Je*A}else{V=V*pt+he*A,H=H*pt+de*A,Z=Z*pt+Me*A,ce=ce*pt+Je*A;const Nt=1/Math.sqrt(V*V+H*H+Z*Z+ce*ce);V*=Nt,H*=Nt,Z*=Nt,ce*=Nt}}r[l]=V,r[l+1]=H,r[l+2]=Z,r[l+3]=ce}static multiplyQuaternionsFlat(r,l,h,f,g,v){const A=h[f],V=h[f+1],H=h[f+2],Z=h[f+3],ce=g[v],he=g[v+1],de=g[v+2],Me=g[v+3];return r[l]=A*Me+Z*ce+V*de-H*he,r[l+1]=V*Me+Z*he+H*ce-A*de,r[l+2]=H*Me+Z*de+A*he-V*ce,r[l+3]=Z*Me-A*ce-V*he-H*de,r}get x(){return this._x}set x(r){this._x=r,this._onChangeCallback()}get y(){return this._y}set y(r){this._y=r,this._onChangeCallback()}get z(){return this._z}set z(r){this._z=r,this._onChangeCallback()}get w(){return this._w}set w(r){this._w=r,this._onChangeCallback()}set(r,l,h,f){return this._x=r,this._y=l,this._z=h,this._w=f,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(r){return this._x=r.x,this._y=r.y,this._z=r.z,this._w=r.w,this._onChangeCallback(),this}setFromEuler(r,l=!0){const h=r._x,f=r._y,g=r._z,v=r._order,A=Math.cos,V=Math.sin,H=A(h/2),Z=A(f/2),ce=A(g/2),he=V(h/2),de=V(f/2),Me=V(g/2);switch(v){case"XYZ":this._x=he*Z*ce+H*de*Me,this._y=H*de*ce-he*Z*Me,this._z=H*Z*Me+he*de*ce,this._w=H*Z*ce-he*de*Me;break;case"YXZ":this._x=he*Z*ce+H*de*Me,this._y=H*de*ce-he*Z*Me,this._z=H*Z*Me-he*de*ce,this._w=H*Z*ce+he*de*Me;break;case"ZXY":this._x=he*Z*ce-H*de*Me,this._y=H*de*ce+he*Z*Me,this._z=H*Z*Me+he*de*ce,this._w=H*Z*ce-he*de*Me;break;case"ZYX":this._x=he*Z*ce-H*de*Me,this._y=H*de*ce+he*Z*Me,this._z=H*Z*Me-he*de*ce,this._w=H*Z*ce+he*de*Me;break;case"YZX":this._x=he*Z*ce+H*de*Me,this._y=H*de*ce+he*Z*Me,this._z=H*Z*Me-he*de*ce,this._w=H*Z*ce-he*de*Me;break;case"XZY":this._x=he*Z*ce-H*de*Me,this._y=H*de*ce-he*Z*Me,this._z=H*Z*Me+he*de*ce,this._w=H*Z*ce+he*de*Me;break;default:_r("Quaternion: .setFromEuler() encountered an unknown order: "+v)}return l===!0&&this._onChangeCallback(),this}setFromAxisAngle(r,l){const h=l/2,f=Math.sin(h);return this._x=r.x*f,this._y=r.y*f,this._z=r.z*f,this._w=Math.cos(h),this._onChangeCallback(),this}setFromRotationMatrix(r){const l=r.elements,h=l[0],f=l[4],g=l[8],v=l[1],A=l[5],V=l[9],H=l[2],Z=l[6],ce=l[10],he=h+A+ce;if(he>0){const de=.5/Math.sqrt(he+1);this._w=.25/de,this._x=(Z-V)*de,this._y=(g-H)*de,this._z=(v-f)*de}else if(h>A&&h>ce){const de=2*Math.sqrt(1+h-A-ce);this._w=(Z-V)/de,this._x=.25*de,this._y=(f+v)/de,this._z=(g+H)/de}else if(A>ce){const de=2*Math.sqrt(1+A-h-ce);this._w=(g-H)/de,this._x=(f+v)/de,this._y=.25*de,this._z=(V+Z)/de}else{const de=2*Math.sqrt(1+ce-h-A);this._w=(v-f)/de,this._x=(g+H)/de,this._y=(V+Z)/de,this._z=.25*de}return this._onChangeCallback(),this}setFromUnitVectors(r,l){let h=r.dot(l)+1;return h<1e-8?(h=0,Math.abs(r.x)>Math.abs(r.z)?(this._x=-r.y,this._y=r.x,this._z=0,this._w=h):(this._x=0,this._y=-r.z,this._z=r.y,this._w=h)):(this._x=r.y*l.z-r.z*l.y,this._y=r.z*l.x-r.x*l.z,this._z=r.x*l.y-r.y*l.x,this._w=h),this.normalize()}angleTo(r){return 2*Math.acos(Math.abs(Br(this.dot(r),-1,1)))}rotateTowards(r,l){const h=this.angleTo(r);if(h===0)return this;const f=Math.min(1,l/h);return this.slerp(r,f),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(r){return this._x*r._x+this._y*r._y+this._z*r._z+this._w*r._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 r=this.length();return r===0?(this._x=0,this._y=0,this._z=0,this._w=1):(r=1/r,this._x=this._x*r,this._y=this._y*r,this._z=this._z*r,this._w=this._w*r),this._onChangeCallback(),this}multiply(r){return this.multiplyQuaternions(this,r)}premultiply(r){return this.multiplyQuaternions(r,this)}multiplyQuaternions(r,l){const h=r._x,f=r._y,g=r._z,v=r._w,A=l._x,V=l._y,H=l._z,Z=l._w;return this._x=h*Z+v*A+f*H-g*V,this._y=f*Z+v*V+g*A-h*H,this._z=g*Z+v*H+h*V-f*A,this._w=v*Z-h*A-f*V-g*H,this._onChangeCallback(),this}slerp(r,l){if(l<=0)return this;if(l>=1)return this.copy(r);let h=r._x,f=r._y,g=r._z,v=r._w,A=this.dot(r);A<0&&(h=-h,f=-f,g=-g,v=-v,A=-A);let V=1-l;if(A<.9995){const H=Math.acos(A),Z=Math.sin(H);V=Math.sin(V*H)/Z,l=Math.sin(l*H)/Z,this._x=this._x*V+h*l,this._y=this._y*V+f*l,this._z=this._z*V+g*l,this._w=this._w*V+v*l,this._onChangeCallback()}else this._x=this._x*V+h*l,this._y=this._y*V+f*l,this._z=this._z*V+g*l,this._w=this._w*V+v*l,this.normalize();return this}slerpQuaternions(r,l,h){return this.copy(r).slerp(l,h)}random(){const r=2*Math.PI*Math.random(),l=2*Math.PI*Math.random(),h=Math.random(),f=Math.sqrt(1-h),g=Math.sqrt(h);return this.set(f*Math.sin(r),f*Math.cos(r),g*Math.sin(l),g*Math.cos(l))}equals(r){return r._x===this._x&&r._y===this._y&&r._z===this._z&&r._w===this._w}fromArray(r,l=0){return this._x=r[l],this._y=r[l+1],this._z=r[l+2],this._w=r[l+3],this._onChangeCallback(),this}toArray(r=[],l=0){return r[l]=this._x,r[l+1]=this._y,r[l+2]=this._z,r[l+3]=this._w,r}fromBufferAttribute(r,l){return this._x=r.getX(l),this._y=r.getY(l),this._z=r.getZ(l),this._w=r.getW(l),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(r){return this._onChangeCallback=r,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Rt{constructor(r=0,l=0,h=0){Rt.prototype.isVector3=!0,this.x=r,this.y=l,this.z=h}set(r,l,h){return h===void 0&&(h=this.z),this.x=r,this.y=l,this.z=h,this}setScalar(r){return this.x=r,this.y=r,this.z=r,this}setX(r){return this.x=r,this}setY(r){return this.y=r,this}setZ(r){return this.z=r,this}setComponent(r,l){switch(r){case 0:this.x=l;break;case 1:this.y=l;break;case 2:this.z=l;break;default:throw new Error("index is out of range: "+r)}return this}getComponent(r){switch(r){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+r)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(r){return this.x=r.x,this.y=r.y,this.z=r.z,this}add(r){return this.x+=r.x,this.y+=r.y,this.z+=r.z,this}addScalar(r){return this.x+=r,this.y+=r,this.z+=r,this}addVectors(r,l){return this.x=r.x+l.x,this.y=r.y+l.y,this.z=r.z+l.z,this}addScaledVector(r,l){return this.x+=r.x*l,this.y+=r.y*l,this.z+=r.z*l,this}sub(r){return this.x-=r.x,this.y-=r.y,this.z-=r.z,this}subScalar(r){return this.x-=r,this.y-=r,this.z-=r,this}subVectors(r,l){return this.x=r.x-l.x,this.y=r.y-l.y,this.z=r.z-l.z,this}multiply(r){return this.x*=r.x,this.y*=r.y,this.z*=r.z,this}multiplyScalar(r){return this.x*=r,this.y*=r,this.z*=r,this}multiplyVectors(r,l){return this.x=r.x*l.x,this.y=r.y*l.y,this.z=r.z*l.z,this}applyEuler(r){return this.applyQuaternion(Ki.setFromEuler(r))}applyAxisAngle(r,l){return this.applyQuaternion(Ki.setFromAxisAngle(r,l))}applyMatrix3(r){const l=this.x,h=this.y,f=this.z,g=r.elements;return this.x=g[0]*l+g[3]*h+g[6]*f,this.y=g[1]*l+g[4]*h+g[7]*f,this.z=g[2]*l+g[5]*h+g[8]*f,this}applyNormalMatrix(r){return this.applyMatrix3(r).normalize()}applyMatrix4(r){const l=this.x,h=this.y,f=this.z,g=r.elements,v=1/(g[3]*l+g[7]*h+g[11]*f+g[15]);return this.x=(g[0]*l+g[4]*h+g[8]*f+g[12])*v,this.y=(g[1]*l+g[5]*h+g[9]*f+g[13])*v,this.z=(g[2]*l+g[6]*h+g[10]*f+g[14])*v,this}applyQuaternion(r){const l=this.x,h=this.y,f=this.z,g=r.x,v=r.y,A=r.z,V=r.w,H=2*(v*f-A*h),Z=2*(A*l-g*f),ce=2*(g*h-v*l);return this.x=l+V*H+v*ce-A*Z,this.y=h+V*Z+A*H-g*ce,this.z=f+V*ce+g*Z-v*H,this}project(r){return this.applyMatrix4(r.matrixWorldInverse).applyMatrix4(r.projectionMatrix)}unproject(r){return this.applyMatrix4(r.projectionMatrixInverse).applyMatrix4(r.matrixWorld)}transformDirection(r){const l=this.x,h=this.y,f=this.z,g=r.elements;return this.x=g[0]*l+g[4]*h+g[8]*f,this.y=g[1]*l+g[5]*h+g[9]*f,this.z=g[2]*l+g[6]*h+g[10]*f,this.normalize()}divide(r){return this.x/=r.x,this.y/=r.y,this.z/=r.z,this}divideScalar(r){return this.multiplyScalar(1/r)}min(r){return this.x=Math.min(this.x,r.x),this.y=Math.min(this.y,r.y),this.z=Math.min(this.z,r.z),this}max(r){return this.x=Math.max(this.x,r.x),this.y=Math.max(this.y,r.y),this.z=Math.max(this.z,r.z),this}clamp(r,l){return this.x=Br(this.x,r.x,l.x),this.y=Br(this.y,r.y,l.y),this.z=Br(this.z,r.z,l.z),this}clampScalar(r,l){return this.x=Br(this.x,r,l),this.y=Br(this.y,r,l),this.z=Br(this.z,r,l),this}clampLength(r,l){const h=this.length();return this.divideScalar(h||1).multiplyScalar(Br(h,r,l))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(r){return this.x*r.x+this.y*r.y+this.z*r.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(r){return this.normalize().multiplyScalar(r)}lerp(r,l){return this.x+=(r.x-this.x)*l,this.y+=(r.y-this.y)*l,this.z+=(r.z-this.z)*l,this}lerpVectors(r,l,h){return this.x=r.x+(l.x-r.x)*h,this.y=r.y+(l.y-r.y)*h,this.z=r.z+(l.z-r.z)*h,this}cross(r){return this.crossVectors(this,r)}crossVectors(r,l){const h=r.x,f=r.y,g=r.z,v=l.x,A=l.y,V=l.z;return this.x=f*V-g*A,this.y=g*v-h*V,this.z=h*A-f*v,this}projectOnVector(r){const l=r.lengthSq();if(l===0)return this.set(0,0,0);const h=r.dot(this)/l;return this.copy(r).multiplyScalar(h)}projectOnPlane(r){return rf.copy(this).projectOnVector(r),this.sub(rf)}reflect(r){return this.sub(rf.copy(r).multiplyScalar(2*this.dot(r)))}angleTo(r){const l=Math.sqrt(this.lengthSq()*r.lengthSq());if(l===0)return Math.PI/2;const h=this.dot(r)/l;return Math.acos(Br(h,-1,1))}distanceTo(r){return Math.sqrt(this.distanceToSquared(r))}distanceToSquared(r){const l=this.x-r.x,h=this.y-r.y,f=this.z-r.z;return l*l+h*h+f*f}manhattanDistanceTo(r){return Math.abs(this.x-r.x)+Math.abs(this.y-r.y)+Math.abs(this.z-r.z)}setFromSpherical(r){return this.setFromSphericalCoords(r.radius,r.phi,r.theta)}setFromSphericalCoords(r,l,h){const f=Math.sin(l)*r;return this.x=f*Math.sin(h),this.y=Math.cos(l)*r,this.z=f*Math.cos(h),this}setFromCylindrical(r){return this.setFromCylindricalCoords(r.radius,r.theta,r.y)}setFromCylindricalCoords(r,l,h){return this.x=r*Math.sin(l),this.y=h,this.z=r*Math.cos(l),this}setFromMatrixPosition(r){const l=r.elements;return this.x=l[12],this.y=l[13],this.z=l[14],this}setFromMatrixScale(r){const l=this.setFromMatrixColumn(r,0).length(),h=this.setFromMatrixColumn(r,1).length(),f=this.setFromMatrixColumn(r,2).length();return this.x=l,this.y=h,this.z=f,this}setFromMatrixColumn(r,l){return this.fromArray(r.elements,l*4)}setFromMatrix3Column(r,l){return this.fromArray(r.elements,l*3)}setFromEuler(r){return this.x=r._x,this.y=r._y,this.z=r._z,this}setFromColor(r){return this.x=r.r,this.y=r.g,this.z=r.b,this}equals(r){return r.x===this.x&&r.y===this.y&&r.z===this.z}fromArray(r,l=0){return this.x=r[l],this.y=r[l+1],this.z=r[l+2],this}toArray(r=[],l=0){return r[l]=this.x,r[l+1]=this.y,r[l+2]=this.z,r}fromBufferAttribute(r,l){return this.x=r.getX(l),this.y=r.getY(l),this.z=r.getZ(l),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const r=Math.random()*Math.PI*2,l=Math.random()*2-1,h=Math.sqrt(1-l*l);return this.x=h*Math.cos(r),this.y=l,this.z=h*Math.sin(r),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const rf=new Rt,Ki=new _l;class da{constructor(r,l,h,f,g,v,A,V,H){da.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],r!==void 0&&this.set(r,l,h,f,g,v,A,V,H)}set(r,l,h,f,g,v,A,V,H){const Z=this.elements;return Z[0]=r,Z[1]=f,Z[2]=A,Z[3]=l,Z[4]=g,Z[5]=V,Z[6]=h,Z[7]=v,Z[8]=H,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(r){const l=this.elements,h=r.elements;return l[0]=h[0],l[1]=h[1],l[2]=h[2],l[3]=h[3],l[4]=h[4],l[5]=h[5],l[6]=h[6],l[7]=h[7],l[8]=h[8],this}extractBasis(r,l,h){return r.setFromMatrix3Column(this,0),l.setFromMatrix3Column(this,1),h.setFromMatrix3Column(this,2),this}setFromMatrix4(r){const l=r.elements;return this.set(l[0],l[4],l[8],l[1],l[5],l[9],l[2],l[6],l[10]),this}multiply(r){return this.multiplyMatrices(this,r)}premultiply(r){return this.multiplyMatrices(r,this)}multiplyMatrices(r,l){const h=r.elements,f=l.elements,g=this.elements,v=h[0],A=h[3],V=h[6],H=h[1],Z=h[4],ce=h[7],he=h[2],de=h[5],Me=h[8],Je=f[0],mt=f[3],pt=f[6],Nt=f[1],Pt=f[4],Gt=f[7],gn=f[2],Sn=f[5],kn=f[8];return g[0]=v*Je+A*Nt+V*gn,g[3]=v*mt+A*Pt+V*Sn,g[6]=v*pt+A*Gt+V*kn,g[1]=H*Je+Z*Nt+ce*gn,g[4]=H*mt+Z*Pt+ce*Sn,g[7]=H*pt+Z*Gt+ce*kn,g[2]=he*Je+de*Nt+Me*gn,g[5]=he*mt+de*Pt+Me*Sn,g[8]=he*pt+de*Gt+Me*kn,this}multiplyScalar(r){const l=this.elements;return l[0]*=r,l[3]*=r,l[6]*=r,l[1]*=r,l[4]*=r,l[7]*=r,l[2]*=r,l[5]*=r,l[8]*=r,this}determinant(){const r=this.elements,l=r[0],h=r[1],f=r[2],g=r[3],v=r[4],A=r[5],V=r[6],H=r[7],Z=r[8];return l*v*Z-l*A*H-h*g*Z+h*A*V+f*g*H-f*v*V}invert(){const r=this.elements,l=r[0],h=r[1],f=r[2],g=r[3],v=r[4],A=r[5],V=r[6],H=r[7],Z=r[8],ce=Z*v-A*H,he=A*V-Z*g,de=H*g-v*V,Me=l*ce+h*he+f*de;if(Me===0)return this.set(0,0,0,0,0,0,0,0,0);const Je=1/Me;return r[0]=ce*Je,r[1]=(f*H-Z*h)*Je,r[2]=(A*h-f*v)*Je,r[3]=he*Je,r[4]=(Z*l-f*V)*Je,r[5]=(f*g-A*l)*Je,r[6]=de*Je,r[7]=(h*V-H*l)*Je,r[8]=(v*l-h*g)*Je,this}transpose(){let r;const l=this.elements;return r=l[1],l[1]=l[3],l[3]=r,r=l[2],l[2]=l[6],l[6]=r,r=l[5],l[5]=l[7],l[7]=r,this}getNormalMatrix(r){return this.setFromMatrix4(r).invert().transpose()}transposeIntoArray(r){const l=this.elements;return r[0]=l[0],r[1]=l[3],r[2]=l[6],r[3]=l[1],r[4]=l[4],r[5]=l[7],r[6]=l[2],r[7]=l[5],r[8]=l[8],this}setUvTransform(r,l,h,f,g,v,A){const V=Math.cos(g),H=Math.sin(g);return this.set(h*V,h*H,-h*(V*v+H*A)+v+r,-f*H,f*V,-f*(-H*v+V*A)+A+l,0,0,1),this}scale(r,l){return this.premultiply(Gu.makeScale(r,l)),this}rotate(r){return this.premultiply(Gu.makeRotation(-r)),this}translate(r,l){return this.premultiply(Gu.makeTranslation(r,l)),this}makeTranslation(r,l){return r.isVector2?this.set(1,0,r.x,0,1,r.y,0,0,1):this.set(1,0,r,0,1,l,0,0,1),this}makeRotation(r){const l=Math.cos(r),h=Math.sin(r);return this.set(l,-h,0,h,l,0,0,0,1),this}makeScale(r,l){return this.set(r,0,0,0,l,0,0,0,1),this}equals(r){const l=this.elements,h=r.elements;for(let f=0;f<9;f++)if(l[f]!==h[f])return!1;return!0}fromArray(r,l=0){for(let h=0;h<9;h++)this.elements[h]=r[h+l];return this}toArray(r=[],l=0){const h=this.elements;return r[l]=h[0],r[l+1]=h[1],r[l+2]=h[2],r[l+3]=h[3],r[l+4]=h[4],r[l+5]=h[5],r[l+6]=h[6],r[l+7]=h[7],r[l+8]=h[8],r}clone(){return new this.constructor().fromArray(this.elements)}}const Gu=new da,lu=new da().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),$m=new da().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function jm(){const j={enabled:!0,workingColorSpace:ou,spaces:{},convert:function(f,g,v){return this.enabled===!1||g===v||!g||!v||(this.spaces[g].transfer===Fi&&(f.r=kl(f.r),f.g=kl(f.g),f.b=kl(f.b)),this.spaces[g].primaries!==this.spaces[v].primaries&&(f.applyMatrix3(this.spaces[g].toXYZ),f.applyMatrix3(this.spaces[v].fromXYZ)),this.spaces[v].transfer===Fi&&(f.r=Dc(f.r),f.g=Dc(f.g),f.b=Dc(f.b))),f},workingToColorSpace:function(f,g){return this.convert(f,this.workingColorSpace,g)},colorSpaceToWorking:function(f,g){return this.convert(f,g,this.workingColorSpace)},getPrimaries:function(f){return this.spaces[f].primaries},getTransfer:function(f){return f===ea?dh:this.spaces[f].transfer},getToneMappingMode:function(f){return this.spaces[f].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(f,g=this.workingColorSpace){return f.fromArray(this.spaces[g].luminanceCoefficients)},define:function(f){Object.assign(this.spaces,f)},_getMatrix:function(f,g,v){return f.copy(this.spaces[g].toXYZ).multiply(this.spaces[v].fromXYZ)},_getDrawingBufferColorSpace:function(f){return this.spaces[f].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(f=this.workingColorSpace){return this.spaces[f].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(f,g){return Ul("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),j.workingToColorSpace(f,g)},toWorkingColorSpace:function(f,g){return Ul("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),j.colorSpaceToWorking(f,g)}},r=[.64,.33,.3,.6,.15,.06],l=[.2126,.7152,.0722],h=[.3127,.329];return j.define({[ou]:{primaries:r,whitePoint:h,transfer:dh,toXYZ:lu,fromXYZ:$m,luminanceCoefficients:l,workingColorSpaceConfig:{unpackColorSpace:uo},outputColorSpaceConfig:{drawingBufferColorSpace:uo}},[uo]:{primaries:r,whitePoint:h,transfer:Fi,toXYZ:lu,fromXYZ:$m,luminanceCoefficients:l,outputColorSpaceConfig:{drawingBufferColorSpace:uo}}}),j}const Mo=jm();function kl(j){return j<.04045?j*.0773993808:Math.pow(j*.9478672986+.0521327014,2.4)}function Dc(j){return j<.0031308?j*12.92:1.055*Math.pow(j,.41666)-.055}let cu;class Ho{static getDataURL(r,l="image/png"){if(/^data:/i.test(r.src)||typeof HTMLCanvasElement=="undefined")return r.src;let h;if(r instanceof HTMLCanvasElement)h=r;else{cu===void 0&&(cu=uc("canvas")),cu.width=r.width,cu.height=r.height;const f=cu.getContext("2d");r instanceof ImageData?f.putImageData(r,0,0):f.drawImage(r,0,0,r.width,r.height),h=cu}return h.toDataURL(l)}static sRGBToLinear(r){if(typeof HTMLImageElement!="undefined"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&r instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&r instanceof ImageBitmap){const l=uc("canvas");l.width=r.width,l.height=r.height;const h=l.getContext("2d");h.drawImage(r,0,0,r.width,r.height);const f=h.getImageData(0,0,r.width,r.height),g=f.data;for(let v=0;v<g.length;v++)g[v]=kl(g[v]/255)*255;return h.putImageData(f,0,0),l}else if(r.data){const l=r.data.slice(0);for(let h=0;h<l.length;h++)l instanceof Uint8Array||l instanceof Uint8ClampedArray?l[h]=Math.floor(kl(l[h]/255)*255):l[h]=kl(l[h]);return{data:l,width:r.width,height:r.height}}else return _r("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),r}}let mr=0;class Ja{constructor(r=null){this.isSource=!0,Object.defineProperty(this,"id",{value:mr++}),this.uuid=El(),this.data=r,this.dataReady=!0,this.version=0}getSize(r){const l=this.data;return typeof HTMLVideoElement!="undefined"&&l instanceof HTMLVideoElement?r.set(l.videoWidth,l.videoHeight,0):l instanceof VideoFrame?r.set(l.displayHeight,l.displayWidth,0):l!==null?r.set(l.width,l.height,l.depth||0):r.set(0,0,0),r}set needsUpdate(r){r===!0&&this.version++}toJSON(r){const l=r===void 0||typeof r=="string";if(!l&&r.images[this.uuid]!==void 0)return r.images[this.uuid];const h={uuid:this.uuid,url:""},f=this.data;if(f!==null){let g;if(Array.isArray(f)){g=[];for(let v=0,A=f.length;v<A;v++)f[v].isDataTexture?g.push(hc(f[v].image)):g.push(hc(f[v]))}else g=hc(f);h.url=g}return l||(r.images[this.uuid]=h),h}}function hc(j){return typeof HTMLImageElement!="undefined"&&j instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&j instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&j instanceof ImageBitmap?Ho.getDataURL(j):j.data?{data:Array.from(j.data),width:j.width,height:j.height,type:j.data.constructor.name}:(_r("Texture: Unable to serialize Texture."),{})}let sf=0;const dp=new Rt;class bl extends zu{constructor(r=bl.DEFAULT_IMAGE,l=bl.DEFAULT_MAPPING,h=$e,f=$e,g=Rn,v=Qn,A=D,V=Oi,H=bl.DEFAULT_ANISOTROPY,Z=ea){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:sf++}),this.uuid=El(),this.name="",this.source=new Ja(r),this.mipmaps=[],this.mapping=l,this.channel=0,this.wrapS=h,this.wrapT=f,this.magFilter=g,this.minFilter=v,this.anisotropy=H,this.format=A,this.internalFormat=null,this.type=V,this.offset=new oi(0,0),this.repeat=new oi(1,1),this.center=new oi(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new da,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=Z,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(r&&r.depth&&r.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(dp).x}get height(){return this.source.getSize(dp).y}get depth(){return this.source.getSize(dp).z}get image(){return this.source.data}set image(r=null){this.source.data=r}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(r,l){this.updateRanges.push({start:r,count:l})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(r){return this.name=r.name,this.source=r.source,this.mipmaps=r.mipmaps.slice(0),this.mapping=r.mapping,this.channel=r.channel,this.wrapS=r.wrapS,this.wrapT=r.wrapT,this.magFilter=r.magFilter,this.minFilter=r.minFilter,this.anisotropy=r.anisotropy,this.format=r.format,this.internalFormat=r.internalFormat,this.type=r.type,this.offset.copy(r.offset),this.repeat.copy(r.repeat),this.center.copy(r.center),this.rotation=r.rotation,this.matrixAutoUpdate=r.matrixAutoUpdate,this.matrix.copy(r.matrix),this.generateMipmaps=r.generateMipmaps,this.premultiplyAlpha=r.premultiplyAlpha,this.flipY=r.flipY,this.unpackAlignment=r.unpackAlignment,this.colorSpace=r.colorSpace,this.renderTarget=r.renderTarget,this.isRenderTargetTexture=r.isRenderTargetTexture,this.isArrayTexture=r.isArrayTexture,this.userData=JSON.parse(JSON.stringify(r.userData)),this.needsUpdate=!0,this}setValues(r){for(const l in r){const h=r[l];if(h===void 0){_r(`Texture.setValues(): parameter '${l}' has value of undefined.`);continue}const f=this[l];if(f===void 0){_r(`Texture.setValues(): property '${l}' does not exist.`);continue}f&&h&&f.isVector2&&h.isVector2||f&&h&&f.isVector3&&h.isVector3||f&&h&&f.isMatrix3&&h.isMatrix3?f.copy(h):this[l]=h}}toJSON(r){const l=r===void 0||typeof r=="string";if(!l&&r.textures[this.uuid]!==void 0)return r.textures[this.uuid];const h={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(r).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&&(h.userData=this.userData),l||(r.textures[this.uuid]=h),h}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(r){if(this.mapping!==Q)return r;if(r.applyMatrix3(this.matrix),r.x<0||r.x>1)switch(this.wrapS){case st:r.x=r.x-Math.floor(r.x);break;case $e:r.x=r.x<0?0:1;break;case ft:Math.abs(Math.floor(r.x)%2)===1?r.x=Math.ceil(r.x)-r.x:r.x=r.x-Math.floor(r.x);break}if(r.y<0||r.y>1)switch(this.wrapT){case st:r.y=r.y-Math.floor(r.y);break;case $e:r.y=r.y<0?0:1;break;case ft:Math.abs(Math.floor(r.y)%2)===1?r.y=Math.ceil(r.y)-r.y:r.y=r.y-Math.floor(r.y);break}return this.flipY&&(r.y=1-r.y),r}set needsUpdate(r){r===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(r){r===!0&&this.pmremVersion++}}bl.DEFAULT_IMAGE=null,bl.DEFAULT_MAPPING=Q,bl.DEFAULT_ANISOTROPY=1;class ka{constructor(r=0,l=0,h=0,f=1){ka.prototype.isVector4=!0,this.x=r,this.y=l,this.z=h,this.w=f}get width(){return this.z}set width(r){this.z=r}get height(){return this.w}set height(r){this.w=r}set(r,l,h,f){return this.x=r,this.y=l,this.z=h,this.w=f,this}setScalar(r){return this.x=r,this.y=r,this.z=r,this.w=r,this}setX(r){return this.x=r,this}setY(r){return this.y=r,this}setZ(r){return this.z=r,this}setW(r){return this.w=r,this}setComponent(r,l){switch(r){case 0:this.x=l;break;case 1:this.y=l;break;case 2:this.z=l;break;case 3:this.w=l;break;default:throw new Error("index is out of range: "+r)}return this}getComponent(r){switch(r){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: "+r)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(r){return this.x=r.x,this.y=r.y,this.z=r.z,this.w=r.w!==void 0?r.w:1,this}add(r){return this.x+=r.x,this.y+=r.y,this.z+=r.z,this.w+=r.w,this}addScalar(r){return this.x+=r,this.y+=r,this.z+=r,this.w+=r,this}addVectors(r,l){return this.x=r.x+l.x,this.y=r.y+l.y,this.z=r.z+l.z,this.w=r.w+l.w,this}addScaledVector(r,l){return this.x+=r.x*l,this.y+=r.y*l,this.z+=r.z*l,this.w+=r.w*l,this}sub(r){return this.x-=r.x,this.y-=r.y,this.z-=r.z,this.w-=r.w,this}subScalar(r){return this.x-=r,this.y-=r,this.z-=r,this.w-=r,this}subVectors(r,l){return this.x=r.x-l.x,this.y=r.y-l.y,this.z=r.z-l.z,this.w=r.w-l.w,this}multiply(r){return this.x*=r.x,this.y*=r.y,this.z*=r.z,this.w*=r.w,this}multiplyScalar(r){return this.x*=r,this.y*=r,this.z*=r,this.w*=r,this}applyMatrix4(r){const l=this.x,h=this.y,f=this.z,g=this.w,v=r.elements;return this.x=v[0]*l+v[4]*h+v[8]*f+v[12]*g,this.y=v[1]*l+v[5]*h+v[9]*f+v[13]*g,this.z=v[2]*l+v[6]*h+v[10]*f+v[14]*g,this.w=v[3]*l+v[7]*h+v[11]*f+v[15]*g,this}divide(r){return this.x/=r.x,this.y/=r.y,this.z/=r.z,this.w/=r.w,this}divideScalar(r){return this.multiplyScalar(1/r)}setAxisAngleFromQuaternion(r){this.w=2*Math.acos(r.w);const l=Math.sqrt(1-r.w*r.w);return l<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=r.x/l,this.y=r.y/l,this.z=r.z/l),this}setAxisAngleFromRotationMatrix(r){let l,h,f,g;const V=r.elements,H=V[0],Z=V[4],ce=V[8],he=V[1],de=V[5],Me=V[9],Je=V[2],mt=V[6],pt=V[10];if(Math.abs(Z-he)<.01&&Math.abs(ce-Je)<.01&&Math.abs(Me-mt)<.01){if(Math.abs(Z+he)<.1&&Math.abs(ce+Je)<.1&&Math.abs(Me+mt)<.1&&Math.abs(H+de+pt-3)<.1)return this.set(1,0,0,0),this;l=Math.PI;const Pt=(H+1)/2,Gt=(de+1)/2,gn=(pt+1)/2,Sn=(Z+he)/4,kn=(ce+Je)/4,In=(Me+mt)/4;return Pt>Gt&&Pt>gn?Pt<.01?(h=0,f=.707106781,g=.707106781):(h=Math.sqrt(Pt),f=Sn/h,g=kn/h):Gt>gn?Gt<.01?(h=.707106781,f=0,g=.707106781):(f=Math.sqrt(Gt),h=Sn/f,g=In/f):gn<.01?(h=.707106781,f=.707106781,g=0):(g=Math.sqrt(gn),h=kn/g,f=In/g),this.set(h,f,g,l),this}let Nt=Math.sqrt((mt-Me)*(mt-Me)+(ce-Je)*(ce-Je)+(he-Z)*(he-Z));return Math.abs(Nt)<.001&&(Nt=1),this.x=(mt-Me)/Nt,this.y=(ce-Je)/Nt,this.z=(he-Z)/Nt,this.w=Math.acos((H+de+pt-1)/2),this}setFromMatrixPosition(r){const l=r.elements;return this.x=l[12],this.y=l[13],this.z=l[14],this.w=l[15],this}min(r){return this.x=Math.min(this.x,r.x),this.y=Math.min(this.y,r.y),this.z=Math.min(this.z,r.z),this.w=Math.min(this.w,r.w),this}max(r){return this.x=Math.max(this.x,r.x),this.y=Math.max(this.y,r.y),this.z=Math.max(this.z,r.z),this.w=Math.max(this.w,r.w),this}clamp(r,l){return this.x=Br(this.x,r.x,l.x),this.y=Br(this.y,r.y,l.y),this.z=Br(this.z,r.z,l.z),this.w=Br(this.w,r.w,l.w),this}clampScalar(r,l){return this.x=Br(this.x,r,l),this.y=Br(this.y,r,l),this.z=Br(this.z,r,l),this.w=Br(this.w,r,l),this}clampLength(r,l){const h=this.length();return this.divideScalar(h||1).multiplyScalar(Br(h,r,l))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(r){return this.x*r.x+this.y*r.y+this.z*r.z+this.w*r.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(r){return this.normalize().multiplyScalar(r)}lerp(r,l){return this.x+=(r.x-this.x)*l,this.y+=(r.y-this.y)*l,this.z+=(r.z-this.z)*l,this.w+=(r.w-this.w)*l,this}lerpVectors(r,l,h){return this.x=r.x+(l.x-r.x)*h,this.y=r.y+(l.y-r.y)*h,this.z=r.z+(l.z-r.z)*h,this.w=r.w+(l.w-r.w)*h,this}equals(r){return r.x===this.x&&r.y===this.y&&r.z===this.z&&r.w===this.w}fromArray(r,l=0){return this.x=r[l],this.y=r[l+1],this.z=r[l+2],this.w=r[l+3],this}toArray(r=[],l=0){return r[l]=this.x,r[l+1]=this.y,r[l+2]=this.z,r[l+3]=this.w,r}fromBufferAttribute(r,l){return this.x=r.getX(l),this.y=r.getY(l),this.z=r.getZ(l),this.w=r.getW(l),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 fa extends null{constructor(r=1,l=1,h={}){super(),h=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Rn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},h),this.isRenderTarget=!0,this.width=r,this.height=l,this.depth=h.depth,this.scissor=new ka(0,0,r,l),this.scissorTest=!1,this.viewport=new ka(0,0,r,l);const f={width:r,height:l,depth:h.depth},g=new bl(f);this.textures=[];const v=h.count;for(let A=0;A<v;A++)this.textures[A]=g.clone(),this.textures[A].isRenderTargetTexture=!0,this.textures[A].renderTarget=this;this._setTextureOptions(h),this.depthBuffer=h.depthBuffer,this.stencilBuffer=h.stencilBuffer,this.resolveDepthBuffer=h.resolveDepthBuffer,this.resolveStencilBuffer=h.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=h.depthTexture,this.samples=h.samples,this.multiview=h.multiview}_setTextureOptions(r={}){const l={minFilter:Rn,generateMipmaps:!1,flipY:!1,internalFormat:null};r.mapping!==void 0&&(l.mapping=r.mapping),r.wrapS!==void 0&&(l.wrapS=r.wrapS),r.wrapT!==void 0&&(l.wrapT=r.wrapT),r.wrapR!==void 0&&(l.wrapR=r.wrapR),r.magFilter!==void 0&&(l.magFilter=r.magFilter),r.minFilter!==void 0&&(l.minFilter=r.minFilter),r.format!==void 0&&(l.format=r.format),r.type!==void 0&&(l.type=r.type),r.anisotropy!==void 0&&(l.anisotropy=r.anisotropy),r.colorSpace!==void 0&&(l.colorSpace=r.colorSpace),r.flipY!==void 0&&(l.flipY=r.flipY),r.generateMipmaps!==void 0&&(l.generateMipmaps=r.generateMipmaps),r.internalFormat!==void 0&&(l.internalFormat=r.internalFormat);for(let h=0;h<this.textures.length;h++)this.textures[h].setValues(l)}get texture(){return this.textures[0]}set texture(r){this.textures[0]=r}set depthTexture(r){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),r!==null&&(r.renderTarget=this),this._depthTexture=r}get depthTexture(){return this._depthTexture}setSize(r,l,h=1){if(this.width!==r||this.height!==l||this.depth!==h){this.width=r,this.height=l,this.depth=h;for(let f=0,g=this.textures.length;f<g;f++)this.textures[f].image.width=r,this.textures[f].image.height=l,this.textures[f].image.depth=h,this.textures[f].isData3DTexture!==!0&&(this.textures[f].isArrayTexture=this.textures[f].image.depth>1);this.dispose()}this.viewport.set(0,0,r,l),this.scissor.set(0,0,r,l)}clone(){return new this.constructor().copy(this)}copy(r){this.width=r.width,this.height=r.height,this.depth=r.depth,this.scissor.copy(r.scissor),this.scissorTest=r.scissorTest,this.viewport.copy(r.viewport),this.textures.length=0;for(let l=0,h=r.textures.length;l<h;l++){this.textures[l]=r.textures[l].clone(),this.textures[l].isRenderTargetTexture=!0,this.textures[l].renderTarget=this;const f=Object.assign({},r.textures[l].image);this.textures[l].source=new Ja(f)}return this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,r.depthTexture!==null&&(this.depthTexture=r.depthTexture.clone()),this.samples=r.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Jl extends null{constructor(r=1,l=1,h={}){super(r,l,h),this.isWebGLRenderTarget=!0}}class Ql extends null{constructor(r=null,l=1,h=1,f=1){super(null),this.isDataArrayTexture=!0,this.image={data:r,width:l,height:h,depth:f},this.magFilter=Ct,this.minFilter=Ct,this.wrapR=$e,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(r){this.layerUpdates.add(r)}clearLayerUpdates(){this.layerUpdates.clear()}}class of extends null{constructor(r=1,l=1,h=1,f={}){super(r,l,f),this.isWebGLArrayRenderTarget=!0,this.depth=h,this.texture=new Ql(null,r,l,h),this._setTextureOptions(f),this.texture.isRenderTargetTexture=!0}}class uu extends null{constructor(r=null,l=1,h=1,f=1){super(null),this.isData3DTexture=!0,this.image={data:r,width:l,height:h,depth:f},this.magFilter=Ct,this.minFilter=Ct,this.wrapR=$e,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class gh extends null{constructor(r=1,l=1,h=1,f={}){super(r,l,f),this.isWebGL3DRenderTarget=!0,this.depth=h,this.texture=new uu(null,r,l,h),this._setTextureOptions(f),this.texture.isRenderTargetTexture=!0}}class na{constructor(r=new Rt(1/0,1/0,1/0),l=new Rt(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=r,this.max=l}set(r,l){return this.min.copy(r),this.max.copy(l),this}setFromArray(r){this.makeEmpty();for(let l=0,h=r.length;l<h;l+=3)this.expandByPoint(Ma.fromArray(r,l));return this}setFromBufferAttribute(r){this.makeEmpty();for(let l=0,h=r.count;l<h;l++)this.expandByPoint(Ma.fromBufferAttribute(r,l));return this}setFromPoints(r){this.makeEmpty();for(let l=0,h=r.length;l<h;l++)this.expandByPoint(r[l]);return this}setFromCenterAndSize(r,l){const h=Ma.copy(l).multiplyScalar(.5);return this.min.copy(r).sub(h),this.max.copy(r).add(h),this}setFromObject(r,l=!1){return this.makeEmpty(),this.expandByObject(r,l)}clone(){return new this.constructor().copy(this)}copy(r){return this.min.copy(r.min),this.max.copy(r.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(r){return this.isEmpty()?r.set(0,0,0):r.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(r){return this.isEmpty()?r.set(0,0,0):r.subVectors(this.max,this.min)}expandByPoint(r){return this.min.min(r),this.max.max(r),this}expandByVector(r){return this.min.sub(r),this.max.add(r),this}expandByScalar(r){return this.min.addScalar(-r),this.max.addScalar(r),this}expandByObject(r,l=!1){r.updateWorldMatrix(!1,!1);const h=r.geometry;if(h!==void 0){const g=h.getAttribute("position");if(l===!0&&g!==void 0&&r.isInstancedMesh!==!0)for(let v=0,A=g.count;v<A;v++)r.isMesh===!0?r.getVertexPosition(v,Ma):Ma.fromBufferAttribute(g,v),Ma.applyMatrix4(r.matrixWorld),this.expandByPoint(Ma);else r.boundingBox!==void 0?(r.boundingBox===null&&r.computeBoundingBox(),dc.copy(r.boundingBox)):(h.boundingBox===null&&h.computeBoundingBox(),dc.copy(h.boundingBox)),dc.applyMatrix4(r.matrixWorld),this.union(dc)}const f=r.children;for(let g=0,v=f.length;g<v;g++)this.expandByObject(f[g],l);return this}containsPoint(r){return r.x>=this.min.x&&r.x<=this.max.x&&r.y>=this.min.y&&r.y<=this.max.y&&r.z>=this.min.z&&r.z<=this.max.z}containsBox(r){return this.min.x<=r.min.x&&r.max.x<=this.max.x&&this.min.y<=r.min.y&&r.max.y<=this.max.y&&this.min.z<=r.min.z&&r.max.z<=this.max.z}getParameter(r,l){return l.set((r.x-this.min.x)/(this.max.x-this.min.x),(r.y-this.min.y)/(this.max.y-this.min.y),(r.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(r){return r.max.x>=this.min.x&&r.min.x<=this.max.x&&r.max.y>=this.min.y&&r.min.y<=this.max.y&&r.max.z>=this.min.z&&r.min.z<=this.max.z}intersectsSphere(r){return this.clampPoint(r.center,Ma),Ma.distanceToSquared(r.center)<=r.radius*r.radius}intersectsPlane(r){let l,h;return r.normal.x>0?(l=r.normal.x*this.min.x,h=r.normal.x*this.max.x):(l=r.normal.x*this.max.x,h=r.normal.x*this.min.x),r.normal.y>0?(l+=r.normal.y*this.min.y,h+=r.normal.y*this.max.y):(l+=r.normal.y*this.max.y,h+=r.normal.y*this.min.y),r.normal.z>0?(l+=r.normal.z*this.min.z,h+=r.normal.z*this.max.z):(l+=r.normal.z*this.max.z,h+=r.normal.z*this.min.z),l<=-r.constant&&h>=-r.constant}intersectsTriangle(r){if(this.isEmpty())return!1;this.getCenter(q),oe.subVectors(this.max,q),fc.subVectors(r.a,q),Oc.subVectors(r.b,q),Fc.subVectors(r.c,q),Al.subVectors(Oc,fc),ne.subVectors(Fc,Oc),$.subVectors(fc,Fc);let l=[0,-Al.z,Al.y,0,-ne.z,ne.y,0,-$.z,$.y,Al.z,0,-Al.x,ne.z,0,-ne.x,$.z,0,-$.x,-Al.y,Al.x,0,-ne.y,ne.x,0,-$.y,$.x,0];return!ze(l,fc,Oc,Fc,oe)||(l=[1,0,0,0,1,0,0,0,1],!ze(l,fc,Oc,Fc,oe))?!1:(xe.crossVectors(Al,ne),l=[xe.x,xe.y,xe.z],ze(l,fc,Oc,Fc,oe))}clampPoint(r,l){return l.copy(r).clamp(this.min,this.max)}distanceToPoint(r){return this.clampPoint(r,Ma).distanceTo(r)}getBoundingSphere(r){return this.isEmpty()?r.makeEmpty():(this.getCenter(r.center),r.radius=this.getSize(Ma).length()*.5),r}intersect(r){return this.min.max(r.min),this.max.min(r.max),this.isEmpty()&&this.makeEmpty(),this}union(r){return this.min.min(r.min),this.max.max(r.max),this}applyMatrix4(r){return this.isEmpty()?this:(za[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(r),za[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(r),za[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(r),za[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(r),za[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(r),za[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(r),za[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(r),za[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(r),this.setFromPoints(za),this)}translate(r){return this.min.add(r),this.max.add(r),this}equals(r){return r.min.equals(this.min)&&r.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(r){return this.min.fromArray(r.min),this.max.fromArray(r.max),this}}const za=[new Rt,new Rt,new Rt,new Rt,new Rt,new Rt,new Rt,new Rt],Ma=new Rt,dc=new na,fc=new Rt,Oc=new Rt,Fc=new Rt,Al=new Rt,ne=new Rt,$=new Rt,q=new Rt,oe=new Rt,xe=new Rt,Ae=new Rt;function ze(j,r,l,h,f){for(let g=0,v=j.length-3;g<=v;g+=3){Ae.fromArray(j,g);const A=f.x*Math.abs(Ae.x)+f.y*Math.abs(Ae.y)+f.z*Math.abs(Ae.z),V=r.dot(Ae),H=l.dot(Ae),Z=h.dot(Ae);if(Math.max(-Math.max(V,H,Z),Math.min(V,H,Z))>A)return!1}return!0}const xt=new na,St=new Rt,Lt=new Rt;class Vt{constructor(r=new Rt,l=-1){this.isSphere=!0,this.center=r,this.radius=l}set(r,l){return this.center.copy(r),this.radius=l,this}setFromPoints(r,l){const h=this.center;l!==void 0?h.copy(l):xt.setFromPoints(r).getCenter(h);let f=0;for(let g=0,v=r.length;g<v;g++)f=Math.max(f,h.distanceToSquared(r[g]));return this.radius=Math.sqrt(f),this}copy(r){return this.center.copy(r.center),this.radius=r.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(r){return r.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(r){return r.distanceTo(this.center)-this.radius}intersectsSphere(r){const l=this.radius+r.radius;return r.center.distanceToSquared(this.center)<=l*l}intersectsBox(r){return r.intersectsSphere(this)}intersectsPlane(r){return Math.abs(r.distanceToPoint(this.center))<=this.radius}clampPoint(r,l){const h=this.center.distanceToSquared(r);return l.copy(r),h>this.radius*this.radius&&(l.sub(this.center).normalize(),l.multiplyScalar(this.radius).add(this.center)),l}getBoundingBox(r){return this.isEmpty()?(r.makeEmpty(),r):(r.set(this.center,this.center),r.expandByScalar(this.radius),r)}applyMatrix4(r){return this.center.applyMatrix4(r),this.radius=this.radius*r.getMaxScaleOnAxis(),this}translate(r){return this.center.add(r),this}expandByPoint(r){if(this.isEmpty())return this.center.copy(r),this.radius=0,this;St.subVectors(r,this.center);const l=St.lengthSq();if(l>this.radius*this.radius){const h=Math.sqrt(l),f=(h-this.radius)*.5;this.center.addScaledVector(St,f/h),this.radius+=f}return this}union(r){return r.isEmpty()?this:this.isEmpty()?(this.copy(r),this):(this.center.equals(r.center)===!0?this.radius=Math.max(this.radius,r.radius):(Lt.subVectors(r.center,this.center).setLength(r.radius),this.expandByPoint(St.copy(r.center).add(Lt)),this.expandByPoint(St.copy(r.center).sub(Lt))),this)}equals(r){return r.center.equals(this.center)&&r.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(r){return this.radius=r.radius,this.center.fromArray(r.center),this}}const Ht=new Rt,hn=new Rt,Ft=new Rt,_n=new Rt,Nn=new Rt,Pn=new Rt,ei=new Rt;class ai{constructor(r=new Rt,l=new Rt(0,0,-1)){this.origin=r,this.direction=l}set(r,l){return this.origin.copy(r),this.direction.copy(l),this}copy(r){return this.origin.copy(r.origin),this.direction.copy(r.direction),this}at(r,l){return l.copy(this.origin).addScaledVector(this.direction,r)}lookAt(r){return this.direction.copy(r).sub(this.origin).normalize(),this}recast(r){return this.origin.copy(this.at(r,Ht)),this}closestPointToPoint(r,l){l.subVectors(r,this.origin);const h=l.dot(this.direction);return h<0?l.copy(this.origin):l.copy(this.origin).addScaledVector(this.direction,h)}distanceToPoint(r){return Math.sqrt(this.distanceSqToPoint(r))}distanceSqToPoint(r){const l=Ht.subVectors(r,this.origin).dot(this.direction);return l<0?this.origin.distanceToSquared(r):(Ht.copy(this.origin).addScaledVector(this.direction,l),Ht.distanceToSquared(r))}distanceSqToSegment(r,l,h,f){hn.copy(r).add(l).multiplyScalar(.5),Ft.copy(l).sub(r).normalize(),_n.copy(this.origin).sub(hn);const g=r.distanceTo(l)*.5,v=-this.direction.dot(Ft),A=_n.dot(this.direction),V=-_n.dot(Ft),H=_n.lengthSq(),Z=Math.abs(1-v*v);let ce,he,de,Me;if(Z>0)if(ce=v*V-A,he=v*A-V,Me=g*Z,ce>=0)if(he>=-Me)if(he<=Me){const Je=1/Z;ce*=Je,he*=Je,de=ce*(ce+v*he+2*A)+he*(v*ce+he+2*V)+H}else he=g,ce=Math.max(0,-(v*he+A)),de=-ce*ce+he*(he+2*V)+H;else he=-g,ce=Math.max(0,-(v*he+A)),de=-ce*ce+he*(he+2*V)+H;else he<=-Me?(ce=Math.max(0,-(-v*g+A)),he=ce>0?-g:Math.min(Math.max(-g,-V),g),de=-ce*ce+he*(he+2*V)+H):he<=Me?(ce=0,he=Math.min(Math.max(-g,-V),g),de=he*(he+2*V)+H):(ce=Math.max(0,-(v*g+A)),he=ce>0?g:Math.min(Math.max(-g,-V),g),de=-ce*ce+he*(he+2*V)+H);else he=v>0?-g:g,ce=Math.max(0,-(v*he+A)),de=-ce*ce+he*(he+2*V)+H;return h&&h.copy(this.origin).addScaledVector(this.direction,ce),f&&f.copy(hn).addScaledVector(Ft,he),de}intersectSphere(r,l){Ht.subVectors(r.center,this.origin);const h=Ht.dot(this.direction),f=Ht.dot(Ht)-h*h,g=r.radius*r.radius;if(f>g)return null;const v=Math.sqrt(g-f),A=h-v,V=h+v;return V<0?null:A<0?this.at(V,l):this.at(A,l)}intersectsSphere(r){return r.radius<0?!1:this.distanceSqToPoint(r.center)<=r.radius*r.radius}distanceToPlane(r){const l=r.normal.dot(this.direction);if(l===0)return r.distanceToPoint(this.origin)===0?0:null;const h=-(this.origin.dot(r.normal)+r.constant)/l;return h>=0?h:null}intersectPlane(r,l){const h=this.distanceToPlane(r);return h===null?null:this.at(h,l)}intersectsPlane(r){const l=r.distanceToPoint(this.origin);return l===0||r.normal.dot(this.direction)*l<0}intersectBox(r,l){let h,f,g,v,A,V;const H=1/this.direction.x,Z=1/this.direction.y,ce=1/this.direction.z,he=this.origin;return H>=0?(h=(r.min.x-he.x)*H,f=(r.max.x-he.x)*H):(h=(r.max.x-he.x)*H,f=(r.min.x-he.x)*H),Z>=0?(g=(r.min.y-he.y)*Z,v=(r.max.y-he.y)*Z):(g=(r.max.y-he.y)*Z,v=(r.min.y-he.y)*Z),h>v||g>f||((g>h||isNaN(h))&&(h=g),(v<f||isNaN(f))&&(f=v),ce>=0?(A=(r.min.z-he.z)*ce,V=(r.max.z-he.z)*ce):(A=(r.max.z-he.z)*ce,V=(r.min.z-he.z)*ce),h>V||A>f)||((A>h||h!==h)&&(h=A),(V<f||f!==f)&&(f=V),f<0)?null:this.at(h>=0?h:f,l)}intersectsBox(r){return this.intersectBox(r,Ht)!==null}intersectTriangle(r,l,h,f,g){Nn.subVectors(l,r),Pn.subVectors(h,r),ei.crossVectors(Nn,Pn);let v=this.direction.dot(ei),A;if(v>0){if(f)return null;A=1}else if(v<0)A=-1,v=-v;else return null;_n.subVectors(this.origin,r);const V=A*this.direction.dot(Pn.crossVectors(_n,Pn));if(V<0)return null;const H=A*this.direction.dot(Nn.cross(_n));if(H<0||V+H>v)return null;const Z=-A*_n.dot(ei);return Z<0?null:this.at(Z/v,g)}applyMatrix4(r){return this.origin.applyMatrix4(r),this.direction.transformDirection(r),this}equals(r){return r.origin.equals(this.origin)&&r.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class On{constructor(r,l,h,f,g,v,A,V,H,Z,ce,he,de,Me,Je,mt){On.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],r!==void 0&&this.set(r,l,h,f,g,v,A,V,H,Z,ce,he,de,Me,Je,mt)}set(r,l,h,f,g,v,A,V,H,Z,ce,he,de,Me,Je,mt){const pt=this.elements;return pt[0]=r,pt[4]=l,pt[8]=h,pt[12]=f,pt[1]=g,pt[5]=v,pt[9]=A,pt[13]=V,pt[2]=H,pt[6]=Z,pt[10]=ce,pt[14]=he,pt[3]=de,pt[7]=Me,pt[11]=Je,pt[15]=mt,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 On().fromArray(this.elements)}copy(r){const l=this.elements,h=r.elements;return l[0]=h[0],l[1]=h[1],l[2]=h[2],l[3]=h[3],l[4]=h[4],l[5]=h[5],l[6]=h[6],l[7]=h[7],l[8]=h[8],l[9]=h[9],l[10]=h[10],l[11]=h[11],l[12]=h[12],l[13]=h[13],l[14]=h[14],l[15]=h[15],this}copyPosition(r){const l=this.elements,h=r.elements;return l[12]=h[12],l[13]=h[13],l[14]=h[14],this}setFromMatrix3(r){const l=r.elements;return this.set(l[0],l[3],l[6],0,l[1],l[4],l[7],0,l[2],l[5],l[8],0,0,0,0,1),this}extractBasis(r,l,h){return r.setFromMatrixColumn(this,0),l.setFromMatrixColumn(this,1),h.setFromMatrixColumn(this,2),this}makeBasis(r,l,h){return this.set(r.x,l.x,h.x,0,r.y,l.y,h.y,0,r.z,l.z,h.z,0,0,0,0,1),this}extractRotation(r){const l=this.elements,h=r.elements,f=1/di.setFromMatrixColumn(r,0).length(),g=1/di.setFromMatrixColumn(r,1).length(),v=1/di.setFromMatrixColumn(r,2).length();return l[0]=h[0]*f,l[1]=h[1]*f,l[2]=h[2]*f,l[3]=0,l[4]=h[4]*g,l[5]=h[5]*g,l[6]=h[6]*g,l[7]=0,l[8]=h[8]*v,l[9]=h[9]*v,l[10]=h[10]*v,l[11]=0,l[12]=0,l[13]=0,l[14]=0,l[15]=1,this}makeRotationFromEuler(r){const l=this.elements,h=r.x,f=r.y,g=r.z,v=Math.cos(h),A=Math.sin(h),V=Math.cos(f),H=Math.sin(f),Z=Math.cos(g),ce=Math.sin(g);if(r.order==="XYZ"){const he=v*Z,de=v*ce,Me=A*Z,Je=A*ce;l[0]=V*Z,l[4]=-V*ce,l[8]=H,l[1]=de+Me*H,l[5]=he-Je*H,l[9]=-A*V,l[2]=Je-he*H,l[6]=Me+de*H,l[10]=v*V}else if(r.order==="YXZ"){const he=V*Z,de=V*ce,Me=H*Z,Je=H*ce;l[0]=he+Je*A,l[4]=Me*A-de,l[8]=v*H,l[1]=v*ce,l[5]=v*Z,l[9]=-A,l[2]=de*A-Me,l[6]=Je+he*A,l[10]=v*V}else if(r.order==="ZXY"){const he=V*Z,de=V*ce,Me=H*Z,Je=H*ce;l[0]=he-Je*A,l[4]=-v*ce,l[8]=Me+de*A,l[1]=de+Me*A,l[5]=v*Z,l[9]=Je-he*A,l[2]=-v*H,l[6]=A,l[10]=v*V}else if(r.order==="ZYX"){const he=v*Z,de=v*ce,Me=A*Z,Je=A*ce;l[0]=V*Z,l[4]=Me*H-de,l[8]=he*H+Je,l[1]=V*ce,l[5]=Je*H+he,l[9]=de*H-Me,l[2]=-H,l[6]=A*V,l[10]=v*V}else if(r.order==="YZX"){const he=v*V,de=v*H,Me=A*V,Je=A*H;l[0]=V*Z,l[4]=Je-he*ce,l[8]=Me*ce+de,l[1]=ce,l[5]=v*Z,l[9]=-A*Z,l[2]=-H*Z,l[6]=de*ce+Me,l[10]=he-Je*ce}else if(r.order==="XZY"){const he=v*V,de=v*H,Me=A*V,Je=A*H;l[0]=V*Z,l[4]=-ce,l[8]=H*Z,l[1]=he*ce+Je,l[5]=v*Z,l[9]=de*ce-Me,l[2]=Me*ce-de,l[6]=A*Z,l[10]=Je*ce+he}return l[3]=0,l[7]=0,l[11]=0,l[12]=0,l[13]=0,l[14]=0,l[15]=1,this}makeRotationFromQuaternion(r){return this.compose(ji,r,Qi)}lookAt(r,l,h){const f=this.elements;return yr.subVectors(r,l),yr.lengthSq()===0&&(yr.z=1),yr.normalize(),er.crossVectors(h,yr),er.lengthSq()===0&&(Math.abs(h.z)===1?yr.x+=1e-4:yr.z+=1e-4,yr.normalize(),er.crossVectors(h,yr)),er.normalize(),gr.crossVectors(yr,er),f[0]=er.x,f[4]=gr.x,f[8]=yr.x,f[1]=er.y,f[5]=gr.y,f[9]=yr.y,f[2]=er.z,f[6]=gr.z,f[10]=yr.z,this}multiply(r){return this.multiplyMatrices(this,r)}premultiply(r){return this.multiplyMatrices(r,this)}multiplyMatrices(r,l){const h=r.elements,f=l.elements,g=this.elements,v=h[0],A=h[4],V=h[8],H=h[12],Z=h[1],ce=h[5],he=h[9],de=h[13],Me=h[2],Je=h[6],mt=h[10],pt=h[14],Nt=h[3],Pt=h[7],Gt=h[11],gn=h[15],Sn=f[0],kn=f[4],In=f[8],ii=f[12],li=f[1],dr=f[5],Zr=f[9],Ts=f[13],to=f[2],ho=f[6],Ra=f[10],fl=f[14],ic=f[3],qo=f[7],Na=f[11],Yo=f[15];return g[0]=v*Sn+A*li+V*to+H*ic,g[4]=v*kn+A*dr+V*ho+H*qo,g[8]=v*In+A*Zr+V*Ra+H*Na,g[12]=v*ii+A*Ts+V*fl+H*Yo,g[1]=Z*Sn+ce*li+he*to+de*ic,g[5]=Z*kn+ce*dr+he*ho+de*qo,g[9]=Z*In+ce*Zr+he*Ra+de*Na,g[13]=Z*ii+ce*Ts+he*fl+de*Yo,g[2]=Me*Sn+Je*li+mt*to+pt*ic,g[6]=Me*kn+Je*dr+mt*ho+pt*qo,g[10]=Me*In+Je*Zr+mt*Ra+pt*Na,g[14]=Me*ii+Je*Ts+mt*fl+pt*Yo,g[3]=Nt*Sn+Pt*li+Gt*to+gn*ic,g[7]=Nt*kn+Pt*dr+Gt*ho+gn*qo,g[11]=Nt*In+Pt*Zr+Gt*Ra+gn*Na,g[15]=Nt*ii+Pt*Ts+Gt*fl+gn*Yo,this}multiplyScalar(r){const l=this.elements;return l[0]*=r,l[4]*=r,l[8]*=r,l[12]*=r,l[1]*=r,l[5]*=r,l[9]*=r,l[13]*=r,l[2]*=r,l[6]*=r,l[10]*=r,l[14]*=r,l[3]*=r,l[7]*=r,l[11]*=r,l[15]*=r,this}determinant(){const r=this.elements,l=r[0],h=r[4],f=r[8],g=r[12],v=r[1],A=r[5],V=r[9],H=r[13],Z=r[2],ce=r[6],he=r[10],de=r[14],Me=r[3],Je=r[7],mt=r[11],pt=r[15];return Me*(+g*V*ce-f*H*ce-g*A*he+h*H*he+f*A*de-h*V*de)+Je*(+l*V*de-l*H*he+g*v*he-f*v*de+f*H*Z-g*V*Z)+mt*(+l*H*ce-l*A*de-g*v*ce+h*v*de+g*A*Z-h*H*Z)+pt*(-f*A*Z-l*V*ce+l*A*he+f*v*ce-h*v*he+h*V*Z)}transpose(){const r=this.elements;let l;return l=r[1],r[1]=r[4],r[4]=l,l=r[2],r[2]=r[8],r[8]=l,l=r[6],r[6]=r[9],r[9]=l,l=r[3],r[3]=r[12],r[12]=l,l=r[7],r[7]=r[13],r[13]=l,l=r[11],r[11]=r[14],r[14]=l,this}setPosition(r,l,h){const f=this.elements;return r.isVector3?(f[12]=r.x,f[13]=r.y,f[14]=r.z):(f[12]=r,f[13]=l,f[14]=h),this}invert(){const r=this.elements,l=r[0],h=r[1],f=r[2],g=r[3],v=r[4],A=r[5],V=r[6],H=r[7],Z=r[8],ce=r[9],he=r[10],de=r[11],Me=r[12],Je=r[13],mt=r[14],pt=r[15],Nt=ce*mt*H-Je*he*H+Je*V*de-A*mt*de-ce*V*pt+A*he*pt,Pt=Me*he*H-Z*mt*H-Me*V*de+v*mt*de+Z*V*pt-v*he*pt,Gt=Z*Je*H-Me*ce*H+Me*A*de-v*Je*de-Z*A*pt+v*ce*pt,gn=Me*ce*V-Z*Je*V-Me*A*he+v*Je*he+Z*A*mt-v*ce*mt,Sn=l*Nt+h*Pt+f*Gt+g*gn;if(Sn===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const kn=1/Sn;return r[0]=Nt*kn,r[1]=(Je*he*g-ce*mt*g-Je*f*de+h*mt*de+ce*f*pt-h*he*pt)*kn,r[2]=(A*mt*g-Je*V*g+Je*f*H-h*mt*H-A*f*pt+h*V*pt)*kn,r[3]=(ce*V*g-A*he*g-ce*f*H+h*he*H+A*f*de-h*V*de)*kn,r[4]=Pt*kn,r[5]=(Z*mt*g-Me*he*g+Me*f*de-l*mt*de-Z*f*pt+l*he*pt)*kn,r[6]=(Me*V*g-v*mt*g-Me*f*H+l*mt*H+v*f*pt-l*V*pt)*kn,r[7]=(v*he*g-Z*V*g+Z*f*H-l*he*H-v*f*de+l*V*de)*kn,r[8]=Gt*kn,r[9]=(Me*ce*g-Z*Je*g-Me*h*de+l*Je*de+Z*h*pt-l*ce*pt)*kn,r[10]=(v*Je*g-Me*A*g+Me*h*H-l*Je*H-v*h*pt+l*A*pt)*kn,r[11]=(Z*A*g-v*ce*g-Z*h*H+l*ce*H+v*h*de-l*A*de)*kn,r[12]=gn*kn,r[13]=(Z*Je*f-Me*ce*f+Me*h*he-l*Je*he-Z*h*mt+l*ce*mt)*kn,r[14]=(Me*A*f-v*Je*f-Me*h*V+l*Je*V+v*h*mt-l*A*mt)*kn,r[15]=(v*ce*f-Z*A*f+Z*h*V-l*ce*V-v*h*he+l*A*he)*kn,this}scale(r){const l=this.elements,h=r.x,f=r.y,g=r.z;return l[0]*=h,l[4]*=f,l[8]*=g,l[1]*=h,l[5]*=f,l[9]*=g,l[2]*=h,l[6]*=f,l[10]*=g,l[3]*=h,l[7]*=f,l[11]*=g,this}getMaxScaleOnAxis(){const r=this.elements,l=r[0]*r[0]+r[1]*r[1]+r[2]*r[2],h=r[4]*r[4]+r[5]*r[5]+r[6]*r[6],f=r[8]*r[8]+r[9]*r[9]+r[10]*r[10];return Math.sqrt(Math.max(l,h,f))}makeTranslation(r,l,h){return r.isVector3?this.set(1,0,0,r.x,0,1,0,r.y,0,0,1,r.z,0,0,0,1):this.set(1,0,0,r,0,1,0,l,0,0,1,h,0,0,0,1),this}makeRotationX(r){const l=Math.cos(r),h=Math.sin(r);return this.set(1,0,0,0,0,l,-h,0,0,h,l,0,0,0,0,1),this}makeRotationY(r){const l=Math.cos(r),h=Math.sin(r);return this.set(l,0,h,0,0,1,0,0,-h,0,l,0,0,0,0,1),this}makeRotationZ(r){const l=Math.cos(r),h=Math.sin(r);return this.set(l,-h,0,0,h,l,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(r,l){const h=Math.cos(l),f=Math.sin(l),g=1-h,v=r.x,A=r.y,V=r.z,H=g*v,Z=g*A;return this.set(H*v+h,H*A-f*V,H*V+f*A,0,H*A+f*V,Z*A+h,Z*V-f*v,0,H*V-f*A,Z*V+f*v,g*V*V+h,0,0,0,0,1),this}makeScale(r,l,h){return this.set(r,0,0,0,0,l,0,0,0,0,h,0,0,0,0,1),this}makeShear(r,l,h,f,g,v){return this.set(1,h,g,0,r,1,v,0,l,f,1,0,0,0,0,1),this}compose(r,l,h){const f=this.elements,g=l._x,v=l._y,A=l._z,V=l._w,H=g+g,Z=v+v,ce=A+A,he=g*H,de=g*Z,Me=g*ce,Je=v*Z,mt=v*ce,pt=A*ce,Nt=V*H,Pt=V*Z,Gt=V*ce,gn=h.x,Sn=h.y,kn=h.z;return f[0]=(1-(Je+pt))*gn,f[1]=(de+Gt)*gn,f[2]=(Me-Pt)*gn,f[3]=0,f[4]=(de-Gt)*Sn,f[5]=(1-(he+pt))*Sn,f[6]=(mt+Nt)*Sn,f[7]=0,f[8]=(Me+Pt)*kn,f[9]=(mt-Nt)*kn,f[10]=(1-(he+Je))*kn,f[11]=0,f[12]=r.x,f[13]=r.y,f[14]=r.z,f[15]=1,this}decompose(r,l,h){const f=this.elements;let g=di.set(f[0],f[1],f[2]).length();const v=di.set(f[4],f[5],f[6]).length(),A=di.set(f[8],f[9],f[10]).length();this.determinant()<0&&(g=-g),r.x=f[12],r.y=f[13],r.z=f[14],Ri.copy(this);const H=1/g,Z=1/v,ce=1/A;return Ri.elements[0]*=H,Ri.elements[1]*=H,Ri.elements[2]*=H,Ri.elements[4]*=Z,Ri.elements[5]*=Z,Ri.elements[6]*=Z,Ri.elements[8]*=ce,Ri.elements[9]*=ce,Ri.elements[10]*=ce,l.setFromRotationMatrix(Ri),h.x=g,h.y=v,h.z=A,this}makePerspective(r,l,h,f,g,v,A=oo,V=!1){const H=this.elements,Z=2*g/(l-r),ce=2*g/(h-f),he=(l+r)/(l-r),de=(h+f)/(h-f);let Me,Je;if(V)Me=g/(v-g),Je=v*g/(v-g);else if(A===oo)Me=-(v+g)/(v-g),Je=-2*v*g/(v-g);else if(A===qa)Me=-v/(v-g),Je=-v*g/(v-g);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+A);return H[0]=Z,H[4]=0,H[8]=he,H[12]=0,H[1]=0,H[5]=ce,H[9]=de,H[13]=0,H[2]=0,H[6]=0,H[10]=Me,H[14]=Je,H[3]=0,H[7]=0,H[11]=-1,H[15]=0,this}makeOrthographic(r,l,h,f,g,v,A=oo,V=!1){const H=this.elements,Z=2/(l-r),ce=2/(h-f),he=-(l+r)/(l-r),de=-(h+f)/(h-f);let Me,Je;if(V)Me=1/(v-g),Je=v/(v-g);else if(A===oo)Me=-2/(v-g),Je=-(v+g)/(v-g);else if(A===qa)Me=-1/(v-g),Je=-g/(v-g);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+A);return H[0]=Z,H[4]=0,H[8]=0,H[12]=he,H[1]=0,H[5]=ce,H[9]=0,H[13]=de,H[2]=0,H[6]=0,H[10]=Me,H[14]=Je,H[3]=0,H[7]=0,H[11]=0,H[15]=1,this}equals(r){const l=this.elements,h=r.elements;for(let f=0;f<16;f++)if(l[f]!==h[f])return!1;return!0}fromArray(r,l=0){for(let h=0;h<16;h++)this.elements[h]=r[h+l];return this}toArray(r=[],l=0){const h=this.elements;return r[l]=h[0],r[l+1]=h[1],r[l+2]=h[2],r[l+3]=h[3],r[l+4]=h[4],r[l+5]=h[5],r[l+6]=h[6],r[l+7]=h[7],r[l+8]=h[8],r[l+9]=h[9],r[l+10]=h[10],r[l+11]=h[11],r[l+12]=h[12],r[l+13]=h[13],r[l+14]=h[14],r[l+15]=h[15],r}}const di=new Rt,Ri=new On,ji=new Rt(0,0,0),Qi=new Rt(1,1,1),er=new Rt,gr=new Rt,yr=new Rt,Pr=new On,Ji=new _l;class us{constructor(r=0,l=0,h=0,f=us.DEFAULT_ORDER){this.isEuler=!0,this._x=r,this._y=l,this._z=h,this._order=f}get x(){return this._x}set x(r){this._x=r,this._onChangeCallback()}get y(){return this._y}set y(r){this._y=r,this._onChangeCallback()}get z(){return this._z}set z(r){this._z=r,this._onChangeCallback()}get order(){return this._order}set order(r){this._order=r,this._onChangeCallback()}set(r,l,h,f=this._order){return this._x=r,this._y=l,this._z=h,this._order=f,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(r){return this._x=r._x,this._y=r._y,this._z=r._z,this._order=r._order,this._onChangeCallback(),this}setFromRotationMatrix(r,l=this._order,h=!0){const f=r.elements,g=f[0],v=f[4],A=f[8],V=f[1],H=f[5],Z=f[9],ce=f[2],he=f[6],de=f[10];switch(l){case"XYZ":this._y=Math.asin(Br(A,-1,1)),Math.abs(A)<.9999999?(this._x=Math.atan2(-Z,de),this._z=Math.atan2(-v,g)):(this._x=Math.atan2(he,H),this._z=0);break;case"YXZ":this._x=Math.asin(-Br(Z,-1,1)),Math.abs(Z)<.9999999?(this._y=Math.atan2(A,de),this._z=Math.atan2(V,H)):(this._y=Math.atan2(-ce,g),this._z=0);break;case"ZXY":this._x=Math.asin(Br(he,-1,1)),Math.abs(he)<.9999999?(this._y=Math.atan2(-ce,de),this._z=Math.atan2(-v,H)):(this._y=0,this._z=Math.atan2(V,g));break;case"ZYX":this._y=Math.asin(-Br(ce,-1,1)),Math.abs(ce)<.9999999?(this._x=Math.atan2(he,de),this._z=Math.atan2(V,g)):(this._x=0,this._z=Math.atan2(-v,H));break;case"YZX":this._z=Math.asin(Br(V,-1,1)),Math.abs(V)<.9999999?(this._x=Math.atan2(-Z,H),this._y=Math.atan2(-ce,g)):(this._x=0,this._y=Math.atan2(A,de));break;case"XZY":this._z=Math.asin(-Br(v,-1,1)),Math.abs(v)<.9999999?(this._x=Math.atan2(he,H),this._y=Math.atan2(A,g)):(this._x=Math.atan2(-Z,de),this._y=0);break;default:_r("Euler: .setFromRotationMatrix() encountered an unknown order: "+l)}return this._order=l,h===!0&&this._onChangeCallback(),this}setFromQuaternion(r,l,h){return Pr.makeRotationFromQuaternion(r),this.setFromRotationMatrix(Pr,l,h)}setFromVector3(r,l=this._order){return this.set(r.x,r.y,r.z,l)}reorder(r){return Ji.setFromEuler(this),this.setFromQuaternion(Ji,r)}equals(r){return r._x===this._x&&r._y===this._y&&r._z===this._z&&r._order===this._order}fromArray(r){return this._x=r[0],this._y=r[1],this._z=r[2],r[3]!==void 0&&(this._order=r[3]),this._onChangeCallback(),this}toArray(r=[],l=0){return r[l]=this._x,r[l+1]=this._y,r[l+2]=this._z,r[l+3]=this._order,r}_onChange(r){return this._onChangeCallback=r,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}us.DEFAULT_ORDER="XYZ";class fs{constructor(){this.mask=1}set(r){this.mask=(1<<r|0)>>>0}enable(r){this.mask|=1<<r|0}enableAll(){this.mask=-1}toggle(r){this.mask^=1<<r|0}disable(r){this.mask&=~(1<<r|0)}disableAll(){this.mask=0}test(r){return(this.mask&r.mask)!==0}isEnabled(r){return(this.mask&(1<<r|0))!==0}}let As=0;const Ws=new Rt,Cs=new _l,hs=new On,Mi=new Rt,Xi=new Rt,Ur=new Rt,zr=new _l,Or=new Rt(1,0,0),Qr=new Rt(0,1,0),Ds=new Rt(0,0,1),Do={type:"added"},Qa={type:"removed"},ao={type:"childadded",child:null},cl={type:"childremoved",child:null};class _s extends zu{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:As++}),this.uuid=El(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=_s.DEFAULT_UP.clone();const r=new Rt,l=new us,h=new _l,f=new Rt(1,1,1);function g(){h.setFromEuler(l,!1)}function v(){l.setFromQuaternion(h,void 0,!1)}l._onChange(g),h._onChange(v),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:r},rotation:{configurable:!0,enumerable:!0,value:l},quaternion:{configurable:!0,enumerable:!0,value:h},scale:{configurable:!0,enumerable:!0,value:f},modelViewMatrix:{value:new On},normalMatrix:{value:new da}}),this.matrix=new On,this.matrixWorld=new On,this.matrixAutoUpdate=_s.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=_s.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new fs,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(r){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(r),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(r){return this.quaternion.premultiply(r),this}setRotationFromAxisAngle(r,l){this.quaternion.setFromAxisAngle(r,l)}setRotationFromEuler(r){this.quaternion.setFromEuler(r,!0)}setRotationFromMatrix(r){this.quaternion.setFromRotationMatrix(r)}setRotationFromQuaternion(r){this.quaternion.copy(r)}rotateOnAxis(r,l){return Cs.setFromAxisAngle(r,l),this.quaternion.multiply(Cs),this}rotateOnWorldAxis(r,l){return Cs.setFromAxisAngle(r,l),this.quaternion.premultiply(Cs),this}rotateX(r){return this.rotateOnAxis(Or,r)}rotateY(r){return this.rotateOnAxis(Qr,r)}rotateZ(r){return this.rotateOnAxis(Ds,r)}translateOnAxis(r,l){return Ws.copy(r).applyQuaternion(this.quaternion),this.position.add(Ws.multiplyScalar(l)),this}translateX(r){return this.translateOnAxis(Or,r)}translateY(r){return this.translateOnAxis(Qr,r)}translateZ(r){return this.translateOnAxis(Ds,r)}localToWorld(r){return this.updateWorldMatrix(!0,!1),r.applyMatrix4(this.matrixWorld)}worldToLocal(r){return this.updateWorldMatrix(!0,!1),r.applyMatrix4(hs.copy(this.matrixWorld).invert())}lookAt(r,l,h){r.isVector3?Mi.copy(r):Mi.set(r,l,h);const f=this.parent;this.updateWorldMatrix(!0,!1),Xi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?hs.lookAt(Xi,Mi,this.up):hs.lookAt(Mi,Xi,this.up),this.quaternion.setFromRotationMatrix(hs),f&&(hs.extractRotation(f.matrixWorld),Cs.setFromRotationMatrix(hs),this.quaternion.premultiply(Cs.invert()))}add(r){if(arguments.length>1){for(let l=0;l<arguments.length;l++)this.add(arguments[l]);return this}return r===this?(Xs("Object3D.add: object can't be added as a child of itself.",r),this):(r&&r.isObject3D?(r.removeFromParent(),r.parent=this,this.children.push(r),r.dispatchEvent(Do),ao.child=r,this.dispatchEvent(ao),ao.child=null):Xs("Object3D.add: object not an instance of THREE.Object3D.",r),this)}remove(r){if(arguments.length>1){for(let h=0;h<arguments.length;h++)this.remove(arguments[h]);return this}const l=this.children.indexOf(r);return l!==-1&&(r.parent=null,this.children.splice(l,1),r.dispatchEvent(Qa),cl.child=r,this.dispatchEvent(cl),cl.child=null),this}removeFromParent(){const r=this.parent;return r!==null&&r.remove(this),this}clear(){return this.remove(...this.children)}attach(r){return this.updateWorldMatrix(!0,!1),hs.copy(this.matrixWorld).invert(),r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),hs.multiply(r.parent.matrixWorld)),r.applyMatrix4(hs),r.removeFromParent(),r.parent=this,this.children.push(r),r.updateWorldMatrix(!1,!0),r.dispatchEvent(Do),ao.child=r,this.dispatchEvent(ao),ao.child=null,this}getObjectById(r){return this.getObjectByProperty("id",r)}getObjectByName(r){return this.getObjectByProperty("name",r)}getObjectByProperty(r,l){if(this[r]===l)return this;for(let h=0,f=this.children.length;h<f;h++){const v=this.children[h].getObjectByProperty(r,l);if(v!==void 0)return v}}getObjectsByProperty(r,l,h=[]){this[r]===l&&h.push(this);const f=this.children;for(let g=0,v=f.length;g<v;g++)f[g].getObjectsByProperty(r,l,h);return h}getWorldPosition(r){return this.updateWorldMatrix(!0,!1),r.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(r){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Xi,r,Ur),r}getWorldScale(r){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Xi,zr,r),r}getWorldDirection(r){this.updateWorldMatrix(!0,!1);const l=this.matrixWorld.elements;return r.set(l[8],l[9],l[10]).normalize()}raycast(){}traverse(r){r(this);const l=this.children;for(let h=0,f=l.length;h<f;h++)l[h].traverse(r)}traverseVisible(r){if(this.visible===!1)return;r(this);const l=this.children;for(let h=0,f=l.length;h<f;h++)l[h].traverseVisible(r)}traverseAncestors(r){const l=this.parent;l!==null&&(r(l),l.traverseAncestors(r))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0);const l=this.children;for(let h=0,f=l.length;h<f;h++)l[h].updateMatrixWorld(r)}updateWorldMatrix(r,l){const h=this.parent;if(r===!0&&h!==null&&h.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),l===!0){const f=this.children;for(let g=0,v=f.length;g<v;g++)f[g].updateWorldMatrix(!1,!0)}}toJSON(r){const l=r===void 0||typeof r=="string",h={};l&&(r={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},h.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const f={};f.uuid=this.uuid,f.type=this.type,this.name!==""&&(f.name=this.name),this.castShadow===!0&&(f.castShadow=!0),this.receiveShadow===!0&&(f.receiveShadow=!0),this.visible===!1&&(f.visible=!1),this.frustumCulled===!1&&(f.frustumCulled=!1),this.renderOrder!==0&&(f.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(f.userData=this.userData),f.layers=this.layers.mask,f.matrix=this.matrix.toArray(),f.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(f.matrixAutoUpdate=!1),this.isInstancedMesh&&(f.type="InstancedMesh",f.count=this.count,f.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(f.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(f.type="BatchedMesh",f.perObjectFrustumCulled=this.perObjectFrustumCulled,f.sortObjects=this.sortObjects,f.drawRanges=this._drawRanges,f.reservedRanges=this._reservedRanges,f.geometryInfo=this._geometryInfo.map(A=>cc(Ys({},A),{boundingBox:A.boundingBox?A.boundingBox.toJSON():void 0,boundingSphere:A.boundingSphere?A.boundingSphere.toJSON():void 0})),f.instanceInfo=this._instanceInfo.map(A=>Ys({},A)),f.availableInstanceIds=this._availableInstanceIds.slice(),f.availableGeometryIds=this._availableGeometryIds.slice(),f.nextIndexStart=this._nextIndexStart,f.nextVertexStart=this._nextVertexStart,f.geometryCount=this._geometryCount,f.maxInstanceCount=this._maxInstanceCount,f.maxVertexCount=this._maxVertexCount,f.maxIndexCount=this._maxIndexCount,f.geometryInitialized=this._geometryInitialized,f.matricesTexture=this._matricesTexture.toJSON(r),f.indirectTexture=this._indirectTexture.toJSON(r),this._colorsTexture!==null&&(f.colorsTexture=this._colorsTexture.toJSON(r)),this.boundingSphere!==null&&(f.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(f.boundingBox=this.boundingBox.toJSON()));function g(A,V){return A[V.uuid]===void 0&&(A[V.uuid]=V.toJSON(r)),V.uuid}if(this.isScene)this.background&&(this.background.isColor?f.background=this.background.toJSON():this.background.isTexture&&(f.background=this.background.toJSON(r).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(f.environment=this.environment.toJSON(r).uuid);else if(this.isMesh||this.isLine||this.isPoints){f.geometry=g(r.geometries,this.geometry);const A=this.geometry.parameters;if(A!==void 0&&A.shapes!==void 0){const V=A.shapes;if(Array.isArray(V))for(let H=0,Z=V.length;H<Z;H++){const ce=V[H];g(r.shapes,ce)}else g(r.shapes,V)}}if(this.isSkinnedMesh&&(f.bindMode=this.bindMode,f.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(g(r.skeletons,this.skeleton),f.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const A=[];for(let V=0,H=this.material.length;V<H;V++)A.push(g(r.materials,this.material[V]));f.material=A}else f.material=g(r.materials,this.material);if(this.children.length>0){f.children=[];for(let A=0;A<this.children.length;A++)f.children.push(this.children[A].toJSON(r).object)}if(this.animations.length>0){f.animations=[];for(let A=0;A<this.animations.length;A++){const V=this.animations[A];f.animations.push(g(r.animations,V))}}if(l){const A=v(r.geometries),V=v(r.materials),H=v(r.textures),Z=v(r.images),ce=v(r.shapes),he=v(r.skeletons),de=v(r.animations),Me=v(r.nodes);A.length>0&&(h.geometries=A),V.length>0&&(h.materials=V),H.length>0&&(h.textures=H),Z.length>0&&(h.images=Z),ce.length>0&&(h.shapes=ce),he.length>0&&(h.skeletons=he),de.length>0&&(h.animations=de),Me.length>0&&(h.nodes=Me)}return h.object=f,h;function v(A){const V=[];for(const H in A){const Z=A[H];delete Z.metadata,V.push(Z)}return V}}clone(r){return new this.constructor().copy(this,r)}copy(r,l=!0){if(this.name=r.name,this.up.copy(r.up),this.position.copy(r.position),this.rotation.order=r.rotation.order,this.quaternion.copy(r.quaternion),this.scale.copy(r.scale),this.matrix.copy(r.matrix),this.matrixWorld.copy(r.matrixWorld),this.matrixAutoUpdate=r.matrixAutoUpdate,this.matrixWorldAutoUpdate=r.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=r.matrixWorldNeedsUpdate,this.layers.mask=r.layers.mask,this.visible=r.visible,this.castShadow=r.castShadow,this.receiveShadow=r.receiveShadow,this.frustumCulled=r.frustumCulled,this.renderOrder=r.renderOrder,this.animations=r.animations.slice(),this.userData=JSON.parse(JSON.stringify(r.userData)),l===!0)for(let h=0;h<r.children.length;h++){const f=r.children[h];this.add(f.clone())}return this}}_s.DEFAULT_UP=new Rt(0,1,0),_s.DEFAULT_MATRIX_AUTO_UPDATE=!0,_s.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const pa=new Rt,Zs=new Rt,Bc=new Rt,Ro=new Rt,zl=new Rt,$o=new Rt,Sa=new Rt,ia=new Rt,ul=new Rt,ra=new Rt,rs=new ka,Us=new ka,jn=new ka;class br{constructor(r=new Rt,l=new Rt,h=new Rt){this.a=r,this.b=l,this.c=h}static getNormal(r,l,h,f){f.subVectors(h,l),pa.subVectors(r,l),f.cross(pa);const g=f.lengthSq();return g>0?f.multiplyScalar(1/Math.sqrt(g)):f.set(0,0,0)}static getBarycoord(r,l,h,f,g){pa.subVectors(f,l),Zs.subVectors(h,l),Bc.subVectors(r,l);const v=pa.dot(pa),A=pa.dot(Zs),V=pa.dot(Bc),H=Zs.dot(Zs),Z=Zs.dot(Bc),ce=v*H-A*A;if(ce===0)return g.set(0,0,0),null;const he=1/ce,de=(H*V-A*Z)*he,Me=(v*Z-A*V)*he;return g.set(1-de-Me,Me,de)}static containsPoint(r,l,h,f){return this.getBarycoord(r,l,h,f,Ro)===null?!1:Ro.x>=0&&Ro.y>=0&&Ro.x+Ro.y<=1}static getInterpolation(r,l,h,f,g,v,A,V){return this.getBarycoord(r,l,h,f,Ro)===null?(V.x=0,V.y=0,"z"in V&&(V.z=0),"w"in V&&(V.w=0),null):(V.setScalar(0),V.addScaledVector(g,Ro.x),V.addScaledVector(v,Ro.y),V.addScaledVector(A,Ro.z),V)}static getInterpolatedAttribute(r,l,h,f,g,v){return rs.setScalar(0),Us.setScalar(0),jn.setScalar(0),rs.fromBufferAttribute(r,l),Us.fromBufferAttribute(r,h),jn.fromBufferAttribute(r,f),v.setScalar(0),v.addScaledVector(rs,g.x),v.addScaledVector(Us,g.y),v.addScaledVector(jn,g.z),v}static isFrontFacing(r,l,h,f){return pa.subVectors(h,l),Zs.subVectors(r,l),pa.cross(Zs).dot(f)<0}set(r,l,h){return this.a.copy(r),this.b.copy(l),this.c.copy(h),this}setFromPointsAndIndices(r,l,h,f){return this.a.copy(r[l]),this.b.copy(r[h]),this.c.copy(r[f]),this}setFromAttributeAndIndices(r,l,h,f){return this.a.fromBufferAttribute(r,l),this.b.fromBufferAttribute(r,h),this.c.fromBufferAttribute(r,f),this}clone(){return new this.constructor().copy(this)}copy(r){return this.a.copy(r.a),this.b.copy(r.b),this.c.copy(r.c),this}getArea(){return pa.subVectors(this.c,this.b),Zs.subVectors(this.a,this.b),pa.cross(Zs).length()*.5}getMidpoint(r){return r.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(r){return br.getNormal(this.a,this.b,this.c,r)}getPlane(r){return r.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(r,l){return br.getBarycoord(r,this.a,this.b,this.c,l)}getInterpolation(r,l,h,f,g){return br.getInterpolation(r,this.a,this.b,this.c,l,h,f,g)}containsPoint(r){return br.containsPoint(r,this.a,this.b,this.c)}isFrontFacing(r){return br.isFrontFacing(this.a,this.b,this.c,r)}intersectsBox(r){return r.intersectsTriangle(this)}closestPointToPoint(r,l){const h=this.a,f=this.b,g=this.c;let v,A;zl.subVectors(f,h),$o.subVectors(g,h),ia.subVectors(r,h);const V=zl.dot(ia),H=$o.dot(ia);if(V<=0&&H<=0)return l.copy(h);ul.subVectors(r,f);const Z=zl.dot(ul),ce=$o.dot(ul);if(Z>=0&&ce<=Z)return l.copy(f);const he=V*ce-Z*H;if(he<=0&&V>=0&&Z<=0)return v=V/(V-Z),l.copy(h).addScaledVector(zl,v);ra.subVectors(r,g);const de=zl.dot(ra),Me=$o.dot(ra);if(Me>=0&&de<=Me)return l.copy(g);const Je=de*H-V*Me;if(Je<=0&&H>=0&&Me<=0)return A=H/(H-Me),l.copy(h).addScaledVector($o,A);const mt=Z*Me-de*ce;if(mt<=0&&ce-Z>=0&&de-Me>=0)return Sa.subVectors(g,f),A=(ce-Z)/(ce-Z+(de-Me)),l.copy(f).addScaledVector(Sa,A);const pt=1/(mt+Je+he);return v=Je*pt,A=he*pt,l.copy(h).addScaledVector(zl,v).addScaledVector($o,A)}equals(r){return r.a.equals(this.a)&&r.b.equals(this.b)&&r.c.equals(this.c)}}const Oo={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},Ei={h:0,s:0,l:0},Hr={h:0,s:0,l:0};function xs(j,r,l){return l<0&&(l+=1),l>1&&(l-=1),l<1/6?j+(r-j)*6*l:l<1/2?r:l<2/3?j+(r-j)*6*(2/3-l):j}class ar{constructor(r,l,h){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(r,l,h)}set(r,l,h){if(l===void 0&&h===void 0){const f=r;f&&f.isColor?this.copy(f):typeof f=="number"?this.setHex(f):typeof f=="string"&&this.setStyle(f)}else this.setRGB(r,l,h);return this}setScalar(r){return this.r=r,this.g=r,this.b=r,this}setHex(r,l=uo){return r=Math.floor(r),this.r=(r>>16&255)/255,this.g=(r>>8&255)/255,this.b=(r&255)/255,Mo.colorSpaceToWorking(this,l),this}setRGB(r,l,h,f=Mo.workingColorSpace){return this.r=r,this.g=l,this.b=h,Mo.colorSpaceToWorking(this,f),this}setHSL(r,l,h,f=Mo.workingColorSpace){if(r=lp(r,1),l=Br(l,0,1),h=Br(h,0,1),l===0)this.r=this.g=this.b=h;else{const g=h<=.5?h*(1+l):h+l-h*l,v=2*h-g;this.r=xs(v,g,r+1/3),this.g=xs(v,g,r),this.b=xs(v,g,r-1/3)}return Mo.colorSpaceToWorking(this,f),this}setStyle(r,l=uo){function h(g){g!==void 0&&parseFloat(g)<1&&_r("Color: Alpha component of "+r+" will be ignored.")}let f;if(f=/^(\w+)\(([^\)]*)\)/.exec(r)){let g;const v=f[1],A=f[2];switch(v){case"rgb":case"rgba":if(g=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(A))return h(g[4]),this.setRGB(Math.min(255,parseInt(g[1],10))/255,Math.min(255,parseInt(g[2],10))/255,Math.min(255,parseInt(g[3],10))/255,l);if(g=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(A))return h(g[4]),this.setRGB(Math.min(100,parseInt(g[1],10))/100,Math.min(100,parseInt(g[2],10))/100,Math.min(100,parseInt(g[3],10))/100,l);break;case"hsl":case"hsla":if(g=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(A))return h(g[4]),this.setHSL(parseFloat(g[1])/360,parseFloat(g[2])/100,parseFloat(g[3])/100,l);break;default:_r("Color: Unknown color model "+r)}}else if(f=/^\#([A-Fa-f\d]+)$/.exec(r)){const g=f[1],v=g.length;if(v===3)return this.setRGB(parseInt(g.charAt(0),16)/15,parseInt(g.charAt(1),16)/15,parseInt(g.charAt(2),16)/15,l);if(v===6)return this.setHex(parseInt(g,16),l);_r("Color: Invalid hex color "+r)}else if(r&&r.length>0)return this.setColorName(r,l);return this}setColorName(r,l=uo){const h=Oo[r.toLowerCase()];return h!==void 0?this.setHex(h,l):_r("Color: Unknown color "+r),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(r){return this.r=r.r,this.g=r.g,this.b=r.b,this}copySRGBToLinear(r){return this.r=kl(r.r),this.g=kl(r.g),this.b=kl(r.b),this}copyLinearToSRGB(r){return this.r=Dc(r.r),this.g=Dc(r.g),this.b=Dc(r.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(r=uo){return Mo.workingToColorSpace(vr.copy(this),r),Math.round(Br(vr.r*255,0,255))*65536+Math.round(Br(vr.g*255,0,255))*256+Math.round(Br(vr.b*255,0,255))}getHexString(r=uo){return("000000"+this.getHex(r).toString(16)).slice(-6)}getHSL(r,l=Mo.workingColorSpace){Mo.workingToColorSpace(vr.copy(this),l);const h=vr.r,f=vr.g,g=vr.b,v=Math.max(h,f,g),A=Math.min(h,f,g);let V,H;const Z=(A+v)/2;if(A===v)V=0,H=0;else{const ce=v-A;switch(H=Z<=.5?ce/(v+A):ce/(2-v-A),v){case h:V=(f-g)/ce+(f<g?6:0);break;case f:V=(g-h)/ce+2;break;case g:V=(h-f)/ce+4;break}V/=6}return r.h=V,r.s=H,r.l=Z,r}getRGB(r,l=Mo.workingColorSpace){return Mo.workingToColorSpace(vr.copy(this),l),r.r=vr.r,r.g=vr.g,r.b=vr.b,r}getStyle(r=uo){Mo.workingToColorSpace(vr.copy(this),r);const l=vr.r,h=vr.g,f=vr.b;return r!==uo?`color(${r} ${l.toFixed(3)} ${h.toFixed(3)} ${f.toFixed(3)})`:`rgb(${Math.round(l*255)},${Math.round(h*255)},${Math.round(f*255)})`}offsetHSL(r,l,h){return this.getHSL(Ei),this.setHSL(Ei.h+r,Ei.s+l,Ei.l+h)}add(r){return this.r+=r.r,this.g+=r.g,this.b+=r.b,this}addColors(r,l){return this.r=r.r+l.r,this.g=r.g+l.g,this.b=r.b+l.b,this}addScalar(r){return this.r+=r,this.g+=r,this.b+=r,this}sub(r){return this.r=Math.max(0,this.r-r.r),this.g=Math.max(0,this.g-r.g),this.b=Math.max(0,this.b-r.b),this}multiply(r){return this.r*=r.r,this.g*=r.g,this.b*=r.b,this}multiplyScalar(r){return this.r*=r,this.g*=r,this.b*=r,this}lerp(r,l){return this.r+=(r.r-this.r)*l,this.g+=(r.g-this.g)*l,this.b+=(r.b-this.b)*l,this}lerpColors(r,l,h){return this.r=r.r+(l.r-r.r)*h,this.g=r.g+(l.g-r.g)*h,this.b=r.b+(l.b-r.b)*h,this}lerpHSL(r,l){this.getHSL(Ei),r.getHSL(Hr);const h=Qh(Ei.h,Hr.h,l),f=Qh(Ei.s,Hr.s,l),g=Qh(Ei.l,Hr.l,l);return this.setHSL(h,f,g),this}setFromVector3(r){return this.r=r.x,this.g=r.y,this.b=r.z,this}applyMatrix3(r){const l=this.r,h=this.g,f=this.b,g=r.elements;return this.r=g[0]*l+g[3]*h+g[6]*f,this.g=g[1]*l+g[4]*h+g[7]*f,this.b=g[2]*l+g[5]*h+g[8]*f,this}equals(r){return r.r===this.r&&r.g===this.g&&r.b===this.b}fromArray(r,l=0){return this.r=r[l],this.g=r[l+1],this.b=r[l+2],this}toArray(r=[],l=0){return r[l]=this.r,r[l+1]=this.g,r[l+2]=this.b,r}fromBufferAttribute(r,l){return this.r=r.getX(l),this.g=r.getY(l),this.b=r.getZ(l),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const vr=new ar;ar.NAMES=Oo;let Rs=0;class No extends zu{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Rs++}),this.uuid=El(),this.name="",this.type="Material",this.blending=fe,this.side=W,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Yt,this.blendDst=At,this.blendEquation=Te,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ar(0,0,0),this.blendAlpha=0,this.depthFunc=ge,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Jh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Kl,this.stencilZFail=Kl,this.stencilZPass=Kl,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.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(r){this._alphaTest>0!=r>0&&this.version++,this._alphaTest=r}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(r){if(r!==void 0)for(const l in r){const h=r[l];if(h===void 0){_r(`Material: parameter '${l}' has value of undefined.`);continue}const f=this[l];if(f===void 0){_r(`Material: '${l}' is not a property of THREE.${this.type}.`);continue}f&&f.isColor?f.set(h):f&&f.isVector3&&h&&h.isVector3?f.copy(h):this[l]=h}}toJSON(r){const l=r===void 0||typeof r=="string";l&&(r={textures:{},images:{}});const h={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};h.uuid=this.uuid,h.type=this.type,this.name!==""&&(h.name=this.name),this.color&&this.color.isColor&&(h.color=this.color.getHex()),this.roughness!==void 0&&(h.roughness=this.roughness),this.metalness!==void 0&&(h.metalness=this.metalness),this.sheen!==void 0&&(h.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(h.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(h.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(h.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(h.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(h.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(h.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(h.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(h.shininess=this.shininess),this.clearcoat!==void 0&&(h.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(h.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(h.clearcoatMap=this.clearcoatMap.toJSON(r).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(h.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(r).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(h.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(r).uuid,h.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(h.sheenColorMap=this.sheenColorMap.toJSON(r).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(h.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(r).uuid),this.dispersion!==void 0&&(h.dispersion=this.dispersion),this.iridescence!==void 0&&(h.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(h.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(h.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(h.iridescenceMap=this.iridescenceMap.toJSON(r).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(h.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(r).uuid),this.anisotropy!==void 0&&(h.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(h.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(h.anisotropyMap=this.anisotropyMap.toJSON(r).uuid),this.map&&this.map.isTexture&&(h.map=this.map.toJSON(r).uuid),this.matcap&&this.matcap.isTexture&&(h.matcap=this.matcap.toJSON(r).uuid),this.alphaMap&&this.alphaMap.isTexture&&(h.alphaMap=this.alphaMap.toJSON(r).uuid),this.lightMap&&this.lightMap.isTexture&&(h.lightMap=this.lightMap.toJSON(r).uuid,h.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(h.aoMap=this.aoMap.toJSON(r).uuid,h.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(h.bumpMap=this.bumpMap.toJSON(r).uuid,h.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(h.normalMap=this.normalMap.toJSON(r).uuid,h.normalMapType=this.normalMapType,h.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(h.displacementMap=this.displacementMap.toJSON(r).uuid,h.displacementScale=this.displacementScale,h.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(h.roughnessMap=this.roughnessMap.toJSON(r).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(h.metalnessMap=this.metalnessMap.toJSON(r).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(h.emissiveMap=this.emissiveMap.toJSON(r).uuid),this.specularMap&&this.specularMap.isTexture&&(h.specularMap=this.specularMap.toJSON(r).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(h.specularIntensityMap=this.specularIntensityMap.toJSON(r).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(h.specularColorMap=this.specularColorMap.toJSON(r).uuid),this.envMap&&this.envMap.isTexture&&(h.envMap=this.envMap.toJSON(r).uuid,this.combine!==void 0&&(h.combine=this.combine)),this.envMapRotation!==void 0&&(h.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(h.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(h.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(h.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(h.gradientMap=this.gradientMap.toJSON(r).uuid),this.transmission!==void 0&&(h.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(h.transmissionMap=this.transmissionMap.toJSON(r).uuid),this.thickness!==void 0&&(h.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(h.thicknessMap=this.thicknessMap.toJSON(r).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(h.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(h.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(h.size=this.size),this.shadowSide!==null&&(h.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(h.sizeAttenuation=this.sizeAttenuation),this.blending!==fe&&(h.blending=this.blending),this.side!==W&&(h.side=this.side),this.vertexColors===!0&&(h.vertexColors=!0),this.opacity<1&&(h.opacity=this.opacity),this.transparent===!0&&(h.transparent=!0),this.blendSrc!==Yt&&(h.blendSrc=this.blendSrc),this.blendDst!==At&&(h.blendDst=this.blendDst),this.blendEquation!==Te&&(h.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(h.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(h.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(h.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(h.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(h.blendAlpha=this.blendAlpha),this.depthFunc!==ge&&(h.depthFunc=this.depthFunc),this.depthTest===!1&&(h.depthTest=this.depthTest),this.depthWrite===!1&&(h.depthWrite=this.depthWrite),this.colorWrite===!1&&(h.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(h.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Jh&&(h.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(h.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(h.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Kl&&(h.stencilFail=this.stencilFail),this.stencilZFail!==Kl&&(h.stencilZFail=this.stencilZFail),this.stencilZPass!==Kl&&(h.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(h.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(h.rotation=this.rotation),this.polygonOffset===!0&&(h.polygonOffset=!0),this.polygonOffsetFactor!==0&&(h.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(h.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(h.linewidth=this.linewidth),this.dashSize!==void 0&&(h.dashSize=this.dashSize),this.gapSize!==void 0&&(h.gapSize=this.gapSize),this.scale!==void 0&&(h.scale=this.scale),this.dithering===!0&&(h.dithering=!0),this.alphaTest>0&&(h.alphaTest=this.alphaTest),this.alphaHash===!0&&(h.alphaHash=!0),this.alphaToCoverage===!0&&(h.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(h.premultipliedAlpha=!0),this.forceSinglePass===!0&&(h.forceSinglePass=!0),this.wireframe===!0&&(h.wireframe=!0),this.wireframeLinewidth>1&&(h.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(h.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(h.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(h.flatShading=!0),this.visible===!1&&(h.visible=!1),this.toneMapped===!1&&(h.toneMapped=!1),this.fog===!1&&(h.fog=!1),Object.keys(this.userData).length>0&&(h.userData=this.userData);function f(g){const v=[];for(const A in g){const V=g[A];delete V.metadata,v.push(V)}return v}if(l){const g=f(r.textures),v=f(r.images);g.length>0&&(h.textures=g),v.length>0&&(h.images=v)}return h}clone(){return new this.constructor().copy(this)}copy(r){this.name=r.name,this.blending=r.blending,this.side=r.side,this.vertexColors=r.vertexColors,this.opacity=r.opacity,this.transparent=r.transparent,this.blendSrc=r.blendSrc,this.blendDst=r.blendDst,this.blendEquation=r.blendEquation,this.blendSrcAlpha=r.blendSrcAlpha,this.blendDstAlpha=r.blendDstAlpha,this.blendEquationAlpha=r.blendEquationAlpha,this.blendColor.copy(r.blendColor),this.blendAlpha=r.blendAlpha,this.depthFunc=r.depthFunc,this.depthTest=r.depthTest,this.depthWrite=r.depthWrite,this.stencilWriteMask=r.stencilWriteMask,this.stencilFunc=r.stencilFunc,this.stencilRef=r.stencilRef,this.stencilFuncMask=r.stencilFuncMask,this.stencilFail=r.stencilFail,this.stencilZFail=r.stencilZFail,this.stencilZPass=r.stencilZPass,this.stencilWrite=r.stencilWrite;const l=r.clippingPlanes;let h=null;if(l!==null){const f=l.length;h=new Array(f);for(let g=0;g!==f;++g)h[g]=l[g].clone()}return this.clippingPlanes=h,this.clipIntersection=r.clipIntersection,this.clipShadows=r.clipShadows,this.shadowSide=r.shadowSide,this.colorWrite=r.colorWrite,this.precision=r.precision,this.polygonOffset=r.polygonOffset,this.polygonOffsetFactor=r.polygonOffsetFactor,this.polygonOffsetUnits=r.polygonOffsetUnits,this.dithering=r.dithering,this.alphaTest=r.alphaTest,this.alphaHash=r.alphaHash,this.alphaToCoverage=r.alphaToCoverage,this.premultipliedAlpha=r.premultipliedAlpha,this.forceSinglePass=r.forceSinglePass,this.visible=r.visible,this.toneMapped=r.toneMapped,this.userData=JSON.parse(JSON.stringify(r.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(r){r===!0&&this.version++}}class Ss extends No{constructor(r){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ar(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.envMapRotation=new us,this.combine=Et,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(r)}copy(r){return super.copy(r),this.color.copy(r.color),this.map=r.map,this.lightMap=r.lightMap,this.lightMapIntensity=r.lightMapIntensity,this.aoMap=r.aoMap,this.aoMapIntensity=r.aoMapIntensity,this.specularMap=r.specularMap,this.alphaMap=r.alphaMap,this.envMap=r.envMap,this.envMapRotation.copy(r.envMapRotation),this.combine=r.combine,this.reflectivity=r.reflectivity,this.refractionRatio=r.refractionRatio,this.wireframe=r.wireframe,this.wireframeLinewidth=r.wireframeLinewidth,this.wireframeLinecap=r.wireframeLinecap,this.wireframeLinejoin=r.wireframeLinejoin,this.fog=r.fog,this}}const Hs=null;function yh(){const j=new ArrayBuffer(4),r=new Float32Array(j),l=new Uint32Array(j),h=new Uint32Array(512),f=new Uint32Array(512);for(let V=0;V<256;++V){const H=V-127;H<-27?(h[V]=0,h[V|256]=32768,f[V]=24,f[V|256]=24):H<-14?(h[V]=1024>>-H-14,h[V|256]=1024>>-H-14|32768,f[V]=-H-1,f[V|256]=-H-1):H<=15?(h[V]=H+15<<10,h[V|256]=H+15<<10|32768,f[V]=13,f[V|256]=13):H<128?(h[V]=31744,h[V|256]=64512,f[V]=24,f[V|256]=24):(h[V]=31744,h[V|256]=64512,f[V]=13,f[V|256]=13)}const g=new Uint32Array(2048),v=new Uint32Array(64),A=new Uint32Array(64);for(let V=1;V<1024;++V){let H=V<<13,Z=0;for(;!(H&8388608);)H<<=1,Z-=8388608;H&=-8388609,Z+=947912704,g[V]=H|Z}for(let V=1024;V<2048;++V)g[V]=939524096+(V-1024<<13);for(let V=1;V<31;++V)v[V]=V<<23;v[31]=1199570944,v[32]=2147483648;for(let V=33;V<63;++V)v[V]=2147483648+(V-32<<23);v[63]=3347054592;for(let V=1;V<64;++V)V!==32&&(A[V]=1024);return{floatView:r,uint32View:l,baseTable:h,shiftTable:f,mantissaTable:g,exponentTable:v,offsetTable:A}}function es(j){Math.abs(j)>65504&&_r("DataUtils.toHalfFloat(): Value out of range."),j=Br(j,-65504,65504),Hs.floatView[0]=j;const r=Hs.uint32View[0],l=r>>23&511;return Hs.baseTable[l]+((r&8388607)>>Hs.shiftTable[l])}function Ta(j){const r=j>>10;return Hs.uint32View[0]=Hs.mantissaTable[Hs.offsetTable[r]+(j&1023)]+Hs.exponentTable[r],Hs.floatView[0]}class pc{static toHalfFloat(r){return es(r)}static fromHalfFloat(r){return Ta(r)}}const lo=new Rt,mc=new oi;let Va=0;class vo{constructor(r,l,h=!1){if(Array.isArray(r))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Va++}),this.name="",this.array=r,this.itemSize=l,this.count=r!==void 0?r.length/l:0,this.normalized=h,this.usage=Uu,this.updateRanges=[],this.gpuType=ys,this.version=0}onUploadCallback(){}set needsUpdate(r){r===!0&&this.version++}setUsage(r){return this.usage=r,this}addUpdateRange(r,l){this.updateRanges.push({start:r,count:l})}clearUpdateRanges(){this.updateRanges.length=0}copy(r){return this.name=r.name,this.array=new r.array.constructor(r.array),this.itemSize=r.itemSize,this.count=r.count,this.normalized=r.normalized,this.usage=r.usage,this.gpuType=r.gpuType,this}copyAt(r,l,h){r*=this.itemSize,h*=l.itemSize;for(let f=0,g=this.itemSize;f<g;f++)this.array[r+f]=l.array[h+f];return this}copyArray(r){return this.array.set(r),this}applyMatrix3(r){if(this.itemSize===2)for(let l=0,h=this.count;l<h;l++)mc.fromBufferAttribute(this,l),mc.applyMatrix3(r),this.setXY(l,mc.x,mc.y);else if(this.itemSize===3)for(let l=0,h=this.count;l<h;l++)lo.fromBufferAttribute(this,l),lo.applyMatrix3(r),this.setXYZ(l,lo.x,lo.y,lo.z);return this}applyMatrix4(r){for(let l=0,h=this.count;l<h;l++)lo.fromBufferAttribute(this,l),lo.applyMatrix4(r),this.setXYZ(l,lo.x,lo.y,lo.z);return this}applyNormalMatrix(r){for(let l=0,h=this.count;l<h;l++)lo.fromBufferAttribute(this,l),lo.applyNormalMatrix(r),this.setXYZ(l,lo.x,lo.y,lo.z);return this}transformDirection(r){for(let l=0,h=this.count;l<h;l++)lo.fromBufferAttribute(this,l),lo.transformDirection(r),this.setXYZ(l,lo.x,lo.y,lo.z);return this}set(r,l=0){return this.array.set(r,l),this}getComponent(r,l){let h=this.array[r*this.itemSize+l];return this.normalized&&(h=Ka(h,this.array)),h}setComponent(r,l,h){return this.normalized&&(h=is(h,this.array)),this.array[r*this.itemSize+l]=h,this}getX(r){let l=this.array[r*this.itemSize];return this.normalized&&(l=Ka(l,this.array)),l}setX(r,l){return this.normalized&&(l=is(l,this.array)),this.array[r*this.itemSize]=l,this}getY(r){let l=this.array[r*this.itemSize+1];return this.normalized&&(l=Ka(l,this.array)),l}setY(r,l){return this.normalized&&(l=is(l,this.array)),this.array[r*this.itemSize+1]=l,this}getZ(r){let l=this.array[r*this.itemSize+2];return this.normalized&&(l=Ka(l,this.array)),l}setZ(r,l){return this.normalized&&(l=is(l,this.array)),this.array[r*this.itemSize+2]=l,this}getW(r){let l=this.array[r*this.itemSize+3];return this.normalized&&(l=Ka(l,this.array)),l}setW(r,l){return this.normalized&&(l=is(l,this.array)),this.array[r*this.itemSize+3]=l,this}setXY(r,l,h){return r*=this.itemSize,this.normalized&&(l=is(l,this.array),h=is(h,this.array)),this.array[r+0]=l,this.array[r+1]=h,this}setXYZ(r,l,h,f){return r*=this.itemSize,this.normalized&&(l=is(l,this.array),h=is(h,this.array),f=is(f,this.array)),this.array[r+0]=l,this.array[r+1]=h,this.array[r+2]=f,this}setXYZW(r,l,h,f,g){return r*=this.itemSize,this.normalized&&(l=is(l,this.array),h=is(h,this.array),f=is(f,this.array),g=is(g,this.array)),this.array[r+0]=l,this.array[r+1]=h,this.array[r+2]=f,this.array[r+3]=g,this}onUpload(r){return this.onUploadCallback=r,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const r={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(r.name=this.name),this.usage!==Uu&&(r.usage=this.usage),r}}class gc extends null{constructor(r,l,h){super(new Int8Array(r),l,h)}}class Xm extends null{constructor(r,l,h){super(new Uint8Array(r),l,h)}}class Zi extends null{constructor(r,l,h){super(new Uint8ClampedArray(r),l,h)}}class dx extends null{constructor(r,l,h){super(new Int16Array(r),l,h)}}class Vl extends vo{constructor(r,l,h){super(new Uint16Array(r),l,h)}}class af extends null{constructor(r,l,h){super(new Int32Array(r),l,h)}}class Wu extends vo{constructor(r,l,h){super(new Uint32Array(r),l,h)}}class Gl extends null{constructor(r,l,h){super(new Uint16Array(r),l,h),this.isFloat16BufferAttribute=!0}getX(r){let l=Ta(this.array[r*this.itemSize]);return this.normalized&&(l=Ka(l,this.array)),l}setX(r,l){return this.normalized&&(l=is(l,this.array)),this.array[r*this.itemSize]=es(l),this}getY(r){let l=Ta(this.array[r*this.itemSize+1]);return this.normalized&&(l=Ka(l,this.array)),l}setY(r,l){return this.normalized&&(l=is(l,this.array)),this.array[r*this.itemSize+1]=es(l),this}getZ(r){let l=Ta(this.array[r*this.itemSize+2]);return this.normalized&&(l=Ka(l,this.array)),l}setZ(r,l){return this.normalized&&(l=is(l,this.array)),this.array[r*this.itemSize+2]=es(l),this}getW(r){let l=Ta(this.array[r*this.itemSize+3]);return this.normalized&&(l=Ka(l,this.array)),l}setW(r,l){return this.normalized&&(l=is(l,this.array)),this.array[r*this.itemSize+3]=es(l),this}setXY(r,l,h){return r*=this.itemSize,this.normalized&&(l=is(l,this.array),h=is(h,this.array)),this.array[r+0]=es(l),this.array[r+1]=es(h),this}setXYZ(r,l,h,f){return r*=this.itemSize,this.normalized&&(l=is(l,this.array),h=is(h,this.array),f=is(f,this.array)),this.array[r+0]=es(l),this.array[r+1]=es(h),this.array[r+2]=es(f),this}setXYZW(r,l,h,f,g){return r*=this.itemSize,this.normalized&&(l=is(l,this.array),h=is(h,this.array),f=is(f,this.array),g=is(g,this.array)),this.array[r+0]=es(l),this.array[r+1]=es(h),this.array[r+2]=es(f),this.array[r+3]=es(g),this}}class qi extends vo{constructor(r,l,h){super(new Float32Array(r),l,h)}}let Ea=0;const xr=new On,Wl=new _s,hl=new Rt,ps=new na,Aa=new na,bs=new Rt;class Fr extends zu{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ea++}),this.uuid=El(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=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(r){return Array.isArray(r)?this.index=new(Bl(r)?Wu:Vl)(r,1):this.index=r,this}setIndirect(r){return this.indirect=r,this}getIndirect(){return this.indirect}getAttribute(r){return this.attributes[r]}setAttribute(r,l){return this.attributes[r]=l,this}deleteAttribute(r){return delete this.attributes[r],this}hasAttribute(r){return this.attributes[r]!==void 0}addGroup(r,l,h=0){this.groups.push({start:r,count:l,materialIndex:h})}clearGroups(){this.groups=[]}setDrawRange(r,l){this.drawRange.start=r,this.drawRange.count=l}applyMatrix4(r){const l=this.attributes.position;l!==void 0&&(l.applyMatrix4(r),l.needsUpdate=!0);const h=this.attributes.normal;if(h!==void 0){const g=new da().getNormalMatrix(r);h.applyNormalMatrix(g),h.needsUpdate=!0}const f=this.attributes.tangent;return f!==void 0&&(f.transformDirection(r),f.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(r){return xr.makeRotationFromQuaternion(r),this.applyMatrix4(xr),this}rotateX(r){return xr.makeRotationX(r),this.applyMatrix4(xr),this}rotateY(r){return xr.makeRotationY(r),this.applyMatrix4(xr),this}rotateZ(r){return xr.makeRotationZ(r),this.applyMatrix4(xr),this}translate(r,l,h){return xr.makeTranslation(r,l,h),this.applyMatrix4(xr),this}scale(r,l,h){return xr.makeScale(r,l,h),this.applyMatrix4(xr),this}lookAt(r){return Wl.lookAt(r),Wl.updateMatrix(),this.applyMatrix4(Wl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(hl).negate(),this.translate(hl.x,hl.y,hl.z),this}setFromPoints(r){const l=this.getAttribute("position");if(l===void 0){const h=[];for(let f=0,g=r.length;f<g;f++){const v=r[f];h.push(v.x,v.y,v.z||0)}this.setAttribute("position",new qi(h,3))}else{const h=Math.min(r.length,l.count);for(let f=0;f<h;f++){const g=r[f];l.setXYZ(f,g.x,g.y,g.z||0)}r.length>l.count&&_r("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),l.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new na);const r=this.attributes.position,l=this.morphAttributes.position;if(r&&r.isGLBufferAttribute){Xs("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Rt(-1/0,-1/0,-1/0),new Rt(1/0,1/0,1/0));return}if(r!==void 0){if(this.boundingBox.setFromBufferAttribute(r),l)for(let h=0,f=l.length;h<f;h++){const g=l[h];ps.setFromBufferAttribute(g),this.morphTargetsRelative?(bs.addVectors(this.boundingBox.min,ps.min),this.boundingBox.expandByPoint(bs),bs.addVectors(this.boundingBox.max,ps.max),this.boundingBox.expandByPoint(bs)):(this.boundingBox.expandByPoint(ps.min),this.boundingBox.expandByPoint(ps.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Xs('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 Vt);const r=this.attributes.position,l=this.morphAttributes.position;if(r&&r.isGLBufferAttribute){Xs("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new Rt,1/0);return}if(r){const h=this.boundingSphere.center;if(ps.setFromBufferAttribute(r),l)for(let g=0,v=l.length;g<v;g++){const A=l[g];Aa.setFromBufferAttribute(A),this.morphTargetsRelative?(bs.addVectors(ps.min,Aa.min),ps.expandByPoint(bs),bs.addVectors(ps.max,Aa.max),ps.expandByPoint(bs)):(ps.expandByPoint(Aa.min),ps.expandByPoint(Aa.max))}ps.getCenter(h);let f=0;for(let g=0,v=r.count;g<v;g++)bs.fromBufferAttribute(r,g),f=Math.max(f,h.distanceToSquared(bs));if(l)for(let g=0,v=l.length;g<v;g++){const A=l[g],V=this.morphTargetsRelative;for(let H=0,Z=A.count;H<Z;H++)bs.fromBufferAttribute(A,H),V&&(hl.fromBufferAttribute(r,H),bs.add(hl)),f=Math.max(f,h.distanceToSquared(bs))}this.boundingSphere.radius=Math.sqrt(f),isNaN(this.boundingSphere.radius)&&Xs('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const r=this.index,l=this.attributes;if(r===null||l.position===void 0||l.normal===void 0||l.uv===void 0){Xs("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const h=l.position,f=l.normal,g=l.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new vo(new Float32Array(4*h.count),4));const v=this.getAttribute("tangent"),A=[],V=[];for(let In=0;In<h.count;In++)A[In]=new Rt,V[In]=new Rt;const H=new Rt,Z=new Rt,ce=new Rt,he=new oi,de=new oi,Me=new oi,Je=new Rt,mt=new Rt;function pt(In,ii,li){H.fromBufferAttribute(h,In),Z.fromBufferAttribute(h,ii),ce.fromBufferAttribute(h,li),he.fromBufferAttribute(g,In),de.fromBufferAttribute(g,ii),Me.fromBufferAttribute(g,li),Z.sub(H),ce.sub(H),de.sub(he),Me.sub(he);const dr=1/(de.x*Me.y-Me.x*de.y);isFinite(dr)&&(Je.copy(Z).multiplyScalar(Me.y).addScaledVector(ce,-de.y).multiplyScalar(dr),mt.copy(ce).multiplyScalar(de.x).addScaledVector(Z,-Me.x).multiplyScalar(dr),A[In].add(Je),A[ii].add(Je),A[li].add(Je),V[In].add(mt),V[ii].add(mt),V[li].add(mt))}let Nt=this.groups;Nt.length===0&&(Nt=[{start:0,count:r.count}]);for(let In=0,ii=Nt.length;In<ii;++In){const li=Nt[In],dr=li.start,Zr=li.count;for(let Ts=dr,to=dr+Zr;Ts<to;Ts+=3)pt(r.getX(Ts+0),r.getX(Ts+1),r.getX(Ts+2))}const Pt=new Rt,Gt=new Rt,gn=new Rt,Sn=new Rt;function kn(In){gn.fromBufferAttribute(f,In),Sn.copy(gn);const ii=A[In];Pt.copy(ii),Pt.sub(gn.multiplyScalar(gn.dot(ii))).normalize(),Gt.crossVectors(Sn,ii);const dr=Gt.dot(V[In])<0?-1:1;v.setXYZW(In,Pt.x,Pt.y,Pt.z,dr)}for(let In=0,ii=Nt.length;In<ii;++In){const li=Nt[In],dr=li.start,Zr=li.count;for(let Ts=dr,to=dr+Zr;Ts<to;Ts+=3)kn(r.getX(Ts+0)),kn(r.getX(Ts+1)),kn(r.getX(Ts+2))}}computeVertexNormals(){const r=this.index,l=this.getAttribute("position");if(l!==void 0){let h=this.getAttribute("normal");if(h===void 0)h=new vo(new Float32Array(l.count*3),3),this.setAttribute("normal",h);else for(let he=0,de=h.count;he<de;he++)h.setXYZ(he,0,0,0);const f=new Rt,g=new Rt,v=new Rt,A=new Rt,V=new Rt,H=new Rt,Z=new Rt,ce=new Rt;if(r)for(let he=0,de=r.count;he<de;he+=3){const Me=r.getX(he+0),Je=r.getX(he+1),mt=r.getX(he+2);f.fromBufferAttribute(l,Me),g.fromBufferAttribute(l,Je),v.fromBufferAttribute(l,mt),Z.subVectors(v,g),ce.subVectors(f,g),Z.cross(ce),A.fromBufferAttribute(h,Me),V.fromBufferAttribute(h,Je),H.fromBufferAttribute(h,mt),A.add(Z),V.add(Z),H.add(Z),h.setXYZ(Me,A.x,A.y,A.z),h.setXYZ(Je,V.x,V.y,V.z),h.setXYZ(mt,H.x,H.y,H.z)}else for(let he=0,de=l.count;he<de;he+=3)f.fromBufferAttribute(l,he+0),g.fromBufferAttribute(l,he+1),v.fromBufferAttribute(l,he+2),Z.subVectors(v,g),ce.subVectors(f,g),Z.cross(ce),h.setXYZ(he+0,Z.x,Z.y,Z.z),h.setXYZ(he+1,Z.x,Z.y,Z.z),h.setXYZ(he+2,Z.x,Z.y,Z.z);this.normalizeNormals(),h.needsUpdate=!0}}normalizeNormals(){const r=this.attributes.normal;for(let l=0,h=r.count;l<h;l++)bs.fromBufferAttribute(r,l),bs.normalize(),r.setXYZ(l,bs.x,bs.y,bs.z)}toNonIndexed(){function r(A,V){const H=A.array,Z=A.itemSize,ce=A.normalized,he=new H.constructor(V.length*Z);let de=0,Me=0;for(let Je=0,mt=V.length;Je<mt;Je++){A.isInterleavedBufferAttribute?de=V[Je]*A.data.stride+A.offset:de=V[Je]*Z;for(let pt=0;pt<Z;pt++)he[Me++]=H[de++]}return new vo(he,Z,ce)}if(this.index===null)return _r("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const l=new Fr,h=this.index.array,f=this.attributes;for(const A in f){const V=f[A],H=r(V,h);l.setAttribute(A,H)}const g=this.morphAttributes;for(const A in g){const V=[],H=g[A];for(let Z=0,ce=H.length;Z<ce;Z++){const he=H[Z],de=r(he,h);V.push(de)}l.morphAttributes[A]=V}l.morphTargetsRelative=this.morphTargetsRelative;const v=this.groups;for(let A=0,V=v.length;A<V;A++){const H=v[A];l.addGroup(H.start,H.count,H.materialIndex)}return l}toJSON(){const r={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),Object.keys(this.userData).length>0&&(r.userData=this.userData),this.parameters!==void 0){const V=this.parameters;for(const H in V)V[H]!==void 0&&(r[H]=V[H]);return r}r.data={attributes:{}};const l=this.index;l!==null&&(r.data.index={type:l.array.constructor.name,array:Array.prototype.slice.call(l.array)});const h=this.attributes;for(const V in h){const H=h[V];r.data.attributes[V]=H.toJSON(r.data)}const f={};let g=!1;for(const V in this.morphAttributes){const H=this.morphAttributes[V],Z=[];for(let ce=0,he=H.length;ce<he;ce++){const de=H[ce];Z.push(de.toJSON(r.data))}Z.length>0&&(f[V]=Z,g=!0)}g&&(r.data.morphAttributes=f,r.data.morphTargetsRelative=this.morphTargetsRelative);const v=this.groups;v.length>0&&(r.data.groups=JSON.parse(JSON.stringify(v)));const A=this.boundingSphere;return A!==null&&(r.data.boundingSphere=A.toJSON()),r}clone(){return new this.constructor().copy(this)}copy(r){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const l={};this.name=r.name;const h=r.index;h!==null&&this.setIndex(h.clone());const f=r.attributes;for(const H in f){const Z=f[H];this.setAttribute(H,Z.clone(l))}const g=r.morphAttributes;for(const H in g){const Z=[],ce=g[H];for(let he=0,de=ce.length;he<de;he++)Z.push(ce[he].clone(l));this.morphAttributes[H]=Z}this.morphTargetsRelative=r.morphTargetsRelative;const v=r.groups;for(let H=0,Z=v.length;H<Z;H++){const ce=v[H];this.addGroup(ce.start,ce.count,ce.materialIndex)}const A=r.boundingBox;A!==null&&(this.boundingBox=A.clone());const V=r.boundingSphere;return V!==null&&(this.boundingSphere=V.clone()),this.drawRange.start=r.drawRange.start,this.drawRange.count=r.drawRange.count,this.userData=r.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const ec=new On,yc=new ai,hu=new Vt,td=new Rt,du=new Rt,Ks=new Rt,nd=new Rt,lf=new Rt,Uc=new Rt,id=new Rt,el=new Rt;class vh extends _s{constructor(r=new Fr,l=new Ss){super(),this.isMesh=!0,this.type="Mesh",this.geometry=r,this.material=l,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(r,l){return super.copy(r,l),r.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=r.morphTargetInfluences.slice()),r.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},r.morphTargetDictionary)),this.material=Array.isArray(r.material)?r.material.slice():r.material,this.geometry=r.geometry,this}updateMorphTargets(){const l=this.geometry.morphAttributes,h=Object.keys(l);if(h.length>0){const f=l[h[0]];if(f!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let g=0,v=f.length;g<v;g++){const A=f[g].name||String(g);this.morphTargetInfluences.push(0),this.morphTargetDictionary[A]=g}}}}getVertexPosition(r,l){const h=this.geometry,f=h.attributes.position,g=h.morphAttributes.position,v=h.morphTargetsRelative;l.fromBufferAttribute(f,r);const A=this.morphTargetInfluences;if(g&&A){Uc.set(0,0,0);for(let V=0,H=g.length;V<H;V++){const Z=A[V],ce=g[V];Z!==0&&(lf.fromBufferAttribute(ce,r),v?Uc.addScaledVector(lf,Z):Uc.addScaledVector(lf.sub(l),Z))}l.add(Uc)}return l}raycast(r,l){const h=this.geometry,f=this.material,g=this.matrixWorld;f!==void 0&&(h.boundingSphere===null&&h.computeBoundingSphere(),hu.copy(h.boundingSphere),hu.applyMatrix4(g),yc.copy(r.ray).recast(r.near),!(hu.containsPoint(yc.origin)===!1&&(yc.intersectSphere(hu,td)===null||yc.origin.distanceToSquared(td)>ip(r.far-r.near,2)))&&(ec.copy(g).invert(),yc.copy(r.ray).applyMatrix4(ec),!(h.boundingBox!==null&&yc.intersectsBox(h.boundingBox)===!1)&&this._computeIntersections(r,l,yc)))}_computeIntersections(r,l,h){let f;const g=this.geometry,v=this.material,A=g.index,V=g.attributes.position,H=g.attributes.uv,Z=g.attributes.uv1,ce=g.attributes.normal,he=g.groups,de=g.drawRange;if(A!==null)if(Array.isArray(v))for(let Me=0,Je=he.length;Me<Je;Me++){const mt=he[Me],pt=v[mt.materialIndex],Nt=Math.max(mt.start,de.start),Pt=Math.min(A.count,Math.min(mt.start+mt.count,de.start+de.count));for(let Gt=Nt,gn=Pt;Gt<gn;Gt+=3){const Sn=A.getX(Gt),kn=A.getX(Gt+1),In=A.getX(Gt+2);f=fp(this,pt,r,h,H,Z,ce,Sn,kn,In),f&&(f.faceIndex=Math.floor(Gt/3),f.face.materialIndex=mt.materialIndex,l.push(f))}}else{const Me=Math.max(0,de.start),Je=Math.min(A.count,de.start+de.count);for(let mt=Me,pt=Je;mt<pt;mt+=3){const Nt=A.getX(mt),Pt=A.getX(mt+1),Gt=A.getX(mt+2);f=fp(this,v,r,h,H,Z,ce,Nt,Pt,Gt),f&&(f.faceIndex=Math.floor(mt/3),l.push(f))}}else if(V!==void 0)if(Array.isArray(v))for(let Me=0,Je=he.length;Me<Je;Me++){const mt=he[Me],pt=v[mt.materialIndex],Nt=Math.max(mt.start,de.start),Pt=Math.min(V.count,Math.min(mt.start+mt.count,de.start+de.count));for(let Gt=Nt,gn=Pt;Gt<gn;Gt+=3){const Sn=Gt,kn=Gt+1,In=Gt+2;f=fp(this,pt,r,h,H,Z,ce,Sn,kn,In),f&&(f.faceIndex=Math.floor(Gt/3),f.face.materialIndex=mt.materialIndex,l.push(f))}}else{const Me=Math.max(0,de.start),Je=Math.min(V.count,de.start+de.count);for(let mt=Me,pt=Je;mt<pt;mt+=3){const Nt=mt,Pt=mt+1,Gt=mt+2;f=fp(this,v,r,h,H,Z,ce,Nt,Pt,Gt),f&&(f.faceIndex=Math.floor(mt/3),l.push(f))}}}}function fx(j,r,l,h,f,g,v,A){let V;if(r.side===Y?V=h.intersectTriangle(v,g,f,!0,A):V=h.intersectTriangle(f,g,v,r.side===W,A),V===null)return null;el.copy(A),el.applyMatrix4(j.matrixWorld);const H=l.ray.origin.distanceTo(el);return H<l.near||H>l.far?null:{distance:H,point:el.clone(),object:j}}function fp(j,r,l,h,f,g,v,A,V,H){j.getVertexPosition(A,du),j.getVertexPosition(V,Ks),j.getVertexPosition(H,nd);const Z=fx(j,r,l,h,du,Ks,nd,id);if(Z){const ce=new Rt;br.getBarycoord(id,du,Ks,nd,ce),f&&(Z.uv=br.getInterpolatedAttribute(f,A,V,H,ce,new oi)),g&&(Z.uv1=br.getInterpolatedAttribute(g,A,V,H,ce,new oi)),v&&(Z.normal=br.getInterpolatedAttribute(v,A,V,H,ce,new Rt),Z.normal.dot(h.direction)>0&&Z.normal.multiplyScalar(-1));const he={a:A,b:V,c:H,normal:new Rt,materialIndex:0};br.getNormal(du,Ks,nd,he.normal),Z.face=he,Z.barycoord=ce}return Z}class qm extends Fr{constructor(r=1,l=1,h=1,f=1,g=1,v=1){super(),this.type="BoxGeometry",this.parameters={width:r,height:l,depth:h,widthSegments:f,heightSegments:g,depthSegments:v};const A=this;f=Math.floor(f),g=Math.floor(g),v=Math.floor(v);const V=[],H=[],Z=[],ce=[];let he=0,de=0;Me("z","y","x",-1,-1,h,l,r,v,g,0),Me("z","y","x",1,-1,h,l,-r,v,g,1),Me("x","z","y",1,1,r,h,l,f,v,2),Me("x","z","y",1,-1,r,h,-l,f,v,3),Me("x","y","z",1,-1,r,l,h,f,g,4),Me("x","y","z",-1,-1,r,l,-h,f,g,5),this.setIndex(V),this.setAttribute("position",new qi(H,3)),this.setAttribute("normal",new qi(Z,3)),this.setAttribute("uv",new qi(ce,2));function Me(Je,mt,pt,Nt,Pt,Gt,gn,Sn,kn,In,ii){const li=Gt/kn,dr=gn/In,Zr=Gt/2,Ts=gn/2,to=Sn/2,ho=kn+1,Ra=In+1;let fl=0,ic=0;const qo=new Rt;for(let Na=0;Na<Ra;Na++){const Yo=Na*dr-Ts;for(let jc=0;jc<ho;jc++){const Sc=jc*li-Zr;qo[Je]=Sc*Nt,qo[mt]=Yo*Pt,qo[pt]=to,H.push(qo.x,qo.y,qo.z),qo[Je]=0,qo[mt]=0,qo[pt]=Sn>0?1:-1,Z.push(qo.x,qo.y,qo.z),ce.push(jc/kn),ce.push(1-Na/In),fl+=1}}for(let Na=0;Na<In;Na++)for(let Yo=0;Yo<kn;Yo++){const jc=he+Yo+ho*Na,Sc=he+Yo+ho*(Na+1),Ph=he+(Yo+1)+ho*(Na+1),nm=he+(Yo+1)+ho*Na;V.push(jc,Sc,nm),V.push(Sc,Ph,nm),ic+=6}A.addGroup(de,ic,ii),de+=ic,he+=fl}}copy(r){return super.copy(r),this.parameters=Object.assign({},r.parameters),this}static fromJSON(r){return new qm(r.width,r.height,r.depth,r.widthSegments,r.heightSegments,r.depthSegments)}}function Ym(j){const r={};for(const l in j){r[l]={};for(const h in j[l]){const f=j[l][h];f&&(f.isColor||f.isMatrix3||f.isMatrix4||f.isVector2||f.isVector3||f.isVector4||f.isTexture||f.isQuaternion)?f.isRenderTargetTexture?(_r("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),r[l][h]=null):r[l][h]=f.clone():Array.isArray(f)?r[l][h]=f.slice():r[l][h]=f}}return r}function kc(j){const r={};for(let l=0;l<j.length;l++){const h=Ym(j[l]);for(const f in h)r[f]=h[f]}return r}function Zm(j){const r=[];for(let l=0;l<j.length;l++)r.push(j[l].clone());return r}function rd(j){const r=j.getRenderTarget();return r===null?j.outputColorSpace:r.isXRRenderTarget===!0?r.texture.colorSpace:Mo.workingColorSpace}const y1={clone:Ym,merge:kc};var px=`void main() {
|
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
|
}`,ma=`void main() {
|
|
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
|
}`;class sd extends null{constructor(r){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=px,this.fragmentShader=ma,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,r!==void 0&&this.setValues(r)}copy(r){return super.copy(r),this.fragmentShader=r.fragmentShader,this.vertexShader=r.vertexShader,this.uniforms=Ym(r.uniforms),this.uniformsGroups=Zm(r.uniformsGroups),this.defines=Object.assign({},r.defines),this.wireframe=r.wireframe,this.wireframeLinewidth=r.wireframeLinewidth,this.fog=r.fog,this.lights=r.lights,this.clipping=r.clipping,this.extensions=Object.assign({},r.extensions),this.glslVersion=r.glslVersion,this}toJSON(r){const l=super.toJSON(r);l.glslVersion=this.glslVersion,l.uniforms={};for(const f in this.uniforms){const v=this.uniforms[f].value;v&&v.isTexture?l.uniforms[f]={type:"t",value:v.toJSON(r).uuid}:v&&v.isColor?l.uniforms[f]={type:"c",value:v.getHex()}:v&&v.isVector2?l.uniforms[f]={type:"v2",value:v.toArray()}:v&&v.isVector3?l.uniforms[f]={type:"v3",value:v.toArray()}:v&&v.isVector4?l.uniforms[f]={type:"v4",value:v.toArray()}:v&&v.isMatrix3?l.uniforms[f]={type:"m3",value:v.toArray()}:v&&v.isMatrix4?l.uniforms[f]={type:"m4",value:v.toArray()}:l.uniforms[f]={value:v}}Object.keys(this.defines).length>0&&(l.defines=this.defines),l.vertexShader=this.vertexShader,l.fragmentShader=this.fragmentShader,l.lights=this.lights,l.clipping=this.clipping;const h={};for(const f in this.extensions)this.extensions[f]===!0&&(h[f]=!0);return Object.keys(h).length>0&&(l.extensions=h),l}}class cf extends _s{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new On,this.projectionMatrix=new On,this.projectionMatrixInverse=new On,this.coordinateSystem=oo,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(r,l){return super.copy(r,l),this.matrixWorldInverse.copy(r.matrixWorldInverse),this.projectionMatrix.copy(r.projectionMatrix),this.projectionMatrixInverse.copy(r.projectionMatrixInverse),this.coordinateSystem=r.coordinateSystem,this}getWorldDirection(r){return super.getWorldDirection(r).negate()}updateMatrixWorld(r){super.updateMatrixWorld(r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(r,l){super.updateWorldMatrix(r,l),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Hu=new Rt,xh=new oi,O0=new oi;class dl extends null{constructor(r=50,l=1,h=.1,f=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=r,this.zoom=1,this.near=h,this.far=f,this.focus=10,this.aspect=l,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(r,l){return super.copy(r,l),this.fov=r.fov,this.zoom=r.zoom,this.near=r.near,this.far=r.far,this.focus=r.focus,this.aspect=r.aspect,this.view=r.view===null?null:Object.assign({},r.view),this.filmGauge=r.filmGauge,this.filmOffset=r.filmOffset,this}setFocalLength(r){const l=.5*this.getFilmHeight()/r;this.fov=Vu*2*Math.atan(l),this.updateProjectionMatrix()}getFocalLength(){const r=Math.tan(au*.5*this.fov);return .5*this.getFilmHeight()/r}getEffectiveFOV(){return Vu*2*Math.atan(Math.tan(au*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(r,l,h){Hu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),l.set(Hu.x,Hu.y).multiplyScalar(-r/Hu.z),Hu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),h.set(Hu.x,Hu.y).multiplyScalar(-r/Hu.z)}getViewSize(r,l){return this.getViewBounds(r,xh,O0),l.subVectors(O0,xh)}setViewOffset(r,l,h,f,g,v){this.aspect=r/l,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=r,this.view.fullHeight=l,this.view.offsetX=h,this.view.offsetY=f,this.view.width=g,this.view.height=v,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const r=this.near;let l=r*Math.tan(au*.5*this.fov)/this.zoom,h=2*l,f=this.aspect*h,g=-.5*f;const v=this.view;if(this.view!==null&&this.view.enabled){const V=v.fullWidth,H=v.fullHeight;g+=v.offsetX*f/V,l-=v.offsetY*h/H,f*=v.width/V,h*=v.height/H}const A=this.filmOffset;A!==0&&(g+=r*A/this.getFilmWidth()),this.projectionMatrix.makePerspective(g,g+f,l,l-h,r,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(r){const l=super.toJSON(r);return l.object.fov=this.fov,l.object.zoom=this.zoom,l.object.near=this.near,l.object.far=this.far,l.object.focus=this.focus,l.object.aspect=this.aspect,this.view!==null&&(l.object.view=Object.assign({},this.view)),l.object.filmGauge=this.filmGauge,l.object.filmOffset=this.filmOffset,l}}const uf=null,$u=1;class F0 extends null{constructor(r,l,h){super(),this.type="CubeCamera",this.renderTarget=h,this.coordinateSystem=null,this.activeMipmapLevel=0;const f=new dl(uf,$u,r,l);f.layers=this.layers,this.add(f);const g=new dl(uf,$u,r,l);g.layers=this.layers,this.add(g);const v=new dl(uf,$u,r,l);v.layers=this.layers,this.add(v);const A=new dl(uf,$u,r,l);A.layers=this.layers,this.add(A);const V=new dl(uf,$u,r,l);V.layers=this.layers,this.add(V);const H=new dl(uf,$u,r,l);H.layers=this.layers,this.add(H)}updateCoordinateSystem(){const r=this.coordinateSystem,l=this.children.concat(),[h,f,g,v,A,V]=l;for(const H of l)this.remove(H);if(r===oo)h.up.set(0,1,0),h.lookAt(1,0,0),f.up.set(0,1,0),f.lookAt(-1,0,0),g.up.set(0,0,-1),g.lookAt(0,1,0),v.up.set(0,0,1),v.lookAt(0,-1,0),A.up.set(0,1,0),A.lookAt(0,0,1),V.up.set(0,1,0),V.lookAt(0,0,-1);else if(r===qa)h.up.set(0,-1,0),h.lookAt(-1,0,0),f.up.set(0,-1,0),f.lookAt(1,0,0),g.up.set(0,0,1),g.lookAt(0,1,0),v.up.set(0,0,-1),v.lookAt(0,-1,0),A.up.set(0,-1,0),A.lookAt(0,0,1),V.up.set(0,-1,0),V.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+r);for(const H of l)this.add(H),H.updateMatrixWorld()}update(r,l){this.parent===null&&this.updateMatrixWorld();const{renderTarget:h,activeMipmapLevel:f}=this;this.coordinateSystem!==r.coordinateSystem&&(this.coordinateSystem=r.coordinateSystem,this.updateCoordinateSystem());const[g,v,A,V,H,Z]=this.children,ce=r.getRenderTarget(),he=r.getActiveCubeFace(),de=r.getActiveMipmapLevel(),Me=r.xr.enabled;r.xr.enabled=!1;const Je=h.texture.generateMipmaps;h.texture.generateMipmaps=!1,r.setRenderTarget(h,0,f),r.render(l,g),r.setRenderTarget(h,1,f),r.render(l,v),r.setRenderTarget(h,2,f),r.render(l,A),r.setRenderTarget(h,3,f),r.render(l,V),r.setRenderTarget(h,4,f),r.render(l,H),h.texture.generateMipmaps=Je,r.setRenderTarget(h,5,f),r.render(l,Z),r.setRenderTarget(ce,he,de),r.xr.enabled=Me,h.texture.needsPMREMUpdate=!0}}class pp extends null{constructor(r=[],l=De,h,f,g,v,A,V,H,Z){super(r,l,h,f,g,v,A,V,H,Z),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(r){this.image=r}}class Km extends null{constructor(r=1,l={}){super(r,r,l),this.isWebGLCubeRenderTarget=!0;const h={width:r,height:r,depth:1},f=[h,h,h,h,h,h];this.texture=new pp(f),this._setTextureOptions(l),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(r,l){this.texture.type=l.type,this.texture.colorSpace=l.colorSpace,this.texture.generateMipmaps=l.generateMipmaps,this.texture.minFilter=l.minFilter,this.texture.magFilter=l.magFilter;const h={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 );
|
|
|
|
|
|
}
|
|
|
`},f=new qm(5,5,5),g=new sd({name:"CubemapFromEquirect",uniforms:Ym(h.uniforms),vertexShader:h.vertexShader,fragmentShader:h.fragmentShader,side:Y,blending:pe});g.uniforms.tEquirect.value=l;const v=new vh(f,g),A=l.minFilter;return l.minFilter===Qn&&(l.minFilter=Rn),new F0(1,10,this).update(r,v),l.minFilter=A,v.geometry.dispose(),v.material.dispose(),this}clear(r,l=!0,h=!0,f=!0){const g=r.getRenderTarget();for(let v=0;v<6;v++)r.setRenderTarget(this,v),r.clear(l,h,f);r.setRenderTarget(g)}}class ju extends _s{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Cl={type:"move"};class hf{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ju,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 ju,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Rt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Rt),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ju,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Rt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Rt),this._grip}dispatchEvent(r){return this._targetRay!==null&&this._targetRay.dispatchEvent(r),this._grip!==null&&this._grip.dispatchEvent(r),this._hand!==null&&this._hand.dispatchEvent(r),this}connect(r){if(r&&r.hand){const l=this._hand;if(l)for(const h of r.hand.values())this._getHandJoint(l,h)}return this.dispatchEvent({type:"connected",data:r}),this}disconnect(r){return this.dispatchEvent({type:"disconnected",data:r}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(r,l,h){let f=null,g=null,v=null;const A=this._targetRay,V=this._grip,H=this._hand;if(r&&l.session.visibilityState!=="visible-blurred"){if(H&&r.hand){v=!0;for(const Je of r.hand.values()){const mt=l.getJointPose(Je,h),pt=this._getHandJoint(H,Je);mt!==null&&(pt.matrix.fromArray(mt.transform.matrix),pt.matrix.decompose(pt.position,pt.rotation,pt.scale),pt.matrixWorldNeedsUpdate=!0,pt.jointRadius=mt.radius),pt.visible=mt!==null}const Z=H.joints["index-finger-tip"],ce=H.joints["thumb-tip"],he=Z.position.distanceTo(ce.position),de=.02,Me=.005;H.inputState.pinching&&he>de+Me?(H.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:r.handedness,target:this})):!H.inputState.pinching&&he<=de-Me&&(H.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:r.handedness,target:this}))}else V!==null&&r.gripSpace&&(g=l.getPose(r.gripSpace,h),g!==null&&(V.matrix.fromArray(g.transform.matrix),V.matrix.decompose(V.position,V.rotation,V.scale),V.matrixWorldNeedsUpdate=!0,g.linearVelocity?(V.hasLinearVelocity=!0,V.linearVelocity.copy(g.linearVelocity)):V.hasLinearVelocity=!1,g.angularVelocity?(V.hasAngularVelocity=!0,V.angularVelocity.copy(g.angularVelocity)):V.hasAngularVelocity=!1));A!==null&&(f=l.getPose(r.targetRaySpace,h),f===null&&g!==null&&(f=g),f!==null&&(A.matrix.fromArray(f.transform.matrix),A.matrix.decompose(A.position,A.rotation,A.scale),A.matrixWorldNeedsUpdate=!0,f.linearVelocity?(A.hasLinearVelocity=!0,A.linearVelocity.copy(f.linearVelocity)):A.hasLinearVelocity=!1,f.angularVelocity?(A.hasAngularVelocity=!0,A.angularVelocity.copy(f.angularVelocity)):A.hasAngularVelocity=!1,this.dispatchEvent(Cl)))}return A!==null&&(A.visible=f!==null),V!==null&&(V.visible=g!==null),H!==null&&(H.visible=v!==null),this}_getHandJoint(r,l){if(r.joints[l.jointName]===void 0){const h=new ju;h.matrixAutoUpdate=!1,h.visible=!1,r.joints[l.jointName]=h,r.add(h)}return r.joints[l.jointName]}}class mp{constructor(r,l=25e-5){this.isFogExp2=!0,this.name="",this.color=new ar(r),this.density=l}clone(){return new mp(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class _h{constructor(r,l=1,h=1e3){this.isFog=!0,this.name="",this.color=new ar(r),this.near=l,this.far=h}clone(){return new _h(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class gp extends null{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new us,this.environmentIntensity=1,this.environmentRotation=new us,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(r,l){return super.copy(r,l),r.background!==null&&(this.background=r.background.clone()),r.environment!==null&&(this.environment=r.environment.clone()),r.fog!==null&&(this.fog=r.fog.clone()),this.backgroundBlurriness=r.backgroundBlurriness,this.backgroundIntensity=r.backgroundIntensity,this.backgroundRotation.copy(r.backgroundRotation),this.environmentIntensity=r.environmentIntensity,this.environmentRotation.copy(r.environmentRotation),r.overrideMaterial!==null&&(this.overrideMaterial=r.overrideMaterial.clone()),this.matrixAutoUpdate=r.matrixAutoUpdate,this}toJSON(r){const l=super.toJSON(r);return this.fog!==null&&(l.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(l.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(l.object.backgroundIntensity=this.backgroundIntensity),l.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(l.object.environmentIntensity=this.environmentIntensity),l.object.environmentRotation=this.environmentRotation.toArray(),l}}class od{constructor(r,l){this.isInterleavedBuffer=!0,this.array=r,this.stride=l,this.count=r!==void 0?r.length/l:0,this.usage=Uu,this.updateRanges=[],this.version=0,this.uuid=El()}onUploadCallback(){}set needsUpdate(r){r===!0&&this.version++}setUsage(r){return this.usage=r,this}addUpdateRange(r,l){this.updateRanges.push({start:r,count:l})}clearUpdateRanges(){this.updateRanges.length=0}copy(r){return this.array=new r.array.constructor(r.array),this.count=r.count,this.stride=r.stride,this.usage=r.usage,this}copyAt(r,l,h){r*=this.stride,h*=l.stride;for(let f=0,g=this.stride;f<g;f++)this.array[r+f]=l.array[h+f];return this}set(r,l=0){return this.array.set(r,l),this}clone(r){r.arrayBuffers===void 0&&(r.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=El()),r.arrayBuffers[this.array.buffer._uuid]===void 0&&(r.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const l=new this.array.constructor(r.arrayBuffers[this.array.buffer._uuid]),h=new this.constructor(l,this.stride);return h.setUsage(this.usage),h}onUpload(r){return this.onUploadCallback=r,this}toJSON(r){return r.arrayBuffers===void 0&&(r.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=El()),r.arrayBuffers[this.array.buffer._uuid]===void 0&&(r.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 Ca=new Rt;class zc{constructor(r,l,h,f=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=r,this.itemSize=l,this.offset=h,this.normalized=f}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(r){this.data.needsUpdate=r}applyMatrix4(r){for(let l=0,h=this.data.count;l<h;l++)Ca.fromBufferAttribute(this,l),Ca.applyMatrix4(r),this.setXYZ(l,Ca.x,Ca.y,Ca.z);return this}applyNormalMatrix(r){for(let l=0,h=this.count;l<h;l++)Ca.fromBufferAttribute(this,l),Ca.applyNormalMatrix(r),this.setXYZ(l,Ca.x,Ca.y,Ca.z);return this}transformDirection(r){for(let l=0,h=this.count;l<h;l++)Ca.fromBufferAttribute(this,l),Ca.transformDirection(r),this.setXYZ(l,Ca.x,Ca.y,Ca.z);return this}getComponent(r,l){let h=this.array[r*this.data.stride+this.offset+l];return this.normalized&&(h=Ka(h,this.array)),h}setComponent(r,l,h){return this.normalized&&(h=is(h,this.array)),this.data.array[r*this.data.stride+this.offset+l]=h,this}setX(r,l){return this.normalized&&(l=is(l,this.array)),this.data.array[r*this.data.stride+this.offset]=l,this}setY(r,l){return this.normalized&&(l=is(l,this.array)),this.data.array[r*this.data.stride+this.offset+1]=l,this}setZ(r,l){return this.normalized&&(l=is(l,this.array)),this.data.array[r*this.data.stride+this.offset+2]=l,this}setW(r,l){return this.normalized&&(l=is(l,this.array)),this.data.array[r*this.data.stride+this.offset+3]=l,this}getX(r){let l=this.data.array[r*this.data.stride+this.offset];return this.normalized&&(l=Ka(l,this.array)),l}getY(r){let l=this.data.array[r*this.data.stride+this.offset+1];return this.normalized&&(l=Ka(l,this.array)),l}getZ(r){let l=this.data.array[r*this.data.stride+this.offset+2];return this.normalized&&(l=Ka(l,this.array)),l}getW(r){let l=this.data.array[r*this.data.stride+this.offset+3];return this.normalized&&(l=Ka(l,this.array)),l}setXY(r,l,h){return r=r*this.data.stride+this.offset,this.normalized&&(l=is(l,this.array),h=is(h,this.array)),this.data.array[r+0]=l,this.data.array[r+1]=h,this}setXYZ(r,l,h,f){return r=r*this.data.stride+this.offset,this.normalized&&(l=is(l,this.array),h=is(h,this.array),f=is(f,this.array)),this.data.array[r+0]=l,this.data.array[r+1]=h,this.data.array[r+2]=f,this}setXYZW(r,l,h,f,g){return r=r*this.data.stride+this.offset,this.normalized&&(l=is(l,this.array),h=is(h,this.array),f=is(f,this.array),g=is(g,this.array)),this.data.array[r+0]=l,this.data.array[r+1]=h,this.data.array[r+2]=f,this.data.array[r+3]=g,this}clone(r){if(r===void 0){Wm("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const l=[];for(let h=0;h<this.count;h++){const f=h*this.data.stride+this.offset;for(let g=0;g<this.itemSize;g++)l.push(this.data.array[f+g])}return new vo(new this.array.constructor(l),this.itemSize,this.normalized)}else return r.interleavedBuffers===void 0&&(r.interleavedBuffers={}),r.interleavedBuffers[this.data.uuid]===void 0&&(r.interleavedBuffers[this.data.uuid]=this.data.clone(r)),new zc(r.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(r){if(r===void 0){Wm("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const l=[];for(let h=0;h<this.count;h++){const f=h*this.data.stride+this.offset;for(let g=0;g<this.itemSize;g++)l.push(this.data.array[f+g])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:l,normalized:this.normalized}}else return r.interleavedBuffers===void 0&&(r.interleavedBuffers={}),r.interleavedBuffers[this.data.uuid]===void 0&&(r.interleavedBuffers[this.data.uuid]=this.data.toJSON(r)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class ad extends No{constructor(r){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ar(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(r)}copy(r){return super.copy(r),this.color.copy(r.color),this.map=r.map,this.alphaMap=r.alphaMap,this.rotation=r.rotation,this.sizeAttenuation=r.sizeAttenuation,this.fog=r.fog,this}}let ld;const bh=new Rt,fu=new Rt,Xu=new Rt,cd=new oi,ud=new oi,B0=new On,Jm=new Rt,wh=new Rt,hd=new Rt,U0=new oi,k0=new oi,z0=new oi;class V0 extends _s{constructor(r=new ad){if(super(),this.isSprite=!0,this.type="Sprite",ld===void 0){ld=new Fr;const l=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),h=new od(l,5);ld.setIndex([0,1,2,0,2,3]),ld.setAttribute("position",new zc(h,3,0,!1)),ld.setAttribute("uv",new zc(h,2,3,!1))}this.geometry=ld,this.material=r,this.center=new oi(.5,.5),this.count=1}raycast(r,l){r.camera===null&&Xs('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),fu.setFromMatrixScale(this.matrixWorld),B0.copy(r.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(r.camera.matrixWorldInverse,this.matrixWorld),Xu.setFromMatrixPosition(this.modelViewMatrix),r.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&fu.multiplyScalar(-Xu.z);const h=this.material.rotation;let f,g;h!==0&&(g=Math.cos(h),f=Math.sin(h));const v=this.center;yp(Jm.set(-.5,-.5,0),Xu,v,fu,f,g),yp(wh.set(.5,-.5,0),Xu,v,fu,f,g),yp(hd.set(.5,.5,0),Xu,v,fu,f,g),U0.set(0,0),k0.set(1,0),z0.set(1,1);let A=r.ray.intersectTriangle(Jm,wh,hd,!1,bh);if(A===null&&(yp(wh.set(-.5,.5,0),Xu,v,fu,f,g),k0.set(0,1),A=r.ray.intersectTriangle(Jm,hd,wh,!1,bh),A===null))return;const V=r.ray.origin.distanceTo(bh);V<r.near||V>r.far||l.push({distance:V,point:bh.clone(),uv:br.getInterpolation(bh,Jm,wh,hd,U0,k0,z0,new oi),face:null,object:this})}copy(r,l){return super.copy(r,l),r.center!==void 0&&this.center.copy(r.center),this.material=r.material,this}}function yp(j,r,l,h,f,g){cd.subVectors(j,l).addScalar(.5).multiply(h),f!==void 0?(ud.x=g*cd.x-f*cd.y,ud.y=f*cd.x+g*cd.y):ud.copy(cd),j.copy(r),j.x+=ud.x,j.y+=ud.y,j.applyMatrix4(B0)}const Qm=new Rt,G0=new Rt;class eg extends null{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(r){super.copy(r,!1);const l=r.levels;for(let h=0,f=l.length;h<f;h++){const g=l[h];this.addLevel(g.object.clone(),g.distance,g.hysteresis)}return this.autoUpdate=r.autoUpdate,this}addLevel(r,l=0,h=0){l=Math.abs(l);const f=this.levels;let g;for(g=0;g<f.length&&!(l<f[g].distance);g++);return f.splice(g,0,{distance:l,hysteresis:h,object:r}),this.add(r),this}removeLevel(r){const l=this.levels;for(let h=0;h<l.length;h++)if(l[h].distance===r){const f=l.splice(h,1);return this.remove(f[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(r){const l=this.levels;if(l.length>0){let h,f;for(h=1,f=l.length;h<f;h++){let g=l[h].distance;if(l[h].object.visible&&(g-=g*l[h].hysteresis),r<g)break}return l[h-1].object}return null}raycast(r,l){if(this.levels.length>0){Qm.setFromMatrixPosition(this.matrixWorld);const f=r.ray.origin.distanceTo(Qm);this.getObjectForDistance(f).raycast(r,l)}}update(r){const l=this.levels;if(l.length>1){Qm.setFromMatrixPosition(r.matrixWorld),G0.setFromMatrixPosition(this.matrixWorld);const h=Qm.distanceTo(G0)/r.zoom;l[0].object.visible=!0;let f,g;for(f=1,g=l.length;f<g;f++){let v=l[f].distance;if(l[f].object.visible&&(v-=v*l[f].hysteresis),h>=v)l[f-1].object.visible=!1,l[f].object.visible=!0;else break}for(this._currentLevel=f-1;f<g;f++)l[f].object.visible=!1}}toJSON(r){const l=super.toJSON(r);this.autoUpdate===!1&&(l.object.autoUpdate=!1),l.object.levels=[];const h=this.levels;for(let f=0,g=h.length;f<g;f++){const v=h[f];l.object.levels.push({object:v.object.uuid,distance:v.distance,hysteresis:v.hysteresis})}return l}}const tg=new Rt,W0=new ka,ng=new ka,v1=new Rt,H0=new On,tc=new Rt,ig=new Vt,mx=new On,vp=new ai;class Vc extends null{constructor(r,l){super(r,l),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=nn,this.bindMatrix=new On,this.bindMatrixInverse=new On,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const r=this.geometry;this.boundingBox===null&&(this.boundingBox=new na),this.boundingBox.makeEmpty();const l=r.getAttribute("position");for(let h=0;h<l.count;h++)this.getVertexPosition(h,tc),this.boundingBox.expandByPoint(tc)}computeBoundingSphere(){const r=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Vt),this.boundingSphere.makeEmpty();const l=r.getAttribute("position");for(let h=0;h<l.count;h++)this.getVertexPosition(h,tc),this.boundingSphere.expandByPoint(tc)}copy(r,l){return super.copy(r,l),this.bindMode=r.bindMode,this.bindMatrix.copy(r.bindMatrix),this.bindMatrixInverse.copy(r.bindMatrixInverse),this.skeleton=r.skeleton,r.boundingBox!==null&&(this.boundingBox=r.boundingBox.clone()),r.boundingSphere!==null&&(this.boundingSphere=r.boundingSphere.clone()),this}raycast(r,l){const h=this.material,f=this.matrixWorld;h!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ig.copy(this.boundingSphere),ig.applyMatrix4(f),r.ray.intersectsSphere(ig)!==!1&&(mx.copy(f).invert(),vp.copy(r.ray).applyMatrix4(mx),!(this.boundingBox!==null&&vp.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(r,l,vp)))}getVertexPosition(r,l){return super.getVertexPosition(r,l),this.applyBoneTransform(r,l),l}bind(r,l){this.skeleton=r,l===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),l=this.matrixWorld),this.bindMatrix.copy(l),this.bindMatrixInverse.copy(l).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const r=new ka,l=this.geometry.attributes.skinWeight;for(let h=0,f=l.count;h<f;h++){r.fromBufferAttribute(l,h);const g=1/r.manhattanLength();g!==1/0?r.multiplyScalar(g):r.set(1,0,0,0),l.setXYZW(h,r.x,r.y,r.z,r.w)}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.bindMode===nn?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===we?this.bindMatrixInverse.copy(this.bindMatrix).invert():_r("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(r,l){const h=this.skeleton,f=this.geometry;W0.fromBufferAttribute(f.attributes.skinIndex,r),ng.fromBufferAttribute(f.attributes.skinWeight,r),tg.copy(l).applyMatrix4(this.bindMatrix),l.set(0,0,0);for(let g=0;g<4;g++){const v=ng.getComponent(g);if(v!==0){const A=W0.getComponent(g);H0.multiplyMatrices(h.bones[A].matrixWorld,h.boneInverses[A]),l.addScaledVector(v1.copy(tg).applyMatrix4(H0),v)}}return l.applyMatrix4(this.bindMatrixInverse)}}class dd extends null{constructor(){super(),this.isBone=!0,this.type="Bone"}}class pu extends null{constructor(r=null,l=1,h=1,f,g,v,A,V,H=Ct,Z=Ct,ce,he){super(null,v,A,V,H,Z,f,g,ce,he),this.isDataTexture=!0,this.image={data:r,width:l,height:h},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const xp=new On,gx=new On;class $0{constructor(r=[],l=[]){this.uuid=El(),this.bones=r.slice(0),this.boneInverses=l,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const r=this.bones,l=this.boneInverses;if(this.boneMatrices=new Float32Array(r.length*16),l.length===0)this.calculateInverses();else if(r.length!==l.length){_r("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let h=0,f=this.bones.length;h<f;h++)this.boneInverses.push(new On)}}calculateInverses(){this.boneInverses.length=0;for(let r=0,l=this.bones.length;r<l;r++){const h=new On;this.bones[r]&&h.copy(this.bones[r].matrixWorld).invert(),this.boneInverses.push(h)}}pose(){for(let r=0,l=this.bones.length;r<l;r++){const h=this.bones[r];h&&h.matrixWorld.copy(this.boneInverses[r]).invert()}for(let r=0,l=this.bones.length;r<l;r++){const h=this.bones[r];h&&(h.parent&&h.parent.isBone?(h.matrix.copy(h.parent.matrixWorld).invert(),h.matrix.multiply(h.matrixWorld)):h.matrix.copy(h.matrixWorld),h.matrix.decompose(h.position,h.quaternion,h.scale))}}update(){const r=this.bones,l=this.boneInverses,h=this.boneMatrices,f=this.boneTexture;for(let g=0,v=r.length;g<v;g++){const A=r[g]?r[g].matrixWorld:gx;xp.multiplyMatrices(A,l[g]),xp.toArray(h,g*16)}f!==null&&(f.needsUpdate=!0)}clone(){return new $0(this.bones,this.boneInverses)}computeBoneTexture(){let r=Math.sqrt(this.bones.length*4);r=Math.ceil(r/4)*4,r=Math.max(r,4);const l=new Float32Array(r*r*4);l.set(this.boneMatrices);const h=new pu(l,r,r,D,ys);return h.needsUpdate=!0,this.boneMatrices=l,this.boneTexture=h,this}getBoneByName(r){for(let l=0,h=this.bones.length;l<h;l++){const f=this.bones[l];if(f.name===r)return f}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(r,l){this.uuid=r.uuid;for(let h=0,f=r.bones.length;h<f;h++){const g=r.bones[h];let v=l[g];v===void 0&&(_r("Skeleton: No bone found with UUID:",g),v=new dd),this.bones.push(v),this.boneInverses.push(new On().fromArray(r.boneInverses[h]))}return this.init(),this}toJSON(){const r={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};r.uuid=this.uuid;const l=this.bones,h=this.boneInverses;for(let f=0,g=l.length;f<g;f++){const v=l[f];r.bones.push(v.uuid);const A=h[f];r.boneInverses.push(A.toArray())}return r}}class qu extends null{constructor(r,l,h,f=1){super(r,l,h),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=f}copy(r){return super.copy(r),this.meshPerAttribute=r.meshPerAttribute,this}toJSON(){const r=super.toJSON();return r.meshPerAttribute=this.meshPerAttribute,r.isInstancedBufferAttribute=!0,r}}const mu=new On,yx=new On,df=null,vx=new na,x1=new On,Rl=new vh,Gc=new Vt;class _1 extends null{constructor(r,l,h){super(r,l),this.isInstancedMesh=!0,this.instanceMatrix=new qu(new Float32Array(h*16),16),this.instanceColor=null,this.morphTexture=null,this.count=h,this.boundingBox=null,this.boundingSphere=null;for(let f=0;f<h;f++)this.setMatrixAt(f,x1)}computeBoundingBox(){const r=this.geometry,l=this.count;this.boundingBox===null&&(this.boundingBox=new na),r.boundingBox===null&&r.computeBoundingBox(),this.boundingBox.makeEmpty();for(let h=0;h<l;h++)this.getMatrixAt(h,mu),vx.copy(r.boundingBox).applyMatrix4(mu),this.boundingBox.union(vx)}computeBoundingSphere(){const r=this.geometry,l=this.count;this.boundingSphere===null&&(this.boundingSphere=new Vt),r.boundingSphere===null&&r.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let h=0;h<l;h++)this.getMatrixAt(h,mu),Gc.copy(r.boundingSphere).applyMatrix4(mu),this.boundingSphere.union(Gc)}copy(r,l){return super.copy(r,l),this.instanceMatrix.copy(r.instanceMatrix),r.morphTexture!==null&&(this.morphTexture=r.morphTexture.clone()),r.instanceColor!==null&&(this.instanceColor=r.instanceColor.clone()),this.count=r.count,r.boundingBox!==null&&(this.boundingBox=r.boundingBox.clone()),r.boundingSphere!==null&&(this.boundingSphere=r.boundingSphere.clone()),this}getColorAt(r,l){l.fromArray(this.instanceColor.array,r*3)}getMatrixAt(r,l){l.fromArray(this.instanceMatrix.array,r*16)}getMorphAt(r,l){const h=l.morphTargetInfluences,f=this.morphTexture.source.data.data,g=h.length+1,v=r*g+1;for(let A=0;A<h.length;A++)h[A]=f[v+A]}raycast(r,l){const h=this.matrixWorld,f=this.count;if(Rl.geometry=this.geometry,Rl.material=this.material,Rl.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Gc.copy(this.boundingSphere),Gc.applyMatrix4(h),r.ray.intersectsSphere(Gc)!==!1))for(let g=0;g<f;g++){this.getMatrixAt(g,mu),yx.multiplyMatrices(h,mu),Rl.matrixWorld=yx,Rl.raycast(r,df);for(let v=0,A=df.length;v<A;v++){const V=df[v];V.instanceId=g,V.object=this,l.push(V)}df.length=0}}setColorAt(r,l){this.instanceColor===null&&(this.instanceColor=new qu(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),l.toArray(this.instanceColor.array,r*3)}setMatrixAt(r,l){l.toArray(this.instanceMatrix.array,r*16)}setMorphAt(r,l){const h=l.morphTargetInfluences,f=h.length+1;this.morphTexture===null&&(this.morphTexture=new pu(new Float32Array(f*this.count),f,this.count,F,ys));const g=this.morphTexture.source.data.data;let v=0;for(let H=0;H<h.length;H++)v+=h[H];const A=this.geometry.morphTargetsRelative?1:1-v,V=f*r;g[V]=A,g.set(h,V+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const ff=new Rt,pf=new Rt,gu=new da;class Nl{constructor(r=new Rt(1,0,0),l=0){this.isPlane=!0,this.normal=r,this.constant=l}set(r,l){return this.normal.copy(r),this.constant=l,this}setComponents(r,l,h,f){return this.normal.set(r,l,h),this.constant=f,this}setFromNormalAndCoplanarPoint(r,l){return this.normal.copy(r),this.constant=-l.dot(this.normal),this}setFromCoplanarPoints(r,l,h){const f=ff.subVectors(h,l).cross(pf.subVectors(r,l)).normalize();return this.setFromNormalAndCoplanarPoint(f,r),this}copy(r){return this.normal.copy(r.normal),this.constant=r.constant,this}normalize(){const r=1/this.normal.length();return this.normal.multiplyScalar(r),this.constant*=r,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(r){return this.normal.dot(r)+this.constant}distanceToSphere(r){return this.distanceToPoint(r.center)-r.radius}projectPoint(r,l){return l.copy(r).addScaledVector(this.normal,-this.distanceToPoint(r))}intersectLine(r,l){const h=r.delta(ff),f=this.normal.dot(h);if(f===0)return this.distanceToPoint(r.start)===0?l.copy(r.start):null;const g=-(r.start.dot(this.normal)+this.constant)/f;return g<0||g>1?null:l.copy(r.start).addScaledVector(h,g)}intersectsLine(r){const l=this.distanceToPoint(r.start),h=this.distanceToPoint(r.end);return l<0&&h>0||h<0&&l>0}intersectsBox(r){return r.intersectsPlane(this)}intersectsSphere(r){return r.intersectsPlane(this)}coplanarPoint(r){return r.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(r,l){const h=l||gu.getNormalMatrix(r),f=this.coplanarPoint(ff).applyMatrix4(r),g=this.normal.applyMatrix3(h).normalize();return this.constant=-f.dot(g),this}translate(r){return this.constant-=r.dot(this.normal),this}equals(r){return r.normal.equals(this.normal)&&r.constant===this.constant}clone(){return new this.constructor().copy(this)}}const yu=new Vt,j0=new oi(.5,.5),rg=new Rt;class X0{constructor(r=new Nl,l=new Nl,h=new Nl,f=new Nl,g=new Nl,v=new Nl){this.planes=[r,l,h,f,g,v]}set(r,l,h,f,g,v){const A=this.planes;return A[0].copy(r),A[1].copy(l),A[2].copy(h),A[3].copy(f),A[4].copy(g),A[5].copy(v),this}copy(r){const l=this.planes;for(let h=0;h<6;h++)l[h].copy(r.planes[h]);return this}setFromProjectionMatrix(r,l=oo,h=!1){const f=this.planes,g=r.elements,v=g[0],A=g[1],V=g[2],H=g[3],Z=g[4],ce=g[5],he=g[6],de=g[7],Me=g[8],Je=g[9],mt=g[10],pt=g[11],Nt=g[12],Pt=g[13],Gt=g[14],gn=g[15];if(f[0].setComponents(H-v,de-Z,pt-Me,gn-Nt).normalize(),f[1].setComponents(H+v,de+Z,pt+Me,gn+Nt).normalize(),f[2].setComponents(H+A,de+ce,pt+Je,gn+Pt).normalize(),f[3].setComponents(H-A,de-ce,pt-Je,gn-Pt).normalize(),h)f[4].setComponents(V,he,mt,Gt).normalize(),f[5].setComponents(H-V,de-he,pt-mt,gn-Gt).normalize();else if(f[4].setComponents(H-V,de-he,pt-mt,gn-Gt).normalize(),l===oo)f[5].setComponents(H+V,de+he,pt+mt,gn+Gt).normalize();else if(l===qa)f[5].setComponents(V,he,mt,Gt).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+l);return this}intersectsObject(r){if(r.boundingSphere!==void 0)r.boundingSphere===null&&r.computeBoundingSphere(),yu.copy(r.boundingSphere).applyMatrix4(r.matrixWorld);else{const l=r.geometry;l.boundingSphere===null&&l.computeBoundingSphere(),yu.copy(l.boundingSphere).applyMatrix4(r.matrixWorld)}return this.intersectsSphere(yu)}intersectsSprite(r){yu.center.set(0,0,0);const l=j0.distanceTo(r.center);return yu.radius=.7071067811865476+l,yu.applyMatrix4(r.matrixWorld),this.intersectsSphere(yu)}intersectsSphere(r){const l=this.planes,h=r.center,f=-r.radius;for(let g=0;g<6;g++)if(l[g].distanceToPoint(h)<f)return!1;return!0}intersectsBox(r){const l=this.planes;for(let h=0;h<6;h++){const f=l[h];if(rg.x=f.normal.x>0?r.max.x:r.min.x,rg.y=f.normal.y>0?r.max.y:r.min.y,rg.z=f.normal.z>0?r.max.z:r.min.z,f.distanceToPoint(rg)<0)return!1}return!0}containsPoint(r){const l=this.planes;for(let h=0;h<6;h++)if(l[h].distanceToPoint(r)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const vu=new On,jo=new X0;class q0{constructor(){this.coordinateSystem=oo}intersectsObject(r,l){if(!l.isArrayCamera||l.cameras.length===0)return!1;for(let h=0;h<l.cameras.length;h++){const f=l.cameras[h];if(vu.multiplyMatrices(f.projectionMatrix,f.matrixWorldInverse),jo.setFromProjectionMatrix(vu,f.coordinateSystem,f.reversedDepth),jo.intersectsObject(r))return!0}return!1}intersectsSprite(r,l){if(!l||!l.cameras||l.cameras.length===0)return!1;for(let h=0;h<l.cameras.length;h++){const f=l.cameras[h];if(vu.multiplyMatrices(f.projectionMatrix,f.matrixWorldInverse),jo.setFromProjectionMatrix(vu,f.coordinateSystem,f.reversedDepth),jo.intersectsSprite(r))return!0}return!1}intersectsSphere(r,l){if(!l||!l.cameras||l.cameras.length===0)return!1;for(let h=0;h<l.cameras.length;h++){const f=l.cameras[h];if(vu.multiplyMatrices(f.projectionMatrix,f.matrixWorldInverse),jo.setFromProjectionMatrix(vu,f.coordinateSystem,f.reversedDepth),jo.intersectsSphere(r))return!0}return!1}intersectsBox(r,l){if(!l||!l.cameras||l.cameras.length===0)return!1;for(let h=0;h<l.cameras.length;h++){const f=l.cameras[h];if(vu.multiplyMatrices(f.projectionMatrix,f.matrixWorldInverse),jo.setFromProjectionMatrix(vu,f.coordinateSystem,f.reversedDepth),jo.intersectsBox(r))return!0}return!1}containsPoint(r,l){if(!l||!l.cameras||l.cameras.length===0)return!1;for(let h=0;h<l.cameras.length;h++){const f=l.cameras[h];if(vu.multiplyMatrices(f.projectionMatrix,f.matrixWorldInverse),jo.setFromProjectionMatrix(vu,f.coordinateSystem,f.reversedDepth),jo.containsPoint(r))return!0}return!1}clone(){return new q0}}function sg(j,r){return j-r}function b1(j,r){return j.z-r.z}function og(j,r){return r.z-j.z}class fd{constructor(){this.index=0,this.pool=[],this.list=[]}push(r,l,h,f){const g=this.pool,v=this.list;this.index>=g.length&&g.push({start:-1,count:-1,z:-1,index:-1});const A=g[this.index];v.push(A),this.index++,A.start=r,A.count=l,A.z=h,A.index=f}reset(){this.list.length=0,this.index=0}}const tl=new On,xx=new ar(1,1,1),_x=new X0,Y0=new q0,Ga=new na,xu=new Vt,_p=new Rt,Mh=new Rt,w1=new Rt,nl=new fd,Wa=new vh,pd=null;function bx(j,r,l=0){const h=r.itemSize;if(j.isInterleavedBufferAttribute||j.array.constructor!==r.array.constructor){const f=j.count;for(let g=0;g<f;g++)for(let v=0;v<h;v++)r.setComponent(g+l,v,j.getComponent(g,v))}else r.array.set(j.array,l*h);r.needsUpdate=!0}function Wc(j,r){if(j.constructor!==r.constructor){const l=Math.min(j.length,r.length);for(let h=0;h<l;h++)r[h]=j[h]}else{const l=Math.min(j.length,r.length);r.set(new j.constructor(j.buffer,0,l))}}class ag extends null{constructor(r,l,h=l*2,f){super(new Fr,f),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=r,this._maxVertexCount=l,this._maxIndexCount=h,this._multiDrawCounts=new Int32Array(r),this._multiDrawStarts=new Int32Array(r),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let r=Math.sqrt(this._maxInstanceCount*4);r=Math.ceil(r/4)*4,r=Math.max(r,4);const l=new Float32Array(r*r*4),h=new pu(l,r,r,D,ys);this._matricesTexture=h}_initIndirectTexture(){let r=Math.sqrt(this._maxInstanceCount);r=Math.ceil(r);const l=new Uint32Array(r*r),h=new pu(l,r,r,X,ls);this._indirectTexture=h}_initColorsTexture(){let r=Math.sqrt(this._maxInstanceCount);r=Math.ceil(r);const l=new Float32Array(r*r*4).fill(1),h=new pu(l,r,r,D,ys);h.colorSpace=Mo.workingColorSpace,this._colorsTexture=h}_initializeGeometry(r){const l=this.geometry,h=this._maxVertexCount,f=this._maxIndexCount;if(this._geometryInitialized===!1){for(const g in r.attributes){const v=r.getAttribute(g),{array:A,itemSize:V,normalized:H}=v,Z=new A.constructor(h*V),ce=new vo(Z,V,H);l.setAttribute(g,ce)}if(r.getIndex()!==null){const g=h>65535?new Uint32Array(f):new Uint16Array(f);l.setIndex(new vo(g,1))}this._geometryInitialized=!0}}_validateGeometry(r){const l=this.geometry;if(!!r.getIndex()!=!!l.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const h in l.attributes){if(!r.hasAttribute(h))throw new Error(`THREE.BatchedMesh: Added geometry missing "${h}". All geometries must have consistent attributes.`);const f=r.getAttribute(h),g=l.getAttribute(h);if(f.itemSize!==g.itemSize||f.normalized!==g.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(r){const l=this._instanceInfo;if(r<0||r>=l.length||l[r].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${r}. Instance is either out of range or has been deleted.`)}validateGeometryId(r){const l=this._geometryInfo;if(r<0||r>=l.length||l[r].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${r}. Geometry is either out of range or has been deleted.`)}setCustomSort(r){return this.customSort=r,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new na);const r=this.boundingBox,l=this._instanceInfo;r.makeEmpty();for(let h=0,f=l.length;h<f;h++){if(l[h].active===!1)continue;const g=l[h].geometryIndex;this.getMatrixAt(h,tl),this.getBoundingBoxAt(g,Ga).applyMatrix4(tl),r.union(Ga)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Vt);const r=this.boundingSphere,l=this._instanceInfo;r.makeEmpty();for(let h=0,f=l.length;h<f;h++){if(l[h].active===!1)continue;const g=l[h].geometryIndex;this.getMatrixAt(h,tl),this.getBoundingSphereAt(g,xu).applyMatrix4(tl),r.union(xu)}}addInstance(r){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const h={visible:!0,active:!0,geometryIndex:r};let f=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(sg),f=this._availableInstanceIds.shift(),this._instanceInfo[f]=h):(f=this._instanceInfo.length,this._instanceInfo.push(h));const g=this._matricesTexture;tl.identity().toArray(g.image.data,f*16),g.needsUpdate=!0;const v=this._colorsTexture;return v&&(xx.toArray(v.image.data,f*4),v.needsUpdate=!0),this._visibilityChanged=!0,f}addGeometry(r,l=-1,h=-1){this._initializeGeometry(r),this._validateGeometry(r);const f={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},g=this._geometryInfo;f.vertexStart=this._nextVertexStart,f.reservedVertexCount=l===-1?r.getAttribute("position").count:l;const v=r.getIndex();if(v!==null&&(f.indexStart=this._nextIndexStart,f.reservedIndexCount=h===-1?v.count:h),f.indexStart!==-1&&f.indexStart+f.reservedIndexCount>this._maxIndexCount||f.vertexStart+f.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let V;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(sg),V=this._availableGeometryIds.shift(),g[V]=f):(V=this._geometryCount,this._geometryCount++,g.push(f)),this.setGeometryAt(V,r),this._nextIndexStart=f.indexStart+f.reservedIndexCount,this._nextVertexStart=f.vertexStart+f.reservedVertexCount,V}setGeometryAt(r,l){if(r>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(l);const h=this.geometry,f=h.getIndex()!==null,g=h.getIndex(),v=l.getIndex(),A=this._geometryInfo[r];if(f&&v.count>A.reservedIndexCount||l.attributes.position.count>A.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const V=A.vertexStart,H=A.reservedVertexCount;A.vertexCount=l.getAttribute("position").count;for(const Z in h.attributes){const ce=l.getAttribute(Z),he=h.getAttribute(Z);bx(ce,he,V);const de=ce.itemSize;for(let Me=ce.count,Je=H;Me<Je;Me++){const mt=V+Me;for(let pt=0;pt<de;pt++)he.setComponent(mt,pt,0)}he.needsUpdate=!0,he.addUpdateRange(V*de,H*de)}if(f){const Z=A.indexStart,ce=A.reservedIndexCount;A.indexCount=l.getIndex().count;for(let he=0;he<v.count;he++)g.setX(Z+he,V+v.getX(he));for(let he=v.count,de=ce;he<de;he++)g.setX(Z+he,V);g.needsUpdate=!0,g.addUpdateRange(Z,A.reservedIndexCount)}return A.start=f?A.indexStart:A.vertexStart,A.count=f?A.indexCount:A.vertexCount,A.boundingBox=null,l.boundingBox!==null&&(A.boundingBox=l.boundingBox.clone()),A.boundingSphere=null,l.boundingSphere!==null&&(A.boundingSphere=l.boundingSphere.clone()),this._visibilityChanged=!0,r}deleteGeometry(r){const l=this._geometryInfo;if(r>=l.length||l[r].active===!1)return this;const h=this._instanceInfo;for(let f=0,g=h.length;f<g;f++)h[f].active&&h[f].geometryIndex===r&&this.deleteInstance(f);return l[r].active=!1,this._availableGeometryIds.push(r),this._visibilityChanged=!0,this}deleteInstance(r){return this.validateInstanceId(r),this._instanceInfo[r].active=!1,this._availableInstanceIds.push(r),this._visibilityChanged=!0,this}optimize(){let r=0,l=0;const h=this._geometryInfo,f=h.map((v,A)=>A).sort((v,A)=>h[v].vertexStart-h[A].vertexStart),g=this.geometry;for(let v=0,A=h.length;v<A;v++){const V=f[v],H=h[V];if(H.active!==!1){if(g.index!==null){if(H.indexStart!==l){const{indexStart:Z,vertexStart:ce,reservedIndexCount:he}=H,de=g.index,Me=de.array,Je=r-ce;for(let mt=Z;mt<Z+he;mt++)Me[mt]=Me[mt]+Je;de.array.copyWithin(l,Z,Z+he),de.addUpdateRange(l,he),H.indexStart=l}l+=H.reservedIndexCount}if(H.vertexStart!==r){const{vertexStart:Z,reservedVertexCount:ce}=H,he=g.attributes;for(const de in he){const Me=he[de],{array:Je,itemSize:mt}=Me;Je.copyWithin(r*mt,Z*mt,(Z+ce)*mt),Me.addUpdateRange(r*mt,ce*mt)}H.vertexStart=r}r+=H.reservedVertexCount,H.start=g.index?H.indexStart:H.vertexStart,this._nextIndexStart=g.index?H.indexStart+H.reservedIndexCount:0,this._nextVertexStart=H.vertexStart+H.reservedVertexCount}}return this}getBoundingBoxAt(r,l){if(r>=this._geometryCount)return null;const h=this.geometry,f=this._geometryInfo[r];if(f.boundingBox===null){const g=new na,v=h.index,A=h.attributes.position;for(let V=f.start,H=f.start+f.count;V<H;V++){let Z=V;v&&(Z=v.getX(Z)),g.expandByPoint(_p.fromBufferAttribute(A,Z))}f.boundingBox=g}return l.copy(f.boundingBox),l}getBoundingSphereAt(r,l){if(r>=this._geometryCount)return null;const h=this.geometry,f=this._geometryInfo[r];if(f.boundingSphere===null){const g=new Vt;this.getBoundingBoxAt(r,Ga),Ga.getCenter(g.center);const v=h.index,A=h.attributes.position;let V=0;for(let H=f.start,Z=f.start+f.count;H<Z;H++){let ce=H;v&&(ce=v.getX(ce)),_p.fromBufferAttribute(A,ce),V=Math.max(V,g.center.distanceToSquared(_p))}g.radius=Math.sqrt(V),f.boundingSphere=g}return l.copy(f.boundingSphere),l}setMatrixAt(r,l){this.validateInstanceId(r);const h=this._matricesTexture,f=this._matricesTexture.image.data;return l.toArray(f,r*16),h.needsUpdate=!0,this}getMatrixAt(r,l){return this.validateInstanceId(r),l.fromArray(this._matricesTexture.image.data,r*16)}setColorAt(r,l){return this.validateInstanceId(r),this._colorsTexture===null&&this._initColorsTexture(),l.toArray(this._colorsTexture.image.data,r*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(r,l){return this.validateInstanceId(r),l.fromArray(this._colorsTexture.image.data,r*4)}setVisibleAt(r,l){return this.validateInstanceId(r),this._instanceInfo[r].visible===l?this:(this._instanceInfo[r].visible=l,this._visibilityChanged=!0,this)}getVisibleAt(r){return this.validateInstanceId(r),this._instanceInfo[r].visible}setGeometryIdAt(r,l){return this.validateInstanceId(r),this.validateGeometryId(l),this._instanceInfo[r].geometryIndex=l,this}getGeometryIdAt(r){return this.validateInstanceId(r),this._instanceInfo[r].geometryIndex}getGeometryRangeAt(r,l={}){this.validateGeometryId(r);const h=this._geometryInfo[r];return l.vertexStart=h.vertexStart,l.vertexCount=h.vertexCount,l.reservedVertexCount=h.reservedVertexCount,l.indexStart=h.indexStart,l.indexCount=h.indexCount,l.reservedIndexCount=h.reservedIndexCount,l.start=h.start,l.count=h.count,l}setInstanceCount(r){const l=this._availableInstanceIds,h=this._instanceInfo;for(l.sort(sg);l[l.length-1]===h.length-1;)h.pop(),l.pop();if(r<h.length)throw new Error(`BatchedMesh: Instance ids outside the range ${r} are being used. Cannot shrink instance count.`);const f=new Int32Array(r),g=new Int32Array(r);Wc(this._multiDrawCounts,f),Wc(this._multiDrawStarts,g),this._multiDrawCounts=f,this._multiDrawStarts=g,this._maxInstanceCount=r;const v=this._indirectTexture,A=this._matricesTexture,V=this._colorsTexture;v.dispose(),this._initIndirectTexture(),Wc(v.image.data,this._indirectTexture.image.data),A.dispose(),this._initMatricesTexture(),Wc(A.image.data,this._matricesTexture.image.data),V&&(V.dispose(),this._initColorsTexture(),Wc(V.image.data,this._colorsTexture.image.data))}setGeometrySize(r,l){const h=[...this._geometryInfo].filter(A=>A.active);if(Math.max(...h.map(A=>A.vertexStart+A.reservedVertexCount))>r)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${l}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...h.map(V=>V.indexStart+V.reservedIndexCount))>l)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${l}. Cannot shrink further.`);const g=this.geometry;g.dispose(),this._maxVertexCount=r,this._maxIndexCount=l,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Fr,this._initializeGeometry(g));const v=this.geometry;g.index&&Wc(g.index.array,v.index.array);for(const A in g.attributes)Wc(g.attributes[A].array,v.attributes[A].array)}raycast(r,l){const h=this._instanceInfo,f=this._geometryInfo,g=this.matrixWorld,v=this.geometry;Wa.material=this.material,Wa.geometry.index=v.index,Wa.geometry.attributes=v.attributes,Wa.geometry.boundingBox===null&&(Wa.geometry.boundingBox=new na),Wa.geometry.boundingSphere===null&&(Wa.geometry.boundingSphere=new Vt);for(let A=0,V=h.length;A<V;A++){if(!h[A].visible||!h[A].active)continue;const H=h[A].geometryIndex,Z=f[H];Wa.geometry.setDrawRange(Z.start,Z.count),this.getMatrixAt(A,Wa.matrixWorld).premultiply(g),this.getBoundingBoxAt(H,Wa.geometry.boundingBox),this.getBoundingSphereAt(H,Wa.geometry.boundingSphere),Wa.raycast(r,pd);for(let ce=0,he=pd.length;ce<he;ce++){const de=pd[ce];de.object=this,de.batchId=A,l.push(de)}pd.length=0}Wa.material=null,Wa.geometry.index=null,Wa.geometry.attributes={},Wa.geometry.setDrawRange(0,1/0)}copy(r){return super.copy(r),this.geometry=r.geometry.clone(),this.perObjectFrustumCulled=r.perObjectFrustumCulled,this.sortObjects=r.sortObjects,this.boundingBox=r.boundingBox!==null?r.boundingBox.clone():null,this.boundingSphere=r.boundingSphere!==null?r.boundingSphere.clone():null,this._geometryInfo=r._geometryInfo.map(l=>cc(Ys({},l),{boundingBox:l.boundingBox!==null?l.boundingBox.clone():null,boundingSphere:l.boundingSphere!==null?l.boundingSphere.clone():null})),this._instanceInfo=r._instanceInfo.map(l=>Ys({},l)),this._availableInstanceIds=r._availableInstanceIds.slice(),this._availableGeometryIds=r._availableGeometryIds.slice(),this._nextIndexStart=r._nextIndexStart,this._nextVertexStart=r._nextVertexStart,this._geometryCount=r._geometryCount,this._maxInstanceCount=r._maxInstanceCount,this._maxVertexCount=r._maxVertexCount,this._maxIndexCount=r._maxIndexCount,this._geometryInitialized=r._geometryInitialized,this._multiDrawCounts=r._multiDrawCounts.slice(),this._multiDrawStarts=r._multiDrawStarts.slice(),this._indirectTexture=r._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=r._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=r._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(r,l,h,f,g){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const v=f.getIndex(),A=v===null?1:v.array.BYTES_PER_ELEMENT,V=this._instanceInfo,H=this._multiDrawStarts,Z=this._multiDrawCounts,ce=this._geometryInfo,he=this.perObjectFrustumCulled,de=this._indirectTexture,Me=de.image.data,Je=h.isArrayCamera?Y0:_x;he&&!h.isArrayCamera&&(tl.multiplyMatrices(h.projectionMatrix,h.matrixWorldInverse).multiply(this.matrixWorld),_x.setFromProjectionMatrix(tl,h.coordinateSystem,h.reversedDepth));let mt=0;if(this.sortObjects){tl.copy(this.matrixWorld).invert(),_p.setFromMatrixPosition(h.matrixWorld).applyMatrix4(tl),Mh.set(0,0,-1).transformDirection(h.matrixWorld).transformDirection(tl);for(let Pt=0,Gt=V.length;Pt<Gt;Pt++)if(V[Pt].visible&&V[Pt].active){const gn=V[Pt].geometryIndex;this.getMatrixAt(Pt,tl),this.getBoundingSphereAt(gn,xu).applyMatrix4(tl);let Sn=!1;if(he&&(Sn=!Je.intersectsSphere(xu,h)),!Sn){const kn=ce[gn],In=w1.subVectors(xu.center,_p).dot(Mh);nl.push(kn.start,kn.count,In,Pt)}}const pt=nl.list,Nt=this.customSort;Nt===null?pt.sort(g.transparent?og:b1):Nt.call(this,pt,h);for(let Pt=0,Gt=pt.length;Pt<Gt;Pt++){const gn=pt[Pt];H[mt]=gn.start*A,Z[mt]=gn.count,Me[mt]=gn.index,mt++}nl.reset()}else for(let pt=0,Nt=V.length;pt<Nt;pt++)if(V[pt].visible&&V[pt].active){const Pt=V[pt].geometryIndex;let Gt=!1;if(he&&(this.getMatrixAt(pt,tl),this.getBoundingSphereAt(Pt,xu).applyMatrix4(tl),Gt=!Je.intersectsSphere(xu,h)),!Gt){const gn=ce[Pt];H[mt]=gn.start*A,Z[mt]=gn.count,Me[mt]=pt,mt++}}de.needsUpdate=!0,this._multiDrawCount=mt,this._visibilityChanged=!1}onBeforeShadow(r,l,h,f,g,v){this.onBeforeRender(r,null,f,g,v)}}class Pl extends null{constructor(r){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ar(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(r)}copy(r){return super.copy(r),this.color.copy(r.color),this.map=r.map,this.linewidth=r.linewidth,this.linecap=r.linecap,this.linejoin=r.linejoin,this.fog=r.fog,this}}const bp=new Rt,Sh=new Rt,wp=new On,mf=new ai,Mp=new Vt,lg=new Rt,wx=new Rt;class gf extends null{constructor(r=new Fr,l=new Pl){super(),this.isLine=!0,this.type="Line",this.geometry=r,this.material=l,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(r,l){return super.copy(r,l),this.material=Array.isArray(r.material)?r.material.slice():r.material,this.geometry=r.geometry,this}computeLineDistances(){const r=this.geometry;if(r.index===null){const l=r.attributes.position,h=[0];for(let f=1,g=l.count;f<g;f++)bp.fromBufferAttribute(l,f-1),Sh.fromBufferAttribute(l,f),h[f]=h[f-1],h[f]+=bp.distanceTo(Sh);r.setAttribute("lineDistance",new qi(h,1))}else _r("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(r,l){const h=this.geometry,f=this.matrixWorld,g=r.params.Line.threshold,v=h.drawRange;if(h.boundingSphere===null&&h.computeBoundingSphere(),Mp.copy(h.boundingSphere),Mp.applyMatrix4(f),Mp.radius+=g,r.ray.intersectsSphere(Mp)===!1)return;wp.copy(f).invert(),mf.copy(r.ray).applyMatrix4(wp);const A=g/((this.scale.x+this.scale.y+this.scale.z)/3),V=A*A,H=this.isLineSegments?2:1,Z=h.index,he=h.attributes.position;if(Z!==null){const de=Math.max(0,v.start),Me=Math.min(Z.count,v.start+v.count);for(let Je=de,mt=Me-1;Je<mt;Je+=H){const pt=Z.getX(Je),Nt=Z.getX(Je+1),Pt=Sp(this,r,mf,V,pt,Nt,Je);Pt&&l.push(Pt)}if(this.isLineLoop){const Je=Z.getX(Me-1),mt=Z.getX(de),pt=Sp(this,r,mf,V,Je,mt,Me-1);pt&&l.push(pt)}}else{const de=Math.max(0,v.start),Me=Math.min(he.count,v.start+v.count);for(let Je=de,mt=Me-1;Je<mt;Je+=H){const pt=Sp(this,r,mf,V,Je,Je+1,Je);pt&&l.push(pt)}if(this.isLineLoop){const Je=Sp(this,r,mf,V,Me-1,de,Me-1);Je&&l.push(Je)}}}updateMorphTargets(){const l=this.geometry.morphAttributes,h=Object.keys(l);if(h.length>0){const f=l[h[0]];if(f!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let g=0,v=f.length;g<v;g++){const A=f[g].name||String(g);this.morphTargetInfluences.push(0),this.morphTargetDictionary[A]=g}}}}}function Sp(j,r,l,h,f,g,v){const A=j.geometry.attributes.position;if(bp.fromBufferAttribute(A,f),Sh.fromBufferAttribute(A,g),l.distanceSqToSegment(bp,Sh,lg,wx)>h)return;lg.applyMatrix4(j.matrixWorld);const H=r.ray.origin.distanceTo(lg);if(!(H<r.near||H>r.far))return{distance:H,point:wx.clone().applyMatrix4(j.matrixWorld),index:v,face:null,faceIndex:null,barycoord:null,object:j}}const cg=new Rt,Tp=new Rt;class Ep extends null{constructor(r,l){super(r,l),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const r=this.geometry;if(r.index===null){const l=r.attributes.position,h=[];for(let f=0,g=l.count;f<g;f+=2)cg.fromBufferAttribute(l,f),Tp.fromBufferAttribute(l,f+1),h[f]=f===0?0:h[f-1],h[f+1]=h[f]+cg.distanceTo(Tp);r.setAttribute("lineDistance",new qi(h,1))}else _r("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class M1 extends null{constructor(r,l){super(r,l),this.isLineLoop=!0,this.type="LineLoop"}}class Z0 extends null{constructor(r){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ar(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(r)}copy(r){return super.copy(r),this.color.copy(r.color),this.map=r.map,this.alphaMap=r.alphaMap,this.size=r.size,this.sizeAttenuation=r.sizeAttenuation,this.fog=r.fog,this}}const S1=new On,Mx=new ai,Ap=new Vt,ug=new Rt;class vE extends null{constructor(r=new Fr,l=new Z0){super(),this.isPoints=!0,this.type="Points",this.geometry=r,this.material=l,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(r,l){return super.copy(r,l),this.material=Array.isArray(r.material)?r.material.slice():r.material,this.geometry=r.geometry,this}raycast(r,l){const h=this.geometry,f=this.matrixWorld,g=r.params.Points.threshold,v=h.drawRange;if(h.boundingSphere===null&&h.computeBoundingSphere(),Ap.copy(h.boundingSphere),Ap.applyMatrix4(f),Ap.radius+=g,r.ray.intersectsSphere(Ap)===!1)return;S1.copy(f).invert(),Mx.copy(r.ray).applyMatrix4(S1);const A=g/((this.scale.x+this.scale.y+this.scale.z)/3),V=A*A,H=h.index,ce=h.attributes.position;if(H!==null){const he=Math.max(0,v.start),de=Math.min(H.count,v.start+v.count);for(let Me=he,Je=de;Me<Je;Me++){const mt=H.getX(Me);ug.fromBufferAttribute(ce,mt),T1(ug,mt,V,f,r,l,this)}}else{const he=Math.max(0,v.start),de=Math.min(ce.count,v.start+v.count);for(let Me=he,Je=de;Me<Je;Me++)ug.fromBufferAttribute(ce,Me),T1(ug,Me,V,f,r,l,this)}}updateMorphTargets(){const l=this.geometry.morphAttributes,h=Object.keys(l);if(h.length>0){const f=l[h[0]];if(f!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let g=0,v=f.length;g<v;g++){const A=f[g].name||String(g);this.morphTargetInfluences.push(0),this.morphTargetDictionary[A]=g}}}}}function T1(j,r,l,h,f,g,v){const A=Mx.distanceSqToPoint(j);if(A<l){const V=new Rt;Mx.closestPointToPoint(j,V),V.applyMatrix4(h);const H=f.ray.origin.distanceTo(V);if(H<f.near||H>f.far)return;g.push({distance:H,distanceToRay:Math.sqrt(A),point:V,index:r,face:null,faceIndex:null,barycoord:null,object:v})}}class L3 extends null{constructor(r,l,h,f,g=Rn,v=Rn,A,V,H){super(r,l,h,f,g,v,A,V,H),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const Z=this;function ce(){Z.needsUpdate=!0,Z._requestVideoFrameCallbackId=r.requestVideoFrameCallback(ce)}"requestVideoFrameCallback"in r&&(this._requestVideoFrameCallbackId=r.requestVideoFrameCallback(ce))}clone(){return new this.constructor(this.image).copy(this)}update(){const r=this.image;"requestVideoFrameCallback"in r===!1&&r.readyState>=r.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class vc extends null{constructor(r,l,h,f,g,v,A,V){super({},r,l,h,f,g,v,A,V),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(r){this.image=r,this.needsUpdate=!0}}class E1 extends null{constructor(r,l){super({width:r,height:l}),this.isFramebufferTexture=!0,this.magFilter=Ct,this.minFilter=Ct,this.generateMipmaps=!1,this.needsUpdate=!0}}class K0 extends null{constructor(r,l,h,f,g,v,A,V,H,Z,ce,he){super(null,v,A,V,H,Z,f,g,ce,he),this.isCompressedTexture=!0,this.image={width:l,height:h},this.mipmaps=r,this.flipY=!1,this.generateMipmaps=!1}}class Sx extends null{constructor(r,l,h,f,g,v){super(r,l,h,g,v),this.isCompressedArrayTexture=!0,this.image.depth=f,this.wrapR=$e,this.layerUpdates=new Set}addLayerUpdate(r){this.layerUpdates.add(r)}clearLayerUpdates(){this.layerUpdates.clear()}}class Cp extends null{constructor(r,l,h){super(void 0,r[0].width,r[0].height,l,h,De),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=r}}class Rp extends bl{constructor(r,l,h,f,g,v,A,V,H){super(r,l,h,f,g,v,A,V,H),this.isCanvasTexture=!0,this.needsUpdate=!0}}class yf extends null{constructor(r,l,h=ls,f,g,v,A=Ct,V=Ct,H,Z=U,ce=1){if(Z!==U&&Z!==_)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const he={width:r,height:l,depth:ce};super(he,f,g,v,A,V,Z,h,H),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(r){return super.copy(r),this.source=new Ja(Object.assign({},r.image)),this.compareFunction=r.compareFunction,this}toJSON(r){const l=super.toJSON(r);return this.compareFunction!==null&&(l.compareFunction=this.compareFunction),l}}class Tx extends null{constructor(r=null){super(),this.sourceTexture=r,this.isExternalTexture=!0}copy(r){return super.copy(r),this.sourceTexture=r.sourceTexture,this}}class vf extends Fr{constructor(r=1,l=1,h=4,f=8,g=1){super(),this.type="CapsuleGeometry",this.parameters={radius:r,height:l,capSegments:h,radialSegments:f,heightSegments:g},l=Math.max(0,l),h=Math.max(1,Math.floor(h)),f=Math.max(3,Math.floor(f)),g=Math.max(1,Math.floor(g));const v=[],A=[],V=[],H=[],Z=l/2,ce=Math.PI/2*r,he=l,de=2*ce+he,Me=h*2+g,Je=f+1,mt=new Rt,pt=new Rt;for(let Nt=0;Nt<=Me;Nt++){let Pt=0,Gt=0,gn=0,Sn=0;if(Nt<=h){const ii=Nt/h,li=ii*Math.PI/2;Gt=-Z-r*Math.cos(li),gn=r*Math.sin(li),Sn=-r*Math.cos(li),Pt=ii*ce}else if(Nt<=h+g){const ii=(Nt-h)/g;Gt=-Z+ii*l,gn=r,Sn=0,Pt=ce+ii*he}else{const ii=(Nt-h-g)/h,li=ii*Math.PI/2;Gt=Z+r*Math.sin(li),gn=r*Math.cos(li),Sn=r*Math.sin(li),Pt=ce+he+ii*ce}const kn=Math.max(0,Math.min(1,Pt/de));let In=0;Nt===0?In=.5/f:Nt===Me&&(In=-.5/f);for(let ii=0;ii<=f;ii++){const li=ii/f,dr=li*Math.PI*2,Zr=Math.sin(dr),Ts=Math.cos(dr);pt.x=-gn*Ts,pt.y=Gt,pt.z=gn*Zr,A.push(pt.x,pt.y,pt.z),mt.set(-gn*Ts,Sn,gn*Zr),mt.normalize(),V.push(mt.x,mt.y,mt.z),H.push(li+In,kn)}if(Nt>0){const ii=(Nt-1)*Je;for(let li=0;li<f;li++){const dr=ii+li,Zr=ii+li+1,Ts=Nt*Je+li,to=Nt*Je+li+1;v.push(dr,Zr,Ts),v.push(Zr,to,Ts)}}}this.setIndex(v),this.setAttribute("position",new qi(A,3)),this.setAttribute("normal",new qi(V,3)),this.setAttribute("uv",new qi(H,2))}copy(r){return super.copy(r),this.parameters=Object.assign({},r.parameters),this}static fromJSON(r){return new vf(r.radius,r.height,r.capSegments,r.radialSegments,r.heightSegments)}}class xf extends Fr{constructor(r=1,l=32,h=0,f=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:r,segments:l,thetaStart:h,thetaLength:f},l=Math.max(3,l);const g=[],v=[],A=[],V=[],H=new Rt,Z=new oi;v.push(0,0,0),A.push(0,0,1),V.push(.5,.5);for(let ce=0,he=3;ce<=l;ce++,he+=3){const de=h+ce/l*f;H.x=r*Math.cos(de),H.y=r*Math.sin(de),v.push(H.x,H.y,H.z),A.push(0,0,1),Z.x=(v[he]/r+1)/2,Z.y=(v[he+1]/r+1)/2,V.push(Z.x,Z.y)}for(let ce=1;ce<=l;ce++)g.push(ce,ce+1,0);this.setIndex(g),this.setAttribute("position",new qi(v,3)),this.setAttribute("normal",new qi(A,3)),this.setAttribute("uv",new qi(V,2))}copy(r){return super.copy(r),this.parameters=Object.assign({},r.parameters),this}static fromJSON(r){return new xf(r.radius,r.segments,r.thetaStart,r.thetaLength)}}class _f extends Fr{constructor(r=1,l=1,h=1,f=32,g=1,v=!1,A=0,V=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:r,radiusBottom:l,height:h,radialSegments:f,heightSegments:g,openEnded:v,thetaStart:A,thetaLength:V};const H=this;f=Math.floor(f),g=Math.floor(g);const Z=[],ce=[],he=[],de=[];let Me=0;const Je=[],mt=h/2;let pt=0;Nt(),v===!1&&(r>0&&Pt(!0),l>0&&Pt(!1)),this.setIndex(Z),this.setAttribute("position",new qi(ce,3)),this.setAttribute("normal",new qi(he,3)),this.setAttribute("uv",new qi(de,2));function Nt(){const Gt=new Rt,gn=new Rt;let Sn=0;const kn=(l-r)/h;for(let In=0;In<=g;In++){const ii=[],li=In/g,dr=li*(l-r)+r;for(let Zr=0;Zr<=f;Zr++){const Ts=Zr/f,to=Ts*V+A,ho=Math.sin(to),Ra=Math.cos(to);gn.x=dr*ho,gn.y=-li*h+mt,gn.z=dr*Ra,ce.push(gn.x,gn.y,gn.z),Gt.set(ho,kn,Ra).normalize(),he.push(Gt.x,Gt.y,Gt.z),de.push(Ts,1-li),ii.push(Me++)}Je.push(ii)}for(let In=0;In<f;In++)for(let ii=0;ii<g;ii++){const li=Je[ii][In],dr=Je[ii+1][In],Zr=Je[ii+1][In+1],Ts=Je[ii][In+1];(r>0||ii!==0)&&(Z.push(li,dr,Ts),Sn+=3),(l>0||ii!==g-1)&&(Z.push(dr,Zr,Ts),Sn+=3)}H.addGroup(pt,Sn,0),pt+=Sn}function Pt(Gt){const gn=Me,Sn=new oi,kn=new Rt;let In=0;const ii=Gt===!0?r:l,li=Gt===!0?1:-1;for(let Zr=1;Zr<=f;Zr++)ce.push(0,mt*li,0),he.push(0,li,0),de.push(.5,.5),Me++;const dr=Me;for(let Zr=0;Zr<=f;Zr++){const to=Zr/f*V+A,ho=Math.cos(to),Ra=Math.sin(to);kn.x=ii*Ra,kn.y=mt*li,kn.z=ii*ho,ce.push(kn.x,kn.y,kn.z),he.push(0,li,0),Sn.x=ho*.5+.5,Sn.y=Ra*.5*li+.5,de.push(Sn.x,Sn.y),Me++}for(let Zr=0;Zr<f;Zr++){const Ts=gn+Zr,to=dr+Zr;Gt===!0?Z.push(to,to+1,Ts):Z.push(to+1,to,Ts),In+=3}H.addGroup(pt,In,Gt===!0?1:2),pt+=In}}copy(r){return super.copy(r),this.parameters=Object.assign({},r.parameters),this}static fromJSON(r){return new _f(r.radiusTop,r.radiusBottom,r.height,r.radialSegments,r.heightSegments,r.openEnded,r.thetaStart,r.thetaLength)}}class md extends _f{constructor(r=1,l=1,h=32,f=1,g=!1,v=0,A=Math.PI*2){super(0,r,l,h,f,g,v,A),this.type="ConeGeometry",this.parameters={radius:r,height:l,radialSegments:h,heightSegments:f,openEnded:g,thetaStart:v,thetaLength:A}}static fromJSON(r){return new md(r.radius,r.height,r.radialSegments,r.heightSegments,r.openEnded,r.thetaStart,r.thetaLength)}}class gd extends Fr{constructor(r=[],l=[],h=1,f=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:r,indices:l,radius:h,detail:f};const g=[],v=[];A(f),H(h),Z(),this.setAttribute("position",new qi(g,3)),this.setAttribute("normal",new qi(g.slice(),3)),this.setAttribute("uv",new qi(v,2)),f===0?this.computeVertexNormals():this.normalizeNormals();function A(Nt){const Pt=new Rt,Gt=new Rt,gn=new Rt;for(let Sn=0;Sn<l.length;Sn+=3)de(l[Sn+0],Pt),de(l[Sn+1],Gt),de(l[Sn+2],gn),V(Pt,Gt,gn,Nt)}function V(Nt,Pt,Gt,gn){const Sn=gn+1,kn=[];for(let In=0;In<=Sn;In++){kn[In]=[];const ii=Nt.clone().lerp(Gt,In/Sn),li=Pt.clone().lerp(Gt,In/Sn),dr=Sn-In;for(let Zr=0;Zr<=dr;Zr++)Zr===0&&In===Sn?kn[In][Zr]=ii:kn[In][Zr]=ii.clone().lerp(li,Zr/dr)}for(let In=0;In<Sn;In++)for(let ii=0;ii<2*(Sn-In)-1;ii++){const li=Math.floor(ii/2);ii%2===0?(he(kn[In][li+1]),he(kn[In+1][li]),he(kn[In][li])):(he(kn[In][li+1]),he(kn[In+1][li+1]),he(kn[In+1][li]))}}function H(Nt){const Pt=new Rt;for(let Gt=0;Gt<g.length;Gt+=3)Pt.x=g[Gt+0],Pt.y=g[Gt+1],Pt.z=g[Gt+2],Pt.normalize().multiplyScalar(Nt),g[Gt+0]=Pt.x,g[Gt+1]=Pt.y,g[Gt+2]=Pt.z}function Z(){const Nt=new Rt;for(let Pt=0;Pt<g.length;Pt+=3){Nt.x=g[Pt+0],Nt.y=g[Pt+1],Nt.z=g[Pt+2];const Gt=mt(Nt)/2/Math.PI+.5,gn=pt(Nt)/Math.PI+.5;v.push(Gt,1-gn)}Me(),ce()}function ce(){for(let Nt=0;Nt<v.length;Nt+=6){const Pt=v[Nt+0],Gt=v[Nt+2],gn=v[Nt+4],Sn=Math.max(Pt,Gt,gn),kn=Math.min(Pt,Gt,gn);Sn>.9&&kn<.1&&(Pt<.2&&(v[Nt+0]+=1),Gt<.2&&(v[Nt+2]+=1),gn<.2&&(v[Nt+4]+=1))}}function he(Nt){g.push(Nt.x,Nt.y,Nt.z)}function de(Nt,Pt){const Gt=Nt*3;Pt.x=r[Gt+0],Pt.y=r[Gt+1],Pt.z=r[Gt+2]}function Me(){const Nt=new Rt,Pt=new Rt,Gt=new Rt,gn=new Rt,Sn=new oi,kn=new oi,In=new oi;for(let ii=0,li=0;ii<g.length;ii+=9,li+=6){Nt.set(g[ii+0],g[ii+1],g[ii+2]),Pt.set(g[ii+3],g[ii+4],g[ii+5]),Gt.set(g[ii+6],g[ii+7],g[ii+8]),Sn.set(v[li+0],v[li+1]),kn.set(v[li+2],v[li+3]),In.set(v[li+4],v[li+5]),gn.copy(Nt).add(Pt).add(Gt).divideScalar(3);const dr=mt(gn);Je(Sn,li+0,Nt,dr),Je(kn,li+2,Pt,dr),Je(In,li+4,Gt,dr)}}function Je(Nt,Pt,Gt,gn){gn<0&&Nt.x===1&&(v[Pt]=Nt.x-1),Gt.x===0&&Gt.z===0&&(v[Pt]=gn/2/Math.PI+.5)}function mt(Nt){return Math.atan2(Nt.z,-Nt.x)}function pt(Nt){return Math.atan2(-Nt.y,Math.sqrt(Nt.x*Nt.x+Nt.z*Nt.z))}}copy(r){return super.copy(r),this.parameters=Object.assign({},r.parameters),this}static fromJSON(r){return new gd(r.vertices,r.indices,r.radius,r.details)}}class xc extends gd{constructor(r=1,l=0){const h=(1+Math.sqrt(5))/2,f=1/h,g=[-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,-f,-h,0,-f,h,0,f,-h,0,f,h,-f,-h,0,-f,h,0,f,-h,0,f,h,0,-h,0,-f,h,0,-f,-h,0,f,h,0,f],v=[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(g,v,r,l),this.type="DodecahedronGeometry",this.parameters={radius:r,detail:l}}static fromJSON(r){return new xc(r.radius,r.detail)}}const bf=new Rt,hg=new Rt,Np=new Rt,yd=new br;class J0 extends Fr{constructor(r=null,l=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:r,thresholdAngle:l},r!==null){const f=Math.pow(10,4),g=Math.cos(au*l),v=r.getIndex(),A=r.getAttribute("position"),V=v?v.count:A.count,H=[0,0,0],Z=["a","b","c"],ce=new Array(3),he={},de=[];for(let Me=0;Me<V;Me+=3){v?(H[0]=v.getX(Me),H[1]=v.getX(Me+1),H[2]=v.getX(Me+2)):(H[0]=Me,H[1]=Me+1,H[2]=Me+2);const{a:Je,b:mt,c:pt}=yd;if(Je.fromBufferAttribute(A,H[0]),mt.fromBufferAttribute(A,H[1]),pt.fromBufferAttribute(A,H[2]),yd.getNormal(Np),ce[0]=`${Math.round(Je.x*f)},${Math.round(Je.y*f)},${Math.round(Je.z*f)}`,ce[1]=`${Math.round(mt.x*f)},${Math.round(mt.y*f)},${Math.round(mt.z*f)}`,ce[2]=`${Math.round(pt.x*f)},${Math.round(pt.y*f)},${Math.round(pt.z*f)}`,!(ce[0]===ce[1]||ce[1]===ce[2]||ce[2]===ce[0]))for(let Nt=0;Nt<3;Nt++){const Pt=(Nt+1)%3,Gt=ce[Nt],gn=ce[Pt],Sn=yd[Z[Nt]],kn=yd[Z[Pt]],In=`${Gt}_${gn}`,ii=`${gn}_${Gt}`;ii in he&&he[ii]?(Np.dot(he[ii].normal)<=g&&(de.push(Sn.x,Sn.y,Sn.z),de.push(kn.x,kn.y,kn.z)),he[ii]=null):In in he||(he[In]={index0:H[Nt],index1:H[Pt],normal:Np.clone()})}}for(const Me in he)if(he[Me]){const{index0:Je,index1:mt}=he[Me];bf.fromBufferAttribute(A,Je),hg.fromBufferAttribute(A,mt),de.push(bf.x,bf.y,bf.z),de.push(hg.x,hg.y,hg.z)}this.setAttribute("position",new qi(de,3))}}copy(r){return super.copy(r),this.parameters=Object.assign({},r.parameters),this}}class _c{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){_r("Curve: .getPoint() not implemented.")}getPointAt(r,l){const h=this.getUtoTmapping(r);return this.getPoint(h,l)}getPoints(r=5){const l=[];for(let h=0;h<=r;h++)l.push(this.getPoint(h/r));return l}getSpacedPoints(r=5){const l=[];for(let h=0;h<=r;h++)l.push(this.getPointAt(h/r));return l}getLength(){const r=this.getLengths();return r[r.length-1]}getLengths(r=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===r+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const l=[];let h,f=this.getPoint(0),g=0;l.push(0);for(let v=1;v<=r;v++)h=this.getPoint(v/r),g+=h.distanceTo(f),l.push(g),f=h;return this.cacheArcLengths=l,l}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(r,l=null){const h=this.getLengths();let f=0;const g=h.length;let v;l?v=l:v=r*h[g-1];let A=0,V=g-1,H;for(;A<=V;)if(f=Math.floor(A+(V-A)/2),H=h[f]-v,H<0)A=f+1;else if(H>0)V=f-1;else{V=f;break}if(f=V,h[f]===v)return f/(g-1);const Z=h[f],he=h[f+1]-Z,de=(v-Z)/he;return(f+de)/(g-1)}getTangent(r,l){let f=r-1e-4,g=r+1e-4;f<0&&(f=0),g>1&&(g=1);const v=this.getPoint(f),A=this.getPoint(g),V=l||(v.isVector2?new oi:new Rt);return V.copy(A).sub(v).normalize(),V}getTangentAt(r,l){const h=this.getUtoTmapping(r);return this.getTangent(h,l)}computeFrenetFrames(r,l=!1){const h=new Rt,f=[],g=[],v=[],A=new Rt,V=new On;for(let de=0;de<=r;de++){const Me=de/r;f[de]=this.getTangentAt(Me,new Rt)}g[0]=new Rt,v[0]=new Rt;let H=Number.MAX_VALUE;const Z=Math.abs(f[0].x),ce=Math.abs(f[0].y),he=Math.abs(f[0].z);Z<=H&&(H=Z,h.set(1,0,0)),ce<=H&&(H=ce,h.set(0,1,0)),he<=H&&h.set(0,0,1),A.crossVectors(f[0],h).normalize(),g[0].crossVectors(f[0],A),v[0].crossVectors(f[0],g[0]);for(let de=1;de<=r;de++){if(g[de]=g[de-1].clone(),v[de]=v[de-1].clone(),A.crossVectors(f[de-1],f[de]),A.length()>Number.EPSILON){A.normalize();const Me=Math.acos(Br(f[de-1].dot(f[de]),-1,1));g[de].applyMatrix4(V.makeRotationAxis(A,Me))}v[de].crossVectors(f[de],g[de])}if(l===!0){let de=Math.acos(Br(g[0].dot(g[r]),-1,1));de/=r,f[0].dot(A.crossVectors(g[0],g[r]))>0&&(de=-de);for(let Me=1;Me<=r;Me++)g[Me].applyMatrix4(V.makeRotationAxis(f[Me],de*Me)),v[Me].crossVectors(f[Me],g[Me])}return{tangents:f,normals:g,binormals:v}}clone(){return new this.constructor().copy(this)}copy(r){return this.arcLengthDivisions=r.arcLengthDivisions,this}toJSON(){const r={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return r.arcLengthDivisions=this.arcLengthDivisions,r.type=this.type,r}fromJSON(r){return this.arcLengthDivisions=r.arcLengthDivisions,this}}class Pp extends _c{constructor(r=0,l=0,h=1,f=1,g=0,v=Math.PI*2,A=!1,V=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=r,this.aY=l,this.xRadius=h,this.yRadius=f,this.aStartAngle=g,this.aEndAngle=v,this.aClockwise=A,this.aRotation=V}getPoint(r,l=new oi){const h=l,f=Math.PI*2;let g=this.aEndAngle-this.aStartAngle;const v=Math.abs(g)<Number.EPSILON;for(;g<0;)g+=f;for(;g>f;)g-=f;g<Number.EPSILON&&(v?g=0:g=f),this.aClockwise===!0&&!v&&(g===f?g=-f:g=g-f);const A=this.aStartAngle+r*g;let V=this.aX+this.xRadius*Math.cos(A),H=this.aY+this.yRadius*Math.sin(A);if(this.aRotation!==0){const Z=Math.cos(this.aRotation),ce=Math.sin(this.aRotation),he=V-this.aX,de=H-this.aY;V=he*Z-de*ce+this.aX,H=he*ce+de*Z+this.aY}return h.set(V,H)}copy(r){return super.copy(r),this.aX=r.aX,this.aY=r.aY,this.xRadius=r.xRadius,this.yRadius=r.yRadius,this.aStartAngle=r.aStartAngle,this.aEndAngle=r.aEndAngle,this.aClockwise=r.aClockwise,this.aRotation=r.aRotation,this}toJSON(){const r=super.toJSON();return r.aX=this.aX,r.aY=this.aY,r.xRadius=this.xRadius,r.yRadius=this.yRadius,r.aStartAngle=this.aStartAngle,r.aEndAngle=this.aEndAngle,r.aClockwise=this.aClockwise,r.aRotation=this.aRotation,r}fromJSON(r){return super.fromJSON(r),this.aX=r.aX,this.aY=r.aY,this.xRadius=r.xRadius,this.yRadius=r.yRadius,this.aStartAngle=r.aStartAngle,this.aEndAngle=r.aEndAngle,this.aClockwise=r.aClockwise,this.aRotation=r.aRotation,this}}class A1 extends Pp{constructor(r,l,h,f,g,v){super(r,l,h,h,f,g,v),this.isArcCurve=!0,this.type="ArcCurve"}}function dg(){let j=0,r=0,l=0,h=0;function f(g,v,A,V){j=g,r=A,l=-3*g+3*v-2*A-V,h=2*g-2*v+A+V}return{initCatmullRom:function(g,v,A,V,H){f(v,A,H*(A-g),H*(V-v))},initNonuniformCatmullRom:function(g,v,A,V,H,Z,ce){let he=(v-g)/H-(A-g)/(H+Z)+(A-v)/Z,de=(A-v)/Z-(V-v)/(Z+ce)+(V-A)/ce;he*=Z,de*=Z,f(v,A,he,de)},calc:function(g){const v=g*g,A=v*g;return j+r*g+l*v+h*A}}}const fg=new Rt,Q0=new dg,ey=new dg,vd=new dg;class C1 extends _c{constructor(r=[],l=!1,h="centripetal",f=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=r,this.closed=l,this.curveType=h,this.tension=f}getPoint(r,l=new Rt){const h=l,f=this.points,g=f.length,v=(g-(this.closed?0:1))*r;let A=Math.floor(v),V=v-A;this.closed?A+=A>0?0:(Math.floor(Math.abs(A)/g)+1)*g:V===0&&A===g-1&&(A=g-2,V=1);let H,Z;this.closed||A>0?H=f[(A-1)%g]:(fg.subVectors(f[0],f[1]).add(f[0]),H=fg);const ce=f[A%g],he=f[(A+1)%g];if(this.closed||A+2<g?Z=f[(A+2)%g]:(fg.subVectors(f[g-1],f[g-2]).add(f[g-1]),Z=fg),this.curveType==="centripetal"||this.curveType==="chordal"){const de=this.curveType==="chordal"?.5:.25;let Me=Math.pow(H.distanceToSquared(ce),de),Je=Math.pow(ce.distanceToSquared(he),de),mt=Math.pow(he.distanceToSquared(Z),de);Je<1e-4&&(Je=1),Me<1e-4&&(Me=Je),mt<1e-4&&(mt=Je),Q0.initNonuniformCatmullRom(H.x,ce.x,he.x,Z.x,Me,Je,mt),ey.initNonuniformCatmullRom(H.y,ce.y,he.y,Z.y,Me,Je,mt),vd.initNonuniformCatmullRom(H.z,ce.z,he.z,Z.z,Me,Je,mt)}else this.curveType==="catmullrom"&&(Q0.initCatmullRom(H.x,ce.x,he.x,Z.x,this.tension),ey.initCatmullRom(H.y,ce.y,he.y,Z.y,this.tension),vd.initCatmullRom(H.z,ce.z,he.z,Z.z,this.tension));return h.set(Q0.calc(V),ey.calc(V),vd.calc(V)),h}copy(r){super.copy(r),this.points=[];for(let l=0,h=r.points.length;l<h;l++){const f=r.points[l];this.points.push(f.clone())}return this.closed=r.closed,this.curveType=r.curveType,this.tension=r.tension,this}toJSON(){const r=super.toJSON();r.points=[];for(let l=0,h=this.points.length;l<h;l++){const f=this.points[l];r.points.push(f.toArray())}return r.closed=this.closed,r.curveType=this.curveType,r.tension=this.tension,r}fromJSON(r){super.fromJSON(r),this.points=[];for(let l=0,h=r.points.length;l<h;l++){const f=r.points[l];this.points.push(new Rt().fromArray(f))}return this.closed=r.closed,this.curveType=r.curveType,this.tension=r.tension,this}}function Ex(j,r,l,h,f){const g=(h-r)*.5,v=(f-l)*.5,A=j*j,V=j*A;return(2*l-2*h+g+v)*V+(-3*l+3*h-2*g-v)*A+g*j+l}function R1(j,r){const l=1-j;return l*l*r}function N1(j,r){return 2*(1-j)*j*r}function Ip(j,r){return j*j*r}function wf(j,r,l,h){return R1(j,r)+N1(j,l)+Ip(j,h)}function Ax(j,r){const l=1-j;return l*l*l*r}function Cx(j,r){const l=1-j;return 3*l*l*j*r}function P1(j,r){return 3*(1-j)*j*j*r}function Rx(j,r){return j*j*j*r}function xd(j,r,l,h,f){return Ax(j,r)+Cx(j,l)+P1(j,h)+Rx(j,f)}class ty extends _c{constructor(r=new oi,l=new oi,h=new oi,f=new oi){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=r,this.v1=l,this.v2=h,this.v3=f}getPoint(r,l=new oi){const h=l,f=this.v0,g=this.v1,v=this.v2,A=this.v3;return h.set(xd(r,f.x,g.x,v.x,A.x),xd(r,f.y,g.y,v.y,A.y)),h}copy(r){return super.copy(r),this.v0.copy(r.v0),this.v1.copy(r.v1),this.v2.copy(r.v2),this.v3.copy(r.v3),this}toJSON(){const r=super.toJSON();return r.v0=this.v0.toArray(),r.v1=this.v1.toArray(),r.v2=this.v2.toArray(),r.v3=this.v3.toArray(),r}fromJSON(r){return super.fromJSON(r),this.v0.fromArray(r.v0),this.v1.fromArray(r.v1),this.v2.fromArray(r.v2),this.v3.fromArray(r.v3),this}}class pg extends _c{constructor(r=new Rt,l=new Rt,h=new Rt,f=new Rt){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=r,this.v1=l,this.v2=h,this.v3=f}getPoint(r,l=new Rt){const h=l,f=this.v0,g=this.v1,v=this.v2,A=this.v3;return h.set(xd(r,f.x,g.x,v.x,A.x),xd(r,f.y,g.y,v.y,A.y),xd(r,f.z,g.z,v.z,A.z)),h}copy(r){return super.copy(r),this.v0.copy(r.v0),this.v1.copy(r.v1),this.v2.copy(r.v2),this.v3.copy(r.v3),this}toJSON(){const r=super.toJSON();return r.v0=this.v0.toArray(),r.v1=this.v1.toArray(),r.v2=this.v2.toArray(),r.v3=this.v3.toArray(),r}fromJSON(r){return super.fromJSON(r),this.v0.fromArray(r.v0),this.v1.fromArray(r.v1),this.v2.fromArray(r.v2),this.v3.fromArray(r.v3),this}}class Nx extends _c{constructor(r=new oi,l=new oi){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=r,this.v2=l}getPoint(r,l=new oi){const h=l;return r===1?h.copy(this.v2):(h.copy(this.v2).sub(this.v1),h.multiplyScalar(r).add(this.v1)),h}getPointAt(r,l){return this.getPoint(r,l)}getTangent(r,l=new oi){return l.subVectors(this.v2,this.v1).normalize()}getTangentAt(r,l){return this.getTangent(r,l)}copy(r){return super.copy(r),this.v1.copy(r.v1),this.v2.copy(r.v2),this}toJSON(){const r=super.toJSON();return r.v1=this.v1.toArray(),r.v2=this.v2.toArray(),r}fromJSON(r){return super.fromJSON(r),this.v1.fromArray(r.v1),this.v2.fromArray(r.v2),this}}class ny extends _c{constructor(r=new Rt,l=new Rt){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=r,this.v2=l}getPoint(r,l=new Rt){const h=l;return r===1?h.copy(this.v2):(h.copy(this.v2).sub(this.v1),h.multiplyScalar(r).add(this.v1)),h}getPointAt(r,l){return this.getPoint(r,l)}getTangent(r,l=new Rt){return l.subVectors(this.v2,this.v1).normalize()}getTangentAt(r,l){return this.getTangent(r,l)}copy(r){return super.copy(r),this.v1.copy(r.v1),this.v2.copy(r.v2),this}toJSON(){const r=super.toJSON();return r.v1=this.v1.toArray(),r.v2=this.v2.toArray(),r}fromJSON(r){return super.fromJSON(r),this.v1.fromArray(r.v1),this.v2.fromArray(r.v2),this}}class _d extends _c{constructor(r=new oi,l=new oi,h=new oi){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=r,this.v1=l,this.v2=h}getPoint(r,l=new oi){const h=l,f=this.v0,g=this.v1,v=this.v2;return h.set(wf(r,f.x,g.x,v.x),wf(r,f.y,g.y,v.y)),h}copy(r){return super.copy(r),this.v0.copy(r.v0),this.v1.copy(r.v1),this.v2.copy(r.v2),this}toJSON(){const r=super.toJSON();return r.v0=this.v0.toArray(),r.v1=this.v1.toArray(),r.v2=this.v2.toArray(),r}fromJSON(r){return super.fromJSON(r),this.v0.fromArray(r.v0),this.v1.fromArray(r.v1),this.v2.fromArray(r.v2),this}}class Px extends _c{constructor(r=new Rt,l=new Rt,h=new Rt){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=r,this.v1=l,this.v2=h}getPoint(r,l=new Rt){const h=l,f=this.v0,g=this.v1,v=this.v2;return h.set(wf(r,f.x,g.x,v.x),wf(r,f.y,g.y,v.y),wf(r,f.z,g.z,v.z)),h}copy(r){return super.copy(r),this.v0.copy(r.v0),this.v1.copy(r.v1),this.v2.copy(r.v2),this}toJSON(){const r=super.toJSON();return r.v0=this.v0.toArray(),r.v1=this.v1.toArray(),r.v2=this.v2.toArray(),r}fromJSON(r){return super.fromJSON(r),this.v0.fromArray(r.v0),this.v1.fromArray(r.v1),this.v2.fromArray(r.v2),this}}class iy extends _c{constructor(r=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=r}getPoint(r,l=new oi){const h=l,f=this.points,g=(f.length-1)*r,v=Math.floor(g),A=g-v,V=f[v===0?v:v-1],H=f[v],Z=f[v>f.length-2?f.length-1:v+1],ce=f[v>f.length-3?f.length-1:v+2];return h.set(Ex(A,V.x,H.x,Z.x,ce.x),Ex(A,V.y,H.y,Z.y,ce.y)),h}copy(r){super.copy(r),this.points=[];for(let l=0,h=r.points.length;l<h;l++){const f=r.points[l];this.points.push(f.clone())}return this}toJSON(){const r=super.toJSON();r.points=[];for(let l=0,h=this.points.length;l<h;l++){const f=this.points[l];r.points.push(f.toArray())}return r}fromJSON(r){super.fromJSON(r),this.points=[];for(let l=0,h=r.points.length;l<h;l++){const f=r.points[l];this.points.push(new oi().fromArray(f))}return this}}var _u=Object.freeze({__proto__:null,ArcCurve:A1,CatmullRomCurve3:C1,CubicBezierCurve:ty,CubicBezierCurve3:pg,EllipseCurve:Pp,LineCurve:Nx,LineCurve3:ny,QuadraticBezierCurve:_d,QuadraticBezierCurve3:Px,SplineCurve:iy});class Lp extends _c{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(r){this.curves.push(r)}closePath(){const r=this.curves[0].getPoint(0),l=this.curves[this.curves.length-1].getPoint(1);if(!r.equals(l)){const h=r.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new _u[h](l,r))}return this}getPoint(r,l){const h=r*this.getLength(),f=this.getCurveLengths();let g=0;for(;g<f.length;){if(f[g]>=h){const v=f[g]-h,A=this.curves[g],V=A.getLength(),H=V===0?0:1-v/V;return A.getPointAt(H,l)}g++}return null}getLength(){const r=this.getCurveLengths();return r[r.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 r=[];let l=0;for(let h=0,f=this.curves.length;h<f;h++)l+=this.curves[h].getLength(),r.push(l);return this.cacheLengths=r,r}getSpacedPoints(r=40){const l=[];for(let h=0;h<=r;h++)l.push(this.getPoint(h/r));return this.autoClose&&l.push(l[0]),l}getPoints(r=12){const l=[];let h;for(let f=0,g=this.curves;f<g.length;f++){const v=g[f],A=v.isEllipseCurve?r*2:v.isLineCurve||v.isLineCurve3?1:v.isSplineCurve?r*v.points.length:r,V=v.getPoints(A);for(let H=0;H<V.length;H++){const Z=V[H];h&&h.equals(Z)||(l.push(Z),h=Z)}}return this.autoClose&&l.length>1&&!l[l.length-1].equals(l[0])&&l.push(l[0]),l}copy(r){super.copy(r),this.curves=[];for(let l=0,h=r.curves.length;l<h;l++){const f=r.curves[l];this.curves.push(f.clone())}return this.autoClose=r.autoClose,this}toJSON(){const r=super.toJSON();r.autoClose=this.autoClose,r.curves=[];for(let l=0,h=this.curves.length;l<h;l++){const f=this.curves[l];r.curves.push(f.toJSON())}return r}fromJSON(r){super.fromJSON(r),this.autoClose=r.autoClose,this.curves=[];for(let l=0,h=r.curves.length;l<h;l++){const f=r.curves[l];this.curves.push(new _u[f.type]().fromJSON(f))}return this}}class ry extends Lp{constructor(r){super(),this.type="Path",this.currentPoint=new oi,r&&this.setFromPoints(r)}setFromPoints(r){this.moveTo(r[0].x,r[0].y);for(let l=1,h=r.length;l<h;l++)this.lineTo(r[l].x,r[l].y);return this}moveTo(r,l){return this.currentPoint.set(r,l),this}lineTo(r,l){const h=new Nx(this.currentPoint.clone(),new oi(r,l));return this.curves.push(h),this.currentPoint.set(r,l),this}quadraticCurveTo(r,l,h,f){const g=new _d(this.currentPoint.clone(),new oi(r,l),new oi(h,f));return this.curves.push(g),this.currentPoint.set(h,f),this}bezierCurveTo(r,l,h,f,g,v){const A=new ty(this.currentPoint.clone(),new oi(r,l),new oi(h,f),new oi(g,v));return this.curves.push(A),this.currentPoint.set(g,v),this}splineThru(r){const l=[this.currentPoint.clone()].concat(r),h=new iy(l);return this.curves.push(h),this.currentPoint.copy(r[r.length-1]),this}arc(r,l,h,f,g,v){const A=this.currentPoint.x,V=this.currentPoint.y;return this.absarc(r+A,l+V,h,f,g,v),this}absarc(r,l,h,f,g,v){return this.absellipse(r,l,h,h,f,g,v),this}ellipse(r,l,h,f,g,v,A,V){const H=this.currentPoint.x,Z=this.currentPoint.y;return this.absellipse(r+H,l+Z,h,f,g,v,A,V),this}absellipse(r,l,h,f,g,v,A,V){const H=new Pp(r,l,h,f,g,v,A,V);if(this.curves.length>0){const ce=H.getPoint(0);ce.equals(this.currentPoint)||this.lineTo(ce.x,ce.y)}this.curves.push(H);const Z=H.getPoint(1);return this.currentPoint.copy(Z),this}copy(r){return super.copy(r),this.currentPoint.copy(r.currentPoint),this}toJSON(){const r=super.toJSON();return r.currentPoint=this.currentPoint.toArray(),r}fromJSON(r){return super.fromJSON(r),this.currentPoint.fromArray(r.currentPoint),this}}class Mf extends ry{constructor(r){super(r),this.uuid=El(),this.type="Shape",this.holes=[]}getPointsHoles(r){const l=[];for(let h=0,f=this.holes.length;h<f;h++)l[h]=this.holes[h].getPoints(r);return l}extractPoints(r){return{shape:this.getPoints(r),holes:this.getPointsHoles(r)}}copy(r){super.copy(r),this.holes=[];for(let l=0,h=r.holes.length;l<h;l++){const f=r.holes[l];this.holes.push(f.clone())}return this}toJSON(){const r=super.toJSON();r.uuid=this.uuid,r.holes=[];for(let l=0,h=this.holes.length;l<h;l++){const f=this.holes[l];r.holes.push(f.toJSON())}return r}fromJSON(r){super.fromJSON(r),this.uuid=r.uuid,this.holes=[];for(let l=0,h=r.holes.length;l<h;l++){const f=r.holes[l];this.holes.push(new ry().fromJSON(f))}return this}}function I1(j,r,l=2){const h=r&&r.length,f=h?r[0]*l:j.length;let g=Ix(j,0,f,l,!0);const v=[];if(!g||g.next===g.prev)return v;let A,V,H;if(h&&(g=B1(j,r,g,l)),j.length>80*l){A=j[0],V=j[1];let Z=A,ce=V;for(let he=l;he<f;he+=l){const de=j[he],Me=j[he+1];de<A&&(A=de),Me<V&&(V=Me),de>Z&&(Z=de),Me>ce&&(ce=Me)}H=Math.max(Z-A,ce-V),H=H!==0?32767/H:0}return Dp(g,v,l,A,V,H,0),v}function Ix(j,r,l,h,f){let g;if(f===G1(j,r,l,h)>0)for(let v=r;v<l;v+=h)g=ly(v/h|0,j[v],j[v+1],g);else for(let v=l-h;v>=r;v-=h)g=ly(v/h|0,j[v],j[v+1],g);return g&&Sf(g,g.next)&&(Tf(g),g=g.next),g}function bd(j,r){if(!j)return j;r||(r=j);let l=j,h;do if(h=!1,!l.steiner&&(Sf(l,l.next)||So(l.prev,l,l.next)===0)){if(Tf(l),l=r=l.prev,l===l.next)break;h=!0}else l=l.next;while(h||l!==r);return r}function Dp(j,r,l,h,f,g,v){if(!j)return;!v&&g&&k1(j,h,f,g);let A=j;for(;j.prev!==j.next;){const V=j.prev,H=j.next;if(g?D1(j,h,f,g):L1(j)){r.push(V.i,j.i,H.i),Tf(j),j=H.next,A=H.next;continue}if(j=H,j===A){v?v===1?(j=O1(bd(j),r),Dp(j,r,l,h,f,g,2)):v===2&&F1(j,r,l,h,f,g):Dp(bd(j),r,l,h,f,g,1);break}}}function L1(j){const r=j.prev,l=j,h=j.next;if(So(r,l,h)>=0)return!1;const f=r.x,g=l.x,v=h.x,A=r.y,V=l.y,H=h.y,Z=Math.min(f,g,v),ce=Math.min(A,V,H),he=Math.max(f,g,v),de=Math.max(A,V,H);let Me=h.next;for(;Me!==r;){if(Me.x>=Z&&Me.x<=he&&Me.y>=ce&&Me.y<=de&&Eh(f,A,g,V,v,H,Me.x,Me.y)&&So(Me.prev,Me,Me.next)>=0)return!1;Me=Me.next}return!0}function D1(j,r,l,h){const f=j.prev,g=j,v=j.next;if(So(f,g,v)>=0)return!1;const A=f.x,V=g.x,H=v.x,Z=f.y,ce=g.y,he=v.y,de=Math.min(A,V,H),Me=Math.min(Z,ce,he),Je=Math.max(A,V,H),mt=Math.max(Z,ce,he),pt=Th(de,Me,r,l,h),Nt=Th(Je,mt,r,l,h);let Pt=j.prevZ,Gt=j.nextZ;for(;Pt&&Pt.z>=pt&&Gt&&Gt.z<=Nt;){if(Pt.x>=de&&Pt.x<=Je&&Pt.y>=Me&&Pt.y<=mt&&Pt!==f&&Pt!==v&&Eh(A,Z,V,ce,H,he,Pt.x,Pt.y)&&So(Pt.prev,Pt,Pt.next)>=0||(Pt=Pt.prevZ,Gt.x>=de&&Gt.x<=Je&&Gt.y>=Me&&Gt.y<=mt&&Gt!==f&&Gt!==v&&Eh(A,Z,V,ce,H,he,Gt.x,Gt.y)&&So(Gt.prev,Gt,Gt.next)>=0))return!1;Gt=Gt.nextZ}for(;Pt&&Pt.z>=pt;){if(Pt.x>=de&&Pt.x<=Je&&Pt.y>=Me&&Pt.y<=mt&&Pt!==f&&Pt!==v&&Eh(A,Z,V,ce,H,he,Pt.x,Pt.y)&&So(Pt.prev,Pt,Pt.next)>=0)return!1;Pt=Pt.prevZ}for(;Gt&&Gt.z<=Nt;){if(Gt.x>=de&&Gt.x<=Je&&Gt.y>=Me&&Gt.y<=mt&&Gt!==f&&Gt!==v&&Eh(A,Z,V,ce,H,he,Gt.x,Gt.y)&&So(Gt.prev,Gt,Gt.next)>=0)return!1;Gt=Gt.nextZ}return!0}function O1(j,r){let l=j;do{const h=l.prev,f=l.next.next;!Sf(h,f)&&oy(h,l,l.next,f)&&Up(h,f)&&Up(f,h)&&(r.push(h.i,l.i,f.i),Tf(l),Tf(l.next),l=j=f),l=l.next}while(l!==j);return bd(l)}function F1(j,r,l,h,f,g){let v=j;do{let A=v.next.next;for(;A!==v.prev;){if(v.i!==A.i&&z1(v,A)){let V=Hc(v,A);v=bd(v,v.next),V=bd(V,V.next),Dp(v,r,l,h,f,g,0),Dp(V,r,l,h,f,g,0);return}A=A.next}v=v.next}while(v!==j)}function B1(j,r,l,h){const f=[];for(let g=0,v=r.length;g<v;g++){const A=r[g]*h,V=g<v-1?r[g+1]*h:j.length,H=Ix(j,A,V,h,!1);H===H.next&&(H.steiner=!0),f.push(Dx(H))}f.sort(sy);for(let g=0;g<f.length;g++)l=U1(f[g],l);return l}function sy(j,r){let l=j.x-r.x;if(l===0&&(l=j.y-r.y,l===0)){const h=(j.next.y-j.y)/(j.next.x-j.x),f=(r.next.y-r.y)/(r.next.x-r.x);l=h-f}return l}function U1(j,r){const l=Lx(j,r);if(!l)return r;const h=Hc(l,j);return bd(h,h.next),bd(l,l.next)}function Lx(j,r){let l=r;const h=j.x,f=j.y;let g=-1/0,v;if(Sf(j,l))return l;do{if(Sf(j,l.next))return l.next;if(f<=l.y&&f>=l.next.y&&l.next.y!==l.y){const ce=l.x+(f-l.y)*(l.next.x-l.x)/(l.next.y-l.y);if(ce<=h&&ce>g&&(g=ce,v=l.x<l.next.x?l:l.next,ce===h))return v}l=l.next}while(l!==r);if(!v)return null;const A=v,V=v.x,H=v.y;let Z=1/0;l=v;do{if(h>=l.x&&l.x>=V&&h!==l.x&&Fp(f<H?h:g,f,V,H,f<H?g:h,f,l.x,l.y)){const ce=Math.abs(f-l.y)/(h-l.x);Up(l,j)&&(ce<Z||ce===Z&&(l.x>v.x||l.x===v.x&&Op(v,l)))&&(v=l,Z=ce)}l=l.next}while(l!==A);return v}function Op(j,r){return So(j.prev,j,r.prev)<0&&So(r.next,j,j.next)<0}function k1(j,r,l,h){let f=j;do f.z===0&&(f.z=Th(f.x,f.y,r,l,h)),f.prevZ=f.prev,f.nextZ=f.next,f=f.next;while(f!==j);f.prevZ.nextZ=null,f.prevZ=null,Xo(f)}function Xo(j){let r,l=1;do{let h=j,f;j=null;let g=null;for(r=0;h;){r++;let v=h,A=0;for(let H=0;H<l&&(A++,v=v.nextZ,!!v);H++);let V=l;for(;A>0||V>0&&v;)A!==0&&(V===0||!v||h.z<=v.z)?(f=h,h=h.nextZ,A--):(f=v,v=v.nextZ,V--),g?g.nextZ=f:j=f,f.prevZ=g,g=f;h=v}g.nextZ=null,l*=2}while(r>1);return j}function Th(j,r,l,h,f){return j=(j-l)*f|0,r=(r-h)*f|0,j=(j|j<<8)&16711935,j=(j|j<<4)&252645135,j=(j|j<<2)&858993459,j=(j|j<<1)&1431655765,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,j|r<<1}function Dx(j){let r=j,l=j;do(r.x<l.x||r.x===l.x&&r.y<l.y)&&(l=r),r=r.next;while(r!==j);return l}function Fp(j,r,l,h,f,g,v,A){return(f-v)*(r-A)>=(j-v)*(g-A)&&(j-v)*(h-A)>=(l-v)*(r-A)&&(l-v)*(g-A)>=(f-v)*(h-A)}function Eh(j,r,l,h,f,g,v,A){return!(j===v&&r===A)&&Fp(j,r,l,h,f,g,v,A)}function z1(j,r){return j.next.i!==r.i&&j.prev.i!==r.i&&!ay(j,r)&&(Up(j,r)&&Up(r,j)&&V1(j,r)&&(So(j.prev,j,r.prev)||So(j,r.prev,r))||Sf(j,r)&&So(j.prev,j,j.next)>0&&So(r.prev,r,r.next)>0)}function So(j,r,l){return(r.y-j.y)*(l.x-r.x)-(r.x-j.x)*(l.y-r.y)}function Sf(j,r){return j.x===r.x&&j.y===r.y}function oy(j,r,l,h){const f=Ah(So(j,r,l)),g=Ah(So(j,r,h)),v=Ah(So(l,h,j)),A=Ah(So(l,h,r));return!!(f!==g&&v!==A||f===0&&Bp(j,l,r)||g===0&&Bp(j,h,r)||v===0&&Bp(l,j,h)||A===0&&Bp(l,r,h))}function Bp(j,r,l){return r.x<=Math.max(j.x,l.x)&&r.x>=Math.min(j.x,l.x)&&r.y<=Math.max(j.y,l.y)&&r.y>=Math.min(j.y,l.y)}function Ah(j){return j>0?1:j<0?-1:0}function ay(j,r){let l=j;do{if(l.i!==j.i&&l.next.i!==j.i&&l.i!==r.i&&l.next.i!==r.i&&oy(l,l.next,j,r))return!0;l=l.next}while(l!==j);return!1}function Up(j,r){return So(j.prev,j,j.next)<0?So(j,r,j.next)>=0&&So(j,j.prev,r)>=0:So(j,r,j.prev)<0||So(j,j.next,r)<0}function V1(j,r){let l=j,h=!1;const f=(j.x+r.x)/2,g=(j.y+r.y)/2;do l.y>g!=l.next.y>g&&l.next.y!==l.y&&f<(l.next.x-l.x)*(g-l.y)/(l.next.y-l.y)+l.x&&(h=!h),l=l.next;while(l!==j);return h}function Hc(j,r){const l=kp(j.i,j.x,j.y),h=kp(r.i,r.x,r.y),f=j.next,g=r.prev;return j.next=r,r.prev=j,l.next=f,f.prev=l,h.next=l,l.prev=h,g.next=h,h.prev=g,h}function ly(j,r,l,h){const f=kp(j,r,l);return h?(f.next=h.next,f.prev=h,h.next.prev=f,h.next=f):(f.prev=f,f.next=f),f}function Tf(j){j.next.prev=j.prev,j.prev.next=j.next,j.prevZ&&(j.prevZ.nextZ=j.nextZ),j.nextZ&&(j.nextZ.prevZ=j.prevZ)}function kp(j,r,l){return{i:j,x:r,y:l,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function G1(j,r,l,h){let f=0;for(let g=r,v=l-h;g<l;g+=h)f+=(j[v]-j[g])*(j[g+1]+j[v+1]),v=g;return f}class W1{static triangulate(r,l,h=2){return I1(r,l,h)}}class bc{static area(r){const l=r.length;let h=0;for(let f=l-1,g=0;g<l;f=g++)h+=r[f].x*r[g].y-r[g].x*r[f].y;return h*.5}static isClockWise(r){return bc.area(r)<0}static triangulateShape(r,l){const h=[],f=[],g=[];mg(r),zp(h,r);let v=r.length;l.forEach(mg);for(let V=0;V<l.length;V++)f.push(v),v+=l[V].length,zp(h,l[V]);const A=W1.triangulate(h,f);for(let V=0;V<A.length;V+=3)g.push(A.slice(V,V+3));return g}}function mg(j){const r=j.length;r>2&&j[r-1].equals(j[0])&&j.pop()}function zp(j,r){for(let l=0;l<r.length;l++)j.push(r[l].x),j.push(r[l].y)}class Ch extends Fr{constructor(r=new Mf([new oi(.5,.5),new oi(-.5,.5),new oi(-.5,-.5),new oi(.5,-.5)]),l={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:r,options:l},r=Array.isArray(r)?r:[r];const h=this,f=[],g=[];for(let A=0,V=r.length;A<V;A++){const H=r[A];v(H)}this.setAttribute("position",new qi(f,3)),this.setAttribute("uv",new qi(g,2)),this.computeVertexNormals();function v(A){const V=[],H=l.curveSegments!==void 0?l.curveSegments:12,Z=l.steps!==void 0?l.steps:1,ce=l.depth!==void 0?l.depth:1;let he=l.bevelEnabled!==void 0?l.bevelEnabled:!0,de=l.bevelThickness!==void 0?l.bevelThickness:.2,Me=l.bevelSize!==void 0?l.bevelSize:de-.1,Je=l.bevelOffset!==void 0?l.bevelOffset:0,mt=l.bevelSegments!==void 0?l.bevelSegments:3;const pt=l.extrudePath,Nt=l.UVGenerator!==void 0?l.UVGenerator:cy;let Pt,Gt=!1,gn,Sn,kn,In;pt&&(Pt=pt.getSpacedPoints(Z),Gt=!0,he=!1,gn=pt.computeFrenetFrames(Z,!1),Sn=new Rt,kn=new Rt,In=new Rt),he||(mt=0,de=0,Me=0,Je=0);const ii=A.extractPoints(H);let li=ii.shape;const dr=ii.holes;if(!bc.isClockWise(li)){li=li.reverse();for(let Ui=0,tr=dr.length;Ui<tr;Ui++){const rr=dr[Ui];bc.isClockWise(rr)&&(dr[Ui]=rr.reverse())}}function Ts(Ui){const rr=10000000000000001e-36;let fr=Ui[0];for(let lr=1;lr<=Ui.length;lr++){const Qs=lr%Ui.length,Es=Ui[Qs],Vo=Es.x-fr.x,Zo=Es.y-fr.y,Ha=Vo*Vo+Zo*Zo,rc=Math.max(Math.abs(Es.x),Math.abs(Es.y),Math.abs(fr.x),Math.abs(fr.y)),Ld=rr*rc*rc;if(Ha<=Ld){Ui.splice(Qs,1),lr--;continue}fr=Es}}Ts(li),dr.forEach(Ts);const to=dr.length,ho=li;for(let Ui=0;Ui<to;Ui++){const tr=dr[Ui];li=li.concat(tr)}function Ra(Ui,tr,rr){return tr||Xs("ExtrudeGeometry: vec does not exist"),Ui.clone().addScaledVector(tr,rr)}const fl=li.length;function ic(Ui,tr,rr){let fr,lr,Qs;const Es=Ui.x-tr.x,Vo=Ui.y-tr.y,Zo=rr.x-Ui.x,Ha=rr.y-Ui.y,rc=Es*Es+Vo*Vo,Ld=Es*Ha-Vo*Zo;if(Math.abs(Ld)>Number.EPSILON){const sc=Math.sqrt(rc),s_=Math.sqrt(Zo*Zo+Ha*Ha),o_=tr.x-Vo/sc,a_=tr.y+Es/sc,yw=rr.x-Ha/s_,vw=rr.y+Zo/s_,l_=((yw-o_)*Ha-(vw-a_)*Zo)/(Es*Ha-Vo*Zo);fr=o_+Es*l_-Ui.x,lr=a_+Vo*l_-Ui.y;const c_=fr*fr+lr*lr;if(c_<=2)return new oi(fr,lr);Qs=Math.sqrt(c_/2)}else{let sc=!1;Es>Number.EPSILON?Zo>Number.EPSILON&&(sc=!0):Es<-Number.EPSILON?Zo<-Number.EPSILON&&(sc=!0):Math.sign(Vo)===Math.sign(Ha)&&(sc=!0),sc?(fr=-Vo,lr=Es,Qs=Math.sqrt(rc)):(fr=Es,lr=Vo,Qs=Math.sqrt(rc/2))}return new oi(fr/Qs,lr/Qs)}const qo=[];for(let Ui=0,tr=ho.length,rr=tr-1,fr=Ui+1;Ui<tr;Ui++,rr++,fr++)rr===tr&&(rr=0),fr===tr&&(fr=0),qo[Ui]=ic(ho[Ui],ho[rr],ho[fr]);const Na=[];let Yo,jc=qo.concat();for(let Ui=0,tr=to;Ui<tr;Ui++){const rr=dr[Ui];Yo=[];for(let fr=0,lr=rr.length,Qs=lr-1,Es=fr+1;fr<lr;fr++,Qs++,Es++)Qs===lr&&(Qs=0),Es===lr&&(Es=0),Yo[fr]=ic(rr[fr],rr[Qs],rr[Es]);Na.push(Yo),jc=jc.concat(Yo)}let Sc;if(mt===0)Sc=bc.triangulateShape(ho,dr);else{const Ui=[],tr=[];for(let rr=0;rr<mt;rr++){const fr=rr/mt,lr=de*Math.cos(fr*Math.PI/2),Qs=Me*Math.sin(fr*Math.PI/2)+Je;for(let Es=0,Vo=ho.length;Es<Vo;Es++){const Zo=Ra(ho[Es],qo[Es],Qs);wu(Zo.x,Zo.y,-lr),fr===0&&Ui.push(Zo)}for(let Es=0,Vo=to;Es<Vo;Es++){const Zo=dr[Es];Yo=Na[Es];const Ha=[];for(let rc=0,Ld=Zo.length;rc<Ld;rc++){const sc=Ra(Zo[rc],Yo[rc],Qs);wu(sc.x,sc.y,-lr),fr===0&&Ha.push(sc)}fr===0&&tr.push(Ha)}}Sc=bc.triangulateShape(Ui,tr)}const Ph=Sc.length,nm=Me+Je;for(let Ui=0;Ui<fl;Ui++){const tr=he?Ra(li[Ui],jc[Ui],nm):li[Ui];Gt?(kn.copy(gn.normals[0]).multiplyScalar(tr.x),Sn.copy(gn.binormals[0]).multiplyScalar(tr.y),In.copy(Pt[0]).add(kn).add(Sn),wu(In.x,In.y,In.z)):wu(tr.x,tr.y,0)}for(let Ui=1;Ui<=Z;Ui++)for(let tr=0;tr<fl;tr++){const rr=he?Ra(li[tr],jc[tr],nm):li[tr];Gt?(kn.copy(gn.normals[Ui]).multiplyScalar(rr.x),Sn.copy(gn.binormals[Ui]).multiplyScalar(rr.y),In.copy(Pt[Ui]).add(kn).add(Sn),wu(In.x,In.y,In.z)):wu(rr.x,rr.y,ce/Z*Ui)}for(let Ui=mt-1;Ui>=0;Ui--){const tr=Ui/mt,rr=de*Math.cos(tr*Math.PI/2),fr=Me*Math.sin(tr*Math.PI/2)+Je;for(let lr=0,Qs=ho.length;lr<Qs;lr++){const Es=Ra(ho[lr],qo[lr],fr);wu(Es.x,Es.y,ce+rr)}for(let lr=0,Qs=dr.length;lr<Qs;lr++){const Es=dr[lr];Yo=Na[lr];for(let Vo=0,Zo=Es.length;Vo<Zo;Vo++){const Ha=Ra(Es[Vo],Yo[Vo],fr);Gt?wu(Ha.x,Ha.y+Pt[Z-1].y,Pt[Z-1].x+rr):wu(Ha.x,Ha.y,ce+rr)}}}gw(),n_();function gw(){const Ui=f.length/3;if(he){let tr=0,rr=fl*tr;for(let fr=0;fr<Ph;fr++){const lr=Sc[fr];Vf(lr[2]+rr,lr[1]+rr,lr[0]+rr)}tr=Z+mt*2,rr=fl*tr;for(let fr=0;fr<Ph;fr++){const lr=Sc[fr];Vf(lr[0]+rr,lr[1]+rr,lr[2]+rr)}}else{for(let tr=0;tr<Ph;tr++){const rr=Sc[tr];Vf(rr[2],rr[1],rr[0])}for(let tr=0;tr<Ph;tr++){const rr=Sc[tr];Vf(rr[0]+fl*Z,rr[1]+fl*Z,rr[2]+fl*Z)}}h.addGroup(Ui,f.length/3-Ui,0)}function n_(){const Ui=f.length/3;let tr=0;i_(ho,tr),tr+=ho.length;for(let rr=0,fr=dr.length;rr<fr;rr++){const lr=dr[rr];i_(lr,tr),tr+=lr.length}h.addGroup(Ui,f.length/3-Ui,1)}function i_(Ui,tr){let rr=Ui.length;for(;--rr>=0;){const fr=rr;let lr=rr-1;lr<0&&(lr=Ui.length-1);for(let Qs=0,Es=Z+mt*2;Qs<Es;Qs++){const Vo=fl*Qs,Zo=fl*(Qs+1),Ha=tr+fr+Vo,rc=tr+lr+Vo,Ld=tr+lr+Zo,sc=tr+fr+Zo;r_(Ha,rc,Ld,sc)}}}function wu(Ui,tr,rr){V.push(Ui),V.push(tr),V.push(rr)}function Vf(Ui,tr,rr){th(Ui),th(tr),th(rr);const fr=f.length/3,lr=Nt.generateTopUV(h,f,fr-3,fr-2,fr-1);nh(lr[0]),nh(lr[1]),nh(lr[2])}function r_(Ui,tr,rr,fr){th(Ui),th(tr),th(fr),th(tr),th(rr),th(fr);const lr=f.length/3,Qs=Nt.generateSideWallUV(h,f,lr-6,lr-3,lr-2,lr-1);nh(Qs[0]),nh(Qs[1]),nh(Qs[3]),nh(Qs[1]),nh(Qs[2]),nh(Qs[3])}function th(Ui){f.push(V[Ui*3+0]),f.push(V[Ui*3+1]),f.push(V[Ui*3+2])}function nh(Ui){g.push(Ui.x),g.push(Ui.y)}}}copy(r){return super.copy(r),this.parameters=Object.assign({},r.parameters),this}toJSON(){const r=super.toJSON(),l=this.parameters.shapes,h=this.parameters.options;return uy(l,h,r)}static fromJSON(r,l){const h=[];for(let g=0,v=r.shapes.length;g<v;g++){const A=l[r.shapes[g]];h.push(A)}const f=r.options.extrudePath;return f!==void 0&&(r.options.extrudePath=new _u[f.type]().fromJSON(f)),new Ch(h,r.options)}}const cy={generateTopUV:function(j,r,l,h,f){const g=r[l*3],v=r[l*3+1],A=r[h*3],V=r[h*3+1],H=r[f*3],Z=r[f*3+1];return[new oi(g,v),new oi(A,V),new oi(H,Z)]},generateSideWallUV:function(j,r,l,h,f,g){const v=r[l*3],A=r[l*3+1],V=r[l*3+2],H=r[h*3],Z=r[h*3+1],ce=r[h*3+2],he=r[f*3],de=r[f*3+1],Me=r[f*3+2],Je=r[g*3],mt=r[g*3+1],pt=r[g*3+2];return Math.abs(A-Z)<Math.abs(v-H)?[new oi(v,1-V),new oi(H,1-ce),new oi(he,1-Me),new oi(Je,1-pt)]:[new oi(A,1-V),new oi(Z,1-ce),new oi(de,1-Me),new oi(mt,1-pt)]}};function uy(j,r,l){if(l.shapes=[],Array.isArray(j))for(let h=0,f=j.length;h<f;h++){const g=j[h];l.shapes.push(g.uuid)}else l.shapes.push(j.uuid);return l.options=Object.assign({},r),r.extrudePath!==void 0&&(l.options.extrudePath=r.extrudePath.toJSON()),l}class hy extends gd{constructor(r=1,l=0){const h=(1+Math.sqrt(5))/2,f=[-1,h,0,1,h,0,-1,-h,0,1,-h,0,0,-1,h,0,1,h,0,-1,-h,0,1,-h,h,0,-1,h,0,1,-h,0,-1,-h,0,1],g=[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(f,g,r,l),this.type="IcosahedronGeometry",this.parameters={radius:r,detail:l}}static fromJSON(r){return new hy(r.radius,r.detail)}}class Yu extends Fr{constructor(r=[new oi(0,-.5),new oi(.5,0),new oi(0,.5)],l=12,h=0,f=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:r,segments:l,phiStart:h,phiLength:f},l=Math.floor(l),f=Br(f,0,Math.PI*2);const g=[],v=[],A=[],V=[],H=[],Z=1/l,ce=new Rt,he=new oi,de=new Rt,Me=new Rt,Je=new Rt;let mt=0,pt=0;for(let Nt=0;Nt<=r.length-1;Nt++)switch(Nt){case 0:mt=r[Nt+1].x-r[Nt].x,pt=r[Nt+1].y-r[Nt].y,de.x=pt*1,de.y=-mt,de.z=pt*0,Je.copy(de),de.normalize(),V.push(de.x,de.y,de.z);break;case r.length-1:V.push(Je.x,Je.y,Je.z);break;default:mt=r[Nt+1].x-r[Nt].x,pt=r[Nt+1].y-r[Nt].y,de.x=pt*1,de.y=-mt,de.z=pt*0,Me.copy(de),de.x+=Je.x,de.y+=Je.y,de.z+=Je.z,de.normalize(),V.push(de.x,de.y,de.z),Je.copy(Me)}for(let Nt=0;Nt<=l;Nt++){const Pt=h+Nt*Z*f,Gt=Math.sin(Pt),gn=Math.cos(Pt);for(let Sn=0;Sn<=r.length-1;Sn++){ce.x=r[Sn].x*Gt,ce.y=r[Sn].y,ce.z=r[Sn].x*gn,v.push(ce.x,ce.y,ce.z),he.x=Nt/l,he.y=Sn/(r.length-1),A.push(he.x,he.y);const kn=V[3*Sn+0]*Gt,In=V[3*Sn+1],ii=V[3*Sn+0]*gn;H.push(kn,In,ii)}}for(let Nt=0;Nt<l;Nt++)for(let Pt=0;Pt<r.length-1;Pt++){const Gt=Pt+Nt*r.length,gn=Gt,Sn=Gt+r.length,kn=Gt+r.length+1,In=Gt+1;g.push(gn,Sn,In),g.push(kn,In,Sn)}this.setIndex(g),this.setAttribute("position",new qi(v,3)),this.setAttribute("uv",new qi(A,2)),this.setAttribute("normal",new qi(H,3))}copy(r){return super.copy(r),this.parameters=Object.assign({},r.parameters),this}static fromJSON(r){return new Yu(r.points,r.segments,r.phiStart,r.phiLength)}}class Ef extends gd{constructor(r=1,l=0){const h=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],f=[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(h,f,r,l),this.type="OctahedronGeometry",this.parameters={radius:r,detail:l}}static fromJSON(r){return new Ef(r.radius,r.detail)}}class Vp extends Fr{constructor(r=1,l=1,h=1,f=1){super(),this.type="PlaneGeometry",this.parameters={width:r,height:l,widthSegments:h,heightSegments:f};const g=r/2,v=l/2,A=Math.floor(h),V=Math.floor(f),H=A+1,Z=V+1,ce=r/A,he=l/V,de=[],Me=[],Je=[],mt=[];for(let pt=0;pt<Z;pt++){const Nt=pt*he-v;for(let Pt=0;Pt<H;Pt++){const Gt=Pt*ce-g;Me.push(Gt,-Nt,0),Je.push(0,0,1),mt.push(Pt/A),mt.push(1-pt/V)}}for(let pt=0;pt<V;pt++)for(let Nt=0;Nt<A;Nt++){const Pt=Nt+H*pt,Gt=Nt+H*(pt+1),gn=Nt+1+H*(pt+1),Sn=Nt+1+H*pt;de.push(Pt,Gt,Sn),de.push(Gt,gn,Sn)}this.setIndex(de),this.setAttribute("position",new qi(Me,3)),this.setAttribute("normal",new qi(Je,3)),this.setAttribute("uv",new qi(mt,2))}copy(r){return super.copy(r),this.parameters=Object.assign({},r.parameters),this}static fromJSON(r){return new Vp(r.width,r.height,r.widthSegments,r.heightSegments)}}class Gp extends Fr{constructor(r=.5,l=1,h=32,f=1,g=0,v=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:r,outerRadius:l,thetaSegments:h,phiSegments:f,thetaStart:g,thetaLength:v},h=Math.max(3,h),f=Math.max(1,f);const A=[],V=[],H=[],Z=[];let ce=r;const he=(l-r)/f,de=new Rt,Me=new oi;for(let Je=0;Je<=f;Je++){for(let mt=0;mt<=h;mt++){const pt=g+mt/h*v;de.x=ce*Math.cos(pt),de.y=ce*Math.sin(pt),V.push(de.x,de.y,de.z),H.push(0,0,1),Me.x=(de.x/l+1)/2,Me.y=(de.y/l+1)/2,Z.push(Me.x,Me.y)}ce+=he}for(let Je=0;Je<f;Je++){const mt=Je*(h+1);for(let pt=0;pt<h;pt++){const Nt=pt+mt,Pt=Nt,Gt=Nt+h+1,gn=Nt+h+2,Sn=Nt+1;A.push(Pt,Gt,Sn),A.push(Gt,gn,Sn)}}this.setIndex(A),this.setAttribute("position",new qi(V,3)),this.setAttribute("normal",new qi(H,3)),this.setAttribute("uv",new qi(Z,2))}copy(r){return super.copy(r),this.parameters=Object.assign({},r.parameters),this}static fromJSON(r){return new Gp(r.innerRadius,r.outerRadius,r.thetaSegments,r.phiSegments,r.thetaStart,r.thetaLength)}}class Af extends Fr{constructor(r=new Mf([new oi(0,.5),new oi(-.5,-.5),new oi(.5,-.5)]),l=12){super(),this.type="ShapeGeometry",this.parameters={shapes:r,curveSegments:l};const h=[],f=[],g=[],v=[];let A=0,V=0;if(Array.isArray(r)===!1)H(r);else for(let Z=0;Z<r.length;Z++)H(r[Z]),this.addGroup(A,V,Z),A+=V,V=0;this.setIndex(h),this.setAttribute("position",new qi(f,3)),this.setAttribute("normal",new qi(g,3)),this.setAttribute("uv",new qi(v,2));function H(Z){const ce=f.length/3,he=Z.extractPoints(l);let de=he.shape;const Me=he.holes;bc.isClockWise(de)===!1&&(de=de.reverse());for(let mt=0,pt=Me.length;mt<pt;mt++){const Nt=Me[mt];bc.isClockWise(Nt)===!0&&(Me[mt]=Nt.reverse())}const Je=bc.triangulateShape(de,Me);for(let mt=0,pt=Me.length;mt<pt;mt++){const Nt=Me[mt];de=de.concat(Nt)}for(let mt=0,pt=de.length;mt<pt;mt++){const Nt=de[mt];f.push(Nt.x,Nt.y,0),g.push(0,0,1),v.push(Nt.x,Nt.y)}for(let mt=0,pt=Je.length;mt<pt;mt++){const Nt=Je[mt],Pt=Nt[0]+ce,Gt=Nt[1]+ce,gn=Nt[2]+ce;h.push(Pt,Gt,gn),V+=3}}}copy(r){return super.copy(r),this.parameters=Object.assign({},r.parameters),this}toJSON(){const r=super.toJSON(),l=this.parameters.shapes;return H1(l,r)}static fromJSON(r,l){const h=[];for(let f=0,g=r.shapes.length;f<g;f++){const v=l[r.shapes[f]];h.push(v)}return new Af(h,r.curveSegments)}}function H1(j,r){if(r.shapes=[],Array.isArray(j))for(let l=0,h=j.length;l<h;l++){const f=j[l];r.shapes.push(f.uuid)}else r.shapes.push(j.uuid);return r}class Cf extends Fr{constructor(r=1,l=32,h=16,f=0,g=Math.PI*2,v=0,A=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:r,widthSegments:l,heightSegments:h,phiStart:f,phiLength:g,thetaStart:v,thetaLength:A},l=Math.max(3,Math.floor(l)),h=Math.max(2,Math.floor(h));const V=Math.min(v+A,Math.PI);let H=0;const Z=[],ce=new Rt,he=new Rt,de=[],Me=[],Je=[],mt=[];for(let pt=0;pt<=h;pt++){const Nt=[],Pt=pt/h;let Gt=0;pt===0&&v===0?Gt=.5/l:pt===h&&V===Math.PI&&(Gt=-.5/l);for(let gn=0;gn<=l;gn++){const Sn=gn/l;ce.x=-r*Math.cos(f+Sn*g)*Math.sin(v+Pt*A),ce.y=r*Math.cos(v+Pt*A),ce.z=r*Math.sin(f+Sn*g)*Math.sin(v+Pt*A),Me.push(ce.x,ce.y,ce.z),he.copy(ce).normalize(),Je.push(he.x,he.y,he.z),mt.push(Sn+Gt,1-Pt),Nt.push(H++)}Z.push(Nt)}for(let pt=0;pt<h;pt++)for(let Nt=0;Nt<l;Nt++){const Pt=Z[pt][Nt+1],Gt=Z[pt][Nt],gn=Z[pt+1][Nt],Sn=Z[pt+1][Nt+1];(pt!==0||v>0)&&de.push(Pt,Gt,Sn),(pt!==h-1||V<Math.PI)&&de.push(Gt,gn,Sn)}this.setIndex(de),this.setAttribute("position",new qi(Me,3)),this.setAttribute("normal",new qi(Je,3)),this.setAttribute("uv",new qi(mt,2))}copy(r){return super.copy(r),this.parameters=Object.assign({},r.parameters),this}static fromJSON(r){return new Cf(r.radius,r.widthSegments,r.heightSegments,r.phiStart,r.phiLength,r.thetaStart,r.thetaLength)}}class gg extends gd{constructor(r=1,l=0){const h=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],f=[2,1,0,0,3,2,1,3,0,2,3,1];super(h,f,r,l),this.type="TetrahedronGeometry",this.parameters={radius:r,detail:l}}static fromJSON(r){return new gg(r.radius,r.detail)}}class yg extends Fr{constructor(r=1,l=.4,h=12,f=48,g=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:r,tube:l,radialSegments:h,tubularSegments:f,arc:g},h=Math.floor(h),f=Math.floor(f);const v=[],A=[],V=[],H=[],Z=new Rt,ce=new Rt,he=new Rt;for(let de=0;de<=h;de++)for(let Me=0;Me<=f;Me++){const Je=Me/f*g,mt=de/h*Math.PI*2;ce.x=(r+l*Math.cos(mt))*Math.cos(Je),ce.y=(r+l*Math.cos(mt))*Math.sin(Je),ce.z=l*Math.sin(mt),A.push(ce.x,ce.y,ce.z),Z.x=r*Math.cos(Je),Z.y=r*Math.sin(Je),he.subVectors(ce,Z).normalize(),V.push(he.x,he.y,he.z),H.push(Me/f),H.push(de/h)}for(let de=1;de<=h;de++)for(let Me=1;Me<=f;Me++){const Je=(f+1)*de+Me-1,mt=(f+1)*(de-1)+Me-1,pt=(f+1)*(de-1)+Me,Nt=(f+1)*de+Me;v.push(Je,mt,Nt),v.push(mt,pt,Nt)}this.setIndex(v),this.setAttribute("position",new qi(A,3)),this.setAttribute("normal",new qi(V,3)),this.setAttribute("uv",new qi(H,2))}copy(r){return super.copy(r),this.parameters=Object.assign({},r.parameters),this}static fromJSON(r){return new yg(r.radius,r.tube,r.radialSegments,r.tubularSegments,r.arc)}}class dy extends Fr{constructor(r=1,l=.4,h=64,f=8,g=2,v=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:r,tube:l,tubularSegments:h,radialSegments:f,p:g,q:v},h=Math.floor(h),f=Math.floor(f);const A=[],V=[],H=[],Z=[],ce=new Rt,he=new Rt,de=new Rt,Me=new Rt,Je=new Rt,mt=new Rt,pt=new Rt;for(let Pt=0;Pt<=h;++Pt){const Gt=Pt/h*g*Math.PI*2;Nt(Gt,g,v,r,de),Nt(Gt+.01,g,v,r,Me),mt.subVectors(Me,de),pt.addVectors(Me,de),Je.crossVectors(mt,pt),pt.crossVectors(Je,mt),Je.normalize(),pt.normalize();for(let gn=0;gn<=f;++gn){const Sn=gn/f*Math.PI*2,kn=-l*Math.cos(Sn),In=l*Math.sin(Sn);ce.x=de.x+(kn*pt.x+In*Je.x),ce.y=de.y+(kn*pt.y+In*Je.y),ce.z=de.z+(kn*pt.z+In*Je.z),V.push(ce.x,ce.y,ce.z),he.subVectors(ce,de).normalize(),H.push(he.x,he.y,he.z),Z.push(Pt/h),Z.push(gn/f)}}for(let Pt=1;Pt<=h;Pt++)for(let Gt=1;Gt<=f;Gt++){const gn=(f+1)*(Pt-1)+(Gt-1),Sn=(f+1)*Pt+(Gt-1),kn=(f+1)*Pt+Gt,In=(f+1)*(Pt-1)+Gt;A.push(gn,Sn,In),A.push(Sn,kn,In)}this.setIndex(A),this.setAttribute("position",new qi(V,3)),this.setAttribute("normal",new qi(H,3)),this.setAttribute("uv",new qi(Z,2));function Nt(Pt,Gt,gn,Sn,kn){const In=Math.cos(Pt),ii=Math.sin(Pt),li=gn/Gt*Pt,dr=Math.cos(li);kn.x=Sn*(2+dr)*.5*In,kn.y=Sn*(2+dr)*ii*.5,kn.z=Sn*Math.sin(li)*.5}}copy(r){return super.copy(r),this.parameters=Object.assign({},r.parameters),this}static fromJSON(r){return new dy(r.radius,r.tube,r.tubularSegments,r.radialSegments,r.p,r.q)}}class Wp extends Fr{constructor(r=new Px(new Rt(-1,-1,0),new Rt(-1,1,0),new Rt(1,1,0)),l=64,h=1,f=8,g=!1){super(),this.type="TubeGeometry",this.parameters={path:r,tubularSegments:l,radius:h,radialSegments:f,closed:g};const v=r.computeFrenetFrames(l,g);this.tangents=v.tangents,this.normals=v.normals,this.binormals=v.binormals;const A=new Rt,V=new Rt,H=new oi;let Z=new Rt;const ce=[],he=[],de=[],Me=[];Je(),this.setIndex(Me),this.setAttribute("position",new qi(ce,3)),this.setAttribute("normal",new qi(he,3)),this.setAttribute("uv",new qi(de,2));function Je(){for(let Pt=0;Pt<l;Pt++)mt(Pt);mt(g===!1?l:0),Nt(),pt()}function mt(Pt){Z=r.getPointAt(Pt/l,Z);const Gt=v.normals[Pt],gn=v.binormals[Pt];for(let Sn=0;Sn<=f;Sn++){const kn=Sn/f*Math.PI*2,In=Math.sin(kn),ii=-Math.cos(kn);V.x=ii*Gt.x+In*gn.x,V.y=ii*Gt.y+In*gn.y,V.z=ii*Gt.z+In*gn.z,V.normalize(),he.push(V.x,V.y,V.z),A.x=Z.x+h*V.x,A.y=Z.y+h*V.y,A.z=Z.z+h*V.z,ce.push(A.x,A.y,A.z)}}function pt(){for(let Pt=1;Pt<=l;Pt++)for(let Gt=1;Gt<=f;Gt++){const gn=(f+1)*(Pt-1)+(Gt-1),Sn=(f+1)*Pt+(Gt-1),kn=(f+1)*Pt+Gt,In=(f+1)*(Pt-1)+Gt;Me.push(gn,Sn,In),Me.push(Sn,kn,In)}}function Nt(){for(let Pt=0;Pt<=l;Pt++)for(let Gt=0;Gt<=f;Gt++)H.x=Pt/l,H.y=Gt/f,de.push(H.x,H.y)}}copy(r){return super.copy(r),this.parameters=Object.assign({},r.parameters),this}toJSON(){const r=super.toJSON();return r.path=this.parameters.path.toJSON(),r}static fromJSON(r){return new Wp(new _u[r.path.type]().fromJSON(r.path),r.tubularSegments,r.radius,r.radialSegments,r.closed)}}class Ox extends Fr{constructor(r=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:r},r!==null){const l=[],h=new Set,f=new Rt,g=new Rt;if(r.index!==null){const v=r.attributes.position,A=r.index;let V=r.groups;V.length===0&&(V=[{start:0,count:A.count,materialIndex:0}]);for(let H=0,Z=V.length;H<Z;++H){const ce=V[H],he=ce.start,de=ce.count;for(let Me=he,Je=he+de;Me<Je;Me+=3)for(let mt=0;mt<3;mt++){const pt=A.getX(Me+mt),Nt=A.getX(Me+(mt+1)%3);f.fromBufferAttribute(v,pt),g.fromBufferAttribute(v,Nt),fy(f,g,h)===!0&&(l.push(f.x,f.y,f.z),l.push(g.x,g.y,g.z))}}}else{const v=r.attributes.position;for(let A=0,V=v.count/3;A<V;A++)for(let H=0;H<3;H++){const Z=3*A+H,ce=3*A+(H+1)%3;f.fromBufferAttribute(v,Z),g.fromBufferAttribute(v,ce),fy(f,g,h)===!0&&(l.push(f.x,f.y,f.z),l.push(g.x,g.y,g.z))}}this.setAttribute("position",new qi(l,3))}}copy(r){return super.copy(r),this.parameters=Object.assign({},r.parameters),this}}function fy(j,r,l){const h=`${j.x},${j.y},${j.z}-${r.x},${r.y},${r.z}`,f=`${r.x},${r.y},${r.z}-${j.x},${j.y},${j.z}`;return l.has(h)===!0||l.has(f)===!0?!1:(l.add(h),l.add(f),!0)}var py=Object.freeze({__proto__:null,BoxGeometry:qm,CapsuleGeometry:vf,CircleGeometry:xf,ConeGeometry:md,CylinderGeometry:_f,DodecahedronGeometry:xc,EdgesGeometry:J0,ExtrudeGeometry:Ch,IcosahedronGeometry:hy,LatheGeometry:Yu,OctahedronGeometry:Ef,PlaneGeometry:Vp,PolyhedronGeometry:gd,RingGeometry:Gp,ShapeGeometry:Af,SphereGeometry:Cf,TetrahedronGeometry:gg,TorusGeometry:yg,TorusKnotGeometry:dy,TubeGeometry:Wp,WireframeGeometry:Ox});class Fx extends null{constructor(r){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new ar(0),this.transparent=!0,this.fog=!0,this.setValues(r)}copy(r){return super.copy(r),this.color.copy(r.color),this.fog=r.fog,this}}class my extends null{constructor(r){super(r),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Bx extends null{constructor(r){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new ar(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 ar(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xa,this.normalScale=new oi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new us,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(r)}copy(r){return super.copy(r),this.defines={STANDARD:""},this.color.copy(r.color),this.roughness=r.roughness,this.metalness=r.metalness,this.map=r.map,this.lightMap=r.lightMap,this.lightMapIntensity=r.lightMapIntensity,this.aoMap=r.aoMap,this.aoMapIntensity=r.aoMapIntensity,this.emissive.copy(r.emissive),this.emissiveMap=r.emissiveMap,this.emissiveIntensity=r.emissiveIntensity,this.bumpMap=r.bumpMap,this.bumpScale=r.bumpScale,this.normalMap=r.normalMap,this.normalMapType=r.normalMapType,this.normalScale.copy(r.normalScale),this.displacementMap=r.displacementMap,this.displacementScale=r.displacementScale,this.displacementBias=r.displacementBias,this.roughnessMap=r.roughnessMap,this.metalnessMap=r.metalnessMap,this.alphaMap=r.alphaMap,this.envMap=r.envMap,this.envMapRotation.copy(r.envMapRotation),this.envMapIntensity=r.envMapIntensity,this.wireframe=r.wireframe,this.wireframeLinewidth=r.wireframeLinewidth,this.wireframeLinecap=r.wireframeLinecap,this.wireframeLinejoin=r.wireframeLinejoin,this.flatShading=r.flatShading,this.fog=r.fog,this}}class Ux extends null{constructor(r){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 oi(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Br(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(l){this.ior=(1+.4*l)/(1-.4*l)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ar(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 ar(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ar(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(r)}get anisotropy(){return this._anisotropy}set anisotropy(r){this._anisotropy>0!=r>0&&this.version++,this._anisotropy=r}get clearcoat(){return this._clearcoat}set clearcoat(r){this._clearcoat>0!=r>0&&this.version++,this._clearcoat=r}get iridescence(){return this._iridescence}set iridescence(r){this._iridescence>0!=r>0&&this.version++,this._iridescence=r}get dispersion(){return this._dispersion}set dispersion(r){this._dispersion>0!=r>0&&this.version++,this._dispersion=r}get sheen(){return this._sheen}set sheen(r){this._sheen>0!=r>0&&this.version++,this._sheen=r}get transmission(){return this._transmission}set transmission(r){this._transmission>0!=r>0&&this.version++,this._transmission=r}copy(r){return super.copy(r),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=r.anisotropy,this.anisotropyRotation=r.anisotropyRotation,this.anisotropyMap=r.anisotropyMap,this.clearcoat=r.clearcoat,this.clearcoatMap=r.clearcoatMap,this.clearcoatRoughness=r.clearcoatRoughness,this.clearcoatRoughnessMap=r.clearcoatRoughnessMap,this.clearcoatNormalMap=r.clearcoatNormalMap,this.clearcoatNormalScale.copy(r.clearcoatNormalScale),this.dispersion=r.dispersion,this.ior=r.ior,this.iridescence=r.iridescence,this.iridescenceMap=r.iridescenceMap,this.iridescenceIOR=r.iridescenceIOR,this.iridescenceThicknessRange=[...r.iridescenceThicknessRange],this.iridescenceThicknessMap=r.iridescenceThicknessMap,this.sheen=r.sheen,this.sheenColor.copy(r.sheenColor),this.sheenColorMap=r.sheenColorMap,this.sheenRoughness=r.sheenRoughness,this.sheenRoughnessMap=r.sheenRoughnessMap,this.transmission=r.transmission,this.transmissionMap=r.transmissionMap,this.thickness=r.thickness,this.thicknessMap=r.thicknessMap,this.attenuationDistance=r.attenuationDistance,this.attenuationColor.copy(r.attenuationColor),this.specularIntensity=r.specularIntensity,this.specularIntensityMap=r.specularIntensityMap,this.specularColor.copy(r.specularColor),this.specularColorMap=r.specularColorMap,this}}class gy extends No{constructor(r){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ar(16777215),this.specular=new ar(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ar(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xa,this.normalScale=new oi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new us,this.combine=Et,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(r)}copy(r){return super.copy(r),this.color.copy(r.color),this.specular.copy(r.specular),this.shininess=r.shininess,this.map=r.map,this.lightMap=r.lightMap,this.lightMapIntensity=r.lightMapIntensity,this.aoMap=r.aoMap,this.aoMapIntensity=r.aoMapIntensity,this.emissive.copy(r.emissive),this.emissiveMap=r.emissiveMap,this.emissiveIntensity=r.emissiveIntensity,this.bumpMap=r.bumpMap,this.bumpScale=r.bumpScale,this.normalMap=r.normalMap,this.normalMapType=r.normalMapType,this.normalScale.copy(r.normalScale),this.displacementMap=r.displacementMap,this.displacementScale=r.displacementScale,this.displacementBias=r.displacementBias,this.specularMap=r.specularMap,this.alphaMap=r.alphaMap,this.envMap=r.envMap,this.envMapRotation.copy(r.envMapRotation),this.combine=r.combine,this.reflectivity=r.reflectivity,this.refractionRatio=r.refractionRatio,this.wireframe=r.wireframe,this.wireframeLinewidth=r.wireframeLinewidth,this.wireframeLinecap=r.wireframeLinecap,this.wireframeLinejoin=r.wireframeLinejoin,this.flatShading=r.flatShading,this.fog=r.fog,this}}class yy extends null{constructor(r){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ar(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ar(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xa,this.normalScale=new oi(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(r)}copy(r){return super.copy(r),this.color.copy(r.color),this.map=r.map,this.gradientMap=r.gradientMap,this.lightMap=r.lightMap,this.lightMapIntensity=r.lightMapIntensity,this.aoMap=r.aoMap,this.aoMapIntensity=r.aoMapIntensity,this.emissive.copy(r.emissive),this.emissiveMap=r.emissiveMap,this.emissiveIntensity=r.emissiveIntensity,this.bumpMap=r.bumpMap,this.bumpScale=r.bumpScale,this.normalMap=r.normalMap,this.normalMapType=r.normalMapType,this.normalScale.copy(r.normalScale),this.displacementMap=r.displacementMap,this.displacementScale=r.displacementScale,this.displacementBias=r.displacementBias,this.alphaMap=r.alphaMap,this.wireframe=r.wireframe,this.wireframeLinewidth=r.wireframeLinewidth,this.wireframeLinecap=r.wireframeLinecap,this.wireframeLinejoin=r.wireframeLinejoin,this.fog=r.fog,this}}class wd extends null{constructor(r){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xa,this.normalScale=new oi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(r)}copy(r){return super.copy(r),this.bumpMap=r.bumpMap,this.bumpScale=r.bumpScale,this.normalMap=r.normalMap,this.normalMapType=r.normalMapType,this.normalScale.copy(r.normalScale),this.displacementMap=r.displacementMap,this.displacementScale=r.displacementScale,this.displacementBias=r.displacementBias,this.wireframe=r.wireframe,this.wireframeLinewidth=r.wireframeLinewidth,this.flatShading=r.flatShading,this}}class kx extends null{constructor(r){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ar(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ar(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xa,this.normalScale=new oi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new us,this.combine=Et,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(r)}copy(r){return super.copy(r),this.color.copy(r.color),this.map=r.map,this.lightMap=r.lightMap,this.lightMapIntensity=r.lightMapIntensity,this.aoMap=r.aoMap,this.aoMapIntensity=r.aoMapIntensity,this.emissive.copy(r.emissive),this.emissiveMap=r.emissiveMap,this.emissiveIntensity=r.emissiveIntensity,this.bumpMap=r.bumpMap,this.bumpScale=r.bumpScale,this.normalMap=r.normalMap,this.normalMapType=r.normalMapType,this.normalScale.copy(r.normalScale),this.displacementMap=r.displacementMap,this.displacementScale=r.displacementScale,this.displacementBias=r.displacementBias,this.specularMap=r.specularMap,this.alphaMap=r.alphaMap,this.envMap=r.envMap,this.envMapRotation.copy(r.envMapRotation),this.combine=r.combine,this.reflectivity=r.reflectivity,this.refractionRatio=r.refractionRatio,this.wireframe=r.wireframe,this.wireframeLinewidth=r.wireframeLinewidth,this.wireframeLinecap=r.wireframeLinecap,this.wireframeLinejoin=r.wireframeLinejoin,this.flatShading=r.flatShading,this.fog=r.fog,this}}class zx extends null{constructor(r){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=rp,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(r)}copy(r){return super.copy(r),this.depthPacking=r.depthPacking,this.map=r.map,this.alphaMap=r.alphaMap,this.displacementMap=r.displacementMap,this.displacementScale=r.displacementScale,this.displacementBias=r.displacementBias,this.wireframe=r.wireframe,this.wireframeLinewidth=r.wireframeLinewidth,this}}class vy extends null{constructor(r){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(r)}copy(r){return super.copy(r),this.map=r.map,this.alphaMap=r.alphaMap,this.displacementMap=r.displacementMap,this.displacementScale=r.displacementScale,this.displacementBias=r.displacementBias,this}}class xy extends null{constructor(r){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ar(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xa,this.normalScale=new oi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(r)}copy(r){return super.copy(r),this.defines={MATCAP:""},this.color.copy(r.color),this.matcap=r.matcap,this.map=r.map,this.bumpMap=r.bumpMap,this.bumpScale=r.bumpScale,this.normalMap=r.normalMap,this.normalMapType=r.normalMapType,this.normalScale.copy(r.normalScale),this.displacementMap=r.displacementMap,this.displacementScale=r.displacementScale,this.displacementBias=r.displacementBias,this.alphaMap=r.alphaMap,this.wireframe=r.wireframe,this.wireframeLinewidth=r.wireframeLinewidth,this.flatShading=r.flatShading,this.fog=r.fog,this}}class $1 extends null{constructor(r){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(r)}copy(r){return super.copy(r),this.scale=r.scale,this.dashSize=r.dashSize,this.gapSize=r.gapSize,this}}function Md(j,r){return!j||j.constructor===r?j:typeof r.BYTES_PER_ELEMENT=="number"?new r(j):Array.prototype.slice.call(j)}function j1(j){return ArrayBuffer.isView(j)&&!(j instanceof DataView)}function Hp(j){function r(f,g){return j[f]-j[g]}const l=j.length,h=new Array(l);for(let f=0;f!==l;++f)h[f]=f;return h.sort(r),h}function _y(j,r,l){const h=j.length,f=new j.constructor(h);for(let g=0,v=0;v!==h;++g){const A=l[g]*r;for(let V=0;V!==r;++V)f[v++]=j[A+V]}return f}function vg(j,r,l,h){let f=1,g=j[0];for(;g!==void 0&&g[h]===void 0;)g=j[f++];if(g===void 0)return;let v=g[h];if(v!==void 0)if(Array.isArray(v))do v=g[h],v!==void 0&&(r.push(g.time),l.push(...v)),g=j[f++];while(g!==void 0);else if(v.toArray!==void 0)do v=g[h],v!==void 0&&(r.push(g.time),v.toArray(l,l.length)),g=j[f++];while(g!==void 0);else do v=g[h],v!==void 0&&(r.push(g.time),l.push(v)),g=j[f++];while(g!==void 0)}function X1(j,r,l,h,f=30){const g=j.clone();g.name=r;const v=[];for(let V=0;V<g.tracks.length;++V){const H=g.tracks[V],Z=H.getValueSize(),ce=[],he=[];for(let de=0;de<H.times.length;++de){const Me=H.times[de]*f;if(!(Me<l||Me>=h)){ce.push(H.times[de]);for(let Je=0;Je<Z;++Je)he.push(H.values[de*Z+Je])}}ce.length!==0&&(H.times=Md(ce,H.times.constructor),H.values=Md(he,H.values.constructor),v.push(H))}g.tracks=v;let A=1/0;for(let V=0;V<g.tracks.length;++V)A>g.tracks[V].times[0]&&(A=g.tracks[V].times[0]);for(let V=0;V<g.tracks.length;++V)g.tracks[V].shift(-1*A);return g.resetDuration(),g}function $c(j,r=0,l=j,h=30){h<=0&&(h=30);const f=l.tracks.length,g=r/h;for(let v=0;v<f;++v){const A=l.tracks[v],V=A.ValueTypeName;if(V==="bool"||V==="string")continue;const H=j.tracks.find(function(pt){return pt.name===A.name&&pt.ValueTypeName===V});if(H===void 0)continue;let Z=0;const ce=A.getValueSize();A.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(Z=ce/3);let he=0;const de=H.getValueSize();H.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(he=de/3);const Me=A.times.length-1;let Je;if(g<=A.times[0]){const pt=Z,Nt=ce-Z;Je=A.values.slice(pt,Nt)}else if(g>=A.times[Me]){const pt=Me*ce+Z,Nt=pt+ce-Z;Je=A.values.slice(pt,Nt)}else{const pt=A.createInterpolant(),Nt=Z,Pt=ce-Z;pt.evaluate(g),Je=pt.resultBuffer.slice(Nt,Pt)}V==="quaternion"&&new _l().fromArray(Je).normalize().conjugate().toArray(Je);const mt=H.times.length;for(let pt=0;pt<mt;++pt){const Nt=pt*de+he;if(V==="quaternion")_l.multiplyQuaternionsFlat(H.values,Nt,Je,0,H.values,Nt);else{const Pt=de-he*2;for(let Gt=0;Gt<Pt;++Gt)H.values[Nt+Gt]-=Je[Gt]}}}return j.blendMode=Lc,j}class $p{static convertArray(r,l){return Md(r,l)}static isTypedArray(r){return j1(r)}static getKeyframeOrder(r){return Hp(r)}static sortedArray(r,l,h){return _y(r,l,h)}static flattenJSON(r,l,h,f){vg(r,l,h,f)}static subclip(r,l,h,f,g=30){return X1(r,l,h,f,g)}static makeClipAdditive(r,l=0,h=r,f=30){return $c(r,l,h,f)}}class jp{constructor(r,l,h,f){this.parameterPositions=r,this._cachedIndex=0,this.resultBuffer=f!==void 0?f:new l.constructor(h),this.sampleValues=l,this.valueSize=h,this.settings=null,this.DefaultSettings_={}}evaluate(r){const l=this.parameterPositions;let h=this._cachedIndex,f=l[h],g=l[h-1];e:{t:{let v;n:{i:if(!(r<f)){for(let A=h+2;;){if(f===void 0){if(r<g)break i;return h=l.length,this._cachedIndex=h,this.copySampleValue_(h-1)}if(h===A)break;if(g=f,f=l[++h],r<f)break t}v=l.length;break n}if(!(r>=g)){const A=l[1];r<A&&(h=2,g=A);for(let V=h-2;;){if(g===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(h===V)break;if(f=g,g=l[--h-1],r>=g)break t}v=h,h=0;break n}break e}for(;h<v;){const A=h+v>>>1;r<l[A]?v=A:h=A+1}if(f=l[h],g=l[h-1],g===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(f===void 0)return h=l.length,this._cachedIndex=h,this.copySampleValue_(h-1)}this._cachedIndex=h,this.intervalChanged_(h,g,f)}return this.interpolate_(h,g,r,f)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(r){const l=this.resultBuffer,h=this.sampleValues,f=this.valueSize,g=r*f;for(let v=0;v!==f;++v)l[v]=h[g+v];return l}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class xg extends jp{constructor(r,l,h,f){super(r,l,h,f),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ha,endingEnd:ha}}intervalChanged_(r,l,h){const f=this.parameterPositions;let g=r-2,v=r+1,A=f[g],V=f[v];if(A===void 0)switch(this.getSettings_().endingStart){case Ba:g=r,A=2*l-h;break;case al:g=f.length-2,A=l+f[g]-f[g+1];break;default:g=r,A=h}if(V===void 0)switch(this.getSettings_().endingEnd){case Ba:v=r,V=2*h-l;break;case al:v=1,V=h+f[1]-f[0];break;default:v=r-1,V=l}const H=(h-l)*.5,Z=this.valueSize;this._weightPrev=H/(l-A),this._weightNext=H/(V-h),this._offsetPrev=g*Z,this._offsetNext=v*Z}interpolate_(r,l,h,f){const g=this.resultBuffer,v=this.sampleValues,A=this.valueSize,V=r*A,H=V-A,Z=this._offsetPrev,ce=this._offsetNext,he=this._weightPrev,de=this._weightNext,Me=(h-l)/(f-l),Je=Me*Me,mt=Je*Me,pt=-he*mt+2*he*Je-he*Me,Nt=(1+he)*mt+(-1.5-2*he)*Je+(-.5+he)*Me+1,Pt=(-1-de)*mt+(1.5+de)*Je+.5*Me,Gt=de*mt-de*Je;for(let gn=0;gn!==A;++gn)g[gn]=pt*v[Z+gn]+Nt*v[H+gn]+Pt*v[V+gn]+Gt*v[ce+gn];return g}}class Vx extends jp{constructor(r,l,h,f){super(r,l,h,f)}interpolate_(r,l,h,f){const g=this.resultBuffer,v=this.sampleValues,A=this.valueSize,V=r*A,H=V-A,Z=(h-l)/(f-l),ce=1-Z;for(let he=0;he!==A;++he)g[he]=v[H+he]*ce+v[V+he]*Z;return g}}class _g extends jp{constructor(r,l,h,f){super(r,l,h,f)}interpolate_(r){return this.copySampleValue_(r-1)}}class wl{constructor(r,l,h,f){if(r===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(l===void 0||l.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+r);this.name=r,this.times=Md(l,this.TimeBufferType),this.values=Md(h,this.ValueBufferType),this.setInterpolation(f||this.DefaultInterpolation)}static toJSON(r){const l=r.constructor;let h;if(l.toJSON!==this.toJSON)h=l.toJSON(r);else{h={name:r.name,times:Md(r.times,Array),values:Md(r.values,Array)};const f=r.getInterpolation();f!==r.DefaultInterpolation&&(h.interpolation=f)}return h.type=r.ValueTypeName,h}InterpolantFactoryMethodDiscrete(r){return new _g(this.times,this.values,this.getValueSize(),r)}InterpolantFactoryMethodLinear(r){return new Vx(this.times,this.values,this.getValueSize(),r)}InterpolantFactoryMethodSmooth(r){return new xg(this.times,this.values,this.getValueSize(),r)}setInterpolation(r){let l;switch(r){case Co:l=this.InterpolantFactoryMethodDiscrete;break;case sl:l=this.InterpolantFactoryMethodLinear;break;case ol:l=this.InterpolantFactoryMethodSmooth;break}if(l===void 0){const h="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(r!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(h);return _r("KeyframeTrack:",h),this}return this.createInterpolant=l,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Co;case this.InterpolantFactoryMethodLinear:return sl;case this.InterpolantFactoryMethodSmooth:return ol}}getValueSize(){return this.values.length/this.times.length}shift(r){if(r!==0){const l=this.times;for(let h=0,f=l.length;h!==f;++h)l[h]+=r}return this}scale(r){if(r!==1){const l=this.times;for(let h=0,f=l.length;h!==f;++h)l[h]*=r}return this}trim(r,l){const h=this.times,f=h.length;let g=0,v=f-1;for(;g!==f&&h[g]<r;)++g;for(;v!==-1&&h[v]>l;)--v;if(++v,g!==0||v!==f){g>=v&&(v=Math.max(v,1),g=v-1);const A=this.getValueSize();this.times=h.slice(g,v),this.values=this.values.slice(g*A,v*A)}return this}validate(){let r=!0;const l=this.getValueSize();l-Math.floor(l)!==0&&(Xs("KeyframeTrack: Invalid value size in track.",this),r=!1);const h=this.times,f=this.values,g=h.length;g===0&&(Xs("KeyframeTrack: Track is empty.",this),r=!1);let v=null;for(let A=0;A!==g;A++){const V=h[A];if(typeof V=="number"&&isNaN(V)){Xs("KeyframeTrack: Time is not a valid number.",this,A,V),r=!1;break}if(v!==null&&v>V){Xs("KeyframeTrack: Out of order keys.",this,A,V,v),r=!1;break}v=V}if(f!==void 0&&j1(f))for(let A=0,V=f.length;A!==V;++A){const H=f[A];if(isNaN(H)){Xs("KeyframeTrack: Value is not a valid number.",this,A,H),r=!1;break}}return r}optimize(){const r=this.times.slice(),l=this.values.slice(),h=this.getValueSize(),f=this.getInterpolation()===ol,g=r.length-1;let v=1;for(let A=1;A<g;++A){let V=!1;const H=r[A],Z=r[A+1];if(H!==Z&&(A!==1||H!==r[0]))if(f)V=!0;else{const ce=A*h,he=ce-h,de=ce+h;for(let Me=0;Me!==h;++Me){const Je=l[ce+Me];if(Je!==l[he+Me]||Je!==l[de+Me]){V=!0;break}}}if(V){if(A!==v){r[v]=r[A];const ce=A*h,he=v*h;for(let de=0;de!==h;++de)l[he+de]=l[ce+de]}++v}}if(g>0){r[v]=r[g];for(let A=g*h,V=v*h,H=0;H!==h;++H)l[V+H]=l[A+H];++v}return v!==r.length?(this.times=r.slice(0,v),this.values=l.slice(0,v*h)):(this.times=r,this.values=l),this}clone(){const r=this.times.slice(),l=this.values.slice(),h=this.constructor,f=new h(this.name,r,l);return f.createInterpolant=this.createInterpolant,f}}wl.prototype.ValueTypeName="",wl.prototype.TimeBufferType=Float32Array,wl.prototype.ValueBufferType=Float32Array,wl.prototype.DefaultInterpolation=sl;class Zu extends wl{constructor(r,l,h){super(r,l,h)}}Zu.prototype.ValueTypeName="bool",Zu.prototype.ValueBufferType=Array,Zu.prototype.DefaultInterpolation=Co,Zu.prototype.InterpolantFactoryMethodLinear=void 0,Zu.prototype.InterpolantFactoryMethodSmooth=void 0;class Xp extends wl{constructor(r,l,h,f){super(r,l,h,f)}}Xp.prototype.ValueTypeName="color";class bg extends wl{constructor(r,l,h,f){super(r,l,h,f)}}bg.prototype.ValueTypeName="number";class q1 extends jp{constructor(r,l,h,f){super(r,l,h,f)}interpolate_(r,l,h,f){const g=this.resultBuffer,v=this.sampleValues,A=this.valueSize,V=(h-l)/(f-l);let H=r*A;for(let Z=H+A;H!==Z;H+=4)_l.slerpFlat(g,0,v,H-A,v,H,V);return g}}class wc extends wl{constructor(r,l,h,f){super(r,l,h,f)}InterpolantFactoryMethodLinear(r){return new q1(this.times,this.values,this.getValueSize(),r)}}wc.prototype.ValueTypeName="quaternion",wc.prototype.InterpolantFactoryMethodSmooth=void 0;class Sd extends wl{constructor(r,l,h){super(r,l,h)}}Sd.prototype.ValueTypeName="string",Sd.prototype.ValueBufferType=Array,Sd.prototype.DefaultInterpolation=Co,Sd.prototype.InterpolantFactoryMethodLinear=void 0,Sd.prototype.InterpolantFactoryMethodSmooth=void 0;class wg extends wl{constructor(r,l,h,f){super(r,l,h,f)}}wg.prototype.ValueTypeName="vector";class Rf{constructor(r="",l=-1,h=[],f=wo){this.name=r,this.tracks=h,this.duration=l,this.blendMode=f,this.uuid=El(),this.userData={},this.duration<0&&this.resetDuration()}static parse(r){const l=[],h=r.tracks,f=1/(r.fps||1);for(let v=0,A=h.length;v!==A;++v)l.push(Y1(h[v]).scale(f));const g=new this(r.name,r.duration,l,r.blendMode);return g.uuid=r.uuid,g.userData=JSON.parse(r.userData||"{}"),g}static toJSON(r){const l=[],h=r.tracks,f={name:r.name,duration:r.duration,tracks:l,uuid:r.uuid,blendMode:r.blendMode,userData:JSON.stringify(r.userData)};for(let g=0,v=h.length;g!==v;++g)l.push(wl.toJSON(h[g]));return f}static CreateFromMorphTargetSequence(r,l,h,f){const g=l.length,v=[];for(let A=0;A<g;A++){let V=[],H=[];V.push((A+g-1)%g,A,(A+1)%g),H.push(0,1,0);const Z=Hp(V);V=_y(V,1,Z),H=_y(H,1,Z),!f&&V[0]===0&&(V.push(g),H.push(H[0])),v.push(new bg(".morphTargetInfluences["+l[A].name+"]",V,H).scale(1/h))}return new this(r,-1,v)}static findByName(r,l){let h=r;if(!Array.isArray(r)){const f=r;h=f.geometry&&f.geometry.animations||f.animations}for(let f=0;f<h.length;f++)if(h[f].name===l)return h[f];return null}static CreateClipsFromMorphTargetSequences(r,l,h){const f={},g=/^([\w-]*?)([\d]+)$/;for(let A=0,V=r.length;A<V;A++){const H=r[A],Z=H.name.match(g);if(Z&&Z.length>1){const ce=Z[1];let he=f[ce];he||(f[ce]=he=[]),he.push(H)}}const v=[];for(const A in f)v.push(this.CreateFromMorphTargetSequence(A,f[A],l,h));return v}static parseAnimation(r,l){if(_r("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!r)return Xs("AnimationClip: No animation in JSONLoader data."),null;const h=function(ce,he,de,Me,Je){if(de.length!==0){const mt=[],pt=[];vg(de,mt,pt,Me),mt.length!==0&&Je.push(new ce(he,mt,pt))}},f=[],g=r.name||"default",v=r.fps||30,A=r.blendMode;let V=r.length||-1;const H=r.hierarchy||[];for(let ce=0;ce<H.length;ce++){const he=H[ce].keys;if(!(!he||he.length===0))if(he[0].morphTargets){const de={};let Me;for(Me=0;Me<he.length;Me++)if(he[Me].morphTargets)for(let Je=0;Je<he[Me].morphTargets.length;Je++)de[he[Me].morphTargets[Je]]=-1;for(const Je in de){const mt=[],pt=[];for(let Nt=0;Nt!==he[Me].morphTargets.length;++Nt){const Pt=he[Me];mt.push(Pt.time),pt.push(Pt.morphTarget===Je?1:0)}f.push(new bg(".morphTargetInfluence["+Je+"]",mt,pt))}V=de.length*v}else{const de=".bones["+l[ce].name+"]";h(wg,de+".position",he,"pos",f),h(wc,de+".quaternion",he,"rot",f),h(wg,de+".scale",he,"scl",f)}}return f.length===0?null:new this(g,V,f,A)}resetDuration(){const r=this.tracks;let l=0;for(let h=0,f=r.length;h!==f;++h){const g=this.tracks[h];l=Math.max(l,g.times[g.times.length-1])}return this.duration=l,this}trim(){for(let r=0;r<this.tracks.length;r++)this.tracks[r].trim(0,this.duration);return this}validate(){let r=!0;for(let l=0;l<this.tracks.length;l++)r=r&&this.tracks[l].validate();return r}optimize(){for(let r=0;r<this.tracks.length;r++)this.tracks[r].optimize();return this}clone(){const r=[];for(let h=0;h<this.tracks.length;h++)r.push(this.tracks[h].clone());const l=new this.constructor(this.name,this.duration,r,this.blendMode);return l.userData=JSON.parse(JSON.stringify(this.userData)),l}toJSON(){return this.constructor.toJSON(this)}}function Ku(j){switch(j.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return bg;case"vector":case"vector2":case"vector3":case"vector4":return wg;case"color":return Xp;case"quaternion":return wc;case"bool":case"boolean":return Zu;case"string":return Sd}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+j)}function Y1(j){if(j.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const r=Ku(j.type);if(j.times===void 0){const l=[],h=[];vg(j.keys,l,h,"value"),j.times=l,j.values=h}return r.parse!==void 0?r.parse(j):new r(j.name,j.times,j.values,j.interpolation)}const Ml={enabled:!1,files:{},add:function(j,r){this.enabled!==!1&&(this.files[j]=r)},get:function(j){if(this.enabled!==!1)return this.files[j]},remove:function(j){delete this.files[j]},clear:function(){this.files={}}};class Z1{constructor(r,l,h){const f=this;let g=!1,v=0,A=0,V;const H=[];this.onStart=void 0,this.onLoad=r,this.onProgress=l,this.onError=h,this._abortController=null,this.itemStart=function(Z){A++,g===!1&&f.onStart!==void 0&&f.onStart(Z,v,A),g=!0},this.itemEnd=function(Z){v++,f.onProgress!==void 0&&f.onProgress(Z,v,A),v===A&&(g=!1,f.onLoad!==void 0&&f.onLoad())},this.itemError=function(Z){f.onError!==void 0&&f.onError(Z)},this.resolveURL=function(Z){return V?V(Z):Z},this.setURLModifier=function(Z){return V=Z,this},this.addHandler=function(Z,ce){return H.push(Z,ce),this},this.removeHandler=function(Z){const ce=H.indexOf(Z);return ce!==-1&&H.splice(ce,2),this},this.getHandler=function(Z){for(let ce=0,he=H.length;ce<he;ce+=2){const de=H[ce],Me=H[ce+1];if(de.global&&(de.lastIndex=0),de.test(Z))return Me}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const xE=new Z1;class Nf{constructor(r){this.manager=r!==void 0?r:xE,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(r,l){const h=this;return new Promise(function(f,g){h.load(r,f,l,g)})}parse(){}setCrossOrigin(r){return this.crossOrigin=r,this}setWithCredentials(r){return this.withCredentials=r,this}setPath(r){return this.path=r,this}setResourcePath(r){return this.resourcePath=r,this}setRequestHeader(r){return this.requestHeader=r,this}abort(){return this}}Nf.DEFAULT_MATERIAL_NAME="__DEFAULT";const Mc={};class _E extends null{constructor(r,l){super(r),this.response=l}}class Td extends null{constructor(r){super(r),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(r,l,h,f){r===void 0&&(r=""),this.path!==void 0&&(r=this.path+r),r=this.manager.resolveURL(r);const g=Ml.get(`file:${r}`);if(g!==void 0)return this.manager.itemStart(r),setTimeout(()=>{l&&l(g),this.manager.itemEnd(r)},0),g;if(Mc[r]!==void 0){Mc[r].push({onLoad:l,onProgress:h,onError:f});return}Mc[r]=[],Mc[r].push({onLoad:l,onProgress:h,onError:f});const v=new Request(r,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),A=this.mimeType,V=this.responseType;fetch(v).then(H=>{if(H.status===200||H.status===0){if(H.status===0&&_r("FileLoader: HTTP Status 0 received."),typeof ReadableStream=="undefined"||H.body===void 0||H.body.getReader===void 0)return H;const Z=Mc[r],ce=H.body.getReader(),he=H.headers.get("X-File-Size")||H.headers.get("Content-Length"),de=he?parseInt(he):0,Me=de!==0;let Je=0;const mt=new ReadableStream({start(pt){Nt();function Nt(){ce.read().then(({done:Pt,value:Gt})=>{if(Pt)pt.close();else{Je+=Gt.byteLength;const gn=new ProgressEvent("progress",{lengthComputable:Me,loaded:Je,total:de});for(let Sn=0,kn=Z.length;Sn<kn;Sn++){const In=Z[Sn];In.onProgress&&In.onProgress(gn)}pt.enqueue(Gt),Nt()}},Pt=>{pt.error(Pt)})}}});return new Response(mt)}else throw new _E(`fetch for "${H.url}" responded with ${H.status}: ${H.statusText}`,H)}).then(H=>{switch(V){case"arraybuffer":return H.arrayBuffer();case"blob":return H.blob();case"document":return H.text().then(Z=>new DOMParser().parseFromString(Z,A));case"json":return H.json();default:if(A==="")return H.text();{const ce=/charset="?([^;"\s]*)"?/i.exec(A),he=ce&&ce[1]?ce[1].toLowerCase():void 0,de=new TextDecoder(he);return H.arrayBuffer().then(Me=>de.decode(Me))}}}).then(H=>{Ml.add(`file:${r}`,H);const Z=Mc[r];delete Mc[r];for(let ce=0,he=Z.length;ce<he;ce++){const de=Z[ce];de.onLoad&&de.onLoad(H)}}).catch(H=>{const Z=Mc[r];if(Z===void 0)throw this.manager.itemError(r),H;delete Mc[r];for(let ce=0,he=Z.length;ce<he;ce++){const de=Z[ce];de.onError&&de.onError(H)}this.manager.itemError(r)}).finally(()=>{this.manager.itemEnd(r)}),this.manager.itemStart(r)}setResponseType(r){return this.responseType=r,this}setMimeType(r){return this.mimeType=r,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class bE extends null{constructor(r){super(r)}load(r,l,h,f){const g=this,v=new Td(this.manager);v.setPath(this.path),v.setRequestHeader(this.requestHeader),v.setWithCredentials(this.withCredentials),v.load(r,function(A){try{l(g.parse(JSON.parse(A)))}catch(V){f?f(V):Xs(V),g.manager.itemError(r)}},h,f)}parse(r){const l=[];for(let h=0;h<r.length;h++){const f=Rf.parse(r[h]);l.push(f)}return l}}class Pf extends null{constructor(r){super(r)}load(r,l,h,f){const g=this,v=[],A=new K0,V=new Td(this.manager);V.setPath(this.path),V.setResponseType("arraybuffer"),V.setRequestHeader(this.requestHeader),V.setWithCredentials(g.withCredentials);let H=0;function Z(ce){V.load(r[ce],function(he){const de=g.parse(he,!0);v[ce]={width:de.width,height:de.height,format:de.format,mipmaps:de.mipmaps},H+=1,H===6&&(de.mipmapCount===1&&(A.minFilter=Rn),A.image=v,A.format=de.format,A.needsUpdate=!0,l&&l(A))},h,f)}if(Array.isArray(r))for(let ce=0,he=r.length;ce<he;++ce)Z(ce);else V.load(r,function(ce){const he=g.parse(ce,!0);if(he.isCubemap){const de=he.mipmaps.length/he.mipmapCount;for(let Me=0;Me<de;Me++){v[Me]={mipmaps:[]};for(let Je=0;Je<he.mipmapCount;Je++)v[Me].mipmaps.push(he.mipmaps[Me*he.mipmapCount+Je]),v[Me].format=he.format,v[Me].width=he.width,v[Me].height=he.height}A.image=v}else A.image.width=he.width,A.image.height=he.height,A.mipmaps=he.mipmaps;he.mipmapCount===1&&(A.minFilter=Rn),A.format=he.format,A.needsUpdate=!0,l&&l(A)},h,f);return A}}const Ed=new WeakMap;class If extends null{constructor(r){super(r)}load(r,l,h,f){this.path!==void 0&&(r=this.path+r),r=this.manager.resolveURL(r);const g=this,v=Ml.get(`image:${r}`);if(v!==void 0){if(v.complete===!0)g.manager.itemStart(r),setTimeout(function(){l&&l(v),g.manager.itemEnd(r)},0);else{let ce=Ed.get(v);ce===void 0&&(ce=[],Ed.set(v,ce)),ce.push({onLoad:l,onError:f})}return v}const A=uc("img");function V(){Z(),l&&l(this);const ce=Ed.get(this)||[];for(let he=0;he<ce.length;he++){const de=ce[he];de.onLoad&&de.onLoad(this)}Ed.delete(this),g.manager.itemEnd(r)}function H(ce){Z(),f&&f(ce),Ml.remove(`image:${r}`);const he=Ed.get(this)||[];for(let de=0;de<he.length;de++){const Me=he[de];Me.onError&&Me.onError(ce)}Ed.delete(this),g.manager.itemError(r),g.manager.itemEnd(r)}function Z(){A.removeEventListener("load",V,!1),A.removeEventListener("error",H,!1)}return A.addEventListener("load",V,!1),A.addEventListener("error",H,!1),r.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(A.crossOrigin=this.crossOrigin),Ml.add(`image:${r}`,A),g.manager.itemStart(r),A.src=r,A}}class K1 extends null{constructor(r){super(r)}load(r,l,h,f){const g=new pp;g.colorSpace=uo;const v=new If(this.manager);v.setCrossOrigin(this.crossOrigin),v.setPath(this.path);let A=0;function V(H){v.load(r[H],function(Z){g.images[H]=Z,A++,A===6&&(g.needsUpdate=!0,l&&l(g))},void 0,f)}for(let H=0;H<r.length;++H)V(H);return g}}class J1 extends null{constructor(r){super(r)}load(r,l,h,f){const g=this,v=new pu,A=new Td(this.manager);return A.setResponseType("arraybuffer"),A.setRequestHeader(this.requestHeader),A.setPath(this.path),A.setWithCredentials(g.withCredentials),A.load(r,function(V){let H;try{H=g.parse(V)}catch(Z){if(f!==void 0)f(Z);else{Z(Z);return}}H.image!==void 0?v.image=H.image:H.data!==void 0&&(v.image.width=H.width,v.image.height=H.height,v.image.data=H.data),v.wrapS=H.wrapS!==void 0?H.wrapS:$e,v.wrapT=H.wrapT!==void 0?H.wrapT:$e,v.magFilter=H.magFilter!==void 0?H.magFilter:Rn,v.minFilter=H.minFilter!==void 0?H.minFilter:Rn,v.anisotropy=H.anisotropy!==void 0?H.anisotropy:1,H.colorSpace!==void 0&&(v.colorSpace=H.colorSpace),H.flipY!==void 0&&(v.flipY=H.flipY),H.format!==void 0&&(v.format=H.format),H.type!==void 0&&(v.type=H.type),H.mipmaps!==void 0&&(v.mipmaps=H.mipmaps,v.minFilter=Qn),H.mipmapCount===1&&(v.minFilter=Rn),H.generateMipmaps!==void 0&&(v.generateMipmaps=H.generateMipmaps),v.needsUpdate=!0,l&&l(v,H)},h,f),v}}class Gx extends null{constructor(r){super(r)}load(r,l,h,f){const g=new bl,v=new If(this.manager);return v.setCrossOrigin(this.crossOrigin),v.setPath(this.path),v.load(r,function(A){g.image=A,g.needsUpdate=!0,l!==void 0&&l(g)},h,f),g}}class wE extends null{constructor(r,l=1){super(),this.isLight=!0,this.type="Light",this.color=new ar(r),this.intensity=l}dispose(){}copy(r,l){return super.copy(r,l),this.color.copy(r.color),this.intensity=r.intensity,this}toJSON(r){const l=super.toJSON(r);return l.object.color=this.color.getHex(),l.object.intensity=this.intensity,this.groundColor!==void 0&&(l.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(l.object.distance=this.distance),this.angle!==void 0&&(l.object.angle=this.angle),this.decay!==void 0&&(l.object.decay=this.decay),this.penumbra!==void 0&&(l.object.penumbra=this.penumbra),this.shadow!==void 0&&(l.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(l.object.target=this.target.uuid),l}}class Mg extends null{constructor(r,l,h){super(r,h),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_s.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ar(l)}copy(r,l){return super.copy(r,l),this.groundColor.copy(r.groundColor),this}}const Sg=new On,Lf=new Rt,Tg=new Rt;class ME{constructor(r){this.camera=r,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new oi(512,512),this.mapType=Oi,this.map=null,this.mapPass=null,this.matrix=new On,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new X0,this._frameExtents=new oi(1,1),this._viewportCount=1,this._viewports=[new ka(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(r){const l=this.camera,h=this.matrix;Lf.setFromMatrixPosition(r.matrixWorld),l.position.copy(Lf),Tg.setFromMatrixPosition(r.target.matrixWorld),l.lookAt(Tg),l.updateMatrixWorld(),Sg.multiplyMatrices(l.projectionMatrix,l.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Sg,l.coordinateSystem,l.reversedDepth),l.reversedDepth?h.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):h.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),h.multiply(Sg)}getViewport(r){return this._viewports[r]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(r){return this.camera=r.camera.clone(),this.intensity=r.intensity,this.bias=r.bias,this.radius=r.radius,this.autoUpdate=r.autoUpdate,this.needsUpdate=r.needsUpdate,this.normalBias=r.normalBias,this.blurSamples=r.blurSamples,this.mapSize.copy(r.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const r={};return this.intensity!==1&&(r.intensity=this.intensity),this.bias!==0&&(r.bias=this.bias),this.normalBias!==0&&(r.normalBias=this.normalBias),this.radius!==1&&(r.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(r.mapSize=this.mapSize.toArray()),r.camera=this.camera.toJSON(!1).object,delete r.camera.matrix,r}}class Wx extends null{constructor(){super(new dl(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(r){const l=this.camera,h=Vu*2*r.angle*this.focus,f=this.mapSize.width/this.mapSize.height*this.aspect,g=r.distance||l.far;(h!==l.fov||f!==l.aspect||g!==l.far)&&(l.fov=h,l.aspect=f,l.far=g,l.updateProjectionMatrix()),super.updateMatrices(r)}copy(r){return super.copy(r),this.focus=r.focus,this}}class Df extends null{constructor(r,l,h=0,f=Math.PI/3,g=0,v=2){super(r,l),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_s.DEFAULT_UP),this.updateMatrix(),this.target=new _s,this.distance=h,this.angle=f,this.penumbra=g,this.decay=v,this.map=null,this.shadow=new Wx}get power(){return this.intensity*Math.PI}set power(r){this.intensity=r/Math.PI}dispose(){this.shadow.dispose()}copy(r,l){return super.copy(r,l),this.distance=r.distance,this.angle=r.angle,this.penumbra=r.penumbra,this.decay=r.decay,this.target=r.target.clone(),this.shadow=r.shadow.clone(),this}}const Hx=new On,Ad=new Rt,qp=new Rt;class $x extends null{constructor(){super(new dl(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new oi(4,2),this._viewportCount=6,this._viewports=[new ka(2,1,1,1),new ka(0,1,1,1),new ka(3,1,1,1),new ka(1,1,1,1),new ka(3,0,1,1),new ka(1,0,1,1)],this._cubeDirections=[new Rt(1,0,0),new Rt(-1,0,0),new Rt(0,0,1),new Rt(0,0,-1),new Rt(0,1,0),new Rt(0,-1,0)],this._cubeUps=[new Rt(0,1,0),new Rt(0,1,0),new Rt(0,1,0),new Rt(0,1,0),new Rt(0,0,1),new Rt(0,0,-1)]}updateMatrices(r,l=0){const h=this.camera,f=this.matrix,g=r.distance||h.far;g!==h.far&&(h.far=g,h.updateProjectionMatrix()),Ad.setFromMatrixPosition(r.matrixWorld),h.position.copy(Ad),qp.copy(h.position),qp.add(this._cubeDirections[l]),h.up.copy(this._cubeUps[l]),h.lookAt(qp),h.updateMatrixWorld(),f.makeTranslation(-Ad.x,-Ad.y,-Ad.z),Hx.multiplyMatrices(h.projectionMatrix,h.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Hx,h.coordinateSystem,h.reversedDepth)}}class Q1 extends null{constructor(r,l,h=0,f=2){super(r,l),this.isPointLight=!0,this.type="PointLight",this.distance=h,this.decay=f,this.shadow=new $x}get power(){return this.intensity*4*Math.PI}set power(r){this.intensity=r/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(r,l){return super.copy(r,l),this.distance=r.distance,this.decay=r.decay,this.shadow=r.shadow.clone(),this}}class by extends null{constructor(r=-1,l=1,h=1,f=-1,g=.1,v=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=r,this.right=l,this.top=h,this.bottom=f,this.near=g,this.far=v,this.updateProjectionMatrix()}copy(r,l){return super.copy(r,l),this.left=r.left,this.right=r.right,this.top=r.top,this.bottom=r.bottom,this.near=r.near,this.far=r.far,this.zoom=r.zoom,this.view=r.view===null?null:Object.assign({},r.view),this}setViewOffset(r,l,h,f,g,v){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=r,this.view.fullHeight=l,this.view.offsetX=h,this.view.offsetY=f,this.view.width=g,this.view.height=v,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const r=(this.right-this.left)/(2*this.zoom),l=(this.top-this.bottom)/(2*this.zoom),h=(this.right+this.left)/2,f=(this.top+this.bottom)/2;let g=h-r,v=h+r,A=f+l,V=f-l;if(this.view!==null&&this.view.enabled){const H=(this.right-this.left)/this.view.fullWidth/this.zoom,Z=(this.top-this.bottom)/this.view.fullHeight/this.zoom;g+=H*this.view.offsetX,v=g+H*this.view.width,A-=Z*this.view.offsetY,V=A-Z*this.view.height}this.projectionMatrix.makeOrthographic(g,v,A,V,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(r){const l=super.toJSON(r);return l.object.zoom=this.zoom,l.object.left=this.left,l.object.right=this.right,l.object.top=this.top,l.object.bottom=this.bottom,l.object.near=this.near,l.object.far=this.far,this.view!==null&&(l.object.view=Object.assign({},this.view)),l}}class wy extends null{constructor(){super(new by(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class jx extends null{constructor(r,l){super(r,l),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_s.DEFAULT_UP),this.updateMatrix(),this.target=new _s,this.shadow=new wy}dispose(){this.shadow.dispose()}copy(r){return super.copy(r),this.target=r.target.clone(),this.shadow=r.shadow.clone(),this}}class ew extends null{constructor(r,l){super(r,l),this.isAmbientLight=!0,this.type="AmbientLight"}}class tw extends null{constructor(r,l,h=10,f=10){super(r,l),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=h,this.height=f}get power(){return this.intensity*this.width*this.height*Math.PI}set power(r){this.intensity=r/(this.width*this.height*Math.PI)}copy(r){return super.copy(r),this.width=r.width,this.height=r.height,this}toJSON(r){const l=super.toJSON(r);return l.object.width=this.width,l.object.height=this.height,l}}class SE{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let r=0;r<9;r++)this.coefficients.push(new Rt)}set(r){for(let l=0;l<9;l++)this.coefficients[l].copy(r[l]);return this}zero(){for(let r=0;r<9;r++)this.coefficients[r].set(0,0,0);return this}getAt(r,l){const h=r.x,f=r.y,g=r.z,v=this.coefficients;return l.copy(v[0]).multiplyScalar(.282095),l.addScaledVector(v[1],.488603*f),l.addScaledVector(v[2],.488603*g),l.addScaledVector(v[3],.488603*h),l.addScaledVector(v[4],1.092548*(h*f)),l.addScaledVector(v[5],1.092548*(f*g)),l.addScaledVector(v[6],.315392*(3*g*g-1)),l.addScaledVector(v[7],1.092548*(h*g)),l.addScaledVector(v[8],.546274*(h*h-f*f)),l}getIrradianceAt(r,l){const h=r.x,f=r.y,g=r.z,v=this.coefficients;return l.copy(v[0]).multiplyScalar(.886227),l.addScaledVector(v[1],2*.511664*f),l.addScaledVector(v[2],2*.511664*g),l.addScaledVector(v[3],2*.511664*h),l.addScaledVector(v[4],2*.429043*h*f),l.addScaledVector(v[5],2*.429043*f*g),l.addScaledVector(v[6],.743125*g*g-.247708),l.addScaledVector(v[7],2*.429043*h*g),l.addScaledVector(v[8],.429043*(h*h-f*f)),l}add(r){for(let l=0;l<9;l++)this.coefficients[l].add(r.coefficients[l]);return this}addScaledSH(r,l){for(let h=0;h<9;h++)this.coefficients[h].addScaledVector(r.coefficients[h],l);return this}scale(r){for(let l=0;l<9;l++)this.coefficients[l].multiplyScalar(r);return this}lerp(r,l){for(let h=0;h<9;h++)this.coefficients[h].lerp(r.coefficients[h],l);return this}equals(r){for(let l=0;l<9;l++)if(!this.coefficients[l].equals(r.coefficients[l]))return!1;return!0}copy(r){return this.set(r.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(r,l=0){const h=this.coefficients;for(let f=0;f<9;f++)h[f].fromArray(r,l+f*3);return this}toArray(r=[],l=0){const h=this.coefficients;for(let f=0;f<9;f++)h[f].toArray(r,l+f*3);return r}static getBasisAt(r,l){const h=r.x,f=r.y,g=r.z;l[0]=.282095,l[1]=.488603*f,l[2]=.488603*g,l[3]=.488603*h,l[4]=1.092548*h*f,l[5]=1.092548*f*g,l[6]=.315392*(3*g*g-1),l[7]=1.092548*h*g,l[8]=.546274*(h*h-f*f)}}class nw extends null{constructor(r=new SE,l=1){super(void 0,l),this.isLightProbe=!0,this.sh=r}copy(r){return super.copy(r),this.sh.copy(r.sh),this}fromJSON(r){return this.intensity=r.intensity,this.sh.fromArray(r.sh),this}toJSON(r){const l=super.toJSON(r);return l.object.sh=this.sh.toArray(),l}}class Eg extends null{constructor(r){super(r),this.textures={}}load(r,l,h,f){const g=this,v=new Td(g.manager);v.setPath(g.path),v.setRequestHeader(g.requestHeader),v.setWithCredentials(g.withCredentials),v.load(r,function(A){try{l(g.parse(JSON.parse(A)))}catch(V){f?f(V):Xs(V),g.manager.itemError(r)}},h,f)}parse(r){const l=this.textures;function h(g){return l[g]===void 0&&_r("MaterialLoader: Undefined texture",g),l[g]}const f=this.createMaterialFromType(r.type);if(r.uuid!==void 0&&(f.uuid=r.uuid),r.name!==void 0&&(f.name=r.name),r.color!==void 0&&f.color!==void 0&&f.color.setHex(r.color),r.roughness!==void 0&&(f.roughness=r.roughness),r.metalness!==void 0&&(f.metalness=r.metalness),r.sheen!==void 0&&(f.sheen=r.sheen),r.sheenColor!==void 0&&(f.sheenColor=new ar().setHex(r.sheenColor)),r.sheenRoughness!==void 0&&(f.sheenRoughness=r.sheenRoughness),r.emissive!==void 0&&f.emissive!==void 0&&f.emissive.setHex(r.emissive),r.specular!==void 0&&f.specular!==void 0&&f.specular.setHex(r.specular),r.specularIntensity!==void 0&&(f.specularIntensity=r.specularIntensity),r.specularColor!==void 0&&f.specularColor!==void 0&&f.specularColor.setHex(r.specularColor),r.shininess!==void 0&&(f.shininess=r.shininess),r.clearcoat!==void 0&&(f.clearcoat=r.clearcoat),r.clearcoatRoughness!==void 0&&(f.clearcoatRoughness=r.clearcoatRoughness),r.dispersion!==void 0&&(f.dispersion=r.dispersion),r.iridescence!==void 0&&(f.iridescence=r.iridescence),r.iridescenceIOR!==void 0&&(f.iridescenceIOR=r.iridescenceIOR),r.iridescenceThicknessRange!==void 0&&(f.iridescenceThicknessRange=r.iridescenceThicknessRange),r.transmission!==void 0&&(f.transmission=r.transmission),r.thickness!==void 0&&(f.thickness=r.thickness),r.attenuationDistance!==void 0&&(f.attenuationDistance=r.attenuationDistance),r.attenuationColor!==void 0&&f.attenuationColor!==void 0&&f.attenuationColor.setHex(r.attenuationColor),r.anisotropy!==void 0&&(f.anisotropy=r.anisotropy),r.anisotropyRotation!==void 0&&(f.anisotropyRotation=r.anisotropyRotation),r.fog!==void 0&&(f.fog=r.fog),r.flatShading!==void 0&&(f.flatShading=r.flatShading),r.blending!==void 0&&(f.blending=r.blending),r.combine!==void 0&&(f.combine=r.combine),r.side!==void 0&&(f.side=r.side),r.shadowSide!==void 0&&(f.shadowSide=r.shadowSide),r.opacity!==void 0&&(f.opacity=r.opacity),r.transparent!==void 0&&(f.transparent=r.transparent),r.alphaTest!==void 0&&(f.alphaTest=r.alphaTest),r.alphaHash!==void 0&&(f.alphaHash=r.alphaHash),r.depthFunc!==void 0&&(f.depthFunc=r.depthFunc),r.depthTest!==void 0&&(f.depthTest=r.depthTest),r.depthWrite!==void 0&&(f.depthWrite=r.depthWrite),r.colorWrite!==void 0&&(f.colorWrite=r.colorWrite),r.blendSrc!==void 0&&(f.blendSrc=r.blendSrc),r.blendDst!==void 0&&(f.blendDst=r.blendDst),r.blendEquation!==void 0&&(f.blendEquation=r.blendEquation),r.blendSrcAlpha!==void 0&&(f.blendSrcAlpha=r.blendSrcAlpha),r.blendDstAlpha!==void 0&&(f.blendDstAlpha=r.blendDstAlpha),r.blendEquationAlpha!==void 0&&(f.blendEquationAlpha=r.blendEquationAlpha),r.blendColor!==void 0&&f.blendColor!==void 0&&f.blendColor.setHex(r.blendColor),r.blendAlpha!==void 0&&(f.blendAlpha=r.blendAlpha),r.stencilWriteMask!==void 0&&(f.stencilWriteMask=r.stencilWriteMask),r.stencilFunc!==void 0&&(f.stencilFunc=r.stencilFunc),r.stencilRef!==void 0&&(f.stencilRef=r.stencilRef),r.stencilFuncMask!==void 0&&(f.stencilFuncMask=r.stencilFuncMask),r.stencilFail!==void 0&&(f.stencilFail=r.stencilFail),r.stencilZFail!==void 0&&(f.stencilZFail=r.stencilZFail),r.stencilZPass!==void 0&&(f.stencilZPass=r.stencilZPass),r.stencilWrite!==void 0&&(f.stencilWrite=r.stencilWrite),r.wireframe!==void 0&&(f.wireframe=r.wireframe),r.wireframeLinewidth!==void 0&&(f.wireframeLinewidth=r.wireframeLinewidth),r.wireframeLinecap!==void 0&&(f.wireframeLinecap=r.wireframeLinecap),r.wireframeLinejoin!==void 0&&(f.wireframeLinejoin=r.wireframeLinejoin),r.rotation!==void 0&&(f.rotation=r.rotation),r.linewidth!==void 0&&(f.linewidth=r.linewidth),r.dashSize!==void 0&&(f.dashSize=r.dashSize),r.gapSize!==void 0&&(f.gapSize=r.gapSize),r.scale!==void 0&&(f.scale=r.scale),r.polygonOffset!==void 0&&(f.polygonOffset=r.polygonOffset),r.polygonOffsetFactor!==void 0&&(f.polygonOffsetFactor=r.polygonOffsetFactor),r.polygonOffsetUnits!==void 0&&(f.polygonOffsetUnits=r.polygonOffsetUnits),r.dithering!==void 0&&(f.dithering=r.dithering),r.alphaToCoverage!==void 0&&(f.alphaToCoverage=r.alphaToCoverage),r.premultipliedAlpha!==void 0&&(f.premultipliedAlpha=r.premultipliedAlpha),r.forceSinglePass!==void 0&&(f.forceSinglePass=r.forceSinglePass),r.visible!==void 0&&(f.visible=r.visible),r.toneMapped!==void 0&&(f.toneMapped=r.toneMapped),r.userData!==void 0&&(f.userData=r.userData),r.vertexColors!==void 0&&(typeof r.vertexColors=="number"?f.vertexColors=r.vertexColors>0:f.vertexColors=r.vertexColors),r.uniforms!==void 0)for(const g in r.uniforms){const v=r.uniforms[g];switch(f.uniforms[g]={},v.type){case"t":f.uniforms[g].value=h(v.value);break;case"c":f.uniforms[g].value=new ar().setHex(v.value);break;case"v2":f.uniforms[g].value=new oi().fromArray(v.value);break;case"v3":f.uniforms[g].value=new Rt().fromArray(v.value);break;case"v4":f.uniforms[g].value=new ka().fromArray(v.value);break;case"m3":f.uniforms[g].value=new da().fromArray(v.value);break;case"m4":f.uniforms[g].value=new On().fromArray(v.value);break;default:f.uniforms[g].value=v.value}}if(r.defines!==void 0&&(f.defines=r.defines),r.vertexShader!==void 0&&(f.vertexShader=r.vertexShader),r.fragmentShader!==void 0&&(f.fragmentShader=r.fragmentShader),r.glslVersion!==void 0&&(f.glslVersion=r.glslVersion),r.extensions!==void 0)for(const g in r.extensions)f.extensions[g]=r.extensions[g];if(r.lights!==void 0&&(f.lights=r.lights),r.clipping!==void 0&&(f.clipping=r.clipping),r.size!==void 0&&(f.size=r.size),r.sizeAttenuation!==void 0&&(f.sizeAttenuation=r.sizeAttenuation),r.map!==void 0&&(f.map=h(r.map)),r.matcap!==void 0&&(f.matcap=h(r.matcap)),r.alphaMap!==void 0&&(f.alphaMap=h(r.alphaMap)),r.bumpMap!==void 0&&(f.bumpMap=h(r.bumpMap)),r.bumpScale!==void 0&&(f.bumpScale=r.bumpScale),r.normalMap!==void 0&&(f.normalMap=h(r.normalMap)),r.normalMapType!==void 0&&(f.normalMapType=r.normalMapType),r.normalScale!==void 0){let g=r.normalScale;Array.isArray(g)===!1&&(g=[g,g]),f.normalScale=new oi().fromArray(g)}return r.displacementMap!==void 0&&(f.displacementMap=h(r.displacementMap)),r.displacementScale!==void 0&&(f.displacementScale=r.displacementScale),r.displacementBias!==void 0&&(f.displacementBias=r.displacementBias),r.roughnessMap!==void 0&&(f.roughnessMap=h(r.roughnessMap)),r.metalnessMap!==void 0&&(f.metalnessMap=h(r.metalnessMap)),r.emissiveMap!==void 0&&(f.emissiveMap=h(r.emissiveMap)),r.emissiveIntensity!==void 0&&(f.emissiveIntensity=r.emissiveIntensity),r.specularMap!==void 0&&(f.specularMap=h(r.specularMap)),r.specularIntensityMap!==void 0&&(f.specularIntensityMap=h(r.specularIntensityMap)),r.specularColorMap!==void 0&&(f.specularColorMap=h(r.specularColorMap)),r.envMap!==void 0&&(f.envMap=h(r.envMap)),r.envMapRotation!==void 0&&f.envMapRotation.fromArray(r.envMapRotation),r.envMapIntensity!==void 0&&(f.envMapIntensity=r.envMapIntensity),r.reflectivity!==void 0&&(f.reflectivity=r.reflectivity),r.refractionRatio!==void 0&&(f.refractionRatio=r.refractionRatio),r.lightMap!==void 0&&(f.lightMap=h(r.lightMap)),r.lightMapIntensity!==void 0&&(f.lightMapIntensity=r.lightMapIntensity),r.aoMap!==void 0&&(f.aoMap=h(r.aoMap)),r.aoMapIntensity!==void 0&&(f.aoMapIntensity=r.aoMapIntensity),r.gradientMap!==void 0&&(f.gradientMap=h(r.gradientMap)),r.clearcoatMap!==void 0&&(f.clearcoatMap=h(r.clearcoatMap)),r.clearcoatRoughnessMap!==void 0&&(f.clearcoatRoughnessMap=h(r.clearcoatRoughnessMap)),r.clearcoatNormalMap!==void 0&&(f.clearcoatNormalMap=h(r.clearcoatNormalMap)),r.clearcoatNormalScale!==void 0&&(f.clearcoatNormalScale=new oi().fromArray(r.clearcoatNormalScale)),r.iridescenceMap!==void 0&&(f.iridescenceMap=h(r.iridescenceMap)),r.iridescenceThicknessMap!==void 0&&(f.iridescenceThicknessMap=h(r.iridescenceThicknessMap)),r.transmissionMap!==void 0&&(f.transmissionMap=h(r.transmissionMap)),r.thicknessMap!==void 0&&(f.thicknessMap=h(r.thicknessMap)),r.anisotropyMap!==void 0&&(f.anisotropyMap=h(r.anisotropyMap)),r.sheenColorMap!==void 0&&(f.sheenColorMap=h(r.sheenColorMap)),r.sheenRoughnessMap!==void 0&&(f.sheenRoughnessMap=h(r.sheenRoughnessMap)),f}setTextures(r){return this.textures=r,this}createMaterialFromType(r){return Eg.createMaterialFromType(r)}static createMaterialFromType(r){const l={ShadowMaterial:Fx,SpriteMaterial:ad,RawShaderMaterial:my,ShaderMaterial:sd,PointsMaterial:Z0,MeshPhysicalMaterial:Ux,MeshStandardMaterial:Bx,MeshPhongMaterial:gy,MeshToonMaterial:yy,MeshNormalMaterial:wd,MeshLambertMaterial:kx,MeshDepthMaterial:zx,MeshDistanceMaterial:vy,MeshBasicMaterial:Ss,MeshMatcapMaterial:xy,LineDashedMaterial:$1,LineBasicMaterial:Pl,Material:No};return new l[r]}}class My{static extractUrlBase(r){const l=r.lastIndexOf("/");return l===-1?"./":r.slice(0,l+1)}static resolveURL(r,l){return typeof r!="string"||r===""?"":(/^https?:\/\//i.test(l)&&/^\//.test(r)&&(l=l.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(r)||/^data:.*,.*$/i.test(r)||/^blob:.*$/i.test(r)?r:l+r)}}class Sy extends null{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(r){return super.copy(r),this.instanceCount=r.instanceCount,this}toJSON(){const r=super.toJSON();return r.instanceCount=this.instanceCount,r.isInstancedBufferGeometry=!0,r}}class TE extends null{constructor(r){super(r)}load(r,l,h,f){const g=this,v=new Td(g.manager);v.setPath(g.path),v.setRequestHeader(g.requestHeader),v.setWithCredentials(g.withCredentials),v.load(r,function(A){try{l(g.parse(JSON.parse(A)))}catch(V){f?f(V):Xs(V),g.manager.itemError(r)}},h,f)}parse(r){const l={},h={};function f(de,Me){if(l[Me]!==void 0)return l[Me];const mt=de.interleavedBuffers[Me],pt=g(de,mt.buffer),Nt=ku(mt.type,pt),Pt=new od(Nt,mt.stride);return Pt.uuid=mt.uuid,l[Me]=Pt,Pt}function g(de,Me){if(h[Me]!==void 0)return h[Me];const mt=de.arrayBuffers[Me],pt=new Uint32Array(mt).buffer;return h[Me]=pt,pt}const v=r.isInstancedBufferGeometry?new Sy:new Fr,A=r.data.index;if(A!==void 0){const de=ku(A.type,A.array);v.setIndex(new vo(de,1))}const V=r.data.attributes;for(const de in V){const Me=V[de];let Je;if(Me.isInterleavedBufferAttribute){const mt=f(r.data,Me.data);Je=new zc(mt,Me.itemSize,Me.offset,Me.normalized)}else{const mt=ku(Me.type,Me.array),pt=Me.isInstancedBufferAttribute?qu:vo;Je=new pt(mt,Me.itemSize,Me.normalized)}Me.name!==void 0&&(Je.name=Me.name),Me.usage!==void 0&&Je.setUsage(Me.usage),v.setAttribute(de,Je)}const H=r.data.morphAttributes;if(H)for(const de in H){const Me=H[de],Je=[];for(let mt=0,pt=Me.length;mt<pt;mt++){const Nt=Me[mt];let Pt;if(Nt.isInterleavedBufferAttribute){const Gt=f(r.data,Nt.data);Pt=new zc(Gt,Nt.itemSize,Nt.offset,Nt.normalized)}else{const Gt=ku(Nt.type,Nt.array);Pt=new vo(Gt,Nt.itemSize,Nt.normalized)}Nt.name!==void 0&&(Pt.name=Nt.name),Je.push(Pt)}v.morphAttributes[de]=Je}r.data.morphTargetsRelative&&(v.morphTargetsRelative=!0);const ce=r.data.groups||r.data.drawcalls||r.data.offsets;if(ce!==void 0)for(let de=0,Me=ce.length;de!==Me;++de){const Je=ce[de];v.addGroup(Je.start,Je.count,Je.materialIndex)}const he=r.data.boundingSphere;return he!==void 0&&(v.boundingSphere=new Vt().fromJSON(he)),r.name&&(v.name=r.name),r.userData&&(v.userData=r.userData),v}}class Ty extends null{constructor(r){super(r)}load(r,l,h,f){const g=this,v=this.path===""?My.extractUrlBase(r):this.path;this.resourcePath=this.resourcePath||v;const A=new Td(this.manager);A.setPath(this.path),A.setRequestHeader(this.requestHeader),A.setWithCredentials(this.withCredentials),A.load(r,function(V){let H=null;try{H=JSON.parse(V)}catch(ce){f!==void 0&&f(ce),ce("ObjectLoader: Can't parse "+r+".",ce.message);return}const Z=H.metadata;if(Z===void 0||Z.type===void 0||Z.type.toLowerCase()==="geometry"){f!==void 0&&f(new Error("THREE.ObjectLoader: Can't load "+r)),Xs("ObjectLoader: Can't load "+r);return}g.parse(H,l)},h,f)}loadAsync(r,l){return hr(this,null,function*(){const h=this,f=this.path===""?My.extractUrlBase(r):this.path;this.resourcePath=this.resourcePath||f;const g=new Td(this.manager);g.setPath(this.path),g.setRequestHeader(this.requestHeader),g.setWithCredentials(this.withCredentials);const v=yield g.loadAsync(r,l),A=JSON.parse(v),V=A.metadata;if(V===void 0||V.type===void 0||V.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+r);return yield h.parseAsync(A)})}parse(r,l){const h=this.parseAnimations(r.animations),f=this.parseShapes(r.shapes),g=this.parseGeometries(r.geometries,f),v=this.parseImages(r.images,function(){l!==void 0&&l(H)}),A=this.parseTextures(r.textures,v),V=this.parseMaterials(r.materials,A),H=this.parseObject(r.object,g,V,A,h),Z=this.parseSkeletons(r.skeletons,H);if(this.bindSkeletons(H,Z),this.bindLightTargets(H),l!==void 0){let ce=!1;for(const he in v)if(v[he].data instanceof HTMLImageElement){ce=!0;break}ce===!1&&l(H)}return H}parseAsync(r){return hr(this,null,function*(){const l=this.parseAnimations(r.animations),h=this.parseShapes(r.shapes),f=this.parseGeometries(r.geometries,h),g=yield this.parseImagesAsync(r.images),v=this.parseTextures(r.textures,g),A=this.parseMaterials(r.materials,v),V=this.parseObject(r.object,f,A,v,l),H=this.parseSkeletons(r.skeletons,V);return this.bindSkeletons(V,H),this.bindLightTargets(V),V})}parseShapes(r){const l={};if(r!==void 0)for(let h=0,f=r.length;h<f;h++){const g=new Mf().fromJSON(r[h]);l[g.uuid]=g}return l}parseSkeletons(r,l){const h={},f={};if(l.traverse(function(g){g.isBone&&(f[g.uuid]=g)}),r!==void 0)for(let g=0,v=r.length;g<v;g++){const A=new $0().fromJSON(r[g],f);h[A.uuid]=A}return h}parseGeometries(r,l){const h={};if(r!==void 0){const f=new TE;for(let g=0,v=r.length;g<v;g++){let A;const V=r[g];switch(V.type){case"BufferGeometry":case"InstancedBufferGeometry":A=f.parse(V);break;default:V.type in py?A=py[V.type].fromJSON(V,l):_r(`ObjectLoader: Unsupported geometry type "${V.type}"`)}A.uuid=V.uuid,V.name!==void 0&&(A.name=V.name),V.userData!==void 0&&(A.userData=V.userData),h[V.uuid]=A}}return h}parseMaterials(r,l){const h={},f={};if(r!==void 0){const g=new Eg;g.setTextures(l);for(let v=0,A=r.length;v<A;v++){const V=r[v];h[V.uuid]===void 0&&(h[V.uuid]=g.parse(V)),f[V.uuid]=h[V.uuid]}}return f}parseAnimations(r){const l={};if(r!==void 0)for(let h=0;h<r.length;h++){const f=r[h],g=Rf.parse(f);l[g.uuid]=g}return l}parseImages(r,l){const h=this,f={};let g;function v(V){return h.manager.itemStart(V),g.load(V,function(){h.manager.itemEnd(V)},void 0,function(){h.manager.itemError(V),h.manager.itemEnd(V)})}function A(V){if(typeof V=="string"){const H=V,Z=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(H)?H:h.resourcePath+H;return v(Z)}else return V.data?{data:ku(V.type,V.data),width:V.width,height:V.height}:null}if(r!==void 0&&r.length>0){const V=new Z1(l);g=new If(V),g.setCrossOrigin(this.crossOrigin);for(let H=0,Z=r.length;H<Z;H++){const ce=r[H],he=ce.url;if(Array.isArray(he)){const de=[];for(let Me=0,Je=he.length;Me<Je;Me++){const mt=he[Me],pt=A(mt);pt!==null&&(pt instanceof HTMLImageElement?de.push(pt):de.push(new pu(pt.data,pt.width,pt.height)))}f[ce.uuid]=new Ja(de)}else{const de=A(ce.url);f[ce.uuid]=new Ja(de)}}}return f}parseImagesAsync(r){return hr(this,null,function*(){const l=this,h={};let f;function g(v){return hr(this,null,function*(){if(typeof v=="string"){const A=v,V=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(A)?A:l.resourcePath+A;return yield f.loadAsync(V)}else return v.data?{data:ku(v.type,v.data),width:v.width,height:v.height}:null})}if(r!==void 0&&r.length>0){f=new If(this.manager),f.setCrossOrigin(this.crossOrigin);for(let v=0,A=r.length;v<A;v++){const V=r[v],H=V.url;if(Array.isArray(H)){const Z=[];for(let ce=0,he=H.length;ce<he;ce++){const de=H[ce],Me=yield g(de);Me!==null&&(Me instanceof HTMLImageElement?Z.push(Me):Z.push(new pu(Me.data,Me.width,Me.height)))}h[V.uuid]=new Ja(Z)}else{const Z=yield g(V.url);h[V.uuid]=new Ja(Z)}}}return h})}parseTextures(r,l){function h(g,v){return typeof g=="number"?g:(_r("ObjectLoader.parseTexture: Constant should be in numeric form.",g),v[g])}const f={};if(r!==void 0)for(let g=0,v=r.length;g<v;g++){const A=r[g];A.image===void 0&&_r('ObjectLoader: No "image" specified for',A.uuid),l[A.image]===void 0&&_r("ObjectLoader: Undefined image",A.image);const V=l[A.image],H=V.data;let Z;Array.isArray(H)?(Z=new pp,H.length===6&&(Z.needsUpdate=!0)):(H&&H.data?Z=new pu:Z=new bl,H&&(Z.needsUpdate=!0)),Z.source=V,Z.uuid=A.uuid,A.name!==void 0&&(Z.name=A.name),A.mapping!==void 0&&(Z.mapping=h(A.mapping,Xx)),A.channel!==void 0&&(Z.channel=A.channel),A.offset!==void 0&&Z.offset.fromArray(A.offset),A.repeat!==void 0&&Z.repeat.fromArray(A.repeat),A.center!==void 0&&Z.center.fromArray(A.center),A.rotation!==void 0&&(Z.rotation=A.rotation),A.wrap!==void 0&&(Z.wrapS=h(A.wrap[0],iw),Z.wrapT=h(A.wrap[1],iw)),A.format!==void 0&&(Z.format=A.format),A.internalFormat!==void 0&&(Z.internalFormat=A.internalFormat),A.type!==void 0&&(Z.type=A.type),A.colorSpace!==void 0&&(Z.colorSpace=A.colorSpace),A.minFilter!==void 0&&(Z.minFilter=h(A.minFilter,Ey)),A.magFilter!==void 0&&(Z.magFilter=h(A.magFilter,Ey)),A.anisotropy!==void 0&&(Z.anisotropy=A.anisotropy),A.flipY!==void 0&&(Z.flipY=A.flipY),A.generateMipmaps!==void 0&&(Z.generateMipmaps=A.generateMipmaps),A.premultiplyAlpha!==void 0&&(Z.premultiplyAlpha=A.premultiplyAlpha),A.unpackAlignment!==void 0&&(Z.unpackAlignment=A.unpackAlignment),A.compareFunction!==void 0&&(Z.compareFunction=A.compareFunction),A.userData!==void 0&&(Z.userData=A.userData),f[A.uuid]=Z}return f}parseObject(r,l,h,f,g){let v;function A(he){return l[he]===void 0&&_r("ObjectLoader: Undefined geometry",he),l[he]}function V(he){if(he!==void 0){if(Array.isArray(he)){const de=[];for(let Me=0,Je=he.length;Me<Je;Me++){const mt=he[Me];h[mt]===void 0&&_r("ObjectLoader: Undefined material",mt),de.push(h[mt])}return de}return h[he]===void 0&&_r("ObjectLoader: Undefined material",he),h[he]}}function H(he){return f[he]===void 0&&_r("ObjectLoader: Undefined texture",he),f[he]}let Z,ce;switch(r.type){case"Scene":v=new gp,r.background!==void 0&&(Number.isInteger(r.background)?v.background=new ar(r.background):v.background=H(r.background)),r.environment!==void 0&&(v.environment=H(r.environment)),r.fog!==void 0&&(r.fog.type==="Fog"?v.fog=new _h(r.fog.color,r.fog.near,r.fog.far):r.fog.type==="FogExp2"&&(v.fog=new mp(r.fog.color,r.fog.density)),r.fog.name!==""&&(v.fog.name=r.fog.name)),r.backgroundBlurriness!==void 0&&(v.backgroundBlurriness=r.backgroundBlurriness),r.backgroundIntensity!==void 0&&(v.backgroundIntensity=r.backgroundIntensity),r.backgroundRotation!==void 0&&v.backgroundRotation.fromArray(r.backgroundRotation),r.environmentIntensity!==void 0&&(v.environmentIntensity=r.environmentIntensity),r.environmentRotation!==void 0&&v.environmentRotation.fromArray(r.environmentRotation);break;case"PerspectiveCamera":v=new dl(r.fov,r.aspect,r.near,r.far),r.focus!==void 0&&(v.focus=r.focus),r.zoom!==void 0&&(v.zoom=r.zoom),r.filmGauge!==void 0&&(v.filmGauge=r.filmGauge),r.filmOffset!==void 0&&(v.filmOffset=r.filmOffset),r.view!==void 0&&(v.view=Object.assign({},r.view));break;case"OrthographicCamera":v=new by(r.left,r.right,r.top,r.bottom,r.near,r.far),r.zoom!==void 0&&(v.zoom=r.zoom),r.view!==void 0&&(v.view=Object.assign({},r.view));break;case"AmbientLight":v=new ew(r.color,r.intensity);break;case"DirectionalLight":v=new jx(r.color,r.intensity),v.target=r.target||"";break;case"PointLight":v=new Q1(r.color,r.intensity,r.distance,r.decay);break;case"RectAreaLight":v=new tw(r.color,r.intensity,r.width,r.height);break;case"SpotLight":v=new Df(r.color,r.intensity,r.distance,r.angle,r.penumbra,r.decay),v.target=r.target||"";break;case"HemisphereLight":v=new Mg(r.color,r.groundColor,r.intensity);break;case"LightProbe":v=new nw().fromJSON(r);break;case"SkinnedMesh":Z=A(r.geometry),ce=V(r.material),v=new Vc(Z,ce),r.bindMode!==void 0&&(v.bindMode=r.bindMode),r.bindMatrix!==void 0&&v.bindMatrix.fromArray(r.bindMatrix),r.skeleton!==void 0&&(v.skeleton=r.skeleton);break;case"Mesh":Z=A(r.geometry),ce=V(r.material),v=new vh(Z,ce);break;case"InstancedMesh":Z=A(r.geometry),ce=V(r.material);const he=r.count,de=r.instanceMatrix,Me=r.instanceColor;v=new _1(Z,ce,he),v.instanceMatrix=new qu(new Float32Array(de.array),16),Me!==void 0&&(v.instanceColor=new qu(new Float32Array(Me.array),Me.itemSize));break;case"BatchedMesh":Z=A(r.geometry),ce=V(r.material),v=new ag(r.maxInstanceCount,r.maxVertexCount,r.maxIndexCount,ce),v.geometry=Z,v.perObjectFrustumCulled=r.perObjectFrustumCulled,v.sortObjects=r.sortObjects,v._drawRanges=r.drawRanges,v._reservedRanges=r.reservedRanges,v._geometryInfo=r.geometryInfo.map(Je=>{let mt=null,pt=null;return Je.boundingBox!==void 0&&(mt=new na().fromJSON(Je.boundingBox)),Je.boundingSphere!==void 0&&(pt=new Vt().fromJSON(Je.boundingSphere)),cc(Ys({},Je),{boundingBox:mt,boundingSphere:pt})}),v._instanceInfo=r.instanceInfo,v._availableInstanceIds=r._availableInstanceIds,v._availableGeometryIds=r._availableGeometryIds,v._nextIndexStart=r.nextIndexStart,v._nextVertexStart=r.nextVertexStart,v._geometryCount=r.geometryCount,v._maxInstanceCount=r.maxInstanceCount,v._maxVertexCount=r.maxVertexCount,v._maxIndexCount=r.maxIndexCount,v._geometryInitialized=r.geometryInitialized,v._matricesTexture=H(r.matricesTexture.uuid),v._indirectTexture=H(r.indirectTexture.uuid),r.colorsTexture!==void 0&&(v._colorsTexture=H(r.colorsTexture.uuid)),r.boundingSphere!==void 0&&(v.boundingSphere=new Vt().fromJSON(r.boundingSphere)),r.boundingBox!==void 0&&(v.boundingBox=new na().fromJSON(r.boundingBox));break;case"LOD":v=new eg;break;case"Line":v=new gf(A(r.geometry),V(r.material));break;case"LineLoop":v=new M1(A(r.geometry),V(r.material));break;case"LineSegments":v=new Ep(A(r.geometry),V(r.material));break;case"PointCloud":case"Points":v=new vE(A(r.geometry),V(r.material));break;case"Sprite":v=new V0(V(r.material));break;case"Group":v=new ju;break;case"Bone":v=new dd;break;default:v=new _s}if(v.uuid=r.uuid,r.name!==void 0&&(v.name=r.name),r.matrix!==void 0?(v.matrix.fromArray(r.matrix),r.matrixAutoUpdate!==void 0&&(v.matrixAutoUpdate=r.matrixAutoUpdate),v.matrixAutoUpdate&&v.matrix.decompose(v.position,v.quaternion,v.scale)):(r.position!==void 0&&v.position.fromArray(r.position),r.rotation!==void 0&&v.rotation.fromArray(r.rotation),r.quaternion!==void 0&&v.quaternion.fromArray(r.quaternion),r.scale!==void 0&&v.scale.fromArray(r.scale)),r.up!==void 0&&v.up.fromArray(r.up),r.castShadow!==void 0&&(v.castShadow=r.castShadow),r.receiveShadow!==void 0&&(v.receiveShadow=r.receiveShadow),r.shadow&&(r.shadow.intensity!==void 0&&(v.shadow.intensity=r.shadow.intensity),r.shadow.bias!==void 0&&(v.shadow.bias=r.shadow.bias),r.shadow.normalBias!==void 0&&(v.shadow.normalBias=r.shadow.normalBias),r.shadow.radius!==void 0&&(v.shadow.radius=r.shadow.radius),r.shadow.mapSize!==void 0&&v.shadow.mapSize.fromArray(r.shadow.mapSize),r.shadow.camera!==void 0&&(v.shadow.camera=this.parseObject(r.shadow.camera))),r.visible!==void 0&&(v.visible=r.visible),r.frustumCulled!==void 0&&(v.frustumCulled=r.frustumCulled),r.renderOrder!==void 0&&(v.renderOrder=r.renderOrder),r.userData!==void 0&&(v.userData=r.userData),r.layers!==void 0&&(v.layers.mask=r.layers),r.children!==void 0){const he=r.children;for(let de=0;de<he.length;de++)v.add(this.parseObject(he[de],l,h,f,g))}if(r.animations!==void 0){const he=r.animations;for(let de=0;de<he.length;de++){const Me=he[de];v.animations.push(g[Me])}}if(r.type==="LOD"){r.autoUpdate!==void 0&&(v.autoUpdate=r.autoUpdate);const he=r.levels;for(let de=0;de<he.length;de++){const Me=he[de],Je=v.getObjectByProperty("uuid",Me.object);Je!==void 0&&v.addLevel(Je,Me.distance,Me.hysteresis)}}return v}bindSkeletons(r,l){Object.keys(l).length!==0&&r.traverse(function(h){if(h.isSkinnedMesh===!0&&h.skeleton!==void 0){const f=l[h.skeleton];f===void 0?_r("ObjectLoader: No skeleton found with UUID:",h.skeleton):h.bind(f,h.bindMatrix)}})}bindLightTargets(r){r.traverse(function(l){if(l.isDirectionalLight||l.isSpotLight){const h=l.target,f=r.getObjectByProperty("uuid",h);f!==void 0?l.target=f:l.target=new _s}})}}const Xx={UVMapping:Q,CubeReflectionMapping:De,CubeRefractionMapping:We,EquirectangularReflectionMapping:Ce,EquirectangularRefractionMapping:Re,CubeUVReflectionMapping:qe},iw={RepeatWrapping:st,ClampToEdgeWrapping:$e,MirroredRepeatWrapping:ft},Ey={NearestFilter:Ct,NearestMipmapNearestFilter:jt,NearestMipmapLinearFilter:pn,LinearFilter:Rn,LinearMipmapNearestFilter:bi,LinearMipmapLinearFilter:Qn},Ag=new WeakMap;class Of extends null{constructor(r){super(r),this.isImageBitmapLoader=!0,typeof createImageBitmap=="undefined"&&_r("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch=="undefined"&&_r("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(r){return this.options=r,this}load(r,l,h,f){r===void 0&&(r=""),this.path!==void 0&&(r=this.path+r),r=this.manager.resolveURL(r);const g=this,v=Ml.get(`image-bitmap:${r}`);if(v!==void 0){if(g.manager.itemStart(r),v.then){v.then(H=>{if(Ag.has(v)===!0)f&&f(Ag.get(v)),g.manager.itemError(r),g.manager.itemEnd(r);else return l&&l(H),g.manager.itemEnd(r),H});return}return setTimeout(function(){l&&l(v),g.manager.itemEnd(r)},0),v}const A={};A.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",A.headers=this.requestHeader,A.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const V=fetch(r,A).then(function(H){return H.blob()}).then(function(H){return createImageBitmap(H,Object.assign(g.options,{colorSpaceConversion:"none"}))}).then(function(H){return Ml.add(`image-bitmap:${r}`,H),l&&l(H),g.manager.itemEnd(r),H}).catch(function(H){f&&f(H),Ag.set(V,H),Ml.remove(`image-bitmap:${r}`),g.manager.itemError(r),g.manager.itemEnd(r)});Ml.add(`image-bitmap:${r}`,V),g.manager.itemStart(r)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let Ay;class Cy{static getContext(){return Ay===void 0&&(Ay=new(window.AudioContext||window.webkitAudioContext)),Ay}static setContext(r){Ay=r}}class qx extends null{constructor(r){super(r)}load(r,l,h,f){const g=this,v=new Td(this.manager);v.setResponseType("arraybuffer"),v.setPath(this.path),v.setRequestHeader(this.requestHeader),v.setWithCredentials(this.withCredentials),v.load(r,function(V){try{const H=V.slice(0);Cy.getContext().decodeAudioData(H,function(ce){l(ce)}).catch(A)}catch(H){A(H)}},h,f);function A(V){f?f(V):Xs(V),g.manager.itemError(r)}}}const Rh=new On,Cg=new On,Cd=new On;class Ff{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new dl,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new dl,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(r){const l=this._cache;if(l.focus!==r.focus||l.fov!==r.fov||l.aspect!==r.aspect*this.aspect||l.near!==r.near||l.far!==r.far||l.zoom!==r.zoom||l.eyeSep!==this.eyeSep){l.focus=r.focus,l.fov=r.fov,l.aspect=r.aspect*this.aspect,l.near=r.near,l.far=r.far,l.zoom=r.zoom,l.eyeSep=this.eyeSep,Cd.copy(r.projectionMatrix);const f=l.eyeSep/2,g=f*l.near/l.focus,v=l.near*Math.tan(au*l.fov*.5)/l.zoom;let A,V;Cg.elements[12]=-f,Rh.elements[12]=f,A=-v*l.aspect+g,V=v*l.aspect+g,Cd.elements[0]=2*l.near/(V-A),Cd.elements[8]=(V+A)/(V-A),this.cameraL.projectionMatrix.copy(Cd),A=-v*l.aspect-g,V=v*l.aspect-g,Cd.elements[0]=2*l.near/(V-A),Cd.elements[8]=(V+A)/(V-A),this.cameraR.projectionMatrix.copy(Cd)}this.cameraL.matrixWorld.copy(r.matrixWorld).multiply(Cg),this.cameraR.matrixWorld.copy(r.matrixWorld).multiply(Rh)}}class Bf extends null{constructor(r=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=r}}class EE{constructor(r=!0){this.autoStart=r,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),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 r=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const l=performance.now();r=(l-this.oldTime)/1e3,this.oldTime=l,this.elapsedTime+=r}return r}}const Uf=new Rt,Ju=new _l,Yx=new Rt,Rd=new Rt,nc=new Rt;class D3 extends null{constructor(){super(),this.type="AudioListener",this.context=Cy.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new EE}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(r){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=r,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(r){return this.gain.gain.setTargetAtTime(r,this.context.currentTime,.01),this}updateMatrixWorld(r){super.updateMatrixWorld(r);const l=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Uf,Ju,Yx),Rd.set(0,0,-1).applyQuaternion(Ju),nc.set(0,1,0).applyQuaternion(Ju),l.positionX){const h=this.context.currentTime+this.timeDelta;l.positionX.linearRampToValueAtTime(Uf.x,h),l.positionY.linearRampToValueAtTime(Uf.y,h),l.positionZ.linearRampToValueAtTime(Uf.z,h),l.forwardX.linearRampToValueAtTime(Rd.x,h),l.forwardY.linearRampToValueAtTime(Rd.y,h),l.forwardZ.linearRampToValueAtTime(Rd.z,h),l.upX.linearRampToValueAtTime(nc.x,h),l.upY.linearRampToValueAtTime(nc.y,h),l.upZ.linearRampToValueAtTime(nc.z,h)}else l.setPosition(Uf.x,Uf.y,Uf.z),l.setOrientation(Rd.x,Rd.y,Rd.z,nc.x,nc.y,nc.z)}}class O3 extends null{constructor(r){super(),this.type="Audio",this.listener=r,this.context=r.context,this.gain=this.context.createGain(),this.gain.connect(r.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(r){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=r,this.connect(),this}setMediaElementSource(r){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(r),this.connect(),this}setMediaStreamSource(r){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(r),this.connect(),this}setBuffer(r){return this.buffer=r,this.sourceType="buffer",this.autoplay&&this.play(),this}play(r=0){if(this.isPlaying===!0){_r("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){_r("Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+r;const l=this.context.createBufferSource();return l.buffer=this.buffer,l.loop=this.loop,l.loopStart=this.loopStart,l.loopEnd=this.loopEnd,l.onended=this.onEnded.bind(this),l.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=l,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){_r("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(r=0){if(this.hasPlaybackControl===!1){_r("Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+r),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let r=1,l=this.filters.length;r<l;r++)this.filters[r-1].connect(this.filters[r]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let r=1,l=this.filters.length;r<l;r++)this.filters[r-1].disconnect(this.filters[r]);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(r){return r||(r=[]),this._connected===!0?(this.disconnect(),this.filters=r.slice(),this.connect()):this.filters=r.slice(),this}setDetune(r){return this.detune=r,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(r){return this.setFilters(r?[r]:[])}setPlaybackRate(r){if(this.hasPlaybackControl===!1){_r("Audio: this Audio has no playback control.");return}return this.playbackRate=r,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return this.hasPlaybackControl===!1?(_r("Audio: this Audio has no playback control."),!1):this.loop}setLoop(r){if(this.hasPlaybackControl===!1){_r("Audio: this Audio has no playback control.");return}return this.loop=r,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(r){return this.loopStart=r,this}setLoopEnd(r){return this.loopEnd=r,this}getVolume(){return this.gain.gain.value}setVolume(r){return this.gain.gain.setTargetAtTime(r,this.context.currentTime,.01),this}copy(r,l){return super.copy(r,l),r.sourceType!=="buffer"?(_r("Audio: Audio source type cannot be copied."),this):(this.autoplay=r.autoplay,this.buffer=r.buffer,this.detune=r.detune,this.loop=r.loop,this.loopStart=r.loopStart,this.loopEnd=r.loopEnd,this.offset=r.offset,this.duration=r.duration,this.playbackRate=r.playbackRate,this.hasPlaybackControl=r.hasPlaybackControl,this.sourceType=r.sourceType,this.filters=r.filters.slice(),this)}clone(r){return new this.constructor(this.listener).copy(this,r)}}const Nd=new Rt,Rg=new _l,rw=new Rt,Qu=new Rt;class AE extends null{constructor(r){super(r),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(r){return this.panner.refDistance=r,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(r){return this.panner.rolloffFactor=r,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(r){return this.panner.distanceModel=r,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(r){return this.panner.maxDistance=r,this}setDirectionalCone(r,l,h){return this.panner.coneInnerAngle=r,this.panner.coneOuterAngle=l,this.panner.coneOuterGain=h,this}updateMatrixWorld(r){if(super.updateMatrixWorld(r),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Nd,Rg,rw),Qu.set(0,0,1).applyQuaternion(Rg);const l=this.panner;if(l.positionX){const h=this.context.currentTime+this.listener.timeDelta;l.positionX.linearRampToValueAtTime(Nd.x,h),l.positionY.linearRampToValueAtTime(Nd.y,h),l.positionZ.linearRampToValueAtTime(Nd.z,h),l.orientationX.linearRampToValueAtTime(Qu.x,h),l.orientationY.linearRampToValueAtTime(Qu.y,h),l.orientationZ.linearRampToValueAtTime(Qu.z,h)}else l.setPosition(Nd.x,Nd.y,Nd.z),l.setOrientation(Qu.x,Qu.y,Qu.z)}}class CE{constructor(r,l=2048){this.analyser=r.context.createAnalyser(),this.analyser.fftSize=l,this.data=new Uint8Array(this.analyser.frequencyBinCount),r.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let r=0;const l=this.getFrequencyData();for(let h=0;h<l.length;h++)r+=l[h];return r/l.length}}class sw{constructor(r,l,h){this.binding=r,this.valueSize=h;let f,g,v;switch(l){case"quaternion":f=this._slerp,g=this._slerpAdditive,v=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(h*6),this._workIndex=5;break;case"string":case"bool":f=this._select,g=this._select,v=this._setAdditiveIdentityOther,this.buffer=new Array(h*5);break;default:f=this._lerp,g=this._lerpAdditive,v=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(h*5)}this._mixBufferRegion=f,this._mixBufferRegionAdditive=g,this._setIdentity=v,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(r,l){const h=this.buffer,f=this.valueSize,g=r*f+f;let v=this.cumulativeWeight;if(v===0){for(let A=0;A!==f;++A)h[g+A]=h[A];v=l}else{v+=l;const A=l/v;this._mixBufferRegion(h,g,0,A,f)}this.cumulativeWeight=v}accumulateAdditive(r){const l=this.buffer,h=this.valueSize,f=h*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(l,f,0,r,h),this.cumulativeWeightAdditive+=r}apply(r){const l=this.valueSize,h=this.buffer,f=r*l+l,g=this.cumulativeWeight,v=this.cumulativeWeightAdditive,A=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,g<1){const V=l*this._origIndex;this._mixBufferRegion(h,f,V,1-g,l)}v>0&&this._mixBufferRegionAdditive(h,f,this._addIndex*l,1,l);for(let V=l,H=l+l;V!==H;++V)if(h[V]!==h[V+l]){A.setValue(h,f);break}}saveOriginalState(){const r=this.binding,l=this.buffer,h=this.valueSize,f=h*this._origIndex;r.getValue(l,f);for(let g=h,v=f;g!==v;++g)l[g]=l[f+g%h];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const r=this.valueSize*3;this.binding.setValue(this.buffer,r)}_setAdditiveIdentityNumeric(){const r=this._addIndex*this.valueSize,l=r+this.valueSize;for(let h=r;h<l;h++)this.buffer[h]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const r=this._origIndex*this.valueSize,l=this._addIndex*this.valueSize;for(let h=0;h<this.valueSize;h++)this.buffer[l+h]=this.buffer[r+h]}_select(r,l,h,f,g){if(f>=.5)for(let v=0;v!==g;++v)r[l+v]=r[h+v]}_slerp(r,l,h,f){_l.slerpFlat(r,l,r,l,r,h,f)}_slerpAdditive(r,l,h,f,g){const v=this._workIndex*g;_l.multiplyQuaternionsFlat(r,v,r,l,r,h),_l.slerpFlat(r,l,r,l,r,v,f)}_lerp(r,l,h,f,g){const v=1-f;for(let A=0;A!==g;++A){const V=l+A;r[V]=r[V]*v+r[h+A]*f}}_lerpAdditive(r,l,h,f,g){for(let v=0;v!==g;++v){const A=l+v;r[A]=r[A]+r[h+v]*f}}}const Ry="\\[\\]\\.:\\/",ow=new RegExp("["+Ry+"]","g"),Ny="[^"+Ry+"]",aw="[^"+Ry.replace("\\.","")+"]",lw=/((?:WC+[\/:])*)/.source.replace("WC",Ny),Js=/(WCOD+)?/.source.replace("WCOD",aw),RE=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Ny),cw=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Ny),uw=new RegExp("^"+lw+Js+RE+cw+"$"),NE=["material","materials","bones","map"];class PE{constructor(r,l,h){const f=h||qs.parseTrackName(l);this._targetGroup=r,this._bindings=r.subscribe_(l,f)}getValue(r,l){this.bind();const h=this._targetGroup.nCachedObjects_,f=this._bindings[h];f!==void 0&&f.getValue(r,l)}setValue(r,l){const h=this._bindings;for(let f=this._targetGroup.nCachedObjects_,g=h.length;f!==g;++f)h[f].setValue(r,l)}bind(){const r=this._bindings;for(let l=this._targetGroup.nCachedObjects_,h=r.length;l!==h;++l)r[l].bind()}unbind(){const r=this._bindings;for(let l=this._targetGroup.nCachedObjects_,h=r.length;l!==h;++l)r[l].unbind()}}class qs{constructor(r,l,h){this.path=l,this.parsedPath=h||qs.parseTrackName(l),this.node=qs.findNode(r,this.parsedPath.nodeName),this.rootNode=r,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(r,l,h){return r&&r.isAnimationObjectGroup?new qs.Composite(r,l,h):new qs(r,l,h)}static sanitizeNodeName(r){return r.replace(/\s/g,"_").replace(ow,"")}static parseTrackName(r){const l=uw.exec(r);if(l===null)throw new Error("PropertyBinding: Cannot parse trackName: "+r);const h={nodeName:l[2],objectName:l[3],objectIndex:l[4],propertyName:l[5],propertyIndex:l[6]},f=h.nodeName&&h.nodeName.lastIndexOf(".");if(f!==void 0&&f!==-1){const g=h.nodeName.substring(f+1);NE.indexOf(g)!==-1&&(h.nodeName=h.nodeName.substring(0,f),h.objectName=g)}if(h.propertyName===null||h.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+r);return h}static findNode(r,l){if(l===void 0||l===""||l==="."||l===-1||l===r.name||l===r.uuid)return r;if(r.skeleton){const h=r.skeleton.getBoneByName(l);if(h!==void 0)return h}if(r.children){const h=function(g){for(let v=0;v<g.length;v++){const A=g[v];if(A.name===l||A.uuid===l)return A;const V=h(A.children);if(V)return V}return null},f=h(r.children);if(f)return f}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(r,l){r[l]=this.targetObject[this.propertyName]}_getValue_array(r,l){const h=this.resolvedProperty;for(let f=0,g=h.length;f!==g;++f)r[l++]=h[f]}_getValue_arrayElement(r,l){r[l]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(r,l){this.resolvedProperty.toArray(r,l)}_setValue_direct(r,l){this.targetObject[this.propertyName]=r[l]}_setValue_direct_setNeedsUpdate(r,l){this.targetObject[this.propertyName]=r[l],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(r,l){this.targetObject[this.propertyName]=r[l],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(r,l){const h=this.resolvedProperty;for(let f=0,g=h.length;f!==g;++f)h[f]=r[l++]}_setValue_array_setNeedsUpdate(r,l){const h=this.resolvedProperty;for(let f=0,g=h.length;f!==g;++f)h[f]=r[l++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(r,l){const h=this.resolvedProperty;for(let f=0,g=h.length;f!==g;++f)h[f]=r[l++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(r,l){this.resolvedProperty[this.propertyIndex]=r[l]}_setValue_arrayElement_setNeedsUpdate(r,l){this.resolvedProperty[this.propertyIndex]=r[l],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(r,l){this.resolvedProperty[this.propertyIndex]=r[l],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(r,l){this.resolvedProperty.fromArray(r,l)}_setValue_fromArray_setNeedsUpdate(r,l){this.resolvedProperty.fromArray(r,l),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(r,l){this.resolvedProperty.fromArray(r,l),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(r,l){this.bind(),this.getValue(r,l)}_setValue_unbound(r,l){this.bind(),this.setValue(r,l)}bind(){let r=this.node;const l=this.parsedPath,h=l.objectName,f=l.propertyName;let g=l.propertyIndex;if(r||(r=qs.findNode(this.rootNode,l.nodeName),this.node=r),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!r){_r("PropertyBinding: No target node found for track: "+this.path+".");return}if(h){let H=l.objectIndex;switch(h){case"materials":if(!r.material){Xs("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!r.material.materials){Xs("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}r=r.material.materials;break;case"bones":if(!r.skeleton){Xs("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}r=r.skeleton.bones;for(let Z=0;Z<r.length;Z++)if(r[Z].name===H){H=Z;break}break;case"map":if("map"in r){r=r.map;break}if(!r.material){Xs("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!r.material.map){Xs("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}r=r.material.map;break;default:if(r[h]===void 0){Xs("PropertyBinding: Can not bind to objectName of node undefined.",this);return}r=r[h]}if(H!==void 0){if(r[H]===void 0){Xs("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,r);return}r=r[H]}}const v=r[f];if(v===void 0){const H=l.nodeName;Xs("PropertyBinding: Trying to update property for track: "+H+"."+f+" but it wasn't found.",r);return}let A=this.Versioning.None;this.targetObject=r,r.isMaterial===!0?A=this.Versioning.NeedsUpdate:r.isObject3D===!0&&(A=this.Versioning.MatrixWorldNeedsUpdate);let V=this.BindingType.Direct;if(g!==void 0){if(f==="morphTargetInfluences"){if(!r.geometry){Xs("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!r.geometry.morphAttributes){Xs("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}r.morphTargetDictionary[g]!==void 0&&(g=r.morphTargetDictionary[g])}V=this.BindingType.ArrayElement,this.resolvedProperty=v,this.propertyIndex=g}else v.fromArray!==void 0&&v.toArray!==void 0?(V=this.BindingType.HasFromToArray,this.resolvedProperty=v):Array.isArray(v)?(V=this.BindingType.EntireArray,this.resolvedProperty=v):this.propertyName=f;this.getValue=this.GetterByBindingType[V],this.setValue=this.SetterByBindingTypeAndVersioning[V][A]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}qs.Composite=PE,qs.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},qs.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},qs.prototype.GetterByBindingType=[qs.prototype._getValue_direct,qs.prototype._getValue_array,qs.prototype._getValue_arrayElement,qs.prototype._getValue_toArray],qs.prototype.SetterByBindingTypeAndVersioning=[[qs.prototype._setValue_direct,qs.prototype._setValue_direct_setNeedsUpdate,qs.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[qs.prototype._setValue_array,qs.prototype._setValue_array_setNeedsUpdate,qs.prototype._setValue_array_setMatrixWorldNeedsUpdate],[qs.prototype._setValue_arrayElement,qs.prototype._setValue_arrayElement_setNeedsUpdate,qs.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[qs.prototype._setValue_fromArray,qs.prototype._setValue_fromArray_setNeedsUpdate,qs.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class IE{constructor(){this.isAnimationObjectGroup=!0,this.uuid=El(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const r={};this._indicesByUUID=r;for(let h=0,f=arguments.length;h!==f;++h)r[arguments[h].uuid]=h;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const l=this;this.stats={objects:{get total(){return l._objects.length},get inUse(){return this.total-l.nCachedObjects_}},get bindingsPerObject(){return l._bindings.length}}}add(){const r=this._objects,l=this._indicesByUUID,h=this._paths,f=this._parsedPaths,g=this._bindings,v=g.length;let A,V=r.length,H=this.nCachedObjects_;for(let Z=0,ce=arguments.length;Z!==ce;++Z){const he=arguments[Z],de=he.uuid;let Me=l[de];if(Me===void 0){Me=V++,l[de]=Me,r.push(he);for(let Je=0,mt=v;Je!==mt;++Je)g[Je].push(new qs(he,h[Je],f[Je]))}else if(Me<H){A=r[Me];const Je=--H,mt=r[Je];l[mt.uuid]=Me,r[Me]=mt,l[de]=Je,r[Je]=he;for(let pt=0,Nt=v;pt!==Nt;++pt){const Pt=g[pt],Gt=Pt[Je];let gn=Pt[Me];Pt[Me]=Gt,gn===void 0&&(gn=new qs(he,h[pt],f[pt])),Pt[Je]=gn}}else r[Me]!==A&&Xs("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=H}remove(){const r=this._objects,l=this._indicesByUUID,h=this._bindings,f=h.length;let g=this.nCachedObjects_;for(let v=0,A=arguments.length;v!==A;++v){const V=arguments[v],H=V.uuid,Z=l[H];if(Z!==void 0&&Z>=g){const ce=g++,he=r[ce];l[he.uuid]=Z,r[Z]=he,l[H]=ce,r[ce]=V;for(let de=0,Me=f;de!==Me;++de){const Je=h[de],mt=Je[ce],pt=Je[Z];Je[Z]=mt,Je[ce]=pt}}}this.nCachedObjects_=g}uncache(){const r=this._objects,l=this._indicesByUUID,h=this._bindings,f=h.length;let g=this.nCachedObjects_,v=r.length;for(let A=0,V=arguments.length;A!==V;++A){const H=arguments[A],Z=H.uuid,ce=l[Z];if(ce!==void 0)if(delete l[Z],ce<g){const he=--g,de=r[he],Me=--v,Je=r[Me];l[de.uuid]=ce,r[ce]=de,l[Je.uuid]=he,r[he]=Je,r.pop();for(let mt=0,pt=f;mt!==pt;++mt){const Nt=h[mt],Pt=Nt[he],Gt=Nt[Me];Nt[ce]=Pt,Nt[he]=Gt,Nt.pop()}}else{const he=--v,de=r[he];he>0&&(l[de.uuid]=ce),r[ce]=de,r.pop();for(let Me=0,Je=f;Me!==Je;++Me){const mt=h[Me];mt[ce]=mt[he],mt.pop()}}}this.nCachedObjects_=g}subscribe_(r,l){const h=this._bindingsIndicesByPath;let f=h[r];const g=this._bindings;if(f!==void 0)return g[f];const v=this._paths,A=this._parsedPaths,V=this._objects,H=V.length,Z=this.nCachedObjects_,ce=new Array(H);f=g.length,h[r]=f,v.push(r),A.push(l),g.push(ce);for(let he=Z,de=V.length;he!==de;++he){const Me=V[he];ce[he]=new qs(Me,r,l)}return ce}unsubscribe_(r){const l=this._bindingsIndicesByPath,h=l[r];if(h!==void 0){const f=this._paths,g=this._parsedPaths,v=this._bindings,A=v.length-1,V=v[A],H=r[A];l[H]=h,v[h]=V,v.pop(),g[h]=g[A],g.pop(),f[h]=f[A],f.pop()}}}class LE{constructor(r,l,h=null,f=l.blendMode){this._mixer=r,this._clip=l,this._localRoot=h,this.blendMode=f;const g=l.tracks,v=g.length,A=new Array(v),V={endingStart:ha,endingEnd:ha};for(let H=0;H!==v;++H){const Z=g[H].createInterpolant(null);A[H]=Z,Z.settings=V}this._interpolantSettings=V,this._interpolants=A,this._propertyBindings=new Array(v),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Yr,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(r){return this._startTime=r,this}setLoop(r,l){return this.loop=r,this.repetitions=l,this}setEffectiveWeight(r){return this.weight=r,this._effectiveWeight=this.enabled?r:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(r){return this._scheduleFading(r,0,1)}fadeOut(r){return this._scheduleFading(r,1,0)}crossFadeFrom(r,l,h=!1){if(r.fadeOut(l),this.fadeIn(l),h===!0){const f=this._clip.duration,g=r._clip.duration,v=g/f,A=f/g;r.warp(1,v,l),this.warp(A,1,l)}return this}crossFadeTo(r,l,h=!1){return r.crossFadeFrom(this,l,h)}stopFading(){const r=this._weightInterpolant;return r!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(r)),this}setEffectiveTimeScale(r){return this.timeScale=r,this._effectiveTimeScale=this.paused?0:r,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(r){return this.timeScale=this._clip.duration/r,this.stopWarping()}syncWith(r){return this.time=r.time,this.timeScale=r.timeScale,this.stopWarping()}halt(r){return this.warp(this._effectiveTimeScale,0,r)}warp(r,l,h){const f=this._mixer,g=f.time,v=this.timeScale;let A=this._timeScaleInterpolant;A===null&&(A=f._lendControlInterpolant(),this._timeScaleInterpolant=A);const V=A.parameterPositions,H=A.sampleValues;return V[0]=g,V[1]=g+h,H[0]=r/v,H[1]=l/v,this}stopWarping(){const r=this._timeScaleInterpolant;return r!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(r)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(r,l,h,f){if(!this.enabled){this._updateWeight(r);return}const g=this._startTime;if(g!==null){const V=(r-g)*h;V<0||h===0?l=0:(this._startTime=null,l=h*V)}l*=this._updateTimeScale(r);const v=this._updateTime(l),A=this._updateWeight(r);if(A>0){const V=this._interpolants,H=this._propertyBindings;switch(this.blendMode){case Lc:for(let Z=0,ce=V.length;Z!==ce;++Z)V[Z].evaluate(v),H[Z].accumulateAdditive(A);break;case wo:default:for(let Z=0,ce=V.length;Z!==ce;++Z)V[Z].evaluate(v),H[Z].accumulate(f,A)}}}_updateWeight(r){let l=0;if(this.enabled){l=this.weight;const h=this._weightInterpolant;if(h!==null){const f=h.evaluate(r)[0];l*=f,r>h.parameterPositions[1]&&(this.stopFading(),f===0&&(this.enabled=!1))}}return this._effectiveWeight=l,l}_updateTimeScale(r){let l=0;if(!this.paused){l=this.timeScale;const h=this._timeScaleInterpolant;if(h!==null){const f=h.evaluate(r)[0];l*=f,r>h.parameterPositions[1]&&(this.stopWarping(),l===0?this.paused=!0:this.timeScale=l)}}return this._effectiveTimeScale=l,l}_updateTime(r){const l=this._clip.duration,h=this.loop;let f=this.time+r,g=this._loopCount;const v=h===ua;if(r===0)return g===-1?f:v&&(g&1)===1?l-f:f;if(h===so){g===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(f>=l)f=l;else if(f<0)f=0;else{this.time=f;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=f,this._mixer.dispatchEvent({type:"finished",action:this,direction:r<0?-1:1})}}else{if(g===-1&&(r>=0?(g=0,this._setEndings(!0,this.repetitions===0,v)):this._setEndings(this.repetitions===0,!0,v)),f>=l||f<0){const A=Math.floor(f/l);f-=l*A,g+=Math.abs(A);const V=this.repetitions-g;if(V<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,f=r>0?l:0,this.time=f,this._mixer.dispatchEvent({type:"finished",action:this,direction:r>0?1:-1});else{if(V===1){const H=r<0;this._setEndings(H,!H,v)}else this._setEndings(!1,!1,v);this._loopCount=g,this.time=f,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:A})}}else this.time=f;if(v&&(g&1)===1)return l-f}return f}_setEndings(r,l,h){const f=this._interpolantSettings;h?(f.endingStart=Ba,f.endingEnd=Ba):(r?f.endingStart=this.zeroSlopeAtStart?Ba:ha:f.endingStart=al,l?f.endingEnd=this.zeroSlopeAtEnd?Ba:ha:f.endingEnd=al)}_scheduleFading(r,l,h){const f=this._mixer,g=f.time;let v=this._weightInterpolant;v===null&&(v=f._lendControlInterpolant(),this._weightInterpolant=v);const A=v.parameterPositions,V=v.sampleValues;return A[0]=g,V[0]=l,A[1]=g+r,V[1]=h,this}}const hw=new Float32Array(1);class F3 extends null{constructor(r){super(),this._root=r,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(r,l){const h=r._localRoot||this._root,f=r._clip.tracks,g=f.length,v=r._propertyBindings,A=r._interpolants,V=h.uuid,H=this._bindingsByRootAndName;let Z=H[V];Z===void 0&&(Z={},H[V]=Z);for(let ce=0;ce!==g;++ce){const he=f[ce],de=he.name;let Me=Z[de];if(Me!==void 0)++Me.referenceCount,v[ce]=Me;else{if(Me=v[ce],Me!==void 0){Me._cacheIndex===null&&(++Me.referenceCount,this._addInactiveBinding(Me,V,de));continue}const Je=l&&l._propertyBindings[ce].binding.parsedPath;Me=new sw(qs.create(h,de,Je),he.ValueTypeName,he.getValueSize()),++Me.referenceCount,this._addInactiveBinding(Me,V,de),v[ce]=Me}A[ce].resultBuffer=Me.buffer}}_activateAction(r){if(!this._isActiveAction(r)){if(r._cacheIndex===null){const h=(r._localRoot||this._root).uuid,f=r._clip.uuid,g=this._actionsByClip[f];this._bindAction(r,g&&g.knownActions[0]),this._addInactiveAction(r,f,h)}const l=r._propertyBindings;for(let h=0,f=l.length;h!==f;++h){const g=l[h];g.useCount++===0&&(this._lendBinding(g),g.saveOriginalState())}this._lendAction(r)}}_deactivateAction(r){if(this._isActiveAction(r)){const l=r._propertyBindings;for(let h=0,f=l.length;h!==f;++h){const g=l[h];--g.useCount===0&&(g.restoreOriginalState(),this._takeBackBinding(g))}this._takeBackAction(r)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const r=this;this.stats={actions:{get total(){return r._actions.length},get inUse(){return r._nActiveActions}},bindings:{get total(){return r._bindings.length},get inUse(){return r._nActiveBindings}},controlInterpolants:{get total(){return r._controlInterpolants.length},get inUse(){return r._nActiveControlInterpolants}}}}_isActiveAction(r){const l=r._cacheIndex;return l!==null&&l<this._nActiveActions}_addInactiveAction(r,l,h){const f=this._actions,g=this._actionsByClip;let v=g[l];if(v===void 0)v={knownActions:[r],actionByRoot:{}},r._byClipCacheIndex=0,g[l]=v;else{const A=v.knownActions;r._byClipCacheIndex=A.length,A.push(r)}r._cacheIndex=f.length,f.push(r),v.actionByRoot[h]=r}_removeInactiveAction(r){const l=this._actions,h=l[l.length-1],f=r._cacheIndex;h._cacheIndex=f,l[f]=h,l.pop(),r._cacheIndex=null;const g=r._clip.uuid,v=this._actionsByClip,A=v[g],V=A.knownActions,H=V[V.length-1],Z=r._byClipCacheIndex;H._byClipCacheIndex=Z,V[Z]=H,V.pop(),r._byClipCacheIndex=null;const ce=A.actionByRoot,he=(r._localRoot||this._root).uuid;delete ce[he],V.length===0&&delete v[g],this._removeInactiveBindingsForAction(r)}_removeInactiveBindingsForAction(r){const l=r._propertyBindings;for(let h=0,f=l.length;h!==f;++h){const g=l[h];--g.referenceCount===0&&this._removeInactiveBinding(g)}}_lendAction(r){const l=this._actions,h=r._cacheIndex,f=this._nActiveActions++,g=l[f];r._cacheIndex=f,l[f]=r,g._cacheIndex=h,l[h]=g}_takeBackAction(r){const l=this._actions,h=r._cacheIndex,f=--this._nActiveActions,g=l[f];r._cacheIndex=f,l[f]=r,g._cacheIndex=h,l[h]=g}_addInactiveBinding(r,l,h){const f=this._bindingsByRootAndName,g=this._bindings;let v=f[l];v===void 0&&(v={},f[l]=v),v[h]=r,r._cacheIndex=g.length,g.push(r)}_removeInactiveBinding(r){const l=this._bindings,h=r.binding,f=h.rootNode.uuid,g=h.path,v=this._bindingsByRootAndName,A=v[f],V=l[l.length-1],H=r._cacheIndex;V._cacheIndex=H,l[H]=V,l.pop(),delete A[g],Object.keys(A).length===0&&delete v[f]}_lendBinding(r){const l=this._bindings,h=r._cacheIndex,f=this._nActiveBindings++,g=l[f];r._cacheIndex=f,l[f]=r,g._cacheIndex=h,l[h]=g}_takeBackBinding(r){const l=this._bindings,h=r._cacheIndex,f=--this._nActiveBindings,g=l[f];r._cacheIndex=f,l[f]=r,g._cacheIndex=h,l[h]=g}_lendControlInterpolant(){const r=this._controlInterpolants,l=this._nActiveControlInterpolants++;let h=r[l];return h===void 0&&(h=new Vx(new Float32Array(2),new Float32Array(2),1,hw),h.__cacheIndex=l,r[l]=h),h}_takeBackControlInterpolant(r){const l=this._controlInterpolants,h=r.__cacheIndex,f=--this._nActiveControlInterpolants,g=l[f];r.__cacheIndex=f,l[f]=r,g.__cacheIndex=h,l[h]=g}clipAction(r,l,h){const f=l||this._root,g=f.uuid;let v=typeof r=="string"?Rf.findByName(f,r):r;const A=v!==null?v.uuid:r,V=this._actionsByClip[A];let H=null;if(h===void 0&&(v!==null?h=v.blendMode:h=wo),V!==void 0){const ce=V.actionByRoot[g];if(ce!==void 0&&ce.blendMode===h)return ce;H=V.knownActions[0],v===null&&(v=H._clip)}if(v===null)return null;const Z=new LE(this,v,l,h);return this._bindAction(Z,H),this._addInactiveAction(Z,A,g),Z}existingAction(r,l){const h=l||this._root,f=h.uuid,g=typeof r=="string"?Rf.findByName(h,r):r,v=g?g.uuid:r,A=this._actionsByClip[v];return A!==void 0&&A.actionByRoot[f]||null}stopAllAction(){const r=this._actions,l=this._nActiveActions;for(let h=l-1;h>=0;--h)r[h].stop();return this}update(r){r*=this.timeScale;const l=this._actions,h=this._nActiveActions,f=this.time+=r,g=Math.sign(r),v=this._accuIndex^=1;for(let H=0;H!==h;++H)l[H]._update(f,r,g,v);const A=this._bindings,V=this._nActiveBindings;for(let H=0;H!==V;++H)A[H].apply(v);return this}setTime(r){this.time=0;for(let l=0;l<this._actions.length;l++)this._actions[l].time=0;return this.update(r)}getRoot(){return this._root}uncacheClip(r){const l=this._actions,h=r.uuid,f=this._actionsByClip,g=f[h];if(g!==void 0){const v=g.knownActions;for(let A=0,V=v.length;A!==V;++A){const H=v[A];this._deactivateAction(H);const Z=H._cacheIndex,ce=l[l.length-1];H._cacheIndex=null,H._byClipCacheIndex=null,ce._cacheIndex=Z,l[Z]=ce,l.pop(),this._removeInactiveBindingsForAction(H)}delete f[h]}}uncacheRoot(r){const l=r.uuid,h=this._actionsByClip;for(const v in h){const A=h[v].actionByRoot,V=A[l];V!==void 0&&(this._deactivateAction(V),this._removeInactiveAction(V))}const f=this._bindingsByRootAndName,g=f[l];if(g!==void 0)for(const v in g){const A=g[v];A.restoreOriginalState(),this._removeInactiveBinding(A)}}uncacheAction(r,l){const h=this.existingAction(r,l);h!==null&&(this._deactivateAction(h),this._removeInactiveAction(h))}}class dw extends null{constructor(r=1,l=1,h=1,f={}){super(r,l,f),this.isRenderTarget3D=!0,this.depth=h,this.texture=new uu(null,r,l,h),this._setTextureOptions(f),this.texture.isRenderTargetTexture=!0}}class Py{constructor(r){this.value=r}clone(){return new Py(this.value.clone===void 0?this.value:this.value.clone())}}let Zx=0;class Kx extends null{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:Zx++}),this.name="",this.usage=Uu,this.uniforms=[]}add(r){return this.uniforms.push(r),this}remove(r){const l=this.uniforms.indexOf(r);return l!==-1&&this.uniforms.splice(l,1),this}setName(r){return this.name=r,this}setUsage(r){return this.usage=r,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(r){this.name=r.name,this.usage=r.usage;const l=r.uniforms;this.uniforms.length=0;for(let h=0,f=l.length;h<f;h++){const g=Array.isArray(l[h])?l[h]:[l[h]];for(let v=0;v<g.length;v++)this.uniforms.push(g[v].clone())}return this}clone(){return new this.constructor().copy(this)}}class B3 extends null{constructor(r,l,h=1){super(r,l),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=h}copy(r){return super.copy(r),this.meshPerAttribute=r.meshPerAttribute,this}clone(r){const l=super.clone(r);return l.meshPerAttribute=this.meshPerAttribute,l}toJSON(r){const l=super.toJSON(r);return l.isInstancedInterleavedBuffer=!0,l.meshPerAttribute=this.meshPerAttribute,l}}class DE{constructor(r,l,h,f,g,v=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=r,this.type=l,this.itemSize=h,this.elementSize=f,this.count=g,this.normalized=v,this.version=0}set needsUpdate(r){r===!0&&this.version++}setBuffer(r){return this.buffer=r,this}setType(r,l){return this.type=r,this.elementSize=l,this}setItemSize(r){return this.itemSize=r,this}setCount(r){return this.count=r,this}}const Iy=new On;class U3{constructor(r,l,h=0,f=1/0){this.ray=new ai(r,l),this.near=h,this.far=f,this.camera=null,this.layers=new fs,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(r,l){this.ray.set(r,l)}setFromCamera(r,l){l.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(l.matrixWorld),this.ray.direction.set(r.x,r.y,.5).unproject(l).sub(this.ray.origin).normalize(),this.camera=l):l.isOrthographicCamera?(this.ray.origin.set(r.x,r.y,(l.near+l.far)/(l.near-l.far)).unproject(l),this.ray.direction.set(0,0,-1).transformDirection(l.matrixWorld),this.camera=l):Xs("Raycaster: Unsupported camera type: "+l.type)}setFromXRController(r){return Iy.identity().extractRotation(r.matrixWorld),this.ray.origin.setFromMatrixPosition(r.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Iy),this}intersectObject(r,l=!0,h=[]){return Ng(r,this,h,l),h.sort(Yp),h}intersectObjects(r,l=!0,h=[]){for(let f=0,g=r.length;f<g;f++)Ng(r[f],this,h,l);return h.sort(Yp),h}}function Yp(j,r){return j.distance-r.distance}function Ng(j,r,l,h){let f=!0;if(j.layers.test(r.layers)&&j.raycast(r,l)===!1&&(f=!1),f===!0&&h===!0){const g=j.children;for(let v=0,A=g.length;v<A;v++)Ng(g[v],r,l,!0)}}class k3{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(r){this._document=r,r.hidden!==void 0&&(this._pageVisibilityHandler=Jx.bind(this),r.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(r){return this._timescale=r,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(r){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(r!==void 0?r:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function Jx(){this._document.hidden===!1&&this.reset()}class Ly{constructor(r=1,l=0,h=0){this.radius=r,this.phi=l,this.theta=h}set(r,l,h){return this.radius=r,this.phi=l,this.theta=h,this}copy(r){return this.radius=r.radius,this.phi=r.phi,this.theta=r.theta,this}makeSafe(){return this.phi=Br(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(r){return this.setFromCartesianCoords(r.x,r.y,r.z)}setFromCartesianCoords(r,l,h){return this.radius=Math.sqrt(r*r+l*l+h*h),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(r,h),this.phi=Math.acos(Br(l/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class Zp{constructor(r=1,l=0,h=0){this.radius=r,this.theta=l,this.y=h}set(r,l,h){return this.radius=r,this.theta=l,this.y=h,this}copy(r){return this.radius=r.radius,this.theta=r.theta,this.y=r.y,this}setFromVector3(r){return this.setFromCartesianCoords(r.x,r.y,r.z)}setFromCartesianCoords(r,l,h){return this.radius=Math.sqrt(r*r+h*h),this.theta=Math.atan2(r,h),this.y=l,this}clone(){return new this.constructor().copy(this)}}class Pd{constructor(r,l,h,f){Pd.prototype.isMatrix2=!0,this.elements=[1,0,0,1],r!==void 0&&this.set(r,l,h,f)}identity(){return this.set(1,0,0,1),this}fromArray(r,l=0){for(let h=0;h<4;h++)this.elements[h]=r[h+l];return this}set(r,l,h,f){const g=this.elements;return g[0]=r,g[2]=l,g[1]=h,g[3]=f,this}}const Pg=new oi;class OE{constructor(r=new oi(1/0,1/0),l=new oi(-1/0,-1/0)){this.isBox2=!0,this.min=r,this.max=l}set(r,l){return this.min.copy(r),this.max.copy(l),this}setFromPoints(r){this.makeEmpty();for(let l=0,h=r.length;l<h;l++)this.expandByPoint(r[l]);return this}setFromCenterAndSize(r,l){const h=Pg.copy(l).multiplyScalar(.5);return this.min.copy(r).sub(h),this.max.copy(r).add(h),this}clone(){return new this.constructor().copy(this)}copy(r){return this.min.copy(r.min),this.max.copy(r.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(r){return this.isEmpty()?r.set(0,0):r.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(r){return this.isEmpty()?r.set(0,0):r.subVectors(this.max,this.min)}expandByPoint(r){return this.min.min(r),this.max.max(r),this}expandByVector(r){return this.min.sub(r),this.max.add(r),this}expandByScalar(r){return this.min.addScalar(-r),this.max.addScalar(r),this}containsPoint(r){return r.x>=this.min.x&&r.x<=this.max.x&&r.y>=this.min.y&&r.y<=this.max.y}containsBox(r){return this.min.x<=r.min.x&&r.max.x<=this.max.x&&this.min.y<=r.min.y&&r.max.y<=this.max.y}getParameter(r,l){return l.set((r.x-this.min.x)/(this.max.x-this.min.x),(r.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(r){return r.max.x>=this.min.x&&r.min.x<=this.max.x&&r.max.y>=this.min.y&&r.min.y<=this.max.y}clampPoint(r,l){return l.copy(r).clamp(this.min,this.max)}distanceToPoint(r){return this.clampPoint(r,Pg).distanceTo(r)}intersect(r){return this.min.max(r.min),this.max.min(r.max),this.isEmpty()&&this.makeEmpty(),this}union(r){return this.min.min(r.min),this.max.max(r.max),this}translate(r){return this.min.add(r),this.max.add(r),this}equals(r){return r.min.equals(this.min)&&r.max.equals(this.max)}}const Qx=new Rt,Dy=new Rt,Id=new Rt,Kp=new Rt,bu=new Rt,Ig=new Rt,Oy=new Rt;class z3{constructor(r=new Rt,l=new Rt){this.start=r,this.end=l}set(r,l){return this.start.copy(r),this.end.copy(l),this}copy(r){return this.start.copy(r.start),this.end.copy(r.end),this}getCenter(r){return r.addVectors(this.start,this.end).multiplyScalar(.5)}delta(r){return r.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(r,l){return this.delta(l).multiplyScalar(r).add(this.start)}closestPointToPointParameter(r,l){Qx.subVectors(r,this.start),Dy.subVectors(this.end,this.start);const h=Dy.dot(Dy);let g=Dy.dot(Qx)/h;return l&&(g=Br(g,0,1)),g}closestPointToPoint(r,l,h){const f=this.closestPointToPointParameter(r,l);return this.delta(h).multiplyScalar(f).add(this.start)}distanceSqToLine3(r,l=Ig,h=Oy){const f=10000000000000001e-32;let g,v;const A=this.start,V=r.start,H=this.end,Z=r.end;Id.subVectors(H,A),Kp.subVectors(Z,V),bu.subVectors(A,V);const ce=Id.dot(Id),he=Kp.dot(Kp),de=Kp.dot(bu);if(ce<=f&&he<=f)return l.copy(A),h.copy(V),l.sub(h),l.dot(l);if(ce<=f)g=0,v=de/he,v=Br(v,0,1);else{const Me=Id.dot(bu);if(he<=f)v=0,g=Br(-Me/ce,0,1);else{const Je=Id.dot(Kp),mt=ce*he-Je*Je;mt!==0?g=Br((Je*de-Me*he)/mt,0,1):g=0,v=(Je*g+de)/he,v<0?(v=0,g=Br(-Me/ce,0,1)):v>1&&(v=1,g=Br((Je-Me)/ce,0,1))}}return l.copy(A).add(Id.multiplyScalar(g)),h.copy(V).add(Kp.multiplyScalar(v)),l.sub(h),l.dot(l)}applyMatrix4(r){return this.start.applyMatrix4(r),this.end.applyMatrix4(r),this}equals(r){return r.start.equals(this.start)&&r.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Fy=new Rt;class V3 extends null{constructor(r,l){super(),this.light=r,this.matrixAutoUpdate=!1,this.color=l,this.type="SpotLightHelper";const h=new Fr,f=[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 v=0,A=1,V=32;v<V;v++,A++){const H=v/V*Math.PI*2,Z=A/V*Math.PI*2;f.push(Math.cos(H),Math.sin(H),1,Math.cos(Z),Math.sin(Z),1)}h.setAttribute("position",new qi(f,3));const g=new Pl({fog:!1,toneMapped:!1});this.cone=new Ep(h,g),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),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const r=this.light.distance?this.light.distance:1e3,l=r*Math.tan(this.light.angle);this.cone.scale.set(l,l,r),Fy.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Fy),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Nh=new Rt,Jp=new On,Lg=new On;class G3 extends null{constructor(r){const l=fw(r),h=new Fr,f=[],g=[];for(let H=0;H<l.length;H++){const Z=l[H];Z.parent&&Z.parent.isBone&&(f.push(0,0,0),f.push(0,0,0),g.push(0,0,0),g.push(0,0,0))}h.setAttribute("position",new qi(f,3)),h.setAttribute("color",new qi(g,3));const v=new Pl({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(h,v),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=r,this.bones=l,this.matrix=r.matrixWorld,this.matrixAutoUpdate=!1;const A=new ar(255),V=new ar(65280);this.setColors(A,V)}updateMatrixWorld(r){const l=this.bones,h=this.geometry,f=h.getAttribute("position");Lg.copy(this.root.matrixWorld).invert();for(let g=0,v=0;g<l.length;g++){const A=l[g];A.parent&&A.parent.isBone&&(Jp.multiplyMatrices(Lg,A.matrixWorld),Nh.setFromMatrixPosition(Jp),f.setXYZ(v,Nh.x,Nh.y,Nh.z),Jp.multiplyMatrices(Lg,A.parent.matrixWorld),Nh.setFromMatrixPosition(Jp),f.setXYZ(v+1,Nh.x,Nh.y,Nh.z),v+=2)}h.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(r)}setColors(r,l){const f=this.geometry.getAttribute("color");for(let g=0;g<f.count;g+=2)f.setXYZ(g,r.r,r.g,r.b),f.setXYZ(g+1,l.r,l.g,l.b);return f.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}function fw(j){const r=[];j.isBone===!0&&r.push(j);for(let l=0;l<j.children.length;l++)r.push(...fw(j.children[l]));return r}class W3 extends null{constructor(r,l,h){const f=new Cf(l,4,2),g=new Ss({wireframe:!0,fog:!1,toneMapped:!1});super(f,g),this.light=r,this.color=h,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 e_=new Rt,Qp=new ar,By=new ar;class H3 extends null{constructor(r,l,h){super(),this.light=r,this.matrix=r.matrixWorld,this.matrixAutoUpdate=!1,this.color=h,this.type="HemisphereLightHelper";const f=new Ef(l);f.rotateY(Math.PI*.5),this.material=new Ss({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const g=f.getAttribute("position"),v=new Float32Array(g.count*3);f.setAttribute("color",new vo(v,3)),this.add(new vh(f,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const r=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const l=r.geometry.getAttribute("color");Qp.copy(this.light.color),By.copy(this.light.groundColor);for(let h=0,f=l.count;h<f;h++){const g=h<f/2?Qp:By;l.setXYZ(h,g.r,g.g,g.b)}l.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),r.lookAt(e_.setFromMatrixPosition(this.light.matrixWorld).negate())}}class Uy extends null{constructor(r=10,l=10,h=4473924,f=8947848){h=new ar(h),f=new ar(f);const g=l/2,v=r/l,A=r/2,V=[],H=[];for(let he=0,de=0,Me=-A;he<=l;he++,Me+=v){V.push(-A,0,Me,A,0,Me),V.push(Me,0,-A,Me,0,A);const Je=he===g?h:f;Je.toArray(H,de),de+=3,Je.toArray(H,de),de+=3,Je.toArray(H,de),de+=3,Je.toArray(H,de),de+=3}const Z=new Fr;Z.setAttribute("position",new qi(V,3)),Z.setAttribute("color",new qi(H,3));const ce=new Pl({vertexColors:!0,toneMapped:!1});super(Z,ce),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class ga extends null{constructor(r=10,l=16,h=8,f=64,g=4473924,v=8947848){g=new ar(g),v=new ar(v);const A=[],V=[];if(l>1)for(let ce=0;ce<l;ce++){const he=ce/l*(Math.PI*2),de=Math.sin(he)*r,Me=Math.cos(he)*r;A.push(0,0,0),A.push(de,0,Me);const Je=ce&1?g:v;V.push(Je.r,Je.g,Je.b),V.push(Je.r,Je.g,Je.b)}for(let ce=0;ce<h;ce++){const he=ce&1?g:v,de=r-r/h*ce;for(let Me=0;Me<f;Me++){let Je=Me/f*(Math.PI*2),mt=Math.sin(Je)*de,pt=Math.cos(Je)*de;A.push(mt,0,pt),V.push(he.r,he.g,he.b),Je=(Me+1)/f*(Math.PI*2),mt=Math.sin(Je)*de,pt=Math.cos(Je)*de,A.push(mt,0,pt),V.push(he.r,he.g,he.b)}}const H=new Fr;H.setAttribute("position",new qi(A,3)),H.setAttribute("color",new qi(V,3));const Z=new Pl({vertexColors:!0,toneMapped:!1});super(H,Z),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const pw=new Rt,ko=new Rt,em=new Rt;class $3 extends null{constructor(r,l,h){super(),this.light=r,this.matrix=r.matrixWorld,this.matrixAutoUpdate=!1,this.color=h,this.type="DirectionalLightHelper",l===void 0&&(l=1);let f=new Fr;f.setAttribute("position",new qi([-l,l,0,l,l,0,l,-l,0,-l,-l,0,-l,l,0],3));const g=new Pl({fog:!1,toneMapped:!1});this.lightPlane=new gf(f,g),this.add(this.lightPlane),f=new Fr,f.setAttribute("position",new qi([0,0,0,0,0,1],3)),this.targetLine=new gf(f,g),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),pw.setFromMatrixPosition(this.light.matrixWorld),ko.setFromMatrixPosition(this.light.target.matrixWorld),em.subVectors(ko,pw),this.lightPlane.lookAt(ko),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(ko),this.targetLine.scale.z=em.length()}}const ky=new Rt,ya=new cf;class mw extends null{constructor(r){const l=new Fr,h=new Pl({color:16777215,vertexColors:!0,toneMapped:!1}),f=[],g=[],v={};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(Me,Je){V(Me),V(Je)}function V(Me){f.push(0,0,0),g.push(0,0,0),v[Me]===void 0&&(v[Me]=[]),v[Me].push(f.length/3-1)}l.setAttribute("position",new qi(f,3)),l.setAttribute("color",new qi(g,3)),super(l,h),this.type="CameraHelper",this.camera=r,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=r.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=v,this.update();const H=new ar(16755200),Z=new ar(16711680),ce=new ar(43775),he=new ar(16777215),de=new ar(3355443);this.setColors(H,Z,ce,he,de)}setColors(r,l,h,f,g){const A=this.geometry.getAttribute("color");return A.setXYZ(0,r.r,r.g,r.b),A.setXYZ(1,r.r,r.g,r.b),A.setXYZ(2,r.r,r.g,r.b),A.setXYZ(3,r.r,r.g,r.b),A.setXYZ(4,r.r,r.g,r.b),A.setXYZ(5,r.r,r.g,r.b),A.setXYZ(6,r.r,r.g,r.b),A.setXYZ(7,r.r,r.g,r.b),A.setXYZ(8,r.r,r.g,r.b),A.setXYZ(9,r.r,r.g,r.b),A.setXYZ(10,r.r,r.g,r.b),A.setXYZ(11,r.r,r.g,r.b),A.setXYZ(12,r.r,r.g,r.b),A.setXYZ(13,r.r,r.g,r.b),A.setXYZ(14,r.r,r.g,r.b),A.setXYZ(15,r.r,r.g,r.b),A.setXYZ(16,r.r,r.g,r.b),A.setXYZ(17,r.r,r.g,r.b),A.setXYZ(18,r.r,r.g,r.b),A.setXYZ(19,r.r,r.g,r.b),A.setXYZ(20,r.r,r.g,r.b),A.setXYZ(21,r.r,r.g,r.b),A.setXYZ(22,r.r,r.g,r.b),A.setXYZ(23,r.r,r.g,r.b),A.setXYZ(24,l.r,l.g,l.b),A.setXYZ(25,l.r,l.g,l.b),A.setXYZ(26,l.r,l.g,l.b),A.setXYZ(27,l.r,l.g,l.b),A.setXYZ(28,l.r,l.g,l.b),A.setXYZ(29,l.r,l.g,l.b),A.setXYZ(30,l.r,l.g,l.b),A.setXYZ(31,l.r,l.g,l.b),A.setXYZ(32,h.r,h.g,h.b),A.setXYZ(33,h.r,h.g,h.b),A.setXYZ(34,h.r,h.g,h.b),A.setXYZ(35,h.r,h.g,h.b),A.setXYZ(36,h.r,h.g,h.b),A.setXYZ(37,h.r,h.g,h.b),A.setXYZ(38,f.r,f.g,f.b),A.setXYZ(39,f.r,f.g,f.b),A.setXYZ(40,g.r,g.g,g.b),A.setXYZ(41,g.r,g.g,g.b),A.setXYZ(42,g.r,g.g,g.b),A.setXYZ(43,g.r,g.g,g.b),A.setXYZ(44,g.r,g.g,g.b),A.setXYZ(45,g.r,g.g,g.b),A.setXYZ(46,g.r,g.g,g.b),A.setXYZ(47,g.r,g.g,g.b),A.setXYZ(48,g.r,g.g,g.b),A.setXYZ(49,g.r,g.g,g.b),A.needsUpdate=!0,this}update(){const r=this.geometry,l=this.pointMap,h=1,f=1;let g,v;if(ya.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)g=1,v=0;else if(this.camera.coordinateSystem===oo)g=-1,v=1;else if(this.camera.coordinateSystem===qa)g=0,v=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);zo("c",l,r,ya,0,0,g),zo("t",l,r,ya,0,0,v),zo("n1",l,r,ya,-h,-f,g),zo("n2",l,r,ya,h,-f,g),zo("n3",l,r,ya,-h,f,g),zo("n4",l,r,ya,h,f,g),zo("f1",l,r,ya,-h,-f,v),zo("f2",l,r,ya,h,-f,v),zo("f3",l,r,ya,-h,f,v),zo("f4",l,r,ya,h,f,v),zo("u1",l,r,ya,h*.7,f*1.1,g),zo("u2",l,r,ya,-h*.7,f*1.1,g),zo("u3",l,r,ya,0,f*2,g),zo("cf1",l,r,ya,-h,0,v),zo("cf2",l,r,ya,h,0,v),zo("cf3",l,r,ya,0,-f,v),zo("cf4",l,r,ya,0,f,v),zo("cn1",l,r,ya,-h,0,g),zo("cn2",l,r,ya,h,0,g),zo("cn3",l,r,ya,0,-f,g),zo("cn4",l,r,ya,0,f,g),r.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function zo(j,r,l,h,f,g,v){ky.set(f,g,v).unproject(h);const A=r[j];if(A!==void 0){const V=l.getAttribute("position");for(let H=0,Z=A.length;H<Z;H++)V.setXYZ(A[H],ky.x,ky.y,ky.z)}}const kf=new na;class j3 extends null{constructor(r,l=16776960){const h=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]),f=new Float32Array(8*3),g=new Fr;g.setIndex(new vo(h,1)),g.setAttribute("position",new vo(f,3)),super(g,new Pl({color:l,toneMapped:!1})),this.object=r,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&kf.setFromObject(this.object),kf.isEmpty())return;const r=kf.min,l=kf.max,h=this.geometry.attributes.position,f=h.array;f[0]=l.x,f[1]=l.y,f[2]=l.z,f[3]=r.x,f[4]=l.y,f[5]=l.z,f[6]=r.x,f[7]=r.y,f[8]=l.z,f[9]=l.x,f[10]=r.y,f[11]=l.z,f[12]=l.x,f[13]=l.y,f[14]=r.z,f[15]=r.x,f[16]=l.y,f[17]=r.z,f[18]=r.x,f[19]=r.y,f[20]=r.z,f[21]=l.x,f[22]=r.y,f[23]=r.z,h.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(r){return this.object=r,this.update(),this}copy(r,l){return super.copy(r,l),this.object=r.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class X3 extends null{constructor(r,l=16776960){const h=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]),f=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],g=new Fr;g.setIndex(new vo(h,1)),g.setAttribute("position",new qi(f,3)),super(g,new Pl({color:l,toneMapped:!1})),this.box=r,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(r){const l=this.box;l.isEmpty()||(l.getCenter(this.position),l.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(r))}dispose(){this.geometry.dispose(),this.material.dispose()}}class q3 extends null{constructor(r,l=1,h=16776960){const f=h,g=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],v=new Fr;v.setAttribute("position",new qi(g,3)),v.computeBoundingSphere(),super(v,new Pl({color:f,toneMapped:!1})),this.type="PlaneHelper",this.plane=r,this.size=l;const A=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],V=new Fr;V.setAttribute("position",new qi(A,3)),V.computeBoundingSphere(),this.add(new vh(V,new Ss({color:f,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(r){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(r)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const tm=new Rt;let Dg,zy;class FE extends null{constructor(r=new Rt(0,0,1),l=new Rt(0,0,0),h=1,f=16776960,g=h*.2,v=g*.2){super(),this.type="ArrowHelper",Dg===void 0&&(Dg=new Fr,Dg.setAttribute("position",new qi([0,0,0,0,1,0],3)),zy=new md(.5,1,5,1),zy.translate(0,-.5,0)),this.position.copy(l),this.line=new gf(Dg,new Pl({color:f,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new vh(zy,new Ss({color:f,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(r),this.setLength(h,g,v)}setDirection(r){if(r.y>.99999)this.quaternion.set(0,0,0,1);else if(r.y<-.99999)this.quaternion.set(1,0,0,0);else{tm.set(r.z,0,-r.x).normalize();const l=Math.acos(r.y);this.quaternion.setFromAxisAngle(tm,l)}}setLength(r,l=r*.2,h=l*.2){this.line.scale.set(1,Math.max(1e-4,r-l),1),this.line.updateMatrix(),this.cone.scale.set(h,l,h),this.cone.position.y=r,this.cone.updateMatrix()}setColor(r){this.line.material.color.set(r),this.cone.material.color.set(r)}copy(r){return super.copy(r,!1),this.line.copy(r.line),this.cone.copy(r.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class Vy extends null{constructor(r=1){const l=[0,0,0,r,0,0,0,0,0,0,r,0,0,0,0,0,0,r],h=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],f=new Fr;f.setAttribute("position",new qi(l,3)),f.setAttribute("color",new qi(h,3));const g=new Pl({vertexColors:!0,toneMapped:!1});super(f,g),this.type="AxesHelper"}setColors(r,l,h){const f=new ar,g=this.geometry.attributes.color.array;return f.set(r),f.toArray(g,0),f.toArray(g,3),f.set(l),f.toArray(g,6),f.toArray(g,9),f.set(h),f.toArray(g,12),f.toArray(g,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class BE{constructor(){this.type="ShapePath",this.color=new ar,this.subPaths=[],this.currentPath=null}moveTo(r,l){return this.currentPath=new ry,this.subPaths.push(this.currentPath),this.currentPath.moveTo(r,l),this}lineTo(r,l){return this.currentPath.lineTo(r,l),this}quadraticCurveTo(r,l,h,f){return this.currentPath.quadraticCurveTo(r,l,h,f),this}bezierCurveTo(r,l,h,f,g,v){return this.currentPath.bezierCurveTo(r,l,h,f,g,v),this}splineThru(r){return this.currentPath.splineThru(r),this}toShapes(r){function l(pt){const Nt=[];for(let Pt=0,Gt=pt.length;Pt<Gt;Pt++){const gn=pt[Pt],Sn=new Mf;Sn.curves=gn.curves,Nt.push(Sn)}return Nt}function h(pt,Nt){const Pt=Nt.length;let Gt=!1;for(let gn=Pt-1,Sn=0;Sn<Pt;gn=Sn++){let kn=Nt[gn],In=Nt[Sn],ii=In.x-kn.x,li=In.y-kn.y;if(Math.abs(li)>Number.EPSILON){if(li<0&&(kn=Nt[Sn],ii=-ii,In=Nt[gn],li=-li),pt.y<kn.y||pt.y>In.y)continue;if(pt.y===kn.y){if(pt.x===kn.x)return!0}else{const dr=li*(pt.x-kn.x)-ii*(pt.y-kn.y);if(dr===0)return!0;if(dr<0)continue;Gt=!Gt}}else{if(pt.y!==kn.y)continue;if(In.x<=pt.x&&pt.x<=kn.x||kn.x<=pt.x&&pt.x<=In.x)return!0}}return Gt}const f=bc.isClockWise,g=this.subPaths;if(g.length===0)return[];let v,A,V;const H=[];if(g.length===1)return A=g[0],V=new Mf,V.curves=A.curves,H.push(V),H;let Z=!f(g[0].getPoints());Z=r?!Z:Z;const ce=[],he=[];let de=[],Me=0,Je;he[Me]=void 0,de[Me]=[];for(let pt=0,Nt=g.length;pt<Nt;pt++)A=g[pt],Je=A.getPoints(),v=f(Je),v=r?!v:v,v?(!Z&&he[Me]&&Me++,he[Me]={s:new Mf,p:Je},he[Me].s.curves=A.curves,Z&&Me++,de[Me]=[]):de[Me].push({h:A,p:Je[0]});if(!he[0])return l(g);if(he.length>1){let pt=!1,Nt=0;for(let Pt=0,Gt=he.length;Pt<Gt;Pt++)ce[Pt]=[];for(let Pt=0,Gt=he.length;Pt<Gt;Pt++){const gn=de[Pt];for(let Sn=0;Sn<gn.length;Sn++){const kn=gn[Sn];let In=!0;for(let ii=0;ii<he.length;ii++)h(kn.p,he[ii].p)&&(Pt!==ii&&Nt++,In?(In=!1,ce[ii].push(kn)):pt=!0);In&&ce[Pt].push(kn)}}Nt>0&&pt===!1&&(de=ce)}let mt;for(let pt=0,Nt=he.length;pt<Nt;pt++){V=he[pt].s,H.push(V),mt=de[pt];for(let Pt=0,Gt=mt.length;Pt<Gt;Pt++)V.holes.push(mt[Pt].h)}return H}}class Y3 extends null{constructor(r,l=null){super(),this.object=r,this.domElement=l,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(r){if(r===void 0){_r("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=r}disconnect(){}dispose(){}update(){}}function zf(j,r){const l=j.image&&j.image.width?j.image.width/j.image.height:1;return l>r?(j.repeat.x=1,j.repeat.y=l/r,j.offset.x=0,j.offset.y=(1-j.repeat.y)/2):(j.repeat.x=r/l,j.repeat.y=1,j.offset.x=(1-j.repeat.x)/2,j.offset.y=0),j}function eh(j,r){const l=j.image&&j.image.width?j.image.width/j.image.height:1;return l>r?(j.repeat.x=r/l,j.repeat.y=1,j.offset.x=(1-j.repeat.x)/2,j.offset.y=0):(j.repeat.x=1,j.repeat.y=l/r,j.offset.x=0,j.offset.y=(1-j.repeat.y)/2),j}function t_(j){return j.repeat.x=1,j.repeat.y=1,j.offset.x=0,j.offset.y=0,j}function Gy(j,r,l,h){const f=Og(h);switch(l){case Bu:return j*r;case F:return j*r/f.components*f.byteLength;case X:return j*r/f.components*f.byteLength;case Ie:return j*r*2/f.components*f.byteLength;case ke:return j*r*2/f.components*f.byteLength;case Pe:return j*r*3/f.components*f.byteLength;case D:return j*r*4/f.components*f.byteLength;case nt:return j*r*4/f.components*f.byteLength;case Wt:case Tt:return Math.floor((j+3)/4)*Math.floor((r+3)/4)*8;case on:case Un:return Math.floor((j+3)/4)*Math.floor((r+3)/4)*16;case bn:case Bt:return Math.max(j,16)*Math.max(r,8)/4;case sn:case ti:return Math.max(j,8)*Math.max(r,8)/2;case $n:case ni:return Math.floor((j+3)/4)*Math.floor((r+3)/4)*8;case Pi:return Math.floor((j+3)/4)*Math.floor((r+3)/4)*16;case ui:return Math.floor((j+3)/4)*Math.floor((r+3)/4)*16;case Lr:return Math.floor((j+4)/5)*Math.floor((r+3)/4)*16;case yi:return Math.floor((j+4)/5)*Math.floor((r+4)/5)*16;case vi:return Math.floor((j+5)/6)*Math.floor((r+4)/5)*16;case Mr:return Math.floor((j+5)/6)*Math.floor((r+5)/6)*16;case Zt:return Math.floor((j+7)/8)*Math.floor((r+4)/5)*16;case Fn:return Math.floor((j+7)/8)*Math.floor((r+5)/6)*16;case hi:return Math.floor((j+7)/8)*Math.floor((r+7)/8)*16;case Xn:return Math.floor((j+9)/10)*Math.floor((r+4)/5)*16;case ds:return Math.floor((j+9)/10)*Math.floor((r+5)/6)*16;case qr:return Math.floor((j+9)/10)*Math.floor((r+7)/8)*16;case vs:return Math.floor((j+9)/10)*Math.floor((r+9)/10)*16;case kr:return Math.floor((j+11)/12)*Math.floor((r+9)/10)*16;case Fs:return Math.floor((j+11)/12)*Math.floor((r+11)/12)*16;case io:case ro:case To:return Math.ceil(j/4)*Math.ceil(r/4)*16;case Eo:case Wr:return Math.ceil(j/4)*Math.ceil(r/4)*8;case eo:case Ao:return Math.ceil(j/4)*Math.ceil(r/4)*16}throw new Error(`Unable to determine texture byte length for ${l} format.`)}function Og(j){switch(j){case Oi:case Gi:return{byteLength:1,components:1};case gs:case ir:case Gs:return{byteLength:2,components:1};case Yl:case Zl:return{byteLength:2,components:4};case ls:case Ls:case ys:return{byteLength:4,components:1};case Fl:case su:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${j}.`)}class Wy{static contain(r,l){return zf(r,l)}static cover(r,l){return eh(r,l)}static fill(r){return t_(r)}static getByteLength(r,l,h,f){return Gy(r,l,h,f)}}typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:w}})),typeof window!="undefined"&&(window.__THREE__?_r("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=w)},97582:function(se,ee,b){"use strict";b.d(ee,{CR:function(){return ae},Jh:function(){return Y},Q_:function(){return Yt},XA:function(){return fe},ZT:function(){return k},_T:function(){return R},ev:function(){return Ne},mG:function(){return W},pi:function(){return O}});var w=function(Ze,rt){return w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(Mt,Ue){Mt.__proto__=Ue}||function(Mt,Ue){for(var Ye in Ue)Object.prototype.hasOwnProperty.call(Ue,Ye)&&(Mt[Ye]=Ue[Ye])},w(Ze,rt)};function k(Ze,rt){if(typeof rt!="function"&&rt!==null)throw new TypeError("Class extends value "+String(rt)+" is not a constructor or null");w(Ze,rt);function Mt(){this.constructor=Ze}Ze.prototype=rt===null?Object.create(rt):(Mt.prototype=rt.prototype,new Mt)}var O=function(){return O=Object.assign||function(rt){for(var Mt,Ue=1,Ye=arguments.length;Ue<Ye;Ue++){Mt=arguments[Ue];for(var be in Mt)Object.prototype.hasOwnProperty.call(Mt,be)&&(rt[be]=Mt[be])}return rt},O.apply(this,arguments)};function R(Ze,rt){var Mt={};for(var Ue in Ze)Object.prototype.hasOwnProperty.call(Ze,Ue)&&rt.indexOf(Ue)<0&&(Mt[Ue]=Ze[Ue]);if(Ze!=null&&typeof Object.getOwnPropertySymbols=="function")for(var Ye=0,Ue=Object.getOwnPropertySymbols(Ze);Ye<Ue.length;Ye++)rt.indexOf(Ue[Ye])<0&&Object.prototype.propertyIsEnumerable.call(Ze,Ue[Ye])&&(Mt[Ue[Ye]]=Ze[Ue[Ye]]);return Mt}function S(Ze,rt,Mt,Ue){var Ye=arguments.length,be=Ye<3?rt:Ue===null?Ue=Object.getOwnPropertyDescriptor(rt,Mt):Ue,ge;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")be=Reflect.decorate(Ze,rt,Mt,Ue);else for(var Ke=Ze.length-1;Ke>=0;Ke--)(ge=Ze[Ke])&&(be=(Ye<3?ge(be):Ye>3?ge(rt,Mt,be):ge(rt,Mt))||be);return Ye>3&&be&&Object.defineProperty(rt,Mt,be),be}function C(Ze,rt){return function(Mt,Ue){rt(Mt,Ue,Ze)}}function x(Ze,rt,Mt,Ue,Ye,be){function ge(ot){if(ot!==void 0&&typeof ot!="function")throw new TypeError("Function expected");return ot}for(var Ke=Ue.kind,wt=Ke==="getter"?"get":Ke==="setter"?"set":"value",Be=!rt&&Ze?Ue.static?Ze:Ze.prototype:null,ut=rt||(Be?Object.getOwnPropertyDescriptor(Be,Ue.name):{}),Et,je=!1,tt=Mt.length-1;tt>=0;tt--){var yt={};for(var B in Ue)yt[B]=B==="access"?{}:Ue[B];for(var B in Ue.access)yt.access[B]=Ue.access[B];yt.addInitializer=function(ot){if(je)throw new TypeError("Cannot add initializers after decoration has completed");be.push(ge(ot||null))};var te=(0,Mt[tt])(Ke==="accessor"?{get:ut.get,set:ut.set}:ut[wt],yt);if(Ke==="accessor"){if(te===void 0)continue;if(te===null||typeof te!="object")throw new TypeError("Object expected");(Et=ge(te.get))&&(ut.get=Et),(Et=ge(te.set))&&(ut.set=Et),(Et=ge(te.init))&&Ye.unshift(Et)}else(Et=ge(te))&&(Ke==="field"?Ye.unshift(Et):ut[wt]=Et)}Be&&Object.defineProperty(Be,Ue.name,ut),je=!0}function E(Ze,rt,Mt){for(var Ue=arguments.length>2,Ye=0;Ye<rt.length;Ye++)Mt=Ue?rt[Ye].call(Ze,Mt):rt[Ye].call(Ze);return Ue?Mt:void 0}function N(Ze){return typeof Ze=="symbol"?Ze:"".concat(Ze)}function L(Ze,rt,Mt){return typeof rt=="symbol"&&(rt=rt.description?"[".concat(rt.description,"]"):""),Object.defineProperty(Ze,"name",{configurable:!0,value:Mt?"".concat(Mt," ",rt):rt})}function P(Ze,rt){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(Ze,rt)}function W(Ze,rt,Mt,Ue){function Ye(be){return be instanceof Mt?be:new Mt(function(ge){ge(be)})}return new(Mt||(Mt=Promise))(function(be,ge){function Ke(ut){try{Be(Ue.next(ut))}catch(Et){ge(Et)}}function wt(ut){try{Be(Ue.throw(ut))}catch(Et){ge(Et)}}function Be(ut){ut.done?be(ut.value):Ye(ut.value).then(Ke,wt)}Be((Ue=Ue.apply(Ze,rt||[])).next())})}function Y(Ze,rt){var Mt={label:0,sent:function(){if(be[0]&1)throw be[1];return be[1]},trys:[],ops:[]},Ue,Ye,be,ge=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return ge.next=Ke(0),ge.throw=Ke(1),ge.return=Ke(2),typeof Symbol=="function"&&(ge[Symbol.iterator]=function(){return this}),ge;function Ke(Be){return function(ut){return wt([Be,ut])}}function wt(Be){if(Ue)throw new TypeError("Generator is already executing.");for(;ge&&(ge=0,Be[0]&&(Mt=0)),Mt;)try{if(Ue=1,Ye&&(be=Be[0]&2?Ye.return:Be[0]?Ye.throw||((be=Ye.return)&&be.call(Ye),0):Ye.next)&&!(be=be.call(Ye,Be[1])).done)return be;switch(Ye=0,be&&(Be=[Be[0]&2,be.value]),Be[0]){case 0:case 1:be=Be;break;case 4:return Mt.label++,{value:Be[1],done:!1};case 5:Mt.label++,Ye=Be[1],Be=[0];continue;case 7:Be=Mt.ops.pop(),Mt.trys.pop();continue;default:if(be=Mt.trys,!(be=be.length>0&&be[be.length-1])&&(Be[0]===6||Be[0]===2)){Mt=0;continue}if(Be[0]===3&&(!be||Be[1]>be[0]&&Be[1]<be[3])){Mt.label=Be[1];break}if(Be[0]===6&&Mt.label<be[1]){Mt.label=be[1],be=Be;break}if(be&&Mt.label<be[2]){Mt.label=be[2],Mt.ops.push(Be);break}be[2]&&Mt.ops.pop(),Mt.trys.pop();continue}Be=rt.call(Ze,Mt)}catch(ut){Be=[6,ut],Ye=0}finally{Ue=be=0}if(Be[0]&5)throw Be[1];return{value:Be[0]?Be[1]:void 0,done:!0}}}var ie=Object.create?function(Ze,rt,Mt,Ue){Ue===void 0&&(Ue=Mt);var Ye=Object.getOwnPropertyDescriptor(rt,Mt);(!Ye||("get"in Ye?!rt.__esModule:Ye.writable||Ye.configurable))&&(Ye={enumerable:!0,get:function(){return rt[Mt]}}),Object.defineProperty(Ze,Ue,Ye)}:function(Ze,rt,Mt,Ue){Ue===void 0&&(Ue=Mt),Ze[Ue]=rt[Mt]};function pe(Ze,rt){for(var Mt in Ze)Mt!=="default"&&!Object.prototype.hasOwnProperty.call(rt,Mt)&&ie(rt,Ze,Mt)}function fe(Ze){var rt=typeof Symbol=="function"&&Symbol.iterator,Mt=rt&&Ze[rt],Ue=0;if(Mt)return Mt.call(Ze);if(Ze&&typeof Ze.length=="number")return{next:function(){return Ze&&Ue>=Ze.length&&(Ze=void 0),{value:Ze&&Ze[Ue++],done:!Ze}}};throw new TypeError(rt?"Object is not iterable.":"Symbol.iterator is not defined.")}function ae(Ze,rt){var Mt=typeof Symbol=="function"&&Ze[Symbol.iterator];if(!Mt)return Ze;var Ue=Mt.call(Ze),Ye,be=[],ge;try{for(;(rt===void 0||rt-- >0)&&!(Ye=Ue.next()).done;)be.push(Ye.value)}catch(Ke){ge={error:Ke}}finally{try{Ye&&!Ye.done&&(Mt=Ue.return)&&Mt.call(Ue)}finally{if(ge)throw ge.error}}return be}function ye(){for(var Ze=[],rt=0;rt<arguments.length;rt++)Ze=Ze.concat(ae(arguments[rt]));return Ze}function ue(){for(var Ze=0,rt=0,Mt=arguments.length;rt<Mt;rt++)Ze+=arguments[rt].length;for(var Ue=Array(Ze),Ye=0,rt=0;rt<Mt;rt++)for(var be=arguments[rt],ge=0,Ke=be.length;ge<Ke;ge++,Ye++)Ue[Ye]=be[ge];return Ue}function Ne(Ze,rt,Mt){if(Mt||arguments.length===2)for(var Ue=0,Ye=rt.length,be;Ue<Ye;Ue++)(be||!(Ue in rt))&&(be||(be=Array.prototype.slice.call(rt,0,Ue)),be[Ue]=rt[Ue]);return Ze.concat(be||Array.prototype.slice.call(rt))}function Te(Ze){return this instanceof Te?(this.v=Ze,this):new Te(Ze)}function _e(Ze,rt,Mt){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var Ue=Mt.apply(Ze,rt||[]),Ye,be=[];return Ye=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),Ke("next"),Ke("throw"),Ke("return",ge),Ye[Symbol.asyncIterator]=function(){return this},Ye;function ge(tt){return function(yt){return Promise.resolve(yt).then(tt,Et)}}function Ke(tt,yt){Ue[tt]&&(Ye[tt]=function(B){return new Promise(function(te,ot){be.push([tt,B,te,ot])>1||wt(tt,B)})},yt&&(Ye[tt]=yt(Ye[tt])))}function wt(tt,yt){try{Be(Ue[tt](yt))}catch(B){je(be[0][3],B)}}function Be(tt){tt.value instanceof Te?Promise.resolve(tt.value.v).then(ut,Et):je(be[0][2],tt)}function ut(tt){wt("next",tt)}function Et(tt){wt("throw",tt)}function je(tt,yt){tt(yt),be.shift(),be.length&&wt(be[0][0],be[0][1])}}function Xe(Ze){var rt,Mt;return rt={},Ue("next"),Ue("throw",function(Ye){throw Ye}),Ue("return"),rt[Symbol.iterator]=function(){return this},rt;function Ue(Ye,be){rt[Ye]=Ze[Ye]?function(ge){return(Mt=!Mt)?{value:Te(Ze[Ye](ge)),done:!1}:be?be(ge):ge}:be}}function Se(Ze){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var rt=Ze[Symbol.asyncIterator],Mt;return rt?rt.call(Ze):(Ze=typeof fe=="function"?fe(Ze):Ze[Symbol.iterator](),Mt={},Ue("next"),Ue("throw"),Ue("return"),Mt[Symbol.asyncIterator]=function(){return this},Mt);function Ue(be){Mt[be]=Ze[be]&&function(ge){return new Promise(function(Ke,wt){ge=Ze[be](ge),Ye(Ke,wt,ge.done,ge.value)})}}function Ye(be,ge,Ke,wt){Promise.resolve(wt).then(function(Be){be({value:Be,done:Ke})},ge)}}function Ge(Ze,rt){return Object.defineProperty?Object.defineProperty(Ze,"raw",{value:rt}):Ze.raw=rt,Ze}var He=Object.create?function(Ze,rt){Object.defineProperty(Ze,"default",{enumerable:!0,value:rt})}:function(Ze,rt){Ze.default=rt},vt=function(Ze){return vt=Object.getOwnPropertyNames||function(rt){var Mt=[];for(var Ue in rt)Object.prototype.hasOwnProperty.call(rt,Ue)&&(Mt[Mt.length]=Ue);return Mt},vt(Ze)};function It(Ze){if(Ze&&Ze.__esModule)return Ze;var rt={};if(Ze!=null)for(var Mt=vt(Ze),Ue=0;Ue<Mt.length;Ue++)Mt[Ue]!=="default"&&ie(rt,Ze,Mt[Ue]);return He(rt,Ze),rt}function zt(Ze){return Ze&&Ze.__esModule?Ze:{default:Ze}}function Yt(Ze,rt,Mt,Ue){if(Mt==="a"&&!Ue)throw new TypeError("Private accessor was defined without a getter");if(typeof rt=="function"?Ze!==rt||!Ue:!rt.has(Ze))throw new TypeError("Cannot read private member from an object whose class did not declare it");return Mt==="m"?Ue:Mt==="a"?Ue.call(Ze):Ue?Ue.value:rt.get(Ze)}function At(Ze,rt,Mt,Ue,Ye){if(Ue==="m")throw new TypeError("Private method is not writable");if(Ue==="a"&&!Ye)throw new TypeError("Private accessor was defined without a setter");if(typeof rt=="function"?Ze!==rt||!Ye:!rt.has(Ze))throw new TypeError("Cannot write private member to an object whose class did not declare it");return Ue==="a"?Ye.call(Ze,Mt):Ye?Ye.value=Mt:rt.set(Ze,Mt),Mt}function lt(Ze,rt){if(rt===null||typeof rt!="object"&&typeof rt!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof Ze=="function"?rt===Ze:Ze.has(rt)}function Ot(Ze,rt,Mt){if(rt!=null){if(typeof rt!="object"&&typeof rt!="function")throw new TypeError("Object expected.");var Ue,Ye;if(Mt){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");Ue=rt[Symbol.asyncDispose]}if(Ue===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");Ue=rt[Symbol.dispose],Mt&&(Ye=Ue)}if(typeof Ue!="function")throw new TypeError("Object not disposable.");Ye&&(Ue=function(){try{Ye.call(this)}catch(be){return Promise.reject(be)}}),Ze.stack.push({value:rt,dispose:Ue,async:Mt})}else Mt&&Ze.stack.push({async:!0});return rt}var le=typeof SuppressedError=="function"?SuppressedError:function(Ze,rt,Mt){var Ue=new Error(Mt);return Ue.name="SuppressedError",Ue.error=Ze,Ue.suppressed=rt,Ue};function Fe(Ze){function rt(be){Ze.error=Ze.hasError?new le(be,Ze.error,"An error was suppressed during disposal."):be,Ze.hasError=!0}var Mt,Ue=0;function Ye(){for(;Mt=Ze.stack.pop();)try{if(!Mt.async&&Ue===1)return Ue=0,Ze.stack.push(Mt),Promise.resolve().then(Ye);if(Mt.dispose){var be=Mt.dispose.call(Mt.value);if(Mt.async)return Ue|=2,Promise.resolve(be).then(Ye,function(ge){return rt(ge),Ye()})}else Ue|=1}catch(ge){rt(ge)}if(Ue===1)return Ze.hasError?Promise.reject(Ze.error):Promise.resolve();if(Ze.hasError)throw Ze.error}return Ye()}function gt(Ze,rt){return typeof Ze=="string"&&/^\.\.?\//.test(Ze)?Ze.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(Mt,Ue,Ye,be,ge){return Ue?rt?".jsx":".js":Ye&&(!be||!ge)?Mt:Ye+be+"."+ge.toLowerCase()+"js"}):Ze}var Jt={__extends:k,__assign:O,__rest:R,__decorate:S,__param:C,__esDecorate:x,__runInitializers:E,__propKey:N,__setFunctionName:L,__metadata:P,__awaiter:W,__generator:Y,__createBinding:ie,__exportStar:pe,__values:fe,__read:ae,__spread:ye,__spreadArrays:ue,__spreadArray:Ne,__await:Te,__asyncGenerator:_e,__asyncDelegator:Xe,__asyncValues:Se,__makeTemplateObject:Ge,__importStar:It,__importDefault:zt,__classPrivateFieldGet:Yt,__classPrivateFieldSet:At,__classPrivateFieldIn:lt,__addDisposableResource:Ot,__disposeResources:Fe,__rewriteRelativeImportExtension:gt}}}]);
|
|
|
}()); |