You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
NewEduCoderBuild/93616.2f9f0c2f.async.js

5057 lines
2.3 MiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

!(function(){var Fq=Object.defineProperty,Bq=Object.defineProperties;var Uq=Object.getOwnPropertyDescriptors;var p3=Object.getOwnPropertySymbols,kq=Object.getPrototypeOf,zq=Object.prototype.hasOwnProperty,Vq=Object.prototype.propertyIsEnumerable,Gq=Reflect.get;var Kf=Math.pow,eE=(ae,ne,b)=>ne in ae?Fq(ae,ne,{enumerable:!0,configurable:!0,writable:!0,value:b}):ae[ne]=b,qs=(ae,ne)=>{for(var b in ne||(ne={}))zq.call(ne,b)&&eE(ae,b,ne[b]);if(p3)for(var b of p3(ne))Vq.call(ne,b)&&eE(ae,b,ne[b]);return ae},ac=(ae,ne)=>Bq(ae,Uq(ne));var aa=(ae,ne,b)=>eE(ae,typeof ne!="symbol"?ne+"":ne,b);var m3=(ae,ne,b)=>Gq(kq(ae),b,ne);var hr=(ae,ne,b)=>new Promise((w,k)=>{var O=R=>{try{S(b.next(R))}catch(x){k(x)}},A=R=>{try{S(b.throw(R))}catch(x){k(x)}},S=R=>R.done?w(R.value):Promise.resolve(R.value).then(O,A);S((b=b.apply(ae,ne)).next())});(self.webpackChunk=self.webpackChunk||[]).push([[93616],{17663:function(ae,ne,b){"use strict";b.d(ne,{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"},A=O,S=b(84089),R=function(N,L){return k.createElement(S.Z,(0,w.Z)({},N,{ref:L,icon:A}))},x=k.forwardRef(R)},73686:function(ae,ne,b){"use strict";b.d(ne,{ni:function(){return lh},EF:function(){return oi}});var w=function($,Z){var le=$.nodes,we=$.edges,Re=[],Ge={};if(!le)throw new Error("invalid nodes data!");return le&&le.forEach(function(wt,Tt){Ge[wt.id]=Tt;var Lt=[];Re.push(Lt)}),we&&we.forEach(function(wt){var Tt=wt.source,Lt=wt.target,Gt=Ge[Tt],$t=Ge[Lt];!Gt&&Gt!==0||!$t&&$t!==0||(Re[Gt][$t]=1,Z||(Re[$t][Gt]=1))}),Re},k=w,O=function($,Z){return $===Z},A=function(){function se($,Z){Z===void 0&&(Z=null),this.value=$,this.next=Z}return se.prototype.toString=function($){return $?$(this.value):"".concat(this.value)},se}(),S=function(){function se($){$===void 0&&($=O),this.head=null,this.tail=null,this.compare=$}return se.prototype.prepend=function($){var Z=new A($,this.head);return this.head=Z,this.tail||(this.tail=Z),this},se.prototype.append=function($){var Z=new A($);return this.head?(this.tail.next=Z,this.tail=Z,this):(this.head=Z,this.tail=Z,this)},se.prototype.delete=function($){if(!this.head)return null;for(var Z=null;this.head&&this.compare(this.head.value,$);)Z=this.head,this.head=this.head.next;var le=this.head;if(le!==null)for(;le.next;)this.compare(le.next.value,$)?(Z=le.next,le.next=le.next.next):le=le.next;return this.compare(this.tail.value,$)&&(this.tail=le),Z},se.prototype.find=function($){var Z=$.value,le=Z===void 0?void 0:Z,we=$.callback,Re=we===void 0?void 0:we;if(!this.head)return null;for(var Ge=this.head;Ge;){if(Re&&Re(Ge.value)||le!==void 0&&this.compare(Ge.value,le))return Ge;Ge=Ge.next}return null},se.prototype.deleteTail=function(){var $=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,$;for(var Z=this.head;Z.next;)Z.next.next?Z=Z.next:Z.next=null;return this.tail=Z,$},se.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),$},se.prototype.fromArray=function($){var Z=this;return $.forEach(function(le){return Z.append(le)}),this},se.prototype.toArray=function(){for(var $=[],Z=this.head;Z;)$.push(Z),Z=Z.next;return $},se.prototype.reverse=function(){for(var $=this.head,Z=null,le=null;$;)le=$.next,$.next=Z,Z=$,$=le;this.tail=this.head,this.head=Z},se.prototype.toString=function($){return $===void 0&&($=void 0),this.toArray().map(function(Z){return Z.toString($)}).toString()},se}(),R=S,x=function(){function se(){this.linkedList=new R}return se.prototype.isEmpty=function(){return!this.linkedList.head},se.prototype.peek=function(){return this.linkedList.head?this.linkedList.head.value:null},se.prototype.enqueue=function($){this.linkedList.append($)},se.prototype.dequeue=function(){var $=this.linkedList.deleteHead();return $?$.value:null},se.prototype.toString=function($){return this.linkedList.toString($)},se}(),E=x,N=function($,Z,le){Z===void 0&&(Z=[]);var we=Z.filter(function(Tt){return Tt.source===$||Tt.target===$});if(le==="target"){var Re=function(Lt){return Lt.source===$};return we.filter(Re).map(function(Tt){return Tt.target})}if(le==="source"){var Ge=function(Lt){return Lt.target===$};return we.filter(Ge).map(function(Tt){return Tt.source})}var wt=function(Lt){return Lt.source===$?Lt.target:Lt.source};return we.map(wt)},L=function($,Z){return Z.filter(function(le){return le.source===$})},P=function($,Z){return Z.filter(function(le){return le.source===$||le.target===$})},W=function($){$===void 0&&($=0);var Z="".concat(Math.random()).split(".")[1].substr(0,5),le="".concat(Math.random()).split(".")[1].substr(0,5);return"".concat($,"-").concat(Z).concat(le)};function K(se){se===void 0&&(se={});var $=se,Z=function(){},le=function(){var we={};return function(Re){var Ge=Re.next,wt=Ge;return we[wt]?!1:(we[wt]=!0,!0)}}();return $.allowTraversal=se.allowTraversal||le,$.enter=se.enter||Z,$.leave=se.leave||Z,$}var re=function($,Z,le,we){we===void 0&&(we=!0);var Re=K(le),Ge=new E,wt=$.edges,Tt=wt===void 0?[]:wt;Ge.enqueue(Z);for(var Lt="",Gt=function(){var hn=Ge.dequeue();Re.enter({current:hn,previous:Lt}),N(hn,Tt,we?"target":void 0).forEach(function(Ft){Re.allowTraversal({previous:Lt,current:hn,next:Ft})&&Ge.enqueue(Ft)}),Re.leave({current:hn,previous:Lt}),Lt=hn};!Ge.isEmpty();)Gt()},ye=re,ge=function($){for(var Z=$.nodes,le=Z===void 0?[]:Z,we=$.edges,Re=we===void 0?[]:we,Ge=[],wt={},Tt=[],Lt=function Ft(_n){Tt.push(_n),wt[_n.id]=!0;for(var Nn=N(_n.id,Re),Pn=function(On){var di=Nn[On];if(!wt[di]){var Ri=le.filter(function(ji){return ji.id===di});Ri.length>0&&Ft(Ri[0])}},ei=0;ei<Nn.length;++ei)Pn(ei)},Gt=0;Gt<le.length;Gt++){var $t=le[Gt];if(!wt[$t.id]){Lt($t);for(var hn=[];Tt.length>0;)hn.push(Tt.pop());Ge.push(hn)}}return Ge},ce=function($){for(var Z=$.nodes,le=Z===void 0?[]:Z,we=$.edges,Re=we===void 0?[]:we,Ge=[],wt={},Tt={},Lt={},Gt=[],$t=0,hn=function Pn(ei){Tt[ei.id]=$t,Lt[ei.id]=$t,$t+=1,Ge.push(ei),wt[ei.id]=!0;for(var ai=N(ei.id,Re,"target").filter(function(Qi){return le.map(function(er){return er.id}).indexOf(Qi)>-1}),On=function(er){var gr=ai[er];if(!Tt[gr]&&Tt[gr]!==0){var yr=le.filter(function(Nr){return Nr.id===gr});yr.length>0&&Pn(yr[0]),Lt[ei.id]=Math.min(Lt[ei.id],Lt[gr])}else wt[gr]&&(Lt[ei.id]=Math.min(Lt[ei.id],Tt[gr]))},di=0;di<ai.length;di++)On(di);if(Lt[ei.id]===Tt[ei.id]){for(var Ri=[];Ge.length>0;){var ji=Ge.pop();if(wt[ji.id]=!1,Ri.push(ji),ji===ei)break}Ri.length>0&&Gt.push(Ri)}},Ft=0,_n=le;Ft<_n.length;Ft++){var Nn=_n[Ft];!Tt[Nn.id]&&Tt[Nn.id]!==0&&hn(Nn)}return Gt};function xe(se,$){return $?ce(se):ge(se)}var fe=function($){var Z={},le=$.nodes,we=le===void 0?[]:le,Re=$.edges,Ge=Re===void 0?[]:Re;return we.forEach(function(wt){Z[wt.id]={degree:0,inDegree:0,outDegree:0}}),Ge.forEach(function(wt){Z[wt.source].degree++,Z[wt.source].outDegree++,Z[wt.target].degree++,Z[wt.target].inDegree++}),Z},Ne=fe,Ae=function($,Z){var le=fe($);return le[Z]?fe($)[Z].inDegree:0},be=function($,Z){var le=fe($);return le[Z]?fe($)[Z].outDegree:0};function Ye(se){se===void 0&&(se={});var $=se,Z=function(){},le=function(){var we={};return function(Re){var Ge=Re.next;return we[Ge]?!1:(we[Ge]=!0,!0)}}();return $.allowTraversal=se.allowTraversal||le,$.enter=se.enter||Z,$.leave=se.leave||Z,$}function Ee(se,$,Z,le,we){we===void 0&&(we=!0),le.enter({current:$,previous:Z});var Re=se.edges,Ge=Re===void 0?[]:Re;N($,Ge,we?"target":void 0).forEach(function(wt){le.allowTraversal({previous:Z,current:$,next:wt})&&Ee(se,wt,$,le,we)}),le.leave({current:$,previous:Z})}function We(se,$,Z,le){le===void 0&&(le=!0),Ee(se,$,"",Ye(Z),le)}var je=function($){var Z=null,le=$.nodes,we=le===void 0?[]:le,Re={},Ge={},wt={},Tt={};we.forEach(function($t){Ge[$t.id]=$t});for(var Lt={enter:function(hn){var Ft=hn.current,_n=hn.previous;if(wt[Ft]){Z={};for(var Nn=Ft,Pn=_n;Pn!==Ft;)Z[Nn]=Pn,Nn=Pn,Pn=Re[Pn];Z[Nn]=Pn}else wt[Ft]=Ft,delete Ge[Ft],Re[Ft]=_n},leave:function(hn){var Ft=hn.current;Tt[Ft]=Ft,delete wt[Ft]},allowTraversal:function(hn){var Ft=hn.next;return Z?!1:!Tt[Ft]}};Object.keys(Ge).length;){var Gt=Object.keys(Ge)[0];We($,Gt,Lt)}return Z},_t=function($,Z,le){var we,Re;le===void 0&&(le=!0);for(var Ge=[],wt=xe($,!1),Tt=0,Lt=wt;Tt<Lt.length;Tt++){var Gt=Lt[Tt];if(Gt.length)for(var $t=Gt[0],hn=$t.id,Ft=[$t],_n=(we={},we[hn]=$t,we),Nn=(Re={},Re[hn]=new Set,Re);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(Es){return Es.id===er});if(er===ei)Ge.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,Nr=[gr,Pn],Ji=_n[ei];Nn[er].size&&!Nn[er].has(Ji)&&(Nr.push(Ji),Ji!==_n[Ji.id]);)Ji=_n[Ji.id];if(Nr.push(Ji),Z&&le?(yr=!1,Nr.findIndex(function(Es){return Z.indexOf(Es.id)>-1})>-1&&(yr=!0)):Z&&!le&&Nr.findIndex(function(Es){return Z.indexOf(Es.id)>-1})>-1&&(yr=!1),yr){for(var cs={},ds=1;ds<Nr.length;ds+=1)cs[Nr[ds-1].id]=Nr[ds];Nr.length&&(cs[Nr[Nr.length-1].id]=Nr[0]),Ge.push(cs)}Nn[er].add(Pn)}},di=0;di<ai.length;di+=1)On(di)}return Ge},It=function($,Z,le){le===void 0&&(le=!0);for(var we=[],Re=new Set,Ge=[],wt=[],Tt={},Lt={},Gt=function(Ji){for(var cs=[Ji];cs.length>0;){var ds=cs.pop();Re.has(ds)&&(Re.delete(ds),Ge[ds.id].forEach(function(Es){cs.push(Es)}),Ge[ds.id].clear())}},$t=function Nr(Ji,cs,ds){var Es=!1;if(Z&&le===!1&&Z.indexOf(Ji.id)>-1)return Es;we.push(Ji),Re.add(Ji);for(var Gs=ds[Ji.id],As=0;As<Gs.length;As+=1){var us=Tt[Gs[As]];if(us===cs){for(var Mi={},Xi=1;Xi<we.length;Xi+=1)Mi[we[Xi-1].id]=we[Xi];we.length&&(Mi[we[we.length-1].id]=we[0]),wt.push(Mi),Es=!0}else Re.has(us)||Nr(us,cs,ds)&&(Es=!0)}if(Es)Gt(Ji);else for(var As=0;As<Gs.length;As+=1){var us=Tt[Gs[As]];Ge[us.id].has(Ji)||Ge[us.id].add(Ji)}return we.pop(),Es},hn=$.nodes,Ft=hn===void 0?[]:hn,_n=0;_n<Ft.length;_n+=1){var Nn=Ft[_n],Pn=Nn.id;Lt[Pn]=_n,Tt[_n]=Nn}if(Z&&le)for(var ei=function(Ji){var cs=Z[Ji];Lt[Ft[Ji].id]=Lt[cs],Lt[cs]=0,Tt[0]=Ft.find(function(ds){return ds.id===cs}),Tt[Lt[Ft[Ji].id]]=Ft[Ji]},_n=0;_n<Z.length;_n++)ei(_n);for(var ai=function(Ji){for(var cs,ds,Es=1/0,Gs=0;Gs<Ji.length;Gs+=1)for(var As=Ji[Gs],us=0;us<As.length;us++){var Mi=Lt[As[us].id];Mi<Es&&(Es=Mi,ds=Gs)}for(var Xi=Ji[ds],Br=[],Gs=0;Gs<Xi.length;Gs+=1){var kr=Xi[Gs];Br[kr.id]=[];for(var Dr=0,Jr=N(kr.id,$.edges,"target").filter(function(Ka){return Xi.map(function(oo){return oo.id}).indexOf(Ka)>-1});Dr<Jr.length;Dr++){var Ls=Jr[Dr];Ls===kr.id&&!(le===!1&&Z.indexOf(kr.id)>-1)?wt.push((cs={},cs[kr.id]=kr,cs)):Br[kr.id].push(Lt[Ls])}}return{component:Xi,adjList:Br,minIdx:Es}},On=0;On<Ft.length;){var di=Ft.filter(function(Nr){return Lt[Nr.id]>=On}),Ri=ce({nodes:di,edges:$.edges}).filter(function(Nr){return Nr.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(Nr){Ge[Nr.id]=new Set});var yr=Tt[Qi];if(Z&&le&&Z.indexOf(yr.id)===-1)return wt;$t(yr,yr,er),On=Qi+1}else break}return wt},kt=function($,Z,le,we){return we===void 0&&(we=!0),Z?It($,le,we):_t($,le,we)},Ut=je,At=function(se,$){return At=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(Z,le){Z.__proto__=le}||function(Z,le){for(var we in le)Object.prototype.hasOwnProperty.call(le,we)&&(Z[we]=le[we])},At(se,$)};function at(se,$){if(typeof $!="function"&&$!==null)throw new TypeError("Class extends value "+String($)+" is not a constructor or null");At(se,$);function Z(){this.constructor=se}se.prototype=$===null?Object.create($):(Z.prototype=$.prototype,new Z)}var Ot=function(){return Ot=Object.assign||function($){for(var Z,le=1,we=arguments.length;le<we;le++){Z=arguments[le];for(var Re in Z)Object.prototype.hasOwnProperty.call(Z,Re)&&($[Re]=Z[Re])}return $},Ot.apply(this,arguments)};function ue(se,$){var Z={};for(var le in se)Object.prototype.hasOwnProperty.call(se,le)&&$.indexOf(le)<0&&(Z[le]=se[le]);if(se!=null&&typeof Object.getOwnPropertySymbols=="function")for(var we=0,le=Object.getOwnPropertySymbols(se);we<le.length;we++)$.indexOf(le[we])<0&&Object.prototype.propertyIsEnumerable.call(se,le[we])&&(Z[le[we]]=se[le[we]]);return Z}function Ue(se,$,Z,le){var we=arguments.length,Re=we<3?$:le===null?le=Object.getOwnPropertyDescriptor($,Z):le,Ge;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Re=Reflect.decorate(se,$,Z,le);else for(var wt=se.length-1;wt>=0;wt--)(Ge=se[wt])&&(Re=(we<3?Ge(Re):we>3?Ge($,Z,Re):Ge($,Z))||Re);return we>3&&Re&&Object.defineProperty($,Z,Re),Re}function vt(se,$){return function(Z,le){$(Z,le,se)}}function Jt(se,$,Z,le,we,Re){function Ge(ei){if(ei!==void 0&&typeof ei!="function")throw new TypeError("Function expected");return ei}for(var wt=le.kind,Tt=wt==="getter"?"get":wt==="setter"?"set":"value",Lt=!$&&se?le.static?se:se.prototype:null,Gt=$||(Lt?Object.getOwnPropertyDescriptor(Lt,le.name):{}),$t,hn=!1,Ft=Z.length-1;Ft>=0;Ft--){var _n={};for(var Nn in le)_n[Nn]=Nn==="access"?{}:le[Nn];for(var Nn in le.access)_n.access[Nn]=le.access[Nn];_n.addInitializer=function(ei){if(hn)throw new TypeError("Cannot add initializers after decoration has completed");Re.push(Ge(ei||null))};var Pn=(0,Z[Ft])(wt==="accessor"?{get:Gt.get,set:Gt.set}:Gt[Tt],_n);if(wt==="accessor"){if(Pn===void 0)continue;if(Pn===null||typeof Pn!="object")throw new TypeError("Object expected");($t=Ge(Pn.get))&&(Gt.get=$t),($t=Ge(Pn.set))&&(Gt.set=$t),($t=Ge(Pn.init))&&we.push($t)}else($t=Ge(Pn))&&(wt==="field"?we.push($t):Gt[Tt]=$t)}Lt&&Object.defineProperty(Lt,le.name,Gt),hn=!0}function Qe(se,$,Z){for(var le=arguments.length>2,we=0;we<$.length;we++)Z=le?$[we].call(se,Z):$[we].call(se);return le?Z:void 0}function rt(se){return typeof se=="symbol"?se:"".concat(se)}function bt(se,$,Z){return typeof $=="symbol"&&($=$.description?"[".concat($.description,"]"):""),Object.defineProperty(se,"name",{configurable:!0,value:Z?"".concat(Z," ",$):$})}function ze(se,$){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(se,$)}function Ze(se,$,Z,le){function we(Re){return Re instanceof Z?Re:new Z(function(Ge){Ge(Re)})}return new(Z||(Z=Promise))(function(Re,Ge){function wt(Gt){try{Lt(le.next(Gt))}catch($t){Ge($t)}}function Tt(Gt){try{Lt(le.throw(Gt))}catch($t){Ge($t)}}function Lt(Gt){Gt.done?Re(Gt.value):we(Gt.value).then(wt,Tt)}Lt((le=le.apply(se,$||[])).next())})}function q(se,$){var Z={label:0,sent:function(){if(Re[0]&1)throw Re[1];return Re[1]},trys:[],ops:[]},le,we,Re,Ge;return Ge={next:wt(0),throw:wt(1),return:wt(2)},typeof Symbol=="function"&&(Ge[Symbol.iterator]=function(){return this}),Ge;function wt(Lt){return function(Gt){return Tt([Lt,Gt])}}function Tt(Lt){if(le)throw new TypeError("Generator is already executing.");for(;Ge&&(Ge=0,Lt[0]&&(Z=0)),Z;)try{if(le=1,we&&(Re=Lt[0]&2?we.return:Lt[0]?we.throw||((Re=we.return)&&Re.call(we),0):we.next)&&!(Re=Re.call(we,Lt[1])).done)return Re;switch(we=0,Re&&(Lt=[Lt[0]&2,Re.value]),Lt[0]){case 0:case 1:Re=Lt;break;case 4:return Z.label++,{value:Lt[1],done:!1};case 5:Z.label++,we=Lt[1],Lt=[0];continue;case 7:Lt=Z.ops.pop(),Z.trys.pop();continue;default:if(Re=Z.trys,!(Re=Re.length>0&&Re[Re.length-1])&&(Lt[0]===6||Lt[0]===2)){Z=0;continue}if(Lt[0]===3&&(!Re||Lt[1]>Re[0]&&Lt[1]<Re[3])){Z.label=Lt[1];break}if(Lt[0]===6&&Z.label<Re[1]){Z.label=Re[1],Re=Lt;break}if(Re&&Z.label<Re[2]){Z.label=Re[2],Z.ops.push(Lt);break}Re[2]&&Z.ops.pop(),Z.trys.pop();continue}Lt=$.call(se,Z)}catch(Gt){Lt=[6,Gt],we=0}finally{le=Re=0}if(Lt[0]&5)throw Lt[1];return{value:Lt[0]?Lt[1]:void 0,done:!0}}}var Y=Object.create?function(se,$,Z,le){le===void 0&&(le=Z);var we=Object.getOwnPropertyDescriptor($,Z);(!we||("get"in we?!$.__esModule:we.writable||we.configurable))&&(we={enumerable:!0,get:function(){return $[Z]}}),Object.defineProperty(se,le,we)}:function(se,$,Z,le){le===void 0&&(le=Z),se[le]=$[Z]};function de(se,$){for(var Z in se)Z!=="default"&&!Object.prototype.hasOwnProperty.call($,Z)&&Y($,se,Z)}function Je(se){var $=typeof Symbol=="function"&&Symbol.iterator,Z=$&&se[$],le=0;if(Z)return Z.call(se);if(se&&typeof se.length=="number")return{next:function(){return se&&le>=se.length&&(se=void 0),{value:se&&se[le++],done:!se}}};throw new TypeError($?"Object is not iterable.":"Symbol.iterator is not defined.")}function Te(se,$){var Z=typeof Symbol=="function"&&se[Symbol.iterator];if(!Z)return se;var le=Z.call(se),we,Re=[],Ge;try{for(;($===void 0||$-- >0)&&!(we=le.next()).done;)Re.push(we.value)}catch(wt){Ge={error:wt}}finally{try{we&&!we.done&&(Z=le.return)&&Z.call(le)}finally{if(Ge)throw Ge.error}}return Re}function $e(){for(var se=[],$=0;$<arguments.length;$++)se=se.concat(Te(arguments[$]));return se}function xt(){for(var se=0,$=0,Z=arguments.length;$<Z;$++)se+=arguments[$].length;for(var le=Array(se),we=0,$=0;$<Z;$++)for(var Re=arguments[$],Ge=0,wt=Re.length;Ge<wt;Ge++,we++)le[we]=Re[Ge];return le}function ke(se,$,Z){if(Z||arguments.length===2)for(var le=0,we=$.length,Re;le<we;le++)(Re||!(le in $))&&(Re||(Re=Array.prototype.slice.call($,0,le)),Re[le]=$[le]);return se.concat(Re||Array.prototype.slice.call($))}function et(se){return this instanceof et?(this.v=se,this):new et(se)}function yt(se,$,Z){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var le=Z.apply(se,$||[]),we,Re=[];return we={},Ge("next"),Ge("throw"),Ge("return"),we[Symbol.asyncIterator]=function(){return this},we;function Ge(hn){le[hn]&&(we[hn]=function(Ft){return new Promise(function(_n,Nn){Re.push([hn,Ft,_n,Nn])>1||wt(hn,Ft)})})}function wt(hn,Ft){try{Tt(le[hn](Ft))}catch(_n){$t(Re[0][3],_n)}}function Tt(hn){hn.value instanceof et?Promise.resolve(hn.value.v).then(Lt,Gt):$t(Re[0][2],hn)}function Lt(hn){wt("next",hn)}function Gt(hn){wt("throw",hn)}function $t(hn,Ft){hn(Ft),Re.shift(),Re.length&&wt(Re[0][0],Re[0][1])}}function B(se){var $,Z;return $={},le("next"),le("throw",function(we){throw we}),le("return"),$[Symbol.iterator]=function(){return this},$;function le(we,Re){$[we]=se[we]?function(Ge){return(Z=!Z)?{value:et(se[we](Ge)),done:!1}:Re?Re(Ge):Ge}:Re}}function ie(se){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var $=se[Symbol.asyncIterator],Z;return $?$.call(se):(se=typeof Je=="function"?Je(se):se[Symbol.iterator](),Z={},le("next"),le("throw"),le("return"),Z[Symbol.asyncIterator]=function(){return this},Z);function le(Re){Z[Re]=se[Re]&&function(Ge){return new Promise(function(wt,Tt){Ge=se[Re](Ge),we(wt,Tt,Ge.done,Ge.value)})}}function we(Re,Ge,wt,Tt){Promise.resolve(Tt).then(function(Lt){Re({value:Lt,done:wt})},Ge)}}function ct(se,$){return Object.defineProperty?Object.defineProperty(se,"raw",{value:$}):se.raw=$,se}var Mt=Object.create?function(se,$){Object.defineProperty(se,"default",{enumerable:!0,value:$})}:function(se,$){se.default=$};function ht(se){if(se&&se.__esModule)return se;var $={};if(se!=null)for(var Z in se)Z!=="default"&&Object.prototype.hasOwnProperty.call(se,Z)&&Y($,se,Z);return Mt($,se),$}function Yt(se){return se&&se.__esModule?se:{default:se}}function en(se,$,Z,le){if(Z==="a"&&!le)throw new TypeError("Private accessor was defined without a getter");if(typeof $=="function"?se!==$||!le:!$.has(se))throw new TypeError("Cannot read private member from an object whose class did not declare it");return Z==="m"?le:Z==="a"?le.call(se):le?le.value:$.get(se)}function nn(se,$,Z,le,we){if(le==="m")throw new TypeError("Private method is not writable");if(le==="a"&&!we)throw new TypeError("Private accessor was defined without a setter");if(typeof $=="function"?se!==$||!we:!$.has(se))throw new TypeError("Cannot write private member to an object whose class did not declare it");return le==="a"?we.call(se,Z):we?we.value=Z:$.set(se,Z),Z}function Me(se,$){if($===null||typeof $!="object"&&typeof $!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof se=="function"?$===se:se.has($)}var te={}.toString,Fe=function(se,$){return te.call(se)==="[object "+$+"]"},Xe=Fe,Pe=function(se){return Xe(se,"Function")},Ie=function(se){return Array.isArray?Array.isArray(se):Xe(se,"Array")},Ke=function(se){var $=typeof se;return se!==null&&$==="object"||$==="function"};function lt(se,$){if(se){var Z;if(Ie(se))for(var le=0,we=se.length;le<we&&(Z=$(se[le],le),Z!==!1);le++);else if(Ke(se)){for(var Re in se)if(se.hasOwnProperty(Re)&&(Z=$(se[Re],Re),Z===!1))break}}}var qe=lt,pt=Object.keys?function(se){return Object.keys(se)}:function(se){var $=[];return qe(se,function(Z,le){Pe(se)&&le==="prototype"||$.push(le)}),$},Ct=null;function Xt(se,$){var Z=keys($),le=Z.length;if(isNil(se))return!le;for(var we=0;we<le;we+=1){var Re=Z[we];if($[Re]!==se[Re]||!(Re in se))return!1}return!0}var Qt=null,pn=function(se){if(!isObjectLike(se)||!isType(se,"Object"))return!1;if(Object.getPrototypeOf(se)===null)return!0;for(var $=se;Object.getPrototypeOf($)!==null;)$=Object.getPrototypeOf($);return Object.getPrototypeOf(se)===$},Wn=null;function Rn(se,$){if(!isArray(se))return null;var Z;if(isFunction($)&&(Z=$),isPlainObject($)&&(Z=function(we){return isMatch(we,$)}),Z){for(var le=0;le<se.length;le+=1)if(Z(se[le]))return se[le]}return null}var bi=null,Lr=function(se,$){for(var Z=null,le=0;le<se.length;le++){var we=se[le],Re=we[$];if(!isNil(Re)){isArray(Re)?Z=Re[0]:Z=Re;break}}return Z},Qn=null,Vi=function(se){if(!isArray(se))return[];for(var $=[],Z=0;Z<se.length;Z++)$=$.concat(se[Z]);return $},Oi=null,Gi=function(se,$){if($===void 0&&($=[]),!isArray(se))$.push(se);else for(var Z=0;Z<se.length;Z+=1)Gi(se[Z],$);return $},ir=null,ms=function(se){if(isArray(se))return se.reduce(function($,Z){return Math.max($,Z)},se[0])},Is=function(se){if(isArray(se))return se.reduce(function($,Z){return Math.min($,Z)},se[0])},as=function(se){var $=se.filter(function(Ge){return!isNaN(Ge)});if(!$.length)return{min:0,max:0};if(isArray(se[0])){for(var Z=[],le=0;le<se.length;le++)Z=Z.concat(se[le]);$=Z}var we=getMax($),Re=getMin($);return{min:Re,max:we}},gs=null,Vs=Array.prototype,Xl=Vs.splice,ql=Vs.indexOf,Da=function(se){for(var $=[],Z=1;Z<arguments.length;Z++)$[Z-1]=arguments[Z];for(var le=0;le<$.length;le++)for(var we=$[le],Re=-1;(Re=ql.call(se,we))>-1;)Xl.call(se,Re,1);return se},Dl=null,nu=Array.prototype.splice,Du=function($,Z){if(!isArrayLike($))return[];for(var le=$?Z.length:0,we=le-1;le--;){var Re=void 0,Ge=Z[le];(le===we||Ge!==Re)&&(Re=Ge,nu.call($,Ge,1))}return $},Le=null,D=function(se,$,Z){if(!isArray(se)&&!isPlainObject(se))return se;var le=Z;return each(se,function(we,Re){le=$(le,we,Re)}),le},U=null,_=function(se,$){var Z=[];if(!isArrayLike(se))return Z;for(var le=-1,we=[],Re=se.length;++le<Re;){var Ge=se[le];$(Ge,le,se)&&(Z.push(Ge),we.push(le))}return pullAt(se,we),Z},F=null,X=function(se){return Xe(se,"String")};function De(se,$){var Z;if(isFunction($))Z=function(we,Re){return $(we)-$(Re)};else{var le=[];isString($)?le.push($):isArray($)&&(le=$),Z=function(we,Re){for(var Ge=0;Ge<le.length;Ge+=1){var wt=le[Ge];if(we[wt]>Re[wt])return 1;if(we[wt]<Re[wt])return-1}return 0}}return se.sort(Z),se}var Ve=null;function it(se,$){$===void 0&&($=new Map);var Z=[];if(Array.isArray(se))for(var le=0,we=se.length;le<we;le++){var Re=se[le];$.has(Re)||(Z.push(Re),$.set(Re,!0))}return Z}var st=function(se,$){for(var Z=[],le={},we=0;we<se.length;we++){var Re=se[we],Ge=Re[$];if(!isNil(Ge)){isArray(Ge)||(Ge=[Ge]);for(var wt=0;wt<Ge.length;wt++){var Tt=Ge[wt];le[Tt]||(Z.push(Tt),le[Tt]=!0)}}}return Z};function Ht(se,$){return isArray(se)||isString(se)?se[0]===$:!1}var Et=null;function on(se,$){return isArray(se)||isString(se)?se[se.length-1]===$:!1}var Un=null,sn=Object.prototype.hasOwnProperty;function bn(se,$){if(!$||!isArray(se))return{};for(var Z={},le=isFunction($)?$:function(wt){return wt[$]},we,Re=0;Re<se.length;Re++){var Ge=se[Re];we=le(Ge),sn.call(Z,we)?Z[we].push(Ge):Z[we]=[Ge]}return Z}var ti=null;function Bt(se,$){if(!$)return{0:se};if(!isFunction($)){var Z=isArray($)?$:$.replace(/\s+/g,"").split("*");$=function(le){for(var we="_",Re=0,Ge=Z.length;Re<Ge;Re++)we+=le[Z[Re]]&&le[Z[Re]].toString();return we}}return groupBy(se,$)}var $n=function(se,$){if(!$)return[se];var Z=groupToMap(se,$),le=[];for(var we in Z)le.push(Z[we]);return le},ni={};function Pi(se){var $=ni[se];if(!$){for(var Z=se.toString(16),le=Z.length;le<6;le++)Z="0"+Z;$="#"+Z,ni[se]=$}return $}var ui=null;function Ir(se){var $=0,Z=0,le=0,we=0;return isArray(se)?se.length===1?$=Z=le=we=se[0]:se.length===2?($=le=se[0],Z=we=se[1]):se.length===3?($=se[0],Z=we=se[1],le=se[2]):($=se[0],Z=se[1],le=se[2],we=se[3]):$=Z=le=we=se,{r1:$,r2:Z,r3:le,r4:we}}var yi=null,vi=function(se){return Xe(se,"Number")},Mr=vi,Zt=function(se){return isNumber(se)&&se%1!==0},Fn=null,hi=function(se){return isNumber(se)&&se%2===0},Xn=null,hs=Number.isInteger?Number.isInteger:function(se){return Mr(se)&&se%1===0},Xr=null,ys=function(se){return isNumber(se)&&se<0},Ur=null,Os=function(se){return isNumber(se)&&se%2!==0},no=null,io=function(se){return isNumber(se)&&se>0},So=null,To=function(se,$){if(isArray(se)){for(var Z,le=-1/0,we=0;we<se.length;we++){var Re=se[we],Ge=isFunction($)?$(Re):Re[$];Ge>le&&(Z=Re,le=Ge)}return Z}},Gr=function(se,$){if(isArray(se)){for(var Z,le=1/0,we=0;we<se.length;we++){var Re=se[we],Ge=isFunction($)?$(Re):Re[$];Ge<le&&(Z=Re,le=Ge)}return Z}},Qs=180/Math.PI,Eo=function(se){return Qs*se},ro=null,qr=Math.PI/180,la=function(se){return qr*se},Ao=null,il=null,rl=Object.values?function(se){return Object.values(se)}:function(se){var $=[];return qe(se,function(Z,le){Pe(se)&&le==="prototype"||$.push(Z)}),$},ca=rl,Oa=function(se,$){return contains(values(se),$)},sl={}.toString,bo=function(se){return sl.call(se).replace(/^\[object /,"").replace(/]$/,"")},Pc=null,Qv=function(se){return isType(se,"Arguments")},oh=null,y0=function(se){return isType(se,"Boolean")},Jf=null,Qf=function(se){return isType(se,"Date")},v0=null,Pm=function(se){return isType(se,"Error")},$a=null;function jd(se){return isNumber(se)&&isFinite(se)}var Qo=Object.prototype,co=function(se){var $=se&&se.constructor,Z=typeof $=="function"&&$.prototype||Qo;return se===Z},iu=null,ah=function(se){return isType(se,"RegExp")},Fi=null,Jb=function(){for(var se=[],$=0;$<arguments.length;$++)se[$]=arguments[$];for(var Z=se[0],le=1;le<se.length;le++){var we=se[le];isFunction(we)&&(we=we.prototype),mix(Z.prototype,we)}},Yl=null,Im=function(se){if(typeof se!="object"||se===null)return se;var $;if(Ie(se)){$=[];for(var Z=0,le=se.length;Z<le;Z++)typeof se[Z]=="object"&&se[Z]!=null?$[Z]=Im(se[Z]):$[Z]=se[Z]}else{$={};for(var we in se)typeof se[we]=="object"&&se[we]!=null?$[we]=Im(se[we]):$[we]=se[we]}return $},Xd=Im,ex=function(se,$){if(!Pe(se))throw new TypeError("Expected a function");var Z=function(){for(var le=[],we=0;we<arguments.length;we++)le[we]=arguments[we];var Re=$?$.apply(this,le):le[0],Ge=Z.cache;if(Ge.has(Re))return Ge.get(Re);var wt=se.apply(this,le);return Ge.set(Re,wt),wt};return Z.cache=new Map,Z},tx=5;function x0(se,$,Z,le){Z=Z||0,le=le||tx;for(var we in $)if($.hasOwnProperty(we)){var Re=$[we];Re!==null&&isPlainObject(Re)?(isPlainObject(se[we])||(se[we]={}),Z<le?x0(se[we],Re,Z+1,le):se[we]=$[we]):isArray(Re)?(se[we]=[],se[we]=se[we].concat(Re)):Re!==void 0&&(se[we]=Re)}}var Qb=function(se){for(var $=[],Z=1;Z<arguments.length;Z++)$[Z-1]=arguments[Z];for(var le=0;le<$.length;le+=1)x0(se,$[le]);return se},e1=null,t1=function(se,$,Z,le){isFunction($)||(Z=$,$=se,se=function(){});var we=Object.create?function(Ge,wt){return Object.create(Ge,{constructor:{value:wt}})}:function(Ge,wt){function Tt(){}Tt.prototype=Ge;var Lt=new Tt;return Lt.constructor=wt,Lt},Re=we($.prototype,se);return se.prototype=mix(Re,se.prototype),se.superclass=we($.prototype,$),mix(Re,Z),mix(se,le),se},n1=null,nx=Object.prototype.hasOwnProperty;function i1(se){if(isNil(se))return!0;if(isArrayLike(se))return!se.length;var $=getType(se);if($==="Map"||$==="Set")return!se.size;if(isPrototype(se))return!Object.keys(se).length;for(var Z in se)if(nx.call(se,Z))return!1;return!0}var r1=null,ix=function(se){return typeof se=="object"&&se!==null},Xh=ix,Lm=function(se){return se!==null&&typeof se!="function"&&isFinite(se.length)},qd=Lm,Yd=function(se,$){if(se===$)return!0;if(!se||!$||X(se)||X($))return!1;if(qd(se)||qd($)){if(se.length!==$.length)return!1;for(var Z=!0,le=0;le<se.length&&(Z=Yd(se[le],$[le]),!!Z);le++);return Z}if(Xh(se)||Xh($)){var we=Object.keys(se),Re=Object.keys($);if(we.length!==Re.length)return!1;for(var Z=!0,le=0;le<we.length&&(Z=Yd(se[we[le]],$[we[le]]),!!Z);le++);return Z}return!1},ep=Yd,_0=function(se,$,Z){return isFunction(Z)?!!Z(se,$):isEqual(se,$)},b0=function(se,$,Z){for(var le=0,we=isString($)?$.split("."):$;se&&le<we.length;)se=se[we[le++]];return se===void 0||le<we.length?Z:se},w0=function(se,$,Z){var le=se,we=isString($)?$.split("."):$;return we.forEach(function(Re,Ge){Ge<we.length-1?(isObject(le[Re])||(le[Re]=isNumber(we[Ge+1])?[]:{}),le=le[Re]):le[Re]=Z}),se},Dm=Object.prototype.hasOwnProperty,Ou=function(se,$){if(se===null||!isPlainObject(se))return{};var Z={};return each($,function(le){Dm.call(se,le)&&(Z[le]=se[le])}),Z},Zd=function(se,$){return reduce(se,function(Z,le,we){return $.includes(we)||(Z[we]=le),Z},{})},Om={},iE=function(se){return se=se||"g",Om[se]?Om[se]+=1:Om[se]=1,se+Om[se]},Fm,rE=ex(function(se,$){$===void 0&&($={});var Z=$.fontSize,le=$.fontFamily,we=$.fontWeight,Re=$.fontStyle,Ge=$.fontVariant;return Fm||(Fm=document.createElement("canvas").getContext("2d")),Fm.font=[Re,Ge,we,Z+"px",le].join(" "),Fm.measureText(X(se)?se:"").width},function(se,$){return $===void 0&&($={}),xt([se],ca($)).join("")}),sE=function(se,$,Z,le){le===void 0&&(le="...");var we=16,Re=measureTextWidth(le,Z),Ge=isString(se)?se:toString(se),wt=$,Tt=[],Lt,Gt;if(measureTextWidth(se,Z)<=$)return se;for(;Lt=Ge.substr(0,we),Gt=measureTextWidth(Lt,Z),!(Gt+Re>wt&&Gt>wt);)if(Tt.push(Lt),wt-=Gt,Ge=Ge.substr(we),!Ge)return Tt.join("");for(;Lt=Ge.substr(0,1),Gt=measureTextWidth(Lt,Z),!(Gt+Re>wt);)if(Tt.push(Lt),wt-=Gt,Ge=Ge.substr(1),!Ge)return Tt.join("");return""+Tt.join("")+le},oE=function(){function se(){this.map={}}return se.prototype.has=function($){return this.map[$]!==void 0},se.prototype.get=function($,Z){var le=this.map[$];return le===void 0?Z:le},se.prototype.set=function($,Z){this.map[$]=Z},se.prototype.clear=function(){this.map={}},se.prototype.delete=function($){delete this.map[$]},se.prototype.size=function(){return Object.keys(this.map).length},se}(),aE=null,s1=function($,Z,le){for(var we=1/0,Re,Ge=0;Ge<Z.length;Ge++){var wt=Z[Ge].id;!le[wt]&&$[wt]<=we&&(we=$[wt],Re=Z[Ge])}return Re},M0=function($,Z,le,we){var Re=$.nodes,Ge=Re===void 0?[]:Re,wt=$.edges,Tt=wt===void 0?[]:wt,Lt=[],Gt={},$t={},hn={};Ge.forEach(function(On,di){var Ri=On.id;Lt.push(Ri),$t[Ri]=1/0,Ri===Z&&($t[Ri]=0)});for(var Ft=Ge.length,_n=function(di){var Ri=s1($t,Ge,Gt),ji=Ri.id;if(Gt[ji]=!0,$t[ji]===1/0)return"continue";var Qi=[];le?Qi=L(ji,Tt):Qi=P(ji,Tt),Qi.forEach(function(er){var gr=er.target,yr=er.source,Nr=gr===ji?yr:gr,Ji=we&&er[we]?er[we]:1;$t[Nr]>$t[Ri.id]+Ji?($t[Nr]=$t[Ri.id]+Ji,hn[Nr]=[Ri.id]):$t[Nr]===$t[Ri.id]+Ji&&hn[Nr].push(Ri.id)})},Nn=0;Nn<Ft;Nn++)_n(Nn);hn[Z]=[Z];var Pn={};for(var ei in $t)$t[ei]!==1/0&&ja(Z,ei,hn,Pn);var ai={};for(var ei in Pn)ai[ei]=Pn[ei][0];return{length:$t,path:ai,allPath:Pn}},so=M0;function ja(se,$,Z,le){if(se===$)return[se];if(le[$])return le[$];for(var we=[],Re=0,Ge=Z[$];Re<Ge.length;Re++){var wt=Ge[Re],Tt=ja(se,wt,Z,le);if(!Tt)return;for(var Lt=0,Gt=Tt;Lt<Gt.length;Lt++){var $t=Gt[Lt];Ie($t)?we.push(ke(ke([],$t,!0),[$],!1)):we.push([$t,$])}}return le[$]=we,le[$]}var lh=function($,Z,le,we,Re){var Ge=so($,Z,we,Re),wt=Ge.length,Tt=Ge.path,Lt=Ge.allPath;return{length:wt[le],path:Tt[le],allPath:Lt[le]}},o1=function($,Z,le,we){var Re;if(Z===le)return[[Z]];var Ge=$.edges,wt=Ge===void 0?[]:Ge,Tt=[Z],Lt=(Re={},Re[Z]=!0,Re),Gt=[],$t=[],hn=we?N(Z,wt,"target"):N(Z,wt);for(Gt.push(hn);Tt.length>0&&Gt.length>0;){var Ft=Gt[Gt.length-1];if(Ft.length){var _n=Ft.shift();_n&&(Tt.push(_n),Lt[_n]=!0,hn=we?N(_n,wt,"target"):N(_n,wt),Gt.push(hn.filter(function(ei){return!Lt[ei]})))}else{var Nn=Tt.pop();Lt[Nn]=!1,Gt.pop();continue}if(Tt[Tt.length-1]===le){var Pn=Tt.map(function(ai){return ai});$t.push(Pn);var Nn=Tt.pop();Lt[Nn]=!1,Gt.pop()}}return $t},a1=function($,Z){for(var le=k($,Z),we=[],Re=le.length,Ge=0;Ge<Re;Ge+=1){we[Ge]=[];for(var wt=0;wt<Re;wt+=1)Ge===wt?we[Ge][wt]=0:le[Ge][wt]===0||!le[Ge][wt]?we[Ge][wt]=1/0:we[Ge][wt]=le[Ge][wt]}for(var Tt=0;Tt<Re;Tt+=1)for(var Ge=0;Ge<Re;Ge+=1)for(var wt=0;wt<Re;wt+=1)we[Ge][wt]>we[Ge][Tt]+we[Tt][wt]&&(we[Ge][wt]=we[Ge][Tt]+we[Tt][wt]);return we},Ol=a1,Xa=function($,Z,le,we){Z===void 0&&(Z=!1),le===void 0&&(le="weight"),we===void 0&&(we=1e3);var Re=$.nodes,Ge=Re===void 0?[]:Re,wt=$.edges,Tt=wt===void 0?[]:wt,Lt={},Gt={};Ge.forEach(function(di,Ri){var ji=W();di.clusterId=ji,Lt[ji]={id:ji,nodes:[di]},Gt[di.id]={node:di,idx:Ri}});var $t=k($,Z),hn=[],Ft={};$t.forEach(function(di,Ri){var ji=0,Qi=Ge[Ri].id;Ft[Qi]={},di.forEach(function(er,gr){if(er){ji+=er;var yr=Ge[gr].id;Ft[Qi][yr]=er}}),hn.push(ji)});for(var _n=0,Nn=function(){var Ri=!1;if(Ge.forEach(function(ji){var Qi={};Object.keys(Ft[ji.id]).forEach(function(Es){var Gs=Ft[ji.id][Es],As=Gt[Es].node,us=As.clusterId;Qi[us]||(Qi[us]=0),Qi[us]+=Gs});var er=-1/0,gr=[];if(Object.keys(Qi).forEach(function(Es){er<Qi[Es]?(er=Qi[Es],gr=[Es]):er===Qi[Es]&&gr.push(Es)}),!(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 Nr=Lt[ji.clusterId],Ji=Nr.nodes.indexOf(ji);Nr.nodes.splice(Ji,1);var cs=Math.floor(Math.random()*gr.length),ds=Lt[gr[cs]];ds.nodes.push(ji),ji.clusterId=ds.id}}}),!Ri)return"break";_n++};_n<we;){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={};Tt.forEach(function(di){var Ri=di.source,ji=di.target,Qi=di[le]||1,er=Gt[Ri].node.clusterId,gr=Gt[ji].node.clusterId,yr="".concat(er,"---").concat(gr);if(ai[yr])ai[yr].weight+=Qi,ai[yr].count++;else{var Nr={source:er,target:gr,weight:Qi,count:1};ai[yr]=Nr,ei.push(Nr)}});var On=[];return Object.keys(Lt).forEach(function(di){On.push(Lt[di])}),{clusters:On,clusterEdges:ei}},Fu=Xa,lc=function(){function se($){this.arr=$}return se.prototype.getArr=function(){return this.arr||[]},se.prototype.add=function($){var Z,le=$.arr;if(!(!((Z=this.arr)===null||Z===void 0)&&Z.length))return new se(le);if(!(le!=null&&le.length))return new se(this.arr);if(this.arr.length===le.length){var we=[];for(var Re in this.arr)we[Re]=this.arr[Re]+le[Re];return new se(we)}},se.prototype.subtract=function($){var Z,le=$.arr;if(!(!((Z=this.arr)===null||Z===void 0)&&Z.length))return new se(le);if(!(le!=null&&le.length))return new se(this.arr);if(this.arr.length===le.length){var we=[];for(var Re in this.arr)we[Re]=this.arr[Re]-le[Re];return new se(we)}},se.prototype.avg=function($){var Z=[];if($!==0)for(var le in this.arr)Z[le]=this.arr[le]/$;return new se(Z)},se.prototype.negate=function(){var $=[];for(var Z in this.arr)$[Z]=-this.arr[Z];return new se($)},se.prototype.squareEuclideanDistance=function($){var Z,le=$.arr;if(!(!((Z=this.arr)===null||Z===void 0)&&Z.length)||!(le!=null&&le.length))return 0;if(this.arr.length===le.length){var we=0;for(var Re in this.arr)we+=Math.pow(this.arr[Re]-$.arr[Re],2);return we}},se.prototype.euclideanDistance=function($){var Z,le=$.arr;if(!(!((Z=this.arr)===null||Z===void 0)&&Z.length)||!(le!=null&&le.length))return 0;if(this.arr.length===le.length){var we=0;for(var Re in this.arr)we+=Math.pow(this.arr[Re]-$.arr[Re],2);return Math.sqrt(we)}else console.error("The two vectors are unequal in length.")},se.prototype.normalize=function(){var $=[],Z=Xd(this.arr);Z.sort(function(Ge,wt){return Ge-wt});var le=Z[Z.length-1],we=Z[0];for(var Re in this.arr)$[Re]=(this.arr[Re]-we)/(le-we);return new se($)},se.prototype.norm2=function(){var $;if(!(!(($=this.arr)===null||$===void 0)&&$.length))return 0;var Z=0;for(var le in this.arr)Z+=Math.pow(this.arr[le],2);return Math.sqrt(Z)},se.prototype.dot=function($){var Z,le=$.arr;if(!(!((Z=this.arr)===null||Z===void 0)&&Z.length)||!(le!=null&&le.length))return 0;if(this.arr.length===le.length){var we=0;for(var Re in this.arr)we+=this.arr[Re]*$.arr[Re];return we}else console.error("The two vectors are unequal in length.")},se.prototype.equal=function($){var Z,le=$.arr;if(((Z=this.arr)===null||Z===void 0?void 0:Z.length)!==(le==null?void 0:le.length))return!1;for(var we in this.arr)if(this.arr[we]!==le[we])return!1;return!0},se}(),Fa=lc,yl=/^(\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})$/,tp=function($,Z){$===void 0&&($=[]),Z===void 0&&(Z=100);var le={};$.forEach(function(Re){Re.properties&&Object.keys(Re.properties).forEach(function(Ge){if(Ge==="id"||!"".concat(Re.properties[Ge]).match(yl)&&!"".concat(Re.properties[Ge]).match(Sr)&&isNaN(Number(Re.properties[Ge]))){le.hasOwnProperty(Ge)&&delete le[Ge];return}le.hasOwnProperty(Ge)?le[Ge]+=1:le[Ge]=1})});var we=Object.keys(le).sort(function(Re,Ge){return le[Ge]-le[Re]});return we.length<Z?we:we.slice(0,Z)},rx=function($,Z){return Z.map(function(le){return $.hasOwnProperty(le)?$[le]:0})},Bm=function($){for(var Z=tp($),le=[],we=0;we<$.length;we++)le[we]=rx($[we].properties,Z);return le},_r=function($,Z){Z===void 0&&(Z=void 0);var le=[];return $.forEach(function(we){Z===void 0&&le.push(we),we[Z]!==void 0&&le.push(we[Z])}),le},js={getAllSortProperties:tp,getPropertyWeight:Bm,getAllProperties:_r},Fl;(function(se){se.EuclideanDistance="euclideanDistance"})(Fl||(Fl={}));var S0=function($,Z,le){var we=[];Z!=null&&Z.length?we=Z:($.forEach(function(Ge){we=we.concat(Object.keys(Ge))}),we=it(we));var Re={};return we.forEach(function(Ge){var wt=[];$.forEach(function(Tt){Tt[Ge]!==void 0&&Tt[Ge]!==""&&wt.push(Tt[Ge])}),wt.length&&!(le!=null&&le.includes(Ge))&&(Re[Ge]=it(wt))}),Re},Bu=function($,Z,le){var we=S0($,Z,le),Re=[];if(!Object.keys(we).length)return Re;var Ge=Object.values(we),wt=Ge.every(function(Tt){return Tt.every(function(Lt){return typeof Lt=="number"})});return $.forEach(function(Tt,Lt){var Gt=[];Object.keys(we).forEach(function($t){var hn=Tt[$t],Ft=we[$t],_n=Ft.findIndex(function(ei){return hn===ei}),Nn=[];if(wt)Nn.push(hn);else for(var Pn=0;Pn<Ft.length;Pn++)Pn===_n?Nn.push(1):Nn.push(0);Gt=Gt.concat(Nn)}),Re[Lt]=Gt}),Re},_a=function($,Z,le,we){le===void 0&&(le=Fl.EuclideanDistance);var Re=0;switch(le){case Fl.EuclideanDistance:Re=new Fa($).euclideanDistance(new Fa(Z));break;default:break}return Re},T0={getAllKeyValueMap:S0,oneHot:Bu,getDistance:_a},ru=function($,Z,le,we){for(var Re=Z.length,Ge=2*we,wt=0,Tt=0;Tt<Re;Tt++)for(var Lt=$[Tt].clusterId,Gt=0;Gt<Re;Gt++){var $t=$[Gt].clusterId;if(Lt===$t){var hn=Z[Tt][Gt]||0,Ft=le[Tt]||0,_n=le[Gt]||0;wt+=hn-Ft*_n/Ge}}return wt*=1/Ge,wt},Uu=function($,Z){$===void 0&&($=[]);for(var le=$.length,we=new Fa([]),Re=0;Re<le;Re++)we=we.add(new Fa(Z[Re]));var Ge=we.avg(le);Ge.normalize();for(var wt=0,Re=0;Re<le;Re++){var Tt=new Fa(Z[Re]),Lt=Tt.squareEuclideanDistance(Ge);wt+=Lt}var Gt=[];$.forEach(function(){Gt.push([])});for(var Re=0;Re<le;Re++){var Tt=new Fa(Z[Re]);$[Re].clusterInertial=0;for(var $t=0;$t<le;$t++){if(Re===$t){Gt[Re][$t]=0;continue}var hn=new Fa(Z[$t]);Gt[Re][$t]=Tt.squareEuclideanDistance(hn),$[Re].clusterInertial+=Gt[Re][$t]}}for(var Ft=0,_n=2*le*wt,Re=0;Re<le;Re++)for(var Nn=$[Re].clusterId,$t=0;$t<le;$t++){var Pn=$[$t].clusterId;if(!(Re===$t||Nn!==Pn)){var ei=$[Re].clusterInertial*$[$t].clusterInertial/Math.pow(_n,2)-Gt[Re][$t]/_n;Ft+=ei}}return Number(Ft.toFixed(4))},Sl=function($,Z,le,we,Re,Ge,wt,Tt,Lt){Z===void 0&&(Z=!1),le===void 0&&(le="weight"),we===void 0&&(we=1e-4),Re===void 0&&(Re=!1),Ge===void 0&&(Ge=void 0),wt===void 0&&(wt=[]),Tt===void 0&&(Tt=["id"]),Lt===void 0&&(Lt=1);var Gt=$.nodes,$t=Gt===void 0?[]:Gt,hn=$.edges,Ft=hn===void 0?[]:hn,_n=[];if(Re){$t.forEach(function(Mi,Xi){Mi.properties=Mi.properties||{},Mi.originIndex=Xi});var Nn=[];$t.every(function(Mi){return Mi.hasOwnProperty("nodeType")})&&(Nn=Array.from(new Set($t.map(function(Mi){return Mi.nodeType}))),$t.forEach(function(Mi){Mi.properties.nodeType=Nn.findIndex(function(Xi){return Xi===Mi.nodeType})}));var Pn=_r($t,Ge);_n=Bu(Pn,wt,Tt)}var ei=1,ai={},On={};$t.forEach(function(Mi,Xi){var Br=String(ei++);Mi.clusterId=Br,ai[Br]={id:Br,nodes:[Mi]},On[Mi.id]={node:Mi,idx:Xi}});var di=k($,Z),Ri=[],ji={},Qi=0;di.forEach(function(Mi,Xi){var Br=0,kr=$t[Xi].id;ji[kr]={},Mi.forEach(function(Dr,Jr){if(Dr){Br+=Dr;var Ls=$t[Jr].id;ji[kr][Ls]=Dr,Qi+=Dr}}),Ri.push(Br)}),Qi/=2;for(var er=1/0,gr=1/0,yr=0,Nr=[],Ji={};;){Re&&$t.every(function(Mi){return Mi.hasOwnProperty("properties")})?er=ru($t,di,Ri,Qi)+Uu($t,_n)*Lt:er=ru($t,di,Ri,Qi),yr===0&&(gr=er,Nr=$t,Ji=ai);var cs=er>0&&er>gr&&er-gr<we;if(er>gr&&(Nr=$t.map(function(Mi){return{node:Mi,clusterId:Mi.clusterId}}),Ji=Xd(ai),gr=er),cs||yr>100)break;yr++,Object.keys(ai).forEach(function(Mi){var Xi=0;Ft.forEach(function(Br){var kr=Br.source,Dr=Br.target,Jr=On[kr].node.clusterId,Ls=On[Dr].node.clusterId;(Jr===Mi&&Ls!==Mi||Ls===Mi&&Jr!==Mi)&&(Xi=Xi+(Br[le]||1))}),ai[Mi].sumTot=Xi}),$t.forEach(function(Mi,Xi){var Br=ai[Mi.clusterId],kr=0,Dr,Jr=Ri[Xi]/(2*Qi),Ls=0,Lo=Br.nodes;Lo.forEach(function(Ho){var wa=On[Ho.id].idx;Ls+=di[Xi][wa]||0});var Ka=Ls-Br.sumTot*Jr,oo=Lo.filter(function(Ho){return Ho.id!==Mi.id}),al=[];oo.forEach(function(Ho,wa){al[wa]=_n[Ho.originIndex]});var xs=Uu(oo,_n)*Lt,da=ji[Mi.id];if(Object.keys(da).forEach(function(Ho){var wa=On[Ho].node,na=wa.clusterId;if(na!==Mi.clusterId){var ll=ai[na],ia=ll.nodes;if(!(!ia||!ia.length)){var is=0;ia.forEach(function(Wr){var vs=On[Wr.id].idx;is+=di[Xi][vs]||0});var Bs=is-ll.sumTot*Jr,jn=ia.concat([Mi]),br=[];jn.forEach(function(Wr,vs){br[vs]=_n[Wr.originIndex]});var Do=Uu(jn,_n)*Lt,Ei=Bs-Ka;Re&&(Ei=Bs+Do-(Ka+xs)),Ei>kr&&(kr=Ei,Dr=ll)}}}),kr>0){Dr.nodes.push(Mi);var Ys=Mi.clusterId;Mi.clusterId=Dr.id;var Oc=Br.nodes.indexOf(Mi);Br.nodes.splice(Oc,1);var Co=0,Ul=0;Ft.forEach(function(Ho){var wa=Ho.source,na=Ho.target,ll=On[wa].node.clusterId,ia=On[na].node.clusterId;(ll===Dr.id&&ia!==Dr.id||ia===Dr.id&&ll!==Dr.id)&&(Co=Co+(Ho[le]||1)),(ll===Ys&&ia!==Ys||ia===Ys&&ll!==Ys)&&(Ul=Ul+(Ho[le]||1))}),Dr.sumTot=Co,Br.sumTot=Ul}})}var ds={},Es=0;Object.keys(Ji).forEach(function(Mi){var Xi=Ji[Mi];if(!Xi.nodes||!Xi.nodes.length){delete Ji[Mi];return}var Br=String(Es+1);Br!==Mi&&(Xi.id=Br,Xi.nodes=Xi.nodes.map(function(kr){return{id:kr.id,clusterId:Br}}),Ji[Br]=Xi,ds[Mi]=Br,delete Ji[Mi],Es++)}),Nr.forEach(function(Mi){var Xi=Mi.node,Br=Mi.clusterId;Xi&&(Xi.clusterId=Br,Xi.clusterId&&ds[Xi.clusterId]&&(Xi.clusterId=ds[Xi.clusterId]))});var Gs=[],As={};Ft.forEach(function(Mi){var Xi=Mi.source,Br=Mi.target,kr=Mi[le]||1,Dr=On[Xi].node.clusterId,Jr=On[Br].node.clusterId;if(!(!Dr||!Jr)){var Ls="".concat(Dr,"---").concat(Jr);if(As[Ls])As[Ls].weight+=kr,As[Ls].count++;else{var Lo={source:Dr,target:Jr,weight:kr,count:1};As[Ls]=Lo,Gs.push(Lo)}}});var us=[];return Object.keys(Ji).forEach(function(Mi){us.push(Ji[Mi])}),{clusters:us,clusterEdges:Gs}},Fr=Sl,np=function($,Z,le,we,Re,Ge,wt,Tt){return Z===void 0&&(Z=!1),le===void 0&&(le="weight"),we===void 0&&(we=1e-4),Re===void 0&&(Re=void 0),Ge===void 0&&(Ge=[]),wt===void 0&&(wt=["id"]),Tt===void 0&&(Tt=1),Fr($,Z,le,we,!0,Re,Ge,wt,Tt)},E0=np,A0=function($,Z){var le;Z===void 0&&(Z=1);for(var we=Xd($),Re=we.nodes,Ge=Re===void 0?[]:Re,wt=we.edges,Tt=wt===void 0?[]:wt,Lt=function(){var hn=Ne({nodes:Ge,edges:Tt}),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(!Ge.length||((le=hn[_n])===null||le===void 0?void 0:le.degree)>=Z)return"break";var Nn=Ge.findIndex(function(Pn){return Pn.id===_n});Ge.splice(Nn,1),Tt=Tt.filter(function(Pn){return!(Pn.source===_n||Pn.target===_n)})};;){var Gt=Lt();if(Gt==="break")break}return{nodes:Ge,edges:Tt}},qh=A0,qa=function($,Z,le){var we=[];switch($){case Fl.EuclideanDistance:we=Z[le];break;default:we=[];break}return we},ls=function($,Z,le,we,Re,Ge){Z===void 0&&(Z=3),le===void 0&&(le=void 0),we===void 0&&(we=[]),Re===void 0&&(Re=["id"]),Ge===void 0&&(Ge=Fl.EuclideanDistance);var wt=$.nodes,Tt=wt===void 0?[]:wt,Lt=$.edges,Gt=Lt===void 0?[]:Lt,$t={clusters:[{id:"0",nodes:Tt}],clusterEdges:[]};if(Ge===Fl.EuclideanDistance&&!Tt.every(function(Br){return Br.hasOwnProperty(le)}))return $t;var hn=[],Ft=[];if(Ge===Fl.EuclideanDistance&&(hn=_r(Tt,le),Ft=Bu(hn,we,Re)),!Ft.length)return $t;for(var _n=it(Ft.map(function(Br){return Br.join("")})),Nn=Math.min(Z,Tt.length,_n.length),Pn=0;Pn<Tt.length;Pn++)Tt[Pn].originIndex=Pn;for(var ei=[],ai=[],On=[],Pn=0;Pn<Nn;Pn++)if(Pn===0){var di=Math.floor(Math.random()*Tt.length);switch(Ge){case Fl.EuclideanDistance:ei[Pn]=Ft[di];break;default:ei[Pn]=[];break}ai.push(di),On[Pn]=[Tt[di]],Tt[di].clusterId=String(Pn)}else{for(var Ri=-1/0,ji=0,Qi=function(Dr){if(!ai.includes(Dr)){for(var Jr=0,Ls=0;Ls<ei.length;Ls++){var Lo=0;switch(Ge){case Fl.EuclideanDistance:Lo=_a(Ft[Tt[Dr].originIndex],ei[Ls],Ge);break;default:break}Jr+=Lo}var Ka=Jr/ei.length;Ka>Ri&&!ei.find(function(oo){return ep(oo,qa(Ge,Ft,Tt[Dr].originIndex))})&&(Ri=Ka,ji=Dr)}},er=0;er<Tt.length;er++)Qi(er);ei[Pn]=qa(Ge,Ft,ji),ai.push(ji),On[Pn]=[Tt[ji]],Tt[ji].clusterId=String(Pn)}for(var gr=0;;){for(var Pn=0;Pn<Tt.length;Pn++){var yr=0,Nr=1/0;if(!(gr===0&&ai.includes(Pn))){for(var Ji=0;Ji<ei.length;Ji++){var cs=0;switch(Ge){case Fl.EuclideanDistance:cs=_a(Ft[Pn],ei[Ji],Ge);break;default:break}cs<Nr&&(Nr=cs,yr=Ji)}if(Tt[Pn].clusterId!==void 0)for(var ds=On[Number(Tt[Pn].clusterId)].length-1;ds>=0;ds--)On[Number(Tt[Pn].clusterId)][ds].id===Tt[Pn].id&&On[Number(Tt[Pn].clusterId)].splice(ds,1);Tt[Pn].clusterId=String(yr),On[yr].push(Tt[Pn])}}for(var Es=!1,Pn=0;Pn<On.length;Pn++){for(var Gs=On[Pn],As=new Fa([]),Ji=0;Ji<Gs.length;Ji++)As=As.add(new Fa(Ft[Gs[Ji].originIndex]));var us=As.avg(Gs.length);us.equal(new Fa(ei[Pn]))||(Es=!0,ei[Pn]=us.getArr())}if(gr++,Tt.every(function(Br){return Br.clusterId!==void 0})&&Es||gr>=1e3)break}var Mi=[],Xi={};return Gt.forEach(function(Br){var kr,Dr,Jr=Br.source,Ls=Br.target,Lo=(kr=Tt.find(function(xs){return xs.id===Jr}))===null||kr===void 0?void 0:kr.clusterId,Ka=(Dr=Tt.find(function(xs){return xs.id===Ls}))===null||Dr===void 0?void 0:Dr.clusterId,oo="".concat(Lo,"---").concat(Ka);if(Xi[oo])Xi[oo].count++;else{var al={source:Lo,target:Ka,count:1};Xi[oo]=al,Mi.push(al)}}),{clusters:On,clusterEdges:Mi}},Yh=ls,yn=function($,Z){var le=new Fa(Z),we=le.norm2(),Re=new Fa($),Ge=Re.norm2(),wt=le.dot(Re),Tt=we*Ge,Lt=Tt?wt/Tt:0;return Lt},ea=yn,ot=function($,Z,le,we,Re){$===void 0&&($=[]),le===void 0&&(le=void 0),we===void 0&&(we=[]),Re===void 0&&(Re=[]);var Ge=Xd($.filter(function(hn){return hn.id!==Z.id})),wt=$.findIndex(function(hn){return hn.id===Z.id}),Tt=_r($,le),Lt=Bu(Tt,we,Re),Gt=Lt[wt],$t=[];return Ge.forEach(function(hn,Ft){if(hn.id!==Z.id){var _n=Lt[Ft],Nn=ea(_n,Gt);$t.push(Nn),hn.cosineSimilarity=Nn}}),Ge.sort(function(hn,Ft){return Ft.cosineSimilarity-hn.cosineSimilarity}),{allCosineSimilarity:$t,similarNodes:Ge}},ip=ot,Um=function(){function se($){this.count=$.length,this.parent={};for(var Z=0,le=$;Z<le.length;Z++){var we=le[Z];this.parent[we]=we}}return se.prototype.find=function($){for(;this.parent[$]!==$;)$=this.parent[$];return $},se.prototype.union=function($,Z){var le=this.find($),we=this.find(Z);le!==we&&(le<we?(this.parent[Z]!==Z&&this.union(this.parent[Z],$),this.parent[Z]=this.parent[$]):(this.parent[$]!==$&&this.union(this.parent[$],Z),this.parent[$]=this.parent[Z]))},se.prototype.connected=function($,Z){return this.find($)===this.find(Z)},se}(),$r=Um,rp=function($,Z){return $-Z},sp=function(){function se($){$===void 0&&($=rp),this.compareFn=$,this.list=[]}return se.prototype.getLeft=function($){return 2*$+1},se.prototype.getRight=function($){return 2*$+2},se.prototype.getParent=function($){return $===0?null:Math.floor(($-1)/2)},se.prototype.isEmpty=function(){return this.list.length<=0},se.prototype.top=function(){return this.isEmpty()?void 0:this.list[0]},se.prototype.delMin=function(){var $=this.top(),Z=this.list.pop();return this.list.length>0&&(this.list[0]=Z,this.moveDown(0)),$},se.prototype.insert=function($){if($!==null){this.list.push($);var Z=this.list.length-1;return this.moveUp(Z),!0}return!1},se.prototype.moveUp=function($){for(var Z=this.getParent($);$&&$>0&&this.compareFn(this.list[Z],this.list[$])>0;){var le=this.list[Z];this.list[Z]=this.list[$],this.list[$]=le,$=Z,Z=this.getParent($)}},se.prototype.moveDown=function($){var Z,le=$,we=this.getLeft($),Re=this.getRight($),Ge=this.list.length;we!==null&&we<Ge&&this.compareFn(this.list[le],this.list[we])>0?le=we:Re!==null&&Re<Ge&&this.compareFn(this.list[le],this.list[Re])>0&&(le=Re),$!==le&&(Z=[this.list[le],this.list[$]],this.list[$]=Z[0],this.list[le]=Z[1],this.moveDown(le))},se}(),C0=sp,ch=function($,Z){var le=[],we=$.nodes,Re=we===void 0?[]:we,Ge=$.edges,wt=Ge===void 0?[]:Ge;if(Re.length===0)return le;var Tt=Re[0],Lt=new Set;Lt.add(Tt);var Gt=function(Pn,ei){return Z?Pn.weight-ei.weight:0},$t=new C0(Gt);for(P(Tt.id,wt).forEach(function(Nn){$t.insert(Nn)});!$t.isEmpty();){var hn=$t.delMin(),Ft=hn.source,_n=hn.target;Lt.has(Ft)&&Lt.has(_n)||(le.push(hn),Lt.has(Ft)||(Lt.add(Ft),P(Ft,wt).forEach(function(Nn){$t.insert(Nn)})),Lt.has(_n)||(Lt.add(_n),P(_n,wt).forEach(function(Nn){$t.insert(Nn)})))}return le},uh=function($,Z){var le=[],we=$.nodes,Re=we===void 0?[]:we,Ge=$.edges,wt=Ge===void 0?[]:Ge;if(Re.length===0)return le;var Tt=wt.map(function(Ft){return Ft});Z&&Tt.sort(function(Ft,_n){return Ft.weight-_n.weight});for(var Lt=new $r(Re.map(function(Ft){return Ft.id}));Tt.length>0;){var Gt=Tt.shift(),$t=Gt.source,hn=Gt.target;Lt.connected($t,hn)||(le.push(Gt),Lt.union($t,hn))}return le},Ya=function($,Z,le){var we={prim:ch,kruskal:uh};return le?we[le]($,Z):uh($,Z)},ns=Ya,ol=function($,Z,le){typeof Z!="number"&&(Z=1e-6),typeof le!="number"&&(le=.85);for(var we=1,Re=0,Ge=1e3,wt=$.nodes,Tt=wt===void 0?[]:wt,Lt=$.edges,Gt=Lt===void 0?[]:Lt,$t=Tt.length,hn,Ft={},_n={},Nn=0;Nn<$t;++Nn){var Pn=Tt[Nn],ei=Pn.id;Ft[ei]=1/$t,_n[ei]=1/$t}for(var ai=Ne($);Ge>0&&we>Z;){Re=0;for(var Nn=0;Nn<$t;++Nn){var Pn=Tt[Nn],ei=Pn.id;if(hn=0,ai[Pn.id].inDegree===0)Ft[ei]=0;else{for(var On=N(ei,Gt,"source"),di=0;di<On.length;++di){var Ri=On[di],ji=ai[Ri].outDegree;ji>0&&(hn+=_n[Ri]/ji)}Ft[ei]=le*hn,Re+=Ft[ei]}}Re=(1-Re)/$t,we=0;for(var Nn=0;Nn<$t;++Nn){var Pn=Tt[Nn],ei=Pn.id;hn=Ft[ei]+Re,we+=Math.abs(hn-_n[ei]),_n[ei]=hn}Ge-=1}return _n},oi=ol,vl=-1,Rt=-1,Kd="-1",Ki="-1",ua=-1,ku="-1",su=function(){function se($,Z,le,we){$===void 0&&($=vl),Z===void 0&&(Z=Rt),le===void 0&&(le=Rt),we===void 0&&(we=Kd),this.id=$,this.from=Z,this.to=le,this.label=we}return se}(),km=function(){function se($,Z){$===void 0&&($=Rt),Z===void 0&&(Z=Ki),this.id=$,this.label=Z,this.edges=[],this.edgeMap={}}return se.prototype.addEdge=function($){this.edges.push($),this.edgeMap[$.id]=$},se}(),zm=function(){function se($,Z,le){$===void 0&&($=Rt),Z===void 0&&(Z=!0),le===void 0&&(le=!1),this.id=$,this.edgeIdAutoIncrease=Z,this.edges=[],this.nodes=[],this.nodeMap={},this.edgeMap={},this.nodeLabelMap={},this.edgeLabelMap={},this.counter=0,this.directed=le}return se.prototype.getNodeNum=function(){return this.nodes.length},se.prototype.addNode=function($,Z){if(!this.nodeMap[$]){var le=new km($,Z);this.nodes.push(le),this.nodeMap[$]=le,this.nodeLabelMap[Z]||(this.nodeLabelMap[Z]=[]),this.nodeLabelMap[Z].push($)}},se.prototype.addEdge=function($,Z,le,we){if((this.edgeIdAutoIncrease||$===void 0)&&($=this.counter++),!(this.nodeMap[Z]&&this.nodeMap[le]&&this.nodeMap[le].edgeMap[$])){var Re=new su($,Z,le,we);if(this.edges.push(Re),this.edgeMap[$]=Re,this.nodeMap[Z].addEdge(Re),this.edgeLabelMap[we]||(this.edgeLabelMap[we]=[]),this.edgeLabelMap[we].push(Re),!this.directed){var Ge=new su($,le,Z,we);this.nodeMap[le].addEdge(Ge),this.edgeLabelMap[we].push(Ge)}}},se}(),wo=function(){function se($,Z,le,we,Re){this.fromNode=$,this.toNode=Z,this.nodeEdgeNodeLabel={nodeLabel1:le||Ki,edgeLabel:we||Kd,nodeLabel2:Re||Ki}}return se.prototype.equalTo=function($){return this.fromNode===$.formNode&&this.toNode===$.toNode&&this.nodeEdgeNodeLabel===$.nodeEdgeNodeLabel},se.prototype.notEqualTo=function($){return!this.equalTo($)},se}(),Bl=function(){function se(){this.rmpath=[],this.dfsEdgeList=[]}return se.prototype.equalTo=function($){var Z=this.dfsEdgeList.length,le=$.length;if(Z!==le)return!1;for(var we=0;we<Z;we++)if(this.dfsEdgeList[we]!==$[we])return!1;return!0},se.prototype.notEqualTo=function($){return!this.equalTo($)},se.prototype.pushBack=function($,Z,le,we,Re){return this.dfsEdgeList.push(new wo($,Z,le,we,Re)),this.dfsEdgeList},se.prototype.toGraph=function($,Z){$===void 0&&($=ua),Z===void 0&&(Z=!1);var le=new zm($,!0,Z);return this.dfsEdgeList.forEach(function(we){var Re=we.fromNode,Ge=we.toNode,wt=we.nodeEdgeNodeLabel,Tt=wt.nodeLabel1,Lt=wt.edgeLabel,Gt=wt.nodeLabel2;Tt!==Ki&&le.addNode(Re,Tt),Gt!==Ki&&le.addNode(Ge,Gt),Tt!==Ki&&Gt!==Tt&&le.addEdge(void 0,Re,Ge,Lt)}),le},se.prototype.buildRmpath=function(){this.rmpath=[];for(var $=void 0,Z=this.dfsEdgeList.length,le=Z-1;le>=0;le--){var we=this.dfsEdgeList[le],Re=we.fromNode,Ge=we.toNode;Re<Ge&&($===void 0||Ge===$)&&(this.rmpath.push(le),$=Re)}return this.rmpath},se.prototype.getNodeNum=function(){var $={};return this.dfsEdgeList.forEach(function(Z){$[Z.fromNode]||($[Z.fromNode]=!0),$[Z.toNode]||($[Z.toNode]=!0)}),Object.keys($).length},se}(),Ic=function(){function se($){if(this.his={},this.nodesUsed={},this.edgesUsed={},this.edges=[],!!$){for(;$;){var Z=$.edge;this.edges.push(Z),this.nodesUsed[Z.from]=1,this.nodesUsed[Z.to]=1,this.edgesUsed[Z.id]=1,$=$.preNode}this.edges=this.edges.reverse()}}return se.prototype.hasNode=function($){return this.nodesUsed[$.id]===1},se.prototype.hasEdge=function($){return this.edgesUsed[$.id]===1},se}(),ou=function(){function se($){var Z=$.graphs,le=$.minSupport,we=le===void 0?2:le,Re=$.minNodeNum,Ge=Re===void 0?1:Re,wt=$.maxNodeNum,Tt=wt===void 0?4:wt,Lt=$.top,Gt=Lt===void 0?10:Lt,$t=$.directed,hn=$t===void 0?!1:$t,Ft=$.verbose,_n=Ft===void 0?!1:Ft;this.graphs=Z,this.dfsCode=new Bl,this.support=0,this.frequentSize1Subgraphs=[],this.frequentSubgraphs=[],this.minSupport=we,this.top=Gt,this.directed=hn,this.counter=0,this.maxNodeNum=Tt,this.minNodeNum=Ge,this.verbose=_n,this.maxNodeNum<this.minNodeNum&&(this.maxNodeNum=this.minNodeNum),this.reportDF=[]}return se.prototype.findForwardRootEdges=function($,Z){var le=this,we=[],Re=$.nodeMap;return Z.edges.forEach(function(Ge){(le.directed||Z.label<=Re[Ge.to].label)&&we.push(Ge)}),we},se.prototype.findBackwardEdge=function($,Z,le,we){if(!this.directed&&Z===le)return null;for(var Re=$.nodeMap,Ge=Re[le.to],wt=Ge.edges,Tt=wt.length,Lt=0;Lt<Tt;Lt++){var Gt=wt[Lt];if(!(we.hasEdge(Gt)||Gt.to!==Z.from)){if(this.directed){if(Re[Z.from].label<Re[le.to].label||Re[Z.from].label===Re[le.to].label&&Z.label<=Gt.label)return Gt}else if(Z.label<Gt.label||Z.label===Gt.label&&Re[Z.to].label<=Re[le.to].label)return Gt}}return null},se.prototype.findForwardPureEdges=function($,Z,le,we){for(var Re=[],Ge=Z.to,wt=$.nodeMap[Ge].edges,Tt=wt.length,Lt=0;Lt<Tt;Lt++){var Gt=wt[Lt],$t=$.nodeMap[Gt.to];le<=$t.label&&!we.hasNode($t)&&Re.push(Gt)}return Re},se.prototype.findForwardRmpathEdges=function($,Z,le,we){for(var Re=[],Ge=$.nodeMap,wt=Ge[Z.to].label,Tt=Ge[Z.from],Lt=Tt.edges,Gt=Lt.length,$t=0;$t<Gt;$t++){var hn=Lt[$t],Ft=Ge[hn.to].label;Z.to===hn.to||le>Ft||we.hasNode(Ge[hn.to])||(Z.label<hn.label||Z.label===hn.label&&wt<=Ft)&&Re.push(hn)}return Re},se.prototype.getSupport=function($){var Z={};return $.forEach(function(le){Z[le.graphId]||(Z[le.graphId]=!0)}),Object.keys(Z).length},se.prototype.findMinLabel=function($){var Z=void 0;return Object.keys($).forEach(function(le){var we=$[le],Re=we.nodeLabel1,Ge=we.edgeLabel,wt=we.nodeLabel2;if(!Z){Z={nodeLabel1:Re,edgeLabel:Ge,nodeLabel2:wt};return}(Re<Z.nodeLabel1||Re===Z.nodeLabel1&&Ge<Z.edgeLabel||Re===Z.nodeLabel1&&Ge===Z.edgeLabel&&wt<Z.nodeLabel2)&&(Z={nodeLabel1:Re,edgeLabel:Ge,nodeLabel2:wt})}),Z},se.prototype.isMin=function(){var $=this,Z=this.dfsCode;if(this.verbose&&console.log("isMin checking",Z),Z.dfsEdgeList.length===1)return!0;var le=this.directed,we=Z.toGraph(ua,le),Re=we.nodeMap,Ge=new Bl,wt={};we.nodes.forEach(function($t){var hn=$.findForwardRootEdges(we,$t);hn.forEach(function(Ft){var _n=Re[Ft.to],Nn="".concat($t.label,"-").concat(Ft.label,"-").concat(_n.label);wt[Nn]||(wt[Nn]={projected:[],nodeLabel1:$t.label,edgeLabel:Ft.label,nodeLabel2:_n.label});var Pn={graphId:we.id,edge:Ft,preNode:null};wt[Nn].projected.push(Pn)})});var Tt=this.findMinLabel(wt);if(Tt){Ge.dfsEdgeList.push(new wo(0,1,Tt.nodeLabel1,Tt.edgeLabel,Tt.nodeLabel2));var Lt=function $t(hn){for(var Ft=Ge.buildRmpath(),_n=Ge.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,Nn=Ge.dfsEdgeList[Ft[0]].toNode,Pn={},ei=!1,ai=0,On=le?-1:0,di=function(As){if(ei)return"break";hn.forEach(function(us){var Mi=new Ic(us),Xi=$.findBackwardEdge(we,Mi.edges[Ft[As]],Mi.edges[Ft[0]],Mi);Xi&&(Pn[Xi.label]||(Pn[Xi.label]={projected:[],edgeLabel:Xi.label}),Pn[Xi.label].projected.push({graphId:we.id,edge:Pn,preNode:us}),ai=Ge.dfsEdgeList[Ft[As]].fromNode,ei=!0)})},Ri=Ft.length-1;Ri>On;Ri--){var ji=di(Ri);if(ji==="break")break}if(ei){var Qi=$.findMinLabel(Pn);Ge.dfsEdgeList.push(new wo(Nn,ai,Ki,Qi.edgeLabel,Ki));var er=Ge.dfsEdgeList.length-1;return $.dfsCode.dfsEdgeList[er]!==Ge.dfsEdgeList[er]?!1:$t(Pn[Qi.edgeLabel].projected)}var gr={};ei=!1;var yr=0;hn.forEach(function(Gs){var As=new Ic(Gs),us=$.findForwardPureEdges(we,As.edges[Ft[0]],_n,As);us.length>0&&(ei=!0,yr=Nn,us.forEach(function(Mi){var Xi="".concat(Mi.label,"-").concat(Re[Mi.to].label);gr[Xi]||(gr[Xi]={projected:[],edgeLabel:Mi.label,nodeLabel2:Re[Mi.to].label}),gr[Xi].projected.push({graphId:we.id,edge:Mi,preNode:Gs})}))});for(var Nr=Ft.length,Ji=function(As){if(ei)return"break";var us=Ft[As];hn.forEach(function(Mi){var Xi=new Ic(Mi),Br=$.findForwardRmpathEdges(we,Xi.edges[us],_n,Xi);Br.length>0&&(ei=!0,yr=Ge.dfsEdgeList[us].fromNode,Br.forEach(function(kr){var Dr="".concat(kr.label,"-").concat(Re[kr.to].label);gr[Dr]||(gr[Dr]={projected:[],edgeLabel:kr.label,nodeLabel2:Re[kr.to].label}),gr[Dr].projected.push({graphId:we.id,edge:kr,preNode:Mi})}))})},Ri=0;Ri<Nr;Ri++){var cs=Ji(Ri);if(cs==="break")break}if(!ei)return!0;var ds=$.findMinLabel(gr);Ge.dfsEdgeList.push(new wo(yr,Nn+1,Ki,ds.edgeLabel,ds.nodeLabel2));var Es=Ge.dfsEdgeList.length-1;return Z.dfsEdgeList[Es]!==Ge.dfsEdgeList[Es]?!1:$t(gr["".concat(ds.edgeLabel,"-").concat(ds.nodeLabel2)].projected)},Gt="".concat(Tt.nodeLabel1,"-").concat(Tt.edgeLabel,"-").concat(Tt.nodeLabel2);return Lt(wt[Gt].projected)}},se.prototype.report=function(){if(!(this.dfsCode.getNodeNum()<this.minNodeNum)){this.counter++;var $=this.dfsCode.toGraph(this.counter,this.directed);this.frequentSubgraphs.push(Xd($))}},se.prototype.subGraphMining=function($){var Z=this,le=this.getSupport($);if(!(le<this.minSupport)&&this.isMin()){this.report();var we=this.dfsCode.getNodeNum(),Re=this.dfsCode.buildRmpath(),Ge=this.dfsCode.dfsEdgeList[Re[0]].toNode,wt=this.dfsCode.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,Tt={},Lt={};$.forEach(function(Gt){for(var $t=Z.graphs[Gt.graphId],hn=$t.nodeMap,Ft=new Ic(Gt),_n=Re.length-1;_n>=0;_n--){var Nn=Z.findBackwardEdge($t,Ft.edges[Re[_n]],Ft.edges[Re[0]],Ft);if(Nn){var Pn="".concat(Z.dfsCode.dfsEdgeList[Re[_n]].fromNode,"-").concat(Nn.label);Lt[Pn]||(Lt[Pn]={projected:[],toNodeId:Z.dfsCode.dfsEdgeList[Re[_n]].fromNode,edgeLabel:Nn.label}),Lt[Pn].projected.push({graphId:Gt.graphId,edge:Nn,preNode:Gt})}}if(!(we>=Z.maxNodeNum)){var ei=Z.findForwardPureEdges($t,Ft.edges[Re[0]],wt,Ft);ei.forEach(function(On){var di="".concat(Ge,"-").concat(On.label,"-").concat(hn[On.to].label);Tt[di]||(Tt[di]={projected:[],fromNodeId:Ge,edgeLabel:On.label,nodeLabel2:hn[On.to].label}),Tt[di].projected.push({graphId:Gt.graphId,edge:On,preNode:Gt})});for(var ai=function(di){var Ri=Z.findForwardRmpathEdges($t,Ft.edges[Re[di]],wt,Ft);Ri.forEach(function(ji){var Qi="".concat(Z.dfsCode.dfsEdgeList[Re[di]].fromNode,"-").concat(ji.label,"-").concat(hn[ji.to].label);Tt[Qi]||(Tt[Qi]={projected:[],fromNodeId:Z.dfsCode.dfsEdgeList[Re[di]].fromNode,edgeLabel:ji.label,nodeLabel2:hn[ji.to].label}),Tt[Qi].projected.push({graphId:Gt.graphId,edge:ji,preNode:Gt})})},_n=0;_n<Re.length;_n++)ai(_n)}}),Object.keys(Lt).forEach(function(Gt){var $t=Lt[Gt],hn=$t.toNodeId,Ft=$t.edgeLabel;Z.dfsCode.dfsEdgeList.push(new wo(Ge,hn,"-1",Ft,"-1")),Z.subGraphMining(Lt[Gt].projected),Z.dfsCode.dfsEdgeList.pop()}),Object.keys(Tt).forEach(function(Gt){var $t=Tt[Gt],hn=$t.fromNodeId,Ft=$t.edgeLabel,_n=$t.nodeLabel2;Z.dfsCode.dfsEdgeList.push(new wo(hn,Ge+1,Ki,Ft,_n)),Z.subGraphMining(Tt[Gt].projected),Z.dfsCode.dfsEdgeList.pop()})}},se.prototype.generate1EdgeFrequentSubGraphs=function(){var $=this.graphs,Z=this.directed,le=this.minSupport,we=this.frequentSize1Subgraphs,Re={},Ge={},wt={},Tt={};return Object.keys($).forEach(function(Lt){var Gt=$[Lt],$t=Gt.nodeMap;Gt.nodes.forEach(function(hn,Ft){var _n=hn.label,Nn="".concat(Lt,"-").concat(_n);if(!wt[Nn]){var Pn=Re[_n]||0;Pn++,Re[_n]=Pn}wt[Nn]={graphKey:Lt,label:_n},hn.edges.forEach(function(ei){var ai=_n,On=$t[ei.to].label;if(!Z&&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(!Ge[Qi]){var er=Ge[Qi]||0;er++,Ge[Qi]=er}Tt[ji]={graphId:Lt,nodeLabel1:ai,edgeLabel:Ri,nodeLabel2:On}})})}),Object.keys(Re).forEach(function(Lt){var Gt=Re[Lt];if(!(Gt<le)){var $t={nodes:[],edges:[]};$t.nodes.push({id:"0",label:Lt}),we.push($t)}}),we},se.prototype.run=function(){var $=this;if(this.frequentSize1Subgraphs=this.generate1EdgeFrequentSubGraphs(),!(this.maxNodeNum<2)){var Z=this.graphs,le=this.directed,we={};Object.keys(Z).forEach(function(Re){var Ge=Z[Re],wt=Ge.nodeMap;Ge.nodes.forEach(function(Tt){var Lt=$.findForwardRootEdges(Ge,Tt);Lt.forEach(function(Gt){var $t=wt[Gt.to],hn="".concat(Tt.label,"-").concat(Gt.label,"-").concat($t.label);we[hn]||(we[hn]={projected:[],nodeLabel1:Tt.label,edgeLabel:Gt.label,nodeLabel2:$t.label});var Ft={graphId:Re,edge:Gt,preNode:null};we[hn].projected.push(Ft)})})}),Object.keys(we).forEach(function(Re){var Ge=we[Re],wt=Ge.projected,Tt=Ge.nodeLabel1,Lt=Ge.edgeLabel,Gt=Ge.nodeLabel2;$.dfsCode.dfsEdgeList.push(new wo(0,1,Tt,Lt,Gt)),$.subGraphMining(wt),$.dfsCode.dfsEdgeList.pop()})}},se}(),Wo=function($,Z,le,we){var Re={};return Object.keys($).forEach(function(Ge,wt){var Tt=$[Ge],Lt=new zm(wt,!0,Z),Gt={};Tt.nodes.forEach(function($t,hn){Lt.addNode(hn,$t[le]),Gt[$t.id]=hn}),Tt.edges.forEach(function($t,hn){var Ft=Gt[$t.source],_n=Gt[$t.target];Lt.addEdge(-1,Ft,_n,$t[we])}),Lt&&Lt.getNodeNum()&&(Re[Lt.id]=Lt)}),Re},mr=function($,Z,le){var we=[];return $.forEach(function(Re){var Ge={nodes:[],edges:[]};Re.nodes.forEach(function(wt){var Tt;Ge.nodes.push((Tt={id:"".concat(wt.id)},Tt[Z]=wt.label,Tt))}),Re.edges.forEach(function(wt){var Tt;Ge.edges.push((Tt={source:"".concat(wt.from),target:"".concat(wt.to)},Tt[le]=wt.label,Tt))}),we.push(Ge)}),we},Za="cluster",cc=function($){var Z=$.graphs,le=$.directed,we=le===void 0?!1:le,Re=$.nodeLabelProp,Ge=Re===void 0?Za:Re,wt=$.edgeLabelProp,Tt=wt===void 0?Za:wt,Lt=Wo(Z,we,Ge,Tt),Gt=$.minSupport,$t=$.maxNodeNum,hn=$.minNodeNum,Ft=$.verbose,_n=$.top,Nn={graphs:Lt,minSupport:Gt,maxNodeNum:$t,minNodeNum:hn,top:_n,verbose:Ft,directed:we},Pn=new ou(Nn);Pn.run();var ei=mr(Pn.frequentSubgraphs,Ge,Tt);return ei},Jd=cc,op=function($,Z,le,we){le===void 0&&(le="cluster"),we===void 0&&(we=2);var Re=[],Ge=$.nodes;return Z.forEach(function(wt,Tt){Re.push(xl(Ge,wt,Tt,le,we))}),Re},xl=function($,Z,le,we,Re){var Ge=[le],wt=[],Tt={};return Z.forEach(function(Lt,Gt){if(Lt<=Re&&le!==Gt){Ge.push(Gt),wt.push($[Gt]);var $t=$[Gt][we];Tt[$t]?(Tt[$t].count++,Tt[$t].dists.push(Lt)):Tt[$t]={count:1,dists:[Lt]}}}),Object.keys(Tt).forEach(function(Lt){Tt[Lt].dists=Tt[Lt].dists.sort(function(Gt,$t){return Gt-$t})}),{nodeIdx:le,nodeId:$[le].id,nodeIdxs:Ge,neighbors:wt,neighborNum:Ge.length-1,nodeLabelCountMap:Tt}},Ba=function($,Z,le,we,Re){var Ge=Math.ceil(le/Z),wt={},Tt=0;return we.forEach(function(Lt,Gt){for(var $t=0,hn=0,Ft=Lt.nodeIdxs,_n=Lt.neighborNum-1;$t<Ge;){for(var Nn=Ft[1+Math.floor(Math.random()*_n)],Pn=0;(wt["".concat(Gt,"-").concat(Nn)]||wt["".concat(Nn,"-").concat(Gt)])&&(Nn=Math.floor(Math.random()*Z),Pn++,!(Pn>2*Z)););if(Pn<2*Z&&(wt["".concat(Gt,"-").concat(Nn)]={start:Gt,end:Nn,distance:Re[Gt][Nn]},$t++,Tt++,Tt>=le))return wt;if(hn++,hn>2*Z)break}if($t<Ge){var ei=Ge-$t;Ge=(Ge+ei)/(Z-Gt-1)}}),wt},ha=function($,Z,le,we){var Re=le.nodes;return we||(we={}),Object.keys($).forEach(function(Ge){var wt,Tt;if(!(we&&we[Ge])){we[Ge]={nodes:[],edges:[]};var Lt=$[Ge],Gt=(wt=Z[Lt.start])===null||wt===void 0?void 0:wt.nodeIdxs,$t=(Tt=Z[Lt.end])===null||Tt===void 0?void 0:Tt.nodeIdxs;if(!(!Gt||!$t)){var hn=new Set($t),Ft=Gt.filter(function(ai){return hn.has(ai)});if(!(!Ft||!Ft.length)){for(var _n={},Nn=Ft.length,Pn=0;Pn<Nn;Pn++){var ei=Re[Ft[Pn]];we[Ge].nodes.push(ei),_n[ei.id]=!0}le.edges.forEach(function(ai){_n[ai.source]&&_n[ai.target]&&we[Ge].edges.push(ai)})}}}}),we},Zl=function($,Z,le,we){var Re,Ge,wt={};$.nodes.forEach(function(Lt){wt[Lt.id]=Lt});var Tt=0;return!(!((Re=Z==null?void 0:Z.edges)===null||Re===void 0)&&Re.length)||((Ge=Z==null?void 0:Z.nodes)===null||Ge===void 0?void 0:Ge.length)<2?0:($.edges.forEach(function(Lt){var Gt=wt[Lt.source][le],$t=wt[Lt.target][le],hn=Z==null?void 0:Z.nodes[0][le],Ft=Z==null?void 0:Z.nodes[1][le],_n=Z==null?void 0:Z.edges[0][we];Lt[we]===_n&&(Gt===hn&&$t===Ft||Gt===Ft&&$t===hn)&&Tt++}),Tt)},Kl=function($,Z,le){for(var we=1/0,Re=0,Ge=function(Lt){var Gt=$[Lt],$t=Object.keys(Gt).sort(function(ai,On){return Gt[ai]-Gt[On]}),hn=10,Ft=[];$t.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+=Gt[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=Gt[ji];ai.graphs.forEach(function(gr,yr){Qi!==yr&&(di+=Math.abs(er-Gt[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;we<ei&&(we=ei,Re=Lt)},wt=0;wt<Z;wt++)Ge(wt);return{structure:le[Re],structureCountMap:$[Re]}},Qd=function($,Z){var le={},we={};return $.forEach(function(Re,Ge){le[Re.id]={idx:Ge,node:Re,degree:0,inDegree:0,outDegree:0};var wt=Re[Z];we[wt]||(we[wt]=[]),we[wt].push(Re)}),{nodeMap:le,nodeLabelMap:we}},au=function($,Z,le){var we={},Re={};return $.forEach(function(Ge,wt){we["".concat(W)]={idx:wt,edge:Ge};var Tt=Ge[Z];Re[Tt]||(Re[Tt]=[]),Re[Tt].push(Ge);var Lt=le[Ge.source];Lt&&(Lt.degree++,Lt.outDegree++);var Gt=le[Ge.target];Gt&&(Gt.degree++,Gt.inDegree++)}),{edgeMap:we,edgeLabelMap:Re}},hh=function($,Z,le){var we=Z.length,Re={};return Z.forEach(function(Ge,wt){for(var Tt=le?0:wt+1,Lt=$[wt].id,Gt=Tt;Gt<we;Gt++)if(wt!==Gt){var $t=$[Gt].id,hn=Ge[Gt];Re["".concat(Lt,"-").concat($t)]=hn,le||(Re["".concat($t,"-").concat(Lt)]=hn)}}),Re},ta=function($,Z,le,we,Re,Ge,wt,Tt,Lt,Gt,$t){var hn,Ft="".concat(Z.id,"-").concat(le.id);if(Gt&&Gt[Ft])return Gt[Ft];var _n=$t?$t[Ft]:void 0;if(!_n){var Nn=(hn={},hn[Ft]={start:we[Z.id].idx,end:we[le.id].idx,distance:Re},hn);$t=ha(Nn,Ge,$,$t),_n=$t[Ft]}return Zl(_n,wt,Tt,Lt)},Ua=function($,Z,le,we){var Re,Ge,wt,Tt=(Re=$[Z])===null||Re===void 0?void 0:Re.degree,Lt=(Ge=$[Z])===null||Ge===void 0?void 0:Ge.inDegree,Gt=(wt=$[Z])===null||wt===void 0?void 0:wt.outDegree;return $[Z]===void 0&&(Tt=1/0,Lt=1/0,Gt=1/0,we[Z].forEach(function($t){var hn=le[$t.id].degree;Tt>hn&&(Tt=hn);var Ft=le[$t.id].inDegree;Lt>Ft&&(Lt=Ft);var _n=le[$t.id].outDegree;Gt>_n&&(Gt=_n)}),$[Z]={degree:Tt,inDegree:Lt,outDegree:Gt}),{minPatternNodeLabelDegree:Tt,minPatternNodeLabelInDegree:Lt,minPatternNodeLabelOutDegree:Gt}},ba=function($,Z,le,we,Re,Ge,wt){var Tt;if(le===void 0&&(le=!1),Ge===void 0&&(Ge="cluster"),wt===void 0&&(wt="cluster"),!(!$||!$.nodes)){var Lt=$.nodes.length;if(Lt){var Gt=Ol($,le),$t=Ol(Z,le),hn=hh($.nodes,Gt,le),Ft=hh(Z.nodes,$t,le),_n=Qd($.nodes,Ge),Nn=_n.nodeMap,Pn=_n.nodeLabelMap,ei=Qd(Z.nodes,Ge),ai=ei.nodeMap,On=ei.nodeLabelMap;au($.edges,wt,Nn);var di=au(Z.edges,wt,ai).edgeLabelMap,Ri=[];$t==null||$t.forEach(function(is){Ri=Ri.concat(is)}),Re||(Re=Math.max.apply(Math,ke(ke([],Ri,!1),[2],!1))),we||(we=Re);var ji=op($,Gt,Ge,we),Qi=op(Z,$t,Ge,we),er=Math.min(100,Lt*(Lt-1)/2),gr=Ba(we,Lt,er,ji,Gt),yr=ha(gr,ji,$),Nr=10,Ji=1,cs=1,ds=4,Es={graphs:yr,nodeLabelProp:Ge,edgeLabelProp:wt,minSupport:Ji,minNodeNum:cs,maxNodeNum:ds,directed:le},Gs=Jd(Es).slice(0,Nr),As=Gs.length,us=[];Gs.forEach(function(is,Bs){us[Bs]={},Object.keys(yr).forEach(function(jn){var br=yr[jn],Do=Zl(br,is,Ge,wt);us[Bs][jn]=Do})});var Mi=Kl(us,As,Gs),Xi=Mi.structure,Br=Mi.structureCountMap,kr=Z.nodes[0],Dr=[],Jr=(Tt=Z.nodes[0])===null||Tt===void 0?void 0:Tt[Ge],Ls=-1/0;Z.nodes.forEach(function(is){var Bs=is[Ge],jn=Pn[Bs];(jn==null?void 0:jn.length)>Ls&&(Ls=jn.length,Dr=jn,Jr=Bs,kr=is)});var Lo={},Ka={},oo={},al={},xs={},da={};Object.keys(On).forEach(function(is,Bs){xs[is]=[],le&&(da[is]=[]);var jn=-1/0,br=On[is],Do={};br.forEach(function(vr){var Cs=Ft["".concat(kr.id,"-").concat(vr.id)];if(Cs&&xs[is].push(Cs),jn<Cs&&(jn=Cs),Do["".concat(kr.id,"-").concat(vr.id)]={start:0,end:ai[vr.id].idx,distance:Cs},le){var Ro=Ft["".concat(vr.id,"-").concat(kr.id)];Ro&&da[is].push(Ro)}}),xs[is]=xs[is].sort(function(vr,Cs){return vr-Cs}),le&&(da[is]=da[is].sort(function(vr,Cs){return vr-Cs})),Ka=ha(Do,Qi,Z,Ka);var Ei=[];if(Object.keys(Do).forEach(function(vr){if(oo[vr]){Ei.push(oo[vr]);return}var Cs=Ka[vr];oo[vr]=Zl(Cs,Xi,Ge,wt),Ei.push(oo[vr])}),Ei=Ei.sort(function(vr,Cs){return Cs-vr}),al["".concat(kr.id,"-").concat(is)]=Ei,is!==Jr)for(var Wr=(Dr==null?void 0:Dr.length)||0,vs=function(Cs){var Ro=Dr[Cs],Ms=ji[Nn[Ro.id].idx],Ws=Ms.nodeLabelCountMap[is],dh=On[is].length;if(!Ws||Ws.count<dh)return Dr.splice(Cs,1),"continue";for(var Qr=!1,Ma=0;Ma<dh;Ma++)if(Ws.dists[Ma]>xs[is][Ma]){Qr=!0;break}if(Qr)return Dr.splice(Cs,1),"continue";var dc={};Ms.neighbors.forEach(function(ka){var yo=hn["".concat(Ro.id,"-").concat(ka.id)];dc["".concat(Ro.id,"-").concat(ka.id)]={start:Nn[Ro.id].idx,end:Nn[ka.id].idx,distance:yo}}),yr=ha(dc,ji,$,yr);var ao=[];Object.keys(dc).forEach(function(ka){if(Br[ka]){ao.push(Br[ka]);return}var yo=yr[ka];Br[ka]=Zl(yo,Xi,Ge,wt),ao.push(Br[ka])}),ao=ao.sort(function(ka,yo){return yo-ka});for(var fc=!1,Ma=0;Ma<dh;Ma++)if(ao[Ma]<Ei[Ma]){fc=!0;break}if(fc)return Dr.splice(Cs,1),"continue"},ar=Wr-1;ar>=0;ar--)vs(ar)});var Ys=[];Dr==null||Dr.forEach(function(is){for(var Bs=Nn[is.id].idx,jn=xl($.nodes,Gt[Bs],Bs,Ge,Re),br=jn.neighbors,Do=br.length,Ei=!1,Wr=Do-1;Wr>=0;Wr--){if(br.length+1<Z.nodes.length){Ei=!0;return}var vs=br[Wr],ar=vs[Ge];if(!On[ar]||!On[ar].length){br.splice(Wr,1);continue}if(!xs[ar]||!xs[ar].length){br.splice(Wr,1);continue}var vr="".concat(is.id,"-").concat(vs.id),Cs=hn[vr],Ro=xs[ar].length-1,Ms=xs[ar][Ro];if(Cs>Ms){br.splice(Wr,1);continue}if(le){var Ws="".concat(vs.id,"-").concat(is.id),dh=hn[Ws];Ro=da[ar].length-1;var Qr=da[ar][Ro];if(dh>Qr){br.splice(Wr,1);continue}}var Ma=Br[vr]?Br[vr]:ta($,is,vs,Nn,Cs,ji,Xi,Ge,wt,Br,yr),dc="".concat(kr.id,"-").concat(ar),ao=al[dc][al[dc].length-1];if(Ma<ao){br.splice(Wr,1);continue}var fc=Ua(Lo,ar,ai,On),ka=fc.minPatternNodeLabelDegree,yo=fc.minPatternNodeLabelInDegree,pc=fc.minPatternNodeLabelOutDegree;if(Nn[vs.id].degree<ka){br.splice(Wr,1);continue}}Ei||Ys.push({nodes:[is].concat(br)})});var Oc=so(Z,kr.id,!1).length,Co={};le?(Object.keys(Oc).forEach(function(is){var Bs=ai[is].node[Ge];Co[Bs]?Co[Bs].push(Oc[is]):Co[Bs]=[Oc[is]]}),Object.keys(Co).forEach(function(is){Co[is].sort(function(Bs,jn){return Bs-jn})})):Co=xs;for(var Ul=Ys.length,Ho=function(Bs){var jn=Ys[Bs],br=jn.nodes[0],Do={},Ei={};jn.nodes.forEach(function(fs,Ta){Ei[fs.id]={idx:Ta,node:fs,degree:0,inDegree:0,outDegree:0};var _s=fs[Ge];Do[_s]?Do[_s]++:Do[_s]=1});var Wr=[],vs={};$.edges.forEach(function(fs){Ei[fs.source]&&Ei[fs.target]&&(Wr.push(fs),vs[fs[wt]]?vs[fs[wt]]++:vs[fs[wt]]=1,Ei[fs.source].degree++,Ei[fs.target].degree++,Ei[fs.source].outDegree++,Ei[fs.target].inDegree++)});for(var ar=Object.keys(di).length,vr=!1,Cs=0;Cs<ar;Cs++){var Ro=Object.keys(di)[Cs];if(!vs[Ro]||vs[Ro]<di[Ro].length){vr=!0;break}}if(vr)return Ys.splice(Bs,1),"continue";var Ms=Wr.length;if(Ms<Z.edges.length)return Ys.splice(Bs,1),"break";for(var Ws=!1,dh=function(Ta){var _s=Wr[Ta],Or=_s[wt],Jl=di[Or];if(!Jl||!Jl.length)return vs[Or]--,Jl&&vs[Or]<Jl.length?(Ws=!0,"break"):(Wr.splice(Ta,1),Ei[_s.source].degree--,Ei[_s.target].degree--,Ei[_s.source].outDegree--,Ei[_s.target].inDegree--,"continue");var mc=Ei[_s.source].node[Ge],lu=Ei[_s.target].node[Ge],Zh=!1;if(Jl.forEach(function(cu){var Zs=ai[cu.source].node,Kh=ai[cu.target].node;Zs[Ge]===mc&&Kh[Ge]===lu&&(Zh=!0),!le&&Zs[Ge]===lu&&Kh[Ge]===mc&&(Zh=!0)}),!Zh)return vs[Or]--,Jl&&vs[Or]<Jl.length?(Ws=!0,"break"):(Wr.splice(Ta,1),Ei[_s.source].degree--,Ei[_s.target].degree--,Ei[_s.source].outDegree--,Ei[_s.target].inDegree--,"continue")},Cs=Ms-1;Cs>=0;Cs--){var Qr=dh(Cs);if(Qr==="break")break}if(Ws)return Ys.splice(Bs,1),"continue";jn.edges=Wr;var Ma=so(jn,jn.nodes[0].id,!1).length;if(Object.keys(Ma).reverse().forEach(function(fs){if(!(fs===jn.nodes[0].id||Ws)){if(Ma[fs]===1/0){var Ta=Ei[fs].node[Ge];if(Do[Ta]--,Do[Ta]<On[Ta].length){Ws=!0;return}var _s=jn.nodes.indexOf(Ei[fs].node);jn.nodes.splice(_s,1),Ei[fs]=void 0;return}var Or=Nn[fs].node[Ge];if(!Co[Or]||!Co[Or].length||Ma[fs]>Co[Or][Co[Or].length-1]){var Ta=Ei[fs].node[Ge];if(Do[Ta]--,Do[Ta]<On[Ta].length){Ws=!0;return}var _s=jn.nodes.indexOf(Ei[fs].node);jn.nodes.splice(_s,1),Ei[fs]=void 0}}}),Ws)return Ys.splice(Bs,1),"continue";for(var dc=!0,ao=0;dc&&!Ws;){dc=!1;var fc=le?Ei[br.id].degree<ai[kr.id].degree||Ei[br.id].inDegree<ai[kr.id].inDegree||Ei[br.id].outDegree<ai[kr.id].outDegree:Ei[br.id].degree<ai[kr.id].degree;if(fc){Ws=!0;break}if(Do[br[Ge]]<On[br[Ge]].length){Ws=!0;break}for(var ka=jn.nodes.length,yo=ka-1;yo>=0;yo--){var pc=jn.nodes[yo],Vm=Ei[pc.id].degree,Zi=Ei[pc.id].inDegree,sx=Ei[pc.id].outDegree,kl=pc[Ge],ef=Ua(Lo,kl,ai,On),zu=ef.minPatternNodeLabelDegree,zl=ef.minPatternNodeLabelInDegree,qi=ef.minPatternNodeLabelOutDegree,Sa=le?Vm<zu||Zi<zl||sx<qi:Vm<zu;if(Sa){if(Do[pc[Ge]]--,Do[pc[Ge]]<On[pc[Ge]].length){Ws=!0;break}jn.nodes.splice(yo,1),Ei[pc.id]=void 0,dc=!0}}if(Ws||!dc&&ao!==0)break;Ms=Wr.length;for(var xr=Ms-1;xr>=0;xr--){var Vl=Wr[xr];if(!Ei[Vl.source]||!Ei[Vl.target]){Wr.splice(xr,1);var cl=Vl[wt];if(vs[cl]--,Ei[Vl.source]&&(Ei[Vl.source].degree--,Ei[Vl.source].outDegree--),Ei[Vl.target]&&(Ei[Vl.target].degree--,Ei[Vl.target].inDegree--),di[cl]&&vs[cl]<di[cl].length){Ws=!0;break}dc=!0}}ao++}if(Ws||Ws||jn.nodes.length<Z.nodes.length||Wr.length<Z.edges.length)return Ys.splice(Bs,1),"continue"},wa=Ul-1;wa>=0;wa--){var na=Ho(wa);if(na==="break")break}for(var ll=Ys.length,ia=function(Bs){var jn=Ys[Bs],br={};jn.edges.forEach(function(Wr){var vs="".concat(Wr.source,"-").concat(Wr.target,"-").concat(Wr.label);br[vs]?br[vs]++:br[vs]=1});for(var Do=function(vs){var ar=Ys[vs],vr={};ar.edges.forEach(function(Ro){var Ms="".concat(Ro.source,"-").concat(Ro.target,"-").concat(Ro.label);vr[Ms]?vr[Ms]++:vr[Ms]=1});var Cs=!0;Object.keys(vr).length!==Object.keys(br).length?Cs=!1:Object.keys(br).forEach(function(Ro){vr[Ro]!==br[Ro]&&(Cs=!1)}),Cs&&Ys.splice(vs,1)},Ei=ll-1;Ei>Bs;Ei--)Do(Ei);ll=Ys.length},wa=0;wa<=ll-1;wa++)ia(wa);return Ys}}},uc=ba,hc=function(){function se($){$===void 0&&($=10),this.linkedList=new R,this.maxStep=$}return Object.defineProperty(se.prototype,"length",{get:function(){return this.linkedList.toArray().length},enumerable:!1,configurable:!0}),se.prototype.isEmpty=function(){return!this.linkedList.head},se.prototype.isMaxStack=function(){return this.toArray().length>=this.maxStep},se.prototype.peek=function(){return this.isEmpty()?null:this.linkedList.head.value},se.prototype.push=function($){this.linkedList.prepend($),this.length>this.maxStep&&this.linkedList.deleteTail()},se.prototype.pop=function(){var $=this.linkedList.deleteHead();return $?$.value:null},se.prototype.toArray=function(){return this.linkedList.toArray().map(function($){return $.value})},se.prototype.clear=function(){for(;!this.isEmpty();)this.pop()},se}(),Lc=hc,Dc=Ut,Tl={getAdjMatrix:k,breadthFirstSearch:ye,connectedComponent:xe,getDegree:Ne,getInDegree:Ae,getOutDegree:be,detectCycle:Ut,detectDirectedCycle:Dc,detectAllCycles:kt,detectAllDirectedCycle:It,detectAllUndirectedCycle:_t,depthFirstSearch:We,dijkstra:so,findAllPath:o1,findShortestPath:lh,floydWarshall:Ol,labelPropagation:Fu,louvain:Fr,iLouvain:E0,kCore:qh,kMeans:Yh,cosineSimilarity:ea,nodesCosineSimilarity:ip,minimumSpanningTree:ns,pageRank:oi,getNeighbors:N,Stack:Lc,GADDI:uc}},90494:function(ae,ne){"use strict";var b="*",w=function(){function k(){this._events={}}return k.prototype.on=function(O,A,S){return this._events[O]||(this._events[O]=[]),this._events[O].push({callback:A,once:!!S}),this},k.prototype.once=function(O,A){return this.on(O,A,!0)},k.prototype.emit=function(O){for(var A=this,S=[],R=1;R<arguments.length;R++)S[R-1]=arguments[R];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 K=L[W],re=K.callback,ye=K.once;ye&&(L.splice(W,1),L.length===0&&delete A._events[O],P--,W--),re.apply(A,S)}};N(x),N(E)},k.prototype.off=function(O,A){if(!O)this._events={};else if(!A)delete this._events[O];else{for(var S=this._events[O]||[],R=S.length,x=0;x<R;x++)S[x].callback===A&&(S.splice(x,1),R--,x--);S.length===0&&delete this._events[O]}return this},k.prototype.getEvents=function(){return this._events},k}();ne.Z=w},11702:function(ae,ne,b){"use strict";b.d(ne,{TE:function(){return A},U4:function(){return je},Xk:function(){return We},Y1:function(){return Xe},_x:function(){return It},hE:function(){return Te},l5:function(){return Ue},ph:function(){return Qe},vp:function(){return xe},x4:function(){return Me}});var w=b(97582),k=b(80450),O=b(31437);function A(Pe,Ie,Ke,lt){var qe=Pe-Ke,pt=Ie-lt;return Math.sqrt(qe*qe+pt*pt)}function S(Pe,Ie){var Ke=Math.min.apply(Math,(0,w.ev)([],(0,w.CR)(Pe),!1)),lt=Math.min.apply(Math,(0,w.ev)([],(0,w.CR)(Ie),!1)),qe=Math.max.apply(Math,(0,w.ev)([],(0,w.CR)(Pe),!1)),pt=Math.max.apply(Math,(0,w.ev)([],(0,w.CR)(Ie),!1));return{x:Ke,y:lt,width:qe-Ke,height:pt-lt}}function R(Pe){return(Pe+Math.PI*2)%(Math.PI*2)}function x(Pe,Ie){var Ke=Math.abs(Pe);return Ie>0?Ke:Ke*-1}function E(Pe,Ie,Ke,lt,qe,pt){var Ct=Ke,Xt=lt;if(Ct===0||Xt===0)return{x:Pe,y:Ie};for(var Qt=qe-Pe,pn=pt-Ie,Wn=Math.abs(Qt),Rn=Math.abs(pn),bi=Ct*Ct,Lr=Xt*Xt,Qn=Math.PI/4,Vi=0,Oi=0,Gi=0;Gi<4;Gi++){Vi=Ct*Math.cos(Qn),Oi=Xt*Math.sin(Qn);var ir=(bi-Lr)*Math.pow(Math.cos(Qn),3)/Ct,ms=(Lr-bi)*Math.pow(Math.sin(Qn),3)/Xt,Is=Vi-ir,as=Oi-ms,gs=Wn-ir,Vs=Rn-ms,Xl=Math.hypot(as,Is),ql=Math.hypot(Vs,gs),Da=Xl*Math.asin((Is*Vs-as*gs)/(Xl*ql)),Dl=Da/Math.sqrt(bi+Lr-Vi*Vi-Oi*Oi);Qn+=Dl,Qn=Math.min(Math.PI/2,Math.max(0,Qn))}return{x:Pe+x(Vi,Qt),y:Ie+x(Oi,pn)}}function N(Pe,Ie,Ke,lt,qe,pt,Ct,Xt){return-1*Ke*Math.cos(qe)*Math.sin(Xt)-lt*Math.sin(qe)*Math.cos(Xt)}function L(Pe,Ie,Ke,lt,qe,pt,Ct,Xt){return-1*Ke*Math.sin(qe)*Math.sin(Xt)+lt*Math.cos(qe)*Math.cos(Xt)}function P(Pe,Ie,Ke){return Math.atan(-Ie/Pe*Math.tan(Ke))}function W(Pe,Ie,Ke){return Math.atan(Ie/(Pe*Math.tan(Ke)))}function K(Pe,Ie,Ke,lt,qe,pt){return Ke*Math.cos(qe)*Math.cos(pt)-lt*Math.sin(qe)*Math.sin(pt)+Pe}function re(Pe,Ie,Ke,lt,qe,pt){return Ke*Math.sin(qe)*Math.cos(pt)+lt*Math.cos(qe)*Math.sin(pt)+Ie}function ye(Pe,Ie,Ke,lt){var qe=Math.atan2(lt*Pe,Ke*Ie);return(qe+Math.PI*2)%(Math.PI*2)}function ge(Pe,Ie,Ke){return{x:Pe*Math.cos(Ke),y:Ie*Math.sin(Ke)}}function ce(Pe,Ie,Ke){var lt=Math.cos(Ke),qe=Math.sin(Ke);return[Pe*lt-Ie*qe,Pe*qe+Ie*lt]}function xe(Pe,Ie,Ke,lt,qe,pt,Ct){for(var Xt=P(Ke,lt,qe),Qt=1/0,pn=-1/0,Wn=[pt,Ct],Rn=-Math.PI*2;Rn<=Math.PI*2;Rn+=Math.PI){var bi=Xt+Rn;pt<Ct?pt<bi&&bi<Ct&&Wn.push(bi):Ct<bi&&bi<pt&&Wn.push(bi)}for(var Rn=0;Rn<Wn.length;Rn++){var Lr=K(Pe,Ie,Ke,lt,qe,Wn[Rn]);Lr<Qt&&(Qt=Lr),Lr>pn&&(pn=Lr)}for(var Qn=W(Ke,lt,qe),Vi=1/0,Oi=-1/0,Gi=[pt,Ct],Rn=-Math.PI*2;Rn<=Math.PI*2;Rn+=Math.PI){var ir=Qn+Rn;pt<Ct?pt<ir&&ir<Ct&&Gi.push(ir):Ct<ir&&ir<pt&&Gi.push(ir)}for(var Rn=0;Rn<Gi.length;Rn++){var ms=re(Pe,Ie,Ke,lt,qe,Gi[Rn]);ms<Vi&&(Vi=ms),ms>Oi&&(Oi=ms)}return{x:Qt,y:Vi,width:pn-Qt,height:Oi-Vi}}function fe(Pe,Ie,Ke,lt,qe,pt,Ct,Xt,Qt){var pn=ce(Xt-Pe,Qt-Ie,-qe),Wn=__read(pn,2),Rn=Wn[0],bi=Wn[1],Lr=E(0,0,Ke,lt,Rn,bi),Qn=ye(Ke,lt,Lr.x,Lr.y);Qn<pt?Lr=ge(Ke,lt,pt):Qn>Ct&&(Lr=ge(Ke,lt,Ct));var Vi=ce(Lr.x,Lr.y,qe);return{x:Vi[0]+Pe,y:Vi[1]+Ie}}function Ne(Pe,Ie,Ke,lt,qe,pt,Ct,Xt){var Qt=(Ct-pt)*Xt+pt,pn=N(Pe,Ie,Ke,lt,qe,pt,Ct,Qt),Wn=L(Pe,Ie,Ke,lt,qe,pt,Ct,Qt);return R(Math.atan2(Wn,pn))}var Ae=1e-4;function be(Pe,Ie,Ke,lt,qe,pt){var Ct=-1,Xt=1/0,Qt=[Ke,lt],pn=20;pt&&pt>200&&(pn=pt/10);for(var Wn=1/pn,Rn=Wn/10,bi=0;bi<=pn;bi++){var Lr=bi*Wn,Qn=[qe.apply(void 0,(0,w.ev)([],(0,w.CR)(Pe.concat([Lr])),!1)),qe.apply(void 0,(0,w.ev)([],(0,w.CR)(Ie.concat([Lr])),!1))],Vi=A(Qt[0],Qt[1],Qn[0],Qn[1]);Vi<Xt&&(Ct=Lr,Xt=Vi)}if(Ct===0)return{x:Pe[0],y:Ie[0]};if(Ct===1){var Oi=Pe.length;return{x:Pe[Oi-1],y:Ie[Oi-1]}}Xt=1/0;for(var bi=0;bi<32&&!(Rn<Ae);bi++){var Gi=Ct-Rn,ir=Ct+Rn,Qn=[qe.apply(void 0,(0,w.ev)([],(0,w.CR)(Pe.concat([Gi])),!1)),qe.apply(void 0,(0,w.ev)([],(0,w.CR)(Ie.concat([Gi])),!1))],Vi=A(Qt[0],Qt[1],Qn[0],Qn[1]);if(Gi>=0&&Vi<Xt)Ct=Gi,Xt=Vi;else{var ms=[qe.apply(void 0,(0,w.ev)([],(0,w.CR)(Pe.concat([ir])),!1)),qe.apply(void 0,(0,w.ev)([],(0,w.CR)(Ie.concat([ir])),!1))],Is=A(Qt[0],Qt[1],ms[0],ms[1]);ir<=1&&Is<Xt?(Ct=ir,Xt=Is):Rn*=.5}}return{x:qe.apply(void 0,(0,w.ev)([],(0,w.CR)(Pe.concat([Ct])),!1)),y:qe.apply(void 0,(0,w.ev)([],(0,w.CR)(Ie.concat([Ct])),!1))}}function Ye(Pe,Ie){for(var Ke=0,lt=Pe.length,qe=0;qe<lt;qe++){var pt=Pe[qe],Ct=Ie[qe],Xt=Pe[(qe+1)%lt],Qt=Ie[(qe+1)%lt];Ke+=A(pt,Ct,Xt,Qt)}return Ke/2}function Ee(Pe,Ie,Ke,lt){return S([Pe,Ke],[Ie,lt])}function We(Pe,Ie,Ke,lt){return A(Pe,Ie,Ke,lt)}function je(Pe,Ie,Ke,lt,qe){return{x:(1-qe)*Pe+qe*Ke,y:(1-qe)*Ie+qe*lt}}function _t(Pe,Ie,Ke,lt,qe,pt){var Ct=(Ke-Pe)*(qe-Pe)+(lt-Ie)*(pt-Ie);if(Ct<0)return A(Pe,Ie,qe,pt);var Xt=(Ke-Pe)*(Ke-Pe)+(lt-Ie)*(lt-Ie);return Ct>Xt?A(Ke,lt,qe,pt):It(Pe,Ie,Ke,lt,qe,pt)}function It(Pe,Ie,Ke,lt,qe,pt){var Ct=[Ke-Pe,lt-Ie];if(O.I6(Ct,[0,0]))return Math.sqrt((qe-Pe)*(qe-Pe)+(pt-Ie)*(pt-Ie));var Xt=[-Ct[1],Ct[0]];O.Fv(Xt,Xt);var Qt=[qe-Pe,pt-Ie];return Math.abs(O.AK(Qt,Xt))}function kt(Pe,Ie,Ke,lt){return Math.atan2(lt-Ie,Ke-Pe)}function Ut(Pe,Ie,Ke,lt,qe){var pt=1-qe;return pt*pt*pt*Pe+3*Ie*qe*pt*pt+3*Ke*qe*qe*pt+lt*qe*qe*qe}function At(Pe,Ie,Ke,lt,qe){var pt=1-qe;return 3*(pt*pt*(Ie-Pe)+2*pt*qe*(Ke-Ie)+qe*qe*(lt-Ke))}function at(Pe,Ie,Ke,lt){var qe=-3*Pe+9*Ie-9*Ke+3*lt,pt=6*Pe-12*Ie+6*Ke,Ct=3*Ie-3*Pe,Xt=[],Qt,pn,Wn;if((0,k.Z)(qe,0))(0,k.Z)(pt,0)||(Qt=-Ct/pt,Qt>=0&&Qt<=1&&Xt.push(Qt));else{var Rn=pt*pt-4*qe*Ct;(0,k.Z)(Rn,0)?Xt.push(-pt/(2*qe)):Rn>0&&(Wn=Math.sqrt(Rn),Qt=(-pt+Wn)/(2*qe),pn=(-pt-Wn)/(2*qe),Qt>=0&&Qt<=1&&Xt.push(Qt),pn>=0&&pn<=1&&Xt.push(pn))}return Xt}function Ot(Pe,Ie,Ke,lt,qe,pt,Ct,Xt,Qt){var pn=Ut(Pe,Ke,qe,Ct,Qt),Wn=Ut(Ie,lt,pt,Xt,Qt),Rn=je(Pe,Ie,Ke,lt,Qt),bi=je(Ke,lt,qe,pt,Qt),Lr=je(qe,pt,Ct,Xt,Qt),Qn=je(Rn.x,Rn.y,bi.x,bi.y,Qt),Vi=je(bi.x,bi.y,Lr.x,Lr.y,Qt);return[[Pe,Ie,Rn.x,Rn.y,Qn.x,Qn.y,pn,Wn],[pn,Wn,Vi.x,Vi.y,Lr.x,Lr.y,Ct,Xt]]}function ue(Pe,Ie,Ke,lt,qe,pt,Ct,Xt,Qt){if(Qt===0)return Ye([Pe,Ke,qe,Ct],[Ie,lt,pt,Xt]);var pn=Ot(Pe,Ie,Ke,lt,qe,pt,Ct,Xt,.5),Wn=__spreadArray(__spreadArray([],__read(pn[0]),!1),[Qt-1],!1),Rn=__spreadArray(__spreadArray([],__read(pn[1]),!1),[Qt-1],!1);return ue.apply(void 0,__spreadArray([],__read(Wn),!1))+ue.apply(void 0,__spreadArray([],__read(Rn),!1))}function Ue(Pe,Ie,Ke,lt,qe,pt,Ct,Xt){for(var Qt=[Pe,Ct],pn=[Ie,Xt],Wn=at(Pe,Ke,qe,Ct),Rn=at(Ie,lt,pt,Xt),bi=0;bi<Wn.length;bi++)Qt.push(Ut(Pe,Ke,qe,Ct,Wn[bi]));for(var bi=0;bi<Rn.length;bi++)pn.push(Ut(Ie,lt,pt,Xt,Rn[bi]));return S(Qt,pn)}function vt(Pe,Ie,Ke,lt,qe,pt,Ct,Xt){return ue(Pe,Ie,Ke,lt,qe,pt,Ct,Xt,3)}function Jt(Pe,Ie,Ke,lt,qe,pt,Ct,Xt,Qt,pn,Wn){return be([Pe,Ke,qe,Ct],[Ie,lt,pt,Xt],Qt,pn,Ut,Wn)}function Qe(Pe,Ie,Ke,lt,qe,pt,Ct,Xt,Qt,pn,Wn){var Rn=Jt(Pe,Ie,Ke,lt,qe,pt,Ct,Xt,Qt,pn,Wn);return A(Rn.x,Rn.y,Qt,pn)}function rt(Pe,Ie,Ke,lt,qe,pt,Ct,Xt,Qt){return{x:Ut(Pe,Ke,qe,Ct,Qt),y:Ut(Ie,lt,pt,Xt,Qt)}}function bt(Pe,Ie,Ke,lt,qe,pt,Ct,Xt,Qt){var pn=At(Pe,Ke,qe,Ct,Qt),Wn=At(Ie,lt,pt,Xt,Qt);return R(Math.atan2(Wn,pn))}function ze(Pe){for(var Ie=0,Ke=[],lt=0;lt<Pe.length-1;lt++){var qe=Pe[lt],pt=Pe[lt+1],Ct=A(qe[0],qe[1],pt[0],pt[1]),Xt={from:qe,to:pt,length:Ct};Ke.push(Xt),Ie+=Ct}return{segments:Ke,totalLength:Ie}}function Ze(Pe){if(Pe.length<2)return 0;for(var Ie=0,Ke=0;Ke<Pe.length-1;Ke++){var lt=Pe[Ke],qe=Pe[Ke+1];Ie+=A(lt[0],lt[1],qe[0],qe[1])}return Ie}function q(Pe,Ie){if(Ie>1||Ie<0||Pe.length<2)return null;var Ke=ze(Pe),lt=Ke.segments,qe=Ke.totalLength;if(qe===0)return{x:Pe[0][0],y:Pe[0][1]};for(var pt=0,Ct=null,Xt=0;Xt<lt.length;Xt++){var Qt=lt[Xt],pn=Qt.from,Wn=Qt.to,Rn=Qt.length/qe;if(Ie>=pt&&Ie<=pt+Rn){var bi=(Ie-pt)/Rn;Ct=je(pn[0],pn[1],Wn[0],Wn[1],bi);break}pt+=Rn}return Ct}function Y(Pe,Ie){if(Ie>1||Ie<0||Pe.length<2)return 0;for(var Ke=ze(Pe),lt=Ke.segments,qe=Ke.totalLength,pt=0,Ct=0,Xt=0;Xt<lt.length;Xt++){var Qt=lt[Xt],pn=Qt.from,Wn=Qt.to,Rn=Qt.length/qe;if(Ie>=pt&&Ie<=pt+Rn){Ct=Math.atan2(Wn[1]-pn[1],Wn[0]-pn[0]);break}pt+=Rn}return Ct}function de(Pe,Ie,Ke){for(var lt=1/0,qe=0;qe<Pe.length-1;qe++){var pt=Pe[qe],Ct=Pe[qe+1],Xt=_t(pt[0],pt[1],Ct[0],Ct[1],Ie,Ke);Xt<lt&&(lt=Xt)}return lt}function Je(Pe){for(var Ie=[],Ke=[],lt=0;lt<Pe.length;lt++){var qe=Pe[lt];Ie.push(qe[0]),Ke.push(qe[1])}return S(Ie,Ke)}function Te(Pe){return Ze(Pe)}function $e(Pe,Ie){return q(Pe,Ie)}function xt(Pe,Ie,Ke){return de(Pe,Ie,Ke)}function ke(Pe,Ie){return Y(Pe,Ie)}function et(Pe){var Ie=Pe.slice(0);return Pe.length&&Ie.push(Pe[0]),Ie}function yt(Pe){return Je(Pe)}function B(Pe){return Ze(et(Pe))}function ie(Pe,Ie){return q(et(Pe),Ie)}function ct(Pe,Ie,Ke){return de(et(Pe),Ie,Ke)}function Mt(Pe,Ie){return Y(et(Pe),Ie)}function ht(Pe,Ie,Ke,lt){var qe=1-lt;return qe*qe*Pe+2*lt*qe*Ie+lt*lt*Ke}function Yt(Pe,Ie,Ke){var lt=Pe+Ke-2*Ie;if((0,k.Z)(lt,0))return[.5];var qe=(Pe-Ie)/lt;return qe<=1&&qe>=0?[qe]:[]}function en(Pe,Ie,Ke,lt,qe,pt,Ct){var Xt=ht(Pe,Ke,qe,Ct),Qt=ht(Ie,lt,pt,Ct),pn=je(Pe,Ie,Ke,lt,Ct),Wn=je(Ke,lt,qe,pt,Ct);return[[Pe,Ie,pn.x,pn.y,Xt,Qt],[Xt,Qt,Wn.x,Wn.y,qe,pt]]}function nn(Pe,Ie,Ke,lt,qe,pt,Ct){if(Ct===0)return(A(Pe,Ie,Ke,lt)+A(Ke,lt,qe,pt)+A(Pe,Ie,qe,pt))/2;var Xt=en(Pe,Ie,Ke,lt,qe,pt,.5),Qt=Xt[0],pn=Xt[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 Me(Pe,Ie,Ke,lt,qe,pt){var Ct=Yt(Pe,Ke,qe)[0],Xt=Yt(Ie,lt,pt)[0],Qt=[Pe,qe],pn=[Ie,pt];return Ct!==void 0&&Qt.push(ht(Pe,Ke,qe,Ct)),Xt!==void 0&&pn.push(ht(Ie,lt,pt,Xt)),S(Qt,pn)}function te(Pe,Ie,Ke,lt,qe,pt){return nn(Pe,Ie,Ke,lt,qe,pt,3)}function Fe(Pe,Ie,Ke,lt,qe,pt,Ct,Xt){return be([Pe,Ke,qe],[Ie,lt,pt],Ct,Xt,ht)}function Xe(Pe,Ie,Ke,lt,qe,pt,Ct,Xt){var Qt=Fe(Pe,Ie,Ke,lt,qe,pt,Ct,Xt);return A(Qt.x,Qt.y,Ct,Xt)}},44326:function(ae,ne,b){"use strict";b.d(ne,{k:function(){return A}});var w=b(90494),k=b(69991),O=b(35105);class A extends w.Z{constructor(x){super();aa(this,"nodeMap",new Map);aa(this,"edgeMap",new Map);aa(this,"inEdgesMap",new Map);aa(this,"outEdgesMap",new Map);aa(this,"bothEdgesMap",new Map);aa(this,"treeIndices",new Map);aa(this,"changes",[]);aa(this,"batchCount",0);aa(this,"onChanged",()=>{});aa(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,K;(W=L.childrenMap.get(x))==null||W.forEach(re=>{L.parentMap.delete(re.id)});const P=L.parentMap.get(x);P&&((K=L.childrenMap.get(P.id))==null||K.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(K=>{this.setParent(K.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 ye,ge;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&&((ye=L.childrenMap.get(W.id))==null||ye.delete(P)),L.parentMap.delete(x);return}const K=this.getNode(E);L.parentMap.set(x,K),W&&((ge=L.childrenMap.get(W.id))==null||ge.delete(P));let re=L.childrenMap.get(K.id);re||(re=new Set,L.childrenMap.set(K.id,re)),re.add(P),this.batch(()=>{this.changes.push({type:"TreeStructureChanged",treeKey:N,nodeId:x,oldParentId:W==null?void 0:W.id,newParentId:K.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=>ac(qs({},L),{data:qs({},L.data)})),E=this.getAllEdges().map(L=>ac(qs({},L),{data:qs({},L.data)})),N=new A({nodes:x,edges:E});return this.treeIndices.forEach(({parentMap:L,childrenMap:P},W)=>{const K=new Map;L.forEach((ye,ge)=>{K.set(ge,N.getNode(ye.id))});const re=new Map;P.forEach((ye,ge)=>{re.set(ge,new Set(Array.from(ye).map(ce=>N.getNode(ce.id))))}),N.treeIndices.set(W,{parentMap:K,childrenMap:re})}),N}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}createView(x){return new k.t(qs({graph:this},x))}}},69991:function(ae,ne,b){"use strict";b.d(ne,{t:function(){return O}});var w=b(35105);const k=()=>!0;class O{constructor(S){aa(this,"graph");aa(this,"nodeFilter");aa(this,"edgeFilter");aa(this,"cacheEnabled");aa(this,"inEdgesMap",new Map);aa(this,"outEdgesMap",new Map);aa(this,"bothEdgesMap",new Map);aa(this,"allNodesMap",new Map);aa(this,"allEdgesMap",new Map);aa(this,"clearCache",()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()});aa(this,"refreshCache",()=>{this.clearCache(),this.updateCache(this.graph.getAllNodes().map(S=>S.id))});aa(this,"updateCache",S=>{const R=new Set;S.forEach(x=>{const E=this.bothEdgesMap.get(x);if(E&&E.forEach(N=>R.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=>R.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))}}),R.forEach(x=>{this.hasEdge(x)?this.allEdgesMap.set(x,this.graph.getEdge(x)):this.allEdgesMap.delete(x)})});aa(this,"handleGraphChanged",S=>{const R=new Set;S.changes.forEach(x=>{switch(x.type){case"NodeAdded":R.add(x.value.id);break;case"NodeDataUpdated":R.add(x.id);break;case"EdgeAdded":R.add(x.value.source),R.add(x.value.target);break;case"EdgeUpdated":(x.propertyName==="source"||x.propertyName==="target")&&(R.add(x.oldValue),R.add(x.newValue));break;case"EdgeDataUpdated":if(S.graph.hasEdge(x.id)){const E=S.graph.getEdge(x.id);R.add(E.source),R.add(E.target)}break;case"EdgeRemoved":R.add(x.value.source),R.add(x.value.target);break;case"NodeRemoved":R.add(x.value.id);break;default:break}}),this.updateCache(R)});this.graph=S.graph;const R=S.nodeFilter||k,x=S.edgeFilter||k;this.nodeFilter=R,this.edgeFilter=E=>{const{source:N,target:L}=this.graph.getEdgeDetail(E.id);return!R(N)||!R(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 R=this.graph.getNode(S);return this.nodeFilter(R)}areNeighbors(S,R){return this.checkNodeExistence(S),this.getNeighbors(R).some(x=>x.id===S)}getNode(S){const R=this.graph.getNode(S);if(!this.nodeFilter(R))throw new Error("Node not found for id: "+S);return R}getRelatedEdges(S,R){return this.checkNodeExistence(S),this.cacheEnabled?R==="in"?this.inEdgesMap.get(S):R==="out"?this.outEdgesMap.get(S):this.bothEdgesMap.get(S):this.graph.getRelatedEdges(S,R).filter(this.edgeFilter)}getDegree(S,R){return this.getRelatedEdges(S,R).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 R=this.getPredecessors(S),x=this.getSuccessors(S);return Array.from(new Set([...R,...x]))}hasEdge(S){if(!this.graph.hasEdge(S))return!1;const R=this.graph.getEdge(S);return this.edgeFilter(R)}getEdge(S){const R=this.graph.getEdge(S);if(!this.edgeFilter(R))throw new Error("Edge not found for id: "+S);return R}getEdgeDetail(S){const R=this.getEdge(S);return{edge:R,source:this.getNode(R.source),target:this.getNode(R.target)}}hasTreeStructure(S){return this.graph.hasTreeStructure(S)}getRoots(S){return this.graph.getRoots(S).filter(this.nodeFilter)}getChildren(S,R){return this.checkNodeExistence(S),this.graph.getChildren(S,R).filter(this.nodeFilter)}getParent(S,R){this.checkNodeExistence(S);const x=this.graph.getParent(S,R);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,R,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,R,E)}dfs(S,R,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,R,E)}}},35105:function(ae,ne,b){"use strict";b.d(ne,{I:function(){return k},O:function(){return w}});function w(O,A,S,R){for(;O.length;){const x=O.shift();if(S(x))return!0;A.add(x.id),R(x.id).forEach(N=>{A.has(N.id)||(A.add(N.id),O.push(N))})}return!1}function k(O,A,S,R){if(S(O))return!0;A.add(O.id);for(const E of R(O.id))if(!A.has(E.id)&&k(E,A,S,R))return!0;return!1}},81746:function(ae){(function(b,w){ae.exports=w()})(typeof self!="undefined"?self:this,function(){return function(ne){var b={};function w(k){if(b[k])return b[k].exports;var O=b[k]={i:k,l:!1,exports:{}};return ne[k].call(O.exports,O,O.exports,w),O.l=!0,O.exports}return w.m=ne,w.c=b,w.d=function(k,O,A){w.o(k,O)||Object.defineProperty(k,O,{configurable:!1,enumerable:!0,get:A})},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(ne,b){function w(k,O,A,S){return S===void 0&&(S="height"),A==="center"?(k[S]+O[S])/2:k.height}ne.exports={assign:Object.assign,getHeight:w}},function(ne,b,w){var k=w(3),O=function(){function A(R,x){x===void 0&&(x={});var E=this;E.options=x,E.rootNode=k(R,x)}var S=A.prototype;return S.execute=function(){throw new Error("please override this method")},A}();ne.exports=O},function(ne,b,w){var k=w(4),O=["LR","RL","TB","BT","H","V"],A=["LR","RL","H"],S=function(N){return A.indexOf(N)>-1},R=O[0];ne.exports=function(E,N,L){var P=N.direction||R;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),K=W.left,re=W.right;L(K,N),L(re,N),N.isHorizontal?K.right2left():K.bottom2top(),re.translate(K.x-re.x,K.y-re.y),E.x=K.x,E.y=re.y;var ye=E.getBoundingBox();N.isHorizontal?ye.top<0&&E.translate(0,-ye.top):ye.left<0&&E.translate(-ye.left,0)}var ge=N.fixedRoot;return ge===void 0&&(ge=!0),ge&&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],K={x:1/0,y:1/0},re={x:-1/0,y:-1/0},ye=0;E.DFTraverse(function(xe){ye++;var fe=xe.x,Ne=xe.y;K.x=Math.min(K.x,fe),K.y=Math.min(K.y,Ne),re.x=Math.max(re.x,fe),re.y=Math.max(re.y,Ne)});var ge=re[W]-K[W];if(ge===0)return;var ce=Math.PI*2/ye;E.DFTraverse(function(xe){var fe=(xe[W]-K[W])/ge*(Math.PI*2-ce)+ce,Ne=xe[P]-E[P];xe.x=Math.cos(fe)*Ne,xe.y=Math.sin(fe)*Ne})}}},function(ne,b,w){var k=w(0),O=18,A=O*2,S=O,R={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||A},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),K=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,K),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],K;K=W.shift();)L(K),W=K.children.concat(W)},DFTraverse:function(L){this.eachNode(L)},BFTraverse:function(L){for(var P=this,W=[P],K;K=W.shift();)L(K),W=W.concat(K.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({},R,L);var W=new x(N,L),K=[W],re;if(!P&&!N.collapsed){for(;re=K.shift();)if(!re.data.collapsed){var ye=L.getChildren(re.data),ge=ye?ye.length:0;if(re.children=new Array(ge),ye&&ge)for(var ce=0;ce<ge;ce++){var xe=new x(ye[ce],L);re.children[ce]=xe,K.push(xe),xe.parent=re,xe.depth=re.depth+1}}}return W}ne.exports=E},function(ne,b,w){var k=w(3);ne.exports=function(O,A){for(var S=k(O.data,A,!0),R=k(O.data,A,!0),x=O.children.length,E=Math.round(x/2),N=A.getSide||function(K,re){return re<E?"right":"left"},L=0;L<x;L++){var P=O.children[L],W=N(P,L);W==="right"?R.children.push(P):S.children.push(P)}return S.eachNode(function(K){K.isRoot()||(K.side="left")}),R.eachNode(function(K){K.isRoot()||(K.side="right")}),{left:S,right:R}}},function(ne,b,w){var k={compactBox:w(6),dendrogram:w(8),indented:w(10),mindmap:w(12)};ne.exports=k},function(ne,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(K,re){return K.__proto__=re,K},O(P,W)}var A=w(1),S=w(7),R=w(2),x=w(0),E=function(P){function W(){return P.apply(this,arguments)||this}k(W,P);var K=W.prototype;return K.execute=function(){var ye=this;return R(ye.rootNode,ye.options,S)},W}(A),N={};function L(P,W){return W=x.assign({},N,W),new E(P,W).execute()}ne.exports=L},function(ne,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 A(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 R(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){R(L,E,N)})}ne.exports=function(x,E){E===void 0&&(E={});var N=E.isHorizontal;function L(We){if(We.cs===0){P(We);return}L(We.c[0]);for(var je=Ye(ge(We.c[0].el),0,null),_t=1;_t<We.cs;++_t){L(We.c[_t]);var It=ge(We.c[_t].er);W(We,_t,je),je=Ye(It,_t,je)}fe(We),P(We)}function P(We){We.cs===0?(We.el=We,We.er=We,We.msel=We.mser=0):(We.el=We.c[0].el,We.msel=We.c[0].msel,We.er=We.c[We.cs-1].er,We.mser=We.c[We.cs-1].mser)}function W(We,je,_t){for(var It=We.c[je-1],kt=It.mod,Ut=We.c[je],At=Ut.mod;It!==null&&Ut!==null;){ge(It)>_t.low&&(_t=_t.nxt);var at=kt+It.prelim+It.w-(At+Ut.prelim);at>0&&(At+=at,K(We,je,_t.index,at));var Ot=ge(It),ue=ge(Ut);Ot<=ue&&(It=ye(It),It!==null&&(kt+=It.mod)),Ot>=ue&&(Ut=re(Ut),Ut!==null&&(At+=Ut.mod))}!It&&Ut?ce(We,je,Ut,At):It&&!Ut&&xe(We,je,It,kt)}function K(We,je,_t,It){We.c[je].mod+=It,We.c[je].msel+=It,We.c[je].mser+=It,Ae(We,je,_t,It)}function re(We){return We.cs===0?We.tl:We.c[0]}function ye(We){return We.cs===0?We.tr:We.c[We.cs-1]}function ge(We){return We.y+We.h}function ce(We,je,_t,It){var kt=We.c[0].el;kt.tl=_t;var Ut=It-_t.mod-We.c[0].msel;kt.mod+=Ut,kt.prelim-=Ut,We.c[0].el=We.c[je].el,We.c[0].msel=We.c[je].msel}function xe(We,je,_t,It){var kt=We.c[je].er;kt.tr=_t;var Ut=It-_t.mod-We.c[je].mser;kt.mod+=Ut,kt.prelim-=Ut,We.c[je].er=We.c[je-1].er,We.c[je].mser=We.c[je-1].mser}function fe(We){We.prelim=(We.c[0].prelim+We.c[0].mod+We.c[We.cs-1].mod+We.c[We.cs-1].prelim+We.c[We.cs-1].w)/2-We.w/2}function Ne(We,je){je+=We.mod,We.x=We.prelim+je,be(We);for(var _t=0;_t<We.cs;_t++)Ne(We.c[_t],je)}function Ae(We,je,_t,It){if(_t!==je-1){var kt=je-_t;We.c[_t+1].shift+=It/kt,We.c[je].shift-=It/kt,We.c[je].change-=It-It/kt}}function be(We){for(var je=0,_t=0,It=0;It<We.cs;It++)je+=We.c[It].shift,_t+=je+We.c[It].change,We.c[It].mod+=_t}function Ye(We,je,_t){for(;_t!==null&&We>=_t.low;)_t=_t.nxt;return{low:We,index:je,nxt:_t}}R(x,N);var Ee=w.fromNode(x,N);return L(Ee),Ne(Ee,0),S(Ee,x,N),A(x,N),x}},function(ne,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(K,re){return K.__proto__=re,K},O(P,W)}var A=w(1),S=w(9),R=w(2),x=w(0),E=function(P){function W(){return P.apply(this,arguments)||this}k(W,P);var K=W.prototype;return K.execute=function(){var ye=this;return ye.rootNode.width=0,R(ye.rootNode,ye.options,S)},W}(A),N={};function L(P,W){return W=x.assign({},N,W),new E(P,W).execute()}ne.exports=L},function(ne,b,w){var k=w(0);function O(R,x){R===void 0&&(R=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 A={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};function S(R,x,E){E?(x.x=R.x,x.y=R.y):(x.x=R.y,x.y=R.x),R.children.forEach(function(N,L){S(N,x.children[L],E)})}ne.exports=function(R,x){x===void 0&&(x={}),x=k.assign({},A,x);var E=0;function N(re){if(!re)return null;re.width=0,re.depth&&re.depth>E&&(E=re.depth);var ye=re.children,ge=ye.length,ce=new O(re.height,[]);return ye.forEach(function(xe,fe){var Ne=N(xe);ce.children.push(Ne),fe===0&&(ce.leftChild=Ne),fe===ge-1&&(ce.rightChild=Ne)}),ce.originNode=re,ce.isLeaf=re.isLeaf(),ce}function L(re){if(re.isLeaf||re.children.length===0)re.drawingDepth=E;else{var ye=re.children.map(function(ce){return L(ce)}),ge=Math.min.apply(null,ye);re.drawingDepth=ge-1}return re.drawingDepth}var P;function W(re){re.x=re.drawingDepth*x.rankSep,re.isLeaf?(re.y=0,P&&(re.y=P.y+P.height+x.nodeSep,re.originNode.parent!==P.originNode.parent&&(re.y+=x.subTreeSep)),P=re):(re.children.forEach(function(ye){W(ye)}),re.y=(re.leftChild.y+re.rightChild.y)/2)}var K=N(R);return L(K),W(K),S(K,R,x.isHorizontal),R}},function(ne,b,w){function k(K,re){K.prototype=Object.create(re.prototype),K.prototype.constructor=K,O(K,re)}function O(K,re){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(ye,ge){return ye.__proto__=ge,ye},O(K,re)}var A=w(1),S=w(11),R=w(4),x=w(0),E=["LR","RL","H"],N=E[0],L=function(K){function re(){return K.apply(this,arguments)||this}k(re,K);var ye=re.prototype;return ye.execute=function(){var ce=this,xe=ce.options,fe=ce.rootNode;xe.isHorizontal=!0;var Ne=xe.indent,Ae=Ne===void 0?20:Ne,be=xe.dropCap,Ye=be===void 0?!0:be,Ee=xe.direction,We=Ee===void 0?N:Ee,je=xe.align;if(We&&E.indexOf(We)===-1)throw new TypeError("Invalid direction: "+We);if(We===E[0])S(fe,Ae,Ye,je);else if(We===E[1])S(fe,Ae,Ye,je),fe.right2left();else if(We===E[2]){var _t=R(fe,xe),It=_t.left,kt=_t.right;S(It,Ae,Ye,je),It.right2left(),S(kt,Ae,Ye,je);var Ut=It.getBoundingBox();kt.translate(Ut.width,0),fe.x=kt.x-fe.width/2}return fe},re}(A),P={};function W(K,re){return re=x.assign({},P,re),new L(K,re).execute()}ne.exports=W},function(ne,b,w){var k=w(0);function O(A,S,R,x,E){var N=(typeof R=="function"?R(A):R)*A.depth;if(!x)try{if(A.id===A.parent.children[0].id){A.x+=N,A.y=S?S.y:0;return}}catch(W){}if(A.x+=N,S){if(A.y=S.y+k.getHeight(S,A,E),S.parent&&A.parent.id!==S.parent.id){var L=S.parent,P=L.y+k.getHeight(L,A,E);A.y=P>A.y?P:A.y}}else A.y=0}ne.exports=function(A,S,R,x){var E=null;A.eachNode(function(N){O(N,E,S,R,x),E=N})}},function(ne,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(K,re){return K.__proto__=re,K},O(P,W)}var A=w(1),S=w(13),R=w(2),x=w(0),E=function(P){function W(){return P.apply(this,arguments)||this}k(W,P);var K=W.prototype;return K.execute=function(){var ye=this;return R(ye.rootNode,ye.options,S)},W}(A),N={};function L(P,W){return W=x.assign({},N,W),new E(P,W).execute()}ne.exports=L},function(ne,b,w){var k=w(0);function O(R,x){var E=0;return R.children.length?R.children.forEach(function(N){E+=O(N,x)}):E=R.height,R._subTreeSep=x.getSubTreeSep(R.data),R.totalHeight=Math.max(R.height,E)+2*R._subTreeSep,R.totalHeight}function A(R){var x=R.children,E=x.length;if(E){x.forEach(function(re){A(re)});var N=x[0],L=x[E-1],P=L.y-N.y+L.height,W=0;if(x.forEach(function(re){W+=re.totalHeight}),P>R.height)R.y=N.y+P/2-R.height/2;else if(x.length!==1||R.height>W){var K=R.y+(R.height-P)/2-N.y;x.forEach(function(re){re.translate(0,K)})}else R.y=(N.y+N.height/2+L.y+L.height/2)/2-R.height/2}}var S={getSubTreeSep:function(){return 0}};ne.exports=function(R,x){x===void 0&&(x={}),x=k.assign({},S,x),R.parent={x:0,width:0,height:0,y:0},R.BFTraverse(function(E){E.x=E.parent.x+E.parent.width}),R.parent=null,O(R,x),R.startY=0,R.y=R.totalHeight/2-R.height/2,R.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 K=N[W];K.startY=N[W-1].startY+N[W-1].totalHeight,K.y=K.startY+K.totalHeight/2-K.height/2}}}}),A(R)}}])})},15278:function(ae,ne,b){"use strict";b.d(ne,{t:function(){return ce}});function w({map:xe,initKey:fe},Ne){const Ae=fe(Ne);return xe.has(Ae)?xe.get(Ae):Ne}function k({map:xe,initKey:fe},Ne){const Ae=fe(Ne);return xe.has(Ae)?xe.get(Ae):(xe.set(Ae,Ne),Ne)}function O({map:xe,initKey:fe},Ne){const Ae=fe(Ne);return xe.has(Ae)&&(Ne=xe.get(Ae),xe.delete(Ae)),Ne}function A(xe){return typeof xe=="object"?xe.valueOf():xe}class S extends Map{constructor(fe){if(super(),this.map=new Map,this.initKey=A,fe!==null)for(const[Ne,Ae]of fe)this.set(Ne,Ae)}get(fe){return super.get(w({map:this.map,initKey:this.initKey},fe))}has(fe){return super.has(w({map:this.map,initKey:this.initKey},fe))}set(fe,Ne){return super.set(k({map:this.map,initKey:this.initKey},fe),Ne)}delete(fe){return super.delete(O({map:this.map,initKey:this.initKey},fe))}}var R=b(74271);const x=Symbol("defaultUnknown");function E(xe,fe,Ne){for(let Ae=0;Ae<fe.length;Ae+=1)xe.has(fe[Ae])||xe.set(Ne(fe[Ae]),Ae)}function N(xe){const{value:fe,from:Ne,to:Ae,mapper:be,notFoundReturn:Ye}=xe;let Ee=be.get(fe);if(Ee===void 0){if(Ye!==x)return Ye;Ee=Ne.push(fe)-1,be.set(fe,Ee)}return Ae[Ee%Ae.length]}function L(xe){return xe instanceof Date?fe=>`${fe}`:typeof xe=="object"?fe=>JSON.stringify(fe):fe=>fe}class P extends R.X{getDefaultOptions(){return{domain:[],range:[],unknown:x}}constructor(fe){super(fe)}map(fe){return this.domainIndexMap.size===0&&E(this.domainIndexMap,this.getDomain(),this.domainKey),N({value:this.domainKey(fe),mapper:this.domainIndexMap,from:this.getDomain(),to:this.getRange(),notFoundReturn:this.options.unknown})}invert(fe){return this.rangeIndexMap.size===0&&E(this.rangeIndexMap,this.getRange(),this.rangeKey),N({value:this.rangeKey(fe),mapper:this.rangeIndexMap,from:this.getRange(),to:this.getDomain(),notFoundReturn:this.options.unknown})}rescale(fe){const[Ne]=this.options.domain,[Ae]=this.options.range;if(this.domainKey=L(Ne),this.rangeKey=L(Ae),!this.rangeIndexMap){this.rangeIndexMap=new Map,this.domainIndexMap=new Map;return}(!fe||fe.range)&&this.rangeIndexMap.clear(),(!fe||fe.domain||fe.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:fe,compare:Ne}=this.options;return this.sortedDomain=Ne?[...fe].sort(Ne):fe,this.sortedDomain}}function W(xe){const fe=Math.min(...xe);return xe.map(Ne=>Ne/fe)}function K(xe,fe){const Ne=xe.length,Ae=fe-Ne;return Ae>0?[...xe,...new Array(Ae).fill(1)]:Ae<0?xe.slice(0,fe):xe}function re(xe){return Math.round(xe*1e12)/1e12}function ye(xe){const{domain:fe,range:Ne,paddingOuter:Ae,paddingInner:be,flex:Ye,round:Ee,align:We}=xe,je=fe.length,_t=K(Ye,je),[It,kt]=Ne,Ut=kt-It,At=2/je*Ae+1-1/je*be,at=Ut/At,Ot=at*be/je,ue=at-je*Ot,Ue=W(_t),vt=Ue.reduce((Je,Te)=>Je+Te),Jt=ue/vt,Qe=new S(fe.map((Je,Te)=>{const $e=Ue[Te]*Jt;return[Je,Ee?Math.floor($e):$e]})),rt=new S(fe.map((Je,Te)=>{const xt=Ue[Te]*Jt+Ot;return[Je,Ee?Math.floor(xt):xt]})),bt=Array.from(rt.values()).reduce((Je,Te)=>Je+Te),Ze=(Ut-(bt-bt/je*be))*We,q=It+Ze;let Y=Ee?Math.round(q):q;const de=new Array(je);for(let Je=0;Je<je;Je+=1){de[Je]=re(Y);const Te=fe[Je];Y+=rt.get(Te)}return{valueBandWidth:Qe,valueStep:rt,adjustedRange:de}}function ge(xe){var fe;const{domain:Ne}=xe,Ae=Ne.length;if(Ae===0)return{valueBandWidth:void 0,valueStep:void 0,adjustedRange:[]};if(!!(!((fe=xe.flex)===null||fe===void 0)&&fe.length))return ye(xe);const{range:Ye,paddingOuter:Ee,paddingInner:We,round:je,align:_t}=xe;let It,kt,Ut=Ye[0];const at=Ye[1]-Ut,Ot=Ee*2,ue=Ae-We;It=at/Math.max(1,Ot+ue),je&&(It=Math.floor(It)),Ut+=(at-It*(Ae-We))*_t,kt=It*(1-We),je&&(Ut=Math.round(Ut),kt=Math.round(kt));const Ue=new Array(Ae).fill(0).map((vt,Jt)=>Ut+Jt*It);return{valueStep:It,valueBandWidth:kt,adjustedRange:Ue}}class ce extends P{getDefaultOptions(){return{domain:[],range:[0,1],align:.5,round:!1,paddingInner:0,paddingOuter:0,padding:0,unknown:x,flex:[]}}constructor(fe){super(fe)}clone(){return new ce(this.options)}getStep(fe){return this.valueStep===void 0?1:typeof this.valueStep=="number"?this.valueStep:fe===void 0?Array.from(this.valueStep.values())[0]:this.valueStep.get(fe)}getBandWidth(fe){return this.valueBandWidth===void 0?1:typeof this.valueBandWidth=="number"?this.valueBandWidth:fe===void 0?Array.from(this.valueBandWidth.values())[0]:this.valueBandWidth.get(fe)}getRange(){return this.adjustedRange}getPaddingInner(){const{padding:fe,paddingInner:Ne}=this.options;return fe>0?fe:Ne}getPaddingOuter(){const{padding:fe,paddingOuter:Ne}=this.options;return fe>0?fe:Ne}rescale(){super.rescale();const{align:fe,domain:Ne,range:Ae,round:be,flex:Ye}=this.options,{adjustedRange:Ee,valueBandWidth:We,valueStep:je}=ge({align:fe,range:Ae,round:be,flex:Ye,paddingInner:this.getPaddingInner(),paddingOuter:this.getPaddingOuter(),domain:Ne});this.valueStep=je,this.valueBandWidth=We,this.adjustedRange=Ee}}},74271:function(ae,ne,b){"use strict";b.d(ne,{X:function(){return k}});var w=b(83787);class k{constructor(A){this.options=(0,w.Z)({},this.getDefaultOptions()),this.update(A)}getOptions(){return this.options}update(A={}){this.options=(0,w.Z)({},this.options,A),this.rescale(A)}rescale(A){}}},53715:function(ae,ne,b){"use strict";b.d(ne,{b:function(){return Ut}});var w=function(At){return At},k=b(74271);function O(At,at){return at-At?Ot=>(Ot-At)/(at-At):Ot=>.5}function A(At,...at){return at.reduce((Ot,ue)=>Ue=>Ot(ue(Ue)),At)}function S(At,at,Ot,ue,Ue){let vt=Ot||0,Jt=ue||At.length;const Qe=Ue||(rt=>rt);for(;vt<Jt;){const rt=Math.floor((vt+Jt)/2);Qe(At[rt])>at?Jt=rt:vt=rt+1}return vt}var R=b(19818),x=b.n(R);function E(At,at,Ot){let ue=Ot;return ue<0&&(ue+=1),ue>1&&(ue-=1),ue<1/6?At+(at-At)*6*ue:ue<1/2?at:ue<2/3?At+(at-At)*(2/3-ue)*6:At}function N(At){const at=At[0]/360,Ot=At[1]/100,ue=At[2]/100,Ue=At[3];if(Ot===0)return[ue*255,ue*255,ue*255,Ue];const vt=ue<.5?ue*(1+Ot):ue+Ot-ue*Ot,Jt=2*ue-vt,Qe=E(Jt,vt,at+1/3),rt=E(Jt,vt,at),bt=E(Jt,vt,at-1/3);return[Qe*255,rt*255,bt*255,Ue]}function L(At){const at=x().get(At);if(!at)return null;const{model:Ot,value:ue}=at;return Ot==="rgb"?ue:Ot==="hsl"?N(ue):null}const P=(At,at)=>Ot=>At*(1-Ot)+at*Ot,W=(At,at)=>{const Ot=L(At),ue=L(at);return Ot===null||ue===null?Ot?()=>At:()=>at:Ue=>{const vt=new Array(4);for(let ze=0;ze<4;ze+=1){const Ze=Ot[ze],q=ue[ze];vt[ze]=Ze*(1-Ue)+q*Ue}const[Jt,Qe,rt,bt]=vt;return`rgba(${Math.round(Jt)}, ${Math.round(Qe)}, ${Math.round(rt)}, ${bt})`}},K=(At,at)=>typeof At=="number"&&typeof at=="number"?P(At,at):typeof At=="string"&&typeof at=="string"?W(At,at):()=>At,re=(At,at)=>{const Ot=P(At,at);return ue=>Math.round(Ot(ue))};var ye=b(71154);function ge(At){return At===null}function ce(At){return!(0,ye.Z)(At)&&!ge(At)&&!Number.isNaN(At)}const xe=Math.sqrt(50),fe=Math.sqrt(10),Ne=Math.sqrt(2);function Ae(At,at,Ot){const ue=(at-At)/Math.max(0,Ot),Ue=Math.floor(Math.log(ue)/Math.LN10),vt=ue/Kf(10,Ue);return Ue>=0?(vt>=xe?10:vt>=fe?5:vt>=Ne?2:1)*Kf(10,Ue):-Kf(10,-Ue)/(vt>=xe?10:vt>=fe?5:vt>=Ne?2:1)}function be(At,at,Ot){const ue=Math.abs(at-At)/Math.max(0,Ot);let Ue=Kf(10,Math.floor(Math.log(ue)/Math.LN10));const vt=ue/Ue;return vt>=xe?Ue*=10:vt>=fe?Ue*=5:vt>=Ne&&(Ue*=2),at<At?-Ue:Ue}const Ye=(At,at,Ot=5)=>{const ue=[At,at];let Ue=0,vt=ue.length-1,Jt=ue[Ue],Qe=ue[vt],rt;return Qe<Jt&&([Jt,Qe]=[Qe,Jt],[Ue,vt]=[vt,Ue]),rt=Ae(Jt,Qe,Ot),rt>0?(Jt=Math.floor(Jt/rt)*rt,Qe=Math.ceil(Qe/rt)*rt,rt=Ae(Jt,Qe,Ot)):rt<0&&(Jt=Math.ceil(Jt*rt)/rt,Qe=Math.floor(Qe*rt)/rt,rt=Ae(Jt,Qe,Ot)),rt>0?(ue[Ue]=Math.floor(Jt/rt)*rt,ue[vt]=Math.ceil(Qe/rt)*rt):rt<0&&(ue[Ue]=Math.ceil(Jt*rt)/rt,ue[vt]=Math.floor(Qe*rt)/rt),ue};function Ee(At,at){const Ot=at<At?at:At,ue=At>at?At:at;return Ue=>Math.min(Math.max(Ot,Ue),ue)}const We=(At,at,Ot)=>{const[ue,Ue]=At,[vt,Jt]=at;let Qe,rt;return ue<Ue?(Qe=O(ue,Ue),rt=Ot(vt,Jt)):(Qe=O(Ue,ue),rt=Ot(Jt,vt)),A(rt,Qe)},je=(At,at,Ot)=>{const ue=Math.min(At.length,at.length)-1,Ue=new Array(ue),vt=new Array(ue),Jt=At[0]>At[ue],Qe=Jt?[...At].reverse():At,rt=Jt?[...at].reverse():at;for(let bt=0;bt<ue;bt+=1)Ue[bt]=O(Qe[bt],Qe[bt+1]),vt[bt]=Ot(rt[bt],rt[bt+1]);return bt=>{const ze=S(At,bt,1,ue)-1,Ze=Ue[ze],q=vt[ze];return A(q,Ze)(bt)}},_t=(At,at,Ot,ue)=>(Math.min(At.length,at.length)>2?je:We)(At,at,ue?re: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(at){return ce(at)?this.output(at):this.options.unknown}invert(at){return ce(at)?this.input(at):this.options.unknown}nice(){if(!this.options.nice)return;const[at,Ot,ue,...Ue]=this.getTickMethodOptions();this.options.domain=this.chooseNice()(at,Ot,ue,...Ue)}getTicks(){const{tickMethod:at}=this.options,[Ot,ue,Ue,...vt]=this.getTickMethodOptions();return at(Ot,ue,Ue,...vt)}getTickMethodOptions(){const{domain:at,tickCount:Ot}=this.options,ue=at[0],Ue=at[at.length-1];return[ue,Ue,Ot]}chooseNice(){return Ye}rescale(){this.nice();const[at,Ot]=this.chooseTransforms();this.composeOutput(at,this.chooseClamp(at)),this.composeInput(at,Ot,this.chooseClamp(Ot))}chooseClamp(at){const{clamp:Ot,range:ue}=this.options,Ue=this.options.domain.map(at),vt=Math.min(Ue.length,ue.length);return Ot?Ee(Ue[0],Ue[vt-1]):w}composeOutput(at,Ot){const{domain:ue,range:Ue,round:vt,interpolate:Jt}=this.options,Qe=_t(ue.map(at),Ue,Jt,vt);this.output=A(Qe,Ot,at)}composeInput(at,Ot,ue){const{domain:Ue,range:vt}=this.options,Jt=_t(vt,Ue.map(at),P);this.input=A(Ot,ue,Jt)}}const kt=(At,at,Ot)=>{let ue,Ue,vt=At,Jt=at;if(vt===Jt&&Ot>0)return[vt];let Qe=Ae(vt,Jt,Ot);if(Qe===0||!Number.isFinite(Qe))return[];if(Qe>0){vt=Math.ceil(vt/Qe),Jt=Math.floor(Jt/Qe),Ue=new Array(ue=Math.ceil(Jt-vt+1));for(let rt=0;rt<ue;rt+=1)Ue[rt]=(vt+rt)*Qe}else{Qe=-Qe,vt=Math.ceil(vt*Qe),Jt=Math.floor(Jt*Qe),Ue=new Array(ue=Math.ceil(Jt-vt+1));for(let rt=0;rt<ue;rt+=1)Ue[rt]=(vt+rt)/Qe}return Ue};class Ut extends It{getDefaultOptions(){return{domain:[0,1],range:[0,1],unknown:void 0,nice:!1,clamp:!1,round:!1,interpolate:K,tickMethod:kt,tickCount:5}}chooseTransforms(){return[w,w]}clone(){return new Ut(this.options)}}},88204:function(ae,ne,b){"use strict";b.d(ne,{L:function(){return w}});function w(k){var O=document.createElement("div");O.innerHTML=k;var A=O.childNodes[0];return A&&O.contains(A)&&O.removeChild(A),A}},81957:function(ae,ne){"use strict";var b=function(w,k,O){return w<k?k:w>O?O:w};ne.Z=b},83207:function(ae,ne,b){"use strict";var w=b(44978),k=function(O){if(typeof O!="object"||O===null)return O;var A;if((0,w.Z)(O)){A=[];for(var S=0,R=O.length;S<R;S++)typeof O[S]=="object"&&O[S]!=null?A[S]=k(O[S]):A[S]=O[S]}else{A={};for(var x in O)typeof O[x]=="object"&&O[x]!=null?A[x]=k(O[x]):A[x]=O[x]}return A};ne.Z=k},68040:function(ae,ne){"use strict";function b(w,k,O){var A;return function(){var S=this,R=arguments,x=function(){A=null,O||w.apply(S,R)},E=O&&!A;clearTimeout(A),A=setTimeout(x,k),E&&w.apply(S,R)}}ne.Z=b},83787:function(ae,ne,b){"use strict";var w=b(44978),k=b(83845),O=5;function A(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(A(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 R=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};ne.Z=R},50814:function(ae,ne,b){"use strict";b.d(ne,{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,A=function(E,N){return(0,w.Z)(E)?E.indexOf(N)>-1:!1},S=A,R=function(E,N){return N===void 0&&(N=[]),O(E,function(L){return!S(N,L)})},x=R},15255:function(ae,ne,b){"use strict";var w=b(44978),k=b(4637);function O(A,S){if(A){var R;if((0,w.Z)(A))for(var x=0,E=A.length;x<E&&(R=S(A[x],x),R!==!1);x++);else if((0,k.Z)(A)){for(var N in A)if(A.hasOwnProperty(N)&&(R=S(A[N],N),R===!1))break}}}ne.Z=O},53032:function(ae,ne,b){"use strict";var w=b(76714);ne.Z=function(k,O,A){for(var S=0,R=(0,w.Z)(O)?O.split("."):O;k&&S<R.length;)k=k[R[S++]];return k===void 0||S<R.length?A:k}},73584:function(ae,ne,b){"use strict";var w=b(44978),k=b(45607),O=Object.prototype.hasOwnProperty;function A(S,R){if(!R||!(0,w.Z)(S))return{};for(var x={},E=(0,k.Z)(R)?R:function(W){return W[R]},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}ne.Z=A},82844:function(ae,ne){"use strict";var b=function(w){return w!==null&&typeof w!="function"&&isFinite(w.length)};ne.Z=b},44978:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(k){return Array.isArray(k)}},90134:function(ae,ne,b){"use strict";var w=b(95456),k=function(O){return(0,w.Z)(O,"Boolean")};ne.Z=k},69246:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(k){return k instanceof Date}},95904:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return P}});var w=b(95147),k=b(82844),O={}.toString,A=function(W){return O.call(W).replace(/^\[object /,"").replace(/]$/,"")},S=A,R=Object.prototype,x=function(W){var K=W&&W.constructor,re=typeof K=="function"&&K.prototype||R;return W===re},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 K=S(W);if(K==="Map"||K==="Set")return!W.size;if(E(W))return!Object.keys(W).length;for(var re in W)if(N.call(W,re))return!1;return!0}var P=L},30335:function(ae,ne,b){"use strict";var w=b(6241),k=b(82844),O=b(76714),A=function(S,R){if(S===R)return!0;if(!S||!R||(0,O.Z)(S)||(0,O.Z)(R))return!1;if((0,k.Z)(S)||(0,k.Z)(R)){if(S.length!==R.length)return!1;for(var x=!0,E=0;E<S.length&&(x=A(S[E],R[E]),!!x);E++);return x}if((0,w.Z)(S)||(0,w.Z)(R)){var N=Object.keys(S),L=Object.keys(R);if(N.length!==L.length)return!1;for(var x=!0,E=0;E<N.length&&(x=A(S[N[E]],R[N[E]]),!!x);E++);return x}return!1};ne.Z=A},45607:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(k){return typeof k=="function"}},95147:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(k){return k==null}},80450:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return k}});var w=1e-5;function k(O,A,S){return S===void 0&&(S=w),O===A||Math.abs(O-A)<S}},25897:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(k){return typeof k=="number"}},6241:function(ae,ne){"use strict";var b=function(w){return typeof w=="object"&&w!==null};ne.Z=b},4637:function(ae,ne){"use strict";ne.Z=function(b){var w=typeof b;return b!==null&&w==="object"||w==="function"}},83845:function(ae,ne,b){"use strict";var w=b(6241),k=b(95456),O=function(A){if(!(0,w.Z)(A)||!(0,k.Z)(A,"Object"))return!1;if(Object.getPrototypeOf(A)===null)return!0;for(var S=A;Object.getPrototypeOf(S)!==null;)S=Object.getPrototypeOf(S);return Object.getPrototypeOf(A)===S};ne.Z=O},76714:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(k){return typeof k=="string"}},95456:function(ae,ne){"use strict";var b={}.toString,w=function(k,O){return b.call(k)==="[object "+O+"]"};ne.Z=w},71154:function(ae,ne){"use strict";var b=function(w){return w===void 0};ne.Z=b},73576:function(ae,ne,b){"use strict";var w=b(92123),k=function(O){var A=(0,w.Z)(O);return A.charAt(0).toLowerCase()+A.substring(1)};ne.Z=k},93442:function(ae,ne,b){"use strict";var w=b(44978),k=b(45607);ne.Z=function(O,A){if((0,w.Z)(O)){for(var S,R=-1/0,x=0;x<O.length;x++){var E=O[x],N=(0,k.Z)(A)?A(E):E[A];N>R&&(S=E,R=N)}return S}}},13882:function(ae,ne,b){"use strict";b.d(ne,{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 A=k[0],S=1;S<O;S++)A=Math.max(A,k[S]);return A}},92426:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return O}});function w(A){var S,R,x,E=A||1;function N(P,W){++S>E&&(x=R,L(1),++S),R[P]=W}function L(P){S=0,R=Object.create(null),P||(x=Object.create(null))}return L(),{clear:L,has:function(P){return R[P]!==void 0||x[P]!==void 0},get:function(P){var W=R[P];if(W!==void 0)return W;if((W=x[P])!==void 0)return N(P,W),W},set:function(P,W){R[P]!==void 0?R[P]=W:N(P,W)}}}var k=new Map;function O(A,S,R){R===void 0&&(R=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(A)||k.set(A,w(R));var P=k.get(A);if(P.has(L))return P.get(L);var W=A.apply(this,E);return P.set(L,W),W};return x}},89372:function(ae,ne,b){"use strict";var w=b(44978),k=b(45607);ne.Z=function(O,A){if((0,w.Z)(O)){for(var S,R=1/0,x=0;x<O.length;x++){var E=O[x],N=(0,k.Z)(A)?A(E):E[A];N<R&&(S=E,R=N)}return S}}},71523:function(ae,ne,b){"use strict";var w=b(44978);ne.Z=function(k){if((0,w.Z)(k))return k.reduce(function(O,A){return Math.min(O,A)},k[0])}},8614:function(ae,ne){"use strict";var b=function(w,k){return(w%k+k)%k};ne.Z=b},13279:function(ae,ne){"use strict";ne.Z=function(){}},35278:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return R}});var w=b(15255),k=b(44978),O=b(83845),A=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=A,R=function(x,E){return S(x,function(N,L,P){return E.includes(P)||(N[P]=L),N},{})}},23413:function(ae,ne,b){"use strict";var w=b(15255),k=b(83845),O=Object.prototype.hasOwnProperty;ne.Z=function(A,S){if(A===null||!(0,k.Z)(A))return{};var R={};return(0,w.Z)(S,function(x){O.call(A,x)&&(R[x]=A[x])}),R}},17829:function(ae,ne,b){"use strict";var w=b(4637),k=b(76714),O=b(25897);ne.Z=function(A,S,R){var x=A,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]=R}),A}},68856:function(ae,ne){"use strict";function b(w,k){return!w||!k?w:w.replace(/\\?\{([^{}]+)\}/g,function(O,A){return O.charAt(0)==="\\"?O.slice(1):k[A]===void 0?"":k[A]})}ne.Z=b},99711:function(ae,ne){"use strict";ne.Z=function(b,w,k){var O,A,S,R,x=0;k||(k={});var E=function(){x=k.leading===!1?0:Date.now(),O=null,R=b.apply(A,S),O||(A=S=null)},N=function(){var L=Date.now();!x&&k.leading===!1&&(x=L);var P=w-(L-x);return A=this,S=arguments,P<=0||P>w?(O&&(clearTimeout(O),O=null),x=L,R=b.apply(A,S),O||(A=S=null)):!O&&k.trailing!==!1&&(O=setTimeout(E,P)),R};return N.cancel=function(){clearTimeout(O),x=0,O=A=S=null},N}},92123:function(ae,ne,b){"use strict";var w=b(95147);ne.Z=function(k){return(0,w.Z)(k)?"":k.toString()}},58029:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(k,O){O===void 0&&(O=new Map);var A=[];if(Array.isArray(k))for(var S=0,R=k.length;S<R;S++){var x=k[S];O.has(x)||(A.push(x),O.set(x,!0))}return A}},71701:function(ae,ne){"use strict";var b={};ne.Z=function(w){return w=w||"g",b[w]?b[w]+=1:b[w]=1,w+b[w]}},83914:function(ae,ne,b){"use strict";var w=b(92123),k=function(O){var A=(0,w.Z)(O);return A.charAt(0).toUpperCase()+A.substring(1)};ne.Z=k},75839:function(ae,ne,b){"use strict";b.d(ne,{Y:function(){return W}});var w=b(97582),k=b(64985);function O(K,re,ye){if(K[ye].length>7){K[ye].shift();for(var ge=K[ye],ce=ye;ge.length;)re[ye]="A",K.splice(ce+=1,0,["C"].concat(ge.splice(0,6)));K.splice(ye,1)}}var A=b(4848),S=b(11013);function R(K){return(0,S.y)(K)&&K.every(function(re){var ye=re[0];return"MC".includes(ye)})}var x=b(74873);function E(K,re,ye,ge,ce,xe){var fe=.3333333333333333,Ne=2/3;return[fe*K+Ne*ye,fe*re+Ne*ge,fe*ce+Ne*ye,fe*xe+Ne*ge,ce,xe]}var N=b(17570),L=function(K,re,ye,ge){var ce=.5,xe=(0,N.k)([K,re],[ye,ge],ce);return(0,w.ev)((0,w.ev)([],xe,!0),[ye,ge,ye,ge],!1)};function P(K,re){var ye=K[0],ge=K.slice(1).map(Number),ce=ge[0],xe=ge[1],fe,Ne=re.x1,Ae=re.y1,be=re.x,Ye=re.y;switch("TQ".includes(ye)||(re.qx=null,re.qy=null),ye){case"M":return re.x=ce,re.y=xe,K;case"A":return fe=[Ne,Ae].concat(ge),["C"].concat((0,x.W)(fe[0],fe[1],fe[2],fe[3],fe[4],fe[5],fe[6],fe[7],fe[8],fe[9]));case"Q":return re.qx=ce,re.qy=xe,fe=[Ne,Ae].concat(ge),["C"].concat(E(fe[0],fe[1],fe[2],fe[3],fe[4],fe[5]));case"L":return["C"].concat(L(Ne,Ae,ce,xe));case"Z":return Ne===be&&Ae===Ye?["C",Ne,Ae,be,Ye,be,Ye]:["C"].concat(L(Ne,Ae,be,Ye));default:}return K}function W(K,re){if(re===void 0&&(re=!1),R(K)){var ye=[].concat(K);return re?[ye,[]]:ye}for(var ge=(0,A.A)(K),ce=(0,w.pi)({},k.z),xe=[],fe="",Ne=ge.length,Ae,be,Ye=[],Ee=0;Ee<Ne;Ee+=1){ge[Ee]&&(fe=ge[Ee][0]),xe[Ee]=fe;var We=P(ge[Ee],ce);ge[Ee]=We,O(ge,xe,Ee),Ne=ge.length,fe==="Z"&&Ye.push(Ee),Ae=ge[Ee],be=Ae.length,ce.x1=+Ae[be-2],ce.y1=+Ae[be-1],ce.x2=+Ae[be-4]||ce.x1,ce.y2=+Ae[be-3]||ce.y1}return re?[ge,Ye]:ge}},18323:function(ae,ne,b){"use strict";b.d(ne,{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(ae,ne,b){"use strict";b.d(ne,{z:function(){return w}});var w={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null}},74873:function(ae,ne,b){"use strict";b.d(ne,{W:function(){return k}});function w(O,A,S){var R=O*Math.cos(S)-A*Math.sin(S),x=O*Math.sin(S)+A*Math.cos(S);return{x:R,y:x}}function k(O,A,S,R,x,E,N,L,P,W){var K=O,re=A,ye=S,ge=R,ce=L,xe=P,fe=Math.PI*120/180,Ne=Math.PI/180*(+x||0),Ae=[],be,Ye,Ee,We,je;if(W)Ye=W[0],Ee=W[1],We=W[2],je=W[3];else{be=w(K,re,-Ne),K=be.x,re=be.y,be=w(ce,xe,-Ne),ce=be.x,xe=be.y;var _t=(K-ce)/2,It=(re-xe)/2,kt=_t*_t/(ye*ye)+It*It/(ge*ge);kt>1&&(kt=Math.sqrt(kt),ye*=kt,ge*=kt);var Ut=ye*ye,At=ge*ge,at=(E===N?-1:1)*Math.sqrt(Math.abs((Ut*At-Ut*It*It-At*_t*_t)/(Ut*It*It+At*_t*_t)));We=at*ye*It/ge+(K+ce)/2,je=at*-ge*_t/ye+(re+xe)/2,Ye=Math.asin(((re-je)/ge*Math.pow(10,9)>>0)/Math.pow(10,9)),Ee=Math.asin(((xe-je)/ge*Math.pow(10,9)>>0)/Math.pow(10,9)),Ye=K<We?Math.PI-Ye:Ye,Ee=ce<We?Math.PI-Ee:Ee,Ye<0&&(Ye=Math.PI*2+Ye),Ee<0&&(Ee=Math.PI*2+Ee),N&&Ye>Ee&&(Ye-=Math.PI*2),!N&&Ee>Ye&&(Ee-=Math.PI*2)}var Ot=Ee-Ye;if(Math.abs(Ot)>fe){var ue=Ee,Ue=ce,vt=xe;Ee=Ye+fe*(N&&Ee>Ye?1:-1),ce=We+ye*Math.cos(Ee),xe=je+ge*Math.sin(Ee),Ae=k(ce,xe,ye,ge,x,0,N,Ue,vt,[Ee,ue,We,je])}Ot=Ee-Ye;var Jt=Math.cos(Ye),Qe=Math.sin(Ye),rt=Math.cos(Ee),bt=Math.sin(Ee),ze=Math.tan(Ot/4),Ze=4/3*ye*ze,q=4/3*ge*ze,Y=[K,re],de=[K+Ze*Qe,re-q*Jt],Je=[ce+Ze*bt,xe-q*rt],Te=[ce,xe];if(de[0]=2*Y[0]-de[0],de[1]=2*Y[1]-de[1],W)return de.concat(Je,Te,Ae);Ae=de.concat(Je,Te,Ae);for(var $e=[],xt=0,ke=Ae.length;xt<ke;xt+=1)$e[xt]=xt%2?w(Ae[xt-1],Ae[xt],Ne).y:w(Ae[xt],Ae[xt+1],Ne).x;return $e}},28659:function(ae,ne,b){"use strict";b.d(ne,{U:function(){return w}});function w(k){return k.map(function(O){return Array.isArray(O)?[].concat(O):O})}},4848:function(ae,ne,b){"use strict";b.d(ne,{A:function(){return Ae}});var w=b(97582),k=b(11013),O=b(64985),A=b(41010),S=b(56346),R=b(18323);function x(be){for(var Ye=be.pathValue[be.segmentStart],Ee=Ye.toLowerCase(),We=be.data;We.length>=R.R[Ee]&&(Ee==="m"&&We.length>2?(be.segments.push([Ye].concat(We.splice(0,2))),Ee="l",Ye=Ye==="m"?"l":"L"):be.segments.push([Ye].concat(We.splice(0,R.R[Ee]))),!!R.R[Ee]););}function E(be){var Ye=be.index,Ee=be.pathValue,We=Ee.charCodeAt(Ye);if(We===48){be.param=0,be.index+=1;return}if(We===49){be.param=1,be.index+=1;return}be.err='[path-util]: invalid Arc flag "'.concat(Ee[Ye],'", expecting 0 or 1 at index ').concat(Ye)}function N(be){return be>=48&&be<=57||be===43||be===45||be===46}function L(be){return be>=48&&be<=57}function P(be){var Ye=be.max,Ee=be.pathValue,We=be.index,je=We,_t=!1,It=!1,kt=!1,Ut=!1,At;if(je>=Ye){be.err="[path-util]: Invalid path value at index ".concat(je,', "pathValue" is missing param');return}if(At=Ee.charCodeAt(je),(At===43||At===45)&&(je+=1,At=Ee.charCodeAt(je)),!L(At)&&At!==46){be.err="[path-util]: Invalid path value at index ".concat(je,', "').concat(Ee[je],'" is not a number');return}if(At!==46){if(_t=At===48,je+=1,At=Ee.charCodeAt(je),_t&&je<Ye&&At&&L(At)){be.err="[path-util]: Invalid path value at index ".concat(We,', "').concat(Ee[We],'" illegal number');return}for(;je<Ye&&L(Ee.charCodeAt(je));)je+=1,It=!0;At=Ee.charCodeAt(je)}if(At===46){for(Ut=!0,je+=1;L(Ee.charCodeAt(je));)je+=1,kt=!0;At=Ee.charCodeAt(je)}if(At===101||At===69){if(Ut&&!It&&!kt){be.err="[path-util]: Invalid path value at index ".concat(je,', "').concat(Ee[je],'" invalid float exponent');return}if(je+=1,At=Ee.charCodeAt(je),(At===43||At===45)&&(je+=1),je<Ye&&L(Ee.charCodeAt(je)))for(;je<Ye&&L(Ee.charCodeAt(je));)je+=1;else{be.err="[path-util]: Invalid path value at index ".concat(je,', "').concat(Ee[je],'" invalid integer exponent');return}}be.index=je,be.param=+be.pathValue.slice(We,je)}function W(be){var Ye=[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279];return be===10||be===13||be===8232||be===8233||be===32||be===9||be===11||be===12||be===160||be>=5760&&Ye.includes(be)}function K(be){for(var Ye=be.pathValue,Ee=be.max;be.index<Ee&&W(Ye.charCodeAt(be.index));)be.index+=1}function re(be){switch(be|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 ye(be){return(be|32)===97}function ge(be){var Ye=be.max,Ee=be.pathValue,We=be.index,je=Ee.charCodeAt(We),_t=R.R[Ee[We].toLowerCase()];if(be.segmentStart=We,!re(je)){be.err='[path-util]: Invalid path value "'.concat(Ee[We],'" is not a path command');return}if(be.index+=1,K(be),be.data=[],!_t){x(be);return}for(;;){for(var It=_t;It>0;It-=1){if(ye(je)&&(It===3||It===4)?E(be):P(be),be.err.length)return;be.data.push(be.param),K(be),be.index<Ye&&Ee.charCodeAt(be.index)===44&&(be.index+=1,K(be))}if(be.index>=be.max||!N(Ee.charCodeAt(be.index)))break}x(be)}var ce=function(){function be(Ye){this.pathValue=Ye,this.segments=[],this.max=Ye.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""}return be}();function xe(be){if((0,S.n)(be))return[].concat(be);var Ye=new ce(be);for(K(Ye);Ye.index<Ye.max&&!Ye.err.length;)ge(Ye);return Ye.err?Ye.err:Ye.segments}function fe(be){if((0,A.b)(be))return[].concat(be);var Ye=xe(be),Ee=0,We=0,je=0,_t=0;return Ye.map(function(It){var kt=It.slice(1).map(Number),Ut=It[0],At=Ut.toUpperCase();if(Ut==="M")return Ee=kt[0],We=kt[1],je=Ee,_t=We,["M",Ee,We];var at;if(Ut!==At)switch(At){case"A":at=[At,kt[0],kt[1],kt[2],kt[3],kt[4],kt[5]+Ee,kt[6]+We];break;case"V":at=[At,kt[0]+We];break;case"H":at=[At,kt[0]+Ee];break;default:{var Ot=kt.map(function(Ue,vt){return Ue+(vt%2?We:Ee)});at=[At].concat(Ot)}}else at=[At].concat(kt);var ue=at.length;switch(At){case"Z":Ee=je,We=_t;break;case"H":Ee=at[1];break;case"V":We=at[1];break;default:Ee=at[ue-2],We=at[ue-1],At==="M"&&(je=Ee,_t=We)}return at})}function Ne(be,Ye){var Ee=be[0],We=Ye.x1,je=Ye.y1,_t=Ye.x2,It=Ye.y2,kt=be.slice(1).map(Number),Ut=be;if("TQ".includes(Ee)||(Ye.qx=null,Ye.qy=null),Ee==="H")Ut=["L",be[1],je];else if(Ee==="V")Ut=["L",We,be[1]];else if(Ee==="S"){var At=We*2-_t,at=je*2-It;Ye.x1=At,Ye.y1=at,Ut=["C",At,at].concat(kt)}else if(Ee==="T"){var Ot=We*2-Ye.qx,ue=je*2-Ye.qy;Ye.qx=Ot,Ye.qy=ue,Ut=["Q",Ot,ue].concat(kt)}else if(Ee==="Q"){var Ue=kt[0],vt=kt[1];Ye.qx=Ue,Ye.qy=vt}return Ut}function Ae(be){if((0,k.y)(be))return[].concat(be);for(var Ye=fe(be),Ee=(0,w.pi)({},O.z),We=0;We<Ye.length;We+=1){Ye[We]=Ne(Ye[We],Ee);var je=Ye[We],_t=je.length;Ee.x1=+je[_t-2],Ee.y1=+je[_t-1],Ee.x2=+je[_t-4]||Ee.x1,Ee.y2=+je[_t-3]||Ee.y1}return Ye}},65850:function(ae,ne,b){"use strict";b.d(ne,{G:function(){return w}});function w(k){var O=k.slice(1).map(function(A,S,R){return S?R[S-1].slice(-2).concat(A.slice(1)):k[0].slice(1).concat(A.slice(1))}).map(function(A){return A.map(function(S,R){return A[A.length-R-2*(1-R%2)]})}).reverse();return[["M"].concat(O[0].slice(0,2))].concat(O.map(function(A){return["C"].concat(A.slice(2))}))}},44078:function(ae,ne,b){"use strict";b.d(ne,{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(ae,ne,b){"use strict";b.d(ne,{x:function(){return S}});var w=b(17570),k=b(6489);function O(R,x){x===void 0&&(x=.5);var E=R.slice(0,2),N=R.slice(2,4),L=R.slice(4,6),P=R.slice(6,8),W=(0,w.k)(E,N,x),K=(0,w.k)(N,L,x),re=(0,w.k)(L,P,x),ye=(0,w.k)(W,K,x),ge=(0,w.k)(K,re,x),ce=(0,w.k)(ye,ge,x);return[["C"].concat(W,ye,ce),["C"].concat(ge,re,P)]}function A(R){return R.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(R,x,E){var N=A(R),L=A(x),P=N.length,W=L.length,K=N.filter(function(be){return be.l}).length,re=L.filter(function(be){return be.l}).length,ye=N.filter(function(be){return be.l}).reduce(function(be,Ye){var Ee=Ye.l;return be+Ee},0)/K||0,ge=L.filter(function(be){return be.l}).reduce(function(be,Ye){var Ee=Ye.l;return be+Ee},0)/re||0,ce=E||Math.max(P,W),xe=[ye,ge],fe=[ce-P,ce-W],Ne=0,Ae=[N,L].map(function(be,Ye){return be.l===ce?be.map(function(Ee){return Ee.s}):be.map(function(Ee,We){return Ne=We&&fe[Ye]&&Ee.l>=xe[Ye],fe[Ye]-=Ne?1:0,Ne?Ee.ss:[Ee.s]}).flat()});return Ae[0].length===Ae[1].length?Ae:S(Ae[0],Ae[1],ce)}},92455:function(ae,ne,b){"use strict";b.d(ne,{b:function(){return A}});var w=b(75839);function k(S,R,x,E,N,L,P,W){return 3*((W-R)*(x+N)-(P-S)*(E+L)+E*(S-N)-x*(R-L)+W*(N+S/3)-P*(L+R/3))/20}function O(S){var R=0,x=0,E=0;return(0,w.Y)(S).map(function(N){var L;switch(N[0]){case"M":return R=N[1],x=N[2],0;default:var P=N.slice(1),W=P[0],K=P[1],re=P[2],ye=P[3],ge=P[4],ce=P[5];return E=k(R,x,W,K,re,ye,ge,ce),L=N.slice(-2),R=L[0],x=L[1],E}}).reduce(function(N,L){return N+L},0)}function A(S){return O(S)>=0}},84329:function(ae,ne,b){"use strict";b.d(ne,{r:function(){return O}});var w=b(97582),k=b(32262);function O(A,S,R){return(0,k.s)(A,S,(0,w.pi)((0,w.pi)({},R),{bbox:!1,length:!0})).point}},83555:function(ae,ne,b){"use strict";b.d(ne,{g:function(){return O}});var w=b(44078);function k(A){var S=A.length,R=S-1;return A.map(function(x,E){return A.map(function(N,L){var P=E+L,W;return L===0||A[P]&&A[P][0]==="M"?(W=A[P],["M"].concat(W.slice(-2))):(P>=S&&(P-=R),A[P])})})}function O(A,S){var R=A.length-1,x=[],E=0,N=0,L=k(A);return L.forEach(function(P,W){A.slice(1).forEach(function(K,re){N+=(0,w.y)(A[(W+re)%R].slice(-2),S[re%R].slice(-2))}),x[W]=N,N=0}),E=x.indexOf(Math.min.apply(null,x)),L[E]}},69877:function(ae,ne,b){"use strict";b.d(ne,{D:function(){return O}});var w=b(97582),k=b(32262);function O(A,S){return(0,k.s)(A,void 0,(0,w.pi)((0,w.pi)({},S),{bbox:!1,length:!0})).length}},41010:function(ae,ne,b){"use strict";b.d(ne,{b:function(){return k}});var w=b(56346);function k(O){return(0,w.n)(O)&&O.every(function(A){var S=A[0];return S===S.toUpperCase()})}},11013:function(ae,ne,b){"use strict";b.d(ne,{y:function(){return k}});var w=b(41010);function k(O){return(0,w.b)(O)&&O.every(function(A){var S=A[0];return"ACLMQZ".includes(S)})}},56346:function(ae,ne,b){"use strict";b.d(ne,{n:function(){return k}});var w=b(18323);function k(O){return Array.isArray(O)&&O.every(function(A){var S=A[0].toLowerCase();return w.R[S]===A.length-1&&"achlmqstvz".includes(S)})}},17570:function(ae,ne,b){"use strict";b.d(ne,{k:function(){return w}});function w(k,O,A){var S=k[0],R=k[1],x=O[0],E=O[1];return[S+(x-S)*A,R+(E-R)*A]}},32262:function(ae,ne,b){"use strict";b.d(ne,{s:function(){return P}});var w=b(4848),k=b(17570),O=b(44078);function A(W,K,re,ye,ge){var ce=(0,O.y)([W,K],[re,ye]),xe={x:0,y:0};if(typeof ge=="number")if(ge<=0)xe={x:W,y:K};else if(ge>=ce)xe={x:re,y:ye};else{var fe=(0,k.k)([W,K],[re,ye],ge/ce),Ne=fe[0],Ae=fe[1];xe={x:Ne,y:Ae}}return{length:ce,point:xe,min:{x:Math.min(W,re),y:Math.min(K,ye)},max:{x:Math.max(W,re),y:Math.max(K,ye)}}}function S(W,K){var re=W.x,ye=W.y,ge=K.x,ce=K.y,xe=re*ge+ye*ce,fe=Math.sqrt((Math.pow(re,2)+Math.pow(ye,2))*(Math.pow(ge,2)+Math.pow(ce,2))),Ne=re*ce-ye*ge<0?-1:1,Ae=Ne*Math.acos(xe/fe);return Ae}function R(W,K,re,ye,ge,ce,xe,fe,Ne,Ae){var be=Math.abs,Ye=Math.sin,Ee=Math.cos,We=Math.sqrt,je=Math.PI,_t=be(re),It=be(ye),kt=(ge%360+360)%360,Ut=kt*(je/180);if(W===fe&&K===Ne)return{x:W,y:K};if(_t===0||It===0)return A(W,K,fe,Ne,Ae).point;var At=(W-fe)/2,at=(K-Ne)/2,Ot={x:Ee(Ut)*At+Ye(Ut)*at,y:-Ye(Ut)*At+Ee(Ut)*at},ue=Math.pow(Ot.x,2)/Math.pow(_t,2)+Math.pow(Ot.y,2)/Math.pow(It,2);ue>1&&(_t*=We(ue),It*=We(ue));var Ue=Math.pow(_t,2)*Math.pow(It,2)-Math.pow(_t,2)*Math.pow(Ot.y,2)-Math.pow(It,2)*Math.pow(Ot.x,2),vt=Math.pow(_t,2)*Math.pow(Ot.y,2)+Math.pow(It,2)*Math.pow(Ot.x,2),Jt=Ue/vt;Jt=Jt<0?0:Jt;var Qe=(ce!==xe?1:-1)*We(Jt),rt={x:Qe*(_t*Ot.y/It),y:Qe*(-(It*Ot.x)/_t)},bt={x:Ee(Ut)*rt.x-Ye(Ut)*rt.y+(W+fe)/2,y:Ye(Ut)*rt.x+Ee(Ut)*rt.y+(K+Ne)/2},ze={x:(Ot.x-rt.x)/_t,y:(Ot.y-rt.y)/It},Ze=S({x:1,y:0},ze),q={x:(-Ot.x-rt.x)/_t,y:(-Ot.y-rt.y)/It},Y=S(ze,q);!xe&&Y>0?Y-=2*je:xe&&Y<0&&(Y+=2*je),Y%=2*je;var de=Ze+Y*Ae,Je=_t*Ee(de),Te=It*Ye(de),$e={x:Ee(Ut)*Je-Ye(Ut)*Te+bt.x,y:Ye(Ut)*Je+Ee(Ut)*Te+bt.y};return $e}function x(W,K,re,ye,ge,ce,xe,fe,Ne,Ae,be){var Ye,Ee=be.bbox,We=Ee===void 0?!0:Ee,je=be.length,_t=je===void 0?!0:je,It=be.sampleSize,kt=It===void 0?30:It,Ut=typeof Ae=="number",At=W,at=K,Ot=0,ue=[At,at,Ot],Ue=[At,at],vt=0,Jt={x:0,y:0},Qe=[{x:At,y:at}];Ut&&Ae<=0&&(Jt={x:At,y:at});for(var rt=0;rt<=kt;rt+=1){if(vt=rt/kt,Ye=R(W,K,re,ye,ge,ce,xe,fe,Ne,vt),At=Ye.x,at=Ye.y,We&&Qe.push({x:At,y:at}),_t&&(Ot+=(0,O.y)(Ue,[At,at])),Ue=[At,at],Ut&&Ot>=Ae&&Ae>ue[2]){var bt=(Ot-Ae)/(Ot-ue[2]);Jt={x:Ue[0]*(1-bt)+ue[0]*bt,y:Ue[1]*(1-bt)+ue[1]*bt}}ue=[At,at,Ot]}return Ut&&Ae>=Ot&&(Jt={x:fe,y:Ne}),{length:Ot,point:Jt,min:{x:Math.min.apply(null,Qe.map(function(ze){return ze.x})),y:Math.min.apply(null,Qe.map(function(ze){return ze.y}))},max:{x:Math.max.apply(null,Qe.map(function(ze){return ze.x})),y:Math.max.apply(null,Qe.map(function(ze){return ze.y}))}}}var E=b(6489);function N(W,K,re,ye,ge,ce,xe){var fe=1-xe;return{x:Math.pow(fe,2)*W+2*fe*xe*re+Math.pow(xe,2)*ge,y:Math.pow(fe,2)*K+2*fe*xe*ye+Math.pow(xe,2)*ce}}function L(W,K,re,ye,ge,ce,xe,fe){var Ne,Ae=fe.bbox,be=Ae===void 0?!0:Ae,Ye=fe.length,Ee=Ye===void 0?!0:Ye,We=fe.sampleSize,je=We===void 0?10:We,_t=typeof xe=="number",It=W,kt=K,Ut=0,At=[It,kt,Ut],at=[It,kt],Ot=0,ue={x:0,y:0},Ue=[{x:It,y:kt}];_t&&xe<=0&&(ue={x:It,y:kt});for(var vt=0;vt<=je;vt+=1){if(Ot=vt/je,Ne=N(W,K,re,ye,ge,ce,Ot),It=Ne.x,kt=Ne.y,be&&Ue.push({x:It,y:kt}),Ee&&(Ut+=(0,O.y)(at,[It,kt])),at=[It,kt],_t&&Ut>=xe&&xe>At[2]){var Jt=(Ut-xe)/(Ut-At[2]);ue={x:at[0]*(1-Jt)+At[0]*Jt,y:at[1]*(1-Jt)+At[1]*Jt}}At=[It,kt,Ut]}return _t&&xe>=Ut&&(ue={x:ge,y:ce}),{length:Ut,point:ue,min:{x:Math.min.apply(null,Ue.map(function(Qe){return Qe.x})),y:Math.min.apply(null,Ue.map(function(Qe){return Qe.y}))},max:{x:Math.max.apply(null,Ue.map(function(Qe){return Qe.x})),y:Math.max.apply(null,Ue.map(function(Qe){return Qe.y}))}}}function P(W,K,re){for(var ye,ge,ce,xe,fe,Ne,Ae=(0,w.A)(W),be=typeof K=="number",Ye,Ee=[],We,je=0,_t=0,It=0,kt=0,Ut,At=[],at=[],Ot=0,ue={x:0,y:0},Ue=ue,vt=ue,Jt=ue,Qe=0,rt=0,bt=Ae.length;rt<bt;rt+=1)Ut=Ae[rt],We=Ut[0],Ye=We==="M",Ee=Ye?Ee:[je,_t].concat(Ut.slice(1)),Ye?(It=Ut[1],kt=Ut[2],ue={x:It,y:kt},Ue=ue,Ot=0,be&&K<.001&&(Jt=ue)):We==="L"?(ye=A(Ee[0],Ee[1],Ee[2],Ee[3],(K||0)-Qe),Ot=ye.length,ue=ye.min,Ue=ye.max,vt=ye.point):We==="A"?(ge=x(Ee[0],Ee[1],Ee[2],Ee[3],Ee[4],Ee[5],Ee[6],Ee[7],Ee[8],(K||0)-Qe,re||{}),Ot=ge.length,ue=ge.min,Ue=ge.max,vt=ge.point):We==="C"?(ce=(0,E.S)(Ee[0],Ee[1],Ee[2],Ee[3],Ee[4],Ee[5],Ee[6],Ee[7],(K||0)-Qe,re||{}),Ot=ce.length,ue=ce.min,Ue=ce.max,vt=ce.point):We==="Q"?(xe=L(Ee[0],Ee[1],Ee[2],Ee[3],Ee[4],Ee[5],(K||0)-Qe,re||{}),Ot=xe.length,ue=xe.min,Ue=xe.max,vt=xe.point):We==="Z"&&(Ee=[je,_t,It,kt],fe=A(Ee[0],Ee[1],Ee[2],Ee[3],(K||0)-Qe),Ot=fe.length,ue=fe.min,Ue=fe.max,vt=fe.point),be&&Qe<K&&Qe+Ot>=K&&(Jt=vt),at.push(Ue),At.push(ue),Qe+=Ot,Ne=We!=="Z"?Ut.slice(-2):[It,kt],je=Ne[0],_t=Ne[1];return be&&K>=Qe&&(Jt={x:je,y:_t}),{length:Qe,point:Jt,min:{x:Math.min.apply(null,At.map(function(ze){return ze.x})),y:Math.min.apply(null,At.map(function(ze){return ze.y}))},max:{x:Math.max.apply(null,at.map(function(ze){return ze.x})),y:Math.max.apply(null,at.map(function(ze){return ze.y}))}}}},6489:function(ae,ne,b){"use strict";b.d(ne,{S:function(){return O}});var w=b(44078);function k(A,S,R,x,E,N,L,P,W){var K=1-W;return{x:Math.pow(K,3)*A+3*Math.pow(K,2)*W*R+3*K*Math.pow(W,2)*E+Math.pow(W,3)*L,y:Math.pow(K,3)*S+3*Math.pow(K,2)*W*x+3*K*Math.pow(W,2)*N+Math.pow(W,3)*P}}function O(A,S,R,x,E,N,L,P,W,K){var re,ye=K.bbox,ge=ye===void 0?!0:ye,ce=K.length,xe=ce===void 0?!0:ce,fe=K.sampleSize,Ne=fe===void 0?10:fe,Ae=typeof W=="number",be=A,Ye=S,Ee=0,We=[be,Ye,Ee],je=[be,Ye],_t=0,It={x:0,y:0},kt=[{x:be,y:Ye}];Ae&&W<=0&&(It={x:be,y:Ye});for(var Ut=0;Ut<=Ne;Ut+=1){if(_t=Ut/Ne,re=k(A,S,R,x,E,N,L,P,_t),be=re.x,Ye=re.y,ge&&kt.push({x:be,y:Ye}),xe&&(Ee+=(0,w.y)(je,[be,Ye])),je=[be,Ye],Ae&&Ee>=W&&W>We[2]){var At=(Ee-W)/(Ee-We[2]);It={x:je[0]*(1-At)+We[0]*At,y:je[1]*(1-At)+We[1]*At}}We=[be,Ye,Ee]}return Ae&&W>=Ee&&(It={x:L,y:P}),{length:Ee,point:It,min:{x:Math.min.apply(null,kt.map(function(at){return at.x})),y:Math.min.apply(null,kt.map(function(at){return at.y}))},max:{x:Math.max.apply(null,kt.map(function(at){return at.x})),y:Math.max.apply(null,kt.map(function(at){return at.y}))}}}},48202:function(ae,ne,b){"use strict";var w,k=Object.defineProperty,O=Le=>{throw TypeError(Le)},A=Math.pow,S=(Le,D,U)=>D in Le?k(Le,D,{enumerable:!0,configurable:!0,writable:!0,value:U}):Le[D]=U,R=(Le,D,U)=>S(Le,typeof D!="symbol"?D+"":D,U),x=(Le,D,U)=>D.has(Le)||O("Cannot "+U),E=(Le,D,U)=>(x(Le,D,"read from private field"),U?U.call(Le):D.get(Le)),N=(Le,D,U)=>D.has(Le)?O("Cannot add the same private member more than once"):D instanceof WeakSet?D.add(Le):D.set(Le,U),L=(Le,D,U,_)=>(x(Le,D,"write to private field"),_?_.call(Le,U):D.set(Le,U),U),P=(Le,D,U)=>(x(Le,D,"access private method"),U),W,K,re;w={value:!0};var ye=b(44091),ge=b(75823);const ce=" ".repeat(2),xe=" ".repeat(4);function fe(){return Ne(this)}function Ne(Le,D={}){const{maxRows:U=15,maxColumns:_=10,maxNumSize:F=8,padMinus:X="auto"}=D;return`${Le.constructor.name} {
${ce}[
${xe}${Ae(Le,U,_,F,X)}
${ce}]
${ce}rows: ${Le.rows}
${ce}columns: ${Le.columns}
}`}function Ae(Le,D,U,_,F){const{rows:X,columns:De}=Le,Ve=Math.min(X,D),it=Math.min(De,U),st=[];if(F==="auto"){F=!1;e:for(let Ht=0;Ht<Ve;Ht++)for(let Et=0;Et<it;Et++)if(Le.get(Ht,Et)<0){F=!0;break e}}for(let Ht=0;Ht<Ve;Ht++){let Et=[];for(let on=0;on<it;on++)Et.push(be(Le.get(Ht,on),_,F));st.push(`${Et.join(" ")}`)}return it!==De&&(st[st.length-1]+=` ... ${De-U} more columns`),Ve!==X&&st.push(`... ${X-D} more rows`),st.join(`
${xe}`)}function be(Le,D,U){return(Le>=0&&U?` ${Ye(Le,D-1)}`:Ye(Le,D)).padEnd(D)}function Ye(Le,D){let U=Le.toString();if(U.length<=D)return U;let _=Le.toFixed(D);if(_.length>D&&(_=Le.toFixed(Math.max(0,D-(_.length-D)))),_.length<=D&&!_.startsWith("0.000")&&!_.startsWith("-0.000"))return _;let F=Le.toExponential(D);return F.length>D&&(F=Le.toExponential(Math.max(0,D-(F.length-D)))),F.slice(0)}function Ee(Le,D){Le.prototype.add=function(_){return typeof _=="number"?this.addS(_):this.addM(_)},Le.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},Le.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},Le.add=function(_,F){return new D(_).add(F)},Le.prototype.sub=function(_){return typeof _=="number"?this.subS(_):this.subM(_)},Le.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},Le.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},Le.sub=function(_,F){return new D(_).sub(F)},Le.prototype.subtract=Le.prototype.sub,Le.prototype.subtractS=Le.prototype.subS,Le.prototype.subtractM=Le.prototype.subM,Le.subtract=Le.sub,Le.prototype.mul=function(_){return typeof _=="number"?this.mulS(_):this.mulM(_)},Le.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},Le.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},Le.mul=function(_,F){return new D(_).mul(F)},Le.prototype.multiply=Le.prototype.mul,Le.prototype.multiplyS=Le.prototype.mulS,Le.prototype.multiplyM=Le.prototype.mulM,Le.multiply=Le.mul,Le.prototype.div=function(_){return typeof _=="number"?this.divS(_):this.divM(_)},Le.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},Le.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},Le.div=function(_,F){return new D(_).div(F)},Le.prototype.divide=Le.prototype.div,Le.prototype.divideS=Le.prototype.divS,Le.prototype.divideM=Le.prototype.divM,Le.divide=Le.div,Le.prototype.mod=function(_){return typeof _=="number"?this.modS(_):this.modM(_)},Le.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},Le.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},Le.mod=function(_,F){return new D(_).mod(F)},Le.prototype.modulus=Le.prototype.mod,Le.prototype.modulusS=Le.prototype.modS,Le.prototype.modulusM=Le.prototype.modM,Le.modulus=Le.mod,Le.prototype.and=function(_){return typeof _=="number"?this.andS(_):this.andM(_)},Le.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},Le.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},Le.and=function(_,F){return new D(_).and(F)},Le.prototype.or=function(_){return typeof _=="number"?this.orS(_):this.orM(_)},Le.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},Le.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},Le.or=function(_,F){return new D(_).or(F)},Le.prototype.xor=function(_){return typeof _=="number"?this.xorS(_):this.xorM(_)},Le.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},Le.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},Le.xor=function(_,F){return new D(_).xor(F)},Le.prototype.leftShift=function(_){return typeof _=="number"?this.leftShiftS(_):this.leftShiftM(_)},Le.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},Le.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},Le.leftShift=function(_,F){return new D(_).leftShift(F)},Le.prototype.signPropagatingRightShift=function(_){return typeof _=="number"?this.signPropagatingRightShiftS(_):this.signPropagatingRightShiftM(_)},Le.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},Le.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},Le.signPropagatingRightShift=function(_,F){return new D(_).signPropagatingRightShift(F)},Le.prototype.rightShift=function(_){return typeof _=="number"?this.rightShiftS(_):this.rightShiftM(_)},Le.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},Le.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},Le.rightShift=function(_,F){return new D(_).rightShift(F)},Le.prototype.zeroFillRightShift=Le.prototype.rightShift,Le.prototype.zeroFillRightShiftS=Le.prototype.rightShiftS,Le.prototype.zeroFillRightShiftM=Le.prototype.rightShiftM,Le.zeroFillRightShift=Le.rightShift,Le.prototype.not=function(){for(let _=0;_<this.rows;_++)for(let F=0;F<this.columns;F++)this.set(_,F,~this.get(_,F));return this},Le.not=function(_){return new D(_).not()},Le.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},Le.abs=function(_){return new D(_).abs()},Le.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},Le.acos=function(_){return new D(_).acos()},Le.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},Le.acosh=function(_){return new D(_).acosh()},Le.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},Le.asin=function(_){return new D(_).asin()},Le.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},Le.asinh=function(_){return new D(_).asinh()},Le.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},Le.atan=function(_){return new D(_).atan()},Le.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},Le.atanh=function(_){return new D(_).atanh()},Le.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},Le.cbrt=function(_){return new D(_).cbrt()},Le.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},Le.ceil=function(_){return new D(_).ceil()},Le.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},Le.clz32=function(_){return new D(_).clz32()},Le.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},Le.cos=function(_){return new D(_).cos()},Le.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},Le.cosh=function(_){return new D(_).cosh()},Le.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},Le.exp=function(_){return new D(_).exp()},Le.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},Le.expm1=function(_){return new D(_).expm1()},Le.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},Le.floor=function(_){return new D(_).floor()},Le.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},Le.fround=function(_){return new D(_).fround()},Le.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},Le.log=function(_){return new D(_).log()},Le.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},Le.log1p=function(_){return new D(_).log1p()},Le.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},Le.log10=function(_){return new D(_).log10()},Le.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},Le.log2=function(_){return new D(_).log2()},Le.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},Le.round=function(_){return new D(_).round()},Le.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},Le.sign=function(_){return new D(_).sign()},Le.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},Le.sin=function(_){return new D(_).sin()},Le.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},Le.sinh=function(_){return new D(_).sinh()},Le.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},Le.sqrt=function(_){return new D(_).sqrt()},Le.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},Le.tan=function(_){return new D(_).tan()},Le.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},Le.tanh=function(_){return new D(_).tanh()},Le.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},Le.trunc=function(_){return new D(_).trunc()},Le.pow=function(_,F){return new D(_).pow(F)},Le.prototype.pow=function(_){return typeof _=="number"?this.powS(_):this.powM(_)},Le.prototype.powS=function(_){for(let F=0;F<this.rows;F++)for(let X=0;X<this.columns;X++)this.set(F,X,A(this.get(F,X),_));return this},Le.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,A(this.get(F,X),_.get(F,X)));return this}}function We(Le,D,U){let _=U?Le.rows:Le.rows-1;if(D<0||D>_)throw new RangeError("Row index out of range")}function je(Le,D,U){let _=U?Le.columns:Le.columns-1;if(D<0||D>_)throw new RangeError("Column index out of range")}function _t(Le,D){if(D.to1DArray&&(D=D.to1DArray()),D.length!==Le.columns)throw new RangeError("vector size must be the same as the number of columns");return D}function It(Le,D){if(D.to1DArray&&(D=D.to1DArray()),D.length!==Le.rows)throw new RangeError("vector size must be the same as the number of rows");return D}function kt(Le,D){if(!ye.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]>=Le.rows)throw new RangeError("row indices are out of range")}function Ut(Le,D){if(!ye.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]>=Le.columns)throw new RangeError("column indices are out of range")}function At(Le,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>=Le.rows||U<0||U>=Le.rows||_<0||_>=Le.columns||F<0||F>=Le.columns)throw new RangeError("Submatrix indices are out of range")}function at(Le,D=0){let U=[];for(let _=0;_<Le;_++)U.push(D);return U}function Ot(Le,D){if(typeof D!="number")throw new TypeError(`${Le} must be a number`)}function ue(Le){if(Le.isEmpty())throw new Error("Empty matrix has no elements to index")}function Ue(Le){let D=at(Le.rows);for(let U=0;U<Le.rows;++U)for(let _=0;_<Le.columns;++_)D[U]+=Le.get(U,_);return D}function vt(Le){let D=at(Le.columns);for(let U=0;U<Le.rows;++U)for(let _=0;_<Le.columns;++_)D[_]+=Le.get(U,_);return D}function Jt(Le){let D=0;for(let U=0;U<Le.rows;U++)for(let _=0;_<Le.columns;_++)D+=Le.get(U,_);return D}function Qe(Le){let D=at(Le.rows,1);for(let U=0;U<Le.rows;++U)for(let _=0;_<Le.columns;++_)D[U]*=Le.get(U,_);return D}function rt(Le){let D=at(Le.columns,1);for(let U=0;U<Le.rows;++U)for(let _=0;_<Le.columns;++_)D[_]*=Le.get(U,_);return D}function bt(Le){let D=1;for(let U=0;U<Le.rows;U++)for(let _=0;_<Le.columns;_++)D*=Le.get(U,_);return D}function ze(Le,D,U){const _=Le.rows,F=Le.columns,X=[];for(let De=0;De<_;De++){let Ve=0,it=0,st=0;for(let Ht=0;Ht<F;Ht++)st=Le.get(De,Ht)-U[De],Ve+=st,it+=st*st;D?X.push((it-Ve*Ve/F)/(F-1)):X.push((it-Ve*Ve/F)/F)}return X}function Ze(Le,D,U){const _=Le.rows,F=Le.columns,X=[];for(let De=0;De<F;De++){let Ve=0,it=0,st=0;for(let Ht=0;Ht<_;Ht++)st=Le.get(Ht,De)-U[De],Ve+=st,it+=st*st;D?X.push((it-Ve*Ve/_)/(_-1)):X.push((it-Ve*Ve/_)/_)}return X}function q(Le,D,U){const _=Le.rows,F=Le.columns,X=_*F;let De=0,Ve=0,it=0;for(let st=0;st<_;st++)for(let Ht=0;Ht<F;Ht++)it=Le.get(st,Ht)-U,De+=it,Ve+=it*it;return D?(Ve-De*De/X)/(X-1):(Ve-De*De/X)/X}function Y(Le,D){for(let U=0;U<Le.rows;U++)for(let _=0;_<Le.columns;_++)Le.set(U,_,Le.get(U,_)-D[U])}function de(Le,D){for(let U=0;U<Le.rows;U++)for(let _=0;_<Le.columns;_++)Le.set(U,_,Le.get(U,_)-D[_])}function Je(Le,D){for(let U=0;U<Le.rows;U++)for(let _=0;_<Le.columns;_++)Le.set(U,_,Le.get(U,_)-D)}function Te(Le){const D=[];for(let U=0;U<Le.rows;U++){let _=0;for(let F=0;F<Le.columns;F++)_+=A(Le.get(U,F),2)/(Le.columns-1);D.push(Math.sqrt(_))}return D}function $e(Le,D){for(let U=0;U<Le.rows;U++)for(let _=0;_<Le.columns;_++)Le.set(U,_,Le.get(U,_)/D[U])}function xt(Le){const D=[];for(let U=0;U<Le.columns;U++){let _=0;for(let F=0;F<Le.rows;F++)_+=A(Le.get(F,U),2)/(Le.rows-1);D.push(Math.sqrt(_))}return D}function ke(Le,D){for(let U=0;U<Le.rows;U++)for(let _=0;_<Le.columns;_++)Le.set(U,_,Le.get(U,_)/D[_])}function et(Le){const D=Le.size-1;let U=0;for(let _=0;_<Le.columns;_++)for(let F=0;F<Le.rows;F++)U+=A(Le.get(F,_),2)/D;return Math.sqrt(U)}function yt(Le,D){for(let U=0;U<Le.rows;U++)for(let _=0;_<Le.columns;_++)Le.set(U,_,Le.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 ht(D,U);for(let De=0;De<D;De++)for(let Ve=0;Ve<U;Ve++)X.set(De,Ve,_[De*U+Ve]);return X}static rowVector(D){let U=new ht(1,D.length);for(let _=0;_<D.length;_++)U.set(0,_,D[_]);return U}static columnVector(D){let U=new ht(D.length,1);for(let _=0;_<D.length;_++)U.set(_,0,D[_]);return U}static zeros(D,U){return new ht(D,U)}static ones(D,U){return new ht(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 ht(D,U);for(let De=0;De<D;De++)for(let Ve=0;Ve<U;Ve++)X.set(De,Ve,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:De=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 Ve=X-F,it=new ht(D,U);for(let st=0;st<D;st++)for(let Ht=0;Ht<U;Ht++){let Et=F+Math.round(De()*Ve);it.set(st,Ht,Et)}return it}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 De=0;De<F;De++)X.set(De,De,_);return X}static diag(D,U,_){let F=D.length;U===void 0&&(U=F),_===void 0&&(_=U);let X=Math.min(F,U,_),De=this.zeros(U,_);for(let Ve=0;Ve<X;Ve++)De.set(Ve,Ve,D[Ve]);return De}static min(D,U){D=this.checkMatrix(D),U=this.checkMatrix(U);let _=D.rows,F=D.columns,X=new ht(_,F);for(let De=0;De<_;De++)for(let Ve=0;Ve<F;Ve++)X.set(De,Ve,Math.min(D.get(De,Ve),U.get(De,Ve)));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 De=0;De<_;De++)for(let Ve=0;Ve<F;Ve++)X.set(De,Ve,Math.max(D.get(De,Ve),U.get(De,Ve)));return X}static checkMatrix(D){return B.isMatrix(D)?D:new ht(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 De=U+1;De<this.rows;De++)this.get(D,De)!==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 De=_;De<D.columns;De++)D.set(U,De,D.get(U,De)/X);for(let De=U+1;De<D.rows;De++){let Ve=D.get(De,_)/D.get(U,_);D.set(De,_,0);for(let it=_+1;it<D.columns;it++)D.set(De,it,D.get(De,it)-D.get(U,it)*Ve)}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,De=!1;for(;X<_&&De===!1;)D.get(F,X)===1?De=!0:X++;for(let Ve=0;Ve<F;Ve++){let it=D.get(Ve,X);for(let st=X;st<U;st++){let Ht=D.get(Ve,st)-it*D.get(F,st);D.set(Ve,st,Ht)}}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 ht(this.rows*U,this.columns*_);for(let X=0;X<U;X++)for(let De=0;De<_;De++)F.setSubMatrix(this,this.rows*X,this.columns*De);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){We(this,D);let U=[];for(let _=0;_<this.columns;_++)U.push(this.get(D,_));return U}getRowVector(D){return ht.rowVector(this.getRow(D))}setRow(D,U){We(this,D),U=_t(this,U);for(let _=0;_<this.columns;_++)this.set(D,_,U[_]);return this}swapRows(D,U){We(this,D),We(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){je(this,D);let U=[];for(let _=0;_<this.rows;_++)U.push(this.get(_,D));return U}getColumnVector(D){return ht.columnVector(this.getColumn(D))}setColumn(D,U){je(this,D),U=It(this,U);for(let _=0;_<this.rows;_++)this.set(_,D,U[_]);return this}swapColumns(D,U){je(this,D),je(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=_t(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=_t(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=_t(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=_t(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){We(this,D);for(let _=0;_<this.columns;_++)this.set(D,_,this.get(D,_)*U);return this}mulColumn(D,U){je(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(){ue(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(){ue(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(We(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){We(this,D),ue(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(We(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){We(this,D),ue(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(je(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){je(this,D),ue(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(je(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){je(this,D),ue(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=ht.checkMatrix(D);let U=this.rows,_=this.columns,F=D.columns,X=new ht(U,F),De=new Float64Array(_);for(let Ve=0;Ve<F;Ve++){for(let it=0;it<_;it++)De[it]=D.get(it,Ve);for(let it=0;it<U;it++){let st=0;for(let Ht=0;Ht<_;Ht++)st+=this.get(it,Ht)*De[Ht];X.set(it,Ve,st)}}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=ht.eye(this.rows),_=this;for(let F=D;F>1;F/=2)F&1&&(U=U.mmul(_)),_=_.mmul(_);return U}strassen2x2(D){D=ht.checkMatrix(D);let U=new ht(2,2);const _=this.get(0,0),F=D.get(0,0),X=this.get(0,1),De=D.get(0,1),Ve=this.get(1,0),it=D.get(1,0),st=this.get(1,1),Ht=D.get(1,1),Et=(_+st)*(F+Ht),on=(Ve+st)*F,Un=_*(De-Ht),sn=st*(it-F),bn=(_+X)*Ht,ti=(Ve-_)*(F+De),Bt=(X-st)*(it+Ht),$n=Et+sn-bn+Bt,ni=Un+bn,Pi=on+sn,ui=Et-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=ht.checkMatrix(D);let U=new ht(3,3);const _=this.get(0,0),F=this.get(0,1),X=this.get(0,2),De=this.get(1,0),Ve=this.get(1,1),it=this.get(1,2),st=this.get(2,0),Ht=this.get(2,1),Et=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-De-Ve-Ht-Et)*ti,Ir=(_-De)*(-Un+ti),yi=Ve*(-on+Un+bn-ti-Bt-$n+Pi),vi=(-_+De+Ve)*(on-Un+ti),Mr=(De+Ve)*(-on+Un),Zt=_*on,Fn=(-_+st+Ht)*(on-sn+Bt),hi=(-_+st)*(sn-Bt),Xn=(st+Ht)*(-on+sn),hs=(_+F+X-Ve-it-st-Ht)*Bt,Xr=Ht*(-on+sn+bn-ti-Bt-$n+ni),ys=(-X+Ht+Et)*(ti+$n-ni),Ur=(X-Et)*(ti-ni),Os=X*$n,no=(Ht+Et)*(-$n+ni),io=(-X+Ve+it)*(Bt+$n-Pi),So=(X-it)*(Bt-Pi),To=(Ve+it)*(-$n+Pi),Gr=F*bn,Qs=it*ni,Eo=De*sn,ro=st*Un,qr=Et*Pi,la=Zt+Os+Gr,Ao=ui+vi+Mr+Zt+ys+Os+no,il=Zt+Fn+Xn+hs+Os+io+To,rl=Ir+yi+vi+Zt+Os+io+So,ca=Ir+vi+Mr+Zt+Qs,Oa=Os+io+So+To+Eo,sl=Zt+Fn+hi+Xr+ys+Ur+Os,bo=ys+Ur+Os+no+ro,Pc=Zt+Fn+hi+Xn+qr;return U.set(0,0,la),U.set(0,1,Ao),U.set(0,2,il),U.set(1,0,rl),U.set(1,1,ca),U.set(1,2,Oa),U.set(2,0,sl),U.set(2,1,bo),U.set(2,2,Pc),U}mmulStrassen(D){D=ht.checkMatrix(D);let U=this.clone(),_=U.rows,F=U.columns,X=D.rows,De=D.columns;F!==X&&console.warn(`Multiplying ${_} x ${F} and ${X} x ${De} matrix: dimensions do not match.`);function Ve(Et,on,Un){let sn=Et.rows,bn=Et.columns;if(sn===on&&bn===Un)return Et;{let ti=B.zeros(on,Un);return ti=ti.setSubMatrix(Et,0,0),ti}}let it=Math.max(_,X),st=Math.max(F,De);U=Ve(U,it,st),D=Ve(D,it,st);function Ht(Et,on,Un,sn){if(Un<=512||sn<=512)return Et.mmul(on);Un%2===1&&sn%2===1?(Et=Ve(Et,Un+1,sn+1),on=Ve(on,Un+1,sn+1)):Un%2===1?(Et=Ve(Et,Un+1,sn),on=Ve(on,Un+1,sn)):sn%2===1&&(Et=Ve(Et,Un,sn+1),on=Ve(on,Un,sn+1));let bn=parseInt(Et.rows/2,10),ti=parseInt(Et.columns/2,10),Bt=Et.subMatrix(0,bn-1,0,ti-1),$n=on.subMatrix(0,bn-1,0,ti-1),ni=Et.subMatrix(0,bn-1,ti,Et.columns-1),Pi=on.subMatrix(0,bn-1,ti,on.columns-1),ui=Et.subMatrix(bn,Et.rows-1,0,ti-1),Ir=on.subMatrix(bn,on.rows-1,0,ti-1),yi=Et.subMatrix(bn,Et.rows-1,ti,Et.columns-1),vi=on.subMatrix(bn,on.rows-1,ti,on.columns-1),Mr=Ht(B.add(Bt,yi),B.add($n,vi),bn,ti),Zt=Ht(B.add(ui,yi),$n,bn,ti),Fn=Ht(Bt,B.sub(Pi,vi),bn,ti),hi=Ht(yi,B.sub(Ir,$n),bn,ti),Xn=Ht(B.add(Bt,ni),vi,bn,ti),hs=Ht(B.sub(ui,Bt),B.add($n,Pi),bn,ti),Xr=Ht(B.sub(ni,yi),B.add(Ir,vi),bn,ti),ys=B.add(Mr,hi);ys.sub(Xn),ys.add(Xr);let Ur=B.add(Fn,Xn),Os=B.add(Zt,hi),no=B.sub(Mr,Zt);no.add(Fn),no.add(hs);let io=B.zeros(2*ys.rows,2*ys.columns);return io=io.setSubMatrix(ys,0,0),io=io.setSubMatrix(Ur,ys.rows,0),io=io.setSubMatrix(Os,0,ys.columns),io=io.setSubMatrix(no,ys.rows,ys.columns),io.subMatrix(0,Un-1,0,sn-1)}return Ht(U,D,it,st)}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 ht(this.rows,this.columns);for(let X=0;X<this.rows;X++){const De=this.getRow(X);De.length>0&&ge(De,{min:U,max:_,output:De}),F.setRow(X,De)}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 ht(this.rows,this.columns);for(let X=0;X<this.columns;X++){const De=this.getColumn(X);De.length&&ge(De,{min:U,max:_,output:De}),F.setColumn(X,De)}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=ht.checkMatrix(D);let U=this.rows,_=this.columns,F=D.rows,X=D.columns,De=new ht(U*F,_*X);for(let Ve=0;Ve<U;Ve++)for(let it=0;it<_;it++)for(let st=0;st<F;st++)for(let Ht=0;Ht<X;Ht++)De.set(F*Ve+st,X*it+Ht,this.get(Ve,it)*D.get(st,Ht));return De}kroneckerSum(D){if(D=ht.checkMatrix(D),!this.isSquare()||!D.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let U=this.rows,_=D.rows,F=this.kroneckerProduct(ht.eye(_,_)),X=ht.eye(U,U).kroneckerProduct(D);return F.add(X)}transpose(){let D=new ht(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=ie){for(let U=0;U<this.rows;U++)this.setRow(U,this.getRow(U).sort(D));return this}sortColumns(D=ie){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 ht(U-D+1,F-_+1);for(let De=D;De<=U;De++)for(let Ve=_;Ve<=F;Ve++)X.set(De-D,Ve-_,this.get(De,Ve));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 ht(D.length,_-U+1);for(let X=0;X<D.length;X++)for(let De=U;De<=_;De++){if(D[X]<0||D[X]>=this.rows)throw new RangeError(`Row index out of range: ${D[X]}`);F.set(X,De-U,this.get(D[X],De))}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 ht(_-U+1,D.length);for(let X=0;X<D.length;X++)for(let De=U;De<=_;De++){if(D[X]<0||D[X]>=this.columns)throw new RangeError(`Column index out of range: ${D[X]}`);F.set(De-U,X,this.get(De,D[X]))}return F}setSubMatrix(D,U,_){if(D=ht.checkMatrix(D),D.isEmpty())return this;let F=U+D.rows-1,X=_+D.columns-1;At(this,U,F,_,X);for(let De=0;De<D.rows;De++)for(let Ve=0;Ve<D.columns;Ve++)this.set(U+De,_+Ve,D.get(De,Ve));return this}selection(D,U){kt(this,D),Ut(this,U);let _=new ht(D.length,U.length);for(let F=0;F<D.length;F++){let X=D[F];for(let De=0;De<U.length;De++){let Ve=U[De];_.set(F,De,this.get(X,Ve))}}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 ht(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 Ue(this);case"column":return vt(this);case void 0:return Jt(this);default:throw new Error(`invalid option: ${D}`)}}product(D){switch(D){case"row":return Qe(this);case"column":return rt(this);case void 0:return bt(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(!ye.isAnyArray(F))throw new TypeError("mean must be an array");return ze(this,_,F)}case"column":{if(!ye.isAnyArray(F))throw new TypeError("mean must be an array");return Ze(this,_,F)}case void 0:{if(typeof F!="number")throw new TypeError("mean must be a number");return q(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(!ye.isAnyArray(_))throw new TypeError("center must be an array");return Y(this,_),this}case"column":{if(!ye.isAnyArray(_))throw new TypeError("center must be an array");return de(this,_),this}case void 0:{if(typeof _!="number")throw new TypeError("center must be a number");return Je(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)_=Te(this);else if(!ye.isAnyArray(_))throw new TypeError("scale must be an array");return $e(this,_),this}case"column":{if(_===void 0)_=xt(this);else if(!ye.isAnyArray(_))throw new TypeError("scale must be an array");return ke(this,_),this}case void 0:{if(_===void 0)_=et(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")]=fe);function ie(Le,D){return Le-D}function ct(Le){return Le.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 Mt=class tE extends B{constructor(D,U){if(super(),N(this,W),R(this,"data"),tE.isMatrix(D))P(this,W,K).call(this,D.rows,D.columns),tE.copy(D,this);else if(Number.isInteger(D)&&D>=0)P(this,W,K).call(this,D,U);else if(ye.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(!ct(_[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 We(this,D),this.data.splice(D,1),this.rows-=1,this}addRow(D,U){return U===void 0&&(U=D,D=this.rows),We(this,D,!0),U=Float64Array.from(_t(this,U)),this.data.splice(D,0,U),this.rows+=1,this}removeColumn(D){je(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),je(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,K=function(Le,D){if(this.data=[],Number.isInteger(D)&&D>=0)for(let U=0;U<Le;U++)this.data.push(new Float64Array(D));else throw new TypeError("nColumns must be a positive integer");this.rows=Le,this.columns=D};let ht=Mt;Ee(B,ht);const Yt=class nE extends B{constructor(D){if(super(),N(this,re),ht.isMatrix(D)){if(!D.isSymmetric())throw new TypeError("not symmetric data");L(this,re,ht.copy(D,new ht(D.rows,D.rows)))}else if(Number.isInteger(D)&&D>=0)L(this,re,new ht(D,D));else if(L(this,re,new ht(D)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return E(this,re).size}get rows(){return E(this,re).rows}get columns(){return E(this,re).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(D){return ht.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 nE(this.diagonalSize);for(const[U,_,F]of this.upperRightEntries())D.set(U,_,F);return D}toMatrix(){return new ht(this)}get(D,U){return E(this,re).get(D,U)}set(D,U,_){return E(this,re).set(D,U,_),E(this,re).set(U,D,_),this}removeCross(D){return E(this,re).removeRow(D),E(this,re).removeColumn(D),this}addCross(D,U){U===void 0&&(U=D,D=this.diagonalSize);const _=U.slice();return _.splice(D,1),E(this,re).addRow(D,_),E(this,re).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 nE(_);for(let X=0,De=0,Ve=0;Ve<U;Ve++)F.set(X,De,D[Ve]),++X>=_&&(X=++De);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)}};re=new WeakMap;let en=Yt;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,De=0;De<_.length;De++)_[De]=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,De=0,Ve=0;Ve<U;Ve++)F.set(X,De,D[Ve]),++X>=_&&(X=++De+1);return F}}nn.prototype.klassSubType="DistanceMatrix";class Me extends B{constructor(D,U,_){super(),this.matrix=D,this.rows=U,this.columns=_}}class te extends Me{constructor(D,U){je(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 Fe extends Me{constructor(D,U){Ut(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 Xe extends Me{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 Pe extends Me{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 Ie extends Me{constructor(D,U){We(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 Ke extends Me{constructor(D,U){kt(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 lt extends Me{constructor(D,U,_){kt(D,U),Ut(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 qe extends Me{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 pt extends Me{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 Xt 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(Le,D){if(ye.isAnyArray(Le))return Le[0]&&ye.isAnyArray(Le[0])?new Xt(Le):new Ct(Le,D);throw new Error("the argument is not an array")}class pn{constructor(D){D=Xt.checkMatrix(D);let U=D.clone(),_=U.rows,F=U.columns,X=new Float64Array(_),De=1,Ve,it,st,Ht,Et,on,Un,sn,bn;for(Ve=0;Ve<_;Ve++)X[Ve]=Ve;for(sn=new Float64Array(_),it=0;it<F;it++){for(Ve=0;Ve<_;Ve++)sn[Ve]=U.get(Ve,it);for(Ve=0;Ve<_;Ve++){for(bn=Math.min(Ve,it),Et=0,st=0;st<bn;st++)Et+=U.get(Ve,st)*sn[st];sn[Ve]-=Et,U.set(Ve,it,sn[Ve])}for(Ht=it,Ve=it+1;Ve<_;Ve++)Math.abs(sn[Ve])>Math.abs(sn[Ht])&&(Ht=Ve);if(Ht!==it){for(st=0;st<F;st++)on=U.get(Ht,st),U.set(Ht,st,U.get(it,st)),U.set(it,st,on);Un=X[Ht],X[Ht]=X[it],X[it]=Un,De=-De}if(it<_&&U.get(it,it)!==0)for(Ve=it+1;Ve<_;Ve++)U.set(Ve,it,U.get(Ve,it)/U.get(it,it))}this.LU=U,this.pivotVector=X,this.pivotSign=De}isSingular(){let D=this.LU,U=D.columns;for(let _=0;_<U;_++)if(D.get(_,_)===0)return!0;return!1}solve(D){D=ht.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),De=U.columns,Ve,it,st;for(st=0;st<De;st++)for(Ve=st+1;Ve<De;Ve++)for(it=0;it<F;it++)X.set(Ve,it,X.get(Ve,it)-X.get(st,it)*U.get(Ve,st));for(st=De-1;st>=0;st--){for(it=0;it<F;it++)X.set(st,it,X.get(st,it)/U.get(st,st));for(Ve=0;Ve<st;Ve++)for(it=0;it<F;it++)X.set(Ve,it,X.get(Ve,it)-X.get(st,it)*U.get(Ve,st))}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 ht(U,_);for(let X=0;X<U;X++)for(let De=0;De<_;De++)X>De?F.set(X,De,D.get(X,De)):X===De?F.set(X,De,1):F.set(X,De,0);return F}get upperTriangularMatrix(){let D=this.LU,U=D.rows,_=D.columns,F=new ht(U,_);for(let X=0;X<U;X++)for(let De=0;De<_;De++)X<=De?F.set(X,De,D.get(X,De)):F.set(X,De,0);return F}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function Wn(Le,D){let U=0;return Math.abs(Le)>Math.abs(D)?(U=D/Le,Math.abs(Le)*Math.sqrt(1+U*U)):D!==0?(U=Le/D,Math.abs(D)*Math.sqrt(1+U*U)):0}class Rn{constructor(D){D=Xt.checkMatrix(D);let U=D.clone(),_=D.rows,F=D.columns,X=new Float64Array(F),De,Ve,it,st;for(it=0;it<F;it++){let Ht=0;for(De=it;De<_;De++)Ht=Wn(Ht,U.get(De,it));if(Ht!==0){for(U.get(it,it)<0&&(Ht=-Ht),De=it;De<_;De++)U.set(De,it,U.get(De,it)/Ht);for(U.set(it,it,U.get(it,it)+1),Ve=it+1;Ve<F;Ve++){for(st=0,De=it;De<_;De++)st+=U.get(De,it)*U.get(De,Ve);for(st=-st/U.get(it,it),De=it;De<_;De++)U.set(De,Ve,U.get(De,Ve)+st*U.get(De,it))}}X[it]=-Ht}this.QR=U,this.Rdiag=X}solve(D){D=ht.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(),De=U.columns,Ve,it,st,Ht;for(st=0;st<De;st++)for(it=0;it<F;it++){for(Ht=0,Ve=st;Ve<_;Ve++)Ht+=U.get(Ve,st)*X.get(Ve,it);for(Ht=-Ht/U.get(st,st),Ve=st;Ve<_;Ve++)X.set(Ve,it,X.get(Ve,it)+Ht*U.get(Ve,st))}for(st=De-1;st>=0;st--){for(it=0;it<F;it++)X.set(st,it,X.get(st,it)/this.Rdiag[st]);for(Ve=0;Ve<st;Ve++)for(it=0;it<F;it++)X.set(Ve,it,X.get(Ve,it)-X.get(st,it)*U.get(Ve,st))}return X.subMatrix(0,De-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 ht(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 ht(U,_),X,De,Ve,it;for(Ve=_-1;Ve>=0;Ve--){for(X=0;X<U;X++)F.set(X,Ve,0);for(F.set(Ve,Ve,1),De=Ve;De<_;De++)if(D.get(Ve,Ve)!==0){for(it=0,X=Ve;X<U;X++)it+=D.get(X,Ve)*F.get(X,De);for(it=-it/D.get(Ve,Ve),X=Ve;X<U;X++)F.set(X,De,F.get(X,De)+it*D.get(X,Ve))}}return F}}class bi{constructor(D,U={}){if(D=Xt.checkMatrix(D),D.isEmpty())throw new Error("Matrix must be non-empty");let _=D.rows,F=D.columns;const{computeLeftSingularVectors:X=!0,computeRightSingularVectors:De=!0,autoTranspose:Ve=!1}=U;let it=!!X,st=!!De,Ht=!1,Et;if(_<F)if(!Ve)Et=D.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else{Et=D.transpose(),_=Et.rows,F=Et.columns,Ht=!0;let Zt=it;it=st,st=Zt}else Et=D.clone();let on=Math.min(_,F),Un=Math.min(_+1,F),sn=new Float64Array(Un),bn=new ht(_,on),ti=new ht(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,_)),Ir=Math.max(Pi,ui);for(let Zt=0;Zt<Ir;Zt++){if(Zt<Pi){sn[Zt]=0;for(let Fn=Zt;Fn<_;Fn++)sn[Zt]=Wn(sn[Zt],Et.get(Fn,Zt));if(sn[Zt]!==0){Et.get(Zt,Zt)<0&&(sn[Zt]=-sn[Zt]);for(let Fn=Zt;Fn<_;Fn++)Et.set(Fn,Zt,Et.get(Fn,Zt)/sn[Zt]);Et.set(Zt,Zt,Et.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+=Et.get(Xn,Zt)*Et.get(Xn,Fn);hi=-hi/Et.get(Zt,Zt);for(let Xn=Zt;Xn<_;Xn++)Et.set(Xn,Fn,Et.get(Xn,Fn)+hi*Et.get(Xn,Zt))}Bt[Fn]=Et.get(Zt,Fn)}if(it&&Zt<Pi)for(let Fn=Zt;Fn<_;Fn++)bn.set(Fn,Zt,Et.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]*Et.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++)Et.set(Xn,Fn,Et.get(Xn,Fn)+hi*$n[Xn])}}if(st)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]=Et.get(Pi,Pi)),_<yi&&(sn[yi-1]=0),ui+1<yi&&(Bt[ui]=Et.get(ui,yi-1)),Bt[yi-1]=0,it){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(st)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 hs=Wn(sn[Xn],hi),Xr=sn[Xn]/hs,ys=hi/hs;if(sn[Xn]=hs,Xn!==Zt&&(hi=-ys*Bt[Xn-1],Bt[Xn-1]=Xr*Bt[Xn-1]),st)for(let Ur=0;Ur<F;Ur++)hs=Xr*ti.get(Ur,Xn)+ys*ti.get(Ur,yi-1),ti.set(Ur,yi-1,-ys*ti.get(Ur,Xn)+Xr*ti.get(Ur,yi-1)),ti.set(Ur,Xn,hs)}break}case 2:{let hi=Bt[Zt-1];Bt[Zt-1]=0;for(let Xn=Zt;Xn<yi;Xn++){let hs=Wn(sn[Xn],hi),Xr=sn[Xn]/hs,ys=hi/hs;if(sn[Xn]=hs,hi=-ys*Bt[Xn],Bt[Xn]=Xr*Bt[Xn],it)for(let Ur=0;Ur<_;Ur++)hs=Xr*bn.get(Ur,Xn)+ys*bn.get(Ur,Zt-1),bn.set(Ur,Zt-1,-ys*bn.get(Ur,Xn)+Xr*bn.get(Ur,Zt-1)),bn.set(Ur,Xn,hs)}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,hs=sn[yi-2]/hi,Xr=Bt[yi-2]/hi,ys=sn[Zt]/hi,Ur=Bt[Zt]/hi,Os=((hs+Xn)*(hs-Xn)+Xr*Xr)/2,no=Xn*Xr*(Xn*Xr);let io=0;(Os!==0||no!==0)&&(Os<0?io=0-Math.sqrt(Os*Os+no):io=Math.sqrt(Os*Os+no),io=no/(Os+io));let So=(ys+Xn)*(ys-Xn)+io,To=ys*Ur;for(let Gr=Zt;Gr<yi-1;Gr++){let Qs=Wn(So,To);Qs===0&&(Qs=Number.MIN_VALUE);let Eo=So/Qs,ro=To/Qs;if(Gr!==Zt&&(Bt[Gr-1]=Qs),So=Eo*sn[Gr]+ro*Bt[Gr],Bt[Gr]=Eo*Bt[Gr]-ro*sn[Gr],To=ro*sn[Gr+1],sn[Gr+1]=Eo*sn[Gr+1],st)for(let qr=0;qr<F;qr++)Qs=Eo*ti.get(qr,Gr)+ro*ti.get(qr,Gr+1),ti.set(qr,Gr+1,-ro*ti.get(qr,Gr)+Eo*ti.get(qr,Gr+1)),ti.set(qr,Gr,Qs);if(Qs=Wn(So,To),Qs===0&&(Qs=Number.MIN_VALUE),Eo=So/Qs,ro=To/Qs,sn[Gr]=Qs,So=Eo*Bt[Gr]+ro*sn[Gr+1],sn[Gr+1]=-ro*Bt[Gr]+Eo*sn[Gr+1],To=ro*Bt[Gr+1],Bt[Gr+1]=Eo*Bt[Gr+1],it&&Gr<_-1)for(let qr=0;qr<_;qr++)Qs=Eo*bn.get(qr,Gr)+ro*bn.get(qr,Gr+1),bn.set(qr,Gr+1,-ro*bn.get(qr,Gr)+Eo*bn.get(qr,Gr+1)),bn.set(qr,Gr,Qs)}Bt[yi-2]=So;break}case 4:{if(sn[Zt]<=0&&(sn[Zt]=sn[Zt]<0?-sn[Zt]:0,st))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,st&&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(it&&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(Ht){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=ht.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 De=this.U,Ve=this.rightSingularVectors,it=Ve.mmul(X),st=Ve.rows,Ht=De.rows,Et=ht.zeros(st,Ht);for(let on=0;on<st;on++)for(let Un=0;Un<Ht;Un++){let sn=0;for(let bn=0;bn<F;bn++)sn+=it.get(on,bn)*De.get(Un,bn);Et.set(on,Un,sn)}return Et.mmul(U)}solveForDiagonal(D){return this.solve(ht.diag(D))}inverse(){let D=this.V,U=this.threshold,_=D.rows,F=D.columns,X=new ht(_,this.s.length);for(let Ht=0;Ht<_;Ht++)for(let Et=0;Et<F;Et++)Math.abs(this.s[Et])>U&&X.set(Ht,Et,D.get(Ht,Et)/this.s[Et]);let De=this.U,Ve=De.rows,it=De.columns,st=new ht(_,Ve);for(let Ht=0;Ht<_;Ht++)for(let Et=0;Et<Ve;Et++){let on=0;for(let Un=0;Un<it;Un++)on+=X.get(Ht,Un)*De.get(Et,Un);st.set(Ht,Et,on)}return st}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 ht.diag(this.s)}}function Lr(Le,D=!1){return Le=Xt.checkMatrix(Le),D?new bi(Le).inverse():Qn(Le,ht.eye(Le.rows))}function Qn(Le,D,U=!1){return Le=Xt.checkMatrix(Le),D=Xt.checkMatrix(D),U?new bi(Le).solve(D):Le.isSquare()?new pn(Le).solve(D):new Rn(Le).solve(D)}function Vi(Le){if(Le=ht.checkMatrix(Le),Le.isSquare()){if(Le.columns===0)return 1;let D,U,_,F;if(Le.columns===2)return D=Le.get(0,0),U=Le.get(0,1),_=Le.get(1,0),F=Le.get(1,1),D*F-U*_;if(Le.columns===3){let X,De,Ve;return X=new lt(Le,[1,2],[1,2]),De=new lt(Le,[1,2],[0,2]),Ve=new lt(Le,[1,2],[0,1]),D=Le.get(0,0),U=Le.get(0,1),_=Le.get(0,2),D*Vi(X)-U*Vi(De)+_*Vi(Ve)}else return new pn(Le).determinant}else throw Error("determinant can only be calculated for a square matrix")}function Oi(Le,D){let U=[];for(let _=0;_<Le;_++)_!==D&&U.push(_);return U}function Gi(Le,D,U,_=1e-9,F=1e-9){if(Le>F)return new Array(D.rows+1).fill(0);{let X=D.addRow(U,[0]);for(let De=0;De<X.rows;De++)Math.abs(X.get(De,0))<_&&X.set(De,0,0);return X.to1DArray()}}function ir(Le,D={}){const{thresholdValue:U=1e-9,thresholdError:_=1e-9}=D;Le=ht.checkMatrix(Le);let F=Le.rows,X=new ht(F,F);for(let De=0;De<F;De++){let Ve=ht.columnVector(Le.getRow(De)),it=Le.subMatrixRow(Oi(F,De)).transpose(),Ht=new bi(it).solve(Ve),Et=ht.sub(Ve,it.mmul(Ht)).abs().max();X.setRow(De,Gi(Et,Ht,De,U,_))}return X}function ms(Le,D=Number.EPSILON){if(Le=ht.checkMatrix(Le),Le.isEmpty())return Le.transpose();let U=new bi(Le,{autoTranspose:!0}),_=U.leftSingularVectors,F=U.rightSingularVectors,X=U.diagonal;for(let De=0;De<X.length;De++)Math.abs(X[De])>D?X[De]=1/X[De]:X[De]=0;return F.mmul(ht.diag(X).mmul(_.transpose()))}function Is(Le,D=Le,U={}){Le=new ht(Le);let _=!1;if(typeof D=="object"&&!ht.isMatrix(D)&&!ye.isAnyArray(D)?(U=D,D=Le,_=!0):D=new ht(D),Le.rows!==D.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:F=!0}=U;F&&(Le=Le.center("column"),_||(D=D.center("column")));const X=Le.transpose().mmul(D);for(let De=0;De<X.rows;De++)for(let Ve=0;Ve<X.columns;Ve++)X.set(De,Ve,X.get(De,Ve)*(1/(Le.rows-1)));return X}function as(Le,D=Le,U={}){Le=new ht(Le);let _=!1;if(typeof D=="object"&&!ht.isMatrix(D)&&!ye.isAnyArray(D)?(U=D,D=Le,_=!0):D=new ht(D),Le.rows!==D.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:F=!0,scale:X=!0}=U;F&&(Le.center("column"),_||D.center("column")),X&&(Le.scale("column"),_||D.scale("column"));const De=Le.standardDeviation("column",{unbiased:!0}),Ve=_?De:D.standardDeviation("column",{unbiased:!0}),it=Le.transpose().mmul(D);for(let st=0;st<it.rows;st++)for(let Ht=0;Ht<it.columns;Ht++)it.set(st,Ht,it.get(st,Ht)*(1/(De[st]*Ve[Ht]))*(1/(Le.rows-1)));return it}class gs{constructor(D,U={}){const{assumeSymmetric:_=!1}=U;if(D=Xt.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 ht(F,F),De=new Float64Array(F),Ve=new Float64Array(F),it=D,st,Ht,Et=!1;if(_?Et=!0:Et=D.isSymmetric(),Et){for(st=0;st<F;st++)for(Ht=0;Ht<F;Ht++)X.set(st,Ht,it.get(st,Ht));Vs(F,Ve,De,X),Xl(F,Ve,De,X)}else{let on=new ht(F,F),Un=new Float64Array(F);for(Ht=0;Ht<F;Ht++)for(st=0;st<F;st++)on.set(st,Ht,it.get(st,Ht));ql(F,on,Un,X),Da(F,Ve,De,X,on)}this.n=F,this.e=Ve,this.d=De,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 ht(D,D),X,De;for(X=0;X<D;X++){for(De=0;De<D;De++)F.set(X,De,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 Vs(Le,D,U,_){let F,X,De,Ve,it,st,Ht,Et;for(it=0;it<Le;it++)U[it]=_.get(Le-1,it);for(Ve=Le-1;Ve>0;Ve--){for(Et=0,De=0,st=0;st<Ve;st++)Et=Et+Math.abs(U[st]);if(Et===0)for(D[Ve]=U[Ve-1],it=0;it<Ve;it++)U[it]=_.get(Ve-1,it),_.set(Ve,it,0),_.set(it,Ve,0);else{for(st=0;st<Ve;st++)U[st]/=Et,De+=U[st]*U[st];for(F=U[Ve-1],X=Math.sqrt(De),F>0&&(X=-X),D[Ve]=Et*X,De=De-F*X,U[Ve-1]=F-X,it=0;it<Ve;it++)D[it]=0;for(it=0;it<Ve;it++){for(F=U[it],_.set(it,Ve,F),X=D[it]+_.get(it,it)*F,st=it+1;st<=Ve-1;st++)X+=_.get(st,it)*U[st],D[st]+=_.get(st,it)*F;D[it]=X}for(F=0,it=0;it<Ve;it++)D[it]/=De,F+=D[it]*U[it];for(Ht=F/(De+De),it=0;it<Ve;it++)D[it]-=Ht*U[it];for(it=0;it<Ve;it++){for(F=U[it],X=D[it],st=it;st<=Ve-1;st++)_.set(st,it,_.get(st,it)-(F*D[st]+X*U[st]));U[it]=_.get(Ve-1,it),_.set(Ve,it,0)}}U[Ve]=De}for(Ve=0;Ve<Le-1;Ve++){if(_.set(Le-1,Ve,_.get(Ve,Ve)),_.set(Ve,Ve,1),De=U[Ve+1],De!==0){for(st=0;st<=Ve;st++)U[st]=_.get(st,Ve+1)/De;for(it=0;it<=Ve;it++){for(X=0,st=0;st<=Ve;st++)X+=_.get(st,Ve+1)*_.get(st,it);for(st=0;st<=Ve;st++)_.set(st,it,_.get(st,it)-X*U[st])}}for(st=0;st<=Ve;st++)_.set(st,Ve+1,0)}for(it=0;it<Le;it++)U[it]=_.get(Le-1,it),_.set(Le-1,it,0);_.set(Le-1,Le-1,1),D[0]=0}function Xl(Le,D,U,_){let F,X,De,Ve,it,st,Ht,Et,on,Un,sn,bn,ti,Bt,$n,ni;for(De=1;De<Le;De++)D[De-1]=D[De];D[Le-1]=0;let Pi=0,ui=0,Ir=Number.EPSILON;for(st=0;st<Le;st++){for(ui=Math.max(ui,Math.abs(U[st])+Math.abs(D[st])),Ht=st;Ht<Le&&!(Math.abs(D[Ht])<=Ir*ui);)Ht++;if(Ht>st)do{for(F=U[st],Et=(U[st+1]-F)/(2*D[st]),on=Wn(Et,1),Et<0&&(on=-on),U[st]=D[st]/(Et+on),U[st+1]=D[st]*(Et+on),Un=U[st+1],X=F-U[st],De=st+2;De<Le;De++)U[De]-=X;for(Pi=Pi+X,Et=U[Ht],sn=1,bn=sn,ti=sn,Bt=D[st+1],$n=0,ni=0,De=Ht-1;De>=st;De--)for(ti=bn,bn=sn,ni=$n,F=sn*D[De],X=sn*Et,on=Wn(Et,D[De]),D[De+1]=$n*on,$n=D[De]/on,sn=Et/on,Et=sn*U[De]-$n*F,U[De+1]=X+$n*(sn*F+$n*U[De]),it=0;it<Le;it++)X=_.get(it,De+1),_.set(it,De+1,$n*_.get(it,De)+sn*X),_.set(it,De,sn*_.get(it,De)-$n*X);Et=-$n*ni*ti*Bt*D[st]/Un,D[st]=$n*Et,U[st]=sn*Et}while(Math.abs(D[st])>Ir*ui);U[st]=U[st]+Pi,D[st]=0}for(De=0;De<Le-1;De++){for(it=De,Et=U[De],Ve=De+1;Ve<Le;Ve++)U[Ve]<Et&&(it=Ve,Et=U[Ve]);if(it!==De)for(U[it]=U[De],U[De]=Et,Ve=0;Ve<Le;Ve++)Et=_.get(Ve,De),_.set(Ve,De,_.get(Ve,it)),_.set(Ve,it,Et)}}function ql(Le,D,U,_){let F=0,X=Le-1,De,Ve,it,st,Ht,Et,on;for(Et=F+1;Et<=X-1;Et++){for(on=0,st=Et;st<=X;st++)on=on+Math.abs(D.get(st,Et-1));if(on!==0){for(it=0,st=X;st>=Et;st--)U[st]=D.get(st,Et-1)/on,it+=U[st]*U[st];for(Ve=Math.sqrt(it),U[Et]>0&&(Ve=-Ve),it=it-U[Et]*Ve,U[Et]=U[Et]-Ve,Ht=Et;Ht<Le;Ht++){for(De=0,st=X;st>=Et;st--)De+=U[st]*D.get(st,Ht);for(De=De/it,st=Et;st<=X;st++)D.set(st,Ht,D.get(st,Ht)-De*U[st])}for(st=0;st<=X;st++){for(De=0,Ht=X;Ht>=Et;Ht--)De+=U[Ht]*D.get(st,Ht);for(De=De/it,Ht=Et;Ht<=X;Ht++)D.set(st,Ht,D.get(st,Ht)-De*U[Ht])}U[Et]=on*U[Et],D.set(Et,Et-1,on*Ve)}}for(st=0;st<Le;st++)for(Ht=0;Ht<Le;Ht++)_.set(st,Ht,st===Ht?1:0);for(Et=X-1;Et>=F+1;Et--)if(D.get(Et,Et-1)!==0){for(st=Et+1;st<=X;st++)U[st]=D.get(st,Et-1);for(Ht=Et;Ht<=X;Ht++){for(Ve=0,st=Et;st<=X;st++)Ve+=U[st]*_.get(st,Ht);for(Ve=Ve/U[Et]/D.get(Et,Et-1),st=Et;st<=X;st++)_.set(st,Ht,_.get(st,Ht)+Ve*U[st])}}}function Da(Le,D,U,_,F){let X=Le-1,De=0,Ve=Le-1,it=Number.EPSILON,st=0,Ht=0,Et=0,on=0,Un=0,sn=0,bn=0,ti=0,Bt,$n,ni,Pi,ui,Ir,yi,vi,Mr,Zt,Fn,hi,Xn,hs,Xr;for(Bt=0;Bt<Le;Bt++)for((Bt<De||Bt>Ve)&&(U[Bt]=F.get(Bt,Bt),D[Bt]=0),$n=Math.max(Bt-1,0);$n<Le;$n++)Ht=Ht+Math.abs(F.get(Bt,$n));for(;X>=De;){for(Pi=X;Pi>De&&(sn=Math.abs(F.get(Pi-1,Pi-1))+Math.abs(F.get(Pi,Pi)),sn===0&&(sn=Ht),!(Math.abs(F.get(Pi,Pi-1))<it*sn));)Pi--;if(Pi===X)F.set(X,X,F.get(X,X)+st),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),Et=(F.get(X-1,X-1)-F.get(X,X))/2,on=Et*Et+yi,bn=Math.sqrt(Math.abs(on)),F.set(X,X,F.get(X,X)+st),F.set(X-1,X-1,F.get(X-1,X-1)+st),vi=F.get(X,X),on>=0){for(bn=Et>=0?Et+bn:Et-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),Et=vi/sn,on=bn/sn,Un=Math.sqrt(Et*Et+on*on),Et=Et/Un,on=on/Un,$n=X-1;$n<Le;$n++)bn=F.get(X-1,$n),F.set(X-1,$n,on*bn+Et*F.get(X,$n)),F.set(X,$n,on*F.get(X,$n)-Et*bn);for(Bt=0;Bt<=X;Bt++)bn=F.get(Bt,X-1),F.set(Bt,X-1,on*bn+Et*F.get(Bt,X)),F.set(Bt,X,on*F.get(Bt,X)-Et*bn);for(Bt=De;Bt<=Ve;Bt++)bn=_.get(Bt,X-1),_.set(Bt,X-1,on*bn+Et*_.get(Bt,X)),_.set(Bt,X,on*_.get(Bt,X)-Et*bn)}else U[X-1]=vi+Et,U[X]=vi+Et,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(st+=vi,Bt=De;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=De;Bt<=X;Bt++)F.set(Bt,Bt,F.get(Bt,Bt)-sn);st+=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,Et=(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(Et)+Math.abs(on)+Math.abs(Un),Et=Et/sn,on=on/sn,Un=Un/sn,!(ui===Pi||Math.abs(F.get(ui,ui-1))*(Math.abs(on)+Math.abs(Un))<it*(Math.abs(Et)*(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&&(hs=ni!==X-1,ni!==ui&&(Et=F.get(ni,ni-1),on=F.get(ni+1,ni-1),Un=hs?F.get(ni+2,ni-1):0,vi=Math.abs(Et)+Math.abs(on)+Math.abs(Un),vi!==0&&(Et=Et/vi,on=on/vi,Un=Un/vi)),vi!==0);ni++)if(sn=Math.sqrt(Et*Et+on*on+Un*Un),Et<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)),Et=Et+sn,vi=Et/sn,Mr=on/sn,bn=Un/sn,on=on/Et,Un=Un/Et,$n=ni;$n<Le;$n++)Et=F.get(ni,$n)+on*F.get(ni+1,$n),hs&&(Et=Et+Un*F.get(ni+2,$n),F.set(ni+2,$n,F.get(ni+2,$n)-Et*bn)),F.set(ni,$n,F.get(ni,$n)-Et*vi),F.set(ni+1,$n,F.get(ni+1,$n)-Et*Mr);for(Bt=0;Bt<=Math.min(X,ni+3);Bt++)Et=vi*F.get(Bt,ni)+Mr*F.get(Bt,ni+1),hs&&(Et=Et+bn*F.get(Bt,ni+2),F.set(Bt,ni+2,F.get(Bt,ni+2)-Et*Un)),F.set(Bt,ni,F.get(Bt,ni)-Et),F.set(Bt,ni+1,F.get(Bt,ni+1)-Et*on);for(Bt=De;Bt<=Ve;Bt++)Et=vi*_.get(Bt,ni)+Mr*_.get(Bt,ni+1),hs&&(Et=Et+bn*_.get(Bt,ni+2),_.set(Bt,ni+2,_.get(Bt,ni+2)-Et*Un)),_.set(Bt,ni,_.get(Bt,ni)-Et),_.set(Bt,ni+1,_.get(Bt,ni+1)-Et*on)}}}if(Ht!==0){for(X=Le-1;X>=0;X--)if(Et=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)-Et,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/(it*Ht)):(vi=F.get(Bt,Bt+1),Mr=F.get(Bt+1,Bt),on=(U[Bt]-Et)*(U[Bt]-Et)+D[Bt]*D[Bt],Ir=(vi*sn-bn*Un)/on,F.set(Bt,X,Ir),F.set(Bt+1,X,Math.abs(vi)>Math.abs(bn)?(-Un-yi*Ir)/vi:(-sn-Mr*Ir)/bn)),Ir=Math.abs(F.get(Bt,X)),it*Ir*Ir>1)for($n=Bt;$n<=X;$n++)F.set($n,X,F.get($n,X)/Ir)}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)-Et)/F.get(X,X-1))):(Xr=Dl(0,-F.get(X-1,X),F.get(X-1,X-1)-Et,on),F.set(X-1,X-1,Xr[0]),F.set(X-1,X,Xr[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)-Et,D[Bt]<0)bn=yi,Un=Zt,sn=Fn;else if(Pi=Bt,D[Bt]===0?(Xr=Dl(-Zt,-Fn,yi,on),F.set(Bt,X-1,Xr[0]),F.set(Bt,X,Xr[1])):(vi=F.get(Bt,Bt+1),Mr=F.get(Bt+1,Bt),hi=(U[Bt]-Et)*(U[Bt]-Et)+D[Bt]*D[Bt]-on*on,Xn=(U[Bt]-Et)*2*on,hi===0&&Xn===0&&(hi=it*Ht*(Math.abs(yi)+Math.abs(on)+Math.abs(vi)+Math.abs(Mr)+Math.abs(bn))),Xr=Dl(vi*Un-bn*Zt+on*Fn,vi*sn-bn*Fn-on*Zt,hi,Xn),F.set(Bt,X-1,Xr[0]),F.set(Bt,X,Xr[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)):(Xr=Dl(-Un-Mr*F.get(Bt,X-1),-sn-Mr*F.get(Bt,X),bn,on),F.set(Bt+1,X-1,Xr[0]),F.set(Bt+1,X,Xr[1]))),Ir=Math.max(Math.abs(F.get(Bt,X-1)),Math.abs(F.get(Bt,X))),it*Ir*Ir>1)for($n=Bt;$n<=X;$n++)F.set($n,X-1,F.get($n,X-1)/Ir),F.set($n,X,F.get($n,X)/Ir)}for(Bt=0;Bt<Le;Bt++)if(Bt<De||Bt>Ve)for($n=Bt;$n<Le;$n++)_.set(Bt,$n,F.get(Bt,$n));for($n=Le-1;$n>=De;$n--)for(Bt=De;Bt<=Ve;Bt++){for(bn=0,ni=De;ni<=Math.min($n,Ve);ni++)bn=bn+_.get(Bt,ni)*F.get(ni,$n);_.set(Bt,$n,bn)}}}function Dl(Le,D,U,_){let F,X;return Math.abs(U)>Math.abs(_)?(F=_/U,X=U+F*_,[(Le+F*D)/X,(D-F*Le)/X]):(F=U/_,X=_+F*U,[(F*Le+D)/X,(F*D-Le)/X])}class nu{constructor(D){if(D=Xt.checkMatrix(D),!D.isSymmetric())throw new Error("Matrix is not symmetric");let U=D,_=U.rows,F=new ht(_,_),X=!0,De,Ve,it;for(Ve=0;Ve<_;Ve++){let st=0;for(it=0;it<Ve;it++){let Ht=0;for(De=0;De<it;De++)Ht+=F.get(it,De)*F.get(Ve,De);Ht=(U.get(Ve,it)-Ht)/F.get(it,it),F.set(Ve,it,Ht),st=st+Ht*Ht}for(st=U.get(Ve,Ve)-st,X&&(X=st>0),F.set(Ve,Ve,Math.sqrt(Math.max(st,0))),it=Ve+1;it<_;it++)F.set(Ve,it,0)}this.L=F,this.positiveDefinite=X}isPositiveDefinite(){return this.positiveDefinite}solve(D){D=Xt.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(),De,Ve,it;for(it=0;it<_;it++)for(Ve=0;Ve<F;Ve++){for(De=0;De<it;De++)X.set(it,Ve,X.get(it,Ve)-X.get(De,Ve)*U.get(it,De));X.set(it,Ve,X.get(it,Ve)/U.get(it,it))}for(it=_-1;it>=0;it--)for(Ve=0;Ve<F;Ve++){for(De=it+1;De<_;De++)X.set(it,Ve,X.get(it,Ve)-X.get(De,Ve)*U.get(De,it));X.set(it,Ve,X.get(it,Ve)/U.get(it,it))}return X}get lowerTriangularMatrix(){return this.L}}class Du{constructor(D,U={}){D=Xt.checkMatrix(D);let{Y:_}=U;const{scaleScores:F=!1,maxIterations:X=1e3,terminationCriteria:De=1e-10}=U;let Ve;if(_){if(ye.isAnyArray(_)&&typeof _[0]=="number"?_=ht.columnVector(_):_=Xt.checkMatrix(_),_.rows!==D.rows)throw new Error("Y should have the same number of rows as X");Ve=_.getColumnVector(0)}else Ve=D.getColumnVector(0);let it=1,st,Ht,Et,on;for(let Un=0;Un<X&&it>De;Un++)Et=D.transpose().mmul(Ve).div(Ve.transpose().mmul(Ve).get(0,0)),Et=Et.div(Et.norm()),st=D.mmul(Et).div(Et.transpose().mmul(Et).get(0,0)),Un>0&&(it=st.clone().sub(on).pow(2).sum()),on=st.clone(),_?(Ht=_.transpose().mmul(st).div(st.transpose().mmul(st).get(0,0)),Ht=Ht.div(Ht.norm()),Ve=_.mmul(Ht).div(Ht.transpose().mmul(Ht).get(0,0))):Ve=st;if(_){let Un=D.transpose().mmul(st).div(st.transpose().mmul(st).get(0,0));Un=Un.div(Un.norm());let sn=D.clone().sub(st.clone().mmul(Un.transpose())),bn=Ve.transpose().mmul(st).div(st.transpose().mmul(st).get(0,0)),ti=_.clone().sub(st.clone().mulS(bn.get(0,0)).mmul(Ht.transpose()));this.t=st,this.p=Un.transpose(),this.w=Et.transpose(),this.q=Ht,this.u=Ve,this.s=st.transpose().mmul(st),this.xResidual=sn,this.yResidual=ti,this.betas=bn}else this.w=Et.transpose(),this.s=st.transpose().mmul(st).sqrt(),F?this.t=st.clone().div(this.s.get(0,0)):this.t=st,this.xResidual=D.sub(st.mmul(Et.transpose()))}}ne.XA=B,ne.a_=nu,ne.yQ=nu,ne.Hs=nn,ne.Ec=gs,ne.dx=gs,ne.LU=pn,ne.Rm=pn,ne.y3=ht,ne.qK=Fe,ne.pb=te,ne.j=Xe,ne.sO=Pe,ne.BZ=Ke,ne.EK=Ie,ne.Db=lt,ne.Fx=qe,ne.tU=pt,ne.Ym=Du,ne.rs=Du,ne.QR=Rn,ne.TB=Rn,ne.oH=bi,ne.Sc=bi,ne.BN=en,ne.it=Ct,ne.$r=Xt,ne.QM=as,ne.AV=Is,w=ht,ne.GH=Vi,ne.SO=Lr,ne.uZ=ir,ne.yU=ms,ne.F1=Qn,ne.re=Qt},22150:function(ae,ne,b){"use strict";b.d(ne,{default:function(){return U}});var w=b(74902),k=b(94184),O=b.n(k),A=b(38379),S=b(67294),R=b(33603),x=b(65223);function E(_){const[F,X]=S.useState(_);return S.useEffect(()=>{const De=setTimeout(()=>{X(_)},_.length?0:10);return()=>{clearTimeout(De)}},[_]),F}var N=b(14747),L=b(50438),P=b(33507),W=b(45503),K=b(67968),ye=_=>{const{componentCls:F}=_,X=`${F}-show-help`,De=`${F}-show-help-item`;return{[X]:{transition:`opacity ${_.motionDurationSlow} ${_.motionEaseInOut}`,"&-appear, &-enter":{opacity:0,"&-active":{opacity:1}},"&-leave":{opacity:1,"&-active":{opacity:0}},[De]:{overflow:"hidden",transition:`height ${_.motionDurationSlow} ${_.motionEaseInOut},
opacity ${_.motionDurationSlow} ${_.motionEaseInOut},
transform ${_.motionDurationSlow} ${_.motionEaseInOut} !important`,[`&${De}-appear, &${De}-enter`]:{transform:"translateY(-5px)",opacity:0,"&-active":{transform:"translateY(0)",opacity:1}},[`&${De}-leave-active`]:{transform:"translateY(-5px)"}}}}};const ge=_=>({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}}),ce=(_,F)=>{const{formItemCls:X}=_;return{[X]:{[`${X}-label > label`]:{height:F},[`${X}-control-input`]:{minHeight:F}}}},xe=_=>{const{componentCls:F}=_;return{[_.componentCls]:Object.assign(Object.assign(Object.assign({},(0,N.Wf)(_)),ge(_)),{[`${F}-text`]:{display:"inline-block",paddingInlineEnd:_.paddingSM},"&-small":Object.assign({},ce(_,_.controlHeightSM)),"&-large":Object.assign({},ce(_,_.controlHeightLG))})}},fe=_=>{const{formItemCls:F,iconCls:X,componentCls:De,rootPrefixCls:Ve,labelRequiredMarkColor:it,labelColor:st,labelFontSize:Ht,labelHeight:Et,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.${Ve}-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:Et,color:st,fontSize:Ht,[`> ${X}`]:{fontSize:_.fontSize,verticalAlign:"top"},[`&${F}-required:not(${F}-required-mark-optional)::before`]:{display:"inline-block",marginInlineEnd:_.marginXXS,color:it,fontSize:_.fontSize,fontFamily:"SimSun, sans-serif",lineHeight:1,content:'"*"',[`${De}-hide-required-mark &`]:{display:"none"}},[`${F}-optional`]:{display:"inline-block",marginInlineStart:_.marginXXS,color:_.colorTextDescription,[`${De}-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^="'${Ve}-col-'"]):not([class*="' ${Ve}-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"}}}}},Ae=_=>{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"}}}}},be=_=>({padding:_.verticalLabelPadding,margin:_.verticalLabelMargin,whiteSpace:"initial",textAlign:"start","> label":{margin:0,"&::after":{visibility:"hidden"}}}),Ye=_=>{const{componentCls:F,formItemCls:X,rootPrefixCls:De}=_;return{[`${X} ${X}-label`]:be(_),[F]:{[X]:{flexWrap:"wrap",[`${X}-label, ${X}-control`]:{[`&:not([class*=" ${De}-col-xs"])`]:{flex:"0 0 100%",maxWidth:"100%"}}}}}},Ee=_=>{const{componentCls:F,formItemCls:X,rootPrefixCls:De}=_;return{[`${F}-vertical`]:{[X]:{"&-row":{flexDirection:"column"},"&-label > label":{height:"auto"},[`${F}-item-control`]:{width:"100%"}}},[`${F}-vertical ${X}-label,
.${De}-col-24${X}-label,
.${De}-col-xl-24${X}-label`]:be(_),[`@media (max-width: ${_.screenXSMax}px)`]:[Ye(_),{[F]:{[`.${De}-col-xs-24${X}-label`]:be(_)}}],[`@media (max-width: ${_.screenSMMax}px)`]:{[F]:{[`.${De}-col-sm-24${X}-label`]:be(_)}},[`@media (max-width: ${_.screenMDMax}px)`]:{[F]:{[`.${De}-col-md-24${X}-label`]:be(_)}},[`@media (max-width: ${_.screenLGMax}px)`]:{[F]:{[`.${De}-col-lg-24${X}-label`]:be(_)}}}},We=(_,F)=>(0,W.TS)(_,{formItemCls:`${_.componentCls}-item`,rootPrefixCls:F});var je=(0,K.Z)("Form",(_,F)=>{let{rootPrefixCls:X}=F;const De=We(_,X);return[xe(De),fe(De),ye(De),Ne(De),Ae(De),Ee(De),(0,P.Z)(De),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 _t=[];function It(_,F,X){let De=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;return{key:typeof _=="string"?_:`${F}-${De}`,error:_,errorStatus:X}}var Ut=_=>{let{help:F,helpStatus:X,errors:De=_t,warnings:Ve=_t,className:it,fieldId:st,onVisibleChanged:Ht}=_;const{prefixCls:Et}=S.useContext(x.Rk),on=`${Et}-item-explain`,[,Un]=je(Et),sn=(0,S.useMemo)(()=>(0,R.Z)(Et),[Et]),bn=E(De),ti=E(Ve),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 st&&($n.id=`${st}_help`),S.createElement(A.default,{motionDeadline:sn.motionDeadline,motionName:`${Et}-show-help`,visible:!!Bt.length,onVisibleChanged:Ht},ni=>{const{className:Pi,style:ui}=ni;return S.createElement("div",Object.assign({},$n,{className:O()(on,Pi,it,Un),style:ui,role:"alert"}),S.createElement(A.CSSMotionList,Object.assign({keys:Bt},(0,R.Z)(Et),{motionName:`${Et}-show-help-item`,component:!1}),Ir=>{const{key:yi,error:vi,errorStatus:Mr,className:Zt,style:Fn}=Ir;return S.createElement("div",{key:yi,className:O()(Zt,{[`${on}-${Mr}`]:Mr}),style:Fn},vi)}))})},At=b(46660),at=b(53124),Ot=b(98866),ue=b(97647),Ue=b(98675),vt=b(17423);const Jt=["parentNode"],Qe="form_item";function rt(_){return _===void 0||_===!1?[]:Array.isArray(_)?_:[_]}function bt(_,F){if(!_.length)return;const X=_.join("_");return F?`${F}_${X}`:Jt.includes(X)?`${Qe}_${X}`:X}function ze(_,F,X,De,Ve,it){let st=De;return it!==void 0?st=it:X.validating?st="validating":_.length?st="error":F.length?st="warning":(X.touched||Ve&&X.validated)&&(st="success"),st}function Ze(_){return rt(_).join("_")}function q(_){const[F]=(0,At.useForm)(),X=S.useRef({}),De=S.useMemo(()=>_!=null?_:Object.assign(Object.assign({},F),{__INTERNAL__:{itemRef:Ve=>it=>{const st=Ze(Ve);it?X.current[st]=it:delete X.current[st]}},scrollToField:function(Ve){let it=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const st=rt(Ve),Ht=bt(st,De.__INTERNAL__.name),Et=Ht?document.getElementById(Ht):null;Et&&(0,vt.Z)(Et,Object.assign({scrollMode:"if-needed",block:"nearest"},it))},getFieldInstance:Ve=>{const it=Ze(Ve);return X.current[it]}}),[_,F]);return[De]}var Y=b(37920),de=function(_,F){var X={};for(var De in _)Object.prototype.hasOwnProperty.call(_,De)&&F.indexOf(De)<0&&(X[De]=_[De]);if(_!=null&&typeof Object.getOwnPropertySymbols=="function")for(var Ve=0,De=Object.getOwnPropertySymbols(_);Ve<De.length;Ve++)F.indexOf(De[Ve])<0&&Object.prototype.propertyIsEnumerable.call(_,De[Ve])&&(X[De[Ve]]=_[De[Ve]]);return X};const Je=(_,F)=>{const X=S.useContext(Ot.Z),{getPrefixCls:De,direction:Ve,form:it}=S.useContext(at.E_),{prefixCls:st,className:Ht,rootClassName:Et,size:on,disabled:Un=X,form:sn,colon:bn,labelAlign:ti,labelWrap:Bt,labelCol:$n,wrapperCol:ni,hideRequiredMark:Pi,layout:ui="horizontal",scrollToFirstError:Ir,requiredMark:yi,onFinishFailed:vi,name:Mr,style:Zt,feedbackIcons:Fn}=_,hi=de(_,["prefixCls","className","rootClassName","size","disabled","form","colon","labelAlign","labelWrap","labelCol","wrapperCol","hideRequiredMark","layout","scrollToFirstError","requiredMark","onFinishFailed","name","style","feedbackIcons"]),Xn=(0,Ue.Z)(on),hs=S.useContext(Y.Z),Xr=(0,S.useMemo)(()=>yi!==void 0?yi:it&&it.requiredMark!==void 0?it.requiredMark:!Pi,[Pi,yi,it]),ys=bn!=null?bn:it==null?void 0:it.colon,Ur=De("form",st),[Os,no]=je(Ur),io=O()(Ur,`${Ur}-${ui}`,{[`${Ur}-hide-required-mark`]:Xr===!1,[`${Ur}-rtl`]:Ve==="rtl",[`${Ur}-${Xn}`]:Xn},no,it==null?void 0:it.className,Ht,Et),[So]=q(sn),{__INTERNAL__:To}=So;To.name=Mr;const Gr=(0,S.useMemo)(()=>({name:Mr,labelAlign:ti,labelCol:$n,labelWrap:Bt,wrapperCol:ni,vertical:ui==="vertical",colon:ys,requiredMark:Xr,itemRef:To.itemRef,form:So,feedbackIcons:Fn}),[Mr,ti,$n,ni,ui,ys,Xr,So,Fn]);S.useImperativeHandle(F,()=>So);const Qs=(ro,qr)=>{if(ro){let la={block:"nearest"};typeof ro=="object"&&(la=ro),So.scrollToField(qr,la)}},Eo=ro=>{if(vi==null||vi(ro),ro.errorFields.length){const qr=ro.errorFields[0].name;if(Ir!==void 0){Qs(Ir,qr);return}it&&it.scrollToFirstError!==void 0&&Qs(it.scrollToFirstError,qr)}};return Os(S.createElement(Ot.n,{disabled:Un},S.createElement(ue.q,{size:Xn},S.createElement(x.RV,Object.assign({},{validateMessages:hs}),S.createElement(x.q3.Provider,{value:Gr},S.createElement(At.default,Object.assign({id:Mr},hi,{name:Mr,onFinishFailed:Eo,form:So,style:Object.assign(Object.assign({},it==null?void 0:it.style),Zt),className:io})))))))};var $e=S.forwardRef(Je),xt=b(9475),ke=b(17799),et=b(96159),yt=b(37419);function B(_){if(typeof _=="function")return _;const F=(0,yt.Z)(_);return F.length<=1?F[0]:F}const ie=()=>{const{status:_,errors:F=[],warnings:X=[]}=(0,S.useContext)(x.aM);return{status:_,errors:F,warnings:X}};ie.Context=x.aM;var ct=ie,Mt=b(96523);function ht(_){const[F,X]=S.useState(_),De=(0,S.useRef)(null),Ve=(0,S.useRef)([]),it=(0,S.useRef)(!1);S.useEffect(()=>(it.current=!1,()=>{it.current=!0,Mt.Z.cancel(De.current),De.current=null}),[]);function st(Ht){it.current||(De.current===null&&(Ve.current=[],De.current=(0,Mt.Z)(()=>{De.current=null,X(Et=>{let on=Et;return Ve.current.forEach(Un=>{on=Un(on)}),on})})),Ve.current.push(Ht))}return[F,st]}function Yt(){const{itemRef:_}=S.useContext(x.q3),F=S.useRef({});function X(De,Ve){const it=Ve&&typeof Ve=="object"&&Ve.ref,st=De.join("_");return(F.current.name!==st||F.current.originRef!==it)&&(F.current.name=st,F.current.originRef=it,F.current.ref=(0,ke.sQ)(_(De),it)),F.current.ref}return X}var en=b(48130),nn=b(14075),Me=b(10366),te=b(92820),Fe=b(21584);const Xe=_=>{const{formItemCls:F}=_;return{"@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none)":{[`${F}-control`]:{display:"flex"}}}};var Pe=(0,K.b)(["Form","item-item"],(_,F)=>{let{rootPrefixCls:X}=F;const De=We(_,X);return[Xe(De)]}),Ke=_=>{const{prefixCls:F,status:X,wrapperCol:De,children:Ve,errors:it,warnings:st,_internalItemRender:Ht,extra:Et,help:on,fieldId:Un,marginBottom:sn,onErrorVisibleChanged:bn}=_,ti=`${F}-item`,Bt=S.useContext(x.q3),$n=De||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`},Ve)),Ir=S.useMemo(()=>({prefixCls:F,status:X}),[F,X]),yi=sn!==null||it.length||st.length?S.createElement("div",{style:{display:"flex",flexWrap:"nowrap"}},S.createElement(x.Rk.Provider,{value:Ir},S.createElement(Ut,{fieldId:Un,errors:it,warnings:st,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=Et?S.createElement("div",Object.assign({},vi,{className:`${ti}-extra`}),Et):null,Zt=Ht&&Ht.mark==="pro_table_render"&&Ht.render?Ht.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(Fe.Z,Object.assign({},$n,{className:ni}),Zt),S.createElement(Pe,{prefixCls:F}))},lt=b(17663),qe=b(24457),pt=b(10110),Ct=b(83062),Xt=function(_,F){var X={};for(var De in _)Object.prototype.hasOwnProperty.call(_,De)&&F.indexOf(De)<0&&(X[De]=_[De]);if(_!=null&&typeof Object.getOwnPropertySymbols=="function")for(var Ve=0,De=Object.getOwnPropertySymbols(_);Ve<De.length;Ve++)F.indexOf(De[Ve])<0&&Object.prototype.propertyIsEnumerable.call(_,De[Ve])&&(X[De[Ve]]=_[De[Ve]]);return X};function Qt(_){return _?typeof _=="object"&&!S.isValidElement(_)?_:{title:_}:null}var Wn=_=>{let{prefixCls:F,label:X,htmlFor:De,labelCol:Ve,labelAlign:it,colon:st,required:Ht,requiredMark:Et,tooltip:on}=_;var Un;const[sn]=(0,pt.Z)("Form"),{vertical:bn,labelAlign:ti,labelCol:Bt,labelWrap:$n,colon:ni}=S.useContext(x.q3);if(!X)return null;const Pi=Ve||Bt||{},ui=it||ti,Ir=`${F}-item-label`,yi=O()(Ir,ui==="left"&&`${Ir}-left`,Pi.className,{[`${Ir}-wrap`]:!!$n});let vi=X;const Mr=st===!0||ni!==!1&&st!==!1;Mr&&!bn&&typeof X=="string"&&X.trim()!==""&&(vi=X.replace(/[:|]\s*$/,""));const Fn=Qt(on);if(Fn){const{icon:Xr=S.createElement(lt.Z,null)}=Fn,ys=Xt(Fn,["icon"]),Ur=S.createElement(Ct.Z,Object.assign({},ys),S.cloneElement(Xr,{className:`${F}-item-tooltip`,title:""}));vi=S.createElement(S.Fragment,null,vi,Ur)}const hi=Et==="optional",Xn=typeof Et=="function";Xn?vi=Et(vi,{required:!!Ht}):hi&&!Ht&&(vi=S.createElement(S.Fragment,null,vi,S.createElement("span",{className:`${F}-item-optional`,title:""},(sn==null?void 0:sn.optional)||((Un=qe.Z.Form)===null||Un===void 0?void 0:Un.optional))));const hs=O()({[`${F}-item-required`]:Ht,[`${F}-item-required-mark-optional`]:hi||Xn,[`${F}-item-no-colon`]:!Mr});return S.createElement(Fe.Z,Object.assign({},Pi,{className:yi}),S.createElement("label",{htmlFor:De,className:hs,title:typeof X=="string"?X:""},vi))},Rn=b(87725),bi=b(16646),Lr=b(87995),Qn=b(3407);const Vi={success:Rn.Z,warning:Lr.Z,error:bi.Z,validating:Qn.Z};function Oi(_){let{children:F,errors:X,warnings:De,hasFeedback:Ve,validateStatus:it,prefixCls:st,meta:Ht,noStyle:Et}=_;const on=`${st}-item`,{feedbackIcons:Un}=S.useContext(x.q3),sn=ze(X,De,Ht,null,!!Ve,it),{isFormItemInput:bn,status:ti}=S.useContext(x.aM),Bt=S.useMemo(()=>{var $n;let ni;if(Ve){const Ir=Ve!==!0&&Ve.icons||Un,yi=sn&&(($n=Ir==null?void 0:Ir({status:sn,errors:X,warnings:De}))===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 Et&&(Pi=bn,ui=(sn!=null?sn:ti)||""),{status:ui,errors:X,warnings:De,hasFeedback:!!Ve,feedbackIcon:ni,isFormItemInput:Pi}},[sn,Ve,Et,bn,ti]);return S.createElement(x.aM.Provider,{value:Bt},F)}var Gi=function(_,F){var X={};for(var De in _)Object.prototype.hasOwnProperty.call(_,De)&&F.indexOf(De)<0&&(X[De]=_[De]);if(_!=null&&typeof Object.getOwnPropertySymbols=="function")for(var Ve=0,De=Object.getOwnPropertySymbols(_);Ve<De.length;Ve++)F.indexOf(De[Ve])<0&&Object.prototype.propertyIsEnumerable.call(_,De[Ve])&&(X[De[Ve]]=_[De[Ve]]);return X};function ir(_){const{prefixCls:F,className:X,rootClassName:De,style:Ve,help:it,errors:st,warnings:Ht,validateStatus:Et,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:Ir}=S.useContext(x.q3),yi=S.useRef(null),vi=E(st),Mr=E(Ht),Zt=it!=null,Fn=!!(Zt||st.length||Ht.length),hi=!!yi.current&&(0,en.Z)(yi.current),[Xn,hs]=S.useState(null);(0,nn.Z)(()=>{if(Fn&&yi.current){const no=getComputedStyle(yi.current);hs(parseInt(no.marginBottom,10))}},[Fn,hi]);const Xr=no=>{no||hs(null)},Ur=function(){let no=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;const io=no?vi:on.errors,So=no?Mr:on.warnings;return ze(io,So,on,"",!!Un,Et)}(),Os=O()(ui,X,De,{[`${ui}-with-help`]:Zt||vi.length||Mr.length,[`${ui}-has-feedback`]:Ur&&Un,[`${ui}-has-success`]:Ur==="success",[`${ui}-has-warning`]:Ur==="warning",[`${ui}-has-error`]:Ur==="error",[`${ui}-is-validating`]:Ur==="validating",[`${ui}-hidden`]:sn});return S.createElement("div",{className:Os,style:Ve,ref:yi},S.createElement(te.Z,Object.assign({className:`${ui}-row`},(0,Me.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:Ir,required:Bt!=null?Bt:$n,prefixCls:F})),S.createElement(Ke,Object.assign({},_,on,{errors:vi,warnings:Mr,prefixCls:F,status:Ur,help:it,marginBottom:Xn,onErrorVisibleChanged:Xr}),S.createElement(x.qI.Provider,{value:ni},S.createElement(Oi,{prefixCls:F,meta:on,errors:on.errors,warnings:on.warnings,hasFeedback:Un,validateStatus:Ur},bn)))),!!Xn&&S.createElement("div",{className:`${ui}-margin-offset`,style:{marginBottom:-Xn}}))}const ms="__SPLIT__",Is=null,as=S.memo(_=>{let{children:F}=_;return F},(_,F)=>_.value===F.value&&_.update===F.update&&_.childProps.length===F.childProps.length&&_.childProps.every((X,De)=>X===F.childProps[De]));function gs(_){return _!=null}function Vs(){return{errors:[],warnings:[],touched:!1,validating:!1,name:[],validated:!1}}function Xl(_){const{name:F,noStyle:X,className:De,dependencies:Ve,prefixCls:it,shouldUpdate:st,rules:Ht,children:Et,required:on,label:Un,messageVariables:sn,trigger:bn="onChange",validateTrigger:ti,hidden:Bt,help:$n}=_,{getPrefixCls:ni}=S.useContext(at.E_),{name:Pi}=S.useContext(x.q3),ui=B(Et),Ir=typeof ui=="function",yi=S.useContext(x.qI),{validateTrigger:vi}=S.useContext(At.FieldContext),Mr=ti!==void 0?ti:vi,Zt=gs(F),Fn=ni("form",it),[hi,Xn]=je(Fn),hs=S.useContext(At.ListContext),Xr=S.useRef(),[ys,Ur]=ht({}),[Os,no]=(0,xt.Z)(()=>Vs()),io=qr=>{const la=hs==null?void 0:hs.getKey(qr.name);if(no(qr.destroy?Vs():qr,!0),X&&$n!==!1&&yi){let Ao=qr.name;if(qr.destroy)Ao=Xr.current||Ao;else if(la!==void 0){const[il,rl]=la;Ao=[il].concat((0,w.Z)(rl)),Xr.current=Ao}yi(qr,Ao)}},So=(qr,la)=>{Ur(Ao=>{const il=Object.assign({},Ao),ca=[].concat((0,w.Z)(qr.name.slice(0,-1)),(0,w.Z)(la)).join(ms);return qr.destroy?delete il[ca]:il[ca]=qr,il})},[To,Gr]=S.useMemo(()=>{const qr=(0,w.Z)(Os.errors),la=(0,w.Z)(Os.warnings);return Object.values(ys).forEach(Ao=>{qr.push.apply(qr,(0,w.Z)(Ao.errors||[])),la.push.apply(la,(0,w.Z)(Ao.warnings||[]))}),[qr,la]},[ys,Os.errors,Os.warnings]),Qs=Yt();function Eo(qr,la,Ao){return X&&!Bt?S.createElement(Oi,{prefixCls:Fn,hasFeedback:_.hasFeedback,validateStatus:_.validateStatus,meta:Os,errors:To,warnings:Gr,noStyle:!0},qr):S.createElement(ir,Object.assign({key:"row"},_,{className:O()(De,Xn),prefixCls:Fn,fieldId:la,isRequired:Ao,errors:To,warnings:Gr,meta:Os,onSubItemMetaChange:So}),qr)}if(!Zt&&!Ir&&!Ve)return hi(Eo(ui));let ro={};return typeof Un=="string"?ro.label=Un:F&&(ro.label=String(F)),sn&&(ro=Object.assign(Object.assign({},ro),sn)),hi(S.createElement(At.Field,Object.assign({},_,{messageVariables:ro,trigger:bn,validateTrigger:Mr,onMetaChange:io}),(qr,la,Ao)=>{const il=rt(F).length&&la?la.name:[],rl=bt(il,Pi),ca=on!==void 0?on:!!(Ht&&Ht.some(bo=>{if(bo&&typeof bo=="object"&&bo.required&&!bo.warningOnly)return!0;if(typeof bo=="function"){const Pc=bo(Ao);return Pc&&Pc.required&&!Pc.warningOnly}return!1})),Oa=Object.assign({},qr);let sl=null;if(Array.isArray(ui)&&Zt)sl=ui;else if(!(Ir&&(!(st||Ve)||Zt))){if(!(Ve&&!Ir&&!Zt))if((0,et.l$)(ui)){const bo=Object.assign(Object.assign({},ui.props),Oa);if(bo.id||(bo.id=rl),$n||To.length>0||Gr.length>0||_.extra){const oh=[];($n||To.length>0)&&oh.push(`${rl}_help`),_.extra&&oh.push(`${rl}_extra`),bo["aria-describedby"]=oh.join(" ")}To.length>0&&(bo["aria-invalid"]="true"),ca&&(bo["aria-required"]="true"),(0,ke.Yr)(ui)&&(bo.ref=Qs(il,ui)),new Set([].concat((0,w.Z)(rt(bn)),(0,w.Z)(rt(Mr)))).forEach(oh=>{bo[oh]=function(){for(var y0,Jf,Qf,v0,Pm,$a=arguments.length,jd=new Array($a),Qo=0;Qo<$a;Qo++)jd[Qo]=arguments[Qo];(Qf=Oa[oh])===null||Qf===void 0||(y0=Qf).call.apply(y0,[Oa].concat(jd)),(Pm=(v0=ui.props)[oh])===null||Pm===void 0||(Jf=Pm).call.apply(Jf,[v0].concat(jd))}});const Qv=[bo["aria-required"],bo["aria-invalid"],bo["aria-describedby"]];sl=S.createElement(as,{value:Oa[_.valuePropName||"value"],update:ui,childProps:Qv},(0,et.Tm)(ui,bo))}else Ir&&(st||Ve)&&!Zt?sl=ui(Ao):sl=ui}return Eo(sl,rl,ca)}))}const ql=Xl;ql.useStatus=ct;var Da=ql,Dl=function(_,F){var X={};for(var De in _)Object.prototype.hasOwnProperty.call(_,De)&&F.indexOf(De)<0&&(X[De]=_[De]);if(_!=null&&typeof Object.getOwnPropertySymbols=="function")for(var Ve=0,De=Object.getOwnPropertySymbols(_);Ve<De.length;Ve++)F.indexOf(De[Ve])<0&&Object.prototype.propertyIsEnumerable.call(_,De[Ve])&&(X[De[Ve]]=_[De[Ve]]);return X},Du=_=>{var{prefixCls:F,children:X}=_,De=Dl(_,["prefixCls","children"]);const{getPrefixCls:Ve}=S.useContext(at.E_),it=Ve("form",F),st=S.useMemo(()=>({prefixCls:it,status:"error"}),[it]);return S.createElement(At.List,Object.assign({},De),(Ht,Et,on)=>S.createElement(x.Rk.Provider,{value:st},X(Ht.map(Un=>Object.assign(Object.assign({},Un),{fieldKey:Un.key})),Et,{errors:on.errors,warnings:on.warnings})))};function Le(){const{form:_}=(0,S.useContext)(x.q3);return _}const D=$e;D.Item=Da,D.List=Du,D.ErrorList=Ut,D.useForm=q,D.useFormInstance=Le,D.useWatch=At.useWatch,D.Provider=x.RV,D.create=()=>{};var U=D},78045:function(ae,ne,b){"use strict";b.d(ne,{ZP:function(){return Jt}});var w=b(94184),k=b.n(w),O=b(5663),A=b(1337),S=b(67294),R=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 K=b(95860),re=b(17799),ye=b(98866),ge=b(65223),ce=b(14747),xe=b(67968),fe=b(45503);const Ne=Qe=>{const{componentCls:rt,antCls:bt}=Qe,ze=`${rt}-group`;return{[ze]:Object.assign(Object.assign({},(0,ce.Wf)(Qe)),{display:"inline-block",fontSize:0,[`&${ze}-rtl`]:{direction:"rtl"},[`${bt}-badge ${bt}-badge-count`]:{zIndex:1},[`> ${bt}-badge:not(:first-child) > ${bt}-button-wrapper`]:{borderInlineStart:"none"}})}},Ae=Qe=>{const{componentCls:rt,wrapperMarginInlineEnd:bt,colorPrimary:ze,radioSize:Ze,motionDurationSlow:q,motionDurationMid:Y,motionEaseInOutCirc:de,colorBgContainer:Je,colorBorder:Te,lineWidth:$e,dotSize:xt,colorBgContainerDisabled:ke,colorTextDisabled:et,paddingXS:yt,dotColorDisabled:B,lineType:ie,radioDotDisabledSize:ct,wireframe:Mt,colorWhite:ht}=Qe,Yt=`${rt}-inner`;return{[`${rt}-wrapper`]:Object.assign(Object.assign({},(0,ce.Wf)(Qe)),{display:"inline-flex",alignItems:"baseline",marginInlineStart:0,marginInlineEnd:bt,cursor:"pointer",[`&${rt}-wrapper-rtl`]:{direction:"rtl"},"&-disabled":{cursor:"not-allowed",color:Qe.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:`${$e}px ${ie} ${ze}`,borderRadius:"50%",visibility:"hidden",content:'""'},[rt]:Object.assign(Object.assign({},(0,ce.Wf)(Qe)),{position:"relative",display:"inline-block",outline:"none",cursor:"pointer",alignSelf:"center",borderRadius:"50%"}),[`${rt}-wrapper:hover &,
&:hover ${Yt}`]:{borderColor:ze},[`${rt}-input:focus-visible + ${Yt}`]:Object.assign({},(0,ce.oN)(Qe)),[`${rt}:hover::after, ${rt}-wrapper:hover &::after`]:{visibility:"visible"},[`${rt}-inner`]:{"&::after":{boxSizing:"border-box",position:"absolute",insetBlockStart:"50%",insetInlineStart:"50%",display:"block",width:Ze,height:Ze,marginBlockStart:Ze/-2,marginInlineStart:Ze/-2,backgroundColor:Mt?ze:ht,borderBlockStart:0,borderInlineStart:0,borderRadius:Ze,transform:"scale(0)",opacity:0,transition:`all ${q} ${de}`,content:'""'},boxSizing:"border-box",position:"relative",insetBlockStart:0,insetInlineStart:0,display:"block",width:Ze,height:Ze,backgroundColor:Je,borderColor:Te,borderStyle:"solid",borderWidth:$e,borderRadius:"50%",transition:`all ${Y}`},[`${rt}-input`]:{position:"absolute",inset:0,zIndex:1,cursor:"pointer",opacity:0},[`${rt}-checked`]:{[Yt]:{borderColor:ze,backgroundColor:Mt?Je:ze,"&::after":{transform:`scale(${xt/Ze})`,opacity:1,transition:`all ${q} ${de}`}}},[`${rt}-disabled`]:{cursor:"not-allowed",[Yt]:{backgroundColor:ke,borderColor:Te,cursor:"not-allowed","&::after":{backgroundColor:B}},[`${rt}-input`]:{cursor:"not-allowed"},[`${rt}-disabled + span`]:{color:et,cursor:"not-allowed"},[`&${rt}-checked`]:{[Yt]:{"&::after":{transform:`scale(${ct/Ze})`}}}},[`span${rt} + *`]:{paddingInlineStart:yt,paddingInlineEnd:yt}})}},be=Qe=>{const{buttonColor:rt,controlHeight:bt,componentCls:ze,lineWidth:Ze,lineType:q,colorBorder:Y,motionDurationSlow:de,motionDurationMid:Je,buttonPaddingInline:Te,fontSize:$e,buttonBg:xt,fontSizeLG:ke,controlHeightLG:et,controlHeightSM:yt,paddingXS:B,borderRadius:ie,borderRadiusSM:ct,borderRadiusLG:Mt,buttonCheckedBg:ht,buttonSolidCheckedColor:Yt,colorTextDisabled:en,colorBgContainerDisabled:nn,buttonCheckedBgDisabled:Me,buttonCheckedColorDisabled:te,colorPrimary:Fe,colorPrimaryHover:Xe,colorPrimaryActive:Pe,buttonSolidCheckedBg:Ie,buttonSolidCheckedHoverBg:Ke,buttonSolidCheckedActiveBg:lt}=Qe;return{[`${ze}-button-wrapper`]:{position:"relative",display:"inline-block",height:bt,margin:0,paddingInline:Te,paddingBlock:0,color:rt,fontSize:$e,lineHeight:`${bt-Ze*2}px`,background:xt,border:`${Ze}px ${q} ${Y}`,borderBlockStartWidth:Ze+.02,borderInlineStartWidth:0,borderInlineEndWidth:Ze,cursor:"pointer",transition:[`color ${Je}`,`background ${Je}`,`box-shadow ${Je}`].join(","),a:{color:rt},[`> ${ze}-button`]:{position:"absolute",insetBlockStart:0,insetInlineStart:0,zIndex:-1,width:"100%",height:"100%"},"&:not(:first-child)":{"&::before":{position:"absolute",insetBlockStart:-Ze,insetInlineStart:-Ze,display:"block",boxSizing:"content-box",width:1,height:"100%",paddingBlock:Ze,paddingInline:0,backgroundColor:Y,transition:`background-color ${de}`,content:'""'}},"&:first-child":{borderInlineStart:`${Ze}px ${q} ${Y}`,borderStartStartRadius:ie,borderEndStartRadius:ie},"&:last-child":{borderStartEndRadius:ie,borderEndEndRadius:ie},"&:first-child:last-child":{borderRadius:ie},[`${ze}-group-large &`]:{height:et,fontSize:ke,lineHeight:`${et-Ze*2}px`,"&:first-child":{borderStartStartRadius:Mt,borderEndStartRadius:Mt},"&:last-child":{borderStartEndRadius:Mt,borderEndEndRadius:Mt}},[`${ze}-group-small &`]:{height:yt,paddingInline:B-Ze,paddingBlock:0,lineHeight:`${yt-Ze*2}px`,"&:first-child":{borderStartStartRadius:ct,borderEndStartRadius:ct},"&:last-child":{borderStartEndRadius:ct,borderEndEndRadius:ct}},"&:hover":{position:"relative",color:Fe},"&:has(:focus-visible)":Object.assign({},(0,ce.oN)(Qe)),[`${ze}-inner, input[type='checkbox'], input[type='radio']`]:{width:0,height:0,opacity:0,pointerEvents:"none"},[`&-checked:not(${ze}-button-wrapper-disabled)`]:{zIndex:1,color:Fe,background:ht,borderColor:Fe,"&::before":{backgroundColor:Fe},"&:first-child":{borderColor:Fe},"&:hover":{color:Xe,borderColor:Xe,"&::before":{backgroundColor:Xe}},"&:active":{color:Pe,borderColor:Pe,"&::before":{backgroundColor:Pe}}},[`${ze}-group-solid &-checked:not(${ze}-button-wrapper-disabled)`]:{color:Yt,background:Ie,borderColor:Ie,"&:hover":{color:Yt,background:Ke,borderColor:Ke},"&:active":{color:Yt,background:lt,borderColor:lt}},"&-disabled":{color:en,backgroundColor:nn,borderColor:Y,cursor:"not-allowed","&:first-child, &:hover":{color:en,backgroundColor:nn,borderColor:Y}},[`&-disabled${ze}-button-wrapper-checked`]:{color:te,backgroundColor:Me,borderColor:Y,boxShadow:"none"}}}},Ye=Qe=>Qe-4*2;var Ee=(0,xe.Z)("Radio",Qe=>{const{controlOutline:rt,controlOutlineWidth:bt,radioSize:ze}=Qe,Ze=`0 0 0 ${bt}px ${rt}`,q=Ze,Y=Ye(ze),de=(0,fe.TS)(Qe,{radioDotDisabledSize:Y,radioFocusShadow:Ze,radioButtonFocusShadow:q});return[Ne(de),Ae(de),be(de)]},Qe=>{const{wireframe:rt,padding:bt,marginXS:ze,lineWidth:Ze,fontSizeLG:q,colorText:Y,colorBgContainer:de,colorTextDisabled:Je,controlItemBgActiveDisabled:Te,colorTextLightSolid:$e,colorPrimary:xt,colorPrimaryHover:ke,colorPrimaryActive:et}=Qe,yt=4,B=q,ie=rt?Ye(B):B-(yt+Ze)*2;return{radioSize:B,dotSize:ie,dotColorDisabled:Je,buttonSolidCheckedColor:$e,buttonSolidCheckedBg:xt,buttonSolidCheckedHoverBg:ke,buttonSolidCheckedActiveBg:et,buttonBg:de,buttonCheckedBg:de,buttonColor:Y,buttonCheckedBgDisabled:Te,buttonCheckedColorDisabled:Je,buttonPaddingInline:bt-Ze,wrapperMarginInlineEnd:ze}}),We=b(45353),je=b(92429),_t=function(Qe,rt){var bt={};for(var ze in Qe)Object.prototype.hasOwnProperty.call(Qe,ze)&&rt.indexOf(ze)<0&&(bt[ze]=Qe[ze]);if(Qe!=null&&typeof Object.getOwnPropertySymbols=="function")for(var Ze=0,ze=Object.getOwnPropertySymbols(Qe);Ze<ze.length;Ze++)rt.indexOf(ze[Ze])<0&&Object.prototype.propertyIsEnumerable.call(Qe,ze[Ze])&&(bt[ze[Ze]]=Qe[ze[Ze]]);return bt};const It=(Qe,rt)=>{var bt,ze;const Ze=S.useContext(L),q=S.useContext(P),{getPrefixCls:Y,direction:de,radio:Je}=S.useContext(R.E_),Te=S.useRef(null),$e=(0,re.sQ)(rt,Te),{isFormItemInput:xt}=S.useContext(ge.aM),ke=Pe=>{var Ie,Ke;(Ie=Qe.onChange)===null||Ie===void 0||Ie.call(Qe,Pe),(Ke=Ze==null?void 0:Ze.onChange)===null||Ke===void 0||Ke.call(Ze,Pe)},{prefixCls:et,className:yt,rootClassName:B,children:ie,style:ct}=Qe,Mt=_t(Qe,["prefixCls","className","rootClassName","children","style"]),ht=Y("radio",et),Yt=((Ze==null?void 0:Ze.optionType)||q)==="button",en=Yt?`${ht}-button`:ht,[nn,Me]=Ee(ht),te=Object.assign({},Mt),Fe=S.useContext(ye.Z);Ze&&(te.name=Ze.name,te.onChange=ke,te.checked=Qe.value===Ze.value,te.disabled=(bt=te.disabled)!==null&&bt!==void 0?bt:Ze.disabled),te.disabled=(ze=te.disabled)!==null&&ze!==void 0?ze:Fe;const Xe=k()(`${en}-wrapper`,{[`${en}-wrapper-checked`]:te.checked,[`${en}-wrapper-disabled`]:te.disabled,[`${en}-wrapper-rtl`]:de==="rtl",[`${en}-wrapper-in-form-item`]:xt},Je==null?void 0:Je.className,yt,B,Me);return nn(S.createElement(We.Z,{component:"Radio",disabled:te.disabled},S.createElement("label",{className:Xe,style:Object.assign(Object.assign({},Je==null?void 0:Je.style),ct),onMouseEnter:Qe.onMouseEnter,onMouseLeave:Qe.onMouseLeave},S.createElement(K.Z,Object.assign({},te,{className:k()(te.className,!Yt&&je.A),type:"radio",prefixCls:en,ref:$e})),ie!==void 0?S.createElement("span",null,ie):null)))};var Ut=S.forwardRef(It);const At=S.forwardRef((Qe,rt)=>{const{getPrefixCls:bt,direction:ze}=S.useContext(R.E_),[Ze,q]=(0,O.Z)(Qe.defaultValue,{value:Qe.value}),Y=Ie=>{const Ke=Ze,lt=Ie.target.value;"value"in Qe||q(lt);const{onChange:qe}=Qe;qe&&lt!==Ke&&qe(Ie)},{prefixCls:de,className:Je,rootClassName:Te,options:$e,buttonStyle:xt="outline",disabled:ke,children:et,size:yt,style:B,id:ie,onMouseEnter:ct,onMouseLeave:Mt,onFocus:ht,onBlur:Yt}=Qe,en=bt("radio",de),nn=`${en}-group`,[Me,te]=Ee(en);let Fe=et;$e&&$e.length>0&&(Fe=$e.map(Ie=>typeof Ie=="string"||typeof Ie=="number"?S.createElement(Ut,{key:Ie.toString(),prefixCls:en,disabled:ke,value:Ie,checked:Ze===Ie},Ie):S.createElement(Ut,{key:`radio-group-value-options-${Ie.value}`,prefixCls:en,disabled:Ie.disabled||ke,value:Ie.value,checked:Ze===Ie.value,title:Ie.title,style:Ie.style},Ie.label)));const Xe=(0,x.Z)(yt),Pe=k()(nn,`${nn}-${xt}`,{[`${nn}-${Xe}`]:Xe,[`${nn}-rtl`]:ze==="rtl"},Je,Te,te);return Me(S.createElement("div",Object.assign({},(0,A.Z)(Qe,{aria:!0,data:!0}),{className:Pe,style:B,onMouseEnter:ct,onMouseLeave:Mt,onFocus:ht,onBlur:Yt,id:ie,ref:rt}),S.createElement(N,{value:{onChange:Y,value:Ze,disabled:Qe.disabled,name:Qe.name,optionType:Qe.optionType}},Fe)))});var at=S.memo(At),Ot=function(Qe,rt){var bt={};for(var ze in Qe)Object.prototype.hasOwnProperty.call(Qe,ze)&&rt.indexOf(ze)<0&&(bt[ze]=Qe[ze]);if(Qe!=null&&typeof Object.getOwnPropertySymbols=="function")for(var Ze=0,ze=Object.getOwnPropertySymbols(Qe);Ze<ze.length;Ze++)rt.indexOf(ze[Ze])<0&&Object.prototype.propertyIsEnumerable.call(Qe,ze[Ze])&&(bt[ze[Ze]]=Qe[ze[Ze]]);return bt};const ue=(Qe,rt)=>{const{getPrefixCls:bt}=S.useContext(R.E_),{prefixCls:ze}=Qe,Ze=Ot(Qe,["prefixCls"]),q=bt("radio",ze);return S.createElement(W,{value:"button"},S.createElement(Ut,Object.assign({prefixCls:q},Ze,{type:"radio",ref:rt})))};var Ue=S.forwardRef(ue);const vt=Ut;vt.Button=Ue,vt.Group=at,vt.__ANT_RADIO=!0;var Jt=vt},89558:function(ae,ne,b){"use strict";b.d(ne,{Ae:function(){return ce},CF:function(){return ht},vC:function(){return B},x1:function(){return R}});function w(Me,te,Fe,Xe,Pe,Ie){const Ke=Me,lt=te,qe=Fe-Ke,pt=Xe-lt;let Ct=Pe-Ke,Xt=Ie-lt,Qt=Ct*qe+Xt*pt,pn=0;Qt<=0?pn=0:(Ct=qe-Ct,Xt=pt-Xt,Qt=Ct*qe+Xt*pt,Qt<=0?pn=0:pn=Qt*Qt/(qe*qe+pt*pt));const Wn=Ct*Ct+Xt*Xt-pn;return Wn<0?0:Wn}function k(Me,te,Fe,Xe){return(Me-Fe)*(Me-Fe)+(te-Xe)*(te-Xe)}function O(Me,te,Fe,Xe,Pe){return k(Me,te,Fe,Xe)<Pe*Pe}function A(Me){if(!Number.isFinite(Me))return Fe=>Fe;if(Me===0)return Math.round;const te=Math.pow(10,Me);return Fe=>Math.round(Fe*te)/te}function S(Me){const te=Math.min(Me.x1,Me.x2),Fe=Math.max(Me.x1,Me.x2),Xe=Math.min(Me.y1,Me.y2),Pe=Math.max(Me.y1,Me.y2);return{x:te,y:Xe,x2:Fe,y2:Pe,width:Fe-te,height:Pe-Xe}}class R{constructor(te,Fe,Xe,Pe){this.x1=te,this.y1=Fe,this.x2=Xe,this.y2=Pe}equals(te){return this.x1===te.x1&&this.y1===te.y1&&this.x2===te.x2&&this.y2===te.y2}draw(te){te.moveTo(this.x1,this.y1),te.lineTo(this.x2,this.y2)}toString(){return`Line(from=(${this.x1},${this.y1}),to=(${this.x2},${this.y2}))`}static from(te){return new R(te.x1,te.y1,te.x2,te.y2)}cuts(te,Fe){if(this.y1===this.y2||Fe<this.y1&&Fe<=this.y2||Fe>this.y1&&Fe>=this.y2||te>this.x1&&te>=this.x2)return!1;if(te<this.x1&&te<=this.x2)return!0;const Xe=this.x1+(Fe-this.y1)*(this.x2-this.x1)/(this.y2-this.y1);return te<=Xe}distSquare(te,Fe){return w(this.x1,this.y1,this.x2,this.y2,te,Fe)}ptClose(te,Fe,Xe){if(this.x1<this.x2){if(te<this.x1-Xe||te>this.x2+Xe)return!1}else if(te<this.x2-Xe||te>this.x1+Xe)return!1;if(this.y1<this.y2){if(Fe<this.y1-Xe||Fe>this.y2+Xe)return!1}else if(Fe<this.y2-Xe||Fe>this.y1+Xe)return!1;return!0}}var x;(function(Me){Me[Me.POINT=1]="POINT",Me[Me.PARALLEL=2]="PARALLEL",Me[Me.COINCIDENT=3]="COINCIDENT",Me[Me.NONE=4]="NONE"})(x||(x={}));class E{constructor(te,Fe=0,Xe=0){this.state=te,this.x=Fe,this.y=Xe}}function N(Me,te){const Fe=(te.x2-te.x1)*(Me.y1-te.y1)-(te.y2-te.y1)*(Me.x1-te.x1),Xe=(Me.x2-Me.x1)*(Me.y1-te.y1)-(Me.y2-Me.y1)*(Me.x1-te.x1),Pe=(te.y2-te.y1)*(Me.x2-Me.x1)-(te.x2-te.x1)*(Me.y2-Me.y1);if(Pe){const Ie=Fe/Pe,Ke=Xe/Pe;return 0<=Ie&&Ie<=1&&0<=Ke&&Ke<=1?new E(x.POINT,Me.x1+Ie*(Me.x2-Me.x1),Me.y1+Ie*(Me.y2-Me.y1)):new E(x.NONE)}return new E(Fe===0||Xe===0?x.COINCIDENT:x.PARALLEL)}function L(Me,te){const Fe=(te.x2-te.x1)*(Me.y1-te.y1)-(te.y2-te.y1)*(Me.x1-te.x1),Xe=(Me.x2-Me.x1)*(Me.y1-te.y1)-(Me.y2-Me.y1)*(Me.x1-te.x1),Pe=(te.y2-te.y1)*(Me.x2-Me.x1)-(te.x2-te.x1)*(Me.y2-Me.y1);if(Pe){const Ie=Fe/Pe,Ke=Xe/Pe;if(0<=Ie&&Ie<=1&&0<=Ke&&Ke<=1)return Ie}return Number.POSITIVE_INFINITY}function P(Me,te){function Fe(Pe,Ie,Ke,lt){let qe=L(te,new R(Pe,Ie,Ke,lt));return qe=Math.abs(qe-.5),qe>=0&&qe<=1?1:0}let Xe=Fe(Me.x,Me.y,Me.x2,Me.y);return Xe+=Fe(Me.x,Me.y,Me.x,Me.y2),Xe>1||(Xe+=Fe(Me.x,Me.y2,Me.x2,Me.y2),Xe>1)?!0:(Xe+=Fe(Me.x2,Me.y,Me.x2,Me.y2),Xe>0)}var W;(function(Me){Me[Me.LEFT=0]="LEFT",Me[Me.TOP=1]="TOP",Me[Me.RIGHT=2]="RIGHT",Me[Me.BOTTOM=3]="BOTTOM"})(W||(W={}));function K(Me,te,Fe){const Xe=new Set;return Me.width<=0?(Xe.add(W.LEFT),Xe.add(W.RIGHT)):te<Me.x?Xe.add(W.LEFT):te>Me.x+Me.width&&Xe.add(W.RIGHT),Me.height<=0?(Xe.add(W.TOP),Xe.add(W.BOTTOM)):Fe<Me.y?Xe.add(W.TOP):Fe>Me.y+Me.height&&Xe.add(W.BOTTOM),Xe}function re(Me,te){let Fe=te.x1,Xe=te.y1;const Pe=te.x2,Ie=te.y2,Ke=Array.from(K(Me,Pe,Ie));if(Ke.length===0)return!0;let lt=K(Me,Fe,Xe);for(;lt.size!==0;){for(const qe of Ke)if(lt.has(qe))return!1;if(lt.has(W.RIGHT)||lt.has(W.LEFT)){let qe=Me.x;lt.has(W.RIGHT)&&(qe+=Me.width),Xe=Xe+(qe-Fe)*(Ie-Xe)/(Pe-Fe),Fe=qe}else{let qe=Me.y;lt.has(W.BOTTOM)&&(qe+=Me.height),Fe=Fe+(qe-Xe)*(Pe-Fe)/(Ie-Xe),Xe=qe}lt=K(Me,Fe,Xe)}return!0}function ye(Me,te){let Fe=Number.POSITIVE_INFINITY,Xe=0;function Pe(Ie,Ke,lt,qe){let pt=L(te,new R(Ie,Ke,lt,qe));pt=Math.abs(pt-.5),pt>=0&&pt<=1&&(Xe++,pt<Fe&&(Fe=pt))}return Pe(Me.x,Me.y,Me.x2,Me.y),Pe(Me.x,Me.y,Me.x,Me.y2),Xe>1||(Pe(Me.x,Me.y2,Me.x2,Me.y2),Xe>1)?Fe:(Pe(Me.x2,Me.y,Me.x2,Me.y2),Xe===0?-1:Fe)}function ge(Me,te){let Fe=0;const Xe=N(Me,new R(te.x,te.y,te.x2,te.y));Fe+=Xe.state===x.POINT?1:0;const Pe=N(Me,new R(te.x,te.y,te.x,te.y2));Fe+=Pe.state===x.POINT?1:0;const Ie=N(Me,new R(te.x,te.y2,te.x2,te.y2));Fe+=Ie.state===x.POINT?1:0;const Ke=N(Me,new R(te.x2,te.y,te.x2,te.y2));return Fe+=Ke.state===x.POINT?1:0,{top:Xe,left:Pe,bottom:Ie,right:Ke,count:Fe}}class ce{constructor(te,Fe,Xe,Pe){this.x=te,this.y=Fe,this.width=Xe,this.height=Pe}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(te){return new ce(te.x,te.y,te.width,te.height)}equals(te){return this.x===te.x&&this.y===te.y&&this.width===te.width&&this.height===te.height}clone(){return new ce(this.x,this.y,this.width,this.height)}add(te){const Fe=Math.min(this.x,te.x),Xe=Math.min(this.y,te.y),Pe=Math.max(this.x2,te.x+te.width),Ie=Math.max(this.y2,te.y+te.height);this.x=Fe,this.y=Xe,this.width=Pe-Fe,this.height=Ie-Xe}addPoint(te){const Fe=Math.min(this.x,te.x),Xe=Math.min(this.y,te.y),Pe=Math.max(this.x2,te.x),Ie=Math.max(this.y2,te.y);this.x=Fe,this.y=Xe,this.width=Pe-Fe,this.height=Ie-Xe}toString(){return`Rectangle[x=${this.x}, y=${this.y}, w=${this.width}, h=${this.height}]`}draw(te){te.rect(this.x,this.y,this.width,this.height)}containsPt(te,Fe){return te>=this.x&&te<=this.x2&&Fe>=this.y&&Fe<=this.y2}get area(){return this.width*this.height}intersects(te){return this.area<=0||te.width<=0||te.height<=0?!1:te.x+te.width>this.x&&te.y+te.height>this.y&&te.x<this.x2&&te.y<this.y2}distSquare(te,Fe){if(this.containsPt(te,Fe))return 0;const Xe=K(this,te,Fe);return Xe.has(W.TOP)?Xe.has(W.LEFT)?k(te,Fe,this.x,this.y):Xe.has(W.RIGHT)?k(te,Fe,this.x2,this.y):(this.y-Fe)*(this.y-Fe):Xe.has(W.BOTTOM)?Xe.has(W.LEFT)?k(te,Fe,this.x,this.y2):Xe.has(W.RIGHT)?k(te,Fe,this.x2,this.y2):(Fe-this.y2)*(Fe-this.y2):Xe.has(W.LEFT)?(this.x-te)*(this.x-te):Xe.has(W.RIGHT)?(te-this.x2)*(te-this.x2):0}}function xe(Me){if(Me.length===0)return null;const te=Me[0],Fe=new ce(te.x,te.y,0,0);for(const Xe of Me)Fe.addPoint(Xe);return Fe}class fe{constructor(te,Fe,Xe){this.cx=te,this.cy=Fe,this.radius=Xe}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(te){return new fe(te.cx,te.cy,te.radius)}containsPt(te,Fe){return k(this.cx,this.cy,te,Fe)<this.radius*this.radius}distSquare(te,Fe){const Xe=k(this.cx,this.cy,te,Fe);if(Xe<this.radius*this.radius)return 0;const Pe=Math.sqrt(Xe)-this.radius;return Pe*Pe}draw(te){te.ellipse(this.cx,this.cy,this.radius,this.radius,0,0,Math.PI*2)}}class Ne{constructor(te,Fe=0,Xe=0,Pe=0,Ie=0,Ke=10,lt=10,qe=new Float32Array(Math.max(0,Ke*lt)).fill(0)){this.pixelGroup=te,this.i=Fe,this.j=Xe,this.pixelX=Pe,this.pixelY=Ie,this.width=Ke,this.height=lt,this.area=qe}createSub(te,Fe){return new Ne(this.pixelGroup,te.x,te.y,Fe.x,Fe.y,te.width,te.height)}static fromPixelRegion(te,Fe){return new Ne(Fe,0,0,te.x,te.y,Math.ceil(te.width/Fe),Math.ceil(te.height/Fe))}copy(te,Fe){return new Ne(this.pixelGroup,this.scaleX(Fe.x),this.scaleY(Fe.y),Fe.x,Fe.y,te.width,te.height,te.area)}boundX(te){return te<this.i?this.i:te>=this.width?this.width-1:te}boundY(te){return te<this.j?this.j:te>=this.height?this.height-1:te}scaleX(te){return this.boundX(Math.floor((te-this.pixelX)/this.pixelGroup))}scaleY(te){return this.boundY(Math.floor((te-this.pixelY)/this.pixelGroup))}scale(te){const Fe=this.scaleX(te.x),Xe=this.scaleY(te.y),Pe=this.boundX(Math.ceil((te.x+te.width-this.pixelX)/this.pixelGroup)),Ie=this.boundY(Math.ceil((te.y+te.height-this.pixelY)/this.pixelGroup)),Ke=Pe-Fe,lt=Ie-Xe;return new ce(Fe,Xe,Ke,lt)}invertScaleX(te){return Math.round(te*this.pixelGroup+this.pixelX)}invertScaleY(te){return Math.round(te*this.pixelGroup+this.pixelY)}addPadding(te,Fe){const Xe=Math.ceil(Fe/this.pixelGroup),Pe=this.boundX(te.x-Xe),Ie=this.boundY(te.y-Xe),Ke=this.boundX(te.x2+Xe),lt=this.boundY(te.y2+Xe),qe=Ke-Pe,pt=lt-Ie;return new ce(Pe,Ie,qe,pt)}get(te,Fe){return te<0||Fe<0||te>=this.width||Fe>=this.height?Number.NaN:this.area[te+Fe*this.width]}inc(te,Fe,Xe){te<0||Fe<0||te>=this.width||Fe>=this.height||(this.area[te+Fe*this.width]+=Xe)}set(te,Fe,Xe){te<0||Fe<0||te>=this.width||Fe>=this.height||(this.area[te+Fe*this.width]=Xe)}incArea(te,Fe){if(te.width<=0||te.height<=0||Fe===0)return;const Xe=this.width,Pe=te.width,Ie=Math.max(0,te.i),Ke=Math.max(0,te.j),lt=Math.min(te.i+te.width,Xe),qe=Math.min(te.j+te.height,this.height);if(!(qe<=0||lt<=0||Ie>=Xe||qe>=this.height))for(let pt=Ke;pt<qe;pt++){const Ct=(pt-te.j)*Pe,Xt=pt*Xe;for(let Qt=Ie;Qt<lt;Qt++){const pn=te.area[Qt-te.i+Ct];pn!==0&&(this.area[Qt+Xt]+=Fe*pn)}}}fill(te){this.area.fill(te)}fillArea(te,Fe){const Xe=te.x+te.y*this.width;for(let Pe=0;Pe<te.height;Pe++){const Ie=Xe+Pe*this.width;this.area.fill(Fe,Ie,Ie+te.width)}}fillHorizontalLine(te,Fe,Xe,Pe){const Ie=te+Fe*this.width;this.area.fill(Pe,Ie,Ie+Xe)}fillVerticalLine(te,Fe,Xe,Pe){const Ie=te+Fe*this.width;for(let Ke=0;Ke<Xe;Ke++)this.area[Ie+Ke*this.width]=Pe}clear(){this.area.fill(0)}toString(){let te="";for(let Fe=0;Fe<this.height;Fe++){const Xe=Fe*this.width;for(let Pe=0;Pe<this.width;Pe++){const Ie=this.area[Xe+Pe];te+=Ie.toFixed(1).padStart(6),te+=" "}te+=`
`}return te}draw(te,Fe=!0){if(this.width<=0||this.height<=0)return;te.save(),Fe&&te.translate(this.pixelX,this.pixelY);const Xe=this.area.reduce((Ke,lt)=>Math.min(Ke,lt),Number.POSITIVE_INFINITY),Pe=this.area.reduce((Ke,lt)=>Math.max(Ke,lt),Number.NEGATIVE_INFINITY),Ie=Ke=>(Ke-Xe)/(Pe-Xe);te.scale(this.pixelGroup,this.pixelGroup);for(let Ke=0;Ke<this.width;Ke++)for(let lt=0;lt<this.height;lt++){const qe=this.area[Ke+lt*this.width];te.fillStyle=`rgba(0, 0, 0, ${Ie(qe)})`,te.fillRect(Ke,lt,1,1)}te.restore()}drawThreshold(te,Fe,Xe=!0){if(!(this.width<=0||this.height<=0)){te.save(),Xe&&te.translate(this.pixelX,this.pixelY),te.scale(this.pixelGroup,this.pixelGroup);for(let Pe=0;Pe<this.width;Pe++)for(let Ie=0;Ie<this.height;Ie++){const Ke=this.area[Pe+Ie*this.width];te.fillStyle=Ke>Fe?"black":"white",te.fillRect(Pe,Ie,1,1)}te.restore()}}}function Ae(Me,te){const Fe=Xe=>({x:Xe.x-te,y:Xe.y-te,width:Xe.width+2*te,height:Xe.height+2*te});return Array.isArray(Me)?Me.map(Fe):Fe(Me)}function be(Me,te,Fe){return Ye(Object.assign(S(Me),{distSquare:(Xe,Pe)=>w(Me.x1,Me.y1,Me.x2,Me.y2,Xe,Pe)}),te,Fe)}function Ye(Me,te,Fe){const Xe=Ae(Me,Fe),Pe=te.scale(Xe),Ie=te.createSub(Pe,Xe);return Ee(Ie,te,Fe,(Ke,lt)=>Me.distSquare(Ke,lt)),Ie}function Ee(Me,te,Fe,Xe){const Pe=Fe*Fe;for(let Ie=0;Ie<Me.height;Ie++)for(let Ke=0;Ke<Me.width;Ke++){const lt=te.invertScaleX(Me.i+Ke),qe=te.invertScaleY(Me.j+Ie),pt=Xe(lt,qe);if(pt===0){Me.set(Ke,Ie,Pe);continue}if(pt<Pe){const Ct=Fe-Math.sqrt(pt);Me.set(Ke,Ie,Ct*Ct)}}return Me}function We(Me,te,Fe){const Xe=te.scale(Me),Pe=te.addPadding(Xe,Fe),Ie=te.createSub(Pe,{x:Me.x-Fe,y:Me.y-Fe}),Ke=Xe.x-Pe.x,lt=Xe.y-Pe.y,qe=Pe.x2-Xe.x2,pt=Pe.y2-Xe.y2,Ct=Pe.width-Ke-qe,Xt=Pe.height-lt-pt,Qt=Fe*Fe;Ie.fillArea({x:Ke,y:lt,width:Ct+1,height:Xt+1},Qt);const pn=[0],Wn=Math.max(lt,Ke,qe,pt);{const Qn=te.invertScaleX(Xe.x+Xe.width/2);for(let Vi=1;Vi<Wn;Vi++){const Oi=te.invertScaleY(Xe.y-Vi),Gi=Me.distSquare(Qn,Oi);if(Gi<Qt){const ir=Fe-Math.sqrt(Gi);pn.push(ir*ir)}else break}}const Rn=[],bi=Math.max(Ke,qe),Lr=Math.max(lt,qe);for(let Qn=1;Qn<bi;Qn++){const Vi=te.invertScaleX(Xe.x-Qn),Oi=[];for(let Gi=1;Gi<Lr;Gi++){const ir=te.invertScaleY(Xe.y-Gi),ms=Me.distSquare(Vi,ir);if(ms<Qt){const Is=Fe-Math.sqrt(ms);Oi.push(Is*Is)}else Oi.push(0)}Rn.push(Oi)}for(let Qn=1;Qn<Math.min(lt,pn.length);Qn++){const Vi=pn[Qn];Ie.fillHorizontalLine(Ke,lt-Qn,Ct+1,Vi)}for(let Qn=1;Qn<Math.min(pt,pn.length);Qn++){const Vi=pn[Qn];Ie.fillHorizontalLine(Ke,lt+Xt+Qn,Ct+1,Vi)}for(let Qn=1;Qn<Math.min(Ke,pn.length);Qn++){const Vi=pn[Qn];Ie.fillVerticalLine(Ke-Qn,lt,Xt+1,Vi)}for(let Qn=1;Qn<Math.min(pt,pn.length);Qn++){const Vi=pn[Qn];Ie.fillVerticalLine(Ke+Ct+Qn,lt,Xt+1,Vi)}for(let Qn=1;Qn<Ke;Qn++){const Vi=Rn[Qn-1],Oi=Ke-Qn;for(let Gi=1;Gi<lt;Gi++)Ie.set(Oi,lt-Gi,Vi[Gi-1]);for(let Gi=1;Gi<pt;Gi++)Ie.set(Oi,lt+Xt+Gi,Vi[Gi-1])}for(let Qn=1;Qn<qe;Qn++){const Vi=Rn[Qn-1],Oi=Ke+Ct+Qn;for(let Gi=1;Gi<lt;Gi++)Ie.set(Oi,lt-Gi,Vi[Gi-1]);for(let Gi=1;Gi<pt;Gi++)Ie.set(Oi,lt+Xt+Gi,Vi[Gi-1])}return Ie}function je(Me,te,Fe,Xe){return{x:Me,y:te,width:Fe,height:Xe}}function _t(Me,te,Fe){return{cx:Me,cy:te,radius:Fe}}function It(Me,te,Fe,Xe){return{x1:Me,y1:te,x2:Fe,y2:Xe}}function kt(Me,te){return{x:Me,y:te}}function Ut(Me,te,Fe,Xe){if(Me.length===0)return[];const Pe=Ue(Me);return Pe.map((Ie,Ke)=>{const lt=Pe.slice(0,Ke);return At(te,Ie,lt,Fe,Xe)}).flat()}function At(Me,te,Fe,Xe,Pe){const Ie=kt(te.cx,te.cy),Ke=ue(Ie,Fe,Me);if(Ke==null)return[];const lt=new R(Ie.x,Ie.y,Ke.cx,Ke.cy),qe=at(lt,Me,Xe,Pe);return Ot(qe,Me)}function at(Me,te,Fe,Xe){const Pe=[],Ie=[];Ie.push(Me);let Ke=!0;for(let lt=0;lt<Fe&&Ke;lt++)for(Ke=!1;!Ke&&Ie.length>0;){const qe=Ie.pop(),pt=Qe(te,qe),Ct=pt?ge(qe,pt):null;if(!pt||!Ct||Ct.count!==2){Ke||Pe.push(qe);continue}let Xt=Xe,Qt=bt(pt,Xt,Ct,!0),pn=Jt(Qt,Ie)||Jt(Qt,Pe),Wn=vt(Qt,te);for(;!pn&&Wn&&Xt>=1;)Xt/=1.5,Qt=bt(pt,Xt,Ct,!0),pn=Jt(Qt,Ie)||Jt(Qt,Pe),Wn=vt(Qt,te);if(Qt&&!pn&&!Wn&&(Ie.push(new R(qe.x1,qe.y1,Qt.x,Qt.y)),Ie.push(new R(Qt.x,Qt.y,qe.x2,qe.y2)),Ke=!0),Ke)continue;Xt=Xe,Qt=bt(pt,Xt,Ct,!1);let Rn=Jt(Qt,Ie)||Jt(Qt,Pe);for(Wn=vt(Qt,te);!Rn&&Wn&&Xt>=1;)Xt/=1.5,Qt=bt(pt,Xt,Ct,!1),Rn=Jt(Qt,Ie)||Jt(Qt,Pe),Wn=vt(Qt,te);Qt&&!Rn&&(Ie.push(new R(qe.x1,qe.y1,Qt.x,Qt.y)),Ie.push(new R(Qt.x,Qt.y,qe.x2,qe.y2)),Ke=!0),Ke||Pe.push(qe)}for(;Ie.length>0;)Pe.push(Ie.pop());return Pe}function Ot(Me,te){const Fe=[];for(;Me.length>0;){const Xe=Me.pop();if(Me.length===0){Fe.push(Xe);break}const Pe=Me.pop(),Ie=new R(Xe.x1,Xe.y1,Pe.x2,Pe.y2);Qe(te,Ie)?(Fe.push(Xe),Me.push(Pe)):Me.push(Ie)}return Fe}function ue(Me,te,Fe){let Xe=Number.POSITIVE_INFINITY;return te.reduce((Pe,Ie)=>{const Ke=k(Me.x,Me.y,Ie.cx,Ie.cy);if(Ke>Xe)return Pe;const lt=new R(Me.x,Me.y,Ie.cx,Ie.cy),qe=rt(Fe,lt);return Ke*(qe+1)*(qe+1)<Xe&&(Pe=Ie,Xe=Ke*(qe+1)*(qe+1)),Pe},null)}function Ue(Me){if(Me.length<2)return Me;let te=0,Fe=0;return Me.forEach(Xe=>{te+=Xe.cx,Fe+=Xe.cy}),te/=Me.length,Fe/=Me.length,Me.map(Xe=>{const Pe=te-Xe.cx,Ie=Fe-Xe.cy,Ke=Pe*Pe+Ie*Ie;return[Xe,Ke]}).sort((Xe,Pe)=>Xe[1]-Pe[1]).map(Xe=>Xe[0])}function vt(Me,te){return te.some(Fe=>Fe.containsPt(Me.x,Me.y))}function Jt(Me,te){return te.some(Fe=>!!(O(Fe.x1,Fe.y1,Me.x,Me.y,.001)||O(Fe.x2,Fe.y2,Me.x,Me.y,.001)))}function Qe(Me,te){let Fe=Number.POSITIVE_INFINITY,Xe=null;for(const Pe of Me){if(!re(Pe,te))continue;const Ie=ye(Pe,te);Ie>=0&&Ie<Fe&&(Xe=Pe,Fe=Ie)}return Xe}function rt(Me,te){return Me.reduce((Fe,Xe)=>re(Xe,te)&&P(Xe,te)?Fe+1:Fe,0)}function bt(Me,te,Fe,Xe){const Pe=Fe.top,Ie=Fe.left,Ke=Fe.bottom,lt=Fe.right;if(Xe){if(Ie.state===x.POINT){if(Pe.state===x.POINT)return kt(Me.x-te,Me.y-te);if(Ke.state===x.POINT)return kt(Me.x-te,Me.y2+te);const Qt=Me.width*Me.height;return Me.width*((Ie.y-Me.y+(lt.y-Me.y))*.5)<Qt*.5?Ie.y>lt.y?kt(Me.x-te,Me.y-te):kt(Me.x2+te,Me.y-te):Ie.y<lt.y?kt(Me.x-te,Me.y2+te):kt(Me.x2+te,Me.y2+te)}if(lt.state===x.POINT){if(Pe.state===x.POINT)return kt(Me.x2+te,Me.y-te);if(Ke.state===x.POINT)return kt(Me.x2+te,Me.y2+te)}const Ct=Me.height*Me.width;return Me.height*((Pe.x-Me.x+(lt.x-Me.x))*.5)<Ct*.5?Pe.x>Ke.x?kt(Me.x-te,Me.y-te):kt(Me.x-te,Me.y2+te):Pe.x<Ke.x?kt(Me.x2+te,Me.y-te):kt(Me.x2+te,Me.y2+te)}if(Ie.state===x.POINT){if(Pe.state===x.POINT)return kt(Me.x2+te,Me.y2+te);if(Ke.state===x.POINT)return kt(Me.x2+te,Me.y-te);const Ct=Me.height*Me.width;return Me.width*((Ie.y-Me.y+(lt.y-Me.y))*.5)<Ct*.5?Ie.y>lt.y?kt(Me.x2+te,Me.y2+te):kt(Me.x-te,Me.y2+te):Ie.y<lt.y?kt(Me.x2+te,Me.y-te):kt(Me.x-te,Me.y-te)}if(lt.state===x.POINT){if(Pe.state===x.POINT)return kt(Me.x-te,Me.y2+te);if(Ke.state===x.POINT)return kt(Me.x-te,Me.y-te)}const qe=Me.height*Me.width;return Me.height*((Pe.x-Me.x+(lt.x-Me.x))*.5)<qe*.5?Pe.x>Ke.x?kt(Me.x2+te,Me.y2+te):kt(Me.x2+te,Me.y-te):Pe.x<Ke.x?kt(Me.x-te,Me.y2+te):kt(Me.x-te,Me.y-te)}function ze(Me,te,Fe,Xe){if(!(Me.closed?Fe<Me.length:Fe<Me.length-1))return!1;const Ie=Me.get(te),Ke=Me.get(Fe+1);for(let lt=te+1;lt<=Fe;lt++){const qe=Me.get(lt);if(w(Ie.x,Ie.y,Ke.x,Ke.y,qe.x,qe.y)>Xe)return!1}return!0}function Ze(Me=0){return te=>{if(Me<0||te.length<3)return te;const Fe=[];let Xe=0;const Pe=Me*Me;for(;Xe<te.length;){let Ie=Xe+1;for(;ze(te,Xe,Ie,Pe);)Ie++;Fe.push(te.get(Xe)),Xe=Ie}return new Je(Fe)}}function q(Me,te){switch(Me){case-2:return(((-te+3)*te-3)*te+1)/6;case-1:return((3*te-6)*te*te+4)/6;case 0:return(((-3*te+3)*te+3)*te+1)/6;case 1:return te*te*te/6;default:throw new Error("unknown error")}}function Y(Me=6){function Ie(Ke,lt,qe){let pt=0,Ct=0;for(let Xt=-2;Xt<=1;Xt++){const Qt=Ke.get(lt+Xt),pn=q(Xt,qe);pt+=pn*Qt.x,Ct+=pn*Qt.y}return{x:pt,y:Ct}}return Ke=>{if(Ke.length<3)return Ke;const lt=[],qe=Ke.closed,pt=Ke.length+3-1+(qe?0:2);lt.push(Ie(Ke,2-(qe?0:2),0));for(let Ct=2-(qe?0:2);Ct<pt;Ct++)for(let Xt=1;Xt<=Me;Xt++)lt.push(Ie(Ke,Ct,Xt/Me));return new Je(lt)}}function de(Me=8){return te=>{let Fe=Me,Xe=te.length;if(Fe>1)for(Xe=Math.floor(te.length/Fe);Xe<3&&Fe>1;)Fe-=1,Xe=Math.floor(te.length/Fe);const Pe=[];for(let Ie=0,Ke=0;Ke<Xe;Ke++,Ie+=Fe)Pe.push(te.get(Ie));return new Je(Pe)}}class Je{constructor(te=[],Fe=!0){this.points=te,this.closed=Fe}get(te){const Fe=te,Xe=this.points.length;return te<0?this.closed?this.get(te+Xe):this.points[0]:te>=Xe?this.closed?this.get(te-Xe):this.points[Xe-1]:this.points[Fe]}get length(){return this.points.length}toString(te=1/0){const Fe=this.points;if(Fe.length===0)return"";const Xe=typeof te=="function"?te:A(te);let Pe="M";for(const Ie of Fe)Pe+=`${Xe(Ie.x)},${Xe(Ie.y)} L`;return Pe=Pe.slice(0,-1),this.closed&&(Pe+=" Z"),Pe}draw(te){const Fe=this.points;if(Fe.length!==0){te.beginPath(),te.moveTo(Fe[0].x,Fe[0].y);for(const Xe of Fe)te.lineTo(Xe.x,Xe.y);this.closed&&te.closePath()}}sample(te){return de(te)(this)}simplify(te){return Ze(te)(this)}bSplines(te){return Y(te)(this)}apply(te){return te(this)}containsElements(te){const Fe=xe(this.points);return Fe?te.every(Xe=>Fe.containsPt(Xe.cx,Xe.cy)&&this.withinArea(Xe.cx,Xe.cy)):!1}withinArea(te,Fe){if(this.length===0)return!1;let Xe=0;const Pe=this.points[0],Ie=new R(Pe.x,Pe.y,Pe.x,Pe.y);for(let Ke=1;Ke<this.points.length;Ke++){const lt=this.points[Ke];Ie.x1=Ie.x2,Ie.y1=Ie.y2,Ie.x2=lt.x,Ie.y2=lt.y,Ie.cuts(te,Fe)&&Xe++}return Ie.x1=Ie.x2,Ie.y1=Ie.y2,Ie.x2=Pe.x,Ie.y2=Pe.y,Ie.cuts(te,Fe)&&Xe++,Xe%2===1}}class Te{constructor(te=0){this.count=0,this.arr=[],this.set=new Set,this.arr.length=te}add(te){this.set.add(`${te.x}x${te.y}`),this.arr[this.count++]=te}contains(te){return this.set.has(`${te.x}x${te.y}`)}isFirst(te){if(this.count===0)return!1;const Fe=this.arr[0];return Fe!=null&&Fe.x===te.x&&Fe.y===te.y}path(){return new Je(this.arr.slice(0,this.count))}clear(){this.set.clear(),this.count=0}get(te){return this.arr[te]}get length(){return this.count}}const $e=0,xt=1,ke=2,et=3;function yt(Me,te){const Fe=(Math.floor(Me.width)+Math.floor(Me.height))*2,Xe=new Te(Fe);function Pe(qe,pt,Ct,Xt){const Qt=Me.get(qe,pt);return Number.isNaN(Qt)?Number.NaN:Qt>te?Ct+Xt:Ct}function Ie(qe,pt){let Ct=$e;return Ct=Pe(qe,pt,Ct,1),Ct=Pe(qe+1,pt,Ct,2),Ct=Pe(qe,pt+1,Ct,4),Ct=Pe(qe+1,pt+1,Ct,8),Number.isNaN(Ct)?-1:Ct}let Ke=xt;function lt(qe,pt){let Ct=qe,Xt=pt,Qt=Me.invertScaleX(Ct),pn=Me.invertScaleY(Xt);for(let Wn=0;Wn<Me.width*Me.height;Wn++){const Rn={x:Qt,y:pn};if(Xe.contains(Rn)){if(Xe.isFirst(Rn))return!0}else Xe.add(Rn);const bi=Ie(Ct,Xt);switch(bi){case-1:return!0;case 0:case 3:case 2:case 7:Ke=ke;break;case 12:case 14:case 4:Ke=et;break;case 6:Ke=Ke===$e?et:ke;break;case 1:case 13:case 5:Ke=$e;break;case 9:Ke=Ke===ke?$e:xt;break;case 10:case 8:case 11:Ke=xt;break;default:return console.warn("Marching squares invalid state: "+bi),!0}switch(Ke){case $e:Xt--,pn-=Me.pixelGroup;break;case xt:Xt++,pn+=Me.pixelGroup;break;case et:Ct--,Qt-=Me.pixelGroup;break;case ke:Ct++,Qt+=Me.pixelGroup;break;default:return console.warn("Marching squares invalid state: "+bi),!0}}return!0}for(let qe=0;qe<Me.width;qe++)for(let pt=0;pt<Me.height;pt++){if(Me.get(qe,pt)<=te)continue;const Ct=Ie(qe,pt);if(!(Ct<0||Ct===15)&&lt(qe,pt))return Xe.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 ie(Me){return Me!=null&&typeof Me.radius=="number"}function ct(Me,te){if(ie(Me)!==ie(te))return!1;if(ie(Me)){const Xe=te;return Me.cx===Xe.cx&&Me.cy===Xe.cy&&Me.radius===Xe.radius}const Fe=te;return Me.x===Fe.x&&Me.y===Fe.y&&Me.width===Fe.width&&Me.height===Fe.height}var Mt;(function(Me){Me[Me.MEMBERS=0]="MEMBERS",Me[Me.NON_MEMBERS=1]="NON_MEMBERS",Me[Me.EDGES=2]="EDGES"})(Mt||(Mt={}));class ht{constructor(te={}){this.dirty=new Set,this.members=[],this.nonMembers=[],this.virtualEdges=[],this.edges=[],this.activeRegion=new ce(0,0,0,0),this.potentialArea=new Ne(1,0,0,0,0,0,0),this.o=Object.assign({},B,te)}pushMember(...te){if(te.length!==0){this.dirty.add(Mt.MEMBERS);for(const Fe of te)this.members.push({raw:Fe,obj:ie(Fe)?fe.from(Fe):ce.from(Fe),area:null})}}removeMember(te){const Fe=this.members.findIndex(Xe=>ct(Xe.raw,te));return Fe<0?!1:(this.members.splice(Fe,1),this.dirty.add(Mt.MEMBERS),!0)}removeNonMember(te){const Fe=this.nonMembers.findIndex(Xe=>ct(Xe.raw,te));return Fe<0?!1:(this.nonMembers.splice(Fe,1),this.dirty.add(Mt.NON_MEMBERS),!0)}removeEdge(te){const Fe=this.edges.findIndex(Xe=>Xe.obj.equals(te));return Fe<0?!1:(this.edges.splice(Fe,1),this.dirty.add(Mt.NON_MEMBERS),!0)}pushNonMember(...te){if(te.length!==0){this.dirty.add(Mt.NON_MEMBERS);for(const Fe of te)this.nonMembers.push({raw:Fe,obj:ie(Fe)?fe.from(Fe):ce.from(Fe),area:null})}}pushEdge(...te){if(te.length!==0){this.dirty.add(Mt.EDGES);for(const Fe of te)this.edges.push({raw:Fe,obj:R.from(Fe),area:null})}}update(){const te=this.dirty.has(Mt.MEMBERS),Fe=this.dirty.has(Mt.NON_MEMBERS);let Xe=this.dirty.has(Mt.EDGES);this.dirty.clear();const Pe=this.members.map(pt=>pt.obj);if(this.o.virtualEdges&&(te||Fe)){const pt=this.nonMembers.map(Qt=>Qt.obj),Ct=Ut(Pe,pt,this.o.maxRoutingIterations,this.o.morphBuffer),Xt=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=Xt.get(Qt.toString()))!==null&&pn!==void 0?pn:null}}),Xe=!0}let Ie=!1;if(te||Xe){const pt=this.virtualEdges.concat(this.edges).map(pn=>pn.obj),Ct=en(Pe,pt),Xt=Math.max(this.o.edgeR1,this.o.nodeR1)+this.o.morphBuffer,Qt=ce.from(Ae(Ct,Xt));Qt.equals(this.activeRegion)||(Ie=!0,this.activeRegion=Qt)}if(Ie){const pt=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(Xt=>Xt.area=null),this.nonMembers.forEach(Xt=>Xt.area=null),this.edges.forEach(Xt=>Xt.area=null),this.virtualEdges.forEach(Xt=>Xt.area=null)):(pt!==this.potentialArea.width||Ct!==this.potentialArea.height)&&(this.potentialArea=Ne.fromPixelRegion(this.activeRegion,this.o.pixelGroup))}const Ke=new Map,lt=pt=>{if(pt.area){const Ct=`${pt.obj.width}x${pt.obj.height}x${pt.obj instanceof ce?"R":"C"}`;Ke.set(Ct,pt.area)}},qe=pt=>{if(pt.area)return;const Ct=`${pt.obj.width}x${pt.obj.height}x${pt.obj instanceof ce?"R":"C"}`;if(Ke.has(Ct)){const Qt=Ke.get(Ct);pt.area=this.potentialArea.copy(Qt,{x:pt.obj.x-this.o.nodeR1,y:pt.obj.y-this.o.nodeR1});return}const Xt=pt.obj instanceof ce?We(pt.obj,this.potentialArea,this.o.nodeR1):Ye(pt.obj,this.potentialArea,this.o.nodeR1);pt.area=Xt,Ke.set(Ct,Xt)};this.members.forEach(lt),this.nonMembers.forEach(lt),this.members.forEach(qe),this.nonMembers.forEach(pt=>{this.activeRegion.intersects(pt.obj)?qe(pt):pt.area=null}),this.edges.forEach(pt=>{pt.area||(pt.area=be(pt.obj,this.potentialArea,this.o.edgeR1))}),this.virtualEdges.forEach(pt=>{pt.area||(pt.area=be(pt.obj,this.potentialArea,this.o.edgeR1))})}drawMembers(te){for(const Fe of this.members)Fe.obj.draw(te)}drawNonMembers(te){for(const Fe of this.nonMembers)Fe.obj.draw(te)}drawEdges(te){for(const Fe of this.edges)Fe.obj.draw(te)}drawPotentialArea(te,Fe=!0){this.potentialArea.draw(te,Fe)}compute(){if(this.members.length===0)return new Je([]);this.dirty.size>0&&this.update();const{o:te,potentialArea:Fe}=this,Xe=this.members.map(lt=>lt.area),Pe=this.virtualEdges.concat(this.edges).map(lt=>lt.area),Ie=this.nonMembers.filter(lt=>lt.area!=null).map(lt=>lt.area),Ke=this.members.map(lt=>lt.obj);return Yt(Fe,Xe,Pe,Ie,lt=>lt.containsElements(Ke),te)}}function Yt(Me,te,Fe,Xe,Pe,Ie={}){const Ke=Object.assign({},B,Ie);let lt=Ke.threshold,qe=Ke.memberInfluenceFactor,pt=Ke.edgeInfluenceFactor,Ct=Ke.nonMemberInfluenceFactor;const Xt=(Ke.nodeR0-Ke.nodeR1)*(Ke.nodeR0-Ke.nodeR1),Qt=(Ke.edgeR0-Ke.edgeR1)*(Ke.edgeR0-Ke.edgeR1);for(let pn=0;pn<Ke.maxMarchingIterations;pn++){if(Me.clear(),qe!==0){const Rn=qe/Xt;for(const bi of te)Me.incArea(bi,Rn)}if(pt!==0){const Rn=pt/Qt;for(const bi of Fe)Me.incArea(bi,Rn)}if(Ct!==0){const Rn=Ct/Xt;for(const bi of Xe)Me.incArea(bi,Rn)}const Wn=yt(Me,lt);if(Wn&&Pe(Wn))return Wn;if(lt*=.95,pn<=Ke.maxMarchingIterations*.5)qe*=1.2,pt*=1.2;else if(Ct!==0&&Xe.length>0)Ct*=.8;else break}return new Je([])}function en(Me,te){if(Me.length===0)return new ce(0,0,0,0);const Fe=ce.from(Me[0]);for(const Xe of Me)Fe.add(Xe);for(const Xe of te)Fe.add(S(Xe));return Fe}function nn(Me,te=[],Fe=[],Xe={}){if(Me.length===0)return new Je([]);const Pe=new ht(Xe);return Pe.pushMember(...Me),Pe.pushNonMember(...te),Pe.pushEdge(...Fe),Pe.compute()}},8874:function(ae){"use strict";ae.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(ae,ne,b){var w=b(8874),k=b(86851),O=Object.hasOwnProperty,A=Object.create(null);for(var S in w)O.call(w,S)&&(A[w[S]]=S);var R=ae.exports={to:{},get:{}};R.get=function(N){var L=N.substring(0,3).toLowerCase(),P,W;switch(L){case"hsl":P=R.get.hsl(N),W="hsl";break;case"hwb":P=R.get.hwb(N),W="hwb";break;default:P=R.get.rgb(N),W="rgb";break}return P?{model:W,value:P}:null},R.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*)?\)$/,K=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,re=/^(\w+)$/,ye=[0,0,0,1],ge,ce,xe;if(ge=N.match(P)){for(xe=ge[2],ge=ge[1],ce=0;ce<3;ce++){var fe=ce*2;ye[ce]=parseInt(ge.slice(fe,fe+2),16)}xe&&(ye[3]=parseInt(xe,16)/255)}else if(ge=N.match(L)){for(ge=ge[1],xe=ge[3],ce=0;ce<3;ce++)ye[ce]=parseInt(ge[ce]+ge[ce],16);xe&&(ye[3]=parseInt(xe+xe,16)/255)}else if(ge=N.match(W)){for(ce=0;ce<3;ce++)ye[ce]=parseInt(ge[ce+1],0);ge[4]&&(ge[5]?ye[3]=parseFloat(ge[4])*.01:ye[3]=parseFloat(ge[4]))}else if(ge=N.match(K)){for(ce=0;ce<3;ce++)ye[ce]=Math.round(parseFloat(ge[ce+1])*2.55);ge[4]&&(ge[5]?ye[3]=parseFloat(ge[4])*.01:ye[3]=parseFloat(ge[4]))}else return(ge=N.match(re))?ge[1]==="transparent"?[0,0,0,0]:O.call(w,ge[1])?(ye=w[ge[1]],ye[3]=1,ye):null:null;for(ce=0;ce<3;ce++)ye[ce]=x(ye[ce],0,255);return ye[3]=x(ye[3],0,1),ye},R.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]),K=(parseFloat(P[1])%360+360)%360,re=x(parseFloat(P[2]),0,100),ye=x(parseFloat(P[3]),0,100),ge=x(isNaN(W)?1:W,0,1);return[K,re,ye,ge]}return null},R.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]),K=(parseFloat(P[1])%360+360)%360,re=x(parseFloat(P[2]),0,100),ye=x(parseFloat(P[3]),0,100),ge=x(isNaN(W)?1:W,0,1);return[K,re,ye,ge]}return null},R.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)):"")},R.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]+")"},R.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]+")"},R.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]+")"},R.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+")"},R.to.keyword=function(N){return A[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(ae,ne,b){ae.exports={graphlib:b(70574),layout:b(98123),debug:b(27570),util:{time:b(11138).time,notime:b(11138).notime},version:b(88177)}},92188:function(ae,ne,b){"use strict";var w=b(38436),k=b(74079);ae.exports={run:O,undo:S};function O(R){var x=R.graph().acyclicer==="greedy"?k(R,E(R)):A(R);w.forEach(x,function(N){var L=R.edge(N);R.removeEdge(N),L.forwardName=N.name,L.reversed=!0,R.setEdge(N.w,N.v,L,w.uniqueId("rev"))});function E(N){return function(L){return N.edge(L).weight}}}function A(R){var x=[],E={},N={};function L(P){w.has(N,P)||(N[P]=!0,E[P]=!0,w.forEach(R.outEdges(P),function(W){w.has(E,W.w)?x.push(W):L(W.w)}),delete E[P])}return w.forEach(R.nodes(),L),x}function S(R){w.forEach(R.edges(),function(x){var E=R.edge(x);if(E.reversed){R.removeEdge(x);var N=E.forwardName;delete E.reversed,delete E.forwardName,R.setEdge(x.w,x.v,E,N)}})}},61133:function(ae,ne,b){var w=b(38436),k=b(11138);ae.exports=O;function O(S){function R(x){var E=S.children(x),N=S.node(x);if(E.length&&w.forEach(E,R),w.has(N,"minRank")){N.borderLeft=[],N.borderRight=[];for(var L=N.minRank,P=N.maxRank+1;L<P;++L)A(S,"borderLeft","_bl",x,N,L),A(S,"borderRight","_br",x,N,L)}}w.forEach(S.children(),R)}function A(S,R,x,E,N,L){var P={width:0,height:0,rank:L,borderType:R},W=N[R][L-1],K=k.addDummyNode(S,"border",P,x);N[R][L]=K,S.setParent(K,E),W&&S.setEdge(W,K,{weight:1})}},53258:function(ae,ne,b){"use strict";var w=b(38436);ae.exports={adjust:k,undo:O};function k(L){var P=L.graph().rankdir.toLowerCase();(P==="lr"||P==="rl")&&A(L)}function O(L){var P=L.graph().rankdir.toLowerCase();(P==="bt"||P==="rl")&&R(L),(P==="lr"||P==="rl")&&(E(L),A(L))}function A(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 R(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(ae){ae.exports=ne;function ne(){var k={};k._next=k._prev=k,this._sentinel=k}ne.prototype.dequeue=function(){var k=this._sentinel,O=k._prev;if(O!==k)return b(O),O},ne.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},ne.prototype.toString=function(){for(var k=[],O=this._sentinel,A=O._prev;A!==O;)k.push(JSON.stringify(A,w)),A=A._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(ae,ne,b){var w=b(38436),k=b(11138),O=b(70574).Graph;ae.exports={debugOrdering:A};function A(S){var R=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(R,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(ae,ne,b){var w;try{w=b(28282)}catch(k){}w||(w=window.graphlib),ae.exports=w},74079:function(ae,ne,b){var w=b(38436),k=b(70574).Graph,O=b(77822);ae.exports=S;var A=w.constant(1);function S(L,P){if(L.nodeCount()<=1)return[];var W=E(L,P||A),K=R(W.graph,W.buckets,W.zeroIdx);return w.flatten(w.map(K,function(re){return L.outEdges(re.v,re.w)}),!0)}function R(L,P,W){for(var K=[],re=P[P.length-1],ye=P[0],ge;L.nodeCount();){for(;ge=ye.dequeue();)x(L,P,W,ge);for(;ge=re.dequeue();)x(L,P,W,ge);if(L.nodeCount()){for(var ce=P.length-2;ce>0;--ce)if(ge=P[ce].dequeue(),ge){K=K.concat(x(L,P,W,ge,!0));break}}}return K}function x(L,P,W,K,re){var ye=re?[]:void 0;return w.forEach(L.inEdges(K.v),function(ge){var ce=L.edge(ge),xe=L.node(ge.v);re&&ye.push({v:ge.v,w:ge.w}),xe.out-=ce,N(P,W,xe)}),w.forEach(L.outEdges(K.v),function(ge){var ce=L.edge(ge),xe=ge.w,fe=L.node(xe);fe.in-=ce,N(P,W,fe)}),L.removeNode(K.v),ye}function E(L,P){var W=new k,K=0,re=0;w.forEach(L.nodes(),function(ce){W.setNode(ce,{v:ce,in:0,out:0})}),w.forEach(L.edges(),function(ce){var xe=W.edge(ce.v,ce.w)||0,fe=P(ce),Ne=xe+fe;W.setEdge(ce.v,ce.w,Ne),re=Math.max(re,W.node(ce.v).out+=fe),K=Math.max(K,W.node(ce.w).in+=fe)});var ye=w.range(re+K+3).map(function(){return new O}),ge=K+1;return w.forEach(W.nodes(),function(ce){N(ye,ge,W.node(ce))}),{graph:W,buckets:ye,zeroIdx:ge}}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(ae,ne,b){"use strict";var w=b(38436),k=b(92188),O=b(45995),A=b(78093),S=b(11138).normalizeRanks,R=b(24219),x=b(11138).removeEmptyRanks,E=b(72981),N=b(61133),L=b(53258),P=b(53408),W=b(17873),K=b(11138),re=b(70574).Graph;ae.exports=ye;function ye(ze,Ze){var q=Ze&&Ze.debugTiming?K.time:K.notime;q("layout",function(){var Y=q(" buildLayoutGraph",function(){return je(ze)});q(" runLayout",function(){ge(Y,q)}),q(" updateInputGraph",function(){ce(ze,Y)})})}function ge(ze,Ze){Ze(" makeSpaceForEdgeLabels",function(){_t(ze)}),Ze(" removeSelfEdges",function(){vt(ze)}),Ze(" acyclic",function(){k.run(ze)}),Ze(" nestingGraph.run",function(){E.run(ze)}),Ze(" rank",function(){A(K.asNonCompoundGraph(ze))}),Ze(" injectEdgeLabelProxies",function(){It(ze)}),Ze(" removeEmptyRanks",function(){x(ze)}),Ze(" nestingGraph.cleanup",function(){E.cleanup(ze)}),Ze(" normalizeRanks",function(){S(ze)}),Ze(" assignRankMinMax",function(){kt(ze)}),Ze(" removeEdgeLabelProxies",function(){Ut(ze)}),Ze(" normalize.run",function(){O.run(ze)}),Ze(" parentDummyChains",function(){R(ze)}),Ze(" addBorderSegments",function(){N(ze)}),Ze(" order",function(){P(ze)}),Ze(" insertSelfEdges",function(){Jt(ze)}),Ze(" adjustCoordinateSystem",function(){L.adjust(ze)}),Ze(" position",function(){W(ze)}),Ze(" positionSelfEdges",function(){Qe(ze)}),Ze(" removeBorderNodes",function(){Ue(ze)}),Ze(" normalize.undo",function(){O.undo(ze)}),Ze(" fixupEdgeLabelCoords",function(){Ot(ze)}),Ze(" undoCoordinateSystem",function(){L.undo(ze)}),Ze(" translateGraph",function(){At(ze)}),Ze(" assignNodeIntersects",function(){at(ze)}),Ze(" reversePoints",function(){ue(ze)}),Ze(" acyclic.undo",function(){k.undo(ze)})}function ce(ze,Ze){w.forEach(ze.nodes(),function(q){var Y=ze.node(q),de=Ze.node(q);Y&&(Y.x=de.x,Y.y=de.y,Ze.children(q).length&&(Y.width=de.width,Y.height=de.height))}),w.forEach(ze.edges(),function(q){var Y=ze.edge(q),de=Ze.edge(q);Y.points=de.points,w.has(de,"x")&&(Y.x=de.x,Y.y=de.y)}),ze.graph().width=Ze.graph().width,ze.graph().height=Ze.graph().height}var xe=["nodesep","edgesep","ranksep","marginx","marginy"],fe={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},Ne=["acyclicer","ranker","rankdir","align"],Ae=["width","height"],be={width:0,height:0},Ye=["minlen","weight","width","height","labeloffset"],Ee={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},We=["labelpos"];function je(ze){var Ze=new re({multigraph:!0,compound:!0}),q=bt(ze.graph());return Ze.setGraph(w.merge({},fe,rt(q,xe),w.pick(q,Ne))),w.forEach(ze.nodes(),function(Y){var de=bt(ze.node(Y));Ze.setNode(Y,w.defaults(rt(de,Ae),be)),Ze.setParent(Y,ze.parent(Y))}),w.forEach(ze.edges(),function(Y){var de=bt(ze.edge(Y));Ze.setEdge(Y,w.merge({},Ee,rt(de,Ye),w.pick(de,We)))}),Ze}function _t(ze){var Ze=ze.graph();Ze.ranksep/=2,w.forEach(ze.edges(),function(q){var Y=ze.edge(q);Y.minlen*=2,Y.labelpos.toLowerCase()!=="c"&&(Ze.rankdir==="TB"||Ze.rankdir==="BT"?Y.width+=Y.labeloffset:Y.height+=Y.labeloffset)})}function It(ze){w.forEach(ze.edges(),function(Ze){var q=ze.edge(Ze);if(q.width&&q.height){var Y=ze.node(Ze.v),de=ze.node(Ze.w),Je={rank:(de.rank-Y.rank)/2+Y.rank,e:Ze};K.addDummyNode(ze,"edge-proxy",Je,"_ep")}})}function kt(ze){var Ze=0;w.forEach(ze.nodes(),function(q){var Y=ze.node(q);Y.borderTop&&(Y.minRank=ze.node(Y.borderTop).rank,Y.maxRank=ze.node(Y.borderBottom).rank,Ze=w.max(Ze,Y.maxRank))}),ze.graph().maxRank=Ze}function Ut(ze){w.forEach(ze.nodes(),function(Ze){var q=ze.node(Ze);q.dummy==="edge-proxy"&&(ze.edge(q.e).labelRank=q.rank,ze.removeNode(Ze))})}function At(ze){var Ze=Number.POSITIVE_INFINITY,q=0,Y=Number.POSITIVE_INFINITY,de=0,Je=ze.graph(),Te=Je.marginx||0,$e=Je.marginy||0;function xt(ke){var et=ke.x,yt=ke.y,B=ke.width,ie=ke.height;Ze=Math.min(Ze,et-B/2),q=Math.max(q,et+B/2),Y=Math.min(Y,yt-ie/2),de=Math.max(de,yt+ie/2)}w.forEach(ze.nodes(),function(ke){xt(ze.node(ke))}),w.forEach(ze.edges(),function(ke){var et=ze.edge(ke);w.has(et,"x")&&xt(et)}),Ze-=Te,Y-=$e,w.forEach(ze.nodes(),function(ke){var et=ze.node(ke);et.x-=Ze,et.y-=Y}),w.forEach(ze.edges(),function(ke){var et=ze.edge(ke);w.forEach(et.points,function(yt){yt.x-=Ze,yt.y-=Y}),w.has(et,"x")&&(et.x-=Ze),w.has(et,"y")&&(et.y-=Y)}),Je.width=q-Ze+Te,Je.height=de-Y+$e}function at(ze){w.forEach(ze.edges(),function(Ze){var q=ze.edge(Ze),Y=ze.node(Ze.v),de=ze.node(Ze.w),Je,Te;q.points?(Je=q.points[0],Te=q.points[q.points.length-1]):(q.points=[],Je=de,Te=Y),q.points.unshift(K.intersectRect(Y,Je)),q.points.push(K.intersectRect(de,Te))})}function Ot(ze){w.forEach(ze.edges(),function(Ze){var q=ze.edge(Ze);if(w.has(q,"x"))switch((q.labelpos==="l"||q.labelpos==="r")&&(q.width-=q.labeloffset),q.labelpos){case"l":q.x-=q.width/2+q.labeloffset;break;case"r":q.x+=q.width/2+q.labeloffset;break}})}function ue(ze){w.forEach(ze.edges(),function(Ze){var q=ze.edge(Ze);q.reversed&&q.points.reverse()})}function Ue(ze){w.forEach(ze.nodes(),function(Ze){if(ze.children(Ze).length){var q=ze.node(Ze),Y=ze.node(q.borderTop),de=ze.node(q.borderBottom),Je=ze.node(w.last(q.borderLeft)),Te=ze.node(w.last(q.borderRight));q.width=Math.abs(Te.x-Je.x),q.height=Math.abs(de.y-Y.y),q.x=Je.x+q.width/2,q.y=Y.y+q.height/2}}),w.forEach(ze.nodes(),function(Ze){ze.node(Ze).dummy==="border"&&ze.removeNode(Ze)})}function vt(ze){w.forEach(ze.edges(),function(Ze){if(Ze.v===Ze.w){var q=ze.node(Ze.v);q.selfEdges||(q.selfEdges=[]),q.selfEdges.push({e:Ze,label:ze.edge(Ze)}),ze.removeEdge(Ze)}})}function Jt(ze){var Ze=K.buildLayerMatrix(ze);w.forEach(Ze,function(q){var Y=0;w.forEach(q,function(de,Je){var Te=ze.node(de);Te.order=Je+Y,w.forEach(Te.selfEdges,function($e){K.addDummyNode(ze,"selfedge",{width:$e.label.width,height:$e.label.height,rank:Te.rank,order:Je+ ++Y,e:$e.e,label:$e.label},"_se")}),delete Te.selfEdges})})}function Qe(ze){w.forEach(ze.nodes(),function(Ze){var q=ze.node(Ze);if(q.dummy==="selfedge"){var Y=ze.node(q.e.v),de=Y.x+Y.width/2,Je=Y.y,Te=q.x-de,$e=Y.height/2;ze.setEdge(q.e,q.label),ze.removeNode(Ze),q.label.points=[{x:de+2*Te/3,y:Je-$e},{x:de+5*Te/6,y:Je-$e},{x:de+Te,y:Je},{x:de+5*Te/6,y:Je+$e},{x:de+2*Te/3,y:Je+$e}],q.label.x=q.x,q.label.y=q.y}})}function rt(ze,Ze){return w.mapValues(w.pick(ze,Ze),Number)}function bt(ze){var Ze={};return w.forEach(ze,function(q,Y){Ze[Y.toLowerCase()]=q}),Ze}},38436:function(ae,ne,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._),ae.exports=w},72981:function(ae,ne,b){var w=b(38436),k=b(11138);ae.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(re){E.edge(re).minlen*=W});var K=R(E)+1;w.forEach(E.children(),function(re){A(E,N,W,K,P,L,re)}),E.graph().nodeRankFactor=W}function A(E,N,L,P,W,K,re){var ye=E.children(re);if(!ye.length){re!==N&&E.setEdge(N,re,{weight:0,minlen:L});return}var ge=k.addBorderNode(E,"_bt"),ce=k.addBorderNode(E,"_bb"),xe=E.node(re);E.setParent(ge,re),xe.borderTop=ge,E.setParent(ce,re),xe.borderBottom=ce,w.forEach(ye,function(fe){A(E,N,L,P,W,K,fe);var Ne=E.node(fe),Ae=Ne.borderTop?Ne.borderTop:fe,be=Ne.borderBottom?Ne.borderBottom:fe,Ye=Ne.borderTop?P:2*P,Ee=Ae!==be?1:W-K[re]+1;E.setEdge(ge,Ae,{weight:Ye,minlen:Ee,nestingEdge:!0}),E.setEdge(be,ce,{weight:Ye,minlen:Ee,nestingEdge:!0})}),E.parent(re)||E.setEdge(N,ge,{weight:0,minlen:W+K[re]})}function S(E){var N={};function L(P,W){var K=E.children(P);K&&K.length&&w.forEach(K,function(re){L(re,W+1)}),N[P]=W}return w.forEach(E.children(),function(P){L(P,1)}),N}function R(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(ae,ne,b){"use strict";var w=b(38436),k=b(11138);ae.exports={run:O,undo:S};function O(R){R.graph().dummyChains=[],w.forEach(R.edges(),function(x){A(R,x)})}function A(R,x){var E=x.v,N=R.node(E).rank,L=x.w,P=R.node(L).rank,W=x.name,K=R.edge(x),re=K.labelRank;if(P!==N+1){R.removeEdge(x);var ye,ge,ce;for(ce=0,++N;N<P;++ce,++N)K.points=[],ge={width:0,height:0,edgeLabel:K,edgeObj:x,rank:N},ye=k.addDummyNode(R,"edge",ge,"_d"),N===re&&(ge.width=K.width,ge.height=K.height,ge.dummy="edge-label",ge.labelpos=K.labelpos),R.setEdge(E,ye,{weight:K.weight},W),ce===0&&R.graph().dummyChains.push(ye),E=ye;R.setEdge(E,L,{weight:K.weight},W)}}function S(R){w.forEach(R.graph().dummyChains,function(x){var E=R.node(x),N=E.edgeLabel,L;for(R.setEdge(E.edgeObj,N);E.dummy;)L=R.successors(x)[0],R.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=R.node(x)})}},55093:function(ae,ne,b){var w=b(38436);ae.exports=k;function k(O,A,S){var R={},x;w.forEach(S,function(E){for(var N=O.parent(E),L,P;N;){if(L=O.parent(N),L?(P=R[L],R[L]=N):(P=x,x=N),P&&P!==N){A.setEdge(P,N);return}N=L}})}},35439:function(ae,ne,b){var w=b(38436);ae.exports=k;function k(O,A){return w.map(A,function(S){var R=O.inEdges(S);if(R.length){var x=w.reduce(R,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(ae,ne,b){var w=b(38436),k=b(70574).Graph;ae.exports=O;function O(S,R,x){var E=A(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===R||P.minRank<=R&&R<=P.maxRank)&&(N.setNode(L),N.setParent(L,W||E),w.forEach(S[x](L),function(K){var re=K.v===L?K.w:K.v,ye=N.edge(re,L),ge=w.isUndefined(ye)?0:ye.weight;N.setEdge(re,L,{weight:S.edge(K).weight+ge})}),w.has(P,"minRank")&&N.setNode(L,{borderLeft:P.borderLeft[R],borderRight:P.borderRight[R]}))}),N}function A(S){for(var R;S.hasNode(R=w.uniqueId("_root")););return R}},56630:function(ae,ne,b){"use strict";var w=b(38436);ae.exports=k;function k(A,S){for(var R=0,x=1;x<S.length;++x)R+=O(A,S[x-1],S[x]);return R}function O(A,S,R){for(var x=w.zipObject(R,w.map(R,function(K,re){return re})),E=w.flatten(w.map(S,function(K){return w.sortBy(w.map(A.outEdges(K),function(re){return{pos:x[re.w],weight:A.edge(re).weight}}),"pos")}),!0),N=1;N<R.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(K){var re=K.pos+N;P[re]+=K.weight;for(var ye=0;re>0;)re%2&&(ye+=P[re+1]),re=re-1>>1,P[re]+=K.weight;W+=K.weight*ye})),W}},53408:function(ae,ne,b){"use strict";var w=b(38436),k=b(2588),O=b(56630),A=b(61026),S=b(23128),R=b(55093),x=b(70574).Graph,E=b(11138);ae.exports=N;function N(K){var re=E.maxRank(K),ye=L(K,w.range(1,re+1),"inEdges"),ge=L(K,w.range(re-1,-1,-1),"outEdges"),ce=k(K);W(K,ce);for(var xe=Number.POSITIVE_INFINITY,fe,Ne=0,Ae=0;Ae<4;++Ne,++Ae){P(Ne%2?ye:ge,Ne%4>=2),ce=E.buildLayerMatrix(K);var be=O(K,ce);be<xe&&(Ae=0,fe=w.cloneDeep(ce),xe=be)}W(K,fe)}function L(K,re,ye){return w.map(re,function(ge){return S(K,ge,ye)})}function P(K,re){var ye=new x;w.forEach(K,function(ge){var ce=ge.graph().root,xe=A(ge,ce,ye,re);w.forEach(xe.vs,function(fe,Ne){ge.node(fe).order=Ne}),R(ge,ye,xe.vs)})}function W(K,re){w.forEach(re,function(ye){w.forEach(ye,function(ge,ce){K.node(ge).order=ce})})}},2588:function(ae,ne,b){"use strict";var w=b(38436);ae.exports=k;function k(O){var A={},S=w.filter(O.nodes(),function(L){return!O.children(L).length}),R=w.max(w.map(S,function(L){return O.node(L).rank})),x=w.map(w.range(R+1),function(){return[]});function E(L){if(!w.has(A,L)){A[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(ae,ne,b){"use strict";var w=b(38436);ae.exports=k;function k(S,R){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(R.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 R=[];function x(L){return function(P){P.merged||(w.isUndefined(P.barycenter)||w.isUndefined(L.barycenter)||P.barycenter>=L.barycenter)&&A(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();R.push(N),w.forEach(N.in.reverse(),x(N)),w.forEach(N.out,E(N))}return w.map(w.filter(R,function(L){return!L.merged}),function(L){return w.pick(L,["vs","i","barycenter","weight"])})}function A(S,R){var x=0,E=0;S.weight&&(x+=S.barycenter*S.weight,E+=S.weight),R.weight&&(x+=R.barycenter*R.weight,E+=R.weight),S.vs=R.vs.concat(S.vs),S.barycenter=x/E,S.weight=E,S.i=Math.min(R.i,S.i),R.merged=!0}},61026:function(ae,ne,b){var w=b(38436),k=b(35439),O=b(83678),A=b(87304);ae.exports=S;function S(E,N,L,P){var W=E.children(N),K=E.node(N),re=K?K.borderLeft:void 0,ye=K?K.borderRight:void 0,ge={};re&&(W=w.filter(W,function(be){return be!==re&&be!==ye}));var ce=k(E,W);w.forEach(ce,function(be){if(E.children(be.v).length){var Ye=S(E,be.v,L,P);ge[be.v]=Ye,w.has(Ye,"barycenter")&&x(be,Ye)}});var xe=O(ce,L);R(xe,ge);var fe=A(xe,P);if(re&&(fe.vs=w.flatten([re,fe.vs,ye],!0),E.predecessors(re).length)){var Ne=E.node(E.predecessors(re)[0]),Ae=E.node(E.predecessors(ye)[0]);w.has(fe,"barycenter")||(fe.barycenter=0,fe.weight=0),fe.barycenter=(fe.barycenter*fe.weight+Ne.order+Ae.order)/(fe.weight+2),fe.weight+=2}return fe}function R(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(ae,ne,b){var w=b(38436),k=b(11138);ae.exports=O;function O(R,x){var E=k.partition(R,function(ge){return w.has(ge,"barycenter")}),N=E.lhs,L=w.sortBy(E.rhs,function(ge){return-ge.i}),P=[],W=0,K=0,re=0;N.sort(S(!!x)),re=A(P,L,re),w.forEach(N,function(ge){re+=ge.vs.length,P.push(ge.vs),W+=ge.barycenter*ge.weight,K+=ge.weight,re=A(P,L,re)});var ye={vs:w.flatten(P,!0)};return K&&(ye.barycenter=W/K,ye.weight=K),ye}function A(R,x,E){for(var N;x.length&&(N=w.last(x)).i<=E;)x.pop(),R.push(N.vs),E++;return E}function S(R){return function(x,E){return x.barycenter<E.barycenter?-1:x.barycenter>E.barycenter?1:R?E.i-x.i:x.i-E.i}}},24219:function(ae,ne,b){var w=b(38436);ae.exports=k;function k(S){var R=A(S);w.forEach(S.graph().dummyChains,function(x){for(var E=S.node(x),N=E.edgeObj,L=O(S,R,N.v,N.w),P=L.path,W=L.lca,K=0,re=P[K],ye=!0;x!==N.w;){if(E=S.node(x),ye){for(;(re=P[K])!==W&&S.node(re).maxRank<E.rank;)K++;re===W&&(ye=!1)}if(!ye){for(;K<P.length-1&&S.node(re=P[K+1]).minRank<=E.rank;)K++;re=P[K]}S.setParent(x,re),x=S.successors(x)[0]}})}function O(S,R,x,E){var N=[],L=[],P=Math.min(R[x].low,R[E].low),W=Math.max(R[x].lim,R[E].lim),K,re;K=x;do K=S.parent(K),N.push(K);while(K&&(R[K].low>P||W>R[K].lim));for(re=K,K=E;(K=S.parent(K))!==re;)L.push(K);return{path:N.concat(L.reverse()),lca:re}}function A(S){var R={},x=0;function E(N){var L=x;w.forEach(S.children(N),E),R[N]={low:L,lim:x++}}return w.forEach(S.children(),E),R}},3573:function(ae,ne,b){"use strict";var w=b(38436),k=b(70574).Graph,O=b(11138);ae.exports={positionX:ye,findType1Conflicts:A,findType2Conflicts:S,addConflict:x,hasConflict:E,verticalAlignment:N,horizontalCompaction:L,alignCoordinates:K,findSmallestWidthAlignment:W,balance:re};function A(xe,fe){var Ne={};function Ae(be,Ye){var Ee=0,We=0,je=be.length,_t=w.last(Ye);return w.forEach(Ye,function(It,kt){var Ut=R(xe,It),At=Ut?xe.node(Ut).order:je;(Ut||It===_t)&&(w.forEach(Ye.slice(We,kt+1),function(at){w.forEach(xe.predecessors(at),function(Ot){var ue=xe.node(Ot),Ue=ue.order;(Ue<Ee||At<Ue)&&!(ue.dummy&&xe.node(at).dummy)&&x(Ne,Ot,at)})}),We=kt+1,Ee=At)}),Ye}return w.reduce(fe,Ae),Ne}function S(xe,fe){var Ne={};function Ae(Ye,Ee,We,je,_t){var It;w.forEach(w.range(Ee,We),function(kt){It=Ye[kt],xe.node(It).dummy&&w.forEach(xe.predecessors(It),function(Ut){var At=xe.node(Ut);At.dummy&&(At.order<je||At.order>_t)&&x(Ne,Ut,It)})})}function be(Ye,Ee){var We=-1,je,_t=0;return w.forEach(Ee,function(It,kt){if(xe.node(It).dummy==="border"){var Ut=xe.predecessors(It);Ut.length&&(je=xe.node(Ut[0]).order,Ae(Ee,_t,kt,We,je),_t=kt,We=je)}Ae(Ee,_t,Ee.length,je,Ye.length)}),Ee}return w.reduce(fe,be),Ne}function R(xe,fe){if(xe.node(fe).dummy)return w.find(xe.predecessors(fe),function(Ne){return xe.node(Ne).dummy})}function x(xe,fe,Ne){if(fe>Ne){var Ae=fe;fe=Ne,Ne=Ae}var be=xe[fe];be||(xe[fe]=be={}),be[Ne]=!0}function E(xe,fe,Ne){if(fe>Ne){var Ae=fe;fe=Ne,Ne=Ae}return w.has(xe[fe],Ne)}function N(xe,fe,Ne,Ae){var be={},Ye={},Ee={};return w.forEach(fe,function(We){w.forEach(We,function(je,_t){be[je]=je,Ye[je]=je,Ee[je]=_t})}),w.forEach(fe,function(We){var je=-1;w.forEach(We,function(_t){var It=Ae(_t);if(It.length){It=w.sortBy(It,function(Ot){return Ee[Ot]});for(var kt=(It.length-1)/2,Ut=Math.floor(kt),At=Math.ceil(kt);Ut<=At;++Ut){var at=It[Ut];Ye[_t]===_t&&je<Ee[at]&&!E(Ne,_t,at)&&(Ye[at]=_t,Ye[_t]=be[_t]=be[at],je=Ee[at])}}})}),{root:be,align:Ye}}function L(xe,fe,Ne,Ae,be){var Ye={},Ee=P(xe,fe,Ne,be),We=be?"borderLeft":"borderRight";function je(kt,Ut){for(var At=Ee.nodes(),at=At.pop(),Ot={};at;)Ot[at]?kt(at):(Ot[at]=!0,At.push(at),At=At.concat(Ut(at))),at=At.pop()}function _t(kt){Ye[kt]=Ee.inEdges(kt).reduce(function(Ut,At){return Math.max(Ut,Ye[At.v]+Ee.edge(At))},0)}function It(kt){var Ut=Ee.outEdges(kt).reduce(function(at,Ot){return Math.min(at,Ye[Ot.w]-Ee.edge(Ot))},Number.POSITIVE_INFINITY),At=xe.node(kt);Ut!==Number.POSITIVE_INFINITY&&At.borderType!==We&&(Ye[kt]=Math.max(Ye[kt],Ut))}return je(_t,Ee.predecessors.bind(Ee)),je(It,Ee.successors.bind(Ee)),w.forEach(Ae,function(kt){Ye[kt]=Ye[Ne[kt]]}),Ye}function P(xe,fe,Ne,Ae){var be=new k,Ye=xe.graph(),Ee=ge(Ye.nodesep,Ye.edgesep,Ae);return w.forEach(fe,function(We){var je;w.forEach(We,function(_t){var It=Ne[_t];if(be.setNode(It),je){var kt=Ne[je],Ut=be.edge(kt,It);be.setEdge(kt,It,Math.max(Ee(xe,_t,je),Ut||0))}je=_t})}),be}function W(xe,fe){return w.minBy(w.values(fe),function(Ne){var Ae=Number.NEGATIVE_INFINITY,be=Number.POSITIVE_INFINITY;return w.forIn(Ne,function(Ye,Ee){var We=ce(xe,Ee)/2;Ae=Math.max(Ye+We,Ae),be=Math.min(Ye-We,be)}),Ae-be})}function K(xe,fe){var Ne=w.values(fe),Ae=w.min(Ne),be=w.max(Ne);w.forEach(["u","d"],function(Ye){w.forEach(["l","r"],function(Ee){var We=Ye+Ee,je=xe[We],_t;if(je!==fe){var It=w.values(je);_t=Ee==="l"?Ae-w.min(It):be-w.max(It),_t&&(xe[We]=w.mapValues(je,function(kt){return kt+_t}))}})})}function re(xe,fe){return w.mapValues(xe.ul,function(Ne,Ae){if(fe)return xe[fe.toLowerCase()][Ae];var be=w.sortBy(w.map(xe,Ae));return(be[1]+be[2])/2})}function ye(xe){var fe=O.buildLayerMatrix(xe),Ne=w.merge(A(xe,fe),S(xe,fe)),Ae={},be;w.forEach(["u","d"],function(Ee){be=Ee==="u"?fe:w.values(fe).reverse(),w.forEach(["l","r"],function(We){We==="r"&&(be=w.map(be,function(kt){return w.values(kt).reverse()}));var je=(Ee==="u"?xe.predecessors:xe.successors).bind(xe),_t=N(xe,be,Ne,je),It=L(xe,be,_t.root,_t.align,We==="r");We==="r"&&(It=w.mapValues(It,function(kt){return-kt})),Ae[Ee+We]=It})});var Ye=W(xe,Ae);return K(Ae,Ye),re(Ae,xe.graph().align)}function ge(xe,fe,Ne){return function(Ae,be,Ye){var Ee=Ae.node(be),We=Ae.node(Ye),je=0,_t;if(je+=Ee.width/2,w.has(Ee,"labelpos"))switch(Ee.labelpos.toLowerCase()){case"l":_t=-Ee.width/2;break;case"r":_t=Ee.width/2;break}if(_t&&(je+=Ne?_t:-_t),_t=0,je+=(Ee.dummy?fe:xe)/2,je+=(We.dummy?fe:xe)/2,je+=We.width/2,w.has(We,"labelpos"))switch(We.labelpos.toLowerCase()){case"l":_t=We.width/2;break;case"r":_t=-We.width/2;break}return _t&&(je+=Ne?_t:-_t),_t=0,je}}function ce(xe,fe){return xe.node(fe).width}},17873:function(ae,ne,b){"use strict";var w=b(38436),k=b(11138),O=b(3573).positionX;ae.exports=A;function A(R){R=k.asNonCompoundGraph(R),S(R),w.forEach(O(R),function(x,E){R.node(E).x=x})}function S(R){var x=k.buildLayerMatrix(R),E=R.graph().ranksep,N=0;w.forEach(x,function(L){var P=w.max(w.map(L,function(W){return R.node(W).height}));w.forEach(L,function(W){R.node(W).y=N+P/2}),N+=P+E})}},20300:function(ae,ne,b){"use strict";var w=b(38436),k=b(70574).Graph,O=b(76681).slack;ae.exports=A;function A(E){var N=new k({directed:!1}),L=E.nodes()[0],P=E.nodeCount();N.setNode(L,{});for(var W,K;S(N,E)<P;)W=R(N,E),K=N.hasNode(W.v)?O(E,W):-O(E,W),x(N,E,K);return N}function S(E,N){function L(P){w.forEach(N.nodeEdges(P),function(W){var K=W.v,re=P===K?W.w:K;!E.hasNode(re)&&!O(N,W)&&(E.setNode(re,{}),E.setEdge(P,re,{}),L(re))})}return w.forEach(E.nodes(),L),E.nodeCount()}function R(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(ae,ne,b){"use strict";var w=b(76681),k=w.longestPath,O=b(20300),A=b(42472);ae.exports=S;function S(N){switch(N.graph().ranker){case"network-simplex":E(N);break;case"tight-tree":x(N);break;case"longest-path":R(N);break;default:E(N)}}var R=k;function x(N){k(N),O(N)}function E(N){A(N)}},42472:function(ae,ne,b){"use strict";var w=b(38436),k=b(20300),O=b(76681).slack,A=b(76681).longestPath,S=b(70574).alg.preorder,R=b(70574).alg.postorder,x=b(11138).simplify;ae.exports=E,E.initLowLimValues=W,E.initCutValues=N,E.calcCutValue=P,E.leaveEdge=re,E.enterEdge=ye,E.exchangeEdges=ge;function E(Ne){Ne=x(Ne),A(Ne);var Ae=k(Ne);W(Ae),N(Ae,Ne);for(var be,Ye;be=re(Ae);)Ye=ye(Ae,Ne,be),ge(Ae,Ne,be,Ye)}function N(Ne,Ae){var be=R(Ne,Ne.nodes());be=be.slice(0,be.length-1),w.forEach(be,function(Ye){L(Ne,Ae,Ye)})}function L(Ne,Ae,be){var Ye=Ne.node(be),Ee=Ye.parent;Ne.edge(be,Ee).cutvalue=P(Ne,Ae,be)}function P(Ne,Ae,be){var Ye=Ne.node(be),Ee=Ye.parent,We=!0,je=Ae.edge(be,Ee),_t=0;return je||(We=!1,je=Ae.edge(Ee,be)),_t=je.weight,w.forEach(Ae.nodeEdges(be),function(It){var kt=It.v===be,Ut=kt?It.w:It.v;if(Ut!==Ee){var At=kt===We,at=Ae.edge(It).weight;if(_t+=At?at:-at,xe(Ne,be,Ut)){var Ot=Ne.edge(be,Ut).cutvalue;_t+=At?-Ot:Ot}}}),_t}function W(Ne,Ae){arguments.length<2&&(Ae=Ne.nodes()[0]),K(Ne,{},1,Ae)}function K(Ne,Ae,be,Ye,Ee){var We=be,je=Ne.node(Ye);return Ae[Ye]=!0,w.forEach(Ne.neighbors(Ye),function(_t){w.has(Ae,_t)||(be=K(Ne,Ae,be,_t,Ye))}),je.low=We,je.lim=be++,Ee?je.parent=Ee:delete je.parent,be}function re(Ne){return w.find(Ne.edges(),function(Ae){return Ne.edge(Ae).cutvalue<0})}function ye(Ne,Ae,be){var Ye=be.v,Ee=be.w;Ae.hasEdge(Ye,Ee)||(Ye=be.w,Ee=be.v);var We=Ne.node(Ye),je=Ne.node(Ee),_t=We,It=!1;We.lim>je.lim&&(_t=je,It=!0);var kt=w.filter(Ae.edges(),function(Ut){return It===fe(Ne,Ne.node(Ut.v),_t)&&It!==fe(Ne,Ne.node(Ut.w),_t)});return w.minBy(kt,function(Ut){return O(Ae,Ut)})}function ge(Ne,Ae,be,Ye){var Ee=be.v,We=be.w;Ne.removeEdge(Ee,We),Ne.setEdge(Ye.v,Ye.w,{}),W(Ne),N(Ne,Ae),ce(Ne,Ae)}function ce(Ne,Ae){var be=w.find(Ne.nodes(),function(Ee){return!Ae.node(Ee).parent}),Ye=S(Ne,be);Ye=Ye.slice(1),w.forEach(Ye,function(Ee){var We=Ne.node(Ee).parent,je=Ae.edge(Ee,We),_t=!1;je||(je=Ae.edge(We,Ee),_t=!0),Ae.node(Ee).rank=Ae.node(We).rank+(_t?je.minlen:-je.minlen)})}function xe(Ne,Ae,be){return Ne.hasEdge(Ae,be)}function fe(Ne,Ae,be){return be.low<=Ae.lim&&Ae.lim<=be.lim}},76681:function(ae,ne,b){"use strict";var w=b(38436);ae.exports={longestPath:k,slack:O};function k(A){var S={};function R(x){var E=A.node(x);if(w.has(S,x))return E.rank;S[x]=!0;var N=w.min(w.map(A.outEdges(x),function(L){return R(L.w)-A.edge(L).minlen}));return(N===Number.POSITIVE_INFINITY||N===void 0||N===null)&&(N=0),E.rank=N}w.forEach(A.sources(),R)}function O(A,S){return A.node(S.w).rank-A.node(S.v).rank-A.edge(S).minlen}},11138:function(ae,ne,b){"use strict";var w=b(38436),k=b(70574).Graph;ae.exports={addDummyNode:O,simplify:A,asNonCompoundGraph:S,successorWeights:R,predecessorWeights:x,intersectRect:E,buildLayerMatrix:N,normalizeRanks:L,removeEmptyRanks:P,addBorderNode:W,maxRank:K,partition:re,time:ye,notime:ge};function O(ce,xe,fe,Ne){var Ae;do Ae=w.uniqueId(Ne);while(ce.hasNode(Ae));return fe.dummy=xe,ce.setNode(Ae,fe),Ae}function A(ce){var xe=new k().setGraph(ce.graph());return w.forEach(ce.nodes(),function(fe){xe.setNode(fe,ce.node(fe))}),w.forEach(ce.edges(),function(fe){var Ne=xe.edge(fe.v,fe.w)||{weight:0,minlen:1},Ae=ce.edge(fe);xe.setEdge(fe.v,fe.w,{weight:Ne.weight+Ae.weight,minlen:Math.max(Ne.minlen,Ae.minlen)})}),xe}function S(ce){var xe=new k({multigraph:ce.isMultigraph()}).setGraph(ce.graph());return w.forEach(ce.nodes(),function(fe){ce.children(fe).length||xe.setNode(fe,ce.node(fe))}),w.forEach(ce.edges(),function(fe){xe.setEdge(fe,ce.edge(fe))}),xe}function R(ce){var xe=w.map(ce.nodes(),function(fe){var Ne={};return w.forEach(ce.outEdges(fe),function(Ae){Ne[Ae.w]=(Ne[Ae.w]||0)+ce.edge(Ae).weight}),Ne});return w.zipObject(ce.nodes(),xe)}function x(ce){var xe=w.map(ce.nodes(),function(fe){var Ne={};return w.forEach(ce.inEdges(fe),function(Ae){Ne[Ae.v]=(Ne[Ae.v]||0)+ce.edge(Ae).weight}),Ne});return w.zipObject(ce.nodes(),xe)}function E(ce,xe){var fe=ce.x,Ne=ce.y,Ae=xe.x-fe,be=xe.y-Ne,Ye=ce.width/2,Ee=ce.height/2;if(!Ae&&!be)throw new Error("Not possible to find intersection inside of the rectangle");var We,je;return Math.abs(be)*Ye>Math.abs(Ae)*Ee?(be<0&&(Ee=-Ee),We=Ee*Ae/be,je=Ee):(Ae<0&&(Ye=-Ye),We=Ye,je=Ye*be/Ae),{x:fe+We,y:Ne+je}}function N(ce){var xe=w.map(w.range(K(ce)+1),function(){return[]});return w.forEach(ce.nodes(),function(fe){var Ne=ce.node(fe),Ae=Ne.rank;w.isUndefined(Ae)||(xe[Ae][Ne.order]=fe)}),xe}function L(ce){var xe=w.min(w.map(ce.nodes(),function(fe){return ce.node(fe).rank}));w.forEach(ce.nodes(),function(fe){var Ne=ce.node(fe);w.has(Ne,"rank")&&(Ne.rank-=xe)})}function P(ce){var xe=w.min(w.map(ce.nodes(),function(be){return ce.node(be).rank})),fe=[];w.forEach(ce.nodes(),function(be){var Ye=ce.node(be).rank-xe;fe[Ye]||(fe[Ye]=[]),fe[Ye].push(be)});var Ne=0,Ae=ce.graph().nodeRankFactor;w.forEach(fe,function(be,Ye){w.isUndefined(be)&&Ye%Ae!==0?--Ne:Ne&&w.forEach(be,function(Ee){ce.node(Ee).rank+=Ne})})}function W(ce,xe,fe,Ne){var Ae={width:0,height:0};return arguments.length>=4&&(Ae.rank=fe,Ae.order=Ne),O(ce,"border",Ae,xe)}function K(ce){return w.max(w.map(ce.nodes(),function(xe){var fe=ce.node(xe).rank;if(!w.isUndefined(fe))return fe}))}function re(ce,xe){var fe={lhs:[],rhs:[]};return w.forEach(ce,function(Ne){xe(Ne)?fe.lhs.push(Ne):fe.rhs.push(Ne)}),fe}function ye(ce,xe){var fe=w.now();try{return xe()}finally{console.log(ce+" time: "+(w.now()-fe)+"ms")}}function ge(ce,xe){return xe()}},88177:function(ae){ae.exports="0.8.5"},26729:function(ae){"use strict";var ne=Object.prototype.hasOwnProperty,b="~";function w(){}Object.create&&(w.prototype=Object.create(null),new w().__proto__||(b=!1));function k(R,x,E){this.fn=R,this.context=x,this.once=E||!1}function O(R,x,E,N,L){if(typeof E!="function")throw new TypeError("The listener must be a function");var P=new k(E,N||R,L),W=b?b+x:x;return R._events[W]?R._events[W].fn?R._events[W]=[R._events[W],P]:R._events[W].push(P):(R._events[W]=P,R._eventsCount++),R}function A(R,x){--R._eventsCount===0?R._events=new w:delete R._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)ne.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 K=b?b+x:x;if(!this._events[K])return!1;var re=this._events[K],ye=arguments.length,ge,ce;if(re.fn){switch(re.once&&this.removeListener(x,re.fn,void 0,!0),ye){case 1:return re.fn.call(re.context),!0;case 2:return re.fn.call(re.context,E),!0;case 3:return re.fn.call(re.context,E,N),!0;case 4:return re.fn.call(re.context,E,N,L),!0;case 5:return re.fn.call(re.context,E,N,L,P),!0;case 6:return re.fn.call(re.context,E,N,L,P,W),!0}for(ce=1,ge=new Array(ye-1);ce<ye;ce++)ge[ce-1]=arguments[ce];re.fn.apply(re.context,ge)}else{var xe=re.length,fe;for(ce=0;ce<xe;ce++)switch(re[ce].once&&this.removeListener(x,re[ce].fn,void 0,!0),ye){case 1:re[ce].fn.call(re[ce].context);break;case 2:re[ce].fn.call(re[ce].context,E);break;case 3:re[ce].fn.call(re[ce].context,E,N);break;case 4:re[ce].fn.call(re[ce].context,E,N,L);break;default:if(!ge)for(fe=1,ge=new Array(ye-1);fe<ye;fe++)ge[fe-1]=arguments[fe];re[ce].fn.apply(re[ce].context,ge)}}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 A(this,P),this;var W=this._events[P];if(W.fn)W.fn===E&&(!L||W.once)&&(!N||W.context===N)&&A(this,P);else{for(var K=0,re=[],ye=W.length;K<ye;K++)(W[K].fn!==E||L&&!W[K].once||N&&W[K].context!==N)&&re.push(W[K]);re.length?this._events[P]=re.length===1?re[0]:re:A(this,P)}return this},S.prototype.removeAllListeners=function(x){var E;return x?(E=b?b+x:x,this._events[E]&&A(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,ae.exports=S},49685:function(ae,ne,b){"use strict";b.d(ne,{Ib:function(){return w},WT:function(){return k}});var w=1e-6,k=typeof Float32Array!="undefined"?Float32Array:Array,O=Math.random;function A(E){k=E}var S=Math.PI/180;function R(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(ae,ne,b){"use strict";b.d(ne,{Ue:function(){return k},al:function(){return R},xO:function(){return O}});var w=b(49685);function k(){var ue=new w.WT(9);return w.WT!=Float32Array&&(ue[1]=0,ue[2]=0,ue[3]=0,ue[5]=0,ue[6]=0,ue[7]=0),ue[0]=1,ue[4]=1,ue[8]=1,ue}function O(ue,Ue){return ue[0]=Ue[0],ue[1]=Ue[1],ue[2]=Ue[2],ue[3]=Ue[4],ue[4]=Ue[5],ue[5]=Ue[6],ue[6]=Ue[8],ue[7]=Ue[9],ue[8]=Ue[10],ue}function A(ue){var Ue=new glMatrix.ARRAY_TYPE(9);return Ue[0]=ue[0],Ue[1]=ue[1],Ue[2]=ue[2],Ue[3]=ue[3],Ue[4]=ue[4],Ue[5]=ue[5],Ue[6]=ue[6],Ue[7]=ue[7],Ue[8]=ue[8],Ue}function S(ue,Ue){return ue[0]=Ue[0],ue[1]=Ue[1],ue[2]=Ue[2],ue[3]=Ue[3],ue[4]=Ue[4],ue[5]=Ue[5],ue[6]=Ue[6],ue[7]=Ue[7],ue[8]=Ue[8],ue}function R(ue,Ue,vt,Jt,Qe,rt,bt,ze,Ze){var q=new w.WT(9);return q[0]=ue,q[1]=Ue,q[2]=vt,q[3]=Jt,q[4]=Qe,q[5]=rt,q[6]=bt,q[7]=ze,q[8]=Ze,q}function x(ue,Ue,vt,Jt,Qe,rt,bt,ze,Ze,q){return ue[0]=Ue,ue[1]=vt,ue[2]=Jt,ue[3]=Qe,ue[4]=rt,ue[5]=bt,ue[6]=ze,ue[7]=Ze,ue[8]=q,ue}function E(ue){return ue[0]=1,ue[1]=0,ue[2]=0,ue[3]=0,ue[4]=1,ue[5]=0,ue[6]=0,ue[7]=0,ue[8]=1,ue}function N(ue,Ue){if(ue===Ue){var vt=Ue[1],Jt=Ue[2],Qe=Ue[5];ue[1]=Ue[3],ue[2]=Ue[6],ue[3]=vt,ue[5]=Ue[7],ue[6]=Jt,ue[7]=Qe}else ue[0]=Ue[0],ue[1]=Ue[3],ue[2]=Ue[6],ue[3]=Ue[1],ue[4]=Ue[4],ue[5]=Ue[7],ue[6]=Ue[2],ue[7]=Ue[5],ue[8]=Ue[8];return ue}function L(ue,Ue){var vt=Ue[0],Jt=Ue[1],Qe=Ue[2],rt=Ue[3],bt=Ue[4],ze=Ue[5],Ze=Ue[6],q=Ue[7],Y=Ue[8],de=Y*bt-ze*q,Je=-Y*rt+ze*Ze,Te=q*rt-bt*Ze,$e=vt*de+Jt*Je+Qe*Te;return $e?($e=1/$e,ue[0]=de*$e,ue[1]=(-Y*Jt+Qe*q)*$e,ue[2]=(ze*Jt-Qe*bt)*$e,ue[3]=Je*$e,ue[4]=(Y*vt-Qe*Ze)*$e,ue[5]=(-ze*vt+Qe*rt)*$e,ue[6]=Te*$e,ue[7]=(-q*vt+Jt*Ze)*$e,ue[8]=(bt*vt-Jt*rt)*$e,ue):null}function P(ue,Ue){var vt=Ue[0],Jt=Ue[1],Qe=Ue[2],rt=Ue[3],bt=Ue[4],ze=Ue[5],Ze=Ue[6],q=Ue[7],Y=Ue[8];return ue[0]=bt*Y-ze*q,ue[1]=Qe*q-Jt*Y,ue[2]=Jt*ze-Qe*bt,ue[3]=ze*Ze-rt*Y,ue[4]=vt*Y-Qe*Ze,ue[5]=Qe*rt-vt*ze,ue[6]=rt*q-bt*Ze,ue[7]=Jt*Ze-vt*q,ue[8]=vt*bt-Jt*rt,ue}function W(ue){var Ue=ue[0],vt=ue[1],Jt=ue[2],Qe=ue[3],rt=ue[4],bt=ue[5],ze=ue[6],Ze=ue[7],q=ue[8];return Ue*(q*rt-bt*Ze)+vt*(-q*Qe+bt*ze)+Jt*(Ze*Qe-rt*ze)}function K(ue,Ue,vt){var Jt=Ue[0],Qe=Ue[1],rt=Ue[2],bt=Ue[3],ze=Ue[4],Ze=Ue[5],q=Ue[6],Y=Ue[7],de=Ue[8],Je=vt[0],Te=vt[1],$e=vt[2],xt=vt[3],ke=vt[4],et=vt[5],yt=vt[6],B=vt[7],ie=vt[8];return ue[0]=Je*Jt+Te*bt+$e*q,ue[1]=Je*Qe+Te*ze+$e*Y,ue[2]=Je*rt+Te*Ze+$e*de,ue[3]=xt*Jt+ke*bt+et*q,ue[4]=xt*Qe+ke*ze+et*Y,ue[5]=xt*rt+ke*Ze+et*de,ue[6]=yt*Jt+B*bt+ie*q,ue[7]=yt*Qe+B*ze+ie*Y,ue[8]=yt*rt+B*Ze+ie*de,ue}function re(ue,Ue,vt){var Jt=Ue[0],Qe=Ue[1],rt=Ue[2],bt=Ue[3],ze=Ue[4],Ze=Ue[5],q=Ue[6],Y=Ue[7],de=Ue[8],Je=vt[0],Te=vt[1];return ue[0]=Jt,ue[1]=Qe,ue[2]=rt,ue[3]=bt,ue[4]=ze,ue[5]=Ze,ue[6]=Je*Jt+Te*bt+q,ue[7]=Je*Qe+Te*ze+Y,ue[8]=Je*rt+Te*Ze+de,ue}function ye(ue,Ue,vt){var Jt=Ue[0],Qe=Ue[1],rt=Ue[2],bt=Ue[3],ze=Ue[4],Ze=Ue[5],q=Ue[6],Y=Ue[7],de=Ue[8],Je=Math.sin(vt),Te=Math.cos(vt);return ue[0]=Te*Jt+Je*bt,ue[1]=Te*Qe+Je*ze,ue[2]=Te*rt+Je*Ze,ue[3]=Te*bt-Je*Jt,ue[4]=Te*ze-Je*Qe,ue[5]=Te*Ze-Je*rt,ue[6]=q,ue[7]=Y,ue[8]=de,ue}function ge(ue,Ue,vt){var Jt=vt[0],Qe=vt[1];return ue[0]=Jt*Ue[0],ue[1]=Jt*Ue[1],ue[2]=Jt*Ue[2],ue[3]=Qe*Ue[3],ue[4]=Qe*Ue[4],ue[5]=Qe*Ue[5],ue[6]=Ue[6],ue[7]=Ue[7],ue[8]=Ue[8],ue}function ce(ue,Ue){return ue[0]=1,ue[1]=0,ue[2]=0,ue[3]=0,ue[4]=1,ue[5]=0,ue[6]=Ue[0],ue[7]=Ue[1],ue[8]=1,ue}function xe(ue,Ue){var vt=Math.sin(Ue),Jt=Math.cos(Ue);return ue[0]=Jt,ue[1]=vt,ue[2]=0,ue[3]=-vt,ue[4]=Jt,ue[5]=0,ue[6]=0,ue[7]=0,ue[8]=1,ue}function fe(ue,Ue){return ue[0]=Ue[0],ue[1]=0,ue[2]=0,ue[3]=0,ue[4]=Ue[1],ue[5]=0,ue[6]=0,ue[7]=0,ue[8]=1,ue}function Ne(ue,Ue){return ue[0]=Ue[0],ue[1]=Ue[1],ue[2]=0,ue[3]=Ue[2],ue[4]=Ue[3],ue[5]=0,ue[6]=Ue[4],ue[7]=Ue[5],ue[8]=1,ue}function Ae(ue,Ue){var vt=Ue[0],Jt=Ue[1],Qe=Ue[2],rt=Ue[3],bt=vt+vt,ze=Jt+Jt,Ze=Qe+Qe,q=vt*bt,Y=Jt*bt,de=Jt*ze,Je=Qe*bt,Te=Qe*ze,$e=Qe*Ze,xt=rt*bt,ke=rt*ze,et=rt*Ze;return ue[0]=1-de-$e,ue[3]=Y-et,ue[6]=Je+ke,ue[1]=Y+et,ue[4]=1-q-$e,ue[7]=Te-xt,ue[2]=Je-ke,ue[5]=Te+xt,ue[8]=1-q-de,ue}function be(ue,Ue){var vt=Ue[0],Jt=Ue[1],Qe=Ue[2],rt=Ue[3],bt=Ue[4],ze=Ue[5],Ze=Ue[6],q=Ue[7],Y=Ue[8],de=Ue[9],Je=Ue[10],Te=Ue[11],$e=Ue[12],xt=Ue[13],ke=Ue[14],et=Ue[15],yt=vt*ze-Jt*bt,B=vt*Ze-Qe*bt,ie=vt*q-rt*bt,ct=Jt*Ze-Qe*ze,Mt=Jt*q-rt*ze,ht=Qe*q-rt*Ze,Yt=Y*xt-de*$e,en=Y*ke-Je*$e,nn=Y*et-Te*$e,Me=de*ke-Je*xt,te=de*et-Te*xt,Fe=Je*et-Te*ke,Xe=yt*Fe-B*te+ie*Me+ct*nn-Mt*en+ht*Yt;return Xe?(Xe=1/Xe,ue[0]=(ze*Fe-Ze*te+q*Me)*Xe,ue[1]=(Ze*nn-bt*Fe-q*en)*Xe,ue[2]=(bt*te-ze*nn+q*Yt)*Xe,ue[3]=(Qe*te-Jt*Fe-rt*Me)*Xe,ue[4]=(vt*Fe-Qe*nn+rt*en)*Xe,ue[5]=(Jt*nn-vt*te-rt*Yt)*Xe,ue[6]=(xt*ht-ke*Mt+et*ct)*Xe,ue[7]=(ke*ie-$e*ht-et*B)*Xe,ue[8]=($e*Mt-xt*ie+et*yt)*Xe,ue):null}function Ye(ue,Ue,vt){return ue[0]=2/Ue,ue[1]=0,ue[2]=0,ue[3]=0,ue[4]=-2/vt,ue[5]=0,ue[6]=-1,ue[7]=1,ue[8]=1,ue}function Ee(ue){return"mat3("+ue[0]+", "+ue[1]+", "+ue[2]+", "+ue[3]+", "+ue[4]+", "+ue[5]+", "+ue[6]+", "+ue[7]+", "+ue[8]+")"}function We(ue){return Math.hypot(ue[0],ue[1],ue[2],ue[3],ue[4],ue[5],ue[6],ue[7],ue[8])}function je(ue,Ue,vt){return ue[0]=Ue[0]+vt[0],ue[1]=Ue[1]+vt[1],ue[2]=Ue[2]+vt[2],ue[3]=Ue[3]+vt[3],ue[4]=Ue[4]+vt[4],ue[5]=Ue[5]+vt[5],ue[6]=Ue[6]+vt[6],ue[7]=Ue[7]+vt[7],ue[8]=Ue[8]+vt[8],ue}function _t(ue,Ue,vt){return ue[0]=Ue[0]-vt[0],ue[1]=Ue[1]-vt[1],ue[2]=Ue[2]-vt[2],ue[3]=Ue[3]-vt[3],ue[4]=Ue[4]-vt[4],ue[5]=Ue[5]-vt[5],ue[6]=Ue[6]-vt[6],ue[7]=Ue[7]-vt[7],ue[8]=Ue[8]-vt[8],ue}function It(ue,Ue,vt){return ue[0]=Ue[0]*vt,ue[1]=Ue[1]*vt,ue[2]=Ue[2]*vt,ue[3]=Ue[3]*vt,ue[4]=Ue[4]*vt,ue[5]=Ue[5]*vt,ue[6]=Ue[6]*vt,ue[7]=Ue[7]*vt,ue[8]=Ue[8]*vt,ue}function kt(ue,Ue,vt,Jt){return ue[0]=Ue[0]+vt[0]*Jt,ue[1]=Ue[1]+vt[1]*Jt,ue[2]=Ue[2]+vt[2]*Jt,ue[3]=Ue[3]+vt[3]*Jt,ue[4]=Ue[4]+vt[4]*Jt,ue[5]=Ue[5]+vt[5]*Jt,ue[6]=Ue[6]+vt[6]*Jt,ue[7]=Ue[7]+vt[7]*Jt,ue[8]=Ue[8]+vt[8]*Jt,ue}function Ut(ue,Ue){return ue[0]===Ue[0]&&ue[1]===Ue[1]&&ue[2]===Ue[2]&&ue[3]===Ue[3]&&ue[4]===Ue[4]&&ue[5]===Ue[5]&&ue[6]===Ue[6]&&ue[7]===Ue[7]&&ue[8]===Ue[8]}function At(ue,Ue){var vt=ue[0],Jt=ue[1],Qe=ue[2],rt=ue[3],bt=ue[4],ze=ue[5],Ze=ue[6],q=ue[7],Y=ue[8],de=Ue[0],Je=Ue[1],Te=Ue[2],$e=Ue[3],xt=Ue[4],ke=Ue[5],et=Ue[6],yt=Ue[7],B=Ue[8];return Math.abs(vt-de)<=glMatrix.EPSILON*Math.max(1,Math.abs(vt),Math.abs(de))&&Math.abs(Jt-Je)<=glMatrix.EPSILON*Math.max(1,Math.abs(Jt),Math.abs(Je))&&Math.abs(Qe-Te)<=glMatrix.EPSILON*Math.max(1,Math.abs(Qe),Math.abs(Te))&&Math.abs(rt-$e)<=glMatrix.EPSILON*Math.max(1,Math.abs(rt),Math.abs($e))&&Math.abs(bt-xt)<=glMatrix.EPSILON*Math.max(1,Math.abs(bt),Math.abs(xt))&&Math.abs(ze-ke)<=glMatrix.EPSILON*Math.max(1,Math.abs(ze),Math.abs(ke))&&Math.abs(Ze-et)<=glMatrix.EPSILON*Math.max(1,Math.abs(Ze),Math.abs(et))&&Math.abs(q-yt)<=glMatrix.EPSILON*Math.max(1,Math.abs(q),Math.abs(yt))&&Math.abs(Y-B)<=glMatrix.EPSILON*Math.max(1,Math.abs(Y),Math.abs(B))}var at=null,Ot=null},85975:function(ae,ne,b){"use strict";b.r(ne),b.d(ne,{add:function(){return de},adjoint:function(){return L},clone:function(){return O},copy:function(){return A},create:function(){return k},determinant:function(){return P},equals:function(){return ke},exactEquals:function(){return xt},frob:function(){return Y},fromQuat:function(){return at},fromQuat2:function(){return je},fromRotation:function(){return Ae},fromRotationTranslation:function(){return We},fromRotationTranslationScale:function(){return Ut},fromRotationTranslationScaleOrigin:function(){return At},fromScaling:function(){return Ne},fromTranslation:function(){return fe},fromValues:function(){return S},fromXRotation:function(){return be},fromYRotation:function(){return Ye},fromZRotation:function(){return Ee},frustum:function(){return Ot},getRotation:function(){return kt},getScaling:function(){return It},getTranslation:function(){return _t},identity:function(){return x},invert:function(){return N},lookAt:function(){return ze},mul:function(){return et},multiply:function(){return W},multiplyScalar:function(){return Te},multiplyScalarAndAdd:function(){return $e},ortho:function(){return rt},orthoNO:function(){return Qe},orthoZO:function(){return bt},perspective:function(){return Ue},perspectiveFromFieldOfView:function(){return Jt},perspectiveNO:function(){return ue},perspectiveZO:function(){return vt},rotate:function(){return ye},rotateX:function(){return ge},rotateY:function(){return ce},rotateZ:function(){return xe},scale:function(){return re},set:function(){return R},str:function(){return q},sub:function(){return yt},subtract:function(){return Je},targetTo:function(){return Ze},translate:function(){return K},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 ie=new w.WT(16);return ie[0]=B[0],ie[1]=B[1],ie[2]=B[2],ie[3]=B[3],ie[4]=B[4],ie[5]=B[5],ie[6]=B[6],ie[7]=B[7],ie[8]=B[8],ie[9]=B[9],ie[10]=B[10],ie[11]=B[11],ie[12]=B[12],ie[13]=B[13],ie[14]=B[14],ie[15]=B[15],ie}function A(B,ie){return B[0]=ie[0],B[1]=ie[1],B[2]=ie[2],B[3]=ie[3],B[4]=ie[4],B[5]=ie[5],B[6]=ie[6],B[7]=ie[7],B[8]=ie[8],B[9]=ie[9],B[10]=ie[10],B[11]=ie[11],B[12]=ie[12],B[13]=ie[13],B[14]=ie[14],B[15]=ie[15],B}function S(B,ie,ct,Mt,ht,Yt,en,nn,Me,te,Fe,Xe,Pe,Ie,Ke,lt){var qe=new w.WT(16);return qe[0]=B,qe[1]=ie,qe[2]=ct,qe[3]=Mt,qe[4]=ht,qe[5]=Yt,qe[6]=en,qe[7]=nn,qe[8]=Me,qe[9]=te,qe[10]=Fe,qe[11]=Xe,qe[12]=Pe,qe[13]=Ie,qe[14]=Ke,qe[15]=lt,qe}function R(B,ie,ct,Mt,ht,Yt,en,nn,Me,te,Fe,Xe,Pe,Ie,Ke,lt,qe){return B[0]=ie,B[1]=ct,B[2]=Mt,B[3]=ht,B[4]=Yt,B[5]=en,B[6]=nn,B[7]=Me,B[8]=te,B[9]=Fe,B[10]=Xe,B[11]=Pe,B[12]=Ie,B[13]=Ke,B[14]=lt,B[15]=qe,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,ie){if(B===ie){var ct=ie[1],Mt=ie[2],ht=ie[3],Yt=ie[6],en=ie[7],nn=ie[11];B[1]=ie[4],B[2]=ie[8],B[3]=ie[12],B[4]=ct,B[6]=ie[9],B[7]=ie[13],B[8]=Mt,B[9]=Yt,B[11]=ie[14],B[12]=ht,B[13]=en,B[14]=nn}else B[0]=ie[0],B[1]=ie[4],B[2]=ie[8],B[3]=ie[12],B[4]=ie[1],B[5]=ie[5],B[6]=ie[9],B[7]=ie[13],B[8]=ie[2],B[9]=ie[6],B[10]=ie[10],B[11]=ie[14],B[12]=ie[3],B[13]=ie[7],B[14]=ie[11],B[15]=ie[15];return B}function N(B,ie){var ct=ie[0],Mt=ie[1],ht=ie[2],Yt=ie[3],en=ie[4],nn=ie[5],Me=ie[6],te=ie[7],Fe=ie[8],Xe=ie[9],Pe=ie[10],Ie=ie[11],Ke=ie[12],lt=ie[13],qe=ie[14],pt=ie[15],Ct=ct*nn-Mt*en,Xt=ct*Me-ht*en,Qt=ct*te-Yt*en,pn=Mt*Me-ht*nn,Wn=Mt*te-Yt*nn,Rn=ht*te-Yt*Me,bi=Fe*lt-Xe*Ke,Lr=Fe*qe-Pe*Ke,Qn=Fe*pt-Ie*Ke,Vi=Xe*qe-Pe*lt,Oi=Xe*pt-Ie*lt,Gi=Pe*pt-Ie*qe,ir=Ct*Gi-Xt*Oi+Qt*Vi+pn*Qn-Wn*Lr+Rn*bi;return ir?(ir=1/ir,B[0]=(nn*Gi-Me*Oi+te*Vi)*ir,B[1]=(ht*Oi-Mt*Gi-Yt*Vi)*ir,B[2]=(lt*Rn-qe*Wn+pt*pn)*ir,B[3]=(Pe*Wn-Xe*Rn-Ie*pn)*ir,B[4]=(Me*Qn-en*Gi-te*Lr)*ir,B[5]=(ct*Gi-ht*Qn+Yt*Lr)*ir,B[6]=(qe*Qt-Ke*Rn-pt*Xt)*ir,B[7]=(Fe*Rn-Pe*Qt+Ie*Xt)*ir,B[8]=(en*Oi-nn*Qn+te*bi)*ir,B[9]=(Mt*Qn-ct*Oi-Yt*bi)*ir,B[10]=(Ke*Wn-lt*Qt+pt*Ct)*ir,B[11]=(Xe*Qt-Fe*Wn-Ie*Ct)*ir,B[12]=(nn*Lr-en*Vi-Me*bi)*ir,B[13]=(ct*Vi-Mt*Lr+ht*bi)*ir,B[14]=(lt*Xt-Ke*pn-qe*Ct)*ir,B[15]=(Fe*pn-Xe*Xt+Pe*Ct)*ir,B):null}function L(B,ie){var ct=ie[0],Mt=ie[1],ht=ie[2],Yt=ie[3],en=ie[4],nn=ie[5],Me=ie[6],te=ie[7],Fe=ie[8],Xe=ie[9],Pe=ie[10],Ie=ie[11],Ke=ie[12],lt=ie[13],qe=ie[14],pt=ie[15];return B[0]=nn*(Pe*pt-Ie*qe)-Xe*(Me*pt-te*qe)+lt*(Me*Ie-te*Pe),B[1]=-(Mt*(Pe*pt-Ie*qe)-Xe*(ht*pt-Yt*qe)+lt*(ht*Ie-Yt*Pe)),B[2]=Mt*(Me*pt-te*qe)-nn*(ht*pt-Yt*qe)+lt*(ht*te-Yt*Me),B[3]=-(Mt*(Me*Ie-te*Pe)-nn*(ht*Ie-Yt*Pe)+Xe*(ht*te-Yt*Me)),B[4]=-(en*(Pe*pt-Ie*qe)-Fe*(Me*pt-te*qe)+Ke*(Me*Ie-te*Pe)),B[5]=ct*(Pe*pt-Ie*qe)-Fe*(ht*pt-Yt*qe)+Ke*(ht*Ie-Yt*Pe),B[6]=-(ct*(Me*pt-te*qe)-en*(ht*pt-Yt*qe)+Ke*(ht*te-Yt*Me)),B[7]=ct*(Me*Ie-te*Pe)-en*(ht*Ie-Yt*Pe)+Fe*(ht*te-Yt*Me),B[8]=en*(Xe*pt-Ie*lt)-Fe*(nn*pt-te*lt)+Ke*(nn*Ie-te*Xe),B[9]=-(ct*(Xe*pt-Ie*lt)-Fe*(Mt*pt-Yt*lt)+Ke*(Mt*Ie-Yt*Xe)),B[10]=ct*(nn*pt-te*lt)-en*(Mt*pt-Yt*lt)+Ke*(Mt*te-Yt*nn),B[11]=-(ct*(nn*Ie-te*Xe)-en*(Mt*Ie-Yt*Xe)+Fe*(Mt*te-Yt*nn)),B[12]=-(en*(Xe*qe-Pe*lt)-Fe*(nn*qe-Me*lt)+Ke*(nn*Pe-Me*Xe)),B[13]=ct*(Xe*qe-Pe*lt)-Fe*(Mt*qe-ht*lt)+Ke*(Mt*Pe-ht*Xe),B[14]=-(ct*(nn*qe-Me*lt)-en*(Mt*qe-ht*lt)+Ke*(Mt*Me-ht*nn)),B[15]=ct*(nn*Pe-Me*Xe)-en*(Mt*Pe-ht*Xe)+Fe*(Mt*Me-ht*nn),B}function P(B){var ie=B[0],ct=B[1],Mt=B[2],ht=B[3],Yt=B[4],en=B[5],nn=B[6],Me=B[7],te=B[8],Fe=B[9],Xe=B[10],Pe=B[11],Ie=B[12],Ke=B[13],lt=B[14],qe=B[15],pt=ie*en-ct*Yt,Ct=ie*nn-Mt*Yt,Xt=ie*Me-ht*Yt,Qt=ct*nn-Mt*en,pn=ct*Me-ht*en,Wn=Mt*Me-ht*nn,Rn=te*Ke-Fe*Ie,bi=te*lt-Xe*Ie,Lr=te*qe-Pe*Ie,Qn=Fe*lt-Xe*Ke,Vi=Fe*qe-Pe*Ke,Oi=Xe*qe-Pe*lt;return pt*Oi-Ct*Vi+Xt*Qn+Qt*Lr-pn*bi+Wn*Rn}function W(B,ie,ct){var Mt=ie[0],ht=ie[1],Yt=ie[2],en=ie[3],nn=ie[4],Me=ie[5],te=ie[6],Fe=ie[7],Xe=ie[8],Pe=ie[9],Ie=ie[10],Ke=ie[11],lt=ie[12],qe=ie[13],pt=ie[14],Ct=ie[15],Xt=ct[0],Qt=ct[1],pn=ct[2],Wn=ct[3];return B[0]=Xt*Mt+Qt*nn+pn*Xe+Wn*lt,B[1]=Xt*ht+Qt*Me+pn*Pe+Wn*qe,B[2]=Xt*Yt+Qt*te+pn*Ie+Wn*pt,B[3]=Xt*en+Qt*Fe+pn*Ke+Wn*Ct,Xt=ct[4],Qt=ct[5],pn=ct[6],Wn=ct[7],B[4]=Xt*Mt+Qt*nn+pn*Xe+Wn*lt,B[5]=Xt*ht+Qt*Me+pn*Pe+Wn*qe,B[6]=Xt*Yt+Qt*te+pn*Ie+Wn*pt,B[7]=Xt*en+Qt*Fe+pn*Ke+Wn*Ct,Xt=ct[8],Qt=ct[9],pn=ct[10],Wn=ct[11],B[8]=Xt*Mt+Qt*nn+pn*Xe+Wn*lt,B[9]=Xt*ht+Qt*Me+pn*Pe+Wn*qe,B[10]=Xt*Yt+Qt*te+pn*Ie+Wn*pt,B[11]=Xt*en+Qt*Fe+pn*Ke+Wn*Ct,Xt=ct[12],Qt=ct[13],pn=ct[14],Wn=ct[15],B[12]=Xt*Mt+Qt*nn+pn*Xe+Wn*lt,B[13]=Xt*ht+Qt*Me+pn*Pe+Wn*qe,B[14]=Xt*Yt+Qt*te+pn*Ie+Wn*pt,B[15]=Xt*en+Qt*Fe+pn*Ke+Wn*Ct,B}function K(B,ie,ct){var Mt=ct[0],ht=ct[1],Yt=ct[2],en,nn,Me,te,Fe,Xe,Pe,Ie,Ke,lt,qe,pt;return ie===B?(B[12]=ie[0]*Mt+ie[4]*ht+ie[8]*Yt+ie[12],B[13]=ie[1]*Mt+ie[5]*ht+ie[9]*Yt+ie[13],B[14]=ie[2]*Mt+ie[6]*ht+ie[10]*Yt+ie[14],B[15]=ie[3]*Mt+ie[7]*ht+ie[11]*Yt+ie[15]):(en=ie[0],nn=ie[1],Me=ie[2],te=ie[3],Fe=ie[4],Xe=ie[5],Pe=ie[6],Ie=ie[7],Ke=ie[8],lt=ie[9],qe=ie[10],pt=ie[11],B[0]=en,B[1]=nn,B[2]=Me,B[3]=te,B[4]=Fe,B[5]=Xe,B[6]=Pe,B[7]=Ie,B[8]=Ke,B[9]=lt,B[10]=qe,B[11]=pt,B[12]=en*Mt+Fe*ht+Ke*Yt+ie[12],B[13]=nn*Mt+Xe*ht+lt*Yt+ie[13],B[14]=Me*Mt+Pe*ht+qe*Yt+ie[14],B[15]=te*Mt+Ie*ht+pt*Yt+ie[15]),B}function re(B,ie,ct){var Mt=ct[0],ht=ct[1],Yt=ct[2];return B[0]=ie[0]*Mt,B[1]=ie[1]*Mt,B[2]=ie[2]*Mt,B[3]=ie[3]*Mt,B[4]=ie[4]*ht,B[5]=ie[5]*ht,B[6]=ie[6]*ht,B[7]=ie[7]*ht,B[8]=ie[8]*Yt,B[9]=ie[9]*Yt,B[10]=ie[10]*Yt,B[11]=ie[11]*Yt,B[12]=ie[12],B[13]=ie[13],B[14]=ie[14],B[15]=ie[15],B}function ye(B,ie,ct,Mt){var ht=Mt[0],Yt=Mt[1],en=Mt[2],nn=Math.hypot(ht,Yt,en),Me,te,Fe,Xe,Pe,Ie,Ke,lt,qe,pt,Ct,Xt,Qt,pn,Wn,Rn,bi,Lr,Qn,Vi,Oi,Gi,ir,ms;return nn<w.Ib?null:(nn=1/nn,ht*=nn,Yt*=nn,en*=nn,Me=Math.sin(ct),te=Math.cos(ct),Fe=1-te,Xe=ie[0],Pe=ie[1],Ie=ie[2],Ke=ie[3],lt=ie[4],qe=ie[5],pt=ie[6],Ct=ie[7],Xt=ie[8],Qt=ie[9],pn=ie[10],Wn=ie[11],Rn=ht*ht*Fe+te,bi=Yt*ht*Fe+en*Me,Lr=en*ht*Fe-Yt*Me,Qn=ht*Yt*Fe-en*Me,Vi=Yt*Yt*Fe+te,Oi=en*Yt*Fe+ht*Me,Gi=ht*en*Fe+Yt*Me,ir=Yt*en*Fe-ht*Me,ms=en*en*Fe+te,B[0]=Xe*Rn+lt*bi+Xt*Lr,B[1]=Pe*Rn+qe*bi+Qt*Lr,B[2]=Ie*Rn+pt*bi+pn*Lr,B[3]=Ke*Rn+Ct*bi+Wn*Lr,B[4]=Xe*Qn+lt*Vi+Xt*Oi,B[5]=Pe*Qn+qe*Vi+Qt*Oi,B[6]=Ie*Qn+pt*Vi+pn*Oi,B[7]=Ke*Qn+Ct*Vi+Wn*Oi,B[8]=Xe*Gi+lt*ir+Xt*ms,B[9]=Pe*Gi+qe*ir+Qt*ms,B[10]=Ie*Gi+pt*ir+pn*ms,B[11]=Ke*Gi+Ct*ir+Wn*ms,ie!==B&&(B[12]=ie[12],B[13]=ie[13],B[14]=ie[14],B[15]=ie[15]),B)}function ge(B,ie,ct){var Mt=Math.sin(ct),ht=Math.cos(ct),Yt=ie[4],en=ie[5],nn=ie[6],Me=ie[7],te=ie[8],Fe=ie[9],Xe=ie[10],Pe=ie[11];return ie!==B&&(B[0]=ie[0],B[1]=ie[1],B[2]=ie[2],B[3]=ie[3],B[12]=ie[12],B[13]=ie[13],B[14]=ie[14],B[15]=ie[15]),B[4]=Yt*ht+te*Mt,B[5]=en*ht+Fe*Mt,B[6]=nn*ht+Xe*Mt,B[7]=Me*ht+Pe*Mt,B[8]=te*ht-Yt*Mt,B[9]=Fe*ht-en*Mt,B[10]=Xe*ht-nn*Mt,B[11]=Pe*ht-Me*Mt,B}function ce(B,ie,ct){var Mt=Math.sin(ct),ht=Math.cos(ct),Yt=ie[0],en=ie[1],nn=ie[2],Me=ie[3],te=ie[8],Fe=ie[9],Xe=ie[10],Pe=ie[11];return ie!==B&&(B[4]=ie[4],B[5]=ie[5],B[6]=ie[6],B[7]=ie[7],B[12]=ie[12],B[13]=ie[13],B[14]=ie[14],B[15]=ie[15]),B[0]=Yt*ht-te*Mt,B[1]=en*ht-Fe*Mt,B[2]=nn*ht-Xe*Mt,B[3]=Me*ht-Pe*Mt,B[8]=Yt*Mt+te*ht,B[9]=en*Mt+Fe*ht,B[10]=nn*Mt+Xe*ht,B[11]=Me*Mt+Pe*ht,B}function xe(B,ie,ct){var Mt=Math.sin(ct),ht=Math.cos(ct),Yt=ie[0],en=ie[1],nn=ie[2],Me=ie[3],te=ie[4],Fe=ie[5],Xe=ie[6],Pe=ie[7];return ie!==B&&(B[8]=ie[8],B[9]=ie[9],B[10]=ie[10],B[11]=ie[11],B[12]=ie[12],B[13]=ie[13],B[14]=ie[14],B[15]=ie[15]),B[0]=Yt*ht+te*Mt,B[1]=en*ht+Fe*Mt,B[2]=nn*ht+Xe*Mt,B[3]=Me*ht+Pe*Mt,B[4]=te*ht-Yt*Mt,B[5]=Fe*ht-en*Mt,B[6]=Xe*ht-nn*Mt,B[7]=Pe*ht-Me*Mt,B}function fe(B,ie){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]=ie[0],B[13]=ie[1],B[14]=ie[2],B[15]=1,B}function Ne(B,ie){return B[0]=ie[0],B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=ie[1],B[6]=0,B[7]=0,B[8]=0,B[9]=0,B[10]=ie[2],B[11]=0,B[12]=0,B[13]=0,B[14]=0,B[15]=1,B}function Ae(B,ie,ct){var Mt=ct[0],ht=ct[1],Yt=ct[2],en=Math.hypot(Mt,ht,Yt),nn,Me,te;return en<w.Ib?null:(en=1/en,Mt*=en,ht*=en,Yt*=en,nn=Math.sin(ie),Me=Math.cos(ie),te=1-Me,B[0]=Mt*Mt*te+Me,B[1]=ht*Mt*te+Yt*nn,B[2]=Yt*Mt*te-ht*nn,B[3]=0,B[4]=Mt*ht*te-Yt*nn,B[5]=ht*ht*te+Me,B[6]=Yt*ht*te+Mt*nn,B[7]=0,B[8]=Mt*Yt*te+ht*nn,B[9]=ht*Yt*te-Mt*nn,B[10]=Yt*Yt*te+Me,B[11]=0,B[12]=0,B[13]=0,B[14]=0,B[15]=1,B)}function be(B,ie){var ct=Math.sin(ie),Mt=Math.cos(ie);return B[0]=1,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=Mt,B[6]=ct,B[7]=0,B[8]=0,B[9]=-ct,B[10]=Mt,B[11]=0,B[12]=0,B[13]=0,B[14]=0,B[15]=1,B}function Ye(B,ie){var ct=Math.sin(ie),Mt=Math.cos(ie);return B[0]=Mt,B[1]=0,B[2]=-ct,B[3]=0,B[4]=0,B[5]=1,B[6]=0,B[7]=0,B[8]=ct,B[9]=0,B[10]=Mt,B[11]=0,B[12]=0,B[13]=0,B[14]=0,B[15]=1,B}function Ee(B,ie){var ct=Math.sin(ie),Mt=Math.cos(ie);return B[0]=Mt,B[1]=ct,B[2]=0,B[3]=0,B[4]=-ct,B[5]=Mt,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 We(B,ie,ct){var Mt=ie[0],ht=ie[1],Yt=ie[2],en=ie[3],nn=Mt+Mt,Me=ht+ht,te=Yt+Yt,Fe=Mt*nn,Xe=Mt*Me,Pe=Mt*te,Ie=ht*Me,Ke=ht*te,lt=Yt*te,qe=en*nn,pt=en*Me,Ct=en*te;return B[0]=1-(Ie+lt),B[1]=Xe+Ct,B[2]=Pe-pt,B[3]=0,B[4]=Xe-Ct,B[5]=1-(Fe+lt),B[6]=Ke+qe,B[7]=0,B[8]=Pe+pt,B[9]=Ke-qe,B[10]=1-(Fe+Ie),B[11]=0,B[12]=ct[0],B[13]=ct[1],B[14]=ct[2],B[15]=1,B}function je(B,ie){var ct=new w.WT(3),Mt=-ie[0],ht=-ie[1],Yt=-ie[2],en=ie[3],nn=ie[4],Me=ie[5],te=ie[6],Fe=ie[7],Xe=Mt*Mt+ht*ht+Yt*Yt+en*en;return Xe>0?(ct[0]=(nn*en+Fe*Mt+Me*Yt-te*ht)*2/Xe,ct[1]=(Me*en+Fe*ht+te*Mt-nn*Yt)*2/Xe,ct[2]=(te*en+Fe*Yt+nn*ht-Me*Mt)*2/Xe):(ct[0]=(nn*en+Fe*Mt+Me*Yt-te*ht)*2,ct[1]=(Me*en+Fe*ht+te*Mt-nn*Yt)*2,ct[2]=(te*en+Fe*Yt+nn*ht-Me*Mt)*2),We(B,ie,ct),B}function _t(B,ie){return B[0]=ie[12],B[1]=ie[13],B[2]=ie[14],B}function It(B,ie){var ct=ie[0],Mt=ie[1],ht=ie[2],Yt=ie[4],en=ie[5],nn=ie[6],Me=ie[8],te=ie[9],Fe=ie[10];return B[0]=Math.hypot(ct,Mt,ht),B[1]=Math.hypot(Yt,en,nn),B[2]=Math.hypot(Me,te,Fe),B}function kt(B,ie){var ct=new w.WT(3);It(ct,ie);var Mt=1/ct[0],ht=1/ct[1],Yt=1/ct[2],en=ie[0]*Mt,nn=ie[1]*ht,Me=ie[2]*Yt,te=ie[4]*Mt,Fe=ie[5]*ht,Xe=ie[6]*Yt,Pe=ie[8]*Mt,Ie=ie[9]*ht,Ke=ie[10]*Yt,lt=en+Fe+Ke,qe=0;return lt>0?(qe=Math.sqrt(lt+1)*2,B[3]=.25*qe,B[0]=(Xe-Ie)/qe,B[1]=(Pe-Me)/qe,B[2]=(nn-te)/qe):en>Fe&&en>Ke?(qe=Math.sqrt(1+en-Fe-Ke)*2,B[3]=(Xe-Ie)/qe,B[0]=.25*qe,B[1]=(nn+te)/qe,B[2]=(Pe+Me)/qe):Fe>Ke?(qe=Math.sqrt(1+Fe-en-Ke)*2,B[3]=(Pe-Me)/qe,B[0]=(nn+te)/qe,B[1]=.25*qe,B[2]=(Xe+Ie)/qe):(qe=Math.sqrt(1+Ke-en-Fe)*2,B[3]=(nn-te)/qe,B[0]=(Pe+Me)/qe,B[1]=(Xe+Ie)/qe,B[2]=.25*qe),B}function Ut(B,ie,ct,Mt){var ht=ie[0],Yt=ie[1],en=ie[2],nn=ie[3],Me=ht+ht,te=Yt+Yt,Fe=en+en,Xe=ht*Me,Pe=ht*te,Ie=ht*Fe,Ke=Yt*te,lt=Yt*Fe,qe=en*Fe,pt=nn*Me,Ct=nn*te,Xt=nn*Fe,Qt=Mt[0],pn=Mt[1],Wn=Mt[2];return B[0]=(1-(Ke+qe))*Qt,B[1]=(Pe+Xt)*Qt,B[2]=(Ie-Ct)*Qt,B[3]=0,B[4]=(Pe-Xt)*pn,B[5]=(1-(Xe+qe))*pn,B[6]=(lt+pt)*pn,B[7]=0,B[8]=(Ie+Ct)*Wn,B[9]=(lt-pt)*Wn,B[10]=(1-(Xe+Ke))*Wn,B[11]=0,B[12]=ct[0],B[13]=ct[1],B[14]=ct[2],B[15]=1,B}function At(B,ie,ct,Mt,ht){var Yt=ie[0],en=ie[1],nn=ie[2],Me=ie[3],te=Yt+Yt,Fe=en+en,Xe=nn+nn,Pe=Yt*te,Ie=Yt*Fe,Ke=Yt*Xe,lt=en*Fe,qe=en*Xe,pt=nn*Xe,Ct=Me*te,Xt=Me*Fe,Qt=Me*Xe,pn=Mt[0],Wn=Mt[1],Rn=Mt[2],bi=ht[0],Lr=ht[1],Qn=ht[2],Vi=(1-(lt+pt))*pn,Oi=(Ie+Qt)*pn,Gi=(Ke-Xt)*pn,ir=(Ie-Qt)*Wn,ms=(1-(Pe+pt))*Wn,Is=(qe+Ct)*Wn,as=(Ke+Xt)*Rn,gs=(qe-Ct)*Rn,Vs=(1-(Pe+lt))*Rn;return B[0]=Vi,B[1]=Oi,B[2]=Gi,B[3]=0,B[4]=ir,B[5]=ms,B[6]=Is,B[7]=0,B[8]=as,B[9]=gs,B[10]=Vs,B[11]=0,B[12]=ct[0]+bi-(Vi*bi+ir*Lr+as*Qn),B[13]=ct[1]+Lr-(Oi*bi+ms*Lr+gs*Qn),B[14]=ct[2]+Qn-(Gi*bi+Is*Lr+Vs*Qn),B[15]=1,B}function at(B,ie){var ct=ie[0],Mt=ie[1],ht=ie[2],Yt=ie[3],en=ct+ct,nn=Mt+Mt,Me=ht+ht,te=ct*en,Fe=Mt*en,Xe=Mt*nn,Pe=ht*en,Ie=ht*nn,Ke=ht*Me,lt=Yt*en,qe=Yt*nn,pt=Yt*Me;return B[0]=1-Xe-Ke,B[1]=Fe+pt,B[2]=Pe-qe,B[3]=0,B[4]=Fe-pt,B[5]=1-te-Ke,B[6]=Ie+lt,B[7]=0,B[8]=Pe+qe,B[9]=Ie-lt,B[10]=1-te-Xe,B[11]=0,B[12]=0,B[13]=0,B[14]=0,B[15]=1,B}function Ot(B,ie,ct,Mt,ht,Yt,en){var nn=1/(ct-ie),Me=1/(ht-Mt),te=1/(Yt-en);return B[0]=Yt*2*nn,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=Yt*2*Me,B[6]=0,B[7]=0,B[8]=(ct+ie)*nn,B[9]=(ht+Mt)*Me,B[10]=(en+Yt)*te,B[11]=-1,B[12]=0,B[13]=0,B[14]=en*Yt*2*te,B[15]=0,B}function ue(B,ie,ct,Mt,ht){var Yt=1/Math.tan(ie/2),en;return B[0]=Yt/ct,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=Yt,B[6]=0,B[7]=0,B[8]=0,B[9]=0,B[11]=-1,B[12]=0,B[13]=0,B[15]=0,ht!=null&&ht!==1/0?(en=1/(Mt-ht),B[10]=(ht+Mt)*en,B[14]=2*ht*Mt*en):(B[10]=-1,B[14]=-2*Mt),B}var Ue=ue;function vt(B,ie,ct,Mt,ht){var Yt=1/Math.tan(ie/2),en;return B[0]=Yt/ct,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=Yt,B[6]=0,B[7]=0,B[8]=0,B[9]=0,B[11]=-1,B[12]=0,B[13]=0,B[15]=0,ht!=null&&ht!==1/0?(en=1/(Mt-ht),B[10]=ht*en,B[14]=ht*Mt*en):(B[10]=-1,B[14]=-Mt),B}function Jt(B,ie,ct,Mt){var ht=Math.tan(ie.upDegrees*Math.PI/180),Yt=Math.tan(ie.downDegrees*Math.PI/180),en=Math.tan(ie.leftDegrees*Math.PI/180),nn=Math.tan(ie.rightDegrees*Math.PI/180),Me=2/(en+nn),te=2/(ht+Yt);return B[0]=Me,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=te,B[6]=0,B[7]=0,B[8]=-((en-nn)*Me*.5),B[9]=(ht-Yt)*te*.5,B[10]=Mt/(ct-Mt),B[11]=-1,B[12]=0,B[13]=0,B[14]=Mt*ct/(ct-Mt),B[15]=0,B}function Qe(B,ie,ct,Mt,ht,Yt,en){var nn=1/(ie-ct),Me=1/(Mt-ht),te=1/(Yt-en);return B[0]=-2*nn,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=-2*Me,B[6]=0,B[7]=0,B[8]=0,B[9]=0,B[10]=2*te,B[11]=0,B[12]=(ie+ct)*nn,B[13]=(ht+Mt)*Me,B[14]=(en+Yt)*te,B[15]=1,B}var rt=Qe;function bt(B,ie,ct,Mt,ht,Yt,en){var nn=1/(ie-ct),Me=1/(Mt-ht),te=1/(Yt-en);return B[0]=-2*nn,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=-2*Me,B[6]=0,B[7]=0,B[8]=0,B[9]=0,B[10]=te,B[11]=0,B[12]=(ie+ct)*nn,B[13]=(ht+Mt)*Me,B[14]=Yt*te,B[15]=1,B}function ze(B,ie,ct,Mt){var ht,Yt,en,nn,Me,te,Fe,Xe,Pe,Ie,Ke=ie[0],lt=ie[1],qe=ie[2],pt=Mt[0],Ct=Mt[1],Xt=Mt[2],Qt=ct[0],pn=ct[1],Wn=ct[2];return Math.abs(Ke-Qt)<w.Ib&&Math.abs(lt-pn)<w.Ib&&Math.abs(qe-Wn)<w.Ib?x(B):(Fe=Ke-Qt,Xe=lt-pn,Pe=qe-Wn,Ie=1/Math.hypot(Fe,Xe,Pe),Fe*=Ie,Xe*=Ie,Pe*=Ie,ht=Ct*Pe-Xt*Xe,Yt=Xt*Fe-pt*Pe,en=pt*Xe-Ct*Fe,Ie=Math.hypot(ht,Yt,en),Ie?(Ie=1/Ie,ht*=Ie,Yt*=Ie,en*=Ie):(ht=0,Yt=0,en=0),nn=Xe*en-Pe*Yt,Me=Pe*ht-Fe*en,te=Fe*Yt-Xe*ht,Ie=Math.hypot(nn,Me,te),Ie?(Ie=1/Ie,nn*=Ie,Me*=Ie,te*=Ie):(nn=0,Me=0,te=0),B[0]=ht,B[1]=nn,B[2]=Fe,B[3]=0,B[4]=Yt,B[5]=Me,B[6]=Xe,B[7]=0,B[8]=en,B[9]=te,B[10]=Pe,B[11]=0,B[12]=-(ht*Ke+Yt*lt+en*qe),B[13]=-(nn*Ke+Me*lt+te*qe),B[14]=-(Fe*Ke+Xe*lt+Pe*qe),B[15]=1,B)}function Ze(B,ie,ct,Mt){var ht=ie[0],Yt=ie[1],en=ie[2],nn=Mt[0],Me=Mt[1],te=Mt[2],Fe=ht-ct[0],Xe=Yt-ct[1],Pe=en-ct[2],Ie=Fe*Fe+Xe*Xe+Pe*Pe;Ie>0&&(Ie=1/Math.sqrt(Ie),Fe*=Ie,Xe*=Ie,Pe*=Ie);var Ke=Me*Pe-te*Xe,lt=te*Fe-nn*Pe,qe=nn*Xe-Me*Fe;return Ie=Ke*Ke+lt*lt+qe*qe,Ie>0&&(Ie=1/Math.sqrt(Ie),Ke*=Ie,lt*=Ie,qe*=Ie),B[0]=Ke,B[1]=lt,B[2]=qe,B[3]=0,B[4]=Xe*qe-Pe*lt,B[5]=Pe*Ke-Fe*qe,B[6]=Fe*lt-Xe*Ke,B[7]=0,B[8]=Fe,B[9]=Xe,B[10]=Pe,B[11]=0,B[12]=ht,B[13]=Yt,B[14]=en,B[15]=1,B}function q(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 Y(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 de(B,ie,ct){return B[0]=ie[0]+ct[0],B[1]=ie[1]+ct[1],B[2]=ie[2]+ct[2],B[3]=ie[3]+ct[3],B[4]=ie[4]+ct[4],B[5]=ie[5]+ct[5],B[6]=ie[6]+ct[6],B[7]=ie[7]+ct[7],B[8]=ie[8]+ct[8],B[9]=ie[9]+ct[9],B[10]=ie[10]+ct[10],B[11]=ie[11]+ct[11],B[12]=ie[12]+ct[12],B[13]=ie[13]+ct[13],B[14]=ie[14]+ct[14],B[15]=ie[15]+ct[15],B}function Je(B,ie,ct){return B[0]=ie[0]-ct[0],B[1]=ie[1]-ct[1],B[2]=ie[2]-ct[2],B[3]=ie[3]-ct[3],B[4]=ie[4]-ct[4],B[5]=ie[5]-ct[5],B[6]=ie[6]-ct[6],B[7]=ie[7]-ct[7],B[8]=ie[8]-ct[8],B[9]=ie[9]-ct[9],B[10]=ie[10]-ct[10],B[11]=ie[11]-ct[11],B[12]=ie[12]-ct[12],B[13]=ie[13]-ct[13],B[14]=ie[14]-ct[14],B[15]=ie[15]-ct[15],B}function Te(B,ie,ct){return B[0]=ie[0]*ct,B[1]=ie[1]*ct,B[2]=ie[2]*ct,B[3]=ie[3]*ct,B[4]=ie[4]*ct,B[5]=ie[5]*ct,B[6]=ie[6]*ct,B[7]=ie[7]*ct,B[8]=ie[8]*ct,B[9]=ie[9]*ct,B[10]=ie[10]*ct,B[11]=ie[11]*ct,B[12]=ie[12]*ct,B[13]=ie[13]*ct,B[14]=ie[14]*ct,B[15]=ie[15]*ct,B}function $e(B,ie,ct,Mt){return B[0]=ie[0]+ct[0]*Mt,B[1]=ie[1]+ct[1]*Mt,B[2]=ie[2]+ct[2]*Mt,B[3]=ie[3]+ct[3]*Mt,B[4]=ie[4]+ct[4]*Mt,B[5]=ie[5]+ct[5]*Mt,B[6]=ie[6]+ct[6]*Mt,B[7]=ie[7]+ct[7]*Mt,B[8]=ie[8]+ct[8]*Mt,B[9]=ie[9]+ct[9]*Mt,B[10]=ie[10]+ct[10]*Mt,B[11]=ie[11]+ct[11]*Mt,B[12]=ie[12]+ct[12]*Mt,B[13]=ie[13]+ct[13]*Mt,B[14]=ie[14]+ct[14]*Mt,B[15]=ie[15]+ct[15]*Mt,B}function xt(B,ie){return B[0]===ie[0]&&B[1]===ie[1]&&B[2]===ie[2]&&B[3]===ie[3]&&B[4]===ie[4]&&B[5]===ie[5]&&B[6]===ie[6]&&B[7]===ie[7]&&B[8]===ie[8]&&B[9]===ie[9]&&B[10]===ie[10]&&B[11]===ie[11]&&B[12]===ie[12]&&B[13]===ie[13]&&B[14]===ie[14]&&B[15]===ie[15]}function ke(B,ie){var ct=B[0],Mt=B[1],ht=B[2],Yt=B[3],en=B[4],nn=B[5],Me=B[6],te=B[7],Fe=B[8],Xe=B[9],Pe=B[10],Ie=B[11],Ke=B[12],lt=B[13],qe=B[14],pt=B[15],Ct=ie[0],Xt=ie[1],Qt=ie[2],pn=ie[3],Wn=ie[4],Rn=ie[5],bi=ie[6],Lr=ie[7],Qn=ie[8],Vi=ie[9],Oi=ie[10],Gi=ie[11],ir=ie[12],ms=ie[13],Is=ie[14],as=ie[15];return Math.abs(ct-Ct)<=w.Ib*Math.max(1,Math.abs(ct),Math.abs(Ct))&&Math.abs(Mt-Xt)<=w.Ib*Math.max(1,Math.abs(Mt),Math.abs(Xt))&&Math.abs(ht-Qt)<=w.Ib*Math.max(1,Math.abs(ht),Math.abs(Qt))&&Math.abs(Yt-pn)<=w.Ib*Math.max(1,Math.abs(Yt),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(Me-bi)<=w.Ib*Math.max(1,Math.abs(Me),Math.abs(bi))&&Math.abs(te-Lr)<=w.Ib*Math.max(1,Math.abs(te),Math.abs(Lr))&&Math.abs(Fe-Qn)<=w.Ib*Math.max(1,Math.abs(Fe),Math.abs(Qn))&&Math.abs(Xe-Vi)<=w.Ib*Math.max(1,Math.abs(Xe),Math.abs(Vi))&&Math.abs(Pe-Oi)<=w.Ib*Math.max(1,Math.abs(Pe),Math.abs(Oi))&&Math.abs(Ie-Gi)<=w.Ib*Math.max(1,Math.abs(Ie),Math.abs(Gi))&&Math.abs(Ke-ir)<=w.Ib*Math.max(1,Math.abs(Ke),Math.abs(ir))&&Math.abs(lt-ms)<=w.Ib*Math.max(1,Math.abs(lt),Math.abs(ms))&&Math.abs(qe-Is)<=w.Ib*Math.max(1,Math.abs(qe),Math.abs(Is))&&Math.abs(pt-as)<=w.Ib*Math.max(1,Math.abs(pt),Math.abs(as))}var et=W,yt=Je},32945:function(ae,ne,b){"use strict";b.d(ne,{Fv:function(){return Qe},JG:function(){return _t},Jp:function(){return L},Su:function(){return Ye},U_:function(){return Ne},Ue:function(){return S},al:function(){return je},dC:function(){return Ut},t8:function(){return It},yY:function(){return x}});var w=b(49685),k=b(35600),O=b(33983),A=b(98333);function S(){var Y=new w.WT(4);return w.WT!=Float32Array&&(Y[0]=0,Y[1]=0,Y[2]=0),Y[3]=1,Y}function R(Y){return Y[0]=0,Y[1]=0,Y[2]=0,Y[3]=1,Y}function x(Y,de,Je){Je=Je*.5;var Te=Math.sin(Je);return Y[0]=Te*de[0],Y[1]=Te*de[1],Y[2]=Te*de[2],Y[3]=Math.cos(Je),Y}function E(Y,de){var Je=Math.acos(de[3])*2,Te=Math.sin(Je/2);return Te>glMatrix.EPSILON?(Y[0]=de[0]/Te,Y[1]=de[1]/Te,Y[2]=de[2]/Te):(Y[0]=1,Y[1]=0,Y[2]=0),Je}function N(Y,de){var Je=at(Y,de);return Math.acos(2*Je*Je-1)}function L(Y,de,Je){var Te=de[0],$e=de[1],xt=de[2],ke=de[3],et=Je[0],yt=Je[1],B=Je[2],ie=Je[3];return Y[0]=Te*ie+ke*et+$e*B-xt*yt,Y[1]=$e*ie+ke*yt+xt*et-Te*B,Y[2]=xt*ie+ke*B+Te*yt-$e*et,Y[3]=ke*ie-Te*et-$e*yt-xt*B,Y}function P(Y,de,Je){Je*=.5;var Te=de[0],$e=de[1],xt=de[2],ke=de[3],et=Math.sin(Je),yt=Math.cos(Je);return Y[0]=Te*yt+ke*et,Y[1]=$e*yt+xt*et,Y[2]=xt*yt-$e*et,Y[3]=ke*yt-Te*et,Y}function W(Y,de,Je){Je*=.5;var Te=de[0],$e=de[1],xt=de[2],ke=de[3],et=Math.sin(Je),yt=Math.cos(Je);return Y[0]=Te*yt-xt*et,Y[1]=$e*yt+ke*et,Y[2]=xt*yt+Te*et,Y[3]=ke*yt-$e*et,Y}function K(Y,de,Je){Je*=.5;var Te=de[0],$e=de[1],xt=de[2],ke=de[3],et=Math.sin(Je),yt=Math.cos(Je);return Y[0]=Te*yt+$e*et,Y[1]=$e*yt-Te*et,Y[2]=xt*yt+ke*et,Y[3]=ke*yt-xt*et,Y}function re(Y,de){var Je=de[0],Te=de[1],$e=de[2];return Y[0]=Je,Y[1]=Te,Y[2]=$e,Y[3]=Math.sqrt(Math.abs(1-Je*Je-Te*Te-$e*$e)),Y}function ye(Y,de){var Je=de[0],Te=de[1],$e=de[2],xt=de[3],ke=Math.sqrt(Je*Je+Te*Te+$e*$e),et=Math.exp(xt),yt=ke>0?et*Math.sin(ke)/ke:0;return Y[0]=Je*yt,Y[1]=Te*yt,Y[2]=$e*yt,Y[3]=et*Math.cos(ke),Y}function ge(Y,de){var Je=de[0],Te=de[1],$e=de[2],xt=de[3],ke=Math.sqrt(Je*Je+Te*Te+$e*$e),et=ke>0?Math.atan2(ke,xt)/ke:0;return Y[0]=Je*et,Y[1]=Te*et,Y[2]=$e*et,Y[3]=.5*Math.log(Je*Je+Te*Te+$e*$e+xt*xt),Y}function ce(Y,de,Je){return ge(Y,de),At(Y,Y,Je),ye(Y,Y),Y}function xe(Y,de,Je,Te){var $e=de[0],xt=de[1],ke=de[2],et=de[3],yt=Je[0],B=Je[1],ie=Je[2],ct=Je[3],Mt,ht,Yt,en,nn;return ht=$e*yt+xt*B+ke*ie+et*ct,ht<0&&(ht=-ht,yt=-yt,B=-B,ie=-ie,ct=-ct),1-ht>w.Ib?(Mt=Math.acos(ht),Yt=Math.sin(Mt),en=Math.sin((1-Te)*Mt)/Yt,nn=Math.sin(Te*Mt)/Yt):(en=1-Te,nn=Te),Y[0]=en*$e+nn*yt,Y[1]=en*xt+nn*B,Y[2]=en*ke+nn*ie,Y[3]=en*et+nn*ct,Y}function fe(Y){var de=glMatrix.RANDOM(),Je=glMatrix.RANDOM(),Te=glMatrix.RANDOM(),$e=Math.sqrt(1-de),xt=Math.sqrt(de);return Y[0]=$e*Math.sin(2*Math.PI*Je),Y[1]=$e*Math.cos(2*Math.PI*Je),Y[2]=xt*Math.sin(2*Math.PI*Te),Y[3]=xt*Math.cos(2*Math.PI*Te),Y}function Ne(Y,de){var Je=de[0],Te=de[1],$e=de[2],xt=de[3],ke=Je*Je+Te*Te+$e*$e+xt*xt,et=ke?1/ke:0;return Y[0]=-Je*et,Y[1]=-Te*et,Y[2]=-$e*et,Y[3]=xt*et,Y}function Ae(Y,de){return Y[0]=-de[0],Y[1]=-de[1],Y[2]=-de[2],Y[3]=de[3],Y}function be(Y,de){var Je=de[0]+de[4]+de[8],Te;if(Je>0)Te=Math.sqrt(Je+1),Y[3]=.5*Te,Te=.5/Te,Y[0]=(de[5]-de[7])*Te,Y[1]=(de[6]-de[2])*Te,Y[2]=(de[1]-de[3])*Te;else{var $e=0;de[4]>de[0]&&($e=1),de[8]>de[$e*3+$e]&&($e=2);var xt=($e+1)%3,ke=($e+2)%3;Te=Math.sqrt(de[$e*3+$e]-de[xt*3+xt]-de[ke*3+ke]+1),Y[$e]=.5*Te,Te=.5/Te,Y[3]=(de[xt*3+ke]-de[ke*3+xt])*Te,Y[xt]=(de[xt*3+$e]+de[$e*3+xt])*Te,Y[ke]=(de[ke*3+$e]+de[$e*3+ke])*Te}return Y}function Ye(Y,de,Je,Te){var $e=.5*Math.PI/180;de*=$e,Je*=$e,Te*=$e;var xt=Math.sin(de),ke=Math.cos(de),et=Math.sin(Je),yt=Math.cos(Je),B=Math.sin(Te),ie=Math.cos(Te);return Y[0]=xt*yt*ie-ke*et*B,Y[1]=ke*et*ie+xt*yt*B,Y[2]=ke*yt*B-xt*et*ie,Y[3]=ke*yt*ie+xt*et*B,Y}function Ee(Y){return"quat("+Y[0]+", "+Y[1]+", "+Y[2]+", "+Y[3]+")"}var We=A.d9,je=A.al,_t=A.JG,It=A.t8,kt=A.IH,Ut=L,At=A.bA,at=A.AK,Ot=A.t7,ue=A.kE,Ue=null,vt=A.we,Jt=null,Qe=A.Fv,rt=A.I6,bt=A.fS,ze=function(){var Y=O.Ue(),de=O.al(1,0,0),Je=O.al(0,1,0);return function(Te,$e,xt){var ke=O.AK($e,xt);return ke<-.999999?(O.kC(Y,de,$e),O.Zh(Y)<1e-6&&O.kC(Y,Je,$e),O.Fv(Y,Y),x(Te,Y,Math.PI),Te):ke>.999999?(Te[0]=0,Te[1]=0,Te[2]=0,Te[3]=1,Te):(O.kC(Y,$e,xt),Te[0]=Y[0],Te[1]=Y[1],Te[2]=Y[2],Te[3]=1+ke,Qe(Te,Te))}}(),Ze=function(){var Y=S(),de=S();return function(Je,Te,$e,xt,ke,et){return xe(Y,Te,ke,et),xe(de,$e,xt,et),xe(Je,Y,de,2*et*(1-et)),Je}}(),q=function(){var Y=k.Ue();return function(de,Je,Te,$e){return Y[0]=Te[0],Y[3]=Te[1],Y[6]=Te[2],Y[1]=$e[0],Y[4]=$e[1],Y[7]=$e[2],Y[2]=-Je[0],Y[5]=-Je[1],Y[8]=-Je[2],Qe(de,be(de,Y))}}()},31437:function(ae,ne,b){"use strict";b.d(ne,{AK:function(){return We},Fv:function(){return Ee},I6:function(){return Jt},JG:function(){return S},Ue:function(){return k},t8:function(){return R}});var w=b(49685);function k(){var Te=new w.WT(2);return w.WT!=Float32Array&&(Te[0]=0,Te[1]=0),Te}function O(Te){var $e=new glMatrix.ARRAY_TYPE(2);return $e[0]=Te[0],$e[1]=Te[1],$e}function A(Te,$e){var xt=new glMatrix.ARRAY_TYPE(2);return xt[0]=Te,xt[1]=$e,xt}function S(Te,$e){return Te[0]=$e[0],Te[1]=$e[1],Te}function R(Te,$e,xt){return Te[0]=$e,Te[1]=xt,Te}function x(Te,$e,xt){return Te[0]=$e[0]+xt[0],Te[1]=$e[1]+xt[1],Te}function E(Te,$e,xt){return Te[0]=$e[0]-xt[0],Te[1]=$e[1]-xt[1],Te}function N(Te,$e,xt){return Te[0]=$e[0]*xt[0],Te[1]=$e[1]*xt[1],Te}function L(Te,$e,xt){return Te[0]=$e[0]/xt[0],Te[1]=$e[1]/xt[1],Te}function P(Te,$e){return Te[0]=Math.ceil($e[0]),Te[1]=Math.ceil($e[1]),Te}function W(Te,$e){return Te[0]=Math.floor($e[0]),Te[1]=Math.floor($e[1]),Te}function K(Te,$e,xt){return Te[0]=Math.min($e[0],xt[0]),Te[1]=Math.min($e[1],xt[1]),Te}function re(Te,$e,xt){return Te[0]=Math.max($e[0],xt[0]),Te[1]=Math.max($e[1],xt[1]),Te}function ye(Te,$e){return Te[0]=Math.round($e[0]),Te[1]=Math.round($e[1]),Te}function ge(Te,$e,xt){return Te[0]=$e[0]*xt,Te[1]=$e[1]*xt,Te}function ce(Te,$e,xt,ke){return Te[0]=$e[0]+xt[0]*ke,Te[1]=$e[1]+xt[1]*ke,Te}function xe(Te,$e){var xt=$e[0]-Te[0],ke=$e[1]-Te[1];return Math.hypot(xt,ke)}function fe(Te,$e){var xt=$e[0]-Te[0],ke=$e[1]-Te[1];return xt*xt+ke*ke}function Ne(Te){var $e=Te[0],xt=Te[1];return Math.hypot($e,xt)}function Ae(Te){var $e=Te[0],xt=Te[1];return $e*$e+xt*xt}function be(Te,$e){return Te[0]=-$e[0],Te[1]=-$e[1],Te}function Ye(Te,$e){return Te[0]=1/$e[0],Te[1]=1/$e[1],Te}function Ee(Te,$e){var xt=$e[0],ke=$e[1],et=xt*xt+ke*ke;return et>0&&(et=1/Math.sqrt(et)),Te[0]=$e[0]*et,Te[1]=$e[1]*et,Te}function We(Te,$e){return Te[0]*$e[0]+Te[1]*$e[1]}function je(Te,$e,xt){var ke=$e[0]*xt[1]-$e[1]*xt[0];return Te[0]=Te[1]=0,Te[2]=ke,Te}function _t(Te,$e,xt,ke){var et=$e[0],yt=$e[1];return Te[0]=et+ke*(xt[0]-et),Te[1]=yt+ke*(xt[1]-yt),Te}function It(Te,$e){$e=$e||1;var xt=glMatrix.RANDOM()*2*Math.PI;return Te[0]=Math.cos(xt)*$e,Te[1]=Math.sin(xt)*$e,Te}function kt(Te,$e,xt){var ke=$e[0],et=$e[1];return Te[0]=xt[0]*ke+xt[2]*et,Te[1]=xt[1]*ke+xt[3]*et,Te}function Ut(Te,$e,xt){var ke=$e[0],et=$e[1];return Te[0]=xt[0]*ke+xt[2]*et+xt[4],Te[1]=xt[1]*ke+xt[3]*et+xt[5],Te}function At(Te,$e,xt){var ke=$e[0],et=$e[1];return Te[0]=xt[0]*ke+xt[3]*et+xt[6],Te[1]=xt[1]*ke+xt[4]*et+xt[7],Te}function at(Te,$e,xt){var ke=$e[0],et=$e[1];return Te[0]=xt[0]*ke+xt[4]*et+xt[12],Te[1]=xt[1]*ke+xt[5]*et+xt[13],Te}function Ot(Te,$e,xt,ke){var et=$e[0]-xt[0],yt=$e[1]-xt[1],B=Math.sin(ke),ie=Math.cos(ke);return Te[0]=et*ie-yt*B+xt[0],Te[1]=et*B+yt*ie+xt[1],Te}function ue(Te,$e){var xt=Te[0],ke=Te[1],et=$e[0],yt=$e[1],B=Math.sqrt(xt*xt+ke*ke)*Math.sqrt(et*et+yt*yt),ie=B&&(xt*et+ke*yt)/B;return Math.acos(Math.min(Math.max(ie,-1),1))}function Ue(Te){return Te[0]=0,Te[1]=0,Te}function vt(Te){return"vec2("+Te[0]+", "+Te[1]+")"}function Jt(Te,$e){return Te[0]===$e[0]&&Te[1]===$e[1]}function Qe(Te,$e){var xt=Te[0],ke=Te[1],et=$e[0],yt=$e[1];return Math.abs(xt-et)<=glMatrix.EPSILON*Math.max(1,Math.abs(xt),Math.abs(et))&&Math.abs(ke-yt)<=glMatrix.EPSILON*Math.max(1,Math.abs(ke),Math.abs(yt))}var rt=null,bt=null,ze=null,Ze=null,q=null,Y=null,de=null,Je=function(){var Te=k();return function($e,xt,ke,et,yt,B){var ie,ct;for(xt||(xt=2),ke||(ke=0),et?ct=Math.min(et*xt+ke,$e.length):ct=$e.length,ie=ke;ie<ct;ie+=xt)Te[0]=$e[ie],Te[1]=$e[ie+1],yt(Te,Te,B),$e[ie]=Te[0],$e[ie+1]=Te[1];return $e}}()},33983:function(ae,ne,b){"use strict";b.d(ne,{$X:function(){return N},AK:function(){return We},Fp:function(){return ye},Fv:function(){return Ee},IH:function(){return E},JG:function(){return R},Jp:function(){return L},TK:function(){return de},Ue:function(){return k},VC:function(){return Ot},VV:function(){return re},Zh:function(){return Te},al:function(){return S},bA:function(){return ce},d9:function(){return O},fF:function(){return At},fS:function(){return ze},kC:function(){return je},kE:function(){return A},kK:function(){return at},lu:function(){return Ze},t7:function(){return _t},t8:function(){return x}});var w=b(49685);function k(){var ke=new w.WT(3);return w.WT!=Float32Array&&(ke[0]=0,ke[1]=0,ke[2]=0),ke}function O(ke){var et=new w.WT(3);return et[0]=ke[0],et[1]=ke[1],et[2]=ke[2],et}function A(ke){var et=ke[0],yt=ke[1],B=ke[2];return Math.hypot(et,yt,B)}function S(ke,et,yt){var B=new w.WT(3);return B[0]=ke,B[1]=et,B[2]=yt,B}function R(ke,et){return ke[0]=et[0],ke[1]=et[1],ke[2]=et[2],ke}function x(ke,et,yt,B){return ke[0]=et,ke[1]=yt,ke[2]=B,ke}function E(ke,et,yt){return ke[0]=et[0]+yt[0],ke[1]=et[1]+yt[1],ke[2]=et[2]+yt[2],ke}function N(ke,et,yt){return ke[0]=et[0]-yt[0],ke[1]=et[1]-yt[1],ke[2]=et[2]-yt[2],ke}function L(ke,et,yt){return ke[0]=et[0]*yt[0],ke[1]=et[1]*yt[1],ke[2]=et[2]*yt[2],ke}function P(ke,et,yt){return ke[0]=et[0]/yt[0],ke[1]=et[1]/yt[1],ke[2]=et[2]/yt[2],ke}function W(ke,et){return ke[0]=Math.ceil(et[0]),ke[1]=Math.ceil(et[1]),ke[2]=Math.ceil(et[2]),ke}function K(ke,et){return ke[0]=Math.floor(et[0]),ke[1]=Math.floor(et[1]),ke[2]=Math.floor(et[2]),ke}function re(ke,et,yt){return ke[0]=Math.min(et[0],yt[0]),ke[1]=Math.min(et[1],yt[1]),ke[2]=Math.min(et[2],yt[2]),ke}function ye(ke,et,yt){return ke[0]=Math.max(et[0],yt[0]),ke[1]=Math.max(et[1],yt[1]),ke[2]=Math.max(et[2],yt[2]),ke}function ge(ke,et){return ke[0]=Math.round(et[0]),ke[1]=Math.round(et[1]),ke[2]=Math.round(et[2]),ke}function ce(ke,et,yt){return ke[0]=et[0]*yt,ke[1]=et[1]*yt,ke[2]=et[2]*yt,ke}function xe(ke,et,yt,B){return ke[0]=et[0]+yt[0]*B,ke[1]=et[1]+yt[1]*B,ke[2]=et[2]+yt[2]*B,ke}function fe(ke,et){var yt=et[0]-ke[0],B=et[1]-ke[1],ie=et[2]-ke[2];return Math.hypot(yt,B,ie)}function Ne(ke,et){var yt=et[0]-ke[0],B=et[1]-ke[1],ie=et[2]-ke[2];return yt*yt+B*B+ie*ie}function Ae(ke){var et=ke[0],yt=ke[1],B=ke[2];return et*et+yt*yt+B*B}function be(ke,et){return ke[0]=-et[0],ke[1]=-et[1],ke[2]=-et[2],ke}function Ye(ke,et){return ke[0]=1/et[0],ke[1]=1/et[1],ke[2]=1/et[2],ke}function Ee(ke,et){var yt=et[0],B=et[1],ie=et[2],ct=yt*yt+B*B+ie*ie;return ct>0&&(ct=1/Math.sqrt(ct)),ke[0]=et[0]*ct,ke[1]=et[1]*ct,ke[2]=et[2]*ct,ke}function We(ke,et){return ke[0]*et[0]+ke[1]*et[1]+ke[2]*et[2]}function je(ke,et,yt){var B=et[0],ie=et[1],ct=et[2],Mt=yt[0],ht=yt[1],Yt=yt[2];return ke[0]=ie*Yt-ct*ht,ke[1]=ct*Mt-B*Yt,ke[2]=B*ht-ie*Mt,ke}function _t(ke,et,yt,B){var ie=et[0],ct=et[1],Mt=et[2];return ke[0]=ie+B*(yt[0]-ie),ke[1]=ct+B*(yt[1]-ct),ke[2]=Mt+B*(yt[2]-Mt),ke}function It(ke,et,yt,B,ie,ct){var Mt=ct*ct,ht=Mt*(2*ct-3)+1,Yt=Mt*(ct-2)+ct,en=Mt*(ct-1),nn=Mt*(3-2*ct);return ke[0]=et[0]*ht+yt[0]*Yt+B[0]*en+ie[0]*nn,ke[1]=et[1]*ht+yt[1]*Yt+B[1]*en+ie[1]*nn,ke[2]=et[2]*ht+yt[2]*Yt+B[2]*en+ie[2]*nn,ke}function kt(ke,et,yt,B,ie,ct){var Mt=1-ct,ht=Mt*Mt,Yt=ct*ct,en=ht*Mt,nn=3*ct*ht,Me=3*Yt*Mt,te=Yt*ct;return ke[0]=et[0]*en+yt[0]*nn+B[0]*Me+ie[0]*te,ke[1]=et[1]*en+yt[1]*nn+B[1]*Me+ie[1]*te,ke[2]=et[2]*en+yt[2]*nn+B[2]*Me+ie[2]*te,ke}function Ut(ke,et){et=et||1;var yt=glMatrix.RANDOM()*2*Math.PI,B=glMatrix.RANDOM()*2-1,ie=Math.sqrt(1-B*B)*et;return ke[0]=Math.cos(yt)*ie,ke[1]=Math.sin(yt)*ie,ke[2]=B*et,ke}function At(ke,et,yt){var B=et[0],ie=et[1],ct=et[2],Mt=yt[3]*B+yt[7]*ie+yt[11]*ct+yt[15];return Mt=Mt||1,ke[0]=(yt[0]*B+yt[4]*ie+yt[8]*ct+yt[12])/Mt,ke[1]=(yt[1]*B+yt[5]*ie+yt[9]*ct+yt[13])/Mt,ke[2]=(yt[2]*B+yt[6]*ie+yt[10]*ct+yt[14])/Mt,ke}function at(ke,et,yt){var B=et[0],ie=et[1],ct=et[2];return ke[0]=B*yt[0]+ie*yt[3]+ct*yt[6],ke[1]=B*yt[1]+ie*yt[4]+ct*yt[7],ke[2]=B*yt[2]+ie*yt[5]+ct*yt[8],ke}function Ot(ke,et,yt){var B=yt[0],ie=yt[1],ct=yt[2],Mt=yt[3],ht=et[0],Yt=et[1],en=et[2],nn=ie*en-ct*Yt,Me=ct*ht-B*en,te=B*Yt-ie*ht,Fe=ie*te-ct*Me,Xe=ct*nn-B*te,Pe=B*Me-ie*nn,Ie=Mt*2;return nn*=Ie,Me*=Ie,te*=Ie,Fe*=2,Xe*=2,Pe*=2,ke[0]=ht+nn+Fe,ke[1]=Yt+Me+Xe,ke[2]=en+te+Pe,ke}function ue(ke,et,yt,B){var ie=[],ct=[];return ie[0]=et[0]-yt[0],ie[1]=et[1]-yt[1],ie[2]=et[2]-yt[2],ct[0]=ie[0],ct[1]=ie[1]*Math.cos(B)-ie[2]*Math.sin(B),ct[2]=ie[1]*Math.sin(B)+ie[2]*Math.cos(B),ke[0]=ct[0]+yt[0],ke[1]=ct[1]+yt[1],ke[2]=ct[2]+yt[2],ke}function Ue(ke,et,yt,B){var ie=[],ct=[];return ie[0]=et[0]-yt[0],ie[1]=et[1]-yt[1],ie[2]=et[2]-yt[2],ct[0]=ie[2]*Math.sin(B)+ie[0]*Math.cos(B),ct[1]=ie[1],ct[2]=ie[2]*Math.cos(B)-ie[0]*Math.sin(B),ke[0]=ct[0]+yt[0],ke[1]=ct[1]+yt[1],ke[2]=ct[2]+yt[2],ke}function vt(ke,et,yt,B){var ie=[],ct=[];return ie[0]=et[0]-yt[0],ie[1]=et[1]-yt[1],ie[2]=et[2]-yt[2],ct[0]=ie[0]*Math.cos(B)-ie[1]*Math.sin(B),ct[1]=ie[0]*Math.sin(B)+ie[1]*Math.cos(B),ct[2]=ie[2],ke[0]=ct[0]+yt[0],ke[1]=ct[1]+yt[1],ke[2]=ct[2]+yt[2],ke}function Jt(ke,et){var yt=ke[0],B=ke[1],ie=ke[2],ct=et[0],Mt=et[1],ht=et[2],Yt=Math.sqrt(yt*yt+B*B+ie*ie),en=Math.sqrt(ct*ct+Mt*Mt+ht*ht),nn=Yt*en,Me=nn&&We(ke,et)/nn;return Math.acos(Math.min(Math.max(Me,-1),1))}function Qe(ke){return ke[0]=0,ke[1]=0,ke[2]=0,ke}function rt(ke){return"vec3("+ke[0]+", "+ke[1]+", "+ke[2]+")"}function bt(ke,et){return ke[0]===et[0]&&ke[1]===et[1]&&ke[2]===et[2]}function ze(ke,et){var yt=ke[0],B=ke[1],ie=ke[2],ct=et[0],Mt=et[1],ht=et[2];return Math.abs(yt-ct)<=w.Ib*Math.max(1,Math.abs(yt),Math.abs(ct))&&Math.abs(B-Mt)<=w.Ib*Math.max(1,Math.abs(B),Math.abs(Mt))&&Math.abs(ie-ht)<=w.Ib*Math.max(1,Math.abs(ie),Math.abs(ht))}var Ze=N,q=null,Y=null,de=fe,Je=null,Te=A,$e=null,xt=function(){var ke=k();return function(et,yt,B,ie,ct,Mt){var ht,Yt;for(yt||(yt=3),B||(B=0),ie?Yt=Math.min(ie*yt+B,et.length):Yt=et.length,ht=B;ht<Yt;ht+=yt)ke[0]=et[ht],ke[1]=et[ht+1],ke[2]=et[ht+2],ct(ke,ke,Mt),et[ht]=ke[0],et[ht+1]=ke[1],et[ht+2]=ke[2];return et}}()},98333:function(ae,ne,b){"use strict";b.d(ne,{AK:function(){return We},Fv:function(){return Ee},I6:function(){return Ot},IH:function(){return x},JG:function(){return S},Ue:function(){return k},al:function(){return A},bA:function(){return ge},d9:function(){return O},fF:function(){return kt},fS:function(){return ue},kE:function(){return Ne},t7:function(){return _t},t8:function(){return R},we:function(){return Ae}});var w=b(49685);function k(){var q=new w.WT(4);return w.WT!=Float32Array&&(q[0]=0,q[1]=0,q[2]=0,q[3]=0),q}function O(q){var Y=new w.WT(4);return Y[0]=q[0],Y[1]=q[1],Y[2]=q[2],Y[3]=q[3],Y}function A(q,Y,de,Je){var Te=new w.WT(4);return Te[0]=q,Te[1]=Y,Te[2]=de,Te[3]=Je,Te}function S(q,Y){return q[0]=Y[0],q[1]=Y[1],q[2]=Y[2],q[3]=Y[3],q}function R(q,Y,de,Je,Te){return q[0]=Y,q[1]=de,q[2]=Je,q[3]=Te,q}function x(q,Y,de){return q[0]=Y[0]+de[0],q[1]=Y[1]+de[1],q[2]=Y[2]+de[2],q[3]=Y[3]+de[3],q}function E(q,Y,de){return q[0]=Y[0]-de[0],q[1]=Y[1]-de[1],q[2]=Y[2]-de[2],q[3]=Y[3]-de[3],q}function N(q,Y,de){return q[0]=Y[0]*de[0],q[1]=Y[1]*de[1],q[2]=Y[2]*de[2],q[3]=Y[3]*de[3],q}function L(q,Y,de){return q[0]=Y[0]/de[0],q[1]=Y[1]/de[1],q[2]=Y[2]/de[2],q[3]=Y[3]/de[3],q}function P(q,Y){return q[0]=Math.ceil(Y[0]),q[1]=Math.ceil(Y[1]),q[2]=Math.ceil(Y[2]),q[3]=Math.ceil(Y[3]),q}function W(q,Y){return q[0]=Math.floor(Y[0]),q[1]=Math.floor(Y[1]),q[2]=Math.floor(Y[2]),q[3]=Math.floor(Y[3]),q}function K(q,Y,de){return q[0]=Math.min(Y[0],de[0]),q[1]=Math.min(Y[1],de[1]),q[2]=Math.min(Y[2],de[2]),q[3]=Math.min(Y[3],de[3]),q}function re(q,Y,de){return q[0]=Math.max(Y[0],de[0]),q[1]=Math.max(Y[1],de[1]),q[2]=Math.max(Y[2],de[2]),q[3]=Math.max(Y[3],de[3]),q}function ye(q,Y){return q[0]=Math.round(Y[0]),q[1]=Math.round(Y[1]),q[2]=Math.round(Y[2]),q[3]=Math.round(Y[3]),q}function ge(q,Y,de){return q[0]=Y[0]*de,q[1]=Y[1]*de,q[2]=Y[2]*de,q[3]=Y[3]*de,q}function ce(q,Y,de,Je){return q[0]=Y[0]+de[0]*Je,q[1]=Y[1]+de[1]*Je,q[2]=Y[2]+de[2]*Je,q[3]=Y[3]+de[3]*Je,q}function xe(q,Y){var de=Y[0]-q[0],Je=Y[1]-q[1],Te=Y[2]-q[2],$e=Y[3]-q[3];return Math.hypot(de,Je,Te,$e)}function fe(q,Y){var de=Y[0]-q[0],Je=Y[1]-q[1],Te=Y[2]-q[2],$e=Y[3]-q[3];return de*de+Je*Je+Te*Te+$e*$e}function Ne(q){var Y=q[0],de=q[1],Je=q[2],Te=q[3];return Math.hypot(Y,de,Je,Te)}function Ae(q){var Y=q[0],de=q[1],Je=q[2],Te=q[3];return Y*Y+de*de+Je*Je+Te*Te}function be(q,Y){return q[0]=-Y[0],q[1]=-Y[1],q[2]=-Y[2],q[3]=-Y[3],q}function Ye(q,Y){return q[0]=1/Y[0],q[1]=1/Y[1],q[2]=1/Y[2],q[3]=1/Y[3],q}function Ee(q,Y){var de=Y[0],Je=Y[1],Te=Y[2],$e=Y[3],xt=de*de+Je*Je+Te*Te+$e*$e;return xt>0&&(xt=1/Math.sqrt(xt)),q[0]=de*xt,q[1]=Je*xt,q[2]=Te*xt,q[3]=$e*xt,q}function We(q,Y){return q[0]*Y[0]+q[1]*Y[1]+q[2]*Y[2]+q[3]*Y[3]}function je(q,Y,de,Je){var Te=de[0]*Je[1]-de[1]*Je[0],$e=de[0]*Je[2]-de[2]*Je[0],xt=de[0]*Je[3]-de[3]*Je[0],ke=de[1]*Je[2]-de[2]*Je[1],et=de[1]*Je[3]-de[3]*Je[1],yt=de[2]*Je[3]-de[3]*Je[2],B=Y[0],ie=Y[1],ct=Y[2],Mt=Y[3];return q[0]=ie*yt-ct*et+Mt*ke,q[1]=-(B*yt)+ct*xt-Mt*$e,q[2]=B*et-ie*xt+Mt*Te,q[3]=-(B*ke)+ie*$e-ct*Te,q}function _t(q,Y,de,Je){var Te=Y[0],$e=Y[1],xt=Y[2],ke=Y[3];return q[0]=Te+Je*(de[0]-Te),q[1]=$e+Je*(de[1]-$e),q[2]=xt+Je*(de[2]-xt),q[3]=ke+Je*(de[3]-ke),q}function It(q,Y){Y=Y||1;var de,Je,Te,$e,xt,ke;do de=glMatrix.RANDOM()*2-1,Je=glMatrix.RANDOM()*2-1,xt=de*de+Je*Je;while(xt>=1);do Te=glMatrix.RANDOM()*2-1,$e=glMatrix.RANDOM()*2-1,ke=Te*Te+$e*$e;while(ke>=1);var et=Math.sqrt((1-xt)/ke);return q[0]=Y*de,q[1]=Y*Je,q[2]=Y*Te*et,q[3]=Y*$e*et,q}function kt(q,Y,de){var Je=Y[0],Te=Y[1],$e=Y[2],xt=Y[3];return q[0]=de[0]*Je+de[4]*Te+de[8]*$e+de[12]*xt,q[1]=de[1]*Je+de[5]*Te+de[9]*$e+de[13]*xt,q[2]=de[2]*Je+de[6]*Te+de[10]*$e+de[14]*xt,q[3]=de[3]*Je+de[7]*Te+de[11]*$e+de[15]*xt,q}function Ut(q,Y,de){var Je=Y[0],Te=Y[1],$e=Y[2],xt=de[0],ke=de[1],et=de[2],yt=de[3],B=yt*Je+ke*$e-et*Te,ie=yt*Te+et*Je-xt*$e,ct=yt*$e+xt*Te-ke*Je,Mt=-xt*Je-ke*Te-et*$e;return q[0]=B*yt+Mt*-xt+ie*-et-ct*-ke,q[1]=ie*yt+Mt*-ke+ct*-xt-B*-et,q[2]=ct*yt+Mt*-et+B*-ke-ie*-xt,q[3]=Y[3],q}function At(q){return q[0]=0,q[1]=0,q[2]=0,q[3]=0,q}function at(q){return"vec4("+q[0]+", "+q[1]+", "+q[2]+", "+q[3]+")"}function Ot(q,Y){return q[0]===Y[0]&&q[1]===Y[1]&&q[2]===Y[2]&&q[3]===Y[3]}function ue(q,Y){var de=q[0],Je=q[1],Te=q[2],$e=q[3],xt=Y[0],ke=Y[1],et=Y[2],yt=Y[3];return Math.abs(de-xt)<=w.Ib*Math.max(1,Math.abs(de),Math.abs(xt))&&Math.abs(Je-ke)<=w.Ib*Math.max(1,Math.abs(Je),Math.abs(ke))&&Math.abs(Te-et)<=w.Ib*Math.max(1,Math.abs(Te),Math.abs(et))&&Math.abs($e-yt)<=w.Ib*Math.max(1,Math.abs($e),Math.abs(yt))}var Ue=null,vt=null,Jt=null,Qe=null,rt=null,bt=null,ze=null,Ze=function(){var q=k();return function(Y,de,Je,Te,$e,xt){var ke,et;for(de||(de=4),Je||(Je=0),Te?et=Math.min(Te*de+Je,Y.length):et=Y.length,ke=Je;ke<et;ke+=de)q[0]=Y[ke],q[1]=Y[ke+1],q[2]=Y[ke+2],q[3]=Y[ke+3],$e(q,q,xt),Y[ke]=q[0],Y[ke+1]=q[1],Y[ke+2]=q[2],Y[ke+3]=q[3];return Y}}()},28282:function(ae,ne,b){var w=b(82354);ae.exports={Graph:w.Graph,json:b(28974),alg:b(12440),version:w.version}},2842:function(ae,ne,b){var w=b(89126);ae.exports=k;function k(O){var A={},S=[],R;function x(E){w.has(A,E)||(A[E]=!0,R.push(E),w.each(O.successors(E),x),w.each(O.predecessors(E),x))}return w.each(O.nodes(),function(E){R=[],x(E),R.length&&S.push(R)}),S}},53984:function(ae,ne,b){var w=b(89126);ae.exports=k;function k(A,S,R){w.isArray(S)||(S=[S]);var x=(A.isDirected()?A.successors:A.neighbors).bind(A),E=[],N={};return w.each(S,function(L){if(!A.hasNode(L))throw new Error("Graph does not have node: "+L);O(A,L,R==="post",N,x,E)}),E}function O(A,S,R,x,E,N){w.has(x,S)||(x[S]=!0,R||N.push(S),w.each(E(S),function(L){O(A,L,R,x,E,N)}),R&&N.push(S))}},84847:function(ae,ne,b){var w=b(63763),k=b(89126);ae.exports=O;function O(A,S,R){return k.transform(A.nodes(),function(x,E){x[E]=w(A,E,S,R)},{})}},63763:function(ae,ne,b){var w=b(89126),k=b(75639);ae.exports=A;var O=w.constant(1);function A(R,x,E,N){return S(R,String(x),E||O,N||function(L){return R.outEdges(L)})}function S(R,x,E,N){var L={},P=new k,W,K,re=function(ye){var ge=ye.v!==W?ye.v:ye.w,ce=L[ge],xe=E(ye),fe=K.distance+xe;if(xe<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+ye+" Weight: "+xe);fe<ce.distance&&(ce.distance=fe,ce.predecessor=W,P.decrease(ge,fe))};for(R.nodes().forEach(function(ye){var ge=ye===x?0:Number.POSITIVE_INFINITY;L[ye]={distance:ge},P.add(ye,ge)});P.size()>0&&(W=P.removeMin(),K=L[W],K.distance!==Number.POSITIVE_INFINITY);)N(W).forEach(re);return L}},9096:function(ae,ne,b){var w=b(89126),k=b(5023);ae.exports=O;function O(A){return w.filter(k(A),function(S){return S.length>1||S.length===1&&A.hasEdge(S[0],S[0])})}},38924:function(ae,ne,b){var w=b(89126);ae.exports=O;var k=w.constant(1);function O(S,R,x){return A(S,R||k,x||function(E){return S.outEdges(E)})}function A(S,R,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,K=R(P);E[L][W]={distance:K,predecessor:L}})}),N.forEach(function(L){var P=E[L];N.forEach(function(W){var K=E[W];N.forEach(function(re){var ye=K[L],ge=P[re],ce=K[re],xe=ye.distance+ge.distance;xe<ce.distance&&(ce.distance=xe,ce.predecessor=ge.predecessor)})})}),E}},12440:function(ae,ne,b){ae.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(ae,ne,b){var w=b(2166);ae.exports=k;function k(O){try{w(O)}catch(A){if(A instanceof w.CycleException)return!1;throw A}return!0}},58828:function(ae,ne,b){var w=b(53984);ae.exports=k;function k(O,A){return w(O,A,"post")}},92648:function(ae,ne,b){var w=b(53984);ae.exports=k;function k(O,A){return w(O,A,"pre")}},80514:function(ae,ne,b){var w=b(89126),k=b(30771),O=b(75639);ae.exports=A;function A(S,R){var x=new k,E={},N=new O,L;function P(K){var re=K.v===L?K.w:K.v,ye=N.priority(re);if(ye!==void 0){var ge=R(K);ge<ye&&(E[re]=L,N.decrease(re,ge))}}if(S.nodeCount()===0)return x;w.each(S.nodes(),function(K){N.add(K,Number.POSITIVE_INFINITY),x.setNode(K)}),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(ae,ne,b){var w=b(89126);ae.exports=k;function k(O){var A=0,S=[],R={},x=[];function E(N){var L=R[N]={onStack:!0,lowlink:A,index:A++};if(S.push(N),O.successors(N).forEach(function(K){w.has(R,K)?R[K].onStack&&(L.lowlink=Math.min(L.lowlink,R[K].index)):(E(K),L.lowlink=Math.min(L.lowlink,R[K].lowlink))}),L.lowlink===L.index){var P=[],W;do W=S.pop(),R[W].onStack=!1,P.push(W);while(N!==W);x.push(P)}}return O.nodes().forEach(function(N){w.has(R,N)||E(N)}),x}},2166:function(ae,ne,b){var w=b(89126);ae.exports=k,k.CycleException=O;function k(A){var S={},R={},x=[];function E(N){if(w.has(R,N))throw new O;w.has(S,N)||(R[N]=!0,S[N]=!0,w.each(A.predecessors(N),E),delete R[N],x.push(N))}if(w.each(A.sinks(),E),w.size(S)!==A.nodeCount())throw new O;return x}function O(){}O.prototype=new Error},75639:function(ae,ne,b){var w=b(89126);ae.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 A=this._keyIndices[O];if(A!==void 0)return this._arr[A].priority},k.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},k.prototype.add=function(O,A){var S=this._keyIndices;if(O=String(O),!w.has(S,O)){var R=this._arr,x=R.length;return S[O]=x,R.push({key:O,priority:A}),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,A){var S=this._keyIndices[O];if(A>this._arr[S].priority)throw new Error("New priority is greater than current priority. Key: "+O+" Old: "+this._arr[S].priority+" New: "+A);this._arr[S].priority=A,this._decrease(S)},k.prototype._heapify=function(O){var A=this._arr,S=2*O,R=S+1,x=O;S<A.length&&(x=A[S].priority<A[x].priority?S:x,R<A.length&&(x=A[R].priority<A[x].priority?R:x),x!==O&&(this._swap(O,x),this._heapify(x)))},k.prototype._decrease=function(O){for(var A=this._arr,S=A[O].priority,R;O!==0&&(R=O>>1,!(A[R].priority<S));)this._swap(O,R),O=R},k.prototype._swap=function(O,A){var S=this._arr,R=this._keyIndices,x=S[O],E=S[A];S[O]=E,S[A]=x,R[E.key]=O,R[x.key]=A}},30771:function(ae,ne,b){"use strict";var w=b(89126);ae.exports=S;var k="\0",O="\0",A="";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 K=arguments,re=this;return w.each(P,function(ye){K.length>1?re.setNode(ye,W):re.setNode(ye)}),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 K=function(re){W.removeEdge(W._edgeObjs[re])};delete this._nodes[P],this._isCompound&&(this._removeFromParentsChildList(P),delete this._parent[P],w.each(this.children(P),function(re){W.setParent(re)}),delete this._children[P]),w.each(w.keys(this._in[P]),K),delete this._in[P],delete this._preds[P],w.each(w.keys(this._out[P]),K),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 K=W;!w.isUndefined(K);K=this.parent(K))if(K===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 K=this;w.each(this._nodes,function(ge,ce){P(ce)&&W.setNode(ce,ge)}),w.each(this._edgeObjs,function(ge){W.hasNode(ge.v)&&W.hasNode(ge.w)&&W.setEdge(ge,K.edge(ge))});var re={};function ye(ge){var ce=K.parent(ge);return ce===void 0||W.hasNode(ce)?(re[ge]=ce,ce):ce in re?re[ce]:ye(ce)}return this._isCompound&&w.each(W.nodes(),function(ge){W.setParent(ge,ye(ge))}),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 K=this,re=arguments;return w.reduce(P,function(ye,ge){return re.length>1?K.setEdge(ye,ge,W):K.setEdge(ye,ge),ge}),this},S.prototype.setEdge=function(){var P,W,K,re,ye=!1,ge=arguments[0];typeof ge=="object"&&ge!==null&&"v"in ge?(P=ge.v,W=ge.w,K=ge.name,arguments.length===2&&(re=arguments[1],ye=!0)):(P=ge,W=arguments[1],K=arguments[3],arguments.length>2&&(re=arguments[2],ye=!0)),P=""+P,W=""+W,w.isUndefined(K)||(K=""+K);var ce=E(this._isDirected,P,W,K);if(w.has(this._edgeLabels,ce))return ye&&(this._edgeLabels[ce]=re),this;if(!w.isUndefined(K)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(P),this.setNode(W),this._edgeLabels[ce]=ye?re:this._defaultEdgeLabelFn(P,W,K);var xe=N(this._isDirected,P,W,K);return P=xe.v,W=xe.w,Object.freeze(xe),this._edgeObjs[ce]=xe,R(this._preds[W],P),R(this._sucs[P],W),this._in[W][ce]=xe,this._out[P][ce]=xe,this._edgeCount++,this},S.prototype.edge=function(P,W,K){var re=arguments.length===1?L(this._isDirected,arguments[0]):E(this._isDirected,P,W,K);return this._edgeLabels[re]},S.prototype.hasEdge=function(P,W,K){var re=arguments.length===1?L(this._isDirected,arguments[0]):E(this._isDirected,P,W,K);return w.has(this._edgeLabels,re)},S.prototype.removeEdge=function(P,W,K){var re=arguments.length===1?L(this._isDirected,arguments[0]):E(this._isDirected,P,W,K),ye=this._edgeObjs[re];return ye&&(P=ye.v,W=ye.w,delete this._edgeLabels[re],delete this._edgeObjs[re],x(this._preds[W],P),x(this._sucs[P],W),delete this._in[W][re],delete this._out[P][re],this._edgeCount--),this},S.prototype.inEdges=function(P,W){var K=this._in[P];if(K){var re=w.values(K);return W?w.filter(re,function(ye){return ye.v===W}):re}},S.prototype.outEdges=function(P,W){var K=this._out[P];if(K){var re=w.values(K);return W?w.filter(re,function(ye){return ye.w===W}):re}},S.prototype.nodeEdges=function(P,W){var K=this.inEdges(P,W);if(K)return K.concat(this.outEdges(P,W))};function R(P,W){P[W]?P[W]++:P[W]=1}function x(P,W){--P[W]||delete P[W]}function E(P,W,K,re){var ye=""+W,ge=""+K;if(!P&&ye>ge){var ce=ye;ye=ge,ge=ce}return ye+A+ge+A+(w.isUndefined(re)?k:re)}function N(P,W,K,re){var ye=""+W,ge=""+K;if(!P&&ye>ge){var ce=ye;ye=ge,ge=ce}var xe={v:ye,w:ge};return re&&(xe.name=re),xe}function L(P,W){return E(P,W.v,W.w,W.name)}},82354:function(ae,ne,b){ae.exports={Graph:b(30771),version:b(49631)}},28974:function(ae,ne,b){var w=b(89126),k=b(30771);ae.exports={write:O,read:R};function O(x){var E={options:{directed:x.isDirected(),multigraph:x.isMultigraph(),compound:x.isCompound()},nodes:A(x),edges:S(x)};return w.isUndefined(x.graph())||(E.value=w.clone(x.graph())),E}function A(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 R(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(ae,ne,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._),ae.exports=w},49631:function(ae){ae.exports="2.1.8"},80817:function(ae){function ne(O,A,S){return(A[0]-O[0])*(S[1]-O[1])-(A[1]-O[1])*(S[0]-O[0])}function b(O){const A=[];for(let S=0;S<O.length;S++){for(;A.length>=2&&ne(A[A.length-2],A[A.length-1],O[S])<=0;)A.pop();A.push(O[S])}return A.pop(),A}function w(O){const A=O.reverse(),S=[];for(let R=0;R<A.length;R++){for(;S.length>=2&&ne(S[S.length-2],S[S.length-1],A[R])<=0;)S.pop();S.push(A[R])}return S.pop(),S}function k(O){const A=b(O),R=w(O).concat(A);return R.push(O[0]),R}ae.exports=k},63652:function(ae){ae.exports={toXy:function(ne,b){return b===void 0?ne.slice():ne.map(function(w){return new Function("pt","return [pt"+b[0]+",pt"+b[1]+"];")(w)})},fromXy:function(ne,b){return b===void 0?ne.slice():ne.map(function(w){return new Function("pt","const o = {}; o"+b[0]+"= pt[0]; o"+b[1]+"= pt[1]; return o;")(w)})}}},58867:function(ae){function ne(w,k){this._cells=[],this._cellSize=k,this._reverseCellSize=1/k;for(let O=0;O<w.length;O++){const A=w[O],S=this.coordToCellNum(A[0]),R=this.coordToCellNum(A[1]);if(this._cells[S])this._cells[S][R]?this._cells[S][R].push(A):this._cells[S][R]=[A];else{const x=[];x[R]=[A],this._cells[S]=x}}}ne.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]),A=this.coordToCellNum(w[2]),S=this.coordToCellNum(w[3]),R=[];for(let x=k;x<=A;x++)for(let E=O;E<=S;E++)for(let N=0;N<this.cellPoints(x,E).length;N++)R.push(this.cellPoints(x,E)[N]);return R},removePoint:function(w){const k=this.coordToCellNum(w[0]),O=this.coordToCellNum(w[1]),A=this._cells[k][O];let S;for(let R=0;R<A.length;R++)if(A[R][0]===w[0]&&A[R][1]===w[1]){S=R;break}return A.splice(S,1),A},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 ne(w,k)}ae.exports=b},1344:function(ae,ne,b){"use strict";const w=b(77444),k=b(58867),O=b(63652),A=b(80817);function S(ce){const xe=[ce[0]];let fe=ce[0];for(let Ne=1;Ne<ce.length;Ne++){const Ae=ce[Ne];(fe[0]!==Ae[0]||fe[1]!==Ae[1])&&xe.push(Ae),fe=Ae}return xe}function R(ce){return ce.sort(function(xe,fe){return xe[0]-fe[0]||xe[1]-fe[1]})}function x(ce,xe){return Math.pow(xe[0]-ce[0],2)+Math.pow(xe[1]-ce[1],2)}function E(ce,xe,fe){const Ne=[xe[0]-ce[0],xe[1]-ce[1]],Ae=[fe[0]-ce[0],fe[1]-ce[1]],be=x(ce,xe),Ye=x(ce,fe);return(Ne[0]*Ae[0]+Ne[1]*Ae[1])/Math.sqrt(be*Ye)}function N(ce,xe){for(let fe=0;fe<xe.length-1;fe++){const Ne=[xe[fe],xe[fe+1]];if(!(ce[0][0]===Ne[0][0]&&ce[0][1]===Ne[0][1]||ce[0][0]===Ne[1][0]&&ce[0][1]===Ne[1][1])&&w(ce,Ne))return!0}return!1}function L(ce){let xe=1/0,fe=1/0,Ne=-1/0,Ae=-1/0;for(let be=ce.length-1;be>=0;be--)ce[be][0]<xe&&(xe=ce[be][0]),ce[be][1]<fe&&(fe=ce[be][1]),ce[be][0]>Ne&&(Ne=ce[be][0]),ce[be][1]>Ae&&(Ae=ce[be][1]);return[Ne-xe,Ae-fe]}function P(ce){return[Math.min(ce[0][0],ce[1][0]),Math.min(ce[0][1],ce[1][1]),Math.max(ce[0][0],ce[1][0]),Math.max(ce[0][1],ce[1][1])]}function W(ce,xe,fe){let Ne=null,Ae=ye,be=ye,Ye,Ee;for(let We=0;We<xe.length;We++)Ye=E(ce[0],ce[1],xe[We]),Ee=E(ce[1],ce[0],xe[We]),Ye>Ae&&Ee>be&&!N([ce[0],xe[We]],fe)&&!N([ce[1],xe[We]],fe)&&(Ae=Ye,be=Ee,Ne=xe[We]);return Ne}function K(ce,xe,fe,Ne,Ae){let be=!1;for(let Ye=0;Ye<ce.length-1;Ye++){const Ee=[ce[Ye],ce[Ye+1]],We=Ee[0][0]+","+Ee[0][1]+","+Ee[1][0]+","+Ee[1][1];if(x(Ee[0],Ee[1])<xe||Ae.has(We))continue;let je=0,_t=P(Ee),It,kt,Ut;do _t=Ne.extendBbox(_t,je),It=_t[2]-_t[0],kt=_t[3]-_t[1],Ut=W(Ee,Ne.rangePoints(_t),ce),je++;while(Ut===null&&(fe[0]>It||fe[1]>kt));It>=fe[0]&&kt>=fe[1]&&Ae.add(We),Ut!==null&&(ce.splice(Ye+1,0,Ut),Ne.removePoint(Ut),be=!0)}return be?K(ce,xe,fe,Ne,Ae):ce}function re(ce,xe,fe){let Ne=xe||20;const Ae=S(R(O.toXy(ce,fe)));if(Ae.length<4){const It=Ae.concat([Ae[0]]);return fe?O.fromXy(It,fe):It}const be=L(Ae),Ye=[be[0]*ge,be[1]*ge],Ee=A(Ae),We=Ae.filter(function(It){return Ee.indexOf(It)<0}),je=Math.ceil(1/(Ae.length/(be[0]*be[1]))),_t=K(Ee,Math.pow(Ne,2),Ye,k(We,je),new Set);return fe?O.fromXy(_t,fe):_t}const ye=Math.cos(90/(180/Math.PI)),ge=.6;ae.exports=re},77444:function(ae){function ne(w,k,O,A,S,R){const x=(R-k)*(O-w)-(A-k)*(S-w);return x>0?!0:!(x<0)}function b(w,k){const O=w[0][0],A=w[0][1],S=w[1][0],R=w[1][1],x=k[0][0],E=k[0][1],N=k[1][0],L=k[1][1];return ne(O,A,x,E,N,L)!==ne(S,R,x,E,N,L)&&ne(O,A,S,R,x,E)!==ne(O,A,S,R,N,L)}ae.exports=b},44091:function(ae,ne,b){"use strict";b.r(ne),b.d(ne,{isAnyArray:function(){return k}});const w=Object.prototype.toString;function k(O){const A=w.call(O);return A.endsWith("Array]")&&!A.includes("Big")}},18552:function(ae,ne,b){var w=b(10852),k=b(55639),O=w(k,"DataView");ae.exports=O},53818:function(ae,ne,b){var w=b(10852),k=b(55639),O=w(k,"Promise");ae.exports=O},58525:function(ae,ne,b){var w=b(10852),k=b(55639),O=w(k,"Set");ae.exports=O},88668:function(ae,ne,b){var w=b(83369),k=b(90619),O=b(72385);function A(S){var R=-1,x=S==null?0:S.length;for(this.__data__=new w;++R<x;)this.add(S[R])}A.prototype.add=A.prototype.push=k,A.prototype.has=O,ae.exports=A},70577:function(ae,ne,b){var w=b(10852),k=b(55639),O=w(k,"WeakMap");ae.exports=O},77412:function(ae){function ne(b,w){for(var k=-1,O=b==null?0:b.length;++k<O&&w(b[k],k,b)!==!1;);return b}ae.exports=ne},34963:function(ae){function ne(b,w){for(var k=-1,O=b==null?0:b.length,A=0,S=[];++k<O;){var R=b[k];w(R,k,b)&&(S[A++]=R)}return S}ae.exports=ne},47443:function(ae,ne,b){var w=b(42118);function k(O,A){var S=O==null?0:O.length;return!!S&&w(O,A,0)>-1}ae.exports=k},1196:function(ae){function ne(b,w,k){for(var O=-1,A=b==null?0:b.length;++O<A;)if(k(w,b[O]))return!0;return!1}ae.exports=ne},29932:function(ae){function ne(b,w){for(var k=-1,O=b==null?0:b.length,A=Array(O);++k<O;)A[k]=w(b[k],k,b);return A}ae.exports=ne},62488:function(ae){function ne(b,w){for(var k=-1,O=w.length,A=b.length;++k<O;)b[A+k]=w[k];return b}ae.exports=ne},62663:function(ae){function ne(b,w,k,O){var A=-1,S=b==null?0:b.length;for(O&&S&&(k=b[++A]);++A<S;)k=w(k,b[A],A,b);return k}ae.exports=ne},82908:function(ae){function ne(b,w){for(var k=-1,O=b==null?0:b.length;++k<O;)if(w(b[k],k,b))return!0;return!1}ae.exports=ne},48983:function(ae,ne,b){var w=b(40371),k=w("length");ae.exports=k},44037:function(ae,ne,b){var w=b(98363),k=b(3674);function O(A,S){return A&&w(S,k(S),A)}ae.exports=O},63886:function(ae,ne,b){var w=b(98363),k=b(81704);function O(A,S){return A&&w(S,k(S),A)}ae.exports=O},85990:function(ae,ne,b){var w=b(46384),k=b(77412),O=b(34865),A=b(44037),S=b(63886),R=b(64626),x=b(278),E=b(18805),N=b(1911),L=b(58234),P=b(46904),W=b(64160),K=b(43824),re=b(29148),ye=b(38517),ge=b(1469),ce=b(44144),xe=b(56688),fe=b(13218),Ne=b(72928),Ae=b(3674),be=b(81704),Ye=1,Ee=2,We=4,je="[object Arguments]",_t="[object Array]",It="[object Boolean]",kt="[object Date]",Ut="[object Error]",At="[object Function]",at="[object GeneratorFunction]",Ot="[object Map]",ue="[object Number]",Ue="[object Object]",vt="[object RegExp]",Jt="[object Set]",Qe="[object String]",rt="[object Symbol]",bt="[object WeakMap]",ze="[object ArrayBuffer]",Ze="[object DataView]",q="[object Float32Array]",Y="[object Float64Array]",de="[object Int8Array]",Je="[object Int16Array]",Te="[object Int32Array]",$e="[object Uint8Array]",xt="[object Uint8ClampedArray]",ke="[object Uint16Array]",et="[object Uint32Array]",yt={};yt[je]=yt[_t]=yt[ze]=yt[Ze]=yt[It]=yt[kt]=yt[q]=yt[Y]=yt[de]=yt[Je]=yt[Te]=yt[Ot]=yt[ue]=yt[Ue]=yt[vt]=yt[Jt]=yt[Qe]=yt[rt]=yt[$e]=yt[xt]=yt[ke]=yt[et]=!0,yt[Ut]=yt[At]=yt[bt]=!1;function B(ie,ct,Mt,ht,Yt,en){var nn,Me=ct&Ye,te=ct&Ee,Fe=ct&We;if(Mt&&(nn=Yt?Mt(ie,ht,Yt,en):Mt(ie)),nn!==void 0)return nn;if(!fe(ie))return ie;var Xe=ge(ie);if(Xe){if(nn=K(ie),!Me)return x(ie,nn)}else{var Pe=W(ie),Ie=Pe==At||Pe==at;if(ce(ie))return R(ie,Me);if(Pe==Ue||Pe==je||Ie&&!Yt){if(nn=te||Ie?{}:ye(ie),!Me)return te?N(ie,S(nn,ie)):E(ie,A(nn,ie))}else{if(!yt[Pe])return Yt?ie:{};nn=re(ie,Pe,Me)}}en||(en=new w);var Ke=en.get(ie);if(Ke)return Ke;en.set(ie,nn),Ne(ie)?ie.forEach(function(pt){nn.add(B(pt,ct,Mt,pt,ie,en))}):xe(ie)&&ie.forEach(function(pt,Ct){nn.set(Ct,B(pt,ct,Mt,Ct,ie,en))});var lt=Fe?te?P:L:te?be:Ae,qe=Xe?void 0:lt(ie);return k(qe||ie,function(pt,Ct){qe&&(Ct=pt,pt=ie[Ct]),O(nn,Ct,B(pt,ct,Mt,Ct,ie,en))}),nn}ae.exports=B},89881:function(ae,ne,b){var w=b(47816),k=b(99291),O=k(w);ae.exports=O},56029:function(ae,ne,b){var w=b(33448);function k(O,A,S){for(var R=-1,x=O.length;++R<x;){var E=O[R],N=A(E);if(N!=null&&(L===void 0?N===N&&!w(N):S(N,L)))var L=N,P=E}return P}ae.exports=k},80760:function(ae,ne,b){var w=b(89881);function k(O,A){var S=[];return w(O,function(R,x,E){A(R,x,E)&&S.push(R)}),S}ae.exports=k},41848:function(ae){function ne(b,w,k,O){for(var A=b.length,S=k+(O?1:-1);O?S--:++S<A;)if(w(b[S],S,b))return S;return-1}ae.exports=ne},21078:function(ae,ne,b){var w=b(62488),k=b(37285);function O(A,S,R,x,E){var N=-1,L=A.length;for(R||(R=k),E||(E=[]);++N<L;){var P=A[N];S>0&&R(P)?S>1?O(P,S-1,R,x,E):w(E,P):x||(E[E.length]=P)}return E}ae.exports=O},47816:function(ae,ne,b){var w=b(28483),k=b(3674);function O(A,S){return A&&w(A,S,k)}ae.exports=O},97786:function(ae,ne,b){var w=b(71811),k=b(40327);function O(A,S){S=w(S,A);for(var R=0,x=S.length;A!=null&&R<x;)A=A[k(S[R++])];return R&&R==x?A:void 0}ae.exports=O},64055:function(ae,ne,b){var w=b(62488),k=b(1469);function O(A,S,R){var x=S(A);return k(A)?x:w(x,R(A))}ae.exports=O},53325:function(ae){function ne(b,w){return b>w}ae.exports=ne},78565:function(ae){var ne=Object.prototype,b=ne.hasOwnProperty;function w(k,O){return k!=null&&b.call(k,O)}ae.exports=w},13:function(ae){function ne(b,w){return b!=null&&w in Object(b)}ae.exports=ne},42118:function(ae,ne,b){var w=b(41848),k=b(62722),O=b(42351);function A(S,R,x){return R===R?O(S,R,x):w(S,k,x)}ae.exports=A},90939:function(ae,ne,b){var w=b(2492),k=b(37005);function O(A,S,R,x,E){return A===S?!0:A==null||S==null||!k(A)&&!k(S)?A!==A&&S!==S:w(A,S,R,x,O,E)}ae.exports=O},2492:function(ae,ne,b){var w=b(46384),k=b(67114),O=b(18351),A=b(16096),S=b(64160),R=b(1469),x=b(44144),E=b(36719),N=1,L="[object Arguments]",P="[object Array]",W="[object Object]",K=Object.prototype,re=K.hasOwnProperty;function ye(ge,ce,xe,fe,Ne,Ae){var be=R(ge),Ye=R(ce),Ee=be?P:S(ge),We=Ye?P:S(ce);Ee=Ee==L?W:Ee,We=We==L?W:We;var je=Ee==W,_t=We==W,It=Ee==We;if(It&&x(ge)){if(!x(ce))return!1;be=!0,je=!1}if(It&&!je)return Ae||(Ae=new w),be||E(ge)?k(ge,ce,xe,fe,Ne,Ae):O(ge,ce,Ee,xe,fe,Ne,Ae);if(!(xe&N)){var kt=je&&re.call(ge,"__wrapped__"),Ut=_t&&re.call(ce,"__wrapped__");if(kt||Ut){var At=kt?ge.value():ge,at=Ut?ce.value():ce;return Ae||(Ae=new w),Ne(At,at,xe,fe,Ae)}}return It?(Ae||(Ae=new w),A(ge,ce,xe,fe,Ne,Ae)):!1}ae.exports=ye},25588:function(ae,ne,b){var w=b(64160),k=b(37005),O="[object Map]";function A(S){return k(S)&&w(S)==O}ae.exports=A},2958:function(ae,ne,b){var w=b(46384),k=b(90939),O=1,A=2;function S(R,x,E,N){var L=E.length,P=L,W=!N;if(R==null)return!P;for(R=Object(R);L--;){var K=E[L];if(W&&K[2]?K[1]!==R[K[0]]:!(K[0]in R))return!1}for(;++L<P;){K=E[L];var re=K[0],ye=R[re],ge=K[1];if(W&&K[2]){if(ye===void 0&&!(re in R))return!1}else{var ce=new w;if(N)var xe=N(ye,ge,re,R,x,ce);if(!(xe===void 0?k(ge,ye,O|A,N,ce):xe))return!1}}return!0}ae.exports=S},62722:function(ae){function ne(b){return b!==b}ae.exports=ne},29221:function(ae,ne,b){var w=b(64160),k=b(37005),O="[object Set]";function A(S){return k(S)&&w(S)==O}ae.exports=A},67206:function(ae,ne,b){var w=b(91573),k=b(16432),O=b(6557),A=b(1469),S=b(39601);function R(x){return typeof x=="function"?x:x==null?O:typeof x=="object"?A(x)?k(x[0],x[1]):w(x):S(x)}ae.exports=R},280:function(ae,ne,b){var w=b(25726),k=b(86916),O=Object.prototype,A=O.hasOwnProperty;function S(R){if(!w(R))return k(R);var x=[];for(var E in Object(R))A.call(R,E)&&E!="constructor"&&x.push(E);return x}ae.exports=S},70433:function(ae){function ne(b,w){return b<w}ae.exports=ne},69199:function(ae,ne,b){var w=b(89881),k=b(98612);function O(A,S){var R=-1,x=k(A)?Array(A.length):[];return w(A,function(E,N,L){x[++R]=S(E,N,L)}),x}ae.exports=O},91573:function(ae,ne,b){var w=b(2958),k=b(1499),O=b(42634);function A(S){var R=k(S);return R.length==1&&R[0][2]?O(R[0][0],R[0][1]):function(x){return x===S||w(x,S,R)}}ae.exports=A},16432:function(ae,ne,b){var w=b(90939),k=b(27361),O=b(79095),A=b(15403),S=b(89162),R=b(42634),x=b(40327),E=1,N=2;function L(P,W){return A(P)&&S(W)?R(x(P),W):function(K){var re=k(K,P);return re===void 0&&re===W?O(K,P):w(W,re,E|N)}}ae.exports=L},82689:function(ae,ne,b){var w=b(29932),k=b(97786),O=b(67206),A=b(69199),S=b(63922),R=b(7518),x=b(85022),E=b(6557),N=b(1469);function L(P,W,K){W.length?W=w(W,function(ge){return N(ge)?function(ce){return k(ce,ge.length===1?ge[0]:ge)}:ge}):W=[E];var re=-1;W=w(W,R(O));var ye=A(P,function(ge,ce,xe){var fe=w(W,function(Ne){return Ne(ge)});return{criteria:fe,index:++re,value:ge}});return S(ye,function(ge,ce){return x(ge,ce,K)})}ae.exports=L},25970:function(ae,ne,b){var w=b(63012),k=b(79095);function O(A,S){return w(A,S,function(R,x){return k(A,x)})}ae.exports=O},63012:function(ae,ne,b){var w=b(97786),k=b(10611),O=b(71811);function A(S,R,x){for(var E=-1,N=R.length,L={};++E<N;){var P=R[E],W=w(S,P);x(W,P)&&k(L,O(P,S),W)}return L}ae.exports=A},40371:function(ae){function ne(b){return function(w){return w==null?void 0:w[b]}}ae.exports=ne},79152:function(ae,ne,b){var w=b(97786);function k(O){return function(A){return w(A,O)}}ae.exports=k},40098:function(ae){var ne=Math.ceil,b=Math.max;function w(k,O,A,S){for(var R=-1,x=b(ne((O-k)/(A||1)),0),E=Array(x);x--;)E[S?x:++R]=k,k+=A;return E}ae.exports=w},10107:function(ae){function ne(b,w,k,O,A){return A(b,function(S,R,x){k=O?(O=!1,S):w(k,S,R,x)}),k}ae.exports=ne},10611:function(ae,ne,b){var w=b(34865),k=b(71811),O=b(65776),A=b(13218),S=b(40327);function R(x,E,N,L){if(!A(x))return x;E=k(E,x);for(var P=-1,W=E.length,K=W-1,re=x;re!=null&&++P<W;){var ye=S(E[P]),ge=N;if(ye==="__proto__"||ye==="constructor"||ye==="prototype")return x;if(P!=K){var ce=re[ye];ge=L?L(ce,ye,re):void 0,ge===void 0&&(ge=A(ce)?ce:O(E[P+1])?[]:{})}w(re,ye,ge),re=re[ye]}return x}ae.exports=R},63922:function(ae){function ne(b,w){var k=b.length;for(b.sort(w);k--;)b[k]=b[k].value;return b}ae.exports=ne},80531:function(ae,ne,b){var w=b(62705),k=b(29932),O=b(1469),A=b(33448),S=1/0,R=w?w.prototype:void 0,x=R?R.toString:void 0;function E(N){if(typeof N=="string")return N;if(O(N))return k(N,E)+"";if(A(N))return x?x.call(N):"";var L=N+"";return L=="0"&&1/N==-S?"-0":L}ae.exports=E},27561:function(ae,ne,b){var w=b(67990),k=/^\s+/;function O(A){return A&&A.slice(0,w(A)+1).replace(k,"")}ae.exports=O},45652:function(ae,ne,b){var w=b(88668),k=b(47443),O=b(1196),A=b(74757),S=b(23593),R=b(21814),x=200;function E(N,L,P){var W=-1,K=k,re=N.length,ye=!0,ge=[],ce=ge;if(P)ye=!1,K=O;else if(re>=x){var xe=L?null:S(N);if(xe)return R(xe);ye=!1,K=A,ce=new w}else ce=L?[]:ge;e:for(;++W<re;){var fe=N[W],Ne=L?L(fe):fe;if(fe=P||fe!==0?fe:0,ye&&Ne===Ne){for(var Ae=ce.length;Ae--;)if(ce[Ae]===Ne)continue e;L&&ce.push(Ne),ge.push(fe)}else K(ce,Ne,P)||(ce!==ge&&ce.push(Ne),ge.push(fe))}return ge}ae.exports=E},47415:function(ae,ne,b){var w=b(29932);function k(O,A){return w(A,function(S){return O[S]})}ae.exports=k},1757:function(ae){function ne(b,w,k){for(var O=-1,A=b.length,S=w.length,R={};++O<A;){var x=O<S?w[O]:void 0;k(R,b[O],x)}return R}ae.exports=ne},74757:function(ae){function ne(b,w){return b.has(w)}ae.exports=ne},54290:function(ae,ne,b){var w=b(6557);function k(O){return typeof O=="function"?O:w}ae.exports=k},71811:function(ae,ne,b){var w=b(1469),k=b(15403),O=b(55514),A=b(79833);function S(R,x){return w(R)?R:k(R,x)?[R]:O(A(R))}ae.exports=S},57157:function(ae,ne,b){var w=b(74318);function k(O,A){var S=A?w(O.buffer):O.buffer;return new O.constructor(S,O.byteOffset,O.byteLength)}ae.exports=k},93147:function(ae){var ne=/\w*$/;function b(w){var k=new w.constructor(w.source,ne.exec(w));return k.lastIndex=w.lastIndex,k}ae.exports=b},40419:function(ae,ne,b){var w=b(62705),k=w?w.prototype:void 0,O=k?k.valueOf:void 0;function A(S){return O?Object(O.call(S)):{}}ae.exports=A},26393:function(ae,ne,b){var w=b(33448);function k(O,A){if(O!==A){var S=O!==void 0,R=O===null,x=O===O,E=w(O),N=A!==void 0,L=A===null,P=A===A,W=w(A);if(!L&&!W&&!E&&O>A||E&&N&&P&&!L&&!W||R&&N&&P||!S&&P||!x)return 1;if(!R&&!E&&!W&&O<A||W&&S&&x&&!R&&!E||L&&S&&x||!N&&x||!P)return-1}return 0}ae.exports=k},85022:function(ae,ne,b){var w=b(26393);function k(O,A,S){for(var R=-1,x=O.criteria,E=A.criteria,N=x.length,L=S.length;++R<N;){var P=w(x[R],E[R]);if(P){if(R>=L)return P;var W=S[R];return P*(W=="desc"?-1:1)}}return O.index-A.index}ae.exports=k},18805:function(ae,ne,b){var w=b(98363),k=b(99551);function O(A,S){return w(A,k(A),S)}ae.exports=O},1911:function(ae,ne,b){var w=b(98363),k=b(51442);function O(A,S){return w(A,k(A),S)}ae.exports=O},99291:function(ae,ne,b){var w=b(98612);function k(O,A){return function(S,R){if(S==null)return S;if(!w(S))return O(S,R);for(var x=S.length,E=A?x:-1,N=Object(S);(A?E--:++E<x)&&R(N[E],E,N)!==!1;);return S}}ae.exports=k},67740:function(ae,ne,b){var w=b(67206),k=b(98612),O=b(3674);function A(S){return function(R,x,E){var N=Object(R);if(!k(R)){var L=w(x,3);R=O(R),x=function(W){return L(N[W],W,N)}}var P=S(R,x,E);return P>-1?N[L?R[P]:P]:void 0}}ae.exports=A},47445:function(ae,ne,b){var w=b(40098),k=b(16612),O=b(18601);function A(S){return function(R,x,E){return E&&typeof E!="number"&&k(R,x,E)&&(x=E=void 0),R=O(R),x===void 0?(x=R,R=0):x=O(x),E=E===void 0?R<x?1:-1:O(E),w(R,x,E,S)}}ae.exports=A},23593:function(ae,ne,b){var w=b(58525),k=b(50308),O=b(21814),A=1/0,S=w&&1/O(new w([,-0]))[1]==A?function(R){return new w(R)}:k;ae.exports=S},67114:function(ae,ne,b){var w=b(88668),k=b(82908),O=b(74757),A=1,S=2;function R(x,E,N,L,P,W){var K=N&A,re=x.length,ye=E.length;if(re!=ye&&!(K&&ye>re))return!1;var ge=W.get(x),ce=W.get(E);if(ge&&ce)return ge==E&&ce==x;var xe=-1,fe=!0,Ne=N&S?new w:void 0;for(W.set(x,E),W.set(E,x);++xe<re;){var Ae=x[xe],be=E[xe];if(L)var Ye=K?L(be,Ae,xe,E,x,W):L(Ae,be,xe,x,E,W);if(Ye!==void 0){if(Ye)continue;fe=!1;break}if(Ne){if(!k(E,function(Ee,We){if(!O(Ne,We)&&(Ae===Ee||P(Ae,Ee,N,L,W)))return Ne.push(We)})){fe=!1;break}}else if(!(Ae===be||P(Ae,be,N,L,W))){fe=!1;break}}return W.delete(x),W.delete(E),fe}ae.exports=R},18351:function(ae,ne,b){var w=b(62705),k=b(11149),O=b(77813),A=b(67114),S=b(68776),R=b(21814),x=1,E=2,N="[object Boolean]",L="[object Date]",P="[object Error]",W="[object Map]",K="[object Number]",re="[object RegExp]",ye="[object Set]",ge="[object String]",ce="[object Symbol]",xe="[object ArrayBuffer]",fe="[object DataView]",Ne=w?w.prototype:void 0,Ae=Ne?Ne.valueOf:void 0;function be(Ye,Ee,We,je,_t,It,kt){switch(We){case fe:if(Ye.byteLength!=Ee.byteLength||Ye.byteOffset!=Ee.byteOffset)return!1;Ye=Ye.buffer,Ee=Ee.buffer;case xe:return!(Ye.byteLength!=Ee.byteLength||!It(new k(Ye),new k(Ee)));case N:case L:case K:return O(+Ye,+Ee);case P:return Ye.name==Ee.name&&Ye.message==Ee.message;case re:case ge:return Ye==Ee+"";case W:var Ut=S;case ye:var At=je&x;if(Ut||(Ut=R),Ye.size!=Ee.size&&!At)return!1;var at=kt.get(Ye);if(at)return at==Ee;je|=E,kt.set(Ye,Ee);var Ot=A(Ut(Ye),Ut(Ee),je,_t,It,kt);return kt.delete(Ye),Ot;case ce:if(Ae)return Ae.call(Ye)==Ae.call(Ee)}return!1}ae.exports=be},16096:function(ae,ne,b){var w=b(58234),k=1,O=Object.prototype,A=O.hasOwnProperty;function S(R,x,E,N,L,P){var W=E&k,K=w(R),re=K.length,ye=w(x),ge=ye.length;if(re!=ge&&!W)return!1;for(var ce=re;ce--;){var xe=K[ce];if(!(W?xe in x:A.call(x,xe)))return!1}var fe=P.get(R),Ne=P.get(x);if(fe&&Ne)return fe==x&&Ne==R;var Ae=!0;P.set(R,x),P.set(x,R);for(var be=W;++ce<re;){xe=K[ce];var Ye=R[xe],Ee=x[xe];if(N)var We=W?N(Ee,Ye,xe,x,R,P):N(Ye,Ee,xe,R,x,P);if(!(We===void 0?Ye===Ee||L(Ye,Ee,E,N,P):We)){Ae=!1;break}be||(be=xe=="constructor")}if(Ae&&!be){var je=R.constructor,_t=x.constructor;je!=_t&&"constructor"in R&&"constructor"in x&&!(typeof je=="function"&&je instanceof je&&typeof _t=="function"&&_t instanceof _t)&&(Ae=!1)}return P.delete(R),P.delete(x),Ae}ae.exports=S},99021:function(ae,ne,b){var w=b(85564),k=b(45357),O=b(30061);function A(S){return O(k(S,void 0,w),S+"")}ae.exports=A},58234:function(ae,ne,b){var w=b(64055),k=b(99551),O=b(3674);function A(S){return w(S,O,k)}ae.exports=A},46904:function(ae,ne,b){var w=b(64055),k=b(51442),O=b(81704);function A(S){return w(S,O,k)}ae.exports=A},1499:function(ae,ne,b){var w=b(89162),k=b(3674);function O(A){for(var S=k(A),R=S.length;R--;){var x=S[R],E=A[x];S[R]=[x,E,w(E)]}return S}ae.exports=O},99551:function(ae,ne,b){var w=b(34963),k=b(70479),O=Object.prototype,A=O.propertyIsEnumerable,S=Object.getOwnPropertySymbols,R=S?function(x){return x==null?[]:(x=Object(x),w(S(x),function(E){return A.call(x,E)}))}:k;ae.exports=R},51442:function(ae,ne,b){var w=b(62488),k=b(85924),O=b(99551),A=b(70479),S=Object.getOwnPropertySymbols,R=S?function(x){for(var E=[];x;)w(E,O(x)),x=k(x);return E}:A;ae.exports=R},64160:function(ae,ne,b){var w=b(18552),k=b(57071),O=b(53818),A=b(58525),S=b(70577),R=b(44239),x=b(80346),E="[object Map]",N="[object Object]",L="[object Promise]",P="[object Set]",W="[object WeakMap]",K="[object DataView]",re=x(w),ye=x(k),ge=x(O),ce=x(A),xe=x(S),fe=R;(w&&fe(new w(new ArrayBuffer(1)))!=K||k&&fe(new k)!=E||O&&fe(O.resolve())!=L||A&&fe(new A)!=P||S&&fe(new S)!=W)&&(fe=function(Ne){var Ae=R(Ne),be=Ae==N?Ne.constructor:void 0,Ye=be?x(be):"";if(Ye)switch(Ye){case re:return K;case ye:return E;case ge:return L;case ce:return P;case xe:return W}return Ae}),ae.exports=fe},222:function(ae,ne,b){var w=b(71811),k=b(35694),O=b(1469),A=b(65776),S=b(41780),R=b(40327);function x(E,N,L){N=w(N,E);for(var P=-1,W=N.length,K=!1;++P<W;){var re=R(N[P]);if(!(K=E!=null&&L(E,re)))break;E=E[re]}return K||++P!=W?K:(W=E==null?0:E.length,!!W&&S(W)&&A(re,W)&&(O(E)||k(E)))}ae.exports=x},62689:function(ae){var ne="\\ud800-\\udfff",b="\\u0300-\\u036f",w="\\ufe20-\\ufe2f",k="\\u20d0-\\u20ff",O=b+w+k,A="\\ufe0e\\ufe0f",S="\\u200d",R=RegExp("["+S+ne+O+A+"]");function x(E){return R.test(E)}ae.exports=x},43824:function(ae){var ne=Object.prototype,b=ne.hasOwnProperty;function w(k){var O=k.length,A=new k.constructor(O);return O&&typeof k[0]=="string"&&b.call(k,"index")&&(A.index=k.index,A.input=k.input),A}ae.exports=w},29148:function(ae,ne,b){var w=b(74318),k=b(57157),O=b(93147),A=b(40419),S=b(77133),R="[object Boolean]",x="[object Date]",E="[object Map]",N="[object Number]",L="[object RegExp]",P="[object Set]",W="[object String]",K="[object Symbol]",re="[object ArrayBuffer]",ye="[object DataView]",ge="[object Float32Array]",ce="[object Float64Array]",xe="[object Int8Array]",fe="[object Int16Array]",Ne="[object Int32Array]",Ae="[object Uint8Array]",be="[object Uint8ClampedArray]",Ye="[object Uint16Array]",Ee="[object Uint32Array]";function We(je,_t,It){var kt=je.constructor;switch(_t){case re:return w(je);case R:case x:return new kt(+je);case ye:return k(je,It);case ge:case ce:case xe:case fe:case Ne:case Ae:case be:case Ye:case Ee:return S(je,It);case E:return new kt;case N:case W:return new kt(je);case L:return O(je);case P:return new kt;case K:return A(je)}}ae.exports=We},37285:function(ae,ne,b){var w=b(62705),k=b(35694),O=b(1469),A=w?w.isConcatSpreadable:void 0;function S(R){return O(R)||k(R)||!!(A&&R&&R[A])}ae.exports=S},15403:function(ae,ne,b){var w=b(1469),k=b(33448),O=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,A=/^\w*$/;function S(R,x){if(w(R))return!1;var E=typeof R;return E=="number"||E=="symbol"||E=="boolean"||R==null||k(R)?!0:A.test(R)||!O.test(R)||x!=null&&R in Object(x)}ae.exports=S},89162:function(ae,ne,b){var w=b(13218);function k(O){return O===O&&!w(O)}ae.exports=k},68776:function(ae){function ne(b){var w=-1,k=Array(b.size);return b.forEach(function(O,A){k[++w]=[A,O]}),k}ae.exports=ne},42634:function(ae){function ne(b,w){return function(k){return k==null?!1:k[b]===w&&(w!==void 0||b in Object(k))}}ae.exports=ne},24523:function(ae,ne,b){var w=b(88306),k=500;function O(A){var S=w(A,function(x){return R.size===k&&R.clear(),x}),R=S.cache;return S}ae.exports=O},86916:function(ae,ne,b){var w=b(5569),k=w(Object.keys,Object);ae.exports=k},90619:function(ae){var ne="__lodash_hash_undefined__";function b(w){return this.__data__.set(w,ne),this}ae.exports=b},72385:function(ae){function ne(b){return this.__data__.has(b)}ae.exports=ne},21814:function(ae){function ne(b){var w=-1,k=Array(b.size);return b.forEach(function(O){k[++w]=O}),k}ae.exports=ne},42351:function(ae){function ne(b,w,k){for(var O=k-1,A=b.length;++O<A;)if(b[O]===w)return O;return-1}ae.exports=ne},88016:function(ae,ne,b){var w=b(48983),k=b(62689),O=b(21903);function A(S){return k(S)?O(S):w(S)}ae.exports=A},55514:function(ae,ne,b){var w=b(24523),k=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,O=/\\(\\)?/g,A=w(function(S){var R=[];return S.charCodeAt(0)===46&&R.push(""),S.replace(k,function(x,E,N,L){R.push(N?L.replace(O,"$1"):E||x)}),R});ae.exports=A},40327:function(ae,ne,b){var w=b(33448),k=1/0;function O(A){if(typeof A=="string"||w(A))return A;var S=A+"";return S=="0"&&1/A==-k?"-0":S}ae.exports=O},67990:function(ae){var ne=/\s/;function b(w){for(var k=w.length;k--&&ne.test(w.charAt(k)););return k}ae.exports=b},21903:function(ae){var ne="\\ud800-\\udfff",b="\\u0300-\\u036f",w="\\ufe20-\\ufe2f",k="\\u20d0-\\u20ff",O=b+w+k,A="\\ufe0e\\ufe0f",S="["+ne+"]",R="["+O+"]",x="\\ud83c[\\udffb-\\udfff]",E="(?:"+R+"|"+x+")",N="[^"+ne+"]",L="(?:\\ud83c[\\udde6-\\uddff]){2}",P="[\\ud800-\\udbff][\\udc00-\\udfff]",W="\\u200d",K=E+"?",re="["+A+"]?",ye="(?:"+W+"(?:"+[N,L,P].join("|")+")"+re+K+")*",ge=re+K+ye,ce="(?:"+[N+R+"?",R,L,P,S].join("|")+")",xe=RegExp(x+"(?="+x+")|"+ce+ge,"g");function fe(Ne){for(var Ae=xe.lastIndex=0;xe.test(Ne);)++Ae;return Ae}ae.exports=fe},66678:function(ae,ne,b){var w=b(85990),k=4;function O(A){return w(A,k)}ae.exports=O},50361:function(ae,ne,b){var w=b(85990),k=1,O=4;function A(S){return w(S,k|O)}ae.exports=A},91747:function(ae,ne,b){var w=b(18460),k=b(77813),O=b(16612),A=b(81704),S=Object.prototype,R=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 K=N[L],re=A(K),ye=-1,ge=re.length;++ye<ge;){var ce=re[ye],xe=E[ce];(xe===void 0||k(xe,S[ce])&&!R.call(E,ce))&&(E[ce]=K[ce])}return E});ae.exports=x},85768:function(ae,ne,b){ae.exports=b(84486)},63105:function(ae,ne,b){var w=b(34963),k=b(80760),O=b(67206),A=b(1469);function S(R,x){var E=A(R)?w:k;return E(R,O(x,3))}ae.exports=S},13311:function(ae,ne,b){var w=b(67740),k=b(30998),O=w(k);ae.exports=O},30998:function(ae,ne,b){var w=b(41848),k=b(67206),O=b(40554),A=Math.max;function S(R,x,E){var N=R==null?0:R.length;if(!N)return-1;var L=E==null?0:O(E);return L<0&&(L=A(N+L,0)),w(R,k(x,3),L)}ae.exports=S},85564:function(ae,ne,b){var w=b(21078);function k(O){var A=O==null?0:O.length;return A?w(O,1):[]}ae.exports=k},84486:function(ae,ne,b){var w=b(77412),k=b(89881),O=b(54290),A=b(1469);function S(R,x){var E=A(R)?w:k;return E(R,O(x))}ae.exports=S},62620:function(ae,ne,b){var w=b(28483),k=b(54290),O=b(81704);function A(S,R){return S==null?S:w(S,k(R),O)}ae.exports=A},27361:function(ae,ne,b){var w=b(97786);function k(O,A,S){var R=O==null?void 0:w(O,A);return R===void 0?S:R}ae.exports=k},18721:function(ae,ne,b){var w=b(78565),k=b(222);function O(A,S){return A!=null&&k(A,S,w)}ae.exports=O},79095:function(ae,ne,b){var w=b(13),k=b(222);function O(A,S){return A!=null&&k(A,S,w)}ae.exports=O},58367:function(ae,ne,b){var w=b(280),k=b(64160),O=b(35694),A=b(1469),S=b(98612),R=b(44144),x=b(25726),E=b(36719),N="[object Map]",L="[object Set]",P=Object.prototype,W=P.hasOwnProperty;function K(re){if(re==null)return!0;if(S(re)&&(A(re)||typeof re=="string"||typeof re.splice=="function"||R(re)||E(re)||O(re)))return!re.length;var ye=k(re);if(ye==N||ye==L)return!re.size;if(x(re))return!w(re).length;for(var ge in re)if(W.call(re,ge))return!1;return!0}ae.exports=K},56688:function(ae,ne,b){var w=b(25588),k=b(7518),O=b(31167),A=O&&O.isMap,S=A?k(A):w;ae.exports=S},72928:function(ae,ne,b){var w=b(29221),k=b(7518),O=b(31167),A=O&&O.isSet,S=A?k(A):w;ae.exports=S},47037:function(ae,ne,b){var w=b(44239),k=b(1469),O=b(37005),A="[object String]";function S(R){return typeof R=="string"||!k(R)&&O(R)&&w(R)==A}ae.exports=S},33448:function(ae,ne,b){var w=b(44239),k=b(37005),O="[object Symbol]";function A(S){return typeof S=="symbol"||k(S)&&w(S)==O}ae.exports=A},52353:function(ae){function ne(b){return b===void 0}ae.exports=ne},3674:function(ae,ne,b){var w=b(14636),k=b(280),O=b(98612);function A(S){return O(S)?w(S):k(S)}ae.exports=A},10928:function(ae){function ne(b){var w=b==null?0:b.length;return w?b[w-1]:void 0}ae.exports=ne},35161:function(ae,ne,b){var w=b(29932),k=b(67206),O=b(69199),A=b(1469);function S(R,x){var E=A(R)?w:O;return E(R,k(x,3))}ae.exports=S},8521:function(ae,ne,b){var w=b(89465),k=b(47816),O=b(67206);function A(S,R){var x={};return R=O(R,3),k(S,function(E,N,L){w(x,N,R(E,N,L))}),x}ae.exports=A},6162:function(ae,ne,b){var w=b(56029),k=b(53325),O=b(6557);function A(S){return S&&S.length?w(S,O,k):void 0}ae.exports=A},88306:function(ae,ne,b){var w=b(83369),k="Expected a function";function O(A,S){if(typeof A!="function"||S!=null&&typeof S!="function")throw new TypeError(k);var R=function(){var x=arguments,E=S?S.apply(this,x):x[0],N=R.cache;if(N.has(E))return N.get(E);var L=A.apply(this,x);return R.cache=N.set(E,L)||N,L};return R.cache=new(O.Cache||w),R}O.Cache=w,ae.exports=O},53632:function(ae,ne,b){var w=b(56029),k=b(70433),O=b(6557);function A(S){return S&&S.length?w(S,O,k):void 0}ae.exports=A},22762:function(ae,ne,b){var w=b(56029),k=b(67206),O=b(70433);function A(S,R){return S&&S.length?w(S,k(R,2),O):void 0}ae.exports=A},50308:function(ae){function ne(){}ae.exports=ne},7771:function(ae,ne,b){var w=b(55639),k=function(){return w.Date.now()};ae.exports=k},78718:function(ae,ne,b){var w=b(25970),k=b(99021),O=k(function(A,S){return A==null?{}:w(A,S)});ae.exports=O},39601:function(ae,ne,b){var w=b(40371),k=b(79152),O=b(15403),A=b(40327);function S(R){return O(R)?w(A(R)):k(R)}ae.exports=S},96026:function(ae,ne,b){var w=b(47445),k=w();ae.exports=k},54061:function(ae,ne,b){var w=b(62663),k=b(89881),O=b(67206),A=b(10107),S=b(1469);function R(x,E,N){var L=S(x)?w:A,P=arguments.length<3;return L(x,O(E,4),N,P,k)}ae.exports=R},84238:function(ae,ne,b){var w=b(280),k=b(64160),O=b(98612),A=b(47037),S=b(88016),R="[object Map]",x="[object Set]";function E(N){if(N==null)return 0;if(O(N))return A(N)?S(N):N.length;var L=k(N);return L==R||L==x?N.size:w(N).length}ae.exports=E},89734:function(ae,ne,b){var w=b(21078),k=b(82689),O=b(18460),A=b(16612),S=O(function(R,x){if(R==null)return[];var E=x.length;return E>1&&A(R,x[0],x[1])?x=[]:E>2&&A(x[0],x[1],x[2])&&(x=[x[0]]),k(R,w(x,1),[])});ae.exports=S},70479:function(ae){function ne(){return[]}ae.exports=ne},18601:function(ae,ne,b){var w=b(14841),k=1/0,O=17976931348623157e292;function A(S){if(!S)return S===0?S:0;if(S=w(S),S===k||S===-k){var R=S<0?-1:1;return R*O}return S===S?S:0}ae.exports=A},40554:function(ae,ne,b){var w=b(18601);function k(O){var A=w(O),S=A%1;return A===A?S?A-S:A:0}ae.exports=k},14841:function(ae,ne,b){var w=b(27561),k=b(13218),O=b(33448),A=NaN,S=/^[-+]0x[0-9a-f]+$/i,R=/^0b[01]+$/i,x=/^0o[0-7]+$/i,E=parseInt;function N(L){if(typeof L=="number")return L;if(O(L))return A;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=R.test(L);return W||x.test(L)?E(L.slice(2),W?2:8):S.test(L)?A:+L}ae.exports=N},79833:function(ae,ne,b){var w=b(80531);function k(O){return O==null?"":w(O)}ae.exports=k},68718:function(ae,ne,b){var w=b(77412),k=b(3118),O=b(47816),A=b(67206),S=b(85924),R=b(1469),x=b(44144),E=b(23560),N=b(13218),L=b(36719);function P(W,K,re){var ye=R(W),ge=ye||x(W)||L(W);if(K=A(K,4),re==null){var ce=W&&W.constructor;ge?re=ye?new ce:[]:N(W)?re=E(ce)?k(S(W)):{}:re={}}return(ge?w:O)(W,function(xe,fe,Ne){return K(re,xe,fe,Ne)}),re}ae.exports=P},93386:function(ae,ne,b){var w=b(21078),k=b(18460),O=b(45652),A=b(29246),S=k(function(R){return O(w(R,1,A,!0))});ae.exports=S},73955:function(ae,ne,b){var w=b(79833),k=0;function O(A){var S=++k;return w(A)+S}ae.exports=O},52628:function(ae,ne,b){var w=b(47415),k=b(3674);function O(A){return A==null?[]:w(A,k(A))}ae.exports=O},7287:function(ae,ne,b){var w=b(34865),k=b(1757);function O(A,S){return k(A||[],S||[],w)}ae.exports=O},75823:function(ae,ne,b){"use strict";b.r(ne),b.d(ne,{default:function(){return A}});var w=b(44091);function k(S){var R=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=R.fromIndex,E=x===void 0?0:x,N=R.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 R=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=R.fromIndex,E=x===void 0?0:x,N=R.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 A(S){var R=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(R.output!==void 0){if(!(0,w.isAnyArray)(R.output))throw new TypeError("output option must be an array if specified");x=R.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=R.min,P=L===void 0?R.autoMinMax?E:0:L,W=R.max,K=W===void 0?R.autoMinMax?N:1:W;if(P>=K)throw new RangeError("min option must be smaller than max option");for(var re=(K-P)/(N-E),ye=0;ye<S.length;ye++)x[ye]=(S[ye]-E)*re+P;return x}},16505:function(ae,ne,b){ae.exports=k,ae.exports.simulator=b(45818);var w=b(77797);function k(A,S){if(!A)throw new Error("Graph structure cannot be undefined");var R=S&&S.createSimulator||b(45818),x=R(S);if(Array.isArray(S))throw new Error("Physics settings is expected to be an object");var E=A.version>19?Ot:at;S&&typeof S.nodeMass=="function"&&(E=S.nodeMass);var N=new Map,L={},P=0,W=x.settings.springTransform||O;Ye(),Ne();var K=!1,re={step:function(){if(P===0)return ye(!0),!0;var ue=x.step();re.lastMove=ue,re.fire("step");var Ue=ue/P,vt=Ue<=.01;return ye(vt),vt},getNodePosition:function(ue){return At(ue).pos},setNodePosition:function(ue){var Ue=At(ue);Ue.setPosition.apply(Ue,Array.prototype.slice.call(arguments,1))},getLinkPosition:function(ue){var Ue=L[ue];if(Ue)return{from:Ue.from.pos,to:Ue.to.pos}},getGraphRect:function(){return x.getBBox()},forEachBody:ge,pinNode:function(ue,Ue){var vt=At(ue.id);vt.isPinned=!!Ue},isNodePinned:function(ue){return At(ue.id).isPinned},dispose:function(){A.off("changed",be),re.fire("disposed")},getBody:fe,getSpring:xe,getForceVectorLength:ce,simulator:x,graph:A,lastMove:0};return w(re),re;function ye(ue){K!==ue&&(K=ue,Ae(ue))}function ge(ue){N.forEach(ue)}function ce(){var ue=0,Ue=0;return ge(function(vt){ue+=Math.abs(vt.force.x),Ue+=Math.abs(vt.force.y)}),Math.sqrt(ue*ue+Ue*Ue)}function xe(ue,Ue){var vt;if(Ue===void 0)typeof ue!="object"?vt=ue:vt=ue.id;else{var Jt=A.hasLink(ue,Ue);if(!Jt)return;vt=Jt.id}return L[vt]}function fe(ue){return N.get(ue)}function Ne(){A.on("changed",be)}function Ae(ue){re.fire("stable",ue)}function be(ue){for(var Ue=0;Ue<ue.length;++Ue){var vt=ue[Ue];vt.changeType==="add"?(vt.node&&Ee(vt.node.id),vt.link&&je(vt.link)):vt.changeType==="remove"&&(vt.node&&We(vt.node),vt.link&&_t(vt.link))}P=A.getNodesCount()}function Ye(){P=0,A.forEachNode(function(ue){Ee(ue.id),P+=1}),A.forEachLink(je)}function Ee(ue){var Ue=N.get(ue);if(!Ue){var vt=A.getNode(ue);if(!vt)throw new Error("initBody() was called with unknown node id");var Jt=vt.position;if(!Jt){var Qe=It(vt);Jt=x.getBestNewBodyPosition(Qe)}Ue=x.addBodyAt(Jt),Ue.id=ue,N.set(ue,Ue),kt(ue),Ut(vt)&&(Ue.isPinned=!0)}}function We(ue){var Ue=ue.id,vt=N.get(Ue);vt&&(N.delete(Ue),x.removeBody(vt))}function je(ue){kt(ue.fromId),kt(ue.toId);var Ue=N.get(ue.fromId),vt=N.get(ue.toId),Jt=x.addSpring(Ue,vt,ue.length);W(ue,Jt),L[ue.id]=Jt}function _t(ue){var Ue=L[ue.id];if(Ue){var vt=A.getNode(ue.fromId),Jt=A.getNode(ue.toId);vt&&kt(vt.id),Jt&&kt(Jt.id),delete L[ue.id],x.removeSpring(Ue)}}function It(ue){var Ue=[];if(!ue.links)return Ue;for(var vt=Math.min(ue.links.length,2),Jt=0;Jt<vt;++Jt){var Qe=ue.links[Jt],rt=Qe.fromId!==ue.id?N.get(Qe.fromId):N.get(Qe.toId);rt&&rt.pos&&Ue.push(rt)}return Ue}function kt(ue){var Ue=N.get(ue);if(Ue.mass=E(ue),Number.isNaN(Ue.mass))throw new Error("Node mass should be a number")}function Ut(ue){return ue&&(ue.isPinned||ue.data&&ue.data.isPinned)}function At(ue){var Ue=N.get(ue);return Ue||(Ee(ue),Ue=N.get(ue)),Ue}function at(ue){var Ue=A.getLinks(ue);return Ue?1+Ue.length/3:1}function Ot(ue){var Ue=A.getLinks(ue);return Ue?1+Ue.size/3:1}}function O(){}},15189:function(ae,ne,b){const w=b(16422);ae.exports=function(O){return A;function A(S,R){let x=R&&R.indent||0,E=R&&R.join!==void 0?R.join:`
`,N=Array(x+1).join(" "),L=[];for(let P=0;P<O;++P){let W=w(P),K=P===0?"":N;L.push(K+S.replace(/{var}/g,W))}return L.join(E)}}},30891:function(ae,ne,b){ae.exports=k,ae.exports.generateFunctionBody=O;const w=b(15189);function k(A){let S=O(A);return new Function("bodies","settings","random",S)}function O(A){let S=w(A);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(ae,ne,b){const w=b(15189);ae.exports=k,ae.exports.generateCreateBodyFunctionBody=O,ae.exports.getVectorCode=S,ae.exports.getBodyCode=A;function k(R,x){let E=O(R,x),{Body:N}=new Function(E)();return N}function O(R,x){return`
${S(R,x)}
${A(R,x)}
return {Body: Body, Vector: Vector};
`}function A(R){let x=w(R),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(R,x){let E=w(R),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(ae,ne,b){const w=b(15189);ae.exports=k,ae.exports.generateCreateDragForceFunctionBody=O;function k(A){let S=O(A);return new Function("options",S)}function O(A){return`
if (!Number.isFinite(options.dragCoefficient)) throw new Error('dragCoefficient is not a finite number');
return {
update: function(body) {
${w(A)("body.force.{var} -= options.dragCoefficient * body.velocity.{var};",{indent:6})}
}
};
`}},34079:function(ae,ne,b){const w=b(15189);ae.exports=k,ae.exports.generateCreateSpringForceFunctionBody=O;function k(A){let S=O(A);return new Function("options","random",S)}function O(A){let S=w(A);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(ae,ne,b){const w=b(15189);ae.exports=k,ae.exports.generateIntegratorFunctionBody=O;function k(A){let S=O(A);return new Function("bodies","timeStep","adaptiveTimeStepWeight",S)}function O(A){let S=w(A);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(ae,ne,b){const w=b(15189),k=b(16422);ae.exports=O,ae.exports.generateQuadTreeFunctionBody=A,ae.exports.getInsertStackCode=N,ae.exports.getQuadNodeCode=E,ae.exports.isSamePosition=S,ae.exports.getChildBodyCode=x,ae.exports.setChildBodyCode=R;function O(L){let P=A(L);return new Function(P)()}function A(L){let P=w(L),W=Math.pow(2,L);return`
${N()}
${E(L)}
${S(L)}
${x(L)}
${R(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) {
${ge(" 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.
${ye()}
}
}
}
${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})}
${re(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 re(ce){let xe=[],fe=Array(ce+1).join(" ");for(let Ne=0;Ne<L;++Ne)xe.push(fe+`if (${k(Ne)} > max_${k(Ne)}) {`),xe.push(fe+` quadIdx = quadIdx + ${Math.pow(2,Ne)};`),xe.push(fe+` min_${k(Ne)} = max_${k(Ne)};`),xe.push(fe+` max_${k(Ne)} = node.max_${k(Ne)};`),xe.push(fe+"}");return xe.join(`
`)}function ye(){let ce=Array(11).join(" "),xe=[];for(let fe=0;fe<W;++fe)xe.push(ce+`if (node.quad${fe}) {`),xe.push(ce+` queue[pushIdx] = node.quad${fe};`),xe.push(ce+" queueLength += 1;"),xe.push(ce+" pushIdx += 1;"),xe.push(ce+"}");return xe.join(`
`)}function ge(ce){let xe=[];for(let fe=0;fe<W;++fe)xe.push(`${ce}quad${fe} = null;`);return xe.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 R(L){var P=Math.pow(2,L);return`
function setChild(node, idx, child) {
${W()}
}`;function W(){let K=[];for(let re=0;re<P;++re){let ye=re===0?" ":" else ";K.push(`${ye}if (idx === ${re}) node.quad${re} = child;`)}return K.join(`
`)}}function x(L){return`function getChild(node, idx) {
${P()}
return null;
}`;function P(){let W=[],K=Math.pow(2,L);for(let re=0;re<K;++re)W.push(` if (idx === ${re}) return node.quad${re};`);return W.join(`
`)}}function E(L){let P=w(L),W=Math.pow(2,L);var K=`
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
${re(" 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 K;function re(ye){let ge=[];for(let ce=0;ce<W;++ce)ge.push(`${ye}quad${ce} = null;`);return ge.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(ae){ae.exports=function(b){return b===0?"x":b===1?"y":b===2?"z":"c"+(b+1)}},45818:function(ae,ne,b){ae.exports=E;var w=b(6410),k=b(1584),O=b(30891),A=b(36647),S=b(34079),R=b(51763),x={};function E(P){var W=b(68403),K=b(35510),re=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=K(P,{springLength:10,springCoefficient:.8,gravity:-12,theta:.8,dragCoefficient:.9,timeStep:.5,adaptiveTimeStepWeight:0,dimensions:2,debug:!1});var ye=x[P.dimensions];if(!ye){var ge=P.dimensions;ye={Body:w(ge,P.debug),createQuadTree:k(ge),createBounds:O(ge),createDragForce:A(ge),createSpringForce:S(ge),integrate:R(ge)},x[ge]=ye}var ce=ye.Body,xe=ye.createQuadTree,fe=ye.createBounds,Ne=ye.createDragForce,Ae=ye.createSpringForce,be=ye.integrate,Ye=Ze=>new ce(Ze),Ee=b(78712).random(42),We=[],je=[],_t=xe(P,Ee),It=fe(We,P,Ee),kt=Ae(P,Ee),Ut=Ne(P),At=0,at=[],Ot=new Map,ue=0;Jt("nbody",bt),Jt("spring",ze);var Ue={bodies:We,quadTree:_t,springs:je,settings:P,addForce:Jt,removeForce:Qe,getForces:rt,step:function(){for(var Ze=0;Ze<at.length;++Ze)at[Ze](ue);var q=be(We,P.timeStep,P.adaptiveTimeStepWeight);return ue+=1,q},addBody:function(Ze){if(!Ze)throw new Error("Body is required");return We.push(Ze),Ze},addBodyAt:function(Ze){if(!Ze)throw new Error("Body position is required");var q=Ye(Ze);return We.push(q),q},removeBody:function(Ze){if(Ze){var q=We.indexOf(Ze);if(!(q<0))return We.splice(q,1),We.length===0&&It.reset(),!0}},addSpring:function(Ze,q,Y,de){if(!Ze||!q)throw new Error("Cannot add null spring to force simulator");typeof Y!="number"&&(Y=-1);var Je=new W(Ze,q,Y,de>=0?de:-1);return je.push(Je),Je},getTotalMovement:function(){return At},removeSpring:function(Ze){if(Ze){var q=je.indexOf(Ze);if(q>-1)return je.splice(q,1),!0}},getBestNewBodyPosition:function(Ze){return It.getBestNewPosition(Ze)},getBBox:vt,getBoundingBox:vt,invalidateBBox:function(){console.warn("invalidateBBox() is deprecated, bounds always recomputed on `getBBox()` call")},gravity:function(Ze){return Ze!==void 0?(P.gravity=Ze,_t.options({gravity:Ze}),this):P.gravity},theta:function(Ze){return Ze!==void 0?(P.theta=Ze,_t.options({theta:Ze}),this):P.theta},random:Ee};return N(P,Ue),re(Ue),Ue;function vt(){return It.update(),It.box}function Jt(Ze,q){if(Ot.has(Ze))throw new Error("Force "+Ze+" is already added");Ot.set(Ze,q),at.push(q)}function Qe(Ze){var q=at.indexOf(Ot.get(Ze));q<0||(at.splice(q,1),Ot.delete(Ze))}function rt(){return Ot}function bt(){if(We.length!==0){_t.insertBodies(We);for(var Ze=We.length;Ze--;){var q=We[Ze];q.isPinned||(q.reset(),_t.updateBodyForce(q),Ut.update(q))}}}function ze(){for(var Ze=je.length;Ze--;)kt.update(je[Ze])}}function N(P,W){for(var K in P)L(P,W,K)}function L(P,W,K){if(P.hasOwnProperty(K)&&typeof W[K]!="function"){var re=Number.isFinite(P[K]);re?W[K]=function(ye){if(ye!==void 0){if(!Number.isFinite(ye))throw new Error("Value of "+K+" should be a valid number.");return P[K]=ye,W}return P[K]}:W[K]=function(ye){return ye!==void 0?(P[K]=ye,W):P[K]}}}},68403:function(ae){ae.exports=ne;function ne(b,w,k,O){this.from=b,this.to=w,this.length=k,this.coefficient=O}},35510:function(ae){ae.exports=ne;function ne(b,w){var k;if(b||(b={}),w){for(k in w)if(w.hasOwnProperty(k)){var O=b.hasOwnProperty(k),A=typeof w[k],S=!O||typeof b[k]!==A;S?b[k]=w[k]:A==="object"&&(b[k]=ne(b[k],w[k]))}}return b}},78712:function(ae){ae.exports=ne,ae.exports.random=ne,ae.exports.randomIterator=R;function ne(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=A,b.prototype.uniform=A,b.prototype.gaussian=w,b.prototype.random=A;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 A(){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 R(x,E){var N=E||ne();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,K,re;for(W=x.length-1;W>0;--W)K=N.next(W+1),re=x[K],x[K]=x[W],x[W]=re;return x}function P(W){var K,re,ye;for(K=x.length-1;K>0;--K)re=N.next(K+1),ye=x[re],x[re]=x[K],x[K]=ye,W(ye);x.length&&W(x[0])}}},95860:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return Ne}});var w=b(87462),k=b(1413),O=b(4942),A=b(97685),S=b(45987),R=b(94184),x=b.n(R),E=b(67294);function N(Ae){var be=E.useRef();be.current=Ae;var Ye=E.useCallback(function(){for(var Ee,We=arguments.length,je=new Array(We),_t=0;_t<We;_t++)je[_t]=arguments[_t];return(Ee=be.current)===null||Ee===void 0?void 0:Ee.call.apply(Ee,[be].concat(je))},[]);return Ye}function L(){return!!(typeof window!="undefined"&&window.document&&window.document.createElement)}var P=L()?E.useLayoutEffect:E.useEffect,W=function(be,Ye){var Ee=E.useRef(!0);P(function(){return be(Ee.current)},Ye),P(function(){return Ee.current=!1,function(){Ee.current=!0}},[])},K=function(be,Ye){W(function(Ee){if(!Ee)return be()},Ye)},re=null;function ye(Ae){var be=E.useRef(!1),Ye=E.useState(Ae),Ee=(0,A.Z)(Ye,2),We=Ee[0],je=Ee[1];E.useEffect(function(){return be.current=!1,function(){be.current=!0}},[]);function _t(It,kt){kt&&be.current||je(It)}return[We,_t]}function ge(Ae){return Ae!==void 0}function ce(Ae,be){var Ye=be||{},Ee=Ye.defaultValue,We=Ye.value,je=Ye.onChange,_t=Ye.postState,It=ye(function(){return ge(We)?We:ge(Ee)?typeof Ee=="function"?Ee():Ee:typeof Ae=="function"?Ae():Ae}),kt=(0,A.Z)(It,2),Ut=kt[0],At=kt[1],at=We!==void 0?We:Ut,Ot=_t?_t(at):at,ue=N(je),Ue=ye([at]),vt=(0,A.Z)(Ue,2),Jt=vt[0],Qe=vt[1];K(function(){var bt=Jt[0];Ut!==bt&&ue(Ut,bt)},[Jt]),K(function(){ge(We)||At(We)},[We]);var rt=N(function(bt,ze){At(bt,ze),Qe([at],ze)});return[Ot,rt]}var xe=["prefixCls","className","style","checked","disabled","defaultChecked","type","title","onChange"],fe=(0,E.forwardRef)(function(Ae,be){var Ye,Ee=Ae.prefixCls,We=Ee===void 0?"rc-checkbox":Ee,je=Ae.className,_t=Ae.style,It=Ae.checked,kt=Ae.disabled,Ut=Ae.defaultChecked,At=Ut===void 0?!1:Ut,at=Ae.type,Ot=at===void 0?"checkbox":at,ue=Ae.title,Ue=Ae.onChange,vt=(0,S.Z)(Ae,xe),Jt=(0,E.useRef)(null),Qe=ce(At,{value:It}),rt=(0,A.Z)(Qe,2),bt=rt[0],ze=rt[1];(0,E.useImperativeHandle)(be,function(){return{focus:function(){var de;(de=Jt.current)===null||de===void 0||de.focus()},blur:function(){var de;(de=Jt.current)===null||de===void 0||de.blur()},input:Jt.current}});var Ze=x()(We,je,(Ye={},(0,O.Z)(Ye,"".concat(We,"-checked"),bt),(0,O.Z)(Ye,"".concat(We,"-disabled"),kt),Ye)),q=function(de){kt||("checked"in Ae||ze(de.target.checked),Ue==null||Ue({target:(0,k.Z)((0,k.Z)({},Ae),{},{type:Ot,checked:de.target.checked}),stopPropagation:function(){de.stopPropagation()},preventDefault:function(){de.preventDefault()},nativeEvent:de.nativeEvent}))};return E.createElement("span",{className:Ze,title:ue,style:_t},E.createElement("input",(0,w.Z)({},vt,{className:"".concat(We,"-input"),ref:Jt,onChange:q,disabled:kt,checked:!!bt,type:Ot})),E.createElement("span",{className:"".concat(We,"-inner")}))}),Ne=fe},86851:function(ae,ne,b){"use strict";var w=b(89594),k=Array.prototype.concat,O=Array.prototype.slice,A=ae.exports=function(R){for(var x=[],E=0,N=R.length;E<N;E++){var L=R[E];w(L)?x=k.call(x,O.call(L)):x.push(L)}return x};A.wrap=function(S){return function(){return S(A(arguments))}}},89594:function(ae){ae.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(ae){"use strict";function ne(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(A,S,R){if(typeof S!="function")throw new Error("callback is expected to be a function");let x=O[A];return x||(x=O[A]=[]),x.push({callback:S,ctx:R}),k},off:function(A,S){if(typeof A>"u")return O=Object.create(null),k;if(O[A])if(typeof S!="function")delete O[A];else{const R=O[A];for(let x=0;x<R.length;++x)R[x].callback===S&&R.splice(x,1)}return k},fire:function(A){const S=O[A];if(!S)return k;let R;arguments.length>1&&(R=Array.prototype.slice.call(arguments,1));for(let x=0;x<S.length;++x){const E=S[x];E.callback.apply(E.ctx,R)}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 A=0;A<O.length;++A)if(k.hasOwnProperty(O[A]))throw new Error("Subject cannot be eventified, since it already has property '"+O[A]+"'")}ae.exports=ne},46951:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return Rq}});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},A=0,S=1,R=2,x=3,E=0,N=1,L=2,P=3,W=0,K=1,re=2,ye=0,ge=1,ce=2,xe=3,fe=4,Ne=5,Ae=100,be=101,Ye=102,Ee=103,We=104,je=200,_t=201,It=202,kt=203,Ut=204,At=205,at=206,Ot=207,ue=208,Ue=209,vt=210,Jt=211,Qe=212,rt=213,bt=214,ze=0,Ze=1,q=2,Y=3,de=4,Je=5,Te=6,$e=7,xt=0,ke=1,et=2,yt=0,B=1,ie=2,ct=3,Mt=4,ht=5,Yt=6,en=7,nn="attached",Me="detached",te=300,Fe=301,Xe=302,Pe=303,Ie=304,Ke=306,lt=1e3,qe=1001,pt=1002,Ct=1003,Xt=1004,Qt=1004,pn=1005,Wn=1005,Rn=1006,bi=1007,Lr=1007,Qn=1008,Vi=1008,Oi=1009,Gi=1010,ir=1011,ms=1012,Is=1013,as=1014,gs=1015,Vs=1016,Xl=1017,ql=1018,Da=1020,Dl=35902,nu=35899,Du=1021,Le=1022,D=1023,U=1026,_=1027,F=1028,X=1029,De=1030,Ve=1031,it=1032,st=1033,Ht=33776,Et=33777,on=33778,Un=33779,sn=35840,bn=35841,ti=35842,Bt=35843,$n=36196,ni=37492,Pi=37496,ui=37808,Ir=37809,yi=37810,vi=37811,Mr=37812,Zt=37813,Fn=37814,hi=37815,Xn=37816,hs=37817,Xr=37818,ys=37819,Ur=37820,Os=37821,no=36492,io=36494,So=36495,To=36283,Gr=36284,Qs=36285,Eo=36286,ro=2200,qr=2201,la=2202,Ao=2300,il=2301,rl=2302,ca=2400,Oa=2401,sl=2402,bo=2500,Pc=2501,Qv=0,oh=1,y0=2,Jf=3200,Qf=3201,v0=3202,Pm=3203,$a=0,jd=1,Qo="",co="srgb",iu="srgb-linear",ah="linear",Fi="srgb",Jb=0,Yl=7680,Im=7681,Xd=7682,ex=7683,tx=34055,x0=34056,Qb=5386,e1=512,t1=513,n1=514,nx=515,i1=516,r1=517,ix=518,Xh=519,Lm=512,qd=513,Yd=514,ep=515,_0=516,b0=517,w0=518,Dm=519,Ou=35044,Zd=35048,Om=35040,iE=35045,Fm=35049,rE=35041,sE=35046,oE=35050,aE=35042,s1="100",M0="300 es",so=2e3,ja=2001,lh={COMPUTE:"compute",RENDER:"render"},o1={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},a1={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};class Ol{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 Xa=["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 Fu=1234567;const lc=Math.PI/180,Fa=180/Math.PI;function yl(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Xa[r&255]+Xa[r>>8&255]+Xa[r>>16&255]+Xa[r>>24&255]+"-"+Xa[e&255]+Xa[e>>8&255]+"-"+Xa[e>>16&15|64]+Xa[e>>24&255]+"-"+Xa[t&63|128]+Xa[t>>8&255]+"-"+Xa[t>>16&255]+Xa[t>>24&255]+Xa[n&255]+Xa[n>>8&255]+Xa[n>>16&255]+Xa[n>>24&255]).toLowerCase()}function Sr(r,e,t){return Math.max(e,Math.min(t,r))}function tp(r,e){return(r%e+e)%e}function rx(r,e,t,n,s){return n+(r-e)*(s-n)/(t-e)}function Bm(r,e,t){return r!==e?(t-r)/(e-r):0}function _r(r,e,t){return(1-t)*r+t*e}function js(r,e,t,n){return _r(r,e,1-Math.exp(-t*n))}function Fl(r,e=1){return e-Math.abs(tp(r,e*2)-e)}function S0(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function Bu(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function _a(r,e){return r+Math.floor(Math.random()*(e-r+1))}function T0(r,e){return r+Math.random()*(e-r)}function ru(r){return r*(.5-Math.random())}function Uu(r){r!==void 0&&(Fu=r);let e=Fu+=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 Sl(r){return r*lc}function Fr(r){return r*Fa}function np(r){return(r&r-1)===0&&r!==0}function E0(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function A0(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function qh(r,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":r.set(c*p,u*m,u*y,c*d);break;case"YZY":r.set(u*y,c*p,u*m,c*d);break;case"ZXZ":r.set(u*m,u*y,c*p,c*d);break;case"XZX":r.set(c*p,u*T,u*M,c*d);break;case"YXY":r.set(u*M,c*p,u*T,c*d);break;case"ZYZ":r.set(u*T,u*M,c*p,c*d);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function qa(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function ls(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const Yh={DEG2RAD:lc,RAD2DEG:Fa,generateUUID:yl,clamp:Sr,euclideanModulo:tp,mapLinear:rx,inverseLerp:Bm,lerp:_r,damp:js,pingpong:Fl,smoothstep:S0,smootherstep:Bu,randInt:_a,randFloat:T0,randFloatSpread:ru,seededRandom:Uu,degToRad:Sl,radToDeg:Fr,isPowerOfTwo:np,ceilPowerOfTwo:E0,floorPowerOfTwo:A0,setQuaternionFromProperEuler:qh,normalize:ls,denormalize:qa};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 ea{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,ee=I>=0?1:-1,Q=1-I*I;if(Q>Number.EPSILON){const _e=Math.sqrt(Q),ve=Math.atan2(_e,I*ee);z=Math.sin(z*ve)/_e,c=Math.sin(c*ve)/_e}const oe=c*ee;if(u=u*z+y*oe,d=d*z+M*oe,p=p*z+T*oe,m=m*z+G*oe,z===1-c){const _e=1/Math.sqrt(u*u+d*d+p*p+m*m);u*=_e,d*=_e,p*=_e,m*=_e}}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 ot{constructor(e=0,t=0,n=0){ot.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(Um.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Um.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 ip.copy(this).projectOnVector(e),this.sub(ip)}reflect(e){return this.sub(ip.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 ip=new ot,Um=new ea;class $r{constructor(e,t,n,s,o,a,c,u,d){$r.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],ee=s[1],Q=s[4],oe=s[7],_e=s[2],ve=s[5],Oe=s[8];return o[0]=a*G+c*ee+u*_e,o[3]=a*z+c*Q+u*ve,o[6]=a*I+c*oe+u*Oe,o[1]=d*G+p*ee+m*_e,o[4]=d*z+p*Q+m*ve,o[7]=d*I+p*oe+m*Oe,o[2]=y*G+M*ee+T*_e,o[5]=y*z+M*Q+T*ve,o[8]=y*I+M*oe+T*Oe,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(rp.makeScale(e,t)),this}rotate(e){return this.premultiply(rp.makeRotation(-e)),this}translate(e,t){return this.premultiply(rp.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 rp=new $r;function sp(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}const C0={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function ch(r,e){return new C0[r](e)}function uh(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function Ya(){const r=uh("canvas");return r.style.display="block",r}const ns={};function ol(r){r in ns||(ns[r]=!0,console.warn(r))}function oi(r,e,t){return new Promise(function(n,s){function o(){switch(r.clientWaitSync(e,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:s();break;case r.TIMEOUT_EXPIRED:setTimeout(o,t);break;default:n()}}setTimeout(o,t)})}const vl=new $r().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Rt=new $r().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Kd(){const r={enabled:!0,workingColorSpace:iu,spaces:{},convert:function(s,o,a){return this.enabled===!1||o===a||!o||!a||(this.spaces[o].transfer===Fi&&(s.r=ua(s.r),s.g=ua(s.g),s.b=ua(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=ku(s.r),s.g=ku(s.g),s.b=ku(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===Qo?ah: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 ol("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(s,o)},toWorkingColorSpace:function(s,o){return ol("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(s,o)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return r.define({[iu]:{primaries:e,whitePoint:n,transfer:ah,toXYZ:vl,fromXYZ:Rt,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:co},outputColorSpaceConfig:{drawingBufferColorSpace:co}},[co]:{primaries:e,whitePoint:n,transfer:Fi,toXYZ:vl,fromXYZ:Rt,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:co}}}),r}const Ki=Kd();function ua(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function ku(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let su;class km{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{su===void 0&&(su=uh("canvas")),su.width=e.width,su.height=e.height;const s=su.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=su}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=uh("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]=ua(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(ua(t[n]/255)*255):t[n]=ua(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 zm=0;class wo{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:zm++}),this.uuid=yl(),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(Bl(s[a].image)):o.push(Bl(s[a]))}else o=Bl(s);n.url=o}return t||(e.images[this.uuid]=n),n}}function Bl(r){return typeof HTMLImageElement!="undefined"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&r instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&r instanceof ImageBitmap?km.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Ic=0;const ou=new ot;class Wo extends Ol{constructor(e=Wo.DEFAULT_IMAGE,t=Wo.DEFAULT_MAPPING,n=qe,s=qe,o=Rn,a=Qn,c=D,u=Oi,d=Wo.DEFAULT_ANISOTROPY,p=Qo){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Ic++}),this.uuid=yl(),this.name="",this.source=new wo(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 $r,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(ou).x}get height(){return this.source.getSize(ou).y}get depth(){return this.source.getSize(ou).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!==te)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case lt:e.x=e.x-Math.floor(e.x);break;case qe:e.x=e.x<0?0:1;break;case pt: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 lt:e.y=e.y-Math.floor(e.y);break;case qe:e.y=e.y<0?0:1;break;case pt: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++}}Wo.DEFAULT_IMAGE=null,Wo.DEFAULT_MAPPING=te,Wo.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 Q=(d+1)/2,oe=(M+1)/2,_e=(I+1)/2,ve=(p+y)/4,Oe=(m+G)/4,He=(T+z)/4;return Q>oe&&Q>_e?Q<.01?(n=0,s=.707106781,o=.707106781):(n=Math.sqrt(Q),s=ve/n,o=Oe/n):oe>_e?oe<.01?(n=.707106781,s=0,o=.707106781):(s=Math.sqrt(oe),n=ve/s,o=He/s):_e<.01?(n=.707106781,s=.707106781,o=0):(o=Math.sqrt(_e),n=Oe/o,s=He/o),this.set(n,s,o,t),this}let ee=Math.sqrt((z-T)*(z-T)+(m-G)*(m-G)+(y-p)*(y-p));return Math.abs(ee)<.001&&(ee=1),this.x=(z-T)/ee,this.y=(m-G)/ee,this.z=(y-p)/ee,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 Za extends Ol{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 Wo(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 wo(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 cc extends Za{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class Jd extends Wo{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=qe,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class op extends null{constructor(e=1,t=1,n=1,s={}){super(e,t,s),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Jd(null,e,t,n),this._setTextureOptions(s),this.texture.isRenderTargetTexture=!0}}class xl extends Wo{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=qe,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ba extends null{constructor(e=1,t=1,n=1,s={}){super(e,t,s),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new xl(null,e,t,n),this._setTextureOptions(s),this.texture.isRenderTargetTexture=!0}}class ha{constructor(e=new ot(1/0,1/0,1/0),t=new ot(-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(Kl.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Kl.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=Kl.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,Kl):Kl.fromBufferAttribute(o,a),Kl.applyMatrix4(e.matrixWorld),this.expandByPoint(Kl);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Qd.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Qd.copy(n.boundingBox)),Qd.applyMatrix4(e.matrixWorld),this.union(Qd)}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,Kl),Kl.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(hc),Lc.subVectors(this.max,hc),au.subVectors(e.a,hc),hh.subVectors(e.b,hc),ta.subVectors(e.c,hc),Ua.subVectors(hh,au),ba.subVectors(ta,hh),uc.subVectors(au,ta);let t=[0,-Ua.z,Ua.y,0,-ba.z,ba.y,0,-uc.z,uc.y,Ua.z,0,-Ua.x,ba.z,0,-ba.x,uc.z,0,-uc.x,-Ua.y,Ua.x,0,-ba.y,ba.x,0,-uc.y,uc.x,0];return!se(t,au,hh,ta,Lc)||(t=[1,0,0,0,1,0,0,0,1],!se(t,au,hh,ta,Lc))?!1:(Dc.crossVectors(Ua,ba),t=[Dc.x,Dc.y,Dc.z],se(t,au,hh,ta,Lc))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Kl).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Kl).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:(Zl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Zl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Zl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Zl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Zl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Zl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Zl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Zl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Zl),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 Zl=[new ot,new ot,new ot,new ot,new ot,new ot,new ot,new ot],Kl=new ot,Qd=new ha,au=new ot,hh=new ot,ta=new ot,Ua=new ot,ba=new ot,uc=new ot,hc=new ot,Lc=new ot,Dc=new ot,Tl=new ot;function se(r,e,t,n,s){for(let o=0,a=r.length-3;o<=a;o+=3){Tl.fromArray(r,o);const c=s.x*Math.abs(Tl.x)+s.y*Math.abs(Tl.y)+s.z*Math.abs(Tl.z),u=e.dot(Tl),d=t.dot(Tl),p=n.dot(Tl);if(Math.max(-Math.max(u,d,p),Math.min(u,d,p))>c)return!1}return!0}const $=new ha,Z=new ot,le=new ot;class we{constructor(e=new ot,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;Z.subVectors(e,this.center);const t=Z.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(Z,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):(le.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Z.copy(e.center).add(le)),this.expandByPoint(Z.copy(e.center).sub(le))),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 Re=new ot,Ge=new ot,wt=new ot,Tt=new ot,Lt=new ot,Gt=new ot,$t=new ot;class hn{constructor(e=new ot,t=new ot(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,Re)),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=Re.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Re.copy(this.origin).addScaledVector(this.direction,t),Re.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){Ge.copy(e).add(t).multiplyScalar(.5),wt.copy(t).sub(e).normalize(),Tt.copy(this.origin).sub(Ge);const o=e.distanceTo(t)*.5,a=-this.direction.dot(wt),c=Tt.dot(this.direction),u=-Tt.dot(wt),d=Tt.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(Ge).addScaledVector(wt,y),M}intersectSphere(e,t){Re.subVectors(e.center,this.origin);const n=Re.dot(this.direction),s=Re.dot(Re)-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,Re)!==null}intersectTriangle(e,t,n,s,o){Lt.subVectors(t,e),Gt.subVectors(n,e),$t.crossVectors(Lt,Gt);let a=this.direction.dot($t),c;if(a>0){if(s)return null;c=1}else if(a<0)c=-1,a=-a;else return null;Tt.subVectors(this.origin,e);const u=c*this.direction.dot(Gt.crossVectors(Tt,Gt));if(u<0)return null;const d=c*this.direction.dot(Lt.cross(Tt));if(d<0||u+d>a)return null;const p=-c*Tt.dot($t);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],ee=n[3],Q=n[7],oe=n[11],_e=n[15],ve=s[0],Oe=s[4],He=s[8],Ce=s[12],Be=s[1],ft=s[5],zt=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*ve+c*Be+u*cn+d*xn,o[4]=a*Oe+c*ft+u*vn+d*si,o[8]=a*He+c*zt+u*mn+d*wn,o[12]=a*Ce+c*tn+u*Yn+d*Gn,o[1]=p*ve+m*Be+y*cn+M*xn,o[5]=p*Oe+m*ft+y*vn+M*si,o[9]=p*He+m*zt+y*mn+M*wn,o[13]=p*Ce+m*tn+y*Yn+M*Gn,o[2]=T*ve+G*Be+z*cn+I*xn,o[6]=T*Oe+G*ft+z*vn+I*si,o[10]=T*He+G*zt+z*mn+I*wn,o[14]=T*Ce+G*tn+z*Yn+I*Gn,o[3]=ee*ve+Q*Be+oe*cn+_e*xn,o[7]=ee*Oe+Q*ft+oe*vn+_e*si,o[11]=ee*He+Q*zt+oe*mn+_e*wn,o[15]=ee*Ce+Q*tn+oe*Yn+_e*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],ee=m*z*d-G*y*d+G*u*M-c*z*M-m*u*I+c*y*I,Q=T*y*d-p*z*d-T*u*M+a*z*M+p*u*I-a*y*I,oe=p*G*d-T*m*d+T*c*M-a*G*M-p*c*I+a*m*I,_e=T*m*u-p*G*u-T*c*y+a*G*y+p*c*z-a*m*z,ve=t*ee+n*Q+s*oe+o*_e;if(ve===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const Oe=1/ve;return e[0]=ee*Oe,e[1]=(G*y*o-m*z*o-G*s*M+n*z*M+m*s*I-n*y*I)*Oe,e[2]=(c*z*o-G*u*o+G*s*d-n*z*d-c*s*I+n*u*I)*Oe,e[3]=(m*u*o-c*y*o-m*s*d+n*y*d+c*s*M-n*u*M)*Oe,e[4]=Q*Oe,e[5]=(p*z*o-T*y*o+T*s*M-t*z*M-p*s*I+t*y*I)*Oe,e[6]=(T*u*o-a*z*o-T*s*d+t*z*d+a*s*I-t*u*I)*Oe,e[7]=(a*y*o-p*u*o+p*s*d-t*y*d-a*s*M+t*u*M)*Oe,e[8]=oe*Oe,e[9]=(T*m*o-p*G*o-T*n*M+t*G*M+p*n*I-t*m*I)*Oe,e[10]=(a*G*o-T*c*o+T*n*d-t*G*d-a*n*I+t*c*I)*Oe,e[11]=(p*c*o-a*m*o-p*n*d+t*m*d+a*n*M-t*c*M)*Oe,e[12]=_e*Oe,e[13]=(p*G*s-T*m*s+T*n*y-t*G*y-p*n*z+t*m*z)*Oe,e[14]=(T*c*s-a*G*s-T*n*u+t*G*u+a*n*z-t*c*z)*Oe,e[15]=(a*m*s-p*c*s+p*n*u-t*m*u-a*n*y+t*c*y)*Oe,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,ee=u*d,Q=u*p,oe=u*m,_e=n.x,ve=n.y,Oe=n.z;return s[0]=(1-(G+I))*_e,s[1]=(M+oe)*_e,s[2]=(T-Q)*_e,s[3]=0,s[4]=(M-oe)*ve,s[5]=(1-(y+I))*ve,s[6]=(z+ee)*ve,s[7]=0,s[8]=(T+Q)*Oe,s[9]=(z-ee)*Oe,s[10]=(1-(y+G))*Oe,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=so,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===so)T=-(a+o)/(a-o),G=-2*a*o/(a-o);else if(c===ja)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=so,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===so)T=-2/(a-o),G=-(a+o)/(a-o);else if(c===ja)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 ot,Nn=new Ft,Pn=new ot(0,0,0),ei=new ot(1,1,1),ai=new ot,On=new ot,di=new ot,Ri=new Ft,ji=new ea;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 ot,Nr=new ea,Ji=new Ft,cs=new ot,ds=new ot,Es=new ot,Gs=new ea,As=new ot(1,0,0),us=new ot(0,1,0),Mi=new ot(0,0,1),Xi={type:"added"},Br={type:"removed"},kr={type:"childadded",child:null},Dr={type:"childremoved",child:null};class Jr extends Ol{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:gr++}),this.uuid=yl(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Jr.DEFAULT_UP.clone();const e=new ot,t=new Qi,n=new ea,s=new ot(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 $r}}),this.matrix=new Ft,this.matrixWorld=new Ft,this.matrixAutoUpdate=Jr.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Jr.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 Nr.setFromAxisAngle(e,t),this.quaternion.multiply(Nr),this}rotateOnWorldAxis(e,t){return Nr.setFromAxisAngle(e,t),this.quaternion.premultiply(Nr),this}rotateX(e){return this.rotateOnAxis(As,e)}rotateY(e){return this.rotateOnAxis(us,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(As,e)}translateY(e){return this.translateOnAxis(us,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?cs.copy(e):cs.set(e,t,n);const s=this.parent;this.updateWorldMatrix(!0,!1),ds.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ji.lookAt(ds,cs,this.up):Ji.lookAt(cs,ds,this.up),this.quaternion.setFromRotationMatrix(Ji),s&&(Ji.extractRotation(s.matrixWorld),Nr.setFromRotationMatrix(Ji),this.quaternion.premultiply(Nr.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),kr.child=e,this.dispatchEvent(kr),kr.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(Br),Dr.child=e,this.dispatchEvent(Dr),Dr.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),kr.child=e,this.dispatchEvent(kr),kr.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(ds,e,Es),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ds,Gs,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=>ac(qs({},c),{boundingBox:c.boundingBox?c.boundingBox.toJSON():void 0,boundingSphere:c.boundingSphere?c.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(c=>qs({},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}}Jr.DEFAULT_UP=new ot(0,1,0),Jr.DEFAULT_MATRIX_AUTO_UPDATE=!0,Jr.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ls=new ot,Lo=new ot,Ka=new ot,oo=new ot,al=new ot,xs=new ot,da=new ot,Ys=new ot,Oc=new ot,Co=new ot,Ul=new mr,Ho=new mr,wa=new mr;class na{constructor(e=new ot,t=new ot,n=new ot){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),Ls.subVectors(e,t),s.cross(Ls);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){Ls.subVectors(s,t),Lo.subVectors(n,t),Ka.subVectors(e,t);const a=Ls.dot(Ls),c=Ls.dot(Lo),u=Ls.dot(Ka),d=Lo.dot(Lo),p=Lo.dot(Ka),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,oo)===null?!1:oo.x>=0&&oo.y>=0&&oo.x+oo.y<=1}static getInterpolation(e,t,n,s,o,a,c,u){return this.getBarycoord(e,t,n,s,oo)===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,oo.x),u.addScaledVector(a,oo.y),u.addScaledVector(c,oo.z),u)}static getInterpolatedAttribute(e,t,n,s,o,a){return Ul.setScalar(0),Ho.setScalar(0),wa.setScalar(0),Ul.fromBufferAttribute(e,t),Ho.fromBufferAttribute(e,n),wa.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(Ul,o.x),a.addScaledVector(Ho,o.y),a.addScaledVector(wa,o.z),a}static isFrontFacing(e,t,n,s){return Ls.subVectors(n,t),Lo.subVectors(e,t),Ls.cross(Lo).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 Ls.subVectors(this.c,this.b),Lo.subVectors(this.a,this.b),Ls.cross(Lo).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return na.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return na.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,o){return na.getInterpolation(e,this.a,this.b,this.c,t,n,s,o)}containsPoint(e){return na.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return na.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;al.subVectors(s,n),xs.subVectors(o,n),Ys.subVectors(e,n);const u=al.dot(Ys),d=xs.dot(Ys);if(u<=0&&d<=0)return t.copy(n);Oc.subVectors(e,s);const p=al.dot(Oc),m=xs.dot(Oc);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(al,a);Co.subVectors(e,o);const M=al.dot(Co),T=xs.dot(Co);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(xs,c);const z=p*T-M*m;if(z<=0&&m-p>=0&&M-T>=0)return da.subVectors(o,s),c=(m-p)/(m-p+(M-T)),t.copy(s).addScaledVector(da,c);const I=1/(z+G+y);return a=G*I,c=y*I,t.copy(n).addScaledVector(al,a).addScaledVector(xs,c)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const ll={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},ia={h:0,s:0,l:0},is={h:0,s:0,l:0};function Bs(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}class 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=co){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=tp(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=Bs(a,o,e+1/3),this.g=Bs(a,o,e),this.b=Bs(a,o,e-1/3)}return Ki.colorSpaceToWorking(this,s),this}setStyle(e,t=co){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=co){const n=ll[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=ua(e.r),this.g=ua(e.g),this.b=ua(e.b),this}copyLinearToSRGB(e){return this.r=ku(e.r),this.g=ku(e.g),this.b=ku(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=co){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=co){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=co){Ki.workingToColorSpace(br.copy(this),e);const t=br.r,n=br.g,s=br.b;return e!==co?`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(ia),this.setHSL(ia.h+e,ia.s+t,ia.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(ia),e.getHSL(is);const n=_r(ia.h,is.h,t),s=_r(ia.s,is.s,t),o=_r(ia.l,is.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=ll;let Do=0;class Ei extends Ol{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Do++}),this.uuid=yl(),this.name="",this.type="Material",this.blending=ge,this.side=W,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Ut,this.blendDst=At,this.blendEquation=Ae,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new jn(0,0,0),this.blendAlpha=0,this.depthFunc=Y,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Xh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Yl,this.stencilZFail=Yl,this.stencilZPass=Yl,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!==ge&&(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!==Ut&&(n.blendSrc=this.blendSrc),this.blendDst!==At&&(n.blendDst=this.blendDst),this.blendEquation!==Ae&&(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!==Y&&(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!==Xh&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Yl&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Yl&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Yl&&(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 Wr 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=xt,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 vs=ar();function ar(){const r=new ArrayBuffer(4),e=new Float32Array(r),t=new Uint32Array(r),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(r){Math.abs(r)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),r=Sr(r,-65504,65504),vs.floatView[0]=r;const e=vs.uint32View[0],t=e>>23&511;return vs.baseTable[t]+((e&8388607)>>vs.shiftTable[t])}function Cs(r){const e=r>>10;return vs.uint32View[0]=vs.mantissaTable[vs.offsetTable[e]+(r&1023)]+vs.exponentTable[e],vs.floatView[0]}class Ro{static toHalfFloat(e){return vr(e)}static fromHalfFloat(e){return Cs(e)}}const Ms=new ot,Ws=new yn;let dh=0;class Qr{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:dh++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Ou,this.updateRanges=[],this.gpuType=gs,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++)Ws.fromBufferAttribute(this,t),Ws.applyMatrix3(e),this.setXY(t,Ws.x,Ws.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Ms.fromBufferAttribute(this,t),Ms.applyMatrix3(e),this.setXYZ(t,Ms.x,Ms.y,Ms.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Ms.fromBufferAttribute(this,t),Ms.applyMatrix4(e),this.setXYZ(t,Ms.x,Ms.y,Ms.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Ms.fromBufferAttribute(this,t),Ms.applyNormalMatrix(e),this.setXYZ(t,Ms.x,Ms.y,Ms.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Ms.fromBufferAttribute(this,t),Ms.transformDirection(e),this.setXYZ(t,Ms.x,Ms.y,Ms.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=qa(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ls(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=qa(t,this.array)),t}setX(e,t){return this.normalized&&(t=ls(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=qa(t,this.array)),t}setY(e,t){return this.normalized&&(t=ls(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=qa(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ls(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=qa(t,this.array)),t}setW(e,t){return this.normalized&&(t=ls(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=ls(t,this.array),n=ls(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=ls(t,this.array),n=ls(n,this.array),s=ls(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=ls(t,this.array),n=ls(n,this.array),s=ls(s,this.array),o=ls(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!==Ou&&(e.usage=this.usage),e}}class Ma extends null{constructor(e,t,n){super(new Int8Array(e),t,n)}}class dc extends null{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class ao extends null{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class fc extends null{constructor(e,t,n){super(new Int16Array(e),t,n)}}class ka extends Qr{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class yo extends null{constructor(e,t,n){super(new Int32Array(e),t,n)}}class pc extends Qr{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Vm extends Qr{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=Cs(this.array[e*this.itemSize]);return this.normalized&&(t=qa(t,this.array)),t}setX(e,t){return this.normalized&&(t=ls(t,this.array)),this.array[e*this.itemSize]=vr(t),this}getY(e){let t=Cs(this.array[e*this.itemSize+1]);return this.normalized&&(t=qa(t,this.array)),t}setY(e,t){return this.normalized&&(t=ls(t,this.array)),this.array[e*this.itemSize+1]=vr(t),this}getZ(e){let t=Cs(this.array[e*this.itemSize+2]);return this.normalized&&(t=qa(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ls(t,this.array)),this.array[e*this.itemSize+2]=vr(t),this}getW(e){let t=Cs(this.array[e*this.itemSize+3]);return this.normalized&&(t=qa(t,this.array)),t}setW(e,t){return this.normalized&&(t=ls(t,this.array)),this.array[e*this.itemSize+3]=vr(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=ls(t,this.array),n=ls(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=ls(t,this.array),n=ls(n,this.array),s=ls(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=ls(t,this.array),n=ls(n,this.array),s=ls(s,this.array),o=ls(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 Qr{constructor(e,t,n){super(new Float32Array(e),t,n)}}let sx=0;const kl=new Ft,ef=new Jr,zu=new ot,zl=new ha,qi=new ha,Sa=new ot;class xr extends Ol{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:sx++}),this.uuid=yl(),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(sp(e)?pc:ka)(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 $r().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 kl.makeRotationFromQuaternion(e),this.applyMatrix4(kl),this}rotateX(e){return kl.makeRotationX(e),this.applyMatrix4(kl),this}rotateY(e){return kl.makeRotationY(e),this.applyMatrix4(kl),this}rotateZ(e){return kl.makeRotationZ(e),this.applyMatrix4(kl),this}translate(e,t,n){return kl.makeTranslation(e,t,n),this.applyMatrix4(kl),this}scale(e,t,n){return kl.makeScale(e,t,n),this.applyMatrix4(kl),this}lookAt(e){return ef.lookAt(e),ef.updateMatrix(),this.applyMatrix4(ef.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(zu).negate(),this.translate(zu.x,zu.y,zu.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 ha);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 ot(-1/0,-1/0,-1/0),new ot(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];zl.setFromBufferAttribute(o),this.morphTargetsRelative?(Sa.addVectors(this.boundingBox.min,zl.min),this.boundingBox.expandByPoint(Sa),Sa.addVectors(this.boundingBox.max,zl.max),this.boundingBox.expandByPoint(Sa)):(this.boundingBox.expandByPoint(zl.min),this.boundingBox.expandByPoint(zl.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 we);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 ot,1/0);return}if(e){const n=this.boundingSphere.center;if(zl.setFromBufferAttribute(e),t)for(let o=0,a=t.length;o<a;o++){const c=t[o];qi.setFromBufferAttribute(c),this.morphTargetsRelative?(Sa.addVectors(zl.min,qi.min),zl.expandByPoint(Sa),Sa.addVectors(zl.max,qi.max),zl.expandByPoint(Sa)):(zl.expandByPoint(qi.min),zl.expandByPoint(qi.max))}zl.getCenter(n);let s=0;for(let o=0,a=e.count;o<a;o++)Sa.fromBufferAttribute(e,o),s=Math.max(s,n.distanceToSquared(Sa));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++)Sa.fromBufferAttribute(c,d),u&&(zu.fromBufferAttribute(e,d),Sa.add(zu)),s=Math.max(s,n.distanceToSquared(Sa))}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 Qr(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),c=[],u=[];for(let He=0;He<n.count;He++)c[He]=new ot,u[He]=new ot;const d=new ot,p=new ot,m=new ot,y=new yn,M=new yn,T=new yn,G=new ot,z=new ot;function I(He,Ce,Be){d.fromBufferAttribute(n,He),p.fromBufferAttribute(n,Ce),m.fromBufferAttribute(n,Be),y.fromBufferAttribute(o,He),M.fromBufferAttribute(o,Ce),T.fromBufferAttribute(o,Be),p.sub(d),m.sub(d),M.sub(y),T.sub(y);const ft=1/(M.x*T.y-T.x*M.y);isFinite(ft)&&(G.copy(p).multiplyScalar(T.y).addScaledVector(m,-M.y).multiplyScalar(ft),z.copy(m).multiplyScalar(M.x).addScaledVector(p,-T.x).multiplyScalar(ft),c[He].add(G),c[Ce].add(G),c[Be].add(G),u[He].add(z),u[Ce].add(z),u[Be].add(z))}let ee=this.groups;ee.length===0&&(ee=[{start:0,count:e.count}]);for(let He=0,Ce=ee.length;He<Ce;++He){const Be=ee[He],ft=Be.start,zt=Be.count;for(let tn=ft,cn=ft+zt;tn<cn;tn+=3)I(e.getX(tn+0),e.getX(tn+1),e.getX(tn+2))}const Q=new ot,oe=new ot,_e=new ot,ve=new ot;function Oe(He){_e.fromBufferAttribute(s,He),ve.copy(_e);const Ce=c[He];Q.copy(Ce),Q.sub(_e.multiplyScalar(_e.dot(Ce))).normalize(),oe.crossVectors(ve,Ce);const ft=oe.dot(u[He])<0?-1:1;a.setXYZW(He,Q.x,Q.y,Q.z,ft)}for(let He=0,Ce=ee.length;He<Ce;++He){const Be=ee[He],ft=Be.start,zt=Be.count;for(let tn=ft,cn=ft+zt;tn<cn;tn+=3)Oe(e.getX(tn+0)),Oe(e.getX(tn+1)),Oe(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 Qr(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 ot,o=new ot,a=new ot,c=new ot,u=new ot,d=new ot,p=new ot,m=new ot;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++)Sa.fromBufferAttribute(e,t),Sa.normalize(),e.setXYZ(t,Sa.x,Sa.y,Sa.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 Qr(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 Vl=new Ft,cl=new hn,fs=new we,Ta=new ot,_s=new ot,Or=new ot,Jl=new ot,mc=new ot,lu=new ot,Zh=new ot,cu=new ot;class Zs extends Jr{constructor(e=new xr,t=new Wr){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){lu.set(0,0,0);for(let u=0,d=o.length;u<d;u++){const p=c[u],m=o[u];p!==0&&(mc.fromBufferAttribute(m,e),a?lu.addScaledVector(mc,p):lu.addScaledVector(mc.sub(t),p))}t.add(lu)}return t}raycast(e,t){const n=this.geometry,s=this.material,o=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),fs.copy(n.boundingSphere),fs.applyMatrix4(o),cl.copy(e.ray).recast(e.near),!(fs.containsPoint(cl.origin)===!1&&(cl.intersectSphere(fs,Ta)===null||cl.origin.distanceToSquared(Ta)>Kf(e.far-e.near,2)))&&(Vl.copy(o).invert(),cl.copy(e.ray).applyMatrix4(Vl),!(n.boundingBox!==null&&cl.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,cl)))}_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],ee=Math.max(z.start,M.start),Q=Math.min(c.count,Math.min(z.start+z.count,M.start+M.count));for(let oe=ee,_e=Q;oe<_e;oe+=3){const ve=c.getX(oe),Oe=c.getX(oe+1),He=c.getX(oe+2);s=tf(this,I,e,n,d,p,m,ve,Oe,He),s&&(s.faceIndex=Math.floor(oe/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 ee=c.getX(z),Q=c.getX(z+1),oe=c.getX(z+2);s=tf(this,a,e,n,d,p,m,ee,Q,oe),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],ee=Math.max(z.start,M.start),Q=Math.min(u.count,Math.min(z.start+z.count,M.start+M.count));for(let oe=ee,_e=Q;oe<_e;oe+=3){const ve=oe,Oe=oe+1,He=oe+2;s=tf(this,I,e,n,d,p,m,ve,Oe,He),s&&(s.faceIndex=Math.floor(oe/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 ee=z,Q=z+1,oe=z+2;s=tf(this,a,e,n,d,p,m,ee,Q,oe),s&&(s.faceIndex=Math.floor(z/3),t.push(s))}}}}function Kh(r,e,t,n,s,o,a,c){let u;if(e.side===K?u=n.intersectTriangle(a,o,s,!0,c):u=n.intersectTriangle(s,o,a,e.side===W,c),u===null)return null;cu.copy(c),cu.applyMatrix4(r.matrixWorld);const d=t.ray.origin.distanceTo(cu);return d<t.near||d>t.far?null:{distance:d,point:cu.clone(),object:r}}function tf(r,e,t,n,s,o,a,c,u,d){r.getVertexPosition(c,_s),r.getVertexPosition(u,Or),r.getVertexPosition(d,Jl);const p=Kh(r,e,t,n,_s,Or,Jl,Zh);if(p){const m=new ot;na.getBarycoord(Zh,_s,Or,Jl,m),s&&(p.uv=na.getInterpolatedAttribute(s,c,u,d,m,new yn)),o&&(p.uv1=na.getInterpolatedAttribute(o,c,u,d,m,new yn)),a&&(p.normal=na.getInterpolatedAttribute(a,c,u,d,m,new ot),p.normal.dot(n.direction)>0&&p.normal.multiplyScalar(-1));const y={a:c,b:u,c:d,normal:new ot,materialIndex:0};na.getNormal(_s,Or,Jl,y.normal),p.face=y,p.barycoord=m}return p}class Fc 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,ee,Q,oe,_e,ve,Oe,He,Ce){const Be=oe/Oe,ft=_e/He,zt=oe/2,tn=_e/2,cn=ve/2,vn=Oe+1,mn=He+1;let Yn=0,xn=0;const si=new ot;for(let wn=0;wn<mn;wn++){const Gn=wn*ft-tn;for(let Si=0;Si<vn;Si++){const nr=Si*Be-zt;si[G]=nr*ee,si[z]=Gn*Q,si[I]=cn,d.push(si.x,si.y,si.z),si[G]=0,si[z]=0,si[I]=ve>0?1:-1,p.push(si.x,si.y,si.z),m.push(Si/Oe),m.push(1-wn/He),Yn+=1}}for(let wn=0;wn<He;wn++)for(let Gn=0;Gn<Oe;Gn++){const Si=y+Gn+vn*wn,nr=y+Gn+vn*(wn+1),ss=y+(Gn+1)+vn*(wn+1),Vn=y+(Gn+1)+vn*wn;u.push(Si,nr,Vn),u.push(nr,ss,Vn),xn+=6}c.addGroup(M,xn,Ce),M+=xn,y+=Yn}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Fc(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Jh(r){const e={};for(const t in r){e[t]={};for(const n in r[t]){const s=r[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 Ja(r){const e={};for(let t=0;t<r.length;t++){const n=Jh(r[t]);for(const s in n)e[s]=n[s]}return e}function fh(r){const e=[];for(let t=0;t<r.length;t++)e.push(r[t].clone());return e}function ox(r){const e=r.getRenderTarget();return e===null?r.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ki.workingColorSpace}const ap={clone:Jh,merge:Ja};var Gm=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,Wm=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;class Bc extends Ei{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Gm,this.fragmentShader=Wm,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=Jh(e.uniforms),this.uniformsGroups=fh(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 Hm extends Jr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ft,this.projectionMatrix=new Ft,this.projectionMatrixInverse=new Ft,this.coordinateSystem=so,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 Qh=new ot,l1=new yn,ax=new yn;class fa extends Hm{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=Fa*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(lc*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Fa*2*Math.atan(Math.tan(lc*.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){Qh.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Qh.x,Qh.y).multiplyScalar(-e/Qh.z),Qh.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Qh.x,Qh.y).multiplyScalar(-e/Qh.z)}getViewSize(e,t){return this.getViewBounds(e,l1,ax),t.subVectors(ax,l1)}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(lc*.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 ed=-90,nf=1;class Vu extends Jr{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new fa(ed,nf,e,t);s.layers=this.layers,this.add(s);const o=new fa(ed,nf,e,t);o.layers=this.layers,this.add(o);const a=new fa(ed,nf,e,t);a.layers=this.layers,this.add(a);const c=new fa(ed,nf,e,t);c.layers=this.layers,this.add(c);const u=new fa(ed,nf,e,t);u.layers=this.layers,this.add(u);const d=new fa(ed,nf,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===so)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===ja)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 ph extends Wo{constructor(e=[],t=Fe,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 R0 extends cc{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 ph(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 Fc(5,5,5),o=new Bc({name:"CubemapFromEquirect",uniforms:Jh(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:K,blending:ye});o.uniforms.tEquirect.value=t;const a=new Zs(s,o),c=t.minFilter;return t.minFilter===Qn&&(t.minFilter=Rn),new Vu(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 ul extends Jr{constructor(){super(),this.isGroup=!0,this.type="Group"}}const rf={type:"move"};class Gu{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ul,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 ul,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ot,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ot),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ul,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ot,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ot),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(rf)))}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 ul;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class N0{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new jn(e),this.density=t}clone(){return new N0(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class lp{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 lp(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class $m extends Jr{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 Wu{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Ou,this.updateRanges=[],this.version=0,this.uuid=yl()}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=yl()),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=yl()),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 El=new ot;class sf{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++)El.fromBufferAttribute(this,t),El.applyMatrix4(e),this.setXYZ(t,El.x,El.y,El.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)El.fromBufferAttribute(this,t),El.applyNormalMatrix(e),this.setXYZ(t,El.x,El.y,El.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)El.fromBufferAttribute(this,t),El.transformDirection(e),this.setXYZ(t,El.x,El.y,El.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=qa(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ls(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=ls(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=ls(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=ls(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=ls(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=qa(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=qa(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=qa(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=qa(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=ls(t,this.array),n=ls(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=ls(t,this.array),n=ls(n,this.array),s=ls(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=ls(t,this.array),n=ls(n,this.array),s=ls(s,this.array),o=ls(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 Qr(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 sf(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 cp 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 mh;const up=new ot,td=new ot,Ea=new ot,Uc=new yn,nd=new yn,id=new Ft,gh=new ot,uu=new ot,Hu=new ot,rd=new yn,sd=new yn,P0=new yn;class jm extends null{constructor(e=new cp){if(super(),this.isSprite=!0,this.type="Sprite",mh===void 0){mh=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 Wu(t,5);mh.setIndex([0,1,2,0,2,3]),mh.setAttribute("position",new sf(n,3,0,!1)),mh.setAttribute("uv",new sf(n,2,3,!1))}this.geometry=mh,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.'),td.setFromMatrixScale(this.matrixWorld),id.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ea.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&td.multiplyScalar(-Ea.z);const n=this.material.rotation;let s,o;n!==0&&(o=Math.cos(n),s=Math.sin(n));const a=this.center;yh(gh.set(-.5,-.5,0),Ea,a,td,s,o),yh(uu.set(.5,-.5,0),Ea,a,td,s,o),yh(Hu.set(.5,.5,0),Ea,a,td,s,o),rd.set(0,0),sd.set(1,0),P0.set(1,1);let c=e.ray.intersectTriangle(gh,uu,Hu,!1,up);if(c===null&&(yh(uu.set(-.5,.5,0),Ea,a,td,s,o),sd.set(0,1),c=e.ray.intersectTriangle(gh,Hu,uu,!1,up),c===null))return;const u=e.ray.origin.distanceTo(up);u<e.near||u>e.far||t.push({distance:u,point:up.clone(),uv:na.getInterpolation(up,gh,uu,Hu,rd,sd,P0,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 yh(r,e,t,n,s,o){Uc.subVectors(r,t).addScalar(.5).multiply(n),s!==void 0?(nd.x=o*Uc.x-s*Uc.y,nd.y=s*Uc.x+o*Uc.y):nd.copy(Uc),r.copy(e),r.x+=nd.x,r.y+=nd.y,r.applyMatrix4(id)}const od=new ot,I0=new ot;class L0 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){od.setFromMatrixPosition(this.matrixWorld);const s=e.ray.origin.distanceTo(od);this.getObjectForDistance(s).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){od.setFromMatrixPosition(e.matrixWorld),I0.setFromMatrixPosition(this.matrixWorld);const n=od.distanceTo(I0)/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 D0=new ot,O0=new mr,hp=new mr,Xm=new ot,F0=new Ft,qm=new ot,Ym=new we,B0=new Ft,Zm=new hn;class c1 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 ha),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,qm),this.boundingBox.expandByPoint(qm)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new we),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,qm),this.boundingSphere.expandByPoint(qm)}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(),Ym.copy(this.boundingSphere),Ym.applyMatrix4(s),e.ray.intersectsSphere(Ym)!==!1&&(B0.copy(s).invert(),Zm.copy(e.ray).applyMatrix4(B0),!(this.boundingBox!==null&&Zm.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Zm)))}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===Me?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,s=this.geometry;O0.fromBufferAttribute(s.attributes.skinIndex,e),hp.fromBufferAttribute(s.attributes.skinWeight,e),D0.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let o=0;o<4;o++){const a=hp.getComponent(o);if(a!==0){const c=O0.getComponent(o);F0.multiplyMatrices(n.bones[c].matrixWorld,n.boneInverses[c]),t.addScaledVector(Xm.copy(D0).applyMatrix4(F0),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class U0 extends null{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Ql extends Wo{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 Km=new Ft,lx=new Ft;class dp{constructor(e=[],t=[]){this.uuid=yl(),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:lx;Km.multiplyMatrices(c,t[o]),Km.toArray(n,o*16)}s!==null&&(s.needsUpdate=!0)}clone(){return new dp(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 Ql(t,e,e,D,gs);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 U0),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 kc extends Qr{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 ad=new Ft,hu=new Ft,fp=null,cx=new ha,k0=new Ft,$u=new Zs,du=new we;class ux extends null{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new kc(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,k0)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new ha),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ad),cx.copy(e.boundingBox).applyMatrix4(ad),this.boundingBox.union(cx)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new we),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ad),du.copy(e.boundingSphere).applyMatrix4(ad),this.boundingSphere.union(du)}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($u.geometry=this.geometry,$u.material=this.material,$u.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),du.copy(this.boundingSphere),du.applyMatrix4(n),e.ray.intersectsSphere(du)!==!1))for(let o=0;o<s;o++){this.getMatrixAt(o,ad),hu.multiplyMatrices(n,ad),$u.matrixWorld=hu,$u.raycast(e,fp);for(let a=0,c=fp.length;a<c;a++){const u=fp[a];u.instanceId=o,u.object=this,t.push(u)}fp.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new kc(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 Ql(new Float32Array(s*this.count),s,this.count,F,gs));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 of=new ot,hx=new ot,u1=new $r;class Al{constructor(e=new ot(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=of.subVectors(n,t).cross(hx.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(of),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||u1.getNormalMatrix(e),s=this.coplanarPoint(of).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 zc=new we,h1=new yn(.5,.5),af=new ot;class lf{constructor(e=new Al,t=new Al,n=new Al,s=new Al,o=new Al,a=new Al){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=so,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],ee=o[12],Q=o[13],oe=o[14],_e=o[15];if(s[0].setComponents(d-a,M-p,I-T,_e-ee).normalize(),s[1].setComponents(d+a,M+p,I+T,_e+ee).normalize(),s[2].setComponents(d+c,M+m,I+G,_e+Q).normalize(),s[3].setComponents(d-c,M-m,I-G,_e-Q).normalize(),n)s[4].setComponents(u,y,z,oe).normalize(),s[5].setComponents(d-u,M-y,I-z,_e-oe).normalize();else if(s[4].setComponents(d-u,M-y,I-z,_e-oe).normalize(),t===so)s[5].setComponents(d+u,M+y,I+z,_e+oe).normalize();else if(t===ja)s[5].setComponents(u,y,z,oe).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(),zc.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),zc.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(zc)}intersectsSprite(e){zc.center.set(0,0,0);const t=h1.distanceTo(e.center);return zc.radius=.7071067811865476+t,zc.applyMatrix4(e.matrixWorld),this.intersectsSphere(zc)}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(af.x=s.normal.x>0?e.max.x:e.min.x,af.y=s.normal.y>0?e.max.y:e.min.y,af.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(af)<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 fu=new Ft,Cl=new lf;class pu{constructor(){this.coordinateSystem=so}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(fu.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse),Cl.setFromProjectionMatrix(fu,s.coordinateSystem,s.reversedDepth),Cl.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(fu.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse),Cl.setFromProjectionMatrix(fu,s.coordinateSystem,s.reversedDepth),Cl.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(fu.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse),Cl.setFromProjectionMatrix(fu,s.coordinateSystem,s.reversedDepth),Cl.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(fu.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse),Cl.setFromProjectionMatrix(fu,s.coordinateSystem,s.reversedDepth),Cl.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(fu.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse),Cl.setFromProjectionMatrix(fu,s.coordinateSystem,s.reversedDepth),Cl.containsPoint(e))return!0}return!1}clone(){return new pu}}function z0(r,e){return r-e}function Jm(r,e){return r.z-e.z}function V0(r,e){return e.z-r.z}class mu{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 $o=new Ft,G0=new jn(1,1,1),Qm=new lf,d1=new pu,eg=new ha,ld=new we,Qa=new ot,dx=new ot,fx=new ot,W0=new mu,za=new Zs,gu=null;function pp(r,e,t=0){const n=e.itemSize;if(r.isInterleavedBufferAttribute||r.array.constructor!==e.array.constructor){const s=r.count;for(let o=0;o<s;o++)for(let a=0;a<n;a++)e.setComponent(o+t,a,r.getComponent(o,a))}else e.array.set(r.array,t*n);e.needsUpdate=!0}function vh(r,e){if(r.constructor!==e.constructor){const t=Math.min(r.length,e.length);for(let n=0;n<t;n++)e[n]=r[n]}else{const t=Math.min(r.length,e.length);e.set(new r.constructor(r.buffer,0,t))}}class f1 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 Ql(t,e,e,D,gs);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),n=new Ql(t,e,e,X,as);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 Ql(t,e,e,D,gs);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 Qr(p,u,d);t.setAttribute(o,m)}if(e.getIndex()!==null){const o=n>65535?new Uint32Array(s):new Uint16Array(s);t.setIndex(new Qr(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 ha);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,$o),this.getBoundingBoxAt(o,eg).applyMatrix4($o),e.union(eg)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new we);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,$o),this.getBoundingSphereAt(o,ld).applyMatrix4($o),e.union(ld)}}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(z0),s=this._availableInstanceIds.shift(),this._instanceInfo[s]=n):(s=this._instanceInfo.length,this._instanceInfo.push(n));const o=this._matricesTexture;$o.identity().toArray(o.image.data,s*16),o.needsUpdate=!0;const a=this._colorsTexture;return a&&(G0.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(z0),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);pp(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 ha,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(Qa.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 we;this.getBoundingBoxAt(e,eg),eg.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)),Qa.fromBufferAttribute(c,m),u=Math.max(u,o.center.distanceToSquared(Qa))}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(z0);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);vh(this._multiDrawCounts,s),vh(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(),vh(a.image.data,this._indirectTexture.image.data),c.dispose(),this._initMatricesTexture(),vh(c.image.data,this._matricesTexture.image.data),u&&(u.dispose(),this._initColorsTexture(),vh(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&&vh(o.index.array,a.index.array);for(const c in o.attributes)vh(o.attributes[c].array,a.attributes[c].array)}raycast(e,t){const n=this._instanceInfo,s=this._geometryInfo,o=this.matrixWorld,a=this.geometry;za.material=this.material,za.geometry.index=a.index,za.geometry.attributes=a.attributes,za.geometry.boundingBox===null&&(za.geometry.boundingBox=new ha),za.geometry.boundingSphere===null&&(za.geometry.boundingSphere=new we);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];za.geometry.setDrawRange(p.start,p.count),this.getMatrixAt(c,za.matrixWorld).premultiply(o),this.getBoundingBoxAt(d,za.geometry.boundingBox),this.getBoundingSphereAt(d,za.geometry.boundingSphere),za.raycast(e,gu);for(let m=0,y=gu.length;m<y;m++){const M=gu[m];M.object=this,M.batchId=c,t.push(M)}gu.length=0}za.material=null,za.geometry.index=null,za.geometry.attributes={},za.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=>ac(qs({},t),{boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>qs({},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?d1:Qm;y&&!n.isArrayCamera&&($o.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),Qm.setFromProjectionMatrix($o,n.coordinateSystem,n.reversedDepth));let z=0;if(this.sortObjects){$o.copy(this.matrixWorld).invert(),Qa.setFromMatrixPosition(n.matrixWorld).applyMatrix4($o),dx.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection($o);for(let Q=0,oe=u.length;Q<oe;Q++)if(u[Q].visible&&u[Q].active){const _e=u[Q].geometryIndex;this.getMatrixAt(Q,$o),this.getBoundingSphereAt(_e,ld).applyMatrix4($o);let ve=!1;if(y&&(ve=!G.intersectsSphere(ld,n)),!ve){const Oe=m[_e],He=fx.subVectors(ld.center,Qa).dot(dx);W0.push(Oe.start,Oe.count,He,Q)}}const I=W0.list,ee=this.customSort;ee===null?I.sort(o.transparent?V0:Jm):ee.call(this,I,n);for(let Q=0,oe=I.length;Q<oe;Q++){const _e=I[Q];d[z]=_e.start*c,p[z]=_e.count,T[z]=_e.index,z++}W0.reset()}else for(let I=0,ee=u.length;I<ee;I++)if(u[I].visible&&u[I].active){const Q=u[I].geometryIndex;let oe=!1;if(y&&(this.getMatrixAt(I,$o),this.getBoundingSphereAt(Q,ld).applyMatrix4($o),oe=!G.intersectsSphere(ld,n)),!oe){const _e=m[Q];d[z]=_e.start*c,p[z]=_e.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 el 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 Va=new ot,cd=new ot,px=new Ft,Vc=new hn,tg=new we,Rl=new ot,mp=new ot;class xh extends Jr{constructor(e=new xr,t=new el){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++)Va.fromBufferAttribute(t,s-1),cd.fromBufferAttribute(t,s),n[s]=n[s-1],n[s]+=Va.distanceTo(cd);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(),tg.copy(n.boundingSphere),tg.applyMatrix4(s),tg.radius+=o,e.ray.intersectsSphere(tg)===!1)return;px.copy(s).invert(),Vc.copy(e.ray).applyMatrix4(px);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),ee=p.getX(G+1),Q=gp(this,e,Vc,u,I,ee,G);Q&&t.push(Q)}if(this.isLineLoop){const G=p.getX(T-1),z=p.getX(M),I=gp(this,e,Vc,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=gp(this,e,Vc,u,G,G+1,G);I&&t.push(I)}if(this.isLineLoop){const G=gp(this,e,Vc,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 gp(r,e,t,n,s,o,a){const c=r.geometry.attributes.position;if(Va.fromBufferAttribute(c,s),cd.fromBufferAttribute(c,o),t.distanceSqToSegment(Va,cd,Rl,mp)>n)return;Rl.applyMatrix4(r.matrixWorld);const d=e.ray.origin.distanceTo(Rl);if(!(d<e.near||d>e.far))return{distance:d,point:mp.clone().applyMatrix4(r.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:r}}const cf=new ot,yp=new ot;class ng 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)cf.fromBufferAttribute(t,s),yp.fromBufferAttribute(t,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+cf.distanceTo(yp);e.setAttribute("lineDistance",new Zi(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class mx extends null{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class uf 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 vp=new Ft,ig=new hn,xp=new we,_p=new ot;class p1 extends null{constructor(e=new xr,t=new uf){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(),xp.copy(n.boundingSphere),xp.applyMatrix4(s),xp.radius+=o,e.ray.intersectsSphere(xp)===!1)return;vp.copy(s).invert(),ig.copy(e.ray).applyMatrix4(vp);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);_p.fromBufferAttribute(m,z),H0(_p,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++)_p.fromBufferAttribute(m,T),H0(_p,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 H0(r,e,t,n,s,o,a){const c=ig.distanceSqToPoint(r);if(c<t){const u=new ot;ig.closestPointToPoint(r,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 m1 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 gx 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 bp extends Wo{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Ct,this.minFilter=Ct,this.generateMipmaps=!1,this.needsUpdate=!0}}class rg 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 lE extends null{constructor(e,t,n,s,o,a){super(e,t,n,o,a),this.isCompressedArrayTexture=!0,this.image.depth=s,this.wrapR=qe,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class g1 extends null{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,Fe),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class g3 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 gc extends Wo{constructor(e,t,n=as,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 wo(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 y1 extends Wo{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class $0 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 ot,I=new ot;for(let ee=0;ee<=T;ee++){let Q=0,oe=0,_e=0,ve=0;if(ee<=n){const Ce=ee/n,Be=Ce*Math.PI/2;oe=-p-e*Math.cos(Be),_e=e*Math.sin(Be),ve=-e*Math.cos(Be),Q=Ce*m}else if(ee<=n+o){const Ce=(ee-n)/o;oe=-p+Ce*t,_e=e,ve=0,Q=m+Ce*y}else{const Ce=(ee-n-o)/n,Be=Ce*Math.PI/2;oe=p+e*Math.sin(Be),_e=e*Math.cos(Be),ve=e*Math.sin(Be),Q=m+y+Ce*m}const Oe=Math.max(0,Math.min(1,Q/M));let He=0;ee===0?He=.5/s:ee===T&&(He=-.5/s);for(let Ce=0;Ce<=s;Ce++){const Be=Ce/s,ft=Be*Math.PI*2,zt=Math.sin(ft),tn=Math.cos(ft);I.x=-_e*tn,I.y=oe,I.z=_e*zt,c.push(I.x,I.y,I.z),z.set(-_e*tn,ve,_e*zt),z.normalize(),u.push(z.x,z.y,z.z),d.push(Be+He,Oe)}if(ee>0){const Ce=(ee-1)*G;for(let Be=0;Be<s;Be++){const ft=Ce+Be,zt=Ce+Be+1,tn=ee*G+Be,cn=ee*G+Be+1;a.push(ft,zt,tn),a.push(zt,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 $0(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class yx 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 ot,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 yx(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class wp 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;ee(),a===!1&&(e>0&&Q(!0),t>0&&Q(!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 ee(){const oe=new ot,_e=new ot;let ve=0;const Oe=(t-e)/n;for(let He=0;He<=o;He++){const Ce=[],Be=He/o,ft=Be*(t-e)+e;for(let zt=0;zt<=s;zt++){const tn=zt/s,cn=tn*u+c,vn=Math.sin(cn),mn=Math.cos(cn);_e.x=ft*vn,_e.y=-Be*n+z,_e.z=ft*mn,m.push(_e.x,_e.y,_e.z),oe.set(vn,Oe,mn).normalize(),y.push(oe.x,oe.y,oe.z),M.push(tn,1-Be),Ce.push(T++)}G.push(Ce)}for(let He=0;He<s;He++)for(let Ce=0;Ce<o;Ce++){const Be=G[Ce][He],ft=G[Ce+1][He],zt=G[Ce+1][He+1],tn=G[Ce][He+1];(e>0||Ce!==0)&&(p.push(Be,ft,tn),ve+=3),(t>0||Ce!==o-1)&&(p.push(ft,zt,tn),ve+=3)}d.addGroup(I,ve,0),I+=ve}function Q(oe){const _e=T,ve=new yn,Oe=new ot;let He=0;const Ce=oe===!0?e:t,Be=oe===!0?1:-1;for(let zt=1;zt<=s;zt++)m.push(0,z*Be,0),y.push(0,Be,0),M.push(.5,.5),T++;const ft=T;for(let zt=0;zt<=s;zt++){const cn=zt/s*u+c,vn=Math.cos(cn),mn=Math.sin(cn);Oe.x=Ce*mn,Oe.y=z*Be,Oe.z=Ce*vn,m.push(Oe.x,Oe.y,Oe.z),y.push(0,Be,0),ve.x=vn*.5+.5,ve.y=mn*.5*Be+.5,M.push(ve.x,ve.y),T++}for(let zt=0;zt<s;zt++){const tn=_e+zt,cn=ft+zt;oe===!0?p.push(cn,cn+1,tn):p.push(cn+1,cn,tn),He+=3}d.addGroup(I,He,oe===!0?1:2),I+=He}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new wp(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Mp extends wp{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 Mp(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class hf 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(ee){const Q=new ot,oe=new ot,_e=new ot;for(let ve=0;ve<t.length;ve+=3)M(t[ve+0],Q),M(t[ve+1],oe),M(t[ve+2],_e),u(Q,oe,_e,ee)}function u(ee,Q,oe,_e){const ve=_e+1,Oe=[];for(let He=0;He<=ve;He++){Oe[He]=[];const Ce=ee.clone().lerp(oe,He/ve),Be=Q.clone().lerp(oe,He/ve),ft=ve-He;for(let zt=0;zt<=ft;zt++)zt===0&&He===ve?Oe[He][zt]=Ce:Oe[He][zt]=Ce.clone().lerp(Be,zt/ft)}for(let He=0;He<ve;He++)for(let Ce=0;Ce<2*(ve-He)-1;Ce++){const Be=Math.floor(Ce/2);Ce%2===0?(y(Oe[He][Be+1]),y(Oe[He+1][Be]),y(Oe[He][Be])):(y(Oe[He][Be+1]),y(Oe[He+1][Be+1]),y(Oe[He+1][Be]))}}function d(ee){const Q=new ot;for(let oe=0;oe<o.length;oe+=3)Q.x=o[oe+0],Q.y=o[oe+1],Q.z=o[oe+2],Q.normalize().multiplyScalar(ee),o[oe+0]=Q.x,o[oe+1]=Q.y,o[oe+2]=Q.z}function p(){const ee=new ot;for(let Q=0;Q<o.length;Q+=3){ee.x=o[Q+0],ee.y=o[Q+1],ee.z=o[Q+2];const oe=z(ee)/2/Math.PI+.5,_e=I(ee)/Math.PI+.5;a.push(oe,1-_e)}T(),m()}function m(){for(let ee=0;ee<a.length;ee+=6){const Q=a[ee+0],oe=a[ee+2],_e=a[ee+4],ve=Math.max(Q,oe,_e),Oe=Math.min(Q,oe,_e);ve>.9&&Oe<.1&&(Q<.2&&(a[ee+0]+=1),oe<.2&&(a[ee+2]+=1),_e<.2&&(a[ee+4]+=1))}}function y(ee){o.push(ee.x,ee.y,ee.z)}function M(ee,Q){const oe=ee*3;Q.x=e[oe+0],Q.y=e[oe+1],Q.z=e[oe+2]}function T(){const ee=new ot,Q=new ot,oe=new ot,_e=new ot,ve=new yn,Oe=new yn,He=new yn;for(let Ce=0,Be=0;Ce<o.length;Ce+=9,Be+=6){ee.set(o[Ce+0],o[Ce+1],o[Ce+2]),Q.set(o[Ce+3],o[Ce+4],o[Ce+5]),oe.set(o[Ce+6],o[Ce+7],o[Ce+8]),ve.set(a[Be+0],a[Be+1]),Oe.set(a[Be+2],a[Be+3]),He.set(a[Be+4],a[Be+5]),_e.copy(ee).add(Q).add(oe).divideScalar(3);const ft=z(_e);G(ve,Be+0,ee,ft),G(Oe,Be+2,Q,ft),G(He,Be+4,oe,ft)}}function G(ee,Q,oe,_e){_e<0&&ee.x===1&&(a[Q]=ee.x-1),oe.x===0&&oe.z===0&&(a[Q]=_e/2/Math.PI+.5)}function z(ee){return Math.atan2(ee.z,-ee.x)}function I(ee){return Math.atan2(-ee.y,Math.sqrt(ee.x*ee.x+ee.z*ee.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new hf(e.vertices,e.indices,e.radius,e.details)}}class vx extends hf{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 vx(e.radius,e.detail)}}const df=new ot,ff=new ot,pf=new ot,ud=new na;class hd 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(lc*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}=ud;if(G.fromBufferAttribute(c,d[0]),z.fromBufferAttribute(c,d[1]),I.fromBufferAttribute(c,d[2]),ud.getNormal(pf),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 ee=0;ee<3;ee++){const Q=(ee+1)%3,oe=m[ee],_e=m[Q],ve=ud[p[ee]],Oe=ud[p[Q]],He=`${oe}_${_e}`,Ce=`${_e}_${oe}`;Ce in y&&y[Ce]?(pf.dot(y[Ce].normal)<=o&&(M.push(ve.x,ve.y,ve.z),M.push(Oe.x,Oe.y,Oe.z)),y[Ce]=null):He in y||(y[He]={index0:d[ee],index1:d[Q],normal:pf.clone()})}}for(const T in y)if(y[T]){const{index0:G,index1:z}=y[T];df.fromBufferAttribute(c,G),ff.fromBufferAttribute(c,z),M.push(df.x,df.y,df.z),M.push(ff.x,ff.y,ff.z)}this.setAttribute("position",new Zi(M,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class yc{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 ot);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 ot,s=[],o=[],a=[],c=new ot,u=new Ft;for(let M=0;M<=e;M++){const T=M/e;s[M]=this.getTangentAt(T,new ot)}o[0]=new ot,a[0]=new ot;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 mf extends yc{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 sg extends mf{constructor(e,t,n,s,o,a){super(e,t,n,n,s,o,a),this.isArcCurve=!0,this.type="ArcCurve"}}function Sp(){let r=0,e=0,t=0,n=0;function s(o,a,c,u){r=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 r+e*o+t*a+n*c}}}const dd=new ot,j0=new Sp,vc=new Sp,Tp=new Sp;class v1 extends yc{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 ot){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]:(dd.subVectors(s[0],s[1]).add(s[0]),d=dd);const m=s[c%o],y=s[(c+1)%o];if(this.closed||c+2<o?p=s[(c+2)%o]:(dd.subVectors(s[o-1],s[o-2]).add(s[o-1]),p=dd),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),vc.initNonuniformCatmullRom(d.y,m.y,y.y,p.y,T,G,z),Tp.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),vc.initCatmullRom(d.y,m.y,y.y,p.y,this.tension),Tp.initCatmullRom(d.z,m.z,y.z,p.z,this.tension));return n.set(j0.calc(u),vc.calc(u),Tp.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 ot().fromArray(s))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function og(r,e,t,n,s){const o=(n-e)*.5,a=(s-t)*.5,c=r*r,u=r*c;return(2*t-2*n+o+a)*u+(-3*t+3*n-2*o-a)*c+o*r+t}function ag(r,e){const t=1-r;return t*t*e}function X0(r,e){return 2*(1-r)*r*e}function q0(r,e){return r*r*e}function fd(r,e,t,n){return ag(r,e)+X0(r,t)+q0(r,n)}function x1(r,e){const t=1-r;return t*t*t*e}function xx(r,e){const t=1-r;return 3*t*t*r*e}function _1(r,e){return 3*(1-r)*r*r*e}function b1(r,e){return r*r*r*e}function Ep(r,e,t,n,s){return x1(r,e)+xx(r,t)+_1(r,n)+b1(r,s)}class gf extends yc{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(Ep(e,s.x,o.x,a.x,c.x),Ep(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 _x extends yc{constructor(e=new ot,t=new ot,n=new ot,s=new ot){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=s}getPoint(e,t=new ot){const n=t,s=this.v0,o=this.v1,a=this.v2,c=this.v3;return n.set(Ep(e,s.x,o.x,a.x,c.x),Ep(e,s.y,o.y,a.y,c.y),Ep(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 bx extends yc{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 w1 extends yc{constructor(e=new ot,t=new ot){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new ot){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 ot){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 wx extends yc{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(fd(e,s.x,o.x,a.x),fd(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 pd extends yc{constructor(e=new ot,t=new ot,n=new ot){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new ot){const n=t,s=this.v0,o=this.v1,a=this.v2;return n.set(fd(e,s.x,o.x,a.x),fd(e,s.y,o.y,a.y),fd(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 Y0 extends yc{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(og(c,u.x,d.x,p.x,m.x),og(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 lg=Object.freeze({__proto__:null,ArcCurve:sg,CatmullRomCurve3:v1,CubicBezierCurve:gf,CubicBezierCurve3:_x,EllipseCurve:mf,LineCurve:bx,LineCurve3:w1,QuadraticBezierCurve:wx,QuadraticBezierCurve3:pd,SplineCurve:Y0});class Mx extends yc{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 lg[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 lg[s.type]().fromJSON(s))}return this}}class Z0 extends Mx{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 bx(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 wx(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 gf(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 Y0(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 mf(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 md extends Z0{constructor(e){super(e),this.uuid=yl(),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 Z0().fromJSON(s))}return this}}function Sx(r,e,t=2){const n=e&&e.length,s=n?e[0]*t:r.length;let o=K0(r,0,s,t,!0);const a=[];if(!o||o.next===o.prev)return a;let c,u,d;if(n&&(o=gd(r,e,o,t)),r.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=r[y],T=r[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 Ap(o,a,t,c,u,d,0),a}function K0(r,e,t,n,s){let o;if(s===Ip(r,e,t,n)>0)for(let a=e;a<t;a+=n)o=Pp(a/n|0,r[a],r[a+1],o);else for(let a=t-n;a>=e;a-=n)o=Pp(a/n|0,r[a],r[a+1],o);return o&&_h(o,o.next)&&(wh(o),o=o.next),o}function yu(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(_h(t,t.next)||jo(t.prev,t,t.next)===0)){if(wh(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Ap(r,e,t,n,s,o,a){if(!r)return;!a&&o&&A1(r,n,s,o);let c=r;for(;r.prev!==r.next;){const u=r.prev,d=r.next;if(o?yf(r,n,s,o):J0(r)){e.push(u.i,r.i,d.i),wh(r),r=d.next,c=d.next;continue}if(r=d,r===c){a?a===1?(r=M1(yu(r),e),Ap(r,e,t,n,s,o,2)):a===2&&Tx(r,e,t,n,s,o):Ap(yu(r),e,t,n,s,o,1);break}}}function J0(r){const e=r.prev,t=r,n=r.next;if(jo(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&&Rp(s,c,o,u,a,d,T.x,T.y)&&jo(T.prev,T,T.next)>=0)return!1;T=T.next}return!0}function yf(r,e,t,n){const s=r.prev,o=r,a=r.next;if(jo(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=Q0(M,T,e,t,n),ee=Q0(G,z,e,t,n);let Q=r.prevZ,oe=r.nextZ;for(;Q&&Q.z>=I&&oe&&oe.z<=ee;){if(Q.x>=M&&Q.x<=G&&Q.y>=T&&Q.y<=z&&Q!==s&&Q!==a&&Rp(c,p,u,m,d,y,Q.x,Q.y)&&jo(Q.prev,Q,Q.next)>=0||(Q=Q.prevZ,oe.x>=M&&oe.x<=G&&oe.y>=T&&oe.y<=z&&oe!==s&&oe!==a&&Rp(c,p,u,m,d,y,oe.x,oe.y)&&jo(oe.prev,oe,oe.next)>=0))return!1;oe=oe.nextZ}for(;Q&&Q.z>=I;){if(Q.x>=M&&Q.x<=G&&Q.y>=T&&Q.y<=z&&Q!==s&&Q!==a&&Rp(c,p,u,m,d,y,Q.x,Q.y)&&jo(Q.prev,Q,Q.next)>=0)return!1;Q=Q.prevZ}for(;oe&&oe.z<=ee;){if(oe.x>=M&&oe.x<=G&&oe.y>=T&&oe.y<=z&&oe!==s&&oe!==a&&Rp(c,p,u,m,d,y,oe.x,oe.y)&&jo(oe.prev,oe,oe.next)>=0)return!1;oe=oe.nextZ}return!0}function M1(r,e){let t=r;do{const n=t.prev,s=t.next.next;!_h(n,s)&&Ax(n,t,t.next,s)&&Mo(n,s)&&Mo(s,n)&&(e.push(n.i,t.i,s.i),wh(t),wh(t.next),t=r=s),t=t.next}while(t!==r);return yu(t)}function Tx(r,e,t,n,s,o){let a=r;do{let c=a.next.next;for(;c!==a.prev;){if(a.i!==c.i&&N1(a,c)){let u=ey(a,c);a=yu(a,a.next),u=yu(u,u.next),Ap(a,e,t,n,s,o,0),Ap(u,e,t,n,s,o,0);return}c=c.next}a=a.next}while(a!==r)}function gd(r,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:r.length,d=K0(r,c,u,n,!1);d===d.next&&(d.steiner=!0),s.push(R1(d))}s.sort(Cp);for(let o=0;o<s.length;o++)t=S1(s[o],t);return t}function Cp(r,e){let t=r.x-e.x;if(t===0&&(t=r.y-e.y,t===0)){const n=(r.next.y-r.y)/(r.next.x-r.x),s=(e.next.y-e.y)/(e.next.x-e.x);t=n-s}return t}function S1(r,e){const t=T1(r,e);if(!t)return e;const n=ey(t,r);return yu(n,n.next),yu(t,t.next)}function T1(r,e){let t=e;const n=r.x,s=r.y;let o=-1/0,a;if(_h(r,t))return t;do{if(_h(r,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&&Ex(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);Mo(t,r)&&(m<p||m===p&&(t.x>a.x||t.x===a.x&&E1(a,t)))&&(a=t,p=m)}t=t.next}while(t!==c);return a}function E1(r,e){return jo(r.prev,r,e.prev)<0&&jo(e.next,r,r.next)<0}function A1(r,e,t,n){let s=r;do s.z===0&&(s.z=Q0(s.x,s.y,e,t,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,C1(s)}function C1(r){let e,t=1;do{let n=r,s;r=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:r=s,s.prevZ=o,o=s;n=a}o.nextZ=null,t*=2}while(e>1);return r}function Q0(r,e,t,n,s){return r=(r-t)*s|0,e=(e-n)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function R1(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function Ex(r,e,t,n,s,o,a,c){return(s-a)*(e-c)>=(r-a)*(o-c)&&(r-a)*(n-c)>=(t-a)*(e-c)&&(t-a)*(o-c)>=(s-a)*(n-c)}function Rp(r,e,t,n,s,o,a,c){return!(r===a&&e===c)&&Ex(r,e,t,n,s,o,a,c)}function N1(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!P1(r,e)&&(Mo(r,e)&&Mo(e,r)&&vf(r,e)&&(jo(r.prev,r,e.prev)||jo(r,e.prev,e))||_h(r,e)&&jo(r.prev,r,r.next)>0&&jo(e.prev,e,e.next)>0)}function jo(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function _h(r,e){return r.x===e.x&&r.y===e.y}function Ax(r,e,t,n){const s=bh(jo(r,e,t)),o=bh(jo(r,e,n)),a=bh(jo(t,n,r)),c=bh(jo(t,n,e));return!!(s!==o&&a!==c||s===0&&Np(r,t,e)||o===0&&Np(r,n,e)||a===0&&Np(t,r,n)||c===0&&Np(t,e,n))}function Np(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function bh(r){return r>0?1:r<0?-1:0}function P1(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&Ax(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function Mo(r,e){return jo(r.prev,r,r.next)<0?jo(r,e,r.next)>=0&&jo(r,r.prev,e)>=0:jo(r,e,r.prev)<0||jo(r,r.next,e)<0}function vf(r,e){let t=r,n=!1;const s=(r.x+e.x)/2,o=(r.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!==r);return n}function ey(r,e){const t=ty(r.i,r.x,r.y),n=ty(e.i,e.x,e.y),s=r.next,o=e.prev;return r.next=e,e.prev=r,t.next=s,s.prev=t,n.next=t,t.prev=n,o.next=n,n.prev=o,n}function Pp(r,e,t,n){const s=ty(r,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 wh(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function ty(r,e,t){return{i:r,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Ip(r,e,t,n){let s=0;for(let o=e,a=t-n;o<t;o+=n)s+=(r[a]-r[o])*(r[o+1]+r[a+1]),a=o;return s}class I1{static triangulate(e,t,n=2){return Sx(e,t,n)}}class Gc{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 Gc.area(e)<0}static triangulateShape(e,t){const n=[],s=[],o=[];ny(e),xf(n,e);let a=e.length;t.forEach(ny);for(let u=0;u<t.length;u++)s.push(a),a+=t[u].length,xf(n,t[u]);const c=I1.triangulate(n,s);for(let u=0;u<c.length;u+=3)o.push(c.slice(u,u+3));return o}}function ny(r){const e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function xf(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}class Lp extends xr{constructor(e=new md([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,ee=t.UVGenerator!==void 0?t.UVGenerator:L1;let Q,oe=!1,_e,ve,Oe,He;I&&(Q=I.getSpacedPoints(p),oe=!0,y=!1,_e=I.computeFrenetFrames(p,!1),ve=new ot,Oe=new ot,He=new ot),y||(z=0,M=0,T=0,G=0);const Ce=c.extractPoints(d);let Be=Ce.shape;const ft=Ce.holes;if(!Gc.isClockWise(Be)){Be=Be.reverse();for(let Kn=0,Zn=ft.length;Kn<Zn;Kn++){const qn=ft[Kn];Gc.isClockWise(qn)&&(ft[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],bs=Ii.x-Hn.x,ps=Ii.y-Hn.y,St=bs*bs+ps*ps,nt=Math.max(Math.abs(Ii.x),Math.abs(Ii.y),Math.abs(Hn.x),Math.abs(Hn.y)),fn=qn*nt*nt;if(St<=fn){Kn.splice(pi,1),Ti--;continue}Hn=Ii}}tn(Be),ft.forEach(tn);const cn=ft.length,vn=Be;for(let Kn=0;Kn<cn;Kn++){const Zn=ft[Kn];Be=Be.concat(Zn)}function mn(Kn,Zn,qn){return Zn||console.error("THREE.ExtrudeGeometry: vec does not exist"),Kn.clone().addScaledVector(Zn,qn)}const Yn=Be.length;function xn(Kn,Zn,qn){let Hn,Ti,pi;const Ii=Kn.x-Zn.x,bs=Kn.y-Zn.y,ps=qn.x-Kn.x,St=qn.y-Kn.y,nt=Ii*Ii+bs*bs,fn=Ii*St-bs*ps;if(Math.abs(fn)>Number.EPSILON){const Dn=Math.sqrt(nt),ri=Math.sqrt(ps*ps+St*St),zn=Zn.x-bs/Dn,Rr=Zn.y+Ii/Dn,Ci=qn.x-St/ri,Tr=qn.y+ps/ri,Er=((Ci-zn)*St-(Tr-Rr)*ps)/(Ii*St-bs*ps);Hn=zn+Ii*Er-Kn.x,Ti=Rr+bs*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?ps>Number.EPSILON&&(Dn=!0):Ii<-Number.EPSILON?ps<-Number.EPSILON&&(Dn=!0):Math.sign(bs)===Math.sign(St)&&(Dn=!0),Dn?(Hn=-bs,Ti=Ii,pi=Math.sqrt(nt)):(Hn=Ii,Ti=bs,pi=Math.sqrt(nt/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=ft[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=Gc.triangulateShape(vn,ft);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,bs=vn.length;Ii<bs;Ii++){const ps=mn(vn[Ii],si[Ii],pi);ki(ps.x,ps.y,-Ti),Hn===0&&Kn.push(ps)}for(let Ii=0,bs=cn;Ii<bs;Ii++){const ps=ft[Ii];Gn=wn[Ii];const St=[];for(let nt=0,fn=ps.length;nt<fn;nt++){const Dn=mn(ps[nt],Gn[nt],pi);ki(Dn.x,Dn.y,-Ti),Hn===0&&St.push(Dn)}Hn===0&&Zn.push(St)}}nr=Gc.triangulateShape(Kn,Zn)}const ss=nr.length,Vn=T+G;for(let Kn=0;Kn<Yn;Kn++){const Zn=y?mn(Be[Kn],Si[Kn],Vn):Be[Kn];oe?(Oe.copy(_e.normals[0]).multiplyScalar(Zn.x),ve.copy(_e.binormals[0]).multiplyScalar(Zn.y),He.copy(Q[0]).add(Oe).add(ve),ki(He.x,He.y,He.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(Be[Zn],Si[Zn],Vn):Be[Zn];oe?(Oe.copy(_e.normals[Kn]).multiplyScalar(qn.x),ve.copy(_e.binormals[Kn]).multiplyScalar(qn.y),He.copy(Q[Kn]).add(Oe).add(ve),ki(He.x,He.y,He.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=ft.length;Ti<pi;Ti++){const Ii=ft[Ti];Gn=wn[Ti];for(let bs=0,ps=Ii.length;bs<ps;bs++){const St=mn(Ii[bs],Gn[bs],Hn);oe?ki(St.x,St.y+Q[p-1].y,Q[p-1].x+qn):ki(St.x,St.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<ss;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<ss;Hn++){const Ti=nr[Hn];Ni(Ti[0]+qn,Ti[1]+qn,Ti[2]+qn)}}else{for(let Zn=0;Zn<ss;Zn++){const qn=nr[Zn];Ni(qn[2],qn[1],qn[0])}for(let Zn=0;Zn<ss;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=ft.length;qn<Hn;qn++){const Ti=ft[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 bs=Yn*pi,ps=Yn*(pi+1),St=Zn+Hn+bs,nt=Zn+Ti+bs,fn=Zn+Ti+ps,Dn=Zn+Hn+ps;Cr(St,nt,fn,Dn)}}}function ki(Kn,Zn,qn){u.push(Kn),u.push(Zn),u.push(qn)}function Ni(Kn,Zn,qn){zs(Kn),zs(Zn),zs(qn);const Hn=s.length/3,Ti=ee.generateTopUV(n,s,Hn-3,Hn-2,Hn-1);Vt(Ti[0]),Vt(Ti[1]),Vt(Ti[2])}function Cr(Kn,Zn,qn,Hn){zs(Kn),zs(Zn),zs(Hn),zs(Zn),zs(qn),zs(Hn);const Ti=s.length/3,pi=ee.generateSideWallUV(n,s,Ti-6,Ti-3,Ti-2,Ti-1);Vt(pi[0]),Vt(pi[1]),Vt(pi[3]),Vt(pi[1]),Vt(pi[2]),Vt(pi[3])}function zs(Kn){s.push(u[Kn*3+0]),s.push(u[Kn*3+1]),s.push(u[Kn*3+2])}function Vt(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 D1(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 lg[s.type]().fromJSON(s)),new Lp(n,e.options)}}const L1={generateTopUV:function(r,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(r,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 D1(r,e,t){if(t.shapes=[],Array.isArray(r))for(let n=0,s=r.length;n<s;n++){const o=r[n];t.shapes.push(o.uuid)}else t.shapes.push(r.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class xc extends hf{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 xc(e.radius,e.detail)}}class cg 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 ot,y=new yn,M=new ot,T=new ot,G=new ot;let z=0,I=0;for(let ee=0;ee<=e.length-1;ee++)switch(ee){case 0:z=e[ee+1].x-e[ee].x,I=e[ee+1].y-e[ee].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[ee+1].x-e[ee].x,I=e[ee+1].y-e[ee].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 ee=0;ee<=t;ee++){const Q=n+ee*p*s,oe=Math.sin(Q),_e=Math.cos(Q);for(let ve=0;ve<=e.length-1;ve++){m.x=e[ve].x*oe,m.y=e[ve].y,m.z=e[ve].x*_e,a.push(m.x,m.y,m.z),y.x=ee/t,y.y=ve/(e.length-1),c.push(y.x,y.y);const Oe=u[3*ve+0]*oe,He=u[3*ve+1],Ce=u[3*ve+0]*_e;d.push(Oe,He,Ce)}}for(let ee=0;ee<t;ee++)for(let Q=0;Q<e.length-1;Q++){const oe=Q+ee*e.length,_e=oe,ve=oe+e.length,Oe=oe+e.length+1,He=oe+1;o.push(_e,ve,He),o.push(Oe,He,ve)}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 cg(e.points,e.segments,e.phiStart,e.phiLength)}}class Dp extends hf{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 Dp(e.radius,e.detail)}}class Mh 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 ee=I*y-a;for(let Q=0;Q<d;Q++){const oe=Q*m-o;T.push(oe,-ee,0),G.push(0,0,1),z.push(Q/c),z.push(1-I/u)}}for(let I=0;I<u;I++)for(let ee=0;ee<c;ee++){const Q=ee+d*I,oe=ee+d*(I+1),_e=ee+1+d*(I+1),ve=ee+1+d*I;M.push(Q,oe,ve),M.push(oe,_e,ve)}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 Mh(e.width,e.height,e.widthSegments,e.heightSegments)}}class iy 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 ot,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 ee=I+z,Q=ee,oe=ee+n+1,_e=ee+n+2,ve=ee+1;c.push(Q,oe,ve),c.push(oe,_e,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))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new iy(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class ry extends xr{constructor(e=new md([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;Gc.isClockWise(M)===!1&&(M=M.reverse());for(let z=0,I=T.length;z<I;z++){const ee=T[z];Gc.isClockWise(ee)===!0&&(T[z]=ee.reverse())}const G=Gc.triangulateShape(M,T);for(let z=0,I=T.length;z<I;z++){const ee=T[z];M=M.concat(ee)}for(let z=0,I=M.length;z<I;z++){const ee=M[z];s.push(ee.x,ee.y,0),o.push(0,0,1),a.push(ee.x,ee.y)}for(let z=0,I=G.length;z<I;z++){const ee=G[z],Q=ee[0]+m,oe=ee[1]+m,_e=ee[2]+m;n.push(Q,oe,_e),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 sy(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 ry(n,e.curveSegments)}}function sy(r,e){if(e.shapes=[],Array.isArray(r))for(let t=0,n=r.length;t<n;t++){const s=r[t];e.shapes.push(s.uuid)}else e.shapes.push(r.uuid);return e}class ju 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 ot,y=new ot,M=[],T=[],G=[],z=[];for(let I=0;I<=n;I++){const ee=[],Q=I/n;let oe=0;I===0&&a===0?oe=.5/t:I===n&&u===Math.PI&&(oe=-.5/t);for(let _e=0;_e<=t;_e++){const ve=_e/t;m.x=-e*Math.cos(s+ve*o)*Math.sin(a+Q*c),m.y=e*Math.cos(a+Q*c),m.z=e*Math.sin(s+ve*o)*Math.sin(a+Q*c),T.push(m.x,m.y,m.z),y.copy(m).normalize(),G.push(y.x,y.y,y.z),z.push(ve+oe,1-Q),ee.push(d++)}p.push(ee)}for(let I=0;I<n;I++)for(let ee=0;ee<t;ee++){const Q=p[I][ee+1],oe=p[I][ee],_e=p[I+1][ee],ve=p[I+1][ee+1];(I!==0||a>0)&&M.push(Q,oe,ve),(I!==n-1||u<Math.PI)&&M.push(oe,_e,ve)}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 ju(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class _f extends hf{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 _f(e.radius,e.detail)}}class Op 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 ot,m=new ot,y=new ot;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,ee=(s+1)*M+T;a.push(G,z,ee),a.push(z,I,ee)}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 Op(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Fp 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 ot,y=new ot,M=new ot,T=new ot,G=new ot,z=new ot,I=new ot;for(let Q=0;Q<=n;++Q){const oe=Q/n*o*Math.PI*2;ee(oe,o,a,e,M),ee(oe+.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 _e=0;_e<=s;++_e){const ve=_e/s*Math.PI*2,Oe=-t*Math.cos(ve),He=t*Math.sin(ve);m.x=M.x+(Oe*I.x+He*G.x),m.y=M.y+(Oe*I.y+He*G.y),m.z=M.z+(Oe*I.z+He*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(Q/n),p.push(_e/s)}}for(let Q=1;Q<=n;Q++)for(let oe=1;oe<=s;oe++){const _e=(s+1)*(Q-1)+(oe-1),ve=(s+1)*Q+(oe-1),Oe=(s+1)*Q+oe,He=(s+1)*(Q-1)+oe;c.push(_e,ve,He),c.push(ve,Oe,He)}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 ee(Q,oe,_e,ve,Oe){const He=Math.cos(Q),Ce=Math.sin(Q),Be=_e/oe*Q,ft=Math.cos(Be);Oe.x=ve*(2+ft)*.5*He,Oe.y=ve*(2+ft)*Ce*.5,Oe.z=ve*Math.sin(Be)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Fp(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class bf extends xr{constructor(e=new pd(new ot(-1,-1,0),new ot(-1,1,0),new ot(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 ot,u=new ot,d=new yn;let p=new ot;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 Q=0;Q<t;Q++)z(Q);z(o===!1?t:0),ee(),I()}function z(Q){p=e.getPointAt(Q/t,p);const oe=a.normals[Q],_e=a.binormals[Q];for(let ve=0;ve<=s;ve++){const Oe=ve/s*Math.PI*2,He=Math.sin(Oe),Ce=-Math.cos(Oe);u.x=Ce*oe.x+He*_e.x,u.y=Ce*oe.y+He*_e.y,u.z=Ce*oe.z+He*_e.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 Q=1;Q<=t;Q++)for(let oe=1;oe<=s;oe++){const _e=(s+1)*(Q-1)+(oe-1),ve=(s+1)*Q+(oe-1),Oe=(s+1)*Q+oe,He=(s+1)*(Q-1)+oe;T.push(_e,ve,He),T.push(ve,Oe,He)}}function ee(){for(let Q=0;Q<=t;Q++)for(let oe=0;oe<=s;oe++)d.x=Q/t,d.y=oe/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 bf(new lg[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class O1 extends xr{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,s=new ot,o=new ot;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),ee=c.getX(T+(z+1)%3);s.fromBufferAttribute(a,I),o.fromBufferAttribute(a,ee),wf(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),wf(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 wf(r,e,t){const n=`${r.x},${r.y},${r.z}-${e.x},${e.y},${e.z}`,s=`${e.x},${e.y},${e.z}-${r.x},${r.y},${r.z}`;return t.has(n)===!0||t.has(s)===!0?!1:(t.add(n),t.add(s),!0)}var ug=Object.freeze({__proto__:null,BoxGeometry:Fc,CapsuleGeometry:$0,CircleGeometry:yx,ConeGeometry:Mp,CylinderGeometry:wp,DodecahedronGeometry:vx,EdgesGeometry:hd,ExtrudeGeometry:Lp,IcosahedronGeometry:xc,LatheGeometry:cg,OctahedronGeometry:Dp,PlaneGeometry:Mh,PolyhedronGeometry:hf,RingGeometry:iy,ShapeGeometry:ry,SphereGeometry:ju,TetrahedronGeometry:_f,TorusGeometry:Op,TorusKnotGeometry:Fp,TubeGeometry:bf,WireframeGeometry:O1});class hg 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 oy extends null{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Bp 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=$a,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 Cx extends Bp{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 ay 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=$a,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=xt,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 ly 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=$a,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 Rx extends Ei{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=$a,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 cy 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=$a,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=xt,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 Nx extends Ei{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Jf,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 Px 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 uy 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=$a,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 hy extends el{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 yd(r,e){return!r||r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function Ix(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Lx(r){function e(s,o){return r[s]-r[o]}const t=r.length,n=new Array(t);for(let s=0;s!==t;++s)n[s]=s;return n.sort(e),n}function dy(r,e,t){const n=r.length,s=new r.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++]=r[c+u]}return s}function fy(r,e,t,n){let s=1,o=r[0];for(;o!==void 0&&o[n]===void 0;)o=r[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=r[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=r[s++];while(o!==void 0);else do a=o[n],a!==void 0&&(e.push(o.time),t.push(a)),o=r[s++];while(o!==void 0)}function F1(r,e,t,n,s=30){const o=r.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=yd(m,d.times.constructor),d.values=yd(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 vd(r,e=0,t=r,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=r.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,ee=m-p;G=c.values.slice(I,ee)}else if(o>=c.times[T]){const I=T*m+p,ee=I+m-p;G=c.values.slice(I,ee)}else{const I=c.createInterpolant(),ee=p,Q=m-p;I.evaluate(o),G=I.resultBuffer.slice(ee,Q)}u==="quaternion"&&new ea().fromArray(G).normalize().conjugate().toArray(G);const z=d.times.length;for(let I=0;I<z;++I){const ee=I*M+y;if(u==="quaternion")ea.multiplyQuaternionsFlat(d.values,ee,G,0,d.values,ee);else{const Q=M-y*2;for(let oe=0;oe<Q;++oe)d.values[ee+oe]-=G[oe]}}}return r.blendMode=Pc,r}class B1{static convertArray(e,t){return yd(e,t)}static isTypedArray(e){return Ix(e)}static getKeyframeOrder(e){return Lx(e)}static sortedArray(e,t,n){return dy(e,t,n)}static flattenJSON(e,t,n,s){fy(e,t,n,s)}static subclip(e,t,n,s,o=30){return F1(e,t,n,s,o)}static makeClipAdditive(e,t=0,n=e,s=30){return vd(e,t,n,s)}}class Up{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 py extends Up{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:ca,endingEnd:ca}}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 Oa:o=e,c=2*t-n;break;case sl: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 Oa:a=e,u=2*n-t;break;case sl: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,ee=(1+y)*z+(-1.5-2*y)*G+(-.5+y)*T+1,Q=(-1-M)*z+(1.5+M)*G+.5*T,oe=M*z-M*G;for(let _e=0;_e!==c;++_e)o[_e]=I*a[p+_e]+ee*a[d+_e]+Q*a[u+_e]+oe*a[m+_e];return o}}class dg extends Up{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 U1 extends Up{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e){return this.copySampleValue_(e-1)}}class Wc{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=yd(t,this.TimeBufferType),this.values=yd(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:yd(e.times,Array),values:yd(e.values,Array)};const s=e.getInterpolation();s!==e.DefaultInterpolation&&(n.interpolation=s)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new U1(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new dg(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new py(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Ao:t=this.InterpolantFactoryMethodDiscrete;break;case il:t=this.InterpolantFactoryMethodLinear;break;case rl: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 Ao;case this.InterpolantFactoryMethodLinear:return il;case this.InterpolantFactoryMethodSmooth:return rl}}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&&Ix(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()===rl,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}}Wc.prototype.ValueTypeName="",Wc.prototype.TimeBufferType=Float32Array,Wc.prototype.ValueBufferType=Float32Array,Wc.prototype.DefaultInterpolation=il;class kp extends Wc{constructor(e,t,n){super(e,t,n)}}kp.prototype.ValueTypeName="bool",kp.prototype.ValueBufferType=Array,kp.prototype.DefaultInterpolation=Ao,kp.prototype.InterpolantFactoryMethodLinear=void 0,kp.prototype.InterpolantFactoryMethodSmooth=void 0;class zp extends Wc{constructor(e,t,n,s){super(e,t,n,s)}}zp.prototype.ValueTypeName="color";class fg extends Wc{constructor(e,t,n,s){super(e,t,n,s)}}fg.prototype.ValueTypeName="number";class Dx extends Up{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)ea.slerpFlat(o,0,a,d-c,a,d,u);return o}}class pg extends Wc{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new Dx(this.times,this.values,this.getValueSize(),e)}}pg.prototype.ValueTypeName="quaternion",pg.prototype.InterpolantFactoryMethodSmooth=void 0;class _l extends Wc{constructor(e,t,n){super(e,t,n)}}_l.prototype.ValueTypeName="string",_l.prototype.ValueBufferType=Array,_l.prototype.DefaultInterpolation=Ao,_l.prototype.InterpolantFactoryMethodLinear=void 0,_l.prototype.InterpolantFactoryMethodSmooth=void 0;class Xu extends Wc{constructor(e,t,n,s){super(e,t,n,s)}}Xu.prototype.ValueTypeName="vector";class Vp{constructor(e="",t=-1,n=[],s=bo){this.name=e,this.tracks=n,this.duration=t,this.blendMode=s,this.uuid=yl(),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(k1(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(Wc.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=Lx(u);u=dy(u,1,p),d=dy(d,1,p),!s&&u[0]===0&&(u.push(o),d.push(d[0])),a.push(new fg(".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=[];fy(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 ee=0;ee!==y[T].morphTargets.length;++ee){const Q=y[T];z.push(Q.time),I.push(Q.morphTarget===G?1:0)}s.push(new fg(".morphTargetInfluence["+G+"]",z,I))}u=M.length*a}else{const M=".bones["+t[m].name+"]";n(Xu,M+".position",y,"pos",s),n(pg,M+".quaternion",y,"rot",s),n(Xu,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 mg(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return fg;case"vector":case"vector2":case"vector3":case"vector4":return Xu;case"color":return zp;case"quaternion":return pg;case"bool":case"boolean":return kp;case"string":return _l}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function k1(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=mg(r.type);if(r.times===void 0){const t=[],n=[];fy(r.keys,t,n,"value"),r.times=t,r.values=n}return e.parse!==void 0?e.parse(r):new e(r.name,r.times,r.values,r.interpolation)}const _c={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(this.files[r]=e)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};class xd{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 gg=new xd;class Mf{constructor(e){this.manager=e!==void 0?e:gg,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}}Mf.DEFAULT_MATERIAL_NAME="__DEFAULT";const qu={};class z1 extends null{constructor(e,t){super(e),this.response=t}}class bl 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=_c.get(`file:${e}`);if(o!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(o),this.manager.itemEnd(e)},0),o;if(qu[e]!==void 0){qu[e].push({onLoad:t,onProgress:n,onError:s});return}qu[e]=[],qu[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=qu[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){ee();function ee(){m.read().then(({done:Q,value:oe})=>{if(Q)I.close();else{G+=oe.byteLength;const _e=new ProgressEvent("progress",{lengthComputable:T,loaded:G,total:M});for(let ve=0,Oe=p.length;ve<Oe;ve++){const He=p[ve];He.onProgress&&He.onProgress(_e)}I.enqueue(oe),ee()}},Q=>{I.error(Q)})}}});return new Response(z)}else throw new z1(`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=>{_c.add(`file:${e}`,d);const p=qu[e];delete qu[e];for(let m=0,y=p.length;m<y;m++){const M=p[m];M.onLoad&&M.onLoad(d)}}).catch(d=>{const p=qu[e];if(p===void 0)throw this.manager.itemError(e),d;delete qu[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 V1 extends null{constructor(e){super(e)}load(e,t,n,s){const o=this,a=new bl(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=Vp.parse(e[n]);t.push(s)}return t}}class cE extends null{constructor(e){super(e)}load(e,t,n,s){const o=this,a=[],c=new rg,u=new bl(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 Sf=new WeakMap;class bc extends Mf{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=_c.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=Sf.get(a);m===void 0&&(m=[],Sf.set(a,m)),m.push({onLoad:t,onError:s})}return a}const c=uh("img");function u(){p(),t&&t(this);const m=Sf.get(this)||[];for(let y=0;y<m.length;y++){const M=m[y];M.onLoad&&M.onLoad(this)}Sf.delete(this),o.manager.itemEnd(e)}function d(m){p(),s&&s(m),_c.remove(`image:${e}`);const y=Sf.get(this)||[];for(let M=0;M<y.length;M++){const T=y[M];T.onError&&T.onError(m)}Sf.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),_c.add(`image:${e}`,c),o.manager.itemStart(e),c.src=e,c}}class uE extends null{constructor(e){super(e)}load(e,t,n,s){const o=new ph;o.colorSpace=co;const a=new bc(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 _d extends null{constructor(e){super(e)}load(e,t,n,s){const o=this,a=new Ql,c=new bl(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:qe,a.wrapT=d.wrapT!==void 0?d.wrapT:qe,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 hE extends Mf{constructor(e){super(e)}load(e,t,n,s){const o=new Wo,a=new bc(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 Tf extends Jr{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 bd extends Tf{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Jr.DEFAULT_UP),this.updateMatrix(),this.groundColor=new jn(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const Ef=new Ft,G1=new ot,W1=new ot;class Ox{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 lf,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;G1.setFromMatrixPosition(e.matrixWorld),t.position.copy(G1),W1.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(W1),t.updateMatrixWorld(),Ef.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ef,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(Ef)}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 dE extends Ox{constructor(){super(new fa(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=Fa*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 yg extends Tf{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(Jr.DEFAULT_UP),this.updateMatrix(),this.target=new Jr,this.distance=n,this.angle=s,this.penumbra=o,this.decay=a,this.map=null,this.shadow=new dE}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 vg=new Ft,Af=new ot,xg=new ot;class fE extends Ox{constructor(){super(new fa(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 ot(1,0,0),new ot(-1,0,0),new ot(0,0,1),new ot(0,0,-1),new ot(0,1,0),new ot(0,-1,0)],this._cubeUps=[new ot(0,1,0),new ot(0,1,0),new ot(0,1,0),new ot(0,1,0),new ot(0,0,1),new ot(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()),Af.setFromMatrixPosition(e.matrixWorld),n.position.copy(Af),xg.copy(n.position),xg.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(xg),n.updateMatrixWorld(),s.makeTranslation(-Af.x,-Af.y,-Af.z),vg.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(vg,n.coordinateSystem,n.reversedDepth)}}class Fx extends Tf{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 fE}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 Cf extends Hm{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 Bx extends Ox{constructor(){super(new Cf(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class wd extends Tf{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Jr.DEFAULT_UP),this.updateMatrix(),this.target=new Jr,this.shadow=new Bx}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Gp extends Tf{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Ux extends Tf{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 H1{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new ot)}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 my extends Tf{constructor(e=new H1,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 gy extends null{constructor(e){super(e),this.textures={}}load(e,t,n,s){const o=this,a=new bl(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 ot().fromArray(a.value);break;case"v4":s.uniforms[o].value=new mr().fromArray(a.value);break;case"m3":s.uniforms[o].value=new $r().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 gy.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:hg,SpriteMaterial:cp,RawShaderMaterial:oy,ShaderMaterial:Bc,PointsMaterial:uf,MeshPhysicalMaterial:Cx,MeshStandardMaterial:Bp,MeshPhongMaterial:ay,MeshToonMaterial:ly,MeshNormalMaterial:Rx,MeshLambertMaterial:cy,MeshDepthMaterial:Nx,MeshDistanceMaterial:Px,MeshBasicMaterial:Wr,MeshMatcapMaterial:uy,LineDashedMaterial:hy,LineBasicMaterial:el,Material:Ei};return new t[e]}}class kx{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 $1 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 j1 extends null{constructor(e){super(e)}load(e,t,n,s){const o=this,a=new bl(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),ee=ch(z.type,I),Q=new Wu(ee,z.stride);return Q.uuid=z.uuid,t[T]=Q,Q}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 $1:new xr,c=e.data.index;if(c!==void 0){const M=ch(c.type,c.array);a.setIndex(new Qr(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 sf(z,T.itemSize,T.offset,T.normalized)}else{const z=ch(T.type,T.array),I=T.isInstancedBufferAttribute?kc:Qr;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 ee=T[z];let Q;if(ee.isInterleavedBufferAttribute){const oe=s(e.data,ee.data);Q=new sf(oe,ee.itemSize,ee.offset,ee.normalized)}else{const oe=ch(ee.type,ee.array);Q=new Qr(oe,ee.itemSize,ee.normalized)}ee.name!==void 0&&(Q.name=ee.name),G.push(Q)}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 we().fromJSON(y)),e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class pE extends null{constructor(e){super(e)}load(e,t,n,s){const o=this,a=this.path===""?kx.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const c=new bl(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===""?kx.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||s;const o=new bl(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 md().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 dp().fromJSON(e[o],s);n[c.uuid]=c}return n}parseGeometries(e,t){const n={};if(e!==void 0){const s=new j1;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 ug?c=ug[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 gy;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=Vp.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:ch(u.type,u.data),width:u.width,height:u.height}:null}if(e!==void 0&&e.length>0){const u=new xd(t);o=new bc(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 Ql(I.data,I.width,I.height)))}s[m.uuid]=new wo(M)}else{const M=c(m.url);s[m.uuid]=new wo(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:ch(a.type,a.data),width:a.width,height:a.height}:null})}if(e!==void 0&&e.length>0){s=new bc(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 Ql(T.data,T.width,T.height)))}n[u.uuid]=new wo(p)}else{const p=yield o(u.url);n[u.uuid]=new wo(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 ph,d.length===6&&(p.needsUpdate=!0)):(d&&d.data?p=new Ql:p=new Wo,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,X1)),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],_g),p.wrapT=n(c.wrap[1],_g)),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,yy)),c.magFilter!==void 0&&(p.magFilter=n(c.magFilter,yy)),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 $m,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 lp(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new N0(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 fa(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 Cf(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 Gp(e.color,e.intensity);break;case"DirectionalLight":a=new wd(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new Fx(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new Ux(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new yg(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||"";break;case"HemisphereLight":a=new bd(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=new my().fromJSON(e);break;case"SkinnedMesh":p=c(e.geometry),m=u(e.material),a=new c1(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 Zs(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 ux(p,m,y),a.instanceMatrix=new kc(new Float32Array(M.array),16),T!==void 0&&(a.instanceColor=new kc(new Float32Array(T.array),T.itemSize));break;case"BatchedMesh":p=c(e.geometry),m=u(e.material),a=new f1(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 ha().fromJSON(G.boundingBox)),G.boundingSphere!==void 0&&(I=new we().fromJSON(G.boundingSphere)),ac(qs({},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 we().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(a.boundingBox=new ha().fromJSON(e.boundingBox));break;case"LOD":a=new L0;break;case"Line":a=new xh(c(e.geometry),u(e.material));break;case"LineLoop":a=new mx(c(e.geometry),u(e.material));break;case"LineSegments":a=new ng(c(e.geometry),u(e.material));break;case"PointCloud":case"Points":a=new p1(c(e.geometry),u(e.material));break;case"Sprite":a=new jm(u(e.material));break;case"Group":a=new ul;break;case"Bone":a=new U0;break;default:a=new Jr}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 Jr}})}}const X1={UVMapping:te,CubeReflectionMapping:Fe,CubeRefractionMapping:Xe,EquirectangularReflectionMapping:Pe,EquirectangularRefractionMapping:Ie,CubeUVReflectionMapping:Ke},_g={RepeatWrapping:lt,ClampToEdgeWrapping:qe,MirroredRepeatWrapping:pt},yy={NearestFilter:Ct,NearestMipmapNearestFilter:Xt,NearestMipmapLinearFilter:pn,LinearFilter:Rn,LinearMipmapNearestFilter:bi,LinearMipmapLinearFilter:Qn},vy=new WeakMap;class mE 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=_c.get(`image-bitmap:${e}`);if(a!==void 0){if(o.manager.itemStart(e),a.then){a.then(d=>{if(vy.has(a)===!0)s&&s(vy.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 _c.add(`image-bitmap:${e}`,d),t&&t(d),o.manager.itemEnd(e),d}).catch(function(d){s&&s(d),vy.set(u,d),_c.remove(`image-bitmap:${e}`),o.manager.itemError(e),o.manager.itemEnd(e)});_c.add(`image-bitmap:${e}`,u),o.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let xy;class zx{static getContext(){return xy===void 0&&(xy=new(window.AudioContext||window.webkitAudioContext)),xy}static setContext(e){xy=e}}class q1 extends null{constructor(e){super(e)}load(e,t,n,s){const o=this,a=new bl(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);zx.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 _y=new Ft,bg=new Ft,Rf=new Ft;class by{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new fa,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new fa,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,Rf.copy(e.projectionMatrix);const s=t.eyeSep/2,o=s*t.near/t.focus,a=t.near*Math.tan(lc*t.fov*.5)/t.zoom;let c,u;bg.elements[12]=-s,_y.elements[12]=s,c=-a*t.aspect+o,u=a*t.aspect+o,Rf.elements[0]=2*t.near/(u-c),Rf.elements[8]=(u+c)/(u-c),this.cameraL.projectionMatrix.copy(Rf),c=-a*t.aspect-o,u=a*t.aspect-o,Rf.elements[0]=2*t.near/(u-c),Rf.elements[8]=(u+c)/(u-c),this.cameraR.projectionMatrix.copy(Rf)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(bg),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(_y)}}class wy extends fa{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Vx{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 Sh=new ot,wg=new ea,Md=new ot,Nf=new ot,Pf=new ot;class gE extends null{constructor(){super(),this.type="AudioListener",this.context=zx.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Vx}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(Sh,wg,Md),Nf.set(0,0,-1).applyQuaternion(wg),Pf.set(0,1,0).applyQuaternion(wg),t.positionX){const n=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Sh.x,n),t.positionY.linearRampToValueAtTime(Sh.y,n),t.positionZ.linearRampToValueAtTime(Sh.z,n),t.forwardX.linearRampToValueAtTime(Nf.x,n),t.forwardY.linearRampToValueAtTime(Nf.y,n),t.forwardZ.linearRampToValueAtTime(Nf.z,n),t.upX.linearRampToValueAtTime(Pf.x,n),t.upY.linearRampToValueAtTime(Pf.y,n),t.upZ.linearRampToValueAtTime(Pf.z,n)}else t.setPosition(Sh.x,Sh.y,Sh.z),t.setOrientation(Nf.x,Nf.y,Nf.z,Pf.x,Pf.y,Pf.z)}}class If 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 Yu=new ot,Gx=new ea,Sd=new ot,ec=new ot;class y3 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(Yu,Gx,Sd),ec.set(0,0,1).applyQuaternion(Gx);const t=this.panner;if(t.positionX){const n=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Yu.x,n),t.positionY.linearRampToValueAtTime(Yu.y,n),t.positionZ.linearRampToValueAtTime(Yu.z,n),t.orientationX.linearRampToValueAtTime(ec.x,n),t.orientationY.linearRampToValueAtTime(ec.y,n),t.orientationZ.linearRampToValueAtTime(ec.z,n)}else t.setPosition(Yu.x,Yu.y,Yu.z),t.setOrientation(ec.x,ec.y,ec.z)}}class v3{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 Td{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){ea.slerpFlat(e,t,e,t,e,n,s)}_slerpAdditive(e,t,n,s,o){const a=this._workIndex*o;ea.multiplyQuaternionsFlat(e,a,e,t,e,n),ea.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 Mg="\\[\\]\\.:\\/",Y1=new RegExp("["+Mg+"]","g"),Zu="[^"+Mg+"]",yE="[^"+Mg.replace("\\.","")+"]",vE=/((?:WC+[\/:])*)/.source.replace("WC",Zu),Z1=/(WCOD+)?/.source.replace("WCOD",yE),My=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Zu),K1=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Zu),Sy=new RegExp("^"+vE+Z1+My+K1+"$"),J1=["material","materials","bones","map"];class Q1{constructor(e,t,n){const s=n||Ks.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 Ks{constructor(e,t,n){this.path=t,this.parsedPath=n||Ks.parseTrackName(t),this.node=Ks.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 Ks.Composite(e,t,n):new Ks(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Y1,"")}static parseTrackName(e){const t=Sy.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);J1.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=Ks.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}}Ks.Composite=Q1,Ks.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Ks.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Ks.prototype.GetterByBindingType=[Ks.prototype._getValue_direct,Ks.prototype._getValue_array,Ks.prototype._getValue_arrayElement,Ks.prototype._getValue_toArray],Ks.prototype.SetterByBindingTypeAndVersioning=[[Ks.prototype._setValue_direct,Ks.prototype._setValue_direct_setNeedsUpdate,Ks.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ks.prototype._setValue_array,Ks.prototype._setValue_array_setNeedsUpdate,Ks.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ks.prototype._setValue_arrayElement,Ks.prototype._setValue_arrayElement_setNeedsUpdate,Ks.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ks.prototype._setValue_fromArray,Ks.prototype._setValue_fromArray_setNeedsUpdate,Ks.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class xE{constructor(){this.isAnimationObjectGroup=!0,this.uuid=yl(),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 Ks(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,ee=a;I!==ee;++I){const Q=o[I],oe=Q[G];let _e=Q[T];Q[T]=oe,_e===void 0&&(_e=new Ks(y,n[I],s[I])),Q[G]=_e}}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 ee=n[z],Q=ee[y],oe=ee[T];ee[m]=Q,ee[y]=oe,ee.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 Ks(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 ew{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:ca,endingEnd:ca};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=qr,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 Pc:for(let p=0,m=u.length;p!==m;++p)u[p].evaluate(a),d[p].accumulateAdditive(c);break;case bo: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===la;if(e===0)return o===-1?s:a&&(o&1)===1?t-s:s;if(n===ro){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=Oa,s.endingEnd=Oa):(e?s.endingStart=this.zeroSlopeAtStart?Oa:ca:s.endingStart=sl,t?s.endingEnd=this.zeroSlopeAtEnd?Oa:ca:s.endingEnd=sl)}_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 tw=new Float32Array(1);class _E 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 Td(Ks.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 dg(new Float32Array(2),new Float32Array(2),1,tw),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"?Vp.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=bo),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 ew(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"?Vp.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 bE extends null{constructor(e=1,t=1,n=1,s={}){super(e,t,s),this.isRenderTarget3D=!0,this.depth=n,this.texture=new xl(null,e,t,n),this._setTextureOptions(s),this.texture.isRenderTargetTexture=!0}}class Xs{constructor(e){this.value=e}clone(){return new Xs(this.value.clone===void 0?this.value:this.value.clone())}}let wE=0;class ME extends null{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:wE++}),this.name="",this.usage=Ou,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 nw extends Wu{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 x3{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 iw=new Ft;class Ty{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 iw.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(iw),this}intersectObject(e,t=!0,n=[]){return Hx(e,this,n,t),n.sort(Wx),n}intersectObjects(e,t=!0,n=[]){for(let s=0,o=e.length;s<o;s++)Hx(e[s],this,n,t);return n.sort(Wx),n}}function Wx(r,e){return r.distance-e.distance}function Hx(r,e,t,n){let s=!0;if(r.layers.test(e.layers)&&r.raycast(e,t)===!1&&(s=!1),s===!0&&n===!0){const o=r.children;for(let a=0,c=o.length;a<c;a++)Hx(o[a],e,t,!0)}}class _3{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=SE.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 SE(){this._document.hidden===!1&&this.reset()}class Ey{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 b3{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 Wp{constructor(e,t,n,s){Wp.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 Sg=new yn;class w3{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=Sg.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,Sg).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 $x=new ot,Ay=new ot,Hp=new ot,Ed=new ot,Tg=new ot,TE=new ot,jx=new ot;class Cy{constructor(e=new ot,t=new ot){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){$x.subVectors(e,this.start),Ay.subVectors(this.end,this.start);const n=Ay.dot(Ay);let o=Ay.dot($x)/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=TE,n=jx){const s=10000000000000001e-32;let o,a;const c=this.start,u=e.start,d=this.end,p=e.end;Hp.subVectors(d,c),Ed.subVectors(p,u),Tg.subVectors(c,u);const m=Hp.dot(Hp),y=Ed.dot(Ed),M=Ed.dot(Tg);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=Hp.dot(Tg);if(y<=s)a=0,o=Sr(-T/m,0,1);else{const G=Hp.dot(Ed),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(Hp.multiplyScalar(o)),n.copy(u).add(Ed.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 Ad=new ot;class $p 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 el({fog:!1,toneMapped:!1});this.cone=new ng(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),Ad.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Ad),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const vu=new ot,Eg=new Ft,Ry=new Ft;class M3 extends null{constructor(e){const t=Ny(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 el({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");Ry.copy(this.root.matrixWorld).invert();for(let o=0,a=0;o<t.length;o++){const c=t[o];c.parent&&c.parent.isBone&&(Eg.multiplyMatrices(Ry,c.matrixWorld),vu.setFromMatrixPosition(Eg),s.setXYZ(a,vu.x,vu.y,vu.z),Eg.multiplyMatrices(Ry,c.parent.matrixWorld),vu.setFromMatrixPosition(Eg),s.setXYZ(a+1,vu.x,vu.y,vu.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 Ny(r){const e=[];r.isBone===!0&&e.push(r);for(let t=0;t<r.children.length;t++)e.push(...Ny(r.children[t]));return e}class S3 extends null{constructor(e,t,n){const s=new ju(t,4,2),o=new Wr({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 Th=new ot,jp=new jn,Ag=new jn;class T3 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 Dp(t);s.rotateY(Math.PI*.5),this.material=new Wr({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 Qr(a,3)),this.add(new Zs(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),Ag.copy(this.light.groundColor);for(let n=0,s=t.count;n<s;n++){const o=n<s/2?jp:Ag;t.setXYZ(n,o.r,o.g,o.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(Th.setFromMatrixPosition(this.light.matrixWorld).negate())}}class rw 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 el({vertexColors:!0,toneMapped:!1});super(p,m),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class E3 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 el({vertexColors:!0,toneMapped:!1});super(d,p),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const Xx=new ot,Xp=new ot,Py=new ot;class A3 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 el({fog:!1,toneMapped:!1});this.lightPlane=new xh(s,o),this.add(this.lightPlane),s=new xr,s.setAttribute("position",new Zi([0,0,0,0,0,1],3)),this.targetLine=new xh(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),Xx.setFromMatrixPosition(this.light.matrixWorld),Xp.setFromMatrixPosition(this.light.target.matrixWorld),Py.subVectors(Xp,Xx),this.lightPlane.lookAt(Xp),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(Xp),this.targetLine.scale.z=Py.length()}}const Iy=new ot,pa=new Hm;class sw extends null{constructor(e){const t=new xr,n=new el({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(pa.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)o=1,a=0;else if(this.camera.coordinateSystem===so)o=-1,a=1;else if(this.camera.coordinateSystem===ja)o=0,a=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);Uo("c",t,e,pa,0,0,o),Uo("t",t,e,pa,0,0,a),Uo("n1",t,e,pa,-n,-s,o),Uo("n2",t,e,pa,n,-s,o),Uo("n3",t,e,pa,-n,s,o),Uo("n4",t,e,pa,n,s,o),Uo("f1",t,e,pa,-n,-s,a),Uo("f2",t,e,pa,n,-s,a),Uo("f3",t,e,pa,-n,s,a),Uo("f4",t,e,pa,n,s,a),Uo("u1",t,e,pa,n*.7,s*1.1,o),Uo("u2",t,e,pa,-n*.7,s*1.1,o),Uo("u3",t,e,pa,0,s*2,o),Uo("cf1",t,e,pa,-n,0,a),Uo("cf2",t,e,pa,n,0,a),Uo("cf3",t,e,pa,0,-s,a),Uo("cf4",t,e,pa,0,s,a),Uo("cn1",t,e,pa,-n,0,o),Uo("cn2",t,e,pa,n,0,o),Uo("cn3",t,e,pa,0,-s,o),Uo("cn4",t,e,pa,0,s,o),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Uo(r,e,t,n,s,o,a){Iy.set(s,o,a).unproject(n);const c=e[r];if(c!==void 0){const u=t.getAttribute("position");for(let d=0,p=c.length;d<p;d++)u.setXYZ(c[d],Iy.x,Iy.y,Iy.z)}}const qp=new ha;class C3 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 Qr(n,1)),o.setAttribute("position",new Qr(s,3)),super(o,new el({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&qp.setFromObject(this.object),qp.isEmpty())return;const e=qp.min,t=qp.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 Ly 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 Qr(n,1)),o.setAttribute("position",new Zi(s,3)),super(o,new el({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 ma 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 el({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 Zs(u,new Wr({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 ow=new ot;let ko,Lf;class R3 extends null{constructor(e=new ot(0,0,1),t=new ot(0,0,0),n=1,s=16776960,o=n*.2,a=o*.2){super(),this.type="ArrowHelper",ko===void 0&&(ko=new xr,ko.setAttribute("position",new Zi([0,0,0,0,1,0],3)),Lf=new Mp(.5,1,5,1),Lf.translate(0,-.5,0)),this.position.copy(t),this.line=new xh(ko,new el({color:s,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Zs(Lf,new Wr({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{ow.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(ow,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 N3 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 el({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 P3{constructor(){this.type="ShapePath",this.color=new jn,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Z0,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 ee=[];for(let Q=0,oe=I.length;Q<oe;Q++){const _e=I[Q],ve=new md;ve.curves=_e.curves,ee.push(ve)}return ee}function n(I,ee){const Q=ee.length;let oe=!1;for(let _e=Q-1,ve=0;ve<Q;_e=ve++){let Oe=ee[_e],He=ee[ve],Ce=He.x-Oe.x,Be=He.y-Oe.y;if(Math.abs(Be)>Number.EPSILON){if(Be<0&&(Oe=ee[ve],Ce=-Ce,He=ee[_e],Be=-Be),I.y<Oe.y||I.y>He.y)continue;if(I.y===Oe.y){if(I.x===Oe.x)return!0}else{const ft=Be*(I.x-Oe.x)-Ce*(I.y-Oe.y);if(ft===0)return!0;if(ft<0)continue;oe=!oe}}else{if(I.y!==Oe.y)continue;if(He.x<=I.x&&I.x<=Oe.x||Oe.x<=I.x&&I.x<=He.x)return!0}}return oe}const s=Gc.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 md,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,ee=o.length;I<ee;I++)c=o[I],G=c.getPoints(),a=s(G),a=e?!a:a,a?(!p&&y[T]&&T++,y[T]={s:new md,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,ee=0;for(let Q=0,oe=y.length;Q<oe;Q++)m[Q]=[];for(let Q=0,oe=y.length;Q<oe;Q++){const _e=M[Q];for(let ve=0;ve<_e.length;ve++){const Oe=_e[ve];let He=!0;for(let Ce=0;Ce<y.length;Ce++)n(Oe.p,y[Ce].p)&&(Q!==Ce&&ee++,He?(He=!1,m[Ce].push(Oe)):I=!0);He&&m[Q].push(Oe)}}ee>0&&I===!1&&(M=m)}let z;for(let I=0,ee=y.length;I<ee;I++){u=y[I].s,d.push(u),z=M[I];for(let Q=0,oe=z.length;Q<oe;Q++)u.holes.push(z[Q].h)}return d}}class Yp extends Ol{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 Cg(r,e){const t=r.image&&r.image.width?r.image.width/r.image.height:1;return t>e?(r.repeat.x=1,r.repeat.y=t/e,r.offset.x=0,r.offset.y=(1-r.repeat.y)/2):(r.repeat.x=e/t,r.repeat.y=1,r.offset.x=(1-r.repeat.x)/2,r.offset.y=0),r}function Dy(r,e){const t=r.image&&r.image.width?r.image.width/r.image.height:1;return t>e?(r.repeat.x=e/t,r.repeat.y=1,r.offset.x=(1-r.repeat.x)/2,r.offset.y=0):(r.repeat.x=1,r.repeat.y=t/e,r.offset.x=0,r.offset.y=(1-r.repeat.y)/2),r}function EE(r){return r.repeat.x=1,r.repeat.y=1,r.offset.x=0,r.offset.y=0,r}function Oy(r,e,t,n){const s=AE(n);switch(t){case Du:return r*e;case F:return r*e/s.components*s.byteLength;case X:return r*e/s.components*s.byteLength;case De:return r*e*2/s.components*s.byteLength;case Ve:return r*e*2/s.components*s.byteLength;case Le:return r*e*3/s.components*s.byteLength;case D:return r*e*4/s.components*s.byteLength;case st:return r*e*4/s.components*s.byteLength;case Ht:case Et:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case on:case Un:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case bn:case Bt:return Math.max(r,16)*Math.max(e,8)/4;case sn:case ti:return Math.max(r,8)*Math.max(e,8)/2;case $n:case ni:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case Pi:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case ui:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Ir:return Math.floor((r+4)/5)*Math.floor((e+3)/4)*16;case yi:return Math.floor((r+4)/5)*Math.floor((e+4)/5)*16;case vi:return Math.floor((r+5)/6)*Math.floor((e+4)/5)*16;case Mr:return Math.floor((r+5)/6)*Math.floor((e+5)/6)*16;case Zt:return Math.floor((r+7)/8)*Math.floor((e+4)/5)*16;case Fn:return Math.floor((r+7)/8)*Math.floor((e+5)/6)*16;case hi:return Math.floor((r+7)/8)*Math.floor((e+7)/8)*16;case Xn:return Math.floor((r+9)/10)*Math.floor((e+4)/5)*16;case hs:return Math.floor((r+9)/10)*Math.floor((e+5)/6)*16;case Xr:return Math.floor((r+9)/10)*Math.floor((e+7)/8)*16;case ys:return Math.floor((r+9)/10)*Math.floor((e+9)/10)*16;case Ur:return Math.floor((r+11)/12)*Math.floor((e+9)/10)*16;case Os:return Math.floor((r+11)/12)*Math.floor((e+11)/12)*16;case no:case io:case So:return Math.ceil(r/4)*Math.ceil(e/4)*16;case To:case Gr:return Math.ceil(r/4)*Math.ceil(e/4)*8;case Qs:case Eo:return Math.ceil(r/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function AE(r){switch(r){case Oi:case Gi:return{byteLength:1,components:1};case ms:case ir:case Vs:return{byteLength:2,components:1};case Xl:case ql:return{byteLength:2,components:4};case as:case Is:case gs:return{byteLength:4,components:1};case Dl:case nu:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${r}.`)}class I3{static contain(e,t){return Cg(e,t)}static cover(e,t){return Dy(e,t)}static fill(e){return EE(e)}static getByteLength(e,t,n,s){return Oy(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 Df=new Al,Ku=new yn,qx=new ot,Fy=new yn,Rg=new yn,By=new ot,j=new ot,i=new Ft,l=new ot,h=new ot;let f=null,g=null;const v=[],C={NONE:-1,PAN:0,ROTATE:1};class V extends Yp{constructor(e,t,n=null){super(t,n),this.objects=e,this.recursive=!0,this.transformGroup=!1,this.rotateSpeed=1,this.raycaster=new Ty,this.mouseButtons={LEFT:k.PAN,MIDDLE:k.PAN,RIGHT:k.ROTATE},this.touches={ONE:O.PAN},this._onPointerMove=H.bind(this),this._onPointerDown=J.bind(this),this._onPointerCancel=he.bind(this),this._onContextMenu=pe.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();Ku.x=(e.clientX-t.left)/t.width*2-1,Ku.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=C.PAN;break;case k.ROTATE:case O.ROTATE:this.state=C.ROTATE;break;default:this.state=C.NONE}}}function H(r){const e=this.object,t=this.domElement,n=this.raycaster;if(this.enabled!==!1){if(this._updatePointer(r),n.setFromCamera(Ku,e),f)this.state===C.PAN?n.ray.intersectPlane(Df,By)&&(f.position.copy(By.sub(qx).applyMatrix4(i)),this.dispatchEvent({type:"drag",object:f})):this.state===C.ROTATE&&(Fy.subVectors(Ku,Rg).multiplyScalar(this.rotateSpeed),f.rotateOnWorldAxis(l,Fy.x),f.rotateOnWorldAxis(h.normalize(),-Fy.y),this.dispatchEvent({type:"drag",object:f})),Rg.copy(Ku);else if(r.pointerType==="mouse"||r.pointerType==="pen")if(v.length=0,n.setFromCamera(Ku,e),n.intersectObjects(this.objects,this.recursive,v),v.length>0){const s=v[0].object;Df.setFromNormalAndCoplanarPoint(e.getWorldDirection(Df.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);Rg.copy(Ku)}}function J(r){const e=this.object,t=this.domElement,n=this.raycaster;this.enabled!==!1&&(this._updatePointer(r),this._updateState(r),v.length=0,n.setFromCamera(Ku,e),n.intersectObjects(this.objects,this.recursive,v),v.length>0&&(this.transformGroup===!0?f=me(v[0].object):f=v[0].object,Df.setFromNormalAndCoplanarPoint(e.getWorldDirection(Df.normal),j.setFromMatrixPosition(f.matrixWorld)),n.ray.intersectPlane(Df,By)&&(this.state===C.PAN?(i.copy(f.parent.matrixWorld).invert(),qx.copy(By).sub(j.setFromMatrixPosition(f.matrixWorld)),t.style.cursor="move",this.dispatchEvent({type:"dragstart",object:f})):this.state===C.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})))),Rg.copy(Ku))}function he(){this.enabled!==!1&&(f&&(this.dispatchEvent({type:"dragend",object:f}),f=null),this.domElement.style.cursor=g?"pointer":"auto",this.state=C.NONE)}function pe(r){this.enabled!==!1&&r.preventDefault()}function me(r,e=null){return r.isGroup&&(e=r),r.parent===null?e:me(r.parent,e)}var Se={value:()=>{}};function tt(){for(var r=0,e=arguments.length,t={},n;r<e;++r){if(!(n=arguments[r]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new gt(t)}function gt(r){this._=r}function mt(r,e){return r.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}})}gt.prototype=tt.prototype={constructor:gt,on:function(r,e){var t=this._,n=mt(r+"",t),s,o=-1,a=n.length;if(arguments.length<2){for(;++o<a;)if((s=(r=n[o]).type)&&(s=Nt(t[s],r.name)))return s;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<a;)if(s=(r=n[o]).type)t[s]=Pt(t[s],r.name,e);else if(e==null)for(s in t)t[s]=Pt(t[s],r.name,null);return this},copy:function(){var r={},e=this._;for(var t in e)r[t]=e[t].slice();return new gt(r)},call:function(r,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(r))throw new Error("unknown type: "+r);for(o=this._[r],n=0,s=o.length;n<s;++n)o[n].value.apply(e,t)},apply:function(r,e,t){if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(var n=this._[r],s=0,o=n.length;s<o;++s)n[s].value.apply(e,t)}};function Nt(r,e){for(var t=0,n=r.length,s;t<n;++t)if((s=r[t]).name===e)return s.value}function Pt(r,e,t){for(var n=0,s=r.length;n<s;++n)if(r[n].name===e){r[n]=Se,r=r.slice(0,n).concat(r.slice(n+1));break}return t!=null&&r.push({name:e,value:t}),r}var Wt=tt,gn=0,Sn=0,kn=0,In=1e3,ii,li,dr=0,Yr=0,Ss=0,eo=typeof performance=="object"&&performance.now?performance:Date,uo=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function Aa(){return Yr||(uo(hl),Yr=eo.now()+Ss)}function hl(){Yr=0}function tc(){this._call=this._time=this._next=null}tc.prototype=Xo.prototype={constructor:tc,restart:function(r,e,t){if(typeof r!="function")throw new TypeError("callback is not a function");t=(t==null?Aa():+t)+(e==null?0:+e),!this._next&&li!==this&&(li?li._next=this:ii=this,li=this),this._call=r,this._time=t,Eh()},stop:function(){this._call&&(this._call=null,this._time=1/0,Eh())}};function Xo(r,e,t){var n=new tc;return n.restart(r,e,t),n}function Ca(){Aa(),++gn;for(var r=ii,e;r;)(e=Yr-r._time)>=0&&r._call.call(void 0,e),r=r._next;--gn}function qo(){Yr=(dr=eo.now())+Ss,gn=Sn=0;try{Ca()}finally{gn=0,wc(),Yr=0}}function Hc(){var r=eo.now(),e=r-dr;e>In&&(Ss-=e,dr=r)}function wc(){for(var r,e=ii,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),r=e,e=e._next):(t=e._next,e._next=null,e=r?r._next=t:ii=t);li=r,Eh(n)}function Eh(r){if(!gn){Sn&&(Sn=clearTimeout(Sn));var e=r-Yr;e>24?(r<1/0&&(Sn=setTimeout(qo,r-eo.now()-Ss)),kn&&(kn=clearInterval(kn))):(kn||(dr=eo.now(),kn=setInterval(Hc,In)),gn=1,uo(qo))}}const Zp=1664525,aw=1013904223,Yx=4294967296;function Zx(){let r=1;return()=>(r=(Zp*r+aw)%Yx)/Yx}var xu=3;function Of(r){return r.x}function Kx(r){return r.y}function Ju(r){return r.z}var Qu=10,Ui=Math.PI*(3-Math.sqrt(5)),tr=Math.PI*20/(9+Math.sqrt(221));function rr(r,e){e=e||2;var t=Math.min(xu,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=Xo(M),m=Wt("tick","end"),y=Zx();r==null&&(r=[]);function M(){T(),m.call("tick",n),s<o&&(p.stop(),m.call("end",n))}function T(I){var ee,Q=r.length,oe;I===void 0&&(I=1);for(var _e=0;_e<I;++_e)for(s+=(c-s)*a,d.forEach(function(ve){ve(s)}),ee=0;ee<Q;++ee)oe=r[ee],oe.fx==null?oe.x+=oe.vx*=u:(oe.x=oe.fx,oe.vx=0),t>1&&(oe.fy==null?oe.y+=oe.vy*=u:(oe.y=oe.fy,oe.vy=0)),t>2&&(oe.fz==null?oe.z+=oe.vz*=u:(oe.z=oe.fz,oe.vz=0));return n}function G(){for(var I=0,ee=r.length,Q;I<ee;++I){if(Q=r[I],Q.index=I,Q.fx!=null&&(Q.x=Q.fx),Q.fy!=null&&(Q.y=Q.fy),Q.fz!=null&&(Q.z=Q.fz),isNaN(Q.x)||t>1&&isNaN(Q.y)||t>2&&isNaN(Q.z)){var oe=Qu*(t>2?Math.cbrt(.5+I):t>1?Math.sqrt(.5+I):I),_e=I*Ui,ve=I*tr;t===1?Q.x=oe:t===2?(Q.x=oe*Math.cos(_e),Q.y=oe*Math.sin(_e)):(Q.x=oe*Math.sin(_e)*Math.cos(ve),Q.y=oe*Math.cos(_e),Q.z=oe*Math.sin(_e)*Math.sin(ve))}(isNaN(Q.vx)||t>1&&isNaN(Q.vy)||t>2&&isNaN(Q.vz))&&(Q.vx=0,t>1&&(Q.vy=0),t>2&&(Q.vz=0))}}function z(I){return I.initialize&&I.initialize(r,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(xu,Math.max(1,Math.round(I))),d.forEach(z),n):t},nodes:function(I){return arguments.length?(r=I,G(),d.forEach(z),n):r},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,ee){return arguments.length>1?(ee==null?d.delete(I):d.set(I,z(ee)),n):d.get(I)},find:function(){var I=Array.prototype.slice.call(arguments),ee=I.shift()||0,Q=(t>1?I.shift():null)||0,oe=(t>2?I.shift():null)||0,_e=I.shift()||1/0,ve=0,Oe=r.length,He,Ce,Be,ft,zt,tn;for(_e*=_e,ve=0;ve<Oe;++ve)zt=r[ve],He=ee-zt.x,Ce=Q-(zt.y||0),Be=oe-(zt.z||0),ft=He*He+Ce*Ce+Be*Be,ft<_e&&(tn=zt,_e=ft);return tn},on:function(I,ee){return arguments.length>1?(m.on(I,ee),n):m.on(I)}}}function fr(r){return function(){return r}}function lr(r){return(r()-.5)*1e-6}function Js(r){return r.index}function Ts(r,e){var t=r.get(e);if(!t)throw new Error("node not found: "+e);return t}function zo(r){var e=Js,t=y,n,s=fr(30),o,a,c,u,d,p,m=1;r==null&&(r=[]);function y(I){return 1/Math.min(u[I.source.index],u[I.target.index])}function M(I){for(var ee=0,Q=r.length;ee<m;++ee)for(var oe=0,_e,ve,Oe,He=0,Ce=0,Be=0,ft,zt;oe<Q;++oe)_e=r[oe],ve=_e.source,Oe=_e.target,He=Oe.x+Oe.vx-ve.x-ve.vx||lr(p),c>1&&(Ce=Oe.y+Oe.vy-ve.y-ve.vy||lr(p)),c>2&&(Be=Oe.z+Oe.vz-ve.z-ve.vz||lr(p)),ft=Math.sqrt(He*He+Ce*Ce+Be*Be),ft=(ft-o[oe])/ft*I*n[oe],He*=ft,Ce*=ft,Be*=ft,Oe.vx-=He*(zt=d[oe]),c>1&&(Oe.vy-=Ce*zt),c>2&&(Oe.vz-=Be*zt),ve.vx+=He*(zt=1-zt),c>1&&(ve.vy+=Ce*zt),c>2&&(ve.vz+=Be*zt)}function T(){if(a){var I,ee=a.length,Q=r.length,oe=new Map(a.map((ve,Oe)=>[e(ve,Oe,a),ve])),_e;for(I=0,u=new Array(ee);I<Q;++I)_e=r[I],_e.index=I,typeof _e.source!="object"&&(_e.source=Ts(oe,_e.source)),typeof _e.target!="object"&&(_e.target=Ts(oe,_e.target)),u[_e.source.index]=(u[_e.source.index]||0)+1,u[_e.target.index]=(u[_e.target.index]||0)+1;for(I=0,d=new Array(Q);I<Q;++I)_e=r[I],d[I]=u[_e.source.index]/(u[_e.source.index]+u[_e.target.index]);n=new Array(Q),G(),o=new Array(Q),z()}}function G(){if(a)for(var I=0,ee=r.length;I<ee;++I)n[I]=+t(r[I],I,r)}function z(){if(a)for(var I=0,ee=r.length;I<ee;++I)o[I]=+s(r[I],I,r)}return M.initialize=function(I,...ee){a=I,p=ee.find(Q=>typeof Q=="function")||Math.random,c=ee.find(Q=>[1,2,3].includes(Q))||2,T()},M.links=function(I){return arguments.length?(r=I,T(),M):r},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 Yo=b(20928),Ga=b(46632),nc=b(67217);function Cd(){var r,e,t,n,s,o=fr(-30),a,c=1,u=1/0,d=.81;function p(T){var G,z=r.length,I=(e===1?(0,Yo.Z)(r,Of):e===2?(0,Ga.Z)(r,Of,Kx):e===3?(0,nc.Z)(r,Of,Kx,Ju):null).visitAfter(y);for(s=T,G=0;G<z;++G)t=r[G],I.visit(M)}function m(){if(r){var T,G=r.length,z;for(a=new Array(G),T=0;T<G;++T)z=r[T],a[z.index]=+o(z,T,r)}}function y(T){var G=0,z,I,ee=0,Q,oe,_e,ve,Oe=T.length;if(Oe){for(Q=oe=_e=ve=0;ve<Oe;++ve)(z=T[ve])&&(I=Math.abs(z.value))&&(G+=z.value,ee+=I,Q+=I*(z.x||0),oe+=I*(z.y||0),_e+=I*(z.z||0));G*=Math.sqrt(4/Oe),T.x=Q/ee,e>1&&(T.y=oe/ee),e>2&&(T.z=_e/ee)}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,ee){if(!T.value)return!0;var Q=[z,I,ee][e-1],oe=T.x-t.x,_e=e>1?T.y-t.y:0,ve=e>2?T.z-t.z:0,Oe=Q-G,He=oe*oe+_e*_e+ve*ve;if(Oe*Oe/d<He)return He<u&&(oe===0&&(oe=lr(n),He+=oe*oe),e>1&&_e===0&&(_e=lr(n),He+=_e*_e),e>2&&ve===0&&(ve=lr(n),He+=ve*ve),He<c&&(He=Math.sqrt(c*He)),t.vx+=oe*T.value*s/He,e>1&&(t.vy+=_e*T.value*s/He),e>2&&(t.vz+=ve*T.value*s/He)),!0;if(T.length||He>=u)return;(T.data!==t||T.next)&&(oe===0&&(oe=lr(n),He+=oe*oe),e>1&&_e===0&&(_e=lr(n),He+=_e*_e),e>2&&ve===0&&(ve=lr(n),He+=ve*ve),He<c&&(He=Math.sqrt(c*He)));do T.data!==t&&(Oe=a[T.data.index]*s/He,t.vx+=oe*Oe,e>1&&(t.vy+=_e*Oe),e>2&&(t.vz+=ve*Oe));while(T=T.next)}return p.initialize=function(T,...G){r=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 ic(r,e,t){var n,s=1;r==null&&(r=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-r)*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?(r=+a,o):r},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 Jx(r,e,t,n){var s,o,a=fr(.1),c,u;typeof r!="function"&&(r=fr(+r)),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,ee=Math.sqrt(G*G+z*z+I*I),Q=(u[y]-ee)*c[y]*m/ee;T.vx+=G*Q,o>1&&(T.vy+=z*Q),o>2&&(T.vz+=I*Q)}}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]=+r(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?(r=typeof m=="function"?m:fr(+m),p(),d):r},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 Qx(r){lw(r);const e=e_(r);return r.on=e.on,r.off=e.off,r.fire=e.fire,r}function e_(r){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}),r},off:function(t,n){if(typeof t=="undefined")return e=Object.create(null),r;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 r},fire:function(t){const n=e[t];if(!n)return r;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 r}}}function lw(r){if(!r)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(r.hasOwnProperty(e[t]))throw new Error("Subject cannot be eventified, since it already has property '"+e[t]+"'")}var cw=t_;function t_(r){if(r=r||{},"uniqueLinkId"in r&&(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).`),r.multigraph=r.uniqueLinkId),r.multigraph===void 0&&(r.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=r.multigraph?oe:Q,a=[],c=mn,u=mn,d=mn,p=mn,m={version:20,addNode:G,addLink:ee,removeLink:He,removeNode:I,getNode:z,getNodeCount:_e,getLinkCount:ve,getEdgeCount:ve,getLinksCount:ve,getNodesCount:_e,getLinks:Oe,forEachNode:si,forEachLinkedNode:tn,forEachLink:zt,beginUpdate:d,endUpdate:p,clear:ft,hasLink:Be,hasNode:z,getLink:Be};return Qx(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 n_(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(Ce),Gn.links=null),e.delete(wn),u(Gn,"remove"),p(),!0}function ee(wn,Gn,Si){d();var nr=z(wn)||G(wn),ss=z(Gn)||G(Gn),Vn=o(wn,Gn,Si),un=t.has(Vn.id);return t.set(Vn.id,Vn),CE(nr,Vn),wn!==Gn&&CE(ss,Vn),c(Vn,un?"update":"add"),p(),Vn}function Q(wn,Gn,Si){var nr=i_(wn,Gn),ss=t.get(nr);return ss?(ss.data=Si,ss):new RE(wn,Gn,Si,nr)}function oe(wn,Gn,Si){var nr=i_(wn,Gn),ss=n.hasOwnProperty(nr);if(ss||Be(wn,Gn)){ss||(n[nr]=0);var Vn="@"+ ++n[nr];nr=i_(wn+Vn,Gn+Vn)}return new RE(wn,Gn,Si,nr)}function _e(){return e.size}function ve(){return t.size}function Oe(wn){var Gn=z(wn);return Gn?Gn.links:null}function He(wn,Gn){return Gn!==void 0&&(wn=Be(wn,Gn)),Ce(wn)}function Ce(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 Be(wn,Gn){if(!(wn===void 0||Gn===void 0))return t.get(i_(wn,Gn))}function ft(){d(),si(function(wn){I(wn.id)}),p()}function zt(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,ss=wn.values(),Vn=ss.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=ss.next()}}function vn(wn,Gn,Si){for(var nr,ss=wn.values(),Vn=ss.next();!Vn.done;){var un=Vn.value;if(un.fromId===Gn&&(nr=Si(e.get(un.toId),un),nr))return!0;Vn=ss.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 n_(r,e){this.id=r,this.links=null,this.data=e}function CE(r,e){r.links?r.links.add(e):r.links=new Set([e])}function RE(r,e,t,n){this.fromId=r,this.toId=e,this.data=t,this.id=n}function i_(r,e){return r.toString()+"\u{1F449} "+e.toString()}var L3=b(16505);function D3(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var uw=D3,O3=typeof global=="object"&&global&&global.Object===Object&&global,F3=O3,B3=typeof self=="object"&&self&&self.Object===Object&&self,U3=F3||B3||Function("return this")(),NE=U3,k3=function(){return NE.Date.now()},hw=k3,z3=/\s/;function V3(r){for(var e=r.length;e--&&z3.test(r.charAt(e)););return e}var G3=V3,W3=/^\s+/;function H3(r){return r&&r.slice(0,G3(r)+1).replace(W3,"")}var $3=H3,j3=NE.Symbol,r_=j3,PE=Object.prototype,X3=PE.hasOwnProperty,q3=PE.toString,Uy=r_?r_.toStringTag:void 0;function Y3(r){var e=X3.call(r,Uy),t=r[Uy];try{r[Uy]=void 0;var n=!0}catch(o){}var s=q3.call(r);return n&&(e?r[Uy]=t:delete r[Uy]),s}var Z3=Y3,K3=Object.prototype,J3=K3.toString;function Q3(r){return J3.call(r)}var eD=Q3,tD="[object Null]",nD="[object Undefined]",IE=r_?r_.toStringTag:void 0;function iD(r){return r==null?r===void 0?nD:tD:IE&&IE in Object(r)?Z3(r):eD(r)}var rD=iD;function sD(r){return r!=null&&typeof r=="object"}var oD=sD,aD="[object Symbol]";function lD(r){return typeof r=="symbol"||oD(r)&&rD(r)==aD}var cD=lD,LE=NaN,uD=/^[-+]0x[0-9a-f]+$/i,hD=/^0b[01]+$/i,dD=/^0o[0-7]+$/i,fD=parseInt;function pD(r){if(typeof r=="number")return r;if(cD(r))return LE;if(uw(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=uw(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=$3(r);var t=hD.test(r);return t||dD.test(r)?fD(r.slice(2),t?2:8):uD.test(r)?LE:+r}var DE=pD,mD="Expected a function",gD=Math.max,yD=Math.min;function vD(r,e,t){var n,s,o,a,c,u,d=0,p=!1,m=!1,y=!0;if(typeof r!="function")throw new TypeError(mD);e=DE(e)||0,uw(t)&&(p=!!t.leading,m="maxWait"in t,o=m?gD(DE(t.maxWait)||0,e):o,y="trailing"in t?!!t.trailing:y);function M(ve){var Oe=n,He=s;return n=s=void 0,d=ve,a=r.apply(He,Oe),a}function T(ve){return d=ve,c=setTimeout(I,e),p?M(ve):a}function G(ve){var Oe=ve-u,He=ve-d,Ce=e-Oe;return m?yD(Ce,o-He):Ce}function z(ve){var Oe=ve-u,He=ve-d;return u===void 0||Oe>=e||Oe<0||m&&He>=o}function I(){var ve=hw();if(z(ve))return ee(ve);c=setTimeout(I,G(ve))}function ee(ve){return c=void 0,y&&n?M(ve):(n=s=void 0,a)}function Q(){c!==void 0&&clearTimeout(c),d=0,n=u=s=c=void 0}function oe(){return c===void 0?a:ee(hw())}function _e(){var ve=hw(),Oe=z(ve);if(n=arguments,s=this,u=ve,Oe){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 _e.cancel=Q,_e.flush=oe,_e}var xD=vD;function OE(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function _D(r){if(Array.isArray(r))return r}function bD(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function wD(r,e,t){return Object.defineProperty(r,"prototype",{writable:!1}),r}function MD(r,e){var t=r==null?null:typeof Symbol!="undefined"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var n,s,o,a,c=[],u=!0,d=!1;try{if(o=(t=t.call(r)).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 SD(){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 TD(r,e){return _D(r)||MD(r,e)||ED(r,e)||SD()}function ED(r,e){if(r){if(typeof r=="string")return OE(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?OE(r,e):void 0}}var AD=wD(function r(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;bD(this,r),this.name=e,this.defaultVal=s,this.triggerUpdate=a,this.onChange=u});function s_(r){var e=r.stateInit,t=e===void 0?function(){return{}}:e,n=r.props,s=n===void 0?{}:n,o=r.methods,a=o===void 0?{}:o,c=r.aliases,u=c===void 0?{}:c,d=r.init,p=d===void 0?function(){}:d,m=r.update,y=m===void 0?function(){}:m,M=Object.keys(s).map(function(T){return new AD(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 ee=!!(this instanceof T&&this.constructor),Q=ee?z.shift():void 0,oe=z[0],_e=oe===void 0?{}:oe,ve=Object.assign({},t instanceof Function?t(_e):t,{initialised:!1}),Oe={};function He(ft){return Ce(ft,_e),Be(),He}var Ce=function(zt,tn){p.call(He,zt,ve,tn),ve.initialised=!0},Be=xD(function(){ve.initialised&&(y.call(He,ve,Oe),Oe={})},1);return M.forEach(function(ft){He[ft.name]=zt(ft);function zt(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=ve[cn];if(!arguments.length)return Si;var nr=Gn===void 0?wn:Gn;return ve[cn]=nr,xn.call(He,nr,ve,Si),!Oe.hasOwnProperty(cn)&&(Oe[cn]=Si),mn&&Be(),He}}}),Object.keys(a).forEach(function(ft){He[ft]=function(){for(var zt,tn=arguments.length,cn=new Array(tn),vn=0;vn<tn;vn++)cn[vn]=arguments[vn];return(zt=a[ft]).call.apply(zt,[He,ve].concat(cn))}}),Object.entries(u).forEach(function(ft){var zt=TD(ft,2),tn=zt[0],cn=zt[1];return He[tn]=He[cn]}),He.resetProps=function(){return M.forEach(function(ft){He[ft.name](ft.defaultVal)}),He},He.resetProps(),ve._rerender=Be,ee&&Q&&He(Q),He}}var Us=function(r){return typeof r=="function"?r:typeof r=="string"?function(e){return e[r]}:function(e){return r}};function CD(r,e){let t;if(e===void 0)for(const n of r)n!=null&&(t>n||t===void 0&&n>=n)&&(t=n);else{let n=-1;for(let s of r)(s=e(s,++n,r))!=null&&(t>s||t===void 0&&s>=s)&&(t=s)}return t}function RD(r,e){let t;if(e===void 0)for(const n of r)n!=null&&(t<n||t===void 0&&n>=n)&&(t=n);else{let n=-1;for(let s of r)(s=e(s,++n,r))!=null&&(t<s||t===void 0&&s>=s)&&(t=s)}return t}function dw(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function ND(r){if(Array.isArray(r))return r}function PD(r){if(Array.isArray(r))return dw(r)}function FE(r,e,t){if(typeof r=="function"?r===e:r.has(e))return arguments.length<3?e:t;throw new TypeError("Private element is not present on this object")}function ID(r,e){if(e.has(r))throw new TypeError("Cannot initialize the same private elements twice on an object")}function LD(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Gl(r,e){return r.get(FE(r,e))}function Ng(r,e,t){ID(r,e),e.set(r,t)}function o_(r,e,t){return r.set(FE(r,e),t),t}function DD(r,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(r,WD(n.key),n)}}function OD(r,e,t){return e&&DD(r.prototype,e),Object.defineProperty(r,"prototype",{writable:!1}),r}function FD(r){if(typeof Symbol!="undefined"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function BD(r,e){var t=r==null?null:typeof Symbol!="undefined"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var n,s,o,a,c=[],u=!0,d=!1;try{if(o=(t=t.call(r)).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 UD(){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 kD(){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 zD(r,e){return ND(r)||BD(r,e)||BE(r,e)||UD()}function VD(r){return PD(r)||FD(r)||BE(r)||kD()}function GD(r,e){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function WD(r){var e=GD(r,"string");return typeof e=="symbol"?e:e+""}function BE(r,e){if(r){if(typeof r=="string")return dw(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?dw(r,e):void 0}}var Pg=new WeakMap,ky=new WeakMap,Ig=new WeakMap,fw=new WeakMap,pw=new WeakMap,mw=new WeakMap,HD=function(){function r(){LD(this,r),Ng(this,Pg,new Map),Ng(this,ky,new Map),Ng(this,Ig,function(e){return e}),Ng(this,fw,function(){return{}}),Ng(this,pw,function(){}),Ng(this,mw,function(){})}return OD(r,[{key:"getObj",value:function(t){return Gl(Pg,this).get(Gl(Ig,this).call(this,t))}},{key:"getData",value:function(t){return Gl(ky,this).get(t)}},{key:"entries",value:function(){return VD(Gl(ky,this).entries()).map(function(t){var n=zD(t,2),s=n[0],o=n[1];return[o,s]})}},{key:"id",value:function(t){return o_(Ig,this,Us(t)),this}},{key:"onCreateObj",value:function(t){return o_(fw,this,t),this}},{key:"onUpdateObj",value:function(t){return o_(pw,this,t),this}},{key:"onRemoveObj",value:function(t){return o_(mw,this,t),this}},{key:"digest",value:function(t){var n=this;t.filter(function(o){return!Gl(Pg,n).has(Gl(Ig,n).call(n,o))}).forEach(function(o){var a=Gl(fw,n).call(n,o);Gl(Pg,n).set(Gl(Ig,n).call(n,o),a),Gl(ky,n).set(a,o)});var s=new Map(t.map(function(o){return[Gl(Ig,n).call(n,o),o]}));return Gl(Pg,this).forEach(function(o,a){s.has(a)?Gl(pw,n).call(n,o,s.get(a)):(Gl(mw,n).call(n,o,a),Gl(Pg,n).delete(a),Gl(ky,n).delete(o))}),this}},{key:"clear",value:function(){return this.digest([]),this}}])}();class UE extends Map{constructor(e,t=VE){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(gw(this,e))}has(e){return super.has(gw(this,e))}set(e,t){return super.set(kE(this,e),t)}delete(e){return super.delete(zE(this,e))}}class Wq extends null{constructor(e,t=VE){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(gw(this,e))}add(e){return super.add(kE(this,e))}delete(e){return super.delete(zE(this,e))}}function gw({_intern:r,_key:e},t){const n=e(t);return r.has(n)?r.get(n):t}function kE({_intern:r,_key:e},t){const n=e(t);return r.has(n)?r.get(n):(r.set(n,t),t)}function zE({_intern:r,_key:e},t){const n=e(t);return r.has(n)&&(t=r.get(n),r.delete(n)),t}function VE(r){return r!==null&&typeof r=="object"?r.valueOf():r}function $D(r,e){switch(arguments.length){case 0:break;case 1:this.range(r);break;default:this.range(e).domain(r);break}return this}function Hq(r,e){switch(arguments.length){case 0:break;case 1:{typeof r=="function"?this.interpolator(r):this.range(r);break}default:{this.domain(r),typeof e=="function"?this.interpolator(e):this.range(e);break}}return this}const GE=Symbol("implicit");function WE(){var r=new UE,e=[],t=[],n=GE;function s(o){let a=r.get(o);if(a===void 0){if(n!==GE)return n;r.set(o,a=e.push(o)-1)}return t[a%t.length]}return s.domain=function(o){if(!arguments.length)return e.slice();e=[],r=new UE;for(const a of o)r.has(a)||r.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 WE(e,t).unknown(n)},$D.apply(s,arguments),s}function jD(r){for(var e=r.length/6|0,t=new Array(e),n=0;n<e;)t[n]="#"+r.slice(n*6,++n*6);return t}var XD=jD("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928"),HE=b(97234);function yw(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function qD(r){if(Array.isArray(r))return r}function YD(r){if(Array.isArray(r))return yw(r)}function $E(r,e,t){if(typeof r=="function"?r===e:r.has(e))return arguments.length<3?e:t;throw new TypeError("Private element is not present on this object")}function ZD(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function jE(r,e,t){return e=Lg(e),rO(r,_w()?Reflect.construct(e,t||[],Lg(r).constructor):e.apply(r,t))}function KD(r,e){if(e.has(r))throw new TypeError("Cannot initialize the same private elements twice on an object")}function XE(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function vw(r,e){return r.get($E(r,e))}function qE(r,e,t){KD(r,e),e.set(r,t)}function YE(r,e,t){return r.set($E(r,e),t),t}function ZE(r,e,t){if(_w())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var s=new(r.bind.apply(r,n));return s}function JD(r,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(r,eA(n.key),n)}}function KE(r,e,t){return e&&JD(r.prototype,e),Object.defineProperty(r,"prototype",{writable:!1}),r}function a_(r,e,t){return(e=eA(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function xw(){return xw=typeof Reflect!="undefined"&&Reflect.get?Reflect.get.bind():function(r,e,t){var n=sO(r,e);if(n){var s=Object.getOwnPropertyDescriptor(n,e);return s.get?s.get.call(arguments.length<3?r:t):s.value}},xw.apply(null,arguments)}function Lg(r){return Lg=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Lg(r)}function JE(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&bw(r,e)}function _w(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_w=function(){return!!r})()}function QD(r){if(typeof Symbol!="undefined"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function eO(r,e){var t=r==null?null:typeof Symbol!="undefined"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var n,s,o,a,c=[],u=!0,d=!1;try{if(o=(t=t.call(r)).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 QE(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),t.push.apply(t,n)}return t}function iO(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?QE(Object(t),!0).forEach(function(n){a_(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):QE(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function rO(r,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 ZD(r)}function bw(r,e){return bw=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},bw(r,e)}function zy(r,e){return qD(r)||eO(r,e)||tA(r,e)||tO()}function sO(r,e){for(;!{}.hasOwnProperty.call(r,e)&&(r=Lg(r))!==null;);return r}function ww(r,e,t,n){var s=xw(Lg(r.prototype),e,t);return typeof s=="function"?function(o){return s.apply(t,o)}:s}function eh(r){return YD(r)||QD(r)||tA(r)||nO()}function oO(r,e){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function eA(r){var e=oO(r,"string");return typeof e=="symbol"?e:e+""}function Mw(r){"@babel/helpers - typeof";return Mw=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},Mw(r)}function tA(r,e){if(r){if(typeof r=="string")return yw(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?yw(r,e):void 0}}var nA=function(e){e instanceof Array?e.forEach(nA):(e.map&&e.map.dispose(),e.dispose())},iA=function(e){e.geometry&&e.geometry.dispose(),e.material&&nA(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(iA)},Sw=function(e){for(;e.children.length;){var t=e.children[0];e.remove(t),iA(t)}},Tw=new WeakMap,l_=new WeakMap,Vy=function(r){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 XE(this,e),n=jE(this,e),a_(n,"scene",void 0),qE(n,Tw,void 0),qE(n,l_,void 0),n.scene=t,YE(Tw,n,a),YE(l_,n,u),n.onRemoveObj(function(){}),n}return JE(e,r),KE(e,[{key:"onCreateObj",value:function(n){var s=this;return ww(e,"onCreateObj",this)([function(o){var a=n(o);return o[vw(l_,s)]=a,a[vw(Tw,s)]=o,s.scene.add(a),a}]),this}},{key:"onRemoveObj",value:function(n){var s=this;return ww(e,"onRemoveObj",this)([function(o,a){var c=ww(e,"getData",s)([o]);n(o,a),s.scene.remove(o),Sw(o),delete c[vw(l_,s)]}]),this}}])}(HD),Gy=function(e){return isNaN(e)?parseInt((0,HE.Z)(e).toHex(),16):e},Ew=function(e){return isNaN(e)?(0,HE.Z)(e).getAlpha():1},aO=WE(XD);function rA(r,e,t){!e||typeof t!="string"||r.filter(function(n){return!n[t]}).forEach(function(n){n[t]=aO(e(n))})}function lO(r,e){var t=r.nodes,n=r.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=oe(T),I=oe(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 ee=d[z],Q=d[I];ee.out.push(Q);function oe(_e){return Mw(_e)==="object"?e(_e):_e}});var p=[];y(Object.values(d));var m=Object.assign.apply(Object,[{}].concat(eh(Object.entries(d).filter(function(M){var T=zy(M,2),G=T[1];return!G.skip}).map(function(M){var T=zy(M,2),G=T[0],z=T[1];return a_({},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 oe=M[I];if(T.indexOf(oe)!==-1){var _e=[].concat(eh(T.slice(T.indexOf(oe))),[oe]).map(function(ve){return e(ve.data)});return p.some(function(ve){return ve.length===_e.length&&ve.every(function(Oe,He){return Oe===_e[He]})})||(p.push(_e),u(_e)),1}G>oe.depth&&(oe.depth=G,y(oe.out,[].concat(eh(T),[oe]),G+(oe.skip?0:1)))},I=0,ee=M.length;I<ee;I++)z()}}var Zr=window.THREE?window.THREE:{Group:ul,Mesh:Zs,MeshLambertMaterial:cy,Color:jn,BufferGeometry:xr,BufferAttribute:Qr,Matrix4:Ft,Vector3:ot,SphereGeometry:ju,CylinderGeometry:wp,TubeGeometry:bf,ConeGeometry:Mp,Line:xh,LineBasicMaterial:el,QuadraticBezierCurve3:pd,CubicBezierCurve3:_x,Box3:ha},sA={graph:cw,forcelayout:L3},cO=2,Aw=new Zr.BufferGeometry().setAttribute?"setAttribute":"addAttribute",c_=new Zr.BufferGeometry().applyMatrix4?"applyMatrix4":"applyMatrix",uO=s_({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=Us(e.nodeThreeObjectExtend);e.nodeDataMapper.entries().forEach(function(y){var M=zy(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=Us(e.linkWidth),u=Us(e.linkCurvature),d=Us(e.linkCurveRotation),p=Us(e.linkThreeObjectExtend);e.linkDataMapper.entries().forEach(function(y){var M=zy(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"],ee=z[t?"target":"to"];if(!(!I||!ee||!I.hasOwnProperty("x")||!ee.hasOwnProperty("x"))){m(T);var Q=p(T);if(!(e.linkPositionUpdate&&e.linkPositionUpdate(Q?G.children[1]:G,{start:{x:I.x,y:I.y,z:I.z},end:{x:ee.x,y:ee.y,z:ee.z}},T)&&!Q)){var oe=30,_e=T.__curve,ve=G.children.length?G.children[0]:G;if(ve.type==="Line"){if(_e){var He=_e.getPoints(oe);ve.geometry.getAttribute("position").array.length!==He.length*3&&ve.geometry[Aw]("position",new Zr.BufferAttribute(new Float32Array(He.length*3),3)),ve.geometry.setFromPoints(He)}else{var Oe=ve.geometry.getAttribute("position");(!Oe||!Oe.array||Oe.array.length!==6)&&ve.geometry[Aw]("position",Oe=new Zr.BufferAttribute(new Float32Array(2*3),3)),Oe.array[0]=I.x,Oe.array[1]=I.y||0,Oe.array[2]=I.z||0,Oe.array[3]=ee.x,Oe.array[4]=ee.y||0,Oe.array[5]=ee.z||0,Oe.needsUpdate=!0}ve.geometry.computeBoundingSphere()}else if(ve.type==="Mesh")if(_e){ve.geometry.type.match(/^Tube(Buffer)?Geometry$/)||(ve.position.set(0,0,0),ve.rotation.set(0,0,0),ve.scale.set(1,1,1));var vn=Math.ceil(c(T)*10)/10,mn=vn/2,Yn=new Zr.TubeGeometry(_e,oe,mn,e.linkResolution,!1);ve.geometry.dispose(),ve.geometry=Yn}else{if(!ve.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)){var Ce=Math.ceil(c(T)*10)/10,Be=Ce/2,ft=new Zr.CylinderGeometry(Be,Be,1,e.linkResolution,1,!1);ft[c_](new Zr.Matrix4().makeTranslation(0,1/2,0)),ft[c_](new Zr.Matrix4().makeRotationX(Math.PI/2)),ve.geometry.dispose(),ve.geometry=ft}var zt=new Zr.Vector3(I.x,I.y||0,I.z||0),tn=new Zr.Vector3(ee.x,ee.y||0,ee.z||0),cn=zt.distanceTo(tn);ve.position.x=zt.x,ve.position.y=zt.y,ve.position.z=zt.z,ve.scale.z=cn,ve.parent.localToWorld(tn),ve.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 Zr.Vector3(T.x,T.y||0,T.z||0),ee=new Zr.Vector3(G.x,G.y||0,G.z||0),Q=I.distanceTo(ee),oe,_e=d(y);if(Q>0){var ve=G.x-T.x,Oe=G.y-T.y||0,He=new Zr.Vector3().subVectors(ee,I),Ce=He.clone().multiplyScalar(z).cross(ve!==0||Oe!==0?new Zr.Vector3(0,0,1):new Zr.Vector3(0,1,0)).applyAxisAngle(He.normalize(),_e).add(new Zr.Vector3().addVectors(I,ee).divideScalar(2));oe=new Zr.QuadraticBezierCurve3(I,Ce,ee)}else{var Be=z*70,ft=-_e,zt=ft+Math.PI/2;oe=new Zr.CubicBezierCurve3(I,new Zr.Vector3(Be*Math.cos(zt),Be*Math.sin(zt),0).add(I),new Zr.Vector3(Be*Math.cos(ft),Be*Math.sin(ft),0).add(I),ee)}y.__curve=oe}}}}function s(){var a=Us(e.linkDirectionalArrowRelPos),c=Us(e.linkDirectionalArrowLength),u=Us(e.nodeVal);e.arrowDataMapper.entries().forEach(function(d){var p=zy(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,ee=c(m),Q=a(m),oe=m.__curve?function(Be){return m.__curve.getPoint(Be)}:function(Be){var ft=function(tn,cn,vn,mn){return cn[tn]+(vn[tn]-cn[tn])*mn||0};return{x:ft("x",T,G,Be),y:ft("y",T,G,Be),z:ft("z",T,G,Be)}},_e=m.__curve?m.__curve.getLength():Math.sqrt(["x","y","z"].map(function(Be){return Math.pow((G[Be]||0)-(T[Be]||0),2)}).reduce(function(Be,ft){return Be+ft},0)),ve=z+ee+(_e-z-I-ee)*Q,Oe=oe(ve/_e),He=oe((ve-ee)/_e);["x","y","z"].forEach(function(Be){return y.position[Be]=He[Be]});var Ce=ZE(Zr.Vector3,eh(["x","y","z"].map(function(Be){return Oe[Be]})));y.parent.localToWorld(Ce),y.lookAt(Ce)}}})}function o(){var a=Us(e.linkDirectionalParticleSpeed),c=Us(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(Q){return u.__curve.getPoint(Q)}:function(Q){var oe=function(ve,Oe,He,Ce){return Oe[ve]+(He[ve]-Oe[ve])*Ce||0};return{x:oe("x",M,T,Q),y:oe("y",M,T,Q),z:oe("z",M,T,Q)}},ee=[].concat(eh(p||[]),eh(m||[]));ee.forEach(function(Q,oe){var _e=Q.parent.__linkThreeObjType==="singleHopPhotons";if(Q.hasOwnProperty("__progressRatio")||(Q.__progressRatio=_e?0:(oe+z)/p.length),Q.__progressRatio+=G,Q.__progressRatio>=1)if(!_e)Q.__progressRatio=Q.__progressRatio%1;else{Q.parent.remove(Q),Sw(Q);return}var ve=Q.__progressRatio,Oe=I(ve);Q.geometry.type!=="SphereGeometry"&&Q.lookAt(Oe.x,Oe.y,Oe.z),["x","y","z"].forEach(function(He){return Q.position[He]=Oe[He]})})}}})}},emitParticle:function(e,t){if(t&&e.graphData.links.includes(t)){if(!t.__singleHopPhotonsObj){var n=new Zr.Group;n.__linkThreeObjType="singleHopPhotons",t.__singleHopPhotonsObj=n,e.graphScene.add(n)}var s=Us(e.linkDirectionalParticleThreeObject)(t);if(s&&e.linkDirectionalParticleThreeObject===s&&(s=s.clone()),!s){var o=Us(e.linkDirectionalParticleWidth),a=Math.ceil(o(t)*10)/10/2,c=e.linkDirectionalParticleResolution,u=new Zr.SphereGeometry(a,c,c),d=Us(e.linkColor),p=Us(e.linkDirectionalParticleColor),m=p(t)||d(t)||"#f0f0f0",y=new Zr.Color(Gy(m)),M=e.linkOpacity*3,T=new Zr.MeshLambertMaterial({color:y,transparent:!0,opacity:M});s=new Zr.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 Zr.Box3;c.copy(o.geometry.boundingBox).applyMatrix4(o.matrixWorld),a.push(c)}return a.concat.apply(a,eh((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,eh(["x","y","z"].map(function(s){return a_({},s,[CD(n,function(o){return o.min[s]}),RD(n,function(o){return o.max[s]})])}))):null}},stateInit:function(){return{d3ForceLayout:rr().force("link",zo()).force("charge",Cd()).force("center",ic()).force("dagRadial",null).stop(),engineRunning:!1}},init:function(e,t){t.graphScene=e,t.nodeDataMapper=new Vy(e,{objBindAttr:"__threeObj"}),t.linkDataMapper=new Vy(e,{objBindAttr:"__lineObj"}),t.arrowDataMapper=new Vy(e,{objBindAttr:"__arrowObj"}),t.particlesDataMapper=new Vy(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"])&&rA(e.graphData.nodes,Us(e.nodeAutoColorBy),e.nodeColor),e.linkAutoColorBy!==null&&n(["linkAutoColorBy","graphData","linkColor"])&&rA(e.graphData.links,Us(e.linkAutoColorBy),e.linkColor),e._flushObjects||n(["graphData","nodeThreeObject","nodeThreeObjectExtend","nodeVal","nodeColor","nodeVisibility","nodeRelSize","nodeResolution","nodeOpacity"])){var s=Us(e.nodeThreeObject),o=Us(e.nodeThreeObjectExtend),a=Us(e.nodeVal),c=Us(e.nodeColor),u=Us(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 Zr.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 Zr.SphereGeometry(fi,ki,ki)),Vn.geometry.dispose(),Vn.geometry=d[Mn]);var Ni=c(un),Cr=new Zr.Color(Gy(Ni||"#ffffaa")),zs=e.nodeOpacity*Ew(Ni);(Vn.material.type!=="MeshLambertMaterial"||!Vn.material.color.equals(Cr)||Vn.material.opacity!==zs)&&(p.hasOwnProperty(Ni)||(p[Ni]=new Zr.MeshLambertMaterial({color:Cr,transparent:!0,opacity:zs})),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=Us(e.linkThreeObject),y=Us(e.linkThreeObjectExtend),M=Us(e.linkMaterial),T=Us(e.linkVisibility),G=Us(e.linkColor),z=Us(e.linkWidth),I={},ee={},Q={},oe=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),Sw(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 Zr.Mesh;else{var Ni=new Zr.BufferGeometry;Ni[Aw]("position",new Zr.BufferAttribute(new Float32Array(2*3),3)),fi=new Zr.Line(Ni)}}var Cr;return un?Mn?(Cr=new Zr.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 zs=new Zr.CylinderGeometry(Ni,Ni,1,Cr,1,!1);zs[c_](new Zr.Matrix4().makeTranslation(0,1/2,0)),zs[c_](new Zr.Matrix4().makeRotationX(Math.PI/2)),I[fi]=zs}Mn.geometry.dispose(),Mn.geometry=I[fi]}}var Vt=M(un);if(Vt)Mn.material=Vt;else{var Kn=G(un),Zn=new Zr.Color(Gy(Kn||"#f0f0f0")),qn=e.linkOpacity*Ew(Kn),Hn=ki?"MeshLambertMaterial":"LineBasicMaterial";if(Mn.material.type!==Hn||!Mn.material.color.equals(Zn)||Mn.material.opacity!==qn){var Ti=ki?ee:Q;Ti.hasOwnProperty(Kn)||(Ti[Kn]=new Zr[Hn]({color:Zn,transparent:qn<1,opacity:qn,depthWrite:qn>=1})),Mn.material.dispose(),Mn.material=Ti[Kn]}}}}).digest(oe),e.linkDirectionalArrowLength||t.hasOwnProperty("linkDirectionalArrowLength")){var _e=Us(e.linkDirectionalArrowLength),ve=Us(e.linkDirectionalArrowColor);e.arrowDataMapper.onCreateObj(function(){var Vn=new Zr.Mesh(void 0,new Zr.MeshLambertMaterial({transparent:!0}));return Vn.__linkThreeObjType="arrow",Vn}).onUpdateObj(function(Vn,un){var Mn=_e(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 Zr.ConeGeometry(Mn*.25,Mn,fi);ki.translate(0,Mn/2,0),ki.rotateX(Math.PI/2),Vn.geometry.dispose(),Vn.geometry=ki}var Ni=ve(un)||G(un)||"#f0f0f0";Vn.material.color=new Zr.Color(Gy(Ni)),Vn.material.opacity=e.linkOpacity*3*Ew(Ni)}).digest(oe.filter(_e))}if(e.linkDirectionalParticles||t.hasOwnProperty("linkDirectionalParticles")){var Oe=Us(e.linkDirectionalParticles),He=Us(e.linkDirectionalParticleWidth),Ce=Us(e.linkDirectionalParticleColor),Be=Us(e.linkDirectionalParticleThreeObject),ft={},zt={};e.particlesDataMapper.onCreateObj(function(){var Vn=new Zr.Group;return Vn.__linkThreeObjType="photons",Vn.__photonDataMapper=new Vy(Vn),Vn}).onUpdateObj(function(Vn,un){var Mn=!!Vn.children.length&&Vn.children[0],fi=Be(un),ki,Ni;if(fi)ki=fi.geometry,Ni=fi.material;else{var Cr=Math.ceil(He(un)*10)/10/2,zs=e.linkDirectionalParticleResolution;Mn&&Mn.geometry.parameters.radius===Cr&&Mn.geometry.parameters.widthSegments===zs?ki=Mn.geometry:(zt.hasOwnProperty(Cr)||(zt[Cr]=new Zr.SphereGeometry(Cr,zs,zs)),ki=zt[Cr]);var Vt=Ce(un)||G(un)||"#f0f0f0",Kn=new Zr.Color(Gy(Vt)),Zn=e.linkOpacity*3;Mn&&Mn.material.color.equals(Kn)&&Mn.material.opacity===Zn?Ni=Mn.material:(ft.hasOwnProperty(Vt)||(ft[Vt]=new Zr.MeshLambertMaterial({color:Kn,transparent:!0,opacity:Zn})),Ni=ft[Vt])}Mn&&(Mn.geometry!==ki&&Mn.geometry.dispose(),Mn.material!==Ni&&Mn.material.dispose());var qn=Math.round(Math.abs(Oe(un)));Vn.__photonDataMapper.id(function(Hn){return Hn.idx}).onCreateObj(function(){return new Zr.Mesh(ki,Ni)}).onUpdateObj(function(Hn){Hn.geometry=ki,Hn.material=Ni}).digest(eh(new Array(qn)).map(function(Hn,Ti){return{idx:Ti}}))}).digest(oe.filter(Oe))}}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&&lO(e.graphData,function(Vn){return Vn[e.nodeId]},{nodeFilter:e.dagNodeFilter,onLoopError:e.onDagError||void 0}),Yn=Math.max.apply(Math,eh(Object.values(mn||[]))),xn=e.dagLevelDistance||e.graphData.nodes.length/(Yn||1)*cO*(["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?Jx(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=sA.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=sA.forcelayout(nr,iO({dimensions:e.numDimensions},e.ngraphPhysics)),cn.graph=nr}for(var ss=0;ss<e.warmupTicks&&!(tn&&e.d3AlphaMin>0&&e.d3ForceLayout.alpha()<e.d3AlphaMin);ss++)cn[tn?"tick":"step"]();e.layout=cn,this.resetCountdown()}e.engineRunning=!0,e.onFinishUpdate()}});function hO(r){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;XE(this,o);for(var c=arguments.length,u=new Array(c),d=0;d<c;d++)u[d]=arguments[d];return a=jE(this,o,[].concat(u)),a.__kapsuleInstance=ZE(r,[].concat(eh(t?[a]:[]),u)),a}return JE(o,s),KE(o)}(e);return Object.keys(r()).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 dO=window.THREE?window.THREE:{Group:ul},oA=hO(uO,dO.Group,!0);function aA(){let r=null,e=!1,t=null,n=null;function s(o,a){t(o,a),n=r.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&(n=r.requestAnimationFrame(s),e=!0)},stop:function(){r.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(o){t=o},setContext:function(o){r=o}}}function fO(r){const e=new WeakMap;function t(c,u){const d=c.array,p=c.usage,m=d.byteLength,y=r.createBuffer();r.bindBuffer(u,y),r.bufferData(u,d,p),c.onUploadCallback();let M;if(d instanceof Float32Array)M=r.FLOAT;else if(typeof Float16Array!="undefined"&&d instanceof Float16Array)M=r.HALF_FLOAT;else if(d instanceof Uint16Array)c.isFloat16BufferAttribute?M=r.HALF_FLOAT:M=r.UNSIGNED_SHORT;else if(d instanceof Int16Array)M=r.SHORT;else if(d instanceof Uint32Array)M=r.UNSIGNED_INT;else if(d instanceof Int32Array)M=r.INT;else if(d instanceof Int8Array)M=r.BYTE;else if(d instanceof Uint8Array)M=r.UNSIGNED_BYTE;else if(d instanceof Uint8ClampedArray)M=r.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(r.bindBuffer(d,c),m.length===0)r.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];r.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&&(r.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 pO=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,mO=`#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`,gO=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,yO=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,vO=`#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`,xO=`#ifdef USE_ALPHATEST
uniform float alphaTest;
#endif`,_O=`#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`,bO=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
#endif`,wO=`#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`,MO=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,SO=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
#endif`,TO=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
#endif`,EO=`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`,AO=`#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`,CO=`#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`,RO=`#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`,NO=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,PO=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
#endif`,IO=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
#endif`,LO=`#if defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
#elif defined( USE_COLOR )
diffuseColor.rgb *= vColor;
#endif`,DO=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR )
varying vec3 vColor;
#endif`,OO=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec3 vColor;
#endif`,FO=`#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`,BO=`#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`,UO=`#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`,kO=`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`,zO=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
#endif`,VO=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,GO=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,WO=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
#endif`,HO="gl_FragColor = linearToOutputTexel( gl_FragColor );",$O=`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 );
}`,jO=`#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`,XO=`#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`,qO=`#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`,YO=`#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`,ZO=`#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`,KO=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
#endif`,JO=`#ifdef USE_FOG
varying float vFogDepth;
#endif`,QO=`#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`,eF=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
uniform float fogDensity;
#else
uniform float fogNear;
uniform float fogFar;
#endif
#endif`,tF=`#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
}`,nF=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
#endif`,iF=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,rF=`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`,sF=`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`,oF=`#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`,aF=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,lF=`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`,cF=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,uF=`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`,hF=`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`,dF=`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 );
}`,fF=`
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`,pF=`#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`,mF=`#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`,gF=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,yF=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
#endif`,vF=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
varying float vFragDepth;
varying float vIsPerspective;
#endif`,xF=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,_F=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
#endif`,bF=`#ifdef USE_MAP
uniform sampler2D map;
#endif`,wF=`#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`,MF=`#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`,SF=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
#endif`,TF=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
#endif`,EF=`#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`,AF=`#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`,CF=`#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`,RF=`#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`,NF=`#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`,PF=`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;`,IF=`#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`,LF=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,DF=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,OF=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
#endif
#endif`,FF=`#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`,BF=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,UF=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,kF=`#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`,zF=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
#endif`,VF=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,GF=`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 );
}`,WF=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
#endif`,HF=`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;`,$F=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,jF=`#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`,XF=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
#endif`,qF=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
#endif`,YF=`#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`,ZF=`#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`,KF=`#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`,JF=`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;
}`,QF=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,eB=`#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`,tB=`#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`,nB=`#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`,iB=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
#endif`,rB=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
#endif`,sB=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,oB=`#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; }`,aB=`#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`,lB=`#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`,cB=`#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`,uB=`#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`,hB=`#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`,dB=`#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 Ns={alphahash_fragment:pO,alphahash_pars_fragment:mO,alphamap_fragment:gO,alphamap_pars_fragment:yO,alphatest_fragment:vO,alphatest_pars_fragment:xO,aomap_fragment:_O,aomap_pars_fragment:bO,batching_pars_vertex:wO,batching_vertex:MO,begin_vertex:SO,beginnormal_vertex:TO,bsdfs:EO,iridescence_fragment:AO,bumpmap_pars_fragment:CO,clipping_planes_fragment:RO,clipping_planes_pars_fragment:NO,clipping_planes_pars_vertex:PO,clipping_planes_vertex:IO,color_fragment:LO,color_pars_fragment:DO,color_pars_vertex:OO,color_vertex:FO,common:BO,cube_uv_reflection_fragment:UO,defaultnormal_vertex:kO,displacementmap_pars_vertex:zO,displacementmap_vertex:VO,emissivemap_fragment:GO,emissivemap_pars_fragment:WO,colorspace_fragment:HO,colorspace_pars_fragment:$O,envmap_fragment:jO,envmap_common_pars_fragment:XO,envmap_pars_fragment:qO,envmap_pars_vertex:YO,envmap_physical_pars_fragment:oF,envmap_vertex:ZO,fog_vertex:KO,fog_pars_vertex:JO,fog_fragment:QO,fog_pars_fragment:eF,gradientmap_pars_fragment:tF,lightmap_pars_fragment:nF,lights_lambert_fragment:iF,lights_lambert_pars_fragment:rF,lights_pars_begin:sF,lights_toon_fragment:aF,lights_toon_pars_fragment:lF,lights_phong_fragment:cF,lights_phong_pars_fragment:uF,lights_physical_fragment:hF,lights_physical_pars_fragment:dF,lights_fragment_begin:fF,lights_fragment_maps:pF,lights_fragment_end:mF,logdepthbuf_fragment:gF,logdepthbuf_pars_fragment:yF,logdepthbuf_pars_vertex:vF,logdepthbuf_vertex:xF,map_fragment:_F,map_pars_fragment:bF,map_particle_fragment:wF,map_particle_pars_fragment:MF,metalnessmap_fragment:SF,metalnessmap_pars_fragment:TF,morphinstance_vertex:EF,morphcolor_vertex:AF,morphnormal_vertex:CF,morphtarget_pars_vertex:RF,morphtarget_vertex:NF,normal_fragment_begin:PF,normal_fragment_maps:IF,normal_pars_fragment:LF,normal_pars_vertex:DF,normal_vertex:OF,normalmap_pars_fragment:FF,clearcoat_normal_fragment_begin:BF,clearcoat_normal_fragment_maps:UF,clearcoat_pars_fragment:kF,iridescence_pars_fragment:zF,opaque_fragment:VF,packing:GF,premultiplied_alpha_fragment:WF,project_vertex:HF,dithering_fragment:$F,dithering_pars_fragment:jF,roughnessmap_fragment:XF,roughnessmap_pars_fragment:qF,shadowmap_pars_fragment:YF,shadowmap_pars_vertex:ZF,shadowmap_vertex:KF,shadowmask_pars_fragment:JF,skinbase_vertex:QF,skinning_pars_vertex:eB,skinning_vertex:tB,skinnormal_vertex:nB,specularmap_fragment:iB,specularmap_pars_fragment:rB,tonemapping_fragment:sB,tonemapping_pars_fragment:oB,transmission_fragment:aB,transmission_pars_fragment:lB,uv_pars_fragment:cB,uv_pars_vertex:uB,uv_vertex:hB,worldpos_vertex:dB,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 $r},alphaMap:{value:null},alphaMapTransform:{value:new $r},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new $r}},envmap:{envMap:{value:null},envMapRotation:{value:new $r},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new $r}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new $r}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new $r},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new $r},normalScale:{value:new yn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new $r},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new $r}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new $r}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new $r}},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 $r},alphaTest:{value:0},uvTransform:{value:new $r}},sprite:{diffuse:{value:new jn(16777215)},opacity:{value:1},center:{value:new yn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new $r},alphaMap:{value:null},alphaMapTransform:{value:new $r},alphaTest:{value:0}}},Ah={basic:{uniforms:Ja([zi.common,zi.specularmap,zi.envmap,zi.aomap,zi.lightmap,zi.fog]),vertexShader:Ns.meshbasic_vert,fragmentShader:Ns.meshbasic_frag},lambert:{uniforms:Ja([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:Ns.meshlambert_vert,fragmentShader:Ns.meshlambert_frag},phong:{uniforms:Ja([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:Ns.meshphong_vert,fragmentShader:Ns.meshphong_frag},standard:{uniforms:Ja([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:Ns.meshphysical_vert,fragmentShader:Ns.meshphysical_frag},toon:{uniforms:Ja([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:Ns.meshtoon_vert,fragmentShader:Ns.meshtoon_frag},matcap:{uniforms:Ja([zi.common,zi.bumpmap,zi.normalmap,zi.displacementmap,zi.fog,{matcap:{value:null}}]),vertexShader:Ns.meshmatcap_vert,fragmentShader:Ns.meshmatcap_frag},points:{uniforms:Ja([zi.points,zi.fog]),vertexShader:Ns.points_vert,fragmentShader:Ns.points_frag},dashed:{uniforms:Ja([zi.common,zi.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ns.linedashed_vert,fragmentShader:Ns.linedashed_frag},depth:{uniforms:Ja([zi.common,zi.displacementmap]),vertexShader:Ns.depth_vert,fragmentShader:Ns.depth_frag},normal:{uniforms:Ja([zi.common,zi.bumpmap,zi.normalmap,zi.displacementmap,{opacity:{value:1}}]),vertexShader:Ns.meshnormal_vert,fragmentShader:Ns.meshnormal_frag},sprite:{uniforms:Ja([zi.sprite,zi.fog]),vertexShader:Ns.sprite_vert,fragmentShader:Ns.sprite_frag},background:{uniforms:{uvTransform:{value:new $r},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ns.background_vert,fragmentShader:Ns.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new $r}},vertexShader:Ns.backgroundCube_vert,fragmentShader:Ns.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ns.cube_vert,fragmentShader:Ns.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ns.equirect_vert,fragmentShader:Ns.equirect_frag},distanceRGBA:{uniforms:Ja([zi.common,zi.displacementmap,{referencePosition:{value:new ot},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ns.distanceRGBA_vert,fragmentShader:Ns.distanceRGBA_frag},shadow:{uniforms:Ja([zi.lights,zi.fog,{color:{value:new jn(0)},opacity:{value:1}}]),vertexShader:Ns.shadow_vert,fragmentShader:Ns.shadow_frag}};Ah.physical={uniforms:Ja([Ah.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new $r},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new $r},clearcoatNormalScale:{value:new yn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new $r},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new $r},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new $r},sheen:{value:0},sheenColor:{value:new jn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new $r},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new $r},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new $r},transmissionSamplerSize:{value:new yn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new $r},attenuationDistance:{value:0},attenuationColor:{value:new jn(0)},specularColor:{value:new jn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new $r},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new $r},anisotropyVector:{value:new yn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new $r}}]),vertexShader:Ns.meshphysical_vert,fragmentShader:Ns.meshphysical_frag};const u_={r:0,b:0,g:0},Kp=new Qi,fB=new Ft;function pB(r,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(Q){let oe=Q.isScene===!0?Q.background:null;return oe&&oe.isTexture&&(oe=(Q.backgroundBlurriness>0?t:e).get(oe)),oe}function G(Q){let oe=!1;const _e=T(Q);_e===null?I(c,u):_e&&_e.isColor&&(I(_e,1),oe=!0);const ve=r.xr.getEnvironmentBlendMode();ve==="additive"?n.buffers.color.setClear(0,0,0,1,a):ve==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(r.autoClear||oe)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil))}function z(Q,oe){const _e=T(oe);_e&&(_e.isCubeTexture||_e.mapping===Ke)?(p===void 0&&(p=new Zs(new Fc(1,1,1),new Bc({name:"BackgroundCubeMaterial",uniforms:Jh(Ah.backgroundCube.uniforms),vertexShader:Ah.backgroundCube.vertexShader,fragmentShader:Ah.backgroundCube.fragmentShader,side:K,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),p.geometry.deleteAttribute("normal"),p.geometry.deleteAttribute("uv"),p.onBeforeRender=function(ve,Oe,He){this.matrixWorld.copyPosition(He.matrixWorld)},Object.defineProperty(p.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(p)),Kp.copy(oe.backgroundRotation),Kp.x*=-1,Kp.y*=-1,Kp.z*=-1,_e.isCubeTexture&&_e.isRenderTargetTexture===!1&&(Kp.y*=-1,Kp.z*=-1),p.material.uniforms.envMap.value=_e,p.material.uniforms.flipEnvMap.value=_e.isCubeTexture&&_e.isRenderTargetTexture===!1?-1:1,p.material.uniforms.backgroundBlurriness.value=oe.backgroundBlurriness,p.material.uniforms.backgroundIntensity.value=oe.backgroundIntensity,p.material.uniforms.backgroundRotation.value.setFromMatrix4(fB.makeRotationFromEuler(Kp)),p.material.toneMapped=Ki.getTransfer(_e.colorSpace)!==Fi,(m!==_e||y!==_e.version||M!==r.toneMapping)&&(p.material.needsUpdate=!0,m=_e,y=_e.version,M=r.toneMapping),p.layers.enableAll(),Q.unshift(p,p.geometry,p.material,0,0,null)):_e&&_e.isTexture&&(d===void 0&&(d=new Zs(new Mh(2,2),new Bc({name:"BackgroundMaterial",uniforms:Jh(Ah.background.uniforms),vertexShader:Ah.background.vertexShader,fragmentShader:Ah.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=_e,d.material.uniforms.backgroundIntensity.value=oe.backgroundIntensity,d.material.toneMapped=Ki.getTransfer(_e.colorSpace)!==Fi,_e.matrixAutoUpdate===!0&&_e.updateMatrix(),d.material.uniforms.uvTransform.value.copy(_e.matrix),(m!==_e||y!==_e.version||M!==r.toneMapping)&&(d.material.needsUpdate=!0,m=_e,y=_e.version,M=r.toneMapping),d.layers.enableAll(),Q.unshift(d,d.geometry,d.material,0,0,null))}function I(Q,oe){Q.getRGB(u_,ox(r)),n.buffers.color.setClear(u_.r,u_.g,u_.b,oe,a)}function ee(){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(Q,oe=1){c.set(Q),u=oe,I(c,u)},getClearAlpha:function(){return u},setClearAlpha:function(Q){u=Q,I(c,u)},render:G,addToRenderList:z,dispose:ee}}function mB(r,e){const t=r.getParameter(r.MAX_VERTEX_ATTRIBS),n={},s=y(null);let o=s,a=!1;function c(Be,ft,zt,tn,cn){let vn=!1;const mn=m(tn,zt,ft);o!==mn&&(o=mn,d(o.object)),vn=M(Be,tn,zt,cn),vn&&T(Be,tn,zt,cn),cn!==null&&e.update(cn,r.ELEMENT_ARRAY_BUFFER),(vn||a)&&(a=!1,oe(Be,ft,zt,tn),cn!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,e.get(cn).buffer))}function u(){return r.createVertexArray()}function d(Be){return r.bindVertexArray(Be)}function p(Be){return r.deleteVertexArray(Be)}function m(Be,ft,zt){const tn=zt.wireframe===!0;let cn=n[Be.id];cn===void 0&&(cn={},n[Be.id]=cn);let vn=cn[ft.id];vn===void 0&&(vn={},cn[ft.id]=vn);let mn=vn[tn];return mn===void 0&&(mn=y(u()),vn[tn]=mn),mn}function y(Be){const ft=[],zt=[],tn=[];for(let cn=0;cn<t;cn++)ft[cn]=0,zt[cn]=0,tn[cn]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:ft,enabledAttributes:zt,attributeDivisors:tn,object:Be,attributes:{},index:null}}function M(Be,ft,zt,tn){const cn=o.attributes,vn=ft.attributes;let mn=0;const Yn=zt.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"&&Be.instanceMatrix&&(Gn=Be.instanceMatrix),xn==="instanceColor"&&Be.instanceColor&&(Gn=Be.instanceColor)),wn===void 0||wn.attribute!==Gn||Gn&&wn.data!==Gn.data)return!0;mn++}return o.attributesNum!==mn||o.index!==tn}function T(Be,ft,zt,tn){const cn={},vn=ft.attributes;let mn=0;const Yn=zt.getAttributes();for(const xn in Yn)if(Yn[xn].location>=0){let wn=vn[xn];wn===void 0&&(xn==="instanceMatrix"&&Be.instanceMatrix&&(wn=Be.instanceMatrix),xn==="instanceColor"&&Be.instanceColor&&(wn=Be.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 Be=o.newAttributes;for(let ft=0,zt=Be.length;ft<zt;ft++)Be[ft]=0}function z(Be){I(Be,0)}function I(Be,ft){const zt=o.newAttributes,tn=o.enabledAttributes,cn=o.attributeDivisors;zt[Be]=1,tn[Be]===0&&(r.enableVertexAttribArray(Be),tn[Be]=1),cn[Be]!==ft&&(r.vertexAttribDivisor(Be,ft),cn[Be]=ft)}function ee(){const Be=o.newAttributes,ft=o.enabledAttributes;for(let zt=0,tn=ft.length;zt<tn;zt++)ft[zt]!==Be[zt]&&(r.disableVertexAttribArray(zt),ft[zt]=0)}function Q(Be,ft,zt,tn,cn,vn,mn){mn===!0?r.vertexAttribIPointer(Be,ft,zt,cn,vn):r.vertexAttribPointer(Be,ft,zt,tn,cn,vn)}function oe(Be,ft,zt,tn){G();const cn=tn.attributes,vn=zt.getAttributes(),mn=ft.defaultAttributeValues;for(const Yn in vn){const xn=vn[Yn];if(xn.location>=0){let si=cn[Yn];if(si===void 0&&(Yn==="instanceMatrix"&&Be.instanceMatrix&&(si=Be.instanceMatrix),Yn==="instanceColor"&&Be.instanceColor&&(si=Be.instanceColor)),si!==void 0){const wn=si.normalized,Gn=si.itemSize,Si=e.get(si);if(Si===void 0)continue;const nr=Si.buffer,ss=Si.type,Vn=Si.bytesPerElement,un=ss===r.INT||ss===r.UNSIGNED_INT||si.gpuType===Is;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);Be.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);r.bindBuffer(r.ARRAY_BUFFER,nr);for(let Ni=0;Ni<xn.locationSize;Ni++)Q(xn.location+Ni,Gn/xn.locationSize,ss,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);Be.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);r.bindBuffer(r.ARRAY_BUFFER,nr);for(let Mn=0;Mn<xn.locationSize;Mn++)Q(xn.location+Mn,Gn/xn.locationSize,ss,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:r.vertexAttrib2fv(xn.location,wn);break;case 3:r.vertexAttrib3fv(xn.location,wn);break;case 4:r.vertexAttrib4fv(xn.location,wn);break;default:r.vertexAttrib1fv(xn.location,wn)}}}}ee()}function _e(){He();for(const Be in n){const ft=n[Be];for(const zt in ft){const tn=ft[zt];for(const cn in tn)p(tn[cn].object),delete tn[cn];delete ft[zt]}delete n[Be]}}function ve(Be){if(n[Be.id]===void 0)return;const ft=n[Be.id];for(const zt in ft){const tn=ft[zt];for(const cn in tn)p(tn[cn].object),delete tn[cn];delete ft[zt]}delete n[Be.id]}function Oe(Be){for(const ft in n){const zt=n[ft];if(zt[Be.id]===void 0)continue;const tn=zt[Be.id];for(const cn in tn)p(tn[cn].object),delete tn[cn];delete zt[Be.id]}}function He(){Ce(),a=!0,o!==s&&(o=s,d(o.object))}function Ce(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:c,reset:He,resetDefaultState:Ce,dispose:_e,releaseStatesOfGeometry:ve,releaseStatesOfProgram:Oe,initAttributes:G,enableAttribute:z,disableUnusedAttributes:ee}}function gB(r,e,t){let n;function s(d){n=d}function o(d,p){r.drawArrays(n,d,p),t.update(p,n,1)}function a(d,p,m){m!==0&&(r.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 yB(r,e,t,n){let s;function o(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){const Oe=e.get("EXT_texture_filter_anisotropic");s=r.getParameter(Oe.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(Oe){return!(Oe!==D&&n.convert(Oe)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT))}function c(Oe){const He=Oe===Vs&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(Oe!==Oi&&n.convert(Oe)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)&&Oe!==gs&&!He)}function u(Oe){if(Oe==="highp"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";Oe="mediump"}return Oe==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.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=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),T=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),G=r.getParameter(r.MAX_TEXTURE_SIZE),z=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),I=r.getParameter(r.MAX_VERTEX_ATTRIBS),ee=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),Q=r.getParameter(r.MAX_VARYING_VECTORS),oe=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),_e=T>0,ve=r.getParameter(r.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:ee,maxVaryings:Q,maxFragmentUniforms:oe,vertexTextures:_e,maxSamples:ve}}function vB(r){const e=this;let t=null,n=0,s=!1,o=!1;const a=new Al,c=new $r,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=r.get(m);if(!s||T===null||T.length===0||o&&!z)o?p(null):d();else{const ee=o?0:n,Q=ee*4;let oe=I.clippingState||null;u.value=oe,oe=p(T,y,Q,M);for(let _e=0;_e!==Q;++_e)oe[_e]=t[_e];I.clippingState=oe,this.numIntersection=G?this.numPlanes:0,this.numPlanes+=ee}};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,ee=y.matrixWorldInverse;c.getNormalMatrix(ee),(z===null||z.length<I)&&(z=new Float32Array(I));for(let Q=0,oe=M;Q!==G;++Q,oe+=4)a.copy(m[Q]).applyMatrix4(ee,c),a.normal.toArray(z,oe),z[oe+3]=a.constant}u.value=z,u.needsUpdate=!0}return e.numPlanes=G,e.numIntersection=0,z}}function xB(r){let e=new WeakMap;function t(a,c){return c===Pe?a.mapping=Fe:c===Ie&&(a.mapping=Xe),a}function n(a){if(a&&a.isTexture){const c=a.mapping;if(c===Pe||c===Ie)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 R0(u.height);return d.fromEquirectangularTexture(r,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 Dg=4,lA=[.125,.215,.35,.446,.526,.582],Jp=20,Cw=new Cf,cA=new jn;let Rw=null,Nw=0,Pw=0,Iw=!1;const Qp=(1+Math.sqrt(5))/2,Og=1/Qp,uA=[new ot(-Qp,Og,0),new ot(Qp,Og,0),new ot(-Og,0,Qp),new ot(Og,0,Qp),new ot(0,Qp,-Og),new ot(0,Qp,Og),new ot(-1,1,-1),new ot(1,1,-1),new ot(-1,1,1),new ot(1,1,1)],_B=new ot;class hA{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=_B}=o;Rw=this._renderer.getRenderTarget(),Nw=this._renderer.getActiveCubeFace(),Pw=this._renderer.getActiveMipmapLevel(),Iw=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=fA(),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(Rw,Nw,Pw),this._renderer.xr.enabled=Iw,e.scissorTest=!1,h_(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Fe||e.mapping===Xe?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Rw=this._renderer.getRenderTarget(),Nw=this._renderer.getActiveCubeFace(),Pw=this._renderer.getActiveMipmapLevel(),Iw=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:Vs,format:D,colorSpace:iu,depthBuffer:!1},s=dA(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=dA(e,t,n);const{_lodMax:o}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=bB(o)),this._blurMaterial=wB(o,e,t)}return s}_compileMaterial(e){const t=new Zs(this._lodPlanes[0],e);this._renderer.compile(t,Cw)}_sceneToCubeUV(e,t,n,s,o){const u=new fa(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(cA),m.toneMapping=yt,m.autoClear=!1,m.state.buffers.depth.getReversed()&&(m.setRenderTarget(s),m.clearDepth(),m.setRenderTarget(null));const G=new Wr({name:"PMREM.Background",side:K,depthWrite:!1,depthTest:!1}),z=new Zs(new Fc,G);let I=!1;const ee=e.background;ee?ee.isColor&&(G.color.copy(ee),e.background=null,I=!0):(G.color.copy(cA),I=!0);for(let Q=0;Q<6;Q++){const oe=Q%3;oe===0?(u.up.set(0,d[Q],0),u.position.set(o.x,o.y,o.z),u.lookAt(o.x+p[Q],o.y,o.z)):oe===1?(u.up.set(0,0,d[Q]),u.position.set(o.x,o.y,o.z),u.lookAt(o.x,o.y+p[Q],o.z)):(u.up.set(0,d[Q],0),u.position.set(o.x,o.y,o.z),u.lookAt(o.x,o.y,o.z+p[Q]));const _e=this._cubeSize;h_(s,oe*_e,Q>2?_e:0,_e,_e),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=ee}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===Fe||e.mapping===Xe;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=pA()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=fA());const o=s?this._cubemapMaterial:this._equirectMaterial,a=new Zs(this._lodPlanes[0],o),c=o.uniforms;c.envMap.value=e;const u=this._cubeSize;h_(t,0,0,3*u,2*u),n.setRenderTarget(t),n.render(a,Cw)}_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=uA[(s-o-1)%uA.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 Zs(this._lodPlanes[s],d),y=d.uniforms,M=this._sizeLods[n]-1,T=isFinite(o)?Math.PI/(2*M):2*Math.PI/(2*Jp-1),G=o/T,z=isFinite(o)?1+Math.floor(p*G):Jp;z>Jp&&console.warn(`sigmaRadians, ${o}, is too large and will clip, as it requested ${z} samples when the maximum is set to ${Jp}`);const I=[];let ee=0;for(let Oe=0;Oe<Jp;++Oe){const He=Oe/G,Ce=Math.exp(-He*He/2);I.push(Ce),Oe===0?ee+=Ce:Oe<z&&(ee+=2*Ce)}for(let Oe=0;Oe<I.length;Oe++)I[Oe]=I[Oe]/ee;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:Q}=this;y.dTheta.value=T,y.mipInt.value=Q-n;const oe=this._sizeLods[s],_e=3*oe*(s>Q-Dg?s-Q+Dg:0),ve=4*(this._cubeSize-oe);h_(t,_e,ve,3*oe,2*oe),u.setRenderTarget(t),u.render(m,Cw)}}function bB(r){const e=[],t=[],n=[];let s=r;const o=r-Dg+1+lA.length;for(let a=0;a<o;a++){const c=Math.pow(2,s);t.push(c);let u=1/c;a>r-Dg?u=lA[a-r+Dg-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,ee=new Float32Array(G*T*M),Q=new Float32Array(z*T*M),oe=new Float32Array(I*T*M);for(let ve=0;ve<M;ve++){const Oe=ve%3*2/3-1,He=ve>2?0:-1,Ce=[Oe,He,0,Oe+2/3,He,0,Oe+2/3,He+1,0,Oe,He,0,Oe+2/3,He+1,0,Oe,He+1,0];ee.set(Ce,G*T*ve),Q.set(y,z*T*ve);const Be=[ve,ve,ve,ve,ve,ve];oe.set(Be,I*T*ve)}const _e=new xr;_e.setAttribute("position",new Qr(ee,G)),_e.setAttribute("uv",new Qr(Q,z)),_e.setAttribute("faceIndex",new Qr(oe,I)),e.push(_e),s>Dg&&s--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function dA(r,e,t){const n=new cc(r,e,t);return n.texture.mapping=Ke,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function h_(r,e,t,n,s){r.viewport.set(e,t,n,s),r.scissor.set(e,t,n,s)}function wB(r,e,t){const n=new Float32Array(Jp),s=new ot(0,1,0);return new Bc({name:"SphericalGaussianBlur",defines:{n:Jp,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Lw(),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:ye,depthTest:!1,depthWrite:!1})}function fA(){return new Bc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Lw(),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:ye,depthTest:!1,depthWrite:!1})}function pA(){return new Bc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Lw(),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:ye,depthTest:!1,depthWrite:!1})}function Lw(){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 MB(r){let e=new WeakMap,t=null;function n(c){if(c&&c.isTexture){const u=c.mapping,d=u===Pe||u===Ie,p=u===Fe||u===Xe;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 hA(r)),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 hA(r)),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 SB(r){const e={};function t(n){if(e[n]!==void 0)return e[n];let s;switch(n){case"WEBGL_depth_texture":s=r.getExtension("WEBGL_depth_texture")||r.getExtension("MOZ_WEBGL_depth_texture")||r.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=r.getExtension("WEBGL_compressed_texture_s3tc")||r.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=r.getExtension("WEBGL_compressed_texture_pvrtc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=r.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&&ol("THREE.WebGLRenderer: "+n+" extension not supported."),s}}}function TB(r,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],r.ARRAY_BUFFER)}function d(m){const y=[],M=m.index,T=m.attributes.position;let G=0;if(M!==null){const ee=M.array;G=M.version;for(let Q=0,oe=ee.length;Q<oe;Q+=3){const _e=ee[Q+0],ve=ee[Q+1],Oe=ee[Q+2];y.push(_e,ve,ve,Oe,Oe,_e)}}else if(T!==void 0){const ee=T.array;G=T.version;for(let Q=0,oe=ee.length/3-1;Q<oe;Q+=3){const _e=Q+0,ve=Q+1,Oe=Q+2;y.push(_e,ve,ve,Oe,Oe,_e)}}else return;const z=new(sp(y)?pc:ka)(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 EB(r,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){r.drawElements(n,M,o,y*a),t.update(M,n,1)}function d(y,M,T){T!==0&&(r.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 ee=0;ee<T;ee++)I+=M[ee]*G[ee];t.update(I,n,1)}}this.setMode=s,this.setIndex=c,this.render=u,this.renderInstances=d,this.renderMultiDraw=p,this.renderMultiDrawInstances=m}function AB(r){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 r.TRIANGLES:t.triangles+=c*(o/3);break;case r.LINES:t.lines+=c*(o/2);break;case r.LINE_STRIP:t.lines+=c*(o-1);break;case r.LINE_LOOP:t.lines+=c*o;break;case r.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 CB(r,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 Ce=function(){Oe.dispose(),n.delete(c),c.removeEventListener("dispose",Ce)};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||[],ee=c.morphAttributes.color||[];let Q=0;M===!0&&(Q=1),T===!0&&(Q=2),G===!0&&(Q=3);let oe=c.attributes.position.count*Q,_e=1;oe>e.maxTextureSize&&(_e=Math.ceil(oe/e.maxTextureSize),oe=e.maxTextureSize);const ve=new Float32Array(oe*_e*4*m),Oe=new Jd(ve,oe,_e,m);Oe.type=gs,Oe.needsUpdate=!0;const He=Q*4;for(let Be=0;Be<m;Be++){const ft=z[Be],zt=I[Be],tn=ee[Be],cn=oe*_e*4*Be;for(let vn=0;vn<ft.count;vn++){const mn=vn*He;M===!0&&(s.fromBufferAttribute(ft,vn),ve[cn+mn+0]=s.x,ve[cn+mn+1]=s.y,ve[cn+mn+2]=s.z,ve[cn+mn+3]=0),T===!0&&(s.fromBufferAttribute(zt,vn),ve[cn+mn+4]=s.x,ve[cn+mn+5]=s.y,ve[cn+mn+6]=s.z,ve[cn+mn+7]=0),G===!0&&(s.fromBufferAttribute(tn,vn),ve[cn+mn+8]=s.x,ve[cn+mn+9]=s.y,ve[cn+mn+10]=s.z,ve[cn+mn+11]=tn.itemSize===4?s.w:1)}}y={count:m,texture:Oe,size:new yn(oe,_e)},n.set(c,y),c.addEventListener("dispose",Ce)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)u.getUniforms().setValue(r,"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(r,"morphTargetBaseInfluence",T),u.getUniforms().setValue(r,"morphTargetInfluences",d)}u.getUniforms().setValue(r,"morphTargetsTexture",y.texture,t),u.getUniforms().setValue(r,"morphTargetsTextureSize",y.size)}return{update:o}}function RB(r,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,r.ARRAY_BUFFER),u.instanceColor!==null&&t.update(u.instanceColor,r.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 mA=new Wo,gA=new gc(1,1),yA=new Jd,vA=new xl,xA=new ph,_A=[],bA=[],wA=new Float32Array(16),MA=new Float32Array(9),SA=new Float32Array(4);function Fg(r,e,t){const n=r[0];if(n<=0||n>0)return r;const s=e*t;let o=_A[s];if(o===void 0&&(o=new Float32Array(s),_A[s]=o),e!==0){n.toArray(o,0);for(let a=1,c=0;a!==e;++a)c+=t,r[a].toArray(o,c)}return o}function dl(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function fl(r,e){for(let t=0,n=e.length;t<n;t++)r[t]=e[t]}function d_(r,e){let t=bA[e];t===void 0&&(t=new Int32Array(e),bA[e]=t);for(let n=0;n!==e;++n)t[n]=r.allocateTextureUnit();return t}function NB(r,e){const t=this.cache;t[0]!==e&&(r.uniform1f(this.addr,e),t[0]=e)}function PB(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dl(t,e))return;r.uniform2fv(this.addr,e),fl(t,e)}}function IB(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(r.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(dl(t,e))return;r.uniform3fv(this.addr,e),fl(t,e)}}function LB(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dl(t,e))return;r.uniform4fv(this.addr,e),fl(t,e)}}function DB(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(dl(t,e))return;r.uniformMatrix2fv(this.addr,!1,e),fl(t,e)}else{if(dl(t,n))return;SA.set(n),r.uniformMatrix2fv(this.addr,!1,SA),fl(t,n)}}function OB(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(dl(t,e))return;r.uniformMatrix3fv(this.addr,!1,e),fl(t,e)}else{if(dl(t,n))return;MA.set(n),r.uniformMatrix3fv(this.addr,!1,MA),fl(t,n)}}function FB(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(dl(t,e))return;r.uniformMatrix4fv(this.addr,!1,e),fl(t,e)}else{if(dl(t,n))return;wA.set(n),r.uniformMatrix4fv(this.addr,!1,wA),fl(t,n)}}function BB(r,e){const t=this.cache;t[0]!==e&&(r.uniform1i(this.addr,e),t[0]=e)}function UB(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dl(t,e))return;r.uniform2iv(this.addr,e),fl(t,e)}}function kB(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(dl(t,e))return;r.uniform3iv(this.addr,e),fl(t,e)}}function zB(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dl(t,e))return;r.uniform4iv(this.addr,e),fl(t,e)}}function VB(r,e){const t=this.cache;t[0]!==e&&(r.uniform1ui(this.addr,e),t[0]=e)}function GB(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dl(t,e))return;r.uniform2uiv(this.addr,e),fl(t,e)}}function WB(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(dl(t,e))return;r.uniform3uiv(this.addr,e),fl(t,e)}}function HB(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dl(t,e))return;r.uniform4uiv(this.addr,e),fl(t,e)}}function $B(r,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(r.uniform1i(this.addr,s),n[0]=s);let o;this.type===r.SAMPLER_2D_SHADOW?(gA.compareFunction=ep,o=gA):o=mA,t.setTexture2D(e||o,s)}function jB(r,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(r.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||vA,s)}function XB(r,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(r.uniform1i(this.addr,s),n[0]=s),t.setTextureCube(e||xA,s)}function qB(r,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(r.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||yA,s)}function YB(r){switch(r){case 5126:return NB;case 35664:return PB;case 35665:return IB;case 35666:return LB;case 35674:return DB;case 35675:return OB;case 35676:return FB;case 5124:case 35670:return BB;case 35667:case 35671:return UB;case 35668:case 35672:return kB;case 35669:case 35673:return zB;case 5125:return VB;case 36294:return GB;case 36295:return WB;case 36296:return HB;case 35678:case 36198:case 36298:case 36306:case 35682:return $B;case 35679:case 36299:case 36307:return jB;case 35680:case 36300:case 36308:case 36293:return XB;case 36289:case 36303:case 36311:case 36292:return qB}}function ZB(r,e){r.uniform1fv(this.addr,e)}function KB(r,e){const t=Fg(e,this.size,2);r.uniform2fv(this.addr,t)}function JB(r,e){const t=Fg(e,this.size,3);r.uniform3fv(this.addr,t)}function QB(r,e){const t=Fg(e,this.size,4);r.uniform4fv(this.addr,t)}function eU(r,e){const t=Fg(e,this.size,4);r.uniformMatrix2fv(this.addr,!1,t)}function tU(r,e){const t=Fg(e,this.size,9);r.uniformMatrix3fv(this.addr,!1,t)}function nU(r,e){const t=Fg(e,this.size,16);r.uniformMatrix4fv(this.addr,!1,t)}function iU(r,e){r.uniform1iv(this.addr,e)}function rU(r,e){r.uniform2iv(this.addr,e)}function sU(r,e){r.uniform3iv(this.addr,e)}function oU(r,e){r.uniform4iv(this.addr,e)}function aU(r,e){r.uniform1uiv(this.addr,e)}function lU(r,e){r.uniform2uiv(this.addr,e)}function cU(r,e){r.uniform3uiv(this.addr,e)}function uU(r,e){r.uniform4uiv(this.addr,e)}function hU(r,e,t){const n=this.cache,s=e.length,o=d_(t,s);dl(n,o)||(r.uniform1iv(this.addr,o),fl(n,o));for(let a=0;a!==s;++a)t.setTexture2D(e[a]||mA,o[a])}function dU(r,e,t){const n=this.cache,s=e.length,o=d_(t,s);dl(n,o)||(r.uniform1iv(this.addr,o),fl(n,o));for(let a=0;a!==s;++a)t.setTexture3D(e[a]||vA,o[a])}function fU(r,e,t){const n=this.cache,s=e.length,o=d_(t,s);dl(n,o)||(r.uniform1iv(this.addr,o),fl(n,o));for(let a=0;a!==s;++a)t.setTextureCube(e[a]||xA,o[a])}function pU(r,e,t){const n=this.cache,s=e.length,o=d_(t,s);dl(n,o)||(r.uniform1iv(this.addr,o),fl(n,o));for(let a=0;a!==s;++a)t.setTexture2DArray(e[a]||yA,o[a])}function mU(r){switch(r){case 5126:return ZB;case 35664:return KB;case 35665:return JB;case 35666:return QB;case 35674:return eU;case 35675:return tU;case 35676:return nU;case 5124:case 35670:return iU;case 35667:case 35671:return rU;case 35668:case 35672:return sU;case 35669:case 35673:return oU;case 5125:return aU;case 36294:return lU;case 36295:return cU;case 36296:return uU;case 35678:case 36198:case 36298:case 36306:case 35682:return hU;case 35679:case 36299:case 36307:return dU;case 35680:case 36300:case 36308:case 36293:return fU;case 36289:case 36303:case 36311:case 36292:return pU}}class gU{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=YB(t.type)}}class yU{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=mU(t.type)}}class vU{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 Dw=/(\w+)(\])?(\[|\.)?/g;function TA(r,e){r.seq.push(e),r.map[e.id]=e}function xU(r,e,t){const n=r.name,s=n.length;for(Dw.lastIndex=0;;){const o=Dw.exec(n),a=Dw.lastIndex;let c=o[1];const u=o[2]==="]",d=o[3];if(u&&(c=c|0),d===void 0||d==="["&&a+2===s){TA(t,d===void 0?new gU(c,r,e):new yU(c,r,e));break}else{let m=t.map[c];m===void 0&&(m=new vU(c),TA(t,m)),t=m}}}class f_{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);xU(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 EA(r,e,t){const n=r.createShader(e);return r.shaderSource(n,t),r.compileShader(n),n}const _U=37297;let bU=0;function wU(r,e){const t=r.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 AA=new $r;function MU(r){Ki._getMatrix(AA,Ki.workingColorSpace,r);const e=`mat3( ${AA.elements.map(t=>t.toFixed(4))} )`;switch(Ki.getTransfer(r)){case ah:return[e,"LinearTransferOETF"];case Fi:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",r),[e,"LinearTransferOETF"]}}function CA(r,e,t){const n=r.getShaderParameter(e,r.COMPILE_STATUS),o=(r.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+`
`+wU(r.getShaderSource(e),c)}else return o}function SU(r,e){const t=MU(e);return[`vec4 ${r}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
`)}function TU(r,e){let t;switch(e){case B:t="Linear";break;case ie:t="Reinhard";break;case ct:t="Cineon";break;case Mt:t="ACESFilmic";break;case Yt:t="AgX";break;case en:t="Neutral";break;case ht:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+r+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const p_=new ot;function EU(){Ki.getLuminanceCoefficients(p_);const r=p_.x.toFixed(4),e=p_.y.toFixed(4),t=p_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${r}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
`)}function AU(r){return[r.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",r.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Wy).join(`
`)}function CU(r){const e=[];for(const t in r){const n=r[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
`)}function RU(r,e){const t={},n=r.getProgramParameter(e,r.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){const o=r.getActiveAttrib(e,s),a=o.name;let c=1;o.type===r.FLOAT_MAT2&&(c=2),o.type===r.FLOAT_MAT3&&(c=3),o.type===r.FLOAT_MAT4&&(c=4),t[a]={type:o.type,location:r.getAttribLocation(e,a),locationSize:c}}return t}function Wy(r){return r!==""}function RA(r,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return r.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function NA(r,e){return r.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const NU=/^[ \t]*#include +<([\w\d./]+)>/gm;function Ow(r){return r.replace(NU,IU)}const PU=new Map;function IU(r,e){let t=Ns[e];if(t===void 0){const n=PU.get(e);if(n!==void 0)t=Ns[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 Ow(t)}const LU=/#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 PA(r){return r.replace(LU,DU)}function DU(r,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 IA(r){let e=`precision ${r.precision} float;
precision ${r.precision} int;
precision ${r.precision} sampler2D;
precision ${r.precision} samplerCube;
precision ${r.precision} sampler3D;
precision ${r.precision} sampler2DArray;
precision ${r.precision} sampler2DShadow;
precision ${r.precision} samplerCubeShadow;
precision ${r.precision} sampler2DArrayShadow;
precision ${r.precision} isampler2D;
precision ${r.precision} isampler3D;
precision ${r.precision} isamplerCube;
precision ${r.precision} isampler2DArray;
precision ${r.precision} usampler2D;
precision ${r.precision} usampler3D;
precision ${r.precision} usamplerCube;
precision ${r.precision} usampler2DArray;
`;return r.precision==="highp"?e+=`
#define HIGH_PRECISION`:r.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:r.precision==="lowp"&&(e+=`
#define LOW_PRECISION`),e}function OU(r){let e="SHADOWMAP_TYPE_BASIC";return r.shadowMapType===N?e="SHADOWMAP_TYPE_PCF":r.shadowMapType===L?e="SHADOWMAP_TYPE_PCF_SOFT":r.shadowMapType===P&&(e="SHADOWMAP_TYPE_VSM"),e}function FU(r){let e="ENVMAP_TYPE_CUBE";if(r.envMap)switch(r.envMapMode){case Fe:case Xe:e="ENVMAP_TYPE_CUBE";break;case Ke:e="ENVMAP_TYPE_CUBE_UV";break}return e}function BU(r){let e="ENVMAP_MODE_REFLECTION";if(r.envMap)switch(r.envMapMode){case Xe:e="ENVMAP_MODE_REFRACTION";break}return e}function UU(r){let e="ENVMAP_BLENDING_NONE";if(r.envMap)switch(r.combine){case xt:e="ENVMAP_BLENDING_MULTIPLY";break;case ke:e="ENVMAP_BLENDING_MIX";break;case et:e="ENVMAP_BLENDING_ADD";break}return e}function kU(r){const e=r.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:n,maxMip:t}}function zU(r,e,t,n){const s=r.getContext(),o=t.defines;let a=t.vertexShader,c=t.fragmentShader;const u=OU(t),d=FU(t),p=BU(t),m=UU(t),y=kU(t),M=AU(t),T=CU(o),G=s.createProgram();let z,I,ee=t.glslVersion?"#version "+t.glslVersion+`
`:"";t.isRawShaderMaterial?(z=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T].filter(Wy).join(`
`),z.length>0&&(z+=`
`),I=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T].filter(Wy).join(`
`),I.length>0&&(I+=`
`)):(z=[IA(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(Wy).join(`
`),I=[IA(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?Ns.tonemapping_pars_fragment:"",t.toneMapping!==yt?TU("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ns.colorspace_pars_fragment,SU("linearToOutputTexel",t.outputColorSpace),EU(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
`].filter(Wy).join(`
`)),a=Ow(a),a=RA(a,t),a=NA(a,t),c=Ow(c),c=RA(c,t),c=NA(c,t),a=PA(a),c=PA(c),t.isRawShaderMaterial!==!0&&(ee=`#version 300 es
`,z=[M,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+z,I=["#define varying in",t.glslVersion===M0?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===M0?"":"#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 Q=ee+z+a,oe=ee+I+c,_e=EA(s,s.VERTEX_SHADER,Q),ve=EA(s,s.FRAGMENT_SHADER,oe);s.attachShader(G,_e),s.attachShader(G,ve),t.index0AttributeName!==void 0?s.bindAttribLocation(G,0,t.index0AttributeName):t.morphTargets===!0&&s.bindAttribLocation(G,0,"position"),s.linkProgram(G);function Oe(ft){if(r.debug.checkShaderErrors){const zt=s.getProgramInfoLog(G)||"",tn=s.getShaderInfoLog(_e)||"",cn=s.getShaderInfoLog(ve)||"",vn=zt.trim(),mn=tn.trim(),Yn=cn.trim();let xn=!0,si=!0;if(s.getProgramParameter(G,s.LINK_STATUS)===!1)if(xn=!1,typeof r.debug.onShaderError=="function")r.debug.onShaderError(s,G,_e,ve);else{const wn=CA(s,_e,"vertex"),Gn=CA(s,ve,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(G,s.VALIDATE_STATUS)+`
Material Name: `+ft.name+`
Material Type: `+ft.type+`
Program Info Log: `+vn+`
`+wn+`
`+Gn)}else vn!==""?console.warn("THREE.WebGLProgram: Program Info Log:",vn):(mn===""||Yn==="")&&(si=!1);si&&(ft.diagnostics={runnable:xn,programLog:vn,vertexShader:{log:mn,prefix:z},fragmentShader:{log:Yn,prefix:I}})}s.deleteShader(_e),s.deleteShader(ve),He=new f_(s,G),Ce=RU(s,G)}let He;this.getUniforms=function(){return He===void 0&&Oe(this),He};let Ce;this.getAttributes=function(){return Ce===void 0&&Oe(this),Ce};let Be=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return Be===!1&&(Be=s.getProgramParameter(G,_U)),Be},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(G),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=bU++,this.cacheKey=e,this.usedTimes=1,this.program=G,this.vertexShader=_e,this.fragmentShader=ve,this}let VU=0;class GU{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 WU(e),t.set(e,n)),n}}class WU{constructor(e){this.id=VU++,this.code=e,this.usedTimes=0}}function HU(r,e,t,n,s,o,a){const c=new er,u=new GU,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(Ce){return d.add(Ce),Ce===0?"uv":`uv${Ce}`}function z(Ce,Be,ft,zt,tn){const cn=zt.fog,vn=tn.geometry,mn=Ce.isMeshStandardMaterial?zt.environment:null,Yn=(Ce.isMeshStandardMaterial?t:e).get(Ce.envMap||mn),xn=Yn&&Yn.mapping===Ke?Yn.image.height:null,si=T[Ce.type];Ce.precision!==null&&(M=s.getMaxPrecision(Ce.precision),M!==Ce.precision&&console.warn("THREE.WebGLProgram.getParameters:",Ce.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,ss,Vn,un;if(si){const _o=Ah[si];nr=_o.vertexShader,ss=_o.fragmentShader}else nr=Ce.vertexShader,ss=Ce.fragmentShader,u.update(Ce),Vn=u.getVertexShaderID(Ce),un=u.getFragmentShaderID(Ce);const Mn=r.getRenderTarget(),fi=r.state.buffers.depth.getReversed(),ki=tn.isInstancedMesh===!0,Ni=tn.isBatchedMesh===!0,Cr=!!Ce.map,zs=!!Ce.matcap,Vt=!!Yn,Kn=!!Ce.aoMap,Zn=!!Ce.lightMap,qn=!!Ce.bumpMap,Hn=!!Ce.normalMap,Ti=!!Ce.displacementMap,pi=!!Ce.emissiveMap,Ii=!!Ce.metalnessMap,bs=!!Ce.roughnessMap,ps=Ce.anisotropy>0,St=Ce.clearcoat>0,nt=Ce.dispersion>0,fn=Ce.iridescence>0,Dn=Ce.sheen>0,ri=Ce.transmission>0,zn=ps&&!!Ce.anisotropyMap,Rr=St&&!!Ce.clearcoatMap,Ci=St&&!!Ce.clearcoatNormalMap,Tr=St&&!!Ce.clearcoatRoughnessMap,Er=fn&&!!Ce.iridescenceMap,mi=fn&&!!Ce.iridescenceThicknessMap,Yi=Dn&&!!Ce.sheenColorMap,ts=Dn&&!!Ce.sheenRoughnessMap,Pr=!!Ce.specularMap,Hi=!!Ce.specularColorMap,Rs=!!Ce.specularIntensityMap,rn=ri&&!!Ce.transmissionMap,wi=ri&&!!Ce.thicknessMap,Di=!!Ce.gradientMap,pr=!!Ce.alphaMap,gi=Ce.alphaTest>0,Jn=!!Ce.alphaHash,Ar=!!Ce.extensions;let ws=yt;Ce.toneMapped&&(Mn===null||Mn.isXRRenderTarget===!0)&&(ws=r.toneMapping);const Go={shaderID:si,shaderType:Ce.type,shaderName:Ce.name,vertexShader:nr,fragmentShader:ss,defines:Ce.defines,customVertexShaderID:Vn,customFragmentShaderID:un,isRawShaderMaterial:Ce.isRawShaderMaterial===!0,glslVersion:Ce.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?r.outputColorSpace:Mn.isXRRenderTarget===!0?Mn.texture.colorSpace:iu,alphaToCoverage:!!Ce.alphaToCoverage,map:Cr,matcap:zs,envMap:Vt,envMapMode:Vt&&Yn.mapping,envMapCubeUVHeight:xn,aoMap:Kn,lightMap:Zn,bumpMap:qn,normalMap:Hn,displacementMap:y&&Ti,emissiveMap:pi,normalMapObjectSpace:Hn&&Ce.normalMapType===jd,normalMapTangentSpace:Hn&&Ce.normalMapType===$a,metalnessMap:Ii,roughnessMap:bs,anisotropy:ps,anisotropyMap:zn,clearcoat:St,clearcoatMap:Rr,clearcoatNormalMap:Ci,clearcoatRoughnessMap:Tr,dispersion:nt,iridescence:fn,iridescenceMap:Er,iridescenceThicknessMap:mi,sheen:Dn,sheenColorMap:Yi,sheenRoughnessMap:ts,specularMap:Pr,specularColorMap:Hi,specularIntensityMap:Rs,transmission:ri,transmissionMap:rn,thicknessMap:wi,gradientMap:Di,opaque:Ce.transparent===!1&&Ce.blending===ge&&Ce.alphaToCoverage===!1,alphaMap:pr,alphaTest:gi,alphaHash:Jn,combine:Ce.combine,mapUv:Cr&&G(Ce.map.channel),aoMapUv:Kn&&G(Ce.aoMap.channel),lightMapUv:Zn&&G(Ce.lightMap.channel),bumpMapUv:qn&&G(Ce.bumpMap.channel),normalMapUv:Hn&&G(Ce.normalMap.channel),displacementMapUv:Ti&&G(Ce.displacementMap.channel),emissiveMapUv:pi&&G(Ce.emissiveMap.channel),metalnessMapUv:Ii&&G(Ce.metalnessMap.channel),roughnessMapUv:bs&&G(Ce.roughnessMap.channel),anisotropyMapUv:zn&&G(Ce.anisotropyMap.channel),clearcoatMapUv:Rr&&G(Ce.clearcoatMap.channel),clearcoatNormalMapUv:Ci&&G(Ce.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Tr&&G(Ce.clearcoatRoughnessMap.channel),iridescenceMapUv:Er&&G(Ce.iridescenceMap.channel),iridescenceThicknessMapUv:mi&&G(Ce.iridescenceThicknessMap.channel),sheenColorMapUv:Yi&&G(Ce.sheenColorMap.channel),sheenRoughnessMapUv:ts&&G(Ce.sheenRoughnessMap.channel),specularMapUv:Pr&&G(Ce.specularMap.channel),specularColorMapUv:Hi&&G(Ce.specularColorMap.channel),specularIntensityMapUv:Rs&&G(Ce.specularIntensityMap.channel),transmissionMapUv:rn&&G(Ce.transmissionMap.channel),thicknessMapUv:wi&&G(Ce.thicknessMap.channel),alphaMapUv:pr&&G(Ce.alphaMap.channel),vertexTangents:!!vn.attributes.tangent&&(Hn||ps),vertexColors:Ce.vertexColors,vertexAlphas:Ce.vertexColors===!0&&!!vn.attributes.color&&vn.attributes.color.itemSize===4,pointsUvs:tn.isPoints===!0&&!!vn.attributes.uv&&(Cr||pr),fog:!!cn,useFog:Ce.fog===!0,fogExp2:!!cn&&cn.isFogExp2,flatShading:Ce.flatShading===!0&&Ce.wireframe===!1,sizeAttenuation:Ce.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:Be.directional.length,numPointLights:Be.point.length,numSpotLights:Be.spot.length,numSpotLightMaps:Be.spotLightMap.length,numRectAreaLights:Be.rectArea.length,numHemiLights:Be.hemi.length,numDirLightShadows:Be.directionalShadowMap.length,numPointLightShadows:Be.pointShadowMap.length,numSpotLightShadows:Be.spotShadowMap.length,numSpotLightShadowsWithMaps:Be.numSpotLightShadowsWithMaps,numLightProbes:Be.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:Ce.dithering,shadowMapEnabled:r.shadowMap.enabled&&ft.length>0,shadowMapType:r.shadowMap.type,toneMapping:ws,decodeVideoTexture:Cr&&Ce.map.isVideoTexture===!0&&Ki.getTransfer(Ce.map.colorSpace)===Fi,decodeVideoTextureEmissive:pi&&Ce.emissiveMap.isVideoTexture===!0&&Ki.getTransfer(Ce.emissiveMap.colorSpace)===Fi,premultipliedAlpha:Ce.premultipliedAlpha,doubleSided:Ce.side===re,flipSided:Ce.side===K,useDepthPacking:Ce.depthPacking>=0,depthPacking:Ce.depthPacking||0,index0AttributeName:Ce.index0AttributeName,extensionClipCullDistance:Ar&&Ce.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ar&&Ce.extensions.multiDraw===!0||Ni)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:Ce.customProgramCacheKey()};return Go.vertexUv1s=d.has(1),Go.vertexUv2s=d.has(2),Go.vertexUv3s=d.has(3),d.clear(),Go}function I(Ce){const Be=[];if(Ce.shaderID?Be.push(Ce.shaderID):(Be.push(Ce.customVertexShaderID),Be.push(Ce.customFragmentShaderID)),Ce.defines!==void 0)for(const ft in Ce.defines)Be.push(ft),Be.push(Ce.defines[ft]);return Ce.isRawShaderMaterial===!1&&(ee(Be,Ce),Q(Be,Ce),Be.push(r.outputColorSpace)),Be.push(Ce.customProgramCacheKey),Be.join()}function ee(Ce,Be){Ce.push(Be.precision),Ce.push(Be.outputColorSpace),Ce.push(Be.envMapMode),Ce.push(Be.envMapCubeUVHeight),Ce.push(Be.mapUv),Ce.push(Be.alphaMapUv),Ce.push(Be.lightMapUv),Ce.push(Be.aoMapUv),Ce.push(Be.bumpMapUv),Ce.push(Be.normalMapUv),Ce.push(Be.displacementMapUv),Ce.push(Be.emissiveMapUv),Ce.push(Be.metalnessMapUv),Ce.push(Be.roughnessMapUv),Ce.push(Be.anisotropyMapUv),Ce.push(Be.clearcoatMapUv),Ce.push(Be.clearcoatNormalMapUv),Ce.push(Be.clearcoatRoughnessMapUv),Ce.push(Be.iridescenceMapUv),Ce.push(Be.iridescenceThicknessMapUv),Ce.push(Be.sheenColorMapUv),Ce.push(Be.sheenRoughnessMapUv),Ce.push(Be.specularMapUv),Ce.push(Be.specularColorMapUv),Ce.push(Be.specularIntensityMapUv),Ce.push(Be.transmissionMapUv),Ce.push(Be.thicknessMapUv),Ce.push(Be.combine),Ce.push(Be.fogExp2),Ce.push(Be.sizeAttenuation),Ce.push(Be.morphTargetsCount),Ce.push(Be.morphAttributeCount),Ce.push(Be.numDirLights),Ce.push(Be.numPointLights),Ce.push(Be.numSpotLights),Ce.push(Be.numSpotLightMaps),Ce.push(Be.numHemiLights),Ce.push(Be.numRectAreaLights),Ce.push(Be.numDirLightShadows),Ce.push(Be.numPointLightShadows),Ce.push(Be.numSpotLightShadows),Ce.push(Be.numSpotLightShadowsWithMaps),Ce.push(Be.numLightProbes),Ce.push(Be.shadowMapType),Ce.push(Be.toneMapping),Ce.push(Be.numClippingPlanes),Ce.push(Be.numClipIntersection),Ce.push(Be.depthPacking)}function Q(Ce,Be){c.disableAll(),Be.supportsVertexTextures&&c.enable(0),Be.instancing&&c.enable(1),Be.instancingColor&&c.enable(2),Be.instancingMorph&&c.enable(3),Be.matcap&&c.enable(4),Be.envMap&&c.enable(5),Be.normalMapObjectSpace&&c.enable(6),Be.normalMapTangentSpace&&c.enable(7),Be.clearcoat&&c.enable(8),Be.iridescence&&c.enable(9),Be.alphaTest&&c.enable(10),Be.vertexColors&&c.enable(11),Be.vertexAlphas&&c.enable(12),Be.vertexUv1s&&c.enable(13),Be.vertexUv2s&&c.enable(14),Be.vertexUv3s&&c.enable(15),Be.vertexTangents&&c.enable(16),Be.anisotropy&&c.enable(17),Be.alphaHash&&c.enable(18),Be.batching&&c.enable(19),Be.dispersion&&c.enable(20),Be.batchingColor&&c.enable(21),Be.gradientMap&&c.enable(22),Ce.push(c.mask),c.disableAll(),Be.fog&&c.enable(0),Be.useFog&&c.enable(1),Be.flatShading&&c.enable(2),Be.logarithmicDepthBuffer&&c.enable(3),Be.reversedDepthBuffer&&c.enable(4),Be.skinning&&c.enable(5),Be.morphTargets&&c.enable(6),Be.morphNormals&&c.enable(7),Be.morphColors&&c.enable(8),Be.premultipliedAlpha&&c.enable(9),Be.shadowMapEnabled&&c.enable(10),Be.doubleSided&&c.enable(11),Be.flipSided&&c.enable(12),Be.useDepthPacking&&c.enable(13),Be.dithering&&c.enable(14),Be.transmission&&c.enable(15),Be.sheen&&c.enable(16),Be.opaque&&c.enable(17),Be.pointsUvs&&c.enable(18),Be.decodeVideoTexture&&c.enable(19),Be.decodeVideoTextureEmissive&&c.enable(20),Be.alphaToCoverage&&c.enable(21),Ce.push(c.mask)}function oe(Ce){const Be=T[Ce.type];let ft;if(Be){const zt=Ah[Be];ft=ap.clone(zt.uniforms)}else ft=Ce.uniforms;return ft}function _e(Ce,Be){let ft;for(let zt=0,tn=p.length;zt<tn;zt++){const cn=p[zt];if(cn.cacheKey===Be){ft=cn,++ft.usedTimes;break}}return ft===void 0&&(ft=new zU(r,Be,Ce,o),p.push(ft)),ft}function ve(Ce){if(--Ce.usedTimes===0){const Be=p.indexOf(Ce);p[Be]=p[p.length-1],p.pop(),Ce.destroy()}}function Oe(Ce){u.remove(Ce)}function He(){u.dispose()}return{getParameters:z,getProgramCacheKey:I,getUniforms:oe,acquireProgram:_e,releaseProgram:ve,releaseShaderCache:Oe,programs:p,dispose:He}}function $U(){let r=new WeakMap;function e(a){return r.has(a)}function t(a){let c=r.get(a);return c===void 0&&(c={},r.set(a,c)),c}function n(a){r.delete(a)}function s(a,c,u){r.get(a)[c]=u}function o(){r=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:o}}function jU(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.z!==e.z?r.z-e.z:r.id-e.id}function LA(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function DA(){const r=[];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=r[e];return I===void 0?(I={id:m.id,object:m,geometry:y,material:M,groupOrder:T,renderOrder:m.renderOrder,z:G,group:z},r[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||jU),n.length>1&&n.sort(y||LA),s.length>1&&s.sort(y||LA)}function p(){for(let m=e,y=r.length;m<y;m++){const M=r[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 XU(){let r=new WeakMap;function e(n,s){const o=r.get(n);let a;return o===void 0?(a=new DA,r.set(n,[a])):s>=o.length?(a=new DA,o.push(a)):a=o[s],a}function t(){r=new WeakMap}return{get:e,dispose:t}}function qU(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new ot,color:new jn};break;case"SpotLight":t={position:new ot,direction:new ot,color:new jn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new ot,color:new jn,distance:0,decay:0};break;case"HemisphereLight":t={direction:new ot,skyColor:new jn,groundColor:new jn};break;case"RectAreaLight":t={color:new jn,position:new ot,halfWidth:new ot,halfHeight:new ot};break}return r[e.id]=t,t}}}function YU(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[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 r[e.id]=t,t}}}let ZU=0;function KU(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function JU(r){const e=new qU,t=YU(),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 ot);const s=new ot,o=new Ft,a=new Ft;function c(d){let p=0,m=0,y=0;for(let Ce=0;Ce<9;Ce++)n.probe[Ce].set(0,0,0);let M=0,T=0,G=0,z=0,I=0,ee=0,Q=0,oe=0,_e=0,ve=0,Oe=0;d.sort(KU);for(let Ce=0,Be=d.length;Ce<Be;Ce++){const ft=d[Ce],zt=ft.color,tn=ft.intensity,cn=ft.distance,vn=ft.shadow&&ft.shadow.map?ft.shadow.map.texture:null;if(ft.isAmbientLight)p+=zt.r*tn,m+=zt.g*tn,y+=zt.b*tn;else if(ft.isLightProbe){for(let mn=0;mn<9;mn++)n.probe[mn].addScaledVector(ft.sh.coefficients[mn],tn);Oe++}else if(ft.isDirectionalLight){const mn=e.get(ft);if(mn.color.copy(ft.color).multiplyScalar(ft.intensity),ft.castShadow){const Yn=ft.shadow,xn=t.get(ft);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]=ft.shadow.matrix,ee++}n.directional[M]=mn,M++}else if(ft.isSpotLight){const mn=e.get(ft);mn.position.setFromMatrixPosition(ft.matrixWorld),mn.color.copy(zt).multiplyScalar(tn),mn.distance=cn,mn.coneCos=Math.cos(ft.angle),mn.penumbraCos=Math.cos(ft.angle*(1-ft.penumbra)),mn.decay=ft.decay,n.spot[G]=mn;const Yn=ft.shadow;if(ft.map&&(n.spotLightMap[_e]=ft.map,_e++,Yn.updateMatrices(ft),ft.castShadow&&ve++),n.spotLightMatrix[G]=Yn.matrix,ft.castShadow){const xn=t.get(ft);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,oe++}G++}else if(ft.isRectAreaLight){const mn=e.get(ft);mn.color.copy(zt).multiplyScalar(tn),mn.halfWidth.set(ft.width*.5,0,0),mn.halfHeight.set(0,ft.height*.5,0),n.rectArea[z]=mn,z++}else if(ft.isPointLight){const mn=e.get(ft);if(mn.color.copy(ft.color).multiplyScalar(ft.intensity),mn.distance=ft.distance,mn.decay=ft.decay,ft.castShadow){const Yn=ft.shadow,xn=t.get(ft);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]=ft.shadow.matrix,Q++}n.point[T]=mn,T++}else if(ft.isHemisphereLight){const mn=e.get(ft);mn.skyColor.copy(ft.color).multiplyScalar(tn),mn.groundColor.copy(ft.groundColor).multiplyScalar(tn),n.hemi[I]=mn,I++}}z>0&&(r.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 He=n.hash;(He.directionalLength!==M||He.pointLength!==T||He.spotLength!==G||He.rectAreaLength!==z||He.hemiLength!==I||He.numDirectionalShadows!==ee||He.numPointShadows!==Q||He.numSpotShadows!==oe||He.numSpotMaps!==_e||He.numLightProbes!==Oe)&&(n.directional.length=M,n.spot.length=G,n.rectArea.length=z,n.point.length=T,n.hemi.length=I,n.directionalShadow.length=ee,n.directionalShadowMap.length=ee,n.pointShadow.length=Q,n.pointShadowMap.length=Q,n.spotShadow.length=oe,n.spotShadowMap.length=oe,n.directionalShadowMatrix.length=ee,n.pointShadowMatrix.length=Q,n.spotLightMatrix.length=oe+_e-ve,n.spotLightMap.length=_e,n.numSpotLightShadowsWithMaps=ve,n.numLightProbes=Oe,He.directionalLength=M,He.pointLength=T,He.spotLength=G,He.rectAreaLength=z,He.hemiLength=I,He.numDirectionalShadows=ee,He.numPointShadows=Q,He.numSpotShadows=oe,He.numSpotMaps=_e,He.numLightProbes=Oe,n.version=ZU++)}function u(d,p){let m=0,y=0,M=0,T=0,G=0;const z=p.matrixWorldInverse;for(let I=0,ee=d.length;I<ee;I++){const Q=d[I];if(Q.isDirectionalLight){const oe=n.directional[m];oe.direction.setFromMatrixPosition(Q.matrixWorld),s.setFromMatrixPosition(Q.target.matrixWorld),oe.direction.sub(s),oe.direction.transformDirection(z),m++}else if(Q.isSpotLight){const oe=n.spot[M];oe.position.setFromMatrixPosition(Q.matrixWorld),oe.position.applyMatrix4(z),oe.direction.setFromMatrixPosition(Q.matrixWorld),s.setFromMatrixPosition(Q.target.matrixWorld),oe.direction.sub(s),oe.direction.transformDirection(z),M++}else if(Q.isRectAreaLight){const oe=n.rectArea[T];oe.position.setFromMatrixPosition(Q.matrixWorld),oe.position.applyMatrix4(z),a.identity(),o.copy(Q.matrixWorld),o.premultiply(z),a.extractRotation(o),oe.halfWidth.set(Q.width*.5,0,0),oe.halfHeight.set(0,Q.height*.5,0),oe.halfWidth.applyMatrix4(a),oe.halfHeight.applyMatrix4(a),T++}else if(Q.isPointLight){const oe=n.point[y];oe.position.setFromMatrixPosition(Q.matrixWorld),oe.position.applyMatrix4(z),y++}else if(Q.isHemisphereLight){const oe=n.hemi[G];oe.direction.setFromMatrixPosition(Q.matrixWorld),oe.direction.transformDirection(z),G++}}}return{setup:c,setupView:u,state:n}}function OA(r){const e=new JU(r),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 QU(r){let e=new WeakMap;function t(s,o=0){const a=e.get(s);let c;return a===void 0?(c=new OA(r),e.set(s,[c])):o>=a.length?(c=new OA(r),a.push(c)):c=a[o],c}function n(){e=new WeakMap}return{get:t,dispose:n}}const ek=`void main() {
gl_Position = vec4( position, 1.0 );
}`,tk=`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 nk(r,e,t){let n=new lf;const s=new yn,o=new yn,a=new mr,c=new Nx({depthPacking:Qf}),u=new Px,d={},p=t.maxTextureSize,m={[W]:K,[K]:W,[re]:re},y=new Bc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new yn},radius:{value:4}},vertexShader:ek,fragmentShader:tk}),M=y.clone();M.defines.HORIZONTAL_PASS=1;const T=new xr;T.setAttribute("position",new Qr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const G=new Zs(T,y),z=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=N;let I=this.type;this.render=function(ve,Oe,He){if(z.enabled===!1||z.autoUpdate===!1&&z.needsUpdate===!1||ve.length===0)return;const Ce=r.getRenderTarget(),Be=r.getActiveCubeFace(),ft=r.getActiveMipmapLevel(),zt=r.state;zt.setBlending(ye),zt.buffers.depth.getReversed()===!0?zt.buffers.color.setClear(0,0,0,0):zt.buffers.color.setClear(1,1,1,1),zt.buffers.depth.setTest(!0),zt.setScissorTest(!1);const tn=I!==P&&this.type===P,cn=I===P&&this.type!==P;for(let vn=0,mn=ve.length;vn<mn;vn++){const Yn=ve[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 cc(s.x,s.y,Gn),xn.map.texture.name=Yn.name+".shadowMap",xn.camera.updateProjectionMatrix()}r.setRenderTarget(xn.map),r.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),zt.viewport(a),xn.updateMatrices(Yn,Gn),n=xn.getFrustum(),oe(Oe,He,xn.camera,Yn,this.type)}xn.isPointLightShadow!==!0&&this.type===P&&ee(xn,He),xn.needsUpdate=!1}I=this.type,z.needsUpdate=!1,r.setRenderTarget(Ce,Be,ft)};function ee(ve,Oe){const He=e.update(G);y.defines.VSM_SAMPLES!==ve.blurSamples&&(y.defines.VSM_SAMPLES=ve.blurSamples,M.defines.VSM_SAMPLES=ve.blurSamples,y.needsUpdate=!0,M.needsUpdate=!0),ve.mapPass===null&&(ve.mapPass=new cc(s.x,s.y)),y.uniforms.shadow_pass.value=ve.map.texture,y.uniforms.resolution.value=ve.mapSize,y.uniforms.radius.value=ve.radius,r.setRenderTarget(ve.mapPass),r.clear(),r.renderBufferDirect(Oe,null,He,y,G,null),M.uniforms.shadow_pass.value=ve.mapPass.texture,M.uniforms.resolution.value=ve.mapSize,M.uniforms.radius.value=ve.radius,r.setRenderTarget(ve.map),r.clear(),r.renderBufferDirect(Oe,null,He,M,G,null)}function Q(ve,Oe,He,Ce){let Be=null;const ft=He.isPointLight===!0?ve.customDistanceMaterial:ve.customDepthMaterial;if(ft!==void 0)Be=ft;else if(Be=He.isPointLight===!0?u:c,r.localClippingEnabled&&Oe.clipShadows===!0&&Array.isArray(Oe.clippingPlanes)&&Oe.clippingPlanes.length!==0||Oe.displacementMap&&Oe.displacementScale!==0||Oe.alphaMap&&Oe.alphaTest>0||Oe.map&&Oe.alphaTest>0||Oe.alphaToCoverage===!0){const zt=Be.uuid,tn=Oe.uuid;let cn=d[zt];cn===void 0&&(cn={},d[zt]=cn);let vn=cn[tn];vn===void 0&&(vn=Be.clone(),cn[tn]=vn,Oe.addEventListener("dispose",_e)),Be=vn}if(Be.visible=Oe.visible,Be.wireframe=Oe.wireframe,Ce===P?Be.side=Oe.shadowSide!==null?Oe.shadowSide:Oe.side:Be.side=Oe.shadowSide!==null?Oe.shadowSide:m[Oe.side],Be.alphaMap=Oe.alphaMap,Be.alphaTest=Oe.alphaToCoverage===!0?.5:Oe.alphaTest,Be.map=Oe.map,Be.clipShadows=Oe.clipShadows,Be.clippingPlanes=Oe.clippingPlanes,Be.clipIntersection=Oe.clipIntersection,Be.displacementMap=Oe.displacementMap,Be.displacementScale=Oe.displacementScale,Be.displacementBias=Oe.displacementBias,Be.wireframeLinewidth=Oe.wireframeLinewidth,Be.linewidth=Oe.linewidth,He.isPointLight===!0&&Be.isMeshDistanceMaterial===!0){const zt=r.properties.get(Be);zt.light=He}return Be}function oe(ve,Oe,He,Ce,Be){if(ve.visible===!1)return;if(ve.layers.test(Oe.layers)&&(ve.isMesh||ve.isLine||ve.isPoints)&&(ve.castShadow||ve.receiveShadow&&Be===P)&&(!ve.frustumCulled||n.intersectsObject(ve))){ve.modelViewMatrix.multiplyMatrices(He.matrixWorldInverse,ve.matrixWorld);const tn=e.update(ve),cn=ve.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=Q(ve,si,Ce,Be);ve.onBeforeShadow(r,ve,Oe,He,tn,wn,xn),r.renderBufferDirect(He,null,tn,wn,ve,xn),ve.onAfterShadow(r,ve,Oe,He,tn,wn,xn)}}}else if(cn.visible){const vn=Q(ve,cn,Ce,Be);ve.onBeforeShadow(r,ve,Oe,He,tn,vn,null),r.renderBufferDirect(He,null,tn,vn,ve,null),ve.onAfterShadow(r,ve,Oe,He,tn,vn,null)}}const zt=ve.children;for(let tn=0,cn=zt.length;tn<cn;tn++)oe(zt[tn],Oe,He,Ce,Be)}function _e(ve){ve.target.removeEventListener("dispose",_e);for(const He in d){const Ce=d[He],Be=ve.target.uuid;Be in Ce&&(Ce[Be].dispose(),delete Ce[Be])}}}const ik={[ze]:Ze,[q]:Te,[de]:$e,[Y]:Je,[Ze]:ze,[Te]:q,[$e]:de,[Je]:Y};function rk(r,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&&(r.colorMask(gi,gi,gi,gi),Di=gi)},setLocked:function(gi){rn=gi},setClear:function(gi,Jn,Ar,ws,Go){Go===!0&&(gi*=ws,Jn*=ws,Ar*=ws),wi.set(gi,Jn,Ar,ws),pr.equals(wi)===!1&&(r.clearColor(gi,Jn,Ar,ws),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 ws=gi;gi=null,this.setClear(ws)}},getReversed:function(){return wi},setTest:function(Jn){Jn?Mn(r.DEPTH_TEST):fi(r.DEPTH_TEST)},setMask:function(Jn){Di!==Jn&&!rn&&(r.depthMask(Jn),Di=Jn)},setFunc:function(Jn){if(wi&&(Jn=ik[Jn]),pr!==Jn){switch(Jn){case ze:r.depthFunc(r.NEVER);break;case Ze:r.depthFunc(r.ALWAYS);break;case q:r.depthFunc(r.LESS);break;case Y:r.depthFunc(r.LEQUAL);break;case de:r.depthFunc(r.EQUAL);break;case Je:r.depthFunc(r.GEQUAL);break;case Te:r.depthFunc(r.GREATER);break;case $e:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}pr=Jn}},setLocked:function(Jn){rn=Jn},setClear:function(Jn){gi!==Jn&&(wi&&(Jn=1-Jn),r.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,ws=null,Go=null;return{setTest:function(_o){rn||(_o?Mn(r.STENCIL_TEST):fi(r.STENCIL_TEST))},setMask:function(_o){wi!==_o&&!rn&&(r.stencilMask(_o),wi=_o)},setFunc:function(_o,$d,jh){(Di!==_o||pr!==$d||gi!==jh)&&(r.stencilFunc(_o,$d,jh),Di=_o,pr=$d,gi=jh)},setOp:function(_o,$d,jh){(Jn!==_o||Ar!==$d||ws!==jh)&&(r.stencilOp(_o,$d,jh),Jn=_o,Ar=$d,ws=jh)},setLocked:function(_o){rn=_o},setClear:function(_o){Go!==_o&&(r.clearStencil(_o),Go=_o)},reset:function(){rn=!1,wi=null,Di=null,pr=null,gi=null,Jn=null,Ar=null,ws=null,Go=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,ee=null,Q=null,oe=null,_e=null,ve=null,Oe=new jn(0,0,0),He=0,Ce=!1,Be=null,ft=null,zt=null,tn=null,cn=null;const vn=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let mn=!1,Yn=0;const xn=r.getParameter(r.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=r.getParameter(r.SCISSOR_BOX),Si=r.getParameter(r.VIEWPORT),nr=new mr().fromArray(Gn),ss=new mr().fromArray(Si);function Vn(rn,wi,Di,pr){const gi=new Uint8Array(4),Jn=r.createTexture();r.bindTexture(rn,Jn),r.texParameteri(rn,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(rn,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let Ar=0;Ar<Di;Ar++)rn===r.TEXTURE_3D||rn===r.TEXTURE_2D_ARRAY?r.texImage3D(wi,0,r.RGBA,1,1,pr,0,r.RGBA,r.UNSIGNED_BYTE,gi):r.texImage2D(wi+Ar,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,gi);return Jn}const un={};un[r.TEXTURE_2D]=Vn(r.TEXTURE_2D,r.TEXTURE_2D,1),un[r.TEXTURE_CUBE_MAP]=Vn(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),un[r.TEXTURE_2D_ARRAY]=Vn(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),un[r.TEXTURE_3D]=Vn(r.TEXTURE_3D,r.TEXTURE_3D,1,1),o.setClear(0,0,0,1),a.setClear(1),c.setClear(0),Mn(r.DEPTH_TEST),a.setFunc(Y),qn(!1),Hn(S),Mn(r.CULL_FACE),Kn(ye);function Mn(rn){p[rn]!==!0&&(r.enable(rn),p[rn]=!0)}function fi(rn){p[rn]!==!1&&(r.disable(rn),p[rn]=!1)}function ki(rn,wi){return m[rn]!==wi?(r.bindFramebuffer(rn,wi),m[rn]=wi,rn===r.DRAW_FRAMEBUFFER&&(m[r.FRAMEBUFFER]=wi),rn===r.FRAMEBUFFER&&(m[r.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]!==r.COLOR_ATTACHMENT0){for(let Jn=0,Ar=gi.length;Jn<Ar;Jn++)Di[Jn]=r.COLOR_ATTACHMENT0+Jn;Di.length=gi.length,pr=!0}}else Di[0]!==r.BACK&&(Di[0]=r.BACK,pr=!0);pr&&r.drawBuffers(Di)}function Cr(rn){return T!==rn?(r.useProgram(rn),T=rn,!0):!1}const zs={[Ae]:r.FUNC_ADD,[be]:r.FUNC_SUBTRACT,[Ye]:r.FUNC_REVERSE_SUBTRACT};zs[Ee]=r.MIN,zs[We]=r.MAX;const Vt={[je]:r.ZERO,[_t]:r.ONE,[It]:r.SRC_COLOR,[Ut]:r.SRC_ALPHA,[vt]:r.SRC_ALPHA_SATURATE,[ue]:r.DST_COLOR,[at]:r.DST_ALPHA,[kt]:r.ONE_MINUS_SRC_COLOR,[At]:r.ONE_MINUS_SRC_ALPHA,[Ue]:r.ONE_MINUS_DST_COLOR,[Ot]:r.ONE_MINUS_DST_ALPHA,[Jt]:r.CONSTANT_COLOR,[Qe]:r.ONE_MINUS_CONSTANT_COLOR,[rt]:r.CONSTANT_ALPHA,[bt]:r.ONE_MINUS_CONSTANT_ALPHA};function Kn(rn,wi,Di,pr,gi,Jn,Ar,ws,Go,_o){if(rn===ye){G===!0&&(fi(r.BLEND),G=!1);return}if(G===!1&&(Mn(r.BLEND),G=!0),rn!==Ne){if(rn!==z||_o!==Ce){if((I!==Ae||oe!==Ae)&&(r.blendEquation(r.FUNC_ADD),I=Ae,oe=Ae),_o)switch(rn){case ge:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case ce:r.blendFunc(r.ONE,r.ONE);break;case xe:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case fe:r.blendFuncSeparate(r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ZERO,r.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",rn);break}else switch(rn){case ge:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case ce:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE,r.ONE,r.ONE);break;case xe:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case fe:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",rn);break}ee=null,Q=null,_e=null,ve=null,Oe.set(0,0,0),He=0,z=rn,Ce=_o}return}gi=gi||wi,Jn=Jn||Di,Ar=Ar||pr,(wi!==I||gi!==oe)&&(r.blendEquationSeparate(zs[wi],zs[gi]),I=wi,oe=gi),(Di!==ee||pr!==Q||Jn!==_e||Ar!==ve)&&(r.blendFuncSeparate(Vt[Di],Vt[pr],Vt[Jn],Vt[Ar]),ee=Di,Q=pr,_e=Jn,ve=Ar),(ws.equals(Oe)===!1||Go!==He)&&(r.blendColor(ws.r,ws.g,ws.b,Go),Oe.copy(ws),He=Go),z=rn,Ce=!1}function Zn(rn,wi){rn.side===re?fi(r.CULL_FACE):Mn(r.CULL_FACE);let Di=rn.side===K;wi&&(Di=!Di),qn(Di),rn.blending===ge&&rn.transparent===!1?Kn(ye):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(r.SAMPLE_ALPHA_TO_COVERAGE):fi(r.SAMPLE_ALPHA_TO_COVERAGE)}function qn(rn){Be!==rn&&(rn?r.frontFace(r.CW):r.frontFace(r.CCW),Be=rn)}function Hn(rn){rn!==A?(Mn(r.CULL_FACE),rn!==ft&&(rn===S?r.cullFace(r.BACK):rn===R?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):fi(r.CULL_FACE),ft=rn}function Ti(rn){rn!==zt&&(mn&&r.lineWidth(rn),zt=rn)}function pi(rn,wi,Di){rn?(Mn(r.POLYGON_OFFSET_FILL),(tn!==wi||cn!==Di)&&(r.polygonOffset(wi,Di),tn=wi,cn=Di)):fi(r.POLYGON_OFFSET_FILL)}function Ii(rn){rn?Mn(r.SCISSOR_TEST):fi(r.SCISSOR_TEST)}function bs(rn){rn===void 0&&(rn=r.TEXTURE0+vn-1),si!==rn&&(r.activeTexture(rn),si=rn)}function ps(rn,wi,Di){Di===void 0&&(si===null?Di=r.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&&(r.activeTexture(Di),si=Di),r.bindTexture(rn,wi||un[rn]),pr.type=rn,pr.texture=wi)}function St(){const rn=wn[si];rn!==void 0&&rn.type!==void 0&&(r.bindTexture(rn.type,null),rn.type=void 0,rn.texture=void 0)}function nt(){try{r.compressedTexImage2D(...arguments)}catch(rn){console.error("THREE.WebGLState:",rn)}}function fn(){try{r.compressedTexImage3D(...arguments)}catch(rn){console.error("THREE.WebGLState:",rn)}}function Dn(){try{r.texSubImage2D(...arguments)}catch(rn){console.error("THREE.WebGLState:",rn)}}function ri(){try{r.texSubImage3D(...arguments)}catch(rn){console.error("THREE.WebGLState:",rn)}}function zn(){try{r.compressedTexSubImage2D(...arguments)}catch(rn){console.error("THREE.WebGLState:",rn)}}function Rr(){try{r.compressedTexSubImage3D(...arguments)}catch(rn){console.error("THREE.WebGLState:",rn)}}function Ci(){try{r.texStorage2D(...arguments)}catch(rn){console.error("THREE.WebGLState:",rn)}}function Tr(){try{r.texStorage3D(...arguments)}catch(rn){console.error("THREE.WebGLState:",rn)}}function Er(){try{r.texImage2D(...arguments)}catch(rn){console.error("THREE.WebGLState:",rn)}}function mi(){try{r.texImage3D(...arguments)}catch(rn){console.error("THREE.WebGLState:",rn)}}function Yi(rn){nr.equals(rn)===!1&&(r.scissor(rn.x,rn.y,rn.z,rn.w),nr.copy(rn))}function ts(rn){ss.equals(rn)===!1&&(r.viewport(rn.x,rn.y,rn.z,rn.w),ss.copy(rn))}function Pr(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=r.getUniformBlockIndex(wi,rn.name),Di.set(rn,pr))}function Hi(rn,wi){const pr=d.get(wi).get(rn);u.get(wi)!==pr&&(r.uniformBlockBinding(wi,pr,rn.__bindingPointIndex),u.set(wi,pr))}function Rs(){r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SCISSOR_TEST),r.disable(r.STENCIL_TEST),r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.ONE,r.ZERO),r.blendFuncSeparate(r.ONE,r.ZERO,r.ONE,r.ZERO),r.blendColor(0,0,0,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(r.LESS),a.setReversed(!1),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(r.ALWAYS,0,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),r.clearStencil(0),r.cullFace(r.BACK),r.frontFace(r.CCW),r.polygonOffset(0,0),r.activeTexture(r.TEXTURE0),r.bindFramebuffer(r.FRAMEBUFFER,null),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(r.READ_FRAMEBUFFER,null),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),p={},si=null,wn={},m={},y=new WeakMap,M=[],T=null,G=!1,z=null,I=null,ee=null,Q=null,oe=null,_e=null,ve=null,Oe=new jn(0,0,0),He=0,Ce=!1,Be=null,ft=null,zt=null,tn=null,cn=null,nr.set(0,0,r.canvas.width,r.canvas.height),ss.set(0,0,r.canvas.width,r.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:bs,bindTexture:ps,unbindTexture:St,compressedTexImage2D:nt,compressedTexImage3D:fn,texImage2D:Er,texImage3D:mi,updateUBOMapping:Pr,uniformBlockBinding:Hi,texStorage2D:Ci,texStorage3D:Tr,texSubImage2D:Dn,texSubImage3D:ri,compressedTexSubImage2D:zn,compressedTexSubImage3D:Rr,scissor:Yi,viewport:ts,reset:Rs}}function sk(r,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(St){}function T(St,nt){return M?new OffscreenCanvas(St,nt):uh("canvas")}function G(St,nt,fn){let Dn=1;const ri=ps(St);if((ri.width>fn||ri.height>fn)&&(Dn=fn/Math.max(ri.width,ri.height)),Dn<1)if(typeof HTMLImageElement!="undefined"&&St instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&St instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&St instanceof ImageBitmap||typeof VideoFrame!="undefined"&&St instanceof VideoFrame){const zn=Math.floor(Dn*ri.width),Rr=Math.floor(Dn*ri.height);m===void 0&&(m=T(zn,Rr));const Ci=nt?T(zn,Rr):m;return Ci.width=zn,Ci.height=Rr,Ci.getContext("2d").drawImage(St,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 St&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+ri.width+"x"+ri.height+")."),St;return St}function z(St){return St.generateMipmaps}function I(St){r.generateMipmap(St)}function ee(St){return St.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:St.isWebGL3DRenderTarget?r.TEXTURE_3D:St.isWebGLArrayRenderTarget||St.isCompressedArrayTexture?r.TEXTURE_2D_ARRAY:r.TEXTURE_2D}function Q(St,nt,fn,Dn,ri=!1){if(St!==null){if(r[St]!==void 0)return r[St];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+St+"'")}let zn=nt;if(nt===r.RED&&(fn===r.FLOAT&&(zn=r.R32F),fn===r.HALF_FLOAT&&(zn=r.R16F),fn===r.UNSIGNED_BYTE&&(zn=r.R8)),nt===r.RED_INTEGER&&(fn===r.UNSIGNED_BYTE&&(zn=r.R8UI),fn===r.UNSIGNED_SHORT&&(zn=r.R16UI),fn===r.UNSIGNED_INT&&(zn=r.R32UI),fn===r.BYTE&&(zn=r.R8I),fn===r.SHORT&&(zn=r.R16I),fn===r.INT&&(zn=r.R32I)),nt===r.RG&&(fn===r.FLOAT&&(zn=r.RG32F),fn===r.HALF_FLOAT&&(zn=r.RG16F),fn===r.UNSIGNED_BYTE&&(zn=r.RG8)),nt===r.RG_INTEGER&&(fn===r.UNSIGNED_BYTE&&(zn=r.RG8UI),fn===r.UNSIGNED_SHORT&&(zn=r.RG16UI),fn===r.UNSIGNED_INT&&(zn=r.RG32UI),fn===r.BYTE&&(zn=r.RG8I),fn===r.SHORT&&(zn=r.RG16I),fn===r.INT&&(zn=r.RG32I)),nt===r.RGB_INTEGER&&(fn===r.UNSIGNED_BYTE&&(zn=r.RGB8UI),fn===r.UNSIGNED_SHORT&&(zn=r.RGB16UI),fn===r.UNSIGNED_INT&&(zn=r.RGB32UI),fn===r.BYTE&&(zn=r.RGB8I),fn===r.SHORT&&(zn=r.RGB16I),fn===r.INT&&(zn=r.RGB32I)),nt===r.RGBA_INTEGER&&(fn===r.UNSIGNED_BYTE&&(zn=r.RGBA8UI),fn===r.UNSIGNED_SHORT&&(zn=r.RGBA16UI),fn===r.UNSIGNED_INT&&(zn=r.RGBA32UI),fn===r.BYTE&&(zn=r.RGBA8I),fn===r.SHORT&&(zn=r.RGBA16I),fn===r.INT&&(zn=r.RGBA32I)),nt===r.RGB&&(fn===r.UNSIGNED_INT_5_9_9_9_REV&&(zn=r.RGB9_E5),fn===r.UNSIGNED_INT_10F_11F_11F_REV&&(zn=r.R11F_G11F_B10F)),nt===r.RGBA){const Rr=ri?ah:Ki.getTransfer(Dn);fn===r.FLOAT&&(zn=r.RGBA32F),fn===r.HALF_FLOAT&&(zn=r.RGBA16F),fn===r.UNSIGNED_BYTE&&(zn=Rr===Fi?r.SRGB8_ALPHA8:r.RGBA8),fn===r.UNSIGNED_SHORT_4_4_4_4&&(zn=r.RGBA4),fn===r.UNSIGNED_SHORT_5_5_5_1&&(zn=r.RGB5_A1)}return(zn===r.R16F||zn===r.R32F||zn===r.RG16F||zn===r.RG32F||zn===r.RGBA16F||zn===r.RGBA32F)&&e.get("EXT_color_buffer_float"),zn}function oe(St,nt){let fn;return St?nt===null||nt===as||nt===Da?fn=r.DEPTH24_STENCIL8:nt===gs?fn=r.DEPTH32F_STENCIL8:nt===ms&&(fn=r.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):nt===null||nt===as||nt===Da?fn=r.DEPTH_COMPONENT24:nt===gs?fn=r.DEPTH_COMPONENT32F:nt===ms&&(fn=r.DEPTH_COMPONENT16),fn}function _e(St,nt){return z(St)===!0||St.isFramebufferTexture&&St.minFilter!==Ct&&St.minFilter!==Rn?Math.log2(Math.max(nt.width,nt.height))+1:St.mipmaps!==void 0&&St.mipmaps.length>0?St.mipmaps.length:St.isCompressedTexture&&Array.isArray(St.image)?nt.mipmaps.length:1}function ve(St){const nt=St.target;nt.removeEventListener("dispose",ve),He(nt),nt.isVideoTexture&&p.delete(nt)}function Oe(St){const nt=St.target;nt.removeEventListener("dispose",Oe),Be(nt)}function He(St){const nt=n.get(St);if(nt.__webglInit===void 0)return;const fn=St.source,Dn=y.get(fn);if(Dn){const ri=Dn[nt.__cacheKey];ri.usedTimes--,ri.usedTimes===0&&Ce(St),Object.keys(Dn).length===0&&y.delete(fn)}n.remove(St)}function Ce(St){const nt=n.get(St);r.deleteTexture(nt.__webglTexture);const fn=St.source,Dn=y.get(fn);delete Dn[nt.__cacheKey],a.memory.textures--}function Be(St){const nt=n.get(St);if(St.depthTexture&&(St.depthTexture.dispose(),n.remove(St.depthTexture)),St.isWebGLCubeRenderTarget)for(let Dn=0;Dn<6;Dn++){if(Array.isArray(nt.__webglFramebuffer[Dn]))for(let ri=0;ri<nt.__webglFramebuffer[Dn].length;ri++)r.deleteFramebuffer(nt.__webglFramebuffer[Dn][ri]);else r.deleteFramebuffer(nt.__webglFramebuffer[Dn]);nt.__webglDepthbuffer&&r.deleteRenderbuffer(nt.__webglDepthbuffer[Dn])}else{if(Array.isArray(nt.__webglFramebuffer))for(let Dn=0;Dn<nt.__webglFramebuffer.length;Dn++)r.deleteFramebuffer(nt.__webglFramebuffer[Dn]);else r.deleteFramebuffer(nt.__webglFramebuffer);if(nt.__webglDepthbuffer&&r.deleteRenderbuffer(nt.__webglDepthbuffer),nt.__webglMultisampledFramebuffer&&r.deleteFramebuffer(nt.__webglMultisampledFramebuffer),nt.__webglColorRenderbuffer)for(let Dn=0;Dn<nt.__webglColorRenderbuffer.length;Dn++)nt.__webglColorRenderbuffer[Dn]&&r.deleteRenderbuffer(nt.__webglColorRenderbuffer[Dn]);nt.__webglDepthRenderbuffer&&r.deleteRenderbuffer(nt.__webglDepthRenderbuffer)}const fn=St.textures;for(let Dn=0,ri=fn.length;Dn<ri;Dn++){const zn=n.get(fn[Dn]);zn.__webglTexture&&(r.deleteTexture(zn.__webglTexture),a.memory.textures--),n.remove(fn[Dn])}n.remove(St)}let ft=0;function zt(){ft=0}function tn(){const St=ft;return St>=s.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+St+" texture units while this GPU supports only "+s.maxTextures),ft+=1,St}function cn(St){const nt=[];return nt.push(St.wrapS),nt.push(St.wrapT),nt.push(St.wrapR||0),nt.push(St.magFilter),nt.push(St.minFilter),nt.push(St.anisotropy),nt.push(St.internalFormat),nt.push(St.format),nt.push(St.type),nt.push(St.generateMipmaps),nt.push(St.premultiplyAlpha),nt.push(St.flipY),nt.push(St.unpackAlignment),nt.push(St.colorSpace),nt.join()}function vn(St,nt){const fn=n.get(St);if(St.isVideoTexture&&Ii(St),St.isRenderTargetTexture===!1&&St.isExternalTexture!==!0&&St.version>0&&fn.__version!==St.version){const Dn=St.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,St,nt);return}}else St.isExternalTexture&&(fn.__webglTexture=St.sourceTexture?St.sourceTexture:null);t.bindTexture(r.TEXTURE_2D,fn.__webglTexture,r.TEXTURE0+nt)}function mn(St,nt){const fn=n.get(St);if(St.isRenderTargetTexture===!1&&St.version>0&&fn.__version!==St.version){un(fn,St,nt);return}t.bindTexture(r.TEXTURE_2D_ARRAY,fn.__webglTexture,r.TEXTURE0+nt)}function Yn(St,nt){const fn=n.get(St);if(St.isRenderTargetTexture===!1&&St.version>0&&fn.__version!==St.version){un(fn,St,nt);return}t.bindTexture(r.TEXTURE_3D,fn.__webglTexture,r.TEXTURE0+nt)}function xn(St,nt){const fn=n.get(St);if(St.version>0&&fn.__version!==St.version){Mn(fn,St,nt);return}t.bindTexture(r.TEXTURE_CUBE_MAP,fn.__webglTexture,r.TEXTURE0+nt)}const si={[lt]:r.REPEAT,[qe]:r.CLAMP_TO_EDGE,[pt]:r.MIRRORED_REPEAT},wn={[Ct]:r.NEAREST,[Xt]:r.NEAREST_MIPMAP_NEAREST,[pn]:r.NEAREST_MIPMAP_LINEAR,[Rn]:r.LINEAR,[bi]:r.LINEAR_MIPMAP_NEAREST,[Qn]:r.LINEAR_MIPMAP_LINEAR},Gn={[Lm]:r.NEVER,[Dm]:r.ALWAYS,[qd]:r.LESS,[ep]:r.LEQUAL,[Yd]:r.EQUAL,[w0]:r.GEQUAL,[_0]:r.GREATER,[b0]:r.NOTEQUAL};function Si(St,nt){if(nt.type===gs&&e.has("OES_texture_float_linear")===!1&&(nt.magFilter===Rn||nt.magFilter===bi||nt.magFilter===pn||nt.magFilter===Qn||nt.minFilter===Rn||nt.minFilter===bi||nt.minFilter===pn||nt.minFilter===Qn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),r.texParameteri(St,r.TEXTURE_WRAP_S,si[nt.wrapS]),r.texParameteri(St,r.TEXTURE_WRAP_T,si[nt.wrapT]),(St===r.TEXTURE_3D||St===r.TEXTURE_2D_ARRAY)&&r.texParameteri(St,r.TEXTURE_WRAP_R,si[nt.wrapR]),r.texParameteri(St,r.TEXTURE_MAG_FILTER,wn[nt.magFilter]),r.texParameteri(St,r.TEXTURE_MIN_FILTER,wn[nt.minFilter]),nt.compareFunction&&(r.texParameteri(St,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(St,r.TEXTURE_COMPARE_FUNC,Gn[nt.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(nt.magFilter===Ct||nt.minFilter!==pn&&nt.minFilter!==Qn||nt.type===gs&&e.has("OES_texture_float_linear")===!1)return;if(nt.anisotropy>1||n.get(nt).__currentAnisotropy){const fn=e.get("EXT_texture_filter_anisotropic");r.texParameterf(St,fn.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(nt.anisotropy,s.getMaxAnisotropy())),n.get(nt).__currentAnisotropy=nt.anisotropy}}}function nr(St,nt){let fn=!1;St.__webglInit===void 0&&(St.__webglInit=!0,nt.addEventListener("dispose",ve));const Dn=nt.source;let ri=y.get(Dn);ri===void 0&&(ri={},y.set(Dn,ri));const zn=cn(nt);if(zn!==St.__cacheKey){ri[zn]===void 0&&(ri[zn]={texture:r.createTexture(),usedTimes:0},a.memory.textures++,fn=!0),ri[zn].usedTimes++;const Rr=ri[St.__cacheKey];Rr!==void 0&&(ri[St.__cacheKey].usedTimes--,Rr.usedTimes===0&&Ce(nt)),St.__cacheKey=zn,St.__webglTexture=ri[zn].texture}return fn}function ss(St,nt,fn){return Math.floor(Math.floor(St/fn)/nt)}function Vn(St,nt,fn,Dn){const zn=St.updateRanges;if(zn.length===0)t.texSubImage2D(r.TEXTURE_2D,0,0,0,nt.width,nt.height,fn,Dn,nt.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],ts=zn[mi],Pr=Yi.start+Yi.count,Hi=ss(ts.start,nt.width,4),Rs=ss(Yi.start,nt.width,4);ts.start<=Pr+1&&Hi===Rs&&ss(ts.start+ts.count-1,nt.width,4)===Hi?Yi.count=Math.max(Yi.count,ts.start+ts.count-Yi.start):(++Rr,zn[Rr]=ts)}zn.length=Rr+1;const Ci=r.getParameter(r.UNPACK_ROW_LENGTH),Tr=r.getParameter(r.UNPACK_SKIP_PIXELS),Er=r.getParameter(r.UNPACK_SKIP_ROWS);r.pixelStorei(r.UNPACK_ROW_LENGTH,nt.width);for(let mi=0,Yi=zn.length;mi<Yi;mi++){const ts=zn[mi],Pr=Math.floor(ts.start/4),Hi=Math.ceil(ts.count/4),Rs=Pr%nt.width,rn=Math.floor(Pr/nt.width),wi=Hi,Di=1;r.pixelStorei(r.UNPACK_SKIP_PIXELS,Rs),r.pixelStorei(r.UNPACK_SKIP_ROWS,rn),t.texSubImage2D(r.TEXTURE_2D,0,Rs,rn,wi,Di,fn,Dn,nt.data)}St.clearUpdateRanges(),r.pixelStorei(r.UNPACK_ROW_LENGTH,Ci),r.pixelStorei(r.UNPACK_SKIP_PIXELS,Tr),r.pixelStorei(r.UNPACK_SKIP_ROWS,Er)}}function un(St,nt,fn){let Dn=r.TEXTURE_2D;(nt.isDataArrayTexture||nt.isCompressedArrayTexture)&&(Dn=r.TEXTURE_2D_ARRAY),nt.isData3DTexture&&(Dn=r.TEXTURE_3D);const ri=nr(St,nt),zn=nt.source;t.bindTexture(Dn,St.__webglTexture,r.TEXTURE0+fn);const Rr=n.get(zn);if(zn.version!==Rr.__version||ri===!0){t.activeTexture(r.TEXTURE0+fn);const Ci=Ki.getPrimaries(Ki.workingColorSpace),Tr=nt.colorSpace===Qo?null:Ki.getPrimaries(nt.colorSpace),Er=nt.colorSpace===Qo||Ci===Tr?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,nt.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,nt.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,nt.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,Er);let mi=G(nt.image,!1,s.maxTextureSize);mi=bs(nt,mi);const Yi=o.convert(nt.format,nt.colorSpace),ts=o.convert(nt.type);let Pr=Q(nt.internalFormat,Yi,ts,nt.colorSpace,nt.isVideoTexture);Si(Dn,nt);let Hi;const Rs=nt.mipmaps,rn=nt.isVideoTexture!==!0,wi=Rr.__version===void 0||ri===!0,Di=zn.dataReady,pr=_e(nt,mi);if(nt.isDepthTexture)Pr=oe(nt.format===_,nt.type),wi&&(rn?t.texStorage2D(r.TEXTURE_2D,1,Pr,mi.width,mi.height):t.texImage2D(r.TEXTURE_2D,0,Pr,mi.width,mi.height,0,Yi,ts,null));else if(nt.isDataTexture)if(Rs.length>0){rn&&wi&&t.texStorage2D(r.TEXTURE_2D,pr,Pr,Rs[0].width,Rs[0].height);for(let gi=0,Jn=Rs.length;gi<Jn;gi++)Hi=Rs[gi],rn?Di&&t.texSubImage2D(r.TEXTURE_2D,gi,0,0,Hi.width,Hi.height,Yi,ts,Hi.data):t.texImage2D(r.TEXTURE_2D,gi,Pr,Hi.width,Hi.height,0,Yi,ts,Hi.data);nt.generateMipmaps=!1}else rn?(wi&&t.texStorage2D(r.TEXTURE_2D,pr,Pr,mi.width,mi.height),Di&&Vn(nt,mi,Yi,ts)):t.texImage2D(r.TEXTURE_2D,0,Pr,mi.width,mi.height,0,Yi,ts,mi.data);else if(nt.isCompressedTexture)if(nt.isCompressedArrayTexture){rn&&wi&&t.texStorage3D(r.TEXTURE_2D_ARRAY,pr,Pr,Rs[0].width,Rs[0].height,mi.depth);for(let gi=0,Jn=Rs.length;gi<Jn;gi++)if(Hi=Rs[gi],nt.format!==D)if(Yi!==null)if(rn){if(Di)if(nt.layerUpdates.size>0){const Ar=Oy(Hi.width,Hi.height,nt.format,nt.type);for(const ws of nt.layerUpdates){const Go=Hi.data.subarray(ws*Ar/Hi.data.BYTES_PER_ELEMENT,(ws+1)*Ar/Hi.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,gi,0,0,ws,Hi.width,Hi.height,1,Yi,Go)}nt.clearLayerUpdates()}else t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,gi,0,0,0,Hi.width,Hi.height,mi.depth,Yi,Hi.data)}else t.compressedTexImage3D(r.TEXTURE_2D_ARRAY,gi,Pr,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(r.TEXTURE_2D_ARRAY,gi,0,0,0,Hi.width,Hi.height,mi.depth,Yi,ts,Hi.data):t.texImage3D(r.TEXTURE_2D_ARRAY,gi,Pr,Hi.width,Hi.height,mi.depth,0,Yi,ts,Hi.data)}else{rn&&wi&&t.texStorage2D(r.TEXTURE_2D,pr,Pr,Rs[0].width,Rs[0].height);for(let gi=0,Jn=Rs.length;gi<Jn;gi++)Hi=Rs[gi],nt.format!==D?Yi!==null?rn?Di&&t.compressedTexSubImage2D(r.TEXTURE_2D,gi,0,0,Hi.width,Hi.height,Yi,Hi.data):t.compressedTexImage2D(r.TEXTURE_2D,gi,Pr,Hi.width,Hi.height,0,Hi.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):rn?Di&&t.texSubImage2D(r.TEXTURE_2D,gi,0,0,Hi.width,Hi.height,Yi,ts,Hi.data):t.texImage2D(r.TEXTURE_2D,gi,Pr,Hi.width,Hi.height,0,Yi,ts,Hi.data)}else if(nt.isDataArrayTexture)if(rn){if(wi&&t.texStorage3D(r.TEXTURE_2D_ARRAY,pr,Pr,mi.width,mi.height,mi.depth),Di)if(nt.layerUpdates.size>0){const gi=Oy(mi.width,mi.height,nt.format,nt.type);for(const Jn of nt.layerUpdates){const Ar=mi.data.subarray(Jn*gi/mi.data.BYTES_PER_ELEMENT,(Jn+1)*gi/mi.data.BYTES_PER_ELEMENT);t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,Jn,mi.width,mi.height,1,Yi,ts,Ar)}nt.clearLayerUpdates()}else t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,mi.width,mi.height,mi.depth,Yi,ts,mi.data)}else t.texImage3D(r.TEXTURE_2D_ARRAY,0,Pr,mi.width,mi.height,mi.depth,0,Yi,ts,mi.data);else if(nt.isData3DTexture)rn?(wi&&t.texStorage3D(r.TEXTURE_3D,pr,Pr,mi.width,mi.height,mi.depth),Di&&t.texSubImage3D(r.TEXTURE_3D,0,0,0,0,mi.width,mi.height,mi.depth,Yi,ts,mi.data)):t.texImage3D(r.TEXTURE_3D,0,Pr,mi.width,mi.height,mi.depth,0,Yi,ts,mi.data);else if(nt.isFramebufferTexture){if(wi)if(rn)t.texStorage2D(r.TEXTURE_2D,pr,Pr,mi.width,mi.height);else{let gi=mi.width,Jn=mi.height;for(let Ar=0;Ar<pr;Ar++)t.texImage2D(r.TEXTURE_2D,Ar,Pr,gi,Jn,0,Yi,ts,null),gi>>=1,Jn>>=1}}else if(Rs.length>0){if(rn&&wi){const gi=ps(Rs[0]);t.texStorage2D(r.TEXTURE_2D,pr,Pr,gi.width,gi.height)}for(let gi=0,Jn=Rs.length;gi<Jn;gi++)Hi=Rs[gi],rn?Di&&t.texSubImage2D(r.TEXTURE_2D,gi,0,0,Yi,ts,Hi):t.texImage2D(r.TEXTURE_2D,gi,Pr,Yi,ts,Hi);nt.generateMipmaps=!1}else if(rn){if(wi){const gi=ps(mi);t.texStorage2D(r.TEXTURE_2D,pr,Pr,gi.width,gi.height)}Di&&t.texSubImage2D(r.TEXTURE_2D,0,0,0,Yi,ts,mi)}else t.texImage2D(r.TEXTURE_2D,0,Pr,Yi,ts,mi);z(nt)&&I(Dn),Rr.__version=zn.version,nt.onUpdate&&nt.onUpdate(nt)}St.__version=nt.version}function Mn(St,nt,fn){if(nt.image.length!==6)return;const Dn=nr(St,nt),ri=nt.source;t.bindTexture(r.TEXTURE_CUBE_MAP,St.__webglTexture,r.TEXTURE0+fn);const zn=n.get(ri);if(ri.version!==zn.__version||Dn===!0){t.activeTexture(r.TEXTURE0+fn);const Rr=Ki.getPrimaries(Ki.workingColorSpace),Ci=nt.colorSpace===Qo?null:Ki.getPrimaries(nt.colorSpace),Tr=nt.colorSpace===Qo||Rr===Ci?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,nt.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,nt.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,nt.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,Tr);const Er=nt.isCompressedTexture||nt.image[0].isCompressedTexture,mi=nt.image[0]&&nt.image[0].isDataTexture,Yi=[];for(let Jn=0;Jn<6;Jn++)!Er&&!mi?Yi[Jn]=G(nt.image[Jn],!0,s.maxCubemapSize):Yi[Jn]=mi?nt.image[Jn].image:nt.image[Jn],Yi[Jn]=bs(nt,Yi[Jn]);const ts=Yi[0],Pr=o.convert(nt.format,nt.colorSpace),Hi=o.convert(nt.type),Rs=Q(nt.internalFormat,Pr,Hi,nt.colorSpace),rn=nt.isVideoTexture!==!0,wi=zn.__version===void 0||Dn===!0,Di=ri.dataReady;let pr=_e(nt,ts);Si(r.TEXTURE_CUBE_MAP,nt);let gi;if(Er){rn&&wi&&t.texStorage2D(r.TEXTURE_CUBE_MAP,pr,Rs,ts.width,ts.height);for(let Jn=0;Jn<6;Jn++){gi=Yi[Jn].mipmaps;for(let Ar=0;Ar<gi.length;Ar++){const ws=gi[Ar];nt.format!==D?Pr!==null?rn?Di&&t.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,Ar,0,0,ws.width,ws.height,Pr,ws.data):t.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,Ar,Rs,ws.width,ws.height,0,ws.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):rn?Di&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,Ar,0,0,ws.width,ws.height,Pr,Hi,ws.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,Ar,Rs,ws.width,ws.height,0,Pr,Hi,ws.data)}}}else{if(gi=nt.mipmaps,rn&&wi){gi.length>0&&pr++;const Jn=ps(Yi[0]);t.texStorage2D(r.TEXTURE_CUBE_MAP,pr,Rs,Jn.width,Jn.height)}for(let Jn=0;Jn<6;Jn++)if(mi){rn?Di&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,0,0,0,Yi[Jn].width,Yi[Jn].height,Pr,Hi,Yi[Jn].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,0,Rs,Yi[Jn].width,Yi[Jn].height,0,Pr,Hi,Yi[Jn].data);for(let Ar=0;Ar<gi.length;Ar++){const Go=gi[Ar].image[Jn].image;rn?Di&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,Ar+1,0,0,Go.width,Go.height,Pr,Hi,Go.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,Ar+1,Rs,Go.width,Go.height,0,Pr,Hi,Go.data)}}else{rn?Di&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,0,0,0,Pr,Hi,Yi[Jn]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,0,Rs,Pr,Hi,Yi[Jn]);for(let Ar=0;Ar<gi.length;Ar++){const ws=gi[Ar];rn?Di&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,Ar+1,0,0,Pr,Hi,ws.image[Jn]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,Ar+1,Rs,Pr,Hi,ws.image[Jn])}}}z(nt)&&I(r.TEXTURE_CUBE_MAP),zn.__version=ri.version,nt.onUpdate&&nt.onUpdate(nt)}St.__version=nt.version}function fi(St,nt,fn,Dn,ri,zn){const Rr=o.convert(fn.format,fn.colorSpace),Ci=o.convert(fn.type),Tr=Q(fn.internalFormat,Rr,Ci,fn.colorSpace),Er=n.get(nt),mi=n.get(fn);if(mi.__renderTarget=nt,!Er.__hasExternalTextures){const Yi=Math.max(1,nt.width>>zn),ts=Math.max(1,nt.height>>zn);ri===r.TEXTURE_3D||ri===r.TEXTURE_2D_ARRAY?t.texImage3D(ri,zn,Tr,Yi,ts,nt.depth,0,Rr,Ci,null):t.texImage2D(ri,zn,Tr,Yi,ts,0,Rr,Ci,null)}t.bindFramebuffer(r.FRAMEBUFFER,St),pi(nt)?c.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,Dn,ri,mi.__webglTexture,0,Ti(nt)):(ri===r.TEXTURE_2D||ri>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&ri<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,Dn,ri,mi.__webglTexture,zn),t.bindFramebuffer(r.FRAMEBUFFER,null)}function ki(St,nt,fn){if(r.bindRenderbuffer(r.RENDERBUFFER,St),nt.depthBuffer){const Dn=nt.depthTexture,ri=Dn&&Dn.isDepthTexture?Dn.type:null,zn=oe(nt.stencilBuffer,ri),Rr=nt.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Ci=Ti(nt);pi(nt)?c.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Ci,zn,nt.width,nt.height):fn?r.renderbufferStorageMultisample(r.RENDERBUFFER,Ci,zn,nt.width,nt.height):r.renderbufferStorage(r.RENDERBUFFER,zn,nt.width,nt.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,Rr,r.RENDERBUFFER,St)}else{const Dn=nt.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=Q(zn.internalFormat,Rr,Ci,zn.colorSpace),Er=Ti(nt);fn&&pi(nt)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,Er,Tr,nt.width,nt.height):pi(nt)?c.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Er,Tr,nt.width,nt.height):r.renderbufferStorage(r.RENDERBUFFER,Tr,nt.width,nt.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function Ni(St,nt){if(nt&&nt.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(r.FRAMEBUFFER,St),!(nt.depthTexture&&nt.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const Dn=n.get(nt.depthTexture);Dn.__renderTarget=nt,(!Dn.__webglTexture||nt.depthTexture.image.width!==nt.width||nt.depthTexture.image.height!==nt.height)&&(nt.depthTexture.image.width=nt.width,nt.depthTexture.image.height=nt.height,nt.depthTexture.needsUpdate=!0),vn(nt.depthTexture,0);const ri=Dn.__webglTexture,zn=Ti(nt);if(nt.depthTexture.format===U)pi(nt)?c.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,ri,0,zn):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,ri,0);else if(nt.depthTexture.format===_)pi(nt)?c.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,ri,0,zn):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,ri,0);else throw new Error("Unknown depthTexture format")}function Cr(St){const nt=n.get(St),fn=St.isWebGLCubeRenderTarget===!0;if(nt.__boundDepthTexture!==St.depthTexture){const Dn=St.depthTexture;if(nt.__depthDisposeCallback&&nt.__depthDisposeCallback(),Dn){const ri=()=>{delete nt.__boundDepthTexture,delete nt.__depthDisposeCallback,Dn.removeEventListener("dispose",ri)};Dn.addEventListener("dispose",ri),nt.__depthDisposeCallback=ri}nt.__boundDepthTexture=Dn}if(St.depthTexture&&!nt.__autoAllocateDepthBuffer){if(fn)throw new Error("target.depthTexture not supported in Cube render targets");const Dn=St.texture.mipmaps;Dn&&Dn.length>0?Ni(nt.__webglFramebuffer[0],St):Ni(nt.__webglFramebuffer,St)}else if(fn){nt.__webglDepthbuffer=[];for(let Dn=0;Dn<6;Dn++)if(t.bindFramebuffer(r.FRAMEBUFFER,nt.__webglFramebuffer[Dn]),nt.__webglDepthbuffer[Dn]===void 0)nt.__webglDepthbuffer[Dn]=r.createRenderbuffer(),ki(nt.__webglDepthbuffer[Dn],St,!1);else{const ri=St.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,zn=nt.__webglDepthbuffer[Dn];r.bindRenderbuffer(r.RENDERBUFFER,zn),r.framebufferRenderbuffer(r.FRAMEBUFFER,ri,r.RENDERBUFFER,zn)}}else{const Dn=St.texture.mipmaps;if(Dn&&Dn.length>0?t.bindFramebuffer(r.FRAMEBUFFER,nt.__webglFramebuffer[0]):t.bindFramebuffer(r.FRAMEBUFFER,nt.__webglFramebuffer),nt.__webglDepthbuffer===void 0)nt.__webglDepthbuffer=r.createRenderbuffer(),ki(nt.__webglDepthbuffer,St,!1);else{const ri=St.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,zn=nt.__webglDepthbuffer;r.bindRenderbuffer(r.RENDERBUFFER,zn),r.framebufferRenderbuffer(r.FRAMEBUFFER,ri,r.RENDERBUFFER,zn)}}t.bindFramebuffer(r.FRAMEBUFFER,null)}function zs(St,nt,fn){const Dn=n.get(St);nt!==void 0&&fi(Dn.__webglFramebuffer,St,St.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),fn!==void 0&&Cr(St)}function Vt(St){const nt=St.texture,fn=n.get(St),Dn=n.get(nt);St.addEventListener("dispose",Oe);const ri=St.textures,zn=St.isWebGLCubeRenderTarget===!0,Rr=ri.length>1;if(Rr||(Dn.__webglTexture===void 0&&(Dn.__webglTexture=r.createTexture()),Dn.__version=nt.version,a.memory.textures++),zn){fn.__webglFramebuffer=[];for(let Ci=0;Ci<6;Ci++)if(nt.mipmaps&&nt.mipmaps.length>0){fn.__webglFramebuffer[Ci]=[];for(let Tr=0;Tr<nt.mipmaps.length;Tr++)fn.__webglFramebuffer[Ci][Tr]=r.createFramebuffer()}else fn.__webglFramebuffer[Ci]=r.createFramebuffer()}else{if(nt.mipmaps&&nt.mipmaps.length>0){fn.__webglFramebuffer=[];for(let Ci=0;Ci<nt.mipmaps.length;Ci++)fn.__webglFramebuffer[Ci]=r.createFramebuffer()}else fn.__webglFramebuffer=r.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=r.createTexture(),a.memory.textures++)}if(St.samples>0&&pi(St)===!1){fn.__webglMultisampledFramebuffer=r.createFramebuffer(),fn.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,fn.__webglMultisampledFramebuffer);for(let Ci=0;Ci<ri.length;Ci++){const Tr=ri[Ci];fn.__webglColorRenderbuffer[Ci]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,fn.__webglColorRenderbuffer[Ci]);const Er=o.convert(Tr.format,Tr.colorSpace),mi=o.convert(Tr.type),Yi=Q(Tr.internalFormat,Er,mi,Tr.colorSpace,St.isXRRenderTarget===!0),ts=Ti(St);r.renderbufferStorageMultisample(r.RENDERBUFFER,ts,Yi,St.width,St.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Ci,r.RENDERBUFFER,fn.__webglColorRenderbuffer[Ci])}r.bindRenderbuffer(r.RENDERBUFFER,null),St.depthBuffer&&(fn.__webglDepthRenderbuffer=r.createRenderbuffer(),ki(fn.__webglDepthRenderbuffer,St,!0)),t.bindFramebuffer(r.FRAMEBUFFER,null)}}if(zn){t.bindTexture(r.TEXTURE_CUBE_MAP,Dn.__webglTexture),Si(r.TEXTURE_CUBE_MAP,nt);for(let Ci=0;Ci<6;Ci++)if(nt.mipmaps&&nt.mipmaps.length>0)for(let Tr=0;Tr<nt.mipmaps.length;Tr++)fi(fn.__webglFramebuffer[Ci][Tr],St,nt,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+Ci,Tr);else fi(fn.__webglFramebuffer[Ci],St,nt,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+Ci,0);z(nt)&&I(r.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=r.TEXTURE_2D;(St.isWebGL3DRenderTarget||St.isWebGLArrayRenderTarget)&&(Yi=St.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),t.bindTexture(Yi,mi.__webglTexture),Si(Yi,Er),fi(fn.__webglFramebuffer,St,Er,r.COLOR_ATTACHMENT0+Ci,Yi,0),z(Er)&&I(Yi)}t.unbindTexture()}else{let Ci=r.TEXTURE_2D;if((St.isWebGL3DRenderTarget||St.isWebGLArrayRenderTarget)&&(Ci=St.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),t.bindTexture(Ci,Dn.__webglTexture),Si(Ci,nt),nt.mipmaps&&nt.mipmaps.length>0)for(let Tr=0;Tr<nt.mipmaps.length;Tr++)fi(fn.__webglFramebuffer[Tr],St,nt,r.COLOR_ATTACHMENT0,Ci,Tr);else fi(fn.__webglFramebuffer,St,nt,r.COLOR_ATTACHMENT0,Ci,0);z(nt)&&I(Ci),t.unbindTexture()}St.depthBuffer&&Cr(St)}function Kn(St){const nt=St.textures;for(let fn=0,Dn=nt.length;fn<Dn;fn++){const ri=nt[fn];if(z(ri)){const zn=ee(St),Rr=n.get(ri).__webglTexture;t.bindTexture(zn,Rr),I(zn),t.unbindTexture()}}}const Zn=[],qn=[];function Hn(St){if(St.samples>0){if(pi(St)===!1){const nt=St.textures,fn=St.width,Dn=St.height;let ri=r.COLOR_BUFFER_BIT;const zn=St.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Rr=n.get(St),Ci=nt.length>1;if(Ci)for(let Er=0;Er<nt.length;Er++)t.bindFramebuffer(r.FRAMEBUFFER,Rr.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Er,r.RENDERBUFFER,null),t.bindFramebuffer(r.FRAMEBUFFER,Rr.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Er,r.TEXTURE_2D,null,0);t.bindFramebuffer(r.READ_FRAMEBUFFER,Rr.__webglMultisampledFramebuffer);const Tr=St.texture.mipmaps;Tr&&Tr.length>0?t.bindFramebuffer(r.DRAW_FRAMEBUFFER,Rr.__webglFramebuffer[0]):t.bindFramebuffer(r.DRAW_FRAMEBUFFER,Rr.__webglFramebuffer);for(let Er=0;Er<nt.length;Er++){if(St.resolveDepthBuffer&&(St.depthBuffer&&(ri|=r.DEPTH_BUFFER_BIT),St.stencilBuffer&&St.resolveStencilBuffer&&(ri|=r.STENCIL_BUFFER_BIT)),Ci){r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,Rr.__webglColorRenderbuffer[Er]);const mi=n.get(nt[Er]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,mi,0)}r.blitFramebuffer(0,0,fn,Dn,0,0,fn,Dn,ri,r.NEAREST),u===!0&&(Zn.length=0,qn.length=0,Zn.push(r.COLOR_ATTACHMENT0+Er),St.depthBuffer&&St.resolveDepthBuffer===!1&&(Zn.push(zn),qn.push(zn),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,qn)),r.invalidateFramebuffer(r.READ_FRAMEBUFFER,Zn))}if(t.bindFramebuffer(r.READ_FRAMEBUFFER,null),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),Ci)for(let Er=0;Er<nt.length;Er++){t.bindFramebuffer(r.FRAMEBUFFER,Rr.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Er,r.RENDERBUFFER,Rr.__webglColorRenderbuffer[Er]);const mi=n.get(nt[Er]).__webglTexture;t.bindFramebuffer(r.FRAMEBUFFER,Rr.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Er,r.TEXTURE_2D,mi,0)}t.bindFramebuffer(r.DRAW_FRAMEBUFFER,Rr.__webglMultisampledFramebuffer)}else if(St.depthBuffer&&St.resolveDepthBuffer===!1&&u){const nt=St.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[nt])}}}function Ti(St){return Math.min(s.maxSamples,St.samples)}function pi(St){const nt=n.get(St);return St.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&nt.__useRenderToTexture!==!1}function Ii(St){const nt=a.render.frame;p.get(St)!==nt&&(p.set(St,nt),St.update())}function bs(St,nt){const fn=St.colorSpace,Dn=St.format,ri=St.type;return St.isCompressedTexture===!0||St.isVideoTexture===!0||fn!==iu&&fn!==Qo&&(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)),nt}function ps(St){return typeof HTMLImageElement!="undefined"&&St instanceof HTMLImageElement?(d.width=St.naturalWidth||St.width,d.height=St.naturalHeight||St.height):typeof VideoFrame!="undefined"&&St instanceof VideoFrame?(d.width=St.displayWidth,d.height=St.displayHeight):(d.width=St.width,d.height=St.height),d}this.allocateTextureUnit=tn,this.resetTextureUnits=zt,this.setTexture2D=vn,this.setTexture2DArray=mn,this.setTexture3D=Yn,this.setTextureCube=xn,this.rebindTextures=zs,this.setupRenderTarget=Vt,this.updateRenderTargetMipmap=Kn,this.updateMultisampleRenderTarget=Hn,this.setupDepthRenderbuffer=Cr,this.setupFrameBufferTexture=fi,this.useMultisampledRTT=pi}function ok(r,e){function t(n,s=Qo){let o;const a=Ki.getTransfer(s);if(n===Oi)return r.UNSIGNED_BYTE;if(n===Xl)return r.UNSIGNED_SHORT_4_4_4_4;if(n===ql)return r.UNSIGNED_SHORT_5_5_5_1;if(n===Dl)return r.UNSIGNED_INT_5_9_9_9_REV;if(n===nu)return r.UNSIGNED_INT_10F_11F_11F_REV;if(n===Gi)return r.BYTE;if(n===ir)return r.SHORT;if(n===ms)return r.UNSIGNED_SHORT;if(n===Is)return r.INT;if(n===as)return r.UNSIGNED_INT;if(n===gs)return r.FLOAT;if(n===Vs)return r.HALF_FLOAT;if(n===Du)return r.ALPHA;if(n===Le)return r.RGB;if(n===D)return r.RGBA;if(n===U)return r.DEPTH_COMPONENT;if(n===_)return r.DEPTH_STENCIL;if(n===F)return r.RED;if(n===X)return r.RED_INTEGER;if(n===De)return r.RG;if(n===Ve)return r.RG_INTEGER;if(n===st)return r.RGBA_INTEGER;if(n===Ht||n===Et||n===on||n===Un)if(a===Fi)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(n===Ht)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Et)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===Ht)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Et)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===Ir||n===yi||n===vi||n===Mr||n===Zt||n===Fn||n===hi||n===Xn||n===hs||n===Xr||n===ys||n===Ur||n===Os)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===Ir)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===hs)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Xr)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ys)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ur)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Os)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===no||n===io||n===So)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(n===no)return a===Fi?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===io)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===So)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===To||n===Gr||n===Qs||n===Eo)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(n===To)return o.COMPRESSED_RED_RGTC1_EXT;if(n===Gr)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Qs)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Eo)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Da?r.UNSIGNED_INT_24_8:r[n]!==void 0?r[n]:null}return{convert:t}}const ak=`
void main() {
gl_Position = vec4( position, 1.0 );
}`,lk=`
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 ck{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new y1(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 Bc({vertexShader:ak,fragmentShader:lk,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Zs(new Mh(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class uk extends Ol{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 ck,I={},ee=t.getContextAttributes();let Q=null,oe=null;const _e=[],ve=[],Oe=new yn;let He=null;const Ce=new fa;Ce.viewport=new mr;const Be=new fa;Be.viewport=new mr;const ft=[Ce,Be],zt=new wy;let tn=null,cn=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(un){let Mn=_e[un];return Mn===void 0&&(Mn=new Gu,_e[un]=Mn),Mn.getTargetRaySpace()},this.getControllerGrip=function(un){let Mn=_e[un];return Mn===void 0&&(Mn=new Gu,_e[un]=Mn),Mn.getGripSpace()},this.getHand=function(un){let Mn=_e[un];return Mn===void 0&&(Mn=new Gu,_e[un]=Mn),Mn.getHandSpace()};function vn(un){const Mn=ve.indexOf(un.inputSource);if(Mn===-1)return;const fi=_e[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<_e.length;un++){const Mn=ve[un];Mn!==null&&(ve[un]=null,_e[un].disconnect(Mn))}tn=null,cn=null,z.reset();for(const un in I)delete I[un];e.setRenderTarget(Q),M=null,y=null,m=null,s=null,oe=null,Vn.stop(),n.isPresenting=!1,e.setPixelRatio(He),e.setSize(Oe.width,Oe.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(Q=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),ee.xrCompatible!==!0&&(yield t.makeXRCompatible()),He=e.getPixelRatio(),e.getSize(Oe),G&&"createProjectionLayer"in XRWebGLBinding.prototype){let fi=null,ki=null,Ni=null;ee.depth&&(Ni=ee.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,fi=ee.stencil?_:U,ki=ee.stencil?Da:as);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),oe=new cc(y.textureWidth,y.textureHeight,{format:D,type:Oi,depthTexture:new gc(y.textureWidth,y.textureHeight,ki,void 0,void 0,void 0,void 0,void 0,void 0,fi),stencilBuffer:ee.stencil,colorSpace:e.outputColorSpace,samples:ee.antialias?4:0,resolveDepthBuffer:y.ignoreDepthValues===!1,resolveStencilBuffer:y.ignoreDepthValues===!1})}else{const fi={antialias:ee.antialias,alpha:!0,depth:ee.depth,stencil:ee.stencil,framebufferScaleFactor:o};M=new XRWebGLLayer(s,t,fi),s.updateRenderState({baseLayer:M}),e.setPixelRatio(1),e.setSize(M.framebufferWidth,M.framebufferHeight,!1),oe=new cc(M.framebufferWidth,M.framebufferHeight,{format:D,type:Oi,colorSpace:e.outputColorSpace,stencilBuffer:ee.stencil,resolveDepthBuffer:M.ignoreDepthValues===!1,resolveStencilBuffer:M.ignoreDepthValues===!1})}oe.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=ve.indexOf(fi);ki>=0&&(ve[ki]=null,_e[ki].disconnect(fi))}for(let Mn=0;Mn<un.added.length;Mn++){const fi=un.added[Mn];let ki=ve.indexOf(fi);if(ki===-1){for(let Cr=0;Cr<_e.length;Cr++)if(Cr>=ve.length){ve.push(fi),ki=Cr;break}else if(ve[Cr]===null){ve[Cr]=fi,ki=Cr;break}if(ki===-1)break}const Ni=_e[ki];Ni&&Ni.connect(fi)}}const xn=new ot,si=new ot;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,zs=Ni[14]/(Ni[10]-1),Vt=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=zs*qn,pi=zs*Hn,Ii=ki/(-qn+Hn),bs=Ii*-qn;if(Mn.matrixWorld.decompose(un.position,un.quaternion,un.scale),un.translateX(bs),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 ps=zs+Ii,St=Vt+Ii,nt=Ti-bs,fn=pi+(ki-bs),Dn=Kn*Vt/St*ps,ri=Zn*Vt/St*ps;un.projectionMatrix.makePerspective(nt,fn,Dn,ri,ps,St),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)),zt.near=Be.near=Ce.near=Mn,zt.far=Be.far=Ce.far=fi,(tn!==zt.near||cn!==zt.far)&&(s.updateRenderState({depthNear:zt.near,depthFar:zt.far}),tn=zt.near,cn=zt.far),zt.layers.mask=un.layers.mask|6,Ce.layers.mask=zt.layers.mask&3,Be.layers.mask=zt.layers.mask&5;const ki=un.parent,Ni=zt.cameras;Gn(zt,ki);for(let Cr=0;Cr<Ni.length;Cr++)Gn(Ni[Cr],ki);Ni.length===2?wn(zt,Ce,Be):zt.projectionMatrix.copy(Ce.projectionMatrix),Si(un,zt,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=Fa*2*Math.atan(1/un.projectionMatrix.elements[5]),un.zoom=1)}this.getCamera=function(){return zt},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(zt)},this.getCameraTexture=function(un){return I[un]};let nr=null;function ss(un,Mn){if(p=Mn.getViewerPose(d||a),T=Mn,p!==null){const fi=p.views;M!==null&&(e.setRenderTargetFramebuffer(oe,M.framebuffer),e.setRenderTarget(oe));let ki=!1;fi.length!==zt.cameras.length&&(zt.cameras.length=0,ki=!0);for(let Vt=0;Vt<fi.length;Vt++){const Kn=fi[Vt];let Zn=null;if(M!==null)Zn=M.getViewport(Kn);else{const Hn=m.getViewSubImage(y,Kn);Zn=Hn.viewport,Vt===0&&(e.setRenderTargetTextures(oe,Hn.colorTexture,Hn.depthStencilTexture),e.setRenderTarget(oe))}let qn=ft[Vt];qn===void 0&&(qn=new fa,qn.layers.enable(Vt),qn.viewport=new mr,ft[Vt]=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),Vt===0&&(zt.matrix.copy(qn.matrix),zt.matrix.decompose(zt.position,zt.quaternion,zt.scale)),ki===!0&&zt.cameras.push(qn)}const Ni=s.enabledFeatures;if(Ni&&Ni.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&G){m=n.getBinding();const Vt=m.getDepthInformation(fi[0]);Vt&&Vt.isValid&&Vt.texture&&z.init(Vt,s.renderState)}if(Ni&&Ni.includes("camera-access")&&G){e.state.unbindTexture(),m=n.getBinding();for(let Vt=0;Vt<fi.length;Vt++){const Kn=fi[Vt].camera;if(Kn){let Zn=I[Kn];Zn||(Zn=new y1,I[Kn]=Zn);const qn=m.getCameraImage(Kn);Zn.sourceTexture=qn}}}}for(let fi=0;fi<_e.length;fi++){const ki=ve[fi],Ni=_e[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 aA;Vn.setAnimationLoop(ss),this.setAnimationLoop=function(un){nr=un},this.dispose=function(){}}}const em=new Qi,hk=new Ft;function dk(r,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,ox(r)),I.isFog?(z.fogNear.value=I.near,z.fogFar.value=I.far):I.isFogExp2&&(z.fogDensity.value=I.density)}function s(z,I,ee,Q,oe){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,oe)):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,ee,Q):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===K&&(z.bumpScale.value*=-1)),I.normalMap&&(z.normalMap.value=I.normalMap,t(I.normalMap,z.normalMapTransform),z.normalScale.value.copy(I.normalScale),I.side===K&&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 ee=e.get(I),Q=ee.envMap,oe=ee.envMapRotation;Q&&(z.envMap.value=Q,em.copy(oe),em.x*=-1,em.y*=-1,em.z*=-1,Q.isCubeTexture&&Q.isRenderTargetTexture===!1&&(em.y*=-1,em.z*=-1),z.envMapRotation.value.setFromMatrix4(hk.makeRotationFromEuler(em)),z.flipEnvMap.value=Q.isCubeTexture&&Q.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,ee,Q){z.diffuse.value.copy(I.color),z.opacity.value=I.opacity,z.size.value=I.size*ee,z.scale.value=Q*.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,ee){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===K&&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=ee.texture,z.transmissionSamplerSize.value.set(ee.width,ee.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 ee=e.get(I).light;z.referencePosition.value.setFromMatrixPosition(ee.matrixWorld),z.nearDistance.value=ee.shadow.camera.near,z.farDistance.value=ee.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function fk(r,e,t,n){let s={},o={},a=[];const c=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function u(ee,Q){const oe=Q.program;n.uniformBlockBinding(ee,oe)}function d(ee,Q){let oe=s[ee.id];oe===void 0&&(T(ee),oe=p(ee),s[ee.id]=oe,ee.addEventListener("dispose",z));const _e=Q.program;n.updateUBOMapping(ee,_e);const ve=e.render.frame;o[ee.id]!==ve&&(y(ee),o[ee.id]=ve)}function p(ee){const Q=m();ee.__bindingPointIndex=Q;const oe=r.createBuffer(),_e=ee.__size,ve=ee.usage;return r.bindBuffer(r.UNIFORM_BUFFER,oe),r.bufferData(r.UNIFORM_BUFFER,_e,ve),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,Q,oe),oe}function m(){for(let ee=0;ee<c;ee++)if(a.indexOf(ee)===-1)return a.push(ee),ee;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function y(ee){const Q=s[ee.id],oe=ee.uniforms,_e=ee.__cache;r.bindBuffer(r.UNIFORM_BUFFER,Q);for(let ve=0,Oe=oe.length;ve<Oe;ve++){const He=Array.isArray(oe[ve])?oe[ve]:[oe[ve]];for(let Ce=0,Be=He.length;Ce<Be;Ce++){const ft=He[Ce];if(M(ft,ve,Ce,_e)===!0){const zt=ft.__offset,tn=Array.isArray(ft.value)?ft.value:[ft.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"?(ft.__data[0]=mn,r.bufferSubData(r.UNIFORM_BUFFER,zt+cn,ft.__data)):mn.isMatrix3?(ft.__data[0]=mn.elements[0],ft.__data[1]=mn.elements[1],ft.__data[2]=mn.elements[2],ft.__data[3]=0,ft.__data[4]=mn.elements[3],ft.__data[5]=mn.elements[4],ft.__data[6]=mn.elements[5],ft.__data[7]=0,ft.__data[8]=mn.elements[6],ft.__data[9]=mn.elements[7],ft.__data[10]=mn.elements[8],ft.__data[11]=0):(mn.toArray(ft.__data,cn),cn+=Yn.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,zt,ft.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function M(ee,Q,oe,_e){const ve=ee.value,Oe=Q+"_"+oe;if(_e[Oe]===void 0)return typeof ve=="number"||typeof ve=="boolean"?_e[Oe]=ve:_e[Oe]=ve.clone(),!0;{const He=_e[Oe];if(typeof ve=="number"||typeof ve=="boolean"){if(He!==ve)return _e[Oe]=ve,!0}else if(He.equals(ve)===!1)return He.copy(ve),!0}return!1}function T(ee){const Q=ee.uniforms;let oe=0;const _e=16;for(let Oe=0,He=Q.length;Oe<He;Oe++){const Ce=Array.isArray(Q[Oe])?Q[Oe]:[Q[Oe]];for(let Be=0,ft=Ce.length;Be<ft;Be++){const zt=Ce[Be],tn=Array.isArray(zt.value)?zt.value:[zt.value];for(let cn=0,vn=tn.length;cn<vn;cn++){const mn=tn[cn],Yn=G(mn),xn=oe%_e,si=xn%Yn.boundary,wn=xn+si;oe+=si,wn!==0&&_e-wn<Yn.storage&&(oe+=_e-wn),zt.__data=new Float32Array(Yn.storage/Float32Array.BYTES_PER_ELEMENT),zt.__offset=oe,oe+=Yn.storage}}}const ve=oe%_e;return ve>0&&(oe+=_e-ve),ee.__size=oe,ee.__cache={},this}function G(ee){const Q={boundary:0,storage:0};return typeof ee=="number"||typeof ee=="boolean"?(Q.boundary=4,Q.storage=4):ee.isVector2?(Q.boundary=8,Q.storage=8):ee.isVector3||ee.isColor?(Q.boundary=16,Q.storage=12):ee.isVector4?(Q.boundary=16,Q.storage=16):ee.isMatrix3?(Q.boundary=48,Q.storage=48):ee.isMatrix4?(Q.boundary=64,Q.storage=64):ee.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",ee),Q}function z(ee){const Q=ee.target;Q.removeEventListener("dispose",z);const oe=a.indexOf(Q.__bindingPointIndex);a.splice(oe,1),r.deleteBuffer(s[Q.id]),delete s[Q.id],delete o[Q.id]}function I(){for(const ee in s)r.deleteBuffer(s[ee]);a=[],s={},o={}}return{bind:u,update:d,dispose:I}}class pk{constructor(e={}){const{canvas:t=Ya(),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 ee=[],Q=[];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 oe=this;let _e=!1;this._outputColorSpace=co;let ve=0,Oe=0,He=null,Ce=-1,Be=null;const ft=new mr,zt=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 ss=new lf;let Vn=!1,un=!1;const Mn=new Ft,fi=new ot,ki=new mr,Ni={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Cr=!1;function zs(){return He===null?xn:1}let Vt=n;function Kn(dt,ln){return t.getContext(dt,ln)}try{const dt={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),Vt===null){const ln="webgl2";if(Vt=Kn(ln,dt),Vt===null)throw Kn(ln)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(dt){throw console.error("THREE.WebGLRenderer: "+dt.message),dt}let Zn,qn,Hn,Ti,pi,Ii,bs,ps,St,nt,fn,Dn,ri,zn,Rr,Ci,Tr,Er,mi,Yi,ts,Pr,Hi,Rs;function rn(){Zn=new SB(Vt),Zn.init(),Pr=new ok(Vt,Zn),qn=new yB(Vt,Zn,e,Pr),Hn=new rk(Vt,Zn),qn.reversedDepthBuffer&&y&&Hn.buffers.depth.setReversed(!0),Ti=new AB(Vt),pi=new $U,Ii=new sk(Vt,Zn,Hn,pi,qn,Pr,Ti),bs=new xB(oe),ps=new MB(oe),St=new fO(Vt),Hi=new mB(Vt,St),nt=new TB(Vt,St,Ti,Hi),fn=new RB(Vt,nt,St,Ti),mi=new CB(Vt,qn,Ii),Ci=new vB(pi),Dn=new HU(oe,bs,ps,Zn,qn,Hi,Ci),ri=new dk(oe,pi),zn=new XU,Rr=new QU(Zn),Er=new pB(oe,bs,ps,Hn,fn,M,u),Tr=new nk(oe,fn,qn),Rs=new fk(Vt,Ti,qn,Hn),Yi=new gB(Vt,Zn,Ti),ts=new EB(Vt,Zn,Ti),Ti.programs=Dn.programs,oe.capabilities=qn,oe.extensions=Zn,oe.properties=pi,oe.renderLists=zn,oe.shadowMap=Tr,oe.state=Hn,oe.info=Ti}rn();const wi=new uk(oe,Vt);this.xr=wi,this.getContext=function(){return Vt},this.getContextAttributes=function(){return Vt.getContextAttributes()},this.forceContextLoss=function(){const dt=Zn.get("WEBGL_lose_context");dt&&dt.loseContext()},this.forceContextRestore=function(){const dt=Zn.get("WEBGL_lose_context");dt&&dt.restoreContext()},this.getPixelRatio=function(){return xn},this.setPixelRatio=function(dt){dt!==void 0&&(xn=dt,this.setSize(mn,Yn,!1))},this.getSize=function(dt){return dt.set(mn,Yn)},this.setSize=function(dt,ln,Tn=!0){if(wi.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}mn=dt,Yn=ln,t.width=Math.floor(dt*xn),t.height=Math.floor(ln*xn),Tn===!0&&(t.style.width=dt+"px",t.style.height=ln+"px"),this.setViewport(0,0,dt,ln)},this.getDrawingBufferSize=function(dt){return dt.set(mn*xn,Yn*xn).floor()},this.setDrawingBufferSize=function(dt,ln,Tn){mn=dt,Yn=ln,xn=Tn,t.width=Math.floor(dt*Tn),t.height=Math.floor(ln*Tn),this.setViewport(0,0,dt,ln)},this.getCurrentViewport=function(dt){return dt.copy(ft)},this.getViewport=function(dt){return dt.copy(Gn)},this.setViewport=function(dt,ln,Tn,En){dt.isVector4?Gn.set(dt.x,dt.y,dt.z,dt.w):Gn.set(dt,ln,Tn,En),Hn.viewport(ft.copy(Gn).multiplyScalar(xn).round())},this.getScissor=function(dt){return dt.copy(Si)},this.setScissor=function(dt,ln,Tn,En){dt.isVector4?Si.set(dt.x,dt.y,dt.z,dt.w):Si.set(dt,ln,Tn,En),Hn.scissor(zt.copy(Si).multiplyScalar(xn).round())},this.getScissorTest=function(){return nr},this.setScissorTest=function(dt){Hn.setScissorTest(nr=dt)},this.setOpaqueSort=function(dt){si=dt},this.setTransparentSort=function(dt){wn=dt},this.getClearColor=function(dt){return dt.copy(Er.getClearColor())},this.setClearColor=function(){Er.setClearColor(...arguments)},this.getClearAlpha=function(){return Er.getClearAlpha()},this.setClearAlpha=function(){Er.setClearAlpha(...arguments)},this.clear=function(dt=!0,ln=!0,Tn=!0){let En=0;if(dt){let dn=!1;if(He!==null){const _i=He.texture.format;dn=_i===st||_i===Ve||_i===X}if(dn){const _i=He.texture.type,$i=_i===Oi||_i===as||_i===ms||_i===Da||_i===Xl||_i===ql,wr=Er.getClearColor(),ur=Er.getClearAlpha(),es=wr.r,os=wr.g,Vr=wr.b;$i?(T[0]=es,T[1]=os,T[2]=Vr,T[3]=ur,Vt.clearBufferuiv(Vt.COLOR,0,T)):(G[0]=es,G[1]=os,G[2]=Vr,G[3]=ur,Vt.clearBufferiv(Vt.COLOR,0,G))}else En|=Vt.COLOR_BUFFER_BIT}ln&&(En|=Vt.DEPTH_BUFFER_BIT),Tn&&(En|=Vt.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Vt.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(),bs.dispose(),ps.dispose(),fn.dispose(),Hi.dispose(),Rs.dispose(),Dn.dispose(),wi.dispose(),wi.removeEventListener("sessionstart",jh),wi.removeEventListener("sessionend",l3),Rm.stop()};function Di(dt){dt.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),_e=!0}function pr(){console.log("THREE.WebGLRenderer: Context Restored."),_e=!1;const dt=Ti.autoReset,ln=Tr.enabled,Tn=Tr.autoUpdate,En=Tr.needsUpdate,dn=Tr.type;rn(),Ti.autoReset=dt,Tr.enabled=ln,Tr.autoUpdate=Tn,Tr.needsUpdate=En,Tr.type=dn}function gi(dt){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",dt.statusMessage)}function Jn(dt){const ln=dt.target;ln.removeEventListener("dispose",Jn),Ar(ln)}function Ar(dt){ws(dt),pi.remove(dt)}function ws(dt){const ln=pi.get(dt).programs;ln!==void 0&&(ln.forEach(function(Tn){Dn.releaseProgram(Tn)}),dt.isShaderMaterial&&Dn.releaseShaderCache(dt))}this.renderBufferDirect=function(dt,ln,Tn,En,dn,_i){ln===null&&(ln=Ni);const $i=dn.isMesh&&dn.matrixWorld.determinant()<0,wr=Nq(dt,ln,Tn,En,dn);Hn.setMaterial(En,$i);let ur=Tn.index,es=1;if(En.wireframe===!0){if(ur=nt.getWireframeAttribute(Tn),ur===void 0)return;es=2}const os=Tn.drawRange,Vr=Tn.attributes.position;let $s=os.start*es,Io=(os.start+os.count)*es;_i!==null&&($s=Math.max($s,_i.start*es),Io=Math.min(Io,(_i.start+_i.count)*es)),ur!==null?($s=Math.max($s,0),Io=Math.min(Io,ur.count)):Vr!=null&&($s=Math.max($s,0),Io=Math.min(Io,Vr.count));const La=Io-$s;if(La<0||La===1/0)return;Hi.setup(dn,En,wr,Tn,ur);let Jo,Bo=Yi;if(ur!==null&&(Jo=St.get(ur),Bo=ts,Bo.setIndex(Jo)),dn.isMesh)En.wireframe===!0?(Hn.setLineWidth(En.wireframeLinewidth*zs()),Bo.setMode(Vt.LINES)):Bo.setMode(Vt.TRIANGLES);else if(dn.isLine){let jr=En.linewidth;jr===void 0&&(jr=1),Hn.setLineWidth(jr*zs()),dn.isLineSegments?Bo.setMode(Vt.LINES):dn.isLineLoop?Bo.setMode(Vt.LINE_LOOP):Bo.setMode(Vt.LINE_STRIP)}else dn.isPoints?Bo.setMode(Vt.POINTS):dn.isSprite&&Bo.setMode(Vt.TRIANGLES);if(dn.isBatchedMesh)if(dn._multiDrawInstances!==null)ol("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Bo.renderMultiDrawInstances(dn._multiDrawStarts,dn._multiDrawCounts,dn._multiDrawCount,dn._multiDrawInstances);else if(Zn.get("WEBGL_multi_draw"))Bo.renderMultiDraw(dn._multiDrawStarts,dn._multiDrawCounts,dn._multiDrawCount);else{const jr=dn._multiDrawStarts,va=dn._multiDrawCounts,lo=dn._multiDrawCount,eu=ur?St.get(ur).bytesPerElement:1,g0=pi.get(En).currentProgram.getUniforms();for(let tu=0;tu<lo;tu++)g0.setValue(Vt,"_gl_DrawID",tu),Bo.render(jr[tu]/eu,va[tu])}else if(dn.isInstancedMesh)Bo.renderInstances($s,La,dn.count);else if(Tn.isInstancedBufferGeometry){const jr=Tn._maxInstanceCount!==void 0?Tn._maxInstanceCount:1/0,va=Math.min(Tn.instanceCount,jr);Bo.renderInstances($s,La,va)}else Bo.render($s,La)};function Go(dt,ln,Tn){dt.transparent===!0&&dt.side===re&&dt.forceSinglePass===!1?(dt.side=K,dt.needsUpdate=!0,Kb(dt,ln,Tn),dt.side=W,dt.needsUpdate=!0,Kb(dt,ln,Tn),dt.side=re):Kb(dt,ln,Tn)}this.compile=function(dt,ln,Tn=null){Tn===null&&(Tn=dt),I=Rr.get(Tn),I.init(ln),Q.push(I),Tn.traverseVisible(function(dn){dn.isLight&&dn.layers.test(ln.layers)&&(I.pushLight(dn),dn.castShadow&&I.pushShadow(dn))}),dt!==Tn&&dt.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 dt.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];Go(wr,Tn,dn),En.add(wr)}else Go(_i,Tn,dn),En.add(_i)}),I=Q.pop(),En},this.compileAsync=function(dt,ln,Tn=null){const En=this.compile(dt,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(dt);return}setTimeout(_i,10)}Zn.get("KHR_parallel_shader_compile")!==null?_i():setTimeout(_i,10)})};let _o=null;function $d(dt){_o&&_o(dt)}function jh(){Rm.stop()}function l3(){Rm.start()}const Rm=new aA;Rm.setAnimationLoop($d),typeof self!="undefined"&&Rm.setContext(self),this.setAnimationLoop=function(dt){_o=dt,wi.setAnimationLoop(dt),dt===null?Rm.stop():Rm.start()},wi.addEventListener("sessionstart",jh),wi.addEventListener("sessionend",l3),this.render=function(dt,ln){if(ln!==void 0&&ln.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(_e===!0)return;if(dt.matrixWorldAutoUpdate===!0&&dt.updateMatrixWorld(),ln.parent===null&&ln.matrixWorldAutoUpdate===!0&&ln.updateMatrixWorld(),wi.enabled===!0&&wi.isPresenting===!0&&(wi.cameraAutoUpdate===!0&&wi.updateCamera(ln),ln=wi.getCamera()),dt.isScene===!0&&dt.onBeforeRender(oe,dt,ln,He),I=Rr.get(dt,Q.length),I.init(ln),Q.push(I),Mn.multiplyMatrices(ln.projectionMatrix,ln.matrixWorldInverse),ss.setFromProjectionMatrix(Mn,so,ln.reversedDepth),un=this.localClippingEnabled,Vn=Ci.init(this.clippingPlanes,un),z=zn.get(dt,ee.length),z.init(),ee.push(z),wi.enabled===!0&&wi.isPresenting===!0){const _i=oe.xr.getDepthSensingMesh();_i!==null&&JT(_i,ln,-1/0,oe.sortObjects)}JT(dt,ln,0,oe.sortObjects),z.finish(),oe.sortObjects===!0&&z.sort(si,wn),Cr=wi.enabled===!1||wi.isPresenting===!1||wi.hasDepthSensing()===!1,Cr&&Er.addToRenderList(z,dt),this.info.render.frame++,Vn===!0&&Ci.beginShadows();const Tn=I.state.shadowsArray;Tr.render(Tn,dt,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];u3(En,dn,dt,ur)}Cr&&Er.render(dt);for(let $i=0,wr=_i.length;$i<wr;$i++){const ur=_i[$i];c3(z,dt,ur,ur.viewport)}}else dn.length>0&&u3(En,dn,dt,ln),Cr&&Er.render(dt),c3(z,dt,ln);He!==null&&Oe===0&&(Ii.updateMultisampleRenderTarget(He),Ii.updateRenderTargetMipmap(He)),dt.isScene===!0&&dt.onAfterRender(oe,dt,ln),Hi.resetDefaultState(),Ce=-1,Be=null,Q.pop(),Q.length>0?(I=Q[Q.length-1],Vn===!0&&Ci.setGlobalState(oe.clippingPlanes,I.state.camera)):I=null,ee.pop(),ee.length>0?z=ee[ee.length-1]:z=null};function JT(dt,ln,Tn,En){if(dt.visible===!1)return;if(dt.layers.test(ln.layers)){if(dt.isGroup)Tn=dt.renderOrder;else if(dt.isLOD)dt.autoUpdate===!0&&dt.update(ln);else if(dt.isLight)I.pushLight(dt),dt.castShadow&&I.pushShadow(dt);else if(dt.isSprite){if(!dt.frustumCulled||ss.intersectsSprite(dt)){En&&ki.setFromMatrixPosition(dt.matrixWorld).applyMatrix4(Mn);const $i=fn.update(dt),wr=dt.material;wr.visible&&z.push(dt,$i,wr,Tn,ki.z,null)}}else if((dt.isMesh||dt.isLine||dt.isPoints)&&(!dt.frustumCulled||ss.intersectsObject(dt))){const $i=fn.update(dt),wr=dt.material;if(En&&(dt.boundingSphere!==void 0?(dt.boundingSphere===null&&dt.computeBoundingSphere(),ki.copy(dt.boundingSphere.center)):($i.boundingSphere===null&&$i.computeBoundingSphere(),ki.copy($i.boundingSphere.center)),ki.applyMatrix4(dt.matrixWorld).applyMatrix4(Mn)),Array.isArray(wr)){const ur=$i.groups;for(let es=0,os=ur.length;es<os;es++){const Vr=ur[es],$s=wr[Vr.materialIndex];$s&&$s.visible&&z.push(dt,$i,$s,Tn,ki.z,Vr)}}else wr.visible&&z.push(dt,$i,wr,Tn,ki.z,null)}}const _i=dt.children;for(let $i=0,wr=_i.length;$i<wr;$i++)JT(_i[$i],ln,Tn,En)}function c3(dt,ln,Tn,En){const dn=dt.opaque,_i=dt.transmissive,$i=dt.transparent;I.setupLightsView(Tn),Vn===!0&&Ci.setGlobalState(oe.clippingPlanes,Tn),En&&Hn.viewport(ft.copy(En)),dn.length>0&&Zb(dn,ln,Tn),_i.length>0&&Zb(_i,ln,Tn),$i.length>0&&Zb($i,ln,Tn),Hn.buffers.depth.setTest(!0),Hn.buffers.depth.setMask(!0),Hn.buffers.color.setMask(!0),Hn.setPolygonOffset(!1)}function u3(dt,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 cc(1,1,{generateMipmaps:!0,type:Zn.has("EXT_color_buffer_half_float")||Zn.has("EXT_color_buffer_float")?Vs:Oi,minFilter:Qn,samples:4,stencilBuffer:o,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ki.workingColorSpace}));const _i=I.state.transmissionRenderTarget[En.id],$i=En.viewport||ft;_i.setSize($i.z*oe.transmissionResolutionScale,$i.w*oe.transmissionResolutionScale);const wr=oe.getRenderTarget(),ur=oe.getActiveCubeFace(),es=oe.getActiveMipmapLevel();oe.setRenderTarget(_i),oe.getClearColor(cn),vn=oe.getClearAlpha(),vn<1&&oe.setClearColor(16777215,.5),oe.clear(),Cr&&Er.render(Tn);const os=oe.toneMapping;oe.toneMapping=yt;const Vr=En.viewport;if(En.viewport!==void 0&&(En.viewport=void 0),I.setupLightsView(En),Vn===!0&&Ci.setGlobalState(oe.clippingPlanes,En),Zb(dt,Tn,En),Ii.updateMultisampleRenderTarget(_i),Ii.updateRenderTargetMipmap(_i),Zn.has("WEBGL_multisampled_render_to_texture")===!1){let $s=!1;for(let Io=0,La=ln.length;Io<La;Io++){const Jo=ln[Io],Bo=Jo.object,jr=Jo.geometry,va=Jo.material,lo=Jo.group;if(va.side===re&&Bo.layers.test(En.layers)){const eu=va.side;va.side=K,va.needsUpdate=!0,h3(Bo,Tn,En,jr,va,lo),va.side=eu,va.needsUpdate=!0,$s=!0}}$s===!0&&(Ii.updateMultisampleRenderTarget(_i),Ii.updateRenderTargetMipmap(_i))}oe.setRenderTarget(wr,ur,es),oe.setClearColor(cn,vn),Vr!==void 0&&(En.viewport=Vr),oe.toneMapping=os}function Zb(dt,ln,Tn){const En=ln.isScene===!0?ln.overrideMaterial:null;for(let dn=0,_i=dt.length;dn<_i;dn++){const $i=dt[dn],wr=$i.object,ur=$i.geometry,es=$i.group;let os=$i.material;os.allowOverride===!0&&En!==null&&(os=En),wr.layers.test(Tn.layers)&&h3(wr,ln,Tn,ur,os,es)}}function h3(dt,ln,Tn,En,dn,_i){dt.onBeforeRender(oe,ln,Tn,En,dn,_i),dt.modelViewMatrix.multiplyMatrices(Tn.matrixWorldInverse,dt.matrixWorld),dt.normalMatrix.getNormalMatrix(dt.modelViewMatrix),dn.onBeforeRender(oe,ln,Tn,En,dt,_i),dn.transparent===!0&&dn.side===re&&dn.forceSinglePass===!1?(dn.side=K,dn.needsUpdate=!0,oe.renderBufferDirect(Tn,ln,En,dn,dt,_i),dn.side=W,dn.needsUpdate=!0,oe.renderBufferDirect(Tn,ln,En,dn,dt,_i),dn.side=re):oe.renderBufferDirect(Tn,ln,En,dn,dt,_i),dt.onAfterRender(oe,ln,Tn,En,dn,_i)}function Kb(dt,ln,Tn){ln.isScene!==!0&&(ln=Ni);const En=pi.get(dt),dn=I.state.lights,_i=I.state.shadowsArray,$i=dn.state.version,wr=Dn.getParameters(dt,dn.state,_i,ln,Tn),ur=Dn.getProgramCacheKey(wr);let es=En.programs;En.environment=dt.isMeshStandardMaterial?ln.environment:null,En.fog=ln.fog,En.envMap=(dt.isMeshStandardMaterial?ps:bs).get(dt.envMap||En.environment),En.envMapRotation=En.environment!==null&&dt.envMap===null?ln.environmentRotation:dt.envMapRotation,es===void 0&&(dt.addEventListener("dispose",Jn),es=new Map,En.programs=es);let os=es.get(ur);if(os!==void 0){if(En.currentProgram===os&&En.lightsStateVersion===$i)return f3(dt,wr),os}else wr.uniforms=Dn.getUniforms(dt),dt.onBeforeCompile(wr,oe),os=Dn.acquireProgram(wr,ur),es.set(ur,os),En.uniforms=wr.uniforms;const Vr=En.uniforms;return(!dt.isShaderMaterial&&!dt.isRawShaderMaterial||dt.clipping===!0)&&(Vr.clippingPlanes=Ci.uniform),f3(dt,wr),En.needsLights=Iq(dt),En.lightsStateVersion=$i,En.needsLights&&(Vr.ambientLightColor.value=dn.state.ambient,Vr.lightProbe.value=dn.state.probe,Vr.directionalLights.value=dn.state.directional,Vr.directionalLightShadows.value=dn.state.directionalShadow,Vr.spotLights.value=dn.state.spot,Vr.spotLightShadows.value=dn.state.spotShadow,Vr.rectAreaLights.value=dn.state.rectArea,Vr.ltc_1.value=dn.state.rectAreaLTC1,Vr.ltc_2.value=dn.state.rectAreaLTC2,Vr.pointLights.value=dn.state.point,Vr.pointLightShadows.value=dn.state.pointShadow,Vr.hemisphereLights.value=dn.state.hemi,Vr.directionalShadowMap.value=dn.state.directionalShadowMap,Vr.directionalShadowMatrix.value=dn.state.directionalShadowMatrix,Vr.spotShadowMap.value=dn.state.spotShadowMap,Vr.spotLightMatrix.value=dn.state.spotLightMatrix,Vr.spotLightMap.value=dn.state.spotLightMap,Vr.pointShadowMap.value=dn.state.pointShadowMap,Vr.pointShadowMatrix.value=dn.state.pointShadowMatrix),En.currentProgram=os,En.uniformsList=null,os}function d3(dt){if(dt.uniformsList===null){const ln=dt.currentProgram.getUniforms();dt.uniformsList=f_.seqWithValue(ln.seq,dt.uniforms)}return dt.uniformsList}function f3(dt,ln){const Tn=pi.get(dt);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 Nq(dt,ln,Tn,En,dn){ln.isScene!==!0&&(ln=Ni),Ii.resetTextureUnits();const _i=ln.fog,$i=En.isMeshStandardMaterial?ln.environment:null,wr=He===null?oe.outputColorSpace:He.isXRRenderTarget===!0?He.texture.colorSpace:iu,ur=(En.isMeshStandardMaterial?ps:bs).get(En.envMap||$i),es=En.vertexColors===!0&&!!Tn.attributes.color&&Tn.attributes.color.itemSize===4,os=!!Tn.attributes.tangent&&(!!En.normalMap||En.anisotropy>0),Vr=!!Tn.morphAttributes.position,$s=!!Tn.morphAttributes.normal,Io=!!Tn.morphAttributes.color;let La=yt;En.toneMapped&&(He===null||He.isXRRenderTarget===!0)&&(La=oe.toneMapping);const Jo=Tn.morphAttributes.position||Tn.morphAttributes.normal||Tn.morphAttributes.color,Bo=Jo!==void 0?Jo.length:0,jr=pi.get(En),va=I.state.lights;if(Vn===!0&&(un===!0||dt!==Be)){const oc=dt===Be&&En.id===Ce;Ci.setState(En,dt,oc)}let lo=!1;En.version===jr.__version?(jr.needsLights&&jr.lightsStateVersion!==va.state.version||jr.outputColorSpace!==wr||dn.isBatchedMesh&&jr.batching===!1||!dn.isBatchedMesh&&jr.batching===!0||dn.isBatchedMesh&&jr.batchingColor===!0&&dn.colorTexture===null||dn.isBatchedMesh&&jr.batchingColor===!1&&dn.colorTexture!==null||dn.isInstancedMesh&&jr.instancing===!1||!dn.isInstancedMesh&&jr.instancing===!0||dn.isSkinnedMesh&&jr.skinning===!1||!dn.isSkinnedMesh&&jr.skinning===!0||dn.isInstancedMesh&&jr.instancingColor===!0&&dn.instanceColor===null||dn.isInstancedMesh&&jr.instancingColor===!1&&dn.instanceColor!==null||dn.isInstancedMesh&&jr.instancingMorph===!0&&dn.morphTexture===null||dn.isInstancedMesh&&jr.instancingMorph===!1&&dn.morphTexture!==null||jr.envMap!==ur||En.fog===!0&&jr.fog!==_i||jr.numClippingPlanes!==void 0&&(jr.numClippingPlanes!==Ci.numPlanes||jr.numIntersection!==Ci.numIntersection)||jr.vertexAlphas!==es||jr.vertexTangents!==os||jr.morphTargets!==Vr||jr.morphNormals!==$s||jr.morphColors!==Io||jr.toneMapping!==La||jr.morphTargetsCount!==Bo)&&(lo=!0):(lo=!0,jr.__version=En.version);let eu=jr.currentProgram;lo===!0&&(eu=Kb(En,ln,dn));let g0=!1,tu=!1,Jv=!1;const xa=eu.getUniforms(),Iu=jr.uniforms;if(Hn.useProgram(eu.program)&&(g0=!0,tu=!0,Jv=!0),En.id!==Ce&&(Ce=En.id,tu=!0),g0||Be!==dt){Hn.buffers.depth.getReversed()&&dt.reversedDepth!==!0&&(dt._reversedDepth=!0,dt.updateProjectionMatrix()),xa.setValue(Vt,"projectionMatrix",dt.projectionMatrix),xa.setValue(Vt,"viewMatrix",dt.matrixWorldInverse);const Nc=xa.map.cameraPosition;Nc!==void 0&&Nc.setValue(Vt,fi.setFromMatrixPosition(dt.matrixWorld)),qn.logarithmicDepthBuffer&&xa.setValue(Vt,"logDepthBufFC",2/(Math.log(dt.far+1)/Math.LN2)),(En.isMeshPhongMaterial||En.isMeshToonMaterial||En.isMeshLambertMaterial||En.isMeshBasicMaterial||En.isMeshStandardMaterial||En.isShaderMaterial)&&xa.setValue(Vt,"isOrthographic",dt.isOrthographicCamera===!0),Be!==dt&&(Be=dt,tu=!0,Jv=!0)}if(dn.isSkinnedMesh){xa.setOptional(Vt,dn,"bindMatrix"),xa.setOptional(Vt,dn,"bindMatrixInverse");const oc=dn.skeleton;oc&&(oc.boneTexture===null&&oc.computeBoneTexture(),xa.setValue(Vt,"boneTexture",oc.boneTexture,Ii))}dn.isBatchedMesh&&(xa.setOptional(Vt,dn,"batchingTexture"),xa.setValue(Vt,"batchingTexture",dn._matricesTexture,Ii),xa.setOptional(Vt,dn,"batchingIdTexture"),xa.setValue(Vt,"batchingIdTexture",dn._indirectTexture,Ii),xa.setOptional(Vt,dn,"batchingColorTexture"),dn._colorsTexture!==null&&xa.setValue(Vt,"batchingColorTexture",dn._colorsTexture,Ii));const Lu=Tn.morphAttributes;if((Lu.position!==void 0||Lu.normal!==void 0||Lu.color!==void 0)&&mi.update(dn,Tn,eu),(tu||jr.receiveShadow!==dn.receiveShadow)&&(jr.receiveShadow=dn.receiveShadow,xa.setValue(Vt,"receiveShadow",dn.receiveShadow)),En.isMeshGouraudMaterial&&En.envMap!==null&&(Iu.envMap.value=ur,Iu.flipEnvMap.value=ur.isCubeTexture&&ur.isRenderTargetTexture===!1?-1:1),En.isMeshStandardMaterial&&En.envMap===null&&ln.environment!==null&&(Iu.envMapIntensity.value=ln.environmentIntensity),tu&&(xa.setValue(Vt,"toneMappingExposure",oe.toneMappingExposure),jr.needsLights&&Pq(Iu,Jv),_i&&En.fog===!0&&ri.refreshFogUniforms(Iu,_i),ri.refreshMaterialUniforms(Iu,En,xn,Yn,I.state.transmissionRenderTarget[dt.id]),f_.upload(Vt,d3(jr),Iu,Ii)),En.isShaderMaterial&&En.uniformsNeedUpdate===!0&&(f_.upload(Vt,d3(jr),Iu,Ii),En.uniformsNeedUpdate=!1),En.isSpriteMaterial&&xa.setValue(Vt,"center",dn.center),xa.setValue(Vt,"modelViewMatrix",dn.modelViewMatrix),xa.setValue(Vt,"normalMatrix",dn.normalMatrix),xa.setValue(Vt,"modelMatrix",dn.matrixWorld),En.isShaderMaterial||En.isRawShaderMaterial){const oc=En.uniformsGroups;for(let Nc=0,QT=oc.length;Nc<QT;Nc++){const Nm=oc[Nc];Rs.update(Nm,eu),Rs.bind(Nm,eu)}}return eu}function Pq(dt,ln){dt.ambientLightColor.needsUpdate=ln,dt.lightProbe.needsUpdate=ln,dt.directionalLights.needsUpdate=ln,dt.directionalLightShadows.needsUpdate=ln,dt.pointLights.needsUpdate=ln,dt.pointLightShadows.needsUpdate=ln,dt.spotLights.needsUpdate=ln,dt.spotLightShadows.needsUpdate=ln,dt.rectAreaLights.needsUpdate=ln,dt.hemisphereLights.needsUpdate=ln}function Iq(dt){return dt.isMeshLambertMaterial||dt.isMeshToonMaterial||dt.isMeshPhongMaterial||dt.isMeshStandardMaterial||dt.isShadowMaterial||dt.isShaderMaterial&&dt.lights===!0}this.getActiveCubeFace=function(){return ve},this.getActiveMipmapLevel=function(){return Oe},this.getRenderTarget=function(){return He},this.setRenderTargetTextures=function(dt,ln,Tn){const En=pi.get(dt);En.__autoAllocateDepthBuffer=dt.resolveDepthBuffer===!1,En.__autoAllocateDepthBuffer===!1&&(En.__useRenderToTexture=!1),pi.get(dt.texture).__webglTexture=ln,pi.get(dt.depthTexture).__webglTexture=En.__autoAllocateDepthBuffer?void 0:Tn,En.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(dt,ln){const Tn=pi.get(dt);Tn.__webglFramebuffer=ln,Tn.__useDefaultFramebuffer=ln===void 0};const Lq=Vt.createFramebuffer();this.setRenderTarget=function(dt,ln=0,Tn=0){He=dt,ve=ln,Oe=Tn;let En=!0,dn=null,_i=!1,$i=!1;if(dt){const ur=pi.get(dt);if(ur.__useDefaultFramebuffer!==void 0)Hn.bindFramebuffer(Vt.FRAMEBUFFER,null),En=!1;else if(ur.__webglFramebuffer===void 0)Ii.setupRenderTarget(dt);else if(ur.__hasExternalTextures)Ii.rebindTextures(dt,pi.get(dt.texture).__webglTexture,pi.get(dt.depthTexture).__webglTexture);else if(dt.depthBuffer){const Vr=dt.depthTexture;if(ur.__boundDepthTexture!==Vr){if(Vr!==null&&pi.has(Vr)&&(dt.width!==Vr.image.width||dt.height!==Vr.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Ii.setupDepthRenderbuffer(dt)}}const es=dt.texture;(es.isData3DTexture||es.isDataArrayTexture||es.isCompressedArrayTexture)&&($i=!0);const os=pi.get(dt).__webglFramebuffer;dt.isWebGLCubeRenderTarget?(Array.isArray(os[ln])?dn=os[ln][Tn]:dn=os[ln],_i=!0):dt.samples>0&&Ii.useMultisampledRTT(dt)===!1?dn=pi.get(dt).__webglMultisampledFramebuffer:Array.isArray(os)?dn=os[Tn]:dn=os,ft.copy(dt.viewport),zt.copy(dt.scissor),tn=dt.scissorTest}else ft.copy(Gn).multiplyScalar(xn).floor(),zt.copy(Si).multiplyScalar(xn).floor(),tn=nr;if(Tn!==0&&(dn=Lq),Hn.bindFramebuffer(Vt.FRAMEBUFFER,dn)&&En&&Hn.drawBuffers(dt,dn),Hn.viewport(ft),Hn.scissor(zt),Hn.setScissorTest(tn),_i){const ur=pi.get(dt.texture);Vt.framebufferTexture2D(Vt.FRAMEBUFFER,Vt.COLOR_ATTACHMENT0,Vt.TEXTURE_CUBE_MAP_POSITIVE_X+ln,ur.__webglTexture,Tn)}else if($i){const ur=ln;for(let es=0;es<dt.textures.length;es++){const os=pi.get(dt.textures[es]);Vt.framebufferTextureLayer(Vt.FRAMEBUFFER,Vt.COLOR_ATTACHMENT0+es,os.__webglTexture,Tn,ur)}}else if(dt!==null&&Tn!==0){const ur=pi.get(dt.texture);Vt.framebufferTexture2D(Vt.FRAMEBUFFER,Vt.COLOR_ATTACHMENT0,Vt.TEXTURE_2D,ur.__webglTexture,Tn)}Ce=-1},this.readRenderTargetPixels=function(dt,ln,Tn,En,dn,_i,$i,wr=0){if(!(dt&&dt.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ur=pi.get(dt).__webglFramebuffer;if(dt.isWebGLCubeRenderTarget&&$i!==void 0&&(ur=ur[$i]),ur){Hn.bindFramebuffer(Vt.FRAMEBUFFER,ur);try{const es=dt.textures[wr],os=es.format,Vr=es.type;if(!qn.textureFormatReadable(os)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!qn.textureTypeReadable(Vr)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ln>=0&&ln<=dt.width-En&&Tn>=0&&Tn<=dt.height-dn&&(dt.textures.length>1&&Vt.readBuffer(Vt.COLOR_ATTACHMENT0+wr),Vt.readPixels(ln,Tn,En,dn,Pr.convert(os),Pr.convert(Vr),_i))}finally{const es=He!==null?pi.get(He).__webglFramebuffer:null;Hn.bindFramebuffer(Vt.FRAMEBUFFER,es)}}},this.readRenderTargetPixelsAsync=function(dt,ln,Tn,En,dn,_i,$i,wr=0){return hr(this,null,function*(){if(!(dt&&dt.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ur=pi.get(dt).__webglFramebuffer;if(dt.isWebGLCubeRenderTarget&&$i!==void 0&&(ur=ur[$i]),ur)if(ln>=0&&ln<=dt.width-En&&Tn>=0&&Tn<=dt.height-dn){Hn.bindFramebuffer(Vt.FRAMEBUFFER,ur);const es=dt.textures[wr],os=es.format,Vr=es.type;if(!qn.textureFormatReadable(os))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!qn.textureTypeReadable(Vr))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const $s=Vt.createBuffer();Vt.bindBuffer(Vt.PIXEL_PACK_BUFFER,$s),Vt.bufferData(Vt.PIXEL_PACK_BUFFER,_i.byteLength,Vt.STREAM_READ),dt.textures.length>1&&Vt.readBuffer(Vt.COLOR_ATTACHMENT0+wr),Vt.readPixels(ln,Tn,En,dn,Pr.convert(os),Pr.convert(Vr),0);const Io=He!==null?pi.get(He).__webglFramebuffer:null;Hn.bindFramebuffer(Vt.FRAMEBUFFER,Io);const La=Vt.fenceSync(Vt.SYNC_GPU_COMMANDS_COMPLETE,0);return Vt.flush(),yield oi(Vt,La,4),Vt.bindBuffer(Vt.PIXEL_PACK_BUFFER,$s),Vt.getBufferSubData(Vt.PIXEL_PACK_BUFFER,0,_i),Vt.deleteBuffer($s),Vt.deleteSync(La),_i}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")})},this.copyFramebufferToTexture=function(dt,ln=null,Tn=0){const En=Math.pow(2,-Tn),dn=Math.floor(dt.image.width*En),_i=Math.floor(dt.image.height*En),$i=ln!==null?ln.x:0,wr=ln!==null?ln.y:0;Ii.setTexture2D(dt,0),Vt.copyTexSubImage2D(Vt.TEXTURE_2D,Tn,0,0,$i,wr,dn,_i),Hn.unbindTexture()};const Dq=Vt.createFramebuffer(),Oq=Vt.createFramebuffer();this.copyTextureToTexture=function(dt,ln,Tn=null,En=null,dn=0,_i=null){_i===null&&(dn!==0?(ol("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),_i=dn,dn=0):_i=0);let $i,wr,ur,es,os,Vr,$s,Io,La;const Jo=dt.isCompressedTexture?dt.mipmaps[_i]:dt.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,es=Tn.min.x,os=Tn.min.y,Vr=Tn.isBox3?Tn.min.z:0;else{const Lu=Math.pow(2,-dn);$i=Math.floor(Jo.width*Lu),wr=Math.floor(Jo.height*Lu),dt.isDataArrayTexture?ur=Jo.depth:dt.isData3DTexture?ur=Math.floor(Jo.depth*Lu):ur=1,es=0,os=0,Vr=0}En!==null?($s=En.x,Io=En.y,La=En.z):($s=0,Io=0,La=0);const Bo=Pr.convert(ln.format),jr=Pr.convert(ln.type);let va;ln.isData3DTexture?(Ii.setTexture3D(ln,0),va=Vt.TEXTURE_3D):ln.isDataArrayTexture||ln.isCompressedArrayTexture?(Ii.setTexture2DArray(ln,0),va=Vt.TEXTURE_2D_ARRAY):(Ii.setTexture2D(ln,0),va=Vt.TEXTURE_2D),Vt.pixelStorei(Vt.UNPACK_FLIP_Y_WEBGL,ln.flipY),Vt.pixelStorei(Vt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ln.premultiplyAlpha),Vt.pixelStorei(Vt.UNPACK_ALIGNMENT,ln.unpackAlignment);const lo=Vt.getParameter(Vt.UNPACK_ROW_LENGTH),eu=Vt.getParameter(Vt.UNPACK_IMAGE_HEIGHT),g0=Vt.getParameter(Vt.UNPACK_SKIP_PIXELS),tu=Vt.getParameter(Vt.UNPACK_SKIP_ROWS),Jv=Vt.getParameter(Vt.UNPACK_SKIP_IMAGES);Vt.pixelStorei(Vt.UNPACK_ROW_LENGTH,Jo.width),Vt.pixelStorei(Vt.UNPACK_IMAGE_HEIGHT,Jo.height),Vt.pixelStorei(Vt.UNPACK_SKIP_PIXELS,es),Vt.pixelStorei(Vt.UNPACK_SKIP_ROWS,os),Vt.pixelStorei(Vt.UNPACK_SKIP_IMAGES,Vr);const xa=dt.isDataArrayTexture||dt.isData3DTexture,Iu=ln.isDataArrayTexture||ln.isData3DTexture;if(dt.isDepthTexture){const Lu=pi.get(dt),oc=pi.get(ln),Nc=pi.get(Lu.__renderTarget),QT=pi.get(oc.__renderTarget);Hn.bindFramebuffer(Vt.READ_FRAMEBUFFER,Nc.__webglFramebuffer),Hn.bindFramebuffer(Vt.DRAW_FRAMEBUFFER,QT.__webglFramebuffer);for(let Nm=0;Nm<ur;Nm++)xa&&(Vt.framebufferTextureLayer(Vt.READ_FRAMEBUFFER,Vt.COLOR_ATTACHMENT0,pi.get(dt).__webglTexture,dn,Vr+Nm),Vt.framebufferTextureLayer(Vt.DRAW_FRAMEBUFFER,Vt.COLOR_ATTACHMENT0,pi.get(ln).__webglTexture,_i,La+Nm)),Vt.blitFramebuffer(es,os,$i,wr,$s,Io,$i,wr,Vt.DEPTH_BUFFER_BIT,Vt.NEAREST);Hn.bindFramebuffer(Vt.READ_FRAMEBUFFER,null),Hn.bindFramebuffer(Vt.DRAW_FRAMEBUFFER,null)}else if(dn!==0||dt.isRenderTargetTexture||pi.has(dt)){const Lu=pi.get(dt),oc=pi.get(ln);Hn.bindFramebuffer(Vt.READ_FRAMEBUFFER,Dq),Hn.bindFramebuffer(Vt.DRAW_FRAMEBUFFER,Oq);for(let Nc=0;Nc<ur;Nc++)xa?Vt.framebufferTextureLayer(Vt.READ_FRAMEBUFFER,Vt.COLOR_ATTACHMENT0,Lu.__webglTexture,dn,Vr+Nc):Vt.framebufferTexture2D(Vt.READ_FRAMEBUFFER,Vt.COLOR_ATTACHMENT0,Vt.TEXTURE_2D,Lu.__webglTexture,dn),Iu?Vt.framebufferTextureLayer(Vt.DRAW_FRAMEBUFFER,Vt.COLOR_ATTACHMENT0,oc.__webglTexture,_i,La+Nc):Vt.framebufferTexture2D(Vt.DRAW_FRAMEBUFFER,Vt.COLOR_ATTACHMENT0,Vt.TEXTURE_2D,oc.__webglTexture,_i),dn!==0?Vt.blitFramebuffer(es,os,$i,wr,$s,Io,$i,wr,Vt.COLOR_BUFFER_BIT,Vt.NEAREST):Iu?Vt.copyTexSubImage3D(va,_i,$s,Io,La+Nc,es,os,$i,wr):Vt.copyTexSubImage2D(va,_i,$s,Io,es,os,$i,wr);Hn.bindFramebuffer(Vt.READ_FRAMEBUFFER,null),Hn.bindFramebuffer(Vt.DRAW_FRAMEBUFFER,null)}else Iu?dt.isDataTexture||dt.isData3DTexture?Vt.texSubImage3D(va,_i,$s,Io,La,$i,wr,ur,Bo,jr,Jo.data):ln.isCompressedArrayTexture?Vt.compressedTexSubImage3D(va,_i,$s,Io,La,$i,wr,ur,Bo,Jo.data):Vt.texSubImage3D(va,_i,$s,Io,La,$i,wr,ur,Bo,jr,Jo):dt.isDataTexture?Vt.texSubImage2D(Vt.TEXTURE_2D,_i,$s,Io,$i,wr,Bo,jr,Jo.data):dt.isCompressedTexture?Vt.compressedTexSubImage2D(Vt.TEXTURE_2D,_i,$s,Io,Jo.width,Jo.height,Bo,Jo.data):Vt.texSubImage2D(Vt.TEXTURE_2D,_i,$s,Io,$i,wr,Bo,jr,Jo);Vt.pixelStorei(Vt.UNPACK_ROW_LENGTH,lo),Vt.pixelStorei(Vt.UNPACK_IMAGE_HEIGHT,eu),Vt.pixelStorei(Vt.UNPACK_SKIP_PIXELS,g0),Vt.pixelStorei(Vt.UNPACK_SKIP_ROWS,tu),Vt.pixelStorei(Vt.UNPACK_SKIP_IMAGES,Jv),_i===0&&ln.generateMipmaps&&Vt.generateMipmap(va),Hn.unbindTexture()},this.initRenderTarget=function(dt){pi.get(dt).__webglFramebuffer===void 0&&Ii.setupRenderTarget(dt)},this.initTexture=function(dt){dt.isCubeTexture?Ii.setTextureCube(dt,0):dt.isData3DTexture?Ii.setTexture3D(dt,0):dt.isDataArrayTexture||dt.isCompressedArrayTexture?Ii.setTexture2DArray(dt,0):Ii.setTexture2D(dt,0),Hn.unbindTexture()},this.resetState=function(){ve=0,Oe=0,He=null,Hn.reset(),Hi.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return so}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 mk=["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"],Fw=new WeakMap;class gk{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=mk,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],ee=s[z];if(I.equals!==void 0){if(I.equals(ee)===!1)return I.copy(ee),!1}else if(ee.isTexture===!0){if(I.id!==ee.id||I.version!==ee.version)return I.id=ee.id,I.version=ee.version,!1}else if(I!==ee)return c[z]=ee,!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],ee=d[z];if(ee===void 0)return delete p[z],!1;if(I.version!==ee.version)return I.version=ee.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(Fw.has(e)){const s=Fw.get(e);if(s.renderId===t)return s.lightsData}const n=this.getLightsData(e.getLights());return Fw.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 Hy(r,e=0){let t=3735928559^e,n=1103547991^e;if(r instanceof Array)for(let s=0,o;s<r.length;s++)o=r[s],t=Math.imul(t^o,2654435761),n=Math.imul(n^o,1597334677);else for(let s=0,o;s<r.length;s++)o=r.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 Bw=r=>Hy(r),$y=r=>Hy(r),jy=(...r)=>Hy(r);function Uw(r,e=!1){const t=[];r.isNode===!0&&t.push(r.id);for(const{property:n,childNode:s}of Xy(r))t.push(Hy(n.slice(0,-4)),s.getCacheKey(e));return Hy(t)}function*Xy(r,e=!1){for(const t of Object.getOwnPropertyNames(r)){if(t.startsWith("_")===!0)continue;const n=r[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 yk=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),FA=new WeakMap;function kw(r){return yk.get(r)}function qy(r){if(/[iu]?vec\d/.test(r))return r.startsWith("ivec")?Int32Array:r.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(r)||/float/.test(r))return Float32Array;if(/uint/.test(r))return Uint32Array;if(/int/.test(r))return Int32Array;throw new Error(`THREE.NodeUtils: Unsupported type: ${r}`)}function zw(r){if(/float|int|uint/.test(r))return 1;if(/vec2/.test(r))return 2;if(/vec3/.test(r))return 3;if(/vec4/.test(r)||/mat2/.test(r))return 4;if(/mat3/.test(r))return 9;if(/mat4/.test(r))return 16;console.error("THREE.TSL: Unsupported type:",r)}function BA(r){if(/float|int|uint/.test(r))return 1;if(/vec2/.test(r))return 2;if(/vec3/.test(r))return 3;if(/vec4/.test(r)||/mat2/.test(r))return 4;if(/mat3/.test(r))return 12;if(/mat4/.test(r))return 16;console.error("THREE.TSL: Unsupported type:",r)}function UA(r){if(/float|int|uint/.test(r))return 4;if(/vec2/.test(r))return 8;if(/vec3/.test(r)||/vec4/.test(r))return 16;if(/mat2/.test(r))return 8;if(/mat3/.test(r))return 48;if(/mat4/.test(r))return 64;console.error("THREE.TSL: Unsupported type:",r)}function Rd(r){if(r==null)return null;const e=typeof r;return r.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":r.isVector2===!0?"vec2":r.isVector3===!0?"vec3":r.isVector4===!0?"vec4":r.isMatrix2===!0?"mat2":r.isMatrix3===!0?"mat3":r.isMatrix4===!0?"mat4":r.isColor===!0?"color":r instanceof ArrayBuffer?"ArrayBuffer":null}function m_(r,...e){const t=r?r.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]])),r==="color"?new jn(...e):t==="vec2"?new yn(...e):t==="vec3"?new ot(...e):t==="vec4"?new mr(...e):t==="mat2"?new Wp(...e):t==="mat3"?new $r(...e):t==="mat4"?new Ft(...e):r==="bool"?e[0]||!1:r==="float"||r==="int"||r==="uint"?e[0]||0:r==="string"?e[0]||"":r==="ArrayBuffer"?Ww(e[0]):null}function Vw(r){let e=FA.get(r);return e===void 0&&(e={},FA.set(r,e)),e}function Gw(r){let e="";const t=new Uint8Array(r);for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function Ww(r){return Uint8Array.from(atob(r),e=>e.charCodeAt(0)).buffer}var TY=Object.freeze({__proto__:null,arrayBufferToBase64:Gw,base64ToArrayBuffer:Ww,getByteBoundaryFromType:UA,getCacheKey:Uw,getDataFromObject:Vw,getLengthFromType:zw,getMemoryLengthFromType:BA,getNodeChildren:Xy,getTypeFromLength:kw,getTypedArrayFromType:qy,getValueFromType:m_,getValueType:Rd,hash:jy,hashArray:$y,hashString:Bw});const Yy={VERTEX:"vertex",FRAGMENT:"fragment"},rs={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},vk={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Nl={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},kA=["fragment","vertex"],Hw=["setup","analyze","generate"],$w=[...kA,"compute"],tm=["x","y","z","w"],xk={analyze:"setup",generate:"analyze"};let _k=0;class Wi extends Ol{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=rs.NONE,this.updateBeforeType=rs.NONE,this.updateAfterType=rs.NONE,this.uuid=Yh.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:_k++})}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,rs.FRAME)}onRenderUpdate(e){return this.onUpdate(e,rs.RENDER)}onObjectUpdate(e){return this.onUpdate(e,rs.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of Xy(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=jy(Uw(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=xk[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 Xy(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 nm 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 zA 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 Ra 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 bk extends Ra{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 wk=tm.join("");class VA 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(tm.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===wk.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 Mk extends Ra{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=tm[y];M===n[0]?(m.push(u),y+=n.length-1):m.push(d+"."+M)}return`${e.getType(o)}( ${m.join(", ")} )`}}class Sk extends Ra{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=tm[m];y===t[p]?(d.push("1.0 - "+(c+"."+y)),p++):d.push(c+"."+y)}return`${e.getType(s)}( ${d.join(", ")} )`}}class jw 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?Rd(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=Rd(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=Gw(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?m_(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 GA=/float|u?int/;class _u extends jw{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 GA.test(n)&&GA.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}}class Tk 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 Ff=null;const Xw=new Map;function An(r,e){if(Xw.has(r)){console.warn(`THREE.TSL: Redefinition of method chaining '${r}'.`);return}if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${r} is not a function`);Xw.set(r,e),r!=="assign"&&(Wi.prototype[r]=function(...t){return this.isStackNode?this.add(e(...t)):e(this,...t)},Wi.prototype[r+"Assign"]=function(...t){return this.isStackNode?this.assign(t[0],e(...t)):this.assign(e(this,...t))})}const Ek=r=>r.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),WA=r=>Ek(r).split("").sort().join("");Wi.prototype.assign=function(...r){if(this.isStackNode!==!0)return Ff!==null?Ff.assign(this,...r):console.error("THREE.TSL: No stack defined for assign operation. Make sure the assign is inside a Fn()."),this;{const e=Xw.get("assign");return this.add(e(...r))}},Wi.prototype.toVarIntent=function(){return this},Wi.prototype.get=function(r){return new Tk(this,r)};const Zy={};function g_(r,e,t){Zy[r]=Zy[e]=Zy[t]={get(){this._cache=this._cache||{};let a=this._cache[r];return a===void 0&&(a=new VA(this,r),this._cache[r]=a),a},set(a){this[r].assign(Cn(a))}};const n=r.toUpperCase(),s=e.toUpperCase(),o=t.toUpperCase();Wi.prototype["set"+n]=Wi.prototype["set"+s]=Wi.prototype["set"+o]=function(a){const c=WA(r);return new Mk(this,c,Cn(a))},Wi.prototype["flip"+n]=Wi.prototype["flip"+s]=Wi.prototype["flip"+o]=function(){const a=WA(r);return new Sk(this,a)}}const Ch=["x","y","z","w"],Rh=["r","g","b","a"],Nh=["s","t","p","q"];for(let r=0;r<4;r++){let e=Ch[r],t=Rh[r],n=Nh[r];g_(e,t,n);for(let s=0;s<4;s++){e=Ch[r]+Ch[s],t=Rh[r]+Rh[s],n=Nh[r]+Nh[s],g_(e,t,n);for(let o=0;o<4;o++){e=Ch[r]+Ch[s]+Ch[o],t=Rh[r]+Rh[s]+Rh[o],n=Nh[r]+Nh[s]+Nh[o],g_(e,t,n);for(let a=0;a<4;a++)e=Ch[r]+Ch[s]+Ch[o]+Ch[a],t=Rh[r]+Rh[s]+Rh[o]+Rh[a],n=Nh[r]+Nh[s]+Nh[o]+Nh[a],g_(e,t,n)}}}for(let r=0;r<32;r++)Zy[r]={get(){this._cache=this._cache||{};let e=this._cache[r];return e===void 0&&(e=new nm(this,new _u(r,"uint")),this._cache[r]=e),e},set(e){this[r].assign(Cn(e))}};Object.defineProperties(Wi.prototype,Zy);const HA=new WeakMap,Ak=function(r,e=null){const t=Rd(r);return t==="node"?r:e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string"?Cn(Kw(r,e)):t==="shader"?r.isFn?r:Kt(r):r},Ck=function(r,e=null){for(const t in r)r[t]=Cn(r[t],e);return r},Rk=function(r,e=null){const t=r.length;for(let n=0;n<t;n++)r[n]=Cn(r[n],e);return r},$A=function(r,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=r.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 r(...im(d(p)))):t!==null?(t=Cn(t),o=(...p)=>s(new r(e,...im(d(p)),t))):o=(...p)=>s(new r(e,...im(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},Nk=function(r,...e){return Cn(new r(...im(e)))};class Pk 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=HA.get(e.constructor);d===void 0&&(d=new WeakMap,HA.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?Ik(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?Lk(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 Ik(r){let e;return x_(r),r[0]&&(r[0].isNode||Object.getPrototypeOf(r[0])!==Object.prototype)?e=[...r]:e=r[0],e}function Lk(r){let e=0;return x_(r),new Proxy(r,{get:(t,n,s)=>{let o;if(n==="length")return o=r.length,o;if(Symbol.iterator===n)o=function*(){for(const a of r)yield Cn(a)};else{if(r.length>0)if(Object.getPrototypeOf(r[0])===Object.prototype){const a=r[0];a[n]===void 0?o=a[e++]:o=Reflect.get(a,n,s)}else r[0]instanceof Wi&&(r[n]===void 0?o=r[e++]:o=Reflect.get(r,n,s));else o=Reflect.get(t,n,s);o=Cn(o)}return o}})}class Dk 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 Pk(this,e))}setup(){return this.call()}}const Ok=[!1,!0],Fk=[0,1,2,3],Bk=[-1,-2],jA=[.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],qw=new Map;for(const r of Ok)qw.set(r,new _u(r));const Yw=new Map;for(const r of Fk)Yw.set(r,new _u(r,"uint"));const Zw=new Map([...Yw].map(r=>new _u(r.value,"int")));for(const r of Bk)Zw.set(r,new _u(r,"int"));const y_=new Map([...Zw].map(r=>new _u(r.value)));for(const r of jA)y_.set(r,new _u(r));for(const r of jA)y_.set(-r,new _u(-r));const v_={bool:qw,uint:Yw,ints:Zw,float:y_},XA=new Map([...qw,...y_]),Kw=(r,e)=>XA.has(r)?XA.get(r):r.isNode===!0?r:new _u(r,e),tl=function(r,e=null){return(...t)=>{for(const s of t)if(s===void 0)return console.error(`THREE.TSL: Invalid parameter for the type "${r}".`),Cn(new _u(0,r));if((t.length===0||!["bool","float","int","uint"].includes(r)&&t.every(s=>{const o=typeof s;return o!=="object"&&o!=="function"}))&&(t=[m_(r,...t)]),t.length===1&&e!==null&&e.has(t[0]))return Jy(e.get(t[0]));if(t.length===1){const s=Kw(t[0],r);return s.nodeType===r?Jy(s):Jy(new zA(s,r))}const n=t.map(s=>Kw(s));return Jy(new bk(n,r))}},Ky=r=>typeof r=="object"&&r!==null?r.value:r,qA=r=>r!=null?r.nodeType||r.convertTo||(typeof r=="string"?r:null):null;function Bg(r,e){return new Dk(r,e)}const Cn=(r,e=null)=>Ak(r,e),Jy=(r,e=null)=>Cn(r,e).toVarIntent(),x_=(r,e=null)=>new Ck(r,e),im=(r,e=null)=>new Rk(r,e),zr=(r,e=null,t=null,n=null)=>new $A(r,e,t,n),xi=(r,...e)=>new Nk(r,...e),ci=(r,e=null,t=null,n={})=>new $A(r,e,t,qs({intent:!0},n));let Uk=0;class kk 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 Bg(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"+Uk++,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(r,e=null){const t=new kk(r,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 Qy=r=>{Ff=r},__=()=>Ff,sr=(...r)=>Ff.If(...r),zk=(...r)=>Ff.Switch(...r);function b_(r){return Ff&&Ff.add(r),r}An("toStack",b_);const YA=new tl("color"),ut=new tl("float",v_.float),Dt=new tl("int",v_.ints),Li=new tl("uint",v_.uint),bu=new tl("bool",v_.bool),Bn=new tl("vec2"),pl=new tl("ivec2"),ZA=new tl("uvec2"),KA=new tl("bvec2"),qt=new tl("vec3"),JA=new tl("ivec3"),Ug=new tl("uvec3"),Jw=new tl("bvec3"),Bi=new tl("vec4"),QA=new tl("ivec4"),eC=new tl("uvec4"),tC=new tl("bvec4"),w_=new tl("mat2"),Wl=new tl("mat3"),rm=new tl("mat4"),Vk=(r="")=>Cn(new _u(r,"string")),Gk=r=>Cn(new _u(r,"ArrayBuffer"));An("toColor",YA),An("toFloat",ut),An("toInt",Dt),An("toUint",Li),An("toBool",bu),An("toVec2",Bn),An("toIVec2",pl),An("toUVec2",ZA),An("toBVec2",KA),An("toVec3",qt),An("toIVec3",JA),An("toUVec3",Ug),An("toBVec3",Jw),An("toVec4",Bi),An("toIVec4",QA),An("toUVec4",eC),An("toBVec4",tC),An("toMat2",w_),An("toMat3",Wl),An("toMat4",rm);const nC=zr(nm).setParameterLength(2),iC=(r,e)=>Cn(new zA(Cn(r),e)),Wk=(r,e)=>Cn(new VA(Cn(r),e));An("element",nC),An("convert",iC);const Hk=r=>(console.warn("THREE.TSL: append() has been renamed to Stack()."),b_(r));An("append",r=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),b_(r)));class ho 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 th=(r,e)=>Cn(new ho(r,e)),$c=(r,e)=>Cn(new ho(r,e,!0)),to=xi(ho,"vec4","DiffuseColor"),Qw=xi(ho,"vec3","EmissiveColor"),Ph=xi(ho,"float","Roughness"),ev=xi(ho,"float","Metalness"),M_=xi(ho,"float","Clearcoat"),tv=xi(ho,"float","ClearcoatRoughness"),sm=xi(ho,"vec3","Sheen"),S_=xi(ho,"float","SheenRoughness"),T_=xi(ho,"float","Iridescence"),eM=xi(ho,"float","IridescenceIOR"),tM=xi(ho,"float","IridescenceThickness"),E_=xi(ho,"float","AlphaT"),Bf=xi(ho,"float","Anisotropy"),nv=xi(ho,"vec3","AnisotropyT"),om=xi(ho,"vec3","AnisotropyB"),Mc=xi(ho,"color","SpecularColor"),iv=xi(ho,"float","SpecularF90"),A_=xi(ho,"float","Shininess"),kg=xi(ho,"vec4","Output"),am=xi(ho,"float","dashSize"),rv=xi(ho,"float","gapSize"),$k=xi(ho,"float","pointWidth"),sv=xi(ho,"float","IOR"),C_=xi(ho,"float","Transmission"),nM=xi(ho,"float","Thickness"),iM=xi(ho,"float","AttenuationDistance"),rM=xi(ho,"color","AttenuationColor"),sM=xi(ho,"float","Dispersion");class rC 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 sC=r=>new rC(r),R_=(r,e=0)=>new rC(r,!0,e),oC=R_("frame"),or=R_("render"),oM=sC("object");class ov extends jw{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=oM}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=(r,e)=>{const t=qA(e||r);return t===r&&(r=m_(t)),r=r&&r.isNode===!0?r.node&&r.node.value||r.value:r,Cn(new ov(r,t))};class aC extends Ra{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 lC=(...r)=>{let e;if(r.length===1){const t=r[0];e=new aC(null,t.length,t)}else{const t=r[0],n=r[1];e=new aC(t,n)}return Cn(e)};An("toArray",(r,e)=>lC(Array(e).fill(r)));class jk extends Ra{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 tm.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 ee=T.components[I];e.addLineFlowCode(`${z}.${ee} = ${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 cC=zr(jk).setParameterLength(2);An("assign",cC);class Xk extends Ra{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(ut(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(ut(0),u)))}return`${n.build(e,"property")}( ${t.join(", ")} )`}}const uC=(r,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?im(e):x_(e[0]),Cn(new Xk(Cn(r),e)));An("call",uC);const qk={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class ra extends Ra{static get type(){return"OperatorNode"}constructor(e,t,n,...s){if(super(),s.length>0){let o=new ra(e,t,n);for(let a=0;a<s.length-1;a++)o=new ra(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(qk[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===so;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 Wa=ci(ra,"+").setParameterLength(2,1/0).setName("add"),Ds=ci(ra,"-").setParameterLength(2,1/0).setName("sub"),Kr=ci(ra,"*").setParameterLength(2,1/0).setName("mul"),jc=ci(ra,"/").setParameterLength(2,1/0).setName("div"),av=ci(ra,"%").setParameterLength(2).setName("mod"),aM=ci(ra,"==").setParameterLength(2).setName("equal"),hC=ci(ra,"!=").setParameterLength(2).setName("notEqual"),dC=ci(ra,"<").setParameterLength(2).setName("lessThan"),lM=ci(ra,">").setParameterLength(2).setName("greaterThan"),fC=ci(ra,"<=").setParameterLength(2).setName("lessThanEqual"),pC=ci(ra,">=").setParameterLength(2).setName("greaterThanEqual"),mC=ci(ra,"&&").setParameterLength(2,1/0).setName("and"),gC=ci(ra,"||").setParameterLength(2,1/0).setName("or"),yC=ci(ra,"!").setParameterLength(1).setName("not"),vC=ci(ra,"^^").setParameterLength(2).setName("xor"),xC=ci(ra,"&").setParameterLength(2).setName("bitAnd"),_C=ci(ra,"~").setParameterLength(2).setName("bitNot"),bC=ci(ra,"|").setParameterLength(2).setName("bitOr"),wC=ci(ra,"^").setParameterLength(2).setName("bitXor"),MC=ci(ra,"<<").setParameterLength(2).setName("shiftLeft"),SC=ci(ra,">>").setParameterLength(2).setName("shiftRight"),TC=Kt(([r])=>(r.addAssign(1),r)),EC=Kt(([r])=>(r.subAssign(1),r)),AC=Kt(([r])=>{const e=Dt(r).toConst();return r.addAssign(1),e}),CC=Kt(([r])=>{const e=Dt(r).toConst();return r.subAssign(1),e});An("add",Wa),An("sub",Ds),An("mul",Kr),An("div",jc),An("mod",av),An("equal",aM),An("notEqual",hC),An("lessThan",dC),An("greaterThan",lM),An("lessThanEqual",fC),An("greaterThanEqual",pC),An("and",mC),An("or",gC),An("not",yC),An("xor",vC),An("bitAnd",xC),An("bitNot",_C),An("bitOr",bC),An("bitXor",wC),An("shiftLeft",MC),An("shiftRight",SC),An("incrementBefore",TC),An("decrementBefore",EC),An("increment",AC),An("decrement",CC);const RC=(r,e)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),av(Dt(r),Dt(e)));An("modInt",RC);class an extends Ra{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=Ds(1,t);else if(s===an.RECIPROCAL)o=jc(1,t);else if(s===an.DIFFERENCE)o=Oo(Ds(t,n));else if(s===an.TRANSFORM_DIRECTION){let a=t,c=n;e.isMatrix(a.getNodeType(e))?c=Bi(qt(c),0):a=Bi(qt(a),0);const u=Kr(a,c).xyz;o=Nd(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===so&&s===an.STEP?m.push(c.build(e,e.getTypeLength(c.getNodeType(e))===1?"float":a),u.build(e,a)):p===so&&(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===ja&&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 NC=ut(1e-6),Yk=ut(1e6),N_=ut(Math.PI),Zk=ut(Math.PI*2),PC=ci(an,an.ALL).setParameterLength(1),IC=ci(an,an.ANY).setParameterLength(1),LC=ci(an,an.RADIANS).setParameterLength(1),DC=ci(an,an.DEGREES).setParameterLength(1),cM=ci(an,an.EXP).setParameterLength(1),zg=ci(an,an.EXP2).setParameterLength(1),P_=ci(an,an.LOG).setParameterLength(1),Ih=ci(an,an.LOG2).setParameterLength(1),Lh=ci(an,an.SQRT).setParameterLength(1),uM=ci(an,an.INVERSE_SQRT).setParameterLength(1),Dh=ci(an,an.FLOOR).setParameterLength(1),I_=ci(an,an.CEIL).setParameterLength(1),Nd=ci(an,an.NORMALIZE).setParameterLength(1),Pd=ci(an,an.FRACT).setParameterLength(1),Xc=ci(an,an.SIN).setParameterLength(1),Id=ci(an,an.COS).setParameterLength(1),OC=ci(an,an.TAN).setParameterLength(1),FC=ci(an,an.ASIN).setParameterLength(1),hM=ci(an,an.ACOS).setParameterLength(1),L_=ci(an,an.ATAN).setParameterLength(1,2),Oo=ci(an,an.ABS).setParameterLength(1),lv=ci(an,an.SIGN).setParameterLength(1),Oh=ci(an,an.LENGTH).setParameterLength(1),BC=ci(an,an.NEGATE).setParameterLength(1),UC=ci(an,an.ONE_MINUS).setParameterLength(1),dM=ci(an,an.DFDX).setParameterLength(1),fM=ci(an,an.DFDY).setParameterLength(1),kC=ci(an,an.ROUND).setParameterLength(1),zC=ci(an,an.RECIPROCAL).setParameterLength(1),pM=ci(an,an.TRUNC).setParameterLength(1),VC=ci(an,an.FWIDTH).setParameterLength(1),GC=ci(an,an.TRANSPOSE).setParameterLength(1),WC=ci(an,an.DETERMINANT).setParameterLength(1),HC=ci(an,an.INVERSE).setParameterLength(1),$C=(r,e)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),aM(r,e)),Sc=ci(an,an.MIN).setParameterLength(2,1/0),ga=ci(an,an.MAX).setParameterLength(2,1/0),D_=ci(an,an.STEP).setParameterLength(2),jC=ci(an,an.REFLECT).setParameterLength(2),XC=ci(an,an.DISTANCE).setParameterLength(2),qC=ci(an,an.DIFFERENCE).setParameterLength(2),Uf=ci(an,an.DOT).setParameterLength(2),O_=ci(an,an.CROSS).setParameterLength(2),wu=ci(an,an.POW).setParameterLength(2),mM=r=>Kr(r,r),YC=r=>Kr(r,r,r),ZC=r=>Kr(r,r,r,r),KC=ci(an,an.TRANSFORM_DIRECTION).setParameterLength(2),JC=r=>Kr(lv(r),wu(Oo(r),1/3)),gM=r=>Uf(r,r),Hs=ci(an,an.MIX).setParameterLength(3),Mu=(r,e=0,t=1)=>Cn(new an(an.CLAMP,Cn(r),Cn(e),Cn(t))),yM=r=>Mu(r),vM=ci(an,an.REFRACT).setParameterLength(3),Su=ci(an,an.SMOOTHSTEP).setParameterLength(3),xM=ci(an,an.FACEFORWARD).setParameterLength(3),QC=Kt(([r])=>{const n=43758.5453,s=Uf(r.xy,Bn(12.9898,78.233)),o=av(s,N_);return Pd(Xc(o).mul(n))}),eR=(r,e,t)=>Hs(e,t,r),tR=(r,e,t)=>Su(e,t,r),nR=(r,e)=>D_(e,r),iR=(r,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),L_(r,e)),Kk=xM,Jk=uM;An("all",PC),An("any",IC),An("equals",$C),An("radians",LC),An("degrees",DC),An("exp",cM),An("exp2",zg),An("log",P_),An("log2",Ih),An("sqrt",Lh),An("inverseSqrt",uM),An("floor",Dh),An("ceil",I_),An("normalize",Nd),An("fract",Pd),An("sin",Xc),An("cos",Id),An("tan",OC),An("asin",FC),An("acos",hM),An("atan",L_),An("abs",Oo),An("sign",lv),An("length",Oh),An("lengthSq",gM),An("negate",BC),An("oneMinus",UC),An("dFdx",dM),An("dFdy",fM),An("round",kC),An("reciprocal",zC),An("trunc",pM),An("fwidth",VC),An("atan2",iR),An("min",Sc),An("max",ga),An("step",nR),An("reflect",jC),An("distance",XC),An("dot",Uf),An("cross",O_),An("pow",wu),An("pow2",mM),An("pow3",YC),An("pow4",ZC),An("transformDirection",KC),An("mix",eR),An("clamp",Mu),An("refract",vM),An("smoothstep",tR),An("faceForward",xM),An("difference",qC),An("saturate",yM),An("cbrt",JC),An("transpose",GC),An("determinant",WC),An("inverse",HC),An("rand",QC);class Qk 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?th(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 wl=zr(Qk).setParameterLength(2,3);An("select",wl);class rR 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(qs(qs({},e.context),this.value)),this.node.build(e),e.setContext(t)}setup(e){const t=e.getContext();e.setContext(qs(qs({},e.context),this.value)),this.node.build(e),e.setContext(t)}generate(e,t){const n=e.getContext();e.setContext(qs(qs({},e.context),this.value));const s=this.node.build(e,t);return e.setContext(n),s}}const cv=zr(rR).setParameterLength(1,2),sR=r=>cv(r,{uniformFlow:!0}),_M=(r,e)=>cv(r,{nodeName:e});function oR(r,e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),_M(r,e)}An("context",cv),An("label",oR),An("uniformFlow",sR),An("setName",_M);class F_ 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 bM=zr(F_),aR=(r,e=null)=>bM(r,e).toStack(),lR=(r,e=null)=>bM(r,e,!0).toStack(),cR=r=>__()===null?r:bM(r).setIntent(!0).toStack();An("toVar",aR),An("toConst",lR),An("toVarIntent",cR);class ez 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 Vg=(r,e,t=null)=>Cn(new ez(Cn(r),e,t));class tz 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=Vg(this.node,"VERTEX")}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage==="fragment"),n}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Yy.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Yy.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,Yy.VERTEX);e.flowNodeFromShaderStage(Yy.VERTEX,n.node,o,a),n[t]=a}return e.getPropertyName(s)}}const Fh=zr(tz).setParameterLength(1,2),uR=r=>Fh(r);An("toVarying",Fh),An("toVertexStage",uR),An("varying",(...r)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),Fh(...r))),An("vertexStage",(...r)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),Fh(...r)));const hR=Kt(([r])=>{const e=r.mul(.9478672986).add(.0521327014).pow(2.4),t=r.mul(.0773993808),n=r.lessThanEqual(.04045);return Hs(e,t,n)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),dR=Kt(([r])=>{const e=r.pow(.41666).mul(1.055).sub(.055),t=r.mul(12.92),n=r.lessThanEqual(.0031308);return Hs(e,t,n)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),wM="WorkingColorSpace",nz="OutputColorSpace";class MM extends Ra{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===wM?Ki.workingColorSpace:t===nz?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(hR(o.rgb),o.a)),Ki.getPrimaries(n)!==Ki.getPrimaries(s)&&(o=Bi(Wl(Ki._getMatrix(new $r,n,s)).mul(o.rgb),o.a)),Ki.getTransfer(s)===Fi&&(o=Bi(dR(o.rgb),o.a))),o}}const fR=(r,e)=>Cn(new MM(Cn(r),wM,e)),B_=(r,e)=>Cn(new MM(Cn(r),e,wM)),iz=(r,e,t)=>Cn(new MM(Cn(r),e,t));An("workingToColorSpace",fR),An("colorSpaceToWorking",B_);let rz=class extends nm{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=rs.OBJECT}setGroup(e){return this.group=e,this}element(e){return Cn(new rz(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 sz=(r,e,t)=>Cn(new pR(r,e,t));class oz 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 mR=(r,e,t=null)=>Cn(new oz(r,e,t));class az extends Ra{static get type(){return"ToneMappingNode"}constructor(e,t=yR,n=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return jy(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 gR=(r,e,t)=>Cn(new az(r,Cn(e),Cn(t))),yR=mR("toneMappingExposure","float");An("toneMapping",(r,e,t)=>gR(e,t,r));class lz extends jw{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=Ou,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 Wu(n,o),u=new sf(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=Fh(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 uv=(r,e=null,t=0,n=0)=>Cn(new lz(r,e,t,n)),vR=(r,e=null,t=0,n=0)=>uv(r,e,t,n).setUsage(Zd),U_=(r,e=null,t=0,n=0)=>uv(r,e,t,n).setInstanced(!0),SM=(r,e=null,t=0,n=0)=>vR(r,e,t,n).setInstanced(!0);An("toAttribute",r=>uv(r.value));class cz 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=rs.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 TM=(r,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 cz(Cn(r),e))},xR=(r,e,t)=>TM(r,t).setCount(e);An("compute",xR),An("computeKernel",TM);class uz 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 hv=(r,e)=>Cn(new uz(Cn(r),e));An("cache",hv);class hz 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 _R=zr(hz).setParameterLength(2);An("bypass",_R);class bR extends Wi{static get type(){return"RemapNode"}constructor(e,t,n,s=ut(0),o=ut(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 wR=zr(bR,null,null,{doClamp:!1}).setParameterLength(3,5),MR=zr(bR).setParameterLength(3,5);An("remap",wR),An("remapClamp",MR);class k_ 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 Ld=zr(k_).setParameterLength(1,2),SR=r=>(r?wl(r,Ld("discard")):Ld("discard")).toStack(),dz=()=>Ld("return").toStack();An("discard",SR);class fz extends Ra{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)||Qo;return n!==yt&&(t=t.toneMapping(n)),s!==Qo&&s!==Ki.workingColorSpace&&(t=t.workingToColorSpace(s)),t}}const EM=(r,e=null,t=null)=>Cn(new fz(Cn(r),e,t));An("renderOutput",EM);class pz extends Ra{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 TR=(r,e=null)=>Cn(new pz(Cn(r),e)).toStack();An("debug",TR);function mz(r){console.warn("THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",r)}class ER 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):Fh(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 rc=(r,e=null)=>Cn(new ER(r,e)),vo=(r=0)=>rc("uv"+(r>0?r:""),"vec2");class gz 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 kf=zr(gz).setParameterLength(1,2);class yz extends ov{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=rs.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 AM=zr(yz).setParameterLength(1),CM=new Wo;class Bh extends ov{static get type(){return"TextureNode"}constructor(e=CM,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=rs.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===as?"uvec4":this.value.type===Is?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return vo(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=cr(this.value.matrix)),this._matrixUniform.mul(qt(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?rs.OBJECT:rs.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(kf(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),ee=m?m.build(e,"float"):null,Q=y?y.build(e,"float"):null,oe=T?T.build(e,"int"):null,_e=M?M.build(e,"float"):null,ve=G?[G[0].build(e,"vec2"),G[1].build(e,"vec2")]:null,Oe=z?this.generateOffset(e,z):null,He=e.getVarFromNode(this);c=e.getPropertyName(He);const Ce=this.generateSnippet(e,o,I,ee,Q,oe,_e,ve,Oe);e.addLineFlowCode(`${c} = ${Ce}`,this),a.snippet=Ce,a.propertyName=c}let u=c;const d=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(u=B_(Ld(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(AM(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 kf(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 vz=zr(Bh).setParameterLength(1,4).setName("texture"),Ps=(r=CM,e=null,t=null,n=null)=>{let s;return r&&r.isTextureNode===!0?(s=Cn(r.clone()),s.referenceNode=r.getBase(),e!==null&&(s.uvNode=Cn(e)),t!==null&&(s.levelNode=Cn(t)),n!==null&&(s.biasNode=Cn(n))):s=vz(r,e,t,n),s},xz=(r=CM)=>Ps(r),Na=(...r)=>Ps(...r).setSampler(!1),_z=r=>(r.isNode===!0?r:Ps(r)).convert("sampler"),bz=r=>(r.isNode===!0?r:Ps(r)).convert("samplerComparison");class RM extends ov{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 dv=(r,e,t)=>Cn(new RM(r,e,t));class wz extends nm{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 Mz extends RM{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?Rd(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=rs.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 wz(this,Cn(e)))}}const Hl=(r,e)=>Cn(new Mz(r,e));class Sz extends Wi{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const Dd=zr(Sz).setParameterLength(1);let fv,pv;class Fo extends Wi{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}getNodeType(){return this.scope===Fo.DPR?"float":this.scope===Fo.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=rs.NONE;return(this.scope===Fo.SIZE||this.scope===Fo.VIEWPORT||this.scope===Fo.DPR)&&(e=rs.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===Fo.VIEWPORT?t!==null?pv.copy(t.viewport):(e.getViewport(pv),pv.multiplyScalar(e.getPixelRatio())):this.scope===Fo.DPR?this._output.value=e.getPixelRatio():t!==null?(fv.width=t.width,fv.height=t.height):e.getDrawingBufferSize(fv)}setup(){const e=this.scope;let t=null;return e===Fo.SIZE?t=cr(fv||(fv=new yn)):e===Fo.VIEWPORT?t=cr(pv||(pv=new mr)):e===Fo.DPR?t=cr(1):t=Bn(mv.div(lm)),this._output=t,t}generate(e){if(this.scope===Fo.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const n=e.getNodeProperties(lm).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${n}.y - ${t}.y )`}return t}return super.generate(e)}}Fo.COORDINATE="coordinate",Fo.VIEWPORT="viewport",Fo.SIZE="size",Fo.UV="uv",Fo.DPR="dpr";const AR=xi(Fo,Fo.DPR),Od=xi(Fo,Fo.UV),lm=xi(Fo,Fo.SIZE),mv=xi(Fo,Fo.COORDINATE),Gg=xi(Fo,Fo.VIEWPORT),NM=Gg.zw,CR=mv.sub(Gg.xy),Tz=CR.div(NM),Ez=Kt(()=>(console.warn('THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),lm),"vec2").once()(),zf=cr(0,"uint").setName("u_cameraIndex").setGroup(R_("cameraIndex")).toVarying("v_cameraIndex"),Fd=cr("float").setName("cameraNear").setGroup(or).onRenderUpdate(({camera:r})=>r.near),Bd=cr("float").setName("cameraFar").setGroup(or).onRenderUpdate(({camera:r})=>r.far),Tu=Kt(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){const t=[];for(const s of r.cameras)t.push(s.projectionMatrix);e=Hl(t).setGroup(or).setName("cameraProjectionMatrices").element(r.isMultiViewCamera?Dd("gl_ViewID_OVR"):zf).toConst("cameraProjectionMatrix")}else e=cr("mat4").setName("cameraProjectionMatrix").setGroup(or).onRenderUpdate(({camera:t})=>t.projectionMatrix);return e}).once()(),Az=Kt(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){const t=[];for(const s of r.cameras)t.push(s.projectionMatrixInverse);e=Hl(t).setGroup(or).setName("cameraProjectionMatricesInverse").element(r.isMultiViewCamera?Dd("gl_ViewID_OVR"):zf).toConst("cameraProjectionMatrixInverse")}else e=cr("mat4").setName("cameraProjectionMatrixInverse").setGroup(or).onRenderUpdate(({camera:t})=>t.projectionMatrixInverse);return e}).once()(),qc=Kt(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){const t=[];for(const s of r.cameras)t.push(s.matrixWorldInverse);e=Hl(t).setGroup(or).setName("cameraViewMatrices").element(r.isMultiViewCamera?Dd("gl_ViewID_OVR"):zf).toConst("cameraViewMatrix")}else e=cr("mat4").setName("cameraViewMatrix").setGroup(or).onRenderUpdate(({camera:t})=>t.matrixWorldInverse);return e}).once()(),Cz=Kt(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){const t=[];for(const s of r.cameras)t.push(s.matrixWorld);e=Hl(t).setGroup(or).setName("cameraWorldMatrices").element(r.isMultiViewCamera?Dd("gl_ViewID_OVR"):zf).toConst("cameraWorldMatrix")}else e=cr("mat4").setName("cameraWorldMatrix").setGroup(or).onRenderUpdate(({camera:t})=>t.matrixWorld);return e}).once()(),Rz=Kt(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){const t=[];for(const s of r.cameras)t.push(s.normalMatrix);e=Hl(t).setGroup(or).setName("cameraNormalMatrices").element(r.isMultiViewCamera?Dd("gl_ViewID_OVR"):zf).toConst("cameraNormalMatrix")}else e=cr("mat3").setName("cameraNormalMatrix").setGroup(or).onRenderUpdate(({camera:t})=>t.normalMatrix);return e}).once()(),gv=Kt(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){const t=[];for(let s=0,o=r.cameras.length;s<o;s++)t.push(new ot);e=Hl(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(r.isMultiViewCamera?Dd("gl_ViewID_OVR"):zf).toConst("cameraPosition")}else e=cr(new ot).setName("cameraPosition").setGroup(or).onRenderUpdate(({camera:t},n)=>n.value.setFromMatrixPosition(t.matrixWorld));return e}).once()(),Nz=Kt(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){const t=[];for(const s of r.cameras)t.push(s.viewport);e=Hl(t,"vec4").setGroup(or).setName("cameraViewports").element(zf).toConst("cameraViewport")}else e=Bi(0,0,lm.x,lm.y).toConst("cameraViewport");return e}).once()(),RR=new we;class Fs extends Wi{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=rs.OBJECT,this.uniformNode=new ov(null)}getNodeType(){const e=this.scope;if(e===Fs.WORLD_MATRIX)return"mat4";if(e===Fs.POSITION||e===Fs.VIEW_POSITION||e===Fs.DIRECTION||e===Fs.SCALE)return"vec3";if(e===Fs.RADIUS)return"float"}update(e){const t=this.object3d,n=this.uniformNode,s=this.scope;if(s===Fs.WORLD_MATRIX)n.value=t.matrixWorld;else if(s===Fs.POSITION)n.value=n.value||new ot,n.value.setFromMatrixPosition(t.matrixWorld);else if(s===Fs.SCALE)n.value=n.value||new ot,n.value.setFromMatrixScale(t.matrixWorld);else if(s===Fs.DIRECTION)n.value=n.value||new ot,t.getWorldDirection(n.value);else if(s===Fs.VIEW_POSITION){const o=e.camera;n.value=n.value||new ot,n.value.setFromMatrixPosition(t.matrixWorld),n.value.applyMatrix4(o.matrixWorldInverse)}else if(s===Fs.RADIUS){const o=e.object.geometry;o.boundingSphere===null&&o.computeBoundingSphere(),RR.copy(o.boundingSphere).applyMatrix4(t.matrixWorld),n.value=RR.radius}}generate(e){const t=this.scope;return t===Fs.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===Fs.POSITION||t===Fs.VIEW_POSITION||t===Fs.DIRECTION||t===Fs.SCALE?this.uniformNode.nodeType="vec3":t===Fs.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}}Fs.WORLD_MATRIX="worldMatrix",Fs.POSITION="position",Fs.SCALE="scale",Fs.VIEW_POSITION="viewPosition",Fs.DIRECTION="direction",Fs.RADIUS="radius";const Pz=zr(Fs,Fs.DIRECTION).setParameterLength(1),Iz=zr(Fs,Fs.WORLD_MATRIX).setParameterLength(1),NR=zr(Fs,Fs.POSITION).setParameterLength(1),Lz=zr(Fs,Fs.SCALE).setParameterLength(1),Dz=zr(Fs,Fs.VIEW_POSITION).setParameterLength(1),Oz=zr(Fs,Fs.RADIUS).setParameterLength(1);class Eu extends Fs{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const Fz=xi(Eu,Eu.DIRECTION),Au=xi(Eu,Eu.WORLD_MATRIX),Bz=xi(Eu,Eu.POSITION),Uz=xi(Eu,Eu.SCALE),kz=xi(Eu,Eu.VIEW_POSITION),PR=xi(Eu,Eu.RADIUS),IR=cr(new $r).onObjectUpdate(({object:r},e)=>e.value.getNormalMatrix(r.matrixWorld)),zz=cr(new Ft).onObjectUpdate(({object:r},e)=>e.value.copy(r.matrixWorld).invert()),Ud=Kt(r=>r.renderer.overrideNodes.modelViewMatrix||LR).once()().toVar("modelViewMatrix"),LR=qc.mul(Au),PM=Kt(r=>(r.context.isHighPrecisionModelViewMatrix=!0,cr("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),IM=Kt(r=>{const e=r.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"),Pl=rc("position","vec3"),Pa=Pl.toVarying("positionLocal"),z_=Pl.toVarying("positionPrevious"),Yc=Kt(r=>Au.mul(Pa).xyz.toVarying(r.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),LM=Kt(()=>Pa.transformDirection(Au).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),Ia=Kt(r=>r.context.setupPositionView().toVarying("v_positionView"),"vec3").once(["POSITION"])(),Vo=Ia.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection");class Vz 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===K?"false":e.getFrontFacing()}}const DR=xi(Vz),DM=ut(DR).mul(2).sub(1),Wg=Kt(([r],{material:e})=>{const t=e.side;return t===K?r=r.mul(-1):t===re&&(r=r.mul(DM)),r}),V_=rc("normal","vec3"),Tc=Kt(r=>r.geometry.hasAttribute("normal")===!1?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),qt(0,1,0)):V_,"vec3").once()().toVar("normalLocal"),OR=Ia.dFdx().cross(Ia.dFdy()).normalize().toVar("normalFlat"),Hg=Kt(r=>{let e;return r.material.flatShading===!0?e=OR:e=OM(Tc).toVarying("v_normalViewGeometry").normalize(),e},"vec3").once()().toVar("normalViewGeometry"),FR=Kt(r=>{let e=Hg.transformDirection(qc);return r.material.flatShading!==!0&&(e=e.toVarying("v_normalWorldGeometry")),e.normalize().toVar("normalWorldGeometry")},"vec3").once()(),fo=Kt(({subBuildFn:r,material:e,context:t})=>{let n;return r==="NORMAL"||r==="VERTEX"?(n=Hg,e.flatShading!==!0&&(n=Wg(n))):n=t.setupNormal().context({getUV:null}),n},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),Vf=fo.transformDirection(qc).toVar("normalWorld"),cm=Kt(({subBuildFn:r,context:e})=>{let t;return r==="NORMAL"||r==="VERTEX"?t=fo:t=e.setupClearcoatNormal().context({getUV:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),BR=Kt(([r,e=Au])=>{const t=Wl(e),n=r.div(qt(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(n).xyz}),OM=Kt(([r],e)=>{const t=e.renderer.overrideNodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(r);const n=IR.mul(r);return qc.transformDirection(n)}),Gz=Kt(()=>(console.warn('THREE.TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),fo)).once(["NORMAL","VERTEX"])(),Wz=Kt(()=>(console.warn('THREE.TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),Vf)).once(["NORMAL","VERTEX"])(),Hz=Kt(()=>(console.warn('THREE.TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),cm)).once(["NORMAL","VERTEX"])(),UR=new Qi,FM=new Ft,kR=cr(0).onReference(({material:r})=>r).onObjectUpdate(({material:r})=>r.refractionRatio),G_=cr(1).onReference(({material:r})=>r).onObjectUpdate(function({material:r,scene:e}){return r.envMap?r.envMapIntensity:e.environmentIntensity}),BM=cr(new Ft).onReference(function(r){return r.material}).onObjectUpdate(function({material:r,scene:e}){const t=e.environment!==null&&r.envMap===null?e.environmentRotation:r.envMapRotation;return t?(UR.copy(t),FM.makeRotationFromEuler(UR)):FM.identity(),FM}),zR=Vo.negate().reflect(fo),VR=Vo.negate().refract(fo,kR),GR=zR.transformDirection(qc).toVar("reflectVector"),WR=VR.transformDirection(qc).toVar("reflectVector"),HR=new ph;class $z extends Bh{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===Fe?GR:e.mapping===Xe?WR:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),qt(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return(e.renderer.coordinateSystem===ja||!n.isRenderTargetTexture)&&(t=qt(t.x.negate(),t.yz)),BM.mul(t)}generateUV(e,t){return t.build(e,"vec3")}}const UM=zr($z).setParameterLength(1,4).setName("cubeTexture"),$g=(r=HR,e=null,t=null,n=null)=>{let s;return r&&r.isCubeTextureNode===!0?(s=Cn(r.clone()),s.referenceNode=r,e!==null&&(s.uvNode=Cn(e)),t!==null&&(s.levelNode=Cn(t)),n!==null&&(s.biasNode=Cn(n))):s=UM(r,e,t,n),s},jz=(r=HR)=>UM(r);class Xz extends nm{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 W_ 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=rs.OBJECT}element(e){return Cn(new Xz(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=dv(null,e,this.count):Array.isArray(this.getValueFromReference())?t=Hl(null,e):e==="texture"?t=Ps(null):e==="cubeTexture"?t=$g(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 No=(r,e,t)=>Cn(new W_(r,e,t)),kM=(r,e,t,n)=>Cn(new W_(r,e,n,t));class qz extends W_{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 kd=(r,e,t=null)=>Cn(new qz(r,e,t)),$R=vo(),Yz=Ia.dFdx(),Zz=Ia.dFdy(),jR=$R.dFdx(),XR=$R.dFdy(),qR=fo,YR=Zz.cross(qR),ZR=qR.cross(Yz),zM=YR.mul(jR.x).add(ZR.mul(XR.x)),VM=YR.mul(jR.y).add(ZR.mul(XR.y)),KR=zM.dot(zM).max(VM.dot(VM)),JR=KR.equal(0).select(0,KR.inverseSqrt()),Kz=zM.mul(JR).toVar("tangentViewFrame"),Jz=VM.mul(JR).toVar("bitangentViewFrame"),H_=Kt(r=>(r.geometry.hasAttribute("tangent")===!1&&r.geometry.computeTangents(),rc("tangent","vec4")))(),yv=H_.xyz.toVar("tangentLocal"),$_=Kt(({subBuildFn:r,geometry:e,material:t})=>{let n;return r==="VERTEX"||e.hasAttribute("tangent")?n=Ud.mul(Bi(yv,0)).xyz.toVarying("v_tangentView").normalize():n=Kz,t.flatShading!==!0&&(n=Wg(n)),n},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),QR=$_.transformDirection(qc).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),j_=Kt(([r,e],{subBuildFn:t,material:n})=>{let s=r.mul(H_.w).xyz;return t==="NORMAL"&&n.flatShading!==!0&&(s=s.toVarying(e)),s}).once(["NORMAL"]),Qz=j_(V_.cross(H_),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),e4=j_(Tc.cross(yv),"v_bitangentLocal").normalize().toVar("bitangentLocal"),e2=Kt(({subBuildFn:r,geometry:e,material:t})=>{let n;return r==="VERTEX"||e.hasAttribute("tangent")?n=j_(fo.cross($_),"v_bitangentView").normalize():n=Jz,t.flatShading!==!0&&(n=Wg(n)),n},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),t4=j_(Vf.cross(QR),"v_bitangentWorld").normalize().toVar("bitangentWorld"),um=Wl($_,e2,fo).toVar("TBNViewMatrix"),t2=Vo.mul(um),n4=(r,e)=>r.sub(t2.mul(e)),n2=Kt(()=>{let r=om.cross(Vo);return r=r.cross(om).normalize(),r=Hs(r,fo,Bf.mul(Ph.oneMinus()).oneMinus().pow2().pow2()).normalize(),r}).once()();class i4 extends Ra{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=$a}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=Wg(a)),s=qt(s.xy.mul(a),s.z)}let o=null;return t===jd?o=OM(s):t===$a?o=um.mul(s).normalize():(console.error(`THREE.NodeMaterial: Unsupported normal map type: ${t}`),o=fo),o}}const GM=zr(i4).setParameterLength(1,2),r4=Kt(({textureNode:r,bumpScale:e})=>{const t=s=>r.cache().context({getUV:o=>s(o.uvNode||vo()),forceUVContext:!0}),n=ut(t(s=>s));return Bn(ut(t(s=>s.add(s.dFdx()))).sub(n),ut(t(s=>s.add(s.dFdy()))).sub(n)).mul(e)}),s4=Kt(r=>{const{surf_pos:e,surf_norm:t,dHdxy:n}=r,s=e.dFdx().normalize(),o=e.dFdy().normalize(),a=t,c=o.cross(a),u=a.cross(s),d=s.dot(c).mul(DM),p=d.sign().mul(n.x.mul(c).add(n.y.mul(u)));return d.abs().mul(t).sub(p).normalize()});class o4 extends Ra{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=r4({textureNode:this.textureNode,bumpScale:e});return s4({surf_pos:Ia,surf_norm:fo,dHdxy:t})}}const WM=zr(o4).setParameterLength(1,2),i2=new Map;class Ln extends Wi{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let n=i2.get(e);return n===void 0&&(n=kd(e,t),i2.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):qt();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=ut(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=GM(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=t.normalMapType):t.bumpMap?s=WM(this.getTexture("bump").r,this.getFloat("bumpScale")):s=fo;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=GM(this.getTexture(n),this.getCache(n+"Scale","vec2")):s=fo;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=w_(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=No("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const a=No("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):ut(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 r2=xi(Ln,Ln.ALPHA_TEST),X_=xi(Ln,Ln.COLOR),s2=xi(Ln,Ln.SHININESS),o2=xi(Ln,Ln.EMISSIVE),q_=xi(Ln,Ln.OPACITY),a2=xi(Ln,Ln.SPECULAR),HM=xi(Ln,Ln.SPECULAR_INTENSITY),l2=xi(Ln,Ln.SPECULAR_COLOR),vv=xi(Ln,Ln.SPECULAR_STRENGTH),Y_=xi(Ln,Ln.REFLECTIVITY),c2=xi(Ln,Ln.ROUGHNESS),u2=xi(Ln,Ln.METALNESS),h2=xi(Ln,Ln.NORMAL),d2=xi(Ln,Ln.CLEARCOAT),f2=xi(Ln,Ln.CLEARCOAT_ROUGHNESS),p2=xi(Ln,Ln.CLEARCOAT_NORMAL),m2=xi(Ln,Ln.ROTATION),g2=xi(Ln,Ln.SHEEN),y2=xi(Ln,Ln.SHEEN_ROUGHNESS),v2=xi(Ln,Ln.ANISOTROPY),x2=xi(Ln,Ln.IRIDESCENCE),_2=xi(Ln,Ln.IRIDESCENCE_IOR),b2=xi(Ln,Ln.IRIDESCENCE_THICKNESS),w2=xi(Ln,Ln.TRANSMISSION),M2=xi(Ln,Ln.THICKNESS),S2=xi(Ln,Ln.IOR),T2=xi(Ln,Ln.ATTENUATION_DISTANCE),E2=xi(Ln,Ln.ATTENUATION_COLOR),$M=xi(Ln,Ln.LINE_SCALE),jM=xi(Ln,Ln.LINE_DASH_SIZE),XM=xi(Ln,Ln.LINE_GAP_SIZE),Z_=xi(Ln,Ln.LINE_WIDTH),qM=xi(Ln,Ln.LINE_DASH_OFFSET),A2=xi(Ln,Ln.POINT_SIZE),C2=xi(Ln,Ln.DISPERSION),YM=xi(Ln,Ln.LIGHT_MAP),R2=xi(Ln,Ln.AO),jg=cr(new yn).onReference(function(r){return r.material}).onRenderUpdate(function({material:r}){this.value.set(r.anisotropy*Math.cos(r.anisotropyRotation),r.anisotropy*Math.sin(r.anisotropyRotation))}),ZM=Kt(r=>r.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class Zo 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===Zo.VERTEX)s=e.getVertexIndex();else if(n===Zo.INSTANCE)s=e.getInstanceIndex();else if(n===Zo.DRAW)s=e.getDrawIndex();else if(n===Zo.INVOCATION_LOCAL)s=e.getInvocationLocalIndex();else if(n===Zo.INVOCATION_SUBGROUP)s=e.getInvocationSubgroupIndex();else if(n===Zo.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=Fh(this).build(e,t),o}}Zo.VERTEX="vertex",Zo.INSTANCE="instance",Zo.SUBGROUP="subgroup",Zo.INVOCATION_LOCAL="invocationLocal",Zo.INVOCATION_SUBGROUP="invocationSubgroup",Zo.DRAW="draw";const N2=xi(Zo,Zo.VERTEX),Gf=xi(Zo,Zo.INSTANCE),a4=xi(Zo,Zo.SUBGROUP),l4=xi(Zo,Zo.INVOCATION_SUBGROUP),c4=xi(Zo,Zo.INVOCATION_LOCAL),P2=xi(Zo,Zo.DRAW);class I2 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=rs.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=dv(t.array,"mat4",Math.max(s,1)).element(Gf);else{const u=new nw(t.array,16,1);this.buffer=u;const d=t.usage===Zd?SM:U_,p=[d(u,"vec4",16,0),d(u,"vec4",16,4),d(u,"vec4",16,8),d(u,"vec4",16,12)];o=rm(...p)}this.instanceMatrixNode=o}if(n&&a===null){const u=new kc(n.array,3),d=n.usage===Zd?SM:U_;this.bufferColor=u,a=qt(d(u,"vec3",3,0)),this.instanceColorNode=a}const c=o.mul(Pa).xyz;if(Pa.assign(c),e.hasGeometryAttribute("normal")){const u=BR(Tc,o);Tc.assign(u)}this.instanceColorNode!==null&&$c("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==Zd&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==Zd&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const u4=zr(I2).setParameterLength(2,3);class h4 extends I2{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:n,instanceColor:s}=e;super(t,n,s),this.instancedMesh=e}}const L2=zr(h4).setParameterLength(1);class d4 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=Gf:this.batchingIdNode=P2);const n=Kt(([T])=>{const G=Dt(kf(Na(this.batchMesh._indirectTexture),0).x),z=Dt(T).mod(G),I=Dt(T).div(G);return Na(this.batchMesh._indirectTexture,pl(z,I)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(Dt(this.batchingIdNode)),s=this.batchMesh._matricesTexture,o=Dt(kf(Na(s),0).x),a=ut(n).mul(4).toInt().toVar(),c=a.mod(o),u=a.div(o),d=rm(Na(s,pl(c,u)),Na(s,pl(c.add(1),u)),Na(s,pl(c.add(2),u)),Na(s,pl(c.add(3),u))),p=this.batchMesh._colorsTexture;if(p!==null){const G=Kt(([z])=>{const I=Dt(kf(Na(p),0).x),ee=z,Q=ee.mod(I),oe=ee.div(I);return Na(p,pl(Q,oe)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(n);$c("vec3","vBatchColor").assign(G)}const m=Wl(d);Pa.assign(d.mul(Pa));const y=Tc.div(qt(m[0].dot(m[0]),m[1].dot(m[1]),m[2].dot(m[2]))),M=m.mul(y).xyz;Tc.assign(M),e.hasGeometryAttribute("tangent")&&yv.mulAssign(m)}}const D2=zr(d4).setParameterLength(1);class f4 extends nm{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 p4=zr(f4).setParameterLength(2);class m4 extends RM{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=kw(e.itemSize),n=e.count):s=t,super(e,s,n),this.isStorageBufferNode=!0,this.structTypeNode=o,this.access=Nl.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 p4(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Nl.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=uv(this.value),this._varying=Fh(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 hm=(r,e=null,t=0)=>Cn(new m4(r,e,t)),g4=(r,e,t)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),hm(r,e,t).setPBO(!0)),O2=new WeakMap;class F2 extends Wi{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=rs.OBJECT,this.skinIndexNode=rc("skinIndex","uvec4"),this.skinWeightNode=rc("skinWeight","vec4"),this.bindMatrixNode=No("bindMatrix","mat4"),this.bindMatrixInverseNode=No("bindMatrixInverse","mat4"),this.boneMatricesNode=kM("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=Pa,this.toPositionNode=Pa,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=Wa(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=Tc){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=Wa(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=kM("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,z_)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||Vw(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&z_.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const n=this.getSkinnedNormal();Tc.assign(n),e.hasGeometryAttribute("tangent")&&yv.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;O2.get(t)!==e.frameId&&(O2.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const B2=r=>Cn(new F2(r)),y4=(r,e=null)=>{const t=new F2(r);return t.positionNode=hm(new kc(r.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(Gf).toVar(),t.skinIndexNode=hm(new kc(new Uint32Array(r.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(Gf).toVar(),t.skinWeightNode=hm(new kc(r.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(Gf).toVar(),t.bindMatrixNode=cr(r.bindMatrix,"mat4"),t.bindMatrixInverseNode=cr(r.bindMatrixInverse,"mat4"),t.boneMatricesNode=dv(r.skeleton.boneMatrices,"mat4",r.skeleton.bones.length),t.toPositionNode=e,Cn(t)};class v4 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]=Ld(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 ee={start:m,end:y},Q=ee.start,oe=ee.end;let _e;const ve=()=>G.includes("<")?"+=":"-=";if(z!=null)switch(typeof z){case"function":_e=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":_e=M+" "+ve()+" "+e.generateConst(T,z);break;case"string":_e=M+" "+z;break;default:z.isNode?_e=M+" "+ve()+" "+z.build(e):(console.error("THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number."),_e="break /* invalid update */")}else T==="int"||T==="uint"?z=G.includes("<")?"++":"--":z=ve()+" 1.",_e=M+" "+z;const Oe=e.getVar(T,M)+" = "+Q,He=M+" "+G+" "+oe;I=`for ( ${Oe}; ${He}; ${_e} )`}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 po=(...r)=>Cn(new v4(im(r,"int"))).toStack(),x4=()=>Ld("continue").toStack(),U2=()=>Ld("break").toStack(),KM=new WeakMap,Zc=new mr,k2=Kt(({bufferMap:r,influence:e,stride:t,width:n,depth:s,offset:o})=>{const a=Dt(N2).mul(t).add(o),c=a.div(n),u=a.sub(c.mul(n));return Na(r,pl(u,c)).depth(s).xyz.mul(e)});function _4(r){const e=r.morphAttributes.position!==void 0,t=r.morphAttributes.normal!==void 0,n=r.morphAttributes.color!==void 0,s=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,o=s!==void 0?s.length:0;let a=KM.get(r);if(a===void 0||a.count!==o){let I=function(){G.dispose(),KM.delete(r),r.removeEventListener("dispose",I)};a!==void 0&&a.texture.dispose();const c=r.morphAttributes.position||[],u=r.morphAttributes.normal||[],d=r.morphAttributes.color||[];let p=0;e===!0&&(p=1),t===!0&&(p=2),n===!0&&(p=3);let m=r.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 Jd(T,m,y,o);G.type=gs,G.needsUpdate=!0;const z=p*4;for(let ee=0;ee<o;ee++){const Q=c[ee],oe=u[ee],_e=d[ee],ve=m*y*4*ee;for(let Oe=0;Oe<Q.count;Oe++){const He=Oe*z;e===!0&&(Zc.fromBufferAttribute(Q,Oe),T[ve+He+0]=Zc.x,T[ve+He+1]=Zc.y,T[ve+He+2]=Zc.z,T[ve+He+3]=0),t===!0&&(Zc.fromBufferAttribute(oe,Oe),T[ve+He+4]=Zc.x,T[ve+He+5]=Zc.y,T[ve+He+6]=Zc.z,T[ve+He+7]=0),n===!0&&(Zc.fromBufferAttribute(_e,Oe),T[ve+He+8]=Zc.x,T[ve+He+9]=Zc.y,T[ve+He+10]=Zc.z,T[ve+He+11]=_e.itemSize===4?Zc.w:1)}}a={count:o,texture:G,stride:p,size:new yn(m,y)},KM.set(r,a),r.addEventListener("dispose",I)}return a}class b4 extends Wi{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=cr(1),this.updateType=rs.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}=_4(t);n===!0&&Pa.mulAssign(this.morphBaseInfluence),s===!0&&Tc.mulAssign(this.morphBaseInfluence);const p=Dt(d.width);po(a,({i:m})=>{const y=ut(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?y.assign(Na(this.mesh.morphTexture,pl(Dt(m).add(1),Dt(Gf))).r):y.assign(No("morphTargetInfluences","float").element(m).toVar()),sr(y.notEqual(0),()=>{n===!0&&Pa.addAssign(k2({bufferMap:c,influence:y,stride:u,width:p,depth:m,offset:Dt(0)})),s===!0&&Tc.addAssign(k2({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 z2=zr(b4).setParameterLength(1);class Xg extends Wi{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class w4 extends Xg{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class M4 extends rR{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=qt().toVar("directDiffuse"),s=qt().toVar("directSpecular"),o=qt().toVar("indirectDiffuse"),a=qt().toVar("indirectSpecular"),c={directDiffuse:n,directSpecular:s,indirectDiffuse:o,indirectSpecular:a};return{radiance:qt().toVar("radiance"),irradiance:qt().toVar("irradiance"),iblIrradiance:qt().toVar("iblIrradiance"),ambientOcclusion:ut(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 V2=zr(M4);class S4 extends Xg{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}const qg=new yn;class K_ extends Bh{static get type(){return"ViewportTextureNode"}constructor(e=Od,t=null,n=null){let s=null;n===null?(s=new bp,s.minFilter=Qn,n=s):s=n,super(n,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=s,this.isOutputTextureNode=!0,this.updateBeforeType=rs.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(qg):qg.set(n.width,n.height);const s=this.getTextureForReference(n);(s.image.width!==qg.width||s.image.height!==qg.height)&&(s.image.width=qg.width,s.image.height=qg.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 T4=zr(K_).setParameterLength(0,3),JM=zr(K_,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let J_=null;class E4 extends K_{static get type(){return"ViewportDepthTextureNode"}constructor(e=Od,t=null){J_===null&&(J_=new gc),super(e,t,J_)}getTextureForReference(){return J_}}const QM=zr(E4).setParameterLength(0,2);class Ec 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===Ec.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,n=this.valueNode;let s=null;if(t===Ec.DEPTH_BASE)n!==null&&(s=G2().assign(n));else if(t===Ec.DEPTH)e.isPerspectiveCamera?s=eS(Ia.z,Fd,Bd):s=Yg(Ia.z,Fd,Bd);else if(t===Ec.LINEAR_DEPTH)if(n!==null)if(e.isPerspectiveCamera){const o=tS(n,Fd,Bd);s=Yg(o,Fd,Bd)}else s=n;else s=Yg(Ia.z,Fd,Bd);return s}}Ec.DEPTH_BASE="depthBase",Ec.DEPTH="depth",Ec.LINEAR_DEPTH="linearDepth";const Yg=(r,e,t)=>r.add(e).div(e.sub(t)),A4=(r,e,t)=>e.sub(t).mul(r).sub(e),eS=(r,e,t)=>e.add(r).mul(t).div(t.sub(e).mul(r)),tS=(r,e,t)=>e.mul(t).div(t.sub(e).mul(r).sub(t)),nS=(r,e,t)=>{e=e.max(1e-6).toVar();const n=Ih(r.negate().div(e)),s=Ih(t.div(e));return n.div(s)},C4=(r,e,t)=>{const n=r.mul(P_(t.div(e)));return ut(Math.E).pow(n).mul(e).negate()},G2=zr(Ec,Ec.DEPTH_BASE),iS=xi(Ec,Ec.DEPTH),Zg=zr(Ec,Ec.LINEAR_DEPTH).setParameterLength(0,1),R4=Zg(QM());iS.assign=r=>G2(r);class Cu extends Wi{static get type(){return"ClippingNode"}constructor(e=Cu.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===Cu.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,s):this.scope===Cu.HARDWARE?this.setupHardwareClipping(s,e):this.setupDefault(n,s)}setupAlphaToCoverage(e,t){return Kt(()=>{const n=ut().toVar("distanceToPlane"),s=ut().toVar("distanceToGradient"),o=ut(1).toVar("clipOpacity"),a=t.length;if(this.hardwareClipping===!1&&a>0){const u=Hl(t).setGroup(or);po(a,({i:d})=>{const p=u.element(d);n.assign(Ia.dot(p.xyz).negate().add(p.w)),s.assign(n.fwidth().div(2)),o.mulAssign(Su(s.negate(),s,n))})}const c=e.length;if(c>0){const u=Hl(e).setGroup(or),d=ut(1).toVar("intersectionClipOpacity");po(c,({i:p})=>{const m=u.element(p);n.assign(Ia.dot(m.xyz).negate().add(m.w)),s.assign(n.fwidth().div(2)),d.mulAssign(Su(s.negate(),s,n).oneMinus())}),o.mulAssign(d.oneMinus())}to.a.mulAssign(o),to.a.equal(0).discard()})()}setupDefault(e,t){return Kt(()=>{const n=t.length;if(this.hardwareClipping===!1&&n>0){const o=Hl(t).setGroup(or);po(n,({i:a})=>{const c=o.element(a);Ia.dot(c.xyz).greaterThan(c.w).discard()})}const s=e.length;if(s>0){const o=Hl(e).setGroup(or),a=bu(!0).toVar("clipped");po(s,({i:c})=>{const u=o.element(c);a.assign(Ia.dot(u.xyz).greaterThan(u.w).and(a))}),a.discard()}})()}setupHardwareClipping(e,t){const n=e.length;return t.enableHardwareClipping(n),Kt(()=>{const s=Hl(e).setGroup(or),o=Dd(t.getClipDistance());po(n,({i:a})=>{const c=s.element(a),u=Ia.dot(c.xyz).sub(c.w).negate();o.element(a).assign(u)})})()}}Cu.ALPHA_TO_COVERAGE="alphaToCoverage",Cu.DEFAULT="default",Cu.HARDWARE="hardware";const N4=()=>Cn(new Cu),P4=()=>Cn(new Cu(Cu.ALPHA_TO_COVERAGE)),I4=()=>Cn(new Cu(Cu.HARDWARE)),L4=.05,W2=Kt(([r])=>Pd(Kr(1e4,Xc(Kr(17,r.x).add(Kr(.1,r.y)))).mul(Wa(.1,Oo(Xc(Kr(13,r.y).add(r.x))))))),H2=Kt(([r])=>W2(Bn(W2(r.xy),r.z))),D4=Kt(([r])=>{const e=ga(Oh(dM(r.xyz)),Oh(fM(r.xyz))),t=ut(1).div(ut(L4).mul(e)).toVar("pixScale"),n=Bn(zg(Dh(Ih(t))),zg(I_(Ih(t)))),s=Bn(H2(Dh(n.x.mul(r.xyz))),H2(Dh(n.y.mul(r.xyz)))),o=Pd(Ih(t)),a=Wa(Kr(o.oneMinus(),s.x),Kr(o,s.y)),c=Sc(o,o.oneMinus()),u=qt(a.mul(a).div(Kr(2,c).mul(Ds(1,c))),a.sub(Kr(.5,c)).div(Ds(1,c)),Ds(1,Ds(1,a).mul(Ds(1,a)).div(Kr(2,c).mul(Ds(1,c))))),d=a.lessThan(c.oneMinus()).select(a.lessThan(c).select(u.x,u.y),u.z);return Mu(d,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class O4 extends ER{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 $2=(r=0)=>Cn(new O4(r)),j2=Kt(([r,e])=>Sc(1,r.oneMinus().div(e)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),X2=Kt(([r,e])=>Sc(r.div(e.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),q2=Kt(([r,e])=>r.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Y2=Kt(([r,e])=>Hs(r.mul(2).mul(e),r.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),D_(.5,r))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),F4=Kt(([r,e])=>{const t=e.a.add(r.a.mul(e.a.oneMinus()));return Bi(e.rgb.mul(e.a).add(r.rgb.mul(r.a).mul(e.a.oneMinus())).div(t),t)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),Z2=Kt(([r])=>Bi(r.rgb.mul(r.a),r.a),{color:"vec4",return:"vec4"}),B4=Kt(([r])=>(sr(r.a.equal(0),()=>Bi(0)),Bi(r.rgb.div(r.a),r.a)),{color:"vec4",return:"vec4"}),U4=(...r)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),j2(r)),k4=(...r)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),X2(r)),z4=(...r)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),q2(r)),V4=(...r)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),Y2(r));class ya 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+Uw(this)}build(e){this.setup(e)}setupObserver(e){return new gk(e)}setup(e){e.context.setupNormal=()=>Vg(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=Vg(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,to.a).max(0);a=this.setupOutput(e,d),kg.assign(a);const p=this.outputNode!==null;if(p&&(a=this.outputNode),n!==null){const m=t.getMRT(),y=this.mrtNode;m!==null?(p&&kg.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=P4():e.stack.add(N4())}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(I4()),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=nS(Ia.z,Fd,Bd):s=Yg(Ia.z,Fd,Bd))}s!==null&&iS.assign(s).toStack()}setupPositionView(){return Ud.mul(Pa).xyz}setupModelViewProjection(){return Tu.mul(Ia)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),ZM}setupPosition(e){const{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&z2(t).toStack(),t.isSkinnedMesh===!0&&B2(t).toStack(),this.displacementMap){const s=kd("displacementMap","texture"),o=kd("displacementScale","float"),a=kd("displacementBias","float");Pa.addAssign(Tc.normalize().mul(s.x.mul(o).add(a)))}return t.isBatchedMesh&&D2(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&L2(t).toStack(),this.positionNode!==null&&Pa.assign(Vg(this.positionNode,"POSITION","vec3")),Pa}setupDiffuseColor({object:e,geometry:t}){this.maskNode!==null&&bu(this.maskNode).not().discard();let n=this.colorNode?Bi(this.colorNode):X_;this.vertexColors===!0&&t.hasAttribute("color")&&(n=n.mul($2())),e.instanceColor&&(n=$c("vec3","vInstanceColor").mul(n)),e.isBatchedMesh&&e._colorsTexture&&(n=$c("vec3","vBatchColor").mul(n)),to.assign(n);const s=this.opacityNode?ut(this.opacityNode):q_;to.a.assign(to.a.mul(s));let o=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(o=this.alphaTestNode!==null?ut(this.alphaTestNode):r2,to.a.lessThanEqual(o).discard()),this.alphaHash===!0&&to.a.lessThan(D4(Pa)).discard(),this.transparent===!1&&this.blending===ge&&this.alphaToCoverage===!1?to.a.assign(1):o===null&&to.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return this.lights===!0?qt(0):to.rgb}setupNormal(){return this.normalNode?qt(this.normalNode):h2}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?kd("envMap","cubeTexture"):kd("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new S4(YM)),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:R2;t.push(new w4(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=V2(c,d,n,s)}else n!==null&&(u=qt(s!==null?Hs(u,n,s):n));return(o&&o.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(Qw.assign(qt(o||o2)),u=u.add(Qw)),u}setupFog(e,t){const n=e.fogNode;return n&&(kg.assign(t),t=Bi(n.toVar())),t}setupPremultipliedAlpha(e,t){return Z2(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=Xy(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 G4=new el;class W4 extends ya{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(G4),this.setValues(e)}}const H4=new hy;class $4 extends ya{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(H4),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?ut(this.offsetNode):qM,t=this.dashScaleNode?ut(this.dashScaleNode):$M,n=this.dashSizeNode?ut(this.dashSizeNode):jM,s=this.gapSizeNode?ut(this.gapSizeNode):XM;am.assign(n),rv.assign(s);const o=Fh(rc("lineDistance").mul(t));(e?o.add(e):o).mod(am.add(rv)).greaterThan(am).discard()}}let Q_=null;class j4 extends K_{static get type(){return"ViewportSharedTextureNode"}constructor(e=Od,t=null){Q_===null&&(Q_=new bp),super(e,t,Q_)}getTextureForReference(){return Q_}updateReference(){return this}}const K2=zr(j4).setParameterLength(0,2),X4=new hy;class EY extends null{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(X4),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=Tu.element(2).element(2),T=Tu.element(3).element(2).mul(-.5).div(m).sub(d.z).div(p.z.sub(d.z));return Bi(Hs(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=rc("instanceStart"),p=rc("instanceEnd"),m=Bi(Ud.mul(Bi(d,1))).toVar("start"),y=Bi(Ud.mul(Bi(p,1))).toVar("end");if(o){const _e=this.dashScaleNode?ut(this.dashScaleNode):$M,ve=this.offsetNode?ut(this.offsetNode):qM,Oe=rc("instanceDistanceStart"),He=rc("instanceDistanceEnd");let Ce=Pl.y.lessThan(.5).select(_e.mul(Oe),_e.mul(He));Ce=Ce.add(ve),$c("float","lineDistance").assign(Ce)}a&&($c("vec3","worldStart").assign(m.xyz),$c("vec3","worldEnd").assign(y.xyz));const M=Gg.z.div(Gg.w),T=Tu.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=Tu.mul(m),z=Tu.mul(y),I=G.xyz.div(G.w),ee=z.xyz.div(z.w),Q=ee.xy.sub(I.xy).toVar();Q.x.assign(Q.x.mul(M)),Q.assign(Q.normalize());const oe=Bi().toVar();if(a){const _e=y.xyz.sub(m.xyz).normalize(),ve=Hs(m.xyz,y.xyz,.5).normalize(),Oe=_e.cross(ve).normalize(),He=_e.cross(Oe),Ce=$c("vec4","worldPos");Ce.assign(Pl.y.lessThan(.5).select(m,y));const Be=Z_.mul(.5);Ce.addAssign(Bi(Pl.x.lessThan(0).select(Oe.mul(Be),Oe.mul(Be).negate()),0)),o||(Ce.addAssign(Bi(Pl.y.lessThan(.5).select(_e.mul(Be).negate(),_e.mul(Be)),0)),Ce.addAssign(Bi(He.mul(Be),0)),sr(Pl.y.greaterThan(1).or(Pl.y.lessThan(0)),()=>{Ce.subAssign(Bi(He.mul(2).mul(Be),0))})),oe.assign(Tu.mul(Ce));const ft=qt().toVar();ft.assign(Pl.y.lessThan(.5).select(I,ee)),oe.z.assign(ft.z.mul(oe.w))}else{const _e=Bn(Q.y,Q.x.negate()).toVar("offset");Q.x.assign(Q.x.div(M)),_e.x.assign(_e.x.div(M)),_e.assign(Pl.x.lessThan(0).select(_e.negate(),_e)),sr(Pl.y.lessThan(0),()=>{_e.assign(_e.sub(Q))}).ElseIf(Pl.y.greaterThan(1),()=>{_e.assign(_e.add(Q))}),_e.assign(_e.mul(Z_)),_e.assign(_e.div(Gg.w)),oe.assign(Pl.y.lessThan(.5).select(G,z)),_e.assign(_e.mul(oe.w)),oe.assign(oe.add(Bi(_e,0,0)))}return oe})();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),ee=M.dot(G),Q=T.dot(T),_e=G.dot(G).mul(Q).sub(I.mul(I)),Oe=z.mul(I).sub(ee.mul(Q)).div(_e).clamp(),He=z.add(I.mul(Oe)).div(Q).clamp();return Bn(Oe,He)});if(this.colorNode=Kt(()=>{const d=vo();if(o){const y=this.dashSizeNode?ut(this.dashSizeNode):jM,M=this.gapSizeNode?ut(this.gapSizeNode):XM;am.assign(y),rv.assign(M);const T=$c("float","lineDistance");d.y.lessThan(-1).or(d.y.greaterThan(1)).discard(),T.mod(am.add(rv)).greaterThan(am).discard()}const p=ut(1).toVar("alpha");if(a){const y=$c("vec3","worldStart"),M=$c("vec3","worldEnd"),T=$c("vec4","worldPos").xyz.normalize().mul(1e5),G=M.sub(y),z=u({p1:y,p2:M,p3:qt(0,0,0),p4:T}),I=y.add(G.mul(z.x)),ee=T.mul(z.y),_e=I.sub(ee).length().div(Z_);if(!o)if(n&&t.samples>1){const ve=_e.fwidth();p.assign(Su(ve.negate().add(.5),ve.add(.5),_e).oneMinus())}else _e.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=ut(T.fwidth()).toVar("dlen");sr(d.y.abs().greaterThan(1),()=>{p.assign(Su(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=rc("instanceColorStart"),M=rc("instanceColorEnd");m=Pl.y.lessThan(.5).select(y,M).mul(X_)}else m=X_;return Bi(m,p)})(),this.transparent){const d=this.opacityNode?ut(this.opacityNode):q_;this.outputNode=Bi(this.colorNode.rgb.mul(d).add(K2().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 J2=r=>Cn(r).mul(.5).add(.5),q4=r=>Cn(r).mul(2).sub(1),Y4=new Rx;class Z4 extends ya{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(Y4),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?ut(this.opacityNode):q_;to.assign(B_(Bi(J2(fo),e),co))}}const rS=Kt(([r=LM])=>{const e=r.z.atan(r.x).mul(1/(Math.PI*2)).add(.5),t=r.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Bn(e,t)});class Q2 extends R0{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 Fc(5,5,5),a=rS(LM),c=new ya;c.colorNode=Ps(t,a,0),c.side=K,c.blending=ye;const u=new Zs(o,c),d=new $m;d.add(u),t.minFilter===Qn&&(t.minFilter=Rn);const p=new Vu(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 xv=new WeakMap;class K4 extends Ra{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=$g(null);const t=new ph;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=rs.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===Pe||a===Ie){if(xv.has(o)){const c=xv.get(o);tN(c,o.mapping),this._cubeTexture=c}else{const c=o.image;if(J4(c)){const u=new Q2(c.height);u.fromEquirectangularTexture(t,o),tN(u.texture,o.mapping),this._cubeTexture=u.texture,xv.set(o,u.texture),o.addEventListener("dispose",eN)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function J4(r){return r==null?!1:r.height>0}function eN(r){const e=r.target;e.removeEventListener("dispose",eN);const t=xv.get(e);t!==void 0&&(xv.delete(e),t.dispose())}function tN(r,e){e===Pe?r.mapping=Fe:e===Ie&&(r.mapping=Xe)}const nN=zr(K4).setParameterLength(1);class sS extends Xg{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=nN(this.envNode)}}class Q4 extends Xg{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=ut(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class eb{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class iN extends eb{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(to.rgb)}finish(e){const{material:t,context:n}=e,s=n.outgoingLight,o=e.context.environment;if(o)switch(t.combine){case xt:s.rgb.assign(Hs(s.rgb,s.rgb.mul(o.rgb),vv.mul(Y_)));break;case ke:s.rgb.assign(Hs(s.rgb,o.rgb,vv.mul(Y_)));break;case et:s.rgb.addAssign(o.rgb.mul(vv.mul(Y_)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",t.combine);break}}}const eV=new Wr;class tV extends ya{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(eV),this.setValues(e)}setupNormal(){return Wg(Hg)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new sS(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Q4(YM)),t}setupOutgoingLight(){return to.rgb}setupLightingModel(){return new iN}}const Kg=Kt(({f0:r,f90:e,dotVH:t})=>{const n=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return r.mul(n.oneMinus()).add(e.mul(n))}),dm=Kt(r=>r.diffuseColor.mul(1/Math.PI)),nV=()=>ut(.25),iV=Kt(({dotNH:r})=>A_.mul(ut(.5)).add(1).mul(ut(1/Math.PI)).mul(r.pow(A_))),rV=Kt(({lightDirection:r})=>{const e=r.add(Vo).normalize(),t=fo.dot(e).clamp(),n=Vo.dot(e).clamp(),s=Kg({f0:Mc,f90:1,dotVH:n}),o=nV(),a=iV({dotNH:t});return s.mul(o).mul(a)});class rN extends iN{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const o=fo.dot(e).clamp().mul(t);n.directDiffuse.addAssign(o.mul(dm({diffuseColor:to.rgb}))),this.specular===!0&&n.directSpecular.addAssign(o.mul(rV({lightDirection:e})).mul(vv))}indirect(e){const{ambientOcclusion:t,irradiance:n,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(n.mul(dm({diffuseColor:to}))),s.indirectDiffuse.mulAssign(t)}}const sV=new cy;class oV extends ya{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(sV),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new sS(t):null}setupLightingModel(){return new rN(!1)}}const aV=new ay;class lV extends ya{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(aV),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new sS(t):null}setupLightingModel(){return new rN}setupVariants(){const e=(this.shininessNode?ut(this.shininessNode):s2).max(1e-4);A_.assign(e);const t=this.specularNode||a2;Mc.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const sN=Kt(r=>{if(r.geometry.hasAttribute("normal")===!1)return ut(0);const e=Hg.dFdx().abs().max(Hg.dFdy().abs());return e.x.max(e.y).max(e.z)}),oS=Kt(r=>{const{roughness:e}=r,t=sN();let n=e.max(.0525);return n=n.add(t),n=n.min(1),n}),oN=Kt(({alpha:r,dotNL:e,dotNV:t})=>{const n=r.pow2(),s=e.mul(n.add(n.oneMinus().mul(t.pow2())).sqrt()),o=t.mul(n.add(n.oneMinus().mul(e.pow2())).sqrt());return jc(.5,s.add(o).max(NC))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),cV=Kt(({alphaT:r,alphaB:e,dotTV:t,dotBV:n,dotTL:s,dotBL:o,dotNV:a,dotNL:c})=>{const u=c.mul(qt(r.mul(t),e.mul(n),a).length()),d=a.mul(qt(r.mul(s),e.mul(o),c).length());return jc(.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"}]}),aN=Kt(({alpha:r,dotNH:e})=>{const t=r.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"}]}),uV=ut(1/Math.PI),hV=Kt(({alphaT:r,alphaB:e,dotNH:t,dotTH:n,dotBH:s})=>{const o=r.mul(e),a=qt(e.mul(n),r.mul(s),o.mul(t)),c=a.dot(a),u=o.div(c);return uV.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"}]}),aS=Kt(({lightDirection:r,f0:e,f90:t,roughness:n,f:s,normalView:o=fo,USE_IRIDESCENCE:a,USE_ANISOTROPY:c})=>{const u=n.pow2(),d=r.add(Vo).normalize(),p=o.dot(r).clamp(),m=o.dot(Vo).clamp(),y=o.dot(d).clamp(),M=Vo.dot(d).clamp();let T=Kg({f0:e,f90:t,dotVH:M}),G,z;if(Ky(a)&&(T=T_.mix(T,s)),Ky(c)){const I=nv.dot(r),ee=nv.dot(Vo),Q=nv.dot(d),oe=om.dot(r),_e=om.dot(Vo),ve=om.dot(d);G=cV({alphaT:E_,alphaB:u,dotTV:ee,dotBV:_e,dotTL:I,dotBL:oe,dotNV:m,dotNL:p}),z=hV({alphaT:E_,alphaB:u,dotNH:y,dotTH:Q,dotBH:ve})}else G=oN({alpha:u,dotNL:p,dotNV:m}),z=aN({alpha:u,dotNH:y});return T.mul(G).mul(z)}),lS=Kt(({roughness:r,dotNV:e})=>{const t=Bi(-1,-.0275,-.572,.022),n=Bi(1,.0425,1.04,-.04),s=r.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"}]}),lN=Kt(r=>{const{dotNV:e,specularColor:t,specularF90:n,roughness:s}=r,o=lS({dotNV:e,roughness:s});return t.mul(o.x).add(n.mul(o.y))}),cN=Kt(({f:r,f90:e,dotVH:t})=>{const n=t.oneMinus().saturate(),s=n.mul(n),o=n.mul(s,s).clamp(0,.9999);return r.sub(qt(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"}]}),dV=Kt(({roughness:r,dotNH:e})=>{const t=r.pow2(),n=ut(1).div(t),o=e.pow2().oneMinus().max(.0078125);return ut(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"}]}),fV=Kt(({dotNV:r,dotNL:e})=>ut(1).div(ut(4).mul(e.add(r).sub(e.mul(r))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),pV=Kt(({lightDirection:r})=>{const e=r.add(Vo).normalize(),t=fo.dot(r).clamp(),n=fo.dot(Vo).clamp(),s=fo.dot(e).clamp(),o=dV({roughness:S_,dotNH:s}),a=fV({dotNV:n,dotNL:t});return sm.mul(o).mul(a)}),mV=Kt(({N:r,V:e,roughness:t})=>{const o=.0078125,a=r.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"}]}),uN=Kt(({f:r})=>{const e=r.length();return ga(e.mul(e).add(r.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),Wf=Kt(({v1:r,v2:e})=>{const t=r.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,ga(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return r.cross(e).mul(c)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),hN=Kt(({N:r,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=qt().toVar();return sr(p.dot(t.sub(s)).greaterThanEqual(0),()=>{const y=e.sub(r.mul(e.dot(r))).normalize(),M=r.cross(y).negate(),T=n.mul(Wl(y,M,r).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(),ee=T.mul(c.sub(t)).normalize().toVar(),Q=qt(0).toVar();Q.addAssign(Wf({v1:G,v2:z})),Q.addAssign(Wf({v1:z,v2:I})),Q.addAssign(Wf({v1:I,v2:ee})),Q.addAssign(Wf({v1:ee,v2:G})),m.assign(qt(uN({f:Q})))}),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"}]}),gV=Kt(({P:r,p0:e,p1:t,p2:n,p3:s})=>{const o=t.sub(e).toVar(),a=s.sub(e).toVar(),c=o.cross(a),u=qt().toVar();return sr(c.dot(r.sub(e)).greaterThanEqual(0),()=>{const d=e.sub(r).normalize().toVar(),p=t.sub(r).normalize().toVar(),m=n.sub(r).normalize().toVar(),y=s.sub(r).normalize().toVar(),M=qt(0).toVar();M.addAssign(Wf({v1:d,v2:p})),M.addAssign(Wf({v1:p,v2:m})),M.addAssign(Wf({v1:m,v2:y})),M.addAssign(Wf({v1:y,v2:d})),u.assign(qt(uN({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"}]}),tb=1/6,dN=r=>Kr(tb,Kr(r,Kr(r,r.negate().add(3)).sub(3)).add(1)),cS=r=>Kr(tb,Kr(r,Kr(r,Kr(3,r).sub(6))).add(4)),fN=r=>Kr(tb,Kr(r,Kr(r,Kr(-3,r).add(3)).add(3)).add(1)),uS=r=>Kr(tb,wu(r,3)),pN=r=>dN(r).add(cS(r)),mN=r=>fN(r).add(uS(r)),gN=r=>Wa(-1,cS(r).div(dN(r).add(cS(r)))),yN=r=>Wa(1,uS(r).div(fN(r).add(uS(r)))),vN=(r,e,t)=>{const n=r.uvNode,s=Kr(n,e.zw).add(.5),o=Dh(s),a=Pd(s),c=pN(a.x),u=mN(a.x),d=gN(a.x),p=yN(a.x),m=gN(a.y),y=yN(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(Wa(c.mul(r.sample(M).level(t)),u.mul(r.sample(T).level(t)))),ee=mN(a.y).mul(Wa(c.mul(r.sample(G).level(t)),u.mul(r.sample(z).level(t))));return I.add(ee)},hS=Kt(([r,e])=>{const t=Bn(r.size(Dt(e))),n=Bn(r.size(Dt(e.add(1)))),s=jc(1,t),o=jc(1,n),a=vN(r,Bi(s,t),Dh(e)),c=vN(r,Bi(o,n),I_(e));return Pd(e).mix(a,c)}),yV=Kt(([r,e])=>{const t=e.mul(AM(r));return hS(r,t)}),xN=Kt(([r,e,t,n,s])=>{const o=qt(vM(e.negate(),Nd(r),jc(1,n))),a=qt(Oh(s[0].xyz),Oh(s[1].xyz),Oh(s[2].xyz));return Nd(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"}]}),vV=Kt(([r,e])=>r.mul(Mu(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),xV=JM(),_V=JM(),_N=Kt(([r,e,t],{material:n})=>{const o=(n.side===K?xV:_V).sample(r),a=Ih(lm.x).mul(vV(e,t));return hS(o,a)}),bN=Kt(([r,e,t])=>(sr(t.notEqual(0),()=>{const n=P_(e).negate().div(t);return cM(n.negate().mul(r))}),qt(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),bV=Kt(([r,e,t,n,s,o,a,c,u,d,p,m,y,M,T])=>{let G,z;if(T){G=Bi().toVar(),z=qt().toVar();const _e=p.sub(1).mul(T.mul(.025)),ve=qt(p.sub(_e),p,p.add(_e));po({start:0,end:3},({i:Oe})=>{const He=ve.element(Oe),Ce=xN(r,e,m,He,c),Be=a.add(Ce),ft=d.mul(u.mul(Bi(Be,1))),zt=Bn(ft.xy.div(ft.w)).toVar();zt.addAssign(1),zt.divAssign(2),zt.assign(Bn(zt.x,zt.y.oneMinus()));const tn=_N(zt,t,He);G.element(Oe).assign(tn.element(Oe)),G.a.addAssign(tn.a),z.element(Oe).assign(n.element(Oe).mul(bN(Oh(Ce),y,M).element(Oe)))}),G.a.divAssign(3)}else{const _e=xN(r,e,m,p,c),ve=a.add(_e),Oe=d.mul(u.mul(Bi(ve,1))),He=Bn(Oe.xy.div(Oe.w)).toVar();He.addAssign(1),He.divAssign(2),He.assign(Bn(He.x,He.y.oneMinus())),G=_N(He,t,p),z=n.mul(bN(Oh(_e),y,M))}const I=z.rgb.mul(G.rgb),ee=r.dot(e).clamp(),Q=qt(lN({dotNV:ee,specularColor:s,specularF90:o,roughness:t})),oe=z.r.add(z.g,z.b).div(3);return Bi(Q.oneMinus().mul(I),G.a.oneMinus().mul(oe).oneMinus())}),wV=Wl(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),MV=r=>{const e=r.sqrt();return qt(1).add(e).div(qt(1).sub(e))},wN=(r,e)=>r.sub(e).div(r.add(e)).pow2(),SV=(r,e)=>{const t=r.mul(2*Math.PI*1e-9),n=qt(54856e-17,44201e-17,52481e-17),s=qt(1681e3,1795300,2208400),o=qt(43278e5,93046e5,66121e5),a=ut(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=qt(c.x.add(a),c.y,c.z).div(10685e-11),wV.mul(c)},TV=Kt(({outsideIOR:r,eta2:e,cosTheta1:t,thinFilmThickness:n,baseF0:s})=>{const o=Hs(r,e,Su(0,.03,n)),c=r.div(o).pow2().mul(t.pow2().oneMinus()).oneMinus();sr(c.lessThan(0),()=>qt(1));const u=c.sqrt(),d=wN(o,r),p=Kg({f0:d,f90:1,dotVH:t}),m=p.oneMinus(),y=o.lessThan(r).select(Math.PI,0),M=ut(Math.PI).sub(y),T=MV(s.clamp(0,.9999)),G=wN(T,o.toVec3()),z=Kg({f0:G,f90:1,dotVH:u}),I=qt(T.x.lessThan(o).select(Math.PI,0),T.y.lessThan(o).select(Math.PI,0),T.z.lessThan(o).select(Math.PI,0)),ee=o.mul(n,u,2),Q=qt(M).add(I),oe=p.mul(z).clamp(1e-5,.9999),_e=oe.sqrt(),ve=m.pow2().mul(z).div(qt(1).sub(oe)),He=p.add(ve).toVar(),Ce=ve.sub(m).toVar();return po({start:1,end:2,condition:"<=",name:"m"},({m:Be})=>{Ce.mulAssign(_e);const ft=SV(ut(Be).mul(ee),ut(Be).mul(Q)).mul(2);He.addAssign(Ce.mul(ft))}),He.max(qt(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"}]}),EV=Kt(({normal:r,viewDir:e,roughness:t})=>{const n=r.dot(e).saturate(),s=t.pow2(),o=wl(t.lessThan(.25),ut(-339.2).mul(s).add(ut(161.4).mul(t)).sub(25.9),ut(-8.48).mul(s).add(ut(14.3).mul(t)).sub(9.95)),a=wl(t.lessThan(.25),ut(44).mul(s).sub(ut(23.7).mul(t)).add(3.26),ut(1.97).mul(s).sub(ut(3.27).mul(t)).add(.72));return wl(t.lessThan(.25),0,ut(.1).mul(t).sub(.025)).add(o.mul(n).add(a).exp()).mul(1/Math.PI).saturate()}),dS=qt(.04),fS=ut(1);class MN extends eb{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=qt().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=qt().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=qt().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=qt().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=qt().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=fo.dot(Vo).clamp();this.iridescenceFresnel=TV({outsideIOR:ut(1),eta2:eM,cosTheta1:t,thinFilmThickness:tM,baseF0:Mc}),this.iridescenceF0=cN({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=Yc,n=gv.sub(Yc).normalize(),s=Vf,o=e.context;o.backdrop=bV(s,n,Ph,to,Mc,iv,t,Au,qc,Tu,sv,nM,rM,iM,this.dispersion?sM:null),o.backdropAlpha=C_,to.a.mulAssign(Hs(1,o.backdrop.a,C_))}super.start(e)}computeMultiscattering(e,t,n){const s=fo.dot(Vo).clamp(),o=lS({roughness:Ph,dotNV:s}),c=(this.iridescenceF0?T_.mix(Mc,this.iridescenceF0):Mc).mul(o.x).add(n.mul(o.y)),d=o.x.add(o.y).oneMinus(),p=Mc.add(Mc.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=fo.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(o.mul(pV({lightDirection:e}))),this.clearcoat===!0){const c=cm.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(c.mul(aS({lightDirection:e,f0:dS,f90:fS,roughness:tv,normalView:cm})))}n.directDiffuse.addAssign(o.mul(dm({diffuseColor:to.rgb}))),n.directSpecular.addAssign(o.mul(aS({lightDirection:e,f0:Mc,f90:1,roughness:Ph,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=fo,M=Vo,T=Ia.toVar(),G=mV({N:y,V:M,roughness:Ph}),z=a.sample(G).toVar(),I=c.sample(G).toVar(),ee=Wl(qt(z.x,0,z.y),qt(0,1,0),qt(z.z,0,z.w)).toVar(),Q=Mc.mul(I.x).add(Mc.oneMinus().mul(I.y)).toVar();o.directSpecular.addAssign(e.mul(Q).mul(hN({N:y,V:M,P:T,mInv:ee,p0:u,p1:d,p2:p,p3:m}))),o.directDiffuse.addAssign(e.mul(to).mul(hN({N:y,V:M,P:T,mInv:Wl(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(dm({diffuseColor:to})))}indirectSpecular(e){const{radiance:t,iblIrradiance:n,reflectedLight:s}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(n.mul(sm,EV({normal:fo,viewDir:Vo,roughness:S_}))),this.clearcoat===!0){const p=cm.dot(Vo).clamp(),m=lN({dotNV:p,specularColor:dS,specularF90:fS,roughness:tv});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(m))}const o=qt().toVar("singleScattering"),a=qt().toVar("multiScattering"),c=n.mul(1/Math.PI);this.computeMultiscattering(o,a,iv);const u=o.add(a),d=to.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=fo.dot(Vo).clamp().add(t),a=Ph.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=cm.dot(Vo).clamp(),s=Kg({dotVH:n,f0:dS,f90:fS}),o=t.mul(M_.mul(s).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(M_));t.assign(o)}if(this.sheen===!0){const n=sm.r.max(sm.g).max(sm.b).mul(.157).oneMinus(),s=t.mul(n).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(s)}}}const SN=ut(1),pS=ut(-2),nb=ut(.8),mS=ut(-1),ib=ut(.4),gS=ut(2),rb=ut(.305),yS=ut(3),TN=ut(.21),AV=ut(4),EN=ut(4),CV=ut(16),RV=Kt(([r])=>{const e=qt(Oo(r)).toVar(),t=ut(-1).toVar();return sr(e.x.greaterThan(e.z),()=>{sr(e.x.greaterThan(e.y),()=>{t.assign(wl(r.x.greaterThan(0),0,3))}).Else(()=>{t.assign(wl(r.y.greaterThan(0),1,4))})}).Else(()=>{sr(e.z.greaterThan(e.y),()=>{t.assign(wl(r.z.greaterThan(0),2,5))}).Else(()=>{t.assign(wl(r.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),NV=Kt(([r,e])=>{const t=Bn().toVar();return sr(e.equal(0),()=>{t.assign(Bn(r.z,r.y).div(Oo(r.x)))}).ElseIf(e.equal(1),()=>{t.assign(Bn(r.x.negate(),r.z.negate()).div(Oo(r.y)))}).ElseIf(e.equal(2),()=>{t.assign(Bn(r.x.negate(),r.y).div(Oo(r.z)))}).ElseIf(e.equal(3),()=>{t.assign(Bn(r.z.negate(),r.y).div(Oo(r.x)))}).ElseIf(e.equal(4),()=>{t.assign(Bn(r.x.negate(),r.z).div(Oo(r.y)))}).Else(()=>{t.assign(Bn(r.x,r.y).div(Oo(r.z)))}),Kr(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),PV=Kt(([r])=>{const e=ut(0).toVar();return sr(r.greaterThanEqual(nb),()=>{e.assign(SN.sub(r).mul(mS.sub(pS)).div(SN.sub(nb)).add(pS))}).ElseIf(r.greaterThanEqual(ib),()=>{e.assign(nb.sub(r).mul(gS.sub(mS)).div(nb.sub(ib)).add(mS))}).ElseIf(r.greaterThanEqual(rb),()=>{e.assign(ib.sub(r).mul(yS.sub(gS)).div(ib.sub(rb)).add(gS))}).ElseIf(r.greaterThanEqual(TN),()=>{e.assign(rb.sub(r).mul(AV.sub(yS)).div(rb.sub(TN)).add(yS))}).Else(()=>{e.assign(ut(-2).mul(Ih(Kr(1.16,r))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),AN=Kt(([r,e])=>{const t=r.toVar();t.assign(Kr(2,t).sub(1));const n=qt(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"}]}),CN=Kt(([r,e,t,n,s,o])=>{const a=ut(t),c=qt(e),u=Mu(PV(a),pS,o),d=Pd(u),p=Dh(u),m=qt(vS(r,c,p,n,s,o)).toVar();return sr(d.notEqual(0),()=>{const y=qt(vS(r,c,p.add(1),n,s,o)).toVar();m.assign(Hs(m,y,d))}),m}),vS=Kt(([r,e,t,n,s,o])=>{const a=ut(t).toVar(),c=qt(e),u=ut(RV(c)).toVar(),d=ut(ga(EN.sub(a),0)).toVar();a.assign(ga(a,EN));const p=ut(zg(a)).toVar(),m=Bn(NV(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(Kr(3,CV))),m.y.addAssign(Kr(4,zg(o).sub(p))),m.x.mulAssign(n),m.y.mulAssign(s),r.sample(m).grad(Bn(),Bn())}),xS=Kt(({envMap:r,mipInt:e,outputDirection:t,theta:n,axis:s,CUBEUV_TEXEL_WIDTH:o,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:c})=>{const u=Id(n),d=t.mul(u).add(s.cross(t).mul(Xc(n))).add(s.mul(s.dot(t).mul(u.oneMinus())));return vS(r,d,e,o,a,c)}),RN=Kt(({n:r,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=qt(wl(e,t,O_(t,n))).toVar();sr(y.equal(qt(0)),()=>{y.assign(qt(n.z,0,n.x.negate()))}),y.assign(Nd(y));const M=qt().toVar();return M.addAssign(s.element(0).mul(xS({theta:0,axis:y,outputDirection:n,mipInt:c,envMap:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:m}))),po({start:Dt(1),end:r},({i:T})=>{sr(T.greaterThanEqual(o),()=>{U2()});const G=ut(a.mul(ut(T))).toVar();M.addAssign(s.element(T).mul(xS({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(xS({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)}),Jg=4,NN=[.125,.215,.35,.446,.526,.582],fm=20,_S=new Cf(-1,1,1,-1,0,1),IV=new fa(90,1),PN=new jn;let bS=null,wS=0,MS=0;const pm=(1+Math.sqrt(5))/2,Qg=1/pm,IN=[new ot(-pm,Qg,0),new ot(pm,Qg,0),new ot(-Qg,0,pm),new ot(Qg,0,pm),new ot(0,pm,-Qg),new ot(0,pm,Qg),new ot(-1,1,-1),new ot(1,1,-1),new ot(-1,1,1),new ot(1,1,1)],LV=new ot,LN=new WeakMap,DV=[3,1,5,0,4,2],SS=AN(vo(),rc("faceIndex")).normalize(),TS=qt(SS.x,SS.y,SS.z);class OV{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=LV,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}bS=this._renderer.getRenderTarget(),wS=this._renderer.getActiveCubeFace(),MS=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=ON(),yield this._compileMaterial(this._cubemapMaterial))})}compileEquirectangularShader(){return hr(this,null,function*(){this._equirectMaterial===null&&(this._equirectMaterial=FN(),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===Fe||e.mapping===Xe?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(bS,wS,MS),e.scissorTest=!1,sb(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),bS=this._renderer.getRenderTarget(),wS=this._renderer.getActiveCubeFace(),MS=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 DN(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=DN(e.width,e.height);const{_lodMax:t}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=FV(t)),this._blurMaterial=BV(t,e.width,e.height)}}_compileMaterial(e){return hr(this,null,function*(){const t=new Zs(this._lodPlanes[0],e);yield this._renderer.compile(t,_S)})}_sceneToCubeUV(e,t,n,s,o){const a=IV;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(PN),d.autoClear=!1;let m=this._backgroundBox;if(m===null){const T=new Wr({name:"PMREM.Background",side:K,depthWrite:!1,depthTest:!1});m=new Zs(new Fc,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(PN),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;sb(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===Fe||e.mapping===Xe;s?this._cubemapMaterial===null&&(this._cubemapMaterial=ON(e)):this._equirectMaterial===null&&(this._equirectMaterial=FN(e));const o=s?this._cubemapMaterial:this._equirectMaterial;o.fragmentNode.value=e;const a=this._lodMeshes[0];a.material=o;const c=this._cubeSize;sb(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,_S)}_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=IN[(s-o-1)%IN.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=LN.get(d),M=this._sizeLods[n]-1,T=isFinite(o)?Math.PI/(2*M):2*Math.PI/(2*fm-1),G=o/T,z=isFinite(o)?1+Math.floor(p*G):fm;z>fm&&console.warn(`sigmaRadians, ${o}, is too large and will clip, as it requested ${z} samples when the maximum is set to ${fm}`);const I=[];let ee=0;for(let Oe=0;Oe<fm;++Oe){const He=Oe/G,Ce=Math.exp(-He*He/2);I.push(Ce),Oe===0?ee+=Ce:Oe<z&&(ee+=2*Ce)}for(let Oe=0;Oe<I.length;Oe++)I[Oe]=I[Oe]/ee;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:Q}=this;y.dTheta.value=T,y.mipInt.value=Q-n;const oe=this._sizeLods[s],_e=3*oe*(s>Q-Jg?s-Q+Jg:0),ve=4*(this._cubeSize-oe);sb(t,_e,ve,3*oe,2*oe),u.setRenderTarget(t),u.render(m,_S)}}function FV(r){const e=[],t=[],n=[],s=[];let o=r;const a=r-Jg+1+NN.length;for(let c=0;c<a;c++){const u=Math.pow(2,o);t.push(u);let d=1/u;c>r-Jg?d=NN[c-r+Jg-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,ee=1,Q=new Float32Array(z*G*T),oe=new Float32Array(I*G*T),_e=new Float32Array(ee*G*T);for(let Oe=0;Oe<T;Oe++){const He=Oe%3*2/3-1,Ce=Oe>2?0:-1,Be=[He,Ce,0,He+2/3,Ce,0,He+2/3,Ce+1,0,He,Ce,0,He+2/3,Ce+1,0,He,Ce+1,0],ft=DV[Oe];Q.set(Be,z*G*ft),oe.set(M,I*G*ft);const zt=[ft,ft,ft,ft,ft,ft];_e.set(zt,ee*G*ft)}const ve=new xr;ve.setAttribute("position",new Qr(Q,z)),ve.setAttribute("uv",new Qr(oe,I)),ve.setAttribute("faceIndex",new Qr(_e,ee)),e.push(ve),s.push(new Zs(ve,null)),o>Jg&&o--}return{lodPlanes:e,sizeLods:t,sigmas:n,lodMeshes:s}}function DN(r,e){const t={magFilter:Rn,minFilter:Rn,generateMipmaps:!1,type:Vs,format:D,colorSpace:iu},n=new Za(r,e,t);return n.texture.mapping=Ke,n.texture.name="PMREM.cubeUv",n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function sb(r,e,t,n,s){r.viewport.set(e,t,n,s),r.scissor.set(e,t,n,s)}function ES(r){const e=new ya;return e.depthTest=!1,e.depthWrite=!1,e.blending=ye,e.name=`PMREM_${r}`,e}function BV(r,e,t){const n=Hl(new Array(fm).fill(0)),s=cr(new ot(0,1,0)),o=cr(0),a=ut(fm),c=cr(0),u=cr(1),d=Ps(null),p=cr(0),m=ut(1/e),y=ut(1/t),M=ut(r),T={n:a,latitudinal:c,weights:n,poleAxis:s,outputDirection:TS,dTheta:o,samples:u,envMap:d,mipInt:p,CUBEUV_TEXEL_WIDTH:m,CUBEUV_TEXEL_HEIGHT:y,CUBEUV_MAX_MIP:M},G=ES("blur");return G.fragmentNode=RN(ac(qs({},T),{latitudinal:c.equal(1)})),LN.set(G,T),G}function ON(r){const e=ES("cubemap");return e.fragmentNode=$g(r,TS),e}function FN(r){const e=ES("equirect");return e.fragmentNode=Ps(r,rS(TS),0),e}const BN=new WeakMap;function UV(r){const e=Math.log2(r)-2,t=1/r;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:t,maxMip:e}}function kV(r,e,t){const n=zV(e);let s=n.get(r);if((s!==void 0?s.pmremVersion:-1)!==r.pmremVersion){const a=r.image;if(r.isCubeTexture)if(GV(a))s=t.fromCubemap(r,s);else return null;else if(WV(a))s=t.fromEquirectangular(r,s);else return null;s.pmremVersion=r.pmremVersion,n.set(r,s)}return s.texture}function zV(r){let e=BN.get(r);return e===void 0&&(e=new WeakMap,BN.set(r,e)),e}class VV extends Ra{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 Wo;s.isRenderTargetTexture=!0,this._texture=Ps(s),this._width=cr(0),this._height=cr(0),this._maxMip=cr(0),this.updateBeforeType=rs.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=UV(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=kV(s,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new OV(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this)),t=BM.mul(qt(t.x,t.y.negate(),t.z));let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),CN(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}}function GV(r){if(r==null)return!1;let e=0;const t=6;for(let n=0;n<t;n++)r[n]!==void 0&&e++;return e===t}function WV(r){return r==null?!1:r.height>0}const AS=zr(VV).setParameterLength(1,3),UN=new WeakMap;class HV extends Xg{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=UN.get(m);y===void 0&&(y=AS(m),UN.set(m,y)),n=y}const o=t.useAnisotropy===!0||t.anisotropy>0?n2:fo,a=n.context(kN(Ph,o)).mul(G_),c=n.context($V(Vf)).mul(Math.PI).mul(G_),u=hv(a),d=hv(c);e.context.radiance.addAssign(u),e.context.iblIrradiance.addAssign(d);const p=e.context.lightingModel.clearcoatRadiance;if(p){const m=n.context(kN(tv,cm)).mul(G_),y=hv(m);p.addAssign(y)}}}const kN=(r,e)=>{let t=null;return{getUV:()=>(t===null&&(t=Vo.negate().reflect(e),t=r.mul(r).mix(t,e).normalize(),t=t.transformDirection(qc)),t),getTextureLevel:()=>r}},$V=r=>({getUV:()=>r,getTextureLevel:()=>ut(1)}),jV=new Bp;class zN extends ya{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(jV),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new HV(t):null}setupLightingModel(){return new MN}setupSpecular(){const e=Hs(qt(.04),to.rgb,ev);Mc.assign(e),iv.assign(1)}setupVariants(){const e=this.metalnessNode?ut(this.metalnessNode):u2;ev.assign(e);let t=this.roughnessNode?ut(this.roughnessNode):c2;t=oS({roughness:t}),Ph.assign(t),this.setupSpecular(),to.assign(Bi(to.rgb.mul(e.oneMinus()),to.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const XV=new Cx;class qV extends zN{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(XV),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?ut(this.iorNode):S2;sv.assign(e),Mc.assign(Hs(Sc(mM(sv.sub(1).div(sv.add(1))).mul(l2),qt(1)).mul(HM),to.rgb,ev)),iv.assign(Hs(HM,1,ev))}setupLightingModel(){return new MN(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?ut(this.clearcoatNode):d2,n=this.clearcoatRoughnessNode?ut(this.clearcoatRoughnessNode):f2;M_.assign(t),tv.assign(oS({roughness:n}))}if(this.useSheen){const t=this.sheenNode?qt(this.sheenNode):g2,n=this.sheenRoughnessNode?ut(this.sheenRoughnessNode):y2;sm.assign(t),S_.assign(n)}if(this.useIridescence){const t=this.iridescenceNode?ut(this.iridescenceNode):x2,n=this.iridescenceIORNode?ut(this.iridescenceIORNode):_2,s=this.iridescenceThicknessNode?ut(this.iridescenceThicknessNode):b2;T_.assign(t),eM.assign(n),tM.assign(s)}if(this.useAnisotropy){const t=(this.anisotropyNode?Bn(this.anisotropyNode):v2).toVar();Bf.assign(t.length()),sr(Bf.equal(0),()=>{t.assign(Bn(1,0))}).Else(()=>{t.divAssign(Bn(Bf)),Bf.assign(Bf.saturate())}),E_.assign(Bf.pow2().mix(Ph.pow2(),1)),nv.assign(um[0].mul(t.x).add(um[1].mul(t.y))),om.assign(um[1].mul(t.x).sub(um[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?ut(this.transmissionNode):w2,n=this.thicknessNode?ut(this.thicknessNode):M2,s=this.attenuationDistanceNode?ut(this.attenuationDistanceNode):T2,o=this.attenuationColorNode?qt(this.attenuationColorNode):E2;if(C_.assign(t),nM.assign(n),iM.assign(s),rM.assign(o),this.useDispersion){const a=this.dispersionNode?ut(this.dispersionNode):C2;sM.assign(a)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?qt(this.clearcoatNormalNode):p2}setup(e){e.context.setupClearcoatNormal=()=>Vg(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 YV 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(fo.mul(c)).normalize(),M=ut(Vo.dot(y.negate()).saturate().pow(p).mul(m)),T=qt(M.add(u).mul(a));n.directDiffuse.addAssign(T.mul(d.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:n},s)}}class AY extends null{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=ut(.1),this.thicknessAmbientNode=ut(0),this.thicknessAttenuationNode=ut(.1),this.thicknessPowerNode=ut(2),this.thicknessScaleNode=ut(10)}get useSSS(){return this.thicknessColorNode!==null}setupLightingModel(){return new YV(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 ZV=Kt(({normal:r,lightDirection:e,builder:t})=>{const n=r.dot(e),s=Bn(n.mul(.5).add(.5),0);if(t.material.gradientMap){const o=kd("gradientMap","texture").context({getUV:()=>s});return qt(o.r)}else{const o=s.fwidth().mul(.5);return Hs(qt(.7),qt(1),Su(ut(.7).sub(o.x),ut(.7).add(o.x),s.x))}});class KV extends eb{direct({lightDirection:e,lightColor:t,reflectedLight:n},s){const o=ZV({normal:V_,lightDirection:e,builder:s}).mul(t);n.directDiffuse.addAssign(o.mul(dm({diffuseColor:to.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:n,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(n.mul(dm({diffuseColor:to}))),s.indirectDiffuse.mulAssign(t)}}const JV=new ly;class QV extends ya{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(JV),this.setValues(e)}setupLightingModel(){return new KV}}const VN=Kt(()=>{const r=qt(Vo.z,0,Vo.x.negate()).normalize(),e=Vo.cross(r);return Bn(r.dot(fo),e.dot(fo)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),e5=new uy;class t5 extends ya{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(e5),this.setValues(e)}setupVariants(e){const t=VN;let n;e.material.matcap?n=kd("matcap","texture").context({getUV:()=>t}):n=qt(Hs(.2,.8,t.y)),to.rgb.mulAssign(n.rgb)}}class n5 extends Ra{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 w_(o,a,a.negate(),o).mul(n)}else{const o=t,a=rm(Bi(1,0,0,0),Bi(0,Id(o.x),Xc(o.x).negate(),0),Bi(0,Xc(o.x),Id(o.x),0),Bi(0,0,0,1)),c=rm(Bi(Id(o.y),0,Xc(o.y),0),Bi(0,1,0,0),Bi(Xc(o.y).negate(),0,Id(o.y),0),Bi(0,0,0,1)),u=rm(Bi(Id(o.z),Xc(o.z).negate(),0,0),Bi(Xc(o.z),Id(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 _v=zr(n5).setParameterLength(2),i5=new cp;class GN extends ya{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(i5),this.setValues(e)}setupPositionView(e){const{object:t,camera:n}=e,{positionNode:s,rotationNode:o,scaleNode:a,sizeAttenuation:c}=this,u=Ud.mul(qt(s||0));let d=Bn(Au[0].xyz.length(),Au[1].xyz.length());a!==null&&(d=d.mul(Bn(a))),n.isPerspectiveCamera&&c===!1&&(d=d.mul(u.z.negate()));let p=Pl.xy;if(t.center&&t.center.isVector2===!0){const M=sz("center","vec2",t);p=p.sub(M.sub(.5))}p=p.mul(d);const m=ut(o||m2),y=_v(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 r5=new uf,s5=new yn;class o5 extends GN{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(r5),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return Ud.mul(qt(e||Pa)).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):A2;d=d.mul(AR),n.isPerspectiveCamera&&c===!0&&(d=d.mul(a5.div(Ia.z.negate()))),o&&o.isNode&&(d=d.mul(Bn(o)));let p=Pl.xy;if(s&&s.isNode){const m=ut(s);p=_v(p,m)}return p=p.mul(d),p=p.div(NM.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 a5=cr(1).onFrameUpdate(function({renderer:r}){const e=r.getSize(s5);this.value=.5*e.y});class l5 extends eb{constructor(){super(),this.shadowNode=ut(1).toVar("shadowMask")}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){to.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(to.rgb)}}const c5=new hg;class u5 extends ya{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(c5),this.setValues(e)}setupLightingModel(){return new l5}}const bv=th("vec3"),WN=th("vec3"),HN=th("vec3");class h5 extends null{constructor(){super()}start(e){const{material:t,context:n}=e,s=th("vec3"),o=th("vec3");sr(gv.sub(Yc).length().greaterThan(PR.mul(2)),()=>{s.assign(gv),o.assign(Yc)}).Else(()=>{s.assign(Yc),o.assign(gv)});const a=o.sub(s),c=cr("int").onRenderUpdate(({material:y})=>y.steps),u=a.length().div(c).toVar(),d=a.normalize().toVar(),p=ut(0).toVar(),m=qt(1).toVar();t.offsetNode&&p.addAssign(t.offsetNode.mul(u)),po(c,()=>{const y=s.add(d.mul(p)),M=qc.mul(Bi(y,1)).xyz;t.depthNode!==null&&(WN.assign(Zg(eS(M.z,Fd,Bd))),n.sceneDepthNode=Zg(t.depthNode).toVar()),n.positionWorld=y,n.shadowPositionWorld=y,n.positionView=M,bv.assign(0);let T;t.scatteringNode&&(T=t.scatteringNode({positionRay:y})),super.start(e),T&&bv.mulAssign(T);const G=bv.mul(.01).negate().mul(u).exp();m.mulAssign(G),p.addAssign(u)}),HN.addAssign(m.saturate().oneMinus())}scatteringLight(e,t){const n=t.context.sceneDepthNode;n?sr(n.greaterThanEqual(WN),()=>{bv.addAssign(e)}):bv.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(gV({P:p,p0:a,p1:c,p2:u,p3:d})).pow(1.5);this.scatteringLight(m,o)}finish(e){e.context.outgoingLight.assign(HN)}}class CY 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 h5}}class d5{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 nh{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 f5=0;function p5(r){const e=Object.keys(r);let t=Object.getPrototypeOf(r);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 m5{constructor(e,t,n,s,o,a,c,u,d,p){this.id=f5++,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 p5(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+",",Bw(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=jy(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=jy(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 mm=[];class g5{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);mm[0]=e,mm[1]=t,mm[2]=a,mm[3]=o;let p=d.get(mm);return p===void 0?(p=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,s,o,a,c,u),d.set(mm,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)),mm.length=0,p}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new nh)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,s,o,a,c,u,d,p,m){const y=this.getChainMap(m),M=new m5(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 Hf{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 Ru={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},$f=16,y5=211,v5=212;class x5 extends Hf{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===Ru.VERTEX?this.backend.createAttribute(e):t===Ru.INDEX?this.backend.createIndexAttribute(e):t===Ru.STORAGE?this.backend.createStorageAttribute(e):t===Ru.INDIRECT&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{const s=this._getBufferAttribute(e);(n.version<s.version||s.usage===Zd)&&(this.backend.updateAttribute(e),n.version=s.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}function $N(r){return r.index!==null?r.index.version:r.attributes.position.version}function jN(r){const e=[],t=r.index,n=r.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(sp(e)?pc:ka)(e,1);return s.version=$N(r),s}class _5 extends Hf{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,Ru.STORAGE):this.updateAttribute(o,Ru.VERTEX);const n=this.getIndex(e);n!==null&&this.updateAttribute(n,Ru.INDEX);const s=e.geometry.indirect;s!==null&&this.updateAttribute(s,Ru.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=jN(t),o.set(t,a)):a.version!==$N(t)&&(this.attributes.delete(a),a=jN(t),o.set(t,a)),s=a}return s}}class b5{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 XN{constructor(e){this.cacheKey=e,this.usedTimes=0}}class w5 extends XN{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}}class M5 extends XN{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let S5=0;class CS{constructor(e,t,n,s=null,o=null){this.id=S5++,this.code=e,this.stage=t,this.name=n,this.transforms=s,this.attributes=o,this.usedTimes=0}}class T5 extends Hf{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 CS(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 CS(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 CS(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 M5(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 w5(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 E5 extends Hf{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?Ru.INDIRECT:Ru.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?Ru.INDIRECT:Ru.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 A5(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?r.z-e.z:r.id-e.id}function qN(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function YN(r){return(r.transmission>0||r.transmissionNode)&&r.side===re&&r.forceSinglePass===!1}class C5{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?(YN(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?(YN(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||A5),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||qN),this.transparent.length>1&&this.transparent.sort(t||qN)}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 wv=[];class R5{constructor(e){this.lighting=e,this.lists=new nh}get(e,t){const n=this.lists;wv[0]=e,wv[1]=t;let s=n.get(wv);return s===void 0&&(s=new C5(this.lighting,e,t),n.set(wv,s)),wv.length=0,s}dispose(){this.lists=new nh}}let N5=0;class P5{constructor(){this.id=N5++,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 ZN(this)}}function ZN(r){const{textures:e,activeCubeFace:t,activeMipmapLevel:n}=r,s=[t,n];for(const o of e)s.push(o.id);return $y(s)}const Mv=[],I5=new $m,L5=new Hm;class D5{constructor(){this.chainMaps={}}get(e,t,n=null){Mv[0]=e,Mv[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(Mv);return a===void 0&&(a=new P5,o.set(Mv,a)),Mv.length=0,n!==null&&(a.sampleCount=n.samples===0?1:n.samples),a}getForClear(e=null){return this.get(I5,L5,e)}_getChainMap(e){return this.chainMaps[e]||(this.chainMaps[e]=new nh)}dispose(){this.chainMaps={}}}const O5=new ot;class F5 extends Hf{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 gc,p.format=e.stencilBuffer?_:U,p.type=e.stencilBuffer?Da:as,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=O5){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 RS 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 KN extends ho{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const B5=(r,e)=>Cn(new KN(r,e));class U5 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 Bg(t);return this._currentCond=wl(e,n),this.add(this._currentCond)}ElseIf(e,t){const n=new Bg(t),s=wl(e,n);return this._currentCond.elseNode=s,this._currentCond=s,this}Else(e){return this._currentCond.elseNode=new Bg(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 Bg(n);let o=t[0];for(let c=1;c<t.length;c++)o=o.or(t[c]);const a=wl(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=__();Qy(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),Qy(s),e.currentStack=n,a}}const ob=zr(U5).setParameterLength(0,1);function k5(r){return Object.entries(r).map(([e,t])=>typeof t=="string"?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})}class z5 extends Wi{static get type(){return"StructTypeNode"}constructor(e,t=null){super("struct"),this.membersLayout=k5(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=BA(o)*t,c=UA(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 V5 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 G5=(r,e=null)=>{const t=new z5(r,e),n=(...s)=>{let o=null;if(s.length>0)if(s[0].isNode){o={};const a=Object.keys(r);for(let c=0;c<s.length;c++)o[a[c]]=s[c]}else o=s[0];return Cn(new V5(t,o))};return n.layout=t,n.isStruct=!0,n};class JN 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 W5=zr(JN);function QN(r,e){for(let t=0;t<r.length;t++)if(r[t].name===e)return t;return-1}class H5 extends JN{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=qs(qs({},this.outputNodes),e.outputNodes);return eP(t)}setup(e){const t=this.outputNodes,n=e.renderer.getRenderTarget(),s=[],o=n.textures;for(const a in t){const c=QN(o,a);s[c]=Bi(t[a])}return this.members=s,super.setup(e)}}const eP=zr(H5);class Sv extends Ra{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 $5=ci(Sv).setParameterLength(2),j5=r=>new Sv(r,"int","float"),X5=r=>new Sv(r,"uint","float"),q5=r=>new Sv(r,"float","int"),Y5=r=>new Sv(r,"float","uint"),Z5=Kt(([r])=>{const e=r.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/Kf(2,32))}),NS=(r,e)=>wu(Kr(4,r.mul(Ds(1,r))),e),K5=(r,e)=>r.lessThan(.5)?NS(r.mul(2),e).div(2):Ds(1,NS(Kr(Ds(1,r),2),e).div(2)),J5=(r,e,t)=>wu(jc(wu(r,e),Wa(wu(r,e),wu(Ds(1,r),t))),1/e),Q5=(r,e)=>Xc(N_.mul(e.mul(r).sub(1))).div(N_.mul(e.mul(r).sub(1))),zd=Kt(([r])=>r.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),eG=Kt(([r])=>qt(zd(r.z.add(zd(r.y.mul(1)))),zd(r.z.add(zd(r.x.mul(1)))),zd(r.y.add(zd(r.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),tG=Kt(([r,e,t])=>{const n=qt(r).toVar(),s=ut(1.4).toVar(),o=ut(0).toVar(),a=qt(n).toVar();return po({start:ut(0),end:ut(3),type:"float",condition:"<="},()=>{const c=qt(eG(a.mul(2))).toVar();n.addAssign(c.add(t.mul(ut(.1).mul(e)))),a.mulAssign(1.8),s.mulAssign(1.5),n.mulAssign(1.2);const u=ut(zd(n.z.add(zd(n.x.add(zd(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 nG 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 iG=zr(nG),Il=r=>(...e)=>iG(r,...e),e0=cr(0).setGroup(or).onRenderUpdate(r=>r.time),rG=cr(0).setGroup(or).onRenderUpdate(r=>r.deltaTime),tP=cr(0,"uint").setGroup(or).onRenderUpdate(r=>r.frameId),sG=(r=e0)=>r.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),oG=(r=e0)=>r.fract().round(),aG=(r=e0)=>r.add(.5).fract().mul(2).sub(1).abs(),lG=(r=e0)=>r.fract(),cG=Kt(([r,e,t=Bn(.5)])=>_v(r.sub(t),e).add(t)),uG=Kt(([r,e,t=Bn(.5)])=>{const n=r.sub(t),s=n.dot(n),a=s.mul(s).mul(e);return r.add(n.mul(a))}),hG=Kt(({position:r=null,horizontal:e=!0,vertical:t=!1})=>{let n;r!==null?(n=Au.toVar(),n[3][0]=r.x,n[3][1]=r.y,n[3][2]=r.z):n=Au;const s=qc.mul(n);return Ky(e)&&(s[0][0]=Au[0].length(),s[0][1]=0,s[0][2]=0),Ky(t)&&(s[1][0]=0,s[1][1]=Au[1].length(),s[1][2]=0),s[2][0]=0,s[2][1]=0,s[2][2]=1,Tu.mul(s).mul(Pa)}),dG=Kt(([r=null])=>{const e=Zg();return Zg(QM(r)).sub(e).lessThan(0).select(Od,r)});class fG extends Wi{static get type(){return"SpriteSheetUVNode"}constructor(e,t=vo(),n=ut(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 pG=zr(fG).setParameterLength(3),nP=Kt(([r,e=null,t=null,n=ut(1),s=Pa,o=Tc])=>{let a=o.abs().normalize();a=a.div(a.dot(qt(1)));const c=s.yz.mul(n),u=s.zx.mul(n),d=s.xy.mul(n),p=r.value,m=e!==null?e.value:p,y=t!==null?t.value:p,M=Ps(p,c).mul(a.x),T=Ps(m,u).mul(a.y),G=Ps(y,d).mul(a.z);return Wa(M,T,G)}),mG=(...r)=>nP(...r),t0=new Al,gm=new ot,n0=new ot,PS=new ot,Tv=new Ft,ab=new ot(0,0,-1),Uh=new mr,Ev=new ot,lb=new ot,Av=new mr,cb=new yn,ub=new Za,gG=Od.flipX();ub.depthTexture=new gc(1,1);let hb=!1;class IS extends Bh{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||ub.texture,gG),this._reflectorBaseNode=e.reflector||new yG(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 IS({defaultTexture:ub.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 yG extends Wi{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:n=new Jr,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&&(ol('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?rs.RENDER:rs.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const n=this.resolutionScale;t.getDrawingBufferSize(cb),e.setSize(Math.round(cb.width*n),Math.round(cb.height*n))}setup(e){return this._updateResolution(ub,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 Za(0,0,{type:Vs,samples:this.samples}),this.generateMipmaps===!0&&(t.texture.minFilter=Vi,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new gc),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&hb)return!1;hb=!0;const{scene:t,camera:n,renderer:s,material:o}=e,{target:a}=this,c=this.getVirtualCamera(n),u=this.getRenderTarget(c);s.getDrawingBufferSize(cb),this._updateResolution(u,s),n0.setFromMatrixPosition(a.matrixWorld),PS.setFromMatrixPosition(n.matrixWorld),Tv.extractRotation(a.matrixWorld),gm.set(0,0,1),gm.applyMatrix4(Tv),Ev.subVectors(n0,PS);const d=Ev.dot(gm)>0;let p=!1;if(d===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){hb=!1;return}p=!0}Ev.reflect(gm).negate(),Ev.add(n0),Tv.extractRotation(n.matrixWorld),ab.set(0,0,-1),ab.applyMatrix4(Tv),ab.add(PS),lb.subVectors(n0,ab),lb.reflect(gm).negate(),lb.add(n0),c.coordinateSystem=n.coordinateSystem,c.position.copy(Ev),c.up.set(0,1,0),c.up.applyMatrix4(Tv),c.up.reflect(gm),c.lookAt(lb),c.near=n.near,c.far=n.far,c.updateMatrixWorld(),c.projectionMatrix.copy(n.projectionMatrix),t0.setFromNormalAndCoplanarPoint(gm,n0),t0.applyMatrix4(c.matrixWorldInverse),Uh.set(t0.normal.x,t0.normal.y,t0.normal.z,t0.constant);const m=c.projectionMatrix;Av.x=(Math.sign(Uh.x)+m.elements[8])/m.elements[0],Av.y=(Math.sign(Uh.y)+m.elements[9])/m.elements[5],Av.z=-1,Av.w=(1+m.elements[10])/m.elements[14],Uh.multiplyScalar(1/Uh.dot(Av));const y=0;m.elements[2]=Uh.x,m.elements[6]=Uh.y,m.elements[10]=s.coordinateSystem===ja?Uh.z-y:Uh.z+1-y,m.elements[14]=Uh.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,hb=!1,this.forceUpdate=!1}get resolution(){return ol('THREE.ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale}set resolution(e){ol('THREE.ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}}const vG=r=>Cn(new IS(r)),LS=new Cf(-1,1,1,-1,0,1);class xG 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 _G=new xG;class Cv extends Zs{constructor(e=null){super(_G,e),this.camera=LS,this.isQuadMesh=!0}renderAsync(e){return hr(this,null,function*(){return e.renderAsync(this,LS)})}render(e){e.render(this,LS)}}const bG=new yn;class wG extends Bh{static get type(){return"RTTNode"}constructor(e,t=null,n=null,s={type:Vs}){const o=new Za(t,n,s);super(o.texture,vo()),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 Cv(new ya),this.updateBeforeType=rs.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(bG),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 Bh(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const iP=(r,...e)=>Cn(new wG(Cn(r),...e)),MG=(r,...e)=>r.isSampleNode||r.isTextureNode?r:r.isPassNode?r.getTextureNode():iP(r,...e),i0=Kt(([r,e,t],n)=>{let s;n.renderer.coordinateSystem===ja?(r=Bn(r.x,r.y.oneMinus()).mul(2).sub(1),s=Bi(qt(r,e),1)):s=Bi(qt(r.x,r.y.oneMinus(),e).mul(2).sub(1),1);const o=Bi(t.mul(s));return o.xyz.div(o.w)}),SG=Kt(([r,e])=>{const t=e.mul(Bi(r,1)),n=t.xy.div(t.w).mul(.5).add(.5).toVar();return Bn(n.x,n.y.oneMinus())}),TG=Kt(([r,e,t])=>{const n=kf(Na(e)),s=pl(r.mul(n)).toVar(),o=Na(e,s).toVar(),a=Na(e,s.sub(pl(2,0))).toVar(),c=Na(e,s.sub(pl(1,0))).toVar(),u=Na(e,s.add(pl(1,0))).toVar(),d=Na(e,s.add(pl(2,0))).toVar(),p=Na(e,s.add(pl(0,2))).toVar(),m=Na(e,s.add(pl(0,1))).toVar(),y=Na(e,s.sub(pl(0,1))).toVar(),M=Na(e,s.sub(pl(0,2))).toVar(),T=Oo(Ds(ut(2).mul(c).sub(a),o)).toVar(),G=Oo(Ds(ut(2).mul(u).sub(d),o)).toVar(),z=Oo(Ds(ut(2).mul(m).sub(p),o)).toVar(),I=Oo(Ds(ut(2).mul(y).sub(M),o)).toVar(),ee=i0(r,o,t).toVar(),Q=T.lessThan(G).select(ee.sub(i0(r.sub(Bn(ut(1).div(n.x),0)),c,t)),ee.negate().add(i0(r.add(Bn(ut(1).div(n.x),0)),u,t))),oe=z.lessThan(I).select(ee.sub(i0(r.add(Bn(0,ut(1).div(n.y))),m,t)),ee.negate().add(i0(r.sub(Bn(0,ut(1).div(n.y))),y,t)));return Nd(O_(Q,oe))});class EG 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(vo())}sample(e){return this.callback(e)}}const AG=(r,e=null)=>Cn(new EG(r,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=rs.OBJECT:e===jf.MATERIAL&&(this.updateType=rs.RENDER)}update(e){this.callback(e)}}jf.OBJECT="object",jf.MATERIAL="material";const rP=(r,e)=>Cn(new jf(r,e)).toStack(),CG=r=>rP(jf.OBJECT,r),RG=r=>rP(jf.MATERIAL,r);class NG extends kc{constructor(e,t,n=Float32Array){const s=ArrayBuffer.isView(e)?e:new n(e*t);super(s,t),this.isStorageInstancedBufferAttribute=!0}}class PG extends Qr{constructor(e,t,n=Float32Array){const s=ArrayBuffer.isView(e)?e:new n(e*t);super(s,t),this.isStorageBufferAttribute=!0}}const IG=(r,e="float")=>{let t,n;e.isStruct===!0?(t=e.layout.getLength(),n=qy("float")):(t=zw(e),n=qy(e));const s=new PG(r,t,n);return hm(s,e,r)},LG=(r,e="float")=>{let t,n;e.isStruct===!0?(t=e.layout.getLength(),n=qy("float")):(t=zw(e),n=qy(e));const s=new NG(r,t,n);return hm(s,e,r)};class DG 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 OG=xi(DG),Rv=new Qi,DS=new Ft;class Ac extends Wi{static get type(){return"SceneNode"}constructor(e=Ac.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===Ac.BACKGROUND_BLURRINESS?s=No("backgroundBlurriness","float",n):t===Ac.BACKGROUND_INTENSITY?s=No("backgroundIntensity","float",n):t===Ac.BACKGROUND_ROTATION?s=cr("mat4").setName("backgroundRotation").setGroup(or).onRenderUpdate(()=>{const o=n.background;return o!==null&&o.isTexture&&o.mapping!==te?(Rv.copy(n.backgroundRotation),Rv.x*=-1,Rv.y*=-1,Rv.z*=-1,DS.makeRotationFromEuler(Rv)):DS.identity(),DS}):console.error("THREE.SceneNode: Unknown scope:",t),s}}Ac.BACKGROUND_BLURRINESS="backgroundBlurriness",Ac.BACKGROUND_INTENSITY="backgroundIntensity",Ac.BACKGROUND_ROTATION="backgroundRotation";const sP=xi(Ac,Ac.BACKGROUND_BLURRINESS),OS=xi(Ac,Ac.BACKGROUND_INTENSITY),oP=xi(Ac,Ac.BACKGROUND_ROTATION);class FG extends Bh{static get type(){return"StorageTextureNode"}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=Nl.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(Nl.READ_WRITE)}toReadOnly(){return this.setAccess(Nl.READ_ONLY)}toWriteOnly(){return this.setAccess(Nl.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 aP=zr(FG).setParameterLength(1,3),BG=(r,e,t)=>{const n=aP(r,e,t);return t!==null&&n.toStack(),n},UG=Kt(({texture:r,uv:e})=>{const n=qt().toVar();return sr(e.x.lessThan(1e-4),()=>{n.assign(qt(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{n.assign(qt(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{n.assign(qt(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{n.assign(qt(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{n.assign(qt(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{n.assign(qt(0,0,-1))}).Else(()=>{const o=r.sample(e.add(qt(-.01,0,0))).r.sub(r.sample(e.add(qt(.01,0,0))).r),a=r.sample(e.add(qt(0,-.01,0))).r.sub(r.sample(e.add(qt(0,.01,0))).r),c=r.sample(e.add(qt(0,0,-.01))).r.sub(r.sample(e.add(qt(0,0,.01))).r);n.assign(qt(o,a,c))}),n.normalize()});class kG extends Bh{static get type(){return"Texture3DNode"}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return qt(.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(kf(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 UG({texture:this,uv:e})}}const lP=zr(kG).setParameterLength(1,3);class zG extends W_{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 VG=(r,e,t)=>Cn(new zG(r,e,t)),cP=new WeakMap;class GG extends Ra{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=rs.OBJECT,this.updateAfterType=rs.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=hP(n);this.previousModelWorldMatrix.value.copy(s);const o=uP(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}){hP(e).copy(e.matrixWorld)}setup(){const e=this.projectionMatrix===null?Tu:cr(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(Ud).mul(Pa),s=this.previousProjectionMatrix.mul(t).mul(z_),o=n.xy.div(n.w),a=s.xy.div(s.w);return Ds(o,a)}}function uP(r){let e=cP.get(r);return e===void 0&&(e={},cP.set(r,e)),e}function hP(r,e=0){const t=uP(r);let n=t[e];return n===void 0&&(t[e]=n=new Ft,t[e].copy(r.matrixWorld)),n}const WG=xi(GG),HG=Kt(([r])=>FS(r.rgb)),$G=Kt(([r,e=ut(1)])=>e.mix(FS(r.rgb),r.rgb)),jG=Kt(([r,e=ut(1)])=>{const t=Wa(r.r,r.g,r.b).div(3),n=r.r.max(r.g.max(r.b)),s=n.sub(t).mul(e).mul(-3);return Hs(r.rgb,n,s)}),XG=Kt(([r,e=ut(1)])=>{const t=qt(.57735,.57735,.57735),n=e.cos();return qt(r.rgb.mul(n).add(t.cross(r.rgb).mul(e.sin()).add(t.mul(Uf(t,r.rgb).mul(n.oneMinus())))))}),FS=(r,e=qt(Ki.getLuminanceCoefficients(new ot)))=>Uf(r,e),qG=Kt(([r,e=qt(1),t=qt(0),n=qt(1),s=ut(1),o=qt(Ki.getLuminanceCoefficients(new ot,iu))])=>{const a=r.rgb.dot(qt(o)),c=ga(r.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,r.a)});class YG extends Ra{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 ZG=zr(YG).setParameterLength(2),db=new yn;class dP extends Bh{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 fP extends dP{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 kh extends Ra{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 gc;o.isRenderTargetTexture=!0,o.name="depth";const a=new Za(this._width*this._pixelRatio,this._height*this._pixelRatio,qs({type:Vs},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=rs.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 fP(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 fP(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=tS(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=Yg(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===kh.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),db.set(a.width,a.height)):(s=this.camera,o=t.getPixelRatio(),t.getSize(db)),this._pixelRatio=o,this.setSize(db.width,db.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()}}kh.COLOR="color",kh.DEPTH="depth";const KG=(r,e,t)=>Cn(new kh(kh.COLOR,r,e,t)),JG=(r,e)=>Cn(new dP(r,e)),QG=(r,e,t)=>Cn(new kh(kh.DEPTH,r,e,t));class e6 extends kh{static get type(){return"ToonOutlinePassNode"}constructor(e,t,n,s,o){super(kh.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 ya;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=K;const t=Tc.negate(),n=Tu.mul(Ud),s=ut(1),o=n.mul(Bi(Pa,1)),a=n.mul(Bi(Pa.add(t),1)),c=Nd(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 t6=(r,e,t=new jn(0,0,0),n=.003,s=1)=>Cn(new e6(r,e,Cn(t),Cn(n),Cn(s))),pP=Kt(([r,e])=>r.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),mP=Kt(([r,e])=>(r=r.mul(e),r.div(r.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),gP=Kt(([r,e])=>{r=r.mul(e),r=r.sub(.004).max(0);const t=r.mul(r.mul(6.2).add(.5)),n=r.mul(r.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"}]}),n6=Kt(([r])=>{const e=r.mul(r.add(.0245786)).sub(90537e-9),t=r.mul(r.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),yP=Kt(([r,e])=>{const t=Wl(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),n=Wl(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return r=r.mul(e).div(.6),r=t.mul(r),r=n6(r),r=n.mul(r),r.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),i6=Wl(qt(1.6605,-.1246,-.0182),qt(-.5876,1.1329,-.1006),qt(-.0728,-.0083,1.1187)),r6=Wl(qt(.6274,.0691,.0164),qt(.3293,.9195,.088),qt(.0433,.0113,.8956)),s6=Kt(([r])=>{const e=qt(r).toVar(),t=qt(e.mul(e)).toVar(),n=qt(t.mul(t)).toVar();return ut(15.5).mul(n.mul(t)).sub(Kr(40.14,n.mul(e))).add(Kr(31.96,n).sub(Kr(6.868,t.mul(e))).add(Kr(.4298,t).add(Kr(.1191,e).sub(.00232))))}),vP=Kt(([r,e])=>{const t=qt(r).toVar(),n=Wl(qt(.856627153315983,.137318972929847,.11189821299995),qt(.0951212405381588,.761241990602591,.0767994186031903),qt(.0482516061458583,.101439036467562,.811302368396859)),s=Wl(qt(1.1271005818144368,-.1413297634984383,-.14132976349843826),qt(-.11060664309660323,1.157823702216272,-.11060664309660294),qt(-.016493938717834573,-.016493938717834257,1.2519364065950405)),o=ut(-12.47393),a=ut(4.026069);return t.mulAssign(e),t.assign(r6.mul(t)),t.assign(n.mul(t)),t.assign(ga(t,1e-10)),t.assign(Ih(t)),t.assign(t.sub(o).div(a.sub(o))),t.assign(Mu(t,0,1)),t.assign(s6(t)),t.assign(s.mul(t)),t.assign(wu(ga(qt(0),t),qt(2.2))),t.assign(i6.mul(t)),t.assign(Mu(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),xP=Kt(([r,e])=>{const t=ut(.76),n=ut(.15);r=r.mul(e);const s=Sc(r.r,Sc(r.g,r.b)),o=wl(s.lessThan(.08),s.sub(Kr(6.25,s.mul(s))),.04);r.subAssign(o);const a=ga(r.r,ga(r.g,r.b));sr(a.lessThan(t),()=>r);const c=Ds(1,t),u=Ds(1,c.mul(c).div(a.add(c.sub(t))));r.mulAssign(u.div(a));const d=Ds(1,jc(1,n.mul(a.sub(u)).add(1)));return Hs(r,qt(u),d)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class $l 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 fb=zr($l).setParameterLength(1,3),o6=(r,e)=>fb(r,e,"js"),a6=(r,e)=>fb(r,e,"wgsl"),l6=(r,e)=>fb(r,e,"glsl");class _P extends $l{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 bP=(r,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 _P(r,e,t)),s=(...o)=>n.call(...o);return s.functionNode=n,s},c6=(r,e)=>bP(r,e,"glsl"),u6=(r,e)=>bP(r,e,"wgsl");class h6 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 Ol,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:ut()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=Gw(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=Ww(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 pb=zr(h6).setParameterLength(1);class wP 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 d6{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 mb=new wP;class f6 extends Wi{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new wP,this._output=pb(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]=pb(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]=pb(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 d6(this),s=mb.get("THREE"),o=mb.get("TSL"),a=this.getMethod(),c=[n,this._local,mb,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:ut()}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=[Bw(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return $y(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 p6=zr(f6).setParameterLength(1,2);function MP(r){let e;const t=r.context.getViewZ;return t!==void 0&&(e=t(this)),(e||Ia.z).negate()}const BS=Kt(([r,e],t)=>{const n=MP(t);return Su(r,e,n)}),US=Kt(([r],e)=>{const t=MP(e);return r.mul(r,t,t).negate().exp().oneMinus()}),Nv=Kt(([r,e])=>Bi(e.toFloat().mix(kg.rgb,r.toVec3()),kg.a));function m6(r,e,t){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),Nv(r,BS(e,t))}function g6(r,e){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),Nv(r,US(e))}let ym=null,vm=null;class y6 extends Wi{static get type(){return"RangeNode"}constructor(e=ut(),t=ut()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Rd(this.minNode.value)),n=e.getTypeLength(Rd(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(Rd(s)),c=e.getTypeLength(Rd(o));ym=ym||new mr,vm=vm||new mr,ym.setScalar(0),vm.setScalar(0),a===1?ym.setScalar(s):s.isColor?ym.set(s.r,s.g,s.b,1):ym.set(s.x,s.y,s.z||0,s.w||0),c===1?vm.setScalar(o):o.isColor?vm.set(o.r,o.g,o.b,1):vm.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=ym.getComponent(M),G=vm.getComponent(M);p[y]=Yh.lerp(T,G,Math.random())}const m=this.getNodeType(e);if(t.count<=4096)n=dv(p,"vec4",t.count).element(Gf).convert(m);else{const y=new kc(p,4);e.geometry.setAttribute("__range"+this.id,y),n=U_(y).convert(m)}}else n=ut(0);return n}}const v6=zr(y6).setParameterLength(2);class x6 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 Pv=(r,e)=>Cn(new x6(r,e)),_6=Pv("numWorkgroups","uvec3"),b6=Pv("workgroupId","uvec3"),w6=Pv("globalId","uvec3"),M6=Pv("localId","uvec3"),S6=Pv("subgroupSize","uint");class T6 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 kS=zr(T6),E6=()=>kS("workgroup").toStack(),A6=()=>kS("storage").toStack(),C6=()=>kS("texture").toStack();class R6 extends nm{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 N6 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 R6(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 P6=(r,e)=>Cn(new N6("Workgroup",r,e));class ml 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=Ld(p,o).toConst()),t.constNode.build(e)}}ml.ATOMIC_LOAD="atomicLoad",ml.ATOMIC_STORE="atomicStore",ml.ATOMIC_ADD="atomicAdd",ml.ATOMIC_SUB="atomicSub",ml.ATOMIC_MAX="atomicMax",ml.ATOMIC_MIN="atomicMin",ml.ATOMIC_AND="atomicAnd",ml.ATOMIC_OR="atomicOr",ml.ATOMIC_XOR="atomicXor";const I6=zr(ml),zh=(r,e,t)=>I6(r,e,t).toStack(),L6=r=>zh(ml.ATOMIC_LOAD,r,null),D6=(r,e)=>zh(ml.ATOMIC_STORE,r,e),O6=(r,e)=>zh(ml.ATOMIC_ADD,r,e),F6=(r,e)=>zh(ml.ATOMIC_SUB,r,e),B6=(r,e)=>zh(ml.ATOMIC_MAX,r,e),U6=(r,e)=>zh(ml.ATOMIC_MIN,r,e),k6=(r,e)=>zh(ml.ATOMIC_AND,r,e),z6=(r,e)=>zh(ml.ATOMIC_OR,r,e),V6=(r,e)=>zh(ml.ATOMIC_XOR,r,e);class Ai extends Ra{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 G6=ci(Ai,Ai.SUBGROUP_ELECT).setParameterLength(0),W6=ci(Ai,Ai.SUBGROUP_BALLOT).setParameterLength(1),H6=ci(Ai,Ai.SUBGROUP_ADD).setParameterLength(1),$6=ci(Ai,Ai.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),j6=ci(Ai,Ai.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),X6=ci(Ai,Ai.SUBGROUP_MUL).setParameterLength(1),q6=ci(Ai,Ai.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),Y6=ci(Ai,Ai.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),Z6=ci(Ai,Ai.SUBGROUP_AND).setParameterLength(1),K6=ci(Ai,Ai.SUBGROUP_OR).setParameterLength(1),J6=ci(Ai,Ai.SUBGROUP_XOR).setParameterLength(1),Q6=ci(Ai,Ai.SUBGROUP_MIN).setParameterLength(1),e8=ci(Ai,Ai.SUBGROUP_MAX).setParameterLength(1),t8=ci(Ai,Ai.SUBGROUP_ALL).setParameterLength(0),n8=ci(Ai,Ai.SUBGROUP_ANY).setParameterLength(0),i8=ci(Ai,Ai.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),r8=ci(Ai,Ai.QUAD_SWAP_X).setParameterLength(1),s8=ci(Ai,Ai.QUAD_SWAP_Y).setParameterLength(1),o8=ci(Ai,Ai.QUAD_SWAP_DIAGONAL).setParameterLength(1),a8=ci(Ai,Ai.SUBGROUP_BROADCAST).setParameterLength(2),l8=ci(Ai,Ai.SUBGROUP_SHUFFLE).setParameterLength(2),c8=ci(Ai,Ai.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),u8=ci(Ai,Ai.SUBGROUP_SHUFFLE_UP).setParameterLength(2),h8=ci(Ai,Ai.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),d8=ci(Ai,Ai.QUAD_BROADCAST).setParameterLength(1);let gb;function yb(r){gb=gb||new WeakMap;let e=gb.get(r);return e===void 0&&gb.set(r,e={}),e}function vb(r){const e=yb(r);return e.shadowMatrix||(e.shadowMatrix=cr("mat4").setGroup(or).onRenderUpdate(t=>((r.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&r.shadow.updateMatrices(r),r.shadow.matrix)))}function SP(r,e=Yc){const t=vb(r).mul(e);return t.xyz.div(t.w)}function zS(r){const e=yb(r);return e.position||(e.position=cr(new ot).setGroup(or).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(r.matrixWorld)))}function TP(r){const e=yb(r);return e.targetPosition||(e.targetPosition=cr(new ot).setGroup(or).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(r.target.matrixWorld)))}function VS(r){const e=yb(r);return e.viewPosition||(e.viewPosition=cr(new ot).setGroup(or).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new ot,n.value.setFromMatrixPosition(r.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)}))}const GS=r=>qc.transformDirection(zS(r).sub(TP(r))),f8=r=>r.sort((e,t)=>e.id-t.id),p8=(r,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===r)return t;return null},WS=new WeakMap,Iv=[];class HS extends Wi{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=th("vec3","totalDiffuse"),this.totalSpecularNode=th("vec3","totalSpecular"),this.outgoingLightNode=th("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(Iv.push(s.id),Iv.push(s.castShadow?1:0),s.isSpotLight===!0){const o=s.map!==null?s.map.id:-1,a=s.colorNode?s.colorNode.getCacheKey():-1;Iv.push(o,a)}}const t=$y(Iv);return Iv.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=f8(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=p8(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;WS.has(a)?d=WS.get(a):(d=Cn(new u(a)),WS.set(a,d)),t.push(d)}}this._lightNodes=t}setupDirectLight(e,t,n){const{lightingModel:s,reflectedLight:o}=e.context;s.direct(ac(qs({},n),{lightNode:t,reflectedLight:o}),e)}setupDirectRectAreaLight(e,t,n){const{lightingModel:s,reflectedLight:o}=e.context;s.directRectArea(ac(qs({},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=qt(m.mix(z,p)):z=qt(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 m8=(r=[])=>Cn(new HS).setLights(r);class g8 extends Wi{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=rs.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){$S.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||Yc)}}const $S=th("vec3","shadowPositionWorld");function jS(r,e={}){return e.toneMapping=r.toneMapping,e.toneMappingExposure=r.toneMappingExposure,e.outputColorSpace=r.outputColorSpace,e.renderTarget=r.getRenderTarget(),e.activeCubeFace=r.getActiveCubeFace(),e.activeMipmapLevel=r.getActiveMipmapLevel(),e.renderObjectFunction=r.getRenderObjectFunction(),e.pixelRatio=r.getPixelRatio(),e.mrt=r.getMRT(),e.clearColor=r.getClearColor(e.clearColor||new jn),e.clearAlpha=r.getClearAlpha(),e.autoClear=r.autoClear,e.scissorTest=r.getScissorTest(),e}function EP(r,e){return e=jS(r,e),r.setMRT(null),r.setRenderObjectFunction(null),r.setClearColor(0,1),r.autoClear=!0,e}function AP(r,e){r.toneMapping=e.toneMapping,r.toneMappingExposure=e.toneMappingExposure,r.outputColorSpace=e.outputColorSpace,r.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),r.setRenderObjectFunction(e.renderObjectFunction),r.setPixelRatio(e.pixelRatio),r.setMRT(e.mrt),r.setClearColor(e.clearColor,e.clearAlpha),r.autoClear=e.autoClear,r.setScissorTest(e.scissorTest)}function XS(r,e={}){return e.background=r.background,e.backgroundNode=r.backgroundNode,e.overrideMaterial=r.overrideMaterial,e}function CP(r,e){return e=XS(r,e),r.background=null,r.backgroundNode=null,r.overrideMaterial=null,e}function RP(r,e){r.background=e.background,r.backgroundNode=e.backgroundNode,r.overrideMaterial=e.overrideMaterial}function y8(r,e,t={}){return t=jS(r,t),t=XS(e,t),t}function NP(r,e,t){return t=EP(r,t),t=CP(e,t),t}function PP(r,e,t){AP(r,t),RP(e,t)}var RY=Object.freeze({__proto__:null,resetRendererAndSceneState:NP,resetRendererState:EP,resetSceneState:CP,restoreRendererAndSceneState:PP,restoreRendererState:AP,restoreSceneState:RP,saveRendererAndSceneState:y8,saveRendererState:jS,saveSceneState:XS});const IP=new WeakMap,LP=Kt(({depthTexture:r,shadowCoord:e,depthLayer:t})=>{let n=Ps(r,e.xy).setName("t_basic");return r.isArrayTexture&&(n=n.depth(t)),n.compare(e.z)}),DP=Kt(({depthTexture:r,shadowCoord:e,shadow:t,depthLayer:n})=>{const s=(z,I)=>{let ee=Ps(r,z);return r.isArrayTexture&&(ee=ee.depth(n)),ee.compare(I)},o=No("mapSize","vec2",t).setGroup(or),a=No("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 Wa(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)}),OP=Kt(({depthTexture:r,shadowCoord:e,shadow:t,depthLayer:n})=>{const s=(m,y)=>{let M=Ps(r,m);return r.isArrayTexture&&(M=M.depth(n)),M.compare(y)},o=No("mapSize","vec2",t).setGroup(or),a=Bn(1).div(o),c=a.x,u=a.y,d=e.xy,p=Pd(d.mul(o).add(.5));return d.subAssign(p.mul(a)),Wa(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),Hs(s(d.add(Bn(c.negate(),0)),e.z),s(d.add(Bn(c.mul(2),0)),e.z),p.x),Hs(s(d.add(Bn(c.negate(),u)),e.z),s(d.add(Bn(c.mul(2),u)),e.z),p.x),Hs(s(d.add(Bn(0,u.negate())),e.z),s(d.add(Bn(0,u.mul(2))),e.z),p.y),Hs(s(d.add(Bn(c,u.negate())),e.z),s(d.add(Bn(c,u.mul(2))),e.z),p.y),Hs(Hs(s(d.add(Bn(c.negate(),u.negate())),e.z),s(d.add(Bn(c.mul(2),u.negate())),e.z),p.x),Hs(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)}),FP=Kt(({depthTexture:r,shadowCoord:e,depthLayer:t})=>{const n=ut(1).toVar();let s=Ps(r).sample(e.xy);r.isArrayTexture&&(s=s.depth(t)),s=s.rg;const o=D_(e.z,s.x);return sr(o.notEqual(ut(1)),()=>{const a=e.z.sub(s.x),c=ga(0,s.y.mul(s.y));let u=c.div(c.add(a.mul(a)));u=Mu(Ds(u,.3).div(.95-.3)),n.assign(Mu(ga(o,u)))}),n}),v8=Kt(([r,e,t])=>{let n=Yc.sub(r).length();return n=n.sub(e).div(t.sub(e)),n=n.saturate(),n}),x8=r=>{const e=r.shadow.camera,t=No("near","float",e).setGroup(or),n=No("far","float",e).setGroup(or),s=NR(r);return v8(s,t,n)},BP=r=>{let e=IP.get(r);if(e===void 0){const t=r.isPointLight?x8(r):null;e=new ya,e.colorNode=Bi(0,0,0,1),e.depthNode=t,e.isShadowPassMaterial=!0,e.name="ShadowMaterial",e.fog=!1,IP.set(r,e)}return e},UP=new nh,r0=[],kP=(r,e,t,n)=>{r0[0]=r,r0[1]=e;let s=UP.get(r0);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&&(Vw(o).useVelocity=!0),o.onBeforeShadow(r,o,c,e.camera,u,a.overrideMaterial,p),r.renderObject(o,a,c,u,d,p,...m),o.onAfterShadow(r,o,c,e.camera,u,a.overrideMaterial,p))},s.shadowType=t,s.useVelocity=n,UP.set(r0,s)),r0[0]=null,r0[1]=null,s},_8=Kt(({samples:r,radius:e,size:t,shadowPass:n,depthLayer:s})=>{const o=ut(0).toVar("meanVertical"),a=ut(0).toVar("squareMeanVertical"),c=r.lessThanEqual(ut(1)).select(ut(0),ut(2).div(r.sub(1))),u=r.lessThanEqual(ut(1)).select(ut(0),ut(-1));po({start:Dt(0),end:Dt(r),type:"int",condition:"<"},({i:p})=>{const m=u.add(ut(p).mul(c));let y=n.sample(Wa(mv.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(r),a.divAssign(r);const d=Lh(a.sub(o.mul(o)));return Bn(o,d)}),b8=Kt(({samples:r,radius:e,size:t,shadowPass:n,depthLayer:s})=>{const o=ut(0).toVar("meanHorizontal"),a=ut(0).toVar("squareMeanHorizontal"),c=r.lessThanEqual(ut(1)).select(ut(0),ut(2).div(r.sub(1))),u=r.lessThanEqual(ut(1)).select(ut(0),ut(-1));po({start:Dt(0),end:Dt(r),type:"int",condition:"<"},({i:p})=>{const m=u.add(ut(p).mul(c));let y=n.sample(Wa(mv.xy,Bn(m,0).mul(e)).div(t));n.value.isArrayTexture&&(y=y.depth(s)),o.addAssign(y.x),a.addAssign(Wa(y.y.mul(y.y),y.x.mul(y.x)))}),o.divAssign(r),a.divAssign(r);const d=Lh(a.sub(o.mul(o)));return Bn(o,d)}),w8=[LP,DP,OP,FP];let qS;const xb=new Cv;class zP extends g8{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,ut(1))}setupShadowCoord(e,t){const{shadow:n}=this,{renderer:s}=e,o=No("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===ja&&(c=c.mul(2).sub(1));else{const u=a.w;a=a.xy.div(u);const d=No("near","float",n.camera).setGroup(or),p=No("far","float",n.camera).setGroup(or);c=nS(u.negate(),d,p)}return a=qt(a.x,a.y.oneMinus(),c.add(o)),a}getShadowFilterFn(e){return w8[e]}setupRenderTarget(e,t){const n=new gc(e.mapSize.width,e.mapSize.height);n.name="ShadowDepthTexture",n.compareFunction=qd;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:De,type:Vs,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:De,type:Vs,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:De,type:Vs,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:De,type:Vs,depthBuffer:!1}));let I=Ps(a);a.isArrayTexture&&(I=I.depth(this.depthLayer));let ee=Ps(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(ee=ee.depth(this.depthLayer));const Q=No("blurSamples","float",s).setGroup(or),oe=No("radius","float",s).setGroup(or),_e=No("mapSize","vec2",s).setGroup(or);let ve=this.vsmMaterialVertical||(this.vsmMaterialVertical=new ya);ve.fragmentNode=_8({samples:Q,radius:oe,size:_e,shadowPass:I,depthLayer:this.depthLayer}).context(e.getSharedContext()),ve.name="VSMVertical",ve=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new ya),ve.fragmentNode=b8({samples:Q,radius:oe,size:_e,shadowPass:ee,depthLayer:this.depthLayer}).context(e.getSharedContext()),ve.name="VSMHorizontal"}const u=No("intensity","float",s).setGroup(or),d=No("normalBias","float",s).setGroup(or),p=vb(n).mul($S.add(Vf.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=Ps(c.texture,m);a.isArrayTexture&&(G=G.depth(this.depthLayer));const z=Hs(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;qS=NP(o,a,qS),a.overrideMaterial=BP(n),o.setRenderObjectFunction(kP(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,PP(o,a,qS)}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),xb.material=this.vsmMaterialVertical,xb.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),xb.material=this.vsmMaterialHorizontal,xb.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 VP=(r,e)=>Cn(new zP(r,e)),M8=new jn,ih=Kt(([r,e])=>{const t=r.toVar(),n=Oo(t),s=jc(1,ga(n.x,ga(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(Ds(4,t.x))})}).ElseIf(n.x.greaterThanEqual(c),()=>{const u=lv(t.x);o.x.assign(t.z.mul(u).add(u.mul(2)))}).ElseIf(n.y.greaterThanEqual(c),()=>{const u=lv(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"}]}),GP=Kt(({depthTexture:r,bd3D:e,dp:t,texelSize:n})=>Ps(r,ih(e,n.y)).compare(t)),WP=Kt(({depthTexture:r,bd3D:e,dp:t,texelSize:n,shadow:s})=>{const o=No("radius","float",s).setGroup(or),a=Bn(-1,1).mul(o).mul(n.y);return Ps(r,ih(e.add(a.xyy),n.y)).compare(t).add(Ps(r,ih(e.add(a.yyy),n.y)).compare(t)).add(Ps(r,ih(e.add(a.xyx),n.y)).compare(t)).add(Ps(r,ih(e.add(a.yyx),n.y)).compare(t)).add(Ps(r,ih(e,n.y)).compare(t)).add(Ps(r,ih(e.add(a.xxy),n.y)).compare(t)).add(Ps(r,ih(e.add(a.yxy),n.y)).compare(t)).add(Ps(r,ih(e.add(a.xxx),n.y)).compare(t)).add(Ps(r,ih(e.add(a.yxx),n.y)).compare(t)).mul(1/9)}),S8=Kt(({filterFn:r,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=No("bias","float",n).setGroup(or),d=cr(n.mapSize).setGroup(or),p=ut(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(r({depthTexture:e,bd3D:y,dp:m,texelSize:M,shadow:n}))}),p}),HP=new mr,s0=new yn,Lv=new yn;class T8 extends zP{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===E?GP:WP}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:n,depthTexture:s,shadowCoord:o,shadow:a}){return S8({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();Lv.copy(t.mapSize),Lv.multiply(c),n.setSize(Lv.width,Lv.height),s0.copy(t.mapSize);const u=o.autoClear,d=o.getClearColor(M8),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=s0.x*M.x,G=Lv.y-s0.y-s0.y*M.y;HP.set(T,G,s0.x*M.z,s0.y*M.w),n.viewport.copy(HP),t.updateMatrices(s,y),o.render(a,t.camera)}o.autoClear=u,o.setClearColor(d,p)}}const $P=(r,e)=>Cn(new T8(r,e));class xm extends Xg{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=rs.FRAME}getHash(){return this.light.uuid}getLightVector(e){return VS(this.light).sub(e.context.positionView||Ia)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return VP(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 YS=Kt(({lightDistance:r,cutoffDistance:e,decayExponent:t})=>{const n=r.pow(t).max(.01).reciprocal();return e.greaterThan(0).select(n.mul(r.div(e).pow4().oneMinus().clamp().pow2()),n)}),jP=({color:r,lightVector:e,cutoffDistance:t,decayExponent:n})=>{const s=e.normalize(),o=e.length(),a=YS({lightDistance:o,cutoffDistance:t,decayExponent:n}),c=r.mul(a);return{lightDirection:s,lightColor:c}};class E8 extends xm{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 $P(this.light)}setupDirect(e){return jP({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const A8=Kt(([r=vo()])=>{const e=r.mul(2),t=e.x.floor(),n=e.y.floor();return t.add(n).mod(2).sign()}),C8=Kt(([r=vo()],{renderer:e,material:t})=>{const n=gM(r.mul(2).sub(1));let s;if(t.alphaToCoverage&&e.samples>1){const o=ut(n.fwidth()).toVar();s=Su(o.oneMinus(),o.add(1),n).oneMinus()}else s=wl(n.greaterThan(1),0,1);return s}),Dv=Kt(([r,e,t])=>{const n=ut(t).toVar(),s=ut(e).toVar(),o=bu(r).toVar();return wl(o,s,n)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),_b=Kt(([r,e])=>{const t=bu(e).toVar(),n=ut(r).toVar();return wl(t,n.negate(),n)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),Ha=Kt(([r])=>{const e=ut(r).toVar();return Dt(Dh(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),Ko=Kt(([r,e])=>{const t=ut(r).toVar();return e.assign(Ha(t)),t.sub(ut(e))}),XP=Il([Kt(([r,e,t,n,s,o])=>{const a=ut(o).toVar(),c=ut(s).toVar(),u=ut(n).toVar(),d=ut(t).toVar(),p=ut(e).toVar(),m=ut(r).toVar(),y=ut(Ds(1,c)).toVar();return Ds(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(([r,e,t,n,s,o])=>{const a=ut(o).toVar(),c=ut(s).toVar(),u=qt(n).toVar(),d=qt(t).toVar(),p=qt(e).toVar(),m=qt(r).toVar(),y=ut(Ds(1,c)).toVar();return Ds(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"}]})]),qP=Il([Kt(([r,e,t,n,s,o,a,c,u,d,p])=>{const m=ut(p).toVar(),y=ut(d).toVar(),M=ut(u).toVar(),T=ut(c).toVar(),G=ut(a).toVar(),z=ut(o).toVar(),I=ut(s).toVar(),ee=ut(n).toVar(),Q=ut(t).toVar(),oe=ut(e).toVar(),_e=ut(r).toVar(),ve=ut(Ds(1,M)).toVar(),Oe=ut(Ds(1,y)).toVar();return ut(Ds(1,m)).toVar().mul(Oe.mul(_e.mul(ve).add(oe.mul(M))).add(y.mul(Q.mul(ve).add(ee.mul(M))))).add(m.mul(Oe.mul(I.mul(ve).add(z.mul(M))).add(y.mul(G.mul(ve).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(([r,e,t,n,s,o,a,c,u,d,p])=>{const m=ut(p).toVar(),y=ut(d).toVar(),M=ut(u).toVar(),T=qt(c).toVar(),G=qt(a).toVar(),z=qt(o).toVar(),I=qt(s).toVar(),ee=qt(n).toVar(),Q=qt(t).toVar(),oe=qt(e).toVar(),_e=qt(r).toVar(),ve=ut(Ds(1,M)).toVar(),Oe=ut(Ds(1,y)).toVar();return ut(Ds(1,m)).toVar().mul(Oe.mul(_e.mul(ve).add(oe.mul(M))).add(y.mul(Q.mul(ve).add(ee.mul(M))))).add(m.mul(Oe.mul(I.mul(ve).add(z.mul(M))).add(y.mul(G.mul(ve).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"}]})]),Ml=Il([Kt(([r,e,t])=>{const n=ut(t).toVar(),s=ut(e).toVar(),o=Li(r).toVar(),a=Li(o.bitAnd(Li(7))).toVar(),c=ut(Dv(a.lessThan(Li(4)),s,n)).toVar(),u=ut(Kr(2,Dv(a.lessThan(Li(4)),n,s))).toVar();return _b(c,bu(a.bitAnd(Li(1)))).add(_b(u,bu(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(([r,e,t,n])=>{const s=ut(n).toVar(),o=ut(t).toVar(),a=ut(e).toVar(),c=Li(r).toVar(),u=Li(c.bitAnd(Li(15))).toVar(),d=ut(Dv(u.lessThan(Li(8)),a,o)).toVar(),p=ut(Dv(u.lessThan(Li(4)),o,Dv(u.equal(Li(12)).or(u.equal(Li(14))),a,s))).toVar();return _b(d,bu(u.bitAnd(Li(1)))).add(_b(p,bu(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"}]})]),Nu=Il([Kt(([r,e,t])=>{const n=ut(t).toVar(),s=ut(e).toVar(),o=Ug(r).toVar();return qt(Ml(o.x,s,n),Ml(o.y,s,n),Ml(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(([r,e,t,n])=>{const s=ut(n).toVar(),o=ut(t).toVar(),a=ut(e).toVar(),c=Ug(r).toVar();return qt(Ml(c.x,a,o,s),Ml(c.y,a,o,s),Ml(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"}]})]),R8=Kt(([r])=>{const e=ut(r).toVar();return Kr(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),N8=Kt(([r])=>{const e=ut(r).toVar();return Kr(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),YP=Il([R8,Kt(([r])=>{const e=qt(r).toVar();return Kr(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),ZP=Il([N8,Kt(([r])=>{const e=qt(r).toVar();return Kr(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),Kc=Kt(([r,e])=>{const t=Dt(e).toVar(),n=Li(r).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"}]}),KP=Kt(([r,e,t])=>{r.subAssign(t),r.bitXorAssign(Kc(t,Dt(4))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(Kc(r,Dt(6))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(Kc(e,Dt(8))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(Kc(t,Dt(16))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(Kc(r,Dt(19))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(Kc(e,Dt(4))),e.addAssign(r)}),Ov=Kt(([r,e,t])=>{const n=Li(t).toVar(),s=Li(e).toVar(),o=Li(r).toVar();return n.bitXorAssign(s),n.subAssign(Kc(s,Dt(14))),o.bitXorAssign(n),o.subAssign(Kc(n,Dt(11))),s.bitXorAssign(o),s.subAssign(Kc(o,Dt(25))),n.bitXorAssign(s),n.subAssign(Kc(s,Dt(16))),o.bitXorAssign(n),o.subAssign(Kc(n,Dt(4))),s.bitXorAssign(o),s.subAssign(Kc(o,Dt(14))),n.bitXorAssign(s),n.subAssign(Kc(s,Dt(24))),n}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),jl=Kt(([r])=>{const e=Li(r).toVar();return ut(e).div(ut(Li(Dt(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),Vh=Kt(([r])=>{const e=ut(r).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"}]}),xo=Il([Kt(([r])=>{const e=Dt(r).toVar(),t=Li(Li(1)).toVar(),n=Li(Li(Dt(3735928559)).add(t.shiftLeft(Li(2))).add(Li(13))).toVar();return Ov(n.add(Li(e)),n,n)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),Kt(([r,e])=>{const t=Dt(e).toVar(),n=Dt(r).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)),Ov(o,a,c)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),Kt(([r,e,t])=>{const n=Dt(t).toVar(),s=Dt(e).toVar(),o=Dt(r).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)),Ov(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(([r,e,t,n])=>{const s=Dt(n).toVar(),o=Dt(t).toVar(),a=Dt(e).toVar(),c=Dt(r).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)),KP(d,p,m),d.addAssign(Li(s)),Ov(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(([r,e,t,n,s])=>{const o=Dt(s).toVar(),a=Dt(n).toVar(),c=Dt(t).toVar(),u=Dt(e).toVar(),d=Dt(r).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)),KP(m,y,M),m.addAssign(Li(a)),y.addAssign(Li(o)),Ov(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"}]})]),Pu=Il([Kt(([r,e])=>{const t=Dt(e).toVar(),n=Dt(r).toVar(),s=Li(xo(n,t)).toVar(),o=Ug().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(([r,e,t])=>{const n=Dt(t).toVar(),s=Dt(e).toVar(),o=Dt(r).toVar(),a=Li(xo(o,s,n)).toVar(),c=Ug().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"}]})]),ZS=Il([Kt(([r])=>{const e=Bn(r).toVar(),t=Dt().toVar(),n=Dt().toVar(),s=ut(Ko(e.x,t)).toVar(),o=ut(Ko(e.y,n)).toVar(),a=ut(Vh(s)).toVar(),c=ut(Vh(o)).toVar(),u=ut(XP(Ml(xo(t,n),s,o),Ml(xo(t.add(Dt(1)),n),s.sub(1),o),Ml(xo(t,n.add(Dt(1))),s,o.sub(1)),Ml(xo(t.add(Dt(1)),n.add(Dt(1))),s.sub(1),o.sub(1)),a,c)).toVar();return YP(u)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),Kt(([r])=>{const e=qt(r).toVar(),t=Dt().toVar(),n=Dt().toVar(),s=Dt().toVar(),o=ut(Ko(e.x,t)).toVar(),a=ut(Ko(e.y,n)).toVar(),c=ut(Ko(e.z,s)).toVar(),u=ut(Vh(o)).toVar(),d=ut(Vh(a)).toVar(),p=ut(Vh(c)).toVar(),m=ut(qP(Ml(xo(t,n,s),o,a,c),Ml(xo(t.add(Dt(1)),n,s),o.sub(1),a,c),Ml(xo(t,n.add(Dt(1)),s),o,a.sub(1),c),Ml(xo(t.add(Dt(1)),n.add(Dt(1)),s),o.sub(1),a.sub(1),c),Ml(xo(t,n,s.add(Dt(1))),o,a,c.sub(1)),Ml(xo(t.add(Dt(1)),n,s.add(Dt(1))),o.sub(1),a,c.sub(1)),Ml(xo(t,n.add(Dt(1)),s.add(Dt(1))),o,a.sub(1),c.sub(1)),Ml(xo(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 ZP(m)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),Fv=Il([Kt(([r])=>{const e=Bn(r).toVar(),t=Dt().toVar(),n=Dt().toVar(),s=ut(Ko(e.x,t)).toVar(),o=ut(Ko(e.y,n)).toVar(),a=ut(Vh(s)).toVar(),c=ut(Vh(o)).toVar(),u=qt(XP(Nu(Pu(t,n),s,o),Nu(Pu(t.add(Dt(1)),n),s.sub(1),o),Nu(Pu(t,n.add(Dt(1))),s,o.sub(1)),Nu(Pu(t.add(Dt(1)),n.add(Dt(1))),s.sub(1),o.sub(1)),a,c)).toVar();return YP(u)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),Kt(([r])=>{const e=qt(r).toVar(),t=Dt().toVar(),n=Dt().toVar(),s=Dt().toVar(),o=ut(Ko(e.x,t)).toVar(),a=ut(Ko(e.y,n)).toVar(),c=ut(Ko(e.z,s)).toVar(),u=ut(Vh(o)).toVar(),d=ut(Vh(a)).toVar(),p=ut(Vh(c)).toVar(),m=qt(qP(Nu(Pu(t,n,s),o,a,c),Nu(Pu(t.add(Dt(1)),n,s),o.sub(1),a,c),Nu(Pu(t,n.add(Dt(1)),s),o,a.sub(1),c),Nu(Pu(t.add(Dt(1)),n.add(Dt(1)),s),o.sub(1),a.sub(1),c),Nu(Pu(t,n,s.add(Dt(1))),o,a,c.sub(1)),Nu(Pu(t.add(Dt(1)),n,s.add(Dt(1))),o.sub(1),a,c.sub(1)),Nu(Pu(t,n.add(Dt(1)),s.add(Dt(1))),o,a.sub(1),c.sub(1)),Nu(Pu(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 ZP(m)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),P8=Il([Kt(([r])=>{const e=ut(r).toVar(),t=Dt(Ha(e)).toVar();return jl(xo(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),Kt(([r])=>{const e=Bn(r).toVar(),t=Dt(Ha(e.x)).toVar(),n=Dt(Ha(e.y)).toVar();return jl(xo(t,n))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),Kt(([r])=>{const e=qt(r).toVar(),t=Dt(Ha(e.x)).toVar(),n=Dt(Ha(e.y)).toVar(),s=Dt(Ha(e.z)).toVar();return jl(xo(t,n,s))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),Kt(([r])=>{const e=Bi(r).toVar(),t=Dt(Ha(e.x)).toVar(),n=Dt(Ha(e.y)).toVar(),s=Dt(Ha(e.z)).toVar(),o=Dt(Ha(e.w)).toVar();return jl(xo(t,n,s,o))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),bb=Il([Kt(([r])=>{const e=ut(r).toVar(),t=Dt(Ha(e)).toVar();return qt(jl(xo(t,Dt(0))),jl(xo(t,Dt(1))),jl(xo(t,Dt(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),Kt(([r])=>{const e=Bn(r).toVar(),t=Dt(Ha(e.x)).toVar(),n=Dt(Ha(e.y)).toVar();return qt(jl(xo(t,n,Dt(0))),jl(xo(t,n,Dt(1))),jl(xo(t,n,Dt(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),Kt(([r])=>{const e=qt(r).toVar(),t=Dt(Ha(e.x)).toVar(),n=Dt(Ha(e.y)).toVar(),s=Dt(Ha(e.z)).toVar();return qt(jl(xo(t,n,s,Dt(0))),jl(xo(t,n,s,Dt(1))),jl(xo(t,n,s,Dt(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Kt(([r])=>{const e=Bi(r).toVar(),t=Dt(Ha(e.x)).toVar(),n=Dt(Ha(e.y)).toVar(),s=Dt(Ha(e.z)).toVar(),o=Dt(Ha(e.w)).toVar();return qt(jl(xo(t,n,s,o,Dt(0))),jl(xo(t,n,s,o,Dt(1))),jl(xo(t,n,s,o,Dt(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),wb=Kt(([r,e,t,n])=>{const s=ut(n).toVar(),o=ut(t).toVar(),a=Dt(e).toVar(),c=qt(r).toVar(),u=ut(0).toVar(),d=ut(1).toVar();return po(a,()=>{u.addAssign(d.mul(ZS(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"}]}),Mb=Kt(([r,e,t,n])=>{const s=ut(n).toVar(),o=ut(t).toVar(),a=Dt(e).toVar(),c=qt(r).toVar(),u=qt(0).toVar(),d=ut(1).toVar();return po(a,()=>{u.addAssign(d.mul(Fv(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"}]}),I8=Kt(([r,e,t,n])=>{const s=ut(n).toVar(),o=ut(t).toVar(),a=Dt(e).toVar(),c=qt(r).toVar();return Bn(wb(c,a,o,s),wb(c.add(qt(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"}]}),L8=Kt(([r,e,t,n])=>{const s=ut(n).toVar(),o=ut(t).toVar(),a=Dt(e).toVar(),c=qt(r).toVar(),u=qt(Mb(c,a,o,s)).toVar(),d=ut(wb(c.add(qt(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"}]}),o0=Il([Kt(([r,e,t,n,s,o,a])=>{const c=Dt(a).toVar(),u=ut(o).toVar(),d=Dt(s).toVar(),p=Dt(n).toVar(),m=Dt(t).toVar(),y=Dt(e).toVar(),M=Bn(r).toVar(),T=qt(bb(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(ut(y),ut(m)).add(G)).toVar(),I=Bn(z.sub(M)).toVar();return sr(c.equal(Dt(2)),()=>Oo(I.x).add(Oo(I.y))),sr(c.equal(Dt(3)),()=>ga(Oo(I.x),Oo(I.y))),Uf(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(([r,e,t,n,s,o,a,c,u])=>{const d=Dt(u).toVar(),p=ut(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=qt(r).toVar(),ee=qt(bb(qt(z.add(M),G.add(y),T.add(m)))).toVar();ee.subAssign(.5),ee.mulAssign(p),ee.addAssign(.5);const Q=qt(qt(ut(z),ut(G),ut(T)).add(ee)).toVar(),oe=qt(Q.sub(I)).toVar();return sr(d.equal(Dt(2)),()=>Oo(oe.x).add(Oo(oe.y)).add(Oo(oe.z))),sr(d.equal(Dt(3)),()=>ga(Oo(oe.x),Oo(oe.y),Oo(oe.z))),Uf(oe,oe)}).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"}]})]),D8=Kt(([r,e,t])=>{const n=Dt(t).toVar(),s=ut(e).toVar(),o=Bn(r).toVar(),a=Dt().toVar(),c=Dt().toVar(),u=Bn(Ko(o.x,a),Ko(o.y,c)).toVar(),d=ut(1e6).toVar();return po({start:-1,end:Dt(1),name:"x",condition:"<="},({x:p})=>{po({start:-1,end:Dt(1),name:"y",condition:"<="},({y:m})=>{const y=ut(o0(u,p,m,a,c,s,n)).toVar();d.assign(Sc(d,y))})}),sr(n.equal(Dt(0)),()=>{d.assign(Lh(d))}),d}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),O8=Kt(([r,e,t])=>{const n=Dt(t).toVar(),s=ut(e).toVar(),o=Bn(r).toVar(),a=Dt().toVar(),c=Dt().toVar(),u=Bn(Ko(o.x,a),Ko(o.y,c)).toVar(),d=Bn(1e6,1e6).toVar();return po({start:-1,end:Dt(1),name:"x",condition:"<="},({x:p})=>{po({start:-1,end:Dt(1),name:"y",condition:"<="},({y:m})=>{const y=ut(o0(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(Lh(d))}),d}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),F8=Kt(([r,e,t])=>{const n=Dt(t).toVar(),s=ut(e).toVar(),o=Bn(r).toVar(),a=Dt().toVar(),c=Dt().toVar(),u=Bn(Ko(o.x,a),Ko(o.y,c)).toVar(),d=qt(1e6,1e6,1e6).toVar();return po({start:-1,end:Dt(1),name:"x",condition:"<="},({x:p})=>{po({start:-1,end:Dt(1),name:"y",condition:"<="},({y:m})=>{const y=ut(o0(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(Lh(d))}),d}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),B8=Il([D8,Kt(([r,e,t])=>{const n=Dt(t).toVar(),s=ut(e).toVar(),o=qt(r).toVar(),a=Dt().toVar(),c=Dt().toVar(),u=Dt().toVar(),d=qt(Ko(o.x,a),Ko(o.y,c),Ko(o.z,u)).toVar(),p=ut(1e6).toVar();return po({start:-1,end:Dt(1),name:"x",condition:"<="},({x:m})=>{po({start:-1,end:Dt(1),name:"y",condition:"<="},({y})=>{po({start:-1,end:Dt(1),name:"z",condition:"<="},({z:M})=>{const T=ut(o0(d,m,y,M,a,c,u,s,n)).toVar();p.assign(Sc(p,T))})})}),sr(n.equal(Dt(0)),()=>{p.assign(Lh(p))}),p}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),U8=Il([O8,Kt(([r,e,t])=>{const n=Dt(t).toVar(),s=ut(e).toVar(),o=qt(r).toVar(),a=Dt().toVar(),c=Dt().toVar(),u=Dt().toVar(),d=qt(Ko(o.x,a),Ko(o.y,c),Ko(o.z,u)).toVar(),p=Bn(1e6,1e6).toVar();return po({start:-1,end:Dt(1),name:"x",condition:"<="},({x:m})=>{po({start:-1,end:Dt(1),name:"y",condition:"<="},({y})=>{po({start:-1,end:Dt(1),name:"z",condition:"<="},({z:M})=>{const T=ut(o0(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(Lh(p))}),p}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),KS=Il([F8,Kt(([r,e,t])=>{const n=Dt(t).toVar(),s=ut(e).toVar(),o=qt(r).toVar(),a=Dt().toVar(),c=Dt().toVar(),u=Dt().toVar(),d=qt(Ko(o.x,a),Ko(o.y,c),Ko(o.z,u)).toVar(),p=qt(1e6,1e6,1e6).toVar();return po({start:-1,end:Dt(1),name:"x",condition:"<="},({x:m})=>{po({start:-1,end:Dt(1),name:"y",condition:"<="},({y})=>{po({start:-1,end:Dt(1),name:"z",condition:"<="},({z:M})=>{const T=ut(o0(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(Lh(p))}),p}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),k8=Kt(([r,e,t,n,s,o,a,c,u,d,p])=>{const m=Dt(r).toVar(),y=Bn(e).toVar(),M=Bn(t).toVar(),T=Bn(n).toVar(),G=ut(s).toVar(),z=ut(o).toVar(),I=ut(a).toVar(),ee=bu(c).toVar(),Q=Dt(u).toVar(),oe=ut(d).toVar(),_e=ut(p).toVar(),ve=y.mul(M).add(T),Oe=ut(0).toVar();return sr(m.equal(Dt(0)),()=>{Oe.assign(Fv(ve))}),sr(m.equal(Dt(1)),()=>{Oe.assign(bb(ve))}),sr(m.equal(Dt(2)),()=>{Oe.assign(KS(ve,G,Dt(0)))}),sr(m.equal(Dt(3)),()=>{Oe.assign(Mb(qt(ve,0),Q,oe,_e))}),Oe.assign(Oe.mul(I.sub(z)).add(z)),sr(ee,()=>{Oe.assign(Mu(Oe,z,I))}),Oe}).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"}]}),z8=Kt(([r,e,t,n,s,o,a,c,u,d,p])=>{const m=Dt(r).toVar(),y=qt(e).toVar(),M=qt(t).toVar(),T=qt(n).toVar(),G=ut(s).toVar(),z=ut(o).toVar(),I=ut(a).toVar(),ee=bu(c).toVar(),Q=Dt(u).toVar(),oe=ut(d).toVar(),_e=ut(p).toVar(),ve=y.mul(M).add(T),Oe=ut(0).toVar();return sr(m.equal(Dt(0)),()=>{Oe.assign(Fv(ve))}),sr(m.equal(Dt(1)),()=>{Oe.assign(bb(ve))}),sr(m.equal(Dt(2)),()=>{Oe.assign(KS(ve,G,Dt(0)))}),sr(m.equal(Dt(3)),()=>{Oe.assign(Mb(ve,Q,oe,_e))}),Oe.assign(Oe.mul(I.sub(z)).add(z)),sr(ee,()=>{Oe.assign(Mu(Oe,z,I))}),Oe}).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"}]}),V8=Kt(([r])=>{const e=r.y,t=r.z,n=qt().toVar();return sr(e.lessThan(1e-4),()=>{n.assign(qt(t,t,t))}).Else(()=>{let s=r.x;s=s.sub(Dh(s)).mul(6).toVar();const o=Dt(pM(s)),a=s.sub(ut(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(qt(t,d,c))}).ElseIf(o.equal(Dt(1)),()=>{n.assign(qt(u,t,c))}).ElseIf(o.equal(Dt(2)),()=>{n.assign(qt(c,t,d))}).ElseIf(o.equal(Dt(3)),()=>{n.assign(qt(c,u,t))}).ElseIf(o.equal(Dt(4)),()=>{n.assign(qt(d,c,t))}).Else(()=>{n.assign(qt(t,c,u))})}),n}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),G8=Kt(([r])=>{const e=qt(r).toVar(),t=ut(e.x).toVar(),n=ut(e.y).toVar(),s=ut(e.z).toVar(),o=ut(Sc(t,Sc(n,s))).toVar(),a=ut(ga(t,ga(n,s))).toVar(),c=ut(a.sub(o)).toVar(),u=ut().toVar(),d=ut().toVar(),p=ut().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(Wa(2,s.sub(t).div(c)))}).Else(()=>{u.assign(Wa(4,t.sub(n).div(c)))}),u.mulAssign(1/6),sr(u.lessThan(0),()=>{u.addAssign(1)})}),qt(u,d,p)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),W8=Kt(([r])=>{const e=qt(r).toVar(),t=Jw(lM(e,qt(.04045))).toVar(),n=qt(e.div(12.92)).toVar(),s=qt(wu(ga(e.add(qt(.055)),qt(0)).div(1.055),qt(2.4))).toVar();return Hs(n,s,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),JP=(r,e)=>{r=ut(r),e=ut(e);const t=Bn(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return Su(r.sub(t),r.add(t),e)},QP=(r,e,t,n)=>Hs(r,e,t[n].clamp()),H8=(r,e,t=vo())=>QP(r,e,t,"x"),$8=(r,e,t=vo())=>QP(r,e,t,"y"),j8=(r,e,t,n,s=vo())=>{const o=s.x.clamp(),a=s.y.clamp(),c=Hs(r,e,o),u=Hs(t,n,o);return Hs(c,u,a)},eI=(r,e,t,n,s)=>Hs(r,e,JP(t,n[s])),X8=(r,e,t,n=vo())=>eI(r,e,t,n,"x"),q8=(r,e,t,n=vo())=>eI(r,e,t,n,"y"),Y8=(r=1,e=0,t=vo())=>t.mul(r).add(e),Z8=(r,e=1)=>(r=ut(r),r.abs().pow(e).mul(r.sign())),K8=(r,e=1,t=.5)=>ut(r).sub(t).mul(e).add(t),J8=(r=vo(),e=1,t=0)=>ZS(r.convert("vec2|vec3")).mul(e).add(t),Q8=(r=vo(),e=1,t=0)=>Fv(r.convert("vec2|vec3")).mul(e).add(t),eW=(r=vo(),e=1,t=0)=>(r=r.convert("vec2|vec3"),Bi(Fv(r),ZS(r.add(Bn(19,73)))).mul(e).add(t)),tW=(r,e=vo(),t=Bn(1,1),n=Bn(0,0),s=1,o=0,a=1,c=!1,u=1,d=2,p=.5)=>k8(r,e.convert("vec2|vec3"),t,n,s,o,a,c,u,d,p),nW=(r,e=vo(),t=Bn(1,1),n=Bn(0,0),s=1,o=0,a=1,c=!1,u=1,d=2,p=.5)=>z8(r,e.convert("vec2|vec3"),t,n,s,o,a,c,u,d,p),iW=(r=vo(),e=1)=>B8(r.convert("vec2|vec3"),e,Dt(1)),rW=(r=vo(),e=1)=>U8(r.convert("vec2|vec3"),e,Dt(1)),sW=(r=vo(),e=1)=>KS(r.convert("vec2|vec3"),e,Dt(1)),oW=(r=vo())=>P8(r.convert("vec2|vec3")),aW=(r=vo(),e=3,t=2,n=.5,s=1)=>wb(r,Dt(e),t,n).mul(s),lW=(r=vo(),e=3,t=2,n=.5,s=1)=>I8(r,Dt(e),t,n).mul(s),cW=(r=vo(),e=3,t=2,n=.5,s=1)=>Mb(r,Dt(e),t,n).mul(s),uW=(r=vo(),e=3,t=2,n=.5,s=1)=>L8(r,Dt(e),t,n).mul(s),hW=(r,e=ut(0))=>Wa(r,e),dW=(r,e=ut(0))=>Ds(r,e),fW=(r,e=ut(1))=>Kr(r,e),pW=(r,e=ut(1))=>jc(r,e),mW=(r,e=ut(1))=>av(r,e),gW=(r,e=ut(1))=>wu(r,e),yW=(r=ut(0),e=ut(1))=>L_(r,e),vW=()=>e0,xW=()=>tP,_W=(r,e=ut(1))=>Ds(e,r),bW=(r,e,t,n)=>r.greaterThan(e).mix(t,n),wW=(r,e,t,n)=>r.greaterThanEqual(e).mix(t,n),MW=(r,e,t,n)=>r.equal(e).mix(t,n),SW=(r,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 r.element(t[n])}if(typeof e=="number")return r.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 r.element(t[e])}return r},TW=(r,e=Bn(.5,.5),t=Bn(1,1),n=ut(0),s=Bn(0,0))=>{let o=r;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},EW=(r,e)=>{r=Bn(r),e=ut(e);const t=e.mul(Math.PI/180);return _v(r,t)},AW=(r,e,t)=>{r=qt(r),e=ut(e),t=qt(t);const n=e.mul(Math.PI/180),s=t.normalize(),o=n.cos(),a=n.sin(),c=ut(1).sub(o);return r.mul(o).add(s.cross(r).mul(a)).add(s.mul(s.dot(r)).mul(c))},CW=(r,e)=>(r=qt(r),e=ut(e),WM(r,e)),RW=Kt(([r,e,t])=>{const n=Nd(r).toVar(),s=Ds(ut(.5).mul(e.sub(t)),Yc).div(n).toVar(),o=Ds(ut(-.5).mul(e.sub(t)),Yc).div(n).toVar(),a=qt().toVar();a.x=n.x.greaterThan(ut(0)).select(s.x,o.x),a.y=n.y.greaterThan(ut(0)).select(s.y,o.y),a.z=n.z.greaterThan(ut(0)).select(s.z,o.z);const c=Sc(a.x,a.y,a.z).toVar();return Yc.add(n.mul(c)).toVar().sub(t)}),tI=Kt(([r,e])=>{const t=r.x,n=r.y,s=r.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(Kr(t,t).sub(Kr(n,n)))),o});var uZ=Object.freeze({__proto__:null,BRDF_GGX:aS,BRDF_Lambert:dm,BasicPointShadowFilter:GP,BasicShadowFilter:LP,Break:U2,Const:lR,Continue:x4,DFGApprox:lS,D_GGX:aN,Discard:SR,EPSILON:NC,F_Schlick:Kg,Fn:Kt,INFINITY:Yk,If:sr,Loop:po,NodeAccess:Nl,NodeShaderStage:Yy,NodeType:vk,NodeUpdateType:rs,OnMaterialUpdate:RG,OnObjectUpdate:CG,PCFShadowFilter:DP,PCFSoftShadowFilter:OP,PI:N_,PI2:Zk,PointShadowFilter:WP,Return:dz,Schlick_to_F0:cN,ScriptableNodeResources:mb,ShaderNode:Bg,Stack:b_,Switch:zk,TBNViewMatrix:um,VSMShadowFilter:FP,V_GGX_SmithCorrelated:oN,Var:aR,VarIntent:cR,abs:Oo,acesFilmicToneMapping:yP,acos:hM,add:Wa,addMethodChaining:An,addNodeElement:mz,agxToneMapping:vP,all:PC,alphaT:E_,and:mC,anisotropy:Bf,anisotropyB:om,anisotropyT:nv,any:IC,append:Hk,array:lC,arrayBuffer:Gk,asin:FC,assign:cC,atan:L_,atan2:iR,atomicAdd:O6,atomicAnd:k6,atomicFunc:zh,atomicLoad:L6,atomicMax:B6,atomicMin:U6,atomicOr:z6,atomicStore:D6,atomicSub:F6,atomicXor:V6,attenuationColor:rM,attenuationDistance:iM,attribute:rc,attributeArray:IG,backgroundBlurriness:sP,backgroundIntensity:OS,backgroundRotation:oP,batch:D2,bentNormalView:n2,billboarding:hG,bitAnd:xC,bitNot:_C,bitOr:bC,bitXor:wC,bitangentGeometry:Qz,bitangentLocal:e4,bitangentView:e2,bitangentWorld:t4,bitcast:$5,blendBurn:j2,blendColor:F4,blendDodge:X2,blendOverlay:Y2,blendScreen:q2,blur:RN,bool:bu,buffer:dv,bufferAttribute:uv,builtin:Dd,bumpMap:WM,burn:U4,bvec2:KA,bvec3:Jw,bvec4:tC,bypass:_R,cache:hv,call:uC,cameraFar:Bd,cameraIndex:zf,cameraNear:Fd,cameraNormalMatrix:Rz,cameraPosition:gv,cameraProjectionMatrix:Tu,cameraProjectionMatrixInverse:Az,cameraViewMatrix:qc,cameraViewport:Nz,cameraWorldMatrix:Cz,cbrt:JC,cdl:qG,ceil:I_,checker:A8,cineonToneMapping:gP,clamp:Mu,clearcoat:M_,clearcoatNormalView:cm,clearcoatRoughness:tv,code:fb,color:YA,colorSpaceToWorking:B_,colorToDirection:q4,compute:xR,computeKernel:TM,computeSkinning:y4,context:cv,convert:iC,convertColorSpace:iz,convertToTexture:MG,cos:Id,cross:O_,cubeTexture:$g,cubeTextureBase:UM,cubeToUV:ih,dFdx:dM,dFdy:fM,dashSize:am,debug:TR,decrement:CC,decrementBefore:EC,defaultBuildStages:Hw,defaultShaderStages:kA,defined:Ky,degrees:DC,deltaTime:rG,densityFog:g6,densityFogFactor:US,depth:iS,depthPass:QG,determinant:WC,difference:qC,diffuseColor:to,directPointLight:jP,directionToColor:J2,directionToFaceDirection:Wg,dispersion:sM,distance:XC,div:jc,dodge:k4,dot:Uf,drawIndex:P2,dynamicBufferAttribute:vR,element:nC,emissive:Qw,equal:aM,equals:$C,equirectUV:rS,exp:cM,exp2:zg,expression:Ld,faceDirection:DM,faceForward:xM,faceforward:Kk,float:ut,floatBitsToInt:j5,floatBitsToUint:X5,floor:Dh,fog:Nv,fract:Pd,frameGroup:oC,frameId:tP,frontFacing:DR,fwidth:VC,gain:K5,gapSize:rv,getConstNodeType:qA,getCurrentStack:__,getDirection:AN,getDistanceAttenuation:YS,getGeometryRoughness:sN,getNormalFromDepth:TG,getParallaxCorrectNormal:RW,getRoughness:oS,getScreenPosition:SG,getShIrradianceAt:tI,getShadowMaterial:BP,getShadowRenderObjectFunction:kP,getTextureIndex:QN,getViewPosition:i0,globalId:w6,glsl:l6,glslFn:c6,grayscale:HG,greaterThan:lM,greaterThanEqual:pC,hash:Z5,highpModelNormalViewMatrix:IM,highpModelViewMatrix:PM,hue:XG,increment:AC,incrementBefore:TC,instance:u4,instanceIndex:Gf,instancedArray:LG,instancedBufferAttribute:U_,instancedDynamicBufferAttribute:SM,instancedMesh:L2,int:Dt,intBitsToFloat:q5,inverse:HC,inverseSqrt:uM,inversesqrt:Jk,invocationLocalIndex:c4,invocationSubgroupIndex:l4,ior:sv,iridescence:T_,iridescenceIOR:eM,iridescenceThickness:tM,ivec2:pl,ivec3:JA,ivec4:QA,js:o6,label:oR,length:Oh,lengthSq:gM,lessThan:dC,lessThanEqual:fC,lightPosition:zS,lightProjectionUV:SP,lightShadowMatrix:vb,lightTargetDirection:GS,lightTargetPosition:TP,lightViewPosition:VS,lightingContext:V2,lights:m8,linearDepth:Zg,linearToneMapping:pP,localId:M6,log:P_,log2:Ih,logarithmicDepthToViewZ:C4,luminance:FS,mat2:w_,mat3:Wl,mat4:rm,matcapUV:VN,materialAO:R2,materialAlphaTest:r2,materialAnisotropy:v2,materialAnisotropyVector:jg,materialAttenuationColor:E2,materialAttenuationDistance:T2,materialClearcoat:d2,materialClearcoatNormal:p2,materialClearcoatRoughness:f2,materialColor:X_,materialDispersion:C2,materialEmissive:o2,materialEnvIntensity:G_,materialEnvRotation:BM,materialIOR:S2,materialIridescence:x2,materialIridescenceIOR:_2,materialIridescenceThickness:b2,materialLightMap:YM,materialLineDashOffset:qM,materialLineDashSize:jM,materialLineGapSize:XM,materialLineScale:$M,materialLineWidth:Z_,materialMetalness:u2,materialNormal:h2,materialOpacity:q_,materialPointSize:A2,materialReference:kd,materialReflectivity:Y_,materialRefractionRatio:kR,materialRotation:m2,materialRoughness:c2,materialSheen:g2,materialSheenRoughness:y2,materialShininess:s2,materialSpecular:a2,materialSpecularColor:l2,materialSpecularIntensity:HM,materialSpecularStrength:vv,materialThickness:M2,materialTransmission:w2,max:ga,maxMipLevel:AM,mediumpModelViewMatrix:LR,metalness:ev,min:Sc,mix:Hs,mixElement:eR,mod:av,modInt:RC,modelDirection:Fz,modelNormalMatrix:IR,modelPosition:Bz,modelRadius:PR,modelScale:Uz,modelViewMatrix:Ud,modelViewPosition:kz,modelViewProjection:ZM,modelWorldMatrix:Au,modelWorldMatrixInverse:zz,morphReference:z2,mrt:eP,mul:Kr,mx_aastep:JP,mx_add:hW,mx_atan2:yW,mx_cell_noise_float:oW,mx_contrast:K8,mx_divide:pW,mx_fractal_noise_float:aW,mx_fractal_noise_vec2:lW,mx_fractal_noise_vec3:cW,mx_fractal_noise_vec4:uW,mx_frame:xW,mx_heighttonormal:CW,mx_hsvtorgb:V8,mx_ifequal:MW,mx_ifgreater:bW,mx_ifgreatereq:wW,mx_invert:_W,mx_modulo:mW,mx_multiply:fW,mx_noise_float:J8,mx_noise_vec3:Q8,mx_noise_vec4:eW,mx_place2d:TW,mx_power:gW,mx_ramp4:j8,mx_ramplr:H8,mx_ramptb:$8,mx_rgbtohsv:G8,mx_rotate2d:EW,mx_rotate3d:AW,mx_safepower:Z8,mx_separate:SW,mx_splitlr:X8,mx_splittb:q8,mx_srgb_texture_to_lin_rec709:W8,mx_subtract:dW,mx_timer:vW,mx_transform_uv:Y8,mx_unifiednoise2d:tW,mx_unifiednoise3d:nW,mx_worley_noise_float:iW,mx_worley_noise_vec2:rW,mx_worley_noise_vec3:sW,negate:BC,neutralToneMapping:xP,nodeArray:im,nodeImmutable:xi,nodeObject:Cn,nodeObjectIntent:Jy,nodeObjects:x_,nodeProxy:zr,nodeProxyIntent:ci,normalFlat:OR,normalGeometry:V_,normalLocal:Tc,normalMap:GM,normalView:fo,normalViewGeometry:Hg,normalWorld:Vf,normalWorldGeometry:FR,normalize:Nd,not:yC,notEqual:hC,numWorkgroups:_6,objectDirection:Pz,objectGroup:oM,objectPosition:NR,objectRadius:Oz,objectScale:Lz,objectViewPosition:Dz,objectWorldMatrix:Iz,oneMinus:UC,or:gC,orthographicDepthToViewZ:A4,oscSawtooth:lG,oscSine:sG,oscSquare:oG,oscTriangle:aG,output:kg,outputStruct:W5,overlay:V4,overloadingFn:Il,parabola:NS,parallaxDirection:t2,parallaxUV:n4,parameter:B5,pass:KG,passTexture:JG,pcurve:J5,perspectiveDepthToViewZ:tS,pmremTexture:AS,pointShadow:$P,pointUV:OG,pointWidth:$k,positionGeometry:Pl,positionLocal:Pa,positionPrevious:z_,positionView:Ia,positionViewDirection:Vo,positionWorld:Yc,positionWorldDirection:LM,posterize:ZG,pow:wu,pow2:mM,pow3:YC,pow4:ZC,premultiplyAlpha:Z2,property:th,quadBroadcast:d8,quadSwapDiagonal:o8,quadSwapX:r8,quadSwapY:s8,radians:LC,rand:QC,range:v6,rangeFog:m6,rangeFogFactor:BS,reciprocal:zC,reference:No,referenceBuffer:kM,reflect:jC,reflectVector:GR,reflectView:zR,reflector:vG,refract:vM,refractVector:WR,refractView:VR,reinhardToneMapping:mP,remap:wR,remapClamp:MR,renderGroup:or,renderOutput:EM,rendererReference:mR,rotate:_v,rotateUV:cG,roughness:Ph,round:kC,rtt:iP,sRGBTransferEOTF:hR,sRGBTransferOETF:dR,sample:AG,sampler:_z,samplerComparison:bz,saturate:yM,saturation:$G,screen:z4,screenCoordinate:mv,screenDPR:AR,screenSize:lm,screenUV:Od,scriptable:p6,scriptableValue:pb,select:wl,setCurrentStack:Qy,setName:_M,shaderStages:$w,shadow:VP,shadowPositionWorld:$S,shapeCircle:C8,sharedUniformGroup:R_,sheen:sm,sheenRoughness:S_,shiftLeft:MC,shiftRight:SC,shininess:A_,sign:lv,sin:Xc,sinc:Q5,skinning:B2,smoothstep:Su,smoothstepElement:tR,specularColor:Mc,specularF90:iv,spherizeUV:uG,split:Wk,spritesheetUV:pG,sqrt:Lh,stack:ob,step:D_,stepElement:nR,storage:hm,storageBarrier:A6,storageObject:g4,storageTexture:aP,string:Vk,struct:G5,sub:Ds,subBuild:Vg,subgroupAdd:H6,subgroupAll:t8,subgroupAnd:Z6,subgroupAny:n8,subgroupBallot:W6,subgroupBroadcast:a8,subgroupBroadcastFirst:i8,subgroupElect:G6,subgroupExclusiveAdd:j6,subgroupExclusiveMul:Y6,subgroupInclusiveAdd:$6,subgroupInclusiveMul:q6,subgroupIndex:a4,subgroupMax:e8,subgroupMin:Q6,subgroupMul:X6,subgroupOr:K6,subgroupShuffle:l8,subgroupShuffleDown:h8,subgroupShuffleUp:u8,subgroupShuffleXor:c8,subgroupSize:S6,subgroupXor:J6,tan:OC,tangentGeometry:H_,tangentLocal:yv,tangentView:$_,tangentWorld:QR,texture:Ps,texture3D:lP,textureBarrier:C6,textureBicubic:yV,textureBicubicLevel:hS,textureCubeUV:CN,textureLoad:Na,textureSize:kf,textureStore:BG,thickness:nM,time:e0,toneMapping:gR,toneMappingExposure:yR,toonOutlinePass:t6,transformDirection:KC,transformNormal:BR,transformNormalToView:OM,transformedClearcoatNormalView:Hz,transformedNormalView:Gz,transformedNormalWorld:Wz,transmission:C_,transpose:GC,triNoise3D:tG,triplanarTexture:mG,triplanarTextures:nP,trunc:pM,uint:Li,uintBitsToFloat:Y5,uniform:cr,uniformArray:Hl,uniformCubeTexture:jz,uniformFlow:sR,uniformGroup:sC,uniformTexture:xz,unpremultiplyAlpha:B4,userData:VG,uv:vo,uvec2:ZA,uvec3:Ug,uvec4:eC,varying:Fh,varyingProperty:$c,vec2:Bn,vec3:qt,vec4:Bi,vectorComponents:tm,velocity:WG,vertexColor:$2,vertexIndex:N2,vertexStage:uR,vibrance:jG,viewZToLogarithmicDepth:nS,viewZToOrthographicDepth:Yg,viewZToPerspectiveDepth:eS,viewport:Gg,viewportCoordinate:CR,viewportDepthTexture:QM,viewportLinearDepth:R4,viewportMipTexture:JM,viewportResolution:Ez,viewportSafeUV:dG,viewportSharedTexture:K2,viewportSize:NM,viewportTexture:T4,viewportUV:Tz,wgsl:a6,wgslFn:u6,workgroupArray:P6,workgroupBarrier:E6,workgroupId:b6,workingToColorSpace:fR,xor:vC});const rh=new RS;class NW extends Hf{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(rh),rh.a=s._clearColor.a;else if(o.isColor===!0)o.getRGB(rh),rh.a=1,a=!0;else if(o.isNode===!0){const u=this.get(e),d=o;rh.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=cv(Bi(d).mul(OS),{getUV:()=>oP.mul(FR),getTextureLevel:()=>sP});let M=ZM;M=M.setZ(M.w);const T=new ya;T.name="Background.material",T.side=K,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 Zs(new ju(1,32,32),T),p.frustumCulled=!1,p.name="Background.mesh",p.onBeforeRender=function(z,I,ee){this.matrixWorld.copyPosition(ee.matrixWorld)},o.addEventListener("dispose",G)}const m=d.getCacheKey();u.backgroundCacheKey!==m&&(u.backgroundMeshNode.node=Bi(d).mul(OS),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"?rh.set(0,0,0,1):c==="alpha-blend"&&rh.set(0,0,0,0),s.autoClear===!0||a===!0){const u=n.clearColorValue;u.r=rh.r,u.g=rh.g,u.b=rh.b,u.a=rh.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 PW=0;class JS{constructor(e="",t=[],n=0,s=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=s,this.id=PW++}}class IW{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 JS(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 nI{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}}class LW{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 iI{constructor(e,t,n=!1,s=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=n,this.count=s}}class DW extends iI{constructor(e,t,n=null,s=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=n,this.interpolationSampling=s}}class OW{constructor(e,t,n=""){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}}let FW=0;class QS{constructor(e=null){this.id=FW++,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 BW{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class Xf{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 UW extends Xf{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class kW extends Xf{constructor(e,t=new yn){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class zW extends Xf{constructor(e,t=new ot){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class VW extends Xf{constructor(e,t=new mr){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class GW extends Xf{constructor(e,t=new jn){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class WW extends Xf{constructor(e,t=new Wp){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class HW extends Xf{constructor(e,t=new $r){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class $W extends Xf{constructor(e,t=new Ft){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class jW extends UW{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class XW extends kW{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class qW extends zW{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class YW extends VW{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class ZW extends GW{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class KW extends WW{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class JW extends HW{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class QW extends $W{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const rI=new WeakMap,eH=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),Sb=r=>/e/g.test(r)?String(r).replace(/\+/g,""):(r=Number(r),r+(r%1?"":".0"));class sI{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=ob(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new QS,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=rI.get(this.renderer);return e===void 0&&(e=new nh,rI.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new Za(e,t,n)}createCubeRenderTarget(e,t){return new Q2(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 JS(e,s,this.bindingsIndexes[e].group,s),n.set(s,a))):a=new JS(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 $w)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()!==rs.NONE&&this.updateNodes.push(e);for(const e of this.sequentialNodes){const t=e.getUpdateBeforeType(),n=e.getUpdateAfterType();t!==rs.NONE&&this.updateBeforeNodes.push(e),n!==rs.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 qs({},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 QS(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 ot:e==="vec4"&&(t=new mr)),e==="float")return Sb(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")}( ${Sb(t.r)}, ${Sb(t.g)}, ${Sb(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 nI(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===Is)return"int";if(t===as)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=kw(e);const s=t==="float"?"":t[0];return/mat2/.test(t)===!0&&(n=n.replace("vec","mat")),s+n}getTypeFromArray(e){return eH.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 Vm)&&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=ob(this.stack);const e=__();return this.stacks.push(e),Qy(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Qy(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 nI("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 BW(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 LW(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 iI(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 DW(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 OW("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 _P,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 KN(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 QS,this.stack=ob();for(const p of Hw)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=qs({},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 ya),s.build(this)}else this.addFlow("compute",e);for(const s of Hw){this.setBuildStage(s),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const o of $w){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 jW(e);if(t==="vec2"||t==="ivec2"||t==="uvec2")return new XW(e);if(t==="vec3"||t==="ivec3"||t==="uvec3")return new qW(e);if(t==="vec4"||t==="ivec4"||t==="uvec4")return new YW(e);if(t==="color")return new ZW(e);if(t==="mat2")return new KW(e);if(t==="mat3")return new JW(e);if(t==="mat4")return new QW(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 oI{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===rs.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===rs.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===rs.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===rs.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===rs.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===rs.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),n=e.updateReference(this);if(t===rs.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===rs.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===rs.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 eT{constructor(e,t,n=null,s="",o=!1){this.type=e,this.name=t,this.count=n,this.qualifier=s,this.isConst=o}}eT.isNodeFunctionInput=!0;class tH extends xm{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:GS(this.light),lightColor:e}}}const tT=new Ft,Tb=new Ft;let Bv=null;class nH extends xm{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=cr(new ot).setGroup(or),this.halfWidth=cr(new ot).setGroup(or),this.updateType=rs.RENDER}update(e){super.update(e);const{light:t}=this,n=e.camera.matrixWorldInverse;Tb.identity(),tT.copy(t.matrixWorld),tT.premultiply(n),Tb.extractRotation(tT),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(Tb),this.halfHeight.value.applyMatrix4(Tb)}setupDirectRectArea(e){let t,n;e.isAvailable("float32Filterable")?(t=Ps(Bv.LTC_FLOAT_1),n=Ps(Bv.LTC_FLOAT_2)):(t=Ps(Bv.LTC_HALF_1),n=Ps(Bv.LTC_HALF_2));const{colorNode:s,light:o}=this,a=VS(o);return{lightColor:s,lightPosition:a,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:n}}static setLTC(e){Bv=e}}class nT extends xm{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 Su(n,s,t)}getLightCoord(e){const t=e.getNodeProperties(this);let n=t.projectionUV;return n===void 0&&(n=SP(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(GS(o)),d=this.getSpotAttenuation(e,u),p=a.length(),m=YS({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=Ps(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 iH extends nT{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=Ps(n,Bn(o,0),0).r}else s=super.getSpotAttenuation(t);return s}}const rH=Kt(([r,e])=>{const t=r.abs().sub(e);return Oh(ga(t,0)).add(Sc(ga(t.x,t.y),0))});class sH extends nT{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=ut(0),n=this.penumbraCosNode,s=vb(this.light).mul(e.context.positionWorld||Yc);return sr(s.w.greaterThan(0),()=>{const o=s.xyz.div(s.w),a=rH(o.xy.sub(Bn(.5)),Bn(.5)),c=jc(-1,Ds(1,hM(n)).sub(1));t.assign(yM(a.mul(-2).mul(c)))}),t}}class oH extends xm{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class aH extends xm{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=Vf.dot(s).mul(.5).add(.5),c=Hs(n,t,a);e.context.irradiance.addAssign(c)}}class lH extends xm{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let n=0;n<9;n++)t.push(new ot);this.lightProbe=Hl(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=tI(Vf,this.lightProbe);e.context.irradiance.addAssign(t)}}class aI{parseFunction(){console.warn("Abstract function.")}}class iT{constructor(e,t,n="",s=""){this.type=e,this.inputs=t,this.name=n,this.precision=s}getCode(){console.warn("Abstract function.")}}iT.isNodeFunction=!0;const cH=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,uH=/[a-z_0-9]+/ig,lI="#pragma main",hH=r=>{r=r.trim();const e=r.indexOf(lI),t=e!==-1?r.slice(e+lI.length):r,n=t.match(cH);if(n!==null&&n.length===5){const s=n[4],o=[];let a=null;for(;(a=uH.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 ee=o[u++][0];c.push(new eT(z,ee,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?r.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 dH extends iT{constructor(e){const{type:t,inputs:n,name:s,precision:o,inputsCode:a,blockCode:c,headerCode:u}=hH(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 fH extends aI{parseFunction(e){return new dH(e)}}const cI=new WeakMap,Gh=[],_m=[];class pH extends Hf{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new oI,this.nodeBuilderCache=new Map,this.callHashCache=new nh,this.groupsData=new nh,this.cacheLib={}}updateGroup(e){const t=e.groupNode,n=t.name;if(n===oM.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===oC.name){const o=this.get(e),a=this.nodeFrame.frameId;return o.frameId!==a?(o.frameId=a,!0):!1}Gh[0]=t,Gh[1]=e;let s=this.groupsData.get(Gh);return s===void 0&&this.groupsData.set(Gh,s={}),Gh.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 IW(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){Gh[0]=e,Gh[1]=t;const n=this.renderer.info.calls,s=this.callHashCache.get(Gh)||{};if(s.callId!==n){const o=this.getEnvironmentNode(e),a=this.getFogNode(e);t&&_m.push(t.getCacheKey(!0)),o&&_m.push(o.getCacheKey()),a&&_m.push(a.getCacheKey()),_m.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),_m.push(this.renderer.shadowMap.enabled?1:0),s.callId=n,s.cacheKey=$y(_m),this.callHashCache.set(Gh,s),_m.length=0}return Gh.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===Pe||n.mapping===Ie||n.mapping===Ke){if(e.backgroundBlurriness>0||n.mapping===Ke)return AS(n);{let a;return n.isCubeTexture===!0?a=$g(n):a=Ps(n),nN(a)}}else{if(n.isTexture===!0)return Ps(n,Od.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=No("color","color",n).setGroup(or),a=No("density","float",n).setGroup(or);return Nv(o,US(a))}else if(n.isFog){const o=No("color","color",n).setGroup(or),a=No("near","float",n).setGroup(or),c=No("far","float",n).setGroup(or);return Nv(o,BS(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 $g(n);if(n.isTexture===!0)return Ps(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 cI.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,n=this.getOutputCacheKey(),s=e.isArrayTexture?lP(e,qt(Od,Dd("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):Ps(e,Od).renderOutput(t.toneMapping,t.currentColorSpace);return cI.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 oI,this.nodeBuilderCache=new Map,this.cacheLib={}}}const rT=new Al;class Eb{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new $r,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++){rT.copy(e[o]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);const a=t[n+o],c=rT.normal;a.x=-c.x,a.y=-c.y,a.z=-c.z,a.w=rT.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 Eb(this),this.clippingGroupContexts.set(e,t)),t.update(this,e),t}get unionClippingCount(){return this.unionPlanes.length}}class mH{constructor(e,t){this.bundleGroup=e,this.camera=t}}const Uv=[];class gH{constructor(){this.bundles=new nh}get(e,t){const n=this.bundles;Uv[0]=e,Uv[1]=t;let s=n.get(Uv);return s===void 0&&(s=new mH(e,t),n.set(Uv,s)),Uv.length=0,s}dispose(){this.bundles=new nh}}class uI{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 yH=new HS,kv=[];class vH extends nh{constructor(){super()}createNode(e=[]){return new HS().setLights(e)}getNode(e,t){if(e.isQuadMesh)return yH;kv[0]=e,kv[1]=t;let n=this.get(kv);return n===void 0&&(n=this.createNode(),this.set(kv,n)),kv.length=0,n}}class zv extends Za{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 hI=new ot,dI=new ot;class xH extends Ol{constructor(e,t=!1){super(),this.enabled=!1,this.isPresenting=!1,this.cameraAutoUpdate=!0,this._renderer=e,this._cameraL=new fa,this._cameraL.viewport=new mr,this._cameraR=new fa,this._cameraR.viewport=new mr,this._cameras=[this._cameraL,this._cameraR],this._cameraXR=new wy,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=TH.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSize=new yn,this._onSessionEvent=wH.bind(this),this._onSessionEnd=MH.bind(this),this._onInputSourcesChange=SH.bind(this),this._onAnimationFrame=EH.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 Mh(e,t),p=new zv(o,a,{format:D,type:Oi,depthTexture:new gc(o,a,u.stencil?Da:as,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 Wr({color:16777215,side:W});m.map=p.texture,m.map.offset.y=1,m.map.repeat.y=-1;const y=new Zs(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 Wr({color:16777215,side:W}),M.plane.material.blending=Ne,M.plane.material.blendEquation=Ae,M.plane.material.blendSrc=je,M.plane.material.blendDst=je,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 wp(e,e,e*t/n,64,64,!0,Math.PI-t/2,t),m=new zv(a,c,{format:D,type:Oi,depthTexture:new gc(a,c,d.stencil?Da:as,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 Wr({color:16777215,side:K});y.map=m.texture,y.map.offset.y=1,y.map.repeat.y=-1;const M=new Zs(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 Wr({color:16777215,side:K}),T.plane.material.blending=Ne,T.plane.material.blendEquation=Ae,T.plane.material.blendSrc=je,T.plane.material.blendDst=je,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 ot,t=new ea,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 Cv(new ya),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?Da:as);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 gc(p.textureWidth,p.textureHeight,c,void 0,void 0,void 0,void 0,void 0,void 0,a,y);if(this._xrRenderTarget=new zv(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 Wr({color:16777215,side:T.type==="cylinder"?K:W}),T.plane.material.blending=Ne,T.plane.material.blendEquation=Ae,T.plane.material.blendSrc=je,T.plane.material.blendDst=je,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 zv(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;fI(o,u);for(let p=0;p<d.length;p++)fI(d[p],u);d.length===2?_H(o,a,c):o.projectionMatrix.copy(a.projectionMatrix),bH(e,o,u)}_getController(e){let t=this._controllers[e];return t===void 0&&(t=new Gu,this._controllers[e]=t),t}}function _H(r,e,t){hI.setFromMatrixPosition(e.matrixWorld),dI.setFromMatrixPosition(t.matrixWorld);const n=hI.distanceTo(dI),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(r.position,r.quaternion,r.scale),r.translateX(G),r.translateZ(T),r.matrixWorld.compose(r.position,r.quaternion,r.scale),r.matrixWorldInverse.copy(r.matrixWorld).invert(),s[10]===-1)r.projectionMatrix.copy(e.projectionMatrix),r.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const z=a+T,I=c+T,ee=y-G,Q=M+(n-G),oe=u*c/I*z,_e=d*c/I*z;r.projectionMatrix.makePerspective(ee,Q,oe,_e,z,I),r.projectionMatrixInverse.copy(r.projectionMatrix).invert()}}function fI(r,e){e===null?r.matrixWorld.copy(r.matrix):r.matrixWorld.multiplyMatrices(e.matrixWorld,r.matrix),r.matrixWorldInverse.copy(r.matrixWorld).invert()}function bH(r,e,t){t===null?r.matrix.copy(e.matrixWorld):(r.matrix.copy(t.matrixWorld),r.matrix.invert(),r.matrix.multiply(e.matrixWorld)),r.matrix.decompose(r.position,r.quaternion,r.scale),r.updateMatrixWorld(!0),r.projectionMatrix.copy(e.projectionMatrix),r.projectionMatrixInverse.copy(e.projectionMatrixInverse),r.isPerspectiveCamera&&(r.fov=Fa*2*Math.atan(1/r.projectionMatrix.elements[5]),r.zoom=1)}function wH(r){const e=this._controllerInputSources.indexOf(r.inputSource);if(e===-1)return;const t=this._controllers[e];if(t!==void 0){const n=this.getReferenceSpace();t.update(r.inputSource,r.frame,n),t.dispatchEvent({type:r.type,data:r.inputSource})}}function MH(){const r=this._session,e=this._renderer;r.removeEventListener("select",this._onSessionEvent),r.removeEventListener("selectstart",this._onSessionEvent),r.removeEventListener("selectend",this._onSessionEvent),r.removeEventListener("squeeze",this._onSessionEvent),r.removeEventListener("squeezestart",this._onSessionEvent),r.removeEventListener("squeezeend",this._onSessionEvent),r.removeEventListener("end",this._onSessionEnd),r.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 zv(t.pixelwidth,t.pixelheight,{format:D,type:Oi,depthTexture:new gc(t.pixelwidth,t.pixelheight,t.stencilBuffer?Da:as,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 SH(r){const e=this._controllers,t=this._controllerInputSources;for(let n=0;n<r.removed.length;n++){const s=r.removed[n],o=t.indexOf(s);o>=0&&(t[o]=null,e[o].disconnect(s))}for(let n=0;n<r.added.length;n++){const s=r.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 TH(r){return r.type==="quad"?this._glBinding.createQuadLayer({transform:new XRRigidTransform(r.translation,r.quaternion),width:r.width/2,height:r.height/2,space:this._referenceSpace,viewPixelWidth:r.pixelwidth,viewPixelHeight:r.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(r.translation,r.quaternion),radius:r.radius,centralAngle:r.centralAngle,aspectRatio:r.aspectRatio,space:this._referenceSpace,viewPixelWidth:r.pixelwidth,viewPixelHeight:r.pixelheight,clearOnAccess:!1})}function EH(r,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 fa,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(r,e),e.detectedPlanes&&this.dispatchEvent({type:"planesdetected",data:e}),this._xrFrame=null}const pI=new $m,a0=new yn,sT=new mr,oT=new lf,aT=new pu,Ab=new Ft,Vd=new mr;class AH{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=Vs,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=co,this.toneMapping=yt,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=o,this.stencil=a,this.info=new b5,this.overrideNodes={modelViewMatrix:null,modelNormalViewMatrix:null},this.library=new uI,this.lighting=new vH,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 Cv(new ya),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 RS(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 xH(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),ee=M.overrideMaterial||G.material,Q=this._objects.get(G,ee,M,T,z.lightsNode,I,I.clippingContext),{fragmentShader:oe,vertexShader:_e}=Q.getNodeBuilderState();return{fragmentShader:oe,vertexShader:_e}})}}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 pH(this,n),this._animation=new d5(this._nodes,this.info),this._attributes=new x5(n),this._background=new NW(this,this._nodes),this._geometries=new _5(this._attributes,this.info),this._textures=new F5(this,n,this.info),this._pipelines=new T5(n,this._nodes),this._bindings=new E5(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new g5(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new R5(this.lighting),this._bundles=new gH,this._renderContexts=new D5,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 Eb),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(Q){Q.isLight&&Q.layers.test(t.layers)&&T.pushLight(Q)}),T.finish(),p!==null){this._textures.updateRenderTarget(p,y);const Q=this._textures.get(p);m.textures=Q.textures,m.depthTexture=Q.depthTexture}else m.textures=null,m.depthTexture=null;this._background.update(d,T,m);const G=T.opaque,z=T.transparent,I=T.transparentDoublePass,ee=T.lightsNode;this.opaque===!0&&G.length>0&&this._renderObjects(G,t,d,ee),this.transparent===!0&&z.length>0&&this._renderTransparents(z,I,t,d,ee),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=PM,this.overrideNodes.modelNormalViewMatrix=IM):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===PM&&this.overrideNodes.modelNormalViewMatrix===IM}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(a0),{depth:c,stencil:u}=this;let d=this._frameBufferTarget;d===null&&(d=new Za(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,ee=this._scissor,Q=this._pixelRatio;M!==null&&(I=M.viewport,ee=M.scissor,Q=1),this.getDrawingBufferSize(a0),sT.set(0,0,a0.width,a0.height);const oe=I.minDepth===void 0?0:I.minDepth,_e=I.maxDepth===void 0?1:I.maxDepth;T.viewportValue.copy(I).multiplyScalar(Q).floor(),T.viewportValue.width>>=y,T.viewportValue.height>>=y,T.viewportValue.minDepth=oe,T.viewportValue.maxDepth=_e,T.viewport=T.viewportValue.equals(sT)===!1,T.scissorValue.copy(ee).multiplyScalar(Q).floor(),T.scissor=this._scissorTest&&T.scissorValue.equals(sT)===!1,T.scissorValue.width>>=y,T.scissorValue.height>>=y,T.clippingContext||(T.clippingContext=new Eb),T.clippingContext.updateGlobal(d,t),d.onBeforeRender(this,e,t,M);const ve=t.isArrayCamera?aT:oT;t.isArrayCamera||(Ab.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),ve.setFromProjectionMatrix(Ab,t.coordinateSystem,t.reversedDepth));const Oe=this._renderLists.get(e,t);if(Oe.begin(),this._projectObject(e,t,0,Oe,T.clippingContext),Oe.finish(),this.sortObjects===!0&&Oe.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=a0.width,T.height=a0.height,T.depth=this.depth,T.stencil=this.stencil;T.width>>=y,T.height>>=y,T.activeCubeFace=m,T.activeMipmapLevel=y,T.occlusionQueryCount=Oe.occlusionQueryCount,T.scissorValue.max(Vd.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,Oe,T),T.camera=t,this.backend.beginRender(T);const{bundles:He,lightsNode:Ce,transparentDoublePass:Be,transparent:ft,opaque:zt}=Oe;return He.length>0&&this._renderBundles(He,d,Ce),this.opaque===!0&&zt.length>0&&this._renderObjects(zt,t,d,Ce),this.transparent===!0&&ft.length>0&&this._renderTransparents(ft,Be,t,d,Ce),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=Vd.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=Vd.copy(t).floor();else{console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=Vd.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?aT:oT;if(!e.frustumCulled||u.intersectsSprite(e,t)){this.sortObjects===!0&&Vd.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Ab);const{geometry:d,material:p}=e;p.visible&&s.push(e,d,p,n,Vd.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?aT:oT;if(!e.frustumCulled||u.intersectsObject(e,t)){const{geometry:d,material:p}=e;if(this.sortObjects===!0&&(d.boundingSphere===null&&d.computeBoundingSphere(),Vd.copy(d.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(Ab)),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,Vd.z,T,o)}}else p.visible&&s.push(e,d,p,n,Vd.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=K;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=re}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===re&&o.forceSinglePass===!1?(o.side=K,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=re):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 mI{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}function CH(r){return r+($f-r%$f)%$f}class gI extends mI{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return CH(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}}class yI extends gI{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let RH=0;class vI extends yI{constructor(e,t){super("UniformBuffer_"+RH++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class NH extends yI{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%$f,d=u%a,p=u+d;t+=d,p!==0&&$f-p<c&&(t+=$f-p),o.offset=t/e,t+=c}return Math.ceil(t/$f)*$f}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 IH(n,s,o)===!1&&(this.buffer.set(s,o),PH(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 PH(r,e,t){for(let n=0,s=e.length;n<s;n++)r[t+n]=e[n]}function IH(r,e,t){for(let n=0,s=e.length;n<s;n++)if(r[t+n]!==e[n])return!1;return!0}let LH=0;class xI extends NH{constructor(e,t){super(e),this.id=LH++,this.groupNode=t,this.isNodeUniformsGroup=!0}}class _I extends mI{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 DH=0;class OH extends _I{constructor(e,t){super(e,t),this.id=DH++,this.store=!1,this.isSampledTexture=!0}}class Cb extends OH{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 bI extends Cb{constructor(e,t,n,s=null){super(e,t,n,s),this.isSampledCubeTexture=!0}}class lT extends Cb{constructor(e,t,n,s=null){super(e,t,n,s),this.isSampledTexture3D=!0}}const wI={textureDimensions:"textureSize",equals:"equal",bitcast_float_int:"floatBitsToInt",bitcast_int_float:"intBitsToFloat",bitcast_uint_float:"uintBitsToFloat",bitcast_float_uint:"floatBitsToUint"},FH={low:"lowp",medium:"mediump",high:"highp"},MI={swizzleAssign:!0,storageBuffer:!1},SI={perspective:"smooth",linear:"noperspective"},TI={centroid:"centroid"},EI=`
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 BH extends sI{constructor(e,t){super(e,t,new fH),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==Qo}getMethod(e){return wI[e]||e}getBitcastMethod(e,t){return wI[`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?Ve:De:o===3?c=a?it:Le:o===4&&(c=a?st:D);const u={Float32Array:gs,Uint8Array:Oi,Uint16Array:ms,Uint32Array:as,Int8Array:Gi,Int16Array:ir,Int32Array:Is,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 Ql(t.array,d,p,c,u[t.array.constructor.name]||gs);M.needsUpdate=!0,M.isPBOTexture=!0;const T=new Bh(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="."+tm.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===as?I="uvec4":s.pbo.type===Is&&(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===as?m="u":p.type===Is&&(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=FH[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!==Is){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=SI[s.interpolationType]||s.interpolationType,c=TI[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=SI[s.interpolationType]||s.interpolationType,c=TI[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=MI[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)}MI[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
${EI}
// 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
${EI}
// 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 Cb(o.name,o.node,u),p.push(c);else if(t==="cubeTexture")c=new bI(o.name,o.node,u),p.push(c);else if(t==="texture3D")c=new lT(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 vI(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 xI(n+"_"+d,u),m[d]=y,p.push(y)),c=this.getNodeUniform(o,t),y.addUniform(c)}a.uniformGPU=c}return o}}let cT=null,l0=null;class AI{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){ol("WebGPURenderer: Timestamp tracking is disabled.");return}const t=this.timestampQueryPool[e];if(!t){ol(`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 cT=cT||new yn,this.renderer.getDrawingBufferSize(cT)}setScissorTest(){}getClearColor(){const e=this.renderer;return l0=l0||new RS,e.getClearColor(l0),l0.getRGB(l0),l0}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:Ya(),"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 UH=0;class kH{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 zH{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===Is,id:UH++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const y=this._createBuffer(s,t,o,a);m=new kH(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 uT,Vv;class VH{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;uT={[Ae]:e.FUNC_ADD,[be]:e.FUNC_SUBTRACT,[Ye]:e.FUNC_REVERSE_SUBTRACT},Vv={[je]:e.ZERO,[_t]:e.ONE,[It]:e.SRC_COLOR,[Ut]:e.SRC_ALPHA,[vt]:e.SRC_ALPHA_SATURATE,[ue]:e.DST_COLOR,[at]:e.DST_ALPHA,[kt]:e.ONE_MINUS_SRC_COLOR,[At]:e.ONE_MINUS_SRC_ALPHA,[Ue]: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!==A?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===S?t.cullFace(t.BACK):e===R?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===ye){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!==Ae||this.currentBlendEquationAlpha!==Ae)&&(d.blendEquation(d.FUNC_ADD),this.currentBlendEquation=Ae,this.currentBlendEquationAlpha=Ae),u)switch(e){case ge:d.blendFuncSeparate(d.ONE,d.ONE_MINUS_SRC_ALPHA,d.ONE,d.ONE_MINUS_SRC_ALPHA);break;case ce:d.blendFunc(d.ONE,d.ONE);break;case xe:d.blendFuncSeparate(d.ZERO,d.ONE_MINUS_SRC_COLOR,d.ZERO,d.ONE);break;case fe: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 ge:d.blendFuncSeparate(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA,d.ONE,d.ONE_MINUS_SRC_ALPHA);break;case ce:d.blendFuncSeparate(d.SRC_ALPHA,d.ONE,d.ONE,d.ONE);break;case xe:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case fe: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(uT[t],uT[o]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=o),(n!==this.currentBlendSrc||s!==this.currentBlendDst||a!==this.currentBlendSrcAlpha||c!==this.currentBlendDstAlpha)&&(d.blendFuncSeparate(Vv[n],Vv[s],Vv[a],Vv[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 ze:t.depthFunc(t.NEVER);break;case Ze:t.depthFunc(t.ALWAYS);break;case q:t.depthFunc(t.LESS);break;case Y:t.depthFunc(t.LEQUAL);break;case de:t.depthFunc(t.EQUAL);break;case Je:t.depthFunc(t.GEQUAL);break;case Te:t.depthFunc(t.GREATER);break;case $e: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===re?this.disable(s.CULL_FACE):this.enable(s.CULL_FACE);let o=e.side===K;t&&(o=!o),this.setFlipSided(o),e.blending===ge&&e.transparent===!1?this.setBlending(ye):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 GH{constructor(e){this.backend=e,this.gl=this.backend.gl,this.extensions=e.extensions}convert(e,t=Qo){const{gl:n,extensions:s}=this;let o;const a=Ki.getTransfer(t);if(e===Oi)return n.UNSIGNED_BYTE;if(e===Xl)return n.UNSIGNED_SHORT_4_4_4_4;if(e===ql)return n.UNSIGNED_SHORT_5_5_5_1;if(e===Dl)return n.UNSIGNED_INT_5_9_9_9_REV;if(e===nu)return n.UNSIGNED_INT_10F_11F_11F_REV;if(e===Gi)return n.BYTE;if(e===ir)return n.SHORT;if(e===ms)return n.UNSIGNED_SHORT;if(e===Is)return n.INT;if(e===as)return n.UNSIGNED_INT;if(e===gs)return n.FLOAT;if(e===Vs)return n.HALF_FLOAT;if(e===Du)return n.ALPHA;if(e===Le)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===De)return n.RG;if(e===Ve)return n.RG_INTEGER;if(e===st)return n.RGBA_INTEGER;if(e===Ht||e===Et||e===on||e===Un)if(a===Fi)if(o=s.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(e===Ht)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(e===Et)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===Ht)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===Et)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===Ir||e===yi||e===vi||e===Mr||e===Zt||e===Fn||e===hi||e===Xn||e===hs||e===Xr||e===ys||e===Ur||e===Os)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===Ir)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===hs)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===Xr)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===ys)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===Ur)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===Os)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(e===no)if(o=s.get("EXT_texture_compression_bptc"),o!==null){if(e===no)return a===Fi?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(e===To||e===Gr||e===Qs||e===Eo)if(o=s.get("EXT_texture_compression_rgtc"),o!==null){if(e===To)return o.COMPRESSED_RED_RGTC1_EXT;if(e===Gr)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(e===Qs)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(e===Eo)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return e===Da?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 CI=!1,Rb,hT,RI;class WH{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},CI===!1&&(this._init(),CI=!0)}_init(){const e=this.gl;Rb={[lt]:e.REPEAT,[qe]:e.CLAMP_TO_EDGE,[pt]:e.MIRRORED_REPEAT},hT={[Ct]:e.NEAREST,[Xt]:e.NEAREST_MIPMAP_NEAREST,[pn]:e.NEAREST_MIPMAP_LINEAR,[Rn]:e.LINEAR,[bi]:e.LINEAR_MIPMAP_NEAREST,[Qn]:e.LINEAR_MIPMAP_LINEAR},RI={[Lm]:e.NEVER,[Dm]:e.ALWAYS,[qd]:e.LESS,[ep]:e.LEQUAL,[Yd]:e.EQUAL,[w0]:e.GEQUAL,[_0]:e.GREATER,[b0]: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?ah: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?ah: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===Qo?null:Ki.getPrimaries(t.colorSpace),u=t.colorSpace===Qo||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,Rb[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,Rb[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||n.texParameteri(e,n.TEXTURE_WRAP_R,Rb[t.wrapR])),n.texParameteri(e,n.TEXTURE_MAG_FILTER,hT[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,hT[p]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,RI[t.compareFunction])),s.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===Ct||t.minFilter!==pn&&t.minFilter!==Qn||t.type===gs&&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=Nb(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=Nb(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=Oy(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=Nb(T);n.texSubImage2D(c,y,0,0,T.width,T.height,u,d,G)}else{const y=Nb(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,ee,Q,oe,_e,ve;const Oe=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,ee=n.min.y,Q=n.isBox3?n.min.z:0;else{const cn=Math.pow(2,-o);T=Math.floor(Oe.width*cn),G=Math.floor(Oe.height*cn),e.isDataArrayTexture||e.isArrayTexture?z=Oe.depth:e.isData3DTexture?z=Math.floor(Oe.depth*cn):z=1,I=0,ee=0,Q=0}s!==null?(oe=s.x,_e=s.y,ve=s.z):(oe=0,_e=0,ve=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 He=c.getParameter(c.UNPACK_ROW_LENGTH),Ce=c.getParameter(c.UNPACK_IMAGE_HEIGHT),Be=c.getParameter(c.UNPACK_SKIP_PIXELS),ft=c.getParameter(c.UNPACK_SKIP_ROWS),zt=c.getParameter(c.UNPACK_SKIP_IMAGES);c.pixelStorei(c.UNPACK_ROW_LENGTH,Oe.width),c.pixelStorei(c.UNPACK_IMAGE_HEIGHT,Oe.height),c.pixelStorei(c.UNPACK_SKIP_PIXELS,I),c.pixelStorei(c.UNPACK_SKIP_ROWS,ee),c.pixelStorei(c.UNPACK_SKIP_IMAGES,Q);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,ee,T,G,oe,_e,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,oe,_e,ve,T,G,z,M,y,Oe.data):t.isCompressedArrayTexture?c.compressedTexSubImage3D(m,a,oe,_e,ve,T,G,z,M,Oe.data):c.texSubImage3D(m,a,oe,_e,ve,T,G,z,M,y,Oe):e.isDataTexture?c.texSubImage2D(m,a,oe,_e,T,G,M,y,Oe.data):e.isCompressedTexture?c.compressedTexSubImage2D(m,a,oe,_e,Oe.width,Oe.height,M,Oe.data):c.texSubImage2D(m,a,oe,_e,T,G,M,y,Oe);c.pixelStorei(c.UNPACK_ROW_LENGTH,He),c.pixelStorei(c.UNPACK_IMAGE_HEIGHT,Ce),c.pixelStorei(c.UNPACK_SKIP_PIXELS,Be),c.pixelStorei(c.UNPACK_SKIP_ROWS,ft),c.pixelStorei(c.UNPACK_SKIP_IMAGES,zt),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()],ee=z.msaaFrameBuffer;o.bindFramebuffer(s.DRAW_FRAMEBUFFER,I),o.bindFramebuffer(s.READ_FRAMEBUFFER,ee);const Q=y-u-p;s.blitFramebuffer(c,Q,c+d,Q+p,c,Q,c+d,Q+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,Q,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,ee=u.createBuffer();u.bindBuffer(u.PIXEL_PACK_BUFFER,ee),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 Q=new T(I/T.BYTES_PER_ELEMENT);return u.bindBuffer(u.PIXEL_PACK_BUFFER,ee),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,Q),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),u.deleteFramebuffer(y),Q})}_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 Nb(r){return r.isDataTexture?r.image.data:typeof HTMLImageElement!="undefined"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&r instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&r instanceof ImageBitmap||typeof OffscreenCanvas!="undefined"&&r instanceof OffscreenCanvas?r:r.data}class HH{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 $H{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 NI={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 jH{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 PI{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 XH extends PI{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 ol(`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 II extends AI{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 HH(this),this.capabilities=new $H(this),this.attributeUtils=new zH(this),this.textureUtils=new WH(this),this.bufferRenderer=new jH(this),this.state=new VH(this),this.utils=new GH(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 so}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 XH(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(lh.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(lh.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(lh.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)&&(ol("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(lh.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 He=this._getVaoKey(M);G=this.vaoCache[He],G===void 0&&(G=this._createVao(M),this.vaoCache[He]=G,T.vaoGPU=G)}const z=e.getIndex(),I=z!==null?this.get(z).bufferGPU:null;d.setVertexState(G,I);const ee=p.lastOcclusionObject;if(ee!==t&&ee!==void 0){if(ee!==null&&ee.occlusionTest===!0&&(u.endQuery(u.ANY_SAMPLES_PASSED),p.occlusionQueryIndex++),t.occlusionTest===!0){const He=u.createQuery();u.beginQuery(u.ANY_SAMPLES_PASSED,He),p.occlusionQueries[p.occlusionQueryIndex]=He,p.occlusionQueryObjects[p.occlusionQueryIndex]=t}p.lastOcclusionObject=t}const Q=this.bufferRenderer;t.isPoints?Q.mode=u.POINTS:t.isLineSegments?Q.mode=u.LINES:t.isLine?Q.mode=u.LINE_STRIP:t.isLineLoop?Q.mode=u.LINE_LOOP:s.wireframe===!0?(d.setLineWidth(s.wireframeLinewidth*this.renderer.getPixelRatio()),Q.mode=u.LINES):Q.mode=u.TRIANGLES;const{vertexCount:oe,instanceCount:_e}=m;let{firstVertex:ve}=m;if(Q.object=t,z!==null){ve*=z.array.BYTES_PER_ELEMENT;const He=this.get(z);Q.index=z.count,Q.type=He.type}else Q.index=0;const Oe=()=>{t.isBatchedMesh?t._multiDrawInstances!==null?(ol("THREE.WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Q.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?Q.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):ol("THREE.WebGLRenderer: WEBGL_multi_draw not supported."):_e>1?Q.renderInstances(ve,oe,_e):Q.render(ve,oe)};if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){const He=this.get(e.camera),Ce=e.camera.cameras,Be=e.getBindingGroup("cameraIndex").bindings[0];if(He.indexesGPU===void 0||He.indexesGPU.length!==Ce.length){const mn=new Uint32Array([0,0,0,0]),Yn=[];for(let xn=0,si=Ce.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)}He.indexesGPU=Yn}const ft=this.get(Be),zt=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=Ce.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=Ce.length;mn<Yn;mn++){const xn=Ce[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*zt,Gn=si.y*zt,Si=si.width*zt,nr=si.height*zt;d.viewport(Math.floor(wn),Math.floor(e.context.height-nr-Gn),Math.floor(Si),Math.floor(nr))}d.bindBufferBase(u.UNIFORM_BUFFER,ft.index,He.indexesGPU[mn]),Oe()}this._currentContext.activeCubeFace=vn,this.renderer._activeCubeFace=vn}}else Oe()}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 BH(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 ee=this.get(I);G.push(ee)}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(NI).filter(s=>NI[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"),ee=this.extensions.get("OVR_multiview2"),Q=this._useMultisampledExtension(o),oe=ZN(e);let _e;if(p?(a.cubeFramebuffers||(a.cubeFramebuffers={}),_e=a.cubeFramebuffers[oe]):M&&T===!1?_e=this._xrFramebuffer:(a.framebuffers||(a.framebuffers={}),_e=a.framebuffers[oe]),_e===void 0){_e=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,_e);const ve=e.textures,Oe=[];if(p){a.cubeFramebuffers[oe]=_e;const{textureGPU:Ce}=this.get(ve[0]),Be=this.renderer._activeCubeFace,ft=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Be,Ce,ft)}else{a.framebuffers[oe]=_e;for(let Ce=0;Ce<ve.length;Ce++){const Be=ve[Ce],ft=this.get(Be);ft.renderTarget=e.renderTarget,ft.cacheKey=oe;const zt=t.COLOR_ATTACHMENT0+Ce;if(o.multiview)ee.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,zt,ft.textureGPU,0,c,0,2);else if(m||y){const tn=this.renderer._activeCubeFace,cn=this.renderer._activeMipmapLevel;t.framebufferTextureLayer(t.FRAMEBUFFER,zt,ft.textureGPU,cn,tn)}else if(Q)I.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,zt,t.TEXTURE_2D,ft.textureGPU,0,c);else{const tn=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,zt,t.TEXTURE_2D,ft.textureGPU,tn)}}}const He=d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(o._autoAllocateDepthBuffer===!0){const Ce=t.createRenderbuffer();this.textureUtils.setupRenderBufferStorage(Ce,e,0,Q),a.xrDepthRenderbuffer=Ce,Oe.push(d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT),t.bindRenderbuffer(t.RENDERBUFFER,Ce),t.framebufferRenderbuffer(t.FRAMEBUFFER,He,t.RENDERBUFFER,Ce)}else if(e.depthTexture!==null){Oe.push(d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT);const Ce=this.get(e.depthTexture);if(Ce.renderTarget=e.renderTarget,Ce.cacheKey=oe,o.multiview)ee.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,He,Ce.textureGPU,0,c,0,2);else if(T&&Q)I.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,He,t.TEXTURE_2D,Ce.textureGPU,0,c);else if(e.depthTexture.isArrayTexture){const Be=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,He,Ce.textureGPU,0,Be)}else t.framebufferTexture2D(t.FRAMEBUFFER,He,t.TEXTURE_2D,Ce.textureGPU,0)}a.depthInvalidationArray=Oe}else{if(this._isRenderCameraDepthArray(e)){n.bindFramebuffer(t.FRAMEBUFFER,_e);const Oe=this.renderer._activeCubeFace,He=this.get(e.depthTexture),Ce=d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.framebufferTextureLayer(t.FRAMEBUFFER,Ce,He.textureGPU,0,Oe)}if((M||Q||o.multiview)&&o._isOpaqueFramebuffer!==!0){n.bindFramebuffer(t.FRAMEBUFFER,_e);const Oe=this.get(e.textures[0]);o.multiview?ee.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,Oe.textureGPU,0,c,0,2):Q?I.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Oe.textureGPU,0,c):t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Oe.textureGPU,0);const He=d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(o._autoAllocateDepthBuffer===!0){const Ce=a.xrDepthRenderbuffer;t.bindRenderbuffer(t.RENDERBUFFER,Ce),t.framebufferRenderbuffer(t.FRAMEBUFFER,He,t.RENDERBUFFER,Ce)}else{const Ce=this.get(e.depthTexture);o.multiview?ee.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,He,Ce.textureGPU,0,c,0,2):Q?I.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,He,t.TEXTURE_2D,Ce.textureGPU,0,c):t.framebufferTexture2D(t.FRAMEBUFFER,He,t.TEXTURE_2D,Ce.textureGPU,0)}}}if(c>0&&Q===!1&&!o.multiview){if(G===void 0){const ve=[];G=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,G);const Oe=[],He=e.textures;for(let Ce=0;Ce<He.length;Ce++){Oe[Ce]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,Oe[Ce]),ve.push(t.COLOR_ATTACHMENT0+Ce);const Be=e.textures[Ce],ft=this.get(Be);t.renderbufferStorageMultisample(t.RENDERBUFFER,c,ft.glInternalFormat,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ce,t.RENDERBUFFER,Oe[Ce])}if(t.bindRenderbuffer(t.RENDERBUFFER,null),a.msaaFrameBuffer=G,a.msaaRenderbuffers=Oe,u&&z===void 0){z=t.createRenderbuffer(),this.textureUtils.setupRenderBufferStorage(z,e,c),a.depthRenderbuffer=z;const Ce=d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;ve.push(Ce)}a.invalidationArray=ve}s=a.msaaFrameBuffer}else s=_e;n.drawBuffers(e,_e)}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 c0={PointList:"point-list",LineList:"line-list",LineStrip:"line-strip",TriangleList:"triangle-list",TriangleStrip:"triangle-strip"},Ll={Never:"never",Less:"less",Equal:"equal",LessEqual:"less-equal",Greater:"greater",NotEqual:"not-equal",GreaterEqual:"greater-equal",Always:"always"},sc={Store:"store"},mo={Load:"load",Clear:"clear"},LI={CCW:"ccw",CW:"cw"},DI={None:"none",Back:"back"},u0={Uint16:"uint16",Uint32:"uint32"},jt={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"},dT={ClampToEdge:"clamp-to-edge",Repeat:"repeat",MirrorRepeat:"mirror-repeat"},bm={Linear:"linear",Nearest:"nearest"},ks={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"},wm={Add:"add",Subtract:"subtract",ReverseSubtract:"reverse-subtract",Min:"min",Max:"max"},OI={None:0,All:15},qf={Keep:"keep",Zero:"zero",Replace:"replace",Invert:"invert",IncrementClamp:"increment-clamp",DecrementClamp:"decrement-clamp",IncrementWrap:"increment-wrap",DecrementWrap:"decrement-wrap"},fT={Storage:"storage",ReadOnlyStorage:"read-only-storage"},pT={WriteOnly:"write-only",ReadOnly:"read-only",ReadWrite:"read-write"},FI={NonFiltering:"non-filtering",Comparison:"comparison"},Mm={Float:"float",UnfilterableFloat:"unfilterable-float",Depth:"depth",SInt:"sint",UInt:"uint"},BI={TwoD:"2d",ThreeD:"3d"},nl={TwoD:"2d",TwoDArray:"2d-array",Cube:"cube",ThreeD:"3d"},qH={All:"all"},Pb={Vertex:"vertex",Instance:"instance"},mT={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 YH extends _I{constructor(e,t,n){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n}update(){this.texture=this.textureNode.value}}class ZH extends gI{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}let KH=0;class JH extends ZH{constructor(e,t){super("StorageBuffer_"+KH++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:Nl.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class QH extends Hf{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:bm.Linear}),this.flipYSampler=e.createSampler({minFilter:bm.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:c0.TriangleStrip,stripIndexFormat:u0.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:c0.TriangleStrip,stripIndexFormat:u0.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:nl.TwoD,baseArrayLayer:n}),m=d.createView({baseMipLevel:0,mipLevelCount:1,dimension:nl.TwoD,baseArrayLayer:0}),y=this.device.createCommandEncoder({}),M=(T,G,z)=>{const I=T.getBindGroupLayout(0),ee=this.device.createBindGroup({layout:I,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:G}]}),Q=y.beginRenderPass({colorAttachments:[{view:z,loadOp:mo.Clear,storeOp:sc.Store,clearValue:[0,0,0,0]}]});Q.setPipeline(T),Q.setBindGroup(0,ee),Q.draw(4,1,0,0),Q.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:nl.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:nl.TwoD,baseArrayLayer:n}),m={colorAttachments:[{view:p,loadOp:mo.Clear,storeOp:sc.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 e9={[Lm]:"never",[qd]:"less",[Yd]:"equal",[ep]:"less-equal",[_0]:"greater",[w0]:"greater-equal",[Dm]:"always",[b0]:"not-equal"},t9=[0,1,3,2,4,5];class n9{constructor(e){this.backend=e,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this.colorBuffer=null,this.depthTexture=new gc,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===bm.Linear&&o.minFilter===bm.Linear&&o.mipmapFilter===bm.Linear&&(o.maxAnisotropy=e.anisotropy),e.isDepthTexture&&e.compareFunction!==null&&(o.compare=e9[e.compareFunction]),s.sampler=n.createSampler(o)}createDefaultTexture(e){let t;const n=gT(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||gT(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!==jt.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=nl.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=Da):e&&(u=U,d=as),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 Wo;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 ph;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?t9[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 QH(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===jt.BC1RGBAUnorm||e===jt.BC1RGBAUnormSRGB)return{byteLength:8,width:4,height:4};if(e===jt.BC2RGBAUnorm||e===jt.BC2RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===jt.BC3RGBAUnorm||e===jt.BC3RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===jt.BC4RUnorm||e===jt.BC4RSnorm)return{byteLength:8,width:4,height:4};if(e===jt.BC5RGUnorm||e===jt.BC5RGSnorm)return{byteLength:16,width:4,height:4};if(e===jt.BC6HRGBUFloat||e===jt.BC6HRGBFloat)return{byteLength:16,width:4,height:4};if(e===jt.BC7RGBAUnorm||e===jt.BC7RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===jt.ETC2RGB8Unorm||e===jt.ETC2RGB8UnormSRGB)return{byteLength:8,width:4,height:4};if(e===jt.ETC2RGB8A1Unorm||e===jt.ETC2RGB8A1UnormSRGB)return{byteLength:8,width:4,height:4};if(e===jt.ETC2RGBA8Unorm||e===jt.ETC2RGBA8UnormSRGB)return{byteLength:16,width:4,height:4};if(e===jt.EACR11Unorm)return{byteLength:8,width:4,height:4};if(e===jt.EACR11Snorm)return{byteLength:8,width:4,height:4};if(e===jt.EACRG11Unorm)return{byteLength:16,width:4,height:4};if(e===jt.EACRG11Snorm)return{byteLength:16,width:4,height:4};if(e===jt.ASTC4x4Unorm||e===jt.ASTC4x4UnormSRGB)return{byteLength:16,width:4,height:4};if(e===jt.ASTC5x4Unorm||e===jt.ASTC5x4UnormSRGB)return{byteLength:16,width:5,height:4};if(e===jt.ASTC5x5Unorm||e===jt.ASTC5x5UnormSRGB)return{byteLength:16,width:5,height:5};if(e===jt.ASTC6x5Unorm||e===jt.ASTC6x5UnormSRGB)return{byteLength:16,width:6,height:5};if(e===jt.ASTC6x6Unorm||e===jt.ASTC6x6UnormSRGB)return{byteLength:16,width:6,height:6};if(e===jt.ASTC8x5Unorm||e===jt.ASTC8x5UnormSRGB)return{byteLength:16,width:8,height:5};if(e===jt.ASTC8x6Unorm||e===jt.ASTC8x6UnormSRGB)return{byteLength:16,width:8,height:6};if(e===jt.ASTC8x8Unorm||e===jt.ASTC8x8UnormSRGB)return{byteLength:16,width:8,height:8};if(e===jt.ASTC10x5Unorm||e===jt.ASTC10x5UnormSRGB)return{byteLength:16,width:10,height:5};if(e===jt.ASTC10x6Unorm||e===jt.ASTC10x6UnormSRGB)return{byteLength:16,width:10,height:6};if(e===jt.ASTC10x8Unorm||e===jt.ASTC10x8UnormSRGB)return{byteLength:16,width:10,height:8};if(e===jt.ASTC10x10Unorm||e===jt.ASTC10x10UnormSRGB)return{byteLength:16,width:10,height:10};if(e===jt.ASTC12x10Unorm||e===jt.ASTC12x10UnormSRGB)return{byteLength:16,width:12,height:10};if(e===jt.ASTC12x12Unorm||e===jt.ASTC12x12UnormSRGB)return{byteLength:16,width:12,height:12}}_convertAddressMode(e){let t=dT.ClampToEdge;return e===lt?t=dT.Repeat:e===pt&&(t=dT.MirrorRepeat),t}_convertFilterMode(e){let t=bm.Linear;return(e===Ct||e===Xt||e===pn)&&(t=bm.Nearest),t}_getBytesPerTexel(e){if(e===jt.R8Unorm||e===jt.R8Snorm||e===jt.R8Uint||e===jt.R8Sint)return 1;if(e===jt.R16Uint||e===jt.R16Sint||e===jt.R16Float||e===jt.RG8Unorm||e===jt.RG8Snorm||e===jt.RG8Uint||e===jt.RG8Sint)return 2;if(e===jt.R32Uint||e===jt.R32Sint||e===jt.R32Float||e===jt.RG16Uint||e===jt.RG16Sint||e===jt.RG16Float||e===jt.RGBA8Unorm||e===jt.RGBA8UnormSRGB||e===jt.RGBA8Snorm||e===jt.RGBA8Uint||e===jt.RGBA8Sint||e===jt.BGRA8Unorm||e===jt.BGRA8UnormSRGB||e===jt.RGB9E5UFloat||e===jt.RGB10A2Unorm||e===jt.RG11B10UFloat||e===jt.Depth32Float||e===jt.Depth24Plus||e===jt.Depth24PlusStencil8||e===jt.Depth32FloatStencil8)return 4;if(e===jt.RG32Uint||e===jt.RG32Sint||e===jt.RG32Float||e===jt.RGBA16Uint||e===jt.RGBA16Sint||e===jt.RGBA16Float)return 8;if(e===jt.RGBA32Uint||e===jt.RGBA32Sint||e===jt.RGBA32Float)return 16}_getTypedArrayType(e){if(e===jt.R8Uint)return Uint8Array;if(e===jt.R8Sint)return Int8Array;if(e===jt.R8Unorm)return Uint8Array;if(e===jt.R8Snorm)return Int8Array;if(e===jt.RG8Uint)return Uint8Array;if(e===jt.RG8Sint)return Int8Array;if(e===jt.RG8Unorm)return Uint8Array;if(e===jt.RG8Snorm)return Int8Array;if(e===jt.RGBA8Uint)return Uint8Array;if(e===jt.RGBA8Sint)return Int8Array;if(e===jt.RGBA8Unorm||e===jt.RGBA8UnormSRGB)return Uint8Array;if(e===jt.RGBA8Snorm)return Int8Array;if(e===jt.R16Uint)return Uint16Array;if(e===jt.R16Sint)return Int16Array;if(e===jt.RG16Uint)return Uint16Array;if(e===jt.RG16Sint)return Int16Array;if(e===jt.RGBA16Uint)return Uint16Array;if(e===jt.RGBA16Sint)return Int16Array;if(e===jt.R16Float||e===jt.RG16Float||e===jt.RGBA16Float)return Uint16Array;if(e===jt.R32Uint)return Uint32Array;if(e===jt.R32Sint)return Int32Array;if(e===jt.R32Float)return Float32Array;if(e===jt.RG32Uint)return Uint32Array;if(e===jt.RG32Sint)return Int32Array;if(e===jt.RG32Float)return Float32Array;if(e===jt.RGBA32Uint)return Uint32Array;if(e===jt.RGBA32Sint)return Int32Array;if(e===jt.RGBA32Float)return Float32Array;if(e===jt.BGRA8Unorm||e===jt.BGRA8UnormSRGB)return Uint8Array;if(e===jt.RGB10A2Unorm||e===jt.RGB9E5UFloat||e===jt.RG11B10UFloat)return Uint32Array;if(e===jt.Depth32Float)return Float32Array;if(e===jt.Depth24Plus||e===jt.Depth24PlusStencil8)return Uint32Array;if(e===jt.Depth32FloatStencil8)return Float32Array}_getDimension(e){let t;return e.is3DTexture||e.isData3DTexture?t=BI.ThreeD:t=BI.TwoD,t}}function gT(r,e=null){const t=r.format,n=r.type,s=r.colorSpace,o=Ki.getTransfer(s);let a;if(r.isCompressedTexture===!0||r.isCompressedArrayTexture===!0)switch(t){case Ht:case Et:a=o===Fi?jt.BC1RGBAUnormSRGB:jt.BC1RGBAUnorm;break;case on:a=o===Fi?jt.BC2RGBAUnormSRGB:jt.BC2RGBAUnorm;break;case Un:a=o===Fi?jt.BC3RGBAUnormSRGB:jt.BC3RGBAUnorm;break;case To:a=jt.BC4RUnorm;break;case Gr:a=jt.BC4RSnorm;break;case Qs:a=jt.BC5RGUnorm;break;case Eo:a=jt.BC5RGSnorm;break;case no:a=o===Fi?jt.BC7RGBAUnormSRGB:jt.BC7RGBAUnorm;break;case ni:case $n:a=o===Fi?jt.ETC2RGB8UnormSRGB:jt.ETC2RGB8Unorm;break;case Pi:a=o===Fi?jt.ETC2RGBA8UnormSRGB:jt.ETC2RGBA8Unorm;break;case ui:a=o===Fi?jt.ASTC4x4UnormSRGB:jt.ASTC4x4Unorm;break;case Ir:a=o===Fi?jt.ASTC5x4UnormSRGB:jt.ASTC5x4Unorm;break;case yi:a=o===Fi?jt.ASTC5x5UnormSRGB:jt.ASTC5x5Unorm;break;case vi:a=o===Fi?jt.ASTC6x5UnormSRGB:jt.ASTC6x5Unorm;break;case Mr:a=o===Fi?jt.ASTC6x6UnormSRGB:jt.ASTC6x6Unorm;break;case Zt:a=o===Fi?jt.ASTC8x5UnormSRGB:jt.ASTC8x5Unorm;break;case Fn:a=o===Fi?jt.ASTC8x6UnormSRGB:jt.ASTC8x6Unorm;break;case hi:a=o===Fi?jt.ASTC8x8UnormSRGB:jt.ASTC8x8Unorm;break;case Xn:a=o===Fi?jt.ASTC10x5UnormSRGB:jt.ASTC10x5Unorm;break;case hs:a=o===Fi?jt.ASTC10x6UnormSRGB:jt.ASTC10x6Unorm;break;case Xr:a=o===Fi?jt.ASTC10x8UnormSRGB:jt.ASTC10x8Unorm;break;case ys:a=o===Fi?jt.ASTC10x10UnormSRGB:jt.ASTC10x10Unorm;break;case Ur:a=o===Fi?jt.ASTC12x10UnormSRGB:jt.ASTC12x10Unorm;break;case Os:a=o===Fi?jt.ASTC12x12UnormSRGB:jt.ASTC12x12Unorm;break;case D:a=o===Fi?jt.RGBA8UnormSRGB:jt.RGBA8Unorm;break;default:console.error("WebGPURenderer: Unsupported texture format.",t)}else switch(t){case D:switch(n){case Gi:a=jt.RGBA8Snorm;break;case ir:a=jt.RGBA16Sint;break;case ms:a=jt.RGBA16Uint;break;case as:a=jt.RGBA32Uint;break;case Is:a=jt.RGBA32Sint;break;case Oi:a=o===Fi?jt.RGBA8UnormSRGB:jt.RGBA8Unorm;break;case Vs:a=jt.RGBA16Float;break;case gs:a=jt.RGBA32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBAFormat.",n)}break;case Le:switch(n){case Dl:a=jt.RGB9E5UFloat;break;case nu:a=jt.RG11B10UFloat;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBFormat.",n)}break;case F:switch(n){case Gi:a=jt.R8Snorm;break;case ir:a=jt.R16Sint;break;case ms:a=jt.R16Uint;break;case as:a=jt.R32Uint;break;case Is:a=jt.R32Sint;break;case Oi:a=jt.R8Unorm;break;case Vs:a=jt.R16Float;break;case gs:a=jt.R32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with RedFormat.",n)}break;case De:switch(n){case Gi:a=jt.RG8Snorm;break;case ir:a=jt.RG16Sint;break;case ms:a=jt.RG16Uint;break;case as:a=jt.RG32Uint;break;case Is:a=jt.RG32Sint;break;case Oi:a=jt.RG8Unorm;break;case Vs:a=jt.RG16Float;break;case gs:a=jt.RG32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with RGFormat.",n)}break;case U:switch(n){case ms:a=jt.Depth16Unorm;break;case as:a=jt.Depth24Plus;break;case gs:a=jt.Depth32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with DepthFormat.",n)}break;case _:switch(n){case Da:a=jt.Depth24PlusStencil8;break;case gs:e&&e.features.has(mT.Depth32FloatStencil8)===!1&&console.error('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),a=jt.Depth32FloatStencil8;break;default:console.error("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",n)}break;case X:switch(n){case Is:a=jt.R32Sint;break;case as:a=jt.R32Uint;break;default:console.error("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",n)}break;case Ve:switch(n){case Is:a=jt.RG32Sint;break;case as:a=jt.RG32Uint;break;default:console.error("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",n)}break;case st:switch(n){case Is:a=jt.RGBA32Sint;break;case as:a=jt.RGBA32Uint;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",n)}break;default:console.error("WebGPURenderer: Unsupported texture format.",t)}return a}const i9=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,r9=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,UI={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"},s9=r=>{r=r.trim();const e=r.match(i9);if(e!==null&&e.length===4){const t=e[2],n=[];let s=null;for(;(s=r9.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=UI[M]),o.push(new eT(M,m))}const a=r.substring(e[0].length),c=e[3]||"void",u=e[1]!==void 0?e[1]:"";return{type:UI[c]||c,inputs:o,name:u,inputsCode:t,blockCode:a,outputType:c}}else throw new Error("FunctionNode: Function is not a WGSL code.")};class o9 extends iT{constructor(e){const{type:t,inputs:n,name:s,inputsCode:o,blockCode:a,outputType:c}=s9(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 a9 extends aI{parseFunction(e){return new o9(e)}}const h0=typeof self!="undefined"?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},l9={[Nl.READ_ONLY]:"read",[Nl.WRITE_ONLY]:"write",[Nl.READ_WRITE]:"read_write"},kI={[lt]:"repeat",[qe]:"clamp",[pt]:"mirror"},Ib={vertex:h0?h0.VERTEX:1,fragment:h0?h0.FRAGMENT:2,compute:h0?h0.COMPUTE:4},zI={instance:!0,swizzleAssign:!1,storageBuffer:!0},c9={"^^":"tsl_xor"},u9={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>"},VI={},Gv={tsl_xor:new $l("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new $l("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new $l("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new $l("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new $l("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new $l("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new $l("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new $l("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 $l("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 $l("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new $l("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 $l("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new $l(`
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 );
}
`)},h9={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 GI="";(typeof navigator!="undefined"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(GI+=`diagnostic( off, derivative_uniformity );
`);class d9 extends sI{constructor(e,t){super(e,t,new a9),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_${kI[e.wrapS]}S_${kI[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let n=VI[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===lt?(s.push(Gv.repeatWrapping_float),a+=` tsl_repeatWrapping_float( coord.${d} )`):u===qe?(s.push(Gv.clampWrapping_float),a+=` tsl_clampWrapping_float( coord.${d} )`):u===pt?(s.push(Gv.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+=`
);
}
`,VI[t]=n=new $l(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 F_(new k_(`textureDimensions( ${a} )`,c)),s.dimensionsSnippet[n]=o,(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)&&(s.arrayLayerCount=new F_(new k_(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(s.cubeFaceCount=new F_(new k_("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===gs||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=c9[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."),Nl.READ_WRITE):Nl.READ_ONLY:e.access}getStorageAccess(e,t){return l9[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 lT(o.name,o.node,u,y):m=new Cb(o.name,o.node,u,y):t==="cubeTexture"?m=new bI(o.name,o.node,u,y):t==="texture3D"&&(m=new lT(o.name,o.node,u,y)),m.store=e.isStorageTextureNode===!0,m.setVisibility(Ib[n]),this.isUnfilterable(e.value)===!1&&m.store===!1){const M=new YH(`${o.name}_sampler`,o.node,u);M.setVisibility(Ib[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"?vI:JH,y=new m(e,u);y.setVisibility(Ib[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 xI(d,u),y.setVisibility(Ib[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=gT(m),z=this.getStorageAccess(u.node,e),I=u.node.value.is3DTexture,ee=u.node.value.isArrayTexture;y=`texture_storage_${I?"3d":`2d${ee?"_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 u9[e]||e}isAvailable(e){let t=zI[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),zI[e]=t),t}_getWGSLMethod(e){return Gv[e]!==void 0&&this._include(e),h9[e]}_include(e){const t=Gv[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
${GI}
// 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 f9{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=jt.Depth24PlusStencil8:e.depth&&(t=jt.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 c0.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return c0.LineList;if(e.isLine)return c0.LineStrip;if(e.isMesh)return c0.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 jt.BGRA8Unorm;if(e===Vs)return jt.RGBA16Float;throw new Error("Unsupported outputType")}}const WI=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"&&WI.set(Float16Array,["float16"]);const p9=new Map([[Vm,["float16"]]]),m9=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class g9{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),ee=Math.ceil(M.count/3);T=I*4*p,G=ee*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?Pb.Instance:Pb.Vertex):(m=o.itemSize*a,y=o.isInstancedBufferAttribute?Pb.Instance:Pb.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=m9.get(s);else{const u=(p9.get(o)||WI.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 y9{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===Nl.READ_WRITE||a.access===Nl.WRITE_ONLY)?u.type=fT.Storage:u.type=fT.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===Nl.READ_WRITE?u.access=pT.ReadWrite:d===Nl.WRITE_ONLY?u.access=pT.WriteOnly:u.access=pT.ReadOnly,a.texture.isArrayTexture?u.viewDimension=nl.TwoDArray:a.texture.is3DTexture&&(u.viewDimension=nl.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=Mm.UnfilterableFloat)),a.texture.isDepthTexture)t.compatibilityMode&&a.texture.compareFunction===null?u.sampleType=Mm.UnfilterableFloat:u.sampleType=Mm.Depth;else if(a.texture.isDataTexture||a.texture.isDataArrayTexture||a.texture.isData3DTexture){const p=a.texture.type;p===Is?u.sampleType=Mm.SInt:p===as?u.sampleType=Mm.UInt:p===gs&&(this.backend.hasFeature("float32-filterable")?u.sampleType=Mm.Float:u.sampleType=Mm.UnfilterableFloat)}a.isSampledCubeTexture?u.viewDimension=nl.Cube:a.texture.isArrayTexture||a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?u.viewDimension=nl.TwoDArray:a.isSampledTexture3D&&(u.viewDimension=nl.ThreeD),c.texture=u}else if(a.isSampler){const u={};a.texture.isDepthTexture&&(a.texture.compareFunction!==null?u.type=FI.Comparison:t.compatibilityMode&&(u.type=FI.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=qH.All;let M;c.isSampledCubeTexture?M=nl.Cube:c.isSampledTexture3D?M=nl.ThreeD:c.texture.isArrayTexture||c.texture.isDataArrayTexture||c.texture.isCompressedArrayTexture?M=nl.TwoDArray:M=nl.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 v9{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!==ye&&(s.blending!==ge||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),ee=[];if(e.context.textures!==null){const tn=e.context.textures;for(let cn=0;cn<tn.length;cn++){const vn=m.getTextureFormatGPU(tn[cn]);ee.push({format:vn,blend:G,writeMask:I})}}else{const tn=m.getCurrentColorFormat(e.context);ee.push({format:tn,blend:G,writeMask:I})}const Q=d.get(c).module,oe=d.get(u).module,_e=this._getPrimitiveState(n,o,s),ve=this._getDepthCompare(s),Oe=m.getCurrentDepthStencilFormat(e.context),He=this._getSampleCount(e.context),Ce={label:`renderPipeline_${s.name||s.type}_${s.id}`,vertex:Object.assign({},Q,{buffers:T}),fragment:Object.assign({},oe,{targets:ee}),primitive:_e,multisample:{count:He,alphaToCoverageEnabled:s.alphaToCoverage&&He>1},layout:p.createPipelineLayout({bindGroupLayouts:M})},Be={},ft=e.context.depth,zt=e.context.stencil;if((ft===!0||zt===!0)&&(ft===!0&&(Be.format=Oe,Be.depthWriteEnabled=s.depthWrite,Be.depthCompare=ve),zt===!0&&(Be.stencilFront=z,Be.stencilBack={},Be.stencilReadMask=s.stencilFuncMask,Be.stencilWriteMask=s.stencilWriteMask),s.polygonOffset===!0&&(Be.depthBias=s.polygonOffsetUnits,Be.depthBiasSlopeScale=s.polygonOffsetFactor,Be.depthBiasClamp=0),Ce.depthStencil=Be),t===null)y.pipeline=p.createRenderPipeline(Ce);else{const tn=new Promise(cn=>{p.createRenderPipelineAsync(Ce).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:wm.Add},n={srcFactor:y,dstFactor:M,operation:wm.Add}};if(u)switch(s){case ge:d(ks.One,ks.OneMinusSrcAlpha,ks.One,ks.OneMinusSrcAlpha);break;case ce:d(ks.One,ks.One,ks.One,ks.One);break;case xe:d(ks.Zero,ks.OneMinusSrc,ks.Zero,ks.One);break;case fe:d(ks.Dst,ks.OneMinusSrcAlpha,ks.Zero,ks.One);break}else switch(s){case ge:d(ks.SrcAlpha,ks.OneMinusSrcAlpha,ks.One,ks.OneMinusSrcAlpha);break;case ce:d(ks.SrcAlpha,ks.One,ks.One,ks.One);break;case xe:console.error("THREE.WebGPURenderer: SubtractiveBlending requires material.premultipliedAlpha = true");break;case fe: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 je:t=ks.Zero;break;case _t:t=ks.One;break;case It:t=ks.Src;break;case kt:t=ks.OneMinusSrc;break;case Ut:t=ks.SrcAlpha;break;case At:t=ks.OneMinusSrcAlpha;break;case ue:t=ks.Dst;break;case Ue:t=ks.OneMinusDst;break;case at:t=ks.DstAlpha;break;case Ot:t=ks.OneMinusDstAlpha;break;case vt:t=ks.SrcAlphaSaturated;break;case y5:t=ks.Constant;break;case v5:t=ks.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 e1:t=Ll.Never;break;case Xh:t=Ll.Always;break;case t1:t=Ll.Less;break;case nx:t=Ll.LessEqual;break;case n1:t=Ll.Equal;break;case ix:t=Ll.GreaterEqual;break;case i1:t=Ll.Greater;break;case r1:t=Ll.NotEqual;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",n)}return t}_getStencilOperation(e){let t;switch(e){case Yl:t=qf.Keep;break;case Jb:t=qf.Zero;break;case Im:t=qf.Replace;break;case Qb:t=qf.Invert;break;case Xd:t=qf.IncrementClamp;break;case ex:t=qf.DecrementClamp;break;case tx:t=qf.IncrementWrap;break;case x0:t=qf.DecrementWrap;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Ae:t=wm.Add;break;case be:t=wm.Subtract;break;case Ye:t=wm.ReverseSubtract;break;case Ee:t=wm.Min;break;case We:t=wm.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?u0.Uint16:u0.Uint32);let a=n.side===K;return e.isMesh&&e.matrixWorld.determinant()<0&&(a=!a),s.frontFace=a===!0?LI.CW:LI.CCW,s.cullMode=n.side===re?DI.None:DI.Back,s}_getColorWriteMask(e){return e.colorWrite===!0?OI.All:OI.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=Ll.Always;else{const n=e.depthFunc;switch(n){case ze:t=Ll.Never;break;case Ze:t=Ll.Always;break;case q:t=Ll.Less;break;case Y:t=Ll.LessEqual;break;case de:t=Ll.Equal;break;case Je:t=Ll.GreaterEqual;break;case Te:t=Ll.Greater;break;case $e:t=Ll.NotEqual;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",n)}}return t}}class x9 extends PI{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 ol(`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 yT extends AI{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 f9(this),this.attributeUtils=new g9(this),this.bindingUtils=new y9(this),this.pipelineUtils=new v9(this),this.textureUtils=new n9(this),this.occludedResolveCache=new Map}init(e){return hr(this,null,function*(){yield m3(yT.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(mT),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(mT.TimestampQuery),this.updateSize()})}get coordinateSystem(){return ja}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:nl.TwoD};if(n.isRenderTarget3D)m=e.activeCubeFace,G.baseArrayLayer=0,G.dimension=nl.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 ee=ac(qs({},G),{baseArrayLayer:I,arrayLayerCount:1,dimension:nl.TwoD}),Q=T.texture.createView(ee);p.push({view:Q,resolveTarget:void 0,depthSlice:void 0})}}else G.dimension=nl.TwoDArray,G.depthOrArrayLayers=d[M].image.depth;if(y!==!0){const z=T.texture.createView(G);let I,ee;T.msaaTexture!==void 0?(I=T.msaaTexture.createView(),ee=z):(I=z,ee=void 0),p.push({view:I,resolveTarget:ee,depthSlice:m})}}if(c={textureViews:p},e.depth){const M=this.get(e.depthTexture),T={};e.depthTexture.isArrayTexture&&(T.dimension=nl.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||mo.Load,storeOp:t.storeOp||sc.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:mo.Load}),this.initTimestampQuery(lh.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=mo.Clear):m.loadOp=mo.Load,m.storeOp=sc.Store}}else{const d=a.colorAttachments[0];e.clearColor?(d.clearValue=e.clearColorValue,d.loadOp=mo.Clear):d.loadOp=mo.Load,d.storeOp=sc.Store}e.depth&&(e.clearDepth?(c.depthClearValue=e.clearDepthValue,c.depthLoadOp=mo.Clear):c.depthLoadOp=mo.Load,c.depthStoreOp=sc.Store),e.stencil&&(e.clearStencil?(c.stencilClearValue=e.clearStencilValue,c.stencilLoadOp=mo.Clear):c.stencilLoadOp=mo.Load,c.stencilStoreOp=sc.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=ac(qs({},n),{colorAttachments:[ac(qs({},n.colorAttachments[0]),{view:n.colorAttachments[c].view})]});if(n.depthStencilAttachment){const d=c;a.viewCache[d]||(a.viewCache[d]=a.texture.createView({dimension:nl.TwoD,baseArrayLayer:c,arrayLayerCount:1})),u.depthStencilAttachment={view:a.viewCache[d],depthLoadOp:o.depthLoadOp||mo.Clear,depthStoreOp:o.depthStoreOp||sc.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=qs({},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=mo.Clear):a.depthLoadOp=mo.Load),e.stencil&&(e.clearStencil?(a.stencilClearValue=e.clearStencilValue,a.stencilLoadOp=mo.Clear):a.stencilLoadOp=mo.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=mo.Clear,G.storeOp=sc.Store}(p||m)&&(u=T.depthStencilAttachment)}else{p=s.depth,m=s.stencil;const T={loadOp:e?mo.Clear:mo.Load,clearValue:e?d:void 0};p&&(T.depthLoadOp=t?mo.Clear:mo.Load,T.depthClearValue=t?a.getClearDepth():void 0,T.depthStoreOp=sc.Store),m&&(T.stencilLoadOp=n?mo.Clear:mo.Load,T.stencilClearValue=n?a.getClearStencil():void 0,T.stencilStoreOp=sc.Store);const G=this._getRenderPassDescriptor(s,T);c=G.colorAttachments,u=G.depthStencilAttachment}p&&u&&(t?(u.depthLoadOp=mo.Clear,u.depthClearValue=a.getClearDepth(),u.depthStoreOp=sc.Store):(u.depthLoadOp=mo.Load,u.depthStoreOp=sc.Store)),m&&u&&(n?(u.stencilLoadOp=mo.Clear,u.stencilClearValue=a.getClearStencil(),u.stencilStoreOp=sc.Store):(u.stencilLoadOp=mo.Load,u.stencilStoreOp=sc.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(lh.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 Q=0,oe=c.length;Q<oe;Q++){const _e=c[Q],ve=this.get(_e);I[_e.index]!==_e.id&&(G.setBindGroup(_e.index,ve.group),I[_e.index]=_e.id)}if(m===!0&&z.index!==p){const Q=this.get(p).buffer,oe=p.array instanceof Uint16Array?u0.Uint16:u0.Uint32;G.setIndexBuffer(Q,oe),z.index=p}const ee=e.getVertexBuffers();for(let Q=0,oe=ee.length;Q<oe;Q++){const _e=ee[Q];if(z.attributes[Q]!==_e){const ve=this.get(_e).buffer;G.setVertexBuffer(Q,ve),z.attributes[Q]=_e}}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,ee=n._multiDrawCounts,Q=n._multiDrawCount,oe=n._multiDrawInstances;oe!==null&&ol("THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let _e=0;_e<Q;_e++){const ve=oe?oe[_e]:1,Oe=ve>1?0:_e;m===!0?G.drawIndexed(ee[_e],ve,I[_e]/p.array.BYTES_PER_ELEMENT,0,Oe):G.draw(ee[_e],ve,I[_e],Oe),t.update(n,ee[_e],ve)}}else if(m===!0){const{vertexCount:I,instanceCount:ee,firstVertex:Q}=y,oe=e.getIndirect();if(oe!==null){const _e=this.get(oe).buffer;G.drawIndexedIndirect(_e,0)}else G.drawIndexed(I,ee,Q,0,0);t.update(n,I,ee)}else{const{vertexCount:I,instanceCount:ee,firstVertex:Q}=y,oe=e.getIndirect();if(oe!==null){const _e=this.get(oe).buffer;G.drawIndirect(_e,0)}else G.draw(I,ee,Q,0);t.update(n,I,ee)}};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 Q=this.get(I),oe=[],_e=new Uint32Array([0,0,0,0]);for(let ve=0,Oe=z.length;ve<Oe;ve++){_e[0]=ve;const He=this.bindingUtils.createBindGroupIndex(_e,Q.layout);oe.push(He)}G.indexesGPU=oe}const ee=this.renderer.getPixelRatio();for(let Q=0,oe=z.length;Q<oe;Q++){const _e=z[Q];if(n.layers.test(_e.layers)){const ve=_e.viewport;let Oe=u.currentPass,He=u.currentSets;if(u.bundleEncoders){const Ce=u.bundleEncoders[Q],Be=u.bundleSets[Q];Oe=Ce,He=Be}ve&&Oe.setViewport(Math.floor(ve.x*ee),Math.floor(ve.y*ee),Math.floor(ve.width*ee),Math.floor(ve.height*ee),o.viewportValue.minDepth,o.viewportValue.maxDepth),I&&G.indexesGPU&&(Oe.setBindGroup(I.index,G.indexesGPU[Q]),He.bindingGroups[I.index]=I.id),T(Oe,He)}}}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 x9(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 d9(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,ee=this.get(t).texture;z.copyTextureToTexture({texture:I,mipLevel:o,origin:{x:p,y:m,z:y}},{texture:ee,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=mo.Load;if(t.depth&&(u.depthStencilAttachment.depthLoadOp=mo.Load),t.stencil&&(u.depthStencilAttachment.stencilLoadOp=mo.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 _9 extends yg{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 b9 extends yg{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 w9 extends uI{constructor(){super(),this.addMaterial(lV,"MeshPhongMaterial"),this.addMaterial(zN,"MeshStandardMaterial"),this.addMaterial(qV,"MeshPhysicalMaterial"),this.addMaterial(QV,"MeshToonMaterial"),this.addMaterial(tV,"MeshBasicMaterial"),this.addMaterial(oV,"MeshLambertMaterial"),this.addMaterial(Z4,"MeshNormalMaterial"),this.addMaterial(t5,"MeshMatcapMaterial"),this.addMaterial(W4,"LineBasicMaterial"),this.addMaterial($4,"LineDashedMaterial"),this.addMaterial(o5,"PointsMaterial"),this.addMaterial(GN,"SpriteMaterial"),this.addMaterial(u5,"ShadowMaterial"),this.addLight(E8,Fx),this.addLight(tH,wd),this.addLight(nH,Ux),this.addLight(nT,yg),this.addLight(oH,Gp),this.addLight(aH,bd),this.addLight(lH,my),this.addLight(iH,_9),this.addLight(sH,b9),this.addToneMapping(pP,B),this.addToneMapping(mP,ie),this.addToneMapping(gP,ct),this.addToneMapping(yP,Mt),this.addToneMapping(vP,Yt),this.addToneMapping(xP,en)}}class M9 extends AH{constructor(e={}){let t;e.forceWebGL?t=II:(t=yT,e.getFallback=()=>(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new II(e)));const n=new t(e);super(n,e),this.library=new w9,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}class hZ extends null{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}}class dZ{constructor(e,t=Bi(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;const n=new ya;n.name="PostProcessing",this._quadMesh=new Cv(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=EM(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 fZ 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 pZ 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 mZ 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 gZ extends null{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}}class S9 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),ut()):Cn(new this.nodes[e])}}class T9 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 yZ 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 S9;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 T9;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 vZ extends null{constructor(){super(),this.isClippingGroup=!0,this.clippingPlanes=[],this.enabled=!0,this.clipIntersection=!1,this.clipShadows=!1}}const vT={type:"change"},xT={type:"start"},_T={type:"end"},HI=1e-6,go={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4},Lb=new yn,Yf=new yn,E9=new ot,Db=new ot,bT=new ot,d0=new ea,$I=new ot,Ob=new ot,wT=new ot,Fb=new ot;class A9 extends Yp{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 ot,this.state=go.NONE,this.keyState=go.NONE,this._lastPosition=new ot,this._lastZoom=1,this._touchZoomDistanceStart=0,this._touchZoomDistanceEnd=0,this._lastAngle=0,this._eye=new ot,this._movePrev=new yn,this._moveCurr=new yn,this._lastAxis=new ot,this._zoomStart=new yn,this._zoomEnd=new yn,this._panStart=new yn,this._panEnd=new yn,this._pointers=[],this._pointerPositions={},this._onPointerMove=R9.bind(this),this._onPointerDown=C9.bind(this),this._onPointerUp=N9.bind(this),this._onPointerCancel=P9.bind(this),this._onContextMenu=U9.bind(this),this._onMouseWheel=B9.bind(this),this._onKeyDown=L9.bind(this),this._onKeyUp=I9.bind(this),this._onTouchStart=k9.bind(this),this._onTouchMove=z9.bind(this),this._onTouchEnd=V9.bind(this),this._onMouseDown=D9.bind(this),this._onMouseMove=O9.bind(this),this._onMouseUp=F9.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)>HI&&(this.dispatchEvent(vT),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>HI||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(vT),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=go.NONE,this.keyState=go.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(vT),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(Yf.copy(this._panEnd).sub(this._panStart),Yf.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;Yf.x*=e,Yf.y*=t}Yf.multiplyScalar(this._eye.length()*this.panSpeed),Db.copy(this._eye).cross(this.object.up).setLength(Yf.x),Db.add(E9.copy(this.object.up).setLength(Yf.y)),this.object.position.add(Db),this.target.add(Db),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(Yf.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){Fb.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=Fb.length();e?(this._eye.copy(this.object.position).sub(this.target),$I.copy(this._eye).normalize(),Ob.copy(this.object.up).normalize(),wT.crossVectors(Ob,$I).normalize(),Ob.setLength(this._moveCurr.y-this._movePrev.y),wT.setLength(this._moveCurr.x-this._movePrev.x),Fb.copy(Ob.add(wT)),bT.crossVectors(Fb,this._eye).normalize(),e*=this.rotateSpeed,d0.setFromAxisAngle(bT,e),this._eye.applyQuaternion(d0),this.object.up.applyQuaternion(d0),this._lastAxis.copy(bT),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),d0.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(d0),this.object.up.applyQuaternion(d0)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===go.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=Yh.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=Yh.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 Lb.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),Lb}_getMouseOnCircle(e,t){return Lb.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),Lb}_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 C9(r){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(r.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),this._addPointer(r),r.pointerType==="touch"?this._onTouchStart(r):this._onMouseDown(r))}function R9(r){this.enabled!==!1&&(r.pointerType==="touch"?this._onTouchMove(r):this._onMouseMove(r))}function N9(r){this.enabled!==!1&&(r.pointerType==="touch"?this._onTouchEnd(r):this._onMouseUp(),this._removePointer(r),this._pointers.length===0&&(this.domElement.releasePointerCapture(r.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp)))}function P9(r){this._removePointer(r)}function I9(){this.enabled!==!1&&(this.keyState=go.NONE,window.addEventListener("keydown",this._onKeyDown))}function L9(r){this.enabled!==!1&&(window.removeEventListener("keydown",this._onKeyDown),this.keyState===go.NONE&&(r.code===this.keys[go.ROTATE]&&!this.noRotate?this.keyState=go.ROTATE:r.code===this.keys[go.ZOOM]&&!this.noZoom?this.keyState=go.ZOOM:r.code===this.keys[go.PAN]&&!this.noPan&&(this.keyState=go.PAN)))}function D9(r){let e;switch(r.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=go.ZOOM;break;case k.ROTATE:this.state=go.ROTATE;break;case k.PAN:this.state=go.PAN;break;default:this.state=go.NONE}const t=this.keyState!==go.NONE?this.keyState:this.state;t===go.ROTATE&&!this.noRotate?(this._moveCurr.copy(this._getMouseOnCircle(r.pageX,r.pageY)),this._movePrev.copy(this._moveCurr)):t===go.ZOOM&&!this.noZoom?(this._zoomStart.copy(this._getMouseOnScreen(r.pageX,r.pageY)),this._zoomEnd.copy(this._zoomStart)):t===go.PAN&&!this.noPan&&(this._panStart.copy(this._getMouseOnScreen(r.pageX,r.pageY)),this._panEnd.copy(this._panStart)),this.dispatchEvent(xT)}function O9(r){const e=this.keyState!==go.NONE?this.keyState:this.state;e===go.ROTATE&&!this.noRotate?(this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this._getMouseOnCircle(r.pageX,r.pageY))):e===go.ZOOM&&!this.noZoom?this._zoomEnd.copy(this._getMouseOnScreen(r.pageX,r.pageY)):e===go.PAN&&!this.noPan&&this._panEnd.copy(this._getMouseOnScreen(r.pageX,r.pageY))}function F9(){this.state=go.NONE,this.dispatchEvent(_T)}function B9(r){if(this.enabled!==!1&&this.noZoom!==!0){switch(r.preventDefault(),r.deltaMode){case 2:this._zoomStart.y-=r.deltaY*.025;break;case 1:this._zoomStart.y-=r.deltaY*.01;break;default:this._zoomStart.y-=r.deltaY*25e-5;break}this.dispatchEvent(xT),this.dispatchEvent(_T)}}function U9(r){this.enabled!==!1&&r.preventDefault()}function k9(r){switch(this._trackPointer(r),this._pointers.length){case 1:this.state=go.TOUCH_ROTATE,this._moveCurr.copy(this._getMouseOnCircle(this._pointers[0].pageX,this._pointers[0].pageY)),this._movePrev.copy(this._moveCurr);break;default:this.state=go.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(xT)}function z9(r){switch(this._trackPointer(r),this._pointers.length){case 1:this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this._getMouseOnCircle(r.pageX,r.pageY));break;default:const e=this._getSecondPointerPosition(r),t=r.pageX-e.x,n=r.pageY-e.y;this._touchZoomDistanceEnd=Math.sqrt(t*t+n*n);const s=(r.pageX+e.x)/2,o=(r.pageY+e.y)/2;this._panEnd.copy(this._getMouseOnScreen(s,o));break}}function V9(r){switch(this._pointers.length){case 0:this.state=go.NONE;break;case 1:this.state=go.TOUCH_ROTATE,this._moveCurr.copy(this._getMouseOnCircle(r.pageX,r.pageY)),this._movePrev.copy(this._moveCurr);break;case 2:this.state=go.TOUCH_ZOOM_PAN;for(let e=0;e<this._pointers.length;e++)if(this._pointers[e].pointerId!==r.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(_T)}const jI={type:"change"},MT={type:"start"},XI={type:"end"},Bb=new hn,qI=new Al,G9=Math.cos(70*Yh.DEG2RAD),gl=new ot,Cc=2*Math.PI,Po={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},ST=1e-6;class W9 extends Yp{constructor(e,t=null){super(e,t),this.state=Po.NONE,this.target=new ot,this.cursor=new ot,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 ot,this._lastQuaternion=new ea,this._lastTargetPosition=new ot,this._quat=new ea().setFromUnitVectors(e.up,new ot(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Ey,this._sphericalDelta=new Ey,this._scale=1,this._panOffset=new ot,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 ot,this._mouse=new yn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=$9.bind(this),this._onPointerDown=H9.bind(this),this._onPointerUp=j9.bind(this),this._onContextMenu=Q9.bind(this),this._onMouseWheel=Y9.bind(this),this._onKeyDown=Z9.bind(this),this._onTouchStart=K9.bind(this),this._onTouchMove=J9.bind(this),this._onMouseDown=X9.bind(this),this._onMouseMove=q9.bind(this),this._interceptControlDown=e7.bind(this),this._interceptControlUp=t7.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(jI),this.update(),this.state=Po.NONE}update(e=null){const t=this.object.position;gl.copy(t).sub(this.target),gl.applyQuaternion(this._quat),this._spherical.setFromVector3(gl),this.autoRotate&&this.state===Po.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+=Cc:n>Math.PI&&(n-=Cc),s<-Math.PI?s+=Cc:s>Math.PI&&(s-=Cc),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(gl.setFromSpherical(this._spherical),gl.applyQuaternion(this._quatInverse),t.copy(this.target).add(gl),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=gl.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 ot(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 ot(this._mouse.x,this._mouse.y,0);d.unproject(this.object),this.object.position.sub(d).add(c),this.object.updateMatrixWorld(),a=gl.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):(Bb.origin.copy(this.object.position),Bb.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Bb.direction))<G9?this.object.lookAt(this.target):(qI.setFromNormalAndCoplanarPoint(this.object.up,this.target),Bb.intersectPlane(qI,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)>ST||8*(1-this._lastQuaternion.dot(this.object.quaternion))>ST||this._lastTargetPosition.distanceToSquared(this.target)>ST?(this.dispatchEvent(jI),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Cc/60*this.autoRotateSpeed*e:Cc/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){gl.setFromMatrixColumn(t,0),gl.multiplyScalar(-e),this._panOffset.add(gl)}_panUp(e,t){this.screenSpacePanning===!0?gl.setFromMatrixColumn(t,1):(gl.setFromMatrixColumn(t,0),gl.crossVectors(this.object.up,gl)),gl.multiplyScalar(e),this._panOffset.add(gl)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;gl.copy(s).sub(this.target);let o=gl.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(Cc*this._rotateDelta.x/t.clientHeight),this._rotateUp(Cc*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(Cc*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(-Cc*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(Cc*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(-Cc*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(Cc*this._rotateDelta.x/t.clientHeight),this._rotateUp(Cc*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 H9(r){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(r.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(r)&&(this._addPointer(r),r.pointerType==="touch"?this._onTouchStart(r):this._onMouseDown(r)))}function $9(r){this.enabled!==!1&&(r.pointerType==="touch"?this._onTouchMove(r):this._onMouseMove(r))}function j9(r){switch(this._removePointer(r),this._pointers.length){case 0:this.domElement.releasePointerCapture(r.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(XI),this.state=Po.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 X9(r){let e;switch(r.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(r),this.state=Po.DOLLY;break;case k.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=Po.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=Po.ROTATE}break;case k.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=Po.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=Po.PAN}break;default:this.state=Po.NONE}this.state!==Po.NONE&&this.dispatchEvent(MT)}function q9(r){switch(this.state){case Po.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(r);break;case Po.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(r);break;case Po.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(r);break}}function Y9(r){this.enabled===!1||this.enableZoom===!1||this.state!==Po.NONE||(r.preventDefault(),this.dispatchEvent(MT),this._handleMouseWheel(this._customWheelEvent(r)),this.dispatchEvent(XI))}function Z9(r){this.enabled!==!1&&this._handleKeyDown(r)}function K9(r){switch(this._trackPointer(r),this._pointers.length){case 1:switch(this.touches.ONE){case O.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(r),this.state=Po.TOUCH_ROTATE;break;case O.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(r),this.state=Po.TOUCH_PAN;break;default:this.state=Po.NONE}break;case 2:switch(this.touches.TWO){case O.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(r),this.state=Po.TOUCH_DOLLY_PAN;break;case O.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(r),this.state=Po.TOUCH_DOLLY_ROTATE;break;default:this.state=Po.NONE}break;default:this.state=Po.NONE}this.state!==Po.NONE&&this.dispatchEvent(MT)}function J9(r){switch(this._trackPointer(r),this.state){case Po.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(r),this.update();break;case Po.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(r),this.update();break;case Po.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(r),this.update();break;case Po.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(r),this.update();break;default:this.state=Po.NONE}}function Q9(r){this.enabled!==!1&&r.preventDefault()}function e7(r){r.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function t7(r){r.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const n7={type:"change"},YI=1e-6,ZI=new ea;class i7 extends Yp{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 ot(0,0,0),this._rotationVector=new ot(0,0,0),this._lastQuaternion=new ea,this._lastPosition=new ot,this._status=0,this._onKeyDown=r7.bind(this),this._onKeyUp=s7.bind(this),this._onPointerMove=a7.bind(this),this._onPointerDown=o7.bind(this),this._onPointerUp=l7.bind(this),this._onPointerCancel=c7.bind(this),this._onContextMenu=u7.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),ZI.set(this._rotationVector.x*s,this._rotationVector.y*s,this._rotationVector.z*s,1).normalize(),t.quaternion.multiply(ZI),(this._lastPosition.distanceToSquared(t.position)>YI||8*(1-this._lastQuaternion.dot(t.quaternion))>YI)&&(this.dispatchEvent(n7),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 r7(r){if(!(r.altKey||this.enabled===!1)){switch(r.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 s7(r){if(this.enabled!==!1){switch(r.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 o7(r){if(this.enabled!==!1)if(this.dragToLook)this._status++;else{switch(r.button){case 0:this._moveState.forward=1;break;case 2:this._moveState.back=1;break}this._updateMovementVector()}}function a7(r){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=-(r.pageX-e.offset[0]-t)/t,this._moveState.pitchDown=(r.pageY-e.offset[1]-n)/n,this._updateRotationVector()}}function l7(r){if(this.enabled!==!1){if(this.dragToLook)this._status--,this._moveState.yawLeft=this._moveState.pitchDown=0;else{switch(r.button){case 0:this._moveState.forward=0;break;case 2:this._moveState.back=0;break}this._updateMovementVector()}this._updateRotationVector()}}function c7(){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 u7(r){this.enabled!==!1&&r.preventDefault()}const h7={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 Ub{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 d7=new Cf(-1,1,1,-1,0,1);class f7 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 p7=new f7;class m7{constructor(e){this._mesh=new Zs(p7,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,d7)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class g7 extends Ub{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof Bc?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=ap.clone(e.uniforms),this.material=new Bc({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 m7(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 KI extends Ub{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 y7 extends Ub{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class v7{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 cc(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Vs}),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 g7(h7),this.copyPass.material.blending=ye,this.clock=new Vx}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()}KI!==void 0&&(a instanceof KI?n=!0:a instanceof y7&&(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 x7 extends Ub{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 Rc(){return Rc=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},Rc.apply(null,arguments)}function _7(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Wv(r,e){return Wv=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},Wv(r,e)}function b7(r,e){r.prototype=Object.create(e.prototype),r.prototype.constructor=r,Wv(r,e)}function TT(r){return TT=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},TT(r)}function w7(r){try{return Function.toString.call(r).indexOf("[native code]")!==-1}catch(e){return typeof r=="function"}}function JI(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(JI=function(){return!!r})()}function M7(r,e,t){if(JI())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var s=new(r.bind.apply(r,n));return t&&Wv(s,t.prototype),s}function ET(r){var e=typeof Map=="function"?new Map:void 0;return ET=function(n){if(n===null||!w7(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 M7(n,arguments,TT(this).constructor)}return s.prototype=Object.create(n.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),Wv(s,n)},ET(r)}function QI(){var r;return r=arguments.length-1,r<0||arguments.length<=r?void 0:arguments[r]}function S7(r){return-r}function T7(r,e){return r+e}function E7(r,e){return r-e}function A7(r,e){return r*e}function C7(r,e){return r/e}function R7(){return Math.max.apply(Math,arguments)}function N7(){return Math.min.apply(Math,arguments)}function P7(){return Array.of.apply(Array,arguments)}var xZ={symbols:{"*":{infix:{symbol:"*",f:A7,notation:"infix",precedence:4,rightToLeft:0,argCount:2},symbol:"*",regSymbol:"\\*"},"/":{infix:{symbol:"/",f:C7,notation:"infix",precedence:4,rightToLeft:0,argCount:2},symbol:"/",regSymbol:"/"},"+":{infix:{symbol:"+",f:T7,notation:"infix",precedence:2,rightToLeft:0,argCount:2},prefix:{symbol:"+",f:QI,notation:"prefix",precedence:3,rightToLeft:0,argCount:1},symbol:"+",regSymbol:"\\+"},"-":{infix:{symbol:"-",f:E7,notation:"infix",precedence:2,rightToLeft:0,argCount:2},prefix:{symbol:"-",f:S7,notation:"prefix",precedence:3,rightToLeft:0,argCount:1},symbol:"-",regSymbol:"-"},",":{infix:{symbol:",",f:P7,notation:"infix",precedence:1,rightToLeft:0,argCount:2},symbol:",",regSymbol:","},"(":{prefix:{symbol:"(",f:QI,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:N7,notation:"func",precedence:0,rightToLeft:0,argCount:1},symbol:"min",regSymbol:"min\\b"},max:{func:{symbol:"max",f:R7,notation:"func",precedence:0,rightToLeft:0,argCount:1},symbol:"max",regSymbol:"max\\b"}}},eL=null,_Z={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 bZ(){for(var r=arguments.length,e=new Array(r),t=0;t<r;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 Hr=function(r){b7(e,r);function e(t){var n;if(1)n=r.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 _7(n)}return e}(ET(Error)),tL=/((?!\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 I7(r){var e={};return e.symbols=r?_extends({},eL.symbols,r.symbols):_extends({},eL.symbols),e}function nL(r,e){var t,n=r.pop();return e.push(n.f.apply(n,(t=[]).concat.apply(t,e.splice(-n.argCount)))),n.precedence}function L7(r,e){var t=I7(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(r);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 Hr(37,n?n.index:r.length,r);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(nL(s,o));c=T.notation==="postfix",T.symbol!==")"&&(s.push(T),c&&nL(s,o))}else if(m){if(s.push(m.prefix||m.func),m.func&&(n=a.exec(r),!n||n[0]!=="("))throw new Hr(38,n?n.index:r.length,r)}else o.push(+d),c=!0}while(n&&s.length);if(s.length)throw new Hr(39,n?n.index:r.length,r);if(n)throw new Hr(40,n?n.index:r.length,r);return o.pop()}function AT(r){return r.split("").reverse().join("")}function wZ(r,e){var t=AT(r),n=t.match(tL);if(n&&!n.every(function(o){return o===n[0]}))throw new Hr(41);var s=AT(t.replace(tL,""));return""+L7(s,e)+(n?AT(n[0]):"")}var D7=/--[\S]*/g;function MZ(r,e){if(!r||!r.match(D7))throw new Hr(73);var t;if(typeof document!="undefined"&&document.documentElement!==null&&(t=getComputedStyle(document.documentElement).getPropertyValue(r)),t)return t.trim();if(e)return e;throw new Hr(74)}function Hv(r){return r.charAt(0).toUpperCase()+r.slice(1)}var O7=null;function F7(r,e){if(!r)return e.toLowerCase();var t=r.split("-");if(t.length>1)return t.splice(1,0,e),t.reduce(function(s,o){return""+s+Hv(o)});var n=r.replace(/([a-z])([A-Z])/g,"$1"+e+"$2");return r===n?""+r+e:n}function B7(r,e){for(var t={},n=0;n<e.length;n+=1)(e[n]||e[n]===0)&&(t[F7(r,O7[n])]=e[n]);return t}function Sm(r){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 B7(r,m)}function iL(r,e){return r.substr(-e.length)===e}var U7=/^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;function rL(r){if(typeof r!="string")return r;var e=r.match(U7);return e?parseFloat(r):r}var k7=function(e){return function(t,n){n===void 0&&(n="16px");var s=t,o=n;if(typeof t=="string"){if(!iL(t,"px"))throw new Hr(69,e,t);s=rL(t)}if(typeof n=="string"){if(!iL(n,"px"))throw new Hr(70,e,n);o=rL(n)}if(typeof s=="string")throw new Hr(71,t,e);if(typeof o=="string")throw new Hr(72,n,e);return""+s/o+e}},sL=k7,SZ=sL("em"),TZ=null,z7=/^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;function Gd(r){if(typeof r!="string")return[r,""];var e=r.match(z7);return e?[parseFloat(r),e[2]]:[r,void 0]}function V7(r,e){if(typeof r!="object"||r===null)throw new Hr(75,typeof r);var t={};return Object.keys(r).forEach(function(n){typeof r[n]=="object"&&r[n]!==null?t[n]=V7(r[n],e):!e||e&&(e===n||e.indexOf(n)>=0)?t[n]=r[n]+" !important":t[n]=r[n]}),t}var oL={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 G7(r){return oL[r]}function EZ(r,e,t){if(e===void 0&&(e="1em"),t===void 0&&(t=1.333),typeof r!="number")throw new Hr(42);if(typeof t=="string"&&!oL[t])throw new Hr(43);var n=typeof e=="string"?Gd(e):[e,""],s=n[0],o=n[1],a=typeof t=="string"?G7(t):t;if(typeof s=="string")throw new Hr(44,e);return""+s*Math.pow(a,r)+(o||"")}var AZ=sL("rem"),CZ=null,CT=16;function aL(r){var e=Gd(r);if(e[1]==="px")return parseFloat(r);if(e[1]==="%")return parseFloat(r)/100*CT;throw new Hr(78,e[1])}function W7(){if(typeof document!="undefined"&&document.documentElement!==null){var r=getComputedStyle(document.documentElement).fontSize;return r?aL(r):CT}return CT}function RZ(r,e){var t=Gd(r);if(t[1]!=="rem"&&t[1]!=="")throw new Hr(77,t[1]);var n=e?aL(e):W7();return t[0]*n+"px"}var H7={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 NZ(r){return H7[r.toLowerCase().trim()]}var $7={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 PZ(r){return $7[r.toLowerCase().trim()]}var j7={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 IZ(r){return j7[r.toLowerCase().trim()]}function lL(r,e,t,n){t===void 0&&(t="320px"),n===void 0&&(n="1200px");var s=Gd(r),o=s[0],a=s[1],c=Gd(e),u=c[0],d=c[1],p=Gd(t),m=p[0],y=p[1],M=Gd(n),T=M[0],G=M[1];if(typeof m!="number"||typeof T!="number"||!y||!G||y!==G)throw new Hr(47);if(typeof o!="number"||typeof u!="number"||a!==d)throw new Hr(48);if(a!==y||d!==G)throw new Hr(76);var z=(o-u)/(m-T),I=u-z*T;return"calc("+I.toFixed(2)+(a||"")+" + "+(100*z).toFixed(2)+"vw)"}function LZ(r){var e;r===void 0&&(r="&");var t=r+"::after";return e={},e[t]={clear:"both",content:'""',display:"table"},e}function DZ(r){return r===void 0&&(r=0),{position:"absolute",top:r,right:r,bottom:r,left:r}}function OZ(r,e){e===void 0&&(e=1);var t={display:"inline-block",maxWidth:r||"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 X7(r,e){var t=typeof Symbol!="undefined"&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=q7(r))||e&&r&&typeof r.length=="number"){t&&(r=t);var n=0;return function(){return n>=r.length?{done:!0}:{done:!1,value:r[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 q7(r,e){if(r){if(typeof r=="string")return cL(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);if(t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set")return Array.from(r);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return cL(r,e)}}function cL(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function FZ(r,e,t){if(e===void 0&&(e="320px"),t===void 0&&(t="1200px"),!Array.isArray(r)&&typeof r!="object"||r===null)throw new Hr(49);if(Array.isArray(r)){for(var n={},s={},o=X7(r),a;!(a=o()).done;){var c,u,d=a.value;if(!d.prop||!d.fromSize||!d.toSize)throw new Hr(50);s[d.prop]=d.fromSize,n["@media (min-width: "+e+")"]=_extends({},n["@media (min-width: "+e+")"],(c={},c[d.prop]=lL(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(!r.prop||!r.fromSize||!r.toSize)throw new Hr(51);return y={},y[r.prop]=r.fromSize,y["@media (min-width: "+e+")"]=(p={},p[r.prop]=lL(r.fromSize,r.toSize,e,t),p),y["@media (min-width: "+t+")"]=(m={},m[r.prop]=r.toSize,m),y}}var Y7=/^\s*data:([a-z]+\/[a-z-]+(;[a-z-]+=[a-z-]+)?)?(;charset=[a-z0-9-]+)?(;base64)?,[a-z0-9!$&',()*+,;=\-._~:@/?%\s]*\s*$/i,Z7={woff:"woff",woff2:"woff2",ttf:"truetype",otf:"opentype",eot:"embedded-opentype",svg:"svg",svgz:"svg"};function uL(r,e){return e?' format("'+Z7[r]+'")':""}function K7(r){return!!r.replace(/\s+/g," ").match(Y7)}function J7(r,e,t){if(K7(r))return'url("'+r+'")'+uL(e[0],t);var n=e.map(function(s){return'url("'+r+"."+s+'")'+uL(s,t)});return n.join(", ")}function Q7(r){var e=r.map(function(t){return'local("'+t+'")'});return e.join(", ")}function e$(r,e,t,n){var s=[];return e&&s.push(Q7(e)),r&&s.push(J7(r,t,n)),s.join(", ")}function BZ(r){var e=r.fontFamily,t=r.fontFilePath,n=r.fontStretch,s=r.fontStyle,o=r.fontVariant,a=r.fontWeight,c=r.fileFormats,u=c===void 0?["eot","woff2","woff","ttf","svg"]:c,d=r.formatHint,p=d===void 0?!1:d,m=r.localFonts,y=m===void 0?[e]:m,M=r.unicodeRange,T=r.fontDisplay,G=r.fontVariationSettings,z=r.fontFeatureSettings;if(!e)throw new Hr(55);if(!t&&!y)throw new Hr(52);if(y&&!Array.isArray(y))throw new Hr(53);if(!Array.isArray(u))throw new Hr(54);var I={"@font-face":{fontFamily:e,src:e$(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 UZ(){return{textIndent:"101%",overflow:"hidden",whiteSpace:"nowrap"}}function kZ(){return{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",whiteSpace:"nowrap",width:"1px"}}function t$(r){return r===void 0&&(r=1.3),`
@media only screen and (-webkit-min-device-pixel-ratio: `+r+`),
only screen and (min--moz-device-pixel-ratio: `+r+`),
only screen and (-o-min-device-pixel-ratio: `+r+`/1),
only screen and (min-resolution: `+Math.round(r*96)+`dpi),
only screen and (min-resolution: `+r+`dppx)
`}function hL(r){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<r.length;o+=1)if(e+=r[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 dL;function zZ(r){var e=r.colorStops,t=r.fallback,n=r.toDirection,s=n===void 0?"":n;if(!e||e.length<2)throw new Hr(56);return{backgroundColor:t||e[0].replace(/,\s+/g,",").split(" ")[0].replace(/,(?=\S)/g,", "),backgroundImage:hL(dL||(dL=_taggedTemplateLiteralLoose(["linear-gradient(","",")"])),s,e.join(", ").replace(/,(?=\S)/g,", "))}}function VZ(){var r;return[(r={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"}},r[`b,
strong`]={fontWeight:"bolder"},r[`code,
kbd,
samp`]={fontFamily:"monospace, monospace",fontSize:"1em"},r.small={fontSize:"80%"},r[`sub,
sup`]={fontSize:"75%",lineHeight:"0",position:"relative",verticalAlign:"baseline"},r.sub={bottom:"-0.25em"},r.sup={top:"-0.5em"},r.img={borderStyle:"none"},r[`button,
input,
optgroup,
select,
textarea`]={fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15",margin:"0"},r[`button,
input`]={overflow:"visible"},r[`button,
select`]={textTransform:"none"},r[`button,
html [type="button"],
[type="reset"],
[type="submit"]`]={WebkitAppearance:"button"},r[`button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner`]={borderStyle:"none",padding:"0"},r[`button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring`]={outline:"1px dotted ButtonText"},r.fieldset={padding:"0.35em 0.625em 0.75em"},r.legend={boxSizing:"border-box",color:"inherit",display:"table",maxWidth:"100%",padding:"0",whiteSpace:"normal"},r.progress={verticalAlign:"baseline"},r.textarea={overflow:"auto"},r[`[type="checkbox"],
[type="radio"]`]={boxSizing:"border-box",padding:"0"},r[`[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button`]={height:"auto"},r['[type="search"]']={WebkitAppearance:"textfield",outlineOffset:"-2px"},r['[type="search"]::-webkit-search-decoration']={WebkitAppearance:"none"},r["::-webkit-file-upload-button"]={WebkitAppearance:"button",font:"inherit"},r.details={display:"block"},r.summary={display:"list-item"},r.template={display:"none"},r["[hidden]"]={display:"none"},r),{"abbr[title]":{textDecoration:"underline dotted"}}]}var fL;function GZ(r){var e=r.colorStops,t=r.extent,n=t===void 0?"":t,s=r.fallback,o=r.position,a=o===void 0?"":o,c=r.shape,u=c===void 0?"":c;if(!e||e.length<2)throw new Hr(57);return{backgroundColor:s||e[0].split(" ")[0],backgroundImage:hL(fL||(fL=_taggedTemplateLiteralLoose(["radial-gradient(","","","",")"])),a,u,n,e.join(", "))}}function WZ(r,e,t,n,s){var o;if(t===void 0&&(t="png"),s===void 0&&(s="_2x"),!r)throw new Hr(58);var a=t.replace(/^\./,""),c=n?n+"."+a:""+r+s+"."+a;return o={backgroundImage:"url("+r+"."+a+")"},o[t$()]=_extends({backgroundImage:"url("+c+")"},e?{backgroundSize:e}:{}),o}var n$={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 i$(r){return n$[r]}function HZ(r){return i$(r)}var r$=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"}},s$=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 Hr(59)}};function $Z(r){var e=r.pointingDirection,t=r.height,n=r.width,s=r.foregroundColor,o=r.backgroundColor,a=o===void 0?"transparent":o,c=Gd(n),u=Gd(t);if(isNaN(u[0])||isNaN(c[0]))throw new Hr(60);return _extends({width:"0",height:"0",borderColor:a},s$(e,s),{borderStyle:"solid",borderWidth:r$(e,u,c)})}function jZ(r){r===void 0&&(r="break-word");var e=r==="break-word"?"break-all":r;return{overflowWrap:r,wordWrap:r,wordBreak:e}}function RT(r){return Math.round(r*255)}function o$(r,e,t){return RT(r)+","+RT(e)+","+RT(t)}function $v(r,e,t,n){if(n===void 0&&(n=o$),e===0)return n(t,t,t);var s=(r%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 a$(r){if(typeof r!="string")return r;var e=r.toLowerCase();return pL[e]?"#"+pL[e]:r}var l$=/^#[a-fA-F0-9]{6}$/,c$=/^#[a-fA-F0-9]{8}$/,u$=/^#[a-fA-F0-9]{3}$/,h$=/^#[a-fA-F0-9]{4}$/,NT=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,d$=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,f$=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,p$=/^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 Wd(r){if(typeof r!="string")throw new Hr(3);var e=a$(r);if(e.match(l$))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(c$)){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(u$))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(h$)){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=NT.exec(e);if(s)return{red:parseInt(""+s[1],10),green:parseInt(""+s[2],10),blue:parseInt(""+s[3],10)};var o=d$.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=f$.exec(e);if(a){var c=parseInt(""+a[1],10),u=parseInt(""+a[2],10)/100,d=parseInt(""+a[3],10)/100,p="rgb("+$v(c,u,d)+")",m=NT.exec(p);if(!m)throw new Hr(4,e,p);return{red:parseInt(""+m[1],10),green:parseInt(""+m[2],10),blue:parseInt(""+m[3],10)}}var y=p$.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("+$v(M,T,G)+")",I=NT.exec(z);if(!I)throw new Hr(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 Hr(5)}function m$(r){var e=r.red/255,t=r.green/255,n=r.blue/255,s=Math.max(e,t,n),o=Math.min(e,t,n),a=(s+o)/2;if(s===o)return r.alpha!==void 0?{hue:0,saturation:0,lightness:a,alpha:r.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,r.alpha!==void 0?{hue:c,saturation:d,lightness:a,alpha:r.alpha}:{hue:c,saturation:d,lightness:a}}function Wh(r){return m$(Wd(r))}var g$=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},PT=g$;function Tm(r){var e=r.toString(16);return e.length===1?"0"+e:e}function IT(r){return Tm(Math.round(r*255))}function y$(r,e,t){return PT("#"+IT(r)+IT(e)+IT(t))}function kb(r,e,t){return $v(r,e,t,y$)}function mL(r,e,t){if(typeof r=="number"&&typeof e=="number"&&typeof t=="number")return kb(r,e,t);if(typeof r=="object"&&e===void 0&&t===void 0)return kb(r.hue,r.saturation,r.lightness);throw new Hr(1)}function gL(r,e,t,n){if(typeof r=="number"&&typeof e=="number"&&typeof t=="number"&&typeof n=="number")return n>=1?kb(r,e,t):"rgba("+$v(r,e,t)+","+n+")";if(typeof r=="object"&&e===void 0&&t===void 0&&n===void 0)return r.alpha>=1?kb(r.hue,r.saturation,r.lightness):"rgba("+$v(r.hue,r.saturation,r.lightness)+","+r.alpha+")";throw new Hr(2)}function zb(r,e,t){if(typeof r=="number"&&typeof e=="number"&&typeof t=="number")return PT("#"+Tm(r)+Tm(e)+Tm(t));if(typeof r=="object"&&e===void 0&&t===void 0)return PT("#"+Tm(r.red)+Tm(r.green)+Tm(r.blue));throw new Hr(6)}function jv(r,e,t,n){if(typeof r=="string"&&typeof e=="number"){var s=Wd(r);return"rgba("+s.red+","+s.green+","+s.blue+","+e+")"}else{if(typeof r=="number"&&typeof e=="number"&&typeof t=="number"&&typeof n=="number")return n>=1?zb(r,e,t):"rgba("+r+","+e+","+t+","+n+")";if(typeof r=="object"&&e===void 0&&t===void 0&&n===void 0)return r.alpha>=1?zb(r.red,r.green,r.blue):"rgba("+r.red+","+r.green+","+r.blue+","+r.alpha+")"}throw new Hr(7)}var v$=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&(typeof e.alpha!="number"||typeof e.alpha=="undefined")},x$=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&typeof e.alpha=="number"},_$=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&(typeof e.alpha!="number"||typeof e.alpha=="undefined")},b$=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&typeof e.alpha=="number"};function sh(r){if(typeof r!="object")throw new Hr(8);if(x$(r))return jv(r);if(v$(r))return zb(r);if(b$(r))return gL(r);if(_$(r))return mL(r);throw new Hr(8)}function yL(r,e,t){return function(){var s=t.concat(Array.prototype.slice.call(arguments));return s.length>=e?r.apply(this,s):yL(r,e,s)}}function Jc(r){return yL(r,r.length,[])}function w$(r,e){if(e==="transparent")return e;var t=Wh(e);return sh(Rc({},t,{hue:t.hue+parseFloat(r)}))}var XZ=Jc(w$),qZ=null;function YZ(r){if(r==="transparent")return r;var e=Wh(r);return sh(_extends({},e,{hue:(e.hue+180)%360}))}function f0(r,e,t){return Math.max(r,Math.min(e,t))}function M$(r,e){if(e==="transparent")return e;var t=Wh(e);return sh(Rc({},t,{lightness:f0(0,1,t.lightness-parseFloat(r))}))}var ZZ=Jc(M$),KZ=null;function S$(r,e){if(e==="transparent")return e;var t=Wh(e);return sh(Rc({},t,{saturation:f0(0,1,t.saturation-parseFloat(r))}))}var JZ=Jc(S$),QZ=null;function LT(r){if(r==="transparent")return 0;var e=Wd(r),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 vL(r,e){var t=LT(r),n=LT(e);return parseFloat((t>n?(t+.05)/(n+.05):(n+.05)/(t+.05)).toFixed(2))}function eK(r){return r==="transparent"?r:sh(_extends({},Wh(r),{saturation:0}))}function tK(r){if(typeof r=="object"&&typeof r.hue=="number"&&typeof r.saturation=="number"&&typeof r.lightness=="number")return r.alpha&&typeof r.alpha=="number"?gL({hue:r.hue,saturation:r.saturation,lightness:r.lightness,alpha:r.alpha}):mL({hue:r.hue,saturation:r.saturation,lightness:r.lightness});throw new Hr(45)}function nK(r){if(r==="transparent")return r;var e=Wd(r);return sh(_extends({},e,{red:255-e.red,green:255-e.green,blue:255-e.blue}))}function T$(r,e){if(e==="transparent")return e;var t=Wh(e);return sh(Rc({},t,{lightness:f0(0,1,t.lightness+parseFloat(r))}))}var iK=Jc(T$),rK=null;function sK(r,e){var t=vL(r,e);return{AA:t>=4.5,AALarge:t>=3,AAA:t>=7,AAALarge:t>=4.5}}function E$(r,e,t){if(e==="transparent")return t;if(t==="transparent")return e;if(r===0)return t;var n=Wd(e),s=Rc({},n,{alpha:typeof n.alpha=="number"?n.alpha:1}),o=Wd(t),a=Rc({},o,{alpha:typeof o.alpha=="number"?o.alpha:1}),c=s.alpha-a.alpha,u=parseFloat(r)*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(r)+a.alpha*(1-parseFloat(r))};return jv(M)}var A$=Jc(E$),xL=A$;function C$(r,e){if(e==="transparent")return e;var t=Wd(e),n=typeof t.alpha=="number"?t.alpha:1,s=Rc({},t,{alpha:f0(0,1,(n*100+parseFloat(r)*100)/100)});return jv(s)}var R$=Jc(C$),N$=R$,_L="#000",bL="#fff";function oK(r,e,t,n){e===void 0&&(e=_L),t===void 0&&(t=bL),n===void 0&&(n=!0);var s=LT(r)>.179,o=s?e:t;return!n||vL(r,o)>=4.5?o:s?_L:bL}function aK(r){if(typeof r=="object"&&typeof r.red=="number"&&typeof r.green=="number"&&typeof r.blue=="number")return typeof r.alpha=="number"?jv({red:r.red,green:r.green,blue:r.blue,alpha:r.alpha}):zb({red:r.red,green:r.green,blue:r.blue});throw new Hr(46)}function P$(r,e){if(e==="transparent")return e;var t=Wh(e);return sh(Rc({},t,{saturation:f0(0,1,t.saturation+parseFloat(r))}))}var lK=Jc(P$),cK=null;function I$(r,e){return e==="transparent"?e:sh(Rc({},Wh(e),{hue:parseFloat(r)}))}var uK=Jc(I$),hK=null;function L$(r,e){return e==="transparent"?e:sh(Rc({},Wh(e),{lightness:parseFloat(r)}))}var dK=Jc(L$),fK=null;function D$(r,e){return e==="transparent"?e:sh(Rc({},Wh(e),{saturation:parseFloat(r)}))}var pK=Jc(D$),mK=null;function O$(r,e){return e==="transparent"?e:xL(parseFloat(r),"rgb(0, 0, 0)",e)}var gK=Jc(O$),yK=null;function F$(r,e){return e==="transparent"?e:xL(parseFloat(r),"rgb(255, 255, 255)",e)}var vK=Jc(F$),xK=null;function B$(r,e){if(e==="transparent")return e;var t=Wd(e),n=typeof t.alpha=="number"?t.alpha:1,s=Rc({},t,{alpha:f0(0,1,+(n*100-parseFloat(r)*100).toFixed(2)/100)});return jv(s)}var _K=Jc(B$),bK=null;function wK(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];var n=Array.isArray(e[0]);if(!n&&e.length>8)throw new Hr(64);var s=e.map(function(o){if(n&&!Array.isArray(o)||!n&&Array.isArray(o))throw new Hr(65);if(Array.isArray(o)&&o.length>8)throw new Hr(66);return Array.isArray(o)?o.join(" "):o}).join(", ");return{animation:s}}function MK(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];return{backgroundImage:e.join(", ")}}function SK(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];return{background:e.join(", ")}}var U$=null;function TK(r){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 r=="string"&&U$.indexOf(r)>=0){var s;return s={},s["border"+Hv(r)+"Width"]=t[0],s["border"+Hv(r)+"Style"]=t[1],s["border"+Hv(r)+"Color"]=t[2],s}else return t.unshift(r),{borderWidth:t[0],borderStyle:t[1],borderColor:t[2]}}function EK(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];return Sm.apply(void 0,["borderColor"].concat(e))}function AK(r,e){var t=Hv(r);if(!e&&e!==0)throw new Hr(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 Hr(63)}function CK(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];return Sm.apply(void 0,["borderStyle"].concat(e))}function RK(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];return Sm.apply(void 0,["borderWidth"].concat(e))}function wL(r,e){var t=e?":"+e:"";return r(t)}function ML(r,e,t){if(!e)throw new Hr(67);if(r.length===0)return wL(e,null);for(var n=[],s=0;s<r.length;s+=1){if(t&&t.indexOf(r[s])<0)throw new Hr(68);n.push(wL(e,r[s]))}return n=n.join(","),n}var k$=null;function z$(r){return"button"+r+`,
input[type="button"]`+r+`,
input[type="reset"]`+r+`,
input[type="submit"]`+r}function NK(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];return ML(e,z$,k$)}function PK(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];return Sm.apply(void 0,["margin"].concat(e))}function IK(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];return Sm.apply(void 0,["padding"].concat(e))}var V$=null;function LK(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];return V$.indexOf(r)>=0&&r?_extends({},Sm.apply(void 0,[""].concat(t)),{position:r}):Sm.apply(void 0,["",r].concat(t))}function DK(r,e){return e===void 0&&(e=r),{height:r,width:e}}var G$=null;function W$(r){return'input[type="color"]'+r+`,
input[type="date"]`+r+`,
input[type="datetime"]`+r+`,
input[type="datetime-local"]`+r+`,
input[type="email"]`+r+`,
input[type="month"]`+r+`,
input[type="number"]`+r+`,
input[type="password"]`+r+`,
input[type="search"]`+r+`,
input[type="tel"]`+r+`,
input[type="text"]`+r+`,
input[type="time"]`+r+`,
input[type="url"]`+r+`,
input[type="week"]`+r+`,
input:not([type])`+r+`,
textarea`+r}function OK(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];return ML(e,W$,G$)}function FK(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];if(Array.isArray(e[0])&&e.length===2){var n=e[1];if(typeof n!="string")throw new Hr(61);var s=e[0].map(function(o){return o+" "+n}).join(", ");return{transition:s}}else return{transition:e.join(", ")}}var Zf=Object.freeze({Linear:Object.freeze({None:function(r){return r},In:function(r){return r},Out:function(r){return r},InOut:function(r){return r}}),Quadratic:Object.freeze({In:function(r){return r*r},Out:function(r){return r*(2-r)},InOut:function(r){return(r*=2)<1?.5*r*r:-.5*(--r*(r-2)-1)}}),Cubic:Object.freeze({In:function(r){return r*r*r},Out:function(r){return--r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r:.5*((r-=2)*r*r+2)}}),Quartic:Object.freeze({In:function(r){return r*r*r*r},Out:function(r){return 1- --r*r*r*r},InOut:function(r){return(r*=2)<1?.5*r*r*r*r:-.5*((r-=2)*r*r*r-2)}}),Quintic:Object.freeze({In:function(r){return r*r*r*r*r},Out:function(r){return--r*r*r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r*r*r:.5*((r-=2)*r*r*r*r+2)}}),Sinusoidal:Object.freeze({In:function(r){return 1-Math.sin((1-r)*Math.PI/2)},Out:function(r){return Math.sin(r*Math.PI/2)},InOut:function(r){return .5*(1-Math.sin(Math.PI*(.5-r)))}}),Exponential:Object.freeze({In:function(r){return r===0?0:Math.pow(1024,r-1)},Out:function(r){return r===1?1:1-Math.pow(2,-10*r)},InOut:function(r){return r===0?0:r===1?1:(r*=2)<1?.5*Math.pow(1024,r-1):.5*(-Math.pow(2,-10*(r-1))+2)}}),Circular:Object.freeze({In:function(r){return 1-Math.sqrt(1-r*r)},Out:function(r){return Math.sqrt(1- --r*r)},InOut:function(r){return(r*=2)<1?-.5*(Math.sqrt(1-r*r)-1):.5*(Math.sqrt(1-(r-=2)*r)+1)}}),Elastic:Object.freeze({In:function(r){return r===0?0:r===1?1:-Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI)},Out:function(r){return r===0?0:r===1?1:Math.pow(2,-10*r)*Math.sin((r-.1)*5*Math.PI)+1},InOut:function(r){return r===0?0:r===1?1:(r*=2,r<1?-.5*Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI):.5*Math.pow(2,-10*(r-1))*Math.sin((r-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(r){var e=1.70158;return r===1?1:r*r*((e+1)*r-e)},Out:function(r){var e=1.70158;return r===0?0:--r*r*((e+1)*r+e)+1},InOut:function(r){var e=2.5949095;return(r*=2)<1?.5*(r*r*((e+1)*r-e)):.5*((r-=2)*r*((e+1)*r+e)+2)}}),Bounce:Object.freeze({In:function(r){return 1-Zf.Bounce.Out(1-r)},Out:function(r){return r<1/2.75?7.5625*r*r:r<2/2.75?7.5625*(r-=1.5/2.75)*r+.75:r<2.5/2.75?7.5625*(r-=2.25/2.75)*r+.9375:7.5625*(r-=2.625/2.75)*r+.984375},InOut:function(r){return r<.5?Zf.Bounce.In(r*2)*.5:Zf.Bounce.Out(r*2-1)*.5+.5}}),generatePow:function(r){return r===void 0&&(r=4),r=r<Number.EPSILON?Number.EPSILON:r,r=r>1e4?1e4:r,{In:function(e){return Math.pow(e,r)},Out:function(e){return 1-Math.pow(1-e,r)},InOut:function(e){return e<.5?Math.pow(e*2,r)/2:(1-Math.pow(2-e*2,r))/2+.5}}}}),p0=function(){return performance.now()},DT=function(){function r(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._tweens={},this._tweensAddedDuringUpdate={},this.add.apply(this,e)}return r.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},r.prototype.removeAll=function(){this._tweens={}},r.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}},r.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()]}},r.prototype.allStopped=function(){return this.getAll().every(function(e){return!e.isPlaying()})},r.prototype.update=function(e,t){e===void 0&&(e=p0()),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)}},r}(),Em={Linear:function(r,e){var t=r.length-1,n=t*e,s=Math.floor(n),o=Em.Utils.Linear;return e<0?o(r[0],r[1],n):e>1?o(r[t],r[t-1],t-n):o(r[s],r[s+1>t?t:s+1],n-s)},Bezier:function(r,e){for(var t=0,n=r.length-1,s=Math.pow,o=Em.Utils.Bernstein,a=0;a<=n;a++)t+=s(1-e,n-a)*s(e,a)*r[a]*o(n,a);return t},CatmullRom:function(r,e){var t=r.length-1,n=t*e,s=Math.floor(n),o=Em.Utils.CatmullRom;return r[0]===r[t]?(e<0&&(s=Math.floor(n=t*(1+e))),o(r[(s-1+t)%t],r[s],r[(s+1)%t],r[(s+2)%t],n-s)):e<0?r[0]-(o(r[0],r[0],r[1],r[1],-n)-r[0]):e>1?r[t]-(o(r[t],r[t],r[t-1],r[t-1],n-t)-r[t]):o(r[s?s-1:0],r[s],r[t<s+1?t:s+1],r[t<s+2?t:s+2],n-s)},Utils:{Linear:function(r,e,t){return(e-r)*t+r},Bernstein:function(r,e){var t=Em.Utils.Factorial;return t(r)/t(e)/t(r-e)},Factorial:function(){var r=[1];return function(e){var t=1;if(r[e])return r[e];for(var n=e;n>1;n--)t*=n;return r[e]=t,t}}(),CatmullRom:function(r,e,t,n,s){var o=(t-r)*.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}}},OT=function(){function r(){}return r.nextId=function(){return r._nextId++},r._nextId=0,r}(),FT=new DT,BT=function(){function r(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=Zf.Linear.None,this._interpolationFunction=Em.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=OT.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=FT,FT.add(this))}return r.prototype.getId=function(){return this._id},r.prototype.isPlaying=function(){return this._isPlaying},r.prototype.isPaused=function(){return this._isPaused},r.prototype.getDuration=function(){return this._duration},r.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},r.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},r.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},r.prototype.start=function(e,t){if(e===void 0&&(e=p0()),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},r.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},r.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 ee={};for(var I in m)ee[I]=m[I];n[a]=m=ee}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}}},r.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},r.prototype.end=function(){return this._goToEnd=!0,this.update(this._startTime+this._duration),this},r.prototype.pause=function(e){return e===void 0&&(e=p0()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this)},r.prototype.resume=function(e){return e===void 0&&(e=p0()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this)},r.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},r.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)},r.prototype.remove=function(){var e;return(e=this._group)===null||e===void 0||e.remove(this),this},r.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},r.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},r.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},r.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},r.prototype.easing=function(e){return e===void 0&&(e=Zf.Linear.None),this._easingFunction=e,this},r.prototype.interpolation=function(e){return e===void 0&&(e=Em.Linear),this._interpolationFunction=e,this},r.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},r.prototype.onStart=function(e){return this._onStartCallback=e,this},r.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},r.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},r.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},r.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},r.prototype.onStop=function(e){return this._onStopCallback=e,this},r.prototype.update=function(e,t){var n=this,s;if(e===void 0&&(e=p0()),t===void 0&&(t=r.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},r.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))}},r.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},r.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},r.autoStartOnUpdate=!1,r}(),H$="25.0.0",$$=OT.nextId,Hh=FT,j$=Hh.getAll.bind(Hh),X$=Hh.removeAll.bind(Hh),q$=Hh.add.bind(Hh),Y$=Hh.remove.bind(Hh),Z$=Hh.update.bind(Hh),BK={Easing:Zf,Group:DT,Interpolation:Em,now:p0,Sequence:OT,nextId:$$,Tween:BT,VERSION:H$,getAll:j$,removeAll:X$,add:q$,remove:Y$,update:Z$};function K$(){}function SL(r){return r==null?K$:function(){return this.querySelector(r)}}function J$(r){typeof r!="function"&&(r=SL(r));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=r.call(u,u.__data__,p,o))&&("__data__"in u&&(d.__data__=u.__data__),c[p]=d);return new Qc(n,this._parents)}function Q$(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function ej(){return[]}function tj(r){return r==null?ej:function(){return this.querySelectorAll(r)}}function nj(r){return function(){return Q$(r.apply(this,arguments))}}function ij(r){typeof r=="function"?r=nj(r):r=tj(r);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(r.call(u,u.__data__,d,a)),s.push(u));return new Qc(n,s)}function rj(r){return function(){return this.matches(r)}}function TL(r){return function(e){return e.matches(r)}}var sj=Array.prototype.find;function oj(r){return function(){return sj.call(this.children,r)}}function aj(){return this.firstElementChild}function lj(r){return this.select(r==null?aj:oj(typeof r=="function"?r:TL(r)))}var cj=Array.prototype.filter;function uj(){return Array.from(this.children)}function hj(r){return function(){return cj.call(this.children,r)}}function dj(r){return this.selectAll(r==null?uj:hj(typeof r=="function"?r:TL(r)))}function fj(r){typeof r!="function"&&(r=rj(r));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])&&r.call(u,u.__data__,d,o)&&c.push(u);return new Qc(n,this._parents)}function EL(r){return new Array(r.length)}function pj(){return new Qc(this._enter||this._groups.map(EL),this._parents)}function Vb(r,e){this.ownerDocument=r.ownerDocument,this.namespaceURI=r.namespaceURI,this._next=null,this._parent=r,this.__data__=e}Vb.prototype={constructor:Vb,appendChild:function(r){return this._parent.insertBefore(r,this._next)},insertBefore:function(r,e){return this._parent.insertBefore(r,e)},querySelector:function(r){return this._parent.querySelector(r)},querySelectorAll:function(r){return this._parent.querySelectorAll(r)}};function mj(r){return function(){return r}}function gj(r,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 Vb(r,o[a]);for(;a<u;++a)(c=e[a])&&(s[a]=c)}function yj(r,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(r,o[c],c,o)+"",(u=d.get(M))?(n[c]=u,u.__data__=o[c],d.delete(M)):t[c]=new Vb(r,o[c]);for(c=0;c<p;++c)(u=e[c])&&d.get(y[c])===u&&(s[c]=u)}function vj(r){return r.__data__}function xj(r,e){if(!arguments.length)return Array.from(this,vj);var t=e?yj:gj,n=this._parents,s=this._groups;typeof r!="function"&&(r=mj(r));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=_j(r.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 ee=0,Q=0,oe,_e;ee<T;++ee)if(oe=G[ee]){for(ee>=Q&&(Q=ee+1);!(_e=z[Q])&&++Q<T;);oe._next=_e||null}}return a=new Qc(a,n),a._enter=c,a._exit=u,a}function _j(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function bj(){return new Qc(this._exit||this._groups.map(EL),this._parents)}function wj(r,e,t){var n=this.enter(),s=this,o=this.exit();return typeof r=="function"?(n=r(n),n&&(n=n.selection())):n=n.append(r+""),e!=null&&(s=e(s),s&&(s=s.selection())),t==null?o.remove():t(o),n&&s?n.merge(s).order():s}function Mj(r){for(var e=r.selection?r.selection():r,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 Qc(c,this._parents)}function Sj(){for(var r=this._groups,e=-1,t=r.length;++e<t;)for(var n=r[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 Tj(r){r||(r=Ej);function e(m,y){return m&&y?r(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 Qc(s,this._parents).order()}function Ej(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function Aj(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function Cj(){return Array.from(this)}function Rj(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,o=n.length;s<o;++s){var a=n[s];if(a)return a}return null}function Nj(){let r=0;for(const e of this)++r;return r}function Pj(){return!this.node()}function Ij(r){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])&&r.call(c,c.__data__,o,s);return this}var UT="http://www.w3.org/1999/xhtml",AL={svg:"http://www.w3.org/2000/svg",xhtml:UT,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function CL(r){var e=r+="",t=e.indexOf(":");return t>=0&&(e=r.slice(0,t))!=="xmlns"&&(r=r.slice(t+1)),AL.hasOwnProperty(e)?{space:AL[e],local:r}:r}function Lj(r){return function(){this.removeAttribute(r)}}function Dj(r){return function(){this.removeAttributeNS(r.space,r.local)}}function Oj(r,e){return function(){this.setAttribute(r,e)}}function Fj(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function Bj(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function Uj(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(r.space,r.local):this.setAttributeNS(r.space,r.local,t)}}function kj(r,e){var t=CL(r);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?Dj:Lj:typeof e=="function"?t.local?Uj:Bj:t.local?Fj:Oj)(t,e))}function RL(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function zj(r){return function(){this.style.removeProperty(r)}}function Vj(r,e,t){return function(){this.style.setProperty(r,e,t)}}function Gj(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function Wj(r,e,t){return arguments.length>1?this.each((e==null?zj:typeof e=="function"?Gj:Vj)(r,e,t==null?"":t)):Hj(this.node(),r)}function Hj(r,e){return r.style.getPropertyValue(e)||RL(r).getComputedStyle(r,null).getPropertyValue(e)}function $j(r){return function(){delete this[r]}}function jj(r,e){return function(){this[r]=e}}function Xj(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function qj(r,e){return arguments.length>1?this.each((e==null?$j:typeof e=="function"?Xj:jj)(r,e)):this.node()[r]}function NL(r){return r.trim().split(/^|\s+/)}function kT(r){return r.classList||new PL(r)}function PL(r){this._node=r,this._names=NL(r.getAttribute("class")||"")}PL.prototype={add:function(r){var e=this._names.indexOf(r);e<0&&(this._names.push(r),this._node.setAttribute("class",this._names.join(" ")))},remove:function(r){var e=this._names.indexOf(r);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(r){return this._names.indexOf(r)>=0}};function IL(r,e){for(var t=kT(r),n=-1,s=e.length;++n<s;)t.add(e[n])}function LL(r,e){for(var t=kT(r),n=-1,s=e.length;++n<s;)t.remove(e[n])}function Yj(r){return function(){IL(this,r)}}function Zj(r){return function(){LL(this,r)}}function Kj(r,e){return function(){(e.apply(this,arguments)?IL:LL)(this,r)}}function Jj(r,e){var t=NL(r+"");if(arguments.length<2){for(var n=kT(this.node()),s=-1,o=t.length;++s<o;)if(!n.contains(t[s]))return!1;return!0}return this.each((typeof e=="function"?Kj:e?Yj:Zj)(t,e))}function Qj(){this.textContent=""}function eX(r){return function(){this.textContent=r}}function tX(r){return function(){var e=r.apply(this,arguments);this.textContent=e==null?"":e}}function nX(r){return arguments.length?this.each(r==null?Qj:(typeof r=="function"?tX:eX)(r)):this.node().textContent}function iX(){this.innerHTML=""}function rX(r){return function(){this.innerHTML=r}}function sX(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e==null?"":e}}function oX(r){return arguments.length?this.each(r==null?iX:(typeof r=="function"?sX:rX)(r)):this.node().innerHTML}function aX(){this.nextSibling&&this.parentNode.appendChild(this)}function lX(){return this.each(aX)}function cX(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function uX(){return this.each(cX)}function hX(r){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===UT&&e.documentElement.namespaceURI===UT?e.createElement(r):e.createElementNS(t,r)}}function dX(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function DL(r){var e=CL(r);return(e.local?dX:hX)(e)}function fX(r){var e=typeof r=="function"?r:DL(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function pX(){return null}function mX(r,e){var t=typeof r=="function"?r:DL(r),n=e==null?pX:typeof e=="function"?e:SL(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function gX(){var r=this.parentNode;r&&r.removeChild(this)}function yX(){return this.each(gX)}function vX(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function xX(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function _X(r){return this.select(r?xX:vX)}function bX(r){return arguments.length?this.property("__data__",r):this.node().__data__}function wX(r){return function(e){r.call(this,e,this.__data__)}}function MX(r){return r.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 SX(r){return function(){var e=this.__on;if(e){for(var t=0,n=-1,s=e.length,o;t<s;++t)o=e[t],(!r.type||o.type===r.type)&&o.name===r.name?this.removeEventListener(o.type,o.listener,o.options):e[++n]=o;++n?e.length=n:delete this.__on}}}function TX(r,e,t){return function(){var n=this.__on,s,o=wX(e);if(n){for(var a=0,c=n.length;a<c;++a)if((s=n[a]).type===r.type&&s.name===r.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(r.type,o,t),s={type:r.type,name:r.name,value:e,listener:o,options:t},n?n.push(s):this.__on=[s]}}function EX(r,e,t){var n=MX(r+""),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?TX:SX,s=0;s<o;++s)this.each(c(n[s],e,t));return this}function OL(r,e,t){var n=RL(r),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)),r.dispatchEvent(s)}function AX(r,e){return function(){return OL(this,r,e)}}function CX(r,e){return function(){return OL(this,r,e.apply(this,arguments))}}function RX(r,e){return this.each((typeof e=="function"?CX:AX)(r,e))}function*NX(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,o=n.length,a;s<o;++s)(a=n[s])&&(yield a)}var FL=[null];function Qc(r,e){this._groups=r,this._parents=e}function PX(){return new Qc([[document.documentElement]],FL)}function IX(){return this}Qc.prototype=PX.prototype={constructor:Qc,select:J$,selectAll:ij,selectChild:lj,selectChildren:dj,filter:fj,data:xj,enter:pj,exit:bj,join:wj,merge:Mj,selection:IX,order:Sj,sort:Tj,call:Aj,nodes:Cj,node:Rj,size:Nj,empty:Pj,each:Ij,attr:kj,style:Wj,property:qj,classed:Jj,text:nX,html:oX,raise:lX,lower:uX,append:fX,insert:mX,remove:yX,clone:_X,datum:bX,on:EX,dispatch:RX,[Symbol.iterator]:NX};var UK=null;function LX(r){return typeof r=="string"?new Qc([[document.querySelector(r)]],[document.documentElement]):new Qc([[r]],FL)}function DX(r){let e;for(;e=r.sourceEvent;)r=e;return r}function OX(r,e){if(r=DX(r),e===void 0&&(e=r.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var n=t.createSVGPoint();return n.x=r.clientX,n.y=r.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var s=e.getBoundingClientRect();return[r.clientX-s.left-e.clientLeft,r.clientY-s.top-e.clientTop]}}return[r.pageX,r.pageY]}var Xv,sa,BL,UL,Am,kL,zL,VL,GL,zT,VT,GT,WL,qv={},HL=[],FX=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Yv=Array.isArray;function $h(r,e){for(var t in e)r[t]=e[t];return r}function WT(r){r&&r.parentNode&&r.parentNode.removeChild(r)}function BX(r,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?Xv.call(arguments,2):t),typeof r=="function"&&r.defaultProps!=null)for(o in r.defaultProps)a[o]===void 0&&(a[o]=r.defaultProps[o]);return Zv(r,a,n,s,null)}function Zv(r,e,t,n,s){var o={type:r,props:e,key:t,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s==null?++BL:s,__i:-1,__u:0};return s==null&&sa.vnode!=null&&sa.vnode(o),o}function kK(){return{current:null}}function Gb(r){return r.children}function Wb(r,e){this.props=r,this.context=e}function m0(r,e){if(e==null)return r.__?m0(r.__,r.__i+1):null;for(var t;e<r.__k.length;e++)if((t=r.__k[e])!=null&&t.__e!=null)return t.__e;return typeof r.type=="function"?m0(r):null}function $L(r){var e,t;if((r=r.__)!=null&&r.__c!=null){for(r.__e=r.__c.base=null,e=0;e<r.__k.length;e++)if((t=r.__k[e])!=null&&t.__e!=null){r.__e=r.__c.base=t.__e;break}return $L(r)}}function HT(r){(!r.__d&&(r.__d=!0)&&Am.push(r)&&!Hb.__r++||kL!=sa.debounceRendering)&&((kL=sa.debounceRendering)||zL)(Hb)}function Hb(){for(var r,e,t,n,s,o,a,c=1;Am.length;)Am.length>c&&Am.sort(VL),r=Am.shift(),c=Am.length,r.__d&&(t=void 0,n=void 0,s=(n=(e=r).__v).__e,o=[],a=[],e.__P&&((t=$h({},n)).__v=n.__v+1,sa.vnode&&sa.vnode(t),$T(e.__P,t,n,e.__n,e.__P.namespaceURI,32&n.__u?[s]:null,o,s==null?m0(n):s,!!(32&n.__u),a),t.__v=n.__v,t.__.__k[t.__i]=t,ZL(o,t,a),n.__e=n.__=null,t.__e!=s&&$L(t)));Hb.__r=0}function jL(r,e,t,n,s,o,a,c,u,d,p){var m,y,M,T,G,z,I,ee=n&&n.__k||HL,Q=e.length;for(u=UX(t,e,ee,u,Q),m=0;m<Q;m++)(M=t.__k[m])!=null&&(y=M.__i==-1?qv:ee[M.__i]||qv,M.__i=m,z=$T(r,M,y,s,o,a,c,u,d,p),T=M.__e,M.ref&&y.ref!=M.ref&&(y.ref&&XT(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=XL(M,u,r,I):typeof M.type=="function"&&z!==void 0?u=z:T&&(u=T.nextSibling),M.__u&=-7);return t.__e=G,u}function UX(r,e,t,n,s){var o,a,c,u,d,p=t.length,m=p,y=0;for(r.__k=new Array(s),o=0;o<s;o++)(a=e[o])!=null&&typeof a!="boolean"&&typeof a!="function"?(u=o+y,(a=r.__k[o]=typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?Zv(null,a,null,null,null):Yv(a)?Zv(Gb,{children:a},null,null,null):a.constructor==null&&a.__b>0?Zv(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=r,a.__b=r.__b+1,c=null,(d=a.__i=zX(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))):r.__k[o]=null;if(m)for(o=0;o<p;o++)(c=t[o])!=null&&!(2&c.__u)&&(c.__e==n&&(n=m0(c)),JL(c,c));return n}function XL(r,e,t,n){var s,o;if(typeof r.type=="function"){for(s=r.__k,o=0;s&&o<s.length;o++)s[o]&&(s[o].__=r,e=XL(s[o],e,t,n));return e}r.__e!=e&&(n&&(e&&r.type&&!e.parentNode&&(e=m0(r)),t.insertBefore(r.__e,e||null)),e=r.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function kX(r,e){return e=e||[],r==null||typeof r=="boolean"||(Yv(r)?r.some(function(t){kX(t,e)}):e.push(r)),e}function zX(r,e,t,n){var s,o,a,c=r.key,u=r.type,d=e[t],p=d!=null&&(2&d.__u)==0;if(d===null&&r.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 qL(r,e,t){e[0]=="-"?r.setProperty(e,t==null?"":t):r[e]=t==null?"":typeof t!="number"||FX.test(e)?t:t+"px"}function $b(r,e,t,n,s){var o,a;e:if(e=="style")if(typeof t=="string")r.style.cssText=t;else{if(typeof n=="string"&&(r.style.cssText=n=""),n)for(e in n)t&&e in t||qL(r.style,e,"");if(t)for(e in t)n&&t[e]==n[e]||qL(r.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(GL,"$1")),a=e.toLowerCase(),e=a in r||e=="onFocusOut"||e=="onFocusIn"?a.slice(2):e.slice(2),r.l||(r.l={}),r.l[e+o]=t,t?n?t.u=n.u:(t.u=zT,r.addEventListener(e,o?GT:VT,o)):r.removeEventListener(e,o?GT:VT,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 r)try{r[e]=t==null?"":t;break e}catch(c){}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?r.removeAttribute(e):r.setAttribute(e,e=="popover"&&t==1?"":t))}}function YL(r){return function(e){if(this.l){var t=this.l[e.type+r];if(e.t==null)e.t=zT++;else if(e.t<t.u)return;return t(sa.event?sa.event(e):e)}}}function $T(r,e,t,n,s,o,a,c,u,d){var p,m,y,M,T,G,z,I,ee,Q,oe,_e,ve,Oe,He,Ce,Be,ft=e.type;if(e.constructor!=null)return null;128&t.__u&&(u=!!(32&t.__u),o=[c=e.__e=t.__e]),(p=sa.__b)&&p(e);e:if(typeof ft=="function")try{if(I=e.props,ee="prototype"in ft&&ft.prototype.render,Q=(p=ft.contextType)&&n[p.__c],oe=p?Q?Q.props.value:p.__:n,t.__c?z=(m=e.__c=t.__c).__=m.__E:(ee?e.__c=m=new ft(I,oe):(e.__c=m=new Wb(I,oe),m.constructor=ft,m.render=GX),Q&&Q.sub(m),m.props=I,m.state||(m.state={}),m.context=oe,m.__n=n,y=m.__d=!0,m.__h=[],m._sb=[]),ee&&m.__s==null&&(m.__s=m.state),ee&&ft.getDerivedStateFromProps!=null&&(m.__s==m.state&&(m.__s=$h({},m.__s)),$h(m.__s,ft.getDerivedStateFromProps(I,m.__s))),M=m.props,T=m.state,m.__v=e,y)ee&&ft.getDerivedStateFromProps==null&&m.componentWillMount!=null&&m.componentWillMount(),ee&&m.componentDidMount!=null&&m.__h.push(m.componentDidMount);else{if(ee&&ft.getDerivedStateFromProps==null&&I!==M&&m.componentWillReceiveProps!=null&&m.componentWillReceiveProps(I,oe),!m.__e&&m.shouldComponentUpdate!=null&&m.shouldComponentUpdate(I,m.__s,oe)===!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(zt){zt&&(zt.__=e)}),_e=0;_e<m._sb.length;_e++)m.__h.push(m._sb[_e]);m._sb=[],m.__h.length&&a.push(m);break e}m.componentWillUpdate!=null&&m.componentWillUpdate(I,m.__s,oe),ee&&m.componentDidUpdate!=null&&m.__h.push(function(){m.componentDidUpdate(M,T,G)})}if(m.context=oe,m.props=I,m.__P=r,m.__e=!1,ve=sa.__r,Oe=0,ee){for(m.state=m.__s,m.__d=!1,ve&&ve(e),p=m.render(m.props,m.state,m.context),He=0;He<m._sb.length;He++)m.__h.push(m._sb[He]);m._sb=[]}else do m.__d=!1,ve&&ve(e),p=m.render(m.props,m.state,m.context),m.state=m.__s;while(m.__d&&++Oe<25);m.state=m.__s,m.getChildContext!=null&&(n=$h($h({},n),m.getChildContext())),ee&&!y&&m.getSnapshotBeforeUpdate!=null&&(G=m.getSnapshotBeforeUpdate(M,T)),Ce=p,p!=null&&p.type===Gb&&p.key==null&&(Ce=KL(p.props.children)),c=jL(r,Yv(Ce)?Ce:[Ce],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(zt){if(e.__v=null,u||o!=null)if(zt.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(Be=o.length;Be--;)WT(o[Be]);jT(e)}else e.__e=t.__e,e.__k=t.__k,zt.then||jT(e);sa.__e(zt,e,t)}else o==null&&e.__v==t.__v?(e.__k=t.__k,e.__e=t.__e):c=e.__e=VX(t.__e,e,t,n,s,o,a,u,d);return(p=sa.diffed)&&p(e),128&e.__u?void 0:c}function jT(r){r&&r.__c&&(r.__c.__e=!0),r&&r.__k&&r.__k.forEach(jT)}function ZL(r,e,t){for(var n=0;n<t.length;n++)XT(t[n],t[++n],t[++n]);sa.__c&&sa.__c(e,r),r.some(function(s){try{r=s.__h,s.__h=[],r.some(function(o){o.call(s)})}catch(o){sa.__e(o,s.__v)}})}function KL(r){return typeof r!="object"||r==null||r.__b&&r.__b>0?r:Yv(r)?r.map(KL):$h({},r)}function VX(r,e,t,n,s,o,a,c,u){var d,p,m,y,M,T,G,z=t.props,I=e.props,ee=e.type;if(ee=="svg"?s="http://www.w3.org/2000/svg":ee=="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==!!ee&&(ee?M.localName==ee:M.nodeType==3)){r=M,o[d]=null;break}}if(r==null){if(ee==null)return document.createTextNode(I);r=document.createElementNS(s,ee,I.is&&I),c&&(sa.__m&&sa.__m(e,o),c=!1),o=null}if(ee==null)z===I||c&&r.data==I||(r.data=I);else{if(o=o&&Xv.call(r.childNodes),z=t.props||qv,!c&&o!=null)for(z={},d=0;d<r.attributes.length;d++)z[(M=r.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;$b(r,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||$b(r,d,M,z[d],s);if(p)c||m&&(p.__html==m.__html||p.__html==r.innerHTML)||(r.innerHTML=p.__html),e.__k=[];else if(m&&(r.innerHTML=""),jL(e.type=="template"?r.content:r,Yv(y)?y:[y],e,t,n,ee=="foreignObject"?"http://www.w3.org/1999/xhtml":s,o,a,o?o[0]:t.__k&&m0(t,0),c,u),o!=null)for(d=o.length;d--;)WT(o[d]);c||(d="value",ee=="progress"&&T==null?r.removeAttribute("value"):T!=null&&(T!==r[d]||ee=="progress"&&!T||ee=="option"&&T!=z[d])&&$b(r,d,T,z[d],s),d="checked",G!=null&&G!=r[d]&&$b(r,d,G,z[d],s))}return r}function XT(r,e,t){try{if(typeof r=="function"){var n=typeof r.__u=="function";n&&r.__u(),n&&e==null||(r.__u=r(e))}else r.current=e}catch(s){sa.__e(s,t)}}function JL(r,e,t){var n,s;if(sa.unmount&&sa.unmount(r),(n=r.ref)&&(n.current&&n.current!=r.__e||XT(n,null,e)),(n=r.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(o){sa.__e(o,e)}n.base=n.__P=null}if(n=r.__k)for(s=0;s<n.length;s++)n[s]&&JL(n[s],e,t||typeof r.type!="function");t||WT(r.__e),r.__c=r.__=r.__e=void 0}function GX(r,e,t){return this.constructor(r,t)}function QL(r,e,t){var n,s,o,a;e==document&&(e=document.documentElement),sa.__&&sa.__(r,e),s=(n=typeof t=="function")?null:t&&t.__k||e.__k,o=[],a=[],$T(e,r=(!n&&t||e).__k=BX(Gb,null,[r]),s||qv,qv,e.namespaceURI,!n&&t?[t]:s?null:e.firstChild?Xv.call(e.childNodes):null,o,!n&&t?t:s?s.__e:e.firstChild,n,a),ZL(o,r,a)}function WX(r,e){QL(r,e,WX)}function e3(r,e,t){var n,s,o,a,c=$h({},r.props);for(o in r.type&&r.type.defaultProps&&(a=r.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?Xv.call(arguments,2):t),Zv(r.type,c,n||r.key,s||r.ref,null)}function zK(r){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,HT(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"+WL++,e.__=r,e.Provider=e.__l=(e.Consumer=function(t,n){return t.children(n)}).contextType=e,e}Xv=HL.slice,sa={__e:function(r,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(r)),a=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(r,n||{}),a=s.__d),a)return s.__E=s}catch(c){r=c}throw r}},BL=0,UL=function(r){return r!=null&&r.constructor==null},Wb.prototype.setState=function(r,e){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=$h({},this.state),typeof r=="function"&&(r=r($h({},t),this.props)),r&&$h(t,r),r!=null&&this.__v&&(e&&this._sb.push(e),HT(this))},Wb.prototype.forceUpdate=function(r){this.__v&&(this.__e=!0,r&&this.__h.push(r),HT(this))},Wb.prototype.render=Gb,Am=[],zL=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,VL=function(r,e){return r.__v.__b-e.__v.__b},Hb.__r=0,GL=/(PointerCapture)$|Capture$/i,zT=0,VT=YL(!1),GT=YL(!0),WL=0;function t3(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function HX(r){if(Array.isArray(r))return r}function $X(r,e,t){return(e=KX(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function jX(r,e){var t=r==null?null:typeof Symbol!="undefined"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var n,s,o,a,c=[],u=!0,d=!1;try{if(o=(t=t.call(r)).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 XX(){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 n3(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),t.push.apply(t,n)}return t}function qX(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?n3(Object(t),!0).forEach(function(n){$X(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):n3(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function YX(r,e){return HX(r)||jX(r,e)||JX(r,e)||XX()}function ZX(r,e){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function KX(r){var e=ZX(r,"string");return typeof e=="symbol"?e:e+""}function jb(r){"@babel/helpers - typeof";return jb=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},jb(r)}function JX(r,e){if(r){if(typeof r=="string")return t3(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?t3(r,e):void 0}}var qT=function(e){if(jb(e)!=="object")return e;var t=e3(e);if(t.props){var n;t.props=qX({},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(qT):qT(t.props.children))}return t},QX=function(e){return UL(e3(e))},eq=function(e,t){delete t.__k,QL(qT(e),t)};function tq(r,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=r:s.appendChild(document.createTextNode(r))}}var nq=`.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;
}
`;tq(nq);var iq=s_({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&&jb(e)==="object"&&!!e.node&&typeof e.node=="function",c=LX(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=YX(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=OX(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):QX(e.content)?(e.tooltipEl.text(""),eq(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 rq(r,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=r:s.appendChild(document.createTextNode(r))}}var sq=`.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;
}`;rq(sq);function YT(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function oq(r){if(Array.isArray(r))return r}function aq(r){if(Array.isArray(r))return YT(r)}function lq(r,e,t){return(e=mq(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function cq(r){if(typeof Symbol!="undefined"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function uq(r,e){var t=r==null?null:typeof Symbol!="undefined"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var n,s,o,a,c=[],u=!0,d=!1;try{if(o=(t=t.call(r)).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 hq(){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 dq(){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 fq(r,e){return oq(r)||uq(r,e)||i3(r,e)||hq()}function Cm(r){return aq(r)||cq(r)||i3(r)||dq()}function pq(r,e){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function mq(r){var e=pq(r,"string");return typeof e=="symbol"?e:e+""}function i3(r,e){if(r){if(typeof r=="string")return YT(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?YT(r,e):void 0}}var oa=window.THREE?window.THREE:{WebGLRenderer:pk,Scene:$m,PerspectiveCamera:fa,Raycaster:Ty,SRGBColorSpace:co,TextureLoader:hE,Vector2:yn,Vector3:ot,Box3:ha,Color:jn,Mesh:Zs,SphereGeometry:ju,MeshBasicMaterial:Wr,BackSide:K,Clock:Vx},r3=s_({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&&Us(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 BT(u).to(a,s).easing(Zf.Quadratic.Out).onUpdate(p).start()),e.tweenGroup.add(new BT(d).to(c,s/3).easing(Zf.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 oa.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 oa.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 oa.Vector3(0,0,0),c=Math.max.apply(Math,Cm(Object.entries(t).map(function(M){var T=fq(M,2),G=T[0],z=T[1];return Math.max.apply(Math,Cm(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 oa.Box3(new oa.Vector3(0,0,0),new oa.Vector3(0,0,0)),s=e.objects.filter(t);return s.length?(s.forEach(function(o){return n.expandByObject(o)}),Object.assign.apply(Object,Cm(["x","y","z"].map(function(o){return lq({},o,[n.min[o],n.max[o]])})))):null},getScreenCoords:function(e,t,n,s){var o=new oa.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 oa.Vector2(t/e.width*2-1,-(n/e.height)*2+1),a=new oa.Raycaster;return a.setFromCamera(o,e.camera),Object.assign({},a.ray.at(s,new oa.Vector3))},intersectingObjects:function(e,t,n){var s=new oa.Vector2(t/e.width*2-1,-(n/e.height)*2+1),o=new oa.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 oa.Scene,camera:new oa.PerspectiveCamera,clock:new oa.Clock,tweenGroup:new DT,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 iq(t.container),t.pointerPos=new oa.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(ee){return Math.abs(ee)>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(ee){var Q=ee.getBoundingClientRect(),oe=window.pageXOffset||document.documentElement.scrollLeft,_e=window.pageYOffset||document.documentElement.scrollTop;return{top:Q.top+_e,left:Q.left+oe}}},{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?M9:oa.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 v7(t.renderer),t.postProcessingComposer.addPass(new x7(t.scene,t.camera)),t.controls=new{trackball:A9,orbit:W9,fly:i7}[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(Cm(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 oa.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(Cm(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(Cm(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(Cm(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 oa.SphereGeometry(e.skyRadius)),t.hasOwnProperty("backgroundColor")){var m=Wd(e.backgroundColor).alpha;m===void 0&&(m=1),e.renderer.setClearColor(new oa.Color(N$(1,e.backgroundColor)),m)}t.hasOwnProperty("backgroundImageUrl")&&(e.backgroundImageUrl?new oa.TextureLoader().load(e.backgroundImageUrl,function(M){M.colorSpace=oa.SRGBColorSpace,e.skysphere.material=new oa.MeshBasicMaterial({map:M,side:oa.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 gq(r,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=r:s.appendChild(document.createTextNode(r))}}var yq=`.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;
}`;gq(yq);function ZT(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function vq(r){if(Array.isArray(r))return ZT(r)}function Kv(r,e,t){return(e=wq(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function xq(r){if(typeof Symbol!="undefined"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function _q(){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 s3(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),t.push.apply(t,n)}return t}function Xb(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?s3(Object(t),!0).forEach(function(n){Kv(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):s3(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function qb(r){return vq(r)||xq(r)||Mq(r)||_q()}function bq(r,e){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function wq(r){var e=bq(r,"string");return typeof e=="symbol"?e:e+""}function Mq(r,e){if(r){if(typeof r=="string")return ZT(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ZT(r,e):void 0}}function o3(r,e){var t=new e;return t._destructor&&t._destructor(),{linkProp:function(s){return{default:t[s](),onChange:function(a,c){c[r][s](a)},triggerUpdate:!1}},linkMethod:function(s){return function(o){for(var a=o[r],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 KT=window.THREE?window.THREE:{AmbientLight:Gp,DirectionalLight:wd,REVISION:w},Sq=170,a3=o3("forceGraph",oA),Tq=Object.assign.apply(Object,qb(["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(r){return Kv({},r,a3.linkProp(r))}))),Eq=Object.assign.apply(Object,qb(["refresh","getGraphBbox","d3Force","d3ReheatSimulation","emitParticle"].map(function(r){return Kv({},r,a3.linkMethod(r))}))),Yb=o3("renderObjs",r3),Aq=Object.assign.apply(Object,qb(["width","height","backgroundColor","showNavInfo","enablePointerInteraction"].map(function(r){return Kv({},r,Yb.linkProp(r))}))),Cq=Object.assign.apply(Object,qb(["lights","cameraPosition","postProcessingComposer"].map(function(r){return Kv({},r,Yb.linkMethod(r))})).concat([{graph2ScreenCoords:Yb.linkMethod("getScreenCoords"),screen2GraphCoords:Yb.linkMethod("getSceneCoords")}])),Rq=s_({props:Xb(Xb({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}},Tq),Aq),methods:Xb(Xb({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:[]})}},Eq),Cq),stateInit:function(e){var t=e.controlType,n=e.rendererConfig,s=e.extraRenderers,o=new oA;return{forceGraph:o,renderObjs:r3({controlType:t,rendererConfig:n,extraRenderers:s}).objects([o]).lights([new KT.AmbientLight(13421772,Math.PI),new KT.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)*Sq)}).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=Hd(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=Hd(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(ee){return G["f".concat(ee)]=G[ee]=z[ee]}),t.forceGraph.d3AlphaTarget(.3).resetCountdown(),G.__dragged=!0,t.onNodeDrag(G,I)}}),d.addEventListener("dragend",function(p){var m=Hd(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 ee="f".concat(I);M[ee]===void 0&&delete y[ee]}),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")}})}}),KT.REVISION<155&&(t.renderObjs.renderer().useLegacyLights=!1),t.renderObjs.hoverOrderComparator(function(u,d){var p=Hd(u);if(!p)return 1;var m=Hd(d);if(!m)return-1;var y=function(T){return T.__graphObjType==="node"};return y(m)-y(p)}).tooltipContent(function(u){var d=Hd(u);return d&&Us(t["".concat(d.__graphObjType,"Label")])(d.__data)||""}).hoverDuringDrag(!1).onHover(function(u){var d=Hd(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)&&Us(t.showPointerCursor)(M)?"add":"remove"]("clickable"),t.hoverObj=d}}).clickAfterDrag(!1).onClick(function(u,d){var p=Hd(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=Hd(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 Hd(r){for(var e=r;e&&!e.hasOwnProperty("__graphObjType");)e=e.parent;return e}},94660:function(ae,ne){"use strict";var b={value:()=>{}};function w(){for(var R=0,x=arguments.length,E={},N;R<x;++R){if(!(N=arguments[R]+"")||N in E||/[\s.]/.test(N))throw new Error("illegal type: "+N);E[N]=[]}return new k(E)}function k(R){this._=R}function O(R,x){return R.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(R,x){var E=this._,N=O(R+"",E),L,P=-1,W=N.length;if(arguments.length<2){for(;++P<W;)if((L=(R=N[P]).type)&&(L=A(E[L],R.name)))return L;return}if(x!=null&&typeof x!="function")throw new Error("invalid callback: "+x);for(;++P<W;)if(L=(R=N[P]).type)E[L]=S(E[L],R.name,x);else if(x==null)for(L in E)E[L]=S(E[L],R.name,null);return this},copy:function(){var R={},x=this._;for(var E in x)R[E]=x[E].slice();return new k(R)},call:function(R,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(R))throw new Error("unknown type: "+R);for(P=this._[R],N=0,L=P.length;N<L;++N)P[N].value.apply(x,E)},apply:function(R,x,E){if(!this._.hasOwnProperty(R))throw new Error("unknown type: "+R);for(var N=this._[R],L=0,P=N.length;L<P;++L)N[L].value.apply(x,E)}};function A(R,x){for(var E=0,N=R.length,L;E<N;++E)if((L=R[E]).name===x)return L.value}function S(R,x,E){for(var N=0,L=R.length;N<L;++N)if(R[N].name===x){R[N]=b,R=R.slice(0,N).concat(R.slice(N+1));break}return E!=null&&R.push({name:x,value:E}),R}ne.Z=w},92770:function(ae,ne,b){"use strict";b.d(ne,{Sc:function(){return We},y3:function(){return L}});var w=b(48202);const k=w.XA,O=w.a_,A=w.yQ,S=w.Hs,R=w.Ec,x=w.dx,E=w.LU,N=w.Rm,L=w.y3,P=w.qK,W=w.pb,K=w.j,re=w.sO,ye=w.BZ,ge=w.EK,ce=w.Db,xe=w.Fx,fe=w.tU,Ne=w.Ym,Ae=w.rs,be=w.QR,Ye=w.TB,Ee=w.oH,We=w.Sc,je=w.BN,_t=w.it,It=w.$r,kt=w.QM,Ut=w.AV;var At=(w.y3,w.y3);const at=w.GH,Ot=w.SO,ue=w.uZ,Ue=w.yU,vt=w.F1,Jt=w.re},54375:function(ae,ne,b){"use strict";b.d(ne,{Ud:function(){return re},Yy:function(){return O}});const w=Symbol("Comlink.proxy"),k=Symbol("Comlink.endpoint"),O=Symbol("Comlink.releaseProxy"),A=Symbol("Comlink.finalizer"),S=Symbol("Comlink.thrown"),R=at=>typeof at=="object"&&at!==null||typeof at=="function",x={canHandle:at=>R(at)&&at[w],serialize(at){const{port1:Ot,port2:ue}=new MessageChannel;return P(at,Ot),[ue,[ue]]},deserialize(at){return at.start(),re(at)}},E={canHandle:at=>R(at)&&S in at,serialize({value:at}){let Ot;return at instanceof Error?Ot={isError:!0,value:{message:at.message,name:at.name,stack:at.stack}}:Ot={isError:!1,value:at},[Ot,[]]},deserialize(at){throw at.isError?Object.assign(new Error(at.value.message),at.value):at.value}},N=new Map([["proxy",x],["throw",E]]);function L(at,Ot){for(const ue of at)if(Ot===ue||ue==="*"||ue instanceof RegExp&&ue.test(Ot))return!0;return!1}function P(at,Ot=globalThis,ue=["*"]){Ot.addEventListener("message",function Ue(vt){if(!vt||!vt.data)return;if(!L(ue,vt.origin)){console.warn(`Invalid origin '${vt.origin}' for comlink proxy`);return}const{id:Jt,type:Qe,path:rt}=Object.assign({path:[]},vt.data),bt=(vt.data.argumentList||[]).map(kt);let ze;try{const Ze=rt.slice(0,-1).reduce((Y,de)=>Y[de],at),q=rt.reduce((Y,de)=>Y[de],at);switch(Qe){case"GET":ze=q;break;case"SET":Ze[rt.slice(-1)[0]]=kt(vt.data.value),ze=!0;break;case"APPLY":ze=q.apply(Ze,bt);break;case"CONSTRUCT":{const Y=new q(...bt);ze=je(Y)}break;case"ENDPOINT":{const{port1:Y,port2:de}=new MessageChannel;P(at,de),ze=We(Y,[Y])}break;case"RELEASE":ze=void 0;break;default:return}}catch(Ze){ze={value:Ze,[S]:0}}Promise.resolve(ze).catch(Ze=>({value:Ze,[S]:0})).then(Ze=>{const[q,Y]=It(Ze);Ot.postMessage(Object.assign(Object.assign({},q),{id:Jt}),Y),Qe==="RELEASE"&&(Ot.removeEventListener("message",Ue),K(Ot),A in at&&typeof at[A]=="function"&&at[A]())}).catch(Ze=>{const[q,Y]=It({value:new TypeError("Unserializable return value"),[S]:0});Ot.postMessage(Object.assign(Object.assign({},q),{id:Jt}),Y)})}),Ot.start&&Ot.start()}function W(at){return at.constructor.name==="MessagePort"}function K(at){W(at)&&at.close()}function re(at,Ot){return Ae(at,[],Ot)}function ye(at){if(at)throw new Error("Proxy has been released and is not useable")}function ge(at){return Ut(at,{type:"RELEASE"}).then(()=>{K(at)})}const ce=new WeakMap,xe="FinalizationRegistry"in globalThis&&new FinalizationRegistry(at=>{const Ot=(ce.get(at)||0)-1;ce.set(at,Ot),Ot===0&&ge(at)});function fe(at,Ot){const ue=(ce.get(Ot)||0)+1;ce.set(Ot,ue),xe&&xe.register(at,Ot,at)}function Ne(at){xe&&xe.unregister(at)}function Ae(at,Ot=[],ue=function(){}){let Ue=!1;const vt=new Proxy(ue,{get(Jt,Qe){if(ye(Ue),Qe===O)return()=>{Ne(vt),ge(at),Ue=!0};if(Qe==="then"){if(Ot.length===0)return{then:()=>vt};const rt=Ut(at,{type:"GET",path:Ot.map(bt=>bt.toString())}).then(kt);return rt.then.bind(rt)}return Ae(at,[...Ot,Qe])},set(Jt,Qe,rt){ye(Ue);const[bt,ze]=It(rt);return Ut(at,{type:"SET",path:[...Ot,Qe].map(Ze=>Ze.toString()),value:bt},ze).then(kt)},apply(Jt,Qe,rt){ye(Ue);const bt=Ot[Ot.length-1];if(bt===k)return Ut(at,{type:"ENDPOINT"}).then(kt);if(bt==="bind")return Ae(at,Ot.slice(0,-1));const[ze,Ze]=Ye(rt);return Ut(at,{type:"APPLY",path:Ot.map(q=>q.toString()),argumentList:ze},Ze).then(kt)},construct(Jt,Qe){ye(Ue);const[rt,bt]=Ye(Qe);return Ut(at,{type:"CONSTRUCT",path:Ot.map(ze=>ze.toString()),argumentList:rt},bt).then(kt)}});return fe(vt,at),vt}function be(at){return Array.prototype.concat.apply([],at)}function Ye(at){const Ot=at.map(It);return[Ot.map(ue=>ue[0]),be(Ot.map(ue=>ue[1]))]}const Ee=new WeakMap;function We(at,Ot){return Ee.set(at,Ot),at}function je(at){return Object.assign(at,{[w]:!0})}function _t(at,Ot=globalThis,ue="*"){return{postMessage:(Ue,vt)=>at.postMessage(Ue,ue,vt),addEventListener:Ot.addEventListener.bind(Ot),removeEventListener:Ot.removeEventListener.bind(Ot)}}function It(at){for(const[Ot,ue]of N)if(ue.canHandle(at)){const[Ue,vt]=ue.serialize(at);return[{type:"HANDLER",name:Ot,value:Ue},vt]}return[{type:"RAW",value:at},Ee.get(at)||[]]}function kt(at){switch(at.type){case"HANDLER":return N.get(at.name).deserialize(at.value);case"RAW":return at.value}}function Ut(at,Ot,ue){return new Promise(Ue=>{const vt=At();at.addEventListener("message",function Jt(Qe){!Qe.data||!Qe.data.id||Qe.data.id!==vt||(at.removeEventListener("message",Jt),Ue(Qe.data))}),at.start&&at.start(),at.postMessage(Object.assign({id:vt},Ot),ue)})}function At(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}},51598:function(ae,ne,b){"use strict";b.d(ne,{H:function(){return O},Z:function(){return w}});function w(A){const S=+this._x.call(null,A);return k(this.cover(S),S,A)}function k(A,S,R){if(isNaN(S))return A;var x,E=A._root,N={data:R},L=A._x0,P=A._x1,W,K,re,ye,ge;if(!E)return A._root=N,A;for(;E.length;)if((re=S>=(W=(L+P)/2))?L=W:P=W,x=E,!(E=E[ye=+re]))return x[ye]=N,A;if(K=+A._x.call(null,E.data),S===K)return N.next=E,x?x[ye]=N:A._root=N,A;do x=x?x[ye]=new Array(2):A._root=new Array(2),(re=S>=(W=(L+P)/2))?L=W:P=W;while((ye=+re)==(ge=+(K>=W)));return x[ge]=E,x[ye]=N,A}function O(A){Array.isArray(A)||(A=Array.from(A));const S=A.length,R=new Float64Array(S);let x=1/0,E=-1/0;for(let N=0,L;N<S;++N)isNaN(L=+this._x.call(null,A[N]))||(R[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,R[N],A[N]);return this}},20928:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return W}});var w=b(51598),k=b(50654),O=b(97164),A=b(7138),S=b(8779),R=b(5115),x=b(42308),E=b(57670),N=b(60972),L=b(46032),P=b(83402);function W(ge,ce){var xe=new K(ce==null?P.P:ce,NaN,NaN);return ge==null?xe:xe.addAll(ge)}function K(ge,ce,xe){this._x=ge,this._x0=ce,this._x1=xe,this._root=void 0}function re(ge){for(var ce={data:ge.data},xe=ce;ge=ge.next;)xe=xe.next={data:ge.data};return ce}var ye=W.prototype=K.prototype;ye.copy=function(){var ge=new K(this._x,this._x0,this._x1),ce=this._root,xe,fe;if(!ce)return ge;if(!ce.length)return ge._root=re(ce),ge;for(xe=[{source:ce,target:ge._root=new Array(2)}];ce=xe.pop();)for(var Ne=0;Ne<2;++Ne)(fe=ce.source[Ne])&&(fe.length?xe.push({source:fe,target:ce.target[Ne]=new Array(2)}):ce.target[Ne]=re(fe));return ge},ye.add=w.Z,ye.addAll=w.H,ye.cover=k.Z,ye.data=O.Z,ye.extent=A.Z,ye.find=S.Z,ye.remove=R.Z,ye.removeAll=R.x,ye.root=x.Z,ye.size=E.Z,ye.visit=N.Z,ye.visitAfter=L.Z,ye.x=P.Z},50654:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(k){if(isNaN(k=+k))return this;var O=this._x0,A=this._x1;if(isNaN(O))A=(O=Math.floor(k))+1;else{for(var S=A-O||1,R=this._root,x,E;O>k||k>=A;)switch(E=+(k<O),x=new Array(2),x[E]=R,R=x,S*=2,E){case 0:A=O+S;break;case 1:O=A-S;break}this._root&&this._root.length&&(this._root=R)}return this._x0=O,this._x1=A,this}},97164:function(ae,ne,b){"use strict";b.d(ne,{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(ae,ne,b){"use strict";b.d(ne,{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(ae,ne,b){"use strict";b.d(ne,{Z:function(){return k}});var w=b(66519);function k(O,A){var S,R=this._x0,x,E,N=this._x1,L=[],P=this._root,W,K;for(P&&L.push(new w.Z(P,R,N)),A==null?A=1/0:(R=O-A,N=O+A);W=L.pop();)if(!(!(P=W.node)||(x=W.x0)>N||(E=W.x1)<R))if(P.length){var re=(x+E)/2;L.push(new w.Z(P[1],re,E),new w.Z(P[0],x,re)),(K=+(O>=re))&&(W=L[L.length-1],L[L.length-1]=L[L.length-1-K],L[L.length-1-K]=W)}else{var ye=Math.abs(O-+this._x.call(null,P.data));ye<A&&(A=ye,R=O-ye,N=O+ye,S=P.data)}return S}},66519:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(k,O,A){this.node=k,this.x0=O,this.x1=A}},5115:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w},x:function(){return k}});function w(O){if(isNaN(P=+this._x.call(null,O)))return this;var A,S=this._root,R,x,E,N=this._x0,L=this._x1,P,W,K,re,ye;if(!S)return this;if(S.length)for(;;){if((K=P>=(W=(N+L)/2))?N=W:L=W,A=S,!(S=S[re=+K]))return this;if(!S.length)break;A[re+1&1]&&(R=A,ye=re)}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):A?(E?A[re]=E:delete A[re],(S=A[0]||A[1])&&S===(A[1]||A[0])&&!S.length&&(R?R[ye]=S:this._root=S),this):(this._root=E,this)}function k(O){for(var A=0,S=O.length;A<S;++A)this.remove(O[A]);return this}},42308:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(){return this._root}},57670:function(ae,ne,b){"use strict";b.d(ne,{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(ae,ne,b){"use strict";b.d(ne,{Z:function(){return k}});var w=b(66519);function k(O){var A=[],S,R=this._root,x,E,N;for(R&&A.push(new w.Z(R,this._x0,this._x1));S=A.pop();)if(!O(R=S.node,E=S.x0,N=S.x1)&&R.length){var L=(E+N)/2;(x=R[1])&&A.push(new w.Z(x,L,N)),(x=R[0])&&A.push(new w.Z(x,E,L))}return this}},46032:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return k}});var w=b(66519);function k(O){var A=[],S=[],R;for(this._root&&A.push(new w.Z(this._root,this._x0,this._x1));R=A.pop();){var x=R.node;if(x.length){var E,N=R.x0,L=R.x1,P=(N+L)/2;(E=x[0])&&A.push(new w.Z(E,N,P)),(E=x[1])&&A.push(new w.Z(E,P,L))}S.push(R)}for(;R=S.pop();)O(R.node,R.x0,R.x1);return this}},83402:function(ae,ne,b){"use strict";b.d(ne,{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(ae,ne,b){"use strict";b.d(ne,{HT:function(){return ye}});var w=0,k=0,O=0,A=1e3,S,R,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(Ae){setTimeout(Ae,17)};function W(){return E||(P(K),E=L.now()+N)}function K(){E=0}function re(){this._call=this._time=this._next=null}re.prototype=ye.prototype={constructor:re,restart:function(Ae,be,Ye){if(typeof Ae!="function")throw new TypeError("callback is not a function");Ye=(Ye==null?W():+Ye)+(be==null?0:+be),!this._next&&R!==this&&(R?R._next=this:S=this,R=this),this._call=Ae,this._time=Ye,Ne()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ne())}};function ye(Ae,be,Ye){var Ee=new re;return Ee.restart(Ae,be,Ye),Ee}function ge(){W(),++w;for(var Ae=S,be;Ae;)(be=E-Ae._time)>=0&&Ae._call.call(void 0,be),Ae=Ae._next;--w}function ce(){E=(x=L.now())+N,w=k=0;try{ge()}finally{w=0,fe(),E=0}}function xe(){var Ae=L.now(),be=Ae-x;be>A&&(N-=be,x=Ae)}function fe(){for(var Ae,be=S,Ye,Ee=1/0;be;)be._call?(Ee>be._time&&(Ee=be._time),Ae=be,be=be._next):(Ye=be._next,be._next=null,be=Ae?Ae._next=Ye:S=Ye);R=Ae,Ne(Ee)}function Ne(Ae){if(!w){k&&(k=clearTimeout(k));var be=Ae-E;be>24?(Ae<1/0&&(k=setTimeout(ce,Ae-L.now()-N)),O&&(O=clearInterval(O))):(O||(x=L.now(),O=setInterval(xe,A)),w=1,P(ce))}}},46846:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(k,O){var A,S=1;k==null&&(k=0),O==null&&(O=0);function R(){var x,E=A.length,N,L=0,P=0;for(x=0;x<E;++x)N=A[x],L+=N.x,P+=N.y;for(L=(L/E-k)*S,P=(P/E-O)*S,x=0;x<E;++x)N=A[x],N.x-=L,N.y-=P}return R.initialize=function(x){A=x},R.x=function(x){return arguments.length?(k=+x,R):k},R.y=function(x){return arguments.length?(O=+x,R):O},R.strength=function(x){return arguments.length?(S=+x,R):S},R}},89281:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return R}});var w=b(46632),k=b(13548),O=b(79778);function A(x){return x.x+x.vx}function S(x){return x.y+x.vy}function R(x){var E,N,L,P=1,W=1;typeof x!="function"&&(x=(0,k.Z)(x==null?1:+x));function K(){for(var ge,ce=E.length,xe,fe,Ne,Ae,be,Ye,Ee=0;Ee<W;++Ee)for(xe=(0,w.Z)(E,A,S).visitAfter(re),ge=0;ge<ce;++ge)fe=E[ge],be=N[fe.index],Ye=be*be,Ne=fe.x+fe.vx,Ae=fe.y+fe.vy,xe.visit(We);function We(je,_t,It,kt,Ut){var At=je.data,at=je.r,Ot=be+at;if(At){if(At.index>fe.index){var ue=Ne-At.x-At.vx,Ue=Ae-At.y-At.vy,vt=ue*ue+Ue*Ue;vt<Ot*Ot&&(ue===0&&(ue=(0,O.Z)(L),vt+=ue*ue),Ue===0&&(Ue=(0,O.Z)(L),vt+=Ue*Ue),vt=(Ot-(vt=Math.sqrt(vt)))/vt*P,fe.vx+=(ue*=vt)*(Ot=(at*=at)/(Ye+at)),fe.vy+=(Ue*=vt)*Ot,At.vx-=ue*(Ot=1-Ot),At.vy-=Ue*Ot)}return}return _t>Ne+Ot||kt<Ne-Ot||It>Ae+Ot||Ut<Ae-Ot}}function re(ge){if(ge.data)return ge.r=N[ge.data.index];for(var ce=ge.r=0;ce<4;++ce)ge[ce]&&ge[ce].r>ge.r&&(ge.r=ge[ce].r)}function ye(){if(E){var ge,ce=E.length,xe;for(N=new Array(ce),ge=0;ge<ce;++ge)xe=E[ge],N[xe.index]=+x(xe,ge,E)}}return K.initialize=function(ge,ce){E=ge,L=ce,ye()},K.iterations=function(ge){return arguments.length?(W=+ge,K):W},K.strength=function(ge){return arguments.length?(P=+ge,K):P},K.radius=function(ge){return arguments.length?(x=typeof ge=="function"?ge:(0,k.Z)(+ge),ye(),K):x},K}},13548:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(k){return function(){return k}}},79778:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(k){return(k()-.5)*1e-6}},3168:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return A}});const w=1664525,k=1013904223,O=4294967296;function A(){let S=1;return()=>(S=(w*S+k)%O)/O}},56561:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return S}});var w=b(13548),k=b(79778);function O(R){return R.index}function A(R,x){var E=R.get(x);if(!E)throw new Error("node not found: "+x);return E}function S(R){var x=O,E=ce,N,L=(0,w.Z)(30),P,W,K,re,ye,ge=1;R==null&&(R=[]);function ce(be){return 1/Math.min(K[be.source.index],K[be.target.index])}function xe(be){for(var Ye=0,Ee=R.length;Ye<ge;++Ye)for(var We=0,je,_t,It,kt,Ut,At,at;We<Ee;++We)je=R[We],_t=je.source,It=je.target,kt=It.x+It.vx-_t.x-_t.vx||(0,k.Z)(ye),Ut=It.y+It.vy-_t.y-_t.vy||(0,k.Z)(ye),At=Math.sqrt(kt*kt+Ut*Ut),At=(At-P[We])/At*be*N[We],kt*=At,Ut*=At,It.vx-=kt*(at=re[We]),It.vy-=Ut*at,_t.vx+=kt*(at=1-at),_t.vy+=Ut*at}function fe(){if(W){var be,Ye=W.length,Ee=R.length,We=new Map(W.map((_t,It)=>[x(_t,It,W),_t])),je;for(be=0,K=new Array(Ye);be<Ee;++be)je=R[be],je.index=be,typeof je.source!="object"&&(je.source=A(We,je.source)),typeof je.target!="object"&&(je.target=A(We,je.target)),K[je.source.index]=(K[je.source.index]||0)+1,K[je.target.index]=(K[je.target.index]||0)+1;for(be=0,re=new Array(Ee);be<Ee;++be)je=R[be],re[be]=K[je.source.index]/(K[je.source.index]+K[je.target.index]);N=new Array(Ee),Ne(),P=new Array(Ee),Ae()}}function Ne(){if(W)for(var be=0,Ye=R.length;be<Ye;++be)N[be]=+E(R[be],be,R)}function Ae(){if(W)for(var be=0,Ye=R.length;be<Ye;++be)P[be]=+L(R[be],be,R)}return xe.initialize=function(be,Ye){W=be,ye=Ye,fe()},xe.links=function(be){return arguments.length?(R=be,fe(),xe):R},xe.id=function(be){return arguments.length?(x=be,xe):x},xe.iterations=function(be){return arguments.length?(ge=+be,xe):ge},xe.strength=function(be){return arguments.length?(E=typeof be=="function"?be:(0,w.Z)(+be),Ne(),xe):E},xe.distance=function(be){return arguments.length?(L=typeof be=="function"?be:(0,w.Z)(+be),Ae(),xe):L},xe}},65475:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return S}});var w=b(46632),k=b(13548),O=b(79778),A=b(80616);function S(){var R,x,E,N,L=(0,k.Z)(-30),P,W=1,K=1/0,re=.81;function ye(fe){var Ne,Ae=R.length,be=(0,w.Z)(R,A.x,A.y).visitAfter(ce);for(N=fe,Ne=0;Ne<Ae;++Ne)x=R[Ne],be.visit(xe)}function ge(){if(R){var fe,Ne=R.length,Ae;for(P=new Array(Ne),fe=0;fe<Ne;++fe)Ae=R[fe],P[Ae.index]=+L(Ae,fe,R)}}function ce(fe){var Ne=0,Ae,be,Ye=0,Ee,We,je;if(fe.length){for(Ee=We=je=0;je<4;++je)(Ae=fe[je])&&(be=Math.abs(Ae.value))&&(Ne+=Ae.value,Ye+=be,Ee+=be*Ae.x,We+=be*Ae.y);fe.x=Ee/Ye,fe.y=We/Ye}else{Ae=fe,Ae.x=Ae.data.x,Ae.y=Ae.data.y;do Ne+=P[Ae.data.index];while(Ae=Ae.next)}fe.value=Ne}function xe(fe,Ne,Ae,be){if(!fe.value)return!0;var Ye=fe.x-x.x,Ee=fe.y-x.y,We=be-Ne,je=Ye*Ye+Ee*Ee;if(We*We/re<je)return je<K&&(Ye===0&&(Ye=(0,O.Z)(E),je+=Ye*Ye),Ee===0&&(Ee=(0,O.Z)(E),je+=Ee*Ee),je<W&&(je=Math.sqrt(W*je)),x.vx+=Ye*fe.value*N/je,x.vy+=Ee*fe.value*N/je),!0;if(fe.length||je>=K)return;(fe.data!==x||fe.next)&&(Ye===0&&(Ye=(0,O.Z)(E),je+=Ye*Ye),Ee===0&&(Ee=(0,O.Z)(E),je+=Ee*Ee),je<W&&(je=Math.sqrt(W*je)));do fe.data!==x&&(We=P[fe.data.index]*N/je,x.vx+=Ye*We,x.vy+=Ee*We);while(fe=fe.next)}return ye.initialize=function(fe,Ne){R=fe,E=Ne,ge()},ye.strength=function(fe){return arguments.length?(L=typeof fe=="function"?fe:(0,k.Z)(+fe),ge(),ye):L},ye.distanceMin=function(fe){return arguments.length?(W=fe*fe,ye):Math.sqrt(W)},ye.distanceMax=function(fe){return arguments.length?(K=fe*fe,ye):Math.sqrt(K)},ye.theta=function(fe){return arguments.length?(re=fe*fe,ye):Math.sqrt(re)},ye}},61217:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return k}});var w=b(13548);function k(O,A,S){var R,x=(0,w.Z)(.1),E,N;typeof O!="function"&&(O=(0,w.Z)(+O)),A==null&&(A=0),S==null&&(S=0);function L(W){for(var K=0,re=R.length;K<re;++K){var ye=R[K],ge=ye.x-A||1e-6,ce=ye.y-S||1e-6,xe=Math.sqrt(ge*ge+ce*ce),fe=(N[K]-xe)*E[K]*W/xe;ye.vx+=ge*fe,ye.vy+=ce*fe}}function P(){if(R){var W,K=R.length;for(E=new Array(K),N=new Array(K),W=0;W<K;++W)N[W]=+O(R[W],W,R),E[W]=isNaN(N[W])?0:+x(R[W],W,R)}}return L.initialize=function(W){R=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?(A=+W,L):A},L.y=function(W){return arguments.length?(S=+W,L):S},L}},80616:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return E},x:function(){return A},y:function(){return S}});var w=b(94660),k=b(45736),O=b(3168);function A(N){return N.x}function S(N){return N.y}var R=10,x=Math.PI*(3-Math.sqrt(5));function E(N){var L,P=1,W=.001,K=1-Math.pow(W,1/300),re=0,ye=.6,ge=new Map,ce=(0,k.HT)(Ne),xe=(0,w.Z)("tick","end"),fe=(0,O.Z)();N==null&&(N=[]);function Ne(){Ae(),xe.call("tick",L),P<W&&(ce.stop(),xe.call("end",L))}function Ae(Ee){var We,je=N.length,_t;Ee===void 0&&(Ee=1);for(var It=0;It<Ee;++It)for(P+=(re-P)*K,ge.forEach(function(kt){kt(P)}),We=0;We<je;++We)_t=N[We],_t.fx==null?_t.x+=_t.vx*=ye:(_t.x=_t.fx,_t.vx=0),_t.fy==null?_t.y+=_t.vy*=ye:(_t.y=_t.fy,_t.vy=0);return L}function be(){for(var Ee=0,We=N.length,je;Ee<We;++Ee){if(je=N[Ee],je.index=Ee,je.fx!=null&&(je.x=je.fx),je.fy!=null&&(je.y=je.fy),isNaN(je.x)||isNaN(je.y)){var _t=R*Math.sqrt(.5+Ee),It=Ee*x;je.x=_t*Math.cos(It),je.y=_t*Math.sin(It)}(isNaN(je.vx)||isNaN(je.vy))&&(je.vx=je.vy=0)}}function Ye(Ee){return Ee.initialize&&Ee.initialize(N,fe),Ee}return be(),L={tick:Ae,restart:function(){return ce.restart(Ne),L},stop:function(){return ce.stop(),L},nodes:function(Ee){return arguments.length?(N=Ee,be(),ge.forEach(Ye),L):N},alpha:function(Ee){return arguments.length?(P=+Ee,L):P},alphaMin:function(Ee){return arguments.length?(W=+Ee,L):W},alphaDecay:function(Ee){return arguments.length?(K=+Ee,L):+K},alphaTarget:function(Ee){return arguments.length?(re=+Ee,L):re},velocityDecay:function(Ee){return arguments.length?(ye=1-Ee,L):1-ye},randomSource:function(Ee){return arguments.length?(fe=Ee,ge.forEach(Ye),L):fe},force:function(Ee,We){return arguments.length>1?(We==null?ge.delete(Ee):ge.set(Ee,Ye(We)),L):ge.get(Ee)},find:function(Ee,We,je){var _t=0,It=N.length,kt,Ut,At,at,Ot;for(je==null?je=1/0:je*=je,_t=0;_t<It;++_t)at=N[_t],kt=Ee-at.x,Ut=We-at.y,At=kt*kt+Ut*Ut,At<je&&(Ot=at,je=At);return Ot},on:function(Ee,We){return arguments.length>1?(xe.on(Ee,We),L):xe.on(Ee)}}}},70341:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return k}});var w=b(13548);function k(O){var A=(0,w.Z)(.1),S,R,x;typeof O!="function"&&(O=(0,w.Z)(O==null?0:+O));function E(L){for(var P=0,W=S.length,K;P<W;++P)K=S[P],K.vx+=(x[P]-K.x)*R[P]*L}function N(){if(S){var L,P=S.length;for(R=new Array(P),x=new Array(P),L=0;L<P;++L)R[L]=isNaN(x[L]=+O(S[L],L,S))?0:+A(S[L],L,S)}}return E.initialize=function(L){S=L,N()},E.strength=function(L){return arguments.length?(A=typeof L=="function"?L:(0,w.Z)(+L),N(),E):A},E.x=function(L){return arguments.length?(O=typeof L=="function"?L:(0,w.Z)(+L),N(),E):O},E}},12688:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return k}});var w=b(13548);function k(O){var A=(0,w.Z)(.1),S,R,x;typeof O!="function"&&(O=(0,w.Z)(O==null?0:+O));function E(L){for(var P=0,W=S.length,K;P<W;++P)K=S[P],K.vy+=(x[P]-K.y)*R[P]*L}function N(){if(S){var L,P=S.length;for(R=new Array(P),x=new Array(P),L=0;L<P;++L)R[L]=isNaN(x[L]=+O(S[L],L,S))?0:+A(S[L],L,S)}}return E.initialize=function(L){S=L,N()},E.strength=function(L){return arguments.length?(A=typeof L=="function"?L:(0,w.Z)(+L),N(),E):A},E.y=function(L){return arguments.length?(O=typeof L=="function"?L:(0,w.Z)(+L),N(),E):O},E}},23473:function(ae,ne,b){"use strict";b.d(ne,{H:function(){return O},Z:function(){return w}});function w(A){const S=+this._x.call(null,A),R=+this._y.call(null,A),x=+this._z.call(null,A);return k(this.cover(S,R,x),S,R,x,A)}function k(A,S,R,x,E){if(isNaN(S)||isNaN(R)||isNaN(x))return A;var N,L=A._root,P={data:E},W=A._x0,K=A._y0,re=A._z0,ye=A._x1,ge=A._y1,ce=A._z1,xe,fe,Ne,Ae,be,Ye,Ee,We,je,_t,It;if(!L)return A._root=P,A;for(;L.length;)if((Ee=S>=(xe=(W+ye)/2))?W=xe:ye=xe,(We=R>=(fe=(K+ge)/2))?K=fe:ge=fe,(je=x>=(Ne=(re+ce)/2))?re=Ne:ce=Ne,N=L,!(L=L[_t=je<<2|We<<1|Ee]))return N[_t]=P,A;if(Ae=+A._x.call(null,L.data),be=+A._y.call(null,L.data),Ye=+A._z.call(null,L.data),S===Ae&&R===be&&x===Ye)return P.next=L,N?N[_t]=P:A._root=P,A;do N=N?N[_t]=new Array(8):A._root=new Array(8),(Ee=S>=(xe=(W+ye)/2))?W=xe:ye=xe,(We=R>=(fe=(K+ge)/2))?K=fe:ge=fe,(je=x>=(Ne=(re+ce)/2))?re=Ne:ce=Ne;while((_t=je<<2|We<<1|Ee)===(It=(Ye>=Ne)<<2|(be>=fe)<<1|Ae>=xe));return N[It]=L,N[_t]=P,A}function O(A){Array.isArray(A)||(A=Array.from(A));const S=A.length,R=new Float64Array(S),x=new Float64Array(S),E=new Float64Array(S);let N=1/0,L=1/0,P=1/0,W=-1/0,K=-1/0,re=-1/0;for(let ye=0,ge,ce,xe,fe;ye<S;++ye)isNaN(ce=+this._x.call(null,ge=A[ye]))||isNaN(xe=+this._y.call(null,ge))||isNaN(fe=+this._z.call(null,ge))||(R[ye]=ce,x[ye]=xe,E[ye]=fe,ce<N&&(N=ce),ce>W&&(W=ce),xe<L&&(L=xe),xe>K&&(K=xe),fe<P&&(P=fe),fe>re&&(re=fe));if(N>W||L>K||P>re)return this;this.cover(N,L,P).cover(W,K,re);for(let ye=0;ye<S;++ye)k(this,R[ye],x[ye],E[ye],A[ye]);return this}},55802:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(k,O,A){if(isNaN(k=+k)||isNaN(O=+O)||isNaN(A=+A))return this;var S=this._x0,R=this._y0,x=this._z0,E=this._x1,N=this._y1,L=this._z1;if(isNaN(S))E=(S=Math.floor(k))+1,N=(R=Math.floor(O))+1,L=(x=Math.floor(A))+1;else{for(var P=E-S||1,W=this._root,K,re;S>k||k>=E||R>O||O>=N||x>A||A>=L;)switch(re=(A<x)<<2|(O<R)<<1|k<S,K=new Array(8),K[re]=W,W=K,P*=2,re){case 0:E=S+P,N=R+P,L=x+P;break;case 1:S=E-P,N=R+P,L=x+P;break;case 2:E=S+P,R=N-P,L=x+P;break;case 3:S=E-P,R=N-P,L=x+P;break;case 4:E=S+P,N=R+P,x=L-P;break;case 5:S=E-P,N=R+P,x=L-P;break;case 6:E=S+P,R=N-P,x=L-P;break;case 7:S=E-P,R=N-P,x=L-P;break}this._root&&this._root.length&&(this._root=W)}return this._x0=S,this._y0=R,this._z0=x,this._x1=E,this._y1=N,this._z1=L,this}},65587:function(ae,ne,b){"use strict";b.d(ne,{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(ae,ne,b){"use strict";b.d(ne,{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(ae,ne,b){"use strict";b.d(ne,{Z:function(){return k}});var w=b(14086);function k(O,A,S,R){var x,E=this._x0,N=this._y0,L=this._z0,P,W,K,re,ye,ge,ce=this._x1,xe=this._y1,fe=this._z1,Ne=[],Ae=this._root,be,Ye;for(Ae&&Ne.push(new w.Z(Ae,E,N,L,ce,xe,fe)),R==null?R=1/0:(E=O-R,N=A-R,L=S-R,ce=O+R,xe=A+R,fe=S+R,R*=R);be=Ne.pop();)if(!(!(Ae=be.node)||(P=be.x0)>ce||(W=be.y0)>xe||(K=be.z0)>fe||(re=be.x1)<E||(ye=be.y1)<N||(ge=be.z1)<L))if(Ae.length){var Ee=(P+re)/2,We=(W+ye)/2,je=(K+ge)/2;Ne.push(new w.Z(Ae[7],Ee,We,je,re,ye,ge),new w.Z(Ae[6],P,We,je,Ee,ye,ge),new w.Z(Ae[5],Ee,W,je,re,We,ge),new w.Z(Ae[4],P,W,je,Ee,We,ge),new w.Z(Ae[3],Ee,We,K,re,ye,je),new w.Z(Ae[2],P,We,K,Ee,ye,je),new w.Z(Ae[1],Ee,W,K,re,We,je),new w.Z(Ae[0],P,W,K,Ee,We,je)),(Ye=(S>=je)<<2|(A>=We)<<1|O>=Ee)&&(be=Ne[Ne.length-1],Ne[Ne.length-1]=Ne[Ne.length-1-Ye],Ne[Ne.length-1-Ye]=be)}else{var _t=O-+this._x.call(null,Ae.data),It=A-+this._y.call(null,Ae.data),kt=S-+this._z.call(null,Ae.data),Ut=_t*_t+It*It+kt*kt;if(Ut<R){var At=Math.sqrt(R=Ut);E=O-At,N=A-At,L=S-At,ce=O+At,xe=A+At,fe=S+At,x=Ae.data}}return x}},14086:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(k,O,A,S,R,x,E){this.node=k,this.x0=O,this.y0=A,this.z0=S,this.x1=R,this.y1=x,this.z1=E}},67217:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return re}});var w=b(23473),k=b(55802),O=b(65587),A=b(31756),S=b(60444),R=b(44576),x=b(76077),E=b(53212),N=b(56173),L=b(36427),P=b(79853),W=b(79840),K=b(87325);function re(xe,fe,Ne,Ae){var be=new ye(fe==null?P.P:fe,Ne==null?W.q:Ne,Ae==null?K.i:Ae,NaN,NaN,NaN,NaN,NaN,NaN);return xe==null?be:be.addAll(xe)}function ye(xe,fe,Ne,Ae,be,Ye,Ee,We,je){this._x=xe,this._y=fe,this._z=Ne,this._x0=Ae,this._y0=be,this._z0=Ye,this._x1=Ee,this._y1=We,this._z1=je,this._root=void 0}function ge(xe){for(var fe={data:xe.data},Ne=fe;xe=xe.next;)Ne=Ne.next={data:xe.data};return fe}var ce=re.prototype=ye.prototype;ce.copy=function(){var xe=new ye(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),fe=this._root,Ne,Ae;if(!fe)return xe;if(!fe.length)return xe._root=ge(fe),xe;for(Ne=[{source:fe,target:xe._root=new Array(8)}];fe=Ne.pop();)for(var be=0;be<8;++be)(Ae=fe.source[be])&&(Ae.length?Ne.push({source:Ae,target:fe.target[be]=new Array(8)}):fe.target[be]=ge(Ae));return xe},ce.add=w.Z,ce.addAll=w.H,ce.cover=k.Z,ce.data=O.Z,ce.extent=A.Z,ce.find=S.Z,ce.remove=R.Z,ce.removeAll=R.x,ce.root=x.Z,ce.size=E.Z,ce.visit=N.Z,ce.visitAfter=L.Z,ce.x=P.Z,ce.y=W.Z,ce.z=K.Z},44576:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w},x:function(){return k}});function w(O){if(isNaN(ye=+this._x.call(null,O))||isNaN(ge=+this._y.call(null,O))||isNaN(ce=+this._z.call(null,O)))return this;var A,S=this._root,R,x,E,N=this._x0,L=this._y0,P=this._z0,W=this._x1,K=this._y1,re=this._z1,ye,ge,ce,xe,fe,Ne,Ae,be,Ye,Ee,We;if(!S)return this;if(S.length)for(;;){if((Ae=ye>=(xe=(N+W)/2))?N=xe:W=xe,(be=ge>=(fe=(L+K)/2))?L=fe:K=fe,(Ye=ce>=(Ne=(P+re)/2))?P=Ne:re=Ne,A=S,!(S=S[Ee=Ye<<2|be<<1|Ae]))return this;if(!S.length)break;(A[Ee+1&7]||A[Ee+2&7]||A[Ee+3&7]||A[Ee+4&7]||A[Ee+5&7]||A[Ee+6&7]||A[Ee+7&7])&&(R=A,We=Ee)}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):A?(E?A[Ee]=E:delete A[Ee],(S=A[0]||A[1]||A[2]||A[3]||A[4]||A[5]||A[6]||A[7])&&S===(A[7]||A[6]||A[5]||A[4]||A[3]||A[2]||A[1]||A[0])&&!S.length&&(R?R[We]=S:this._root=S),this):(this._root=E,this)}function k(O){for(var A=0,S=O.length;A<S;++A)this.remove(O[A]);return this}},76077:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(){return this._root}},53212:function(ae,ne,b){"use strict";b.d(ne,{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(ae,ne,b){"use strict";b.d(ne,{Z:function(){return k}});var w=b(14086);function k(O){var A=[],S,R=this._root,x,E,N,L,P,W,K;for(R&&A.push(new w.Z(R,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));S=A.pop();)if(!O(R=S.node,E=S.x0,N=S.y0,L=S.z0,P=S.x1,W=S.y1,K=S.z1)&&R.length){var re=(E+P)/2,ye=(N+W)/2,ge=(L+K)/2;(x=R[7])&&A.push(new w.Z(x,re,ye,ge,P,W,K)),(x=R[6])&&A.push(new w.Z(x,E,ye,ge,re,W,K)),(x=R[5])&&A.push(new w.Z(x,re,N,ge,P,ye,K)),(x=R[4])&&A.push(new w.Z(x,E,N,ge,re,ye,K)),(x=R[3])&&A.push(new w.Z(x,re,ye,L,P,W,ge)),(x=R[2])&&A.push(new w.Z(x,E,ye,L,re,W,ge)),(x=R[1])&&A.push(new w.Z(x,re,N,L,P,ye,ge)),(x=R[0])&&A.push(new w.Z(x,E,N,L,re,ye,ge))}return this}},36427:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return k}});var w=b(14086);function k(O){var A=[],S=[],R;for(this._root&&A.push(new w.Z(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));R=A.pop();){var x=R.node;if(x.length){var E,N=R.x0,L=R.y0,P=R.z0,W=R.x1,K=R.y1,re=R.z1,ye=(N+W)/2,ge=(L+K)/2,ce=(P+re)/2;(E=x[0])&&A.push(new w.Z(E,N,L,P,ye,ge,ce)),(E=x[1])&&A.push(new w.Z(E,ye,L,P,W,ge,ce)),(E=x[2])&&A.push(new w.Z(E,N,ge,P,ye,K,ce)),(E=x[3])&&A.push(new w.Z(E,ye,ge,P,W,K,ce)),(E=x[4])&&A.push(new w.Z(E,N,L,ce,ye,ge,re)),(E=x[5])&&A.push(new w.Z(E,ye,L,ce,W,ge,re)),(E=x[6])&&A.push(new w.Z(E,N,ge,ce,ye,K,re)),(E=x[7])&&A.push(new w.Z(E,ye,ge,ce,W,K,re))}S.push(R)}for(;R=S.pop();)O(R.node,R.x0,R.y0,R.z0,R.x1,R.y1,R.z1);return this}},79853:function(ae,ne,b){"use strict";b.d(ne,{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(ae,ne,b){"use strict";b.d(ne,{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(ae,ne,b){"use strict";b.d(ne,{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(ae,ne,b){"use strict";b.d(ne,{H:function(){return O},Z:function(){return w}});function w(A){const S=+this._x.call(null,A),R=+this._y.call(null,A);return k(this.cover(S,R),S,R,A)}function k(A,S,R,x){if(isNaN(S)||isNaN(R))return A;var E,N=A._root,L={data:x},P=A._x0,W=A._y0,K=A._x1,re=A._y1,ye,ge,ce,xe,fe,Ne,Ae,be;if(!N)return A._root=L,A;for(;N.length;)if((fe=S>=(ye=(P+K)/2))?P=ye:K=ye,(Ne=R>=(ge=(W+re)/2))?W=ge:re=ge,E=N,!(N=N[Ae=Ne<<1|fe]))return E[Ae]=L,A;if(ce=+A._x.call(null,N.data),xe=+A._y.call(null,N.data),S===ce&&R===xe)return L.next=N,E?E[Ae]=L:A._root=L,A;do E=E?E[Ae]=new Array(4):A._root=new Array(4),(fe=S>=(ye=(P+K)/2))?P=ye:K=ye,(Ne=R>=(ge=(W+re)/2))?W=ge:re=ge;while((Ae=Ne<<1|fe)===(be=(xe>=ge)<<1|ce>=ye));return E[be]=N,E[Ae]=L,A}function O(A){var S,R,x=A.length,E,N,L=new Array(x),P=new Array(x),W=1/0,K=1/0,re=-1/0,ye=-1/0;for(R=0;R<x;++R)isNaN(E=+this._x.call(null,S=A[R]))||isNaN(N=+this._y.call(null,S))||(L[R]=E,P[R]=N,E<W&&(W=E),E>re&&(re=E),N<K&&(K=N),N>ye&&(ye=N));if(W>re||K>ye)return this;for(this.cover(W,K).cover(re,ye),R=0;R<x;++R)k(this,L[R],P[R],A[R]);return this}},86290:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(k,O){if(isNaN(k=+k)||isNaN(O=+O))return this;var A=this._x0,S=this._y0,R=this._x1,x=this._y1;if(isNaN(A))R=(A=Math.floor(k))+1,x=(S=Math.floor(O))+1;else{for(var E=R-A||1,N=this._root,L,P;A>k||k>=R||S>O||O>=x;)switch(P=(O<S)<<1|k<A,L=new Array(4),L[P]=N,N=L,E*=2,P){case 0:R=A+E,x=S+E;break;case 1:A=R-E,x=S+E;break;case 2:R=A+E,S=x-E;break;case 3:A=R-E,S=x-E;break}this._root&&this._root.length&&(this._root=N)}return this._x0=A,this._y0=S,this._x1=R,this._y1=x,this}},11145:function(ae,ne,b){"use strict";b.d(ne,{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(ae,ne,b){"use strict";b.d(ne,{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(ae,ne,b){"use strict";b.d(ne,{Z:function(){return k}});var w=b(92936);function k(O,A,S){var R,x=this._x0,E=this._y0,N,L,P,W,K=this._x1,re=this._y1,ye=[],ge=this._root,ce,xe;for(ge&&ye.push(new w.Z(ge,x,E,K,re)),S==null?S=1/0:(x=O-S,E=A-S,K=O+S,re=A+S,S*=S);ce=ye.pop();)if(!(!(ge=ce.node)||(N=ce.x0)>K||(L=ce.y0)>re||(P=ce.x1)<x||(W=ce.y1)<E))if(ge.length){var fe=(N+P)/2,Ne=(L+W)/2;ye.push(new w.Z(ge[3],fe,Ne,P,W),new w.Z(ge[2],N,Ne,fe,W),new w.Z(ge[1],fe,L,P,Ne),new w.Z(ge[0],N,L,fe,Ne)),(xe=(A>=Ne)<<1|O>=fe)&&(ce=ye[ye.length-1],ye[ye.length-1]=ye[ye.length-1-xe],ye[ye.length-1-xe]=ce)}else{var Ae=O-+this._x.call(null,ge.data),be=A-+this._y.call(null,ge.data),Ye=Ae*Ae+be*be;if(Ye<S){var Ee=Math.sqrt(S=Ye);x=O-Ee,E=A-Ee,K=O+Ee,re=A+Ee,R=ge.data}}return R}},92936:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(k,O,A,S,R){this.node=k,this.x0=O,this.y0=A,this.x1=S,this.y1=R}},46632:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return K}});var w=b(59715),k=b(86290),O=b(11145),A=b(57059),S=b(13297),R=b(85854),x=b(39033),E=b(56590),N=b(61034),L=b(88020),P=b(40220),W=b(88792);function K(ce,xe,fe){var Ne=new re(xe==null?P.P:xe,fe==null?W.q:fe,NaN,NaN,NaN,NaN);return ce==null?Ne:Ne.addAll(ce)}function re(ce,xe,fe,Ne,Ae,be){this._x=ce,this._y=xe,this._x0=fe,this._y0=Ne,this._x1=Ae,this._y1=be,this._root=void 0}function ye(ce){for(var xe={data:ce.data},fe=xe;ce=ce.next;)fe=fe.next={data:ce.data};return xe}var ge=K.prototype=re.prototype;ge.copy=function(){var ce=new re(this._x,this._y,this._x0,this._y0,this._x1,this._y1),xe=this._root,fe,Ne;if(!xe)return ce;if(!xe.length)return ce._root=ye(xe),ce;for(fe=[{source:xe,target:ce._root=new Array(4)}];xe=fe.pop();)for(var Ae=0;Ae<4;++Ae)(Ne=xe.source[Ae])&&(Ne.length?fe.push({source:Ne,target:xe.target[Ae]=new Array(4)}):xe.target[Ae]=ye(Ne));return ce},ge.add=w.Z,ge.addAll=w.H,ge.cover=k.Z,ge.data=O.Z,ge.extent=A.Z,ge.find=S.Z,ge.remove=R.Z,ge.removeAll=R.x,ge.root=x.Z,ge.size=E.Z,ge.visit=N.Z,ge.visitAfter=L.Z,ge.x=P.Z,ge.y=W.Z},85854:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w},x:function(){return k}});function w(O){if(isNaN(K=+this._x.call(null,O))||isNaN(re=+this._y.call(null,O)))return this;var A,S=this._root,R,x,E,N=this._x0,L=this._y0,P=this._x1,W=this._y1,K,re,ye,ge,ce,xe,fe,Ne;if(!S)return this;if(S.length)for(;;){if((ce=K>=(ye=(N+P)/2))?N=ye:P=ye,(xe=re>=(ge=(L+W)/2))?L=ge:W=ge,A=S,!(S=S[fe=xe<<1|ce]))return this;if(!S.length)break;(A[fe+1&3]||A[fe+2&3]||A[fe+3&3])&&(R=A,Ne=fe)}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):A?(E?A[fe]=E:delete A[fe],(S=A[0]||A[1]||A[2]||A[3])&&S===(A[3]||A[2]||A[1]||A[0])&&!S.length&&(R?R[Ne]=S:this._root=S),this):(this._root=E,this)}function k(O){for(var A=0,S=O.length;A<S;++A)this.remove(O[A]);return this}},39033:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(){return this._root}},56590:function(ae,ne,b){"use strict";b.d(ne,{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(ae,ne,b){"use strict";b.d(ne,{Z:function(){return k}});var w=b(92936);function k(O){var A=[],S,R=this._root,x,E,N,L,P;for(R&&A.push(new w.Z(R,this._x0,this._y0,this._x1,this._y1));S=A.pop();)if(!O(R=S.node,E=S.x0,N=S.y0,L=S.x1,P=S.y1)&&R.length){var W=(E+L)/2,K=(N+P)/2;(x=R[3])&&A.push(new w.Z(x,W,K,L,P)),(x=R[2])&&A.push(new w.Z(x,E,K,W,P)),(x=R[1])&&A.push(new w.Z(x,W,N,L,K)),(x=R[0])&&A.push(new w.Z(x,E,N,W,K))}return this}},88020:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return k}});var w=b(92936);function k(O){var A=[],S=[],R;for(this._root&&A.push(new w.Z(this._root,this._x0,this._y0,this._x1,this._y1));R=A.pop();){var x=R.node;if(x.length){var E,N=R.x0,L=R.y0,P=R.x1,W=R.y1,K=(N+P)/2,re=(L+W)/2;(E=x[0])&&A.push(new w.Z(E,N,L,K,re)),(E=x[1])&&A.push(new w.Z(E,K,L,P,re)),(E=x[2])&&A.push(new w.Z(E,N,re,K,W)),(E=x[3])&&A.push(new w.Z(E,K,re,P,W))}S.push(R)}for(;R=S.pop();)O(R.node,R.x0,R.y0,R.x1,R.y1);return this}},40220:function(ae,ne,b){"use strict";b.d(ne,{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(ae,ne,b){"use strict";b.d(ne,{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(ae,ne,b){"use strict";var w=b(26729);ne.Z=w},38870:function(ae,ne,b){"use strict";b.d(ne,{KI_:function(){return co},Kj0:function(){return fh},ROQ:function(){return Mp},TlE:function(){return yo},ZAu:function(){return Wu},ehD:function(){return re},jyi:function(){return O0},u9r:function(){return Or},vBJ:function(){return Ms},xeV:function(){return nd},xo$:function(){return wf},xoR:function(){return uy}});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},A=0,S=1,R=2,x=3,E=0,N=1,L=2,P=3,W=0,K=1,re=2,ye=0,ge=1,ce=2,xe=3,fe=4,Ne=5,Ae=100,be=101,Ye=102,Ee=103,We=104,je=200,_t=201,It=202,kt=203,Ut=204,At=205,at=206,Ot=207,ue=208,Ue=209,vt=210,Jt=211,Qe=212,rt=213,bt=214,ze=0,Ze=1,q=2,Y=3,de=4,Je=5,Te=6,$e=7,xt=0,ke=1,et=2,yt=0,B=1,ie=2,ct=3,Mt=4,ht=5,Yt=6,en=7,nn="attached",Me="detached",te=300,Fe=301,Xe=302,Pe=303,Ie=304,Ke=306,lt=1e3,qe=1001,pt=1002,Ct=1003,Xt=1004,Qt=1004,pn=1005,Wn=1005,Rn=1006,bi=1007,Lr=1007,Qn=1008,Vi=1008,Oi=1009,Gi=1010,ir=1011,ms=1012,Is=1013,as=1014,gs=1015,Vs=1016,Xl=1017,ql=1018,Da=1020,Dl=35902,nu=35899,Du=1021,Le=1022,D=1023,U=1026,_=1027,F=1028,X=1029,De=1030,Ve=1031,it=1032,st=1033,Ht=33776,Et=33777,on=33778,Un=33779,sn=35840,bn=35841,ti=35842,Bt=35843,$n=36196,ni=37492,Pi=37496,ui=37808,Ir=37809,yi=37810,vi=37811,Mr=37812,Zt=37813,Fn=37814,hi=37815,Xn=37816,hs=37817,Xr=37818,ys=37819,Ur=37820,Os=37821,no=36492,io=36494,So=36495,To=36283,Gr=36284,Qs=36285,Eo=36286,ro=2200,qr=2201,la=2202,Ao=2300,il=2301,rl=2302,ca=2400,Oa=2401,sl=2402,bo=2500,Pc=2501,Qv=0,oh=1,y0=2,Jf=3200,Qf=3201,v0=3202,Pm=3203,$a=0,jd=1,Qo="",co="srgb",iu="srgb-linear",ah="linear",Fi="srgb",Jb=0,Yl=7680,Im=7681,Xd=7682,ex=7683,tx=34055,x0=34056,Qb=5386,e1=512,t1=513,n1=514,nx=515,i1=516,r1=517,ix=518,Xh=519,Lm=512,qd=513,Yd=514,ep=515,_0=516,b0=517,w0=518,Dm=519,Ou=35044,Zd=35048,Om=35040,iE=35045,Fm=35049,rE=35041,sE=35046,oE=35050,aE=35042,s1="100",M0="300 es",so=2e3,ja=2001,lh={COMPUTE:"compute",RENDER:"render"},o1={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},a1={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};function Ol(j){for(let i=j.length-1;i>=0;--i)if(j[i]>=65535)return!0;return!1}const Xa={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Fu(j,i){return new Xa[j](i)}function lc(j){return document.createElementNS("http://www.w3.org/1999/xhtml",j)}function Fa(){const j=lc("canvas");return j.style.display="block",j}const yl={};let Sr=null;function tp(j){Sr=j}function rx(){return Sr}function Bm(...j){const i="THREE."+j.shift();Sr?Sr("log",i,...j):console.log(i,...j)}function _r(...j){const i="THREE."+j.shift();Sr?Sr("warn",i,...j):console.warn(i,...j)}function js(...j){const i="THREE."+j.shift();Sr?Sr("error",i,...j):console.error(i,...j)}function Fl(...j){const i=j.join(" ");i in yl||(yl[i]=!0,_r(...j))}function S0(j,i,l){return new Promise(function(h,f){function g(){switch(j.clientWaitSync(i,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 Bu{addEventListener(i,l){this._listeners===void 0&&(this._listeners={});const h=this._listeners;h[i]===void 0&&(h[i]=[]),h[i].indexOf(l)===-1&&h[i].push(l)}hasEventListener(i,l){const h=this._listeners;return h===void 0?!1:h[i]!==void 0&&h[i].indexOf(l)!==-1}removeEventListener(i,l){const h=this._listeners;if(h===void 0)return;const f=h[i];if(f!==void 0){const g=f.indexOf(l);g!==-1&&f.splice(g,1)}}dispatchEvent(i){const l=this._listeners;if(l===void 0)return;const h=l[i.type];if(h!==void 0){i.target=this;const f=h.slice(0);for(let g=0,v=f.length;g<v;g++)f[g].call(this,i);i.target=null}}}const _a=["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 T0=1234567;const ru=Math.PI/180,Uu=180/Math.PI;function Sl(){const j=Math.random()*4294967295|0,i=Math.random()*4294967295|0,l=Math.random()*4294967295|0,h=Math.random()*4294967295|0;return(_a[j&255]+_a[j>>8&255]+_a[j>>16&255]+_a[j>>24&255]+"-"+_a[i&255]+_a[i>>8&255]+"-"+_a[i>>16&15|64]+_a[i>>24&255]+"-"+_a[l&63|128]+_a[l>>8&255]+"-"+_a[l>>16&255]+_a[l>>24&255]+_a[h&255]+_a[h>>8&255]+_a[h>>16&255]+_a[h>>24&255]).toLowerCase()}function Fr(j,i,l){return Math.max(i,Math.min(l,j))}function np(j,i){return(j%i+i)%i}function E0(j,i,l,h,f){return h+(j-i)*(f-h)/(l-i)}function A0(j,i,l){return j!==i?(l-j)/(i-j):0}function qh(j,i,l){return(1-l)*j+l*i}function qa(j,i,l,h){return qh(j,i,1-Math.exp(-l*h))}function ls(j,i=1){return i-Math.abs(np(j,i*2)-i)}function Yh(j,i,l){return j<=i?0:j>=l?1:(j=(j-i)/(l-i),j*j*(3-2*j))}function yn(j,i,l){return j<=i?0:j>=l?1:(j=(j-i)/(l-i),j*j*j*(j*(j*6-15)+10))}function ea(j,i){return j+Math.floor(Math.random()*(i-j+1))}function ot(j,i){return j+Math.random()*(i-j)}function ip(j){return j*(.5-Math.random())}function Um(j){j!==void 0&&(T0=j);let i=T0+=1831565813;return i=Math.imul(i^i>>>15,i|1),i^=i+Math.imul(i^i>>>7,i|61),((i^i>>>14)>>>0)/4294967296}function $r(j){return j*ru}function rp(j){return j*Uu}function sp(j){return(j&j-1)===0&&j!==0}function C0(j){return Math.pow(2,Math.ceil(Math.log(j)/Math.LN2))}function ch(j){return Math.pow(2,Math.floor(Math.log(j)/Math.LN2))}function uh(j,i,l,h,f){const g=Math.cos,v=Math.sin,C=g(l/2),V=v(l/2),H=g((i+h)/2),J=v((i+h)/2),he=g((i-h)/2),pe=v((i-h)/2),me=g((h-i)/2),Se=v((h-i)/2);switch(f){case"XYX":j.set(C*J,V*he,V*pe,C*H);break;case"YZY":j.set(V*pe,C*J,V*he,C*H);break;case"ZXZ":j.set(V*he,V*pe,C*J,C*H);break;case"XZX":j.set(C*J,V*Se,V*me,C*H);break;case"YXY":j.set(V*me,C*J,V*Se,C*H);break;case"ZYZ":j.set(V*Se,V*me,C*J,C*H);break;default:_r("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+f)}}function Ya(j,i){switch(i.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 ns(j,i){switch(i.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 ol={DEG2RAD:ru,RAD2DEG:Uu,generateUUID:Sl,clamp:Fr,euclideanModulo:np,mapLinear:E0,inverseLerp:A0,lerp:qh,damp:qa,pingpong:ls,smoothstep:Yh,smootherstep:yn,randInt:ea,randFloat:ot,randFloatSpread:ip,seededRandom:Um,degToRad:$r,radToDeg:rp,isPowerOfTwo:sp,ceilPowerOfTwo:C0,floorPowerOfTwo:ch,setQuaternionFromProperEuler:uh,normalize:ns,denormalize:Ya};class oi{constructor(i=0,l=0){oi.prototype.isVector2=!0,this.x=i,this.y=l}get width(){return this.x}set width(i){this.x=i}get height(){return this.y}set height(i){this.y=i}set(i,l){return this.x=i,this.y=l,this}setScalar(i){return this.x=i,this.y=i,this}setX(i){return this.x=i,this}setY(i){return this.y=i,this}setComponent(i,l){switch(i){case 0:this.x=l;break;case 1:this.y=l;break;default:throw new Error("index is out of range: "+i)}return this}getComponent(i){switch(i){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+i)}}clone(){return new this.constructor(this.x,this.y)}copy(i){return this.x=i.x,this.y=i.y,this}add(i){return this.x+=i.x,this.y+=i.y,this}addScalar(i){return this.x+=i,this.y+=i,this}addVectors(i,l){return this.x=i.x+l.x,this.y=i.y+l.y,this}addScaledVector(i,l){return this.x+=i.x*l,this.y+=i.y*l,this}sub(i){return this.x-=i.x,this.y-=i.y,this}subScalar(i){return this.x-=i,this.y-=i,this}subVectors(i,l){return this.x=i.x-l.x,this.y=i.y-l.y,this}multiply(i){return this.x*=i.x,this.y*=i.y,this}multiplyScalar(i){return this.x*=i,this.y*=i,this}divide(i){return this.x/=i.x,this.y/=i.y,this}divideScalar(i){return this.multiplyScalar(1/i)}applyMatrix3(i){const l=this.x,h=this.y,f=i.elements;return this.x=f[0]*l+f[3]*h+f[6],this.y=f[1]*l+f[4]*h+f[7],this}min(i){return this.x=Math.min(this.x,i.x),this.y=Math.min(this.y,i.y),this}max(i){return this.x=Math.max(this.x,i.x),this.y=Math.max(this.y,i.y),this}clamp(i,l){return this.x=Fr(this.x,i.x,l.x),this.y=Fr(this.y,i.y,l.y),this}clampScalar(i,l){return this.x=Fr(this.x,i,l),this.y=Fr(this.y,i,l),this}clampLength(i,l){const h=this.length();return this.divideScalar(h||1).multiplyScalar(Fr(h,i,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(i){return this.x*i.x+this.y*i.y}cross(i){return this.x*i.y-this.y*i.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(i){const l=Math.sqrt(this.lengthSq()*i.lengthSq());if(l===0)return Math.PI/2;const h=this.dot(i)/l;return Math.acos(Fr(h,-1,1))}distanceTo(i){return Math.sqrt(this.distanceToSquared(i))}distanceToSquared(i){const l=this.x-i.x,h=this.y-i.y;return l*l+h*h}manhattanDistanceTo(i){return Math.abs(this.x-i.x)+Math.abs(this.y-i.y)}setLength(i){return this.normalize().multiplyScalar(i)}lerp(i,l){return this.x+=(i.x-this.x)*l,this.y+=(i.y-this.y)*l,this}lerpVectors(i,l,h){return this.x=i.x+(l.x-i.x)*h,this.y=i.y+(l.y-i.y)*h,this}equals(i){return i.x===this.x&&i.y===this.y}fromArray(i,l=0){return this.x=i[l],this.y=i[l+1],this}toArray(i=[],l=0){return i[l]=this.x,i[l+1]=this.y,i}fromBufferAttribute(i,l){return this.x=i.getX(l),this.y=i.getY(l),this}rotateAround(i,l){const h=Math.cos(l),f=Math.sin(l),g=this.x-i.x,v=this.y-i.y;return this.x=g*h-v*f+i.x,this.y=g*f+v*h+i.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class vl{constructor(i=0,l=0,h=0,f=1){this.isQuaternion=!0,this._x=i,this._y=l,this._z=h,this._w=f}static slerpFlat(i,l,h,f,g,v,C){let V=h[f+0],H=h[f+1],J=h[f+2],he=h[f+3],pe=g[v+0],me=g[v+1],Se=g[v+2],tt=g[v+3];if(C<=0){i[l+0]=V,i[l+1]=H,i[l+2]=J,i[l+3]=he;return}if(C>=1){i[l+0]=pe,i[l+1]=me,i[l+2]=Se,i[l+3]=tt;return}if(he!==tt||V!==pe||H!==me||J!==Se){let gt=V*pe+H*me+J*Se+he*tt;gt<0&&(pe=-pe,me=-me,Se=-Se,tt=-tt,gt=-gt);let mt=1-C;if(gt<.9995){const Nt=Math.acos(gt),Pt=Math.sin(Nt);mt=Math.sin(mt*Nt)/Pt,C=Math.sin(C*Nt)/Pt,V=V*mt+pe*C,H=H*mt+me*C,J=J*mt+Se*C,he=he*mt+tt*C}else{V=V*mt+pe*C,H=H*mt+me*C,J=J*mt+Se*C,he=he*mt+tt*C;const Nt=1/Math.sqrt(V*V+H*H+J*J+he*he);V*=Nt,H*=Nt,J*=Nt,he*=Nt}}i[l]=V,i[l+1]=H,i[l+2]=J,i[l+3]=he}static multiplyQuaternionsFlat(i,l,h,f,g,v){const C=h[f],V=h[f+1],H=h[f+2],J=h[f+3],he=g[v],pe=g[v+1],me=g[v+2],Se=g[v+3];return i[l]=C*Se+J*he+V*me-H*pe,i[l+1]=V*Se+J*pe+H*he-C*me,i[l+2]=H*Se+J*me+C*pe-V*he,i[l+3]=J*Se-C*he-V*pe-H*me,i}get x(){return this._x}set x(i){this._x=i,this._onChangeCallback()}get y(){return this._y}set y(i){this._y=i,this._onChangeCallback()}get z(){return this._z}set z(i){this._z=i,this._onChangeCallback()}get w(){return this._w}set w(i){this._w=i,this._onChangeCallback()}set(i,l,h,f){return this._x=i,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(i){return this._x=i.x,this._y=i.y,this._z=i.z,this._w=i.w,this._onChangeCallback(),this}setFromEuler(i,l=!0){const h=i._x,f=i._y,g=i._z,v=i._order,C=Math.cos,V=Math.sin,H=C(h/2),J=C(f/2),he=C(g/2),pe=V(h/2),me=V(f/2),Se=V(g/2);switch(v){case"XYZ":this._x=pe*J*he+H*me*Se,this._y=H*me*he-pe*J*Se,this._z=H*J*Se+pe*me*he,this._w=H*J*he-pe*me*Se;break;case"YXZ":this._x=pe*J*he+H*me*Se,this._y=H*me*he-pe*J*Se,this._z=H*J*Se-pe*me*he,this._w=H*J*he+pe*me*Se;break;case"ZXY":this._x=pe*J*he-H*me*Se,this._y=H*me*he+pe*J*Se,this._z=H*J*Se+pe*me*he,this._w=H*J*he-pe*me*Se;break;case"ZYX":this._x=pe*J*he-H*me*Se,this._y=H*me*he+pe*J*Se,this._z=H*J*Se-pe*me*he,this._w=H*J*he+pe*me*Se;break;case"YZX":this._x=pe*J*he+H*me*Se,this._y=H*me*he+pe*J*Se,this._z=H*J*Se-pe*me*he,this._w=H*J*he-pe*me*Se;break;case"XZY":this._x=pe*J*he-H*me*Se,this._y=H*me*he-pe*J*Se,this._z=H*J*Se+pe*me*he,this._w=H*J*he+pe*me*Se;break;default:_r("Quaternion: .setFromEuler() encountered an unknown order: "+v)}return l===!0&&this._onChangeCallback(),this}setFromAxisAngle(i,l){const h=l/2,f=Math.sin(h);return this._x=i.x*f,this._y=i.y*f,this._z=i.z*f,this._w=Math.cos(h),this._onChangeCallback(),this}setFromRotationMatrix(i){const l=i.elements,h=l[0],f=l[4],g=l[8],v=l[1],C=l[5],V=l[9],H=l[2],J=l[6],he=l[10],pe=h+C+he;if(pe>0){const me=.5/Math.sqrt(pe+1);this._w=.25/me,this._x=(J-V)*me,this._y=(g-H)*me,this._z=(v-f)*me}else if(h>C&&h>he){const me=2*Math.sqrt(1+h-C-he);this._w=(J-V)/me,this._x=.25*me,this._y=(f+v)/me,this._z=(g+H)/me}else if(C>he){const me=2*Math.sqrt(1+C-h-he);this._w=(g-H)/me,this._x=(f+v)/me,this._y=.25*me,this._z=(V+J)/me}else{const me=2*Math.sqrt(1+he-h-C);this._w=(v-f)/me,this._x=(g+H)/me,this._y=(V+J)/me,this._z=.25*me}return this._onChangeCallback(),this}setFromUnitVectors(i,l){let h=i.dot(l)+1;return h<1e-8?(h=0,Math.abs(i.x)>Math.abs(i.z)?(this._x=-i.y,this._y=i.x,this._z=0,this._w=h):(this._x=0,this._y=-i.z,this._z=i.y,this._w=h)):(this._x=i.y*l.z-i.z*l.y,this._y=i.z*l.x-i.x*l.z,this._z=i.x*l.y-i.y*l.x,this._w=h),this.normalize()}angleTo(i){return 2*Math.acos(Math.abs(Fr(this.dot(i),-1,1)))}rotateTowards(i,l){const h=this.angleTo(i);if(h===0)return this;const f=Math.min(1,l/h);return this.slerp(i,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(i){return this._x*i._x+this._y*i._y+this._z*i._z+this._w*i._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 i=this.length();return i===0?(this._x=0,this._y=0,this._z=0,this._w=1):(i=1/i,this._x=this._x*i,this._y=this._y*i,this._z=this._z*i,this._w=this._w*i),this._onChangeCallback(),this}multiply(i){return this.multiplyQuaternions(this,i)}premultiply(i){return this.multiplyQuaternions(i,this)}multiplyQuaternions(i,l){const h=i._x,f=i._y,g=i._z,v=i._w,C=l._x,V=l._y,H=l._z,J=l._w;return this._x=h*J+v*C+f*H-g*V,this._y=f*J+v*V+g*C-h*H,this._z=g*J+v*H+h*V-f*C,this._w=v*J-h*C-f*V-g*H,this._onChangeCallback(),this}slerp(i,l){if(l<=0)return this;if(l>=1)return this.copy(i);let h=i._x,f=i._y,g=i._z,v=i._w,C=this.dot(i);C<0&&(h=-h,f=-f,g=-g,v=-v,C=-C);let V=1-l;if(C<.9995){const H=Math.acos(C),J=Math.sin(H);V=Math.sin(V*H)/J,l=Math.sin(l*H)/J,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(i,l,h){return this.copy(i).slerp(l,h)}random(){const i=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(i),f*Math.cos(i),g*Math.sin(l),g*Math.cos(l))}equals(i){return i._x===this._x&&i._y===this._y&&i._z===this._z&&i._w===this._w}fromArray(i,l=0){return this._x=i[l],this._y=i[l+1],this._z=i[l+2],this._w=i[l+3],this._onChangeCallback(),this}toArray(i=[],l=0){return i[l]=this._x,i[l+1]=this._y,i[l+2]=this._z,i[l+3]=this._w,i}fromBufferAttribute(i,l){return this._x=i.getX(l),this._y=i.getY(l),this._z=i.getZ(l),this._w=i.getW(l),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(i){return this._onChangeCallback=i,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Rt{constructor(i=0,l=0,h=0){Rt.prototype.isVector3=!0,this.x=i,this.y=l,this.z=h}set(i,l,h){return h===void 0&&(h=this.z),this.x=i,this.y=l,this.z=h,this}setScalar(i){return this.x=i,this.y=i,this.z=i,this}setX(i){return this.x=i,this}setY(i){return this.y=i,this}setZ(i){return this.z=i,this}setComponent(i,l){switch(i){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: "+i)}return this}getComponent(i){switch(i){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+i)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(i){return this.x=i.x,this.y=i.y,this.z=i.z,this}add(i){return this.x+=i.x,this.y+=i.y,this.z+=i.z,this}addScalar(i){return this.x+=i,this.y+=i,this.z+=i,this}addVectors(i,l){return this.x=i.x+l.x,this.y=i.y+l.y,this.z=i.z+l.z,this}addScaledVector(i,l){return this.x+=i.x*l,this.y+=i.y*l,this.z+=i.z*l,this}sub(i){return this.x-=i.x,this.y-=i.y,this.z-=i.z,this}subScalar(i){return this.x-=i,this.y-=i,this.z-=i,this}subVectors(i,l){return this.x=i.x-l.x,this.y=i.y-l.y,this.z=i.z-l.z,this}multiply(i){return this.x*=i.x,this.y*=i.y,this.z*=i.z,this}multiplyScalar(i){return this.x*=i,this.y*=i,this.z*=i,this}multiplyVectors(i,l){return this.x=i.x*l.x,this.y=i.y*l.y,this.z=i.z*l.z,this}applyEuler(i){return this.applyQuaternion(Ki.setFromEuler(i))}applyAxisAngle(i,l){return this.applyQuaternion(Ki.setFromAxisAngle(i,l))}applyMatrix3(i){const l=this.x,h=this.y,f=this.z,g=i.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(i){return this.applyMatrix3(i).normalize()}applyMatrix4(i){const l=this.x,h=this.y,f=this.z,g=i.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(i){const l=this.x,h=this.y,f=this.z,g=i.x,v=i.y,C=i.z,V=i.w,H=2*(v*f-C*h),J=2*(C*l-g*f),he=2*(g*h-v*l);return this.x=l+V*H+v*he-C*J,this.y=h+V*J+C*H-g*he,this.z=f+V*he+g*J-v*H,this}project(i){return this.applyMatrix4(i.matrixWorldInverse).applyMatrix4(i.projectionMatrix)}unproject(i){return this.applyMatrix4(i.projectionMatrixInverse).applyMatrix4(i.matrixWorld)}transformDirection(i){const l=this.x,h=this.y,f=this.z,g=i.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(i){return this.x/=i.x,this.y/=i.y,this.z/=i.z,this}divideScalar(i){return this.multiplyScalar(1/i)}min(i){return this.x=Math.min(this.x,i.x),this.y=Math.min(this.y,i.y),this.z=Math.min(this.z,i.z),this}max(i){return this.x=Math.max(this.x,i.x),this.y=Math.max(this.y,i.y),this.z=Math.max(this.z,i.z),this}clamp(i,l){return this.x=Fr(this.x,i.x,l.x),this.y=Fr(this.y,i.y,l.y),this.z=Fr(this.z,i.z,l.z),this}clampScalar(i,l){return this.x=Fr(this.x,i,l),this.y=Fr(this.y,i,l),this.z=Fr(this.z,i,l),this}clampLength(i,l){const h=this.length();return this.divideScalar(h||1).multiplyScalar(Fr(h,i,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(i){return this.x*i.x+this.y*i.y+this.z*i.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(i){return this.normalize().multiplyScalar(i)}lerp(i,l){return this.x+=(i.x-this.x)*l,this.y+=(i.y-this.y)*l,this.z+=(i.z-this.z)*l,this}lerpVectors(i,l,h){return this.x=i.x+(l.x-i.x)*h,this.y=i.y+(l.y-i.y)*h,this.z=i.z+(l.z-i.z)*h,this}cross(i){return this.crossVectors(this,i)}crossVectors(i,l){const h=i.x,f=i.y,g=i.z,v=l.x,C=l.y,V=l.z;return this.x=f*V-g*C,this.y=g*v-h*V,this.z=h*C-f*v,this}projectOnVector(i){const l=i.lengthSq();if(l===0)return this.set(0,0,0);const h=i.dot(this)/l;return this.copy(i).multiplyScalar(h)}projectOnPlane(i){return Kd.copy(this).projectOnVector(i),this.sub(Kd)}reflect(i){return this.sub(Kd.copy(i).multiplyScalar(2*this.dot(i)))}angleTo(i){const l=Math.sqrt(this.lengthSq()*i.lengthSq());if(l===0)return Math.PI/2;const h=this.dot(i)/l;return Math.acos(Fr(h,-1,1))}distanceTo(i){return Math.sqrt(this.distanceToSquared(i))}distanceToSquared(i){const l=this.x-i.x,h=this.y-i.y,f=this.z-i.z;return l*l+h*h+f*f}manhattanDistanceTo(i){return Math.abs(this.x-i.x)+Math.abs(this.y-i.y)+Math.abs(this.z-i.z)}setFromSpherical(i){return this.setFromSphericalCoords(i.radius,i.phi,i.theta)}setFromSphericalCoords(i,l,h){const f=Math.sin(l)*i;return this.x=f*Math.sin(h),this.y=Math.cos(l)*i,this.z=f*Math.cos(h),this}setFromCylindrical(i){return this.setFromCylindricalCoords(i.radius,i.theta,i.y)}setFromCylindricalCoords(i,l,h){return this.x=i*Math.sin(l),this.y=h,this.z=i*Math.cos(l),this}setFromMatrixPosition(i){const l=i.elements;return this.x=l[12],this.y=l[13],this.z=l[14],this}setFromMatrixScale(i){const l=this.setFromMatrixColumn(i,0).length(),h=this.setFromMatrixColumn(i,1).length(),f=this.setFromMatrixColumn(i,2).length();return this.x=l,this.y=h,this.z=f,this}setFromMatrixColumn(i,l){return this.fromArray(i.elements,l*4)}setFromMatrix3Column(i,l){return this.fromArray(i.elements,l*3)}setFromEuler(i){return this.x=i._x,this.y=i._y,this.z=i._z,this}setFromColor(i){return this.x=i.r,this.y=i.g,this.z=i.b,this}equals(i){return i.x===this.x&&i.y===this.y&&i.z===this.z}fromArray(i,l=0){return this.x=i[l],this.y=i[l+1],this.z=i[l+2],this}toArray(i=[],l=0){return i[l]=this.x,i[l+1]=this.y,i[l+2]=this.z,i}fromBufferAttribute(i,l){return this.x=i.getX(l),this.y=i.getY(l),this.z=i.getZ(l),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const i=Math.random()*Math.PI*2,l=Math.random()*2-1,h=Math.sqrt(1-l*l);return this.x=h*Math.cos(i),this.y=l,this.z=h*Math.sin(i),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Kd=new Rt,Ki=new vl;class ua{constructor(i,l,h,f,g,v,C,V,H){ua.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],i!==void 0&&this.set(i,l,h,f,g,v,C,V,H)}set(i,l,h,f,g,v,C,V,H){const J=this.elements;return J[0]=i,J[1]=f,J[2]=C,J[3]=l,J[4]=g,J[5]=V,J[6]=h,J[7]=v,J[8]=H,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(i){const l=this.elements,h=i.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(i,l,h){return i.setFromMatrix3Column(this,0),l.setFromMatrix3Column(this,1),h.setFromMatrix3Column(this,2),this}setFromMatrix4(i){const l=i.elements;return this.set(l[0],l[4],l[8],l[1],l[5],l[9],l[2],l[6],l[10]),this}multiply(i){return this.multiplyMatrices(this,i)}premultiply(i){return this.multiplyMatrices(i,this)}multiplyMatrices(i,l){const h=i.elements,f=l.elements,g=this.elements,v=h[0],C=h[3],V=h[6],H=h[1],J=h[4],he=h[7],pe=h[2],me=h[5],Se=h[8],tt=f[0],gt=f[3],mt=f[6],Nt=f[1],Pt=f[4],Wt=f[7],gn=f[2],Sn=f[5],kn=f[8];return g[0]=v*tt+C*Nt+V*gn,g[3]=v*gt+C*Pt+V*Sn,g[6]=v*mt+C*Wt+V*kn,g[1]=H*tt+J*Nt+he*gn,g[4]=H*gt+J*Pt+he*Sn,g[7]=H*mt+J*Wt+he*kn,g[2]=pe*tt+me*Nt+Se*gn,g[5]=pe*gt+me*Pt+Se*Sn,g[8]=pe*mt+me*Wt+Se*kn,this}multiplyScalar(i){const l=this.elements;return l[0]*=i,l[3]*=i,l[6]*=i,l[1]*=i,l[4]*=i,l[7]*=i,l[2]*=i,l[5]*=i,l[8]*=i,this}determinant(){const i=this.elements,l=i[0],h=i[1],f=i[2],g=i[3],v=i[4],C=i[5],V=i[6],H=i[7],J=i[8];return l*v*J-l*C*H-h*g*J+h*C*V+f*g*H-f*v*V}invert(){const i=this.elements,l=i[0],h=i[1],f=i[2],g=i[3],v=i[4],C=i[5],V=i[6],H=i[7],J=i[8],he=J*v-C*H,pe=C*V-J*g,me=H*g-v*V,Se=l*he+h*pe+f*me;if(Se===0)return this.set(0,0,0,0,0,0,0,0,0);const tt=1/Se;return i[0]=he*tt,i[1]=(f*H-J*h)*tt,i[2]=(C*h-f*v)*tt,i[3]=pe*tt,i[4]=(J*l-f*V)*tt,i[5]=(f*g-C*l)*tt,i[6]=me*tt,i[7]=(h*V-H*l)*tt,i[8]=(v*l-h*g)*tt,this}transpose(){let i;const l=this.elements;return i=l[1],l[1]=l[3],l[3]=i,i=l[2],l[2]=l[6],l[6]=i,i=l[5],l[5]=l[7],l[7]=i,this}getNormalMatrix(i){return this.setFromMatrix4(i).invert().transpose()}transposeIntoArray(i){const l=this.elements;return i[0]=l[0],i[1]=l[3],i[2]=l[6],i[3]=l[1],i[4]=l[4],i[5]=l[7],i[6]=l[2],i[7]=l[5],i[8]=l[8],this}setUvTransform(i,l,h,f,g,v,C){const V=Math.cos(g),H=Math.sin(g);return this.set(h*V,h*H,-h*(V*v+H*C)+v+i,-f*H,f*V,-f*(-H*v+V*C)+C+l,0,0,1),this}scale(i,l){return this.premultiply(ku.makeScale(i,l)),this}rotate(i){return this.premultiply(ku.makeRotation(-i)),this}translate(i,l){return this.premultiply(ku.makeTranslation(i,l)),this}makeTranslation(i,l){return i.isVector2?this.set(1,0,i.x,0,1,i.y,0,0,1):this.set(1,0,i,0,1,l,0,0,1),this}makeRotation(i){const l=Math.cos(i),h=Math.sin(i);return this.set(l,-h,0,h,l,0,0,0,1),this}makeScale(i,l){return this.set(i,0,0,0,l,0,0,0,1),this}equals(i){const l=this.elements,h=i.elements;for(let f=0;f<9;f++)if(l[f]!==h[f])return!1;return!0}fromArray(i,l=0){for(let h=0;h<9;h++)this.elements[h]=i[h+l];return this}toArray(i=[],l=0){const h=this.elements;return i[l]=h[0],i[l+1]=h[1],i[l+2]=h[2],i[l+3]=h[3],i[l+4]=h[4],i[l+5]=h[5],i[l+6]=h[6],i[l+7]=h[7],i[l+8]=h[8],i}clone(){return new this.constructor().fromArray(this.elements)}}const ku=new ua,su=new ua().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),km=new ua().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function zm(){const j={enabled:!0,workingColorSpace:iu,spaces:{},convert:function(f,g,v){return this.enabled===!1||g===v||!g||!v||(this.spaces[g].transfer===Fi&&(f.r=Bl(f.r),f.g=Bl(f.g),f.b=Bl(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=Ic(f.r),f.g=Ic(f.g),f.b=Ic(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===Qo?ah: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 Fl("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),j.workingToColorSpace(f,g)},toWorkingColorSpace:function(f,g){return Fl("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),j.colorSpaceToWorking(f,g)}},i=[.64,.33,.3,.6,.15,.06],l=[.2126,.7152,.0722],h=[.3127,.329];return j.define({[iu]:{primaries:i,whitePoint:h,transfer:ah,toXYZ:su,fromXYZ:km,luminanceCoefficients:l,workingColorSpaceConfig:{unpackColorSpace:co},outputColorSpaceConfig:{drawingBufferColorSpace:co}},[co]:{primaries:i,whitePoint:h,transfer:Fi,toXYZ:su,fromXYZ:km,luminanceCoefficients:l,outputColorSpaceConfig:{drawingBufferColorSpace:co}}}),j}const wo=zm();function Bl(j){return j<.04045?j*.0773993808:Math.pow(j*.9478672986+.0521327014,2.4)}function Ic(j){return j<.0031308?j*12.92:1.055*Math.pow(j,.41666)-.055}let ou;class Wo{static getDataURL(i,l="image/png"){if(/^data:/i.test(i.src)||typeof HTMLCanvasElement=="undefined")return i.src;let h;if(i instanceof HTMLCanvasElement)h=i;else{ou===void 0&&(ou=lc("canvas")),ou.width=i.width,ou.height=i.height;const f=ou.getContext("2d");i instanceof ImageData?f.putImageData(i,0,0):f.drawImage(i,0,0,i.width,i.height),h=ou}return h.toDataURL(l)}static sRGBToLinear(i){if(typeof HTMLImageElement!="undefined"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&i instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&i instanceof ImageBitmap){const l=lc("canvas");l.width=i.width,l.height=i.height;const h=l.getContext("2d");h.drawImage(i,0,0,i.width,i.height);const f=h.getImageData(0,0,i.width,i.height),g=f.data;for(let v=0;v<g.length;v++)g[v]=Bl(g[v]/255)*255;return h.putImageData(f,0,0),l}else if(i.data){const l=i.data.slice(0);for(let h=0;h<l.length;h++)l instanceof Uint8Array||l instanceof Uint8ClampedArray?l[h]=Math.floor(Bl(l[h]/255)*255):l[h]=Bl(l[h]);return{data:l,width:i.width,height:i.height}}else return _r("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),i}}let mr=0;class Za{constructor(i=null){this.isSource=!0,Object.defineProperty(this,"id",{value:mr++}),this.uuid=Sl(),this.data=i,this.dataReady=!0,this.version=0}getSize(i){const l=this.data;return typeof HTMLVideoElement!="undefined"&&l instanceof HTMLVideoElement?i.set(l.videoWidth,l.videoHeight,0):l instanceof VideoFrame?i.set(l.displayHeight,l.displayWidth,0):l!==null?i.set(l.width,l.height,l.depth||0):i.set(0,0,0),i}set needsUpdate(i){i===!0&&this.version++}toJSON(i){const l=i===void 0||typeof i=="string";if(!l&&i.images[this.uuid]!==void 0)return i.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,C=f.length;v<C;v++)f[v].isDataTexture?g.push(cc(f[v].image)):g.push(cc(f[v]))}else g=cc(f);h.url=g}return l||(i.images[this.uuid]=h),h}}function cc(j){return typeof HTMLImageElement!="undefined"&&j instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&j instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&j instanceof ImageBitmap?Wo.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 Jd=0;const op=new Rt;class xl extends Bu{constructor(i=xl.DEFAULT_IMAGE,l=xl.DEFAULT_MAPPING,h=qe,f=qe,g=Rn,v=Qn,C=D,V=Oi,H=xl.DEFAULT_ANISOTROPY,J=Qo){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Jd++}),this.uuid=Sl(),this.name="",this.source=new Za(i),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=C,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 ua,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=J,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(i&&i.depth&&i.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(op).x}get height(){return this.source.getSize(op).y}get depth(){return this.source.getSize(op).z}get image(){return this.source.data}set image(i=null){this.source.data=i}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(i,l){this.updateRanges.push({start:i,count:l})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(i){return this.name=i.name,this.source=i.source,this.mipmaps=i.mipmaps.slice(0),this.mapping=i.mapping,this.channel=i.channel,this.wrapS=i.wrapS,this.wrapT=i.wrapT,this.magFilter=i.magFilter,this.minFilter=i.minFilter,this.anisotropy=i.anisotropy,this.format=i.format,this.internalFormat=i.internalFormat,this.type=i.type,this.offset.copy(i.offset),this.repeat.copy(i.repeat),this.center.copy(i.center),this.rotation=i.rotation,this.matrixAutoUpdate=i.matrixAutoUpdate,this.matrix.copy(i.matrix),this.generateMipmaps=i.generateMipmaps,this.premultiplyAlpha=i.premultiplyAlpha,this.flipY=i.flipY,this.unpackAlignment=i.unpackAlignment,this.colorSpace=i.colorSpace,this.renderTarget=i.renderTarget,this.isRenderTargetTexture=i.isRenderTargetTexture,this.isArrayTexture=i.isArrayTexture,this.userData=JSON.parse(JSON.stringify(i.userData)),this.needsUpdate=!0,this}setValues(i){for(const l in i){const h=i[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(i){const l=i===void 0||typeof i=="string";if(!l&&i.textures[this.uuid]!==void 0)return i.textures[this.uuid];const h={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(i).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||(i.textures[this.uuid]=h),h}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(i){if(this.mapping!==te)return i;if(i.applyMatrix3(this.matrix),i.x<0||i.x>1)switch(this.wrapS){case lt:i.x=i.x-Math.floor(i.x);break;case qe:i.x=i.x<0?0:1;break;case pt:Math.abs(Math.floor(i.x)%2)===1?i.x=Math.ceil(i.x)-i.x:i.x=i.x-Math.floor(i.x);break}if(i.y<0||i.y>1)switch(this.wrapT){case lt:i.y=i.y-Math.floor(i.y);break;case qe:i.y=i.y<0?0:1;break;case pt:Math.abs(Math.floor(i.y)%2)===1?i.y=Math.ceil(i.y)-i.y:i.y=i.y-Math.floor(i.y);break}return this.flipY&&(i.y=1-i.y),i}set needsUpdate(i){i===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(i){i===!0&&this.pmremVersion++}}xl.DEFAULT_IMAGE=null,xl.DEFAULT_MAPPING=te,xl.DEFAULT_ANISOTROPY=1;class Ba{constructor(i=0,l=0,h=0,f=1){Ba.prototype.isVector4=!0,this.x=i,this.y=l,this.z=h,this.w=f}get width(){return this.z}set width(i){this.z=i}get height(){return this.w}set height(i){this.w=i}set(i,l,h,f){return this.x=i,this.y=l,this.z=h,this.w=f,this}setScalar(i){return this.x=i,this.y=i,this.z=i,this.w=i,this}setX(i){return this.x=i,this}setY(i){return this.y=i,this}setZ(i){return this.z=i,this}setW(i){return this.w=i,this}setComponent(i,l){switch(i){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: "+i)}return this}getComponent(i){switch(i){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: "+i)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(i){return this.x=i.x,this.y=i.y,this.z=i.z,this.w=i.w!==void 0?i.w:1,this}add(i){return this.x+=i.x,this.y+=i.y,this.z+=i.z,this.w+=i.w,this}addScalar(i){return this.x+=i,this.y+=i,this.z+=i,this.w+=i,this}addVectors(i,l){return this.x=i.x+l.x,this.y=i.y+l.y,this.z=i.z+l.z,this.w=i.w+l.w,this}addScaledVector(i,l){return this.x+=i.x*l,this.y+=i.y*l,this.z+=i.z*l,this.w+=i.w*l,this}sub(i){return this.x-=i.x,this.y-=i.y,this.z-=i.z,this.w-=i.w,this}subScalar(i){return this.x-=i,this.y-=i,this.z-=i,this.w-=i,this}subVectors(i,l){return this.x=i.x-l.x,this.y=i.y-l.y,this.z=i.z-l.z,this.w=i.w-l.w,this}multiply(i){return this.x*=i.x,this.y*=i.y,this.z*=i.z,this.w*=i.w,this}multiplyScalar(i){return this.x*=i,this.y*=i,this.z*=i,this.w*=i,this}applyMatrix4(i){const l=this.x,h=this.y,f=this.z,g=this.w,v=i.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(i){return this.x/=i.x,this.y/=i.y,this.z/=i.z,this.w/=i.w,this}divideScalar(i){return this.multiplyScalar(1/i)}setAxisAngleFromQuaternion(i){this.w=2*Math.acos(i.w);const l=Math.sqrt(1-i.w*i.w);return l<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=i.x/l,this.y=i.y/l,this.z=i.z/l),this}setAxisAngleFromRotationMatrix(i){let l,h,f,g;const V=i.elements,H=V[0],J=V[4],he=V[8],pe=V[1],me=V[5],Se=V[9],tt=V[2],gt=V[6],mt=V[10];if(Math.abs(J-pe)<.01&&Math.abs(he-tt)<.01&&Math.abs(Se-gt)<.01){if(Math.abs(J+pe)<.1&&Math.abs(he+tt)<.1&&Math.abs(Se+gt)<.1&&Math.abs(H+me+mt-3)<.1)return this.set(1,0,0,0),this;l=Math.PI;const Pt=(H+1)/2,Wt=(me+1)/2,gn=(mt+1)/2,Sn=(J+pe)/4,kn=(he+tt)/4,In=(Se+gt)/4;return Pt>Wt&&Pt>gn?Pt<.01?(h=0,f=.707106781,g=.707106781):(h=Math.sqrt(Pt),f=Sn/h,g=kn/h):Wt>gn?Wt<.01?(h=.707106781,f=0,g=.707106781):(f=Math.sqrt(Wt),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((gt-Se)*(gt-Se)+(he-tt)*(he-tt)+(pe-J)*(pe-J));return Math.abs(Nt)<.001&&(Nt=1),this.x=(gt-Se)/Nt,this.y=(he-tt)/Nt,this.z=(pe-J)/Nt,this.w=Math.acos((H+me+mt-1)/2),this}setFromMatrixPosition(i){const l=i.elements;return this.x=l[12],this.y=l[13],this.z=l[14],this.w=l[15],this}min(i){return this.x=Math.min(this.x,i.x),this.y=Math.min(this.y,i.y),this.z=Math.min(this.z,i.z),this.w=Math.min(this.w,i.w),this}max(i){return this.x=Math.max(this.x,i.x),this.y=Math.max(this.y,i.y),this.z=Math.max(this.z,i.z),this.w=Math.max(this.w,i.w),this}clamp(i,l){return this.x=Fr(this.x,i.x,l.x),this.y=Fr(this.y,i.y,l.y),this.z=Fr(this.z,i.z,l.z),this.w=Fr(this.w,i.w,l.w),this}clampScalar(i,l){return this.x=Fr(this.x,i,l),this.y=Fr(this.y,i,l),this.z=Fr(this.z,i,l),this.w=Fr(this.w,i,l),this}clampLength(i,l){const h=this.length();return this.divideScalar(h||1).multiplyScalar(Fr(h,i,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(i){return this.x*i.x+this.y*i.y+this.z*i.z+this.w*i.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(i){return this.normalize().multiplyScalar(i)}lerp(i,l){return this.x+=(i.x-this.x)*l,this.y+=(i.y-this.y)*l,this.z+=(i.z-this.z)*l,this.w+=(i.w-this.w)*l,this}lerpVectors(i,l,h){return this.x=i.x+(l.x-i.x)*h,this.y=i.y+(l.y-i.y)*h,this.z=i.z+(l.z-i.z)*h,this.w=i.w+(l.w-i.w)*h,this}equals(i){return i.x===this.x&&i.y===this.y&&i.z===this.z&&i.w===this.w}fromArray(i,l=0){return this.x=i[l],this.y=i[l+1],this.z=i[l+2],this.w=i[l+3],this}toArray(i=[],l=0){return i[l]=this.x,i[l+1]=this.y,i[l+2]=this.z,i[l+3]=this.w,i}fromBufferAttribute(i,l){return this.x=i.getX(l),this.y=i.getY(l),this.z=i.getZ(l),this.w=i.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 ha extends null{constructor(i=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=i,this.height=l,this.depth=h.depth,this.scissor=new Ba(0,0,i,l),this.scissorTest=!1,this.viewport=new Ba(0,0,i,l);const f={width:i,height:l,depth:h.depth},g=new xl(f);this.textures=[];const v=h.count;for(let C=0;C<v;C++)this.textures[C]=g.clone(),this.textures[C].isRenderTargetTexture=!0,this.textures[C].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(i={}){const l={minFilter:Rn,generateMipmaps:!1,flipY:!1,internalFormat:null};i.mapping!==void 0&&(l.mapping=i.mapping),i.wrapS!==void 0&&(l.wrapS=i.wrapS),i.wrapT!==void 0&&(l.wrapT=i.wrapT),i.wrapR!==void 0&&(l.wrapR=i.wrapR),i.magFilter!==void 0&&(l.magFilter=i.magFilter),i.minFilter!==void 0&&(l.minFilter=i.minFilter),i.format!==void 0&&(l.format=i.format),i.type!==void 0&&(l.type=i.type),i.anisotropy!==void 0&&(l.anisotropy=i.anisotropy),i.colorSpace!==void 0&&(l.colorSpace=i.colorSpace),i.flipY!==void 0&&(l.flipY=i.flipY),i.generateMipmaps!==void 0&&(l.generateMipmaps=i.generateMipmaps),i.internalFormat!==void 0&&(l.internalFormat=i.internalFormat);for(let h=0;h<this.textures.length;h++)this.textures[h].setValues(l)}get texture(){return this.textures[0]}set texture(i){this.textures[0]=i}set depthTexture(i){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),i!==null&&(i.renderTarget=this),this._depthTexture=i}get depthTexture(){return this._depthTexture}setSize(i,l,h=1){if(this.width!==i||this.height!==l||this.depth!==h){this.width=i,this.height=l,this.depth=h;for(let f=0,g=this.textures.length;f<g;f++)this.textures[f].image.width=i,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,i,l),this.scissor.set(0,0,i,l)}clone(){return new this.constructor().copy(this)}copy(i){this.width=i.width,this.height=i.height,this.depth=i.depth,this.scissor.copy(i.scissor),this.scissorTest=i.scissorTest,this.viewport.copy(i.viewport),this.textures.length=0;for(let l=0,h=i.textures.length;l<h;l++){this.textures[l]=i.textures[l].clone(),this.textures[l].isRenderTargetTexture=!0,this.textures[l].renderTarget=this;const f=Object.assign({},i.textures[l].image);this.textures[l].source=new Za(f)}return this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,i.depthTexture!==null&&(this.depthTexture=i.depthTexture.clone()),this.samples=i.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Zl extends null{constructor(i=1,l=1,h={}){super(i,l,h),this.isWebGLRenderTarget=!0}}class Kl extends null{constructor(i=null,l=1,h=1,f=1){super(null),this.isDataArrayTexture=!0,this.image={data:i,width:l,height:h,depth:f},this.magFilter=Ct,this.minFilter=Ct,this.wrapR=qe,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(i){this.layerUpdates.add(i)}clearLayerUpdates(){this.layerUpdates.clear()}}class Qd extends null{constructor(i=1,l=1,h=1,f={}){super(i,l,f),this.isWebGLArrayRenderTarget=!0,this.depth=h,this.texture=new Kl(null,i,l,h),this._setTextureOptions(f),this.texture.isRenderTargetTexture=!0}}class au extends null{constructor(i=null,l=1,h=1,f=1){super(null),this.isData3DTexture=!0,this.image={data:i,width:l,height:h,depth:f},this.magFilter=Ct,this.minFilter=Ct,this.wrapR=qe,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class hh extends null{constructor(i=1,l=1,h=1,f={}){super(i,l,f),this.isWebGL3DRenderTarget=!0,this.depth=h,this.texture=new au(null,i,l,h),this._setTextureOptions(f),this.texture.isRenderTargetTexture=!0}}class ta{constructor(i=new Rt(1/0,1/0,1/0),l=new Rt(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=i,this.max=l}set(i,l){return this.min.copy(i),this.max.copy(l),this}setFromArray(i){this.makeEmpty();for(let l=0,h=i.length;l<h;l+=3)this.expandByPoint(ba.fromArray(i,l));return this}setFromBufferAttribute(i){this.makeEmpty();for(let l=0,h=i.count;l<h;l++)this.expandByPoint(ba.fromBufferAttribute(i,l));return this}setFromPoints(i){this.makeEmpty();for(let l=0,h=i.length;l<h;l++)this.expandByPoint(i[l]);return this}setFromCenterAndSize(i,l){const h=ba.copy(l).multiplyScalar(.5);return this.min.copy(i).sub(h),this.max.copy(i).add(h),this}setFromObject(i,l=!1){return this.makeEmpty(),this.expandByObject(i,l)}clone(){return new this.constructor().copy(this)}copy(i){return this.min.copy(i.min),this.max.copy(i.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(i){return this.isEmpty()?i.set(0,0,0):i.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(i){return this.isEmpty()?i.set(0,0,0):i.subVectors(this.max,this.min)}expandByPoint(i){return this.min.min(i),this.max.max(i),this}expandByVector(i){return this.min.sub(i),this.max.add(i),this}expandByScalar(i){return this.min.addScalar(-i),this.max.addScalar(i),this}expandByObject(i,l=!1){i.updateWorldMatrix(!1,!1);const h=i.geometry;if(h!==void 0){const g=h.getAttribute("position");if(l===!0&&g!==void 0&&i.isInstancedMesh!==!0)for(let v=0,C=g.count;v<C;v++)i.isMesh===!0?i.getVertexPosition(v,ba):ba.fromBufferAttribute(g,v),ba.applyMatrix4(i.matrixWorld),this.expandByPoint(ba);else i.boundingBox!==void 0?(i.boundingBox===null&&i.computeBoundingBox(),uc.copy(i.boundingBox)):(h.boundingBox===null&&h.computeBoundingBox(),uc.copy(h.boundingBox)),uc.applyMatrix4(i.matrixWorld),this.union(uc)}const f=i.children;for(let g=0,v=f.length;g<v;g++)this.expandByObject(f[g],l);return this}containsPoint(i){return i.x>=this.min.x&&i.x<=this.max.x&&i.y>=this.min.y&&i.y<=this.max.y&&i.z>=this.min.z&&i.z<=this.max.z}containsBox(i){return this.min.x<=i.min.x&&i.max.x<=this.max.x&&this.min.y<=i.min.y&&i.max.y<=this.max.y&&this.min.z<=i.min.z&&i.max.z<=this.max.z}getParameter(i,l){return l.set((i.x-this.min.x)/(this.max.x-this.min.x),(i.y-this.min.y)/(this.max.y-this.min.y),(i.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(i){return i.max.x>=this.min.x&&i.min.x<=this.max.x&&i.max.y>=this.min.y&&i.min.y<=this.max.y&&i.max.z>=this.min.z&&i.min.z<=this.max.z}intersectsSphere(i){return this.clampPoint(i.center,ba),ba.distanceToSquared(i.center)<=i.radius*i.radius}intersectsPlane(i){let l,h;return i.normal.x>0?(l=i.normal.x*this.min.x,h=i.normal.x*this.max.x):(l=i.normal.x*this.max.x,h=i.normal.x*this.min.x),i.normal.y>0?(l+=i.normal.y*this.min.y,h+=i.normal.y*this.max.y):(l+=i.normal.y*this.max.y,h+=i.normal.y*this.min.y),i.normal.z>0?(l+=i.normal.z*this.min.z,h+=i.normal.z*this.max.z):(l+=i.normal.z*this.max.z,h+=i.normal.z*this.min.z),l<=-i.constant&&h>=-i.constant}intersectsTriangle(i){if(this.isEmpty())return!1;this.getCenter(Z),le.subVectors(this.max,Z),hc.subVectors(i.a,Z),Lc.subVectors(i.b,Z),Dc.subVectors(i.c,Z),Tl.subVectors(Lc,hc),se.subVectors(Dc,Lc),$.subVectors(hc,Dc);let l=[0,-Tl.z,Tl.y,0,-se.z,se.y,0,-$.z,$.y,Tl.z,0,-Tl.x,se.z,0,-se.x,$.z,0,-$.x,-Tl.y,Tl.x,0,-se.y,se.x,0,-$.y,$.x,0];return!Ge(l,hc,Lc,Dc,le)||(l=[1,0,0,0,1,0,0,0,1],!Ge(l,hc,Lc,Dc,le))?!1:(we.crossVectors(Tl,se),l=[we.x,we.y,we.z],Ge(l,hc,Lc,Dc,le))}clampPoint(i,l){return l.copy(i).clamp(this.min,this.max)}distanceToPoint(i){return this.clampPoint(i,ba).distanceTo(i)}getBoundingSphere(i){return this.isEmpty()?i.makeEmpty():(this.getCenter(i.center),i.radius=this.getSize(ba).length()*.5),i}intersect(i){return this.min.max(i.min),this.max.min(i.max),this.isEmpty()&&this.makeEmpty(),this}union(i){return this.min.min(i.min),this.max.max(i.max),this}applyMatrix4(i){return this.isEmpty()?this:(Ua[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(i),Ua[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(i),Ua[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(i),Ua[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(i),Ua[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(i),Ua[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(i),Ua[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(i),Ua[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(i),this.setFromPoints(Ua),this)}translate(i){return this.min.add(i),this.max.add(i),this}equals(i){return i.min.equals(this.min)&&i.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(i){return this.min.fromArray(i.min),this.max.fromArray(i.max),this}}const Ua=[new Rt,new Rt,new Rt,new Rt,new Rt,new Rt,new Rt,new Rt],ba=new Rt,uc=new ta,hc=new Rt,Lc=new Rt,Dc=new Rt,Tl=new Rt,se=new Rt,$=new Rt,Z=new Rt,le=new Rt,we=new Rt,Re=new Rt;function Ge(j,i,l,h,f){for(let g=0,v=j.length-3;g<=v;g+=3){Re.fromArray(j,g);const C=f.x*Math.abs(Re.x)+f.y*Math.abs(Re.y)+f.z*Math.abs(Re.z),V=i.dot(Re),H=l.dot(Re),J=h.dot(Re);if(Math.max(-Math.max(V,H,J),Math.min(V,H,J))>C)return!1}return!0}const wt=new ta,Tt=new Rt,Lt=new Rt;class Gt{constructor(i=new Rt,l=-1){this.isSphere=!0,this.center=i,this.radius=l}set(i,l){return this.center.copy(i),this.radius=l,this}setFromPoints(i,l){const h=this.center;l!==void 0?h.copy(l):wt.setFromPoints(i).getCenter(h);let f=0;for(let g=0,v=i.length;g<v;g++)f=Math.max(f,h.distanceToSquared(i[g]));return this.radius=Math.sqrt(f),this}copy(i){return this.center.copy(i.center),this.radius=i.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(i){return i.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(i){return i.distanceTo(this.center)-this.radius}intersectsSphere(i){const l=this.radius+i.radius;return i.center.distanceToSquared(this.center)<=l*l}intersectsBox(i){return i.intersectsSphere(this)}intersectsPlane(i){return Math.abs(i.distanceToPoint(this.center))<=this.radius}clampPoint(i,l){const h=this.center.distanceToSquared(i);return l.copy(i),h>this.radius*this.radius&&(l.sub(this.center).normalize(),l.multiplyScalar(this.radius).add(this.center)),l}getBoundingBox(i){return this.isEmpty()?(i.makeEmpty(),i):(i.set(this.center,this.center),i.expandByScalar(this.radius),i)}applyMatrix4(i){return this.center.applyMatrix4(i),this.radius=this.radius*i.getMaxScaleOnAxis(),this}translate(i){return this.center.add(i),this}expandByPoint(i){if(this.isEmpty())return this.center.copy(i),this.radius=0,this;Tt.subVectors(i,this.center);const l=Tt.lengthSq();if(l>this.radius*this.radius){const h=Math.sqrt(l),f=(h-this.radius)*.5;this.center.addScaledVector(Tt,f/h),this.radius+=f}return this}union(i){return i.isEmpty()?this:this.isEmpty()?(this.copy(i),this):(this.center.equals(i.center)===!0?this.radius=Math.max(this.radius,i.radius):(Lt.subVectors(i.center,this.center).setLength(i.radius),this.expandByPoint(Tt.copy(i.center).add(Lt)),this.expandByPoint(Tt.copy(i.center).sub(Lt))),this)}equals(i){return i.center.equals(this.center)&&i.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(i){return this.radius=i.radius,this.center.fromArray(i.center),this}}const $t=new Rt,hn=new Rt,Ft=new Rt,_n=new Rt,Nn=new Rt,Pn=new Rt,ei=new Rt;class ai{constructor(i=new Rt,l=new Rt(0,0,-1)){this.origin=i,this.direction=l}set(i,l){return this.origin.copy(i),this.direction.copy(l),this}copy(i){return this.origin.copy(i.origin),this.direction.copy(i.direction),this}at(i,l){return l.copy(this.origin).addScaledVector(this.direction,i)}lookAt(i){return this.direction.copy(i).sub(this.origin).normalize(),this}recast(i){return this.origin.copy(this.at(i,$t)),this}closestPointToPoint(i,l){l.subVectors(i,this.origin);const h=l.dot(this.direction);return h<0?l.copy(this.origin):l.copy(this.origin).addScaledVector(this.direction,h)}distanceToPoint(i){return Math.sqrt(this.distanceSqToPoint(i))}distanceSqToPoint(i){const l=$t.subVectors(i,this.origin).dot(this.direction);return l<0?this.origin.distanceToSquared(i):($t.copy(this.origin).addScaledVector(this.direction,l),$t.distanceToSquared(i))}distanceSqToSegment(i,l,h,f){hn.copy(i).add(l).multiplyScalar(.5),Ft.copy(l).sub(i).normalize(),_n.copy(this.origin).sub(hn);const g=i.distanceTo(l)*.5,v=-this.direction.dot(Ft),C=_n.dot(this.direction),V=-_n.dot(Ft),H=_n.lengthSq(),J=Math.abs(1-v*v);let he,pe,me,Se;if(J>0)if(he=v*V-C,pe=v*C-V,Se=g*J,he>=0)if(pe>=-Se)if(pe<=Se){const tt=1/J;he*=tt,pe*=tt,me=he*(he+v*pe+2*C)+pe*(v*he+pe+2*V)+H}else pe=g,he=Math.max(0,-(v*pe+C)),me=-he*he+pe*(pe+2*V)+H;else pe=-g,he=Math.max(0,-(v*pe+C)),me=-he*he+pe*(pe+2*V)+H;else pe<=-Se?(he=Math.max(0,-(-v*g+C)),pe=he>0?-g:Math.min(Math.max(-g,-V),g),me=-he*he+pe*(pe+2*V)+H):pe<=Se?(he=0,pe=Math.min(Math.max(-g,-V),g),me=pe*(pe+2*V)+H):(he=Math.max(0,-(v*g+C)),pe=he>0?g:Math.min(Math.max(-g,-V),g),me=-he*he+pe*(pe+2*V)+H);else pe=v>0?-g:g,he=Math.max(0,-(v*pe+C)),me=-he*he+pe*(pe+2*V)+H;return h&&h.copy(this.origin).addScaledVector(this.direction,he),f&&f.copy(hn).addScaledVector(Ft,pe),me}intersectSphere(i,l){$t.subVectors(i.center,this.origin);const h=$t.dot(this.direction),f=$t.dot($t)-h*h,g=i.radius*i.radius;if(f>g)return null;const v=Math.sqrt(g-f),C=h-v,V=h+v;return V<0?null:C<0?this.at(V,l):this.at(C,l)}intersectsSphere(i){return i.radius<0?!1:this.distanceSqToPoint(i.center)<=i.radius*i.radius}distanceToPlane(i){const l=i.normal.dot(this.direction);if(l===0)return i.distanceToPoint(this.origin)===0?0:null;const h=-(this.origin.dot(i.normal)+i.constant)/l;return h>=0?h:null}intersectPlane(i,l){const h=this.distanceToPlane(i);return h===null?null:this.at(h,l)}intersectsPlane(i){const l=i.distanceToPoint(this.origin);return l===0||i.normal.dot(this.direction)*l<0}intersectBox(i,l){let h,f,g,v,C,V;const H=1/this.direction.x,J=1/this.direction.y,he=1/this.direction.z,pe=this.origin;return H>=0?(h=(i.min.x-pe.x)*H,f=(i.max.x-pe.x)*H):(h=(i.max.x-pe.x)*H,f=(i.min.x-pe.x)*H),J>=0?(g=(i.min.y-pe.y)*J,v=(i.max.y-pe.y)*J):(g=(i.max.y-pe.y)*J,v=(i.min.y-pe.y)*J),h>v||g>f||((g>h||isNaN(h))&&(h=g),(v<f||isNaN(f))&&(f=v),he>=0?(C=(i.min.z-pe.z)*he,V=(i.max.z-pe.z)*he):(C=(i.max.z-pe.z)*he,V=(i.min.z-pe.z)*he),h>V||C>f)||((C>h||h!==h)&&(h=C),(V<f||f!==f)&&(f=V),f<0)?null:this.at(h>=0?h:f,l)}intersectsBox(i){return this.intersectBox(i,$t)!==null}intersectTriangle(i,l,h,f,g){Nn.subVectors(l,i),Pn.subVectors(h,i),ei.crossVectors(Nn,Pn);let v=this.direction.dot(ei),C;if(v>0){if(f)return null;C=1}else if(v<0)C=-1,v=-v;else return null;_n.subVectors(this.origin,i);const V=C*this.direction.dot(Pn.crossVectors(_n,Pn));if(V<0)return null;const H=C*this.direction.dot(Nn.cross(_n));if(H<0||V+H>v)return null;const J=-C*_n.dot(ei);return J<0?null:this.at(J/v,g)}applyMatrix4(i){return this.origin.applyMatrix4(i),this.direction.transformDirection(i),this}equals(i){return i.origin.equals(this.origin)&&i.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class On{constructor(i,l,h,f,g,v,C,V,H,J,he,pe,me,Se,tt,gt){On.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],i!==void 0&&this.set(i,l,h,f,g,v,C,V,H,J,he,pe,me,Se,tt,gt)}set(i,l,h,f,g,v,C,V,H,J,he,pe,me,Se,tt,gt){const mt=this.elements;return mt[0]=i,mt[4]=l,mt[8]=h,mt[12]=f,mt[1]=g,mt[5]=v,mt[9]=C,mt[13]=V,mt[2]=H,mt[6]=J,mt[10]=he,mt[14]=pe,mt[3]=me,mt[7]=Se,mt[11]=tt,mt[15]=gt,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(i){const l=this.elements,h=i.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(i){const l=this.elements,h=i.elements;return l[12]=h[12],l[13]=h[13],l[14]=h[14],this}setFromMatrix3(i){const l=i.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(i,l,h){return i.setFromMatrixColumn(this,0),l.setFromMatrixColumn(this,1),h.setFromMatrixColumn(this,2),this}makeBasis(i,l,h){return this.set(i.x,l.x,h.x,0,i.y,l.y,h.y,0,i.z,l.z,h.z,0,0,0,0,1),this}extractRotation(i){const l=this.elements,h=i.elements,f=1/di.setFromMatrixColumn(i,0).length(),g=1/di.setFromMatrixColumn(i,1).length(),v=1/di.setFromMatrixColumn(i,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(i){const l=this.elements,h=i.x,f=i.y,g=i.z,v=Math.cos(h),C=Math.sin(h),V=Math.cos(f),H=Math.sin(f),J=Math.cos(g),he=Math.sin(g);if(i.order==="XYZ"){const pe=v*J,me=v*he,Se=C*J,tt=C*he;l[0]=V*J,l[4]=-V*he,l[8]=H,l[1]=me+Se*H,l[5]=pe-tt*H,l[9]=-C*V,l[2]=tt-pe*H,l[6]=Se+me*H,l[10]=v*V}else if(i.order==="YXZ"){const pe=V*J,me=V*he,Se=H*J,tt=H*he;l[0]=pe+tt*C,l[4]=Se*C-me,l[8]=v*H,l[1]=v*he,l[5]=v*J,l[9]=-C,l[2]=me*C-Se,l[6]=tt+pe*C,l[10]=v*V}else if(i.order==="ZXY"){const pe=V*J,me=V*he,Se=H*J,tt=H*he;l[0]=pe-tt*C,l[4]=-v*he,l[8]=Se+me*C,l[1]=me+Se*C,l[5]=v*J,l[9]=tt-pe*C,l[2]=-v*H,l[6]=C,l[10]=v*V}else if(i.order==="ZYX"){const pe=v*J,me=v*he,Se=C*J,tt=C*he;l[0]=V*J,l[4]=Se*H-me,l[8]=pe*H+tt,l[1]=V*he,l[5]=tt*H+pe,l[9]=me*H-Se,l[2]=-H,l[6]=C*V,l[10]=v*V}else if(i.order==="YZX"){const pe=v*V,me=v*H,Se=C*V,tt=C*H;l[0]=V*J,l[4]=tt-pe*he,l[8]=Se*he+me,l[1]=he,l[5]=v*J,l[9]=-C*J,l[2]=-H*J,l[6]=me*he+Se,l[10]=pe-tt*he}else if(i.order==="XZY"){const pe=v*V,me=v*H,Se=C*V,tt=C*H;l[0]=V*J,l[4]=-he,l[8]=H*J,l[1]=pe*he+tt,l[5]=v*J,l[9]=me*he-Se,l[2]=Se*he-me,l[6]=C*J,l[10]=tt*he+pe}return l[3]=0,l[7]=0,l[11]=0,l[12]=0,l[13]=0,l[14]=0,l[15]=1,this}makeRotationFromQuaternion(i){return this.compose(ji,i,Qi)}lookAt(i,l,h){const f=this.elements;return yr.subVectors(i,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(i){return this.multiplyMatrices(this,i)}premultiply(i){return this.multiplyMatrices(i,this)}multiplyMatrices(i,l){const h=i.elements,f=l.elements,g=this.elements,v=h[0],C=h[4],V=h[8],H=h[12],J=h[1],he=h[5],pe=h[9],me=h[13],Se=h[2],tt=h[6],gt=h[10],mt=h[14],Nt=h[3],Pt=h[7],Wt=h[11],gn=h[15],Sn=f[0],kn=f[4],In=f[8],ii=f[12],li=f[1],dr=f[5],Yr=f[9],Ss=f[13],eo=f[2],uo=f[6],Aa=f[10],hl=f[14],tc=f[3],Xo=f[7],Ca=f[11],qo=f[15];return g[0]=v*Sn+C*li+V*eo+H*tc,g[4]=v*kn+C*dr+V*uo+H*Xo,g[8]=v*In+C*Yr+V*Aa+H*Ca,g[12]=v*ii+C*Ss+V*hl+H*qo,g[1]=J*Sn+he*li+pe*eo+me*tc,g[5]=J*kn+he*dr+pe*uo+me*Xo,g[9]=J*In+he*Yr+pe*Aa+me*Ca,g[13]=J*ii+he*Ss+pe*hl+me*qo,g[2]=Se*Sn+tt*li+gt*eo+mt*tc,g[6]=Se*kn+tt*dr+gt*uo+mt*Xo,g[10]=Se*In+tt*Yr+gt*Aa+mt*Ca,g[14]=Se*ii+tt*Ss+gt*hl+mt*qo,g[3]=Nt*Sn+Pt*li+Wt*eo+gn*tc,g[7]=Nt*kn+Pt*dr+Wt*uo+gn*Xo,g[11]=Nt*In+Pt*Yr+Wt*Aa+gn*Ca,g[15]=Nt*ii+Pt*Ss+Wt*hl+gn*qo,this}multiplyScalar(i){const l=this.elements;return l[0]*=i,l[4]*=i,l[8]*=i,l[12]*=i,l[1]*=i,l[5]*=i,l[9]*=i,l[13]*=i,l[2]*=i,l[6]*=i,l[10]*=i,l[14]*=i,l[3]*=i,l[7]*=i,l[11]*=i,l[15]*=i,this}determinant(){const i=this.elements,l=i[0],h=i[4],f=i[8],g=i[12],v=i[1],C=i[5],V=i[9],H=i[13],J=i[2],he=i[6],pe=i[10],me=i[14],Se=i[3],tt=i[7],gt=i[11],mt=i[15];return Se*(+g*V*he-f*H*he-g*C*pe+h*H*pe+f*C*me-h*V*me)+tt*(+l*V*me-l*H*pe+g*v*pe-f*v*me+f*H*J-g*V*J)+gt*(+l*H*he-l*C*me-g*v*he+h*v*me+g*C*J-h*H*J)+mt*(-f*C*J-l*V*he+l*C*pe+f*v*he-h*v*pe+h*V*J)}transpose(){const i=this.elements;let l;return l=i[1],i[1]=i[4],i[4]=l,l=i[2],i[2]=i[8],i[8]=l,l=i[6],i[6]=i[9],i[9]=l,l=i[3],i[3]=i[12],i[12]=l,l=i[7],i[7]=i[13],i[13]=l,l=i[11],i[11]=i[14],i[14]=l,this}setPosition(i,l,h){const f=this.elements;return i.isVector3?(f[12]=i.x,f[13]=i.y,f[14]=i.z):(f[12]=i,f[13]=l,f[14]=h),this}invert(){const i=this.elements,l=i[0],h=i[1],f=i[2],g=i[3],v=i[4],C=i[5],V=i[6],H=i[7],J=i[8],he=i[9],pe=i[10],me=i[11],Se=i[12],tt=i[13],gt=i[14],mt=i[15],Nt=he*gt*H-tt*pe*H+tt*V*me-C*gt*me-he*V*mt+C*pe*mt,Pt=Se*pe*H-J*gt*H-Se*V*me+v*gt*me+J*V*mt-v*pe*mt,Wt=J*tt*H-Se*he*H+Se*C*me-v*tt*me-J*C*mt+v*he*mt,gn=Se*he*V-J*tt*V-Se*C*pe+v*tt*pe+J*C*gt-v*he*gt,Sn=l*Nt+h*Pt+f*Wt+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 i[0]=Nt*kn,i[1]=(tt*pe*g-he*gt*g-tt*f*me+h*gt*me+he*f*mt-h*pe*mt)*kn,i[2]=(C*gt*g-tt*V*g+tt*f*H-h*gt*H-C*f*mt+h*V*mt)*kn,i[3]=(he*V*g-C*pe*g-he*f*H+h*pe*H+C*f*me-h*V*me)*kn,i[4]=Pt*kn,i[5]=(J*gt*g-Se*pe*g+Se*f*me-l*gt*me-J*f*mt+l*pe*mt)*kn,i[6]=(Se*V*g-v*gt*g-Se*f*H+l*gt*H+v*f*mt-l*V*mt)*kn,i[7]=(v*pe*g-J*V*g+J*f*H-l*pe*H-v*f*me+l*V*me)*kn,i[8]=Wt*kn,i[9]=(Se*he*g-J*tt*g-Se*h*me+l*tt*me+J*h*mt-l*he*mt)*kn,i[10]=(v*tt*g-Se*C*g+Se*h*H-l*tt*H-v*h*mt+l*C*mt)*kn,i[11]=(J*C*g-v*he*g-J*h*H+l*he*H+v*h*me-l*C*me)*kn,i[12]=gn*kn,i[13]=(J*tt*f-Se*he*f+Se*h*pe-l*tt*pe-J*h*gt+l*he*gt)*kn,i[14]=(Se*C*f-v*tt*f-Se*h*V+l*tt*V+v*h*gt-l*C*gt)*kn,i[15]=(v*he*f-J*C*f+J*h*V-l*he*V-v*h*pe+l*C*pe)*kn,this}scale(i){const l=this.elements,h=i.x,f=i.y,g=i.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 i=this.elements,l=i[0]*i[0]+i[1]*i[1]+i[2]*i[2],h=i[4]*i[4]+i[5]*i[5]+i[6]*i[6],f=i[8]*i[8]+i[9]*i[9]+i[10]*i[10];return Math.sqrt(Math.max(l,h,f))}makeTranslation(i,l,h){return i.isVector3?this.set(1,0,0,i.x,0,1,0,i.y,0,0,1,i.z,0,0,0,1):this.set(1,0,0,i,0,1,0,l,0,0,1,h,0,0,0,1),this}makeRotationX(i){const l=Math.cos(i),h=Math.sin(i);return this.set(1,0,0,0,0,l,-h,0,0,h,l,0,0,0,0,1),this}makeRotationY(i){const l=Math.cos(i),h=Math.sin(i);return this.set(l,0,h,0,0,1,0,0,-h,0,l,0,0,0,0,1),this}makeRotationZ(i){const l=Math.cos(i),h=Math.sin(i);return this.set(l,-h,0,0,h,l,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(i,l){const h=Math.cos(l),f=Math.sin(l),g=1-h,v=i.x,C=i.y,V=i.z,H=g*v,J=g*C;return this.set(H*v+h,H*C-f*V,H*V+f*C,0,H*C+f*V,J*C+h,J*V-f*v,0,H*V-f*C,J*V+f*v,g*V*V+h,0,0,0,0,1),this}makeScale(i,l,h){return this.set(i,0,0,0,0,l,0,0,0,0,h,0,0,0,0,1),this}makeShear(i,l,h,f,g,v){return this.set(1,h,g,0,i,1,v,0,l,f,1,0,0,0,0,1),this}compose(i,l,h){const f=this.elements,g=l._x,v=l._y,C=l._z,V=l._w,H=g+g,J=v+v,he=C+C,pe=g*H,me=g*J,Se=g*he,tt=v*J,gt=v*he,mt=C*he,Nt=V*H,Pt=V*J,Wt=V*he,gn=h.x,Sn=h.y,kn=h.z;return f[0]=(1-(tt+mt))*gn,f[1]=(me+Wt)*gn,f[2]=(Se-Pt)*gn,f[3]=0,f[4]=(me-Wt)*Sn,f[5]=(1-(pe+mt))*Sn,f[6]=(gt+Nt)*Sn,f[7]=0,f[8]=(Se+Pt)*kn,f[9]=(gt-Nt)*kn,f[10]=(1-(pe+tt))*kn,f[11]=0,f[12]=i.x,f[13]=i.y,f[14]=i.z,f[15]=1,this}decompose(i,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(),C=di.set(f[8],f[9],f[10]).length();this.determinant()<0&&(g=-g),i.x=f[12],i.y=f[13],i.z=f[14],Ri.copy(this);const H=1/g,J=1/v,he=1/C;return Ri.elements[0]*=H,Ri.elements[1]*=H,Ri.elements[2]*=H,Ri.elements[4]*=J,Ri.elements[5]*=J,Ri.elements[6]*=J,Ri.elements[8]*=he,Ri.elements[9]*=he,Ri.elements[10]*=he,l.setFromRotationMatrix(Ri),h.x=g,h.y=v,h.z=C,this}makePerspective(i,l,h,f,g,v,C=so,V=!1){const H=this.elements,J=2*g/(l-i),he=2*g/(h-f),pe=(l+i)/(l-i),me=(h+f)/(h-f);let Se,tt;if(V)Se=g/(v-g),tt=v*g/(v-g);else if(C===so)Se=-(v+g)/(v-g),tt=-2*v*g/(v-g);else if(C===ja)Se=-v/(v-g),tt=-v*g/(v-g);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+C);return H[0]=J,H[4]=0,H[8]=pe,H[12]=0,H[1]=0,H[5]=he,H[9]=me,H[13]=0,H[2]=0,H[6]=0,H[10]=Se,H[14]=tt,H[3]=0,H[7]=0,H[11]=-1,H[15]=0,this}makeOrthographic(i,l,h,f,g,v,C=so,V=!1){const H=this.elements,J=2/(l-i),he=2/(h-f),pe=-(l+i)/(l-i),me=-(h+f)/(h-f);let Se,tt;if(V)Se=1/(v-g),tt=v/(v-g);else if(C===so)Se=-2/(v-g),tt=-(v+g)/(v-g);else if(C===ja)Se=-1/(v-g),tt=-g/(v-g);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+C);return H[0]=J,H[4]=0,H[8]=0,H[12]=pe,H[1]=0,H[5]=he,H[9]=0,H[13]=me,H[2]=0,H[6]=0,H[10]=Se,H[14]=tt,H[3]=0,H[7]=0,H[11]=0,H[15]=1,this}equals(i){const l=this.elements,h=i.elements;for(let f=0;f<16;f++)if(l[f]!==h[f])return!1;return!0}fromArray(i,l=0){for(let h=0;h<16;h++)this.elements[h]=i[h+l];return this}toArray(i=[],l=0){const h=this.elements;return i[l]=h[0],i[l+1]=h[1],i[l+2]=h[2],i[l+3]=h[3],i[l+4]=h[4],i[l+5]=h[5],i[l+6]=h[6],i[l+7]=h[7],i[l+8]=h[8],i[l+9]=h[9],i[l+10]=h[10],i[l+11]=h[11],i[l+12]=h[12],i[l+13]=h[13],i[l+14]=h[14],i[l+15]=h[15],i}}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,Nr=new On,Ji=new vl;class cs{constructor(i=0,l=0,h=0,f=cs.DEFAULT_ORDER){this.isEuler=!0,this._x=i,this._y=l,this._z=h,this._order=f}get x(){return this._x}set x(i){this._x=i,this._onChangeCallback()}get y(){return this._y}set y(i){this._y=i,this._onChangeCallback()}get z(){return this._z}set z(i){this._z=i,this._onChangeCallback()}get order(){return this._order}set order(i){this._order=i,this._onChangeCallback()}set(i,l,h,f=this._order){return this._x=i,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(i){return this._x=i._x,this._y=i._y,this._z=i._z,this._order=i._order,this._onChangeCallback(),this}setFromRotationMatrix(i,l=this._order,h=!0){const f=i.elements,g=f[0],v=f[4],C=f[8],V=f[1],H=f[5],J=f[9],he=f[2],pe=f[6],me=f[10];switch(l){case"XYZ":this._y=Math.asin(Fr(C,-1,1)),Math.abs(C)<.9999999?(this._x=Math.atan2(-J,me),this._z=Math.atan2(-v,g)):(this._x=Math.atan2(pe,H),this._z=0);break;case"YXZ":this._x=Math.asin(-Fr(J,-1,1)),Math.abs(J)<.9999999?(this._y=Math.atan2(C,me),this._z=Math.atan2(V,H)):(this._y=Math.atan2(-he,g),this._z=0);break;case"ZXY":this._x=Math.asin(Fr(pe,-1,1)),Math.abs(pe)<.9999999?(this._y=Math.atan2(-he,me),this._z=Math.atan2(-v,H)):(this._y=0,this._z=Math.atan2(V,g));break;case"ZYX":this._y=Math.asin(-Fr(he,-1,1)),Math.abs(he)<.9999999?(this._x=Math.atan2(pe,me),this._z=Math.atan2(V,g)):(this._x=0,this._z=Math.atan2(-v,H));break;case"YZX":this._z=Math.asin(Fr(V,-1,1)),Math.abs(V)<.9999999?(this._x=Math.atan2(-J,H),this._y=Math.atan2(-he,g)):(this._x=0,this._y=Math.atan2(C,me));break;case"XZY":this._z=Math.asin(-Fr(v,-1,1)),Math.abs(v)<.9999999?(this._x=Math.atan2(pe,H),this._y=Math.atan2(C,g)):(this._x=Math.atan2(-J,me),this._y=0);break;default:_r("Euler: .setFromRotationMatrix() encountered an unknown order: "+l)}return this._order=l,h===!0&&this._onChangeCallback(),this}setFromQuaternion(i,l,h){return Nr.makeRotationFromQuaternion(i),this.setFromRotationMatrix(Nr,l,h)}setFromVector3(i,l=this._order){return this.set(i.x,i.y,i.z,l)}reorder(i){return Ji.setFromEuler(this),this.setFromQuaternion(Ji,i)}equals(i){return i._x===this._x&&i._y===this._y&&i._z===this._z&&i._order===this._order}fromArray(i){return this._x=i[0],this._y=i[1],this._z=i[2],i[3]!==void 0&&(this._order=i[3]),this._onChangeCallback(),this}toArray(i=[],l=0){return i[l]=this._x,i[l+1]=this._y,i[l+2]=this._z,i[l+3]=this._order,i}_onChange(i){return this._onChangeCallback=i,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}cs.DEFAULT_ORDER="XYZ";class ds{constructor(){this.mask=1}set(i){this.mask=(1<<i|0)>>>0}enable(i){this.mask|=1<<i|0}enableAll(){this.mask=-1}toggle(i){this.mask^=1<<i|0}disable(i){this.mask&=~(1<<i|0)}disableAll(){this.mask=0}test(i){return(this.mask&i.mask)!==0}isEnabled(i){return(this.mask&(1<<i|0))!==0}}let Es=0;const Gs=new Rt,As=new vl,us=new On,Mi=new Rt,Xi=new Rt,Br=new Rt,kr=new vl,Dr=new Rt(1,0,0),Jr=new Rt(0,1,0),Ls=new Rt(0,0,1),Lo={type:"added"},Ka={type:"removed"},oo={type:"childadded",child:null},al={type:"childremoved",child:null};class xs extends Bu{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Es++}),this.uuid=Sl(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=xs.DEFAULT_UP.clone();const i=new Rt,l=new cs,h=new vl,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:i},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 ua}}),this.matrix=new On,this.matrixWorld=new On,this.matrixAutoUpdate=xs.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=xs.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ds,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(i){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(i),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(i){return this.quaternion.premultiply(i),this}setRotationFromAxisAngle(i,l){this.quaternion.setFromAxisAngle(i,l)}setRotationFromEuler(i){this.quaternion.setFromEuler(i,!0)}setRotationFromMatrix(i){this.quaternion.setFromRotationMatrix(i)}setRotationFromQuaternion(i){this.quaternion.copy(i)}rotateOnAxis(i,l){return As.setFromAxisAngle(i,l),this.quaternion.multiply(As),this}rotateOnWorldAxis(i,l){return As.setFromAxisAngle(i,l),this.quaternion.premultiply(As),this}rotateX(i){return this.rotateOnAxis(Dr,i)}rotateY(i){return this.rotateOnAxis(Jr,i)}rotateZ(i){return this.rotateOnAxis(Ls,i)}translateOnAxis(i,l){return Gs.copy(i).applyQuaternion(this.quaternion),this.position.add(Gs.multiplyScalar(l)),this}translateX(i){return this.translateOnAxis(Dr,i)}translateY(i){return this.translateOnAxis(Jr,i)}translateZ(i){return this.translateOnAxis(Ls,i)}localToWorld(i){return this.updateWorldMatrix(!0,!1),i.applyMatrix4(this.matrixWorld)}worldToLocal(i){return this.updateWorldMatrix(!0,!1),i.applyMatrix4(us.copy(this.matrixWorld).invert())}lookAt(i,l,h){i.isVector3?Mi.copy(i):Mi.set(i,l,h);const f=this.parent;this.updateWorldMatrix(!0,!1),Xi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?us.lookAt(Xi,Mi,this.up):us.lookAt(Mi,Xi,this.up),this.quaternion.setFromRotationMatrix(us),f&&(us.extractRotation(f.matrixWorld),As.setFromRotationMatrix(us),this.quaternion.premultiply(As.invert()))}add(i){if(arguments.length>1){for(let l=0;l<arguments.length;l++)this.add(arguments[l]);return this}return i===this?(js("Object3D.add: object can't be added as a child of itself.",i),this):(i&&i.isObject3D?(i.removeFromParent(),i.parent=this,this.children.push(i),i.dispatchEvent(Lo),oo.child=i,this.dispatchEvent(oo),oo.child=null):js("Object3D.add: object not an instance of THREE.Object3D.",i),this)}remove(i){if(arguments.length>1){for(let h=0;h<arguments.length;h++)this.remove(arguments[h]);return this}const l=this.children.indexOf(i);return l!==-1&&(i.parent=null,this.children.splice(l,1),i.dispatchEvent(Ka),al.child=i,this.dispatchEvent(al),al.child=null),this}removeFromParent(){const i=this.parent;return i!==null&&i.remove(this),this}clear(){return this.remove(...this.children)}attach(i){return this.updateWorldMatrix(!0,!1),us.copy(this.matrixWorld).invert(),i.parent!==null&&(i.parent.updateWorldMatrix(!0,!1),us.multiply(i.parent.matrixWorld)),i.applyMatrix4(us),i.removeFromParent(),i.parent=this,this.children.push(i),i.updateWorldMatrix(!1,!0),i.dispatchEvent(Lo),oo.child=i,this.dispatchEvent(oo),oo.child=null,this}getObjectById(i){return this.getObjectByProperty("id",i)}getObjectByName(i){return this.getObjectByProperty("name",i)}getObjectByProperty(i,l){if(this[i]===l)return this;for(let h=0,f=this.children.length;h<f;h++){const v=this.children[h].getObjectByProperty(i,l);if(v!==void 0)return v}}getObjectsByProperty(i,l,h=[]){this[i]===l&&h.push(this);const f=this.children;for(let g=0,v=f.length;g<v;g++)f[g].getObjectsByProperty(i,l,h);return h}getWorldPosition(i){return this.updateWorldMatrix(!0,!1),i.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(i){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Xi,i,Br),i}getWorldScale(i){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Xi,kr,i),i}getWorldDirection(i){this.updateWorldMatrix(!0,!1);const l=this.matrixWorld.elements;return i.set(l[8],l[9],l[10]).normalize()}raycast(){}traverse(i){i(this);const l=this.children;for(let h=0,f=l.length;h<f;h++)l[h].traverse(i)}traverseVisible(i){if(this.visible===!1)return;i(this);const l=this.children;for(let h=0,f=l.length;h<f;h++)l[h].traverseVisible(i)}traverseAncestors(i){const l=this.parent;l!==null&&(i(l),l.traverseAncestors(i))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(i){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||i)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,i=!0);const l=this.children;for(let h=0,f=l.length;h<f;h++)l[h].updateMatrixWorld(i)}updateWorldMatrix(i,l){const h=this.parent;if(i===!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(i){const l=i===void 0||typeof i=="string",h={};l&&(i={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(C=>ac(qs({},C),{boundingBox:C.boundingBox?C.boundingBox.toJSON():void 0,boundingSphere:C.boundingSphere?C.boundingSphere.toJSON():void 0})),f.instanceInfo=this._instanceInfo.map(C=>qs({},C)),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(i),f.indirectTexture=this._indirectTexture.toJSON(i),this._colorsTexture!==null&&(f.colorsTexture=this._colorsTexture.toJSON(i)),this.boundingSphere!==null&&(f.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(f.boundingBox=this.boundingBox.toJSON()));function g(C,V){return C[V.uuid]===void 0&&(C[V.uuid]=V.toJSON(i)),V.uuid}if(this.isScene)this.background&&(this.background.isColor?f.background=this.background.toJSON():this.background.isTexture&&(f.background=this.background.toJSON(i).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(f.environment=this.environment.toJSON(i).uuid);else if(this.isMesh||this.isLine||this.isPoints){f.geometry=g(i.geometries,this.geometry);const C=this.geometry.parameters;if(C!==void 0&&C.shapes!==void 0){const V=C.shapes;if(Array.isArray(V))for(let H=0,J=V.length;H<J;H++){const he=V[H];g(i.shapes,he)}else g(i.shapes,V)}}if(this.isSkinnedMesh&&(f.bindMode=this.bindMode,f.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(g(i.skeletons,this.skeleton),f.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const C=[];for(let V=0,H=this.material.length;V<H;V++)C.push(g(i.materials,this.material[V]));f.material=C}else f.material=g(i.materials,this.material);if(this.children.length>0){f.children=[];for(let C=0;C<this.children.length;C++)f.children.push(this.children[C].toJSON(i).object)}if(this.animations.length>0){f.animations=[];for(let C=0;C<this.animations.length;C++){const V=this.animations[C];f.animations.push(g(i.animations,V))}}if(l){const C=v(i.geometries),V=v(i.materials),H=v(i.textures),J=v(i.images),he=v(i.shapes),pe=v(i.skeletons),me=v(i.animations),Se=v(i.nodes);C.length>0&&(h.geometries=C),V.length>0&&(h.materials=V),H.length>0&&(h.textures=H),J.length>0&&(h.images=J),he.length>0&&(h.shapes=he),pe.length>0&&(h.skeletons=pe),me.length>0&&(h.animations=me),Se.length>0&&(h.nodes=Se)}return h.object=f,h;function v(C){const V=[];for(const H in C){const J=C[H];delete J.metadata,V.push(J)}return V}}clone(i){return new this.constructor().copy(this,i)}copy(i,l=!0){if(this.name=i.name,this.up.copy(i.up),this.position.copy(i.position),this.rotation.order=i.rotation.order,this.quaternion.copy(i.quaternion),this.scale.copy(i.scale),this.matrix.copy(i.matrix),this.matrixWorld.copy(i.matrixWorld),this.matrixAutoUpdate=i.matrixAutoUpdate,this.matrixWorldAutoUpdate=i.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=i.matrixWorldNeedsUpdate,this.layers.mask=i.layers.mask,this.visible=i.visible,this.castShadow=i.castShadow,this.receiveShadow=i.receiveShadow,this.frustumCulled=i.frustumCulled,this.renderOrder=i.renderOrder,this.animations=i.animations.slice(),this.userData=JSON.parse(JSON.stringify(i.userData)),l===!0)for(let h=0;h<i.children.length;h++){const f=i.children[h];this.add(f.clone())}return this}}xs.DEFAULT_UP=new Rt(0,1,0),xs.DEFAULT_MATRIX_AUTO_UPDATE=!0,xs.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const da=new Rt,Ys=new Rt,Oc=new Rt,Co=new Rt,Ul=new Rt,Ho=new Rt,wa=new Rt,na=new Rt,ll=new Rt,ia=new Rt,is=new Ba,Bs=new Ba,jn=new Ba;class br{constructor(i=new Rt,l=new Rt,h=new Rt){this.a=i,this.b=l,this.c=h}static getNormal(i,l,h,f){f.subVectors(h,l),da.subVectors(i,l),f.cross(da);const g=f.lengthSq();return g>0?f.multiplyScalar(1/Math.sqrt(g)):f.set(0,0,0)}static getBarycoord(i,l,h,f,g){da.subVectors(f,l),Ys.subVectors(h,l),Oc.subVectors(i,l);const v=da.dot(da),C=da.dot(Ys),V=da.dot(Oc),H=Ys.dot(Ys),J=Ys.dot(Oc),he=v*H-C*C;if(he===0)return g.set(0,0,0),null;const pe=1/he,me=(H*V-C*J)*pe,Se=(v*J-C*V)*pe;return g.set(1-me-Se,Se,me)}static containsPoint(i,l,h,f){return this.getBarycoord(i,l,h,f,Co)===null?!1:Co.x>=0&&Co.y>=0&&Co.x+Co.y<=1}static getInterpolation(i,l,h,f,g,v,C,V){return this.getBarycoord(i,l,h,f,Co)===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,Co.x),V.addScaledVector(v,Co.y),V.addScaledVector(C,Co.z),V)}static getInterpolatedAttribute(i,l,h,f,g,v){return is.setScalar(0),Bs.setScalar(0),jn.setScalar(0),is.fromBufferAttribute(i,l),Bs.fromBufferAttribute(i,h),jn.fromBufferAttribute(i,f),v.setScalar(0),v.addScaledVector(is,g.x),v.addScaledVector(Bs,g.y),v.addScaledVector(jn,g.z),v}static isFrontFacing(i,l,h,f){return da.subVectors(h,l),Ys.subVectors(i,l),da.cross(Ys).dot(f)<0}set(i,l,h){return this.a.copy(i),this.b.copy(l),this.c.copy(h),this}setFromPointsAndIndices(i,l,h,f){return this.a.copy(i[l]),this.b.copy(i[h]),this.c.copy(i[f]),this}setFromAttributeAndIndices(i,l,h,f){return this.a.fromBufferAttribute(i,l),this.b.fromBufferAttribute(i,h),this.c.fromBufferAttribute(i,f),this}clone(){return new this.constructor().copy(this)}copy(i){return this.a.copy(i.a),this.b.copy(i.b),this.c.copy(i.c),this}getArea(){return da.subVectors(this.c,this.b),Ys.subVectors(this.a,this.b),da.cross(Ys).length()*.5}getMidpoint(i){return i.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(i){return br.getNormal(this.a,this.b,this.c,i)}getPlane(i){return i.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(i,l){return br.getBarycoord(i,this.a,this.b,this.c,l)}getInterpolation(i,l,h,f,g){return br.getInterpolation(i,this.a,this.b,this.c,l,h,f,g)}containsPoint(i){return br.containsPoint(i,this.a,this.b,this.c)}isFrontFacing(i){return br.isFrontFacing(this.a,this.b,this.c,i)}intersectsBox(i){return i.intersectsTriangle(this)}closestPointToPoint(i,l){const h=this.a,f=this.b,g=this.c;let v,C;Ul.subVectors(f,h),Ho.subVectors(g,h),na.subVectors(i,h);const V=Ul.dot(na),H=Ho.dot(na);if(V<=0&&H<=0)return l.copy(h);ll.subVectors(i,f);const J=Ul.dot(ll),he=Ho.dot(ll);if(J>=0&&he<=J)return l.copy(f);const pe=V*he-J*H;if(pe<=0&&V>=0&&J<=0)return v=V/(V-J),l.copy(h).addScaledVector(Ul,v);ia.subVectors(i,g);const me=Ul.dot(ia),Se=Ho.dot(ia);if(Se>=0&&me<=Se)return l.copy(g);const tt=me*H-V*Se;if(tt<=0&&H>=0&&Se<=0)return C=H/(H-Se),l.copy(h).addScaledVector(Ho,C);const gt=J*Se-me*he;if(gt<=0&&he-J>=0&&me-Se>=0)return wa.subVectors(g,f),C=(he-J)/(he-J+(me-Se)),l.copy(f).addScaledVector(wa,C);const mt=1/(gt+tt+pe);return v=tt*mt,C=pe*mt,l.copy(h).addScaledVector(Ul,v).addScaledVector(Ho,C)}equals(i){return i.a.equals(this.a)&&i.b.equals(this.b)&&i.c.equals(this.c)}}const Do={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},Wr={h:0,s:0,l:0};function vs(j,i,l){return l<0&&(l+=1),l>1&&(l-=1),l<1/6?j+(i-j)*6*l:l<1/2?i:l<2/3?j+(i-j)*6*(2/3-l):j}class ar{constructor(i,l,h){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(i,l,h)}set(i,l,h){if(l===void 0&&h===void 0){const f=i;f&&f.isColor?this.copy(f):typeof f=="number"?this.setHex(f):typeof f=="string"&&this.setStyle(f)}else this.setRGB(i,l,h);return this}setScalar(i){return this.r=i,this.g=i,this.b=i,this}setHex(i,l=co){return i=Math.floor(i),this.r=(i>>16&255)/255,this.g=(i>>8&255)/255,this.b=(i&255)/255,wo.colorSpaceToWorking(this,l),this}setRGB(i,l,h,f=wo.workingColorSpace){return this.r=i,this.g=l,this.b=h,wo.colorSpaceToWorking(this,f),this}setHSL(i,l,h,f=wo.workingColorSpace){if(i=np(i,1),l=Fr(l,0,1),h=Fr(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=vs(v,g,i+1/3),this.g=vs(v,g,i),this.b=vs(v,g,i-1/3)}return wo.colorSpaceToWorking(this,f),this}setStyle(i,l=co){function h(g){g!==void 0&&parseFloat(g)<1&&_r("Color: Alpha component of "+i+" will be ignored.")}let f;if(f=/^(\w+)\(([^\)]*)\)/.exec(i)){let g;const v=f[1],C=f[2];switch(v){case"rgb":case"rgba":if(g=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(C))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(C))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(C))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 "+i)}}else if(f=/^\#([A-Fa-f\d]+)$/.exec(i)){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 "+i)}else if(i&&i.length>0)return this.setColorName(i,l);return this}setColorName(i,l=co){const h=Do[i.toLowerCase()];return h!==void 0?this.setHex(h,l):_r("Color: Unknown color "+i),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(i){return this.r=i.r,this.g=i.g,this.b=i.b,this}copySRGBToLinear(i){return this.r=Bl(i.r),this.g=Bl(i.g),this.b=Bl(i.b),this}copyLinearToSRGB(i){return this.r=Ic(i.r),this.g=Ic(i.g),this.b=Ic(i.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(i=co){return wo.workingToColorSpace(vr.copy(this),i),Math.round(Fr(vr.r*255,0,255))*65536+Math.round(Fr(vr.g*255,0,255))*256+Math.round(Fr(vr.b*255,0,255))}getHexString(i=co){return("000000"+this.getHex(i).toString(16)).slice(-6)}getHSL(i,l=wo.workingColorSpace){wo.workingToColorSpace(vr.copy(this),l);const h=vr.r,f=vr.g,g=vr.b,v=Math.max(h,f,g),C=Math.min(h,f,g);let V,H;const J=(C+v)/2;if(C===v)V=0,H=0;else{const he=v-C;switch(H=J<=.5?he/(v+C):he/(2-v-C),v){case h:V=(f-g)/he+(f<g?6:0);break;case f:V=(g-h)/he+2;break;case g:V=(h-f)/he+4;break}V/=6}return i.h=V,i.s=H,i.l=J,i}getRGB(i,l=wo.workingColorSpace){return wo.workingToColorSpace(vr.copy(this),l),i.r=vr.r,i.g=vr.g,i.b=vr.b,i}getStyle(i=co){wo.workingToColorSpace(vr.copy(this),i);const l=vr.r,h=vr.g,f=vr.b;return i!==co?`color(${i} ${l.toFixed(3)} ${h.toFixed(3)} ${f.toFixed(3)})`:`rgb(${Math.round(l*255)},${Math.round(h*255)},${Math.round(f*255)})`}offsetHSL(i,l,h){return this.getHSL(Ei),this.setHSL(Ei.h+i,Ei.s+l,Ei.l+h)}add(i){return this.r+=i.r,this.g+=i.g,this.b+=i.b,this}addColors(i,l){return this.r=i.r+l.r,this.g=i.g+l.g,this.b=i.b+l.b,this}addScalar(i){return this.r+=i,this.g+=i,this.b+=i,this}sub(i){return this.r=Math.max(0,this.r-i.r),this.g=Math.max(0,this.g-i.g),this.b=Math.max(0,this.b-i.b),this}multiply(i){return this.r*=i.r,this.g*=i.g,this.b*=i.b,this}multiplyScalar(i){return this.r*=i,this.g*=i,this.b*=i,this}lerp(i,l){return this.r+=(i.r-this.r)*l,this.g+=(i.g-this.g)*l,this.b+=(i.b-this.b)*l,this}lerpColors(i,l,h){return this.r=i.r+(l.r-i.r)*h,this.g=i.g+(l.g-i.g)*h,this.b=i.b+(l.b-i.b)*h,this}lerpHSL(i,l){this.getHSL(Ei),i.getHSL(Wr);const h=qh(Ei.h,Wr.h,l),f=qh(Ei.s,Wr.s,l),g=qh(Ei.l,Wr.l,l);return this.setHSL(h,f,g),this}setFromVector3(i){return this.r=i.x,this.g=i.y,this.b=i.z,this}applyMatrix3(i){const l=this.r,h=this.g,f=this.b,g=i.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(i){return i.r===this.r&&i.g===this.g&&i.b===this.b}fromArray(i,l=0){return this.r=i[l],this.g=i[l+1],this.b=i[l+2],this}toArray(i=[],l=0){return i[l]=this.r,i[l+1]=this.g,i[l+2]=this.b,i}fromBufferAttribute(i,l){return this.r=i.getX(l),this.g=i.getY(l),this.b=i.getZ(l),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const vr=new ar;ar.NAMES=Do;let Cs=0;class Ro extends Bu{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Cs++}),this.uuid=Sl(),this.name="",this.type="Material",this.blending=ge,this.side=W,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Ut,this.blendDst=At,this.blendEquation=Ae,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ar(0,0,0),this.blendAlpha=0,this.depthFunc=Y,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Xh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Yl,this.stencilZFail=Yl,this.stencilZPass=Yl,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(i){this._alphaTest>0!=i>0&&this.version++,this._alphaTest=i}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(i){if(i!==void 0)for(const l in i){const h=i[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(i){const l=i===void 0||typeof i=="string";l&&(i={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(i).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(h.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(i).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(h.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(i).uuid,h.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(h.sheenColorMap=this.sheenColorMap.toJSON(i).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(h.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(i).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(i).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(h.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(i).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(i).uuid),this.map&&this.map.isTexture&&(h.map=this.map.toJSON(i).uuid),this.matcap&&this.matcap.isTexture&&(h.matcap=this.matcap.toJSON(i).uuid),this.alphaMap&&this.alphaMap.isTexture&&(h.alphaMap=this.alphaMap.toJSON(i).uuid),this.lightMap&&this.lightMap.isTexture&&(h.lightMap=this.lightMap.toJSON(i).uuid,h.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(h.aoMap=this.aoMap.toJSON(i).uuid,h.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(h.bumpMap=this.bumpMap.toJSON(i).uuid,h.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(h.normalMap=this.normalMap.toJSON(i).uuid,h.normalMapType=this.normalMapType,h.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(h.displacementMap=this.displacementMap.toJSON(i).uuid,h.displacementScale=this.displacementScale,h.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(h.roughnessMap=this.roughnessMap.toJSON(i).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(h.metalnessMap=this.metalnessMap.toJSON(i).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(h.emissiveMap=this.emissiveMap.toJSON(i).uuid),this.specularMap&&this.specularMap.isTexture&&(h.specularMap=this.specularMap.toJSON(i).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(h.specularIntensityMap=this.specularIntensityMap.toJSON(i).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(h.specularColorMap=this.specularColorMap.toJSON(i).uuid),this.envMap&&this.envMap.isTexture&&(h.envMap=this.envMap.toJSON(i).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(i).uuid),this.transmission!==void 0&&(h.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(h.transmissionMap=this.transmissionMap.toJSON(i).uuid),this.thickness!==void 0&&(h.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(h.thicknessMap=this.thicknessMap.toJSON(i).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!==ge&&(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!==Ut&&(h.blendSrc=this.blendSrc),this.blendDst!==At&&(h.blendDst=this.blendDst),this.blendEquation!==Ae&&(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!==Y&&(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!==Xh&&(h.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(h.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(h.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Yl&&(h.stencilFail=this.stencilFail),this.stencilZFail!==Yl&&(h.stencilZFail=this.stencilZFail),this.stencilZPass!==Yl&&(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 C in g){const V=g[C];delete V.metadata,v.push(V)}return v}if(l){const g=f(i.textures),v=f(i.images);g.length>0&&(h.textures=g),v.length>0&&(h.images=v)}return h}clone(){return new this.constructor().copy(this)}copy(i){this.name=i.name,this.blending=i.blending,this.side=i.side,this.vertexColors=i.vertexColors,this.opacity=i.opacity,this.transparent=i.transparent,this.blendSrc=i.blendSrc,this.blendDst=i.blendDst,this.blendEquation=i.blendEquation,this.blendSrcAlpha=i.blendSrcAlpha,this.blendDstAlpha=i.blendDstAlpha,this.blendEquationAlpha=i.blendEquationAlpha,this.blendColor.copy(i.blendColor),this.blendAlpha=i.blendAlpha,this.depthFunc=i.depthFunc,this.depthTest=i.depthTest,this.depthWrite=i.depthWrite,this.stencilWriteMask=i.stencilWriteMask,this.stencilFunc=i.stencilFunc,this.stencilRef=i.stencilRef,this.stencilFuncMask=i.stencilFuncMask,this.stencilFail=i.stencilFail,this.stencilZFail=i.stencilZFail,this.stencilZPass=i.stencilZPass,this.stencilWrite=i.stencilWrite;const l=i.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=i.clipIntersection,this.clipShadows=i.clipShadows,this.shadowSide=i.shadowSide,this.colorWrite=i.colorWrite,this.precision=i.precision,this.polygonOffset=i.polygonOffset,this.polygonOffsetFactor=i.polygonOffsetFactor,this.polygonOffsetUnits=i.polygonOffsetUnits,this.dithering=i.dithering,this.alphaTest=i.alphaTest,this.alphaHash=i.alphaHash,this.alphaToCoverage=i.alphaToCoverage,this.premultipliedAlpha=i.premultipliedAlpha,this.forceSinglePass=i.forceSinglePass,this.visible=i.visible,this.toneMapped=i.toneMapped,this.userData=JSON.parse(JSON.stringify(i.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(i){i===!0&&this.version++}}class Ms extends Ro{constructor(i){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 cs,this.combine=xt,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(i)}copy(i){return super.copy(i),this.color.copy(i.color),this.map=i.map,this.lightMap=i.lightMap,this.lightMapIntensity=i.lightMapIntensity,this.aoMap=i.aoMap,this.aoMapIntensity=i.aoMapIntensity,this.specularMap=i.specularMap,this.alphaMap=i.alphaMap,this.envMap=i.envMap,this.envMapRotation.copy(i.envMapRotation),this.combine=i.combine,this.reflectivity=i.reflectivity,this.refractionRatio=i.refractionRatio,this.wireframe=i.wireframe,this.wireframeLinewidth=i.wireframeLinewidth,this.wireframeLinecap=i.wireframeLinecap,this.wireframeLinejoin=i.wireframeLinejoin,this.fog=i.fog,this}}const Ws=null;function dh(){const j=new ArrayBuffer(4),i=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),C=new Uint32Array(64);for(let V=1;V<1024;++V){let H=V<<13,J=0;for(;!(H&8388608);)H<<=1,J-=8388608;H&=-8388609,J+=947912704,g[V]=H|J}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&&(C[V]=1024);return{floatView:i,uint32View:l,baseTable:h,shiftTable:f,mantissaTable:g,exponentTable:v,offsetTable:C}}function Qr(j){Math.abs(j)>65504&&_r("DataUtils.toHalfFloat(): Value out of range."),j=Fr(j,-65504,65504),Ws.floatView[0]=j;const i=Ws.uint32View[0],l=i>>23&511;return Ws.baseTable[l]+((i&8388607)>>Ws.shiftTable[l])}function Ma(j){const i=j>>10;return Ws.uint32View[0]=Ws.mantissaTable[Ws.offsetTable[i]+(j&1023)]+Ws.exponentTable[i],Ws.floatView[0]}class dc{static toHalfFloat(i){return Qr(i)}static fromHalfFloat(i){return Ma(i)}}const ao=new Rt,fc=new oi;let ka=0;class yo{constructor(i,l,h=!1){if(Array.isArray(i))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:ka++}),this.name="",this.array=i,this.itemSize=l,this.count=i!==void 0?i.length/l:0,this.normalized=h,this.usage=Ou,this.updateRanges=[],this.gpuType=gs,this.version=0}onUploadCallback(){}set needsUpdate(i){i===!0&&this.version++}setUsage(i){return this.usage=i,this}addUpdateRange(i,l){this.updateRanges.push({start:i,count:l})}clearUpdateRanges(){this.updateRanges.length=0}copy(i){return this.name=i.name,this.array=new i.array.constructor(i.array),this.itemSize=i.itemSize,this.count=i.count,this.normalized=i.normalized,this.usage=i.usage,this.gpuType=i.gpuType,this}copyAt(i,l,h){i*=this.itemSize,h*=l.itemSize;for(let f=0,g=this.itemSize;f<g;f++)this.array[i+f]=l.array[h+f];return this}copyArray(i){return this.array.set(i),this}applyMatrix3(i){if(this.itemSize===2)for(let l=0,h=this.count;l<h;l++)fc.fromBufferAttribute(this,l),fc.applyMatrix3(i),this.setXY(l,fc.x,fc.y);else if(this.itemSize===3)for(let l=0,h=this.count;l<h;l++)ao.fromBufferAttribute(this,l),ao.applyMatrix3(i),this.setXYZ(l,ao.x,ao.y,ao.z);return this}applyMatrix4(i){for(let l=0,h=this.count;l<h;l++)ao.fromBufferAttribute(this,l),ao.applyMatrix4(i),this.setXYZ(l,ao.x,ao.y,ao.z);return this}applyNormalMatrix(i){for(let l=0,h=this.count;l<h;l++)ao.fromBufferAttribute(this,l),ao.applyNormalMatrix(i),this.setXYZ(l,ao.x,ao.y,ao.z);return this}transformDirection(i){for(let l=0,h=this.count;l<h;l++)ao.fromBufferAttribute(this,l),ao.transformDirection(i),this.setXYZ(l,ao.x,ao.y,ao.z);return this}set(i,l=0){return this.array.set(i,l),this}getComponent(i,l){let h=this.array[i*this.itemSize+l];return this.normalized&&(h=Ya(h,this.array)),h}setComponent(i,l,h){return this.normalized&&(h=ns(h,this.array)),this.array[i*this.itemSize+l]=h,this}getX(i){let l=this.array[i*this.itemSize];return this.normalized&&(l=Ya(l,this.array)),l}setX(i,l){return this.normalized&&(l=ns(l,this.array)),this.array[i*this.itemSize]=l,this}getY(i){let l=this.array[i*this.itemSize+1];return this.normalized&&(l=Ya(l,this.array)),l}setY(i,l){return this.normalized&&(l=ns(l,this.array)),this.array[i*this.itemSize+1]=l,this}getZ(i){let l=this.array[i*this.itemSize+2];return this.normalized&&(l=Ya(l,this.array)),l}setZ(i,l){return this.normalized&&(l=ns(l,this.array)),this.array[i*this.itemSize+2]=l,this}getW(i){let l=this.array[i*this.itemSize+3];return this.normalized&&(l=Ya(l,this.array)),l}setW(i,l){return this.normalized&&(l=ns(l,this.array)),this.array[i*this.itemSize+3]=l,this}setXY(i,l,h){return i*=this.itemSize,this.normalized&&(l=ns(l,this.array),h=ns(h,this.array)),this.array[i+0]=l,this.array[i+1]=h,this}setXYZ(i,l,h,f){return i*=this.itemSize,this.normalized&&(l=ns(l,this.array),h=ns(h,this.array),f=ns(f,this.array)),this.array[i+0]=l,this.array[i+1]=h,this.array[i+2]=f,this}setXYZW(i,l,h,f,g){return i*=this.itemSize,this.normalized&&(l=ns(l,this.array),h=ns(h,this.array),f=ns(f,this.array),g=ns(g,this.array)),this.array[i+0]=l,this.array[i+1]=h,this.array[i+2]=f,this.array[i+3]=g,this}onUpload(i){return this.onUploadCallback=i,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const i={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(i.name=this.name),this.usage!==Ou&&(i.usage=this.usage),i}}class pc extends null{constructor(i,l,h){super(new Int8Array(i),l,h)}}class Vm extends null{constructor(i,l,h){super(new Uint8Array(i),l,h)}}class Zi extends null{constructor(i,l,h){super(new Uint8ClampedArray(i),l,h)}}class sx extends null{constructor(i,l,h){super(new Int16Array(i),l,h)}}class kl extends yo{constructor(i,l,h){super(new Uint16Array(i),l,h)}}class ef extends null{constructor(i,l,h){super(new Int32Array(i),l,h)}}class zu extends yo{constructor(i,l,h){super(new Uint32Array(i),l,h)}}class zl extends null{constructor(i,l,h){super(new Uint16Array(i),l,h),this.isFloat16BufferAttribute=!0}getX(i){let l=Ma(this.array[i*this.itemSize]);return this.normalized&&(l=Ya(l,this.array)),l}setX(i,l){return this.normalized&&(l=ns(l,this.array)),this.array[i*this.itemSize]=Qr(l),this}getY(i){let l=Ma(this.array[i*this.itemSize+1]);return this.normalized&&(l=Ya(l,this.array)),l}setY(i,l){return this.normalized&&(l=ns(l,this.array)),this.array[i*this.itemSize+1]=Qr(l),this}getZ(i){let l=Ma(this.array[i*this.itemSize+2]);return this.normalized&&(l=Ya(l,this.array)),l}setZ(i,l){return this.normalized&&(l=ns(l,this.array)),this.array[i*this.itemSize+2]=Qr(l),this}getW(i){let l=Ma(this.array[i*this.itemSize+3]);return this.normalized&&(l=Ya(l,this.array)),l}setW(i,l){return this.normalized&&(l=ns(l,this.array)),this.array[i*this.itemSize+3]=Qr(l),this}setXY(i,l,h){return i*=this.itemSize,this.normalized&&(l=ns(l,this.array),h=ns(h,this.array)),this.array[i+0]=Qr(l),this.array[i+1]=Qr(h),this}setXYZ(i,l,h,f){return i*=this.itemSize,this.normalized&&(l=ns(l,this.array),h=ns(h,this.array),f=ns(f,this.array)),this.array[i+0]=Qr(l),this.array[i+1]=Qr(h),this.array[i+2]=Qr(f),this}setXYZW(i,l,h,f,g){return i*=this.itemSize,this.normalized&&(l=ns(l,this.array),h=ns(h,this.array),f=ns(f,this.array),g=ns(g,this.array)),this.array[i+0]=Qr(l),this.array[i+1]=Qr(h),this.array[i+2]=Qr(f),this.array[i+3]=Qr(g),this}}class qi extends yo{constructor(i,l,h){super(new Float32Array(i),l,h)}}let Sa=0;const xr=new On,Vl=new xs,cl=new Rt,fs=new ta,Ta=new ta,_s=new Rt;class Or extends Bu{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Sa++}),this.uuid=Sl(),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(i){return Array.isArray(i)?this.index=new(Ol(i)?zu:kl)(i,1):this.index=i,this}setIndirect(i){return this.indirect=i,this}getIndirect(){return this.indirect}getAttribute(i){return this.attributes[i]}setAttribute(i,l){return this.attributes[i]=l,this}deleteAttribute(i){return delete this.attributes[i],this}hasAttribute(i){return this.attributes[i]!==void 0}addGroup(i,l,h=0){this.groups.push({start:i,count:l,materialIndex:h})}clearGroups(){this.groups=[]}setDrawRange(i,l){this.drawRange.start=i,this.drawRange.count=l}applyMatrix4(i){const l=this.attributes.position;l!==void 0&&(l.applyMatrix4(i),l.needsUpdate=!0);const h=this.attributes.normal;if(h!==void 0){const g=new ua().getNormalMatrix(i);h.applyNormalMatrix(g),h.needsUpdate=!0}const f=this.attributes.tangent;return f!==void 0&&(f.transformDirection(i),f.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(i){return xr.makeRotationFromQuaternion(i),this.applyMatrix4(xr),this}rotateX(i){return xr.makeRotationX(i),this.applyMatrix4(xr),this}rotateY(i){return xr.makeRotationY(i),this.applyMatrix4(xr),this}rotateZ(i){return xr.makeRotationZ(i),this.applyMatrix4(xr),this}translate(i,l,h){return xr.makeTranslation(i,l,h),this.applyMatrix4(xr),this}scale(i,l,h){return xr.makeScale(i,l,h),this.applyMatrix4(xr),this}lookAt(i){return Vl.lookAt(i),Vl.updateMatrix(),this.applyMatrix4(Vl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(cl).negate(),this.translate(cl.x,cl.y,cl.z),this}setFromPoints(i){const l=this.getAttribute("position");if(l===void 0){const h=[];for(let f=0,g=i.length;f<g;f++){const v=i[f];h.push(v.x,v.y,v.z||0)}this.setAttribute("position",new qi(h,3))}else{const h=Math.min(i.length,l.count);for(let f=0;f<h;f++){const g=i[f];l.setXYZ(f,g.x,g.y,g.z||0)}i.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 ta);const i=this.attributes.position,l=this.morphAttributes.position;if(i&&i.isGLBufferAttribute){js("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(i!==void 0){if(this.boundingBox.setFromBufferAttribute(i),l)for(let h=0,f=l.length;h<f;h++){const g=l[h];fs.setFromBufferAttribute(g),this.morphTargetsRelative?(_s.addVectors(this.boundingBox.min,fs.min),this.boundingBox.expandByPoint(_s),_s.addVectors(this.boundingBox.max,fs.max),this.boundingBox.expandByPoint(_s)):(this.boundingBox.expandByPoint(fs.min),this.boundingBox.expandByPoint(fs.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&js('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 Gt);const i=this.attributes.position,l=this.morphAttributes.position;if(i&&i.isGLBufferAttribute){js("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new Rt,1/0);return}if(i){const h=this.boundingSphere.center;if(fs.setFromBufferAttribute(i),l)for(let g=0,v=l.length;g<v;g++){const C=l[g];Ta.setFromBufferAttribute(C),this.morphTargetsRelative?(_s.addVectors(fs.min,Ta.min),fs.expandByPoint(_s),_s.addVectors(fs.max,Ta.max),fs.expandByPoint(_s)):(fs.expandByPoint(Ta.min),fs.expandByPoint(Ta.max))}fs.getCenter(h);let f=0;for(let g=0,v=i.count;g<v;g++)_s.fromBufferAttribute(i,g),f=Math.max(f,h.distanceToSquared(_s));if(l)for(let g=0,v=l.length;g<v;g++){const C=l[g],V=this.morphTargetsRelative;for(let H=0,J=C.count;H<J;H++)_s.fromBufferAttribute(C,H),V&&(cl.fromBufferAttribute(i,H),_s.add(cl)),f=Math.max(f,h.distanceToSquared(_s))}this.boundingSphere.radius=Math.sqrt(f),isNaN(this.boundingSphere.radius)&&js('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const i=this.index,l=this.attributes;if(i===null||l.position===void 0||l.normal===void 0||l.uv===void 0){js("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 yo(new Float32Array(4*h.count),4));const v=this.getAttribute("tangent"),C=[],V=[];for(let In=0;In<h.count;In++)C[In]=new Rt,V[In]=new Rt;const H=new Rt,J=new Rt,he=new Rt,pe=new oi,me=new oi,Se=new oi,tt=new Rt,gt=new Rt;function mt(In,ii,li){H.fromBufferAttribute(h,In),J.fromBufferAttribute(h,ii),he.fromBufferAttribute(h,li),pe.fromBufferAttribute(g,In),me.fromBufferAttribute(g,ii),Se.fromBufferAttribute(g,li),J.sub(H),he.sub(H),me.sub(pe),Se.sub(pe);const dr=1/(me.x*Se.y-Se.x*me.y);isFinite(dr)&&(tt.copy(J).multiplyScalar(Se.y).addScaledVector(he,-me.y).multiplyScalar(dr),gt.copy(he).multiplyScalar(me.x).addScaledVector(J,-Se.x).multiplyScalar(dr),C[In].add(tt),C[ii].add(tt),C[li].add(tt),V[In].add(gt),V[ii].add(gt),V[li].add(gt))}let Nt=this.groups;Nt.length===0&&(Nt=[{start:0,count:i.count}]);for(let In=0,ii=Nt.length;In<ii;++In){const li=Nt[In],dr=li.start,Yr=li.count;for(let Ss=dr,eo=dr+Yr;Ss<eo;Ss+=3)mt(i.getX(Ss+0),i.getX(Ss+1),i.getX(Ss+2))}const Pt=new Rt,Wt=new Rt,gn=new Rt,Sn=new Rt;function kn(In){gn.fromBufferAttribute(f,In),Sn.copy(gn);const ii=C[In];Pt.copy(ii),Pt.sub(gn.multiplyScalar(gn.dot(ii))).normalize(),Wt.crossVectors(Sn,ii);const dr=Wt.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,Yr=li.count;for(let Ss=dr,eo=dr+Yr;Ss<eo;Ss+=3)kn(i.getX(Ss+0)),kn(i.getX(Ss+1)),kn(i.getX(Ss+2))}}computeVertexNormals(){const i=this.index,l=this.getAttribute("position");if(l!==void 0){let h=this.getAttribute("normal");if(h===void 0)h=new yo(new Float32Array(l.count*3),3),this.setAttribute("normal",h);else for(let pe=0,me=h.count;pe<me;pe++)h.setXYZ(pe,0,0,0);const f=new Rt,g=new Rt,v=new Rt,C=new Rt,V=new Rt,H=new Rt,J=new Rt,he=new Rt;if(i)for(let pe=0,me=i.count;pe<me;pe+=3){const Se=i.getX(pe+0),tt=i.getX(pe+1),gt=i.getX(pe+2);f.fromBufferAttribute(l,Se),g.fromBufferAttribute(l,tt),v.fromBufferAttribute(l,gt),J.subVectors(v,g),he.subVectors(f,g),J.cross(he),C.fromBufferAttribute(h,Se),V.fromBufferAttribute(h,tt),H.fromBufferAttribute(h,gt),C.add(J),V.add(J),H.add(J),h.setXYZ(Se,C.x,C.y,C.z),h.setXYZ(tt,V.x,V.y,V.z),h.setXYZ(gt,H.x,H.y,H.z)}else for(let pe=0,me=l.count;pe<me;pe+=3)f.fromBufferAttribute(l,pe+0),g.fromBufferAttribute(l,pe+1),v.fromBufferAttribute(l,pe+2),J.subVectors(v,g),he.subVectors(f,g),J.cross(he),h.setXYZ(pe+0,J.x,J.y,J.z),h.setXYZ(pe+1,J.x,J.y,J.z),h.setXYZ(pe+2,J.x,J.y,J.z);this.normalizeNormals(),h.needsUpdate=!0}}normalizeNormals(){const i=this.attributes.normal;for(let l=0,h=i.count;l<h;l++)_s.fromBufferAttribute(i,l),_s.normalize(),i.setXYZ(l,_s.x,_s.y,_s.z)}toNonIndexed(){function i(C,V){const H=C.array,J=C.itemSize,he=C.normalized,pe=new H.constructor(V.length*J);let me=0,Se=0;for(let tt=0,gt=V.length;tt<gt;tt++){C.isInterleavedBufferAttribute?me=V[tt]*C.data.stride+C.offset:me=V[tt]*J;for(let mt=0;mt<J;mt++)pe[Se++]=H[me++]}return new yo(pe,J,he)}if(this.index===null)return _r("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const l=new Or,h=this.index.array,f=this.attributes;for(const C in f){const V=f[C],H=i(V,h);l.setAttribute(C,H)}const g=this.morphAttributes;for(const C in g){const V=[],H=g[C];for(let J=0,he=H.length;J<he;J++){const pe=H[J],me=i(pe,h);V.push(me)}l.morphAttributes[C]=V}l.morphTargetsRelative=this.morphTargetsRelative;const v=this.groups;for(let C=0,V=v.length;C<V;C++){const H=v[C];l.addGroup(H.start,H.count,H.materialIndex)}return l}toJSON(){const i={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),Object.keys(this.userData).length>0&&(i.userData=this.userData),this.parameters!==void 0){const V=this.parameters;for(const H in V)V[H]!==void 0&&(i[H]=V[H]);return i}i.data={attributes:{}};const l=this.index;l!==null&&(i.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];i.data.attributes[V]=H.toJSON(i.data)}const f={};let g=!1;for(const V in this.morphAttributes){const H=this.morphAttributes[V],J=[];for(let he=0,pe=H.length;he<pe;he++){const me=H[he];J.push(me.toJSON(i.data))}J.length>0&&(f[V]=J,g=!0)}g&&(i.data.morphAttributes=f,i.data.morphTargetsRelative=this.morphTargetsRelative);const v=this.groups;v.length>0&&(i.data.groups=JSON.parse(JSON.stringify(v)));const C=this.boundingSphere;return C!==null&&(i.data.boundingSphere=C.toJSON()),i}clone(){return new this.constructor().copy(this)}copy(i){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const l={};this.name=i.name;const h=i.index;h!==null&&this.setIndex(h.clone());const f=i.attributes;for(const H in f){const J=f[H];this.setAttribute(H,J.clone(l))}const g=i.morphAttributes;for(const H in g){const J=[],he=g[H];for(let pe=0,me=he.length;pe<me;pe++)J.push(he[pe].clone(l));this.morphAttributes[H]=J}this.morphTargetsRelative=i.morphTargetsRelative;const v=i.groups;for(let H=0,J=v.length;H<J;H++){const he=v[H];this.addGroup(he.start,he.count,he.materialIndex)}const C=i.boundingBox;C!==null&&(this.boundingBox=C.clone());const V=i.boundingSphere;return V!==null&&(this.boundingSphere=V.clone()),this.drawRange.start=i.drawRange.start,this.drawRange.count=i.drawRange.count,this.userData=i.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Jl=new On,mc=new ai,lu=new Gt,Zh=new Rt,cu=new Rt,Zs=new Rt,Kh=new Rt,tf=new Rt,Fc=new Rt,Jh=new Rt,Ja=new Rt;class fh extends xs{constructor(i=new Or,l=new Ms){super(),this.isMesh=!0,this.type="Mesh",this.geometry=i,this.material=l,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(i,l){return super.copy(i,l),i.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=i.morphTargetInfluences.slice()),i.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},i.morphTargetDictionary)),this.material=Array.isArray(i.material)?i.material.slice():i.material,this.geometry=i.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 C=f[g].name||String(g);this.morphTargetInfluences.push(0),this.morphTargetDictionary[C]=g}}}}getVertexPosition(i,l){const h=this.geometry,f=h.attributes.position,g=h.morphAttributes.position,v=h.morphTargetsRelative;l.fromBufferAttribute(f,i);const C=this.morphTargetInfluences;if(g&&C){Fc.set(0,0,0);for(let V=0,H=g.length;V<H;V++){const J=C[V],he=g[V];J!==0&&(tf.fromBufferAttribute(he,i),v?Fc.addScaledVector(tf,J):Fc.addScaledVector(tf.sub(l),J))}l.add(Fc)}return l}raycast(i,l){const h=this.geometry,f=this.material,g=this.matrixWorld;f!==void 0&&(h.boundingSphere===null&&h.computeBoundingSphere(),lu.copy(h.boundingSphere),lu.applyMatrix4(g),mc.copy(i.ray).recast(i.near),!(lu.containsPoint(mc.origin)===!1&&(mc.intersectSphere(lu,Zh)===null||mc.origin.distanceToSquared(Zh)>Kf(i.far-i.near,2)))&&(Jl.copy(g).invert(),mc.copy(i.ray).applyMatrix4(Jl),!(h.boundingBox!==null&&mc.intersectsBox(h.boundingBox)===!1)&&this._computeIntersections(i,l,mc)))}_computeIntersections(i,l,h){let f;const g=this.geometry,v=this.material,C=g.index,V=g.attributes.position,H=g.attributes.uv,J=g.attributes.uv1,he=g.attributes.normal,pe=g.groups,me=g.drawRange;if(C!==null)if(Array.isArray(v))for(let Se=0,tt=pe.length;Se<tt;Se++){const gt=pe[Se],mt=v[gt.materialIndex],Nt=Math.max(gt.start,me.start),Pt=Math.min(C.count,Math.min(gt.start+gt.count,me.start+me.count));for(let Wt=Nt,gn=Pt;Wt<gn;Wt+=3){const Sn=C.getX(Wt),kn=C.getX(Wt+1),In=C.getX(Wt+2);f=ap(this,mt,i,h,H,J,he,Sn,kn,In),f&&(f.faceIndex=Math.floor(Wt/3),f.face.materialIndex=gt.materialIndex,l.push(f))}}else{const Se=Math.max(0,me.start),tt=Math.min(C.count,me.start+me.count);for(let gt=Se,mt=tt;gt<mt;gt+=3){const Nt=C.getX(gt),Pt=C.getX(gt+1),Wt=C.getX(gt+2);f=ap(this,v,i,h,H,J,he,Nt,Pt,Wt),f&&(f.faceIndex=Math.floor(gt/3),l.push(f))}}else if(V!==void 0)if(Array.isArray(v))for(let Se=0,tt=pe.length;Se<tt;Se++){const gt=pe[Se],mt=v[gt.materialIndex],Nt=Math.max(gt.start,me.start),Pt=Math.min(V.count,Math.min(gt.start+gt.count,me.start+me.count));for(let Wt=Nt,gn=Pt;Wt<gn;Wt+=3){const Sn=Wt,kn=Wt+1,In=Wt+2;f=ap(this,mt,i,h,H,J,he,Sn,kn,In),f&&(f.faceIndex=Math.floor(Wt/3),f.face.materialIndex=gt.materialIndex,l.push(f))}}else{const Se=Math.max(0,me.start),tt=Math.min(V.count,me.start+me.count);for(let gt=Se,mt=tt;gt<mt;gt+=3){const Nt=gt,Pt=gt+1,Wt=gt+2;f=ap(this,v,i,h,H,J,he,Nt,Pt,Wt),f&&(f.faceIndex=Math.floor(gt/3),l.push(f))}}}}function ox(j,i,l,h,f,g,v,C){let V;if(i.side===K?V=h.intersectTriangle(v,g,f,!0,C):V=h.intersectTriangle(f,g,v,i.side===W,C),V===null)return null;Ja.copy(C),Ja.applyMatrix4(j.matrixWorld);const H=l.ray.origin.distanceTo(Ja);return H<l.near||H>l.far?null:{distance:H,point:Ja.clone(),object:j}}function ap(j,i,l,h,f,g,v,C,V,H){j.getVertexPosition(C,cu),j.getVertexPosition(V,Zs),j.getVertexPosition(H,Kh);const J=ox(j,i,l,h,cu,Zs,Kh,Jh);if(J){const he=new Rt;br.getBarycoord(Jh,cu,Zs,Kh,he),f&&(J.uv=br.getInterpolatedAttribute(f,C,V,H,he,new oi)),g&&(J.uv1=br.getInterpolatedAttribute(g,C,V,H,he,new oi)),v&&(J.normal=br.getInterpolatedAttribute(v,C,V,H,he,new Rt),J.normal.dot(h.direction)>0&&J.normal.multiplyScalar(-1));const pe={a:C,b:V,c:H,normal:new Rt,materialIndex:0};br.getNormal(cu,Zs,Kh,pe.normal),J.face=pe,J.barycoord=he}return J}class Gm extends Or{constructor(i=1,l=1,h=1,f=1,g=1,v=1){super(),this.type="BoxGeometry",this.parameters={width:i,height:l,depth:h,widthSegments:f,heightSegments:g,depthSegments:v};const C=this;f=Math.floor(f),g=Math.floor(g),v=Math.floor(v);const V=[],H=[],J=[],he=[];let pe=0,me=0;Se("z","y","x",-1,-1,h,l,i,v,g,0),Se("z","y","x",1,-1,h,l,-i,v,g,1),Se("x","z","y",1,1,i,h,l,f,v,2),Se("x","z","y",1,-1,i,h,-l,f,v,3),Se("x","y","z",1,-1,i,l,h,f,g,4),Se("x","y","z",-1,-1,i,l,-h,f,g,5),this.setIndex(V),this.setAttribute("position",new qi(H,3)),this.setAttribute("normal",new qi(J,3)),this.setAttribute("uv",new qi(he,2));function Se(tt,gt,mt,Nt,Pt,Wt,gn,Sn,kn,In,ii){const li=Wt/kn,dr=gn/In,Yr=Wt/2,Ss=gn/2,eo=Sn/2,uo=kn+1,Aa=In+1;let hl=0,tc=0;const Xo=new Rt;for(let Ca=0;Ca<Aa;Ca++){const qo=Ca*dr-Ss;for(let Hc=0;Hc<uo;Hc++){const wc=Hc*li-Yr;Xo[tt]=wc*Nt,Xo[gt]=qo*Pt,Xo[mt]=eo,H.push(Xo.x,Xo.y,Xo.z),Xo[tt]=0,Xo[gt]=0,Xo[mt]=Sn>0?1:-1,J.push(Xo.x,Xo.y,Xo.z),he.push(Hc/kn),he.push(1-Ca/In),hl+=1}}for(let Ca=0;Ca<In;Ca++)for(let qo=0;qo<kn;qo++){const Hc=pe+qo+uo*Ca,wc=pe+qo+uo*(Ca+1),Eh=pe+(qo+1)+uo*(Ca+1),Zp=pe+(qo+1)+uo*Ca;V.push(Hc,wc,Zp),V.push(wc,Eh,Zp),tc+=6}C.addGroup(me,tc,ii),me+=tc,pe+=hl}}copy(i){return super.copy(i),this.parameters=Object.assign({},i.parameters),this}static fromJSON(i){return new Gm(i.width,i.height,i.depth,i.widthSegments,i.heightSegments,i.depthSegments)}}function Wm(j){const i={};for(const l in j){i[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()."),i[l][h]=null):i[l][h]=f.clone():Array.isArray(f)?i[l][h]=f.slice():i[l][h]=f}}return i}function Bc(j){const i={};for(let l=0;l<j.length;l++){const h=Wm(j[l]);for(const f in h)i[f]=h[f]}return i}function Hm(j){const i=[];for(let l=0;l<j.length;l++)i.push(j[l].clone());return i}function Qh(j){const i=j.getRenderTarget();return i===null?j.outputColorSpace:i.isXRRenderTarget===!0?i.texture.colorSpace:wo.workingColorSpace}const l1={clone:Wm,merge:Bc};var ax=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fa=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;class ed extends null{constructor(i){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=ax,this.fragmentShader=fa,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,i!==void 0&&this.setValues(i)}copy(i){return super.copy(i),this.fragmentShader=i.fragmentShader,this.vertexShader=i.vertexShader,this.uniforms=Wm(i.uniforms),this.uniformsGroups=Hm(i.uniformsGroups),this.defines=Object.assign({},i.defines),this.wireframe=i.wireframe,this.wireframeLinewidth=i.wireframeLinewidth,this.fog=i.fog,this.lights=i.lights,this.clipping=i.clipping,this.extensions=Object.assign({},i.extensions),this.glslVersion=i.glslVersion,this}toJSON(i){const l=super.toJSON(i);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(i).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 nf extends xs{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new On,this.projectionMatrix=new On,this.projectionMatrixInverse=new On,this.coordinateSystem=so,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(i,l){return super.copy(i,l),this.matrixWorldInverse.copy(i.matrixWorldInverse),this.projectionMatrix.copy(i.projectionMatrix),this.projectionMatrixInverse.copy(i.projectionMatrixInverse),this.coordinateSystem=i.coordinateSystem,this}getWorldDirection(i){return super.getWorldDirection(i).negate()}updateMatrixWorld(i){super.updateMatrixWorld(i),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(i,l){super.updateWorldMatrix(i,l),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Vu=new Rt,ph=new oi,R0=new oi;class ul extends null{constructor(i=50,l=1,h=.1,f=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=i,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(i,l){return super.copy(i,l),this.fov=i.fov,this.zoom=i.zoom,this.near=i.near,this.far=i.far,this.focus=i.focus,this.aspect=i.aspect,this.view=i.view===null?null:Object.assign({},i.view),this.filmGauge=i.filmGauge,this.filmOffset=i.filmOffset,this}setFocalLength(i){const l=.5*this.getFilmHeight()/i;this.fov=Uu*2*Math.atan(l),this.updateProjectionMatrix()}getFocalLength(){const i=Math.tan(ru*.5*this.fov);return .5*this.getFilmHeight()/i}getEffectiveFOV(){return Uu*2*Math.atan(Math.tan(ru*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(i,l,h){Vu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),l.set(Vu.x,Vu.y).multiplyScalar(-i/Vu.z),Vu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),h.set(Vu.x,Vu.y).multiplyScalar(-i/Vu.z)}getViewSize(i,l){return this.getViewBounds(i,ph,R0),l.subVectors(R0,ph)}setViewOffset(i,l,h,f,g,v){this.aspect=i/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=i,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 i=this.near;let l=i*Math.tan(ru*.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 C=this.filmOffset;C!==0&&(g+=i*C/this.getFilmWidth()),this.projectionMatrix.makePerspective(g,g+f,l,l-h,i,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(i){const l=super.toJSON(i);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 rf=null,Gu=1;class N0 extends null{constructor(i,l,h){super(),this.type="CubeCamera",this.renderTarget=h,this.coordinateSystem=null,this.activeMipmapLevel=0;const f=new ul(rf,Gu,i,l);f.layers=this.layers,this.add(f);const g=new ul(rf,Gu,i,l);g.layers=this.layers,this.add(g);const v=new ul(rf,Gu,i,l);v.layers=this.layers,this.add(v);const C=new ul(rf,Gu,i,l);C.layers=this.layers,this.add(C);const V=new ul(rf,Gu,i,l);V.layers=this.layers,this.add(V);const H=new ul(rf,Gu,i,l);H.layers=this.layers,this.add(H)}updateCoordinateSystem(){const i=this.coordinateSystem,l=this.children.concat(),[h,f,g,v,C,V]=l;for(const H of l)this.remove(H);if(i===so)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),C.up.set(0,1,0),C.lookAt(0,0,1),V.up.set(0,1,0),V.lookAt(0,0,-1);else if(i===ja)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),C.up.set(0,-1,0),C.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: "+i);for(const H of l)this.add(H),H.updateMatrixWorld()}update(i,l){this.parent===null&&this.updateMatrixWorld();const{renderTarget:h,activeMipmapLevel:f}=this;this.coordinateSystem!==i.coordinateSystem&&(this.coordinateSystem=i.coordinateSystem,this.updateCoordinateSystem());const[g,v,C,V,H,J]=this.children,he=i.getRenderTarget(),pe=i.getActiveCubeFace(),me=i.getActiveMipmapLevel(),Se=i.xr.enabled;i.xr.enabled=!1;const tt=h.texture.generateMipmaps;h.texture.generateMipmaps=!1,i.setRenderTarget(h,0,f),i.render(l,g),i.setRenderTarget(h,1,f),i.render(l,v),i.setRenderTarget(h,2,f),i.render(l,C),i.setRenderTarget(h,3,f),i.render(l,V),i.setRenderTarget(h,4,f),i.render(l,H),h.texture.generateMipmaps=tt,i.setRenderTarget(h,5,f),i.render(l,J),i.setRenderTarget(he,pe,me),i.xr.enabled=Se,h.texture.needsPMREMUpdate=!0}}class lp extends null{constructor(i=[],l=Fe,h,f,g,v,C,V,H,J){super(i,l,h,f,g,v,C,V,H,J),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(i){this.image=i}}class $m extends null{constructor(i=1,l={}){super(i,i,l),this.isWebGLCubeRenderTarget=!0;const h={width:i,height:i,depth:1},f=[h,h,h,h,h,h];this.texture=new lp(f),this._setTextureOptions(l),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(i,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 Gm(5,5,5),g=new ed({name:"CubemapFromEquirect",uniforms:Wm(h.uniforms),vertexShader:h.vertexShader,fragmentShader:h.fragmentShader,side:K,blending:ye});g.uniforms.tEquirect.value=l;const v=new fh(f,g),C=l.minFilter;return l.minFilter===Qn&&(l.minFilter=Rn),new N0(1,10,this).update(i,v),l.minFilter=C,v.geometry.dispose(),v.material.dispose(),this}clear(i,l=!0,h=!0,f=!0){const g=i.getRenderTarget();for(let v=0;v<6;v++)i.setRenderTarget(this,v),i.clear(l,h,f);i.setRenderTarget(g)}}class Wu extends xs{constructor(){super(),this.isGroup=!0,this.type="Group"}}const El={type:"move"};class sf{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Wu,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 Wu,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 Wu,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(i){return this._targetRay!==null&&this._targetRay.dispatchEvent(i),this._grip!==null&&this._grip.dispatchEvent(i),this._hand!==null&&this._hand.dispatchEvent(i),this}connect(i){if(i&&i.hand){const l=this._hand;if(l)for(const h of i.hand.values())this._getHandJoint(l,h)}return this.dispatchEvent({type:"connected",data:i}),this}disconnect(i){return this.dispatchEvent({type:"disconnected",data:i}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(i,l,h){let f=null,g=null,v=null;const C=this._targetRay,V=this._grip,H=this._hand;if(i&&l.session.visibilityState!=="visible-blurred"){if(H&&i.hand){v=!0;for(const tt of i.hand.values()){const gt=l.getJointPose(tt,h),mt=this._getHandJoint(H,tt);gt!==null&&(mt.matrix.fromArray(gt.transform.matrix),mt.matrix.decompose(mt.position,mt.rotation,mt.scale),mt.matrixWorldNeedsUpdate=!0,mt.jointRadius=gt.radius),mt.visible=gt!==null}const J=H.joints["index-finger-tip"],he=H.joints["thumb-tip"],pe=J.position.distanceTo(he.position),me=.02,Se=.005;H.inputState.pinching&&pe>me+Se?(H.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:i.handedness,target:this})):!H.inputState.pinching&&pe<=me-Se&&(H.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:i.handedness,target:this}))}else V!==null&&i.gripSpace&&(g=l.getPose(i.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));C!==null&&(f=l.getPose(i.targetRaySpace,h),f===null&&g!==null&&(f=g),f!==null&&(C.matrix.fromArray(f.transform.matrix),C.matrix.decompose(C.position,C.rotation,C.scale),C.matrixWorldNeedsUpdate=!0,f.linearVelocity?(C.hasLinearVelocity=!0,C.linearVelocity.copy(f.linearVelocity)):C.hasLinearVelocity=!1,f.angularVelocity?(C.hasAngularVelocity=!0,C.angularVelocity.copy(f.angularVelocity)):C.hasAngularVelocity=!1,this.dispatchEvent(El)))}return C!==null&&(C.visible=f!==null),V!==null&&(V.visible=g!==null),H!==null&&(H.visible=v!==null),this}_getHandJoint(i,l){if(i.joints[l.jointName]===void 0){const h=new Wu;h.matrixAutoUpdate=!1,h.visible=!1,i.joints[l.jointName]=h,i.add(h)}return i.joints[l.jointName]}}class cp{constructor(i,l=25e-5){this.isFogExp2=!0,this.name="",this.color=new ar(i),this.density=l}clone(){return new cp(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class mh{constructor(i,l=1,h=1e3){this.isFog=!0,this.name="",this.color=new ar(i),this.near=l,this.far=h}clone(){return new mh(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class up 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 cs,this.environmentIntensity=1,this.environmentRotation=new cs,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(i,l){return super.copy(i,l),i.background!==null&&(this.background=i.background.clone()),i.environment!==null&&(this.environment=i.environment.clone()),i.fog!==null&&(this.fog=i.fog.clone()),this.backgroundBlurriness=i.backgroundBlurriness,this.backgroundIntensity=i.backgroundIntensity,this.backgroundRotation.copy(i.backgroundRotation),this.environmentIntensity=i.environmentIntensity,this.environmentRotation.copy(i.environmentRotation),i.overrideMaterial!==null&&(this.overrideMaterial=i.overrideMaterial.clone()),this.matrixAutoUpdate=i.matrixAutoUpdate,this}toJSON(i){const l=super.toJSON(i);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 td{constructor(i,l){this.isInterleavedBuffer=!0,this.array=i,this.stride=l,this.count=i!==void 0?i.length/l:0,this.usage=Ou,this.updateRanges=[],this.version=0,this.uuid=Sl()}onUploadCallback(){}set needsUpdate(i){i===!0&&this.version++}setUsage(i){return this.usage=i,this}addUpdateRange(i,l){this.updateRanges.push({start:i,count:l})}clearUpdateRanges(){this.updateRanges.length=0}copy(i){return this.array=new i.array.constructor(i.array),this.count=i.count,this.stride=i.stride,this.usage=i.usage,this}copyAt(i,l,h){i*=this.stride,h*=l.stride;for(let f=0,g=this.stride;f<g;f++)this.array[i+f]=l.array[h+f];return this}set(i,l=0){return this.array.set(i,l),this}clone(i){i.arrayBuffers===void 0&&(i.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Sl()),i.arrayBuffers[this.array.buffer._uuid]===void 0&&(i.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const l=new this.array.constructor(i.arrayBuffers[this.array.buffer._uuid]),h=new this.constructor(l,this.stride);return h.setUsage(this.usage),h}onUpload(i){return this.onUploadCallback=i,this}toJSON(i){return i.arrayBuffers===void 0&&(i.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Sl()),i.arrayBuffers[this.array.buffer._uuid]===void 0&&(i.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 Ea=new Rt;class Uc{constructor(i,l,h,f=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=i,this.itemSize=l,this.offset=h,this.normalized=f}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(i){this.data.needsUpdate=i}applyMatrix4(i){for(let l=0,h=this.data.count;l<h;l++)Ea.fromBufferAttribute(this,l),Ea.applyMatrix4(i),this.setXYZ(l,Ea.x,Ea.y,Ea.z);return this}applyNormalMatrix(i){for(let l=0,h=this.count;l<h;l++)Ea.fromBufferAttribute(this,l),Ea.applyNormalMatrix(i),this.setXYZ(l,Ea.x,Ea.y,Ea.z);return this}transformDirection(i){for(let l=0,h=this.count;l<h;l++)Ea.fromBufferAttribute(this,l),Ea.transformDirection(i),this.setXYZ(l,Ea.x,Ea.y,Ea.z);return this}getComponent(i,l){let h=this.array[i*this.data.stride+this.offset+l];return this.normalized&&(h=Ya(h,this.array)),h}setComponent(i,l,h){return this.normalized&&(h=ns(h,this.array)),this.data.array[i*this.data.stride+this.offset+l]=h,this}setX(i,l){return this.normalized&&(l=ns(l,this.array)),this.data.array[i*this.data.stride+this.offset]=l,this}setY(i,l){return this.normalized&&(l=ns(l,this.array)),this.data.array[i*this.data.stride+this.offset+1]=l,this}setZ(i,l){return this.normalized&&(l=ns(l,this.array)),this.data.array[i*this.data.stride+this.offset+2]=l,this}setW(i,l){return this.normalized&&(l=ns(l,this.array)),this.data.array[i*this.data.stride+this.offset+3]=l,this}getX(i){let l=this.data.array[i*this.data.stride+this.offset];return this.normalized&&(l=Ya(l,this.array)),l}getY(i){let l=this.data.array[i*this.data.stride+this.offset+1];return this.normalized&&(l=Ya(l,this.array)),l}getZ(i){let l=this.data.array[i*this.data.stride+this.offset+2];return this.normalized&&(l=Ya(l,this.array)),l}getW(i){let l=this.data.array[i*this.data.stride+this.offset+3];return this.normalized&&(l=Ya(l,this.array)),l}setXY(i,l,h){return i=i*this.data.stride+this.offset,this.normalized&&(l=ns(l,this.array),h=ns(h,this.array)),this.data.array[i+0]=l,this.data.array[i+1]=h,this}setXYZ(i,l,h,f){return i=i*this.data.stride+this.offset,this.normalized&&(l=ns(l,this.array),h=ns(h,this.array),f=ns(f,this.array)),this.data.array[i+0]=l,this.data.array[i+1]=h,this.data.array[i+2]=f,this}setXYZW(i,l,h,f,g){return i=i*this.data.stride+this.offset,this.normalized&&(l=ns(l,this.array),h=ns(h,this.array),f=ns(f,this.array),g=ns(g,this.array)),this.data.array[i+0]=l,this.data.array[i+1]=h,this.data.array[i+2]=f,this.data.array[i+3]=g,this}clone(i){if(i===void 0){Bm("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 yo(new this.array.constructor(l),this.itemSize,this.normalized)}else return i.interleavedBuffers===void 0&&(i.interleavedBuffers={}),i.interleavedBuffers[this.data.uuid]===void 0&&(i.interleavedBuffers[this.data.uuid]=this.data.clone(i)),new Uc(i.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(i){if(i===void 0){Bm("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 i.interleavedBuffers===void 0&&(i.interleavedBuffers={}),i.interleavedBuffers[this.data.uuid]===void 0&&(i.interleavedBuffers[this.data.uuid]=this.data.toJSON(i)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class nd extends Ro{constructor(i){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(i)}copy(i){return super.copy(i),this.color.copy(i.color),this.map=i.map,this.alphaMap=i.alphaMap,this.rotation=i.rotation,this.sizeAttenuation=i.sizeAttenuation,this.fog=i.fog,this}}let id;const gh=new Rt,uu=new Rt,Hu=new Rt,rd=new oi,sd=new oi,P0=new On,jm=new Rt,yh=new Rt,od=new Rt,I0=new oi,L0=new oi,D0=new oi;class O0 extends xs{constructor(i=new nd){if(super(),this.isSprite=!0,this.type="Sprite",id===void 0){id=new Or;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 td(l,5);id.setIndex([0,1,2,0,2,3]),id.setAttribute("position",new Uc(h,3,0,!1)),id.setAttribute("uv",new Uc(h,2,3,!1))}this.geometry=id,this.material=i,this.center=new oi(.5,.5),this.count=1}raycast(i,l){i.camera===null&&js('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),uu.setFromMatrixScale(this.matrixWorld),P0.copy(i.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(i.camera.matrixWorldInverse,this.matrixWorld),Hu.setFromMatrixPosition(this.modelViewMatrix),i.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&uu.multiplyScalar(-Hu.z);const h=this.material.rotation;let f,g;h!==0&&(g=Math.cos(h),f=Math.sin(h));const v=this.center;hp(jm.set(-.5,-.5,0),Hu,v,uu,f,g),hp(yh.set(.5,-.5,0),Hu,v,uu,f,g),hp(od.set(.5,.5,0),Hu,v,uu,f,g),I0.set(0,0),L0.set(1,0),D0.set(1,1);let C=i.ray.intersectTriangle(jm,yh,od,!1,gh);if(C===null&&(hp(yh.set(-.5,.5,0),Hu,v,uu,f,g),L0.set(0,1),C=i.ray.intersectTriangle(jm,od,yh,!1,gh),C===null))return;const V=i.ray.origin.distanceTo(gh);V<i.near||V>i.far||l.push({distance:V,point:gh.clone(),uv:br.getInterpolation(gh,jm,yh,od,I0,L0,D0,new oi),face:null,object:this})}copy(i,l){return super.copy(i,l),i.center!==void 0&&this.center.copy(i.center),this.material=i.material,this}}function hp(j,i,l,h,f,g){rd.subVectors(j,l).addScalar(.5).multiply(h),f!==void 0?(sd.x=g*rd.x-f*rd.y,sd.y=f*rd.x+g*rd.y):sd.copy(rd),j.copy(i),j.x+=sd.x,j.y+=sd.y,j.applyMatrix4(P0)}const Xm=new Rt,F0=new Rt;class qm extends null{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(i){super.copy(i,!1);const l=i.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=i.autoUpdate,this}addLevel(i,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:i}),this.add(i),this}removeLevel(i){const l=this.levels;for(let h=0;h<l.length;h++)if(l[h].distance===i){const f=l.splice(h,1);return this.remove(f[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(i){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),i<g)break}return l[h-1].object}return null}raycast(i,l){if(this.levels.length>0){Xm.setFromMatrixPosition(this.matrixWorld);const f=i.ray.origin.distanceTo(Xm);this.getObjectForDistance(f).raycast(i,l)}}update(i){const l=this.levels;if(l.length>1){Xm.setFromMatrixPosition(i.matrixWorld),F0.setFromMatrixPosition(this.matrixWorld);const h=Xm.distanceTo(F0)/i.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(i){const l=super.toJSON(i);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 Ym=new Rt,B0=new Ba,Zm=new Ba,c1=new Rt,U0=new On,Ql=new Rt,Km=new Gt,lx=new On,dp=new ai;class kc extends null{constructor(i,l){super(i,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 i=this.geometry;this.boundingBox===null&&(this.boundingBox=new ta),this.boundingBox.makeEmpty();const l=i.getAttribute("position");for(let h=0;h<l.count;h++)this.getVertexPosition(h,Ql),this.boundingBox.expandByPoint(Ql)}computeBoundingSphere(){const i=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Gt),this.boundingSphere.makeEmpty();const l=i.getAttribute("position");for(let h=0;h<l.count;h++)this.getVertexPosition(h,Ql),this.boundingSphere.expandByPoint(Ql)}copy(i,l){return super.copy(i,l),this.bindMode=i.bindMode,this.bindMatrix.copy(i.bindMatrix),this.bindMatrixInverse.copy(i.bindMatrixInverse),this.skeleton=i.skeleton,i.boundingBox!==null&&(this.boundingBox=i.boundingBox.clone()),i.boundingSphere!==null&&(this.boundingSphere=i.boundingSphere.clone()),this}raycast(i,l){const h=this.material,f=this.matrixWorld;h!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Km.copy(this.boundingSphere),Km.applyMatrix4(f),i.ray.intersectsSphere(Km)!==!1&&(lx.copy(f).invert(),dp.copy(i.ray).applyMatrix4(lx),!(this.boundingBox!==null&&dp.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(i,l,dp)))}getVertexPosition(i,l){return super.getVertexPosition(i,l),this.applyBoneTransform(i,l),l}bind(i,l){this.skeleton=i,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 i=new Ba,l=this.geometry.attributes.skinWeight;for(let h=0,f=l.count;h<f;h++){i.fromBufferAttribute(l,h);const g=1/i.manhattanLength();g!==1/0?i.multiplyScalar(g):i.set(1,0,0,0),l.setXYZW(h,i.x,i.y,i.z,i.w)}}updateMatrixWorld(i){super.updateMatrixWorld(i),this.bindMode===nn?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Me?this.bindMatrixInverse.copy(this.bindMatrix).invert():_r("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(i,l){const h=this.skeleton,f=this.geometry;B0.fromBufferAttribute(f.attributes.skinIndex,i),Zm.fromBufferAttribute(f.attributes.skinWeight,i),Ym.copy(l).applyMatrix4(this.bindMatrix),l.set(0,0,0);for(let g=0;g<4;g++){const v=Zm.getComponent(g);if(v!==0){const C=B0.getComponent(g);U0.multiplyMatrices(h.bones[C].matrixWorld,h.boneInverses[C]),l.addScaledVector(c1.copy(Ym).applyMatrix4(U0),v)}}return l.applyMatrix4(this.bindMatrixInverse)}}class ad extends null{constructor(){super(),this.isBone=!0,this.type="Bone"}}class hu extends null{constructor(i=null,l=1,h=1,f,g,v,C,V,H=Ct,J=Ct,he,pe){super(null,v,C,V,H,J,f,g,he,pe),this.isDataTexture=!0,this.image={data:i,width:l,height:h},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const fp=new On,cx=new On;class k0{constructor(i=[],l=[]){this.uuid=Sl(),this.bones=i.slice(0),this.boneInverses=l,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const i=this.bones,l=this.boneInverses;if(this.boneMatrices=new Float32Array(i.length*16),l.length===0)this.calculateInverses();else if(i.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 i=0,l=this.bones.length;i<l;i++){const h=new On;this.bones[i]&&h.copy(this.bones[i].matrixWorld).invert(),this.boneInverses.push(h)}}pose(){for(let i=0,l=this.bones.length;i<l;i++){const h=this.bones[i];h&&h.matrixWorld.copy(this.boneInverses[i]).invert()}for(let i=0,l=this.bones.length;i<l;i++){const h=this.bones[i];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 i=this.bones,l=this.boneInverses,h=this.boneMatrices,f=this.boneTexture;for(let g=0,v=i.length;g<v;g++){const C=i[g]?i[g].matrixWorld:cx;fp.multiplyMatrices(C,l[g]),fp.toArray(h,g*16)}f!==null&&(f.needsUpdate=!0)}clone(){return new k0(this.bones,this.boneInverses)}computeBoneTexture(){let i=Math.sqrt(this.bones.length*4);i=Math.ceil(i/4)*4,i=Math.max(i,4);const l=new Float32Array(i*i*4);l.set(this.boneMatrices);const h=new hu(l,i,i,D,gs);return h.needsUpdate=!0,this.boneMatrices=l,this.boneTexture=h,this}getBoneByName(i){for(let l=0,h=this.bones.length;l<h;l++){const f=this.bones[l];if(f.name===i)return f}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(i,l){this.uuid=i.uuid;for(let h=0,f=i.bones.length;h<f;h++){const g=i.bones[h];let v=l[g];v===void 0&&(_r("Skeleton: No bone found with UUID:",g),v=new ad),this.bones.push(v),this.boneInverses.push(new On().fromArray(i.boneInverses[h]))}return this.init(),this}toJSON(){const i={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};i.uuid=this.uuid;const l=this.bones,h=this.boneInverses;for(let f=0,g=l.length;f<g;f++){const v=l[f];i.bones.push(v.uuid);const C=h[f];i.boneInverses.push(C.toArray())}return i}}class $u extends null{constructor(i,l,h,f=1){super(i,l,h),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=f}copy(i){return super.copy(i),this.meshPerAttribute=i.meshPerAttribute,this}toJSON(){const i=super.toJSON();return i.meshPerAttribute=this.meshPerAttribute,i.isInstancedBufferAttribute=!0,i}}const du=new On,ux=new On,of=null,hx=new ta,u1=new On,Al=new fh,zc=new Gt;class h1 extends null{constructor(i,l,h){super(i,l),this.isInstancedMesh=!0,this.instanceMatrix=new $u(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,u1)}computeBoundingBox(){const i=this.geometry,l=this.count;this.boundingBox===null&&(this.boundingBox=new ta),i.boundingBox===null&&i.computeBoundingBox(),this.boundingBox.makeEmpty();for(let h=0;h<l;h++)this.getMatrixAt(h,du),hx.copy(i.boundingBox).applyMatrix4(du),this.boundingBox.union(hx)}computeBoundingSphere(){const i=this.geometry,l=this.count;this.boundingSphere===null&&(this.boundingSphere=new Gt),i.boundingSphere===null&&i.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let h=0;h<l;h++)this.getMatrixAt(h,du),zc.copy(i.boundingSphere).applyMatrix4(du),this.boundingSphere.union(zc)}copy(i,l){return super.copy(i,l),this.instanceMatrix.copy(i.instanceMatrix),i.morphTexture!==null&&(this.morphTexture=i.morphTexture.clone()),i.instanceColor!==null&&(this.instanceColor=i.instanceColor.clone()),this.count=i.count,i.boundingBox!==null&&(this.boundingBox=i.boundingBox.clone()),i.boundingSphere!==null&&(this.boundingSphere=i.boundingSphere.clone()),this}getColorAt(i,l){l.fromArray(this.instanceColor.array,i*3)}getMatrixAt(i,l){l.fromArray(this.instanceMatrix.array,i*16)}getMorphAt(i,l){const h=l.morphTargetInfluences,f=this.morphTexture.source.data.data,g=h.length+1,v=i*g+1;for(let C=0;C<h.length;C++)h[C]=f[v+C]}raycast(i,l){const h=this.matrixWorld,f=this.count;if(Al.geometry=this.geometry,Al.material=this.material,Al.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),zc.copy(this.boundingSphere),zc.applyMatrix4(h),i.ray.intersectsSphere(zc)!==!1))for(let g=0;g<f;g++){this.getMatrixAt(g,du),ux.multiplyMatrices(h,du),Al.matrixWorld=ux,Al.raycast(i,of);for(let v=0,C=of.length;v<C;v++){const V=of[v];V.instanceId=g,V.object=this,l.push(V)}of.length=0}}setColorAt(i,l){this.instanceColor===null&&(this.instanceColor=new $u(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),l.toArray(this.instanceColor.array,i*3)}setMatrixAt(i,l){l.toArray(this.instanceMatrix.array,i*16)}setMorphAt(i,l){const h=l.morphTargetInfluences,f=h.length+1;this.morphTexture===null&&(this.morphTexture=new hu(new Float32Array(f*this.count),f,this.count,F,gs));const g=this.morphTexture.source.data.data;let v=0;for(let H=0;H<h.length;H++)v+=h[H];const C=this.geometry.morphTargetsRelative?1:1-v,V=f*i;g[V]=C,g.set(h,V+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const af=new Rt,lf=new Rt,fu=new ua;class Cl{constructor(i=new Rt(1,0,0),l=0){this.isPlane=!0,this.normal=i,this.constant=l}set(i,l){return this.normal.copy(i),this.constant=l,this}setComponents(i,l,h,f){return this.normal.set(i,l,h),this.constant=f,this}setFromNormalAndCoplanarPoint(i,l){return this.normal.copy(i),this.constant=-l.dot(this.normal),this}setFromCoplanarPoints(i,l,h){const f=af.subVectors(h,l).cross(lf.subVectors(i,l)).normalize();return this.setFromNormalAndCoplanarPoint(f,i),this}copy(i){return this.normal.copy(i.normal),this.constant=i.constant,this}normalize(){const i=1/this.normal.length();return this.normal.multiplyScalar(i),this.constant*=i,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(i){return this.normal.dot(i)+this.constant}distanceToSphere(i){return this.distanceToPoint(i.center)-i.radius}projectPoint(i,l){return l.copy(i).addScaledVector(this.normal,-this.distanceToPoint(i))}intersectLine(i,l){const h=i.delta(af),f=this.normal.dot(h);if(f===0)return this.distanceToPoint(i.start)===0?l.copy(i.start):null;const g=-(i.start.dot(this.normal)+this.constant)/f;return g<0||g>1?null:l.copy(i.start).addScaledVector(h,g)}intersectsLine(i){const l=this.distanceToPoint(i.start),h=this.distanceToPoint(i.end);return l<0&&h>0||h<0&&l>0}intersectsBox(i){return i.intersectsPlane(this)}intersectsSphere(i){return i.intersectsPlane(this)}coplanarPoint(i){return i.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(i,l){const h=l||fu.getNormalMatrix(i),f=this.coplanarPoint(af).applyMatrix4(i),g=this.normal.applyMatrix3(h).normalize();return this.constant=-f.dot(g),this}translate(i){return this.constant-=i.dot(this.normal),this}equals(i){return i.normal.equals(this.normal)&&i.constant===this.constant}clone(){return new this.constructor().copy(this)}}const pu=new Gt,z0=new oi(.5,.5),Jm=new Rt;class V0{constructor(i=new Cl,l=new Cl,h=new Cl,f=new Cl,g=new Cl,v=new Cl){this.planes=[i,l,h,f,g,v]}set(i,l,h,f,g,v){const C=this.planes;return C[0].copy(i),C[1].copy(l),C[2].copy(h),C[3].copy(f),C[4].copy(g),C[5].copy(v),this}copy(i){const l=this.planes;for(let h=0;h<6;h++)l[h].copy(i.planes[h]);return this}setFromProjectionMatrix(i,l=so,h=!1){const f=this.planes,g=i.elements,v=g[0],C=g[1],V=g[2],H=g[3],J=g[4],he=g[5],pe=g[6],me=g[7],Se=g[8],tt=g[9],gt=g[10],mt=g[11],Nt=g[12],Pt=g[13],Wt=g[14],gn=g[15];if(f[0].setComponents(H-v,me-J,mt-Se,gn-Nt).normalize(),f[1].setComponents(H+v,me+J,mt+Se,gn+Nt).normalize(),f[2].setComponents(H+C,me+he,mt+tt,gn+Pt).normalize(),f[3].setComponents(H-C,me-he,mt-tt,gn-Pt).normalize(),h)f[4].setComponents(V,pe,gt,Wt).normalize(),f[5].setComponents(H-V,me-pe,mt-gt,gn-Wt).normalize();else if(f[4].setComponents(H-V,me-pe,mt-gt,gn-Wt).normalize(),l===so)f[5].setComponents(H+V,me+pe,mt+gt,gn+Wt).normalize();else if(l===ja)f[5].setComponents(V,pe,gt,Wt).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+l);return this}intersectsObject(i){if(i.boundingSphere!==void 0)i.boundingSphere===null&&i.computeBoundingSphere(),pu.copy(i.boundingSphere).applyMatrix4(i.matrixWorld);else{const l=i.geometry;l.boundingSphere===null&&l.computeBoundingSphere(),pu.copy(l.boundingSphere).applyMatrix4(i.matrixWorld)}return this.intersectsSphere(pu)}intersectsSprite(i){pu.center.set(0,0,0);const l=z0.distanceTo(i.center);return pu.radius=.7071067811865476+l,pu.applyMatrix4(i.matrixWorld),this.intersectsSphere(pu)}intersectsSphere(i){const l=this.planes,h=i.center,f=-i.radius;for(let g=0;g<6;g++)if(l[g].distanceToPoint(h)<f)return!1;return!0}intersectsBox(i){const l=this.planes;for(let h=0;h<6;h++){const f=l[h];if(Jm.x=f.normal.x>0?i.max.x:i.min.x,Jm.y=f.normal.y>0?i.max.y:i.min.y,Jm.z=f.normal.z>0?i.max.z:i.min.z,f.distanceToPoint(Jm)<0)return!1}return!0}containsPoint(i){const l=this.planes;for(let h=0;h<6;h++)if(l[h].distanceToPoint(i)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const mu=new On,$o=new V0;class G0{constructor(){this.coordinateSystem=so}intersectsObject(i,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(mu.multiplyMatrices(f.projectionMatrix,f.matrixWorldInverse),$o.setFromProjectionMatrix(mu,f.coordinateSystem,f.reversedDepth),$o.intersectsObject(i))return!0}return!1}intersectsSprite(i,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(mu.multiplyMatrices(f.projectionMatrix,f.matrixWorldInverse),$o.setFromProjectionMatrix(mu,f.coordinateSystem,f.reversedDepth),$o.intersectsSprite(i))return!0}return!1}intersectsSphere(i,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(mu.multiplyMatrices(f.projectionMatrix,f.matrixWorldInverse),$o.setFromProjectionMatrix(mu,f.coordinateSystem,f.reversedDepth),$o.intersectsSphere(i))return!0}return!1}intersectsBox(i,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(mu.multiplyMatrices(f.projectionMatrix,f.matrixWorldInverse),$o.setFromProjectionMatrix(mu,f.coordinateSystem,f.reversedDepth),$o.intersectsBox(i))return!0}return!1}containsPoint(i,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(mu.multiplyMatrices(f.projectionMatrix,f.matrixWorldInverse),$o.setFromProjectionMatrix(mu,f.coordinateSystem,f.reversedDepth),$o.containsPoint(i))return!0}return!1}clone(){return new G0}}function Qm(j,i){return j-i}function d1(j,i){return j.z-i.z}function eg(j,i){return i.z-j.z}class ld{constructor(){this.index=0,this.pool=[],this.list=[]}push(i,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 C=g[this.index];v.push(C),this.index++,C.start=i,C.count=l,C.z=h,C.index=f}reset(){this.list.length=0,this.index=0}}const Qa=new On,dx=new ar(1,1,1),fx=new V0,W0=new G0,za=new ta,gu=new Gt,pp=new Rt,vh=new Rt,f1=new Rt,el=new ld,Va=new fh,cd=null;function px(j,i,l=0){const h=i.itemSize;if(j.isInterleavedBufferAttribute||j.array.constructor!==i.array.constructor){const f=j.count;for(let g=0;g<f;g++)for(let v=0;v<h;v++)i.setComponent(g+l,v,j.getComponent(g,v))}else i.array.set(j.array,l*h);i.needsUpdate=!0}function Vc(j,i){if(j.constructor!==i.constructor){const l=Math.min(j.length,i.length);for(let h=0;h<l;h++)i[h]=j[h]}else{const l=Math.min(j.length,i.length);i.set(new j.constructor(j.buffer,0,l))}}class tg extends null{constructor(i,l,h=l*2,f){super(new Or,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=i,this._maxVertexCount=l,this._maxIndexCount=h,this._multiDrawCounts=new Int32Array(i),this._multiDrawStarts=new Int32Array(i),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 i=Math.sqrt(this._maxInstanceCount*4);i=Math.ceil(i/4)*4,i=Math.max(i,4);const l=new Float32Array(i*i*4),h=new hu(l,i,i,D,gs);this._matricesTexture=h}_initIndirectTexture(){let i=Math.sqrt(this._maxInstanceCount);i=Math.ceil(i);const l=new Uint32Array(i*i),h=new hu(l,i,i,X,as);this._indirectTexture=h}_initColorsTexture(){let i=Math.sqrt(this._maxInstanceCount);i=Math.ceil(i);const l=new Float32Array(i*i*4).fill(1),h=new hu(l,i,i,D,gs);h.colorSpace=wo.workingColorSpace,this._colorsTexture=h}_initializeGeometry(i){const l=this.geometry,h=this._maxVertexCount,f=this._maxIndexCount;if(this._geometryInitialized===!1){for(const g in i.attributes){const v=i.getAttribute(g),{array:C,itemSize:V,normalized:H}=v,J=new C.constructor(h*V),he=new yo(J,V,H);l.setAttribute(g,he)}if(i.getIndex()!==null){const g=h>65535?new Uint32Array(f):new Uint16Array(f);l.setIndex(new yo(g,1))}this._geometryInitialized=!0}}_validateGeometry(i){const l=this.geometry;if(!!i.getIndex()!=!!l.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const h in l.attributes){if(!i.hasAttribute(h))throw new Error(`THREE.BatchedMesh: Added geometry missing "${h}". All geometries must have consistent attributes.`);const f=i.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(i){const l=this._instanceInfo;if(i<0||i>=l.length||l[i].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${i}. Instance is either out of range or has been deleted.`)}validateGeometryId(i){const l=this._geometryInfo;if(i<0||i>=l.length||l[i].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${i}. Geometry is either out of range or has been deleted.`)}setCustomSort(i){return this.customSort=i,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ta);const i=this.boundingBox,l=this._instanceInfo;i.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,Qa),this.getBoundingBoxAt(g,za).applyMatrix4(Qa),i.union(za)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Gt);const i=this.boundingSphere,l=this._instanceInfo;i.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,Qa),this.getBoundingSphereAt(g,gu).applyMatrix4(Qa),i.union(gu)}}addInstance(i){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:i};let f=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(Qm),f=this._availableInstanceIds.shift(),this._instanceInfo[f]=h):(f=this._instanceInfo.length,this._instanceInfo.push(h));const g=this._matricesTexture;Qa.identity().toArray(g.image.data,f*16),g.needsUpdate=!0;const v=this._colorsTexture;return v&&(dx.toArray(v.image.data,f*4),v.needsUpdate=!0),this._visibilityChanged=!0,f}addGeometry(i,l=-1,h=-1){this._initializeGeometry(i),this._validateGeometry(i);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?i.getAttribute("position").count:l;const v=i.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(Qm),V=this._availableGeometryIds.shift(),g[V]=f):(V=this._geometryCount,this._geometryCount++,g.push(f)),this.setGeometryAt(V,i),this._nextIndexStart=f.indexStart+f.reservedIndexCount,this._nextVertexStart=f.vertexStart+f.reservedVertexCount,V}setGeometryAt(i,l){if(i>=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(),C=this._geometryInfo[i];if(f&&v.count>C.reservedIndexCount||l.attributes.position.count>C.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const V=C.vertexStart,H=C.reservedVertexCount;C.vertexCount=l.getAttribute("position").count;for(const J in h.attributes){const he=l.getAttribute(J),pe=h.getAttribute(J);px(he,pe,V);const me=he.itemSize;for(let Se=he.count,tt=H;Se<tt;Se++){const gt=V+Se;for(let mt=0;mt<me;mt++)pe.setComponent(gt,mt,0)}pe.needsUpdate=!0,pe.addUpdateRange(V*me,H*me)}if(f){const J=C.indexStart,he=C.reservedIndexCount;C.indexCount=l.getIndex().count;for(let pe=0;pe<v.count;pe++)g.setX(J+pe,V+v.getX(pe));for(let pe=v.count,me=he;pe<me;pe++)g.setX(J+pe,V);g.needsUpdate=!0,g.addUpdateRange(J,C.reservedIndexCount)}return C.start=f?C.indexStart:C.vertexStart,C.count=f?C.indexCount:C.vertexCount,C.boundingBox=null,l.boundingBox!==null&&(C.boundingBox=l.boundingBox.clone()),C.boundingSphere=null,l.boundingSphere!==null&&(C.boundingSphere=l.boundingSphere.clone()),this._visibilityChanged=!0,i}deleteGeometry(i){const l=this._geometryInfo;if(i>=l.length||l[i].active===!1)return this;const h=this._instanceInfo;for(let f=0,g=h.length;f<g;f++)h[f].active&&h[f].geometryIndex===i&&this.deleteInstance(f);return l[i].active=!1,this._availableGeometryIds.push(i),this._visibilityChanged=!0,this}deleteInstance(i){return this.validateInstanceId(i),this._instanceInfo[i].active=!1,this._availableInstanceIds.push(i),this._visibilityChanged=!0,this}optimize(){let i=0,l=0;const h=this._geometryInfo,f=h.map((v,C)=>C).sort((v,C)=>h[v].vertexStart-h[C].vertexStart),g=this.geometry;for(let v=0,C=h.length;v<C;v++){const V=f[v],H=h[V];if(H.active!==!1){if(g.index!==null){if(H.indexStart!==l){const{indexStart:J,vertexStart:he,reservedIndexCount:pe}=H,me=g.index,Se=me.array,tt=i-he;for(let gt=J;gt<J+pe;gt++)Se[gt]=Se[gt]+tt;me.array.copyWithin(l,J,J+pe),me.addUpdateRange(l,pe),H.indexStart=l}l+=H.reservedIndexCount}if(H.vertexStart!==i){const{vertexStart:J,reservedVertexCount:he}=H,pe=g.attributes;for(const me in pe){const Se=pe[me],{array:tt,itemSize:gt}=Se;tt.copyWithin(i*gt,J*gt,(J+he)*gt),Se.addUpdateRange(i*gt,he*gt)}H.vertexStart=i}i+=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(i,l){if(i>=this._geometryCount)return null;const h=this.geometry,f=this._geometryInfo[i];if(f.boundingBox===null){const g=new ta,v=h.index,C=h.attributes.position;for(let V=f.start,H=f.start+f.count;V<H;V++){let J=V;v&&(J=v.getX(J)),g.expandByPoint(pp.fromBufferAttribute(C,J))}f.boundingBox=g}return l.copy(f.boundingBox),l}getBoundingSphereAt(i,l){if(i>=this._geometryCount)return null;const h=this.geometry,f=this._geometryInfo[i];if(f.boundingSphere===null){const g=new Gt;this.getBoundingBoxAt(i,za),za.getCenter(g.center);const v=h.index,C=h.attributes.position;let V=0;for(let H=f.start,J=f.start+f.count;H<J;H++){let he=H;v&&(he=v.getX(he)),pp.fromBufferAttribute(C,he),V=Math.max(V,g.center.distanceToSquared(pp))}g.radius=Math.sqrt(V),f.boundingSphere=g}return l.copy(f.boundingSphere),l}setMatrixAt(i,l){this.validateInstanceId(i);const h=this._matricesTexture,f=this._matricesTexture.image.data;return l.toArray(f,i*16),h.needsUpdate=!0,this}getMatrixAt(i,l){return this.validateInstanceId(i),l.fromArray(this._matricesTexture.image.data,i*16)}setColorAt(i,l){return this.validateInstanceId(i),this._colorsTexture===null&&this._initColorsTexture(),l.toArray(this._colorsTexture.image.data,i*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(i,l){return this.validateInstanceId(i),l.fromArray(this._colorsTexture.image.data,i*4)}setVisibleAt(i,l){return this.validateInstanceId(i),this._instanceInfo[i].visible===l?this:(this._instanceInfo[i].visible=l,this._visibilityChanged=!0,this)}getVisibleAt(i){return this.validateInstanceId(i),this._instanceInfo[i].visible}setGeometryIdAt(i,l){return this.validateInstanceId(i),this.validateGeometryId(l),this._instanceInfo[i].geometryIndex=l,this}getGeometryIdAt(i){return this.validateInstanceId(i),this._instanceInfo[i].geometryIndex}getGeometryRangeAt(i,l={}){this.validateGeometryId(i);const h=this._geometryInfo[i];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(i){const l=this._availableInstanceIds,h=this._instanceInfo;for(l.sort(Qm);l[l.length-1]===h.length-1;)h.pop(),l.pop();if(i<h.length)throw new Error(`BatchedMesh: Instance ids outside the range ${i} are being used. Cannot shrink instance count.`);const f=new Int32Array(i),g=new Int32Array(i);Vc(this._multiDrawCounts,f),Vc(this._multiDrawStarts,g),this._multiDrawCounts=f,this._multiDrawStarts=g,this._maxInstanceCount=i;const v=this._indirectTexture,C=this._matricesTexture,V=this._colorsTexture;v.dispose(),this._initIndirectTexture(),Vc(v.image.data,this._indirectTexture.image.data),C.dispose(),this._initMatricesTexture(),Vc(C.image.data,this._matricesTexture.image.data),V&&(V.dispose(),this._initColorsTexture(),Vc(V.image.data,this._colorsTexture.image.data))}setGeometrySize(i,l){const h=[...this._geometryInfo].filter(C=>C.active);if(Math.max(...h.map(C=>C.vertexStart+C.reservedVertexCount))>i)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=i,this._maxIndexCount=l,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Or,this._initializeGeometry(g));const v=this.geometry;g.index&&Vc(g.index.array,v.index.array);for(const C in g.attributes)Vc(g.attributes[C].array,v.attributes[C].array)}raycast(i,l){const h=this._instanceInfo,f=this._geometryInfo,g=this.matrixWorld,v=this.geometry;Va.material=this.material,Va.geometry.index=v.index,Va.geometry.attributes=v.attributes,Va.geometry.boundingBox===null&&(Va.geometry.boundingBox=new ta),Va.geometry.boundingSphere===null&&(Va.geometry.boundingSphere=new Gt);for(let C=0,V=h.length;C<V;C++){if(!h[C].visible||!h[C].active)continue;const H=h[C].geometryIndex,J=f[H];Va.geometry.setDrawRange(J.start,J.count),this.getMatrixAt(C,Va.matrixWorld).premultiply(g),this.getBoundingBoxAt(H,Va.geometry.boundingBox),this.getBoundingSphereAt(H,Va.geometry.boundingSphere),Va.raycast(i,cd);for(let he=0,pe=cd.length;he<pe;he++){const me=cd[he];me.object=this,me.batchId=C,l.push(me)}cd.length=0}Va.material=null,Va.geometry.index=null,Va.geometry.attributes={},Va.geometry.setDrawRange(0,1/0)}copy(i){return super.copy(i),this.geometry=i.geometry.clone(),this.perObjectFrustumCulled=i.perObjectFrustumCulled,this.sortObjects=i.sortObjects,this.boundingBox=i.boundingBox!==null?i.boundingBox.clone():null,this.boundingSphere=i.boundingSphere!==null?i.boundingSphere.clone():null,this._geometryInfo=i._geometryInfo.map(l=>ac(qs({},l),{boundingBox:l.boundingBox!==null?l.boundingBox.clone():null,boundingSphere:l.boundingSphere!==null?l.boundingSphere.clone():null})),this._instanceInfo=i._instanceInfo.map(l=>qs({},l)),this._availableInstanceIds=i._availableInstanceIds.slice(),this._availableGeometryIds=i._availableGeometryIds.slice(),this._nextIndexStart=i._nextIndexStart,this._nextVertexStart=i._nextVertexStart,this._geometryCount=i._geometryCount,this._maxInstanceCount=i._maxInstanceCount,this._maxVertexCount=i._maxVertexCount,this._maxIndexCount=i._maxIndexCount,this._geometryInitialized=i._geometryInitialized,this._multiDrawCounts=i._multiDrawCounts.slice(),this._multiDrawStarts=i._multiDrawStarts.slice(),this._indirectTexture=i._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=i._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=i._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(i,l,h,f,g){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const v=f.getIndex(),C=v===null?1:v.array.BYTES_PER_ELEMENT,V=this._instanceInfo,H=this._multiDrawStarts,J=this._multiDrawCounts,he=this._geometryInfo,pe=this.perObjectFrustumCulled,me=this._indirectTexture,Se=me.image.data,tt=h.isArrayCamera?W0:fx;pe&&!h.isArrayCamera&&(Qa.multiplyMatrices(h.projectionMatrix,h.matrixWorldInverse).multiply(this.matrixWorld),fx.setFromProjectionMatrix(Qa,h.coordinateSystem,h.reversedDepth));let gt=0;if(this.sortObjects){Qa.copy(this.matrixWorld).invert(),pp.setFromMatrixPosition(h.matrixWorld).applyMatrix4(Qa),vh.set(0,0,-1).transformDirection(h.matrixWorld).transformDirection(Qa);for(let Pt=0,Wt=V.length;Pt<Wt;Pt++)if(V[Pt].visible&&V[Pt].active){const gn=V[Pt].geometryIndex;this.getMatrixAt(Pt,Qa),this.getBoundingSphereAt(gn,gu).applyMatrix4(Qa);let Sn=!1;if(pe&&(Sn=!tt.intersectsSphere(gu,h)),!Sn){const kn=he[gn],In=f1.subVectors(gu.center,pp).dot(vh);el.push(kn.start,kn.count,In,Pt)}}const mt=el.list,Nt=this.customSort;Nt===null?mt.sort(g.transparent?eg:d1):Nt.call(this,mt,h);for(let Pt=0,Wt=mt.length;Pt<Wt;Pt++){const gn=mt[Pt];H[gt]=gn.start*C,J[gt]=gn.count,Se[gt]=gn.index,gt++}el.reset()}else for(let mt=0,Nt=V.length;mt<Nt;mt++)if(V[mt].visible&&V[mt].active){const Pt=V[mt].geometryIndex;let Wt=!1;if(pe&&(this.getMatrixAt(mt,Qa),this.getBoundingSphereAt(Pt,gu).applyMatrix4(Qa),Wt=!tt.intersectsSphere(gu,h)),!Wt){const gn=he[Pt];H[gt]=gn.start*C,J[gt]=gn.count,Se[gt]=mt,gt++}}me.needsUpdate=!0,this._multiDrawCount=gt,this._visibilityChanged=!1}onBeforeShadow(i,l,h,f,g,v){this.onBeforeRender(i,null,f,g,v)}}class Rl extends null{constructor(i){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(i)}copy(i){return super.copy(i),this.color.copy(i.color),this.map=i.map,this.linewidth=i.linewidth,this.linecap=i.linecap,this.linejoin=i.linejoin,this.fog=i.fog,this}}const mp=new Rt,xh=new Rt,gp=new On,cf=new ai,yp=new Gt,ng=new Rt,mx=new Rt;class uf extends null{constructor(i=new Or,l=new Rl){super(),this.isLine=!0,this.type="Line",this.geometry=i,this.material=l,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(i,l){return super.copy(i,l),this.material=Array.isArray(i.material)?i.material.slice():i.material,this.geometry=i.geometry,this}computeLineDistances(){const i=this.geometry;if(i.index===null){const l=i.attributes.position,h=[0];for(let f=1,g=l.count;f<g;f++)mp.fromBufferAttribute(l,f-1),xh.fromBufferAttribute(l,f),h[f]=h[f-1],h[f]+=mp.distanceTo(xh);i.setAttribute("lineDistance",new qi(h,1))}else _r("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(i,l){const h=this.geometry,f=this.matrixWorld,g=i.params.Line.threshold,v=h.drawRange;if(h.boundingSphere===null&&h.computeBoundingSphere(),yp.copy(h.boundingSphere),yp.applyMatrix4(f),yp.radius+=g,i.ray.intersectsSphere(yp)===!1)return;gp.copy(f).invert(),cf.copy(i.ray).applyMatrix4(gp);const C=g/((this.scale.x+this.scale.y+this.scale.z)/3),V=C*C,H=this.isLineSegments?2:1,J=h.index,pe=h.attributes.position;if(J!==null){const me=Math.max(0,v.start),Se=Math.min(J.count,v.start+v.count);for(let tt=me,gt=Se-1;tt<gt;tt+=H){const mt=J.getX(tt),Nt=J.getX(tt+1),Pt=vp(this,i,cf,V,mt,Nt,tt);Pt&&l.push(Pt)}if(this.isLineLoop){const tt=J.getX(Se-1),gt=J.getX(me),mt=vp(this,i,cf,V,tt,gt,Se-1);mt&&l.push(mt)}}else{const me=Math.max(0,v.start),Se=Math.min(pe.count,v.start+v.count);for(let tt=me,gt=Se-1;tt<gt;tt+=H){const mt=vp(this,i,cf,V,tt,tt+1,tt);mt&&l.push(mt)}if(this.isLineLoop){const tt=vp(this,i,cf,V,Se-1,me,Se-1);tt&&l.push(tt)}}}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 C=f[g].name||String(g);this.morphTargetInfluences.push(0),this.morphTargetDictionary[C]=g}}}}}function vp(j,i,l,h,f,g,v){const C=j.geometry.attributes.position;if(mp.fromBufferAttribute(C,f),xh.fromBufferAttribute(C,g),l.distanceSqToSegment(mp,xh,ng,mx)>h)return;ng.applyMatrix4(j.matrixWorld);const H=i.ray.origin.distanceTo(ng);if(!(H<i.near||H>i.far))return{distance:H,point:mx.clone().applyMatrix4(j.matrixWorld),index:v,face:null,faceIndex:null,barycoord:null,object:j}}const ig=new Rt,xp=new Rt;class _p extends null{constructor(i,l){super(i,l),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const i=this.geometry;if(i.index===null){const l=i.attributes.position,h=[];for(let f=0,g=l.count;f<g;f+=2)ig.fromBufferAttribute(l,f),xp.fromBufferAttribute(l,f+1),h[f]=f===0?0:h[f-1],h[f+1]=h[f]+ig.distanceTo(xp);i.setAttribute("lineDistance",new qi(h,1))}else _r("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class p1 extends null{constructor(i,l){super(i,l),this.isLineLoop=!0,this.type="LineLoop"}}class H0 extends null{constructor(i){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(i)}copy(i){return super.copy(i),this.color.copy(i.color),this.map=i.map,this.alphaMap=i.alphaMap,this.size=i.size,this.sizeAttenuation=i.sizeAttenuation,this.fog=i.fog,this}}const m1=new On,gx=new ai,bp=new Gt,rg=new Rt;class lE extends null{constructor(i=new Or,l=new H0){super(),this.isPoints=!0,this.type="Points",this.geometry=i,this.material=l,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(i,l){return super.copy(i,l),this.material=Array.isArray(i.material)?i.material.slice():i.material,this.geometry=i.geometry,this}raycast(i,l){const h=this.geometry,f=this.matrixWorld,g=i.params.Points.threshold,v=h.drawRange;if(h.boundingSphere===null&&h.computeBoundingSphere(),bp.copy(h.boundingSphere),bp.applyMatrix4(f),bp.radius+=g,i.ray.intersectsSphere(bp)===!1)return;m1.copy(f).invert(),gx.copy(i.ray).applyMatrix4(m1);const C=g/((this.scale.x+this.scale.y+this.scale.z)/3),V=C*C,H=h.index,he=h.attributes.position;if(H!==null){const pe=Math.max(0,v.start),me=Math.min(H.count,v.start+v.count);for(let Se=pe,tt=me;Se<tt;Se++){const gt=H.getX(Se);rg.fromBufferAttribute(he,gt),g1(rg,gt,V,f,i,l,this)}}else{const pe=Math.max(0,v.start),me=Math.min(he.count,v.start+v.count);for(let Se=pe,tt=me;Se<tt;Se++)rg.fromBufferAttribute(he,Se),g1(rg,Se,V,f,i,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 C=f[g].name||String(g);this.morphTargetInfluences.push(0),this.morphTargetDictionary[C]=g}}}}}function g1(j,i,l,h,f,g,v){const C=gx.distanceSqToPoint(j);if(C<l){const V=new Rt;gx.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(C),point:V,index:i,face:null,faceIndex:null,barycoord:null,object:v})}}class g3 extends null{constructor(i,l,h,f,g=Rn,v=Rn,C,V,H){super(i,l,h,f,g,v,C,V,H),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const J=this;function he(){J.needsUpdate=!0,J._requestVideoFrameCallbackId=i.requestVideoFrameCallback(he)}"requestVideoFrameCallback"in i&&(this._requestVideoFrameCallbackId=i.requestVideoFrameCallback(he))}clone(){return new this.constructor(this.image).copy(this)}update(){const i=this.image;"requestVideoFrameCallback"in i===!1&&i.readyState>=i.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class gc extends null{constructor(i,l,h,f,g,v,C,V){super({},i,l,h,f,g,v,C,V),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(i){this.image=i,this.needsUpdate=!0}}class y1 extends null{constructor(i,l){super({width:i,height:l}),this.isFramebufferTexture=!0,this.magFilter=Ct,this.minFilter=Ct,this.generateMipmaps=!1,this.needsUpdate=!0}}class $0 extends null{constructor(i,l,h,f,g,v,C,V,H,J,he,pe){super(null,v,C,V,H,J,f,g,he,pe),this.isCompressedTexture=!0,this.image={width:l,height:h},this.mipmaps=i,this.flipY=!1,this.generateMipmaps=!1}}class yx extends null{constructor(i,l,h,f,g,v){super(i,l,h,g,v),this.isCompressedArrayTexture=!0,this.image.depth=f,this.wrapR=qe,this.layerUpdates=new Set}addLayerUpdate(i){this.layerUpdates.add(i)}clearLayerUpdates(){this.layerUpdates.clear()}}class wp extends null{constructor(i,l,h){super(void 0,i[0].width,i[0].height,l,h,Fe),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=i}}class Mp extends xl{constructor(i,l,h,f,g,v,C,V,H){super(i,l,h,f,g,v,C,V,H),this.isCanvasTexture=!0,this.needsUpdate=!0}}class hf extends null{constructor(i,l,h=as,f,g,v,C=Ct,V=Ct,H,J=U,he=1){if(J!==U&&J!==_)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const pe={width:i,height:l,depth:he};super(pe,f,g,v,C,V,J,h,H),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(i){return super.copy(i),this.source=new Za(Object.assign({},i.image)),this.compareFunction=i.compareFunction,this}toJSON(i){const l=super.toJSON(i);return this.compareFunction!==null&&(l.compareFunction=this.compareFunction),l}}class vx extends null{constructor(i=null){super(),this.sourceTexture=i,this.isExternalTexture=!0}copy(i){return super.copy(i),this.sourceTexture=i.sourceTexture,this}}class df extends Or{constructor(i=1,l=1,h=4,f=8,g=1){super(),this.type="CapsuleGeometry",this.parameters={radius:i,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=[],C=[],V=[],H=[],J=l/2,he=Math.PI/2*i,pe=l,me=2*he+pe,Se=h*2+g,tt=f+1,gt=new Rt,mt=new Rt;for(let Nt=0;Nt<=Se;Nt++){let Pt=0,Wt=0,gn=0,Sn=0;if(Nt<=h){const ii=Nt/h,li=ii*Math.PI/2;Wt=-J-i*Math.cos(li),gn=i*Math.sin(li),Sn=-i*Math.cos(li),Pt=ii*he}else if(Nt<=h+g){const ii=(Nt-h)/g;Wt=-J+ii*l,gn=i,Sn=0,Pt=he+ii*pe}else{const ii=(Nt-h-g)/h,li=ii*Math.PI/2;Wt=J+i*Math.sin(li),gn=i*Math.cos(li),Sn=i*Math.sin(li),Pt=he+pe+ii*he}const kn=Math.max(0,Math.min(1,Pt/me));let In=0;Nt===0?In=.5/f:Nt===Se&&(In=-.5/f);for(let ii=0;ii<=f;ii++){const li=ii/f,dr=li*Math.PI*2,Yr=Math.sin(dr),Ss=Math.cos(dr);mt.x=-gn*Ss,mt.y=Wt,mt.z=gn*Yr,C.push(mt.x,mt.y,mt.z),gt.set(-gn*Ss,Sn,gn*Yr),gt.normalize(),V.push(gt.x,gt.y,gt.z),H.push(li+In,kn)}if(Nt>0){const ii=(Nt-1)*tt;for(let li=0;li<f;li++){const dr=ii+li,Yr=ii+li+1,Ss=Nt*tt+li,eo=Nt*tt+li+1;v.push(dr,Yr,Ss),v.push(Yr,eo,Ss)}}}this.setIndex(v),this.setAttribute("position",new qi(C,3)),this.setAttribute("normal",new qi(V,3)),this.setAttribute("uv",new qi(H,2))}copy(i){return super.copy(i),this.parameters=Object.assign({},i.parameters),this}static fromJSON(i){return new df(i.radius,i.height,i.capSegments,i.radialSegments,i.heightSegments)}}class ff extends Or{constructor(i=1,l=32,h=0,f=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:i,segments:l,thetaStart:h,thetaLength:f},l=Math.max(3,l);const g=[],v=[],C=[],V=[],H=new Rt,J=new oi;v.push(0,0,0),C.push(0,0,1),V.push(.5,.5);for(let he=0,pe=3;he<=l;he++,pe+=3){const me=h+he/l*f;H.x=i*Math.cos(me),H.y=i*Math.sin(me),v.push(H.x,H.y,H.z),C.push(0,0,1),J.x=(v[pe]/i+1)/2,J.y=(v[pe+1]/i+1)/2,V.push(J.x,J.y)}for(let he=1;he<=l;he++)g.push(he,he+1,0);this.setIndex(g),this.setAttribute("position",new qi(v,3)),this.setAttribute("normal",new qi(C,3)),this.setAttribute("uv",new qi(V,2))}copy(i){return super.copy(i),this.parameters=Object.assign({},i.parameters),this}static fromJSON(i){return new ff(i.radius,i.segments,i.thetaStart,i.thetaLength)}}class pf extends Or{constructor(i=1,l=1,h=1,f=32,g=1,v=!1,C=0,V=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:i,radiusBottom:l,height:h,radialSegments:f,heightSegments:g,openEnded:v,thetaStart:C,thetaLength:V};const H=this;f=Math.floor(f),g=Math.floor(g);const J=[],he=[],pe=[],me=[];let Se=0;const tt=[],gt=h/2;let mt=0;Nt(),v===!1&&(i>0&&Pt(!0),l>0&&Pt(!1)),this.setIndex(J),this.setAttribute("position",new qi(he,3)),this.setAttribute("normal",new qi(pe,3)),this.setAttribute("uv",new qi(me,2));function Nt(){const Wt=new Rt,gn=new Rt;let Sn=0;const kn=(l-i)/h;for(let In=0;In<=g;In++){const ii=[],li=In/g,dr=li*(l-i)+i;for(let Yr=0;Yr<=f;Yr++){const Ss=Yr/f,eo=Ss*V+C,uo=Math.sin(eo),Aa=Math.cos(eo);gn.x=dr*uo,gn.y=-li*h+gt,gn.z=dr*Aa,he.push(gn.x,gn.y,gn.z),Wt.set(uo,kn,Aa).normalize(),pe.push(Wt.x,Wt.y,Wt.z),me.push(Ss,1-li),ii.push(Se++)}tt.push(ii)}for(let In=0;In<f;In++)for(let ii=0;ii<g;ii++){const li=tt[ii][In],dr=tt[ii+1][In],Yr=tt[ii+1][In+1],Ss=tt[ii][In+1];(i>0||ii!==0)&&(J.push(li,dr,Ss),Sn+=3),(l>0||ii!==g-1)&&(J.push(dr,Yr,Ss),Sn+=3)}H.addGroup(mt,Sn,0),mt+=Sn}function Pt(Wt){const gn=Se,Sn=new oi,kn=new Rt;let In=0;const ii=Wt===!0?i:l,li=Wt===!0?1:-1;for(let Yr=1;Yr<=f;Yr++)he.push(0,gt*li,0),pe.push(0,li,0),me.push(.5,.5),Se++;const dr=Se;for(let Yr=0;Yr<=f;Yr++){const eo=Yr/f*V+C,uo=Math.cos(eo),Aa=Math.sin(eo);kn.x=ii*Aa,kn.y=gt*li,kn.z=ii*uo,he.push(kn.x,kn.y,kn.z),pe.push(0,li,0),Sn.x=uo*.5+.5,Sn.y=Aa*.5*li+.5,me.push(Sn.x,Sn.y),Se++}for(let Yr=0;Yr<f;Yr++){const Ss=gn+Yr,eo=dr+Yr;Wt===!0?J.push(eo,eo+1,Ss):J.push(eo+1,eo,Ss),In+=3}H.addGroup(mt,In,Wt===!0?1:2),mt+=In}}copy(i){return super.copy(i),this.parameters=Object.assign({},i.parameters),this}static fromJSON(i){return new pf(i.radiusTop,i.radiusBottom,i.height,i.radialSegments,i.heightSegments,i.openEnded,i.thetaStart,i.thetaLength)}}class ud extends pf{constructor(i=1,l=1,h=32,f=1,g=!1,v=0,C=Math.PI*2){super(0,i,l,h,f,g,v,C),this.type="ConeGeometry",this.parameters={radius:i,height:l,radialSegments:h,heightSegments:f,openEnded:g,thetaStart:v,thetaLength:C}}static fromJSON(i){return new ud(i.radius,i.height,i.radialSegments,i.heightSegments,i.openEnded,i.thetaStart,i.thetaLength)}}class hd extends Or{constructor(i=[],l=[],h=1,f=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:i,indices:l,radius:h,detail:f};const g=[],v=[];C(f),H(h),J(),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 C(Nt){const Pt=new Rt,Wt=new Rt,gn=new Rt;for(let Sn=0;Sn<l.length;Sn+=3)me(l[Sn+0],Pt),me(l[Sn+1],Wt),me(l[Sn+2],gn),V(Pt,Wt,gn,Nt)}function V(Nt,Pt,Wt,gn){const Sn=gn+1,kn=[];for(let In=0;In<=Sn;In++){kn[In]=[];const ii=Nt.clone().lerp(Wt,In/Sn),li=Pt.clone().lerp(Wt,In/Sn),dr=Sn-In;for(let Yr=0;Yr<=dr;Yr++)Yr===0&&In===Sn?kn[In][Yr]=ii:kn[In][Yr]=ii.clone().lerp(li,Yr/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?(pe(kn[In][li+1]),pe(kn[In+1][li]),pe(kn[In][li])):(pe(kn[In][li+1]),pe(kn[In+1][li+1]),pe(kn[In+1][li]))}}function H(Nt){const Pt=new Rt;for(let Wt=0;Wt<g.length;Wt+=3)Pt.x=g[Wt+0],Pt.y=g[Wt+1],Pt.z=g[Wt+2],Pt.normalize().multiplyScalar(Nt),g[Wt+0]=Pt.x,g[Wt+1]=Pt.y,g[Wt+2]=Pt.z}function J(){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 Wt=gt(Nt)/2/Math.PI+.5,gn=mt(Nt)/Math.PI+.5;v.push(Wt,1-gn)}Se(),he()}function he(){for(let Nt=0;Nt<v.length;Nt+=6){const Pt=v[Nt+0],Wt=v[Nt+2],gn=v[Nt+4],Sn=Math.max(Pt,Wt,gn),kn=Math.min(Pt,Wt,gn);Sn>.9&&kn<.1&&(Pt<.2&&(v[Nt+0]+=1),Wt<.2&&(v[Nt+2]+=1),gn<.2&&(v[Nt+4]+=1))}}function pe(Nt){g.push(Nt.x,Nt.y,Nt.z)}function me(Nt,Pt){const Wt=Nt*3;Pt.x=i[Wt+0],Pt.y=i[Wt+1],Pt.z=i[Wt+2]}function Se(){const Nt=new Rt,Pt=new Rt,Wt=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]),Wt.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(Wt).divideScalar(3);const dr=gt(gn);tt(Sn,li+0,Nt,dr),tt(kn,li+2,Pt,dr),tt(In,li+4,Wt,dr)}}function tt(Nt,Pt,Wt,gn){gn<0&&Nt.x===1&&(v[Pt]=Nt.x-1),Wt.x===0&&Wt.z===0&&(v[Pt]=gn/2/Math.PI+.5)}function gt(Nt){return Math.atan2(Nt.z,-Nt.x)}function mt(Nt){return Math.atan2(-Nt.y,Math.sqrt(Nt.x*Nt.x+Nt.z*Nt.z))}}copy(i){return super.copy(i),this.parameters=Object.assign({},i.parameters),this}static fromJSON(i){return new hd(i.vertices,i.indices,i.radius,i.details)}}class yc extends hd{constructor(i=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,i,l),this.type="DodecahedronGeometry",this.parameters={radius:i,detail:l}}static fromJSON(i){return new yc(i.radius,i.detail)}}const mf=new Rt,sg=new Rt,Sp=new Rt,dd=new br;class j0 extends Or{constructor(i=null,l=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:i,thresholdAngle:l},i!==null){const f=Math.pow(10,4),g=Math.cos(ru*l),v=i.getIndex(),C=i.getAttribute("position"),V=v?v.count:C.count,H=[0,0,0],J=["a","b","c"],he=new Array(3),pe={},me=[];for(let Se=0;Se<V;Se+=3){v?(H[0]=v.getX(Se),H[1]=v.getX(Se+1),H[2]=v.getX(Se+2)):(H[0]=Se,H[1]=Se+1,H[2]=Se+2);const{a:tt,b:gt,c:mt}=dd;if(tt.fromBufferAttribute(C,H[0]),gt.fromBufferAttribute(C,H[1]),mt.fromBufferAttribute(C,H[2]),dd.getNormal(Sp),he[0]=`${Math.round(tt.x*f)},${Math.round(tt.y*f)},${Math.round(tt.z*f)}`,he[1]=`${Math.round(gt.x*f)},${Math.round(gt.y*f)},${Math.round(gt.z*f)}`,he[2]=`${Math.round(mt.x*f)},${Math.round(mt.y*f)},${Math.round(mt.z*f)}`,!(he[0]===he[1]||he[1]===he[2]||he[2]===he[0]))for(let Nt=0;Nt<3;Nt++){const Pt=(Nt+1)%3,Wt=he[Nt],gn=he[Pt],Sn=dd[J[Nt]],kn=dd[J[Pt]],In=`${Wt}_${gn}`,ii=`${gn}_${Wt}`;ii in pe&&pe[ii]?(Sp.dot(pe[ii].normal)<=g&&(me.push(Sn.x,Sn.y,Sn.z),me.push(kn.x,kn.y,kn.z)),pe[ii]=null):In in pe||(pe[In]={index0:H[Nt],index1:H[Pt],normal:Sp.clone()})}}for(const Se in pe)if(pe[Se]){const{index0:tt,index1:gt}=pe[Se];mf.fromBufferAttribute(C,tt),sg.fromBufferAttribute(C,gt),me.push(mf.x,mf.y,mf.z),me.push(sg.x,sg.y,sg.z)}this.setAttribute("position",new qi(me,3))}}copy(i){return super.copy(i),this.parameters=Object.assign({},i.parameters),this}}class vc{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){_r("Curve: .getPoint() not implemented.")}getPointAt(i,l){const h=this.getUtoTmapping(i);return this.getPoint(h,l)}getPoints(i=5){const l=[];for(let h=0;h<=i;h++)l.push(this.getPoint(h/i));return l}getSpacedPoints(i=5){const l=[];for(let h=0;h<=i;h++)l.push(this.getPointAt(h/i));return l}getLength(){const i=this.getLengths();return i[i.length-1]}getLengths(i=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===i+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<=i;v++)h=this.getPoint(v/i),g+=h.distanceTo(f),l.push(g),f=h;return this.cacheArcLengths=l,l}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(i,l=null){const h=this.getLengths();let f=0;const g=h.length;let v;l?v=l:v=i*h[g-1];let C=0,V=g-1,H;for(;C<=V;)if(f=Math.floor(C+(V-C)/2),H=h[f]-v,H<0)C=f+1;else if(H>0)V=f-1;else{V=f;break}if(f=V,h[f]===v)return f/(g-1);const J=h[f],pe=h[f+1]-J,me=(v-J)/pe;return(f+me)/(g-1)}getTangent(i,l){let f=i-1e-4,g=i+1e-4;f<0&&(f=0),g>1&&(g=1);const v=this.getPoint(f),C=this.getPoint(g),V=l||(v.isVector2?new oi:new Rt);return V.copy(C).sub(v).normalize(),V}getTangentAt(i,l){const h=this.getUtoTmapping(i);return this.getTangent(h,l)}computeFrenetFrames(i,l=!1){const h=new Rt,f=[],g=[],v=[],C=new Rt,V=new On;for(let me=0;me<=i;me++){const Se=me/i;f[me]=this.getTangentAt(Se,new Rt)}g[0]=new Rt,v[0]=new Rt;let H=Number.MAX_VALUE;const J=Math.abs(f[0].x),he=Math.abs(f[0].y),pe=Math.abs(f[0].z);J<=H&&(H=J,h.set(1,0,0)),he<=H&&(H=he,h.set(0,1,0)),pe<=H&&h.set(0,0,1),C.crossVectors(f[0],h).normalize(),g[0].crossVectors(f[0],C),v[0].crossVectors(f[0],g[0]);for(let me=1;me<=i;me++){if(g[me]=g[me-1].clone(),v[me]=v[me-1].clone(),C.crossVectors(f[me-1],f[me]),C.length()>Number.EPSILON){C.normalize();const Se=Math.acos(Fr(f[me-1].dot(f[me]),-1,1));g[me].applyMatrix4(V.makeRotationAxis(C,Se))}v[me].crossVectors(f[me],g[me])}if(l===!0){let me=Math.acos(Fr(g[0].dot(g[i]),-1,1));me/=i,f[0].dot(C.crossVectors(g[0],g[i]))>0&&(me=-me);for(let Se=1;Se<=i;Se++)g[Se].applyMatrix4(V.makeRotationAxis(f[Se],me*Se)),v[Se].crossVectors(f[Se],g[Se])}return{tangents:f,normals:g,binormals:v}}clone(){return new this.constructor().copy(this)}copy(i){return this.arcLengthDivisions=i.arcLengthDivisions,this}toJSON(){const i={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return i.arcLengthDivisions=this.arcLengthDivisions,i.type=this.type,i}fromJSON(i){return this.arcLengthDivisions=i.arcLengthDivisions,this}}class Tp extends vc{constructor(i=0,l=0,h=1,f=1,g=0,v=Math.PI*2,C=!1,V=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=i,this.aY=l,this.xRadius=h,this.yRadius=f,this.aStartAngle=g,this.aEndAngle=v,this.aClockwise=C,this.aRotation=V}getPoint(i,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 C=this.aStartAngle+i*g;let V=this.aX+this.xRadius*Math.cos(C),H=this.aY+this.yRadius*Math.sin(C);if(this.aRotation!==0){const J=Math.cos(this.aRotation),he=Math.sin(this.aRotation),pe=V-this.aX,me=H-this.aY;V=pe*J-me*he+this.aX,H=pe*he+me*J+this.aY}return h.set(V,H)}copy(i){return super.copy(i),this.aX=i.aX,this.aY=i.aY,this.xRadius=i.xRadius,this.yRadius=i.yRadius,this.aStartAngle=i.aStartAngle,this.aEndAngle=i.aEndAngle,this.aClockwise=i.aClockwise,this.aRotation=i.aRotation,this}toJSON(){const i=super.toJSON();return i.aX=this.aX,i.aY=this.aY,i.xRadius=this.xRadius,i.yRadius=this.yRadius,i.aStartAngle=this.aStartAngle,i.aEndAngle=this.aEndAngle,i.aClockwise=this.aClockwise,i.aRotation=this.aRotation,i}fromJSON(i){return super.fromJSON(i),this.aX=i.aX,this.aY=i.aY,this.xRadius=i.xRadius,this.yRadius=i.yRadius,this.aStartAngle=i.aStartAngle,this.aEndAngle=i.aEndAngle,this.aClockwise=i.aClockwise,this.aRotation=i.aRotation,this}}class v1 extends Tp{constructor(i,l,h,f,g,v){super(i,l,h,h,f,g,v),this.isArcCurve=!0,this.type="ArcCurve"}}function og(){let j=0,i=0,l=0,h=0;function f(g,v,C,V){j=g,i=C,l=-3*g+3*v-2*C-V,h=2*g-2*v+C+V}return{initCatmullRom:function(g,v,C,V,H){f(v,C,H*(C-g),H*(V-v))},initNonuniformCatmullRom:function(g,v,C,V,H,J,he){let pe=(v-g)/H-(C-g)/(H+J)+(C-v)/J,me=(C-v)/J-(V-v)/(J+he)+(V-C)/he;pe*=J,me*=J,f(v,C,pe,me)},calc:function(g){const v=g*g,C=v*g;return j+i*g+l*v+h*C}}}const ag=new Rt,X0=new og,q0=new og,fd=new og;class x1 extends vc{constructor(i=[],l=!1,h="centripetal",f=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=i,this.closed=l,this.curveType=h,this.tension=f}getPoint(i,l=new Rt){const h=l,f=this.points,g=f.length,v=(g-(this.closed?0:1))*i;let C=Math.floor(v),V=v-C;this.closed?C+=C>0?0:(Math.floor(Math.abs(C)/g)+1)*g:V===0&&C===g-1&&(C=g-2,V=1);let H,J;this.closed||C>0?H=f[(C-1)%g]:(ag.subVectors(f[0],f[1]).add(f[0]),H=ag);const he=f[C%g],pe=f[(C+1)%g];if(this.closed||C+2<g?J=f[(C+2)%g]:(ag.subVectors(f[g-1],f[g-2]).add(f[g-1]),J=ag),this.curveType==="centripetal"||this.curveType==="chordal"){const me=this.curveType==="chordal"?.5:.25;let Se=Math.pow(H.distanceToSquared(he),me),tt=Math.pow(he.distanceToSquared(pe),me),gt=Math.pow(pe.distanceToSquared(J),me);tt<1e-4&&(tt=1),Se<1e-4&&(Se=tt),gt<1e-4&&(gt=tt),X0.initNonuniformCatmullRom(H.x,he.x,pe.x,J.x,Se,tt,gt),q0.initNonuniformCatmullRom(H.y,he.y,pe.y,J.y,Se,tt,gt),fd.initNonuniformCatmullRom(H.z,he.z,pe.z,J.z,Se,tt,gt)}else this.curveType==="catmullrom"&&(X0.initCatmullRom(H.x,he.x,pe.x,J.x,this.tension),q0.initCatmullRom(H.y,he.y,pe.y,J.y,this.tension),fd.initCatmullRom(H.z,he.z,pe.z,J.z,this.tension));return h.set(X0.calc(V),q0.calc(V),fd.calc(V)),h}copy(i){super.copy(i),this.points=[];for(let l=0,h=i.points.length;l<h;l++){const f=i.points[l];this.points.push(f.clone())}return this.closed=i.closed,this.curveType=i.curveType,this.tension=i.tension,this}toJSON(){const i=super.toJSON();i.points=[];for(let l=0,h=this.points.length;l<h;l++){const f=this.points[l];i.points.push(f.toArray())}return i.closed=this.closed,i.curveType=this.curveType,i.tension=this.tension,i}fromJSON(i){super.fromJSON(i),this.points=[];for(let l=0,h=i.points.length;l<h;l++){const f=i.points[l];this.points.push(new Rt().fromArray(f))}return this.closed=i.closed,this.curveType=i.curveType,this.tension=i.tension,this}}function xx(j,i,l,h,f){const g=(h-i)*.5,v=(f-l)*.5,C=j*j,V=j*C;return(2*l-2*h+g+v)*V+(-3*l+3*h-2*g-v)*C+g*j+l}function _1(j,i){const l=1-j;return l*l*i}function b1(j,i){return 2*(1-j)*j*i}function Ep(j,i){return j*j*i}function gf(j,i,l,h){return _1(j,i)+b1(j,l)+Ep(j,h)}function _x(j,i){const l=1-j;return l*l*l*i}function bx(j,i){const l=1-j;return 3*l*l*j*i}function w1(j,i){return 3*(1-j)*j*j*i}function wx(j,i){return j*j*j*i}function pd(j,i,l,h,f){return _x(j,i)+bx(j,l)+w1(j,h)+wx(j,f)}class Y0 extends vc{constructor(i=new oi,l=new oi,h=new oi,f=new oi){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=i,this.v1=l,this.v2=h,this.v3=f}getPoint(i,l=new oi){const h=l,f=this.v0,g=this.v1,v=this.v2,C=this.v3;return h.set(pd(i,f.x,g.x,v.x,C.x),pd(i,f.y,g.y,v.y,C.y)),h}copy(i){return super.copy(i),this.v0.copy(i.v0),this.v1.copy(i.v1),this.v2.copy(i.v2),this.v3.copy(i.v3),this}toJSON(){const i=super.toJSON();return i.v0=this.v0.toArray(),i.v1=this.v1.toArray(),i.v2=this.v2.toArray(),i.v3=this.v3.toArray(),i}fromJSON(i){return super.fromJSON(i),this.v0.fromArray(i.v0),this.v1.fromArray(i.v1),this.v2.fromArray(i.v2),this.v3.fromArray(i.v3),this}}class lg extends vc{constructor(i=new Rt,l=new Rt,h=new Rt,f=new Rt){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=i,this.v1=l,this.v2=h,this.v3=f}getPoint(i,l=new Rt){const h=l,f=this.v0,g=this.v1,v=this.v2,C=this.v3;return h.set(pd(i,f.x,g.x,v.x,C.x),pd(i,f.y,g.y,v.y,C.y),pd(i,f.z,g.z,v.z,C.z)),h}copy(i){return super.copy(i),this.v0.copy(i.v0),this.v1.copy(i.v1),this.v2.copy(i.v2),this.v3.copy(i.v3),this}toJSON(){const i=super.toJSON();return i.v0=this.v0.toArray(),i.v1=this.v1.toArray(),i.v2=this.v2.toArray(),i.v3=this.v3.toArray(),i}fromJSON(i){return super.fromJSON(i),this.v0.fromArray(i.v0),this.v1.fromArray(i.v1),this.v2.fromArray(i.v2),this.v3.fromArray(i.v3),this}}class Mx extends vc{constructor(i=new oi,l=new oi){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=i,this.v2=l}getPoint(i,l=new oi){const h=l;return i===1?h.copy(this.v2):(h.copy(this.v2).sub(this.v1),h.multiplyScalar(i).add(this.v1)),h}getPointAt(i,l){return this.getPoint(i,l)}getTangent(i,l=new oi){return l.subVectors(this.v2,this.v1).normalize()}getTangentAt(i,l){return this.getTangent(i,l)}copy(i){return super.copy(i),this.v1.copy(i.v1),this.v2.copy(i.v2),this}toJSON(){const i=super.toJSON();return i.v1=this.v1.toArray(),i.v2=this.v2.toArray(),i}fromJSON(i){return super.fromJSON(i),this.v1.fromArray(i.v1),this.v2.fromArray(i.v2),this}}class Z0 extends vc{constructor(i=new Rt,l=new Rt){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=i,this.v2=l}getPoint(i,l=new Rt){const h=l;return i===1?h.copy(this.v2):(h.copy(this.v2).sub(this.v1),h.multiplyScalar(i).add(this.v1)),h}getPointAt(i,l){return this.getPoint(i,l)}getTangent(i,l=new Rt){return l.subVectors(this.v2,this.v1).normalize()}getTangentAt(i,l){return this.getTangent(i,l)}copy(i){return super.copy(i),this.v1.copy(i.v1),this.v2.copy(i.v2),this}toJSON(){const i=super.toJSON();return i.v1=this.v1.toArray(),i.v2=this.v2.toArray(),i}fromJSON(i){return super.fromJSON(i),this.v1.fromArray(i.v1),this.v2.fromArray(i.v2),this}}class md extends vc{constructor(i=new oi,l=new oi,h=new oi){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=i,this.v1=l,this.v2=h}getPoint(i,l=new oi){const h=l,f=this.v0,g=this.v1,v=this.v2;return h.set(gf(i,f.x,g.x,v.x),gf(i,f.y,g.y,v.y)),h}copy(i){return super.copy(i),this.v0.copy(i.v0),this.v1.copy(i.v1),this.v2.copy(i.v2),this}toJSON(){const i=super.toJSON();return i.v0=this.v0.toArray(),i.v1=this.v1.toArray(),i.v2=this.v2.toArray(),i}fromJSON(i){return super.fromJSON(i),this.v0.fromArray(i.v0),this.v1.fromArray(i.v1),this.v2.fromArray(i.v2),this}}class Sx extends vc{constructor(i=new Rt,l=new Rt,h=new Rt){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=i,this.v1=l,this.v2=h}getPoint(i,l=new Rt){const h=l,f=this.v0,g=this.v1,v=this.v2;return h.set(gf(i,f.x,g.x,v.x),gf(i,f.y,g.y,v.y),gf(i,f.z,g.z,v.z)),h}copy(i){return super.copy(i),this.v0.copy(i.v0),this.v1.copy(i.v1),this.v2.copy(i.v2),this}toJSON(){const i=super.toJSON();return i.v0=this.v0.toArray(),i.v1=this.v1.toArray(),i.v2=this.v2.toArray(),i}fromJSON(i){return super.fromJSON(i),this.v0.fromArray(i.v0),this.v1.fromArray(i.v1),this.v2.fromArray(i.v2),this}}class K0 extends vc{constructor(i=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=i}getPoint(i,l=new oi){const h=l,f=this.points,g=(f.length-1)*i,v=Math.floor(g),C=g-v,V=f[v===0?v:v-1],H=f[v],J=f[v>f.length-2?f.length-1:v+1],he=f[v>f.length-3?f.length-1:v+2];return h.set(xx(C,V.x,H.x,J.x,he.x),xx(C,V.y,H.y,J.y,he.y)),h}copy(i){super.copy(i),this.points=[];for(let l=0,h=i.points.length;l<h;l++){const f=i.points[l];this.points.push(f.clone())}return this}toJSON(){const i=super.toJSON();i.points=[];for(let l=0,h=this.points.length;l<h;l++){const f=this.points[l];i.points.push(f.toArray())}return i}fromJSON(i){super.fromJSON(i),this.points=[];for(let l=0,h=i.points.length;l<h;l++){const f=i.points[l];this.points.push(new oi().fromArray(f))}return this}}var yu=Object.freeze({__proto__:null,ArcCurve:v1,CatmullRomCurve3:x1,CubicBezierCurve:Y0,CubicBezierCurve3:lg,EllipseCurve:Tp,LineCurve:Mx,LineCurve3:Z0,QuadraticBezierCurve:md,QuadraticBezierCurve3:Sx,SplineCurve:K0});class Ap extends vc{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(i){this.curves.push(i)}closePath(){const i=this.curves[0].getPoint(0),l=this.curves[this.curves.length-1].getPoint(1);if(!i.equals(l)){const h=i.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new yu[h](l,i))}return this}getPoint(i,l){const h=i*this.getLength(),f=this.getCurveLengths();let g=0;for(;g<f.length;){if(f[g]>=h){const v=f[g]-h,C=this.curves[g],V=C.getLength(),H=V===0?0:1-v/V;return C.getPointAt(H,l)}g++}return null}getLength(){const i=this.getCurveLengths();return i[i.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 i=[];let l=0;for(let h=0,f=this.curves.length;h<f;h++)l+=this.curves[h].getLength(),i.push(l);return this.cacheLengths=i,i}getSpacedPoints(i=40){const l=[];for(let h=0;h<=i;h++)l.push(this.getPoint(h/i));return this.autoClose&&l.push(l[0]),l}getPoints(i=12){const l=[];let h;for(let f=0,g=this.curves;f<g.length;f++){const v=g[f],C=v.isEllipseCurve?i*2:v.isLineCurve||v.isLineCurve3?1:v.isSplineCurve?i*v.points.length:i,V=v.getPoints(C);for(let H=0;H<V.length;H++){const J=V[H];h&&h.equals(J)||(l.push(J),h=J)}}return this.autoClose&&l.length>1&&!l[l.length-1].equals(l[0])&&l.push(l[0]),l}copy(i){super.copy(i),this.curves=[];for(let l=0,h=i.curves.length;l<h;l++){const f=i.curves[l];this.curves.push(f.clone())}return this.autoClose=i.autoClose,this}toJSON(){const i=super.toJSON();i.autoClose=this.autoClose,i.curves=[];for(let l=0,h=this.curves.length;l<h;l++){const f=this.curves[l];i.curves.push(f.toJSON())}return i}fromJSON(i){super.fromJSON(i),this.autoClose=i.autoClose,this.curves=[];for(let l=0,h=i.curves.length;l<h;l++){const f=i.curves[l];this.curves.push(new yu[f.type]().fromJSON(f))}return this}}class J0 extends Ap{constructor(i){super(),this.type="Path",this.currentPoint=new oi,i&&this.setFromPoints(i)}setFromPoints(i){this.moveTo(i[0].x,i[0].y);for(let l=1,h=i.length;l<h;l++)this.lineTo(i[l].x,i[l].y);return this}moveTo(i,l){return this.currentPoint.set(i,l),this}lineTo(i,l){const h=new Mx(this.currentPoint.clone(),new oi(i,l));return this.curves.push(h),this.currentPoint.set(i,l),this}quadraticCurveTo(i,l,h,f){const g=new md(this.currentPoint.clone(),new oi(i,l),new oi(h,f));return this.curves.push(g),this.currentPoint.set(h,f),this}bezierCurveTo(i,l,h,f,g,v){const C=new Y0(this.currentPoint.clone(),new oi(i,l),new oi(h,f),new oi(g,v));return this.curves.push(C),this.currentPoint.set(g,v),this}splineThru(i){const l=[this.currentPoint.clone()].concat(i),h=new K0(l);return this.curves.push(h),this.currentPoint.copy(i[i.length-1]),this}arc(i,l,h,f,g,v){const C=this.currentPoint.x,V=this.currentPoint.y;return this.absarc(i+C,l+V,h,f,g,v),this}absarc(i,l,h,f,g,v){return this.absellipse(i,l,h,h,f,g,v),this}ellipse(i,l,h,f,g,v,C,V){const H=this.currentPoint.x,J=this.currentPoint.y;return this.absellipse(i+H,l+J,h,f,g,v,C,V),this}absellipse(i,l,h,f,g,v,C,V){const H=new Tp(i,l,h,f,g,v,C,V);if(this.curves.length>0){const he=H.getPoint(0);he.equals(this.currentPoint)||this.lineTo(he.x,he.y)}this.curves.push(H);const J=H.getPoint(1);return this.currentPoint.copy(J),this}copy(i){return super.copy(i),this.currentPoint.copy(i.currentPoint),this}toJSON(){const i=super.toJSON();return i.currentPoint=this.currentPoint.toArray(),i}fromJSON(i){return super.fromJSON(i),this.currentPoint.fromArray(i.currentPoint),this}}class yf extends J0{constructor(i){super(i),this.uuid=Sl(),this.type="Shape",this.holes=[]}getPointsHoles(i){const l=[];for(let h=0,f=this.holes.length;h<f;h++)l[h]=this.holes[h].getPoints(i);return l}extractPoints(i){return{shape:this.getPoints(i),holes:this.getPointsHoles(i)}}copy(i){super.copy(i),this.holes=[];for(let l=0,h=i.holes.length;l<h;l++){const f=i.holes[l];this.holes.push(f.clone())}return this}toJSON(){const i=super.toJSON();i.uuid=this.uuid,i.holes=[];for(let l=0,h=this.holes.length;l<h;l++){const f=this.holes[l];i.holes.push(f.toJSON())}return i}fromJSON(i){super.fromJSON(i),this.uuid=i.uuid,this.holes=[];for(let l=0,h=i.holes.length;l<h;l++){const f=i.holes[l];this.holes.push(new J0().fromJSON(f))}return this}}function M1(j,i,l=2){const h=i&&i.length,f=h?i[0]*l:j.length;let g=Tx(j,0,f,l,!0);const v=[];if(!g||g.next===g.prev)return v;let C,V,H;if(h&&(g=C1(j,i,g,l)),j.length>80*l){C=j[0],V=j[1];let J=C,he=V;for(let pe=l;pe<f;pe+=l){const me=j[pe],Se=j[pe+1];me<C&&(C=me),Se<V&&(V=Se),me>J&&(J=me),Se>he&&(he=Se)}H=Math.max(J-C,he-V),H=H!==0?32767/H:0}return Cp(g,v,l,C,V,H,0),v}function Tx(j,i,l,h,f){let g;if(f===L1(j,i,l,h)>0)for(let v=i;v<l;v+=h)g=ny(v/h|0,j[v],j[v+1],g);else for(let v=l-h;v>=i;v-=h)g=ny(v/h|0,j[v],j[v+1],g);return g&&vf(g,g.next)&&(xf(g),g=g.next),g}function gd(j,i){if(!j)return j;i||(i=j);let l=j,h;do if(h=!1,!l.steiner&&(vf(l,l.next)||Mo(l.prev,l,l.next)===0)){if(xf(l),l=i=l.prev,l===l.next)break;h=!0}else l=l.next;while(h||l!==i);return i}function Cp(j,i,l,h,f,g,v){if(!j)return;!v&&g&&N1(j,h,f,g);let C=j;for(;j.prev!==j.next;){const V=j.prev,H=j.next;if(g?T1(j,h,f,g):S1(j)){i.push(V.i,j.i,H.i),xf(j),j=H.next,C=H.next;continue}if(j=H,j===C){v?v===1?(j=E1(gd(j),i),Cp(j,i,l,h,f,g,2)):v===2&&A1(j,i,l,h,f,g):Cp(gd(j),i,l,h,f,g,1);break}}}function S1(j){const i=j.prev,l=j,h=j.next;if(Mo(i,l,h)>=0)return!1;const f=i.x,g=l.x,v=h.x,C=i.y,V=l.y,H=h.y,J=Math.min(f,g,v),he=Math.min(C,V,H),pe=Math.max(f,g,v),me=Math.max(C,V,H);let Se=h.next;for(;Se!==i;){if(Se.x>=J&&Se.x<=pe&&Se.y>=he&&Se.y<=me&&bh(f,C,g,V,v,H,Se.x,Se.y)&&Mo(Se.prev,Se,Se.next)>=0)return!1;Se=Se.next}return!0}function T1(j,i,l,h){const f=j.prev,g=j,v=j.next;if(Mo(f,g,v)>=0)return!1;const C=f.x,V=g.x,H=v.x,J=f.y,he=g.y,pe=v.y,me=Math.min(C,V,H),Se=Math.min(J,he,pe),tt=Math.max(C,V,H),gt=Math.max(J,he,pe),mt=_h(me,Se,i,l,h),Nt=_h(tt,gt,i,l,h);let Pt=j.prevZ,Wt=j.nextZ;for(;Pt&&Pt.z>=mt&&Wt&&Wt.z<=Nt;){if(Pt.x>=me&&Pt.x<=tt&&Pt.y>=Se&&Pt.y<=gt&&Pt!==f&&Pt!==v&&bh(C,J,V,he,H,pe,Pt.x,Pt.y)&&Mo(Pt.prev,Pt,Pt.next)>=0||(Pt=Pt.prevZ,Wt.x>=me&&Wt.x<=tt&&Wt.y>=Se&&Wt.y<=gt&&Wt!==f&&Wt!==v&&bh(C,J,V,he,H,pe,Wt.x,Wt.y)&&Mo(Wt.prev,Wt,Wt.next)>=0))return!1;Wt=Wt.nextZ}for(;Pt&&Pt.z>=mt;){if(Pt.x>=me&&Pt.x<=tt&&Pt.y>=Se&&Pt.y<=gt&&Pt!==f&&Pt!==v&&bh(C,J,V,he,H,pe,Pt.x,Pt.y)&&Mo(Pt.prev,Pt,Pt.next)>=0)return!1;Pt=Pt.prevZ}for(;Wt&&Wt.z<=Nt;){if(Wt.x>=me&&Wt.x<=tt&&Wt.y>=Se&&Wt.y<=gt&&Wt!==f&&Wt!==v&&bh(C,J,V,he,H,pe,Wt.x,Wt.y)&&Mo(Wt.prev,Wt,Wt.next)>=0)return!1;Wt=Wt.nextZ}return!0}function E1(j,i){let l=j;do{const h=l.prev,f=l.next.next;!vf(h,f)&&ey(h,l,l.next,f)&&Ip(h,f)&&Ip(f,h)&&(i.push(h.i,l.i,f.i),xf(l),xf(l.next),l=j=f),l=l.next}while(l!==j);return gd(l)}function A1(j,i,l,h,f,g){let v=j;do{let C=v.next.next;for(;C!==v.prev;){if(v.i!==C.i&&P1(v,C)){let V=Gc(v,C);v=gd(v,v.next),V=gd(V,V.next),Cp(v,i,l,h,f,g,0),Cp(V,i,l,h,f,g,0);return}C=C.next}v=v.next}while(v!==j)}function C1(j,i,l,h){const f=[];for(let g=0,v=i.length;g<v;g++){const C=i[g]*h,V=g<v-1?i[g+1]*h:j.length,H=Tx(j,C,V,h,!1);H===H.next&&(H.steiner=!0),f.push(Ax(H))}f.sort(Q0);for(let g=0;g<f.length;g++)l=R1(f[g],l);return l}function Q0(j,i){let l=j.x-i.x;if(l===0&&(l=j.y-i.y,l===0)){const h=(j.next.y-j.y)/(j.next.x-j.x),f=(i.next.y-i.y)/(i.next.x-i.x);l=h-f}return l}function R1(j,i){const l=Ex(j,i);if(!l)return i;const h=Gc(l,j);return gd(h,h.next),gd(l,l.next)}function Ex(j,i){let l=i;const h=j.x,f=j.y;let g=-1/0,v;if(vf(j,l))return l;do{if(vf(j,l.next))return l.next;if(f<=l.y&&f>=l.next.y&&l.next.y!==l.y){const he=l.x+(f-l.y)*(l.next.x-l.x)/(l.next.y-l.y);if(he<=h&&he>g&&(g=he,v=l.x<l.next.x?l:l.next,he===h))return v}l=l.next}while(l!==i);if(!v)return null;const C=v,V=v.x,H=v.y;let J=1/0;l=v;do{if(h>=l.x&&l.x>=V&&h!==l.x&&Np(f<H?h:g,f,V,H,f<H?g:h,f,l.x,l.y)){const he=Math.abs(f-l.y)/(h-l.x);Ip(l,j)&&(he<J||he===J&&(l.x>v.x||l.x===v.x&&Rp(v,l)))&&(v=l,J=he)}l=l.next}while(l!==C);return v}function Rp(j,i){return Mo(j.prev,j,i.prev)<0&&Mo(i.next,j,j.next)<0}function N1(j,i,l,h){let f=j;do f.z===0&&(f.z=_h(f.x,f.y,i,l,h)),f.prevZ=f.prev,f.nextZ=f.next,f=f.next;while(f!==j);f.prevZ.nextZ=null,f.prevZ=null,jo(f)}function jo(j){let i,l=1;do{let h=j,f;j=null;let g=null;for(i=0;h;){i++;let v=h,C=0;for(let H=0;H<l&&(C++,v=v.nextZ,!!v);H++);let V=l;for(;C>0||V>0&&v;)C!==0&&(V===0||!v||h.z<=v.z)?(f=h,h=h.nextZ,C--):(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(i>1);return j}function _h(j,i,l,h,f){return j=(j-l)*f|0,i=(i-h)*f|0,j=(j|j<<8)&16711935,j=(j|j<<4)&252645135,j=(j|j<<2)&858993459,j=(j|j<<1)&1431655765,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,j|i<<1}function Ax(j){let i=j,l=j;do(i.x<l.x||i.x===l.x&&i.y<l.y)&&(l=i),i=i.next;while(i!==j);return l}function Np(j,i,l,h,f,g,v,C){return(f-v)*(i-C)>=(j-v)*(g-C)&&(j-v)*(h-C)>=(l-v)*(i-C)&&(l-v)*(g-C)>=(f-v)*(h-C)}function bh(j,i,l,h,f,g,v,C){return!(j===v&&i===C)&&Np(j,i,l,h,f,g,v,C)}function P1(j,i){return j.next.i!==i.i&&j.prev.i!==i.i&&!ty(j,i)&&(Ip(j,i)&&Ip(i,j)&&I1(j,i)&&(Mo(j.prev,j,i.prev)||Mo(j,i.prev,i))||vf(j,i)&&Mo(j.prev,j,j.next)>0&&Mo(i.prev,i,i.next)>0)}function Mo(j,i,l){return(i.y-j.y)*(l.x-i.x)-(i.x-j.x)*(l.y-i.y)}function vf(j,i){return j.x===i.x&&j.y===i.y}function ey(j,i,l,h){const f=wh(Mo(j,i,l)),g=wh(Mo(j,i,h)),v=wh(Mo(l,h,j)),C=wh(Mo(l,h,i));return!!(f!==g&&v!==C||f===0&&Pp(j,l,i)||g===0&&Pp(j,h,i)||v===0&&Pp(l,j,h)||C===0&&Pp(l,i,h))}function Pp(j,i,l){return i.x<=Math.max(j.x,l.x)&&i.x>=Math.min(j.x,l.x)&&i.y<=Math.max(j.y,l.y)&&i.y>=Math.min(j.y,l.y)}function wh(j){return j>0?1:j<0?-1:0}function ty(j,i){let l=j;do{if(l.i!==j.i&&l.next.i!==j.i&&l.i!==i.i&&l.next.i!==i.i&&ey(l,l.next,j,i))return!0;l=l.next}while(l!==j);return!1}function Ip(j,i){return Mo(j.prev,j,j.next)<0?Mo(j,i,j.next)>=0&&Mo(j,j.prev,i)>=0:Mo(j,i,j.prev)<0||Mo(j,j.next,i)<0}function I1(j,i){let l=j,h=!1;const f=(j.x+i.x)/2,g=(j.y+i.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 Gc(j,i){const l=Lp(j.i,j.x,j.y),h=Lp(i.i,i.x,i.y),f=j.next,g=i.prev;return j.next=i,i.prev=j,l.next=f,f.prev=l,h.next=l,l.prev=h,g.next=h,h.prev=g,h}function ny(j,i,l,h){const f=Lp(j,i,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 xf(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 Lp(j,i,l){return{i:j,x:i,y:l,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function L1(j,i,l,h){let f=0;for(let g=i,v=l-h;g<l;g+=h)f+=(j[v]-j[g])*(j[g+1]+j[v+1]),v=g;return f}class D1{static triangulate(i,l,h=2){return M1(i,l,h)}}class xc{static area(i){const l=i.length;let h=0;for(let f=l-1,g=0;g<l;f=g++)h+=i[f].x*i[g].y-i[g].x*i[f].y;return h*.5}static isClockWise(i){return xc.area(i)<0}static triangulateShape(i,l){const h=[],f=[],g=[];cg(i),Dp(h,i);let v=i.length;l.forEach(cg);for(let V=0;V<l.length;V++)f.push(v),v+=l[V].length,Dp(h,l[V]);const C=D1.triangulate(h,f);for(let V=0;V<C.length;V+=3)g.push(C.slice(V,V+3));return g}}function cg(j){const i=j.length;i>2&&j[i-1].equals(j[0])&&j.pop()}function Dp(j,i){for(let l=0;l<i.length;l++)j.push(i[l].x),j.push(i[l].y)}class Mh extends Or{constructor(i=new yf([new oi(.5,.5),new oi(-.5,.5),new oi(-.5,-.5),new oi(.5,-.5)]),l={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:i,options:l},i=Array.isArray(i)?i:[i];const h=this,f=[],g=[];for(let C=0,V=i.length;C<V;C++){const H=i[C];v(H)}this.setAttribute("position",new qi(f,3)),this.setAttribute("uv",new qi(g,2)),this.computeVertexNormals();function v(C){const V=[],H=l.curveSegments!==void 0?l.curveSegments:12,J=l.steps!==void 0?l.steps:1,he=l.depth!==void 0?l.depth:1;let pe=l.bevelEnabled!==void 0?l.bevelEnabled:!0,me=l.bevelThickness!==void 0?l.bevelThickness:.2,Se=l.bevelSize!==void 0?l.bevelSize:me-.1,tt=l.bevelOffset!==void 0?l.bevelOffset:0,gt=l.bevelSegments!==void 0?l.bevelSegments:3;const mt=l.extrudePath,Nt=l.UVGenerator!==void 0?l.UVGenerator:iy;let Pt,Wt=!1,gn,Sn,kn,In;mt&&(Pt=mt.getSpacedPoints(J),Wt=!0,pe=!1,gn=mt.computeFrenetFrames(J,!1),Sn=new Rt,kn=new Rt,In=new Rt),pe||(gt=0,me=0,Se=0,tt=0);const ii=C.extractPoints(H);let li=ii.shape;const dr=ii.holes;if(!xc.isClockWise(li)){li=li.reverse();for(let Ui=0,tr=dr.length;Ui<tr;Ui++){const rr=dr[Ui];xc.isClockWise(rr)&&(dr[Ui]=rr.reverse())}}function Ss(Ui){const rr=10000000000000001e-36;let fr=Ui[0];for(let lr=1;lr<=Ui.length;lr++){const Js=lr%Ui.length,Ts=Ui[Js],zo=Ts.x-fr.x,Yo=Ts.y-fr.y,Ga=zo*zo+Yo*Yo,nc=Math.max(Math.abs(Ts.x),Math.abs(Ts.y),Math.abs(fr.x),Math.abs(fr.y)),Cd=rr*nc*nc;if(Ga<=Cd){Ui.splice(Js,1),lr--;continue}fr=Ts}}Ss(li),dr.forEach(Ss);const eo=dr.length,uo=li;for(let Ui=0;Ui<eo;Ui++){const tr=dr[Ui];li=li.concat(tr)}function Aa(Ui,tr,rr){return tr||js("ExtrudeGeometry: vec does not exist"),Ui.clone().addScaledVector(tr,rr)}const hl=li.length;function tc(Ui,tr,rr){let fr,lr,Js;const Ts=Ui.x-tr.x,zo=Ui.y-tr.y,Yo=rr.x-Ui.x,Ga=rr.y-Ui.y,nc=Ts*Ts+zo*zo,Cd=Ts*Ga-zo*Yo;if(Math.abs(Cd)>Number.EPSILON){const ic=Math.sqrt(nc),Jx=Math.sqrt(Yo*Yo+Ga*Ga),Qx=tr.x-zo/ic,e_=tr.y+Ts/ic,lw=rr.x-Ga/Jx,cw=rr.y+Yo/Jx,t_=((lw-Qx)*Ga-(cw-e_)*Yo)/(Ts*Ga-zo*Yo);fr=Qx+Ts*t_-Ui.x,lr=e_+zo*t_-Ui.y;const n_=fr*fr+lr*lr;if(n_<=2)return new oi(fr,lr);Js=Math.sqrt(n_/2)}else{let ic=!1;Ts>Number.EPSILON?Yo>Number.EPSILON&&(ic=!0):Ts<-Number.EPSILON?Yo<-Number.EPSILON&&(ic=!0):Math.sign(zo)===Math.sign(Ga)&&(ic=!0),ic?(fr=-zo,lr=Ts,Js=Math.sqrt(nc)):(fr=Ts,lr=zo,Js=Math.sqrt(nc/2))}return new oi(fr/Js,lr/Js)}const Xo=[];for(let Ui=0,tr=uo.length,rr=tr-1,fr=Ui+1;Ui<tr;Ui++,rr++,fr++)rr===tr&&(rr=0),fr===tr&&(fr=0),Xo[Ui]=tc(uo[Ui],uo[rr],uo[fr]);const Ca=[];let qo,Hc=Xo.concat();for(let Ui=0,tr=eo;Ui<tr;Ui++){const rr=dr[Ui];qo=[];for(let fr=0,lr=rr.length,Js=lr-1,Ts=fr+1;fr<lr;fr++,Js++,Ts++)Js===lr&&(Js=0),Ts===lr&&(Ts=0),qo[fr]=tc(rr[fr],rr[Js],rr[Ts]);Ca.push(qo),Hc=Hc.concat(qo)}let wc;if(gt===0)wc=xc.triangulateShape(uo,dr);else{const Ui=[],tr=[];for(let rr=0;rr<gt;rr++){const fr=rr/gt,lr=me*Math.cos(fr*Math.PI/2),Js=Se*Math.sin(fr*Math.PI/2)+tt;for(let Ts=0,zo=uo.length;Ts<zo;Ts++){const Yo=Aa(uo[Ts],Xo[Ts],Js);xu(Yo.x,Yo.y,-lr),fr===0&&Ui.push(Yo)}for(let Ts=0,zo=eo;Ts<zo;Ts++){const Yo=dr[Ts];qo=Ca[Ts];const Ga=[];for(let nc=0,Cd=Yo.length;nc<Cd;nc++){const ic=Aa(Yo[nc],qo[nc],Js);xu(ic.x,ic.y,-lr),fr===0&&Ga.push(ic)}fr===0&&tr.push(Ga)}}wc=xc.triangulateShape(Ui,tr)}const Eh=wc.length,Zp=Se+tt;for(let Ui=0;Ui<hl;Ui++){const tr=pe?Aa(li[Ui],Hc[Ui],Zp):li[Ui];Wt?(kn.copy(gn.normals[0]).multiplyScalar(tr.x),Sn.copy(gn.binormals[0]).multiplyScalar(tr.y),In.copy(Pt[0]).add(kn).add(Sn),xu(In.x,In.y,In.z)):xu(tr.x,tr.y,0)}for(let Ui=1;Ui<=J;Ui++)for(let tr=0;tr<hl;tr++){const rr=pe?Aa(li[tr],Hc[tr],Zp):li[tr];Wt?(kn.copy(gn.normals[Ui]).multiplyScalar(rr.x),Sn.copy(gn.binormals[Ui]).multiplyScalar(rr.y),In.copy(Pt[Ui]).add(kn).add(Sn),xu(In.x,In.y,In.z)):xu(rr.x,rr.y,he/J*Ui)}for(let Ui=gt-1;Ui>=0;Ui--){const tr=Ui/gt,rr=me*Math.cos(tr*Math.PI/2),fr=Se*Math.sin(tr*Math.PI/2)+tt;for(let lr=0,Js=uo.length;lr<Js;lr++){const Ts=Aa(uo[lr],Xo[lr],fr);xu(Ts.x,Ts.y,he+rr)}for(let lr=0,Js=dr.length;lr<Js;lr++){const Ts=dr[lr];qo=Ca[lr];for(let zo=0,Yo=Ts.length;zo<Yo;zo++){const Ga=Aa(Ts[zo],qo[zo],fr);Wt?xu(Ga.x,Ga.y+Pt[J-1].y,Pt[J-1].x+rr):xu(Ga.x,Ga.y,he+rr)}}}aw(),Yx();function aw(){const Ui=f.length/3;if(pe){let tr=0,rr=hl*tr;for(let fr=0;fr<Eh;fr++){const lr=wc[fr];Of(lr[2]+rr,lr[1]+rr,lr[0]+rr)}tr=J+gt*2,rr=hl*tr;for(let fr=0;fr<Eh;fr++){const lr=wc[fr];Of(lr[0]+rr,lr[1]+rr,lr[2]+rr)}}else{for(let tr=0;tr<Eh;tr++){const rr=wc[tr];Of(rr[2],rr[1],rr[0])}for(let tr=0;tr<Eh;tr++){const rr=wc[tr];Of(rr[0]+hl*J,rr[1]+hl*J,rr[2]+hl*J)}}h.addGroup(Ui,f.length/3-Ui,0)}function Yx(){const Ui=f.length/3;let tr=0;Zx(uo,tr),tr+=uo.length;for(let rr=0,fr=dr.length;rr<fr;rr++){const lr=dr[rr];Zx(lr,tr),tr+=lr.length}h.addGroup(Ui,f.length/3-Ui,1)}function Zx(Ui,tr){let rr=Ui.length;for(;--rr>=0;){const fr=rr;let lr=rr-1;lr<0&&(lr=Ui.length-1);for(let Js=0,Ts=J+gt*2;Js<Ts;Js++){const zo=hl*Js,Yo=hl*(Js+1),Ga=tr+fr+zo,nc=tr+lr+zo,Cd=tr+lr+Yo,ic=tr+fr+Yo;Kx(Ga,nc,Cd,ic)}}}function xu(Ui,tr,rr){V.push(Ui),V.push(tr),V.push(rr)}function Of(Ui,tr,rr){Ju(Ui),Ju(tr),Ju(rr);const fr=f.length/3,lr=Nt.generateTopUV(h,f,fr-3,fr-2,fr-1);Qu(lr[0]),Qu(lr[1]),Qu(lr[2])}function Kx(Ui,tr,rr,fr){Ju(Ui),Ju(tr),Ju(fr),Ju(tr),Ju(rr),Ju(fr);const lr=f.length/3,Js=Nt.generateSideWallUV(h,f,lr-6,lr-3,lr-2,lr-1);Qu(Js[0]),Qu(Js[1]),Qu(Js[3]),Qu(Js[1]),Qu(Js[2]),Qu(Js[3])}function Ju(Ui){f.push(V[Ui*3+0]),f.push(V[Ui*3+1]),f.push(V[Ui*3+2])}function Qu(Ui){g.push(Ui.x),g.push(Ui.y)}}}copy(i){return super.copy(i),this.parameters=Object.assign({},i.parameters),this}toJSON(){const i=super.toJSON(),l=this.parameters.shapes,h=this.parameters.options;return ry(l,h,i)}static fromJSON(i,l){const h=[];for(let g=0,v=i.shapes.length;g<v;g++){const C=l[i.shapes[g]];h.push(C)}const f=i.options.extrudePath;return f!==void 0&&(i.options.extrudePath=new yu[f.type]().fromJSON(f)),new Mh(h,i.options)}}const iy={generateTopUV:function(j,i,l,h,f){const g=i[l*3],v=i[l*3+1],C=i[h*3],V=i[h*3+1],H=i[f*3],J=i[f*3+1];return[new oi(g,v),new oi(C,V),new oi(H,J)]},generateSideWallUV:function(j,i,l,h,f,g){const v=i[l*3],C=i[l*3+1],V=i[l*3+2],H=i[h*3],J=i[h*3+1],he=i[h*3+2],pe=i[f*3],me=i[f*3+1],Se=i[f*3+2],tt=i[g*3],gt=i[g*3+1],mt=i[g*3+2];return Math.abs(C-J)<Math.abs(v-H)?[new oi(v,1-V),new oi(H,1-he),new oi(pe,1-Se),new oi(tt,1-mt)]:[new oi(C,1-V),new oi(J,1-he),new oi(me,1-Se),new oi(gt,1-mt)]}};function ry(j,i,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({},i),i.extrudePath!==void 0&&(l.options.extrudePath=i.extrudePath.toJSON()),l}class sy extends hd{constructor(i=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,i,l),this.type="IcosahedronGeometry",this.parameters={radius:i,detail:l}}static fromJSON(i){return new sy(i.radius,i.detail)}}class ju extends Or{constructor(i=[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:i,segments:l,phiStart:h,phiLength:f},l=Math.floor(l),f=Fr(f,0,Math.PI*2);const g=[],v=[],C=[],V=[],H=[],J=1/l,he=new Rt,pe=new oi,me=new Rt,Se=new Rt,tt=new Rt;let gt=0,mt=0;for(let Nt=0;Nt<=i.length-1;Nt++)switch(Nt){case 0:gt=i[Nt+1].x-i[Nt].x,mt=i[Nt+1].y-i[Nt].y,me.x=mt*1,me.y=-gt,me.z=mt*0,tt.copy(me),me.normalize(),V.push(me.x,me.y,me.z);break;case i.length-1:V.push(tt.x,tt.y,tt.z);break;default:gt=i[Nt+1].x-i[Nt].x,mt=i[Nt+1].y-i[Nt].y,me.x=mt*1,me.y=-gt,me.z=mt*0,Se.copy(me),me.x+=tt.x,me.y+=tt.y,me.z+=tt.z,me.normalize(),V.push(me.x,me.y,me.z),tt.copy(Se)}for(let Nt=0;Nt<=l;Nt++){const Pt=h+Nt*J*f,Wt=Math.sin(Pt),gn=Math.cos(Pt);for(let Sn=0;Sn<=i.length-1;Sn++){he.x=i[Sn].x*Wt,he.y=i[Sn].y,he.z=i[Sn].x*gn,v.push(he.x,he.y,he.z),pe.x=Nt/l,pe.y=Sn/(i.length-1),C.push(pe.x,pe.y);const kn=V[3*Sn+0]*Wt,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<i.length-1;Pt++){const Wt=Pt+Nt*i.length,gn=Wt,Sn=Wt+i.length,kn=Wt+i.length+1,In=Wt+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(C,2)),this.setAttribute("normal",new qi(H,3))}copy(i){return super.copy(i),this.parameters=Object.assign({},i.parameters),this}static fromJSON(i){return new ju(i.points,i.segments,i.phiStart,i.phiLength)}}class _f extends hd{constructor(i=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,i,l),this.type="OctahedronGeometry",this.parameters={radius:i,detail:l}}static fromJSON(i){return new _f(i.radius,i.detail)}}class Op extends Or{constructor(i=1,l=1,h=1,f=1){super(),this.type="PlaneGeometry",this.parameters={width:i,height:l,widthSegments:h,heightSegments:f};const g=i/2,v=l/2,C=Math.floor(h),V=Math.floor(f),H=C+1,J=V+1,he=i/C,pe=l/V,me=[],Se=[],tt=[],gt=[];for(let mt=0;mt<J;mt++){const Nt=mt*pe-v;for(let Pt=0;Pt<H;Pt++){const Wt=Pt*he-g;Se.push(Wt,-Nt,0),tt.push(0,0,1),gt.push(Pt/C),gt.push(1-mt/V)}}for(let mt=0;mt<V;mt++)for(let Nt=0;Nt<C;Nt++){const Pt=Nt+H*mt,Wt=Nt+H*(mt+1),gn=Nt+1+H*(mt+1),Sn=Nt+1+H*mt;me.push(Pt,Wt,Sn),me.push(Wt,gn,Sn)}this.setIndex(me),this.setAttribute("position",new qi(Se,3)),this.setAttribute("normal",new qi(tt,3)),this.setAttribute("uv",new qi(gt,2))}copy(i){return super.copy(i),this.parameters=Object.assign({},i.parameters),this}static fromJSON(i){return new Op(i.width,i.height,i.widthSegments,i.heightSegments)}}class Fp extends Or{constructor(i=.5,l=1,h=32,f=1,g=0,v=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:i,outerRadius:l,thetaSegments:h,phiSegments:f,thetaStart:g,thetaLength:v},h=Math.max(3,h),f=Math.max(1,f);const C=[],V=[],H=[],J=[];let he=i;const pe=(l-i)/f,me=new Rt,Se=new oi;for(let tt=0;tt<=f;tt++){for(let gt=0;gt<=h;gt++){const mt=g+gt/h*v;me.x=he*Math.cos(mt),me.y=he*Math.sin(mt),V.push(me.x,me.y,me.z),H.push(0,0,1),Se.x=(me.x/l+1)/2,Se.y=(me.y/l+1)/2,J.push(Se.x,Se.y)}he+=pe}for(let tt=0;tt<f;tt++){const gt=tt*(h+1);for(let mt=0;mt<h;mt++){const Nt=mt+gt,Pt=Nt,Wt=Nt+h+1,gn=Nt+h+2,Sn=Nt+1;C.push(Pt,Wt,Sn),C.push(Wt,gn,Sn)}}this.setIndex(C),this.setAttribute("position",new qi(V,3)),this.setAttribute("normal",new qi(H,3)),this.setAttribute("uv",new qi(J,2))}copy(i){return super.copy(i),this.parameters=Object.assign({},i.parameters),this}static fromJSON(i){return new Fp(i.innerRadius,i.outerRadius,i.thetaSegments,i.phiSegments,i.thetaStart,i.thetaLength)}}class bf extends Or{constructor(i=new yf([new oi(0,.5),new oi(-.5,-.5),new oi(.5,-.5)]),l=12){super(),this.type="ShapeGeometry",this.parameters={shapes:i,curveSegments:l};const h=[],f=[],g=[],v=[];let C=0,V=0;if(Array.isArray(i)===!1)H(i);else for(let J=0;J<i.length;J++)H(i[J]),this.addGroup(C,V,J),C+=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(J){const he=f.length/3,pe=J.extractPoints(l);let me=pe.shape;const Se=pe.holes;xc.isClockWise(me)===!1&&(me=me.reverse());for(let gt=0,mt=Se.length;gt<mt;gt++){const Nt=Se[gt];xc.isClockWise(Nt)===!0&&(Se[gt]=Nt.reverse())}const tt=xc.triangulateShape(me,Se);for(let gt=0,mt=Se.length;gt<mt;gt++){const Nt=Se[gt];me=me.concat(Nt)}for(let gt=0,mt=me.length;gt<mt;gt++){const Nt=me[gt];f.push(Nt.x,Nt.y,0),g.push(0,0,1),v.push(Nt.x,Nt.y)}for(let gt=0,mt=tt.length;gt<mt;gt++){const Nt=tt[gt],Pt=Nt[0]+he,Wt=Nt[1]+he,gn=Nt[2]+he;h.push(Pt,Wt,gn),V+=3}}}copy(i){return super.copy(i),this.parameters=Object.assign({},i.parameters),this}toJSON(){const i=super.toJSON(),l=this.parameters.shapes;return O1(l,i)}static fromJSON(i,l){const h=[];for(let f=0,g=i.shapes.length;f<g;f++){const v=l[i.shapes[f]];h.push(v)}return new bf(h,i.curveSegments)}}function O1(j,i){if(i.shapes=[],Array.isArray(j))for(let l=0,h=j.length;l<h;l++){const f=j[l];i.shapes.push(f.uuid)}else i.shapes.push(j.uuid);return i}class wf extends Or{constructor(i=1,l=32,h=16,f=0,g=Math.PI*2,v=0,C=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:i,widthSegments:l,heightSegments:h,phiStart:f,phiLength:g,thetaStart:v,thetaLength:C},l=Math.max(3,Math.floor(l)),h=Math.max(2,Math.floor(h));const V=Math.min(v+C,Math.PI);let H=0;const J=[],he=new Rt,pe=new Rt,me=[],Se=[],tt=[],gt=[];for(let mt=0;mt<=h;mt++){const Nt=[],Pt=mt/h;let Wt=0;mt===0&&v===0?Wt=.5/l:mt===h&&V===Math.PI&&(Wt=-.5/l);for(let gn=0;gn<=l;gn++){const Sn=gn/l;he.x=-i*Math.cos(f+Sn*g)*Math.sin(v+Pt*C),he.y=i*Math.cos(v+Pt*C),he.z=i*Math.sin(f+Sn*g)*Math.sin(v+Pt*C),Se.push(he.x,he.y,he.z),pe.copy(he).normalize(),tt.push(pe.x,pe.y,pe.z),gt.push(Sn+Wt,1-Pt),Nt.push(H++)}J.push(Nt)}for(let mt=0;mt<h;mt++)for(let Nt=0;Nt<l;Nt++){const Pt=J[mt][Nt+1],Wt=J[mt][Nt],gn=J[mt+1][Nt],Sn=J[mt+1][Nt+1];(mt!==0||v>0)&&me.push(Pt,Wt,Sn),(mt!==h-1||V<Math.PI)&&me.push(Wt,gn,Sn)}this.setIndex(me),this.setAttribute("position",new qi(Se,3)),this.setAttribute("normal",new qi(tt,3)),this.setAttribute("uv",new qi(gt,2))}copy(i){return super.copy(i),this.parameters=Object.assign({},i.parameters),this}static fromJSON(i){return new wf(i.radius,i.widthSegments,i.heightSegments,i.phiStart,i.phiLength,i.thetaStart,i.thetaLength)}}class ug extends hd{constructor(i=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,i,l),this.type="TetrahedronGeometry",this.parameters={radius:i,detail:l}}static fromJSON(i){return new ug(i.radius,i.detail)}}class hg extends Or{constructor(i=1,l=.4,h=12,f=48,g=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:i,tube:l,radialSegments:h,tubularSegments:f,arc:g},h=Math.floor(h),f=Math.floor(f);const v=[],C=[],V=[],H=[],J=new Rt,he=new Rt,pe=new Rt;for(let me=0;me<=h;me++)for(let Se=0;Se<=f;Se++){const tt=Se/f*g,gt=me/h*Math.PI*2;he.x=(i+l*Math.cos(gt))*Math.cos(tt),he.y=(i+l*Math.cos(gt))*Math.sin(tt),he.z=l*Math.sin(gt),C.push(he.x,he.y,he.z),J.x=i*Math.cos(tt),J.y=i*Math.sin(tt),pe.subVectors(he,J).normalize(),V.push(pe.x,pe.y,pe.z),H.push(Se/f),H.push(me/h)}for(let me=1;me<=h;me++)for(let Se=1;Se<=f;Se++){const tt=(f+1)*me+Se-1,gt=(f+1)*(me-1)+Se-1,mt=(f+1)*(me-1)+Se,Nt=(f+1)*me+Se;v.push(tt,gt,Nt),v.push(gt,mt,Nt)}this.setIndex(v),this.setAttribute("position",new qi(C,3)),this.setAttribute("normal",new qi(V,3)),this.setAttribute("uv",new qi(H,2))}copy(i){return super.copy(i),this.parameters=Object.assign({},i.parameters),this}static fromJSON(i){return new hg(i.radius,i.tube,i.radialSegments,i.tubularSegments,i.arc)}}class oy extends Or{constructor(i=1,l=.4,h=64,f=8,g=2,v=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:i,tube:l,tubularSegments:h,radialSegments:f,p:g,q:v},h=Math.floor(h),f=Math.floor(f);const C=[],V=[],H=[],J=[],he=new Rt,pe=new Rt,me=new Rt,Se=new Rt,tt=new Rt,gt=new Rt,mt=new Rt;for(let Pt=0;Pt<=h;++Pt){const Wt=Pt/h*g*Math.PI*2;Nt(Wt,g,v,i,me),Nt(Wt+.01,g,v,i,Se),gt.subVectors(Se,me),mt.addVectors(Se,me),tt.crossVectors(gt,mt),mt.crossVectors(tt,gt),tt.normalize(),mt.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);he.x=me.x+(kn*mt.x+In*tt.x),he.y=me.y+(kn*mt.y+In*tt.y),he.z=me.z+(kn*mt.z+In*tt.z),V.push(he.x,he.y,he.z),pe.subVectors(he,me).normalize(),H.push(pe.x,pe.y,pe.z),J.push(Pt/h),J.push(gn/f)}}for(let Pt=1;Pt<=h;Pt++)for(let Wt=1;Wt<=f;Wt++){const gn=(f+1)*(Pt-1)+(Wt-1),Sn=(f+1)*Pt+(Wt-1),kn=(f+1)*Pt+Wt,In=(f+1)*(Pt-1)+Wt;C.push(gn,Sn,In),C.push(Sn,kn,In)}this.setIndex(C),this.setAttribute("position",new qi(V,3)),this.setAttribute("normal",new qi(H,3)),this.setAttribute("uv",new qi(J,2));function Nt(Pt,Wt,gn,Sn,kn){const In=Math.cos(Pt),ii=Math.sin(Pt),li=gn/Wt*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(i){return super.copy(i),this.parameters=Object.assign({},i.parameters),this}static fromJSON(i){return new oy(i.radius,i.tube,i.tubularSegments,i.radialSegments,i.p,i.q)}}class Bp extends Or{constructor(i=new Sx(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:i,tubularSegments:l,radius:h,radialSegments:f,closed:g};const v=i.computeFrenetFrames(l,g);this.tangents=v.tangents,this.normals=v.normals,this.binormals=v.binormals;const C=new Rt,V=new Rt,H=new oi;let J=new Rt;const he=[],pe=[],me=[],Se=[];tt(),this.setIndex(Se),this.setAttribute("position",new qi(he,3)),this.setAttribute("normal",new qi(pe,3)),this.setAttribute("uv",new qi(me,2));function tt(){for(let Pt=0;Pt<l;Pt++)gt(Pt);gt(g===!1?l:0),Nt(),mt()}function gt(Pt){J=i.getPointAt(Pt/l,J);const Wt=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*Wt.x+In*gn.x,V.y=ii*Wt.y+In*gn.y,V.z=ii*Wt.z+In*gn.z,V.normalize(),pe.push(V.x,V.y,V.z),C.x=J.x+h*V.x,C.y=J.y+h*V.y,C.z=J.z+h*V.z,he.push(C.x,C.y,C.z)}}function mt(){for(let Pt=1;Pt<=l;Pt++)for(let Wt=1;Wt<=f;Wt++){const gn=(f+1)*(Pt-1)+(Wt-1),Sn=(f+1)*Pt+(Wt-1),kn=(f+1)*Pt+Wt,In=(f+1)*(Pt-1)+Wt;Se.push(gn,Sn,In),Se.push(Sn,kn,In)}}function Nt(){for(let Pt=0;Pt<=l;Pt++)for(let Wt=0;Wt<=f;Wt++)H.x=Pt/l,H.y=Wt/f,me.push(H.x,H.y)}}copy(i){return super.copy(i),this.parameters=Object.assign({},i.parameters),this}toJSON(){const i=super.toJSON();return i.path=this.parameters.path.toJSON(),i}static fromJSON(i){return new Bp(new yu[i.path.type]().fromJSON(i.path),i.tubularSegments,i.radius,i.radialSegments,i.closed)}}class Cx extends Or{constructor(i=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:i},i!==null){const l=[],h=new Set,f=new Rt,g=new Rt;if(i.index!==null){const v=i.attributes.position,C=i.index;let V=i.groups;V.length===0&&(V=[{start:0,count:C.count,materialIndex:0}]);for(let H=0,J=V.length;H<J;++H){const he=V[H],pe=he.start,me=he.count;for(let Se=pe,tt=pe+me;Se<tt;Se+=3)for(let gt=0;gt<3;gt++){const mt=C.getX(Se+gt),Nt=C.getX(Se+(gt+1)%3);f.fromBufferAttribute(v,mt),g.fromBufferAttribute(v,Nt),ay(f,g,h)===!0&&(l.push(f.x,f.y,f.z),l.push(g.x,g.y,g.z))}}}else{const v=i.attributes.position;for(let C=0,V=v.count/3;C<V;C++)for(let H=0;H<3;H++){const J=3*C+H,he=3*C+(H+1)%3;f.fromBufferAttribute(v,J),g.fromBufferAttribute(v,he),ay(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(i){return super.copy(i),this.parameters=Object.assign({},i.parameters),this}}function ay(j,i,l){const h=`${j.x},${j.y},${j.z}-${i.x},${i.y},${i.z}`,f=`${i.x},${i.y},${i.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 ly=Object.freeze({__proto__:null,BoxGeometry:Gm,CapsuleGeometry:df,CircleGeometry:ff,ConeGeometry:ud,CylinderGeometry:pf,DodecahedronGeometry:yc,EdgesGeometry:j0,ExtrudeGeometry:Mh,IcosahedronGeometry:sy,LatheGeometry:ju,OctahedronGeometry:_f,PlaneGeometry:Op,PolyhedronGeometry:hd,RingGeometry:Fp,ShapeGeometry:bf,SphereGeometry:wf,TetrahedronGeometry:ug,TorusGeometry:hg,TorusKnotGeometry:oy,TubeGeometry:Bp,WireframeGeometry:Cx});class Rx extends null{constructor(i){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new ar(0),this.transparent=!0,this.fog=!0,this.setValues(i)}copy(i){return super.copy(i),this.color.copy(i.color),this.fog=i.fog,this}}class cy extends null{constructor(i){super(i),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Nx extends null{constructor(i){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=$a,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 cs,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(i)}copy(i){return super.copy(i),this.defines={STANDARD:""},this.color.copy(i.color),this.roughness=i.roughness,this.metalness=i.metalness,this.map=i.map,this.lightMap=i.lightMap,this.lightMapIntensity=i.lightMapIntensity,this.aoMap=i.aoMap,this.aoMapIntensity=i.aoMapIntensity,this.emissive.copy(i.emissive),this.emissiveMap=i.emissiveMap,this.emissiveIntensity=i.emissiveIntensity,this.bumpMap=i.bumpMap,this.bumpScale=i.bumpScale,this.normalMap=i.normalMap,this.normalMapType=i.normalMapType,this.normalScale.copy(i.normalScale),this.displacementMap=i.displacementMap,this.displacementScale=i.displacementScale,this.displacementBias=i.displacementBias,this.roughnessMap=i.roughnessMap,this.metalnessMap=i.metalnessMap,this.alphaMap=i.alphaMap,this.envMap=i.envMap,this.envMapRotation.copy(i.envMapRotation),this.envMapIntensity=i.envMapIntensity,this.wireframe=i.wireframe,this.wireframeLinewidth=i.wireframeLinewidth,this.wireframeLinecap=i.wireframeLinecap,this.wireframeLinejoin=i.wireframeLinejoin,this.flatShading=i.flatShading,this.fog=i.fog,this}}class Px extends null{constructor(i){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 Fr(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(i)}get anisotropy(){return this._anisotropy}set anisotropy(i){this._anisotropy>0!=i>0&&this.version++,this._anisotropy=i}get clearcoat(){return this._clearcoat}set clearcoat(i){this._clearcoat>0!=i>0&&this.version++,this._clearcoat=i}get iridescence(){return this._iridescence}set iridescence(i){this._iridescence>0!=i>0&&this.version++,this._iridescence=i}get dispersion(){return this._dispersion}set dispersion(i){this._dispersion>0!=i>0&&this.version++,this._dispersion=i}get sheen(){return this._sheen}set sheen(i){this._sheen>0!=i>0&&this.version++,this._sheen=i}get transmission(){return this._transmission}set transmission(i){this._transmission>0!=i>0&&this.version++,this._transmission=i}copy(i){return super.copy(i),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=i.anisotropy,this.anisotropyRotation=i.anisotropyRotation,this.anisotropyMap=i.anisotropyMap,this.clearcoat=i.clearcoat,this.clearcoatMap=i.clearcoatMap,this.clearcoatRoughness=i.clearcoatRoughness,this.clearcoatRoughnessMap=i.clearcoatRoughnessMap,this.clearcoatNormalMap=i.clearcoatNormalMap,this.clearcoatNormalScale.copy(i.clearcoatNormalScale),this.dispersion=i.dispersion,this.ior=i.ior,this.iridescence=i.iridescence,this.iridescenceMap=i.iridescenceMap,this.iridescenceIOR=i.iridescenceIOR,this.iridescenceThicknessRange=[...i.iridescenceThicknessRange],this.iridescenceThicknessMap=i.iridescenceThicknessMap,this.sheen=i.sheen,this.sheenColor.copy(i.sheenColor),this.sheenColorMap=i.sheenColorMap,this.sheenRoughness=i.sheenRoughness,this.sheenRoughnessMap=i.sheenRoughnessMap,this.transmission=i.transmission,this.transmissionMap=i.transmissionMap,this.thickness=i.thickness,this.thicknessMap=i.thicknessMap,this.attenuationDistance=i.attenuationDistance,this.attenuationColor.copy(i.attenuationColor),this.specularIntensity=i.specularIntensity,this.specularIntensityMap=i.specularIntensityMap,this.specularColor.copy(i.specularColor),this.specularColorMap=i.specularColorMap,this}}class uy extends Ro{constructor(i){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=$a,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 cs,this.combine=xt,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(i)}copy(i){return super.copy(i),this.color.copy(i.color),this.specular.copy(i.specular),this.shininess=i.shininess,this.map=i.map,this.lightMap=i.lightMap,this.lightMapIntensity=i.lightMapIntensity,this.aoMap=i.aoMap,this.aoMapIntensity=i.aoMapIntensity,this.emissive.copy(i.emissive),this.emissiveMap=i.emissiveMap,this.emissiveIntensity=i.emissiveIntensity,this.bumpMap=i.bumpMap,this.bumpScale=i.bumpScale,this.normalMap=i.normalMap,this.normalMapType=i.normalMapType,this.normalScale.copy(i.normalScale),this.displacementMap=i.displacementMap,this.displacementScale=i.displacementScale,this.displacementBias=i.displacementBias,this.specularMap=i.specularMap,this.alphaMap=i.alphaMap,this.envMap=i.envMap,this.envMapRotation.copy(i.envMapRotation),this.combine=i.combine,this.reflectivity=i.reflectivity,this.refractionRatio=i.refractionRatio,this.wireframe=i.wireframe,this.wireframeLinewidth=i.wireframeLinewidth,this.wireframeLinecap=i.wireframeLinecap,this.wireframeLinejoin=i.wireframeLinejoin,this.flatShading=i.flatShading,this.fog=i.fog,this}}class hy extends null{constructor(i){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=$a,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(i)}copy(i){return super.copy(i),this.color.copy(i.color),this.map=i.map,this.gradientMap=i.gradientMap,this.lightMap=i.lightMap,this.lightMapIntensity=i.lightMapIntensity,this.aoMap=i.aoMap,this.aoMapIntensity=i.aoMapIntensity,this.emissive.copy(i.emissive),this.emissiveMap=i.emissiveMap,this.emissiveIntensity=i.emissiveIntensity,this.bumpMap=i.bumpMap,this.bumpScale=i.bumpScale,this.normalMap=i.normalMap,this.normalMapType=i.normalMapType,this.normalScale.copy(i.normalScale),this.displacementMap=i.displacementMap,this.displacementScale=i.displacementScale,this.displacementBias=i.displacementBias,this.alphaMap=i.alphaMap,this.wireframe=i.wireframe,this.wireframeLinewidth=i.wireframeLinewidth,this.wireframeLinecap=i.wireframeLinecap,this.wireframeLinejoin=i.wireframeLinejoin,this.fog=i.fog,this}}class yd extends null{constructor(i){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=$a,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(i)}copy(i){return super.copy(i),this.bumpMap=i.bumpMap,this.bumpScale=i.bumpScale,this.normalMap=i.normalMap,this.normalMapType=i.normalMapType,this.normalScale.copy(i.normalScale),this.displacementMap=i.displacementMap,this.displacementScale=i.displacementScale,this.displacementBias=i.displacementBias,this.wireframe=i.wireframe,this.wireframeLinewidth=i.wireframeLinewidth,this.flatShading=i.flatShading,this}}class Ix extends null{constructor(i){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=$a,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 cs,this.combine=xt,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(i)}copy(i){return super.copy(i),this.color.copy(i.color),this.map=i.map,this.lightMap=i.lightMap,this.lightMapIntensity=i.lightMapIntensity,this.aoMap=i.aoMap,this.aoMapIntensity=i.aoMapIntensity,this.emissive.copy(i.emissive),this.emissiveMap=i.emissiveMap,this.emissiveIntensity=i.emissiveIntensity,this.bumpMap=i.bumpMap,this.bumpScale=i.bumpScale,this.normalMap=i.normalMap,this.normalMapType=i.normalMapType,this.normalScale.copy(i.normalScale),this.displacementMap=i.displacementMap,this.displacementScale=i.displacementScale,this.displacementBias=i.displacementBias,this.specularMap=i.specularMap,this.alphaMap=i.alphaMap,this.envMap=i.envMap,this.envMapRotation.copy(i.envMapRotation),this.combine=i.combine,this.reflectivity=i.reflectivity,this.refractionRatio=i.refractionRatio,this.wireframe=i.wireframe,this.wireframeLinewidth=i.wireframeLinewidth,this.wireframeLinecap=i.wireframeLinecap,this.wireframeLinejoin=i.wireframeLinejoin,this.flatShading=i.flatShading,this.fog=i.fog,this}}class Lx extends null{constructor(i){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Jf,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(i)}copy(i){return super.copy(i),this.depthPacking=i.depthPacking,this.map=i.map,this.alphaMap=i.alphaMap,this.displacementMap=i.displacementMap,this.displacementScale=i.displacementScale,this.displacementBias=i.displacementBias,this.wireframe=i.wireframe,this.wireframeLinewidth=i.wireframeLinewidth,this}}class dy extends null{constructor(i){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(i)}copy(i){return super.copy(i),this.map=i.map,this.alphaMap=i.alphaMap,this.displacementMap=i.displacementMap,this.displacementScale=i.displacementScale,this.displacementBias=i.displacementBias,this}}class fy extends null{constructor(i){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=$a,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(i)}copy(i){return super.copy(i),this.defines={MATCAP:""},this.color.copy(i.color),this.matcap=i.matcap,this.map=i.map,this.bumpMap=i.bumpMap,this.bumpScale=i.bumpScale,this.normalMap=i.normalMap,this.normalMapType=i.normalMapType,this.normalScale.copy(i.normalScale),this.displacementMap=i.displacementMap,this.displacementScale=i.displacementScale,this.displacementBias=i.displacementBias,this.alphaMap=i.alphaMap,this.wireframe=i.wireframe,this.wireframeLinewidth=i.wireframeLinewidth,this.flatShading=i.flatShading,this.fog=i.fog,this}}class F1 extends null{constructor(i){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(i)}copy(i){return super.copy(i),this.scale=i.scale,this.dashSize=i.dashSize,this.gapSize=i.gapSize,this}}function vd(j,i){return!j||j.constructor===i?j:typeof i.BYTES_PER_ELEMENT=="number"?new i(j):Array.prototype.slice.call(j)}function B1(j){return ArrayBuffer.isView(j)&&!(j instanceof DataView)}function Up(j){function i(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(i),h}function py(j,i,l){const h=j.length,f=new j.constructor(h);for(let g=0,v=0;v!==h;++g){const C=l[g]*i;for(let V=0;V!==i;++V)f[v++]=j[C+V]}return f}function dg(j,i,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&&(i.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&&(i.push(g.time),v.toArray(l,l.length)),g=j[f++];while(g!==void 0);else do v=g[h],v!==void 0&&(i.push(g.time),l.push(v)),g=j[f++];while(g!==void 0)}function U1(j,i,l,h,f=30){const g=j.clone();g.name=i;const v=[];for(let V=0;V<g.tracks.length;++V){const H=g.tracks[V],J=H.getValueSize(),he=[],pe=[];for(let me=0;me<H.times.length;++me){const Se=H.times[me]*f;if(!(Se<l||Se>=h)){he.push(H.times[me]);for(let tt=0;tt<J;++tt)pe.push(H.values[me*J+tt])}}he.length!==0&&(H.times=vd(he,H.times.constructor),H.values=vd(pe,H.values.constructor),v.push(H))}g.tracks=v;let C=1/0;for(let V=0;V<g.tracks.length;++V)C>g.tracks[V].times[0]&&(C=g.tracks[V].times[0]);for(let V=0;V<g.tracks.length;++V)g.tracks[V].shift(-1*C);return g.resetDuration(),g}function Wc(j,i=0,l=j,h=30){h<=0&&(h=30);const f=l.tracks.length,g=i/h;for(let v=0;v<f;++v){const C=l.tracks[v],V=C.ValueTypeName;if(V==="bool"||V==="string")continue;const H=j.tracks.find(function(mt){return mt.name===C.name&&mt.ValueTypeName===V});if(H===void 0)continue;let J=0;const he=C.getValueSize();C.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(J=he/3);let pe=0;const me=H.getValueSize();H.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(pe=me/3);const Se=C.times.length-1;let tt;if(g<=C.times[0]){const mt=J,Nt=he-J;tt=C.values.slice(mt,Nt)}else if(g>=C.times[Se]){const mt=Se*he+J,Nt=mt+he-J;tt=C.values.slice(mt,Nt)}else{const mt=C.createInterpolant(),Nt=J,Pt=he-J;mt.evaluate(g),tt=mt.resultBuffer.slice(Nt,Pt)}V==="quaternion"&&new vl().fromArray(tt).normalize().conjugate().toArray(tt);const gt=H.times.length;for(let mt=0;mt<gt;++mt){const Nt=mt*me+pe;if(V==="quaternion")vl.multiplyQuaternionsFlat(H.values,Nt,tt,0,H.values,Nt);else{const Pt=me-pe*2;for(let Wt=0;Wt<Pt;++Wt)H.values[Nt+Wt]-=tt[Wt]}}}return j.blendMode=Pc,j}class kp{static convertArray(i,l){return vd(i,l)}static isTypedArray(i){return B1(i)}static getKeyframeOrder(i){return Up(i)}static sortedArray(i,l,h){return py(i,l,h)}static flattenJSON(i,l,h,f){dg(i,l,h,f)}static subclip(i,l,h,f,g=30){return U1(i,l,h,f,g)}static makeClipAdditive(i,l=0,h=i,f=30){return Wc(i,l,h,f)}}class zp{constructor(i,l,h,f){this.parameterPositions=i,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(i){const l=this.parameterPositions;let h=this._cachedIndex,f=l[h],g=l[h-1];e:{t:{let v;n:{i:if(!(i<f)){for(let C=h+2;;){if(f===void 0){if(i<g)break i;return h=l.length,this._cachedIndex=h,this.copySampleValue_(h-1)}if(h===C)break;if(g=f,f=l[++h],i<f)break t}v=l.length;break n}if(!(i>=g)){const C=l[1];i<C&&(h=2,g=C);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],i>=g)break t}v=h,h=0;break n}break e}for(;h<v;){const C=h+v>>>1;i<l[C]?v=C:h=C+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,i,f)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(i){const l=this.resultBuffer,h=this.sampleValues,f=this.valueSize,g=i*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 fg extends zp{constructor(i,l,h,f){super(i,l,h,f),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ca,endingEnd:ca}}intervalChanged_(i,l,h){const f=this.parameterPositions;let g=i-2,v=i+1,C=f[g],V=f[v];if(C===void 0)switch(this.getSettings_().endingStart){case Oa:g=i,C=2*l-h;break;case sl:g=f.length-2,C=l+f[g]-f[g+1];break;default:g=i,C=h}if(V===void 0)switch(this.getSettings_().endingEnd){case Oa:v=i,V=2*h-l;break;case sl:v=1,V=h+f[1]-f[0];break;default:v=i-1,V=l}const H=(h-l)*.5,J=this.valueSize;this._weightPrev=H/(l-C),this._weightNext=H/(V-h),this._offsetPrev=g*J,this._offsetNext=v*J}interpolate_(i,l,h,f){const g=this.resultBuffer,v=this.sampleValues,C=this.valueSize,V=i*C,H=V-C,J=this._offsetPrev,he=this._offsetNext,pe=this._weightPrev,me=this._weightNext,Se=(h-l)/(f-l),tt=Se*Se,gt=tt*Se,mt=-pe*gt+2*pe*tt-pe*Se,Nt=(1+pe)*gt+(-1.5-2*pe)*tt+(-.5+pe)*Se+1,Pt=(-1-me)*gt+(1.5+me)*tt+.5*Se,Wt=me*gt-me*tt;for(let gn=0;gn!==C;++gn)g[gn]=mt*v[J+gn]+Nt*v[H+gn]+Pt*v[V+gn]+Wt*v[he+gn];return g}}class Dx extends zp{constructor(i,l,h,f){super(i,l,h,f)}interpolate_(i,l,h,f){const g=this.resultBuffer,v=this.sampleValues,C=this.valueSize,V=i*C,H=V-C,J=(h-l)/(f-l),he=1-J;for(let pe=0;pe!==C;++pe)g[pe]=v[H+pe]*he+v[V+pe]*J;return g}}class pg extends zp{constructor(i,l,h,f){super(i,l,h,f)}interpolate_(i){return this.copySampleValue_(i-1)}}class _l{constructor(i,l,h,f){if(i===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 "+i);this.name=i,this.times=vd(l,this.TimeBufferType),this.values=vd(h,this.ValueBufferType),this.setInterpolation(f||this.DefaultInterpolation)}static toJSON(i){const l=i.constructor;let h;if(l.toJSON!==this.toJSON)h=l.toJSON(i);else{h={name:i.name,times:vd(i.times,Array),values:vd(i.values,Array)};const f=i.getInterpolation();f!==i.DefaultInterpolation&&(h.interpolation=f)}return h.type=i.ValueTypeName,h}InterpolantFactoryMethodDiscrete(i){return new pg(this.times,this.values,this.getValueSize(),i)}InterpolantFactoryMethodLinear(i){return new Dx(this.times,this.values,this.getValueSize(),i)}InterpolantFactoryMethodSmooth(i){return new fg(this.times,this.values,this.getValueSize(),i)}setInterpolation(i){let l;switch(i){case Ao:l=this.InterpolantFactoryMethodDiscrete;break;case il:l=this.InterpolantFactoryMethodLinear;break;case rl: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(i!==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 Ao;case this.InterpolantFactoryMethodLinear:return il;case this.InterpolantFactoryMethodSmooth:return rl}}getValueSize(){return this.values.length/this.times.length}shift(i){if(i!==0){const l=this.times;for(let h=0,f=l.length;h!==f;++h)l[h]+=i}return this}scale(i){if(i!==1){const l=this.times;for(let h=0,f=l.length;h!==f;++h)l[h]*=i}return this}trim(i,l){const h=this.times,f=h.length;let g=0,v=f-1;for(;g!==f&&h[g]<i;)++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 C=this.getValueSize();this.times=h.slice(g,v),this.values=this.values.slice(g*C,v*C)}return this}validate(){let i=!0;const l=this.getValueSize();l-Math.floor(l)!==0&&(js("KeyframeTrack: Invalid value size in track.",this),i=!1);const h=this.times,f=this.values,g=h.length;g===0&&(js("KeyframeTrack: Track is empty.",this),i=!1);let v=null;for(let C=0;C!==g;C++){const V=h[C];if(typeof V=="number"&&isNaN(V)){js("KeyframeTrack: Time is not a valid number.",this,C,V),i=!1;break}if(v!==null&&v>V){js("KeyframeTrack: Out of order keys.",this,C,V,v),i=!1;break}v=V}if(f!==void 0&&B1(f))for(let C=0,V=f.length;C!==V;++C){const H=f[C];if(isNaN(H)){js("KeyframeTrack: Value is not a valid number.",this,C,H),i=!1;break}}return i}optimize(){const i=this.times.slice(),l=this.values.slice(),h=this.getValueSize(),f=this.getInterpolation()===rl,g=i.length-1;let v=1;for(let C=1;C<g;++C){let V=!1;const H=i[C],J=i[C+1];if(H!==J&&(C!==1||H!==i[0]))if(f)V=!0;else{const he=C*h,pe=he-h,me=he+h;for(let Se=0;Se!==h;++Se){const tt=l[he+Se];if(tt!==l[pe+Se]||tt!==l[me+Se]){V=!0;break}}}if(V){if(C!==v){i[v]=i[C];const he=C*h,pe=v*h;for(let me=0;me!==h;++me)l[pe+me]=l[he+me]}++v}}if(g>0){i[v]=i[g];for(let C=g*h,V=v*h,H=0;H!==h;++H)l[V+H]=l[C+H];++v}return v!==i.length?(this.times=i.slice(0,v),this.values=l.slice(0,v*h)):(this.times=i,this.values=l),this}clone(){const i=this.times.slice(),l=this.values.slice(),h=this.constructor,f=new h(this.name,i,l);return f.createInterpolant=this.createInterpolant,f}}_l.prototype.ValueTypeName="",_l.prototype.TimeBufferType=Float32Array,_l.prototype.ValueBufferType=Float32Array,_l.prototype.DefaultInterpolation=il;class Xu extends _l{constructor(i,l,h){super(i,l,h)}}Xu.prototype.ValueTypeName="bool",Xu.prototype.ValueBufferType=Array,Xu.prototype.DefaultInterpolation=Ao,Xu.prototype.InterpolantFactoryMethodLinear=void 0,Xu.prototype.InterpolantFactoryMethodSmooth=void 0;class Vp extends _l{constructor(i,l,h,f){super(i,l,h,f)}}Vp.prototype.ValueTypeName="color";class mg extends _l{constructor(i,l,h,f){super(i,l,h,f)}}mg.prototype.ValueTypeName="number";class k1 extends zp{constructor(i,l,h,f){super(i,l,h,f)}interpolate_(i,l,h,f){const g=this.resultBuffer,v=this.sampleValues,C=this.valueSize,V=(h-l)/(f-l);let H=i*C;for(let J=H+C;H!==J;H+=4)vl.slerpFlat(g,0,v,H-C,v,H,V);return g}}class _c extends _l{constructor(i,l,h,f){super(i,l,h,f)}InterpolantFactoryMethodLinear(i){return new k1(this.times,this.values,this.getValueSize(),i)}}_c.prototype.ValueTypeName="quaternion",_c.prototype.InterpolantFactoryMethodSmooth=void 0;class xd extends _l{constructor(i,l,h){super(i,l,h)}}xd.prototype.ValueTypeName="string",xd.prototype.ValueBufferType=Array,xd.prototype.DefaultInterpolation=Ao,xd.prototype.InterpolantFactoryMethodLinear=void 0,xd.prototype.InterpolantFactoryMethodSmooth=void 0;class gg extends _l{constructor(i,l,h,f){super(i,l,h,f)}}gg.prototype.ValueTypeName="vector";class Mf{constructor(i="",l=-1,h=[],f=bo){this.name=i,this.tracks=h,this.duration=l,this.blendMode=f,this.uuid=Sl(),this.userData={},this.duration<0&&this.resetDuration()}static parse(i){const l=[],h=i.tracks,f=1/(i.fps||1);for(let v=0,C=h.length;v!==C;++v)l.push(z1(h[v]).scale(f));const g=new this(i.name,i.duration,l,i.blendMode);return g.uuid=i.uuid,g.userData=JSON.parse(i.userData||"{}"),g}static toJSON(i){const l=[],h=i.tracks,f={name:i.name,duration:i.duration,tracks:l,uuid:i.uuid,blendMode:i.blendMode,userData:JSON.stringify(i.userData)};for(let g=0,v=h.length;g!==v;++g)l.push(_l.toJSON(h[g]));return f}static CreateFromMorphTargetSequence(i,l,h,f){const g=l.length,v=[];for(let C=0;C<g;C++){let V=[],H=[];V.push((C+g-1)%g,C,(C+1)%g),H.push(0,1,0);const J=Up(V);V=py(V,1,J),H=py(H,1,J),!f&&V[0]===0&&(V.push(g),H.push(H[0])),v.push(new mg(".morphTargetInfluences["+l[C].name+"]",V,H).scale(1/h))}return new this(i,-1,v)}static findByName(i,l){let h=i;if(!Array.isArray(i)){const f=i;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(i,l,h){const f={},g=/^([\w-]*?)([\d]+)$/;for(let C=0,V=i.length;C<V;C++){const H=i[C],J=H.name.match(g);if(J&&J.length>1){const he=J[1];let pe=f[he];pe||(f[he]=pe=[]),pe.push(H)}}const v=[];for(const C in f)v.push(this.CreateFromMorphTargetSequence(C,f[C],l,h));return v}static parseAnimation(i,l){if(_r("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!i)return js("AnimationClip: No animation in JSONLoader data."),null;const h=function(he,pe,me,Se,tt){if(me.length!==0){const gt=[],mt=[];dg(me,gt,mt,Se),gt.length!==0&&tt.push(new he(pe,gt,mt))}},f=[],g=i.name||"default",v=i.fps||30,C=i.blendMode;let V=i.length||-1;const H=i.hierarchy||[];for(let he=0;he<H.length;he++){const pe=H[he].keys;if(!(!pe||pe.length===0))if(pe[0].morphTargets){const me={};let Se;for(Se=0;Se<pe.length;Se++)if(pe[Se].morphTargets)for(let tt=0;tt<pe[Se].morphTargets.length;tt++)me[pe[Se].morphTargets[tt]]=-1;for(const tt in me){const gt=[],mt=[];for(let Nt=0;Nt!==pe[Se].morphTargets.length;++Nt){const Pt=pe[Se];gt.push(Pt.time),mt.push(Pt.morphTarget===tt?1:0)}f.push(new mg(".morphTargetInfluence["+tt+"]",gt,mt))}V=me.length*v}else{const me=".bones["+l[he].name+"]";h(gg,me+".position",pe,"pos",f),h(_c,me+".quaternion",pe,"rot",f),h(gg,me+".scale",pe,"scl",f)}}return f.length===0?null:new this(g,V,f,C)}resetDuration(){const i=this.tracks;let l=0;for(let h=0,f=i.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 i=0;i<this.tracks.length;i++)this.tracks[i].trim(0,this.duration);return this}validate(){let i=!0;for(let l=0;l<this.tracks.length;l++)i=i&&this.tracks[l].validate();return i}optimize(){for(let i=0;i<this.tracks.length;i++)this.tracks[i].optimize();return this}clone(){const i=[];for(let h=0;h<this.tracks.length;h++)i.push(this.tracks[h].clone());const l=new this.constructor(this.name,this.duration,i,this.blendMode);return l.userData=JSON.parse(JSON.stringify(this.userData)),l}toJSON(){return this.constructor.toJSON(this)}}function qu(j){switch(j.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return mg;case"vector":case"vector2":case"vector3":case"vector4":return gg;case"color":return Vp;case"quaternion":return _c;case"bool":case"boolean":return Xu;case"string":return xd}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+j)}function z1(j){if(j.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const i=qu(j.type);if(j.times===void 0){const l=[],h=[];dg(j.keys,l,h,"value"),j.times=l,j.values=h}return i.parse!==void 0?i.parse(j):new i(j.name,j.times,j.values,j.interpolation)}const bl={enabled:!1,files:{},add:function(j,i){this.enabled!==!1&&(this.files[j]=i)},get:function(j){if(this.enabled!==!1)return this.files[j]},remove:function(j){delete this.files[j]},clear:function(){this.files={}}};class V1{constructor(i,l,h){const f=this;let g=!1,v=0,C=0,V;const H=[];this.onStart=void 0,this.onLoad=i,this.onProgress=l,this.onError=h,this._abortController=null,this.itemStart=function(J){C++,g===!1&&f.onStart!==void 0&&f.onStart(J,v,C),g=!0},this.itemEnd=function(J){v++,f.onProgress!==void 0&&f.onProgress(J,v,C),v===C&&(g=!1,f.onLoad!==void 0&&f.onLoad())},this.itemError=function(J){f.onError!==void 0&&f.onError(J)},this.resolveURL=function(J){return V?V(J):J},this.setURLModifier=function(J){return V=J,this},this.addHandler=function(J,he){return H.push(J,he),this},this.removeHandler=function(J){const he=H.indexOf(J);return he!==-1&&H.splice(he,2),this},this.getHandler=function(J){for(let he=0,pe=H.length;he<pe;he+=2){const me=H[he],Se=H[he+1];if(me.global&&(me.lastIndex=0),me.test(J))return Se}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 cE=new V1;class Sf{constructor(i){this.manager=i!==void 0?i:cE,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(i,l){const h=this;return new Promise(function(f,g){h.load(i,f,l,g)})}parse(){}setCrossOrigin(i){return this.crossOrigin=i,this}setWithCredentials(i){return this.withCredentials=i,this}setPath(i){return this.path=i,this}setResourcePath(i){return this.resourcePath=i,this}setRequestHeader(i){return this.requestHeader=i,this}abort(){return this}}Sf.DEFAULT_MATERIAL_NAME="__DEFAULT";const bc={};class uE extends null{constructor(i,l){super(i),this.response=l}}class _d extends null{constructor(i){super(i),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(i,l,h,f){i===void 0&&(i=""),this.path!==void 0&&(i=this.path+i),i=this.manager.resolveURL(i);const g=bl.get(`file:${i}`);if(g!==void 0)return this.manager.itemStart(i),setTimeout(()=>{l&&l(g),this.manager.itemEnd(i)},0),g;if(bc[i]!==void 0){bc[i].push({onLoad:l,onProgress:h,onError:f});return}bc[i]=[],bc[i].push({onLoad:l,onProgress:h,onError:f});const v=new Request(i,{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,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 J=bc[i],he=H.body.getReader(),pe=H.headers.get("X-File-Size")||H.headers.get("Content-Length"),me=pe?parseInt(pe):0,Se=me!==0;let tt=0;const gt=new ReadableStream({start(mt){Nt();function Nt(){he.read().then(({done:Pt,value:Wt})=>{if(Pt)mt.close();else{tt+=Wt.byteLength;const gn=new ProgressEvent("progress",{lengthComputable:Se,loaded:tt,total:me});for(let Sn=0,kn=J.length;Sn<kn;Sn++){const In=J[Sn];In.onProgress&&In.onProgress(gn)}mt.enqueue(Wt),Nt()}},Pt=>{mt.error(Pt)})}}});return new Response(gt)}else throw new uE(`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(J=>new DOMParser().parseFromString(J,C));case"json":return H.json();default:if(C==="")return H.text();{const he=/charset="?([^;"\s]*)"?/i.exec(C),pe=he&&he[1]?he[1].toLowerCase():void 0,me=new TextDecoder(pe);return H.arrayBuffer().then(Se=>me.decode(Se))}}}).then(H=>{bl.add(`file:${i}`,H);const J=bc[i];delete bc[i];for(let he=0,pe=J.length;he<pe;he++){const me=J[he];me.onLoad&&me.onLoad(H)}}).catch(H=>{const J=bc[i];if(J===void 0)throw this.manager.itemError(i),H;delete bc[i];for(let he=0,pe=J.length;he<pe;he++){const me=J[he];me.onError&&me.onError(H)}this.manager.itemError(i)}).finally(()=>{this.manager.itemEnd(i)}),this.manager.itemStart(i)}setResponseType(i){return this.responseType=i,this}setMimeType(i){return this.mimeType=i,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class hE extends null{constructor(i){super(i)}load(i,l,h,f){const g=this,v=new _d(this.manager);v.setPath(this.path),v.setRequestHeader(this.requestHeader),v.setWithCredentials(this.withCredentials),v.load(i,function(C){try{l(g.parse(JSON.parse(C)))}catch(V){f?f(V):js(V),g.manager.itemError(i)}},h,f)}parse(i){const l=[];for(let h=0;h<i.length;h++){const f=Mf.parse(i[h]);l.push(f)}return l}}class Tf extends null{constructor(i){super(i)}load(i,l,h,f){const g=this,v=[],C=new $0,V=new _d(this.manager);V.setPath(this.path),V.setResponseType("arraybuffer"),V.setRequestHeader(this.requestHeader),V.setWithCredentials(g.withCredentials);let H=0;function J(he){V.load(i[he],function(pe){const me=g.parse(pe,!0);v[he]={width:me.width,height:me.height,format:me.format,mipmaps:me.mipmaps},H+=1,H===6&&(me.mipmapCount===1&&(C.minFilter=Rn),C.image=v,C.format=me.format,C.needsUpdate=!0,l&&l(C))},h,f)}if(Array.isArray(i))for(let he=0,pe=i.length;he<pe;++he)J(he);else V.load(i,function(he){const pe=g.parse(he,!0);if(pe.isCubemap){const me=pe.mipmaps.length/pe.mipmapCount;for(let Se=0;Se<me;Se++){v[Se]={mipmaps:[]};for(let tt=0;tt<pe.mipmapCount;tt++)v[Se].mipmaps.push(pe.mipmaps[Se*pe.mipmapCount+tt]),v[Se].format=pe.format,v[Se].width=pe.width,v[Se].height=pe.height}C.image=v}else C.image.width=pe.width,C.image.height=pe.height,C.mipmaps=pe.mipmaps;pe.mipmapCount===1&&(C.minFilter=Rn),C.format=pe.format,C.needsUpdate=!0,l&&l(C)},h,f);return C}}const bd=new WeakMap;class Ef extends null{constructor(i){super(i)}load(i,l,h,f){this.path!==void 0&&(i=this.path+i),i=this.manager.resolveURL(i);const g=this,v=bl.get(`image:${i}`);if(v!==void 0){if(v.complete===!0)g.manager.itemStart(i),setTimeout(function(){l&&l(v),g.manager.itemEnd(i)},0);else{let he=bd.get(v);he===void 0&&(he=[],bd.set(v,he)),he.push({onLoad:l,onError:f})}return v}const C=lc("img");function V(){J(),l&&l(this);const he=bd.get(this)||[];for(let pe=0;pe<he.length;pe++){const me=he[pe];me.onLoad&&me.onLoad(this)}bd.delete(this),g.manager.itemEnd(i)}function H(he){J(),f&&f(he),bl.remove(`image:${i}`);const pe=bd.get(this)||[];for(let me=0;me<pe.length;me++){const Se=pe[me];Se.onError&&Se.onError(he)}bd.delete(this),g.manager.itemError(i),g.manager.itemEnd(i)}function J(){C.removeEventListener("load",V,!1),C.removeEventListener("error",H,!1)}return C.addEventListener("load",V,!1),C.addEventListener("error",H,!1),i.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(C.crossOrigin=this.crossOrigin),bl.add(`image:${i}`,C),g.manager.itemStart(i),C.src=i,C}}class G1 extends null{constructor(i){super(i)}load(i,l,h,f){const g=new lp;g.colorSpace=co;const v=new Ef(this.manager);v.setCrossOrigin(this.crossOrigin),v.setPath(this.path);let C=0;function V(H){v.load(i[H],function(J){g.images[H]=J,C++,C===6&&(g.needsUpdate=!0,l&&l(g))},void 0,f)}for(let H=0;H<i.length;++H)V(H);return g}}class W1 extends null{constructor(i){super(i)}load(i,l,h,f){const g=this,v=new hu,C=new _d(this.manager);return C.setResponseType("arraybuffer"),C.setRequestHeader(this.requestHeader),C.setPath(this.path),C.setWithCredentials(g.withCredentials),C.load(i,function(V){let H;try{H=g.parse(V)}catch(J){if(f!==void 0)f(J);else{J(J);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:qe,v.wrapT=H.wrapT!==void 0?H.wrapT:qe,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 Ox extends null{constructor(i){super(i)}load(i,l,h,f){const g=new xl,v=new Ef(this.manager);return v.setCrossOrigin(this.crossOrigin),v.setPath(this.path),v.load(i,function(C){g.image=C,g.needsUpdate=!0,l!==void 0&&l(g)},h,f),g}}class dE extends null{constructor(i,l=1){super(),this.isLight=!0,this.type="Light",this.color=new ar(i),this.intensity=l}dispose(){}copy(i,l){return super.copy(i,l),this.color.copy(i.color),this.intensity=i.intensity,this}toJSON(i){const l=super.toJSON(i);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 yg extends null{constructor(i,l,h){super(i,h),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(xs.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ar(l)}copy(i,l){return super.copy(i,l),this.groundColor.copy(i.groundColor),this}}const vg=new On,Af=new Rt,xg=new Rt;class fE{constructor(i){this.camera=i,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 V0,this._frameExtents=new oi(1,1),this._viewportCount=1,this._viewports=[new Ba(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(i){const l=this.camera,h=this.matrix;Af.setFromMatrixPosition(i.matrixWorld),l.position.copy(Af),xg.setFromMatrixPosition(i.target.matrixWorld),l.lookAt(xg),l.updateMatrixWorld(),vg.multiplyMatrices(l.projectionMatrix,l.matrixWorldInverse),this._frustum.setFromProjectionMatrix(vg,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(vg)}getViewport(i){return this._viewports[i]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(i){return this.camera=i.camera.clone(),this.intensity=i.intensity,this.bias=i.bias,this.radius=i.radius,this.autoUpdate=i.autoUpdate,this.needsUpdate=i.needsUpdate,this.normalBias=i.normalBias,this.blurSamples=i.blurSamples,this.mapSize.copy(i.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const i={};return this.intensity!==1&&(i.intensity=this.intensity),this.bias!==0&&(i.bias=this.bias),this.normalBias!==0&&(i.normalBias=this.normalBias),this.radius!==1&&(i.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(i.mapSize=this.mapSize.toArray()),i.camera=this.camera.toJSON(!1).object,delete i.camera.matrix,i}}class Fx extends null{constructor(){super(new ul(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(i){const l=this.camera,h=Uu*2*i.angle*this.focus,f=this.mapSize.width/this.mapSize.height*this.aspect,g=i.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(i)}copy(i){return super.copy(i),this.focus=i.focus,this}}class Cf extends null{constructor(i,l,h=0,f=Math.PI/3,g=0,v=2){super(i,l),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(xs.DEFAULT_UP),this.updateMatrix(),this.target=new xs,this.distance=h,this.angle=f,this.penumbra=g,this.decay=v,this.map=null,this.shadow=new Fx}get power(){return this.intensity*Math.PI}set power(i){this.intensity=i/Math.PI}dispose(){this.shadow.dispose()}copy(i,l){return super.copy(i,l),this.distance=i.distance,this.angle=i.angle,this.penumbra=i.penumbra,this.decay=i.decay,this.target=i.target.clone(),this.shadow=i.shadow.clone(),this}}const Bx=new On,wd=new Rt,Gp=new Rt;class Ux extends null{constructor(){super(new ul(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new oi(4,2),this._viewportCount=6,this._viewports=[new Ba(2,1,1,1),new Ba(0,1,1,1),new Ba(3,1,1,1),new Ba(1,1,1,1),new Ba(3,0,1,1),new Ba(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(i,l=0){const h=this.camera,f=this.matrix,g=i.distance||h.far;g!==h.far&&(h.far=g,h.updateProjectionMatrix()),wd.setFromMatrixPosition(i.matrixWorld),h.position.copy(wd),Gp.copy(h.position),Gp.add(this._cubeDirections[l]),h.up.copy(this._cubeUps[l]),h.lookAt(Gp),h.updateMatrixWorld(),f.makeTranslation(-wd.x,-wd.y,-wd.z),Bx.multiplyMatrices(h.projectionMatrix,h.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Bx,h.coordinateSystem,h.reversedDepth)}}class H1 extends null{constructor(i,l,h=0,f=2){super(i,l),this.isPointLight=!0,this.type="PointLight",this.distance=h,this.decay=f,this.shadow=new Ux}get power(){return this.intensity*4*Math.PI}set power(i){this.intensity=i/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(i,l){return super.copy(i,l),this.distance=i.distance,this.decay=i.decay,this.shadow=i.shadow.clone(),this}}class my extends null{constructor(i=-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=i,this.right=l,this.top=h,this.bottom=f,this.near=g,this.far=v,this.updateProjectionMatrix()}copy(i,l){return super.copy(i,l),this.left=i.left,this.right=i.right,this.top=i.top,this.bottom=i.bottom,this.near=i.near,this.far=i.far,this.zoom=i.zoom,this.view=i.view===null?null:Object.assign({},i.view),this}setViewOffset(i,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=i,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 i=(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-i,v=h+i,C=f+l,V=f-l;if(this.view!==null&&this.view.enabled){const H=(this.right-this.left)/this.view.fullWidth/this.zoom,J=(this.top-this.bottom)/this.view.fullHeight/this.zoom;g+=H*this.view.offsetX,v=g+H*this.view.width,C-=J*this.view.offsetY,V=C-J*this.view.height}this.projectionMatrix.makeOrthographic(g,v,C,V,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(i){const l=super.toJSON(i);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 gy extends null{constructor(){super(new my(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class kx extends null{constructor(i,l){super(i,l),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(xs.DEFAULT_UP),this.updateMatrix(),this.target=new xs,this.shadow=new gy}dispose(){this.shadow.dispose()}copy(i){return super.copy(i),this.target=i.target.clone(),this.shadow=i.shadow.clone(),this}}class $1 extends null{constructor(i,l){super(i,l),this.isAmbientLight=!0,this.type="AmbientLight"}}class j1 extends null{constructor(i,l,h=10,f=10){super(i,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(i){this.intensity=i/(this.width*this.height*Math.PI)}copy(i){return super.copy(i),this.width=i.width,this.height=i.height,this}toJSON(i){const l=super.toJSON(i);return l.object.width=this.width,l.object.height=this.height,l}}class pE{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let i=0;i<9;i++)this.coefficients.push(new Rt)}set(i){for(let l=0;l<9;l++)this.coefficients[l].copy(i[l]);return this}zero(){for(let i=0;i<9;i++)this.coefficients[i].set(0,0,0);return this}getAt(i,l){const h=i.x,f=i.y,g=i.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(i,l){const h=i.x,f=i.y,g=i.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(i){for(let l=0;l<9;l++)this.coefficients[l].add(i.coefficients[l]);return this}addScaledSH(i,l){for(let h=0;h<9;h++)this.coefficients[h].addScaledVector(i.coefficients[h],l);return this}scale(i){for(let l=0;l<9;l++)this.coefficients[l].multiplyScalar(i);return this}lerp(i,l){for(let h=0;h<9;h++)this.coefficients[h].lerp(i.coefficients[h],l);return this}equals(i){for(let l=0;l<9;l++)if(!this.coefficients[l].equals(i.coefficients[l]))return!1;return!0}copy(i){return this.set(i.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(i,l=0){const h=this.coefficients;for(let f=0;f<9;f++)h[f].fromArray(i,l+f*3);return this}toArray(i=[],l=0){const h=this.coefficients;for(let f=0;f<9;f++)h[f].toArray(i,l+f*3);return i}static getBasisAt(i,l){const h=i.x,f=i.y,g=i.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 X1 extends null{constructor(i=new pE,l=1){super(void 0,l),this.isLightProbe=!0,this.sh=i}copy(i){return super.copy(i),this.sh.copy(i.sh),this}fromJSON(i){return this.intensity=i.intensity,this.sh.fromArray(i.sh),this}toJSON(i){const l=super.toJSON(i);return l.object.sh=this.sh.toArray(),l}}class _g extends null{constructor(i){super(i),this.textures={}}load(i,l,h,f){const g=this,v=new _d(g.manager);v.setPath(g.path),v.setRequestHeader(g.requestHeader),v.setWithCredentials(g.withCredentials),v.load(i,function(C){try{l(g.parse(JSON.parse(C)))}catch(V){f?f(V):js(V),g.manager.itemError(i)}},h,f)}parse(i){const l=this.textures;function h(g){return l[g]===void 0&&_r("MaterialLoader: Undefined texture",g),l[g]}const f=this.createMaterialFromType(i.type);if(i.uuid!==void 0&&(f.uuid=i.uuid),i.name!==void 0&&(f.name=i.name),i.color!==void 0&&f.color!==void 0&&f.color.setHex(i.color),i.roughness!==void 0&&(f.roughness=i.roughness),i.metalness!==void 0&&(f.metalness=i.metalness),i.sheen!==void 0&&(f.sheen=i.sheen),i.sheenColor!==void 0&&(f.sheenColor=new ar().setHex(i.sheenColor)),i.sheenRoughness!==void 0&&(f.sheenRoughness=i.sheenRoughness),i.emissive!==void 0&&f.emissive!==void 0&&f.emissive.setHex(i.emissive),i.specular!==void 0&&f.specular!==void 0&&f.specular.setHex(i.specular),i.specularIntensity!==void 0&&(f.specularIntensity=i.specularIntensity),i.specularColor!==void 0&&f.specularColor!==void 0&&f.specularColor.setHex(i.specularColor),i.shininess!==void 0&&(f.shininess=i.shininess),i.clearcoat!==void 0&&(f.clearcoat=i.clearcoat),i.clearcoatRoughness!==void 0&&(f.clearcoatRoughness=i.clearcoatRoughness),i.dispersion!==void 0&&(f.dispersion=i.dispersion),i.iridescence!==void 0&&(f.iridescence=i.iridescence),i.iridescenceIOR!==void 0&&(f.iridescenceIOR=i.iridescenceIOR),i.iridescenceThicknessRange!==void 0&&(f.iridescenceThicknessRange=i.iridescenceThicknessRange),i.transmission!==void 0&&(f.transmission=i.transmission),i.thickness!==void 0&&(f.thickness=i.thickness),i.attenuationDistance!==void 0&&(f.attenuationDistance=i.attenuationDistance),i.attenuationColor!==void 0&&f.attenuationColor!==void 0&&f.attenuationColor.setHex(i.attenuationColor),i.anisotropy!==void 0&&(f.anisotropy=i.anisotropy),i.anisotropyRotation!==void 0&&(f.anisotropyRotation=i.anisotropyRotation),i.fog!==void 0&&(f.fog=i.fog),i.flatShading!==void 0&&(f.flatShading=i.flatShading),i.blending!==void 0&&(f.blending=i.blending),i.combine!==void 0&&(f.combine=i.combine),i.side!==void 0&&(f.side=i.side),i.shadowSide!==void 0&&(f.shadowSide=i.shadowSide),i.opacity!==void 0&&(f.opacity=i.opacity),i.transparent!==void 0&&(f.transparent=i.transparent),i.alphaTest!==void 0&&(f.alphaTest=i.alphaTest),i.alphaHash!==void 0&&(f.alphaHash=i.alphaHash),i.depthFunc!==void 0&&(f.depthFunc=i.depthFunc),i.depthTest!==void 0&&(f.depthTest=i.depthTest),i.depthWrite!==void 0&&(f.depthWrite=i.depthWrite),i.colorWrite!==void 0&&(f.colorWrite=i.colorWrite),i.blendSrc!==void 0&&(f.blendSrc=i.blendSrc),i.blendDst!==void 0&&(f.blendDst=i.blendDst),i.blendEquation!==void 0&&(f.blendEquation=i.blendEquation),i.blendSrcAlpha!==void 0&&(f.blendSrcAlpha=i.blendSrcAlpha),i.blendDstAlpha!==void 0&&(f.blendDstAlpha=i.blendDstAlpha),i.blendEquationAlpha!==void 0&&(f.blendEquationAlpha=i.blendEquationAlpha),i.blendColor!==void 0&&f.blendColor!==void 0&&f.blendColor.setHex(i.blendColor),i.blendAlpha!==void 0&&(f.blendAlpha=i.blendAlpha),i.stencilWriteMask!==void 0&&(f.stencilWriteMask=i.stencilWriteMask),i.stencilFunc!==void 0&&(f.stencilFunc=i.stencilFunc),i.stencilRef!==void 0&&(f.stencilRef=i.stencilRef),i.stencilFuncMask!==void 0&&(f.stencilFuncMask=i.stencilFuncMask),i.stencilFail!==void 0&&(f.stencilFail=i.stencilFail),i.stencilZFail!==void 0&&(f.stencilZFail=i.stencilZFail),i.stencilZPass!==void 0&&(f.stencilZPass=i.stencilZPass),i.stencilWrite!==void 0&&(f.stencilWrite=i.stencilWrite),i.wireframe!==void 0&&(f.wireframe=i.wireframe),i.wireframeLinewidth!==void 0&&(f.wireframeLinewidth=i.wireframeLinewidth),i.wireframeLinecap!==void 0&&(f.wireframeLinecap=i.wireframeLinecap),i.wireframeLinejoin!==void 0&&(f.wireframeLinejoin=i.wireframeLinejoin),i.rotation!==void 0&&(f.rotation=i.rotation),i.linewidth!==void 0&&(f.linewidth=i.linewidth),i.dashSize!==void 0&&(f.dashSize=i.dashSize),i.gapSize!==void 0&&(f.gapSize=i.gapSize),i.scale!==void 0&&(f.scale=i.scale),i.polygonOffset!==void 0&&(f.polygonOffset=i.polygonOffset),i.polygonOffsetFactor!==void 0&&(f.polygonOffsetFactor=i.polygonOffsetFactor),i.polygonOffsetUnits!==void 0&&(f.polygonOffsetUnits=i.polygonOffsetUnits),i.dithering!==void 0&&(f.dithering=i.dithering),i.alphaToCoverage!==void 0&&(f.alphaToCoverage=i.alphaToCoverage),i.premultipliedAlpha!==void 0&&(f.premultipliedAlpha=i.premultipliedAlpha),i.forceSinglePass!==void 0&&(f.forceSinglePass=i.forceSinglePass),i.visible!==void 0&&(f.visible=i.visible),i.toneMapped!==void 0&&(f.toneMapped=i.toneMapped),i.userData!==void 0&&(f.userData=i.userData),i.vertexColors!==void 0&&(typeof i.vertexColors=="number"?f.vertexColors=i.vertexColors>0:f.vertexColors=i.vertexColors),i.uniforms!==void 0)for(const g in i.uniforms){const v=i.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 Ba().fromArray(v.value);break;case"m3":f.uniforms[g].value=new ua().fromArray(v.value);break;case"m4":f.uniforms[g].value=new On().fromArray(v.value);break;default:f.uniforms[g].value=v.value}}if(i.defines!==void 0&&(f.defines=i.defines),i.vertexShader!==void 0&&(f.vertexShader=i.vertexShader),i.fragmentShader!==void 0&&(f.fragmentShader=i.fragmentShader),i.glslVersion!==void 0&&(f.glslVersion=i.glslVersion),i.extensions!==void 0)for(const g in i.extensions)f.extensions[g]=i.extensions[g];if(i.lights!==void 0&&(f.lights=i.lights),i.clipping!==void 0&&(f.clipping=i.clipping),i.size!==void 0&&(f.size=i.size),i.sizeAttenuation!==void 0&&(f.sizeAttenuation=i.sizeAttenuation),i.map!==void 0&&(f.map=h(i.map)),i.matcap!==void 0&&(f.matcap=h(i.matcap)),i.alphaMap!==void 0&&(f.alphaMap=h(i.alphaMap)),i.bumpMap!==void 0&&(f.bumpMap=h(i.bumpMap)),i.bumpScale!==void 0&&(f.bumpScale=i.bumpScale),i.normalMap!==void 0&&(f.normalMap=h(i.normalMap)),i.normalMapType!==void 0&&(f.normalMapType=i.normalMapType),i.normalScale!==void 0){let g=i.normalScale;Array.isArray(g)===!1&&(g=[g,g]),f.normalScale=new oi().fromArray(g)}return i.displacementMap!==void 0&&(f.displacementMap=h(i.displacementMap)),i.displacementScale!==void 0&&(f.displacementScale=i.displacementScale),i.displacementBias!==void 0&&(f.displacementBias=i.displacementBias),i.roughnessMap!==void 0&&(f.roughnessMap=h(i.roughnessMap)),i.metalnessMap!==void 0&&(f.metalnessMap=h(i.metalnessMap)),i.emissiveMap!==void 0&&(f.emissiveMap=h(i.emissiveMap)),i.emissiveIntensity!==void 0&&(f.emissiveIntensity=i.emissiveIntensity),i.specularMap!==void 0&&(f.specularMap=h(i.specularMap)),i.specularIntensityMap!==void 0&&(f.specularIntensityMap=h(i.specularIntensityMap)),i.specularColorMap!==void 0&&(f.specularColorMap=h(i.specularColorMap)),i.envMap!==void 0&&(f.envMap=h(i.envMap)),i.envMapRotation!==void 0&&f.envMapRotation.fromArray(i.envMapRotation),i.envMapIntensity!==void 0&&(f.envMapIntensity=i.envMapIntensity),i.reflectivity!==void 0&&(f.reflectivity=i.reflectivity),i.refractionRatio!==void 0&&(f.refractionRatio=i.refractionRatio),i.lightMap!==void 0&&(f.lightMap=h(i.lightMap)),i.lightMapIntensity!==void 0&&(f.lightMapIntensity=i.lightMapIntensity),i.aoMap!==void 0&&(f.aoMap=h(i.aoMap)),i.aoMapIntensity!==void 0&&(f.aoMapIntensity=i.aoMapIntensity),i.gradientMap!==void 0&&(f.gradientMap=h(i.gradientMap)),i.clearcoatMap!==void 0&&(f.clearcoatMap=h(i.clearcoatMap)),i.clearcoatRoughnessMap!==void 0&&(f.clearcoatRoughnessMap=h(i.clearcoatRoughnessMap)),i.clearcoatNormalMap!==void 0&&(f.clearcoatNormalMap=h(i.clearcoatNormalMap)),i.clearcoatNormalScale!==void 0&&(f.clearcoatNormalScale=new oi().fromArray(i.clearcoatNormalScale)),i.iridescenceMap!==void 0&&(f.iridescenceMap=h(i.iridescenceMap)),i.iridescenceThicknessMap!==void 0&&(f.iridescenceThicknessMap=h(i.iridescenceThicknessMap)),i.transmissionMap!==void 0&&(f.transmissionMap=h(i.transmissionMap)),i.thicknessMap!==void 0&&(f.thicknessMap=h(i.thicknessMap)),i.anisotropyMap!==void 0&&(f.anisotropyMap=h(i.anisotropyMap)),i.sheenColorMap!==void 0&&(f.sheenColorMap=h(i.sheenColorMap)),i.sheenRoughnessMap!==void 0&&(f.sheenRoughnessMap=h(i.sheenRoughnessMap)),f}setTextures(i){return this.textures=i,this}createMaterialFromType(i){return _g.createMaterialFromType(i)}static createMaterialFromType(i){const l={ShadowMaterial:Rx,SpriteMaterial:nd,RawShaderMaterial:cy,ShaderMaterial:ed,PointsMaterial:H0,MeshPhysicalMaterial:Px,MeshStandardMaterial:Nx,MeshPhongMaterial:uy,MeshToonMaterial:hy,MeshNormalMaterial:yd,MeshLambertMaterial:Ix,MeshDepthMaterial:Lx,MeshDistanceMaterial:dy,MeshBasicMaterial:Ms,MeshMatcapMaterial:fy,LineDashedMaterial:F1,LineBasicMaterial:Rl,Material:Ro};return new l[i]}}class yy{static extractUrlBase(i){const l=i.lastIndexOf("/");return l===-1?"./":i.slice(0,l+1)}static resolveURL(i,l){return typeof i!="string"||i===""?"":(/^https?:\/\//i.test(l)&&/^\//.test(i)&&(l=l.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(i)||/^data:.*,.*$/i.test(i)||/^blob:.*$/i.test(i)?i:l+i)}}class vy extends null{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(i){return super.copy(i),this.instanceCount=i.instanceCount,this}toJSON(){const i=super.toJSON();return i.instanceCount=this.instanceCount,i.isInstancedBufferGeometry=!0,i}}class mE extends null{constructor(i){super(i)}load(i,l,h,f){const g=this,v=new _d(g.manager);v.setPath(g.path),v.setRequestHeader(g.requestHeader),v.setWithCredentials(g.withCredentials),v.load(i,function(C){try{l(g.parse(JSON.parse(C)))}catch(V){f?f(V):js(V),g.manager.itemError(i)}},h,f)}parse(i){const l={},h={};function f(me,Se){if(l[Se]!==void 0)return l[Se];const gt=me.interleavedBuffers[Se],mt=g(me,gt.buffer),Nt=Fu(gt.type,mt),Pt=new td(Nt,gt.stride);return Pt.uuid=gt.uuid,l[Se]=Pt,Pt}function g(me,Se){if(h[Se]!==void 0)return h[Se];const gt=me.arrayBuffers[Se],mt=new Uint32Array(gt).buffer;return h[Se]=mt,mt}const v=i.isInstancedBufferGeometry?new vy:new Or,C=i.data.index;if(C!==void 0){const me=Fu(C.type,C.array);v.setIndex(new yo(me,1))}const V=i.data.attributes;for(const me in V){const Se=V[me];let tt;if(Se.isInterleavedBufferAttribute){const gt=f(i.data,Se.data);tt=new Uc(gt,Se.itemSize,Se.offset,Se.normalized)}else{const gt=Fu(Se.type,Se.array),mt=Se.isInstancedBufferAttribute?$u:yo;tt=new mt(gt,Se.itemSize,Se.normalized)}Se.name!==void 0&&(tt.name=Se.name),Se.usage!==void 0&&tt.setUsage(Se.usage),v.setAttribute(me,tt)}const H=i.data.morphAttributes;if(H)for(const me in H){const Se=H[me],tt=[];for(let gt=0,mt=Se.length;gt<mt;gt++){const Nt=Se[gt];let Pt;if(Nt.isInterleavedBufferAttribute){const Wt=f(i.data,Nt.data);Pt=new Uc(Wt,Nt.itemSize,Nt.offset,Nt.normalized)}else{const Wt=Fu(Nt.type,Nt.array);Pt=new yo(Wt,Nt.itemSize,Nt.normalized)}Nt.name!==void 0&&(Pt.name=Nt.name),tt.push(Pt)}v.morphAttributes[me]=tt}i.data.morphTargetsRelative&&(v.morphTargetsRelative=!0);const he=i.data.groups||i.data.drawcalls||i.data.offsets;if(he!==void 0)for(let me=0,Se=he.length;me!==Se;++me){const tt=he[me];v.addGroup(tt.start,tt.count,tt.materialIndex)}const pe=i.data.boundingSphere;return pe!==void 0&&(v.boundingSphere=new Gt().fromJSON(pe)),i.name&&(v.name=i.name),i.userData&&(v.userData=i.userData),v}}class xy extends null{constructor(i){super(i)}load(i,l,h,f){const g=this,v=this.path===""?yy.extractUrlBase(i):this.path;this.resourcePath=this.resourcePath||v;const C=new _d(this.manager);C.setPath(this.path),C.setRequestHeader(this.requestHeader),C.setWithCredentials(this.withCredentials),C.load(i,function(V){let H=null;try{H=JSON.parse(V)}catch(he){f!==void 0&&f(he),he("ObjectLoader: Can't parse "+i+".",he.message);return}const J=H.metadata;if(J===void 0||J.type===void 0||J.type.toLowerCase()==="geometry"){f!==void 0&&f(new Error("THREE.ObjectLoader: Can't load "+i)),js("ObjectLoader: Can't load "+i);return}g.parse(H,l)},h,f)}loadAsync(i,l){return hr(this,null,function*(){const h=this,f=this.path===""?yy.extractUrlBase(i):this.path;this.resourcePath=this.resourcePath||f;const g=new _d(this.manager);g.setPath(this.path),g.setRequestHeader(this.requestHeader),g.setWithCredentials(this.withCredentials);const v=yield g.loadAsync(i,l),C=JSON.parse(v),V=C.metadata;if(V===void 0||V.type===void 0||V.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+i);return yield h.parseAsync(C)})}parse(i,l){const h=this.parseAnimations(i.animations),f=this.parseShapes(i.shapes),g=this.parseGeometries(i.geometries,f),v=this.parseImages(i.images,function(){l!==void 0&&l(H)}),C=this.parseTextures(i.textures,v),V=this.parseMaterials(i.materials,C),H=this.parseObject(i.object,g,V,C,h),J=this.parseSkeletons(i.skeletons,H);if(this.bindSkeletons(H,J),this.bindLightTargets(H),l!==void 0){let he=!1;for(const pe in v)if(v[pe].data instanceof HTMLImageElement){he=!0;break}he===!1&&l(H)}return H}parseAsync(i){return hr(this,null,function*(){const l=this.parseAnimations(i.animations),h=this.parseShapes(i.shapes),f=this.parseGeometries(i.geometries,h),g=yield this.parseImagesAsync(i.images),v=this.parseTextures(i.textures,g),C=this.parseMaterials(i.materials,v),V=this.parseObject(i.object,f,C,v,l),H=this.parseSkeletons(i.skeletons,V);return this.bindSkeletons(V,H),this.bindLightTargets(V),V})}parseShapes(i){const l={};if(i!==void 0)for(let h=0,f=i.length;h<f;h++){const g=new yf().fromJSON(i[h]);l[g.uuid]=g}return l}parseSkeletons(i,l){const h={},f={};if(l.traverse(function(g){g.isBone&&(f[g.uuid]=g)}),i!==void 0)for(let g=0,v=i.length;g<v;g++){const C=new k0().fromJSON(i[g],f);h[C.uuid]=C}return h}parseGeometries(i,l){const h={};if(i!==void 0){const f=new mE;for(let g=0,v=i.length;g<v;g++){let C;const V=i[g];switch(V.type){case"BufferGeometry":case"InstancedBufferGeometry":C=f.parse(V);break;default:V.type in ly?C=ly[V.type].fromJSON(V,l):_r(`ObjectLoader: Unsupported geometry type "${V.type}"`)}C.uuid=V.uuid,V.name!==void 0&&(C.name=V.name),V.userData!==void 0&&(C.userData=V.userData),h[V.uuid]=C}}return h}parseMaterials(i,l){const h={},f={};if(i!==void 0){const g=new _g;g.setTextures(l);for(let v=0,C=i.length;v<C;v++){const V=i[v];h[V.uuid]===void 0&&(h[V.uuid]=g.parse(V)),f[V.uuid]=h[V.uuid]}}return f}parseAnimations(i){const l={};if(i!==void 0)for(let h=0;h<i.length;h++){const f=i[h],g=Mf.parse(f);l[g.uuid]=g}return l}parseImages(i,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 C(V){if(typeof V=="string"){const H=V,J=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(H)?H:h.resourcePath+H;return v(J)}else return V.data?{data:Fu(V.type,V.data),width:V.width,height:V.height}:null}if(i!==void 0&&i.length>0){const V=new V1(l);g=new Ef(V),g.setCrossOrigin(this.crossOrigin);for(let H=0,J=i.length;H<J;H++){const he=i[H],pe=he.url;if(Array.isArray(pe)){const me=[];for(let Se=0,tt=pe.length;Se<tt;Se++){const gt=pe[Se],mt=C(gt);mt!==null&&(mt instanceof HTMLImageElement?me.push(mt):me.push(new hu(mt.data,mt.width,mt.height)))}f[he.uuid]=new Za(me)}else{const me=C(he.url);f[he.uuid]=new Za(me)}}}return f}parseImagesAsync(i){return hr(this,null,function*(){const l=this,h={};let f;function g(v){return hr(this,null,function*(){if(typeof v=="string"){const C=v,V=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(C)?C:l.resourcePath+C;return yield f.loadAsync(V)}else return v.data?{data:Fu(v.type,v.data),width:v.width,height:v.height}:null})}if(i!==void 0&&i.length>0){f=new Ef(this.manager),f.setCrossOrigin(this.crossOrigin);for(let v=0,C=i.length;v<C;v++){const V=i[v],H=V.url;if(Array.isArray(H)){const J=[];for(let he=0,pe=H.length;he<pe;he++){const me=H[he],Se=yield g(me);Se!==null&&(Se instanceof HTMLImageElement?J.push(Se):J.push(new hu(Se.data,Se.width,Se.height)))}h[V.uuid]=new Za(J)}else{const J=yield g(V.url);h[V.uuid]=new Za(J)}}}return h})}parseTextures(i,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(i!==void 0)for(let g=0,v=i.length;g<v;g++){const C=i[g];C.image===void 0&&_r('ObjectLoader: No "image" specified for',C.uuid),l[C.image]===void 0&&_r("ObjectLoader: Undefined image",C.image);const V=l[C.image],H=V.data;let J;Array.isArray(H)?(J=new lp,H.length===6&&(J.needsUpdate=!0)):(H&&H.data?J=new hu:J=new xl,H&&(J.needsUpdate=!0)),J.source=V,J.uuid=C.uuid,C.name!==void 0&&(J.name=C.name),C.mapping!==void 0&&(J.mapping=h(C.mapping,zx)),C.channel!==void 0&&(J.channel=C.channel),C.offset!==void 0&&J.offset.fromArray(C.offset),C.repeat!==void 0&&J.repeat.fromArray(C.repeat),C.center!==void 0&&J.center.fromArray(C.center),C.rotation!==void 0&&(J.rotation=C.rotation),C.wrap!==void 0&&(J.wrapS=h(C.wrap[0],q1),J.wrapT=h(C.wrap[1],q1)),C.format!==void 0&&(J.format=C.format),C.internalFormat!==void 0&&(J.internalFormat=C.internalFormat),C.type!==void 0&&(J.type=C.type),C.colorSpace!==void 0&&(J.colorSpace=C.colorSpace),C.minFilter!==void 0&&(J.minFilter=h(C.minFilter,_y)),C.magFilter!==void 0&&(J.magFilter=h(C.magFilter,_y)),C.anisotropy!==void 0&&(J.anisotropy=C.anisotropy),C.flipY!==void 0&&(J.flipY=C.flipY),C.generateMipmaps!==void 0&&(J.generateMipmaps=C.generateMipmaps),C.premultiplyAlpha!==void 0&&(J.premultiplyAlpha=C.premultiplyAlpha),C.unpackAlignment!==void 0&&(J.unpackAlignment=C.unpackAlignment),C.compareFunction!==void 0&&(J.compareFunction=C.compareFunction),C.userData!==void 0&&(J.userData=C.userData),f[C.uuid]=J}return f}parseObject(i,l,h,f,g){let v;function C(pe){return l[pe]===void 0&&_r("ObjectLoader: Undefined geometry",pe),l[pe]}function V(pe){if(pe!==void 0){if(Array.isArray(pe)){const me=[];for(let Se=0,tt=pe.length;Se<tt;Se++){const gt=pe[Se];h[gt]===void 0&&_r("ObjectLoader: Undefined material",gt),me.push(h[gt])}return me}return h[pe]===void 0&&_r("ObjectLoader: Undefined material",pe),h[pe]}}function H(pe){return f[pe]===void 0&&_r("ObjectLoader: Undefined texture",pe),f[pe]}let J,he;switch(i.type){case"Scene":v=new up,i.background!==void 0&&(Number.isInteger(i.background)?v.background=new ar(i.background):v.background=H(i.background)),i.environment!==void 0&&(v.environment=H(i.environment)),i.fog!==void 0&&(i.fog.type==="Fog"?v.fog=new mh(i.fog.color,i.fog.near,i.fog.far):i.fog.type==="FogExp2"&&(v.fog=new cp(i.fog.color,i.fog.density)),i.fog.name!==""&&(v.fog.name=i.fog.name)),i.backgroundBlurriness!==void 0&&(v.backgroundBlurriness=i.backgroundBlurriness),i.backgroundIntensity!==void 0&&(v.backgroundIntensity=i.backgroundIntensity),i.backgroundRotation!==void 0&&v.backgroundRotation.fromArray(i.backgroundRotation),i.environmentIntensity!==void 0&&(v.environmentIntensity=i.environmentIntensity),i.environmentRotation!==void 0&&v.environmentRotation.fromArray(i.environmentRotation);break;case"PerspectiveCamera":v=new ul(i.fov,i.aspect,i.near,i.far),i.focus!==void 0&&(v.focus=i.focus),i.zoom!==void 0&&(v.zoom=i.zoom),i.filmGauge!==void 0&&(v.filmGauge=i.filmGauge),i.filmOffset!==void 0&&(v.filmOffset=i.filmOffset),i.view!==void 0&&(v.view=Object.assign({},i.view));break;case"OrthographicCamera":v=new my(i.left,i.right,i.top,i.bottom,i.near,i.far),i.zoom!==void 0&&(v.zoom=i.zoom),i.view!==void 0&&(v.view=Object.assign({},i.view));break;case"AmbientLight":v=new $1(i.color,i.intensity);break;case"DirectionalLight":v=new kx(i.color,i.intensity),v.target=i.target||"";break;case"PointLight":v=new H1(i.color,i.intensity,i.distance,i.decay);break;case"RectAreaLight":v=new j1(i.color,i.intensity,i.width,i.height);break;case"SpotLight":v=new Cf(i.color,i.intensity,i.distance,i.angle,i.penumbra,i.decay),v.target=i.target||"";break;case"HemisphereLight":v=new yg(i.color,i.groundColor,i.intensity);break;case"LightProbe":v=new X1().fromJSON(i);break;case"SkinnedMesh":J=C(i.geometry),he=V(i.material),v=new kc(J,he),i.bindMode!==void 0&&(v.bindMode=i.bindMode),i.bindMatrix!==void 0&&v.bindMatrix.fromArray(i.bindMatrix),i.skeleton!==void 0&&(v.skeleton=i.skeleton);break;case"Mesh":J=C(i.geometry),he=V(i.material),v=new fh(J,he);break;case"InstancedMesh":J=C(i.geometry),he=V(i.material);const pe=i.count,me=i.instanceMatrix,Se=i.instanceColor;v=new h1(J,he,pe),v.instanceMatrix=new $u(new Float32Array(me.array),16),Se!==void 0&&(v.instanceColor=new $u(new Float32Array(Se.array),Se.itemSize));break;case"BatchedMesh":J=C(i.geometry),he=V(i.material),v=new tg(i.maxInstanceCount,i.maxVertexCount,i.maxIndexCount,he),v.geometry=J,v.perObjectFrustumCulled=i.perObjectFrustumCulled,v.sortObjects=i.sortObjects,v._drawRanges=i.drawRanges,v._reservedRanges=i.reservedRanges,v._geometryInfo=i.geometryInfo.map(tt=>{let gt=null,mt=null;return tt.boundingBox!==void 0&&(gt=new ta().fromJSON(tt.boundingBox)),tt.boundingSphere!==void 0&&(mt=new Gt().fromJSON(tt.boundingSphere)),ac(qs({},tt),{boundingBox:gt,boundingSphere:mt})}),v._instanceInfo=i.instanceInfo,v._availableInstanceIds=i._availableInstanceIds,v._availableGeometryIds=i._availableGeometryIds,v._nextIndexStart=i.nextIndexStart,v._nextVertexStart=i.nextVertexStart,v._geometryCount=i.geometryCount,v._maxInstanceCount=i.maxInstanceCount,v._maxVertexCount=i.maxVertexCount,v._maxIndexCount=i.maxIndexCount,v._geometryInitialized=i.geometryInitialized,v._matricesTexture=H(i.matricesTexture.uuid),v._indirectTexture=H(i.indirectTexture.uuid),i.colorsTexture!==void 0&&(v._colorsTexture=H(i.colorsTexture.uuid)),i.boundingSphere!==void 0&&(v.boundingSphere=new Gt().fromJSON(i.boundingSphere)),i.boundingBox!==void 0&&(v.boundingBox=new ta().fromJSON(i.boundingBox));break;case"LOD":v=new qm;break;case"Line":v=new uf(C(i.geometry),V(i.material));break;case"LineLoop":v=new p1(C(i.geometry),V(i.material));break;case"LineSegments":v=new _p(C(i.geometry),V(i.material));break;case"PointCloud":case"Points":v=new lE(C(i.geometry),V(i.material));break;case"Sprite":v=new O0(V(i.material));break;case"Group":v=new Wu;break;case"Bone":v=new ad;break;default:v=new xs}if(v.uuid=i.uuid,i.name!==void 0&&(v.name=i.name),i.matrix!==void 0?(v.matrix.fromArray(i.matrix),i.matrixAutoUpdate!==void 0&&(v.matrixAutoUpdate=i.matrixAutoUpdate),v.matrixAutoUpdate&&v.matrix.decompose(v.position,v.quaternion,v.scale)):(i.position!==void 0&&v.position.fromArray(i.position),i.rotation!==void 0&&v.rotation.fromArray(i.rotation),i.quaternion!==void 0&&v.quaternion.fromArray(i.quaternion),i.scale!==void 0&&v.scale.fromArray(i.scale)),i.up!==void 0&&v.up.fromArray(i.up),i.castShadow!==void 0&&(v.castShadow=i.castShadow),i.receiveShadow!==void 0&&(v.receiveShadow=i.receiveShadow),i.shadow&&(i.shadow.intensity!==void 0&&(v.shadow.intensity=i.shadow.intensity),i.shadow.bias!==void 0&&(v.shadow.bias=i.shadow.bias),i.shadow.normalBias!==void 0&&(v.shadow.normalBias=i.shadow.normalBias),i.shadow.radius!==void 0&&(v.shadow.radius=i.shadow.radius),i.shadow.mapSize!==void 0&&v.shadow.mapSize.fromArray(i.shadow.mapSize),i.shadow.camera!==void 0&&(v.shadow.camera=this.parseObject(i.shadow.camera))),i.visible!==void 0&&(v.visible=i.visible),i.frustumCulled!==void 0&&(v.frustumCulled=i.frustumCulled),i.renderOrder!==void 0&&(v.renderOrder=i.renderOrder),i.userData!==void 0&&(v.userData=i.userData),i.layers!==void 0&&(v.layers.mask=i.layers),i.children!==void 0){const pe=i.children;for(let me=0;me<pe.length;me++)v.add(this.parseObject(pe[me],l,h,f,g))}if(i.animations!==void 0){const pe=i.animations;for(let me=0;me<pe.length;me++){const Se=pe[me];v.animations.push(g[Se])}}if(i.type==="LOD"){i.autoUpdate!==void 0&&(v.autoUpdate=i.autoUpdate);const pe=i.levels;for(let me=0;me<pe.length;me++){const Se=pe[me],tt=v.getObjectByProperty("uuid",Se.object);tt!==void 0&&v.addLevel(tt,Se.distance,Se.hysteresis)}}return v}bindSkeletons(i,l){Object.keys(l).length!==0&&i.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(i){i.traverse(function(l){if(l.isDirectionalLight||l.isSpotLight){const h=l.target,f=i.getObjectByProperty("uuid",h);f!==void 0?l.target=f:l.target=new xs}})}}const zx={UVMapping:te,CubeReflectionMapping:Fe,CubeRefractionMapping:Xe,EquirectangularReflectionMapping:Pe,EquirectangularRefractionMapping:Ie,CubeUVReflectionMapping:Ke},q1={RepeatWrapping:lt,ClampToEdgeWrapping:qe,MirroredRepeatWrapping:pt},_y={NearestFilter:Ct,NearestMipmapNearestFilter:Xt,NearestMipmapLinearFilter:pn,LinearFilter:Rn,LinearMipmapNearestFilter:bi,LinearMipmapLinearFilter:Qn},bg=new WeakMap;class Rf extends null{constructor(i){super(i),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(i){return this.options=i,this}load(i,l,h,f){i===void 0&&(i=""),this.path!==void 0&&(i=this.path+i),i=this.manager.resolveURL(i);const g=this,v=bl.get(`image-bitmap:${i}`);if(v!==void 0){if(g.manager.itemStart(i),v.then){v.then(H=>{if(bg.has(v)===!0)f&&f(bg.get(v)),g.manager.itemError(i),g.manager.itemEnd(i);else return l&&l(H),g.manager.itemEnd(i),H});return}return setTimeout(function(){l&&l(v),g.manager.itemEnd(i)},0),v}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 V=fetch(i,C).then(function(H){return H.blob()}).then(function(H){return createImageBitmap(H,Object.assign(g.options,{colorSpaceConversion:"none"}))}).then(function(H){return bl.add(`image-bitmap:${i}`,H),l&&l(H),g.manager.itemEnd(i),H}).catch(function(H){f&&f(H),bg.set(V,H),bl.remove(`image-bitmap:${i}`),g.manager.itemError(i),g.manager.itemEnd(i)});bl.add(`image-bitmap:${i}`,V),g.manager.itemStart(i)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let by;class wy{static getContext(){return by===void 0&&(by=new(window.AudioContext||window.webkitAudioContext)),by}static setContext(i){by=i}}class Vx extends null{constructor(i){super(i)}load(i,l,h,f){const g=this,v=new _d(this.manager);v.setResponseType("arraybuffer"),v.setPath(this.path),v.setRequestHeader(this.requestHeader),v.setWithCredentials(this.withCredentials),v.load(i,function(V){try{const H=V.slice(0);wy.getContext().decodeAudioData(H,function(he){l(he)}).catch(C)}catch(H){C(H)}},h,f);function C(V){f?f(V):js(V),g.manager.itemError(i)}}}const Sh=new On,wg=new On,Md=new On;class Nf{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ul,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ul,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(i){const l=this._cache;if(l.focus!==i.focus||l.fov!==i.fov||l.aspect!==i.aspect*this.aspect||l.near!==i.near||l.far!==i.far||l.zoom!==i.zoom||l.eyeSep!==this.eyeSep){l.focus=i.focus,l.fov=i.fov,l.aspect=i.aspect*this.aspect,l.near=i.near,l.far=i.far,l.zoom=i.zoom,l.eyeSep=this.eyeSep,Md.copy(i.projectionMatrix);const f=l.eyeSep/2,g=f*l.near/l.focus,v=l.near*Math.tan(ru*l.fov*.5)/l.zoom;let C,V;wg.elements[12]=-f,Sh.elements[12]=f,C=-v*l.aspect+g,V=v*l.aspect+g,Md.elements[0]=2*l.near/(V-C),Md.elements[8]=(V+C)/(V-C),this.cameraL.projectionMatrix.copy(Md),C=-v*l.aspect-g,V=v*l.aspect-g,Md.elements[0]=2*l.near/(V-C),Md.elements[8]=(V+C)/(V-C),this.cameraR.projectionMatrix.copy(Md)}this.cameraL.matrixWorld.copy(i.matrixWorld).multiply(wg),this.cameraR.matrixWorld.copy(i.matrixWorld).multiply(Sh)}}class Pf extends null{constructor(i=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=i}}class gE{constructor(i=!0){this.autoStart=i,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 i=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const l=performance.now();i=(l-this.oldTime)/1e3,this.oldTime=l,this.elapsedTime+=i}return i}}const If=new Rt,Yu=new vl,Gx=new Rt,Sd=new Rt,ec=new Rt;class y3 extends null{constructor(){super(),this.type="AudioListener",this.context=wy.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new gE}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(i){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=i,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(i){return this.gain.gain.setTargetAtTime(i,this.context.currentTime,.01),this}updateMatrixWorld(i){super.updateMatrixWorld(i);const l=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(If,Yu,Gx),Sd.set(0,0,-1).applyQuaternion(Yu),ec.set(0,1,0).applyQuaternion(Yu),l.positionX){const h=this.context.currentTime+this.timeDelta;l.positionX.linearRampToValueAtTime(If.x,h),l.positionY.linearRampToValueAtTime(If.y,h),l.positionZ.linearRampToValueAtTime(If.z,h),l.forwardX.linearRampToValueAtTime(Sd.x,h),l.forwardY.linearRampToValueAtTime(Sd.y,h),l.forwardZ.linearRampToValueAtTime(Sd.z,h),l.upX.linearRampToValueAtTime(ec.x,h),l.upY.linearRampToValueAtTime(ec.y,h),l.upZ.linearRampToValueAtTime(ec.z,h)}else l.setPosition(If.x,If.y,If.z),l.setOrientation(Sd.x,Sd.y,Sd.z,ec.x,ec.y,ec.z)}}class v3 extends null{constructor(i){super(),this.type="Audio",this.listener=i,this.context=i.context,this.gain=this.context.createGain(),this.gain.connect(i.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(i){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=i,this.connect(),this}setMediaElementSource(i){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(i),this.connect(),this}setMediaStreamSource(i){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(i),this.connect(),this}setBuffer(i){return this.buffer=i,this.sourceType="buffer",this.autoplay&&this.play(),this}play(i=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+i;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(i=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+i),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let i=1,l=this.filters.length;i<l;i++)this.filters[i-1].connect(this.filters[i]);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 i=1,l=this.filters.length;i<l;i++)this.filters[i-1].disconnect(this.filters[i]);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(i){return i||(i=[]),this._connected===!0?(this.disconnect(),this.filters=i.slice(),this.connect()):this.filters=i.slice(),this}setDetune(i){return this.detune=i,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(i){return this.setFilters(i?[i]:[])}setPlaybackRate(i){if(this.hasPlaybackControl===!1){_r("Audio: this Audio has no playback control.");return}return this.playbackRate=i,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(i){if(this.hasPlaybackControl===!1){_r("Audio: this Audio has no playback control.");return}return this.loop=i,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(i){return this.loopStart=i,this}setLoopEnd(i){return this.loopEnd=i,this}getVolume(){return this.gain.gain.value}setVolume(i){return this.gain.gain.setTargetAtTime(i,this.context.currentTime,.01),this}copy(i,l){return super.copy(i,l),i.sourceType!=="buffer"?(_r("Audio: Audio source type cannot be copied."),this):(this.autoplay=i.autoplay,this.buffer=i.buffer,this.detune=i.detune,this.loop=i.loop,this.loopStart=i.loopStart,this.loopEnd=i.loopEnd,this.offset=i.offset,this.duration=i.duration,this.playbackRate=i.playbackRate,this.hasPlaybackControl=i.hasPlaybackControl,this.sourceType=i.sourceType,this.filters=i.filters.slice(),this)}clone(i){return new this.constructor(this.listener).copy(this,i)}}const Td=new Rt,Mg=new vl,Y1=new Rt,Zu=new Rt;class yE extends null{constructor(i){super(i),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(i){return this.panner.refDistance=i,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(i){return this.panner.rolloffFactor=i,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(i){return this.panner.distanceModel=i,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(i){return this.panner.maxDistance=i,this}setDirectionalCone(i,l,h){return this.panner.coneInnerAngle=i,this.panner.coneOuterAngle=l,this.panner.coneOuterGain=h,this}updateMatrixWorld(i){if(super.updateMatrixWorld(i),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Td,Mg,Y1),Zu.set(0,0,1).applyQuaternion(Mg);const l=this.panner;if(l.positionX){const h=this.context.currentTime+this.listener.timeDelta;l.positionX.linearRampToValueAtTime(Td.x,h),l.positionY.linearRampToValueAtTime(Td.y,h),l.positionZ.linearRampToValueAtTime(Td.z,h),l.orientationX.linearRampToValueAtTime(Zu.x,h),l.orientationY.linearRampToValueAtTime(Zu.y,h),l.orientationZ.linearRampToValueAtTime(Zu.z,h)}else l.setPosition(Td.x,Td.y,Td.z),l.setOrientation(Zu.x,Zu.y,Zu.z)}}class vE{constructor(i,l=2048){this.analyser=i.context.createAnalyser(),this.analyser.fftSize=l,this.data=new Uint8Array(this.analyser.frequencyBinCount),i.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let i=0;const l=this.getFrequencyData();for(let h=0;h<l.length;h++)i+=l[h];return i/l.length}}class Z1{constructor(i,l,h){this.binding=i,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(i,l){const h=this.buffer,f=this.valueSize,g=i*f+f;let v=this.cumulativeWeight;if(v===0){for(let C=0;C!==f;++C)h[g+C]=h[C];v=l}else{v+=l;const C=l/v;this._mixBufferRegion(h,g,0,C,f)}this.cumulativeWeight=v}accumulateAdditive(i){const l=this.buffer,h=this.valueSize,f=h*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(l,f,0,i,h),this.cumulativeWeightAdditive+=i}apply(i){const l=this.valueSize,h=this.buffer,f=i*l+l,g=this.cumulativeWeight,v=this.cumulativeWeightAdditive,C=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]){C.setValue(h,f);break}}saveOriginalState(){const i=this.binding,l=this.buffer,h=this.valueSize,f=h*this._origIndex;i.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 i=this.valueSize*3;this.binding.setValue(this.buffer,i)}_setAdditiveIdentityNumeric(){const i=this._addIndex*this.valueSize,l=i+this.valueSize;for(let h=i;h<l;h++)this.buffer[h]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const i=this._origIndex*this.valueSize,l=this._addIndex*this.valueSize;for(let h=0;h<this.valueSize;h++)this.buffer[l+h]=this.buffer[i+h]}_select(i,l,h,f,g){if(f>=.5)for(let v=0;v!==g;++v)i[l+v]=i[h+v]}_slerp(i,l,h,f){vl.slerpFlat(i,l,i,l,i,h,f)}_slerpAdditive(i,l,h,f,g){const v=this._workIndex*g;vl.multiplyQuaternionsFlat(i,v,i,l,i,h),vl.slerpFlat(i,l,i,l,i,v,f)}_lerp(i,l,h,f,g){const v=1-f;for(let C=0;C!==g;++C){const V=l+C;i[V]=i[V]*v+i[h+C]*f}}_lerpAdditive(i,l,h,f,g){for(let v=0;v!==g;++v){const C=l+v;i[C]=i[C]+i[h+v]*f}}}const My="\\[\\]\\.:\\/",K1=new RegExp("["+My+"]","g"),Sy="[^"+My+"]",J1="[^"+My.replace("\\.","")+"]",Q1=/((?:WC+[\/:])*)/.source.replace("WC",Sy),Ks=/(WCOD+)?/.source.replace("WCOD",J1),xE=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Sy),ew=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Sy),tw=new RegExp("^"+Q1+Ks+xE+ew+"$"),_E=["material","materials","bones","map"];class bE{constructor(i,l,h){const f=h||Xs.parseTrackName(l);this._targetGroup=i,this._bindings=i.subscribe_(l,f)}getValue(i,l){this.bind();const h=this._targetGroup.nCachedObjects_,f=this._bindings[h];f!==void 0&&f.getValue(i,l)}setValue(i,l){const h=this._bindings;for(let f=this._targetGroup.nCachedObjects_,g=h.length;f!==g;++f)h[f].setValue(i,l)}bind(){const i=this._bindings;for(let l=this._targetGroup.nCachedObjects_,h=i.length;l!==h;++l)i[l].bind()}unbind(){const i=this._bindings;for(let l=this._targetGroup.nCachedObjects_,h=i.length;l!==h;++l)i[l].unbind()}}class Xs{constructor(i,l,h){this.path=l,this.parsedPath=h||Xs.parseTrackName(l),this.node=Xs.findNode(i,this.parsedPath.nodeName),this.rootNode=i,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(i,l,h){return i&&i.isAnimationObjectGroup?new Xs.Composite(i,l,h):new Xs(i,l,h)}static sanitizeNodeName(i){return i.replace(/\s/g,"_").replace(K1,"")}static parseTrackName(i){const l=tw.exec(i);if(l===null)throw new Error("PropertyBinding: Cannot parse trackName: "+i);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);_E.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: "+i);return h}static findNode(i,l){if(l===void 0||l===""||l==="."||l===-1||l===i.name||l===i.uuid)return i;if(i.skeleton){const h=i.skeleton.getBoneByName(l);if(h!==void 0)return h}if(i.children){const h=function(g){for(let v=0;v<g.length;v++){const C=g[v];if(C.name===l||C.uuid===l)return C;const V=h(C.children);if(V)return V}return null},f=h(i.children);if(f)return f}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(i,l){i[l]=this.targetObject[this.propertyName]}_getValue_array(i,l){const h=this.resolvedProperty;for(let f=0,g=h.length;f!==g;++f)i[l++]=h[f]}_getValue_arrayElement(i,l){i[l]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(i,l){this.resolvedProperty.toArray(i,l)}_setValue_direct(i,l){this.targetObject[this.propertyName]=i[l]}_setValue_direct_setNeedsUpdate(i,l){this.targetObject[this.propertyName]=i[l],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(i,l){this.targetObject[this.propertyName]=i[l],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(i,l){const h=this.resolvedProperty;for(let f=0,g=h.length;f!==g;++f)h[f]=i[l++]}_setValue_array_setNeedsUpdate(i,l){const h=this.resolvedProperty;for(let f=0,g=h.length;f!==g;++f)h[f]=i[l++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(i,l){const h=this.resolvedProperty;for(let f=0,g=h.length;f!==g;++f)h[f]=i[l++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(i,l){this.resolvedProperty[this.propertyIndex]=i[l]}_setValue_arrayElement_setNeedsUpdate(i,l){this.resolvedProperty[this.propertyIndex]=i[l],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(i,l){this.resolvedProperty[this.propertyIndex]=i[l],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(i,l){this.resolvedProperty.fromArray(i,l)}_setValue_fromArray_setNeedsUpdate(i,l){this.resolvedProperty.fromArray(i,l),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(i,l){this.resolvedProperty.fromArray(i,l),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(i,l){this.bind(),this.getValue(i,l)}_setValue_unbound(i,l){this.bind(),this.setValue(i,l)}bind(){let i=this.node;const l=this.parsedPath,h=l.objectName,f=l.propertyName;let g=l.propertyIndex;if(i||(i=Xs.findNode(this.rootNode,l.nodeName),this.node=i),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!i){_r("PropertyBinding: No target node found for track: "+this.path+".");return}if(h){let H=l.objectIndex;switch(h){case"materials":if(!i.material){js("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!i.material.materials){js("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}i=i.material.materials;break;case"bones":if(!i.skeleton){js("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}i=i.skeleton.bones;for(let J=0;J<i.length;J++)if(i[J].name===H){H=J;break}break;case"map":if("map"in i){i=i.map;break}if(!i.material){js("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!i.material.map){js("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}i=i.material.map;break;default:if(i[h]===void 0){js("PropertyBinding: Can not bind to objectName of node undefined.",this);return}i=i[h]}if(H!==void 0){if(i[H]===void 0){js("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,i);return}i=i[H]}}const v=i[f];if(v===void 0){const H=l.nodeName;js("PropertyBinding: Trying to update property for track: "+H+"."+f+" but it wasn't found.",i);return}let C=this.Versioning.None;this.targetObject=i,i.isMaterial===!0?C=this.Versioning.NeedsUpdate:i.isObject3D===!0&&(C=this.Versioning.MatrixWorldNeedsUpdate);let V=this.BindingType.Direct;if(g!==void 0){if(f==="morphTargetInfluences"){if(!i.geometry){js("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!i.geometry.morphAttributes){js("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}i.morphTargetDictionary[g]!==void 0&&(g=i.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][C]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Xs.Composite=bE,Xs.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Xs.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Xs.prototype.GetterByBindingType=[Xs.prototype._getValue_direct,Xs.prototype._getValue_array,Xs.prototype._getValue_arrayElement,Xs.prototype._getValue_toArray],Xs.prototype.SetterByBindingTypeAndVersioning=[[Xs.prototype._setValue_direct,Xs.prototype._setValue_direct_setNeedsUpdate,Xs.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Xs.prototype._setValue_array,Xs.prototype._setValue_array_setNeedsUpdate,Xs.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Xs.prototype._setValue_arrayElement,Xs.prototype._setValue_arrayElement_setNeedsUpdate,Xs.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Xs.prototype._setValue_fromArray,Xs.prototype._setValue_fromArray_setNeedsUpdate,Xs.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class wE{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Sl(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const i={};this._indicesByUUID=i;for(let h=0,f=arguments.length;h!==f;++h)i[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 i=this._objects,l=this._indicesByUUID,h=this._paths,f=this._parsedPaths,g=this._bindings,v=g.length;let C,V=i.length,H=this.nCachedObjects_;for(let J=0,he=arguments.length;J!==he;++J){const pe=arguments[J],me=pe.uuid;let Se=l[me];if(Se===void 0){Se=V++,l[me]=Se,i.push(pe);for(let tt=0,gt=v;tt!==gt;++tt)g[tt].push(new Xs(pe,h[tt],f[tt]))}else if(Se<H){C=i[Se];const tt=--H,gt=i[tt];l[gt.uuid]=Se,i[Se]=gt,l[me]=tt,i[tt]=pe;for(let mt=0,Nt=v;mt!==Nt;++mt){const Pt=g[mt],Wt=Pt[tt];let gn=Pt[Se];Pt[Se]=Wt,gn===void 0&&(gn=new Xs(pe,h[mt],f[mt])),Pt[tt]=gn}}else i[Se]!==C&&js("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=H}remove(){const i=this._objects,l=this._indicesByUUID,h=this._bindings,f=h.length;let g=this.nCachedObjects_;for(let v=0,C=arguments.length;v!==C;++v){const V=arguments[v],H=V.uuid,J=l[H];if(J!==void 0&&J>=g){const he=g++,pe=i[he];l[pe.uuid]=J,i[J]=pe,l[H]=he,i[he]=V;for(let me=0,Se=f;me!==Se;++me){const tt=h[me],gt=tt[he],mt=tt[J];tt[J]=gt,tt[he]=mt}}}this.nCachedObjects_=g}uncache(){const i=this._objects,l=this._indicesByUUID,h=this._bindings,f=h.length;let g=this.nCachedObjects_,v=i.length;for(let C=0,V=arguments.length;C!==V;++C){const H=arguments[C],J=H.uuid,he=l[J];if(he!==void 0)if(delete l[J],he<g){const pe=--g,me=i[pe],Se=--v,tt=i[Se];l[me.uuid]=he,i[he]=me,l[tt.uuid]=pe,i[pe]=tt,i.pop();for(let gt=0,mt=f;gt!==mt;++gt){const Nt=h[gt],Pt=Nt[pe],Wt=Nt[Se];Nt[he]=Pt,Nt[pe]=Wt,Nt.pop()}}else{const pe=--v,me=i[pe];pe>0&&(l[me.uuid]=he),i[he]=me,i.pop();for(let Se=0,tt=f;Se!==tt;++Se){const gt=h[Se];gt[he]=gt[pe],gt.pop()}}}this.nCachedObjects_=g}subscribe_(i,l){const h=this._bindingsIndicesByPath;let f=h[i];const g=this._bindings;if(f!==void 0)return g[f];const v=this._paths,C=this._parsedPaths,V=this._objects,H=V.length,J=this.nCachedObjects_,he=new Array(H);f=g.length,h[i]=f,v.push(i),C.push(l),g.push(he);for(let pe=J,me=V.length;pe!==me;++pe){const Se=V[pe];he[pe]=new Xs(Se,i,l)}return he}unsubscribe_(i){const l=this._bindingsIndicesByPath,h=l[i];if(h!==void 0){const f=this._paths,g=this._parsedPaths,v=this._bindings,C=v.length-1,V=v[C],H=i[C];l[H]=h,v[h]=V,v.pop(),g[h]=g[C],g.pop(),f[h]=f[C],f.pop()}}}class ME{constructor(i,l,h=null,f=l.blendMode){this._mixer=i,this._clip=l,this._localRoot=h,this.blendMode=f;const g=l.tracks,v=g.length,C=new Array(v),V={endingStart:ca,endingEnd:ca};for(let H=0;H!==v;++H){const J=g[H].createInterpolant(null);C[H]=J,J.settings=V}this._interpolantSettings=V,this._interpolants=C,this._propertyBindings=new Array(v),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=qr,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(i){return this._startTime=i,this}setLoop(i,l){return this.loop=i,this.repetitions=l,this}setEffectiveWeight(i){return this.weight=i,this._effectiveWeight=this.enabled?i:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(i){return this._scheduleFading(i,0,1)}fadeOut(i){return this._scheduleFading(i,1,0)}crossFadeFrom(i,l,h=!1){if(i.fadeOut(l),this.fadeIn(l),h===!0){const f=this._clip.duration,g=i._clip.duration,v=g/f,C=f/g;i.warp(1,v,l),this.warp(C,1,l)}return this}crossFadeTo(i,l,h=!1){return i.crossFadeFrom(this,l,h)}stopFading(){const i=this._weightInterpolant;return i!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(i)),this}setEffectiveTimeScale(i){return this.timeScale=i,this._effectiveTimeScale=this.paused?0:i,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(i){return this.timeScale=this._clip.duration/i,this.stopWarping()}syncWith(i){return this.time=i.time,this.timeScale=i.timeScale,this.stopWarping()}halt(i){return this.warp(this._effectiveTimeScale,0,i)}warp(i,l,h){const f=this._mixer,g=f.time,v=this.timeScale;let C=this._timeScaleInterpolant;C===null&&(C=f._lendControlInterpolant(),this._timeScaleInterpolant=C);const V=C.parameterPositions,H=C.sampleValues;return V[0]=g,V[1]=g+h,H[0]=i/v,H[1]=l/v,this}stopWarping(){const i=this._timeScaleInterpolant;return i!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(i)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(i,l,h,f){if(!this.enabled){this._updateWeight(i);return}const g=this._startTime;if(g!==null){const V=(i-g)*h;V<0||h===0?l=0:(this._startTime=null,l=h*V)}l*=this._updateTimeScale(i);const v=this._updateTime(l),C=this._updateWeight(i);if(C>0){const V=this._interpolants,H=this._propertyBindings;switch(this.blendMode){case Pc:for(let J=0,he=V.length;J!==he;++J)V[J].evaluate(v),H[J].accumulateAdditive(C);break;case bo:default:for(let J=0,he=V.length;J!==he;++J)V[J].evaluate(v),H[J].accumulate(f,C)}}}_updateWeight(i){let l=0;if(this.enabled){l=this.weight;const h=this._weightInterpolant;if(h!==null){const f=h.evaluate(i)[0];l*=f,i>h.parameterPositions[1]&&(this.stopFading(),f===0&&(this.enabled=!1))}}return this._effectiveWeight=l,l}_updateTimeScale(i){let l=0;if(!this.paused){l=this.timeScale;const h=this._timeScaleInterpolant;if(h!==null){const f=h.evaluate(i)[0];l*=f,i>h.parameterPositions[1]&&(this.stopWarping(),l===0?this.paused=!0:this.timeScale=l)}}return this._effectiveTimeScale=l,l}_updateTime(i){const l=this._clip.duration,h=this.loop;let f=this.time+i,g=this._loopCount;const v=h===la;if(i===0)return g===-1?f:v&&(g&1)===1?l-f:f;if(h===ro){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:i<0?-1:1})}}else{if(g===-1&&(i>=0?(g=0,this._setEndings(!0,this.repetitions===0,v)):this._setEndings(this.repetitions===0,!0,v)),f>=l||f<0){const C=Math.floor(f/l);f-=l*C,g+=Math.abs(C);const V=this.repetitions-g;if(V<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,f=i>0?l:0,this.time=f,this._mixer.dispatchEvent({type:"finished",action:this,direction:i>0?1:-1});else{if(V===1){const H=i<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:C})}}else this.time=f;if(v&&(g&1)===1)return l-f}return f}_setEndings(i,l,h){const f=this._interpolantSettings;h?(f.endingStart=Oa,f.endingEnd=Oa):(i?f.endingStart=this.zeroSlopeAtStart?Oa:ca:f.endingStart=sl,l?f.endingEnd=this.zeroSlopeAtEnd?Oa:ca:f.endingEnd=sl)}_scheduleFading(i,l,h){const f=this._mixer,g=f.time;let v=this._weightInterpolant;v===null&&(v=f._lendControlInterpolant(),this._weightInterpolant=v);const C=v.parameterPositions,V=v.sampleValues;return C[0]=g,V[0]=l,C[1]=g+i,V[1]=h,this}}const nw=new Float32Array(1);class x3 extends null{constructor(i){super(),this._root=i,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(i,l){const h=i._localRoot||this._root,f=i._clip.tracks,g=f.length,v=i._propertyBindings,C=i._interpolants,V=h.uuid,H=this._bindingsByRootAndName;let J=H[V];J===void 0&&(J={},H[V]=J);for(let he=0;he!==g;++he){const pe=f[he],me=pe.name;let Se=J[me];if(Se!==void 0)++Se.referenceCount,v[he]=Se;else{if(Se=v[he],Se!==void 0){Se._cacheIndex===null&&(++Se.referenceCount,this._addInactiveBinding(Se,V,me));continue}const tt=l&&l._propertyBindings[he].binding.parsedPath;Se=new Z1(Xs.create(h,me,tt),pe.ValueTypeName,pe.getValueSize()),++Se.referenceCount,this._addInactiveBinding(Se,V,me),v[he]=Se}C[he].resultBuffer=Se.buffer}}_activateAction(i){if(!this._isActiveAction(i)){if(i._cacheIndex===null){const h=(i._localRoot||this._root).uuid,f=i._clip.uuid,g=this._actionsByClip[f];this._bindAction(i,g&&g.knownActions[0]),this._addInactiveAction(i,f,h)}const l=i._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(i)}}_deactivateAction(i){if(this._isActiveAction(i)){const l=i._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(i)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const i=this;this.stats={actions:{get total(){return i._actions.length},get inUse(){return i._nActiveActions}},bindings:{get total(){return i._bindings.length},get inUse(){return i._nActiveBindings}},controlInterpolants:{get total(){return i._controlInterpolants.length},get inUse(){return i._nActiveControlInterpolants}}}}_isActiveAction(i){const l=i._cacheIndex;return l!==null&&l<this._nActiveActions}_addInactiveAction(i,l,h){const f=this._actions,g=this._actionsByClip;let v=g[l];if(v===void 0)v={knownActions:[i],actionByRoot:{}},i._byClipCacheIndex=0,g[l]=v;else{const C=v.knownActions;i._byClipCacheIndex=C.length,C.push(i)}i._cacheIndex=f.length,f.push(i),v.actionByRoot[h]=i}_removeInactiveAction(i){const l=this._actions,h=l[l.length-1],f=i._cacheIndex;h._cacheIndex=f,l[f]=h,l.pop(),i._cacheIndex=null;const g=i._clip.uuid,v=this._actionsByClip,C=v[g],V=C.knownActions,H=V[V.length-1],J=i._byClipCacheIndex;H._byClipCacheIndex=J,V[J]=H,V.pop(),i._byClipCacheIndex=null;const he=C.actionByRoot,pe=(i._localRoot||this._root).uuid;delete he[pe],V.length===0&&delete v[g],this._removeInactiveBindingsForAction(i)}_removeInactiveBindingsForAction(i){const l=i._propertyBindings;for(let h=0,f=l.length;h!==f;++h){const g=l[h];--g.referenceCount===0&&this._removeInactiveBinding(g)}}_lendAction(i){const l=this._actions,h=i._cacheIndex,f=this._nActiveActions++,g=l[f];i._cacheIndex=f,l[f]=i,g._cacheIndex=h,l[h]=g}_takeBackAction(i){const l=this._actions,h=i._cacheIndex,f=--this._nActiveActions,g=l[f];i._cacheIndex=f,l[f]=i,g._cacheIndex=h,l[h]=g}_addInactiveBinding(i,l,h){const f=this._bindingsByRootAndName,g=this._bindings;let v=f[l];v===void 0&&(v={},f[l]=v),v[h]=i,i._cacheIndex=g.length,g.push(i)}_removeInactiveBinding(i){const l=this._bindings,h=i.binding,f=h.rootNode.uuid,g=h.path,v=this._bindingsByRootAndName,C=v[f],V=l[l.length-1],H=i._cacheIndex;V._cacheIndex=H,l[H]=V,l.pop(),delete C[g],Object.keys(C).length===0&&delete v[f]}_lendBinding(i){const l=this._bindings,h=i._cacheIndex,f=this._nActiveBindings++,g=l[f];i._cacheIndex=f,l[f]=i,g._cacheIndex=h,l[h]=g}_takeBackBinding(i){const l=this._bindings,h=i._cacheIndex,f=--this._nActiveBindings,g=l[f];i._cacheIndex=f,l[f]=i,g._cacheIndex=h,l[h]=g}_lendControlInterpolant(){const i=this._controlInterpolants,l=this._nActiveControlInterpolants++;let h=i[l];return h===void 0&&(h=new Dx(new Float32Array(2),new Float32Array(2),1,nw),h.__cacheIndex=l,i[l]=h),h}_takeBackControlInterpolant(i){const l=this._controlInterpolants,h=i.__cacheIndex,f=--this._nActiveControlInterpolants,g=l[f];i.__cacheIndex=f,l[f]=i,g.__cacheIndex=h,l[h]=g}clipAction(i,l,h){const f=l||this._root,g=f.uuid;let v=typeof i=="string"?Mf.findByName(f,i):i;const C=v!==null?v.uuid:i,V=this._actionsByClip[C];let H=null;if(h===void 0&&(v!==null?h=v.blendMode:h=bo),V!==void 0){const he=V.actionByRoot[g];if(he!==void 0&&he.blendMode===h)return he;H=V.knownActions[0],v===null&&(v=H._clip)}if(v===null)return null;const J=new ME(this,v,l,h);return this._bindAction(J,H),this._addInactiveAction(J,C,g),J}existingAction(i,l){const h=l||this._root,f=h.uuid,g=typeof i=="string"?Mf.findByName(h,i):i,v=g?g.uuid:i,C=this._actionsByClip[v];return C!==void 0&&C.actionByRoot[f]||null}stopAllAction(){const i=this._actions,l=this._nActiveActions;for(let h=l-1;h>=0;--h)i[h].stop();return this}update(i){i*=this.timeScale;const l=this._actions,h=this._nActiveActions,f=this.time+=i,g=Math.sign(i),v=this._accuIndex^=1;for(let H=0;H!==h;++H)l[H]._update(f,i,g,v);const C=this._bindings,V=this._nActiveBindings;for(let H=0;H!==V;++H)C[H].apply(v);return this}setTime(i){this.time=0;for(let l=0;l<this._actions.length;l++)this._actions[l].time=0;return this.update(i)}getRoot(){return this._root}uncacheClip(i){const l=this._actions,h=i.uuid,f=this._actionsByClip,g=f[h];if(g!==void 0){const v=g.knownActions;for(let C=0,V=v.length;C!==V;++C){const H=v[C];this._deactivateAction(H);const J=H._cacheIndex,he=l[l.length-1];H._cacheIndex=null,H._byClipCacheIndex=null,he._cacheIndex=J,l[J]=he,l.pop(),this._removeInactiveBindingsForAction(H)}delete f[h]}}uncacheRoot(i){const l=i.uuid,h=this._actionsByClip;for(const v in h){const C=h[v].actionByRoot,V=C[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 C=g[v];C.restoreOriginalState(),this._removeInactiveBinding(C)}}uncacheAction(i,l){const h=this.existingAction(i,l);h!==null&&(this._deactivateAction(h),this._removeInactiveAction(h))}}class iw extends null{constructor(i=1,l=1,h=1,f={}){super(i,l,f),this.isRenderTarget3D=!0,this.depth=h,this.texture=new au(null,i,l,h),this._setTextureOptions(f),this.texture.isRenderTargetTexture=!0}}class Ty{constructor(i){this.value=i}clone(){return new Ty(this.value.clone===void 0?this.value:this.value.clone())}}let Wx=0;class Hx extends null{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:Wx++}),this.name="",this.usage=Ou,this.uniforms=[]}add(i){return this.uniforms.push(i),this}remove(i){const l=this.uniforms.indexOf(i);return l!==-1&&this.uniforms.splice(l,1),this}setName(i){return this.name=i,this}setUsage(i){return this.usage=i,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(i){this.name=i.name,this.usage=i.usage;const l=i.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 _3 extends null{constructor(i,l,h=1){super(i,l),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=h}copy(i){return super.copy(i),this.meshPerAttribute=i.meshPerAttribute,this}clone(i){const l=super.clone(i);return l.meshPerAttribute=this.meshPerAttribute,l}toJSON(i){const l=super.toJSON(i);return l.isInstancedInterleavedBuffer=!0,l.meshPerAttribute=this.meshPerAttribute,l}}class SE{constructor(i,l,h,f,g,v=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=i,this.type=l,this.itemSize=h,this.elementSize=f,this.count=g,this.normalized=v,this.version=0}set needsUpdate(i){i===!0&&this.version++}setBuffer(i){return this.buffer=i,this}setType(i,l){return this.type=i,this.elementSize=l,this}setItemSize(i){return this.itemSize=i,this}setCount(i){return this.count=i,this}}const Ey=new On;class b3{constructor(i,l,h=0,f=1/0){this.ray=new ai(i,l),this.near=h,this.far=f,this.camera=null,this.layers=new ds,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(i,l){this.ray.set(i,l)}setFromCamera(i,l){l.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(l.matrixWorld),this.ray.direction.set(i.x,i.y,.5).unproject(l).sub(this.ray.origin).normalize(),this.camera=l):l.isOrthographicCamera?(this.ray.origin.set(i.x,i.y,(l.near+l.far)/(l.near-l.far)).unproject(l),this.ray.direction.set(0,0,-1).transformDirection(l.matrixWorld),this.camera=l):js("Raycaster: Unsupported camera type: "+l.type)}setFromXRController(i){return Ey.identity().extractRotation(i.matrixWorld),this.ray.origin.setFromMatrixPosition(i.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Ey),this}intersectObject(i,l=!0,h=[]){return Sg(i,this,h,l),h.sort(Wp),h}intersectObjects(i,l=!0,h=[]){for(let f=0,g=i.length;f<g;f++)Sg(i[f],this,h,l);return h.sort(Wp),h}}function Wp(j,i){return j.distance-i.distance}function Sg(j,i,l,h){let f=!0;if(j.layers.test(i.layers)&&j.raycast(i,l)===!1&&(f=!1),f===!0&&h===!0){const g=j.children;for(let v=0,C=g.length;v<C;v++)Sg(g[v],i,l,!0)}}class w3{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(i){this._document=i,i.hidden!==void 0&&(this._pageVisibilityHandler=$x.bind(this),i.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(i){return this._timescale=i,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(i){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(i!==void 0?i:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function $x(){this._document.hidden===!1&&this.reset()}class Ay{constructor(i=1,l=0,h=0){this.radius=i,this.phi=l,this.theta=h}set(i,l,h){return this.radius=i,this.phi=l,this.theta=h,this}copy(i){return this.radius=i.radius,this.phi=i.phi,this.theta=i.theta,this}makeSafe(){return this.phi=Fr(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(i){return this.setFromCartesianCoords(i.x,i.y,i.z)}setFromCartesianCoords(i,l,h){return this.radius=Math.sqrt(i*i+l*l+h*h),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(i,h),this.phi=Math.acos(Fr(l/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class Hp{constructor(i=1,l=0,h=0){this.radius=i,this.theta=l,this.y=h}set(i,l,h){return this.radius=i,this.theta=l,this.y=h,this}copy(i){return this.radius=i.radius,this.theta=i.theta,this.y=i.y,this}setFromVector3(i){return this.setFromCartesianCoords(i.x,i.y,i.z)}setFromCartesianCoords(i,l,h){return this.radius=Math.sqrt(i*i+h*h),this.theta=Math.atan2(i,h),this.y=l,this}clone(){return new this.constructor().copy(this)}}class Ed{constructor(i,l,h,f){Ed.prototype.isMatrix2=!0,this.elements=[1,0,0,1],i!==void 0&&this.set(i,l,h,f)}identity(){return this.set(1,0,0,1),this}fromArray(i,l=0){for(let h=0;h<4;h++)this.elements[h]=i[h+l];return this}set(i,l,h,f){const g=this.elements;return g[0]=i,g[2]=l,g[1]=h,g[3]=f,this}}const Tg=new oi;class TE{constructor(i=new oi(1/0,1/0),l=new oi(-1/0,-1/0)){this.isBox2=!0,this.min=i,this.max=l}set(i,l){return this.min.copy(i),this.max.copy(l),this}setFromPoints(i){this.makeEmpty();for(let l=0,h=i.length;l<h;l++)this.expandByPoint(i[l]);return this}setFromCenterAndSize(i,l){const h=Tg.copy(l).multiplyScalar(.5);return this.min.copy(i).sub(h),this.max.copy(i).add(h),this}clone(){return new this.constructor().copy(this)}copy(i){return this.min.copy(i.min),this.max.copy(i.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(i){return this.isEmpty()?i.set(0,0):i.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(i){return this.isEmpty()?i.set(0,0):i.subVectors(this.max,this.min)}expandByPoint(i){return this.min.min(i),this.max.max(i),this}expandByVector(i){return this.min.sub(i),this.max.add(i),this}expandByScalar(i){return this.min.addScalar(-i),this.max.addScalar(i),this}containsPoint(i){return i.x>=this.min.x&&i.x<=this.max.x&&i.y>=this.min.y&&i.y<=this.max.y}containsBox(i){return this.min.x<=i.min.x&&i.max.x<=this.max.x&&this.min.y<=i.min.y&&i.max.y<=this.max.y}getParameter(i,l){return l.set((i.x-this.min.x)/(this.max.x-this.min.x),(i.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(i){return i.max.x>=this.min.x&&i.min.x<=this.max.x&&i.max.y>=this.min.y&&i.min.y<=this.max.y}clampPoint(i,l){return l.copy(i).clamp(this.min,this.max)}distanceToPoint(i){return this.clampPoint(i,Tg).distanceTo(i)}intersect(i){return this.min.max(i.min),this.max.min(i.max),this.isEmpty()&&this.makeEmpty(),this}union(i){return this.min.min(i.min),this.max.max(i.max),this}translate(i){return this.min.add(i),this.max.add(i),this}equals(i){return i.min.equals(this.min)&&i.max.equals(this.max)}}const jx=new Rt,Cy=new Rt,Ad=new Rt,$p=new Rt,vu=new Rt,Eg=new Rt,Ry=new Rt;class M3{constructor(i=new Rt,l=new Rt){this.start=i,this.end=l}set(i,l){return this.start.copy(i),this.end.copy(l),this}copy(i){return this.start.copy(i.start),this.end.copy(i.end),this}getCenter(i){return i.addVectors(this.start,this.end).multiplyScalar(.5)}delta(i){return i.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(i,l){return this.delta(l).multiplyScalar(i).add(this.start)}closestPointToPointParameter(i,l){jx.subVectors(i,this.start),Cy.subVectors(this.end,this.start);const h=Cy.dot(Cy);let g=Cy.dot(jx)/h;return l&&(g=Fr(g,0,1)),g}closestPointToPoint(i,l,h){const f=this.closestPointToPointParameter(i,l);return this.delta(h).multiplyScalar(f).add(this.start)}distanceSqToLine3(i,l=Eg,h=Ry){const f=10000000000000001e-32;let g,v;const C=this.start,V=i.start,H=this.end,J=i.end;Ad.subVectors(H,C),$p.subVectors(J,V),vu.subVectors(C,V);const he=Ad.dot(Ad),pe=$p.dot($p),me=$p.dot(vu);if(he<=f&&pe<=f)return l.copy(C),h.copy(V),l.sub(h),l.dot(l);if(he<=f)g=0,v=me/pe,v=Fr(v,0,1);else{const Se=Ad.dot(vu);if(pe<=f)v=0,g=Fr(-Se/he,0,1);else{const tt=Ad.dot($p),gt=he*pe-tt*tt;gt!==0?g=Fr((tt*me-Se*pe)/gt,0,1):g=0,v=(tt*g+me)/pe,v<0?(v=0,g=Fr(-Se/he,0,1)):v>1&&(v=1,g=Fr((tt-Se)/he,0,1))}}return l.copy(C).add(Ad.multiplyScalar(g)),h.copy(V).add($p.multiplyScalar(v)),l.sub(h),l.dot(l)}applyMatrix4(i){return this.start.applyMatrix4(i),this.end.applyMatrix4(i),this}equals(i){return i.start.equals(this.start)&&i.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Ny=new Rt;class S3 extends null{constructor(i,l){super(),this.light=i,this.matrixAutoUpdate=!1,this.color=l,this.type="SpotLightHelper";const h=new Or,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,C=1,V=32;v<V;v++,C++){const H=v/V*Math.PI*2,J=C/V*Math.PI*2;f.push(Math.cos(H),Math.sin(H),1,Math.cos(J),Math.sin(J),1)}h.setAttribute("position",new qi(f,3));const g=new Rl({fog:!1,toneMapped:!1});this.cone=new _p(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 i=this.light.distance?this.light.distance:1e3,l=i*Math.tan(this.light.angle);this.cone.scale.set(l,l,i),Ny.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Ny),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Th=new Rt,jp=new On,Ag=new On;class T3 extends null{constructor(i){const l=rw(i),h=new Or,f=[],g=[];for(let H=0;H<l.length;H++){const J=l[H];J.parent&&J.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 Rl({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(h,v),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=i,this.bones=l,this.matrix=i.matrixWorld,this.matrixAutoUpdate=!1;const C=new ar(255),V=new ar(65280);this.setColors(C,V)}updateMatrixWorld(i){const l=this.bones,h=this.geometry,f=h.getAttribute("position");Ag.copy(this.root.matrixWorld).invert();for(let g=0,v=0;g<l.length;g++){const C=l[g];C.parent&&C.parent.isBone&&(jp.multiplyMatrices(Ag,C.matrixWorld),Th.setFromMatrixPosition(jp),f.setXYZ(v,Th.x,Th.y,Th.z),jp.multiplyMatrices(Ag,C.parent.matrixWorld),Th.setFromMatrixPosition(jp),f.setXYZ(v+1,Th.x,Th.y,Th.z),v+=2)}h.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(i)}setColors(i,l){const f=this.geometry.getAttribute("color");for(let g=0;g<f.count;g+=2)f.setXYZ(g,i.r,i.g,i.b),f.setXYZ(g+1,l.r,l.g,l.b);return f.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}function rw(j){const i=[];j.isBone===!0&&i.push(j);for(let l=0;l<j.children.length;l++)i.push(...rw(j.children[l]));return i}class E3 extends null{constructor(i,l,h){const f=new wf(l,4,2),g=new Ms({wireframe:!0,fog:!1,toneMapped:!1});super(f,g),this.light=i,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 Xx=new Rt,Xp=new ar,Py=new ar;class A3 extends null{constructor(i,l,h){super(),this.light=i,this.matrix=i.matrixWorld,this.matrixAutoUpdate=!1,this.color=h,this.type="HemisphereLightHelper";const f=new _f(l);f.rotateY(Math.PI*.5),this.material=new Ms({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 yo(v,3)),this.add(new fh(f,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const i=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const l=i.geometry.getAttribute("color");Xp.copy(this.light.color),Py.copy(this.light.groundColor);for(let h=0,f=l.count;h<f;h++){const g=h<f/2?Xp:Py;l.setXYZ(h,g.r,g.g,g.b)}l.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),i.lookAt(Xx.setFromMatrixPosition(this.light.matrixWorld).negate())}}class Iy extends null{constructor(i=10,l=10,h=4473924,f=8947848){h=new ar(h),f=new ar(f);const g=l/2,v=i/l,C=i/2,V=[],H=[];for(let pe=0,me=0,Se=-C;pe<=l;pe++,Se+=v){V.push(-C,0,Se,C,0,Se),V.push(Se,0,-C,Se,0,C);const tt=pe===g?h:f;tt.toArray(H,me),me+=3,tt.toArray(H,me),me+=3,tt.toArray(H,me),me+=3,tt.toArray(H,me),me+=3}const J=new Or;J.setAttribute("position",new qi(V,3)),J.setAttribute("color",new qi(H,3));const he=new Rl({vertexColors:!0,toneMapped:!1});super(J,he),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class pa extends null{constructor(i=10,l=16,h=8,f=64,g=4473924,v=8947848){g=new ar(g),v=new ar(v);const C=[],V=[];if(l>1)for(let he=0;he<l;he++){const pe=he/l*(Math.PI*2),me=Math.sin(pe)*i,Se=Math.cos(pe)*i;C.push(0,0,0),C.push(me,0,Se);const tt=he&1?g:v;V.push(tt.r,tt.g,tt.b),V.push(tt.r,tt.g,tt.b)}for(let he=0;he<h;he++){const pe=he&1?g:v,me=i-i/h*he;for(let Se=0;Se<f;Se++){let tt=Se/f*(Math.PI*2),gt=Math.sin(tt)*me,mt=Math.cos(tt)*me;C.push(gt,0,mt),V.push(pe.r,pe.g,pe.b),tt=(Se+1)/f*(Math.PI*2),gt=Math.sin(tt)*me,mt=Math.cos(tt)*me,C.push(gt,0,mt),V.push(pe.r,pe.g,pe.b)}}const H=new Or;H.setAttribute("position",new qi(C,3)),H.setAttribute("color",new qi(V,3));const J=new Rl({vertexColors:!0,toneMapped:!1});super(H,J),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const sw=new Rt,Uo=new Rt,qp=new Rt;class C3 extends null{constructor(i,l,h){super(),this.light=i,this.matrix=i.matrixWorld,this.matrixAutoUpdate=!1,this.color=h,this.type="DirectionalLightHelper",l===void 0&&(l=1);let f=new Or;f.setAttribute("position",new qi([-l,l,0,l,l,0,l,-l,0,-l,-l,0,-l,l,0],3));const g=new Rl({fog:!1,toneMapped:!1});this.lightPlane=new uf(f,g),this.add(this.lightPlane),f=new Or,f.setAttribute("position",new qi([0,0,0,0,0,1],3)),this.targetLine=new uf(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),sw.setFromMatrixPosition(this.light.matrixWorld),Uo.setFromMatrixPosition(this.light.target.matrixWorld),qp.subVectors(Uo,sw),this.lightPlane.lookAt(Uo),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(Uo),this.targetLine.scale.z=qp.length()}}const Ly=new Rt,ma=new nf;class ow extends null{constructor(i){const l=new Or,h=new Rl({color:16777215,vertexColors:!0,toneMapped:!1}),f=[],g=[],v={};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(Se,tt){V(Se),V(tt)}function V(Se){f.push(0,0,0),g.push(0,0,0),v[Se]===void 0&&(v[Se]=[]),v[Se].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=i,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=i.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=v,this.update();const H=new ar(16755200),J=new ar(16711680),he=new ar(43775),pe=new ar(16777215),me=new ar(3355443);this.setColors(H,J,he,pe,me)}setColors(i,l,h,f,g){const C=this.geometry.getAttribute("color");return C.setXYZ(0,i.r,i.g,i.b),C.setXYZ(1,i.r,i.g,i.b),C.setXYZ(2,i.r,i.g,i.b),C.setXYZ(3,i.r,i.g,i.b),C.setXYZ(4,i.r,i.g,i.b),C.setXYZ(5,i.r,i.g,i.b),C.setXYZ(6,i.r,i.g,i.b),C.setXYZ(7,i.r,i.g,i.b),C.setXYZ(8,i.r,i.g,i.b),C.setXYZ(9,i.r,i.g,i.b),C.setXYZ(10,i.r,i.g,i.b),C.setXYZ(11,i.r,i.g,i.b),C.setXYZ(12,i.r,i.g,i.b),C.setXYZ(13,i.r,i.g,i.b),C.setXYZ(14,i.r,i.g,i.b),C.setXYZ(15,i.r,i.g,i.b),C.setXYZ(16,i.r,i.g,i.b),C.setXYZ(17,i.r,i.g,i.b),C.setXYZ(18,i.r,i.g,i.b),C.setXYZ(19,i.r,i.g,i.b),C.setXYZ(20,i.r,i.g,i.b),C.setXYZ(21,i.r,i.g,i.b),C.setXYZ(22,i.r,i.g,i.b),C.setXYZ(23,i.r,i.g,i.b),C.setXYZ(24,l.r,l.g,l.b),C.setXYZ(25,l.r,l.g,l.b),C.setXYZ(26,l.r,l.g,l.b),C.setXYZ(27,l.r,l.g,l.b),C.setXYZ(28,l.r,l.g,l.b),C.setXYZ(29,l.r,l.g,l.b),C.setXYZ(30,l.r,l.g,l.b),C.setXYZ(31,l.r,l.g,l.b),C.setXYZ(32,h.r,h.g,h.b),C.setXYZ(33,h.r,h.g,h.b),C.setXYZ(34,h.r,h.g,h.b),C.setXYZ(35,h.r,h.g,h.b),C.setXYZ(36,h.r,h.g,h.b),C.setXYZ(37,h.r,h.g,h.b),C.setXYZ(38,f.r,f.g,f.b),C.setXYZ(39,f.r,f.g,f.b),C.setXYZ(40,g.r,g.g,g.b),C.setXYZ(41,g.r,g.g,g.b),C.setXYZ(42,g.r,g.g,g.b),C.setXYZ(43,g.r,g.g,g.b),C.setXYZ(44,g.r,g.g,g.b),C.setXYZ(45,g.r,g.g,g.b),C.setXYZ(46,g.r,g.g,g.b),C.setXYZ(47,g.r,g.g,g.b),C.setXYZ(48,g.r,g.g,g.b),C.setXYZ(49,g.r,g.g,g.b),C.needsUpdate=!0,this}update(){const i=this.geometry,l=this.pointMap,h=1,f=1;let g,v;if(ma.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)g=1,v=0;else if(this.camera.coordinateSystem===so)g=-1,v=1;else if(this.camera.coordinateSystem===ja)g=0,v=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);ko("c",l,i,ma,0,0,g),ko("t",l,i,ma,0,0,v),ko("n1",l,i,ma,-h,-f,g),ko("n2",l,i,ma,h,-f,g),ko("n3",l,i,ma,-h,f,g),ko("n4",l,i,ma,h,f,g),ko("f1",l,i,ma,-h,-f,v),ko("f2",l,i,ma,h,-f,v),ko("f3",l,i,ma,-h,f,v),ko("f4",l,i,ma,h,f,v),ko("u1",l,i,ma,h*.7,f*1.1,g),ko("u2",l,i,ma,-h*.7,f*1.1,g),ko("u3",l,i,ma,0,f*2,g),ko("cf1",l,i,ma,-h,0,v),ko("cf2",l,i,ma,h,0,v),ko("cf3",l,i,ma,0,-f,v),ko("cf4",l,i,ma,0,f,v),ko("cn1",l,i,ma,-h,0,g),ko("cn2",l,i,ma,h,0,g),ko("cn3",l,i,ma,0,-f,g),ko("cn4",l,i,ma,0,f,g),i.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function ko(j,i,l,h,f,g,v){Ly.set(f,g,v).unproject(h);const C=i[j];if(C!==void 0){const V=l.getAttribute("position");for(let H=0,J=C.length;H<J;H++)V.setXYZ(C[H],Ly.x,Ly.y,Ly.z)}}const Lf=new ta;class R3 extends null{constructor(i,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 Or;g.setIndex(new yo(h,1)),g.setAttribute("position",new yo(f,3)),super(g,new Rl({color:l,toneMapped:!1})),this.object=i,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&Lf.setFromObject(this.object),Lf.isEmpty())return;const i=Lf.min,l=Lf.max,h=this.geometry.attributes.position,f=h.array;f[0]=l.x,f[1]=l.y,f[2]=l.z,f[3]=i.x,f[4]=l.y,f[5]=l.z,f[6]=i.x,f[7]=i.y,f[8]=l.z,f[9]=l.x,f[10]=i.y,f[11]=l.z,f[12]=l.x,f[13]=l.y,f[14]=i.z,f[15]=i.x,f[16]=l.y,f[17]=i.z,f[18]=i.x,f[19]=i.y,f[20]=i.z,f[21]=l.x,f[22]=i.y,f[23]=i.z,h.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(i){return this.object=i,this.update(),this}copy(i,l){return super.copy(i,l),this.object=i.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class N3 extends null{constructor(i,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 Or;g.setIndex(new yo(h,1)),g.setAttribute("position",new qi(f,3)),super(g,new Rl({color:l,toneMapped:!1})),this.box=i,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(i){const l=this.box;l.isEmpty()||(l.getCenter(this.position),l.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(i))}dispose(){this.geometry.dispose(),this.material.dispose()}}class P3 extends null{constructor(i,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 Or;v.setAttribute("position",new qi(g,3)),v.computeBoundingSphere(),super(v,new Rl({color:f,toneMapped:!1})),this.type="PlaneHelper",this.plane=i,this.size=l;const C=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],V=new Or;V.setAttribute("position",new qi(C,3)),V.computeBoundingSphere(),this.add(new fh(V,new Ms({color:f,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(i){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(i)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const Yp=new Rt;let Cg,Dy;class EE extends null{constructor(i=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",Cg===void 0&&(Cg=new Or,Cg.setAttribute("position",new qi([0,0,0,0,1,0],3)),Dy=new ud(.5,1,5,1),Dy.translate(0,-.5,0)),this.position.copy(l),this.line=new uf(Cg,new Rl({color:f,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new fh(Dy,new Ms({color:f,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(i),this.setLength(h,g,v)}setDirection(i){if(i.y>.99999)this.quaternion.set(0,0,0,1);else if(i.y<-.99999)this.quaternion.set(1,0,0,0);else{Yp.set(i.z,0,-i.x).normalize();const l=Math.acos(i.y);this.quaternion.setFromAxisAngle(Yp,l)}}setLength(i,l=i*.2,h=l*.2){this.line.scale.set(1,Math.max(1e-4,i-l),1),this.line.updateMatrix(),this.cone.scale.set(h,l,h),this.cone.position.y=i,this.cone.updateMatrix()}setColor(i){this.line.material.color.set(i),this.cone.material.color.set(i)}copy(i){return super.copy(i,!1),this.line.copy(i.line),this.cone.copy(i.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class Oy extends null{constructor(i=1){const l=[0,0,0,i,0,0,0,0,0,0,i,0,0,0,0,0,0,i],h=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],f=new Or;f.setAttribute("position",new qi(l,3)),f.setAttribute("color",new qi(h,3));const g=new Rl({vertexColors:!0,toneMapped:!1});super(f,g),this.type="AxesHelper"}setColors(i,l,h){const f=new ar,g=this.geometry.attributes.color.array;return f.set(i),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 AE{constructor(){this.type="ShapePath",this.color=new ar,this.subPaths=[],this.currentPath=null}moveTo(i,l){return this.currentPath=new J0,this.subPaths.push(this.currentPath),this.currentPath.moveTo(i,l),this}lineTo(i,l){return this.currentPath.lineTo(i,l),this}quadraticCurveTo(i,l,h,f){return this.currentPath.quadraticCurveTo(i,l,h,f),this}bezierCurveTo(i,l,h,f,g,v){return this.currentPath.bezierCurveTo(i,l,h,f,g,v),this}splineThru(i){return this.currentPath.splineThru(i),this}toShapes(i){function l(mt){const Nt=[];for(let Pt=0,Wt=mt.length;Pt<Wt;Pt++){const gn=mt[Pt],Sn=new yf;Sn.curves=gn.curves,Nt.push(Sn)}return Nt}function h(mt,Nt){const Pt=Nt.length;let Wt=!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),mt.y<kn.y||mt.y>In.y)continue;if(mt.y===kn.y){if(mt.x===kn.x)return!0}else{const dr=li*(mt.x-kn.x)-ii*(mt.y-kn.y);if(dr===0)return!0;if(dr<0)continue;Wt=!Wt}}else{if(mt.y!==kn.y)continue;if(In.x<=mt.x&&mt.x<=kn.x||kn.x<=mt.x&&mt.x<=In.x)return!0}}return Wt}const f=xc.isClockWise,g=this.subPaths;if(g.length===0)return[];let v,C,V;const H=[];if(g.length===1)return C=g[0],V=new yf,V.curves=C.curves,H.push(V),H;let J=!f(g[0].getPoints());J=i?!J:J;const he=[],pe=[];let me=[],Se=0,tt;pe[Se]=void 0,me[Se]=[];for(let mt=0,Nt=g.length;mt<Nt;mt++)C=g[mt],tt=C.getPoints(),v=f(tt),v=i?!v:v,v?(!J&&pe[Se]&&Se++,pe[Se]={s:new yf,p:tt},pe[Se].s.curves=C.curves,J&&Se++,me[Se]=[]):me[Se].push({h:C,p:tt[0]});if(!pe[0])return l(g);if(pe.length>1){let mt=!1,Nt=0;for(let Pt=0,Wt=pe.length;Pt<Wt;Pt++)he[Pt]=[];for(let Pt=0,Wt=pe.length;Pt<Wt;Pt++){const gn=me[Pt];for(let Sn=0;Sn<gn.length;Sn++){const kn=gn[Sn];let In=!0;for(let ii=0;ii<pe.length;ii++)h(kn.p,pe[ii].p)&&(Pt!==ii&&Nt++,In?(In=!1,he[ii].push(kn)):mt=!0);In&&he[Pt].push(kn)}}Nt>0&&mt===!1&&(me=he)}let gt;for(let mt=0,Nt=pe.length;mt<Nt;mt++){V=pe[mt].s,H.push(V),gt=me[mt];for(let Pt=0,Wt=gt.length;Pt<Wt;Pt++)V.holes.push(gt[Pt].h)}return H}}class I3 extends null{constructor(i,l=null){super(),this.object=i,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(i){if(i===void 0){_r("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=i}disconnect(){}dispose(){}update(){}}function Df(j,i){const l=j.image&&j.image.width?j.image.width/j.image.height:1;return l>i?(j.repeat.x=1,j.repeat.y=l/i,j.offset.x=0,j.offset.y=(1-j.repeat.y)/2):(j.repeat.x=i/l,j.repeat.y=1,j.offset.x=(1-j.repeat.x)/2,j.offset.y=0),j}function Ku(j,i){const l=j.image&&j.image.width?j.image.width/j.image.height:1;return l>i?(j.repeat.x=i/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/i,j.offset.x=0,j.offset.y=(1-j.repeat.y)/2),j}function qx(j){return j.repeat.x=1,j.repeat.y=1,j.offset.x=0,j.offset.y=0,j}function Fy(j,i,l,h){const f=Rg(h);switch(l){case Du:return j*i;case F:return j*i/f.components*f.byteLength;case X:return j*i/f.components*f.byteLength;case De:return j*i*2/f.components*f.byteLength;case Ve:return j*i*2/f.components*f.byteLength;case Le:return j*i*3/f.components*f.byteLength;case D:return j*i*4/f.components*f.byteLength;case st:return j*i*4/f.components*f.byteLength;case Ht:case Et:return Math.floor((j+3)/4)*Math.floor((i+3)/4)*8;case on:case Un:return Math.floor((j+3)/4)*Math.floor((i+3)/4)*16;case bn:case Bt:return Math.max(j,16)*Math.max(i,8)/4;case sn:case ti:return Math.max(j,8)*Math.max(i,8)/2;case $n:case ni:return Math.floor((j+3)/4)*Math.floor((i+3)/4)*8;case Pi:return Math.floor((j+3)/4)*Math.floor((i+3)/4)*16;case ui:return Math.floor((j+3)/4)*Math.floor((i+3)/4)*16;case Ir:return Math.floor((j+4)/5)*Math.floor((i+3)/4)*16;case yi:return Math.floor((j+4)/5)*Math.floor((i+4)/5)*16;case vi:return Math.floor((j+5)/6)*Math.floor((i+4)/5)*16;case Mr:return Math.floor((j+5)/6)*Math.floor((i+5)/6)*16;case Zt:return Math.floor((j+7)/8)*Math.floor((i+4)/5)*16;case Fn:return Math.floor((j+7)/8)*Math.floor((i+5)/6)*16;case hi:return Math.floor((j+7)/8)*Math.floor((i+7)/8)*16;case Xn:return Math.floor((j+9)/10)*Math.floor((i+4)/5)*16;case hs:return Math.floor((j+9)/10)*Math.floor((i+5)/6)*16;case Xr:return Math.floor((j+9)/10)*Math.floor((i+7)/8)*16;case ys:return Math.floor((j+9)/10)*Math.floor((i+9)/10)*16;case Ur:return Math.floor((j+11)/12)*Math.floor((i+9)/10)*16;case Os:return Math.floor((j+11)/12)*Math.floor((i+11)/12)*16;case no:case io:case So:return Math.ceil(j/4)*Math.ceil(i/4)*16;case To:case Gr:return Math.ceil(j/4)*Math.ceil(i/4)*8;case Qs:case Eo:return Math.ceil(j/4)*Math.ceil(i/4)*16}throw new Error(`Unable to determine texture byte length for ${l} format.`)}function Rg(j){switch(j){case Oi:case Gi:return{byteLength:1,components:1};case ms:case ir:case Vs:return{byteLength:2,components:1};case Xl:case ql:return{byteLength:2,components:4};case as:case Is:case gs:return{byteLength:4,components:1};case Dl:case nu:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${j}.`)}class By{static contain(i,l){return Df(i,l)}static cover(i,l){return Ku(i,l)}static fill(i){return qx(i)}static getByteLength(i,l,h,f){return Fy(i,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)},97234:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return A}});function w(q){"@babel/helpers - typeof";return w=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(Y){return typeof Y}:function(Y){return Y&&typeof Symbol=="function"&&Y.constructor===Symbol&&Y!==Symbol.prototype?"symbol":typeof Y},w(q)}var k=/^\s+/,O=/\s+$/;function A(q,Y){if(q=q||"",Y=Y||{},q instanceof A)return q;if(!(this instanceof A))return new A(q,Y);var de=S(q);this._originalInput=q,this._r=de.r,this._g=de.g,this._b=de.b,this._a=de.a,this._roundA=Math.round(100*this._a)/100,this._format=Y.format||de.format,this._gradientType=Y.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=de.ok}A.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 Y=this.toRgb();return(Y.r*299+Y.g*587+Y.b*114)/1e3},getLuminance:function(){var Y=this.toRgb(),de,Je,Te,$e,xt,ke;return de=Y.r/255,Je=Y.g/255,Te=Y.b/255,de<=.03928?$e=de/12.92:$e=Math.pow((de+.055)/1.055,2.4),Je<=.03928?xt=Je/12.92:xt=Math.pow((Je+.055)/1.055,2.4),Te<=.03928?ke=Te/12.92:ke=Math.pow((Te+.055)/1.055,2.4),.2126*$e+.7152*xt+.0722*ke},setAlpha:function(Y){return this._a=kt(Y),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var Y=N(this._r,this._g,this._b);return{h:Y.h*360,s:Y.s,v:Y.v,a:this._a}},toHsvString:function(){var Y=N(this._r,this._g,this._b),de=Math.round(Y.h*360),Je=Math.round(Y.s*100),Te=Math.round(Y.v*100);return this._a==1?"hsv("+de+", "+Je+"%, "+Te+"%)":"hsva("+de+", "+Je+"%, "+Te+"%, "+this._roundA+")"},toHsl:function(){var Y=x(this._r,this._g,this._b);return{h:Y.h*360,s:Y.s,l:Y.l,a:this._a}},toHslString:function(){var Y=x(this._r,this._g,this._b),de=Math.round(Y.h*360),Je=Math.round(Y.s*100),Te=Math.round(Y.l*100);return this._a==1?"hsl("+de+", "+Je+"%, "+Te+"%)":"hsla("+de+", "+Je+"%, "+Te+"%, "+this._roundA+")"},toHex:function(Y){return P(this._r,this._g,this._b,Y)},toHexString:function(Y){return"#"+this.toHex(Y)},toHex8:function(Y){return W(this._r,this._g,this._b,this._a,Y)},toHex8String:function(Y){return"#"+this.toHex8(Y)},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(Ut(this._r,255)*100)+"%",g:Math.round(Ut(this._g,255)*100)+"%",b:Math.round(Ut(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(Ut(this._r,255)*100)+"%, "+Math.round(Ut(this._g,255)*100)+"%, "+Math.round(Ut(this._b,255)*100)+"%)":"rgba("+Math.round(Ut(this._r,255)*100)+"%, "+Math.round(Ut(this._g,255)*100)+"%, "+Math.round(Ut(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:_t[P(this._r,this._g,this._b,!0)]||!1},toFilter:function(Y){var de="#"+K(this._r,this._g,this._b,this._a),Je=de,Te=this._gradientType?"GradientType = 1, ":"";if(Y){var $e=A(Y);Je="#"+K($e._r,$e._g,$e._b,$e._a)}return"progid:DXImageTransform.Microsoft.gradient("+Te+"startColorstr="+de+",endColorstr="+Je+")"},toString:function(Y){var de=!!Y;Y=Y||this._format;var Je=!1,Te=this._a<1&&this._a>=0,$e=!de&&Te&&(Y==="hex"||Y==="hex6"||Y==="hex3"||Y==="hex4"||Y==="hex8"||Y==="name");return $e?Y==="name"&&this._a===0?this.toName():this.toRgbString():(Y==="rgb"&&(Je=this.toRgbString()),Y==="prgb"&&(Je=this.toPercentageRgbString()),(Y==="hex"||Y==="hex6")&&(Je=this.toHexString()),Y==="hex3"&&(Je=this.toHexString(!0)),Y==="hex4"&&(Je=this.toHex8String(!0)),Y==="hex8"&&(Je=this.toHex8String()),Y==="name"&&(Je=this.toName()),Y==="hsl"&&(Je=this.toHslString()),Y==="hsv"&&(Je=this.toHsvString()),Je||this.toHexString())},clone:function(){return A(this.toString())},_applyModification:function(Y,de){var Je=Y.apply(null,[this].concat([].slice.call(de)));return this._r=Je._r,this._g=Je._g,this._b=Je._b,this.setAlpha(Je._a),this},lighten:function(){return this._applyModification(ce,arguments)},brighten:function(){return this._applyModification(xe,arguments)},darken:function(){return this._applyModification(fe,arguments)},desaturate:function(){return this._applyModification(re,arguments)},saturate:function(){return this._applyModification(ye,arguments)},greyscale:function(){return this._applyModification(ge,arguments)},spin:function(){return this._applyModification(Ne,arguments)},_applyCombination:function(Y,de){return Y.apply(null,[this].concat([].slice.call(de)))},analogous:function(){return this._applyCombination(Ee,arguments)},complement:function(){return this._applyCombination(Ae,arguments)},monochromatic:function(){return this._applyCombination(We,arguments)},splitcomplement:function(){return this._applyCombination(Ye,arguments)},triad:function(){return this._applyCombination(be,[3])},tetrad:function(){return this._applyCombination(be,[4])}},A.fromRatio=function(q,Y){if(w(q)=="object"){var de={};for(var Je in q)q.hasOwnProperty(Je)&&(Je==="a"?de[Je]=q[Je]:de[Je]=vt(q[Je]));q=de}return A(q,Y)};function S(q){var Y={r:0,g:0,b:0},de=1,Je=null,Te=null,$e=null,xt=!1,ke=!1;return typeof q=="string"&&(q=ze(q)),w(q)=="object"&&(bt(q.r)&&bt(q.g)&&bt(q.b)?(Y=R(q.r,q.g,q.b),xt=!0,ke=String(q.r).substr(-1)==="%"?"prgb":"rgb"):bt(q.h)&&bt(q.s)&&bt(q.v)?(Je=vt(q.s),Te=vt(q.v),Y=L(q.h,Je,Te),xt=!0,ke="hsv"):bt(q.h)&&bt(q.s)&&bt(q.l)&&(Je=vt(q.s),$e=vt(q.l),Y=E(q.h,Je,$e),xt=!0,ke="hsl"),q.hasOwnProperty("a")&&(de=q.a)),de=kt(de),{ok:xt,format:q.format||ke,r:Math.min(255,Math.max(Y.r,0)),g:Math.min(255,Math.max(Y.g,0)),b:Math.min(255,Math.max(Y.b,0)),a:de}}function R(q,Y,de){return{r:Ut(q,255)*255,g:Ut(Y,255)*255,b:Ut(de,255)*255}}function x(q,Y,de){q=Ut(q,255),Y=Ut(Y,255),de=Ut(de,255);var Je=Math.max(q,Y,de),Te=Math.min(q,Y,de),$e,xt,ke=(Je+Te)/2;if(Je==Te)$e=xt=0;else{var et=Je-Te;switch(xt=ke>.5?et/(2-Je-Te):et/(Je+Te),Je){case q:$e=(Y-de)/et+(Y<de?6:0);break;case Y:$e=(de-q)/et+2;break;case de:$e=(q-Y)/et+4;break}$e/=6}return{h:$e,s:xt,l:ke}}function E(q,Y,de){var Je,Te,$e;q=Ut(q,360),Y=Ut(Y,100),de=Ut(de,100);function xt(yt,B,ie){return ie<0&&(ie+=1),ie>1&&(ie-=1),ie<1/6?yt+(B-yt)*6*ie:ie<1/2?B:ie<2/3?yt+(B-yt)*(2/3-ie)*6:yt}if(Y===0)Je=Te=$e=de;else{var ke=de<.5?de*(1+Y):de+Y-de*Y,et=2*de-ke;Je=xt(et,ke,q+1/3),Te=xt(et,ke,q),$e=xt(et,ke,q-1/3)}return{r:Je*255,g:Te*255,b:$e*255}}function N(q,Y,de){q=Ut(q,255),Y=Ut(Y,255),de=Ut(de,255);var Je=Math.max(q,Y,de),Te=Math.min(q,Y,de),$e,xt,ke=Je,et=Je-Te;if(xt=Je===0?0:et/Je,Je==Te)$e=0;else{switch(Je){case q:$e=(Y-de)/et+(Y<de?6:0);break;case Y:$e=(de-q)/et+2;break;case de:$e=(q-Y)/et+4;break}$e/=6}return{h:$e,s:xt,v:ke}}function L(q,Y,de){q=Ut(q,360)*6,Y=Ut(Y,100),de=Ut(de,100);var Je=Math.floor(q),Te=q-Je,$e=de*(1-Y),xt=de*(1-Te*Y),ke=de*(1-(1-Te)*Y),et=Je%6,yt=[de,xt,$e,$e,ke,de][et],B=[ke,de,de,xt,$e,$e][et],ie=[$e,$e,ke,de,de,xt][et];return{r:yt*255,g:B*255,b:ie*255}}function P(q,Y,de,Je){var Te=[Ue(Math.round(q).toString(16)),Ue(Math.round(Y).toString(16)),Ue(Math.round(de).toString(16))];return Je&&Te[0].charAt(0)==Te[0].charAt(1)&&Te[1].charAt(0)==Te[1].charAt(1)&&Te[2].charAt(0)==Te[2].charAt(1)?Te[0].charAt(0)+Te[1].charAt(0)+Te[2].charAt(0):Te.join("")}function W(q,Y,de,Je,Te){var $e=[Ue(Math.round(q).toString(16)),Ue(Math.round(Y).toString(16)),Ue(Math.round(de).toString(16)),Ue(Jt(Je))];return Te&&$e[0].charAt(0)==$e[0].charAt(1)&&$e[1].charAt(0)==$e[1].charAt(1)&&$e[2].charAt(0)==$e[2].charAt(1)&&$e[3].charAt(0)==$e[3].charAt(1)?$e[0].charAt(0)+$e[1].charAt(0)+$e[2].charAt(0)+$e[3].charAt(0):$e.join("")}function K(q,Y,de,Je){var Te=[Ue(Jt(Je)),Ue(Math.round(q).toString(16)),Ue(Math.round(Y).toString(16)),Ue(Math.round(de).toString(16))];return Te.join("")}A.equals=function(q,Y){return!q||!Y?!1:A(q).toRgbString()==A(Y).toRgbString()},A.random=function(){return A.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function re(q,Y){Y=Y===0?0:Y||10;var de=A(q).toHsl();return de.s-=Y/100,de.s=At(de.s),A(de)}function ye(q,Y){Y=Y===0?0:Y||10;var de=A(q).toHsl();return de.s+=Y/100,de.s=At(de.s),A(de)}function ge(q){return A(q).desaturate(100)}function ce(q,Y){Y=Y===0?0:Y||10;var de=A(q).toHsl();return de.l+=Y/100,de.l=At(de.l),A(de)}function xe(q,Y){Y=Y===0?0:Y||10;var de=A(q).toRgb();return de.r=Math.max(0,Math.min(255,de.r-Math.round(255*-(Y/100)))),de.g=Math.max(0,Math.min(255,de.g-Math.round(255*-(Y/100)))),de.b=Math.max(0,Math.min(255,de.b-Math.round(255*-(Y/100)))),A(de)}function fe(q,Y){Y=Y===0?0:Y||10;var de=A(q).toHsl();return de.l-=Y/100,de.l=At(de.l),A(de)}function Ne(q,Y){var de=A(q).toHsl(),Je=(de.h+Y)%360;return de.h=Je<0?360+Je:Je,A(de)}function Ae(q){var Y=A(q).toHsl();return Y.h=(Y.h+180)%360,A(Y)}function be(q,Y){if(isNaN(Y)||Y<=0)throw new Error("Argument to polyad must be a positive number");for(var de=A(q).toHsl(),Je=[A(q)],Te=360/Y,$e=1;$e<Y;$e++)Je.push(A({h:(de.h+$e*Te)%360,s:de.s,l:de.l}));return Je}function Ye(q){var Y=A(q).toHsl(),de=Y.h;return[A(q),A({h:(de+72)%360,s:Y.s,l:Y.l}),A({h:(de+216)%360,s:Y.s,l:Y.l})]}function Ee(q,Y,de){Y=Y||6,de=de||30;var Je=A(q).toHsl(),Te=360/de,$e=[A(q)];for(Je.h=(Je.h-(Te*Y>>1)+720)%360;--Y;)Je.h=(Je.h+Te)%360,$e.push(A(Je));return $e}function We(q,Y){Y=Y||6;for(var de=A(q).toHsv(),Je=de.h,Te=de.s,$e=de.v,xt=[],ke=1/Y;Y--;)xt.push(A({h:Je,s:Te,v:$e})),$e=($e+ke)%1;return xt}A.mix=function(q,Y,de){de=de===0?0:de||50;var Je=A(q).toRgb(),Te=A(Y).toRgb(),$e=de/100,xt={r:(Te.r-Je.r)*$e+Je.r,g:(Te.g-Je.g)*$e+Je.g,b:(Te.b-Je.b)*$e+Je.b,a:(Te.a-Je.a)*$e+Je.a};return A(xt)},A.readability=function(q,Y){var de=A(q),Je=A(Y);return(Math.max(de.getLuminance(),Je.getLuminance())+.05)/(Math.min(de.getLuminance(),Je.getLuminance())+.05)},A.isReadable=function(q,Y,de){var Je=A.readability(q,Y),Te,$e;switch($e=!1,Te=Ze(de),Te.level+Te.size){case"AAsmall":case"AAAlarge":$e=Je>=4.5;break;case"AAlarge":$e=Je>=3;break;case"AAAsmall":$e=Je>=7;break}return $e},A.mostReadable=function(q,Y,de){var Je=null,Te=0,$e,xt,ke,et;de=de||{},xt=de.includeFallbackColors,ke=de.level,et=de.size;for(var yt=0;yt<Y.length;yt++)$e=A.readability(q,Y[yt]),$e>Te&&(Te=$e,Je=A(Y[yt]));return A.isReadable(q,Je,{level:ke,size:et})||!xt?Je:(de.includeFallbackColors=!1,A.mostReadable(q,["#fff","#000"],de))};var je=A.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"},_t=A.hexNames=It(je);function It(q){var Y={};for(var de in q)q.hasOwnProperty(de)&&(Y[q[de]]=de);return Y}function kt(q){return q=parseFloat(q),(isNaN(q)||q<0||q>1)&&(q=1),q}function Ut(q,Y){Ot(q)&&(q="100%");var de=ue(q);return q=Math.min(Y,Math.max(0,parseFloat(q))),de&&(q=parseInt(q*Y,10)/100),Math.abs(q-Y)<1e-6?1:q%Y/parseFloat(Y)}function At(q){return Math.min(1,Math.max(0,q))}function at(q){return parseInt(q,16)}function Ot(q){return typeof q=="string"&&q.indexOf(".")!=-1&&parseFloat(q)===1}function ue(q){return typeof q=="string"&&q.indexOf("%")!=-1}function Ue(q){return q.length==1?"0"+q:""+q}function vt(q){return q<=1&&(q=q*100+"%"),q}function Jt(q){return Math.round(parseFloat(q)*255).toString(16)}function Qe(q){return at(q)/255}var rt=function(){var q="[-\\+]?\\d+%?",Y="[-\\+]?\\d*\\.\\d+%?",de="(?:"+Y+")|(?:"+q+")",Je="[\\s|\\(]+("+de+")[,|\\s]+("+de+")[,|\\s]+("+de+")\\s*\\)?",Te="[\\s|\\(]+("+de+")[,|\\s]+("+de+")[,|\\s]+("+de+")[,|\\s]+("+de+")\\s*\\)?";return{CSS_UNIT:new RegExp(de),rgb:new RegExp("rgb"+Je),rgba:new RegExp("rgba"+Te),hsl:new RegExp("hsl"+Je),hsla:new RegExp("hsla"+Te),hsv:new RegExp("hsv"+Je),hsva:new RegExp("hsva"+Te),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 bt(q){return!!rt.CSS_UNIT.exec(q)}function ze(q){q=q.replace(k,"").replace(O,"").toLowerCase();var Y=!1;if(je[q])q=je[q],Y=!0;else if(q=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var de;return(de=rt.rgb.exec(q))?{r:de[1],g:de[2],b:de[3]}:(de=rt.rgba.exec(q))?{r:de[1],g:de[2],b:de[3],a:de[4]}:(de=rt.hsl.exec(q))?{h:de[1],s:de[2],l:de[3]}:(de=rt.hsla.exec(q))?{h:de[1],s:de[2],l:de[3],a:de[4]}:(de=rt.hsv.exec(q))?{h:de[1],s:de[2],v:de[3]}:(de=rt.hsva.exec(q))?{h:de[1],s:de[2],v:de[3],a:de[4]}:(de=rt.hex8.exec(q))?{r:at(de[1]),g:at(de[2]),b:at(de[3]),a:Qe(de[4]),format:Y?"name":"hex8"}:(de=rt.hex6.exec(q))?{r:at(de[1]),g:at(de[2]),b:at(de[3]),format:Y?"name":"hex"}:(de=rt.hex4.exec(q))?{r:at(de[1]+""+de[1]),g:at(de[2]+""+de[2]),b:at(de[3]+""+de[3]),a:Qe(de[4]+""+de[4]),format:Y?"name":"hex8"}:(de=rt.hex3.exec(q))?{r:at(de[1]+""+de[1]),g:at(de[2]+""+de[2]),b:at(de[3]+""+de[3]),format:Y?"name":"hex"}:!1}function Ze(q){var Y,de;return q=q||{level:"AA",size:"small"},Y=(q.level||"AA").toUpperCase(),de=(q.size||"small").toLowerCase(),Y!=="AA"&&Y!=="AAA"&&(Y="AA"),de!=="small"&&de!=="large"&&(de="small"),{level:Y,size:de}}},97582:function(ae,ne,b){"use strict";b.d(ne,{CR:function(){return ce},Jh:function(){return K},Q_:function(){return Ut},XA:function(){return ge},ZT:function(){return k},_T:function(){return A},ev:function(){return Ne},mG:function(){return W},pi:function(){return O}});var w=function(Qe,rt){return w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(bt,ze){bt.__proto__=ze}||function(bt,ze){for(var Ze in ze)Object.prototype.hasOwnProperty.call(ze,Ze)&&(bt[Ze]=ze[Ze])},w(Qe,rt)};function k(Qe,rt){if(typeof rt!="function"&&rt!==null)throw new TypeError("Class extends value "+String(rt)+" is not a constructor or null");w(Qe,rt);function bt(){this.constructor=Qe}Qe.prototype=rt===null?Object.create(rt):(bt.prototype=rt.prototype,new bt)}var O=function(){return O=Object.assign||function(rt){for(var bt,ze=1,Ze=arguments.length;ze<Ze;ze++){bt=arguments[ze];for(var q in bt)Object.prototype.hasOwnProperty.call(bt,q)&&(rt[q]=bt[q])}return rt},O.apply(this,arguments)};function A(Qe,rt){var bt={};for(var ze in Qe)Object.prototype.hasOwnProperty.call(Qe,ze)&&rt.indexOf(ze)<0&&(bt[ze]=Qe[ze]);if(Qe!=null&&typeof Object.getOwnPropertySymbols=="function")for(var Ze=0,ze=Object.getOwnPropertySymbols(Qe);Ze<ze.length;Ze++)rt.indexOf(ze[Ze])<0&&Object.prototype.propertyIsEnumerable.call(Qe,ze[Ze])&&(bt[ze[Ze]]=Qe[ze[Ze]]);return bt}function S(Qe,rt,bt,ze){var Ze=arguments.length,q=Ze<3?rt:ze===null?ze=Object.getOwnPropertyDescriptor(rt,bt):ze,Y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")q=Reflect.decorate(Qe,rt,bt,ze);else for(var de=Qe.length-1;de>=0;de--)(Y=Qe[de])&&(q=(Ze<3?Y(q):Ze>3?Y(rt,bt,q):Y(rt,bt))||q);return Ze>3&&q&&Object.defineProperty(rt,bt,q),q}function R(Qe,rt){return function(bt,ze){rt(bt,ze,Qe)}}function x(Qe,rt,bt,ze,Ze,q){function Y(ct){if(ct!==void 0&&typeof ct!="function")throw new TypeError("Function expected");return ct}for(var de=ze.kind,Je=de==="getter"?"get":de==="setter"?"set":"value",Te=!rt&&Qe?ze.static?Qe:Qe.prototype:null,$e=rt||(Te?Object.getOwnPropertyDescriptor(Te,ze.name):{}),xt,ke=!1,et=bt.length-1;et>=0;et--){var yt={};for(var B in ze)yt[B]=B==="access"?{}:ze[B];for(var B in ze.access)yt.access[B]=ze.access[B];yt.addInitializer=function(ct){if(ke)throw new TypeError("Cannot add initializers after decoration has completed");q.push(Y(ct||null))};var ie=(0,bt[et])(de==="accessor"?{get:$e.get,set:$e.set}:$e[Je],yt);if(de==="accessor"){if(ie===void 0)continue;if(ie===null||typeof ie!="object")throw new TypeError("Object expected");(xt=Y(ie.get))&&($e.get=xt),(xt=Y(ie.set))&&($e.set=xt),(xt=Y(ie.init))&&Ze.unshift(xt)}else(xt=Y(ie))&&(de==="field"?Ze.unshift(xt):$e[Je]=xt)}Te&&Object.defineProperty(Te,ze.name,$e),ke=!0}function E(Qe,rt,bt){for(var ze=arguments.length>2,Ze=0;Ze<rt.length;Ze++)bt=ze?rt[Ze].call(Qe,bt):rt[Ze].call(Qe);return ze?bt:void 0}function N(Qe){return typeof Qe=="symbol"?Qe:"".concat(Qe)}function L(Qe,rt,bt){return typeof rt=="symbol"&&(rt=rt.description?"[".concat(rt.description,"]"):""),Object.defineProperty(Qe,"name",{configurable:!0,value:bt?"".concat(bt," ",rt):rt})}function P(Qe,rt){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(Qe,rt)}function W(Qe,rt,bt,ze){function Ze(q){return q instanceof bt?q:new bt(function(Y){Y(q)})}return new(bt||(bt=Promise))(function(q,Y){function de($e){try{Te(ze.next($e))}catch(xt){Y(xt)}}function Je($e){try{Te(ze.throw($e))}catch(xt){Y(xt)}}function Te($e){$e.done?q($e.value):Ze($e.value).then(de,Je)}Te((ze=ze.apply(Qe,rt||[])).next())})}function K(Qe,rt){var bt={label:0,sent:function(){if(q[0]&1)throw q[1];return q[1]},trys:[],ops:[]},ze,Ze,q,Y=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return Y.next=de(0),Y.throw=de(1),Y.return=de(2),typeof Symbol=="function"&&(Y[Symbol.iterator]=function(){return this}),Y;function de(Te){return function($e){return Je([Te,$e])}}function Je(Te){if(ze)throw new TypeError("Generator is already executing.");for(;Y&&(Y=0,Te[0]&&(bt=0)),bt;)try{if(ze=1,Ze&&(q=Te[0]&2?Ze.return:Te[0]?Ze.throw||((q=Ze.return)&&q.call(Ze),0):Ze.next)&&!(q=q.call(Ze,Te[1])).done)return q;switch(Ze=0,q&&(Te=[Te[0]&2,q.value]),Te[0]){case 0:case 1:q=Te;break;case 4:return bt.label++,{value:Te[1],done:!1};case 5:bt.label++,Ze=Te[1],Te=[0];continue;case 7:Te=bt.ops.pop(),bt.trys.pop();continue;default:if(q=bt.trys,!(q=q.length>0&&q[q.length-1])&&(Te[0]===6||Te[0]===2)){bt=0;continue}if(Te[0]===3&&(!q||Te[1]>q[0]&&Te[1]<q[3])){bt.label=Te[1];break}if(Te[0]===6&&bt.label<q[1]){bt.label=q[1],q=Te;break}if(q&&bt.label<q[2]){bt.label=q[2],bt.ops.push(Te);break}q[2]&&bt.ops.pop(),bt.trys.pop();continue}Te=rt.call(Qe,bt)}catch($e){Te=[6,$e],Ze=0}finally{ze=q=0}if(Te[0]&5)throw Te[1];return{value:Te[0]?Te[1]:void 0,done:!0}}}var re=Object.create?function(Qe,rt,bt,ze){ze===void 0&&(ze=bt);var Ze=Object.getOwnPropertyDescriptor(rt,bt);(!Ze||("get"in Ze?!rt.__esModule:Ze.writable||Ze.configurable))&&(Ze={enumerable:!0,get:function(){return rt[bt]}}),Object.defineProperty(Qe,ze,Ze)}:function(Qe,rt,bt,ze){ze===void 0&&(ze=bt),Qe[ze]=rt[bt]};function ye(Qe,rt){for(var bt in Qe)bt!=="default"&&!Object.prototype.hasOwnProperty.call(rt,bt)&&re(rt,Qe,bt)}function ge(Qe){var rt=typeof Symbol=="function"&&Symbol.iterator,bt=rt&&Qe[rt],ze=0;if(bt)return bt.call(Qe);if(Qe&&typeof Qe.length=="number")return{next:function(){return Qe&&ze>=Qe.length&&(Qe=void 0),{value:Qe&&Qe[ze++],done:!Qe}}};throw new TypeError(rt?"Object is not iterable.":"Symbol.iterator is not defined.")}function ce(Qe,rt){var bt=typeof Symbol=="function"&&Qe[Symbol.iterator];if(!bt)return Qe;var ze=bt.call(Qe),Ze,q=[],Y;try{for(;(rt===void 0||rt-- >0)&&!(Ze=ze.next()).done;)q.push(Ze.value)}catch(de){Y={error:de}}finally{try{Ze&&!Ze.done&&(bt=ze.return)&&bt.call(ze)}finally{if(Y)throw Y.error}}return q}function xe(){for(var Qe=[],rt=0;rt<arguments.length;rt++)Qe=Qe.concat(ce(arguments[rt]));return Qe}function fe(){for(var Qe=0,rt=0,bt=arguments.length;rt<bt;rt++)Qe+=arguments[rt].length;for(var ze=Array(Qe),Ze=0,rt=0;rt<bt;rt++)for(var q=arguments[rt],Y=0,de=q.length;Y<de;Y++,Ze++)ze[Ze]=q[Y];return ze}function Ne(Qe,rt,bt){if(bt||arguments.length===2)for(var ze=0,Ze=rt.length,q;ze<Ze;ze++)(q||!(ze in rt))&&(q||(q=Array.prototype.slice.call(rt,0,ze)),q[ze]=rt[ze]);return Qe.concat(q||Array.prototype.slice.call(rt))}function Ae(Qe){return this instanceof Ae?(this.v=Qe,this):new Ae(Qe)}function be(Qe,rt,bt){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var ze=bt.apply(Qe,rt||[]),Ze,q=[];return Ze=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),de("next"),de("throw"),de("return",Y),Ze[Symbol.asyncIterator]=function(){return this},Ze;function Y(et){return function(yt){return Promise.resolve(yt).then(et,xt)}}function de(et,yt){ze[et]&&(Ze[et]=function(B){return new Promise(function(ie,ct){q.push([et,B,ie,ct])>1||Je(et,B)})},yt&&(Ze[et]=yt(Ze[et])))}function Je(et,yt){try{Te(ze[et](yt))}catch(B){ke(q[0][3],B)}}function Te(et){et.value instanceof Ae?Promise.resolve(et.value.v).then($e,xt):ke(q[0][2],et)}function $e(et){Je("next",et)}function xt(et){Je("throw",et)}function ke(et,yt){et(yt),q.shift(),q.length&&Je(q[0][0],q[0][1])}}function Ye(Qe){var rt,bt;return rt={},ze("next"),ze("throw",function(Ze){throw Ze}),ze("return"),rt[Symbol.iterator]=function(){return this},rt;function ze(Ze,q){rt[Ze]=Qe[Ze]?function(Y){return(bt=!bt)?{value:Ae(Qe[Ze](Y)),done:!1}:q?q(Y):Y}:q}}function Ee(Qe){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var rt=Qe[Symbol.asyncIterator],bt;return rt?rt.call(Qe):(Qe=typeof ge=="function"?ge(Qe):Qe[Symbol.iterator](),bt={},ze("next"),ze("throw"),ze("return"),bt[Symbol.asyncIterator]=function(){return this},bt);function ze(q){bt[q]=Qe[q]&&function(Y){return new Promise(function(de,Je){Y=Qe[q](Y),Ze(de,Je,Y.done,Y.value)})}}function Ze(q,Y,de,Je){Promise.resolve(Je).then(function(Te){q({value:Te,done:de})},Y)}}function We(Qe,rt){return Object.defineProperty?Object.defineProperty(Qe,"raw",{value:rt}):Qe.raw=rt,Qe}var je=Object.create?function(Qe,rt){Object.defineProperty(Qe,"default",{enumerable:!0,value:rt})}:function(Qe,rt){Qe.default=rt},_t=function(Qe){return _t=Object.getOwnPropertyNames||function(rt){var bt=[];for(var ze in rt)Object.prototype.hasOwnProperty.call(rt,ze)&&(bt[bt.length]=ze);return bt},_t(Qe)};function It(Qe){if(Qe&&Qe.__esModule)return Qe;var rt={};if(Qe!=null)for(var bt=_t(Qe),ze=0;ze<bt.length;ze++)bt[ze]!=="default"&&re(rt,Qe,bt[ze]);return je(rt,Qe),rt}function kt(Qe){return Qe&&Qe.__esModule?Qe:{default:Qe}}function Ut(Qe,rt,bt,ze){if(bt==="a"&&!ze)throw new TypeError("Private accessor was defined without a getter");if(typeof rt=="function"?Qe!==rt||!ze:!rt.has(Qe))throw new TypeError("Cannot read private member from an object whose class did not declare it");return bt==="m"?ze:bt==="a"?ze.call(Qe):ze?ze.value:rt.get(Qe)}function At(Qe,rt,bt,ze,Ze){if(ze==="m")throw new TypeError("Private method is not writable");if(ze==="a"&&!Ze)throw new TypeError("Private accessor was defined without a setter");if(typeof rt=="function"?Qe!==rt||!Ze:!rt.has(Qe))throw new TypeError("Cannot write private member to an object whose class did not declare it");return ze==="a"?Ze.call(Qe,bt):Ze?Ze.value=bt:rt.set(Qe,bt),bt}function at(Qe,rt){if(rt===null||typeof rt!="object"&&typeof rt!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof Qe=="function"?rt===Qe:Qe.has(rt)}function Ot(Qe,rt,bt){if(rt!=null){if(typeof rt!="object"&&typeof rt!="function")throw new TypeError("Object expected.");var ze,Ze;if(bt){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");ze=rt[Symbol.asyncDispose]}if(ze===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");ze=rt[Symbol.dispose],bt&&(Ze=ze)}if(typeof ze!="function")throw new TypeError("Object not disposable.");Ze&&(ze=function(){try{Ze.call(this)}catch(q){return Promise.reject(q)}}),Qe.stack.push({value:rt,dispose:ze,async:bt})}else bt&&Qe.stack.push({async:!0});return rt}var ue=typeof SuppressedError=="function"?SuppressedError:function(Qe,rt,bt){var ze=new Error(bt);return ze.name="SuppressedError",ze.error=Qe,ze.suppressed=rt,ze};function Ue(Qe){function rt(q){Qe.error=Qe.hasError?new ue(q,Qe.error,"An error was suppressed during disposal."):q,Qe.hasError=!0}var bt,ze=0;function Ze(){for(;bt=Qe.stack.pop();)try{if(!bt.async&&ze===1)return ze=0,Qe.stack.push(bt),Promise.resolve().then(Ze);if(bt.dispose){var q=bt.dispose.call(bt.value);if(bt.async)return ze|=2,Promise.resolve(q).then(Ze,function(Y){return rt(Y),Ze()})}else ze|=1}catch(Y){rt(Y)}if(ze===1)return Qe.hasError?Promise.reject(Qe.error):Promise.resolve();if(Qe.hasError)throw Qe.error}return Ze()}function vt(Qe,rt){return typeof Qe=="string"&&/^\.\.?\//.test(Qe)?Qe.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(bt,ze,Ze,q,Y){return ze?rt?".jsx":".js":Ze&&(!q||!Y)?bt:Ze+q+"."+Y.toLowerCase()+"js"}):Qe}var Jt={__extends:k,__assign:O,__rest:A,__decorate:S,__param:R,__esDecorate:x,__runInitializers:E,__propKey:N,__setFunctionName:L,__metadata:P,__awaiter:W,__generator:K,__createBinding:re,__exportStar:ye,__values:ge,__read:ce,__spread:xe,__spreadArrays:fe,__spreadArray:Ne,__await:Ae,__asyncGenerator:be,__asyncDelegator:Ye,__asyncValues:Ee,__makeTemplateObject:We,__importStar:It,__importDefault:kt,__classPrivateFieldGet:Ut,__classPrivateFieldSet:At,__classPrivateFieldIn:at,__addDisposableResource:Ot,__disposeResources:Ue,__rewriteRelativeImportExtension:vt}}}]);
}());