@pan-ya/libgeo3dviewer 1.7.31 → 1.7.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/libgeo3dviewer.cjs.js +9 -9
- package/dist/libgeo3dviewer.es.js +1256 -1212
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Je=Object.defineProperty;var Ye=(e,t,n)=>t in e?Je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ue=(e,t,n)=>(Ye(e,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const jsxRuntime=require("react/jsx-runtime"),EngineCore=require("@babylonjs/core"),gpuPicker=require("@babylonjs/core/Collisions/gpuPicker"),React=require("react"),reactBabylonjs=require("react-babylonjs"),axios=require("axios"),inspector=require("@babylonjs/inspector");require("@babylonjs/core/Engines/Extensions/engine.query");require("@babylonjs/core/Legacy/legacy");const dynamic=require("@babylonjs/loaders/dynamic"),EngineGui=require("@babylonjs/gui"),EngineMaterial=require("@babylonjs/materials");require("@babylonjs/materials/legacy/legacy-grid");require("@babylonjs/core/Loading/Plugins/babylonFileLoader");require("@babylonjs/core/Loading/sceneLoader");require("@babylonjs/core/Materials");require("@babylonjs/loaders/OBJ");require("@babylonjs/loaders/STL");require("@babylonjs/loaders/glTF");const TubeUtil=require("./TubeUtil-c71e3fbe.cjs"),client=require("react-dom/client"),reactDom=require("react-dom");var commonjsGlobal=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function commonjsRequire(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var UPNG$1={exports:{}},common={},hasRequiredCommon;function requireCommon(){return hasRequiredCommon||(hasRequiredCommon=1,function(e){var t=typeof Uint8Array!="undefined"&&typeof Uint16Array!="undefined"&&typeof Int32Array!="undefined";function n(o,i){return Object.prototype.hasOwnProperty.call(o,i)}e.assign=function(o){for(var i=Array.prototype.slice.call(arguments,1);i.length;){var s=i.shift();if(s){if(typeof s!="object")throw new TypeError(s+"must be non-object");for(var l in s)n(s,l)&&(o[l]=s[l])}}return o},e.shrinkBuf=function(o,i){return o.length===i?o:o.subarray?o.subarray(0,i):(o.length=i,o)};var a={arraySet:function(o,i,s,l,c){if(i.subarray&&o.subarray){o.set(i.subarray(s,s+l),c);return}for(var f=0;f<l;f++)o[c+f]=i[s+f]},flattenChunks:function(o){var i,s,l,c,f,u;for(l=0,i=0,s=o.length;i<s;i++)l+=o[i].length;for(u=new Uint8Array(l),c=0,i=0,s=o.length;i<s;i++)f=o[i],u.set(f,c),c+=f.length;return u}},r={arraySet:function(o,i,s,l,c){for(var f=0;f<l;f++)o[c+f]=i[s+f]},flattenChunks:function(o){return[].concat.apply([],o)}};e.setTyped=function(o){o?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,a)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,r))},e.setTyped(t)}(common)),common}var deflate$1={},deflate={},trees={},hasRequiredTrees;function requireTrees(){if(hasRequiredTrees)return trees;hasRequiredTrees=1;var e=requireCommon(),t=4,n=0,a=1,r=2;function o(M){for(var oe=M.length;--oe>=0;)M[oe]=0}var i=0,s=1,l=2,c=3,f=258,u=29,d=256,h=d+1+u,m=30,R=19,v=2*h+1,g=15,x=16,y=7,E=256,k=16,b=17,C=18,_=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],A=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],N=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],S=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],I=512,O=new Array((h+2)*2);o(O);var F=new Array(m*2);o(F);var L=new Array(I);o(L);var w=new Array(f-c+1);o(w);var B=new Array(u);o(B);var D=new Array(m);o(D);function W(M,oe,le,me,z){this.static_tree=M,this.extra_bits=oe,this.extra_base=le,this.elems=me,this.max_length=z,this.has_stree=M&&M.length}var ae,ne,U;function re(M,oe){this.dyn_tree=M,this.max_code=0,this.stat_desc=oe}function te(M){return M<256?L[M]:L[256+(M>>>7)]}function K(M,oe){M.pending_buf[M.pending++]=oe&255,M.pending_buf[M.pending++]=oe>>>8&255}function Z(M,oe,le){M.bi_valid>x-le?(M.bi_buf|=oe<<M.bi_valid&65535,K(M,M.bi_buf),M.bi_buf=oe>>x-M.bi_valid,M.bi_valid+=le-x):(M.bi_buf|=oe<<M.bi_valid&65535,M.bi_valid+=le)}function de(M,oe,le){Z(M,le[oe*2],le[oe*2+1])}function ee(M,oe){var le=0;do le|=M&1,M>>>=1,le<<=1;while(--oe>0);return le>>>1}function G(M){M.bi_valid===16?(K(M,M.bi_buf),M.bi_buf=0,M.bi_valid=0):M.bi_valid>=8&&(M.pending_buf[M.pending++]=M.bi_buf&255,M.bi_buf>>=8,M.bi_valid-=8)}function ge(M,oe){var le=oe.dyn_tree,me=oe.max_code,z=oe.stat_desc.static_tree,X=oe.stat_desc.has_stree,T=oe.stat_desc.extra_bits,ie=oe.stat_desc.extra_base,xe=oe.stat_desc.max_length,p,j,q,P,$,H,ve=0;for(P=0;P<=g;P++)M.bl_count[P]=0;for(le[M.heap[M.heap_max]*2+1]=0,p=M.heap_max+1;p<v;p++)j=M.heap[p],P=le[le[j*2+1]*2+1]+1,P>xe&&(P=xe,ve++),le[j*2+1]=P,!(j>me)&&(M.bl_count[P]++,$=0,j>=ie&&($=T[j-ie]),H=le[j*2],M.opt_len+=H*(P+$),X&&(M.static_len+=H*(z[j*2+1]+$)));if(ve!==0){do{for(P=xe-1;M.bl_count[P]===0;)P--;M.bl_count[P]--,M.bl_count[P+1]+=2,M.bl_count[xe]--,ve-=2}while(ve>0);for(P=xe;P!==0;P--)for(j=M.bl_count[P];j!==0;)q=M.heap[--p],!(q>me)&&(le[q*2+1]!==P&&(M.opt_len+=(P-le[q*2+1])*le[q*2],le[q*2+1]=P),j--)}}function fe(M,oe,le){var me=new Array(g+1),z=0,X,T;for(X=1;X<=g;X++)me[X]=z=z+le[X-1]<<1;for(T=0;T<=oe;T++){var ie=M[T*2+1];ie!==0&&(M[T*2]=ee(me[ie]++,ie))}}function V(){var M,oe,le,me,z,X=new Array(g+1);for(le=0,me=0;me<u-1;me++)for(B[me]=le,M=0;M<1<<_[me];M++)w[le++]=me;for(w[le-1]=me,z=0,me=0;me<16;me++)for(D[me]=z,M=0;M<1<<A[me];M++)L[z++]=me;for(z>>=7;me<m;me++)for(D[me]=z<<7,M=0;M<1<<A[me]-7;M++)L[256+z++]=me;for(oe=0;oe<=g;oe++)X[oe]=0;for(M=0;M<=143;)O[M*2+1]=8,M++,X[8]++;for(;M<=255;)O[M*2+1]=9,M++,X[9]++;for(;M<=279;)O[M*2+1]=7,M++,X[7]++;for(;M<=287;)O[M*2+1]=8,M++,X[8]++;for(fe(O,h+1,X),M=0;M<m;M++)F[M*2+1]=5,F[M*2]=ee(M,5);ae=new W(O,_,d+1,h,g),ne=new W(F,A,0,m,g),U=new W(new Array(0),N,0,R,y)}function J(M){var oe;for(oe=0;oe<h;oe++)M.dyn_ltree[oe*2]=0;for(oe=0;oe<m;oe++)M.dyn_dtree[oe*2]=0;for(oe=0;oe<R;oe++)M.bl_tree[oe*2]=0;M.dyn_ltree[E*2]=1,M.opt_len=M.static_len=0,M.last_lit=M.matches=0}function Ce(M){M.bi_valid>8?K(M,M.bi_buf):M.bi_valid>0&&(M.pending_buf[M.pending++]=M.bi_buf),M.bi_buf=0,M.bi_valid=0}function Y(M,oe,le,me){Ce(M),me&&(K(M,le),K(M,~le)),e.arraySet(M.pending_buf,M.window,oe,le,M.pending),M.pending+=le}function se(M,oe,le,me){var z=oe*2,X=le*2;return M[z]<M[X]||M[z]===M[X]&&me[oe]<=me[le]}function ce(M,oe,le){for(var me=M.heap[le],z=le<<1;z<=M.heap_len&&(z<M.heap_len&&se(oe,M.heap[z+1],M.heap[z],M.depth)&&z++,!se(oe,me,M.heap[z],M.depth));)M.heap[le]=M.heap[z],le=z,z<<=1;M.heap[le]=me}function Q(M,oe,le){var me,z,X=0,T,ie;if(M.last_lit!==0)do me=M.pending_buf[M.d_buf+X*2]<<8|M.pending_buf[M.d_buf+X*2+1],z=M.pending_buf[M.l_buf+X],X++,me===0?de(M,z,oe):(T=w[z],de(M,T+d+1,oe),ie=_[T],ie!==0&&(z-=B[T],Z(M,z,ie)),me--,T=te(me),de(M,T,le),ie=A[T],ie!==0&&(me-=D[T],Z(M,me,ie)));while(X<M.last_lit);de(M,E,oe)}function ye(M,oe){var le=oe.dyn_tree,me=oe.stat_desc.static_tree,z=oe.stat_desc.has_stree,X=oe.stat_desc.elems,T,ie,xe=-1,p;for(M.heap_len=0,M.heap_max=v,T=0;T<X;T++)le[T*2]!==0?(M.heap[++M.heap_len]=xe=T,M.depth[T]=0):le[T*2+1]=0;for(;M.heap_len<2;)p=M.heap[++M.heap_len]=xe<2?++xe:0,le[p*2]=1,M.depth[p]=0,M.opt_len--,z&&(M.static_len-=me[p*2+1]);for(oe.max_code=xe,T=M.heap_len>>1;T>=1;T--)ce(M,le,T);p=X;do T=M.heap[1],M.heap[1]=M.heap[M.heap_len--],ce(M,le,1),ie=M.heap[1],M.heap[--M.heap_max]=T,M.heap[--M.heap_max]=ie,le[p*2]=le[T*2]+le[ie*2],M.depth[p]=(M.depth[T]>=M.depth[ie]?M.depth[T]:M.depth[ie])+1,le[T*2+1]=le[ie*2+1]=p,M.heap[1]=p++,ce(M,le,1);while(M.heap_len>=2);M.heap[--M.heap_max]=M.heap[1],ge(M,oe),fe(le,xe,M.bl_count)}function Re(M,oe,le){var me,z=-1,X,T=oe[0*2+1],ie=0,xe=7,p=4;for(T===0&&(xe=138,p=3),oe[(le+1)*2+1]=65535,me=0;me<=le;me++)X=T,T=oe[(me+1)*2+1],!(++ie<xe&&X===T)&&(ie<p?M.bl_tree[X*2]+=ie:X!==0?(X!==z&&M.bl_tree[X*2]++,M.bl_tree[k*2]++):ie<=10?M.bl_tree[b*2]++:M.bl_tree[C*2]++,ie=0,z=X,T===0?(xe=138,p=3):X===T?(xe=6,p=3):(xe=7,p=4))}function Te(M,oe,le){var me,z=-1,X,T=oe[0*2+1],ie=0,xe=7,p=4;for(T===0&&(xe=138,p=3),me=0;me<=le;me++)if(X=T,T=oe[(me+1)*2+1],!(++ie<xe&&X===T)){if(ie<p)do de(M,X,M.bl_tree);while(--ie!==0);else X!==0?(X!==z&&(de(M,X,M.bl_tree),ie--),de(M,k,M.bl_tree),Z(M,ie-3,2)):ie<=10?(de(M,b,M.bl_tree),Z(M,ie-3,3)):(de(M,C,M.bl_tree),Z(M,ie-11,7));ie=0,z=X,T===0?(xe=138,p=3):X===T?(xe=6,p=3):(xe=7,p=4)}}function Ee(M){var oe;for(Re(M,M.dyn_ltree,M.l_desc.max_code),Re(M,M.dyn_dtree,M.d_desc.max_code),ye(M,M.bl_desc),oe=R-1;oe>=3&&M.bl_tree[S[oe]*2+1]===0;oe--);return M.opt_len+=3*(oe+1)+5+5+4,oe}function _e(M,oe,le,me){var z;for(Z(M,oe-257,5),Z(M,le-1,5),Z(M,me-4,4),z=0;z<me;z++)Z(M,M.bl_tree[S[z]*2+1],3);Te(M,M.dyn_ltree,oe-1),Te(M,M.dyn_dtree,le-1)}function Se(M){var oe=4093624447,le;for(le=0;le<=31;le++,oe>>>=1)if(oe&1&&M.dyn_ltree[le*2]!==0)return n;if(M.dyn_ltree[9*2]!==0||M.dyn_ltree[10*2]!==0||M.dyn_ltree[13*2]!==0)return a;for(le=32;le<d;le++)if(M.dyn_ltree[le*2]!==0)return a;return n}var Ne=!1;function Ae(M){Ne||(V(),Ne=!0),M.l_desc=new re(M.dyn_ltree,ae),M.d_desc=new re(M.dyn_dtree,ne),M.bl_desc=new re(M.bl_tree,U),M.bi_buf=0,M.bi_valid=0,J(M)}function Me(M,oe,le,me){Z(M,(i<<1)+(me?1:0),3),Y(M,oe,le,!0)}function be(M){Z(M,s<<1,3),de(M,E,O),G(M)}function Ie(M,oe,le,me){var z,X,T=0;M.level>0?(M.strm.data_type===r&&(M.strm.data_type=Se(M)),ye(M,M.l_desc),ye(M,M.d_desc),T=Ee(M),z=M.opt_len+3+7>>>3,X=M.static_len+3+7>>>3,X<=z&&(z=X)):z=X=le+5,le+4<=z&&oe!==-1?Me(M,oe,le,me):M.strategy===t||X===z?(Z(M,(s<<1)+(me?1:0),3),Q(M,O,F)):(Z(M,(l<<1)+(me?1:0),3),_e(M,M.l_desc.max_code+1,M.d_desc.max_code+1,T+1),Q(M,M.dyn_ltree,M.dyn_dtree)),J(M),me&&Ce(M)}function $e(M,oe,le){return M.pending_buf[M.d_buf+M.last_lit*2]=oe>>>8&255,M.pending_buf[M.d_buf+M.last_lit*2+1]=oe&255,M.pending_buf[M.l_buf+M.last_lit]=le&255,M.last_lit++,oe===0?M.dyn_ltree[le*2]++:(M.matches++,oe--,M.dyn_ltree[(w[le]+d+1)*2]++,M.dyn_dtree[te(oe)*2]++),M.last_lit===M.lit_bufsize-1}return trees._tr_init=Ae,trees._tr_stored_block=Me,trees._tr_flush_block=Ie,trees._tr_tally=$e,trees._tr_align=be,trees}var adler32_1,hasRequiredAdler32;function requireAdler32(){if(hasRequiredAdler32)return adler32_1;hasRequiredAdler32=1;function e(t,n,a,r){for(var o=t&65535|0,i=t>>>16&65535|0,s=0;a!==0;){s=a>2e3?2e3:a,a-=s;do o=o+n[r++]|0,i=i+o|0;while(--s);o%=65521,i%=65521}return o|i<<16|0}return adler32_1=e,adler32_1}var crc32_1,hasRequiredCrc32;function requireCrc32(){if(hasRequiredCrc32)return crc32_1;hasRequiredCrc32=1;function e(){for(var a,r=[],o=0;o<256;o++){a=o;for(var i=0;i<8;i++)a=a&1?3988292384^a>>>1:a>>>1;r[o]=a}return r}var t=e();function n(a,r,o,i){var s=t,l=i+o;a^=-1;for(var c=i;c<l;c++)a=a>>>8^s[(a^r[c])&255];return a^-1}return crc32_1=n,crc32_1}var messages,hasRequiredMessages;function requireMessages(){return hasRequiredMessages||(hasRequiredMessages=1,messages={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}),messages}var hasRequiredDeflate$1;function requireDeflate$1(){if(hasRequiredDeflate$1)return deflate;hasRequiredDeflate$1=1;var e=requireCommon(),t=requireTrees(),n=requireAdler32(),a=requireCrc32(),r=requireMessages(),o=0,i=1,s=3,l=4,c=5,f=0,u=1,d=-2,h=-3,m=-5,R=-1,v=1,g=2,x=3,y=4,E=0,k=2,b=8,C=9,_=15,A=8,N=29,S=256,I=S+1+N,O=30,F=19,L=2*I+1,w=15,B=3,D=258,W=D+B+1,ae=32,ne=42,U=69,re=73,te=91,K=103,Z=113,de=666,ee=1,G=2,ge=3,fe=4,V=3;function J(p,j){return p.msg=r[j],j}function Ce(p){return(p<<1)-(p>4?9:0)}function Y(p){for(var j=p.length;--j>=0;)p[j]=0}function se(p){var j=p.state,q=j.pending;q>p.avail_out&&(q=p.avail_out),q!==0&&(e.arraySet(p.output,j.pending_buf,j.pending_out,q,p.next_out),p.next_out+=q,j.pending_out+=q,p.total_out+=q,p.avail_out-=q,j.pending-=q,j.pending===0&&(j.pending_out=0))}function ce(p,j){t._tr_flush_block(p,p.block_start>=0?p.block_start:-1,p.strstart-p.block_start,j),p.block_start=p.strstart,se(p.strm)}function Q(p,j){p.pending_buf[p.pending++]=j}function ye(p,j){p.pending_buf[p.pending++]=j>>>8&255,p.pending_buf[p.pending++]=j&255}function Re(p,j,q,P){var $=p.avail_in;return $>P&&($=P),$===0?0:(p.avail_in-=$,e.arraySet(j,p.input,p.next_in,$,q),p.state.wrap===1?p.adler=n(p.adler,j,$,q):p.state.wrap===2&&(p.adler=a(p.adler,j,$,q)),p.next_in+=$,p.total_in+=$,$)}function Te(p,j){var q=p.max_chain_length,P=p.strstart,$,H,ve=p.prev_length,pe=p.nice_match,he=p.strstart>p.w_size-W?p.strstart-(p.w_size-W):0,Pe=p.window,Ue=p.w_mask,Oe=p.prev,ke=p.strstart+D,Le=Pe[P+ve-1],De=Pe[P+ve];p.prev_length>=p.good_match&&(q>>=2),pe>p.lookahead&&(pe=p.lookahead);do if($=j,!(Pe[$+ve]!==De||Pe[$+ve-1]!==Le||Pe[$]!==Pe[P]||Pe[++$]!==Pe[P+1])){P+=2,$++;do;while(Pe[++P]===Pe[++$]&&Pe[++P]===Pe[++$]&&Pe[++P]===Pe[++$]&&Pe[++P]===Pe[++$]&&Pe[++P]===Pe[++$]&&Pe[++P]===Pe[++$]&&Pe[++P]===Pe[++$]&&Pe[++P]===Pe[++$]&&P<ke);if(H=D-(ke-P),P=ke-D,H>ve){if(p.match_start=j,ve=H,H>=pe)break;Le=Pe[P+ve-1],De=Pe[P+ve]}}while((j=Oe[j&Ue])>he&&--q!==0);return ve<=p.lookahead?ve:p.lookahead}function Ee(p){var j=p.w_size,q,P,$,H,ve;do{if(H=p.window_size-p.lookahead-p.strstart,p.strstart>=j+(j-W)){e.arraySet(p.window,p.window,j,j,0),p.match_start-=j,p.strstart-=j,p.block_start-=j,P=p.hash_size,q=P;do $=p.head[--q],p.head[q]=$>=j?$-j:0;while(--P);P=j,q=P;do $=p.prev[--q],p.prev[q]=$>=j?$-j:0;while(--P);H+=j}if(p.strm.avail_in===0)break;if(P=Re(p.strm,p.window,p.strstart+p.lookahead,H),p.lookahead+=P,p.lookahead+p.insert>=B)for(ve=p.strstart-p.insert,p.ins_h=p.window[ve],p.ins_h=(p.ins_h<<p.hash_shift^p.window[ve+1])&p.hash_mask;p.insert&&(p.ins_h=(p.ins_h<<p.hash_shift^p.window[ve+B-1])&p.hash_mask,p.prev[ve&p.w_mask]=p.head[p.ins_h],p.head[p.ins_h]=ve,ve++,p.insert--,!(p.lookahead+p.insert<B)););}while(p.lookahead<W&&p.strm.avail_in!==0)}function _e(p,j){var q=65535;for(q>p.pending_buf_size-5&&(q=p.pending_buf_size-5);;){if(p.lookahead<=1){if(Ee(p),p.lookahead===0&&j===o)return ee;if(p.lookahead===0)break}p.strstart+=p.lookahead,p.lookahead=0;var P=p.block_start+q;if((p.strstart===0||p.strstart>=P)&&(p.lookahead=p.strstart-P,p.strstart=P,ce(p,!1),p.strm.avail_out===0)||p.strstart-p.block_start>=p.w_size-W&&(ce(p,!1),p.strm.avail_out===0))return ee}return p.insert=0,j===l?(ce(p,!0),p.strm.avail_out===0?ge:fe):(p.strstart>p.block_start&&(ce(p,!1),p.strm.avail_out===0),ee)}function Se(p,j){for(var q,P;;){if(p.lookahead<W){if(Ee(p),p.lookahead<W&&j===o)return ee;if(p.lookahead===0)break}if(q=0,p.lookahead>=B&&(p.ins_h=(p.ins_h<<p.hash_shift^p.window[p.strstart+B-1])&p.hash_mask,q=p.prev[p.strstart&p.w_mask]=p.head[p.ins_h],p.head[p.ins_h]=p.strstart),q!==0&&p.strstart-q<=p.w_size-W&&(p.match_length=Te(p,q)),p.match_length>=B)if(P=t._tr_tally(p,p.strstart-p.match_start,p.match_length-B),p.lookahead-=p.match_length,p.match_length<=p.max_lazy_match&&p.lookahead>=B){p.match_length--;do p.strstart++,p.ins_h=(p.ins_h<<p.hash_shift^p.window[p.strstart+B-1])&p.hash_mask,q=p.prev[p.strstart&p.w_mask]=p.head[p.ins_h],p.head[p.ins_h]=p.strstart;while(--p.match_length!==0);p.strstart++}else p.strstart+=p.match_length,p.match_length=0,p.ins_h=p.window[p.strstart],p.ins_h=(p.ins_h<<p.hash_shift^p.window[p.strstart+1])&p.hash_mask;else P=t._tr_tally(p,0,p.window[p.strstart]),p.lookahead--,p.strstart++;if(P&&(ce(p,!1),p.strm.avail_out===0))return ee}return p.insert=p.strstart<B-1?p.strstart:B-1,j===l?(ce(p,!0),p.strm.avail_out===0?ge:fe):p.last_lit&&(ce(p,!1),p.strm.avail_out===0)?ee:G}function Ne(p,j){for(var q,P,$;;){if(p.lookahead<W){if(Ee(p),p.lookahead<W&&j===o)return ee;if(p.lookahead===0)break}if(q=0,p.lookahead>=B&&(p.ins_h=(p.ins_h<<p.hash_shift^p.window[p.strstart+B-1])&p.hash_mask,q=p.prev[p.strstart&p.w_mask]=p.head[p.ins_h],p.head[p.ins_h]=p.strstart),p.prev_length=p.match_length,p.prev_match=p.match_start,p.match_length=B-1,q!==0&&p.prev_length<p.max_lazy_match&&p.strstart-q<=p.w_size-W&&(p.match_length=Te(p,q),p.match_length<=5&&(p.strategy===v||p.match_length===B&&p.strstart-p.match_start>4096)&&(p.match_length=B-1)),p.prev_length>=B&&p.match_length<=p.prev_length){$=p.strstart+p.lookahead-B,P=t._tr_tally(p,p.strstart-1-p.prev_match,p.prev_length-B),p.lookahead-=p.prev_length-1,p.prev_length-=2;do++p.strstart<=$&&(p.ins_h=(p.ins_h<<p.hash_shift^p.window[p.strstart+B-1])&p.hash_mask,q=p.prev[p.strstart&p.w_mask]=p.head[p.ins_h],p.head[p.ins_h]=p.strstart);while(--p.prev_length!==0);if(p.match_available=0,p.match_length=B-1,p.strstart++,P&&(ce(p,!1),p.strm.avail_out===0))return ee}else if(p.match_available){if(P=t._tr_tally(p,0,p.window[p.strstart-1]),P&&ce(p,!1),p.strstart++,p.lookahead--,p.strm.avail_out===0)return ee}else p.match_available=1,p.strstart++,p.lookahead--}return p.match_available&&(P=t._tr_tally(p,0,p.window[p.strstart-1]),p.match_available=0),p.insert=p.strstart<B-1?p.strstart:B-1,j===l?(ce(p,!0),p.strm.avail_out===0?ge:fe):p.last_lit&&(ce(p,!1),p.strm.avail_out===0)?ee:G}function Ae(p,j){for(var q,P,$,H,ve=p.window;;){if(p.lookahead<=D){if(Ee(p),p.lookahead<=D&&j===o)return ee;if(p.lookahead===0)break}if(p.match_length=0,p.lookahead>=B&&p.strstart>0&&($=p.strstart-1,P=ve[$],P===ve[++$]&&P===ve[++$]&&P===ve[++$])){H=p.strstart+D;do;while(P===ve[++$]&&P===ve[++$]&&P===ve[++$]&&P===ve[++$]&&P===ve[++$]&&P===ve[++$]&&P===ve[++$]&&P===ve[++$]&&$<H);p.match_length=D-(H-$),p.match_length>p.lookahead&&(p.match_length=p.lookahead)}if(p.match_length>=B?(q=t._tr_tally(p,1,p.match_length-B),p.lookahead-=p.match_length,p.strstart+=p.match_length,p.match_length=0):(q=t._tr_tally(p,0,p.window[p.strstart]),p.lookahead--,p.strstart++),q&&(ce(p,!1),p.strm.avail_out===0))return ee}return p.insert=0,j===l?(ce(p,!0),p.strm.avail_out===0?ge:fe):p.last_lit&&(ce(p,!1),p.strm.avail_out===0)?ee:G}function Me(p,j){for(var q;;){if(p.lookahead===0&&(Ee(p),p.lookahead===0)){if(j===o)return ee;break}if(p.match_length=0,q=t._tr_tally(p,0,p.window[p.strstart]),p.lookahead--,p.strstart++,q&&(ce(p,!1),p.strm.avail_out===0))return ee}return p.insert=0,j===l?(ce(p,!0),p.strm.avail_out===0?ge:fe):p.last_lit&&(ce(p,!1),p.strm.avail_out===0)?ee:G}function be(p,j,q,P,$){this.good_length=p,this.max_lazy=j,this.nice_length=q,this.max_chain=P,this.func=$}var Ie;Ie=[new be(0,0,0,0,_e),new be(4,4,8,4,Se),new be(4,5,16,8,Se),new be(4,6,32,32,Se),new be(4,4,16,16,Ne),new be(8,16,32,32,Ne),new be(8,16,128,128,Ne),new be(8,32,128,256,Ne),new be(32,128,258,1024,Ne),new be(32,258,258,4096,Ne)];function $e(p){p.window_size=2*p.w_size,Y(p.head),p.max_lazy_match=Ie[p.level].max_lazy,p.good_match=Ie[p.level].good_length,p.nice_match=Ie[p.level].nice_length,p.max_chain_length=Ie[p.level].max_chain,p.strstart=0,p.block_start=0,p.lookahead=0,p.insert=0,p.match_length=p.prev_length=B-1,p.match_available=0,p.ins_h=0}function M(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=b,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new e.Buf16(L*2),this.dyn_dtree=new e.Buf16((2*O+1)*2),this.bl_tree=new e.Buf16((2*F+1)*2),Y(this.dyn_ltree),Y(this.dyn_dtree),Y(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new e.Buf16(w+1),this.heap=new e.Buf16(2*I+1),Y(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new e.Buf16(2*I+1),Y(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function oe(p){var j;return!p||!p.state?J(p,d):(p.total_in=p.total_out=0,p.data_type=k,j=p.state,j.pending=0,j.pending_out=0,j.wrap<0&&(j.wrap=-j.wrap),j.status=j.wrap?ne:Z,p.adler=j.wrap===2?0:1,j.last_flush=o,t._tr_init(j),f)}function le(p){var j=oe(p);return j===f&&$e(p.state),j}function me(p,j){return!p||!p.state||p.state.wrap!==2?d:(p.state.gzhead=j,f)}function z(p,j,q,P,$,H){if(!p)return d;var ve=1;if(j===R&&(j=6),P<0?(ve=0,P=-P):P>15&&(ve=2,P-=16),$<1||$>C||q!==b||P<8||P>15||j<0||j>9||H<0||H>y)return J(p,d);P===8&&(P=9);var pe=new M;return p.state=pe,pe.strm=p,pe.wrap=ve,pe.gzhead=null,pe.w_bits=P,pe.w_size=1<<pe.w_bits,pe.w_mask=pe.w_size-1,pe.hash_bits=$+7,pe.hash_size=1<<pe.hash_bits,pe.hash_mask=pe.hash_size-1,pe.hash_shift=~~((pe.hash_bits+B-1)/B),pe.window=new e.Buf8(pe.w_size*2),pe.head=new e.Buf16(pe.hash_size),pe.prev=new e.Buf16(pe.w_size),pe.lit_bufsize=1<<$+6,pe.pending_buf_size=pe.lit_bufsize*4,pe.pending_buf=new e.Buf8(pe.pending_buf_size),pe.d_buf=1*pe.lit_bufsize,pe.l_buf=(1+2)*pe.lit_bufsize,pe.level=j,pe.strategy=H,pe.method=q,le(p)}function X(p,j){return z(p,j,b,_,A,E)}function T(p,j){var q,P,$,H;if(!p||!p.state||j>c||j<0)return p?J(p,d):d;if(P=p.state,!p.output||!p.input&&p.avail_in!==0||P.status===de&&j!==l)return J(p,p.avail_out===0?m:d);if(P.strm=p,q=P.last_flush,P.last_flush=j,P.status===ne)if(P.wrap===2)p.adler=0,Q(P,31),Q(P,139),Q(P,8),P.gzhead?(Q(P,(P.gzhead.text?1:0)+(P.gzhead.hcrc?2:0)+(P.gzhead.extra?4:0)+(P.gzhead.name?8:0)+(P.gzhead.comment?16:0)),Q(P,P.gzhead.time&255),Q(P,P.gzhead.time>>8&255),Q(P,P.gzhead.time>>16&255),Q(P,P.gzhead.time>>24&255),Q(P,P.level===9?2:P.strategy>=g||P.level<2?4:0),Q(P,P.gzhead.os&255),P.gzhead.extra&&P.gzhead.extra.length&&(Q(P,P.gzhead.extra.length&255),Q(P,P.gzhead.extra.length>>8&255)),P.gzhead.hcrc&&(p.adler=a(p.adler,P.pending_buf,P.pending,0)),P.gzindex=0,P.status=U):(Q(P,0),Q(P,0),Q(P,0),Q(P,0),Q(P,0),Q(P,P.level===9?2:P.strategy>=g||P.level<2?4:0),Q(P,V),P.status=Z);else{var ve=b+(P.w_bits-8<<4)<<8,pe=-1;P.strategy>=g||P.level<2?pe=0:P.level<6?pe=1:P.level===6?pe=2:pe=3,ve|=pe<<6,P.strstart!==0&&(ve|=ae),ve+=31-ve%31,P.status=Z,ye(P,ve),P.strstart!==0&&(ye(P,p.adler>>>16),ye(P,p.adler&65535)),p.adler=1}if(P.status===U)if(P.gzhead.extra){for($=P.pending;P.gzindex<(P.gzhead.extra.length&65535)&&!(P.pending===P.pending_buf_size&&(P.gzhead.hcrc&&P.pending>$&&(p.adler=a(p.adler,P.pending_buf,P.pending-$,$)),se(p),$=P.pending,P.pending===P.pending_buf_size));)Q(P,P.gzhead.extra[P.gzindex]&255),P.gzindex++;P.gzhead.hcrc&&P.pending>$&&(p.adler=a(p.adler,P.pending_buf,P.pending-$,$)),P.gzindex===P.gzhead.extra.length&&(P.gzindex=0,P.status=re)}else P.status=re;if(P.status===re)if(P.gzhead.name){$=P.pending;do{if(P.pending===P.pending_buf_size&&(P.gzhead.hcrc&&P.pending>$&&(p.adler=a(p.adler,P.pending_buf,P.pending-$,$)),se(p),$=P.pending,P.pending===P.pending_buf_size)){H=1;break}P.gzindex<P.gzhead.name.length?H=P.gzhead.name.charCodeAt(P.gzindex++)&255:H=0,Q(P,H)}while(H!==0);P.gzhead.hcrc&&P.pending>$&&(p.adler=a(p.adler,P.pending_buf,P.pending-$,$)),H===0&&(P.gzindex=0,P.status=te)}else P.status=te;if(P.status===te)if(P.gzhead.comment){$=P.pending;do{if(P.pending===P.pending_buf_size&&(P.gzhead.hcrc&&P.pending>$&&(p.adler=a(p.adler,P.pending_buf,P.pending-$,$)),se(p),$=P.pending,P.pending===P.pending_buf_size)){H=1;break}P.gzindex<P.gzhead.comment.length?H=P.gzhead.comment.charCodeAt(P.gzindex++)&255:H=0,Q(P,H)}while(H!==0);P.gzhead.hcrc&&P.pending>$&&(p.adler=a(p.adler,P.pending_buf,P.pending-$,$)),H===0&&(P.status=K)}else P.status=K;if(P.status===K&&(P.gzhead.hcrc?(P.pending+2>P.pending_buf_size&&se(p),P.pending+2<=P.pending_buf_size&&(Q(P,p.adler&255),Q(P,p.adler>>8&255),p.adler=0,P.status=Z)):P.status=Z),P.pending!==0){if(se(p),p.avail_out===0)return P.last_flush=-1,f}else if(p.avail_in===0&&Ce(j)<=Ce(q)&&j!==l)return J(p,m);if(P.status===de&&p.avail_in!==0)return J(p,m);if(p.avail_in!==0||P.lookahead!==0||j!==o&&P.status!==de){var he=P.strategy===g?Me(P,j):P.strategy===x?Ae(P,j):Ie[P.level].func(P,j);if((he===ge||he===fe)&&(P.status=de),he===ee||he===ge)return p.avail_out===0&&(P.last_flush=-1),f;if(he===G&&(j===i?t._tr_align(P):j!==c&&(t._tr_stored_block(P,0,0,!1),j===s&&(Y(P.head),P.lookahead===0&&(P.strstart=0,P.block_start=0,P.insert=0))),se(p),p.avail_out===0))return P.last_flush=-1,f}return j!==l?f:P.wrap<=0?u:(P.wrap===2?(Q(P,p.adler&255),Q(P,p.adler>>8&255),Q(P,p.adler>>16&255),Q(P,p.adler>>24&255),Q(P,p.total_in&255),Q(P,p.total_in>>8&255),Q(P,p.total_in>>16&255),Q(P,p.total_in>>24&255)):(ye(P,p.adler>>>16),ye(P,p.adler&65535)),se(p),P.wrap>0&&(P.wrap=-P.wrap),P.pending!==0?f:u)}function ie(p){var j;return!p||!p.state?d:(j=p.state.status,j!==ne&&j!==U&&j!==re&&j!==te&&j!==K&&j!==Z&&j!==de?J(p,d):(p.state=null,j===Z?J(p,h):f))}function xe(p,j){var q=j.length,P,$,H,ve,pe,he,Pe,Ue;if(!p||!p.state||(P=p.state,ve=P.wrap,ve===2||ve===1&&P.status!==ne||P.lookahead))return d;for(ve===1&&(p.adler=n(p.adler,j,q,0)),P.wrap=0,q>=P.w_size&&(ve===0&&(Y(P.head),P.strstart=0,P.block_start=0,P.insert=0),Ue=new e.Buf8(P.w_size),e.arraySet(Ue,j,q-P.w_size,P.w_size,0),j=Ue,q=P.w_size),pe=p.avail_in,he=p.next_in,Pe=p.input,p.avail_in=q,p.next_in=0,p.input=j,Ee(P);P.lookahead>=B;){$=P.strstart,H=P.lookahead-(B-1);do P.ins_h=(P.ins_h<<P.hash_shift^P.window[$+B-1])&P.hash_mask,P.prev[$&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=$,$++;while(--H);P.strstart=$,P.lookahead=B-1,Ee(P)}return P.strstart+=P.lookahead,P.block_start=P.strstart,P.insert=P.lookahead,P.lookahead=0,P.match_length=P.prev_length=B-1,P.match_available=0,p.next_in=he,p.input=Pe,p.avail_in=pe,P.wrap=ve,f}return deflate.deflateInit=X,deflate.deflateInit2=z,deflate.deflateReset=le,deflate.deflateResetKeep=oe,deflate.deflateSetHeader=me,deflate.deflate=T,deflate.deflateEnd=ie,deflate.deflateSetDictionary=xe,deflate.deflateInfo="pako deflate (from Nodeca project)",deflate}var strings={},hasRequiredStrings;function requireStrings(){if(hasRequiredStrings)return strings;hasRequiredStrings=1;var e=requireCommon(),t=!0,n=!0;try{String.fromCharCode.apply(null,[0])}catch(i){t=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(i){n=!1}for(var a=new e.Buf8(256),r=0;r<256;r++)a[r]=r>=252?6:r>=248?5:r>=240?4:r>=224?3:r>=192?2:1;a[254]=a[254]=1,strings.string2buf=function(i){var s,l,c,f,u,d=i.length,h=0;for(f=0;f<d;f++)l=i.charCodeAt(f),(l&64512)===55296&&f+1<d&&(c=i.charCodeAt(f+1),(c&64512)===56320&&(l=65536+(l-55296<<10)+(c-56320),f++)),h+=l<128?1:l<2048?2:l<65536?3:4;for(s=new e.Buf8(h),u=0,f=0;u<h;f++)l=i.charCodeAt(f),(l&64512)===55296&&f+1<d&&(c=i.charCodeAt(f+1),(c&64512)===56320&&(l=65536+(l-55296<<10)+(c-56320),f++)),l<128?s[u++]=l:l<2048?(s[u++]=192|l>>>6,s[u++]=128|l&63):l<65536?(s[u++]=224|l>>>12,s[u++]=128|l>>>6&63,s[u++]=128|l&63):(s[u++]=240|l>>>18,s[u++]=128|l>>>12&63,s[u++]=128|l>>>6&63,s[u++]=128|l&63);return s};function o(i,s){if(s<65534&&(i.subarray&&n||!i.subarray&&t))return String.fromCharCode.apply(null,e.shrinkBuf(i,s));for(var l="",c=0;c<s;c++)l+=String.fromCharCode(i[c]);return l}return strings.buf2binstring=function(i){return o(i,i.length)},strings.binstring2buf=function(i){for(var s=new e.Buf8(i.length),l=0,c=s.length;l<c;l++)s[l]=i.charCodeAt(l);return s},strings.buf2string=function(i,s){var l,c,f,u,d=s||i.length,h=new Array(d*2);for(c=0,l=0;l<d;){if(f=i[l++],f<128){h[c++]=f;continue}if(u=a[f],u>4){h[c++]=65533,l+=u-1;continue}for(f&=u===2?31:u===3?15:7;u>1&&l<d;)f=f<<6|i[l++]&63,u--;if(u>1){h[c++]=65533;continue}f<65536?h[c++]=f:(f-=65536,h[c++]=55296|f>>10&1023,h[c++]=56320|f&1023)}return o(h,c)},strings.utf8border=function(i,s){var l;for(s=s||i.length,s>i.length&&(s=i.length),l=s-1;l>=0&&(i[l]&192)===128;)l--;return l<0||l===0?s:l+a[i[l]]>s?l:s},strings}var zstream,hasRequiredZstream;function requireZstream(){if(hasRequiredZstream)return zstream;hasRequiredZstream=1;function e(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}return zstream=e,zstream}var hasRequiredDeflate;function requireDeflate(){if(hasRequiredDeflate)return deflate$1;hasRequiredDeflate=1;var e=requireDeflate$1(),t=requireCommon(),n=requireStrings(),a=requireMessages(),r=requireZstream(),o=Object.prototype.toString,i=0,s=4,l=0,c=1,f=2,u=-1,d=0,h=8;function m(x){if(!(this instanceof m))return new m(x);this.options=t.assign({level:u,method:h,chunkSize:16384,windowBits:15,memLevel:8,strategy:d,to:""},x||{});var y=this.options;y.raw&&y.windowBits>0?y.windowBits=-y.windowBits:y.gzip&&y.windowBits>0&&y.windowBits<16&&(y.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new r,this.strm.avail_out=0;var E=e.deflateInit2(this.strm,y.level,y.method,y.windowBits,y.memLevel,y.strategy);if(E!==l)throw new Error(a[E]);if(y.header&&e.deflateSetHeader(this.strm,y.header),y.dictionary){var k;if(typeof y.dictionary=="string"?k=n.string2buf(y.dictionary):o.call(y.dictionary)==="[object ArrayBuffer]"?k=new Uint8Array(y.dictionary):k=y.dictionary,E=e.deflateSetDictionary(this.strm,k),E!==l)throw new Error(a[E]);this._dict_set=!0}}m.prototype.push=function(x,y){var E=this.strm,k=this.options.chunkSize,b,C;if(this.ended)return!1;C=y===~~y?y:y===!0?s:i,typeof x=="string"?E.input=n.string2buf(x):o.call(x)==="[object ArrayBuffer]"?E.input=new Uint8Array(x):E.input=x,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new t.Buf8(k),E.next_out=0,E.avail_out=k),b=e.deflate(E,C),b!==c&&b!==l)return this.onEnd(b),this.ended=!0,!1;(E.avail_out===0||E.avail_in===0&&(C===s||C===f))&&(this.options.to==="string"?this.onData(n.buf2binstring(t.shrinkBuf(E.output,E.next_out))):this.onData(t.shrinkBuf(E.output,E.next_out)))}while((E.avail_in>0||E.avail_out===0)&&b!==c);return C===s?(b=e.deflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===l):(C===f&&(this.onEnd(l),E.avail_out=0),!0)},m.prototype.onData=function(x){this.chunks.push(x)},m.prototype.onEnd=function(x){x===l&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=t.flattenChunks(this.chunks)),this.chunks=[],this.err=x,this.msg=this.strm.msg};function R(x,y){var E=new m(y);if(E.push(x,!0),E.err)throw E.msg||a[E.err];return E.result}function v(x,y){return y=y||{},y.raw=!0,R(x,y)}function g(x,y){return y=y||{},y.gzip=!0,R(x,y)}return deflate$1.Deflate=m,deflate$1.deflate=R,deflate$1.deflateRaw=v,deflate$1.gzip=g,deflate$1}var inflate$1={},inflate={},inffast,hasRequiredInffast;function requireInffast(){if(hasRequiredInffast)return inffast;hasRequiredInffast=1;var e=30,t=12;return inffast=function(a,r){var o,i,s,l,c,f,u,d,h,m,R,v,g,x,y,E,k,b,C,_,A,N,S,I,O;o=a.state,i=a.next_in,I=a.input,s=i+(a.avail_in-5),l=a.next_out,O=a.output,c=l-(r-a.avail_out),f=l+(a.avail_out-257),u=o.dmax,d=o.wsize,h=o.whave,m=o.wnext,R=o.window,v=o.hold,g=o.bits,x=o.lencode,y=o.distcode,E=(1<<o.lenbits)-1,k=(1<<o.distbits)-1;e:do{g<15&&(v+=I[i++]<<g,g+=8,v+=I[i++]<<g,g+=8),b=x[v&E];t:for(;;){if(C=b>>>24,v>>>=C,g-=C,C=b>>>16&255,C===0)O[l++]=b&65535;else if(C&16){_=b&65535,C&=15,C&&(g<C&&(v+=I[i++]<<g,g+=8),_+=v&(1<<C)-1,v>>>=C,g-=C),g<15&&(v+=I[i++]<<g,g+=8,v+=I[i++]<<g,g+=8),b=y[v&k];n:for(;;){if(C=b>>>24,v>>>=C,g-=C,C=b>>>16&255,C&16){if(A=b&65535,C&=15,g<C&&(v+=I[i++]<<g,g+=8,g<C&&(v+=I[i++]<<g,g+=8)),A+=v&(1<<C)-1,A>u){a.msg="invalid distance too far back",o.mode=e;break e}if(v>>>=C,g-=C,C=l-c,A>C){if(C=A-C,C>h&&o.sane){a.msg="invalid distance too far back",o.mode=e;break e}if(N=0,S=R,m===0){if(N+=d-C,C<_){_-=C;do O[l++]=R[N++];while(--C);N=l-A,S=O}}else if(m<C){if(N+=d+m-C,C-=m,C<_){_-=C;do O[l++]=R[N++];while(--C);if(N=0,m<_){C=m,_-=C;do O[l++]=R[N++];while(--C);N=l-A,S=O}}}else if(N+=m-C,C<_){_-=C;do O[l++]=R[N++];while(--C);N=l-A,S=O}for(;_>2;)O[l++]=S[N++],O[l++]=S[N++],O[l++]=S[N++],_-=3;_&&(O[l++]=S[N++],_>1&&(O[l++]=S[N++]))}else{N=l-A;do O[l++]=O[N++],O[l++]=O[N++],O[l++]=O[N++],_-=3;while(_>2);_&&(O[l++]=O[N++],_>1&&(O[l++]=O[N++]))}}else if(C&64){a.msg="invalid distance code",o.mode=e;break e}else{b=y[(b&65535)+(v&(1<<C)-1)];continue n}break}}else if(C&64)if(C&32){o.mode=t;break e}else{a.msg="invalid literal/length code",o.mode=e;break e}else{b=x[(b&65535)+(v&(1<<C)-1)];continue t}break}}while(i<s&&l<f);_=g>>3,i-=_,g-=_<<3,v&=(1<<g)-1,a.next_in=i,a.next_out=l,a.avail_in=i<s?5+(s-i):5-(i-s),a.avail_out=l<f?257+(f-l):257-(l-f),o.hold=v,o.bits=g},inffast}var inftrees,hasRequiredInftrees;function requireInftrees(){if(hasRequiredInftrees)return inftrees;hasRequiredInftrees=1;var e=requireCommon(),t=15,n=852,a=592,r=0,o=1,i=2,s=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],f=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];return inftrees=function(d,h,m,R,v,g,x,y){var E=y.bits,k=0,b=0,C=0,_=0,A=0,N=0,S=0,I=0,O=0,F=0,L,w,B,D,W,ae=null,ne=0,U,re=new e.Buf16(t+1),te=new e.Buf16(t+1),K=null,Z=0,de,ee,G;for(k=0;k<=t;k++)re[k]=0;for(b=0;b<R;b++)re[h[m+b]]++;for(A=E,_=t;_>=1&&re[_]===0;_--);if(A>_&&(A=_),_===0)return v[g++]=1<<24|64<<16|0,v[g++]=1<<24|64<<16|0,y.bits=1,0;for(C=1;C<_&&re[C]===0;C++);for(A<C&&(A=C),I=1,k=1;k<=t;k++)if(I<<=1,I-=re[k],I<0)return-1;if(I>0&&(d===r||_!==1))return-1;for(te[1]=0,k=1;k<t;k++)te[k+1]=te[k]+re[k];for(b=0;b<R;b++)h[m+b]!==0&&(x[te[h[m+b]]++]=b);if(d===r?(ae=K=x,U=19):d===o?(ae=s,ne-=257,K=l,Z-=257,U=256):(ae=c,K=f,U=-1),F=0,b=0,k=C,W=g,N=A,S=0,B=-1,O=1<<A,D=O-1,d===o&&O>n||d===i&&O>a)return 1;for(;;){de=k-S,x[b]<U?(ee=0,G=x[b]):x[b]>U?(ee=K[Z+x[b]],G=ae[ne+x[b]]):(ee=32+64,G=0),L=1<<k-S,w=1<<N,C=w;do w-=L,v[W+(F>>S)+w]=de<<24|ee<<16|G|0;while(w!==0);for(L=1<<k-1;F&L;)L>>=1;if(L!==0?(F&=L-1,F+=L):F=0,b++,--re[k]===0){if(k===_)break;k=h[m+x[b]]}if(k>A&&(F&D)!==B){for(S===0&&(S=A),W+=C,N=k-S,I=1<<N;N+S<_&&(I-=re[N+S],!(I<=0));)N++,I<<=1;if(O+=1<<N,d===o&&O>n||d===i&&O>a)return 1;B=F&D,v[B]=A<<24|N<<16|W-g|0}}return F!==0&&(v[W+F]=k-S<<24|64<<16|0),y.bits=A,0},inftrees}var hasRequiredInflate$1;function requireInflate$1(){if(hasRequiredInflate$1)return inflate;hasRequiredInflate$1=1;var e=requireCommon(),t=requireAdler32(),n=requireCrc32(),a=requireInffast(),r=requireInftrees(),o=0,i=1,s=2,l=4,c=5,f=6,u=0,d=1,h=2,m=-2,R=-3,v=-4,g=-5,x=8,y=1,E=2,k=3,b=4,C=5,_=6,A=7,N=8,S=9,I=10,O=11,F=12,L=13,w=14,B=15,D=16,W=17,ae=18,ne=19,U=20,re=21,te=22,K=23,Z=24,de=25,ee=26,G=27,ge=28,fe=29,V=30,J=31,Ce=32,Y=852,se=592,ce=15,Q=ce;function ye(z){return(z>>>24&255)+(z>>>8&65280)+((z&65280)<<8)+((z&255)<<24)}function Re(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new e.Buf16(320),this.work=new e.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Te(z){var X;return!z||!z.state?m:(X=z.state,z.total_in=z.total_out=X.total=0,z.msg="",X.wrap&&(z.adler=X.wrap&1),X.mode=y,X.last=0,X.havedict=0,X.dmax=32768,X.head=null,X.hold=0,X.bits=0,X.lencode=X.lendyn=new e.Buf32(Y),X.distcode=X.distdyn=new e.Buf32(se),X.sane=1,X.back=-1,u)}function Ee(z){var X;return!z||!z.state?m:(X=z.state,X.wsize=0,X.whave=0,X.wnext=0,Te(z))}function _e(z,X){var T,ie;return!z||!z.state||(ie=z.state,X<0?(T=0,X=-X):(T=(X>>4)+1,X<48&&(X&=15)),X&&(X<8||X>15))?m:(ie.window!==null&&ie.wbits!==X&&(ie.window=null),ie.wrap=T,ie.wbits=X,Ee(z))}function Se(z,X){var T,ie;return z?(ie=new Re,z.state=ie,ie.window=null,T=_e(z,X),T!==u&&(z.state=null),T):m}function Ne(z){return Se(z,Q)}var Ae=!0,Me,be;function Ie(z){if(Ae){var X;for(Me=new e.Buf32(512),be=new e.Buf32(32),X=0;X<144;)z.lens[X++]=8;for(;X<256;)z.lens[X++]=9;for(;X<280;)z.lens[X++]=7;for(;X<288;)z.lens[X++]=8;for(r(i,z.lens,0,288,Me,0,z.work,{bits:9}),X=0;X<32;)z.lens[X++]=5;r(s,z.lens,0,32,be,0,z.work,{bits:5}),Ae=!1}z.lencode=Me,z.lenbits=9,z.distcode=be,z.distbits=5}function $e(z,X,T,ie){var xe,p=z.state;return p.window===null&&(p.wsize=1<<p.wbits,p.wnext=0,p.whave=0,p.window=new e.Buf8(p.wsize)),ie>=p.wsize?(e.arraySet(p.window,X,T-p.wsize,p.wsize,0),p.wnext=0,p.whave=p.wsize):(xe=p.wsize-p.wnext,xe>ie&&(xe=ie),e.arraySet(p.window,X,T-ie,xe,p.wnext),ie-=xe,ie?(e.arraySet(p.window,X,T-ie,ie,0),p.wnext=ie,p.whave=p.wsize):(p.wnext+=xe,p.wnext===p.wsize&&(p.wnext=0),p.whave<p.wsize&&(p.whave+=xe))),0}function M(z,X){var T,ie,xe,p,j,q,P,$,H,ve,pe,he,Pe,Ue,Oe=0,ke,Le,De,Ve,Ge,je,we,ze,Fe=new e.Buf8(4),He,We,Ze=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!z||!z.state||!z.output||!z.input&&z.avail_in!==0)return m;T=z.state,T.mode===F&&(T.mode=L),j=z.next_out,xe=z.output,P=z.avail_out,p=z.next_in,ie=z.input,q=z.avail_in,$=T.hold,H=T.bits,ve=q,pe=P,ze=u;e:for(;;)switch(T.mode){case y:if(T.wrap===0){T.mode=L;break}for(;H<16;){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}if(T.wrap&2&&$===35615){T.check=0,Fe[0]=$&255,Fe[1]=$>>>8&255,T.check=n(T.check,Fe,2,0),$=0,H=0,T.mode=E;break}if(T.flags=0,T.head&&(T.head.done=!1),!(T.wrap&1)||((($&255)<<8)+($>>8))%31){z.msg="incorrect header check",T.mode=V;break}if(($&15)!==x){z.msg="unknown compression method",T.mode=V;break}if($>>>=4,H-=4,we=($&15)+8,T.wbits===0)T.wbits=we;else if(we>T.wbits){z.msg="invalid window size",T.mode=V;break}T.dmax=1<<we,z.adler=T.check=1,T.mode=$&512?I:F,$=0,H=0;break;case E:for(;H<16;){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}if(T.flags=$,(T.flags&255)!==x){z.msg="unknown compression method",T.mode=V;break}if(T.flags&57344){z.msg="unknown header flags set",T.mode=V;break}T.head&&(T.head.text=$>>8&1),T.flags&512&&(Fe[0]=$&255,Fe[1]=$>>>8&255,T.check=n(T.check,Fe,2,0)),$=0,H=0,T.mode=k;case k:for(;H<32;){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}T.head&&(T.head.time=$),T.flags&512&&(Fe[0]=$&255,Fe[1]=$>>>8&255,Fe[2]=$>>>16&255,Fe[3]=$>>>24&255,T.check=n(T.check,Fe,4,0)),$=0,H=0,T.mode=b;case b:for(;H<16;){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}T.head&&(T.head.xflags=$&255,T.head.os=$>>8),T.flags&512&&(Fe[0]=$&255,Fe[1]=$>>>8&255,T.check=n(T.check,Fe,2,0)),$=0,H=0,T.mode=C;case C:if(T.flags&1024){for(;H<16;){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}T.length=$,T.head&&(T.head.extra_len=$),T.flags&512&&(Fe[0]=$&255,Fe[1]=$>>>8&255,T.check=n(T.check,Fe,2,0)),$=0,H=0}else T.head&&(T.head.extra=null);T.mode=_;case _:if(T.flags&1024&&(he=T.length,he>q&&(he=q),he&&(T.head&&(we=T.head.extra_len-T.length,T.head.extra||(T.head.extra=new Array(T.head.extra_len)),e.arraySet(T.head.extra,ie,p,he,we)),T.flags&512&&(T.check=n(T.check,ie,he,p)),q-=he,p+=he,T.length-=he),T.length))break e;T.length=0,T.mode=A;case A:if(T.flags&2048){if(q===0)break e;he=0;do we=ie[p+he++],T.head&&we&&T.length<65536&&(T.head.name+=String.fromCharCode(we));while(we&&he<q);if(T.flags&512&&(T.check=n(T.check,ie,he,p)),q-=he,p+=he,we)break e}else T.head&&(T.head.name=null);T.length=0,T.mode=N;case N:if(T.flags&4096){if(q===0)break e;he=0;do we=ie[p+he++],T.head&&we&&T.length<65536&&(T.head.comment+=String.fromCharCode(we));while(we&&he<q);if(T.flags&512&&(T.check=n(T.check,ie,he,p)),q-=he,p+=he,we)break e}else T.head&&(T.head.comment=null);T.mode=S;case S:if(T.flags&512){for(;H<16;){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}if($!==(T.check&65535)){z.msg="header crc mismatch",T.mode=V;break}$=0,H=0}T.head&&(T.head.hcrc=T.flags>>9&1,T.head.done=!0),z.adler=T.check=0,T.mode=F;break;case I:for(;H<32;){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}z.adler=T.check=ye($),$=0,H=0,T.mode=O;case O:if(T.havedict===0)return z.next_out=j,z.avail_out=P,z.next_in=p,z.avail_in=q,T.hold=$,T.bits=H,h;z.adler=T.check=1,T.mode=F;case F:if(X===c||X===f)break e;case L:if(T.last){$>>>=H&7,H-=H&7,T.mode=G;break}for(;H<3;){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}switch(T.last=$&1,$>>>=1,H-=1,$&3){case 0:T.mode=w;break;case 1:if(Ie(T),T.mode=U,X===f){$>>>=2,H-=2;break e}break;case 2:T.mode=W;break;case 3:z.msg="invalid block type",T.mode=V}$>>>=2,H-=2;break;case w:for($>>>=H&7,H-=H&7;H<32;){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}if(($&65535)!==($>>>16^65535)){z.msg="invalid stored block lengths",T.mode=V;break}if(T.length=$&65535,$=0,H=0,T.mode=B,X===f)break e;case B:T.mode=D;case D:if(he=T.length,he){if(he>q&&(he=q),he>P&&(he=P),he===0)break e;e.arraySet(xe,ie,p,he,j),q-=he,p+=he,P-=he,j+=he,T.length-=he;break}T.mode=F;break;case W:for(;H<14;){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}if(T.nlen=($&31)+257,$>>>=5,H-=5,T.ndist=($&31)+1,$>>>=5,H-=5,T.ncode=($&15)+4,$>>>=4,H-=4,T.nlen>286||T.ndist>30){z.msg="too many length or distance symbols",T.mode=V;break}T.have=0,T.mode=ae;case ae:for(;T.have<T.ncode;){for(;H<3;){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}T.lens[Ze[T.have++]]=$&7,$>>>=3,H-=3}for(;T.have<19;)T.lens[Ze[T.have++]]=0;if(T.lencode=T.lendyn,T.lenbits=7,He={bits:T.lenbits},ze=r(o,T.lens,0,19,T.lencode,0,T.work,He),T.lenbits=He.bits,ze){z.msg="invalid code lengths set",T.mode=V;break}T.have=0,T.mode=ne;case ne:for(;T.have<T.nlen+T.ndist;){for(;Oe=T.lencode[$&(1<<T.lenbits)-1],ke=Oe>>>24,Le=Oe>>>16&255,De=Oe&65535,!(ke<=H);){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}if(De<16)$>>>=ke,H-=ke,T.lens[T.have++]=De;else{if(De===16){for(We=ke+2;H<We;){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}if($>>>=ke,H-=ke,T.have===0){z.msg="invalid bit length repeat",T.mode=V;break}we=T.lens[T.have-1],he=3+($&3),$>>>=2,H-=2}else if(De===17){for(We=ke+3;H<We;){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}$>>>=ke,H-=ke,we=0,he=3+($&7),$>>>=3,H-=3}else{for(We=ke+7;H<We;){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}$>>>=ke,H-=ke,we=0,he=11+($&127),$>>>=7,H-=7}if(T.have+he>T.nlen+T.ndist){z.msg="invalid bit length repeat",T.mode=V;break}for(;he--;)T.lens[T.have++]=we}}if(T.mode===V)break;if(T.lens[256]===0){z.msg="invalid code -- missing end-of-block",T.mode=V;break}if(T.lenbits=9,He={bits:T.lenbits},ze=r(i,T.lens,0,T.nlen,T.lencode,0,T.work,He),T.lenbits=He.bits,ze){z.msg="invalid literal/lengths set",T.mode=V;break}if(T.distbits=6,T.distcode=T.distdyn,He={bits:T.distbits},ze=r(s,T.lens,T.nlen,T.ndist,T.distcode,0,T.work,He),T.distbits=He.bits,ze){z.msg="invalid distances set",T.mode=V;break}if(T.mode=U,X===f)break e;case U:T.mode=re;case re:if(q>=6&&P>=258){z.next_out=j,z.avail_out=P,z.next_in=p,z.avail_in=q,T.hold=$,T.bits=H,a(z,pe),j=z.next_out,xe=z.output,P=z.avail_out,p=z.next_in,ie=z.input,q=z.avail_in,$=T.hold,H=T.bits,T.mode===F&&(T.back=-1);break}for(T.back=0;Oe=T.lencode[$&(1<<T.lenbits)-1],ke=Oe>>>24,Le=Oe>>>16&255,De=Oe&65535,!(ke<=H);){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}if(Le&&!(Le&240)){for(Ve=ke,Ge=Le,je=De;Oe=T.lencode[je+(($&(1<<Ve+Ge)-1)>>Ve)],ke=Oe>>>24,Le=Oe>>>16&255,De=Oe&65535,!(Ve+ke<=H);){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}$>>>=Ve,H-=Ve,T.back+=Ve}if($>>>=ke,H-=ke,T.back+=ke,T.length=De,Le===0){T.mode=ee;break}if(Le&32){T.back=-1,T.mode=F;break}if(Le&64){z.msg="invalid literal/length code",T.mode=V;break}T.extra=Le&15,T.mode=te;case te:if(T.extra){for(We=T.extra;H<We;){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}T.length+=$&(1<<T.extra)-1,$>>>=T.extra,H-=T.extra,T.back+=T.extra}T.was=T.length,T.mode=K;case K:for(;Oe=T.distcode[$&(1<<T.distbits)-1],ke=Oe>>>24,Le=Oe>>>16&255,De=Oe&65535,!(ke<=H);){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}if(!(Le&240)){for(Ve=ke,Ge=Le,je=De;Oe=T.distcode[je+(($&(1<<Ve+Ge)-1)>>Ve)],ke=Oe>>>24,Le=Oe>>>16&255,De=Oe&65535,!(Ve+ke<=H);){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}$>>>=Ve,H-=Ve,T.back+=Ve}if($>>>=ke,H-=ke,T.back+=ke,Le&64){z.msg="invalid distance code",T.mode=V;break}T.offset=De,T.extra=Le&15,T.mode=Z;case Z:if(T.extra){for(We=T.extra;H<We;){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}T.offset+=$&(1<<T.extra)-1,$>>>=T.extra,H-=T.extra,T.back+=T.extra}if(T.offset>T.dmax){z.msg="invalid distance too far back",T.mode=V;break}T.mode=de;case de:if(P===0)break e;if(he=pe-P,T.offset>he){if(he=T.offset-he,he>T.whave&&T.sane){z.msg="invalid distance too far back",T.mode=V;break}he>T.wnext?(he-=T.wnext,Pe=T.wsize-he):Pe=T.wnext-he,he>T.length&&(he=T.length),Ue=T.window}else Ue=xe,Pe=j-T.offset,he=T.length;he>P&&(he=P),P-=he,T.length-=he;do xe[j++]=Ue[Pe++];while(--he);T.length===0&&(T.mode=re);break;case ee:if(P===0)break e;xe[j++]=T.length,P--,T.mode=re;break;case G:if(T.wrap){for(;H<32;){if(q===0)break e;q--,$|=ie[p++]<<H,H+=8}if(pe-=P,z.total_out+=pe,T.total+=pe,pe&&(z.adler=T.check=T.flags?n(T.check,xe,pe,j-pe):t(T.check,xe,pe,j-pe)),pe=P,(T.flags?$:ye($))!==T.check){z.msg="incorrect data check",T.mode=V;break}$=0,H=0}T.mode=ge;case ge:if(T.wrap&&T.flags){for(;H<32;){if(q===0)break e;q--,$+=ie[p++]<<H,H+=8}if($!==(T.total&4294967295)){z.msg="incorrect length check",T.mode=V;break}$=0,H=0}T.mode=fe;case fe:ze=d;break e;case V:ze=R;break e;case J:return v;case Ce:default:return m}return z.next_out=j,z.avail_out=P,z.next_in=p,z.avail_in=q,T.hold=$,T.bits=H,(T.wsize||pe!==z.avail_out&&T.mode<V&&(T.mode<G||X!==l))&&$e(z,z.output,z.next_out,pe-z.avail_out),ve-=z.avail_in,pe-=z.avail_out,z.total_in+=ve,z.total_out+=pe,T.total+=pe,T.wrap&&pe&&(z.adler=T.check=T.flags?n(T.check,xe,pe,z.next_out-pe):t(T.check,xe,pe,z.next_out-pe)),z.data_type=T.bits+(T.last?64:0)+(T.mode===F?128:0)+(T.mode===U||T.mode===B?256:0),(ve===0&&pe===0||X===l)&&ze===u&&(ze=g),ze}function oe(z){if(!z||!z.state)return m;var X=z.state;return X.window&&(X.window=null),z.state=null,u}function le(z,X){var T;return!z||!z.state||(T=z.state,!(T.wrap&2))?m:(T.head=X,X.done=!1,u)}function me(z,X){var T=X.length,ie,xe,p;return!z||!z.state||(ie=z.state,ie.wrap!==0&&ie.mode!==O)?m:ie.mode===O&&(xe=1,xe=t(xe,X,T,0),xe!==ie.check)?R:(p=$e(z,X,T,T),p?(ie.mode=J,v):(ie.havedict=1,u))}return inflate.inflateReset=Ee,inflate.inflateReset2=_e,inflate.inflateResetKeep=Te,inflate.inflateInit=Ne,inflate.inflateInit2=Se,inflate.inflate=M,inflate.inflateEnd=oe,inflate.inflateGetHeader=le,inflate.inflateSetDictionary=me,inflate.inflateInfo="pako inflate (from Nodeca project)",inflate}var constants,hasRequiredConstants;function requireConstants(){return hasRequiredConstants||(hasRequiredConstants=1,constants={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}),constants}var gzheader,hasRequiredGzheader;function requireGzheader(){if(hasRequiredGzheader)return gzheader;hasRequiredGzheader=1;function e(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}return gzheader=e,gzheader}var hasRequiredInflate;function requireInflate(){if(hasRequiredInflate)return inflate$1;hasRequiredInflate=1;var e=requireInflate$1(),t=requireCommon(),n=requireStrings(),a=requireConstants(),r=requireMessages(),o=requireZstream(),i=requireGzheader(),s=Object.prototype.toString;function l(u){if(!(this instanceof l))return new l(u);this.options=t.assign({chunkSize:16384,windowBits:0,to:""},u||{});var d=this.options;d.raw&&d.windowBits>=0&&d.windowBits<16&&(d.windowBits=-d.windowBits,d.windowBits===0&&(d.windowBits=-15)),d.windowBits>=0&&d.windowBits<16&&!(u&&u.windowBits)&&(d.windowBits+=32),d.windowBits>15&&d.windowBits<48&&(d.windowBits&15||(d.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new o,this.strm.avail_out=0;var h=e.inflateInit2(this.strm,d.windowBits);if(h!==a.Z_OK)throw new Error(r[h]);if(this.header=new i,e.inflateGetHeader(this.strm,this.header),d.dictionary&&(typeof d.dictionary=="string"?d.dictionary=n.string2buf(d.dictionary):s.call(d.dictionary)==="[object ArrayBuffer]"&&(d.dictionary=new Uint8Array(d.dictionary)),d.raw&&(h=e.inflateSetDictionary(this.strm,d.dictionary),h!==a.Z_OK)))throw new Error(r[h])}l.prototype.push=function(u,d){var h=this.strm,m=this.options.chunkSize,R=this.options.dictionary,v,g,x,y,E,k=!1;if(this.ended)return!1;g=d===~~d?d:d===!0?a.Z_FINISH:a.Z_NO_FLUSH,typeof u=="string"?h.input=n.binstring2buf(u):s.call(u)==="[object ArrayBuffer]"?h.input=new Uint8Array(u):h.input=u,h.next_in=0,h.avail_in=h.input.length;do{if(h.avail_out===0&&(h.output=new t.Buf8(m),h.next_out=0,h.avail_out=m),v=e.inflate(h,a.Z_NO_FLUSH),v===a.Z_NEED_DICT&&R&&(v=e.inflateSetDictionary(this.strm,R)),v===a.Z_BUF_ERROR&&k===!0&&(v=a.Z_OK,k=!1),v!==a.Z_STREAM_END&&v!==a.Z_OK)return this.onEnd(v),this.ended=!0,!1;h.next_out&&(h.avail_out===0||v===a.Z_STREAM_END||h.avail_in===0&&(g===a.Z_FINISH||g===a.Z_SYNC_FLUSH))&&(this.options.to==="string"?(x=n.utf8border(h.output,h.next_out),y=h.next_out-x,E=n.buf2string(h.output,x),h.next_out=y,h.avail_out=m-y,y&&t.arraySet(h.output,h.output,x,y,0),this.onData(E)):this.onData(t.shrinkBuf(h.output,h.next_out))),h.avail_in===0&&h.avail_out===0&&(k=!0)}while((h.avail_in>0||h.avail_out===0)&&v!==a.Z_STREAM_END);return v===a.Z_STREAM_END&&(g=a.Z_FINISH),g===a.Z_FINISH?(v=e.inflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===a.Z_OK):(g===a.Z_SYNC_FLUSH&&(this.onEnd(a.Z_OK),h.avail_out=0),!0)},l.prototype.onData=function(u){this.chunks.push(u)},l.prototype.onEnd=function(u){u===a.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=t.flattenChunks(this.chunks)),this.chunks=[],this.err=u,this.msg=this.strm.msg};function c(u,d){var h=new l(d);if(h.push(u,!0),h.err)throw h.msg||r[h.err];return h.result}function f(u,d){return d=d||{},d.raw=!0,c(u,d)}return inflate$1.Inflate=l,inflate$1.inflate=c,inflate$1.inflateRaw=f,inflate$1.ungzip=c,inflate$1}var pako_1,hasRequiredPako;function requirePako(){if(hasRequiredPako)return pako_1;hasRequiredPako=1;var e=requireCommon().assign,t=requireDeflate(),n=requireInflate(),a=requireConstants(),r={};return e(r,t,n,a),pako_1=r,pako_1}(function(e){(function(){var t={},n;e.exports=t,typeof commonjsRequire=="function"?n=requirePako():n=window.pako,function(a,r){a.toRGBA8=function(o){var i=o.width,s=o.height;if(o.tabs.acTL==null)return[a.toRGBA8.decodeImage(o.data,i,s,o).buffer];var l=[];o.frames[0].data==null&&(o.frames[0].data=o.data);for(var c,f=new Uint8Array(i*s*4),u=0;u<o.frames.length;u++){var d=o.frames[u],h=d.rect.x,m=d.rect.y,R=d.rect.width,v=d.rect.height,g=a.toRGBA8.decodeImage(d.data,R,v,o);if(u==0?c=g:d.blend==0?a._copyTile(g,R,v,c,i,s,h,m,0):d.blend==1&&a._copyTile(g,R,v,c,i,s,h,m,1),l.push(c.buffer),c=c.slice(0),d.dispose!=0){if(d.dispose==1)a._copyTile(f,R,v,c,i,s,h,m,0);else if(d.dispose==2){for(var x=u-1;o.frames[x].dispose==2;)x--;c=new Uint8Array(l[x]).slice(0)}}}return l},a.toRGBA8.decodeImage=function(o,i,s,l){var c=i*s,f=a.decode._getBPP(l),u=Math.ceil(i*f/8),d=new Uint8Array(c*4),h=new Uint32Array(d.buffer),m=l.ctype,R=l.depth,v=a._bin.readUshort;if(m==6){var g=c<<2;if(R==8)for(var x=0;x<g;x++)d[x]=o[x];if(R==16)for(var x=0;x<g;x++)d[x]=o[x<<1]}else if(m==2){var y=l.tabs.tRNS,E=-1,k=-1,b=-1;if(y&&(E=y[0],k=y[1],b=y[2]),R==8)for(var x=0;x<c;x++){var C=x<<2,_=x*3;d[C]=o[_],d[C+1]=o[_+1],d[C+2]=o[_+2],d[C+3]=255,E!=-1&&o[_]==E&&o[_+1]==k&&o[_+2]==b&&(d[C+3]=0)}if(R==16)for(var x=0;x<c;x++){var C=x<<2,_=x*6;d[C]=o[_],d[C+1]=o[_+2],d[C+2]=o[_+4],d[C+3]=255,E!=-1&&v(o,_)==E&&v(o,_+2)==k&&v(o,_+4)==b&&(d[C+3]=0)}}else if(m==3){var A=l.tabs.PLTE,N=l.tabs.tRNS,S=N?N.length:0;if(R==1)for(var I=0;I<s;I++)for(var O=I*u,F=I*i,x=0;x<i;x++){var C=F+x<<2,L=o[O+(x>>3)]>>7-((x&7)<<0)&1,w=3*L;d[C]=A[w],d[C+1]=A[w+1],d[C+2]=A[w+2],d[C+3]=L<S?N[L]:255}if(R==2)for(var I=0;I<s;I++)for(var O=I*u,F=I*i,x=0;x<i;x++){var C=F+x<<2,L=o[O+(x>>2)]>>6-((x&3)<<1)&3,w=3*L;d[C]=A[w],d[C+1]=A[w+1],d[C+2]=A[w+2],d[C+3]=L<S?N[L]:255}if(R==4)for(var I=0;I<s;I++)for(var O=I*u,F=I*i,x=0;x<i;x++){var C=F+x<<2,L=o[O+(x>>1)]>>4-((x&1)<<2)&15,w=3*L;d[C]=A[w],d[C+1]=A[w+1],d[C+2]=A[w+2],d[C+3]=L<S?N[L]:255}if(R==8)for(var x=0;x<c;x++){var C=x<<2,L=o[x],w=3*L;d[C]=A[w],d[C+1]=A[w+1],d[C+2]=A[w+2],d[C+3]=L<S?N[L]:255}}else if(m==4){if(R==8)for(var x=0;x<c;x++){var C=x<<2,B=x<<1,D=o[B];d[C]=D,d[C+1]=D,d[C+2]=D,d[C+3]=o[B+1]}if(R==16)for(var x=0;x<c;x++){var C=x<<2,B=x<<2,D=o[B];d[C]=D,d[C+1]=D,d[C+2]=D,d[C+3]=o[B+2]}}else if(m==0){var E=l.tabs.tRNS?l.tabs.tRNS:-1;if(R==1)for(var x=0;x<c;x++){var D=255*(o[x>>3]>>7-(x&7)&1),W=D==E*255?0:255;h[x]=W<<24|D<<16|D<<8|D}if(R==2)for(var x=0;x<c;x++){var D=85*(o[x>>2]>>6-((x&3)<<1)&3),W=D==E*85?0:255;h[x]=W<<24|D<<16|D<<8|D}if(R==4)for(var x=0;x<c;x++){var D=17*(o[x>>1]>>4-((x&1)<<2)&15),W=D==E*17?0:255;h[x]=W<<24|D<<16|D<<8|D}if(R==8)for(var x=0;x<c;x++){var D=o[x],W=D==E?0:255;h[x]=W<<24|D<<16|D<<8|D}if(R==16)for(var x=0;x<c;x++){var D=o[x<<1],W=v(o,x<<1)==E?0:255;h[x]=W<<24|D<<16|D<<8|D}}return d},a.decode=function(o){for(var i=new Uint8Array(o),s=8,l=a._bin,c=l.readUshort,f=l.readUint,u={tabs:{},frames:[]},d=new Uint8Array(i.length),h=0,m,R=0,v=[137,80,78,71,13,10,26,10],g=0;g<8;g++)if(i[g]!=v[g])throw"The input is not a PNG file!";for(;s<i.length;){var x=l.readUint(i,s);s+=4;var y=l.readASCII(i,s,4);if(s+=4,y=="IHDR")a.decode._IHDR(i,s,u);else if(y=="IDAT"){for(var g=0;g<x;g++)d[h+g]=i[s+g];h+=x}else if(y=="acTL")u.tabs[y]={num_frames:f(i,s),num_plays:f(i,s+4)},m=new Uint8Array(i.length);else if(y=="fcTL"){if(R!=0){var E=u.frames[u.frames.length-1];E.data=a.decode._decompress(u,m.slice(0,R),E.rect.width,E.rect.height),R=0}var k={x:f(i,s+12),y:f(i,s+16),width:f(i,s+4),height:f(i,s+8)},b=c(i,s+22);b=c(i,s+20)/(b==0?100:b);var C={rect:k,delay:Math.round(b*1e3),dispose:i[s+24],blend:i[s+25]};u.frames.push(C)}else if(y=="fdAT"){for(var g=0;g<x-4;g++)m[R+g]=i[s+g+4];R+=x-4}else if(y=="pHYs")u.tabs[y]=[l.readUint(i,s),l.readUint(i,s+4),i[s+8]];else if(y=="cHRM"){u.tabs[y]=[];for(var g=0;g<8;g++)u.tabs[y].push(l.readUint(i,s+g*4))}else if(y=="tEXt"){u.tabs[y]==null&&(u.tabs[y]={});var _=l.nextZero(i,s),A=l.readASCII(i,s,_-s),N=l.readASCII(i,_+1,s+x-_-1);u.tabs[y][A]=N}else if(y=="iTXt"){u.tabs[y]==null&&(u.tabs[y]={});var _=0,S=s;_=l.nextZero(i,S);var A=l.readASCII(i,S,_-S);S=_+1,i[S],i[S+1],S+=2,_=l.nextZero(i,S),l.readASCII(i,S,_-S),S=_+1,_=l.nextZero(i,S),l.readUTF8(i,S,_-S),S=_+1;var N=l.readUTF8(i,S,x-(S-s));u.tabs[y][A]=N}else if(y=="PLTE")u.tabs[y]=l.readBytes(i,s,x);else if(y=="hIST"){var I=u.tabs.PLTE.length/3;u.tabs[y]=[];for(var g=0;g<I;g++)u.tabs[y].push(c(i,s+g*2))}else if(y=="tRNS")u.ctype==3?u.tabs[y]=l.readBytes(i,s,x):u.ctype==0?u.tabs[y]=c(i,s):u.ctype==2&&(u.tabs[y]=[c(i,s),c(i,s+2),c(i,s+4)]);else if(y=="gAMA")u.tabs[y]=l.readUint(i,s)/1e5;else if(y=="sRGB")u.tabs[y]=i[s];else if(y=="bKGD")u.ctype==0||u.ctype==4?u.tabs[y]=[c(i,s)]:u.ctype==2||u.ctype==6?u.tabs[y]=[c(i,s),c(i,s+2),c(i,s+4)]:u.ctype==3&&(u.tabs[y]=i[s]);else if(y=="IEND"){if(R!=0){var E=u.frames[u.frames.length-1];E.data=a.decode._decompress(u,m.slice(0,R),E.rect.width,E.rect.height),R=0}u.data=a.decode._decompress(u,d,u.width,u.height);break}s+=x,l.readUint(i,s),s+=4}return delete u.compress,delete u.interlace,delete u.filter,u},a.decode._decompress=function(o,i,s,l){return o.compress==0&&(i=a.decode._inflate(i)),o.interlace==0?i=a.decode._filterZero(i,o,0,s,l):o.interlace==1&&(i=a.decode._readInterlace(i,o)),i},a.decode._inflate=function(o){return r.inflate(o)},a.decode._readInterlace=function(o,i){for(var s=i.width,l=i.height,c=a.decode._getBPP(i),f=c>>3,u=Math.ceil(s*c/8),d=new Uint8Array(l*u),h=0,m=[0,0,4,0,2,0,1],R=[0,4,0,2,0,1,0],v=[8,8,8,4,4,2,2],g=[8,8,4,4,2,2,1],x=0;x<7;){for(var y=v[x],E=g[x],k=0,b=0,C=m[x];C<l;)C+=y,b++;for(var _=R[x];_<s;)_+=E,k++;var A=Math.ceil(k*c/8);a.decode._filterZero(o,i,h,k,b);for(var N=0,S=m[x];S<l;){for(var I=R[x],O=h+N*A<<3;I<s;){if(c==1){var F=o[O>>3];F=F>>7-(O&7)&1,d[S*u+(I>>3)]|=F<<7-((I&3)<<0)}if(c==2){var F=o[O>>3];F=F>>6-(O&7)&3,d[S*u+(I>>2)]|=F<<6-((I&3)<<1)}if(c==4){var F=o[O>>3];F=F>>4-(O&7)&15,d[S*u+(I>>1)]|=F<<4-((I&1)<<2)}if(c>=8)for(var L=S*u+I*f,w=0;w<f;w++)d[L+w]=o[(O>>3)+w];O+=c,I+=E}N++,S+=y}k*b!=0&&(h+=b*(1+A)),x=x+1}return d},a.decode._getBPP=function(o){var i=[1,null,3,1,2,null,4][o.ctype];return i*o.depth},a.decode._filterZero=function(o,i,s,l,c){var f=a.decode._getBPP(i),u=Math.ceil(l*f/8),d=a.decode._paeth;f=Math.ceil(f/8);for(var h=0;h<c;h++){var m=s+h*u,R=m+h+1,v=o[R-1];if(v==0)for(var g=0;g<u;g++)o[m+g]=o[R+g];else if(v==1){for(var g=0;g<f;g++)o[m+g]=o[R+g];for(var g=f;g<u;g++)o[m+g]=o[R+g]+o[m+g-f]&255}else if(h==0){for(var g=0;g<f;g++)o[m+g]=o[R+g];if(v==2)for(var g=f;g<u;g++)o[m+g]=o[R+g]&255;if(v==3)for(var g=f;g<u;g++)o[m+g]=o[R+g]+(o[m+g-f]>>1)&255;if(v==4)for(var g=f;g<u;g++)o[m+g]=o[R+g]+d(o[m+g-f],0,0)&255}else{if(v==2)for(var g=0;g<u;g++)o[m+g]=o[R+g]+o[m+g-u]&255;if(v==3){for(var g=0;g<f;g++)o[m+g]=o[R+g]+(o[m+g-u]>>1)&255;for(var g=f;g<u;g++)o[m+g]=o[R+g]+(o[m+g-u]+o[m+g-f]>>1)&255}if(v==4){for(var g=0;g<f;g++)o[m+g]=o[R+g]+d(0,o[m+g-u],0)&255;for(var g=f;g<u;g++)o[m+g]=o[R+g]+d(o[m+g-f],o[m+g-u],o[m+g-f-u])&255}}}return o},a.decode._paeth=function(o,i,s){var l=o+i-s,c=Math.abs(l-o),f=Math.abs(l-i),u=Math.abs(l-s);return c<=f&&c<=u?o:f<=u?i:s},a.decode._IHDR=function(o,i,s){var l=a._bin;s.width=l.readUint(o,i),i+=4,s.height=l.readUint(o,i),i+=4,s.depth=o[i],i++,s.ctype=o[i],i++,s.compress=o[i],i++,s.filter=o[i],i++,s.interlace=o[i],i++},a._bin={nextZero:function(o,i){for(;o[i]!=0;)i++;return i},readUshort:function(o,i){return o[i]<<8|o[i+1]},writeUshort:function(o,i,s){o[i]=s>>8&255,o[i+1]=s&255},readUint:function(o,i){return o[i]*(256*256*256)+(o[i+1]<<16|o[i+2]<<8|o[i+3])},writeUint:function(o,i,s){o[i]=s>>24&255,o[i+1]=s>>16&255,o[i+2]=s>>8&255,o[i+3]=s&255},readASCII:function(o,i,s){for(var l="",c=0;c<s;c++)l+=String.fromCharCode(o[i+c]);return l},writeASCII:function(o,i,s){for(var l=0;l<s.length;l++)o[i+l]=s.charCodeAt(l)},readBytes:function(o,i,s){for(var l=[],c=0;c<s;c++)l.push(o[i+c]);return l},pad:function(o){return o.length<2?"0"+o:o},readUTF8:function(o,i,s){for(var l="",c,f=0;f<s;f++)l+="%"+a._bin.pad(o[i+f].toString(16));try{c=decodeURIComponent(l)}catch(u){return a._bin.readASCII(o,i,s)}return c}},a._copyTile=function(o,i,s,l,c,f,u,d,h){for(var m=Math.min(i,c),R=Math.min(s,f),v=0,g=0,x=0;x<R;x++)for(var y=0;y<m;y++)if(u>=0&&d>=0?(v=x*i+y<<2,g=(d+x)*c+u+y<<2):(v=(-d+x)*i-u+y<<2,g=x*c+y<<2),h==0)l[g]=o[v],l[g+1]=o[v+1],l[g+2]=o[v+2],l[g+3]=o[v+3];else if(h==1){var E=o[v+3]*.00392156862745098,k=o[v]*E,b=o[v+1]*E,C=o[v+2]*E,_=l[g+3]*(1/255),A=l[g]*_,N=l[g+1]*_,S=l[g+2]*_,I=1-E,O=E+_*I,F=O==0?0:1/O;l[g+3]=255*O,l[g+0]=(k+A*I)*F,l[g+1]=(b+N*I)*F,l[g+2]=(C+S*I)*F}else if(h==2){var E=o[v+3],k=o[v],b=o[v+1],C=o[v+2],_=l[g+3],A=l[g],N=l[g+1],S=l[g+2];E==_&&k==A&&b==N&&C==S?(l[g]=0,l[g+1]=0,l[g+2]=0,l[g+3]=0):(l[g]=k,l[g+1]=b,l[g+2]=C,l[g+3]=E)}else if(h==3){var E=o[v+3],k=o[v],b=o[v+1],C=o[v+2],_=l[g+3],A=l[g],N=l[g+1],S=l[g+2];if(E==_&&k==A&&b==N&&C==S)continue;if(E<220&&_>20)return!1}return!0},a.encode=function(o,i,s,l,c,f){l==null&&(l=0),f==null&&(f=!1);for(var u=new Uint8Array(o[0].byteLength*o.length+100),d=[137,80,78,71,13,10,26,10],h=0;h<8;h++)u[h]=d[h];var m=8,R=a._bin,v=a.crc.crc,g=R.writeUint,x=R.writeUshort,y=R.writeASCII,E=a.encode.compressPNG(o,i,s,l,f);g(u,m,13),m+=4,y(u,m,"IHDR"),m+=4,g(u,m,i),m+=4,g(u,m,s),m+=4,u[m]=E.depth,m++,u[m]=E.ctype,m++,u[m]=0,m++,u[m]=0,m++,u[m]=0,m++,g(u,m,v(u,m-17,17)),m+=4,g(u,m,1),m+=4,y(u,m,"sRGB"),m+=4,u[m]=1,m++,g(u,m,v(u,m-5,5)),m+=4;var k=o.length>1;if(k&&(g(u,m,8),m+=4,y(u,m,"acTL"),m+=4,g(u,m,o.length),m+=4,g(u,m,0),m+=4,g(u,m,v(u,m-12,12)),m+=4),E.ctype==3){var b=E.plte.length;g(u,m,b*3),m+=4,y(u,m,"PLTE"),m+=4;for(var h=0;h<b;h++){var C=h*3,_=E.plte[h],A=_&255,N=_>>8&255,S=_>>16&255;u[m+C+0]=A,u[m+C+1]=N,u[m+C+2]=S}if(m+=b*3,g(u,m,v(u,m-b*3-4,b*3+4)),m+=4,E.gotAlpha){g(u,m,b),m+=4,y(u,m,"tRNS"),m+=4;for(var h=0;h<b;h++)u[m+h]=E.plte[h]>>24&255;m+=b,g(u,m,v(u,m-b-4,b+4)),m+=4}}for(var I=0,O=0;O<E.frames.length;O++){var F=E.frames[O];k&&(g(u,m,26),m+=4,y(u,m,"fcTL"),m+=4,g(u,m,I++),m+=4,g(u,m,F.rect.width),m+=4,g(u,m,F.rect.height),m+=4,g(u,m,F.rect.x),m+=4,g(u,m,F.rect.y),m+=4,x(u,m,c[O]),m+=2,x(u,m,1e3),m+=2,u[m]=F.dispose,m++,u[m]=F.blend,m++,g(u,m,v(u,m-30,30)),m+=4);var L=F.cimg,b=L.length;g(u,m,b+(O==0?0:4)),m+=4;var w=m;y(u,m,O==0?"IDAT":"fdAT"),m+=4,O!=0&&(g(u,m,I++),m+=4);for(var h=0;h<b;h++)u[m+h]=L[h];m+=b,g(u,m,v(u,w,m-w)),m+=4}return g(u,m,0),m+=4,y(u,m,"IEND"),m+=4,g(u,m,v(u,m-4,4)),m+=4,u.buffer.slice(0,m)},a.encode.compressPNG=function(o,i,s,l,c){for(var f=a.encode.compress(o,i,s,l,!1,c),u=0;u<o.length;u++){var d=f.frames[u];d.rect.width;var h=d.rect.height,m=d.bpl,R=d.bpp,v=new Uint8Array(h*m+h);d.cimg=a.encode._filterZero(d.img,h,R,m,v)}return f},a.encode.compress=function(o,i,s,l,c,f){f==null&&(f=!1);for(var u=6,d=8,h=4,m=255,R=0;R<o.length;R++)for(var v=new Uint8Array(o[R]),g=v.length,x=0;x<g;x+=4)m&=v[x+3];var y=m!=255,E={},k=[];if(o.length!=0&&(E[0]=0,k.push(0),l!=0&&l--),l!=0){var b=a.quantize(o,l,c);o=b.bufs;for(var x=0;x<b.plte.length;x++){var C=b.plte[x].est.rgba;E[C]==null&&(E[C]=k.length,k.push(C))}}else for(var R=0;R<o.length;R++)for(var _=new Uint32Array(o[R]),g=_.length,x=0;x<g;x++){var C=_[x];if((x<i||C!=_[x-1]&&C!=_[x-i])&&E[C]==null&&(E[C]=k.length,k.push(C),k.length>=300))break}var A=y?c:!1,N=k.length;N<=256&&f==!1&&(N<=2?d=1:N<=4?d=2:N<=16?d=4:d=8,c&&(d=8),y=!0);for(var S=[],R=0;R<o.length;R++){var I=new Uint8Array(o[R]),O=new Uint32Array(I.buffer),F=0,L=0,w=i,B=s,D=0;if(R!=0&&!A){for(var W=c||R==1||S[S.length-2].dispose==2?1:2,ae=0,ne=1e9,U=0;U<W;U++){for(var fe=new Uint8Array(o[R-1-U]),re=new Uint32Array(o[R-1-U]),te=i,K=s,Z=-1,de=-1,ee=0;ee<s;ee++)for(var G=0;G<i;G++){var x=ee*i+G;O[x]!=re[x]&&(G<te&&(te=G),G>Z&&(Z=G),ee<K&&(K=ee),ee>de&&(de=ee))}var ge=Z==-1?1:(Z-te+1)*(de-K+1);ge<ne&&(ne=ge,ae=U,Z==-1?(F=L=0,w=B=1):(F=te,L=K,w=Z-te+1,B=de-K+1))}var fe=new Uint8Array(o[R-1-ae]);ae==1&&(S[S.length-1].dispose=2);var V=new Uint8Array(w*B*4);new Uint32Array(V.buffer),a._copyTile(fe,i,s,V,w,B,-F,-L,0),a._copyTile(I,i,s,V,w,B,-F,-L,3)?(a._copyTile(I,i,s,V,w,B,-F,-L,2),D=1):(a._copyTile(I,i,s,V,w,B,-F,-L,0),D=0),I=V,O=new Uint32Array(I.buffer)}var J=4*w;if(N<=256&&f==!1){J=Math.ceil(d*w/8);for(var V=new Uint8Array(J*B),ee=0;ee<B;ee++){var x=ee*J,Ce=ee*w;if(d==8)for(var G=0;G<w;G++)V[x+G]=E[O[Ce+G]];else if(d==4)for(var G=0;G<w;G++)V[x+(G>>1)]|=E[O[Ce+G]]<<4-(G&1)*4;else if(d==2)for(var G=0;G<w;G++)V[x+(G>>2)]|=E[O[Ce+G]]<<6-(G&3)*2;else if(d==1)for(var G=0;G<w;G++)V[x+(G>>3)]|=E[O[Ce+G]]<<7-(G&7)*1}I=V,u=3,h=1}else if(y==!1&&o.length==1){for(var V=new Uint8Array(w*B*3),Y=w*B,x=0;x<Y;x++){var se=x*3,ce=x*4;V[se]=I[ce],V[se+1]=I[ce+1],V[se+2]=I[ce+2]}I=V,u=2,h=3,J=3*w}S.push({rect:{x:F,y:L,width:w,height:B},img:I,bpl:J,bpp:h,blend:D,dispose:A?1:0})}return{ctype:u,depth:d,plte:k,gotAlpha:y,frames:S}},a.encode._filterZero=function(o,i,s,l,c){for(var f=[],u=0;u<5;u++)if(!(i*l>5e5&&(u==2||u==3||u==4))){for(var d=0;d<i;d++)a.encode._filterLine(c,o,d,l,s,u);if(f.push(r.deflate(c)),s==1)break}for(var h,m=1e9,R=0;R<f.length;R++)f[R].length<m&&(h=R,m=f[R].length);return f[h]},a.encode._filterLine=function(o,i,s,l,c,f){var u=s*l,d=u+s,h=a.decode._paeth;if(o[d]=f,d++,f==0)for(var m=0;m<l;m++)o[d+m]=i[u+m];else if(f==1){for(var m=0;m<c;m++)o[d+m]=i[u+m];for(var m=c;m<l;m++)o[d+m]=i[u+m]-i[u+m-c]+256&255}else if(s==0){for(var m=0;m<c;m++)o[d+m]=i[u+m];if(f==2)for(var m=c;m<l;m++)o[d+m]=i[u+m];if(f==3)for(var m=c;m<l;m++)o[d+m]=i[u+m]-(i[u+m-c]>>1)+256&255;if(f==4)for(var m=c;m<l;m++)o[d+m]=i[u+m]-h(i[u+m-c],0,0)+256&255}else{if(f==2)for(var m=0;m<l;m++)o[d+m]=i[u+m]+256-i[u+m-l]&255;if(f==3){for(var m=0;m<c;m++)o[d+m]=i[u+m]+256-(i[u+m-l]>>1)&255;for(var m=c;m<l;m++)o[d+m]=i[u+m]+256-(i[u+m-l]+i[u+m-c]>>1)&255}if(f==4){for(var m=0;m<c;m++)o[d+m]=i[u+m]+256-h(0,i[u+m-l],0)&255;for(var m=c;m<l;m++)o[d+m]=i[u+m]+256-h(i[u+m-c],i[u+m-l],i[u+m-c-l])&255}}},a.crc={table:function(){for(var o=new Uint32Array(256),i=0;i<256;i++){for(var s=i,l=0;l<8;l++)s&1?s=3988292384^s>>>1:s=s>>>1;o[i]=s}return o}(),update:function(o,i,s,l){for(var c=0;c<l;c++)o=a.crc.table[(o^i[s+c])&255]^o>>>8;return o},crc:function(o,i,s){return a.crc.update(4294967295,o,i,s)^4294967295}},a.quantize=function(o,i,s){for(var l=[],c=0,f=0;f<o.length;f++)l.push(a.encode.alphaMul(new Uint8Array(o[f]),s)),c+=o[f].byteLength;for(var u=new Uint8Array(c),d=new Uint32Array(u.buffer),h=0,f=0;f<l.length;f++){for(var m=l[f],R=m.length,v=0;v<R;v++)u[h+v]=m[v];h+=R}var g={i0:0,i1:u.length,bst:null,est:null,tdst:0,left:null,right:null};g.bst=a.quantize.stats(u,g.i0,g.i1),g.est=a.quantize.estats(g.bst);for(var x=[g];x.length<i;){for(var y=0,E=0,f=0;f<x.length;f++)x[f].est.L>y&&(y=x[f].est.L,E=f);if(y<.001)break;var k=x[E],b=a.quantize.splitPixels(u,d,k.i0,k.i1,k.est.e,k.est.eMq255),C={i0:k.i0,i1:b,bst:null,est:null,tdst:0,left:null,right:null};C.bst=a.quantize.stats(u,C.i0,C.i1),C.est=a.quantize.estats(C.bst);var _={i0:b,i1:k.i1,bst:null,est:null,tdst:0,left:null,right:null};_.bst={R:[],m:[],N:k.bst.N-C.bst.N};for(var f=0;f<16;f++)_.bst.R[f]=k.bst.R[f]-C.bst.R[f];for(var f=0;f<4;f++)_.bst.m[f]=k.bst.m[f]-C.bst.m[f];_.est=a.quantize.estats(_.bst),k.left=C,k.right=_,x[E]=C,x.push(_)}x.sort(function(W,ae){return ae.bst.N-W.bst.N});for(var A=0;A<l.length;A++){for(var N=a.quantize.planeDst,S=new Uint8Array(l[A].buffer),I=new Uint32Array(l[A].buffer),O=S.length,f=0;f<O;f+=4){for(var F=S[f]*.00392156862745098,L=S[f+1]*(1/255),w=S[f+2]*(1/255),B=S[f+3]*(1/255),D=g;D.left;)D=N(D.est,F,L,w,B)<=0?D.left:D.right;I[f>>2]=D.est.rgba}l[A]=I.buffer}return{bufs:l,plte:x}},a.quantize.getNearest=function(o,i,s,l,c){if(o.left==null)return o.tdst=a.quantize.dist(o.est.q,i,s,l,c),o;var f=a.quantize.planeDst(o.est,i,s,l,c),u=o.left,d=o.right;f>0&&(u=o.right,d=o.left);var h=a.quantize.getNearest(u,i,s,l,c);if(h.tdst<=f*f)return h;var m=a.quantize.getNearest(d,i,s,l,c);return m.tdst<h.tdst?m:h},a.quantize.planeDst=function(o,i,s,l,c){var f=o.e;return f[0]*i+f[1]*s+f[2]*l+f[3]*c-o.eMq},a.quantize.dist=function(o,i,s,l,c){var f=i-o[0],u=s-o[1],d=l-o[2],h=c-o[3];return f*f+u*u+d*d+h*h},a.quantize.splitPixels=function(o,i,s,l,c,f){var u=a.quantize.vecDot;for(l-=4;s<l;){for(;u(o,s,c)<=f;)s+=4;for(;u(o,l,c)>f;)l-=4;if(s>=l)break;var d=i[s>>2];i[s>>2]=i[l>>2],i[l>>2]=d,s+=4,l-=4}for(;u(o,s,c)>f;)s-=4;return s+4},a.quantize.vecDot=function(o,i,s){return o[i]*s[0]+o[i+1]*s[1]+o[i+2]*s[2]+o[i+3]*s[3]},a.quantize.stats=function(o,i,s){for(var l=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=[0,0,0,0],f=s-i>>2,u=i;u<s;u+=4){var d=o[u]*.00392156862745098,h=o[u+1]*(1/255),m=o[u+2]*(1/255),R=o[u+3]*(1/255);c[0]+=d,c[1]+=h,c[2]+=m,c[3]+=R,l[0]+=d*d,l[1]+=d*h,l[2]+=d*m,l[3]+=d*R,l[5]+=h*h,l[6]+=h*m,l[7]+=h*R,l[10]+=m*m,l[11]+=m*R,l[15]+=R*R}return l[4]=l[1],l[8]=l[2],l[12]=l[3],l[9]=l[6],l[13]=l[7],l[14]=l[11],{R:l,m:c,N:f}},a.quantize.estats=function(o){var i=o.R,s=o.m,l=o.N,c=s[0],f=s[1],u=s[2],d=s[3],h=l==0?0:1/l,m=[i[0]-c*c*h,i[1]-c*f*h,i[2]-c*u*h,i[3]-c*d*h,i[4]-f*c*h,i[5]-f*f*h,i[6]-f*u*h,i[7]-f*d*h,i[8]-u*c*h,i[9]-u*f*h,i[10]-u*u*h,i[11]-u*d*h,i[12]-d*c*h,i[13]-d*f*h,i[14]-d*u*h,i[15]-d*d*h],R=m,v=a.M4,g=[.5,.5,.5,.5],x=0,y=0;if(l!=0)for(var E=0;E<10&&(g=v.multVec(R,g),y=Math.sqrt(v.dot(g,g)),g=v.sml(1/y,g),!(Math.abs(y-x)<1e-9));E++)x=y;var k=[c*h,f*h,u*h,d*h],b=v.dot(v.sml(255,k),g),C=k[3]<.001?0:1/k[3];return{Cov:m,q:k,e:g,L:x,eMq255:b,eMq:v.dot(g,k),rgba:(Math.round(255*k[3])<<24|Math.round(255*k[2]*C)<<16|Math.round(255*k[1]*C)<<8|Math.round(255*k[0]*C)<<0)>>>0}},a.M4={multVec:function(o,i){return[o[0]*i[0]+o[1]*i[1]+o[2]*i[2]+o[3]*i[3],o[4]*i[0]+o[5]*i[1]+o[6]*i[2]+o[7]*i[3],o[8]*i[0]+o[9]*i[1]+o[10]*i[2]+o[11]*i[3],o[12]*i[0]+o[13]*i[1]+o[14]*i[2]+o[15]*i[3]]},dot:function(o,i){return o[0]*i[0]+o[1]*i[1]+o[2]*i[2]+o[3]*i[3]},sml:function(o,i){return[o*i[0],o*i[1],o*i[2],o*i[3]]}},a.encode.alphaMul=function(o,i){for(var s=new Uint8Array(o.length),l=o.length>>2,c=0;c<l;c++){var f=c<<2,u=o[f+3];i&&(u=u<128?0:255);var d=u*(1/255);s[f+0]=o[f+0]*d,s[f+1]=o[f+1]*d,s[f+2]=o[f+2]*d,s[f+3]=u}return s}}(t,n)})()})(UPNG$1);var UPNGExports=UPNG$1.exports;const UPNG=getDefaultExportFromCjs(UPNGExports),batchUpdate=reactDom.unstable_batchedUpdates,Common={batchUpdate},calcGUIScale=e=>new EngineCore.Vector3(1/(e&&e.scalePlane?e.scalePlane:1)*Math.min(e&&e.scalePlane?e.scalePlane:1,e&&e.scaleDepth?e.scaleDepth:1),1/(e&&e.scaleDepth?e.scaleDepth:1)*Math.min(e&&e.scalePlane?e.scalePlane:1,e&&e.scaleDepth?e.scaleDepth:1),1/(e&&e.scalePlane?e.scalePlane:1)*Math.min(e&&e.scalePlane?e.scalePlane:1,e&&e.scaleDepth?e.scaleDepth:1)),calcTransformNodeScale=e=>new EngineCore.Vector3(e?e.scalePlane:1,e?e.scaleDepth:1,e?e.scalePlane:1),calcInvTransformNodeScale=e=>e?new EngineCore.Vector3(1/(e.scalePlane?e.scalePlane:1),1/(e.scaleDepth?e.scaleDepth:1),1/(e.scalePlane?e.scalePlane:1)):EngineCore.Vector3.One(),calcCompass=e=>{if(e instanceof EngineCore.ArcRotateCamera){const t=e.alpha;return(t>0?t:Math.PI-t)/Math.PI*180%360}return 0},convertPositionArrayToVector3=e=>{const t=[];return e.forEach(n=>{t.push(convertPositionToVector3(n))}),t},convertPositionToVector3=e=>new EngineCore.Vector3(e.x,e.y,e.z),convertVertexToVector3=e=>new EngineCore.Vector3(e.x,e.y,e.z),convertColorToColor3=e=>new EngineCore.Color3(e.r,e.g,e.b);var HoverType=(e=>(e[e.START=0]="START",e[e.CONTINUE=1]="CONTINUE",e[e.END=2]="END",e))(HoverType||{}),MaterialType=(e=>(e[e.ONE_COLOR=0]="ONE_COLOR",e[e.COLOR_CODEC=1]="COLOR_CODEC",e[e.TEXTURE=2]="TEXTURE",e[e.COLOR_ID=3]="COLOR_ID",e))(MaterialType||{}),MaterialSideOrientation=(e=>(e[e.ClockWiseSideOrientation=EngineCore.Material.ClockWiseSideOrientation]="ClockWiseSideOrientation",e[e.CounterClockWiseSideOrientation=EngineCore.Material.CounterClockWiseSideOrientation]="CounterClockWiseSideOrientation",e))(MaterialSideOrientation||{}),ScaleMode=(e=>(e[e.PLANE=0]="PLANE",e[e.DEPTH=1]="DEPTH",e[e.NONE=2]="NONE",e))(ScaleMode||{});const WorkspaceMetaContext=React.createContext(void 0),ViewerCameraPropsContext=React.createContext({viewCamera:void 0,setViewCamera:()=>{},cameraRefObject:void 0}),ColorProviderContext=React.createContext({colorIDs:{},colorCodecs:{}}),ColorCodecImageContext=React.createContext(null);var LoadingScreen=(e=>(e[e.ENGINE_DEFAULT=0]="ENGINE_DEFAULT",e[e.NONE=1]="NONE",e))(LoadingScreen||{});const FetchAndCacheContext=React.createContext({onPreFetch:e=>new Promise(t=>{t(e)}),onFinish:()=>{console.log("Loaded")},onProgress:(e,t)=>{console.log(`Loading ${e}/${t}`)},useLoadingScreen:1,hideLoadingWhenPostCalculate:!0}),GPUPickingContext=React.createContext(null),Geo3DProvider=(e,t)=>{var ge,fe,V,J,Ce;const{children:n,workspaceMeta:a={max:new EngineCore.Vector3(Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER),min:new EngineCore.Vector3(Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER),scaleDepth:1,scalePlane:1,origin:EngineCore.Vector3.Zero(),_isDefault:!0},colorProvider:r={colorIDs:{},colorCodecs:{}},cacheProvider:o={onPreFetch:Y=>new Promise(se=>{se(Y)}),onFinish:()=>{console.log("Loaded")},onProgress:(Y,se)=>{console.log(`Loading ${Y} of ${se}`)},useLoadingScreen:1}}=e,i=reactBabylonjs.useScene(),s=reactBabylonjs.useCanvas(),[l,c]=React.useState(void 0),f=React.useRef({}),[u,d]=React.useState({}),h=React.useRef(0),m=React.useRef(0),R=React.useRef(new Set),v=React.useRef(new Map),g=React.useRef({lastReportedLoaded:-1,lastReportedTotal:-1}),[,x]=React.useState(0),y=React.useRef(null),E=React.useRef(null),k=React.useRef(!1),b=React.useRef(null),C=React.useRef([]),_=React.useRef(null),A=React.useRef(0),N=React.useRef(new WeakMap),S=React.useRef(1),I=React.useRef(new Map),O=React.useRef(0);React.useEffect(()=>{if(r.colorCodecs){console.log("[Geo3DViewer] 开始色标刷新");const Y={};if(Object.keys(r.colorCodecs).forEach(ce=>{console.log(`[Geo3DViewer] 正在生成色标 ${ce}`);const Q=r.colorCodecs[ce],ye=new Uint8Array(Q.array.length*4);Q.array.forEach((Ee,_e)=>{ye[_e*4+0]=Math.trunc(Ee.r*255),ye[_e*4+1]=Math.trunc(Ee.g*255),ye[_e*4+2]=Math.trunc(Ee.b*255),ye[_e*4+3]=255}),console.log(`[Geo3DViewer] 正在创建色标采样贴图 ${ce}`);const Re=EngineCore.RawTexture.CreateRGBATexture(ye,1,Q.array.length,i,!0,!1);Re.name=`color-codec-${ce}`,console.log(`[Geo3DViewer] 正在创建色标图例 ${ce}`);const Te=URL.createObjectURL(new Blob([UPNG.encode([ye.buffer],1,Q.array.length,0)]));console.log(`[Geo3DViewer] 正在构建色标 ${ce}`),Y[ce]={blobUrl:Te,min:Q.min,max:Q.max,texture:Re}}),i){console.log(`[Geo3DViewer] 正在移除原有色标 共 ${Object.keys(f.current).length} 个`),Object.keys(f.current).forEach(Q=>{console.log(`[Geo3DViewer] 正在移除色标 ${Q}`),i.removeTexture(f.current[Q].texture),f.current[Q].texture.dispose(),URL.revokeObjectURL(f.current[Q].blobUrl)}),f.current=Y;const ce=i.getMaterialByTags("remap");console.log("[Geo3DViewer] 已完成色标刷新,正在更新关联的材质"),ce.forEach(Q=>{Q instanceof EngineCore.ShaderMaterial?Q.setTexture("textureSampler",Y[Q.metadata.colorCodec].texture):(Q.getBlockByName("RemappedTexture").texture=Y[Q.metadata.colorCodec].texture,Q.markAsDirty(EngineCore.NodeMaterial.TextureDirtyFlag))}),console.log(`[Geo3DViewer] 已有 ${ce.length} 个材质执行了更新`)}}},[r.colorCodecs,i]);const F=React.useCallback(Y=>!Y||Y.isDisposed()||!Y.metadata||!("pickable"in Y.metadata)||!Y.metadata.pickable?null:Y.metadata.pickable,[]),L=React.useCallback(Y=>!!(Y&&(Y.onHover||Y.onLeftClick||Y.onMiddleClick||Y.onRightClick)),[]),w=React.useCallback(Y=>{if(s){if(Y&&(Y.onLeftClick||Y.onMiddleClick||Y.onRightClick)){s.style.setProperty("cursor","pointer");return}s.style.setProperty("cursor","default")}},[s]),B=React.useCallback(()=>{var se;const Y=(se=E.current)==null?void 0:se._pickingTexture;y.current!==(Y!=null?Y:null)&&(y.current=Y!=null?Y:null,x(ce=>ce+1))},[]),D=React.useCallback(Y=>{const se=N.current.get(Y);if(se)return se;const ce=S.current++;return N.current.set(Y,ce),ce},[]),W=React.useCallback(()=>{const Y=[],se=new Set;if(!i)return Y;i.meshes.forEach(Q=>{if(!Q||Q.isDisposed())return;const ye=F(Q);if(!(!(L(ye)&&Q.isEnabled()&&Q.isVisible&&Q.isReady(!0)&&Q.isPickable)||se.has(Q))&&(se.add(Q),Y.push(Q),Q.isAnInstance)){const Te=Q.sourceMesh;Te&&!Te.isDisposed()&&Te.isEnabled()&&Te.isVisible&&Te.isReady(!0)&&!se.has(Te)&&(se.add(Te),Y.push(Te))}});const ce=C.current.length===Y.length&&C.current.every((Q,ye)=>Q===Y[ye]);return E.current||(E.current=new gpuPicker.GPUPicker),ce||(E.current.setPickingList(Y.length>0?Y.slice():null),C.current=Y,B()),Y},[F,L,i,B]),ae=React.useCallback(async(Y,se)=>{if(!i)return null;if(!W().length||!E.current)return B(),null;B();const Q=await E.current.pickAsync(Y,se,!1);return B(),Q},[i,W,B]);React.useEffect(()=>{if(!i)return;const Y=i.onBeforeRenderObservable.add(()=>{W()});return()=>{i.onBeforeRenderObservable.remove(Y)}},[i,W]);const ne=React.useCallback((Y,se,ce)=>i?i.pick(se,ce,Q=>Q===Y,!1,void 0):null,[i]),U=React.useCallback(()=>{A.current+=1,I.current.clear()},[]),re=React.useCallback(Y=>new Proxy({},{get:(se,ce)=>{const Q=Y();if(!Q)return;const ye=Q[ce];return typeof ye=="function"?ye.bind(Q):ye},set:(se,ce,Q)=>{const ye=Y();return ye?(ye[ce]=Q,!0):!1},has:(se,ce)=>{const Q=Y();return Q?ce in Q:!1},ownKeys:()=>{const se=Y();return se?Reflect.ownKeys(se):[]},getOwnPropertyDescriptor:(se,ce)=>{const Q=Y();if(Q)return Object.getOwnPropertyDescriptor(Q,ce)}}),[]),te=React.useCallback((Y,se,ce)=>{const Q=A.current,ye=D(Y),Re=`${Q}:${ye}:${Math.round(se)}:${Math.round(ce)}`,Te=()=>{var Me,be,Ie;const Ee=I.current.get(Re);if(Ee)return Ee;const _e=ne(Y,se,ce),Se=(Me=_e==null?void 0:_e.pickedPoint)!=null?Me:null,Ne=(Ie=Se==null?void 0:Se.add((be=a.origin)!=null?be:EngineCore.Vector3.Zero()))!=null?Ie:null,Ae={raw:Se,world:Ne};return I.current.set(Re,Ae),Ae};return{rawWorldPosition:re(()=>Te().raw),worldPosition:re(()=>Te().world)}},[re,D,ne,a.origin]),K=React.useCallback((Y,se,ce,Q,ye)=>{var Se,Ne;const Re=F(Y);if(!Re||!Re.onHover)return;const Te=new EngineCore.Vector2(ce.clientX,ce.clientY),Ee=se!==HoverType.END&&Re.needWorldPosition?te(Y,Q,ye):null,_e=Re.valueCallback?Re.valueCallback(Te,(Se=Ee==null?void 0:Ee.worldPosition)!=null?Se:null,(Ne=Ee==null?void 0:Ee.rawWorldPosition)!=null?Ne:null):null;Re.onHover(Re.name,Te,Ee==null?void 0:Ee.worldPosition,se,_e,Re.extra)},[te,F]),Z=React.useCallback((Y,se)=>{const ce=Y&&F(Y)&&L(F(Y))?Y:null,Q=b.current;Q&&Q!==ce&&K(Q,HoverType.END,se.event,se.x,se.y),ce&&K(ce,Q===ce?HoverType.CONTINUE:HoverType.START,se.event,se.x,se.y),b.current=ce,w(ce?F(ce):null)},[F,L,K,w]),de=React.useCallback(async()=>{var Y;if(!k.current){for(k.current=!0;_.current;){const se=_.current;if(_.current=null,!i||i.skipPointerMovePicking){Z(null,se);continue}const ce=await ae(se.x,se.y),Q=(Y=ce==null?void 0:ce.mesh)!=null?Y:null;if(U(),i.skipPointerMovePicking){Z(null,se);continue}Z(Q,se)}k.current=!1}},[U,ae,i,Z]),ee=React.useCallback(async(Y,se,ce)=>{var Se;if(!i)return;for(;k.current;)await new Promise(Ne=>setTimeout(Ne,8));if(Date.now()-O.current<100){O.current=Date.now();return}O.current=Date.now();const Q=await ae(se,ce);U();const ye=(Se=Q==null?void 0:Q.mesh)!=null?Se:null,Re=F(ye);if(console.log(`[Geo3DViewer] 指针拾取 ${!!ye} 于面 ${ye}`,Re,Q),!ye||!Re)return;const Te=new EngineCore.Vector2(Y.clientX,Y.clientY),Ee=te(ye,se,ce),_e=Re.valueCallback?Re.valueCallback(Te,Ee.worldPosition,Ee.rawWorldPosition):null;if(Y.button===0&&Re.onLeftClick){Re.onLeftClick(Re.name,Te,Ee.worldPosition,_e,Re.extra);return}if(Y.button===1&&Re.onMiddleClick){Re.onMiddleClick(Re.name,Te,Ee.worldPosition,_e,Re.extra);return}Y.button===2&&Re.onRightClick&&Re.onRightClick(Re.name,Te,Ee.worldPosition,_e,Re.extra)},[U,te,F,ae,i]);React.useEffect(()=>{if(i)return i.skipPointerDownPicking=!0,i.skipPointerUpPicking=!0,()=>{i.skipPointerDownPicking=!1,i.skipPointerUpPicking=!1}},[i]),React.useEffect(()=>{if(!i)return;const Y=i.onPointerObservable.add(se=>{const ce=se.event;if(se.type===EngineCore.PointerEventTypes.POINTERMOVE){if(i.skipPointerMovePicking){b.current&&Z(null,{event:ce,x:i.pointerX,y:i.pointerY});return}_.current={event:ce,x:i.pointerX,y:i.pointerY},de();return}if(se.type===EngineCore.PointerEventTypes.POINTERUP){if(i.skipPointerMovePicking)return;ee(ce,i.pointerX,i.pointerY)}});return()=>{i.onPointerObservable.remove(Y),_.current=null,b.current=null,w(null)}},[ee,de,i,w,Z]),React.useEffect(()=>()=>{var Y;_.current=null,C.current=[],b.current=null,I.current.clear(),(Y=E.current)==null||Y.dispose(),E.current=null,y.current=null},[]);const G=React.useRef(void 0);return React.useImperativeHandle(t,()=>i,[i]),jsxRuntime.jsx(WorkspaceMetaContext.Provider,{value:{min:(ge=a.min)!=null?ge:new EngineCore.Vector3(Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER),max:(fe=a.max)!=null?fe:new EngineCore.Vector3(Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER),scaleDepth:(V=a.scaleDepth)!=null?V:1,scalePlane:(J=a.scalePlane)!=null?J:1,_isDefault:(Ce=a._isDefault)!=null?Ce:!0,origin:EngineCore.Vector3.Zero()},children:jsxRuntime.jsx(ViewerCameraPropsContext.Provider,{value:{viewCamera:l,setViewCamera:c,cameraRefObject:G},children:jsxRuntime.jsx(FetchAndCacheContext.Provider,{value:o,children:jsxRuntime.jsxs(CacheProviderContext.Provider,{value:{cache:u,setCache:d,loadedCount:m,totalCount:h,pending:R,inflight:v,reported:g},children:[jsxRuntime.jsx(CacheCallback$1,{}),jsxRuntime.jsx(ColorCodecImageContext.Provider,{value:{colorCodecsImage:f},children:jsxRuntime.jsx(ColorProviderContext.Provider,{value:r,children:jsxRuntime.jsx(GPUPickingContext.Provider,{value:{gpuPickingTexture:y},children:n})})})]})})})})},Geo3DProvider$1=React.forwardRef(Geo3DProvider),jsonDecoder=new TextDecoder;var CacheType=(e=>(e[e.URL_PREFIX_MATCH=0]="URL_PREFIX_MATCH",e[e.EXACTLY_MATCH=1]="EXACTLY_MATCH",e))(CacheType||{}),AssetType=(e=>(e[e.BINARY=0]="BINARY",e[e.TEXTURE=1]="TEXTURE",e[e.MODEL=2]="MODEL",e[e.JSON=3]="JSON",e))(AssetType||{});const useCacheProvider=({url:e,cacheType:t=0,assetType:n=0})=>{var k,b,C,_,A,N;const a=reactBabylonjs.useScene(),{onPreFetch:r}=React.useContext(FetchAndCacheContext),o=React.useContext(CacheProviderContext),i=React.useRef(0),s=React.useRef(0),l=React.useRef(new Set),c=React.useRef(new Map),[f,u]=React.useState(void 0),d=(k=o==null?void 0:o.cache)!=null?k:{},h=(b=o==null?void 0:o.setCache)!=null?b:()=>{},m=(C=o==null?void 0:o.loadedCount)!=null?C:s,R=(_=o==null?void 0:o.totalCount)!=null?_:i,v=(A=o==null?void 0:o.pending)!=null?A:l,g=(N=o==null?void 0:o.inflight)!=null?N:c,x=React.useCallback(async S=>{let I=1,O;for(;I>=0;)try{return(await axios.get(S,{responseType:"arraybuffer",timeout:2e4})).data}catch(F){O=F,I-=1,I>=0&&await new Promise(L=>setTimeout(L,300))}throw O},[]),y=React.useCallback((S,I)=>{if(S){if(I===1)return d[S];if(I===0){const O=S.split("?")[0];return d[O]}}},[d]),E=React.useCallback(async(S,I,O)=>{const F=g.current.get(S);if(F){const w=await F;w&&u(w);return}const L=(async()=>{v.current.add(S),R.current=R.current+1;try{const w=await r(S),B=[];w!==S&&B.push(S),I===0?(B.push(w.split("?")[0]),B.push(w)):I===1&&B.push(w);const D=await x(w),W={};let ae;if(O===0)ae={buffer:D};else if(O===1){const ne=URL.createObjectURL(new Blob([D])),U=new EngineCore.Texture(ne,a,!0,!1,void 0,()=>{URL.revokeObjectURL(ne)},()=>{URL.revokeObjectURL(ne)});ae={buffer:D,texture:U}}else if(O===2){if(!a)throw new Error("Scene not ready for model loading");const ne=URL.createObjectURL(new Blob([D]));try{let U=w.split("?")[0];U=(U==null?void 0:U.split(".").pop())||"";const re=await EngineCore.LoadAssetContainerAsync(ne,a,{pluginExtension:`.${U}`});ae={buffer:D,assets:re}}finally{URL.revokeObjectURL(ne)}}else ae={buffer:D,json:JSON.parse(jsonDecoder.decode(D))};return B.forEach(ne=>{W[ne]=ae}),h(ne=>{let U=!1;const re={...ne};return B.forEach(te=>{re[te]||(re[te]=ae,U=!0)}),U?re:ne}),m.current=m.current+1,u(ae),ae}catch(w){console.error(w),m.current=m.current+1;return}finally{v.current.delete(S),g.current.delete(S)}})();g.current.set(S,L),await L},[x,r,g,m,v,h,R,a]);return React.useEffect(()=>{if(e){const S=y(e,t);if(S){u(S);return}v.current.has(e)||E(e,t,n)}},[n,t,E,y,v,e]),f},useCachedBinary=({url:e,cacheType:t=0})=>{const n=useCacheProvider({url:e,cacheType:t,assetType:0}),[a,r]=React.useState(void 0);return React.useEffect(()=>{r(o=>(n==null?void 0:n.buffer)!==o?n==null?void 0:n.buffer:o)},[n]),a},useCachedTexture=({url:e,cacheType:t=0})=>{const n=useCacheProvider({url:e,cacheType:t,assetType:1}),[a,r]=React.useState(void 0);return React.useEffect(()=>{r(o=>{if((n==null?void 0:n.texture)!==o){const i=n==null?void 0:n.texture;if(i)return i.hasAlpha=!0,i}return o})},[n]),a},useCachedModel=({url:e,cacheType:t=0})=>{const n=useCacheProvider({url:e,cacheType:t,assetType:2}),[a,r]=React.useState(void 0);return React.useEffect(()=>{r(o=>(n==null?void 0:n.assets)!==o?n==null?void 0:n.assets:o)},[n]),a},useCachedJSON=({url:e,cacheType:t=0})=>{const n=useCacheProvider({url:e,cacheType:t,assetType:3}),[a,r]=React.useState(void 0);return React.useEffect(()=>{r(o=>(n==null?void 0:n.json)!==o?n==null?void 0:n.json:o)},[n]),a},CacheProviderContext=React.createContext(void 0),CacheCallback=()=>{var y,E,k,b;const e=reactBabylonjs.useScene(),t=reactBabylonjs.useEngine(),{onFinish:n,onProgress:a,useLoadingScreen:r,hideLoadingWhenPostCalculate:o}=React.useContext(FetchAndCacheContext),i=React.useContext(CacheProviderContext),s=React.useRef(0),l=React.useRef(0),c=React.useRef({lastReportedLoaded:-1,lastReportedTotal:-1}),f=React.useRef([]),u=(y=i==null?void 0:i.totalCount)!=null?y:s,d=(E=i==null?void 0:i.loadedCount)!=null?E:l,h=(k=i==null?void 0:i.reported)!=null?k:c,m=(b=i==null?void 0:i.pending)!=null?b:f,R=React.useRef(null),v=Array.isArray(m.current)?m.current.length:m.current.size,g=React.useCallback(C=>{r===LoadingScreen.ENGINE_DEFAULT&&t&&(C?(R.current&&(clearTimeout(R.current),R.current=null),console.log("[Geo3DViewer] 显示加载界面"),t.displayLoadingUI()):R.current=setTimeout(()=>{console.log("[Geo3DViewer] 隐藏加载界面"),t.hideLoadingUI()},1e3))},[r,t]),x=React.useCallback(()=>{if(e&&h&&h.current){if(h.current.lastReportedLoaded!=d.current||h.current.lastReportedTotal!=u.current||v>0){console.log("[Geo3DViewer] 加载进度",d.current,u.current,v,"使用 Post 加载器",o,e.getMeshesByTags("loading").length+e.getTransformNodesByTags("loading").length);const C=a||(()=>{}),_=n||(()=>{});d.current<u.current||v>0||o&&e.getMeshesByTags("loading").length+e.getTransformNodesByTags("loading").length>0?(console.log("[Geo3DViewer] 加载进度",d.current,u.current),C(d.current,u.current),g(!0)):o?e.getMeshesByTags("loading").length+e.getTransformNodesByTags("loading").length===0&&(_(),g(!1)):d.current===u.current&&(_(),g(!1))}h.current.lastReportedLoaded=d.current,h.current.lastReportedTotal=u.current}},[h,d,u,a,m,g,o,e,n]);return React.useEffect(()=>{x();const C=setInterval(()=>{x()},1e3);return()=>clearInterval(C)},[x]),jsxRuntime.jsx(jsxRuntime.Fragment,{})},CacheCallback$1=CacheCallback,CachePreload=({url:e,cacheType:t,assetType:n=AssetType.BINARY})=>(useCacheProvider({url:e,cacheType:t,assetType:n}),jsxRuntime.jsx(jsxRuntime.Fragment,{})),CachePreload$1=CachePreload;class SimpleAnimationController{constructor(t){ue(this,"_nodes",[]);ue(this,"_speed",1);ue(this,"_loop",!1);ue(this,"_length",0);ue(this,"_name","");ue(this,"_stop",!1);ue(this,"_handler");ue(this,"_normalizedTime",0);ue(this,"_currentTime",0);this._name=t}set speed(t){this._speed=t}get name(){return this._name}get speed(){return this._speed}set loop(t){this._loop=t}get loop(){return this._loop}get time(){return this._normalizedTime*this.length*1e3}get normalized(){return this._normalizedTime}get index(){return 0}get length(){return this._length}get isPlaying(){return!(this._normalizedTime==0||this._normalizedTime>=1)}set nodes(t){this._nodes=t;const n=this._nodes[this._nodes.length-1].curves[0];this._length=n.keys[n.keys.length-1].time}get nodes(){return this._nodes}stop(){this._stop=!0}play(t=0){this._normalizedTime=t/this._length,this._stop=!1,this._currentTime=Date.now(),this.startPlay()}startPlay(){const t=setInterval(()=>{this.update()},30);this._handler=t}update(){if(this._stop){clearInterval(this._handler);return}const t=Date.now()-this._currentTime;this._currentTime=Date.now(),this._normalizedTime+=t/this._length*this._speed;for(let n=0;n<this._nodes.length;n++)this._nodes[n].update(this._normalizedTime*this._length);if(this._normalizedTime>=1){clearInterval(this._handler),this._normalizedTime=1;for(let n=0;n<this._nodes.length;n++)this._nodes[n].reset();this._loop&&!this._stop&&this.play();return}}onDestory(){clearInterval(this._handler)}}var indexMinimal={},minimal$1={},aspromise=asPromise;function asPromise(e,t){for(var n=new Array(arguments.length-1),a=0,r=2,o=!0;r<arguments.length;)n[a++]=arguments[r++];return new Promise(function(s,l){n[a]=function(f){if(o)if(o=!1,f)l(f);else{for(var u=new Array(arguments.length-1),d=0;d<u.length;)u[d++]=arguments[d];s.apply(null,u)}};try{e.apply(t||null,n)}catch(c){o&&(o=!1,l(c))}})}var base64$1={};(function(e){var t=e;t.length=function(s){var l=s.length;if(!l)return 0;for(var c=0;--l%4>1&&s.charAt(l)==="=";)++c;return Math.ceil(s.length*3)/4-c};for(var n=new Array(64),a=new Array(123),r=0;r<64;)a[n[r]=r<26?r+65:r<52?r+71:r<62?r-4:r-59|43]=r++;t.encode=function(s,l,c){for(var f=null,u=[],d=0,h=0,m;l<c;){var R=s[l++];switch(h){case 0:u[d++]=n[R>>2],m=(R&3)<<4,h=1;break;case 1:u[d++]=n[m|R>>4],m=(R&15)<<2,h=2;break;case 2:u[d++]=n[m|R>>6],u[d++]=n[R&63],h=0;break}d>8191&&((f||(f=[])).push(String.fromCharCode.apply(String,u)),d=0)}return h&&(u[d++]=n[m],u[d++]=61,h===1&&(u[d++]=61)),f?(d&&f.push(String.fromCharCode.apply(String,u.slice(0,d))),f.join("")):String.fromCharCode.apply(String,u.slice(0,d))};var o="invalid encoding";t.decode=function(s,l,c){for(var f=c,u=0,d,h=0;h<s.length;){var m=s.charCodeAt(h++);if(m===61&&u>1)break;if((m=a[m])===void 0)throw Error(o);switch(u){case 0:d=m,u=1;break;case 1:l[c++]=d<<2|(m&48)>>4,d=m,u=2;break;case 2:l[c++]=(d&15)<<4|(m&60)>>2,d=m,u=3;break;case 3:l[c++]=(d&3)<<6|m,u=0;break}}if(u===1)throw Error(o);return c-f},t.test=function(s){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s)}})(base64$1);var eventemitter=EventEmitter;function EventEmitter(){this._listeners={}}EventEmitter.prototype.on=function(t,n,a){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:n,ctx:a||this}),this};EventEmitter.prototype.off=function(t,n){if(t===void 0)this._listeners={};else if(n===void 0)this._listeners[t]=[];else for(var a=this._listeners[t],r=0;r<a.length;)a[r].fn===n?a.splice(r,1):++r;return this};EventEmitter.prototype.emit=function(t){var n=this._listeners[t];if(n){for(var a=[],r=1;r<arguments.length;)a.push(arguments[r++]);for(r=0;r<n.length;)n[r].fn.apply(n[r++].ctx,a)}return this};var float=factory(factory);function factory(e){return typeof Float32Array!="undefined"?function(){var t=new Float32Array([-0]),n=new Uint8Array(t.buffer),a=n[3]===128;function r(l,c,f){t[0]=l,c[f]=n[0],c[f+1]=n[1],c[f+2]=n[2],c[f+3]=n[3]}function o(l,c,f){t[0]=l,c[f]=n[3],c[f+1]=n[2],c[f+2]=n[1],c[f+3]=n[0]}e.writeFloatLE=a?r:o,e.writeFloatBE=a?o:r;function i(l,c){return n[0]=l[c],n[1]=l[c+1],n[2]=l[c+2],n[3]=l[c+3],t[0]}function s(l,c){return n[3]=l[c],n[2]=l[c+1],n[1]=l[c+2],n[0]=l[c+3],t[0]}e.readFloatLE=a?i:s,e.readFloatBE=a?s:i}():function(){function t(a,r,o,i){var s=r<0?1:0;if(s&&(r=-r),r===0)a(1/r>0?0:2147483648,o,i);else if(isNaN(r))a(2143289344,o,i);else if(r>34028234663852886e22)a((s<<31|2139095040)>>>0,o,i);else if(r<11754943508222875e-54)a((s<<31|Math.round(r/1401298464324817e-60))>>>0,o,i);else{var l=Math.floor(Math.log(r)/Math.LN2),c=Math.round(r*Math.pow(2,-l)*8388608)&8388607;a((s<<31|l+127<<23|c)>>>0,o,i)}}e.writeFloatLE=t.bind(null,writeUintLE),e.writeFloatBE=t.bind(null,writeUintBE);function n(a,r,o){var i=a(r,o),s=(i>>31)*2+1,l=i>>>23&255,c=i&8388607;return l===255?c?NaN:s*(1/0):l===0?s*1401298464324817e-60*c:s*Math.pow(2,l-150)*(c+8388608)}e.readFloatLE=n.bind(null,readUintLE),e.readFloatBE=n.bind(null,readUintBE)}(),typeof Float64Array!="undefined"?function(){var t=new Float64Array([-0]),n=new Uint8Array(t.buffer),a=n[7]===128;function r(l,c,f){t[0]=l,c[f]=n[0],c[f+1]=n[1],c[f+2]=n[2],c[f+3]=n[3],c[f+4]=n[4],c[f+5]=n[5],c[f+6]=n[6],c[f+7]=n[7]}function o(l,c,f){t[0]=l,c[f]=n[7],c[f+1]=n[6],c[f+2]=n[5],c[f+3]=n[4],c[f+4]=n[3],c[f+5]=n[2],c[f+6]=n[1],c[f+7]=n[0]}e.writeDoubleLE=a?r:o,e.writeDoubleBE=a?o:r;function i(l,c){return n[0]=l[c],n[1]=l[c+1],n[2]=l[c+2],n[3]=l[c+3],n[4]=l[c+4],n[5]=l[c+5],n[6]=l[c+6],n[7]=l[c+7],t[0]}function s(l,c){return n[7]=l[c],n[6]=l[c+1],n[5]=l[c+2],n[4]=l[c+3],n[3]=l[c+4],n[2]=l[c+5],n[1]=l[c+6],n[0]=l[c+7],t[0]}e.readDoubleLE=a?i:s,e.readDoubleBE=a?s:i}():function(){function t(a,r,o,i,s,l){var c=i<0?1:0;if(c&&(i=-i),i===0)a(0,s,l+r),a(1/i>0?0:2147483648,s,l+o);else if(isNaN(i))a(0,s,l+r),a(2146959360,s,l+o);else if(i>17976931348623157e292)a(0,s,l+r),a((c<<31|2146435072)>>>0,s,l+o);else{var f;if(i<22250738585072014e-324)f=i/5e-324,a(f>>>0,s,l+r),a((c<<31|f/4294967296)>>>0,s,l+o);else{var u=Math.floor(Math.log(i)/Math.LN2);u===1024&&(u=1023),f=i*Math.pow(2,-u),a(f*4503599627370496>>>0,s,l+r),a((c<<31|u+1023<<20|f*1048576&1048575)>>>0,s,l+o)}}}e.writeDoubleLE=t.bind(null,writeUintLE,0,4),e.writeDoubleBE=t.bind(null,writeUintBE,4,0);function n(a,r,o,i,s){var l=a(i,s+r),c=a(i,s+o),f=(c>>31)*2+1,u=c>>>20&2047,d=4294967296*(c&1048575)+l;return u===2047?d?NaN:f*(1/0):u===0?f*5e-324*d:f*Math.pow(2,u-1075)*(d+4503599627370496)}e.readDoubleLE=n.bind(null,readUintLE,0,4),e.readDoubleBE=n.bind(null,readUintBE,4,0)}(),e}function writeUintLE(e,t,n){t[n]=e&255,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}function writeUintBE(e,t,n){t[n]=e>>>24,t[n+1]=e>>>16&255,t[n+2]=e>>>8&255,t[n+3]=e&255}function readUintLE(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function readUintBE(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}var inquire_1=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}var utf8$2={};(function(e){var t=e;t.length=function(a){for(var r=0,o=0,i=0;i<a.length;++i)o=a.charCodeAt(i),o<128?r+=1:o<2048?r+=2:(o&64512)===55296&&(a.charCodeAt(i+1)&64512)===56320?(++i,r+=4):r+=3;return r},t.read=function(a,r,o){var i=o-r;if(i<1)return"";for(var s=null,l=[],c=0,f;r<o;)f=a[r++],f<128?l[c++]=f:f>191&&f<224?l[c++]=(f&31)<<6|a[r++]&63:f>239&&f<365?(f=((f&7)<<18|(a[r++]&63)<<12|(a[r++]&63)<<6|a[r++]&63)-65536,l[c++]=55296+(f>>10),l[c++]=56320+(f&1023)):l[c++]=(f&15)<<12|(a[r++]&63)<<6|a[r++]&63,c>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,l)),c=0);return s?(c&&s.push(String.fromCharCode.apply(String,l.slice(0,c))),s.join("")):String.fromCharCode.apply(String,l.slice(0,c))},t.write=function(a,r,o){for(var i=o,s,l,c=0;c<a.length;++c)s=a.charCodeAt(c),s<128?r[o++]=s:s<2048?(r[o++]=s>>6|192,r[o++]=s&63|128):(s&64512)===55296&&((l=a.charCodeAt(c+1))&64512)===56320?(s=65536+((s&1023)<<10)+(l&1023),++c,r[o++]=s>>18|240,r[o++]=s>>12&63|128,r[o++]=s>>6&63|128,r[o++]=s&63|128):(r[o++]=s>>12|224,r[o++]=s>>6&63|128,r[o++]=s&63|128);return o-i}})(utf8$2);var pool_1=pool;function pool(e,t,n){var a=n||8192,r=a>>>1,o=null,i=a;return function(l){if(l<1||l>r)return e(l);i+l>a&&(o=e(a),i=0);var c=t.call(o,i,i+=l);return i&7&&(i=(i|7)+1),c}}var longbits,hasRequiredLongbits;function requireLongbits(){if(hasRequiredLongbits)return longbits;hasRequiredLongbits=1,longbits=t;var e=requireMinimal();function t(o,i){this.lo=o>>>0,this.hi=i>>>0}var n=t.zero=new t(0,0);n.toNumber=function(){return 0},n.zzEncode=n.zzDecode=function(){return this},n.length=function(){return 1};var a=t.zeroHash="\0\0\0\0\0\0\0\0";t.fromNumber=function(i){if(i===0)return n;var s=i<0;s&&(i=-i);var l=i>>>0,c=(i-l)/4294967296>>>0;return s&&(c=~c>>>0,l=~l>>>0,++l>4294967295&&(l=0,++c>4294967295&&(c=0))),new t(l,c)},t.from=function(i){if(typeof i=="number")return t.fromNumber(i);if(e.isString(i))if(e.Long)i=e.Long.fromString(i);else return t.fromNumber(parseInt(i,10));return i.low||i.high?new t(i.low>>>0,i.high>>>0):n},t.prototype.toNumber=function(i){if(!i&&this.hi>>>31){var s=~this.lo+1>>>0,l=~this.hi>>>0;return s||(l=l+1>>>0),-(s+l*4294967296)}return this.lo+this.hi*4294967296},t.prototype.toLong=function(i){return e.Long?new e.Long(this.lo|0,this.hi|0,!!i):{low:this.lo|0,high:this.hi|0,unsigned:!!i}};var r=String.prototype.charCodeAt;return t.fromHash=function(i){return i===a?n:new t((r.call(i,0)|r.call(i,1)<<8|r.call(i,2)<<16|r.call(i,3)<<24)>>>0,(r.call(i,4)|r.call(i,5)<<8|r.call(i,6)<<16|r.call(i,7)<<24)>>>0)},t.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},t.prototype.zzEncode=function(){var i=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^i)>>>0,this.lo=(this.lo<<1^i)>>>0,this},t.prototype.zzDecode=function(){var i=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^i)>>>0,this.hi=(this.hi>>>1^i)>>>0,this},t.prototype.length=function(){var i=this.lo,s=(this.lo>>>28|this.hi<<4)>>>0,l=this.hi>>>24;return l===0?s===0?i<16384?i<128?1:2:i<2097152?3:4:s<16384?s<128?5:6:s<2097152?7:8:l<128?9:10},longbits}var hasRequiredMinimal;function requireMinimal(){return hasRequiredMinimal||(hasRequiredMinimal=1,function(e){var t=e;t.asPromise=aspromise,t.base64=base64$1,t.EventEmitter=eventemitter,t.float=float,t.inquire=inquire_1,t.utf8=utf8$2,t.pool=pool_1,t.LongBits=requireLongbits(),t.isNode=!!(typeof commonjsGlobal!="undefined"&&commonjsGlobal&&commonjsGlobal.process&&commonjsGlobal.process.versions&&commonjsGlobal.process.versions.node),t.global=t.isNode&&commonjsGlobal||typeof window!="undefined"&&window||typeof self!="undefined"&&self||commonjsGlobal,t.emptyArray=Object.freeze?Object.freeze([]):[],t.emptyObject=Object.freeze?Object.freeze({}):{},t.isInteger=Number.isInteger||function(o){return typeof o=="number"&&isFinite(o)&&Math.floor(o)===o},t.isString=function(o){return typeof o=="string"||o instanceof String},t.isObject=function(o){return o&&typeof o=="object"},t.isset=t.isSet=function(o,i){var s=o[i];return s!=null&&o.hasOwnProperty(i)?typeof s!="object"||(Array.isArray(s)?s.length:Object.keys(s).length)>0:!1},t.Buffer=function(){try{var r=t.inquire("buffer").Buffer;return r.prototype.utf8Write?r:null}catch(o){return null}}(),t._Buffer_from=null,t._Buffer_allocUnsafe=null,t.newBuffer=function(o){return typeof o=="number"?t.Buffer?t._Buffer_allocUnsafe(o):new t.Array(o):t.Buffer?t._Buffer_from(o):typeof Uint8Array=="undefined"?o:new Uint8Array(o)},t.Array=typeof Uint8Array!="undefined"?Uint8Array:Array,t.Long=t.global.dcodeIO&&t.global.dcodeIO.Long||t.global.Long||t.inquire("long"),t.key2Re=/^true|false|0|1$/,t.key32Re=/^-?(?:0|[1-9][0-9]*)$/,t.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,t.longToHash=function(o){return o?t.LongBits.from(o).toHash():t.LongBits.zeroHash},t.longFromHash=function(o,i){var s=t.LongBits.fromHash(o);return t.Long?t.Long.fromBits(s.lo,s.hi,i):s.toNumber(!!i)};function n(r,o,i){for(var s=Object.keys(o),l=0;l<s.length;++l)(r[s[l]]===void 0||!i)&&(r[s[l]]=o[s[l]]);return r}t.merge=n,t.lcFirst=function(o){return o.charAt(0).toLowerCase()+o.substring(1)};function a(r){function o(i,s){if(!(this instanceof o))return new o(i,s);Object.defineProperty(this,"message",{get:function(){return i}}),Error.captureStackTrace?Error.captureStackTrace(this,o):Object.defineProperty(this,"stack",{value:new Error().stack||""}),s&&n(this,s)}return o.prototype=Object.create(Error.prototype,{constructor:{value:o,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return r},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),o}t.newError=a,t.ProtocolError=a("ProtocolError"),t.oneOfGetter=function(o){for(var i={},s=0;s<o.length;++s)i[o[s]]=1;return function(){for(var l=Object.keys(this),c=l.length-1;c>-1;--c)if(i[l[c]]===1&&this[l[c]]!==void 0&&this[l[c]]!==null)return l[c]}},t.oneOfSetter=function(o){return function(i){for(var s=0;s<o.length;++s)o[s]!==i&&delete this[o[s]]}},t.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},t._configure=function(){var r=t.Buffer;if(!r){t._Buffer_from=t._Buffer_allocUnsafe=null;return}t._Buffer_from=r.from!==Uint8Array.from&&r.from||function(i,s){return new r(i,s)},t._Buffer_allocUnsafe=r.allocUnsafe||function(i){return new r(i)}}}(minimal$1)),minimal$1}var writer=Writer$1,util$4=requireMinimal(),BufferWriter$1,LongBits$1=util$4.LongBits,base64=util$4.base64,utf8$1=util$4.utf8;function Op(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}function noop(){}function State(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function Writer$1(){this.len=0,this.head=new Op(noop,0,0),this.tail=this.head,this.states=null}var create$1=function e(){return util$4.Buffer?function(){return(Writer$1.create=function(){return new BufferWriter$1})()}:function(){return new Writer$1}};Writer$1.create=create$1();Writer$1.alloc=function e(t){return new util$4.Array(t)};util$4.Array!==Array&&(Writer$1.alloc=util$4.pool(Writer$1.alloc,util$4.Array.prototype.subarray));Writer$1.prototype._push=function e(t,n,a){return this.tail=this.tail.next=new Op(t,n,a),this.len+=n,this};function writeByte(e,t,n){t[n]=e&255}function writeVarint32(e,t,n){for(;e>127;)t[n++]=e&127|128,e>>>=7;t[n]=e}function VarintOp(e,t){this.len=e,this.next=void 0,this.val=t}VarintOp.prototype=Object.create(Op.prototype);VarintOp.prototype.fn=writeVarint32;Writer$1.prototype.uint32=function e(t){return this.len+=(this.tail=this.tail.next=new VarintOp((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this};Writer$1.prototype.int32=function e(t){return t<0?this._push(writeVarint64,10,LongBits$1.fromNumber(t)):this.uint32(t)};Writer$1.prototype.sint32=function e(t){return this.uint32((t<<1^t>>31)>>>0)};function writeVarint64(e,t,n){for(;e.hi;)t[n++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[n++]=e.lo&127|128,e.lo=e.lo>>>7;t[n++]=e.lo}Writer$1.prototype.uint64=function e(t){var n=LongBits$1.from(t);return this._push(writeVarint64,n.length(),n)};Writer$1.prototype.int64=Writer$1.prototype.uint64;Writer$1.prototype.sint64=function e(t){var n=LongBits$1.from(t).zzEncode();return this._push(writeVarint64,n.length(),n)};Writer$1.prototype.bool=function e(t){return this._push(writeByte,1,t?1:0)};function writeFixed32(e,t,n){t[n]=e&255,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}Writer$1.prototype.fixed32=function e(t){return this._push(writeFixed32,4,t>>>0)};Writer$1.prototype.sfixed32=Writer$1.prototype.fixed32;Writer$1.prototype.fixed64=function e(t){var n=LongBits$1.from(t);return this._push(writeFixed32,4,n.lo)._push(writeFixed32,4,n.hi)};Writer$1.prototype.sfixed64=Writer$1.prototype.fixed64;Writer$1.prototype.float=function e(t){return this._push(util$4.float.writeFloatLE,4,t)};Writer$1.prototype.double=function e(t){return this._push(util$4.float.writeDoubleLE,8,t)};var writeBytes=util$4.Array.prototype.set?function e(t,n,a){n.set(t,a)}:function e(t,n,a){for(var r=0;r<t.length;++r)n[a+r]=t[r]};Writer$1.prototype.bytes=function e(t){var n=t.length>>>0;if(!n)return this._push(writeByte,1,0);if(util$4.isString(t)){var a=Writer$1.alloc(n=base64.length(t));base64.decode(t,a,0),t=a}return this.uint32(n)._push(writeBytes,n,t)};Writer$1.prototype.string=function e(t){var n=utf8$1.length(t);return n?this.uint32(n)._push(utf8$1.write,n,t):this._push(writeByte,1,0)};Writer$1.prototype.fork=function e(){return this.states=new State(this),this.head=this.tail=new Op(noop,0,0),this.len=0,this};Writer$1.prototype.reset=function e(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Op(noop,0,0),this.len=0),this};Writer$1.prototype.ldelim=function e(){var t=this.head,n=this.tail,a=this.len;return this.reset().uint32(a),a&&(this.tail.next=t.next,this.tail=n,this.len+=a),this};Writer$1.prototype.finish=function e(){for(var t=this.head.next,n=this.constructor.alloc(this.len),a=0;t;)t.fn(t.val,n,a),a+=t.len,t=t.next;return n};Writer$1._configure=function(e){BufferWriter$1=e,Writer$1.create=create$1(),BufferWriter$1._configure()};var writer_buffer=BufferWriter,Writer=writer;(BufferWriter.prototype=Object.create(Writer.prototype)).constructor=BufferWriter;var util$3=requireMinimal();function BufferWriter(){Writer.call(this)}BufferWriter._configure=function(){BufferWriter.alloc=util$3._Buffer_allocUnsafe,BufferWriter.writeBytesBuffer=util$3.Buffer&&util$3.Buffer.prototype instanceof Uint8Array&&util$3.Buffer.prototype.set.name==="set"?function(t,n,a){n.set(t,a)}:function(t,n,a){if(t.copy)t.copy(n,a,0,t.length);else for(var r=0;r<t.length;)n[a++]=t[r++]}};BufferWriter.prototype.bytes=function e(t){util$3.isString(t)&&(t=util$3._Buffer_from(t,"base64"));var n=t.length>>>0;return this.uint32(n),n&&this._push(BufferWriter.writeBytesBuffer,n,t),this};function writeStringBuffer(e,t,n){e.length<40?util$3.utf8.write(e,t,n):t.utf8Write?t.utf8Write(e,n):t.write(e,n)}BufferWriter.prototype.string=function e(t){var n=util$3.Buffer.byteLength(t);return this.uint32(n),n&&this._push(writeStringBuffer,n,t),this};BufferWriter._configure();var reader=Reader$1,util$2=requireMinimal(),BufferReader$1,LongBits=util$2.LongBits,utf8=util$2.utf8;function indexOutOfRange(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function Reader$1(e){this.buf=e,this.pos=0,this.len=e.length}var create_array=typeof Uint8Array!="undefined"?function e(t){if(t instanceof Uint8Array||Array.isArray(t))return new Reader$1(t);throw Error("illegal buffer")}:function e(t){if(Array.isArray(t))return new Reader$1(t);throw Error("illegal buffer")},create=function e(){return util$2.Buffer?function(n){return(Reader$1.create=function(r){return util$2.Buffer.isBuffer(r)?new BufferReader$1(r):create_array(r)})(n)}:create_array};Reader$1.create=create();Reader$1.prototype._slice=util$2.Array.prototype.subarray||util$2.Array.prototype.slice;Reader$1.prototype.uint32=function e(){var t=4294967295;return function(){if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,indexOutOfRange(this,10);return t}}();Reader$1.prototype.int32=function e(){return this.uint32()|0};Reader$1.prototype.sint32=function e(){var t=this.uint32();return t>>>1^-(t&1)|0};function readLongVarint(){var e=new LongBits(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw indexOutOfRange(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw indexOutOfRange(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}Reader$1.prototype.bool=function e(){return this.uint32()!==0};function readFixed32_end(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}Reader$1.prototype.fixed32=function e(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)};Reader$1.prototype.sfixed32=function e(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)|0};function readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange(this,8);return new LongBits(readFixed32_end(this.buf,this.pos+=4),readFixed32_end(this.buf,this.pos+=4))}Reader$1.prototype.float=function e(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);var t=util$2.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t};Reader$1.prototype.double=function e(){if(this.pos+8>this.len)throw indexOutOfRange(this,4);var t=util$2.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t};Reader$1.prototype.bytes=function e(){var t=this.uint32(),n=this.pos,a=this.pos+t;if(a>this.len)throw indexOutOfRange(this,t);if(this.pos+=t,Array.isArray(this.buf))return this.buf.slice(n,a);if(n===a){var r=util$2.Buffer;return r?r.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,n,a)};Reader$1.prototype.string=function e(){var t=this.bytes();return utf8.read(t,0,t.length)};Reader$1.prototype.skip=function e(t){if(typeof t=="number"){if(this.pos+t>this.len)throw indexOutOfRange(this,t);this.pos+=t}else do if(this.pos>=this.len)throw indexOutOfRange(this);while(this.buf[this.pos++]&128);return this};Reader$1.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this};Reader$1._configure=function(e){BufferReader$1=e,Reader$1.create=create(),BufferReader$1._configure();var t=util$2.Long?"toLong":"toNumber";util$2.merge(Reader$1.prototype,{int64:function(){return readLongVarint.call(this)[t](!1)},uint64:function(){return readLongVarint.call(this)[t](!0)},sint64:function(){return readLongVarint.call(this).zzDecode()[t](!1)},fixed64:function(){return readFixed64.call(this)[t](!0)},sfixed64:function(){return readFixed64.call(this)[t](!1)}})};var reader_buffer=BufferReader,Reader=reader;(BufferReader.prototype=Object.create(Reader.prototype)).constructor=BufferReader;var util$1=requireMinimal();function BufferReader(e){Reader.call(this,e)}BufferReader._configure=function(){util$1.Buffer&&(BufferReader.prototype._slice=util$1.Buffer.prototype.slice)};BufferReader.prototype.string=function e(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))};BufferReader._configure();var rpc={},service=Service,util=requireMinimal();(Service.prototype=Object.create(util.EventEmitter.prototype)).constructor=Service;function Service(e,t,n){if(typeof e!="function")throw TypeError("rpcImpl must be a function");util.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=!!t,this.responseDelimited=!!n}Service.prototype.rpcCall=function e(t,n,a,r,o){if(!r)throw TypeError("request must be specified");var i=this;if(!o)return util.asPromise(e,i,t,n,a,r);if(!i.rpcImpl){setTimeout(function(){o(Error("already ended"))},0);return}try{return i.rpcImpl(t,n[i.requestDelimited?"encodeDelimited":"encode"](r).finish(),function(l,c){if(l)return i.emit("error",l,t),o(l);if(c===null){i.end(!0);return}if(!(c instanceof a))try{c=a[i.responseDelimited?"decodeDelimited":"decode"](c)}catch(f){return i.emit("error",f,t),o(f)}return i.emit("data",c,t),o(null,c)})}catch(s){i.emit("error",s,t),setTimeout(function(){o(s)},0);return}};Service.prototype.end=function e(t){return this.rpcImpl&&(t||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this};(function(e){var t=e;t.Service=service})(rpc);var roots={};(function(e){var t=e;t.build="minimal",t.Writer=writer,t.BufferWriter=writer_buffer,t.Reader=reader,t.BufferReader=reader_buffer,t.util=requireMinimal(),t.rpc=rpc,t.roots=roots,t.configure=n;function n(){t.util._configure(),t.Writer._configure(t.BufferWriter),t.Reader._configure(t.BufferReader)}n()})(indexMinimal);var minimal=indexMinimal;function dataTypeFromJSON(e){switch(e){case 0:case"UNKNOWN":return 0;case 4:case"ROADWAY":return 4;case-1:case"UNRECOGNIZED":default:return-1}}function dataTypeToJSON(e){switch(e){case 0:return"UNKNOWN";case 4:return"ROADWAY";case-1:default:return"UNRECOGNIZED"}}function createBaseVertex(){return{x:0,y:0,z:0}}const Vertex={encode(e,t=minimal.Writer.create()){return e.x!==0&&t.uint32(13).float(e.x),e.y!==0&&t.uint32(21).float(e.y),e.z!==0&&t.uint32(29).float(e.z),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseVertex();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==13)break;r.x=n.float();continue;case 2:if(o!==21)break;r.y=n.float();continue;case 3:if(o!==29)break;r.z=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{x:isSet$h(e.x)?globalThis.Number(e.x):0,y:isSet$h(e.y)?globalThis.Number(e.y):0,z:isSet$h(e.z)?globalThis.Number(e.z):0}},toJSON(e){const t={};return e.x!==0&&(t.x=e.x),e.y!==0&&(t.y=e.y),e.z!==0&&(t.z=e.z),t},create(e){return Vertex.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=createBaseVertex();return t.x=(n=e.x)!=null?n:0,t.y=(a=e.y)!=null?a:0,t.z=(r=e.z)!=null?r:0,t}};function createBaseColor(){return{r:0,g:0,b:0,a:0}}const Color={encode(e,t=minimal.Writer.create()){return e.r!==0&&t.uint32(13).float(e.r),e.g!==0&&t.uint32(21).float(e.g),e.b!==0&&t.uint32(29).float(e.b),e.a!==0&&t.uint32(37).float(e.a),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseColor();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==13)break;r.r=n.float();continue;case 2:if(o!==21)break;r.g=n.float();continue;case 3:if(o!==29)break;r.b=n.float();continue;case 4:if(o!==37)break;r.a=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{r:isSet$h(e.r)?globalThis.Number(e.r):0,g:isSet$h(e.g)?globalThis.Number(e.g):0,b:isSet$h(e.b)?globalThis.Number(e.b):0,a:isSet$h(e.a)?globalThis.Number(e.a):0}},toJSON(e){const t={};return e.r!==0&&(t.r=e.r),e.g!==0&&(t.g=e.g),e.b!==0&&(t.b=e.b),e.a!==0&&(t.a=e.a),t},create(e){return Color.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o;const t=createBaseColor();return t.r=(n=e.r)!=null?n:0,t.g=(a=e.g)!=null?a:0,t.b=(r=e.b)!=null?r:0,t.a=(o=e.a)!=null?o:0,t}};function createBasePosition(){return{x:0,y:0,z:0}}const Position={encode(e,t=minimal.Writer.create()){return e.x!==0&&t.uint32(13).float(e.x),e.y!==0&&t.uint32(21).float(e.y),e.z!==0&&t.uint32(29).float(e.z),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBasePosition();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==13)break;r.x=n.float();continue;case 2:if(o!==21)break;r.y=n.float();continue;case 3:if(o!==29)break;r.z=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{x:isSet$h(e.x)?globalThis.Number(e.x):0,y:isSet$h(e.y)?globalThis.Number(e.y):0,z:isSet$h(e.z)?globalThis.Number(e.z):0}},toJSON(e){const t={};return e.x!==0&&(t.x=e.x),e.y!==0&&(t.y=e.y),e.z!==0&&(t.z=e.z),t},create(e){return Position.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=createBasePosition();return t.x=(n=e.x)!=null?n:0,t.y=(a=e.y)!=null?a:0,t.z=(r=e.z)!=null?r:0,t}};function createBaseMesh(){return{vertices:[],normals:[],indices:[],colors:[],uv:[]}}const Mesh={encode(e,t=minimal.Writer.create()){t.uint32(10).fork();for(const n of e.vertices)t.float(n);t.ldelim(),t.uint32(18).fork();for(const n of e.normals)t.float(n);t.ldelim(),t.uint32(26).fork();for(const n of e.indices)t.uint32(n);t.ldelim(),t.uint32(34).fork();for(const n of e.colors)t.float(n);t.ldelim(),t.uint32(42).fork();for(const n of e.uv)t.float(n);return t.ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseMesh();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o===13){r.vertices.push(n.float());continue}if(o===10){const i=n.uint32()+n.pos;for(;n.pos<i;)r.vertices.push(n.float());continue}break;case 2:if(o===21){r.normals.push(n.float());continue}if(o===18){const i=n.uint32()+n.pos;for(;n.pos<i;)r.normals.push(n.float());continue}break;case 3:if(o===24){r.indices.push(n.uint32());continue}if(o===26){const i=n.uint32()+n.pos;for(;n.pos<i;)r.indices.push(n.uint32());continue}break;case 4:if(o===37){r.colors.push(n.float());continue}if(o===34){const i=n.uint32()+n.pos;for(;n.pos<i;)r.colors.push(n.float());continue}break;case 5:if(o===45){r.uv.push(n.float());continue}if(o===42){const i=n.uint32()+n.pos;for(;n.pos<i;)r.uv.push(n.float());continue}break}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{vertices:globalThis.Array.isArray(e==null?void 0:e.vertices)?e.vertices.map(t=>globalThis.Number(t)):[],normals:globalThis.Array.isArray(e==null?void 0:e.normals)?e.normals.map(t=>globalThis.Number(t)):[],indices:globalThis.Array.isArray(e==null?void 0:e.indices)?e.indices.map(t=>globalThis.Number(t)):[],colors:globalThis.Array.isArray(e==null?void 0:e.colors)?e.colors.map(t=>globalThis.Number(t)):[],uv:globalThis.Array.isArray(e==null?void 0:e.uv)?e.uv.map(t=>globalThis.Number(t)):[]}},toJSON(e){var n,a,r,o,i;const t={};return(n=e.vertices)!=null&&n.length&&(t.vertices=e.vertices),(a=e.normals)!=null&&a.length&&(t.normals=e.normals),(r=e.indices)!=null&&r.length&&(t.indices=e.indices.map(s=>Math.round(s))),(o=e.colors)!=null&&o.length&&(t.colors=e.colors),(i=e.uv)!=null&&i.length&&(t.uv=e.uv),t},create(e){return Mesh.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=createBaseMesh();return t.vertices=((n=e.vertices)==null?void 0:n.map(s=>s))||[],t.normals=((a=e.normals)==null?void 0:a.map(s=>s))||[],t.indices=((r=e.indices)==null?void 0:r.map(s=>s))||[],t.colors=((o=e.colors)==null?void 0:o.map(s=>s))||[],t.uv=((i=e.uv)==null?void 0:i.map(s=>s))||[],t}};function isSet$h(e){return e!=null}function roadWayTypeFromJSON(e){switch(e){case 0:case"RECTANGLE":return 0;case 1:case"CICLE":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function roadWayTypeToJSON(e){switch(e){case 0:return"RECTANGLE";case 1:return"CICLE";case-1:default:return"UNRECOGNIZED"}}function createBaseRoadWay(){return{dataType:0,name:"",position:void 0,boxes:[]}}const RoadWay$2={encode(e,t=minimal.Writer.create()){e.dataType!==0&&t.uint32(8).int32(e.dataType),e.name!==""&&t.uint32(26).string(e.name),e.position!==void 0&&Vertex.encode(e.position,t.uint32(34).fork()).ldelim();for(const n of e.boxes)RoadWay_RoadWayBox.encode(n,t.uint32(66).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWay();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==8)break;r.dataType=n.int32();continue;case 3:if(o!==26)break;r.name=n.string();continue;case 4:if(o!==34)break;r.position=Vertex.decode(n,n.uint32());continue;case 8:if(o!==66)break;r.boxes.push(RoadWay_RoadWayBox.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{dataType:isSet$g(e.dataType)?dataTypeFromJSON(e.dataType):0,name:isSet$g(e.name)?globalThis.String(e.name):"",position:isSet$g(e.position)?Vertex.fromJSON(e.position):void 0,boxes:globalThis.Array.isArray(e==null?void 0:e.boxes)?e.boxes.map(t=>RoadWay_RoadWayBox.fromJSON(t)):[]}},toJSON(e){var n;const t={};return e.dataType!==0&&(t.dataType=dataTypeToJSON(e.dataType)),e.name!==""&&(t.name=e.name),e.position!==void 0&&(t.position=Vertex.toJSON(e.position)),(n=e.boxes)!=null&&n.length&&(t.boxes=e.boxes.map(a=>RoadWay_RoadWayBox.toJSON(a))),t},create(e){return RoadWay$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=createBaseRoadWay();return t.dataType=(n=e.dataType)!=null?n:0,t.name=(a=e.name)!=null?a:"",t.position=e.position!==void 0&&e.position!==null?Vertex.fromPartial(e.position):void 0,t.boxes=((r=e.boxes)==null?void 0:r.map(o=>RoadWay_RoadWayBox.fromPartial(o)))||[],t}};function createBaseRoadWay_RoadWayBox(){return{name:"",leftSpace:0,rightSpace:0,startPosition:void 0,endPosition:void 0,type:0,topMesh:void 0,sideMesh:void 0,bottomMesh:void 0,width:0,height:0,startOutWidth:0,endOutWidth:0}}const RoadWay_RoadWayBox={encode(e,t=minimal.Writer.create()){return e.name!==""&&t.uint32(10).string(e.name),e.leftSpace!==0&&t.uint32(21).float(e.leftSpace),e.rightSpace!==0&&t.uint32(29).float(e.rightSpace),e.startPosition!==void 0&&Vertex.encode(e.startPosition,t.uint32(34).fork()).ldelim(),e.endPosition!==void 0&&Vertex.encode(e.endPosition,t.uint32(42).fork()).ldelim(),e.type!==0&&t.uint32(48).int32(e.type),e.topMesh!==void 0&&Mesh.encode(e.topMesh,t.uint32(58).fork()).ldelim(),e.sideMesh!==void 0&&Mesh.encode(e.sideMesh,t.uint32(66).fork()).ldelim(),e.bottomMesh!==void 0&&Mesh.encode(e.bottomMesh,t.uint32(74).fork()).ldelim(),e.width!==0&&t.uint32(85).float(e.width),e.height!==0&&t.uint32(93).float(e.height),e.startOutWidth!==0&&t.uint32(101).float(e.startOutWidth),e.endOutWidth!==0&&t.uint32(109).float(e.endOutWidth),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWay_RoadWayBox();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==21)break;r.leftSpace=n.float();continue;case 3:if(o!==29)break;r.rightSpace=n.float();continue;case 4:if(o!==34)break;r.startPosition=Vertex.decode(n,n.uint32());continue;case 5:if(o!==42)break;r.endPosition=Vertex.decode(n,n.uint32());continue;case 6:if(o!==48)break;r.type=n.int32();continue;case 7:if(o!==58)break;r.topMesh=Mesh.decode(n,n.uint32());continue;case 8:if(o!==66)break;r.sideMesh=Mesh.decode(n,n.uint32());continue;case 9:if(o!==74)break;r.bottomMesh=Mesh.decode(n,n.uint32());continue;case 10:if(o!==85)break;r.width=n.float();continue;case 11:if(o!==93)break;r.height=n.float();continue;case 12:if(o!==101)break;r.startOutWidth=n.float();continue;case 13:if(o!==109)break;r.endOutWidth=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$g(e.name)?globalThis.String(e.name):"",leftSpace:isSet$g(e.leftSpace)?globalThis.Number(e.leftSpace):0,rightSpace:isSet$g(e.rightSpace)?globalThis.Number(e.rightSpace):0,startPosition:isSet$g(e.startPosition)?Vertex.fromJSON(e.startPosition):void 0,endPosition:isSet$g(e.endPosition)?Vertex.fromJSON(e.endPosition):void 0,type:isSet$g(e.type)?roadWayTypeFromJSON(e.type):0,topMesh:isSet$g(e.topMesh)?Mesh.fromJSON(e.topMesh):void 0,sideMesh:isSet$g(e.sideMesh)?Mesh.fromJSON(e.sideMesh):void 0,bottomMesh:isSet$g(e.bottomMesh)?Mesh.fromJSON(e.bottomMesh):void 0,width:isSet$g(e.width)?globalThis.Number(e.width):0,height:isSet$g(e.height)?globalThis.Number(e.height):0,startOutWidth:isSet$g(e.startOutWidth)?globalThis.Number(e.startOutWidth):0,endOutWidth:isSet$g(e.endOutWidth)?globalThis.Number(e.endOutWidth):0}},toJSON(e){const t={};return e.name!==""&&(t.name=e.name),e.leftSpace!==0&&(t.leftSpace=e.leftSpace),e.rightSpace!==0&&(t.rightSpace=e.rightSpace),e.startPosition!==void 0&&(t.startPosition=Vertex.toJSON(e.startPosition)),e.endPosition!==void 0&&(t.endPosition=Vertex.toJSON(e.endPosition)),e.type!==0&&(t.type=roadWayTypeToJSON(e.type)),e.topMesh!==void 0&&(t.topMesh=Mesh.toJSON(e.topMesh)),e.sideMesh!==void 0&&(t.sideMesh=Mesh.toJSON(e.sideMesh)),e.bottomMesh!==void 0&&(t.bottomMesh=Mesh.toJSON(e.bottomMesh)),e.width!==0&&(t.width=e.width),e.height!==0&&(t.height=e.height),e.startOutWidth!==0&&(t.startOutWidth=e.startOutWidth),e.endOutWidth!==0&&(t.endOutWidth=e.endOutWidth),t},create(e){return RoadWay_RoadWayBox.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l,c;const t=createBaseRoadWay_RoadWayBox();return t.name=(n=e.name)!=null?n:"",t.leftSpace=(a=e.leftSpace)!=null?a:0,t.rightSpace=(r=e.rightSpace)!=null?r:0,t.startPosition=e.startPosition!==void 0&&e.startPosition!==null?Vertex.fromPartial(e.startPosition):void 0,t.endPosition=e.endPosition!==void 0&&e.endPosition!==null?Vertex.fromPartial(e.endPosition):void 0,t.type=(o=e.type)!=null?o:0,t.topMesh=e.topMesh!==void 0&&e.topMesh!==null?Mesh.fromPartial(e.topMesh):void 0,t.sideMesh=e.sideMesh!==void 0&&e.sideMesh!==null?Mesh.fromPartial(e.sideMesh):void 0,t.bottomMesh=e.bottomMesh!==void 0&&e.bottomMesh!==null?Mesh.fromPartial(e.bottomMesh):void 0,t.width=(i=e.width)!=null?i:0,t.height=(s=e.height)!=null?s:0,t.startOutWidth=(l=e.startOutWidth)!=null?l:0,t.endOutWidth=(c=e.endOutWidth)!=null?c:0,t}};function isSet$g(e){return e!=null}function roadWayAnim_FrameTypeFromJSON(e){switch(e){case 0:case"NORMAL_FRAME":return 0;case 1:case"KEY_FRAME":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function roadWayAnim_FrameTypeToJSON(e){switch(e){case 0:return"NORMAL_FRAME";case 1:return"KEY_FRAME";case-1:default:return"UNRECOGNIZED"}}var RoadWayAnim_AnimType=(e=>(e[e.RUN=0]="RUN",e[e.WATER=1]="WATER",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(RoadWayAnim_AnimType||{});function roadWayAnim_AnimTypeFromJSON(e){switch(e){case 0:case"RUN":return 0;case 1:case"WATER":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function roadWayAnim_AnimTypeToJSON(e){switch(e){case 0:return"RUN";case 1:return"WATER";case-1:default:return"UNRECOGNIZED"}}function createBaseRoadWayAnim(){return{name:"",frameRate:0,type:0,frames:[],boxes:[],animType:0,colors:[]}}const RoadWayAnim={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.frameRate!==0&&t.uint32(16).uint32(e.frameRate),e.type!==0&&t.uint32(24).int32(e.type);for(const n of e.frames)RoadWayAnim_Frame.encode(n,t.uint32(34).fork()).ldelim();for(const n of e.boxes)RoadWay_RoadWayBox.encode(n,t.uint32(42).fork()).ldelim();e.animType!==0&&t.uint32(48).int32(e.animType);for(const n of e.colors)Color.encode(n,t.uint32(58).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayAnim();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==16)break;r.frameRate=n.uint32();continue;case 3:if(o!==24)break;r.type=n.int32();continue;case 4:if(o!==34)break;r.frames.push(RoadWayAnim_Frame.decode(n,n.uint32()));continue;case 5:if(o!==42)break;r.boxes.push(RoadWay_RoadWayBox.decode(n,n.uint32()));continue;case 6:if(o!==48)break;r.animType=n.int32();continue;case 7:if(o!==58)break;r.colors.push(Color.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$f(e.name)?globalThis.String(e.name):"",frameRate:isSet$f(e.frameRate)?globalThis.Number(e.frameRate):0,type:isSet$f(e.type)?roadWayAnim_FrameTypeFromJSON(e.type):0,frames:globalThis.Array.isArray(e==null?void 0:e.frames)?e.frames.map(t=>RoadWayAnim_Frame.fromJSON(t)):[],boxes:globalThis.Array.isArray(e==null?void 0:e.boxes)?e.boxes.map(t=>RoadWay_RoadWayBox.fromJSON(t)):[],animType:isSet$f(e.animType)?roadWayAnim_AnimTypeFromJSON(e.animType):0,colors:globalThis.Array.isArray(e==null?void 0:e.colors)?e.colors.map(t=>Color.fromJSON(t)):[]}},toJSON(e){var n,a,r;const t={};return e.name!==""&&(t.name=e.name),e.frameRate!==0&&(t.frameRate=Math.round(e.frameRate)),e.type!==0&&(t.type=roadWayAnim_FrameTypeToJSON(e.type)),(n=e.frames)!=null&&n.length&&(t.frames=e.frames.map(o=>RoadWayAnim_Frame.toJSON(o))),(a=e.boxes)!=null&&a.length&&(t.boxes=e.boxes.map(o=>RoadWay_RoadWayBox.toJSON(o))),e.animType!==0&&(t.animType=roadWayAnim_AnimTypeToJSON(e.animType)),(r=e.colors)!=null&&r.length&&(t.colors=e.colors.map(o=>Color.toJSON(o))),t},create(e){return RoadWayAnim.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l;const t=createBaseRoadWayAnim();return t.name=(n=e.name)!=null?n:"",t.frameRate=(a=e.frameRate)!=null?a:0,t.type=(r=e.type)!=null?r:0,t.frames=((o=e.frames)==null?void 0:o.map(c=>RoadWayAnim_Frame.fromPartial(c)))||[],t.boxes=((i=e.boxes)==null?void 0:i.map(c=>RoadWay_RoadWayBox.fromPartial(c)))||[],t.animType=(s=e.animType)!=null?s:0,t.colors=((l=e.colors)==null?void 0:l.map(c=>Color.fromPartial(c)))||[],t}};function createBaseRoadWayAnim_Percent(){return{start:0,end:0}}const RoadWayAnim_Percent={encode(e,t=minimal.Writer.create()){return e.start!==0&&t.uint32(13).float(e.start),e.end!==0&&t.uint32(21).float(e.end),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayAnim_Percent();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==13)break;r.start=n.float();continue;case 2:if(o!==21)break;r.end=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{start:isSet$f(e.start)?globalThis.Number(e.start):0,end:isSet$f(e.end)?globalThis.Number(e.end):0}},toJSON(e){const t={};return e.start!==0&&(t.start=e.start),e.end!==0&&(t.end=e.end),t},create(e){return RoadWayAnim_Percent.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseRoadWayAnim_Percent();return t.start=(n=e.start)!=null?n:0,t.end=(a=e.end)!=null?a:0,t}};function createBaseRoadWayAnim_Node(){return{index:0,name:"",percent:[],colorPercent:[]}}const RoadWayAnim_Node={encode(e,t=minimal.Writer.create()){e.index!==0&&t.uint32(8).uint32(e.index),e.name!==""&&t.uint32(18).string(e.name);for(const n of e.percent)RoadWayAnim_Percent.encode(n,t.uint32(26).fork()).ldelim();for(const n of e.colorPercent)RoadWayAnim_Percent.encode(n,t.uint32(34).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayAnim_Node();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==8)break;r.index=n.uint32();continue;case 2:if(o!==18)break;r.name=n.string();continue;case 3:if(o!==26)break;r.percent.push(RoadWayAnim_Percent.decode(n,n.uint32()));continue;case 4:if(o!==34)break;r.colorPercent.push(RoadWayAnim_Percent.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{index:isSet$f(e.index)?globalThis.Number(e.index):0,name:isSet$f(e.name)?globalThis.String(e.name):"",percent:globalThis.Array.isArray(e==null?void 0:e.percent)?e.percent.map(t=>RoadWayAnim_Percent.fromJSON(t)):[],colorPercent:globalThis.Array.isArray(e==null?void 0:e.colorPercent)?e.colorPercent.map(t=>RoadWayAnim_Percent.fromJSON(t)):[]}},toJSON(e){var n,a;const t={};return e.index!==0&&(t.index=Math.round(e.index)),e.name!==""&&(t.name=e.name),(n=e.percent)!=null&&n.length&&(t.percent=e.percent.map(r=>RoadWayAnim_Percent.toJSON(r))),(a=e.colorPercent)!=null&&a.length&&(t.colorPercent=e.colorPercent.map(r=>RoadWayAnim_Percent.toJSON(r))),t},create(e){return RoadWayAnim_Node.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o;const t=createBaseRoadWayAnim_Node();return t.index=(n=e.index)!=null?n:0,t.name=(a=e.name)!=null?a:"",t.percent=((r=e.percent)==null?void 0:r.map(i=>RoadWayAnim_Percent.fromPartial(i)))||[],t.colorPercent=((o=e.colorPercent)==null?void 0:o.map(i=>RoadWayAnim_Percent.fromPartial(i)))||[],t}};function createBaseRoadWayAnim_Frame(){return{node:[],time:0}}const RoadWayAnim_Frame={encode(e,t=minimal.Writer.create()){for(const n of e.node)RoadWayAnim_Node.encode(n,t.uint32(10).fork()).ldelim();return e.time!==0&&t.uint32(21).float(e.time),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayAnim_Frame();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.node.push(RoadWayAnim_Node.decode(n,n.uint32()));continue;case 2:if(o!==21)break;r.time=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{node:globalThis.Array.isArray(e==null?void 0:e.node)?e.node.map(t=>RoadWayAnim_Node.fromJSON(t)):[],time:isSet$f(e.time)?globalThis.Number(e.time):0}},toJSON(e){var n;const t={};return(n=e.node)!=null&&n.length&&(t.node=e.node.map(a=>RoadWayAnim_Node.toJSON(a))),e.time!==0&&(t.time=e.time),t},create(e){return RoadWayAnim_Frame.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseRoadWayAnim_Frame();return t.node=((n=e.node)==null?void 0:n.map(r=>RoadWayAnim_Node.fromPartial(r)))||[],t.time=(a=e.time)!=null?a:0,t}};function isSet$f(e){return e!=null}function roadWayNearFlowAnim_FrameTypeFromJSON(e){switch(e){case 0:case"NORMAL_FRAME":return 0;case 1:case"KEY_FRAME":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function roadWayNearFlowAnim_FrameTypeToJSON(e){switch(e){case 0:return"NORMAL_FRAME";case 1:return"KEY_FRAME";case-1:default:return"UNRECOGNIZED"}}function createBaseRoadWayNearFlowAnim(){return{name:"",frameRate:0,type:0,nodes:[],boxes:[]}}const RoadWayNearFlowAnim={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.frameRate!==0&&t.uint32(16).uint32(e.frameRate),e.type!==0&&t.uint32(24).int32(e.type);for(const n of e.nodes)RoadWayNearFlowAnim_Node.encode(n,t.uint32(34).fork()).ldelim();for(const n of e.boxes)RoadWay_RoadWayBox.encode(n,t.uint32(42).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayNearFlowAnim();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==16)break;r.frameRate=n.uint32();continue;case 3:if(o!==24)break;r.type=n.int32();continue;case 4:if(o!==34)break;r.nodes.push(RoadWayNearFlowAnim_Node.decode(n,n.uint32()));continue;case 5:if(o!==42)break;r.boxes.push(RoadWay_RoadWayBox.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$e(e.name)?globalThis.String(e.name):"",frameRate:isSet$e(e.frameRate)?globalThis.Number(e.frameRate):0,type:isSet$e(e.type)?roadWayNearFlowAnim_FrameTypeFromJSON(e.type):0,nodes:globalThis.Array.isArray(e==null?void 0:e.nodes)?e.nodes.map(t=>RoadWayNearFlowAnim_Node.fromJSON(t)):[],boxes:globalThis.Array.isArray(e==null?void 0:e.boxes)?e.boxes.map(t=>RoadWay_RoadWayBox.fromJSON(t)):[]}},toJSON(e){var n,a;const t={};return e.name!==""&&(t.name=e.name),e.frameRate!==0&&(t.frameRate=Math.round(e.frameRate)),e.type!==0&&(t.type=roadWayNearFlowAnim_FrameTypeToJSON(e.type)),(n=e.nodes)!=null&&n.length&&(t.nodes=e.nodes.map(r=>RoadWayNearFlowAnim_Node.toJSON(r))),(a=e.boxes)!=null&&a.length&&(t.boxes=e.boxes.map(r=>RoadWay_RoadWayBox.toJSON(r))),t},create(e){return RoadWayNearFlowAnim.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=createBaseRoadWayNearFlowAnim();return t.name=(n=e.name)!=null?n:"",t.frameRate=(a=e.frameRate)!=null?a:0,t.type=(r=e.type)!=null?r:0,t.nodes=((o=e.nodes)==null?void 0:o.map(s=>RoadWayNearFlowAnim_Node.fromPartial(s)))||[],t.boxes=((i=e.boxes)==null?void 0:i.map(s=>RoadWay_RoadWayBox.fromPartial(s)))||[],t}};function createBaseRoadWayNearFlowAnim_Percent(){return{start:0,end:0}}const RoadWayNearFlowAnim_Percent={encode(e,t=minimal.Writer.create()){return e.start!==0&&t.uint32(13).float(e.start),e.end!==0&&t.uint32(21).float(e.end),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayNearFlowAnim_Percent();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==13)break;r.start=n.float();continue;case 2:if(o!==21)break;r.end=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{start:isSet$e(e.start)?globalThis.Number(e.start):0,end:isSet$e(e.end)?globalThis.Number(e.end):0}},toJSON(e){const t={};return e.start!==0&&(t.start=e.start),e.end!==0&&(t.end=e.end),t},create(e){return RoadWayNearFlowAnim_Percent.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseRoadWayNearFlowAnim_Percent();return t.start=(n=e.start)!=null?n:0,t.end=(a=e.end)!=null?a:0,t}};function createBaseRoadWayNearFlowAnim_Node(){return{index:0,name:"",frames:[]}}const RoadWayNearFlowAnim_Node={encode(e,t=minimal.Writer.create()){e.index!==0&&t.uint32(8).uint32(e.index),e.name!==""&&t.uint32(18).string(e.name);for(const n of e.frames)RoadWayNearFlowAnim_Frame.encode(n,t.uint32(26).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayNearFlowAnim_Node();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==8)break;r.index=n.uint32();continue;case 2:if(o!==18)break;r.name=n.string();continue;case 3:if(o!==26)break;r.frames.push(RoadWayNearFlowAnim_Frame.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{index:isSet$e(e.index)?globalThis.Number(e.index):0,name:isSet$e(e.name)?globalThis.String(e.name):"",frames:globalThis.Array.isArray(e==null?void 0:e.frames)?e.frames.map(t=>RoadWayNearFlowAnim_Frame.fromJSON(t)):[]}},toJSON(e){var n;const t={};return e.index!==0&&(t.index=Math.round(e.index)),e.name!==""&&(t.name=e.name),(n=e.frames)!=null&&n.length&&(t.frames=e.frames.map(a=>RoadWayNearFlowAnim_Frame.toJSON(a))),t},create(e){return RoadWayNearFlowAnim_Node.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=createBaseRoadWayNearFlowAnim_Node();return t.index=(n=e.index)!=null?n:0,t.name=(a=e.name)!=null?a:"",t.frames=((r=e.frames)==null?void 0:r.map(o=>RoadWayNearFlowAnim_Frame.fromPartial(o)))||[],t}};function createBaseRoadWayNearFlowAnim_Frame(){return{time:0,percent:[],colorPercent:[]}}const RoadWayNearFlowAnim_Frame={encode(e,t=minimal.Writer.create()){e.time!==0&&t.uint32(13).float(e.time);for(const n of e.percent)RoadWayNearFlowAnim_Percent.encode(n,t.uint32(18).fork()).ldelim();for(const n of e.colorPercent)RoadWayNearFlowAnim_Percent.encode(n,t.uint32(26).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayNearFlowAnim_Frame();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==13)break;r.time=n.float();continue;case 2:if(o!==18)break;r.percent.push(RoadWayNearFlowAnim_Percent.decode(n,n.uint32()));continue;case 3:if(o!==26)break;r.colorPercent.push(RoadWayNearFlowAnim_Percent.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{time:isSet$e(e.time)?globalThis.Number(e.time):0,percent:globalThis.Array.isArray(e==null?void 0:e.percent)?e.percent.map(t=>RoadWayNearFlowAnim_Percent.fromJSON(t)):[],colorPercent:globalThis.Array.isArray(e==null?void 0:e.colorPercent)?e.colorPercent.map(t=>RoadWayNearFlowAnim_Percent.fromJSON(t)):[]}},toJSON(e){var n,a;const t={};return e.time!==0&&(t.time=e.time),(n=e.percent)!=null&&n.length&&(t.percent=e.percent.map(r=>RoadWayNearFlowAnim_Percent.toJSON(r))),(a=e.colorPercent)!=null&&a.length&&(t.colorPercent=e.colorPercent.map(r=>RoadWayNearFlowAnim_Percent.toJSON(r))),t},create(e){return RoadWayNearFlowAnim_Frame.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=createBaseRoadWayNearFlowAnim_Frame();return t.time=(n=e.time)!=null?n:0,t.percent=((a=e.percent)==null?void 0:a.map(o=>RoadWayNearFlowAnim_Percent.fromPartial(o)))||[],t.colorPercent=((r=e.colorPercent)==null?void 0:r.map(o=>RoadWayNearFlowAnim_Percent.fromPartial(o)))||[],t}};function isSet$e(e){return e!=null}function roadWayNearAnim_FrameTypeFromJSON(e){switch(e){case 0:case"NORMAL_FRAME":return 0;case 1:case"KEY_FRAME":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function roadWayNearAnim_FrameTypeToJSON(e){switch(e){case 0:return"NORMAL_FRAME";case 1:return"KEY_FRAME";case-1:default:return"UNRECOGNIZED"}}function createBaseRoadWayNearAnim(){return{name:"",frameRate:0,type:0,frames:[],url:""}}const RoadWayNearAnim={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.frameRate!==0&&t.uint32(16).uint32(e.frameRate),e.type!==0&&t.uint32(24).int32(e.type);for(const n of e.frames)RoadWayNearAnim_Frame.encode(n,t.uint32(34).fork()).ldelim();return e.url!==""&&t.uint32(42).string(e.url),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayNearAnim();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==16)break;r.frameRate=n.uint32();continue;case 3:if(o!==24)break;r.type=n.int32();continue;case 4:if(o!==34)break;r.frames.push(RoadWayNearAnim_Frame.decode(n,n.uint32()));continue;case 5:if(o!==42)break;r.url=n.string();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$d(e.name)?globalThis.String(e.name):"",frameRate:isSet$d(e.frameRate)?globalThis.Number(e.frameRate):0,type:isSet$d(e.type)?roadWayNearAnim_FrameTypeFromJSON(e.type):0,frames:globalThis.Array.isArray(e==null?void 0:e.frames)?e.frames.map(t=>RoadWayNearAnim_Frame.fromJSON(t)):[],url:isSet$d(e.url)?globalThis.String(e.url):""}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),e.frameRate!==0&&(t.frameRate=Math.round(e.frameRate)),e.type!==0&&(t.type=roadWayNearAnim_FrameTypeToJSON(e.type)),(n=e.frames)!=null&&n.length&&(t.frames=e.frames.map(a=>RoadWayNearAnim_Frame.toJSON(a))),e.url!==""&&(t.url=e.url),t},create(e){return RoadWayNearAnim.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=createBaseRoadWayNearAnim();return t.name=(n=e.name)!=null?n:"",t.frameRate=(a=e.frameRate)!=null?a:0,t.type=(r=e.type)!=null?r:0,t.frames=((o=e.frames)==null?void 0:o.map(s=>RoadWayNearAnim_Frame.fromPartial(s)))||[],t.url=(i=e.url)!=null?i:"",t}};function createBaseRoadWayNearAnim_Node(){return{name:"",position:void 0}}const RoadWayNearAnim_Node={encode(e,t=minimal.Writer.create()){return e.name!==""&&t.uint32(10).string(e.name),e.position!==void 0&&Position.encode(e.position,t.uint32(18).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayNearAnim_Node();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.position=Position.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$d(e.name)?globalThis.String(e.name):"",position:isSet$d(e.position)?Position.fromJSON(e.position):void 0}},toJSON(e){const t={};return e.name!==""&&(t.name=e.name),e.position!==void 0&&(t.position=Position.toJSON(e.position)),t},create(e){return RoadWayNearAnim_Node.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=createBaseRoadWayNearAnim_Node();return t.name=(n=e.name)!=null?n:"",t.position=e.position!==void 0&&e.position!==null?Position.fromPartial(e.position):void 0,t}};function createBaseRoadWayNearAnim_Frame(){return{nodes:[],time:0}}const RoadWayNearAnim_Frame={encode(e,t=minimal.Writer.create()){for(const n of e.nodes)RoadWayNearAnim_Node.encode(n,t.uint32(10).fork()).ldelim();return e.time!==0&&t.uint32(21).float(e.time),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayNearAnim_Frame();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.nodes.push(RoadWayNearAnim_Node.decode(n,n.uint32()));continue;case 2:if(o!==21)break;r.time=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{nodes:globalThis.Array.isArray(e==null?void 0:e.nodes)?e.nodes.map(t=>RoadWayNearAnim_Node.fromJSON(t)):[],time:isSet$d(e.time)?globalThis.Number(e.time):0}},toJSON(e){var n;const t={};return(n=e.nodes)!=null&&n.length&&(t.nodes=e.nodes.map(a=>RoadWayNearAnim_Node.toJSON(a))),e.time!==0&&(t.time=e.time),t},create(e){return RoadWayNearAnim_Frame.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseRoadWayNearAnim_Frame();return t.nodes=((n=e.nodes)==null?void 0:n.map(r=>RoadWayNearAnim_Node.fromPartial(r)))||[],t.time=(a=e.time)!=null?a:0,t}};function isSet$d(e){return e!=null}class AnimationCurve{constructor(){ue(this,"_keys",[]);ue(this,"getLastKey",()=>this._keys[this._keys.length-1]);ue(this,"getFirstKey",()=>this._keys[0])}get keys(){return this._keys}get length(){return this._keys[this._keys.length-1].time}evaluate(t){const n=this.getKeyIndex(t);if(n!=-1){const a=Math.max(n-1,0),r=(t-this._keys[a].time)/(this._keys[n].time-this._keys[a].time);return EngineCore.Scalar.Lerp(this._keys[a].value,this._keys[n].value,r)}}getKeyIndex(t){for(let n=0;n<this._keys.length;n++)if(t<=this._keys[n].time)return n;return-1}addKey(t){this._keys.push(t)}}class AnimationKeyFrame{constructor(t,n){ue(this,"time");ue(this,"value");this.time=t,this.value=n}}class AnimationNode{constructor(t){ue(this,"_curves",[]);this._curves=t}get curves(){return this._curves}update(t){}reset(){}}class AnimationRoadWayNearNode extends AnimationNode{constructor(){super(...arguments);ue(this,"_name","");ue(this,"_url","");ue(this,"_start");ue(this,"_end");ue(this,"_current")}set name(n){this._name=n}get name(){return this._name}set url(n){this._url=n}get url(){return this._url}set start(n){this._start=n}get start(){return this._start}set end(n){this._end=n}get end(){return this._end}set current(n){this._current=n}get current(){return this._current}getEndPosition(){var o,i,s;const n=(o=this.curves[0].getLastKey())==null?void 0:o.value,a=(i=this.curves[1].getLastKey())==null?void 0:i.value,r=(s=this.curves[2].getLastKey())==null?void 0:s.value;return new EngineCore.Vector3(n,a,r)}getStartPosition(){const n=this.curves[0].getFirstKey().value,a=this.curves[1].getFirstKey().value,r=this.curves[2].getFirstKey().value;return new EngineCore.Vector3(n,a,r)}update(n){var i,s,l;if(n<this.curves[0].length){const c=(i=this.curves[0].evaluate(n))!=null?i:0,f=(s=this.curves[1].evaluate(n))!=null?s:0,u=(l=this.curves[2].evaluate(n))!=null?l:0;this._start=this.getStartPosition(),this._current=new EngineCore.Vector3(c,f,u),this._end=this.getEndPosition();return}const a=this.curves[0].getLastKey().value,r=this.curves[1].getLastKey().value,o=this.curves[2].getLastKey().value;this._start=this.getStartPosition(),this._current=new EngineCore.Vector3(a,r,o),this._end=this.getEndPosition()}reset(){}}class AnimationRoadWayNode extends AnimationNode{constructor(){super(...arguments);ue(this,"_range",[]);ue(this,"_percent",[]);ue(this,"_start");ue(this,"_end");ue(this,"_name","");ue(this,"_meshs");ue(this,"_colors",[]);ue(this,"_type","run")}set percent(n){this._percent=n}get percent(){return this._percent}set start(n){this._start=n}get start(){return this._start}set end(n){this._end=n}get end(){return this._end}set meshs(n){this._meshs=n}get meshs(){return this._meshs}set name(n){this._name=n}get name(){return this._name}set range(n){this._range=n}get range(){return this._range}set colors(n){this._colors=n}get colors(){return this._colors}set type(n){this._type=n}get type(){return this._type}update(n){var a;this._range=[],this._percent=[];for(let r=0;r<this.curves.length;r++){const o=this.curves[r];if(n<o.length){this._range.push((a=o.evaluate(n))!=null?a:0);continue}this._range.push(o.getLastKey().value)}for(let r=0;r<this._range.length;r+=2)this._percent.push({start:this._range[r],end:this._range[r+1]})}reset(){}}class AnimationRoadWayWaterNode extends AnimationNode{constructor(){super(...arguments);ue(this,"_range",[]);ue(this,"_percent",[]);ue(this,"_colorPercent",[]);ue(this,"_start");ue(this,"_end");ue(this,"_name","");ue(this,"_meshs");ue(this,"_colors",[]);ue(this,"_type","run");ue(this,"_percentLength",2)}set percent(n){this._percent=n}get percent(){return this._percent}set colorPercent(n){this._colorPercent=n}get colorPercent(){return this._colorPercent}set percentLength(n){this._percentLength=n}get percentLength(){return this._percentLength}set start(n){this._start=n}get start(){return this._start}set end(n){this._end=n}get end(){return this._end}set meshs(n){this._meshs=n}get meshs(){return this._meshs}set name(n){this._name=n}get name(){return this._name}set range(n){this._range=n}get range(){return this._range}set rangeColors(n){this._range=n}get rangeColors(){return this._range}set colors(n){this._colors=n}get colors(){return this._colors}set type(n){this._type=n}get type(){return this._type}update(n){var a;this._range=[],this._percent=[],this._colorPercent=[];for(let r=0;r<this.curves.length;r++){const o=this.curves[r];if(n<o.length){this._range.push((a=o.evaluate(n))!=null?a:0);continue}this._range.push(o.getLastKey().value)}for(let r=0;r<this._percentLength;r+=2)this._percent.push({start:this._range[r],end:this._range[r+1]});for(let r=this._percentLength;r<this._range.length;r+=2)this._colorPercent.push({start:this._range[r],end:this._range[r+1]})}reset(){}}var a0,a1,a2,a3,b1,b2,left_corner,right_corner;function gaussCoef(e){e<.5&&(e=.5);var t=Math.exp(.726*.726)/e,n=Math.exp(-t),a=Math.exp(-2*t),r=(1-n)*(1-n)/(1+2*t*n-a);return a0=r,a1=r*(t-1)*n,a2=r*(t+1)*n,a3=-r*a,b1=2*n,b2=-a,left_corner=(a0+a1)/(1-b1-b2),right_corner=(a2+a3)/(1-b1-b2),new Float32Array([a0,a1,a2,a3,b1,b2,left_corner,right_corner])}function convolveRGBA(e,t,n,a,r,o){var i,s,l,c,f,u,d,h,m,R,v,g,x,y,E,k,b,C,_,A,N,S,I,O,F,L,w,B,D,W;for(F=0;F<o;F++){for(S=F*r,I=F,O=0,i=e[S],s=i&255,l=i>>8&255,c=i>>16&255,f=i>>24&255,C=s*a[6],_=l*a[6],A=c*a[6],N=f*a[6],y=C,E=_,k=A,b=N,w=a[0],B=a[1],D=a[4],W=a[5],L=0;L<r;L++)i=e[S],u=i&255,d=i>>8&255,h=i>>16&255,m=i>>24&255,R=u*w+s*B+y*D+C*W,v=d*w+l*B+E*D+_*W,g=h*w+c*B+k*D+A*W,x=m*w+f*B+b*D+N*W,C=y,_=E,A=k,N=b,y=R,E=v,k=g,b=x,s=u,l=d,c=h,f=m,n[O]=y,n[O+1]=E,n[O+2]=k,n[O+3]=b,O+=4,S++;for(S--,O-=4,I+=o*(r-1),i=e[S],s=i&255,l=i>>8&255,c=i>>16&255,f=i>>24&255,C=s*a[7],_=l*a[7],A=c*a[7],N=f*a[7],y=C,E=_,k=A,b=N,u=s,d=l,h=c,m=f,w=a[2],B=a[3],L=r-1;L>=0;L--)R=u*w+s*B+y*D+C*W,v=d*w+l*B+E*D+_*W,g=h*w+c*B+k*D+A*W,x=m*w+f*B+b*D+N*W,C=y,_=E,A=k,N=b,y=R,E=v,k=g,b=x,s=u,l=d,c=h,f=m,i=e[S],u=i&255,d=i>>8&255,h=i>>16&255,m=i>>24&255,i=(n[O]+y<<0)+(n[O+1]+E<<8)+(n[O+2]+k<<16)+(n[O+3]+b<<24),t[I]=i,S--,O-=4,I-=o}}function blurRGBA(e,t,n,a){if(a){var r=new Uint32Array(e.buffer),o=new Uint32Array(r.length),i=new Float32Array(Math.max(t,n)*4),s=gaussCoef(a);convolveRGBA(r,o,i,s,t,n),convolveRGBA(o,r,i,s,n,t)}}var glur=blurRGBA;const glur$1=getDefaultExportFromCjs(glur),FORCE_WATER_PULL_DOWN=!1;class AnimationWaterEffectNode extends AnimationNode{constructor(){super(...arguments);ue(this,"_range",[]);ue(this,"_percent",[]);ue(this,"_colorPercent",[]);ue(this,"_start");ue(this,"_end");ue(this,"_name","");ue(this,"_width",0);ue(this,"_height",0);ue(this,"_waterHeight",0);ue(this,"_waterLength",0);ue(this,"_heightMapRaw",new Uint8Array([0,0,0,0]));ue(this,"_lastHeightMapRaw",new Uint8Array([0,0,0,0]));ue(this,"_bottomShape",[]);ue(this,"_percentLength",2);ue(this,"_time",0);ue(this,"_glurMap",new Uint8Array([0,0,0,0]));ue(this,"_startOutWidth",0);ue(this,"_endOutWidth",0)}set start(n){this._start=n}get start(){return this._start}set end(n){this._end=n}get end(){return this._end}set name(n){this._name=n}get name(){return this._name}set percent(n){this._percent=n}get percent(){return this._percent}set colorPercent(n){this._colorPercent=n}get colorPercent(){return this._colorPercent}set percentLength(n){this._percentLength=n}get percentLength(){return this._percentLength}set width(n){this._width=n}get width(){return this._width}set height(n){this._height=n}get height(){return this._height}set waterHeight(n){this._waterHeight=n}get waterHeight(){return this._waterHeight}set waterLength(n){this._waterLength=n}get waterLength(){return this._waterLength}set time(n){this._time=n}get time(){return this._time}set startOutWidth(n){this._startOutWidth=n}get startOutWidth(){return this._startOutWidth}set endOutWidth(n){this._endOutWidth=n}get endOutWidth(){return this._endOutWidth}get center(){return EngineCore.Vector3.Center(this._start||EngineCore.Vector3.Zero(),this._end||EngineCore.Vector3.Zero())}equalArray(n,a){if(n.byteLength!=a.byteLength)return!1;const r=new Uint8Array(n),o=new Uint8Array(a);for(let i=0;i!=n.byteLength;i++)if(r[i]!=o[i])return!1;return!0}generateHeightMap(){const n=Math.floor(this._waterLength);if(n>0){let a=n;FORCE_WATER_PULL_DOWN&&(a+=2);const r=new Uint8Array(a*4);for(let o=0;o<r.length;o++){const i=o*4;r[i]=0,r[i+1]=0,r[i+2]=0,r[i+3]=0}this._heightMapRaw=r}}get bottomShape(){return this._bottomShape}set bottomShape(n){this._bottomShape=n}updateHeightMapByPercent(n,a,r){const o=this._heightMapRaw;let i=0;FORCE_WATER_PULL_DOWN&&(i=1);const s=i+Math.floor(n*this._waterLength),l=i+Math.floor(a*this._waterLength);for(let c=s;c<l;c++){const f=c*4;o[f]=Math.trunc(r*255),o[f+1]=Math.trunc(r*255),o[f+2]=Math.trunc(r*255),o[f+3]=Math.trunc(r*255)}this._heightMapRaw=o}get glurHeightMap(){return this._glurMap}update(n){var a;this._range=[],this._percent=[],this._colorPercent=[];for(let r=0;r<this.curves.length;r++){const o=this.curves[r];if(n<o.length){this._range.push((a=o.evaluate(n))!=null?a:0);continue}this._range.push(o.getLastKey().value)}for(let r=0;r<this._percentLength;r+=2){const o=this._range[r],i=this._range[r+1],s=Math.min(o,i),l=Math.max(o,i);s!=l&&this.updateHeightMapByPercent(s,l,.5)}for(let r=this._percentLength;r<this._range.length;r+=2){const o=this._range[r],i=this._range[r+1],s=Math.min(o,i),l=Math.max(o,i);s!=l&&this.updateHeightMapByPercent(s,l,1)}if(!this.equalArray(this._heightMapRaw,this._lastHeightMapRaw)){if(this.time=n,this._heightMapRaw.length===0)return new Uint8Array([0,0,0,0]);const r=new Uint8Array(this._heightMapRaw);let o=this._waterLength;FORCE_WATER_PULL_DOWN&&(o+=2),glur$1(r,1,o,5),FORCE_WATER_PULL_DOWN&&(r[0]=0,r[1]=0,r[2]=0,r[3]=0,r[r.length-4]=0,r[r.length-3]=0,r[r.length-2]=0,r[r.length-1]=0),this._lastHeightMapRaw=this._heightMapRaw.slice(0),this._glurMap=r}}reset(){}cross(n,a,r){return(a.x-n.x)*(r.y-n.y)-(a.y-n.y)*(r.x-n.x)}convexHull(n){n.sort((o,i)=>o.x===i.x?o.y-i.y:o.x-i.x);const a=[];for(const o of n){for(;a.length>=2&&this.cross(a[a.length-2],a[a.length-1],o)<=0;)a.pop();a.push(o)}const r=[];for(let o=n.length-1;o>=0;o--){const i=n[o];for(;r.length>=2&&this.cross(r[r.length-2],r[r.length-1],i)<=0;)r.pop();r.push(i)}return a.pop(),r.pop(),a.concat(r)}}const buildRoadWayAnimation=e=>{const t=RoadWayAnim.decode(new Uint8Array(e)),n=[];console.log(t);const a=[];for(let r=0;r<t.frames.length;r++)for(let o=0;o<t.frames[r].node.length;o++){const i=t.frames[r].node[o];a.findIndex(l=>l===i.name)===-1&&a.push(i.name)}for(let r=0;r<a.length;r++){const o=[],i=t.frames[0].node[0].percent.length,s=t.frames[0].node[0].colorPercent.length;for(let f=0;f<(i+s)*2;f++)o.push(new AnimationCurve);let l=0;for(let f=0;f<t.frames.length;f++){const u=t.frames[f],d=u.node.findIndex(h=>h.name===a[r]);if(d!==-1){for(let h=0;h<i;h++){const m=new AnimationKeyFrame(u.time*1e3,u.node[d].percent[h].start),R=new AnimationKeyFrame(u.time*1e3,u.node[d].percent[h].end);o[h*2].addKey(m),o[h*2+1].addKey(R)}for(let h=0;h<s;h++){const m=new AnimationKeyFrame(u.time*1e3,u.node[d].colorPercent[h].start),R=new AnimationKeyFrame(u.time*1e3,u.node[d].colorPercent[h].end);o[i*2+h*2].addKey(m),o[i*2+h*2+1].addKey(R)}l=u.node[d].index}}const c=t.animType===RoadWayAnim_AnimType.WATER?new AnimationRoadWayWaterNode(o):new AnimationRoadWayNode(o);c.meshs=[t.boxes[l].topMesh,t.boxes[l].bottomMesh,t.boxes[l].sideMesh],c.name=a[r],c.start=convertVertexToVector3(t.boxes[l].startPosition),c.end=convertVertexToVector3(t.boxes[l].endPosition),c.type=t.animType===RoadWayAnim_AnimType.RUN?"run":"water",c.colors=t.colors.map(f=>convertColorToColor3(f)),t.animType===RoadWayAnim_AnimType.WATER&&(c.percentLength=i*2);for(let f=0;f<c.curves.length;f++)if(c.curves[f].keys[0].time!==0){const u=c.curves[f].keys[0],d=new AnimationKeyFrame(0,u.value);d.time=0,c.curves[f].keys.unshift(d)}n.push(c)}return n},buildRoadWayNearAnimation=e=>{const t=RoadWayNearAnim.decode(new Uint8Array(e)),n=[];console.log(t);const a=[];for(let r=0;r<t.frames.length;r++)for(let o=0;o<t.frames[r].nodes.length;o++){const i=t.frames[r].nodes[o];a.findIndex(l=>l===i.name)===-1&&a.push(i.name)}for(let r=0;r<a.length;r++){const o=[];o.push(new AnimationCurve),o.push(new AnimationCurve),o.push(new AnimationCurve);for(let s=0;s<t.frames.length;s++){const l=t.frames[s],c=l.nodes.findIndex(f=>f.name===a[r]);if(c!==-1){const f=new AnimationKeyFrame(l.time*1e3,l.nodes[c].position.x),u=new AnimationKeyFrame(l.time*1e3,l.nodes[c].position.y),d=new AnimationKeyFrame(l.time*1e3,l.nodes[c].position.z);o[0].addKey(f),o[1].addKey(u),o[2].addKey(d)}}const i=new AnimationRoadWayNearNode(o);i.name=a[r],i.url=t.url;for(let s=0;s<i.curves.length;s++)if(i.curves[s].keys[0].time!==0){const l=i.curves[s].keys[0],c=new AnimationKeyFrame(0,l.value);c.time=0,i.curves[s].keys.unshift(c)}n.push(i)}return n},buildWaterEffectAnimation=e=>{const t=RoadWayNearFlowAnim.decode(new Uint8Array(e)),n=[];console.log(t);for(let a=0;a<t.nodes.length;a++){const r=[],o=t.nodes[0].frames[0].percent.length,i=t.nodes[0].frames[0].colorPercent.length;for(let m=0;m<(o+i)*2;m++)r.push(new AnimationCurve);for(let m=0;m<t.nodes[a].frames.length;m++){const R=t.nodes[a].frames[m];if("percent"in R&&"colorPercent"in R){for(let v=0;v<o;v++){const g=new AnimationKeyFrame(R.time*1e3,R.percent[v].start),x=new AnimationKeyFrame(R.time*1e3,R.percent[v].end);r[v*2].addKey(g),r[v*2+1].addKey(x)}for(let v=0;v<i;v++){const g=new AnimationKeyFrame(R.time*1e3,R.colorPercent[v].start),x=new AnimationKeyFrame(R.time*1e3,R.colorPercent[v].end);r[o*2+v*2].addKey(g),r[o*2+v*2+1].addKey(x)}}else console.error("[Geo3DViewer] 数据中缺少 percent 或 colorPercent ",t.nodes[a],R)}const s=t.nodes[a].index,l=new AnimationWaterEffectNode(r);l.name=t.nodes[a].name,l.start=convertVertexToVector3(t.boxes[s].startPosition),l.end=convertVertexToVector3(t.boxes[s].endPosition),l.startOutWidth=t.boxes[s].startOutWidth||0,l.endOutWidth=t.boxes[s].endOutWidth||0,l.waterHeight=.5,l.width=t.boxes[s].width||3.5,l.waterLength=EngineCore.Vector3.Distance(l.start,l.end)+.05+l.startOutWidth+l.endOutWidth,l.generateHeightMap();const c=[];for(let m=0;m<t.boxes[s].bottomMesh.vertices.length;m+=3)c.push(new EngineCore.Vector3(t.boxes[s].bottomMesh.vertices[m],t.boxes[s].bottomMesh.vertices[m+1],t.boxes[s].bottomMesh.vertices[m+2]));const f=new EngineCore.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),u=new EngineCore.Vector3(Number.MIN_VALUE,Number.MIN_VALUE,Number.MIN_VALUE);c.forEach(m=>{m.x<f.x&&(f.x=m.x),m.y<f.y&&(f.y=m.y),m.z<f.z&&(f.z=m.z),m.x>u.x&&(u.x=m.x),m.y>u.y&&(u.y=m.y),m.z>u.z&&(u.z=m.z)});const d=[];t.boxes[s].bottomMesh.indices.forEach(m=>{d.push(c[m].subtract(f).multiplyByFloats(1/(u.x-f.x),1/(u.y-f.y),1/(u.z-f.z)))});const h=[];for(let m=0;m<d.length;m+=3)h.push([d[m],d[m+1],d[m+2]]);l.bottomShape=h,l.height=t.boxes[s].height||t.boxes[s].topMesh.vertices[1]-t.boxes[s].bottomMesh.vertices[1],l.percentLength=o*2,console.log("[Geo3DViewer] 正在构建动画 ",l);for(let m=0;m<l.curves.length;m++)if(l.curves[m].keys[0].time!==0){const R=l.curves[m].keys[0],v=new AnimationKeyFrame(0,R.value);v.time=0,l.curves[m].keys.unshift(v)}n.push(l)}return n},Animation=e=>{const{name:t,children:n,url:a,type:r="roadway",speed:o=1}=e,i=React.useRef(null),[s,l]=React.useState(),c=React.useRef(!1),f=useCachedBinary({url:a,cacheType:CacheType.URL_PREFIX_MATCH}),u=(d,h)=>{let m=[];switch(d){case"roadway":m=buildRoadWayAnimation(h);break;case"roadwaynear":m=buildRoadWayNearAnimation(h);break;case"water":m=buildWaterEffectAnimation(h);break;default:m=buildRoadWayAnimation(h)}return m};return React.useEffect(()=>{if(f&&!c.current){c.current=!0;const d=u(r,f);console.log(d);const h=new SimpleAnimationController(t);h.nodes=d,i.current=h,i.current.speed=o,i.current.play(),c.current=!1}},[f,t,o,r]),React.useEffect(()=>()=>{i.current&&!c.current&&(console.log("destory animation!"),i.current.onDestory())},[]),React.useEffect(()=>{const d=setInterval(()=>{i.current&&i.current.normalized>0&&l({nodes:i.current.nodes})},100);return()=>{clearInterval(d)}},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:s&&React.isValidElement(n)?React.cloneElement(n,{nodes:s==null?void 0:s.nodes,speed:o}):n})},Animation$1=Animation;function createBaseVirtualVolume(){return{name:"",vMin:0,vMax:0,xMin:0,yMin:0,xMax:0,yMax:0,zMin:0,zMax:0,points:[],indices:[],value:[],center:void 0}}const VirtualVolume={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.vMin!==0&&t.uint32(21).float(e.vMin),e.vMax!==0&&t.uint32(29).float(e.vMax),e.xMin!==0&&t.uint32(37).float(e.xMin),e.yMin!==0&&t.uint32(45).float(e.yMin),e.xMax!==0&&t.uint32(53).float(e.xMax),e.yMax!==0&&t.uint32(61).float(e.yMax),e.zMin!==0&&t.uint32(69).float(e.zMin),e.zMax!==0&&t.uint32(77).float(e.zMax),t.uint32(90).fork();for(const n of e.points)t.float(n);t.ldelim(),t.uint32(98).fork();for(const n of e.indices)t.int32(n);t.ldelim(),t.uint32(106).fork();for(const n of e.value)t.float(n);return t.ldelim(),e.center!==void 0&&Vertex.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseVirtualVolume();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==21)break;r.vMin=n.float();continue;case 3:if(o!==29)break;r.vMax=n.float();continue;case 4:if(o!==37)break;r.xMin=n.float();continue;case 5:if(o!==45)break;r.yMin=n.float();continue;case 6:if(o!==53)break;r.xMax=n.float();continue;case 7:if(o!==61)break;r.yMax=n.float();continue;case 8:if(o!==69)break;r.zMin=n.float();continue;case 9:if(o!==77)break;r.zMax=n.float();continue;case 11:if(o===93){r.points.push(n.float());continue}if(o===90){const i=n.uint32()+n.pos;for(;n.pos<i;)r.points.push(n.float());continue}break;case 12:if(o===96){r.indices.push(n.int32());continue}if(o===98){const i=n.uint32()+n.pos;for(;n.pos<i;)r.indices.push(n.int32());continue}break;case 13:if(o===109){r.value.push(n.float());continue}if(o===106){const i=n.uint32()+n.pos;for(;n.pos<i;)r.value.push(n.float());continue}break;case 31:if(o!==250)break;r.center=Vertex.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$c(e.name)?globalThis.String(e.name):"",vMin:isSet$c(e.vMin)?globalThis.Number(e.vMin):0,vMax:isSet$c(e.vMax)?globalThis.Number(e.vMax):0,xMin:isSet$c(e.xMin)?globalThis.Number(e.xMin):0,yMin:isSet$c(e.yMin)?globalThis.Number(e.yMin):0,xMax:isSet$c(e.xMax)?globalThis.Number(e.xMax):0,yMax:isSet$c(e.yMax)?globalThis.Number(e.yMax):0,zMin:isSet$c(e.zMin)?globalThis.Number(e.zMin):0,zMax:isSet$c(e.zMax)?globalThis.Number(e.zMax):0,points:globalThis.Array.isArray(e==null?void 0:e.points)?e.points.map(t=>globalThis.Number(t)):[],indices:globalThis.Array.isArray(e==null?void 0:e.indices)?e.indices.map(t=>globalThis.Number(t)):[],value:globalThis.Array.isArray(e==null?void 0:e.value)?e.value.map(t=>globalThis.Number(t)):[],center:isSet$c(e.center)?Vertex.fromJSON(e.center):void 0}},toJSON(e){var n,a,r;const t={};return e.name!==""&&(t.name=e.name),e.vMin!==0&&(t.vMin=e.vMin),e.vMax!==0&&(t.vMax=e.vMax),e.xMin!==0&&(t.xMin=e.xMin),e.yMin!==0&&(t.yMin=e.yMin),e.xMax!==0&&(t.xMax=e.xMax),e.yMax!==0&&(t.yMax=e.yMax),e.zMin!==0&&(t.zMin=e.zMin),e.zMax!==0&&(t.zMax=e.zMax),(n=e.points)!=null&&n.length&&(t.points=e.points),(a=e.indices)!=null&&a.length&&(t.indices=e.indices.map(o=>Math.round(o))),(r=e.value)!=null&&r.length&&(t.value=e.value),e.center!==void 0&&(t.center=Vertex.toJSON(e.center)),t},create(e){return VirtualVolume.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l,c,f,u,d,h;const t=createBaseVirtualVolume();return t.name=(n=e.name)!=null?n:"",t.vMin=(a=e.vMin)!=null?a:0,t.vMax=(r=e.vMax)!=null?r:0,t.xMin=(o=e.xMin)!=null?o:0,t.yMin=(i=e.yMin)!=null?i:0,t.xMax=(s=e.xMax)!=null?s:0,t.yMax=(l=e.yMax)!=null?l:0,t.zMin=(c=e.zMin)!=null?c:0,t.zMax=(f=e.zMax)!=null?f:0,t.points=((u=e.points)==null?void 0:u.map(m=>m))||[],t.indices=((d=e.indices)==null?void 0:d.map(m=>m))||[],t.value=((h=e.value)==null?void 0:h.map(m=>m))||[],t.center=e.center!==void 0&&e.center!==null?Vertex.fromPartial(e.center):void 0,t}};function isSet$c(e){return e!=null}const CustomShader=(e,t)=>{const n=React.useRef(null),{name:a,vertex:r,fragment:o,needDepthPrePass:i=!1,backFaceCulling:s,transparencyMode:l=EngineCore.Material.MATERIAL_OPAQUE,alphaMode:c=EngineCore.Engine.ALPHA_COMBINE,alpha:f=1,options:u,zOffset:d=1,zOffsetUnits:h,disableDepthWrite:m=!1,clipPlane:R,depthFunction:v,sideOrientation:g=EngineCore.Material.ClockWiseSideOrientation}=e;return React.useImperativeHandle(t,()=>n.current,[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("shaderMaterial",{ref:n,name:`${a}-material`,sideOrientation:g,needDepthPrePass:i,backFaceCulling:s,transparencyMode:l,alphaMode:c,depthFunction:v,alpha:f,shaderPath:{vertexSource:r,fragmentSource:o},options:u,zOffset:d,zOffsetUnits:h,clipPlane:R,disableDepthWrite:m})})},CustomShader$1=React.forwardRef(CustomShader),terrainFragmentSource=`#ifdef GL_ES
|
|
1
|
+
"use strict";var Je=Object.defineProperty;var Ye=(e,t,n)=>t in e?Je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var le=(e,t,n)=>(Ye(e,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const jsxRuntime=require("react/jsx-runtime"),EngineCore=require("@babylonjs/core"),gpuPicker=require("@babylonjs/core/Collisions/gpuPicker"),React=require("react"),reactBabylonjs=require("react-babylonjs"),axios=require("axios"),inspector=require("@babylonjs/inspector");require("@babylonjs/core/Engines/Extensions/engine.query");require("@babylonjs/core/Legacy/legacy");const dynamic=require("@babylonjs/loaders/dynamic"),EngineGui=require("@babylonjs/gui"),EngineMaterial=require("@babylonjs/materials");require("@babylonjs/materials/legacy/legacy-grid");require("@babylonjs/core/Loading/Plugins/babylonFileLoader");require("@babylonjs/core/Loading/sceneLoader");require("@babylonjs/core/Materials");require("@babylonjs/loaders/OBJ");require("@babylonjs/loaders/STL");require("@babylonjs/loaders/glTF");const TubeUtil=require("./TubeUtil-c71e3fbe.cjs"),client=require("react-dom/client"),reactDom=require("react-dom");var commonjsGlobal=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function commonjsRequire(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var UPNG$1={exports:{}},common={},hasRequiredCommon;function requireCommon(){return hasRequiredCommon||(hasRequiredCommon=1,function(e){var t=typeof Uint8Array!="undefined"&&typeof Uint16Array!="undefined"&&typeof Int32Array!="undefined";function n(o,i){return Object.prototype.hasOwnProperty.call(o,i)}e.assign=function(o){for(var i=Array.prototype.slice.call(arguments,1);i.length;){var s=i.shift();if(s){if(typeof s!="object")throw new TypeError(s+"must be non-object");for(var l in s)n(s,l)&&(o[l]=s[l])}}return o},e.shrinkBuf=function(o,i){return o.length===i?o:o.subarray?o.subarray(0,i):(o.length=i,o)};var a={arraySet:function(o,i,s,l,c){if(i.subarray&&o.subarray){o.set(i.subarray(s,s+l),c);return}for(var f=0;f<l;f++)o[c+f]=i[s+f]},flattenChunks:function(o){var i,s,l,c,f,u;for(l=0,i=0,s=o.length;i<s;i++)l+=o[i].length;for(u=new Uint8Array(l),c=0,i=0,s=o.length;i<s;i++)f=o[i],u.set(f,c),c+=f.length;return u}},r={arraySet:function(o,i,s,l,c){for(var f=0;f<l;f++)o[c+f]=i[s+f]},flattenChunks:function(o){return[].concat.apply([],o)}};e.setTyped=function(o){o?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,a)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,r))},e.setTyped(t)}(common)),common}var deflate$1={},deflate={},trees={},hasRequiredTrees;function requireTrees(){if(hasRequiredTrees)return trees;hasRequiredTrees=1;var e=requireCommon(),t=4,n=0,a=1,r=2;function o(M){for(var re=M.length;--re>=0;)M[re]=0}var i=0,s=1,l=2,c=3,f=258,u=29,d=256,h=d+1+u,m=30,R=19,v=2*h+1,g=15,x=16,y=7,E=256,k=16,b=17,C=18,_=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],A=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],N=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],S=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],I=512,O=new Array((h+2)*2);o(O);var F=new Array(m*2);o(F);var w=new Array(I);o(w);var L=new Array(f-c+1);o(L);var B=new Array(u);o(B);var D=new Array(m);o(D);function W(M,re,se,me,z){this.static_tree=M,this.extra_bits=re,this.extra_base=se,this.elems=me,this.max_length=z,this.has_stree=M&&M.length}var ae,ee,H;function oe(M,re){this.dyn_tree=M,this.max_code=0,this.stat_desc=re}function te(M){return M<256?w[M]:w[256+(M>>>7)]}function K(M,re){M.pending_buf[M.pending++]=re&255,M.pending_buf[M.pending++]=re>>>8&255}function Z(M,re,se){M.bi_valid>x-se?(M.bi_buf|=re<<M.bi_valid&65535,K(M,M.bi_buf),M.bi_buf=re>>x-M.bi_valid,M.bi_valid+=se-x):(M.bi_buf|=re<<M.bi_valid&65535,M.bi_valid+=se)}function ce(M,re,se){Z(M,se[re*2],se[re*2+1])}function Q(M,re){var se=0;do se|=M&1,M>>>=1,se<<=1;while(--re>0);return se>>>1}function G(M){M.bi_valid===16?(K(M,M.bi_buf),M.bi_buf=0,M.bi_valid=0):M.bi_valid>=8&&(M.pending_buf[M.pending++]=M.bi_buf&255,M.bi_buf>>=8,M.bi_valid-=8)}function ge(M,re){var se=re.dyn_tree,me=re.max_code,z=re.stat_desc.static_tree,X=re.stat_desc.has_stree,T=re.stat_desc.extra_bits,ie=re.stat_desc.extra_base,xe=re.stat_desc.max_length,p,j,q,P,$,U,ve=0;for(P=0;P<=g;P++)M.bl_count[P]=0;for(se[M.heap[M.heap_max]*2+1]=0,p=M.heap_max+1;p<v;p++)j=M.heap[p],P=se[se[j*2+1]*2+1]+1,P>xe&&(P=xe,ve++),se[j*2+1]=P,!(j>me)&&(M.bl_count[P]++,$=0,j>=ie&&($=T[j-ie]),U=se[j*2],M.opt_len+=U*(P+$),X&&(M.static_len+=U*(z[j*2+1]+$)));if(ve!==0){do{for(P=xe-1;M.bl_count[P]===0;)P--;M.bl_count[P]--,M.bl_count[P+1]+=2,M.bl_count[xe]--,ve-=2}while(ve>0);for(P=xe;P!==0;P--)for(j=M.bl_count[P];j!==0;)q=M.heap[--p],!(q>me)&&(se[q*2+1]!==P&&(M.opt_len+=(P-se[q*2+1])*se[q*2],se[q*2+1]=P),j--)}}function fe(M,re,se){var me=new Array(g+1),z=0,X,T;for(X=1;X<=g;X++)me[X]=z=z+se[X-1]<<1;for(T=0;T<=re;T++){var ie=M[T*2+1];ie!==0&&(M[T*2]=Q(me[ie]++,ie))}}function V(){var M,re,se,me,z,X=new Array(g+1);for(se=0,me=0;me<u-1;me++)for(B[me]=se,M=0;M<1<<_[me];M++)L[se++]=me;for(L[se-1]=me,z=0,me=0;me<16;me++)for(D[me]=z,M=0;M<1<<A[me];M++)w[z++]=me;for(z>>=7;me<m;me++)for(D[me]=z<<7,M=0;M<1<<A[me]-7;M++)w[256+z++]=me;for(re=0;re<=g;re++)X[re]=0;for(M=0;M<=143;)O[M*2+1]=8,M++,X[8]++;for(;M<=255;)O[M*2+1]=9,M++,X[9]++;for(;M<=279;)O[M*2+1]=7,M++,X[7]++;for(;M<=287;)O[M*2+1]=8,M++,X[8]++;for(fe(O,h+1,X),M=0;M<m;M++)F[M*2+1]=5,F[M*2]=Q(M,5);ae=new W(O,_,d+1,h,g),ee=new W(F,A,0,m,g),H=new W(new Array(0),N,0,R,y)}function J(M){var re;for(re=0;re<h;re++)M.dyn_ltree[re*2]=0;for(re=0;re<m;re++)M.dyn_dtree[re*2]=0;for(re=0;re<R;re++)M.bl_tree[re*2]=0;M.dyn_ltree[E*2]=1,M.opt_len=M.static_len=0,M.last_lit=M.matches=0}function Re(M){M.bi_valid>8?K(M,M.bi_buf):M.bi_valid>0&&(M.pending_buf[M.pending++]=M.bi_buf),M.bi_buf=0,M.bi_valid=0}function Ce(M,re,se,me){Re(M),me&&(K(M,se),K(M,~se)),e.arraySet(M.pending_buf,M.window,re,se,M.pending),M.pending+=se}function Y(M,re,se,me){var z=re*2,X=se*2;return M[z]<M[X]||M[z]===M[X]&&me[re]<=me[se]}function ue(M,re,se){for(var me=M.heap[se],z=se<<1;z<=M.heap_len&&(z<M.heap_len&&Y(re,M.heap[z+1],M.heap[z],M.depth)&&z++,!Y(re,me,M.heap[z],M.depth));)M.heap[se]=M.heap[z],se=z,z<<=1;M.heap[se]=me}function ne(M,re,se){var me,z,X=0,T,ie;if(M.last_lit!==0)do me=M.pending_buf[M.d_buf+X*2]<<8|M.pending_buf[M.d_buf+X*2+1],z=M.pending_buf[M.l_buf+X],X++,me===0?ce(M,z,re):(T=L[z],ce(M,T+d+1,re),ie=_[T],ie!==0&&(z-=B[T],Z(M,z,ie)),me--,T=te(me),ce(M,T,se),ie=A[T],ie!==0&&(me-=D[T],Z(M,me,ie)));while(X<M.last_lit);ce(M,E,re)}function de(M,re){var se=re.dyn_tree,me=re.stat_desc.static_tree,z=re.stat_desc.has_stree,X=re.stat_desc.elems,T,ie,xe=-1,p;for(M.heap_len=0,M.heap_max=v,T=0;T<X;T++)se[T*2]!==0?(M.heap[++M.heap_len]=xe=T,M.depth[T]=0):se[T*2+1]=0;for(;M.heap_len<2;)p=M.heap[++M.heap_len]=xe<2?++xe:0,se[p*2]=1,M.depth[p]=0,M.opt_len--,z&&(M.static_len-=me[p*2+1]);for(re.max_code=xe,T=M.heap_len>>1;T>=1;T--)ue(M,se,T);p=X;do T=M.heap[1],M.heap[1]=M.heap[M.heap_len--],ue(M,se,1),ie=M.heap[1],M.heap[--M.heap_max]=T,M.heap[--M.heap_max]=ie,se[p*2]=se[T*2]+se[ie*2],M.depth[p]=(M.depth[T]>=M.depth[ie]?M.depth[T]:M.depth[ie])+1,se[T*2+1]=se[ie*2+1]=p,M.heap[1]=p++,ue(M,se,1);while(M.heap_len>=2);M.heap[--M.heap_max]=M.heap[1],ge(M,re),fe(se,xe,M.bl_count)}function _e(M,re,se){var me,z=-1,X,T=re[0*2+1],ie=0,xe=7,p=4;for(T===0&&(xe=138,p=3),re[(se+1)*2+1]=65535,me=0;me<=se;me++)X=T,T=re[(me+1)*2+1],!(++ie<xe&&X===T)&&(ie<p?M.bl_tree[X*2]+=ie:X!==0?(X!==z&&M.bl_tree[X*2]++,M.bl_tree[k*2]++):ie<=10?M.bl_tree[b*2]++:M.bl_tree[C*2]++,ie=0,z=X,T===0?(xe=138,p=3):X===T?(xe=6,p=3):(xe=7,p=4))}function ye(M,re,se){var me,z=-1,X,T=re[0*2+1],ie=0,xe=7,p=4;for(T===0&&(xe=138,p=3),me=0;me<=se;me++)if(X=T,T=re[(me+1)*2+1],!(++ie<xe&&X===T)){if(ie<p)do ce(M,X,M.bl_tree);while(--ie!==0);else X!==0?(X!==z&&(ce(M,X,M.bl_tree),ie--),ce(M,k,M.bl_tree),Z(M,ie-3,2)):ie<=10?(ce(M,b,M.bl_tree),Z(M,ie-3,3)):(ce(M,C,M.bl_tree),Z(M,ie-11,7));ie=0,z=X,T===0?(xe=138,p=3):X===T?(xe=6,p=3):(xe=7,p=4)}}function Te(M){var re;for(_e(M,M.dyn_ltree,M.l_desc.max_code),_e(M,M.dyn_dtree,M.d_desc.max_code),de(M,M.bl_desc),re=R-1;re>=3&&M.bl_tree[S[re]*2+1]===0;re--);return M.opt_len+=3*(re+1)+5+5+4,re}function Ee(M,re,se,me){var z;for(Z(M,re-257,5),Z(M,se-1,5),Z(M,me-4,4),z=0;z<me;z++)Z(M,M.bl_tree[S[z]*2+1],3);ye(M,M.dyn_ltree,re-1),ye(M,M.dyn_dtree,se-1)}function Se(M){var re=4093624447,se;for(se=0;se<=31;se++,re>>>=1)if(re&1&&M.dyn_ltree[se*2]!==0)return n;if(M.dyn_ltree[9*2]!==0||M.dyn_ltree[10*2]!==0||M.dyn_ltree[13*2]!==0)return a;for(se=32;se<d;se++)if(M.dyn_ltree[se*2]!==0)return a;return n}var be=!1;function Ae(M){be||(V(),be=!0),M.l_desc=new oe(M.dyn_ltree,ae),M.d_desc=new oe(M.dyn_dtree,ee),M.bl_desc=new oe(M.bl_tree,H),M.bi_buf=0,M.bi_valid=0,J(M)}function Ie(M,re,se,me){Z(M,(i<<1)+(me?1:0),3),Ce(M,re,se,!0)}function Pe(M){Z(M,s<<1,3),ce(M,E,O),G(M)}function Oe(M,re,se,me){var z,X,T=0;M.level>0?(M.strm.data_type===r&&(M.strm.data_type=Se(M)),de(M,M.l_desc),de(M,M.d_desc),T=Te(M),z=M.opt_len+3+7>>>3,X=M.static_len+3+7>>>3,X<=z&&(z=X)):z=X=se+5,se+4<=z&&re!==-1?Ie(M,re,se,me):M.strategy===t||X===z?(Z(M,(s<<1)+(me?1:0),3),ne(M,O,F)):(Z(M,(l<<1)+(me?1:0),3),Ee(M,M.l_desc.max_code+1,M.d_desc.max_code+1,T+1),ne(M,M.dyn_ltree,M.dyn_dtree)),J(M),me&&Re(M)}function Fe(M,re,se){return M.pending_buf[M.d_buf+M.last_lit*2]=re>>>8&255,M.pending_buf[M.d_buf+M.last_lit*2+1]=re&255,M.pending_buf[M.l_buf+M.last_lit]=se&255,M.last_lit++,re===0?M.dyn_ltree[se*2]++:(M.matches++,re--,M.dyn_ltree[(L[se]+d+1)*2]++,M.dyn_dtree[te(re)*2]++),M.last_lit===M.lit_bufsize-1}return trees._tr_init=Ae,trees._tr_stored_block=Ie,trees._tr_flush_block=Oe,trees._tr_tally=Fe,trees._tr_align=Pe,trees}var adler32_1,hasRequiredAdler32;function requireAdler32(){if(hasRequiredAdler32)return adler32_1;hasRequiredAdler32=1;function e(t,n,a,r){for(var o=t&65535|0,i=t>>>16&65535|0,s=0;a!==0;){s=a>2e3?2e3:a,a-=s;do o=o+n[r++]|0,i=i+o|0;while(--s);o%=65521,i%=65521}return o|i<<16|0}return adler32_1=e,adler32_1}var crc32_1,hasRequiredCrc32;function requireCrc32(){if(hasRequiredCrc32)return crc32_1;hasRequiredCrc32=1;function e(){for(var a,r=[],o=0;o<256;o++){a=o;for(var i=0;i<8;i++)a=a&1?3988292384^a>>>1:a>>>1;r[o]=a}return r}var t=e();function n(a,r,o,i){var s=t,l=i+o;a^=-1;for(var c=i;c<l;c++)a=a>>>8^s[(a^r[c])&255];return a^-1}return crc32_1=n,crc32_1}var messages,hasRequiredMessages;function requireMessages(){return hasRequiredMessages||(hasRequiredMessages=1,messages={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}),messages}var hasRequiredDeflate$1;function requireDeflate$1(){if(hasRequiredDeflate$1)return deflate;hasRequiredDeflate$1=1;var e=requireCommon(),t=requireTrees(),n=requireAdler32(),a=requireCrc32(),r=requireMessages(),o=0,i=1,s=3,l=4,c=5,f=0,u=1,d=-2,h=-3,m=-5,R=-1,v=1,g=2,x=3,y=4,E=0,k=2,b=8,C=9,_=15,A=8,N=29,S=256,I=S+1+N,O=30,F=19,w=2*I+1,L=15,B=3,D=258,W=D+B+1,ae=32,ee=42,H=69,oe=73,te=91,K=103,Z=113,ce=666,Q=1,G=2,ge=3,fe=4,V=3;function J(p,j){return p.msg=r[j],j}function Re(p){return(p<<1)-(p>4?9:0)}function Ce(p){for(var j=p.length;--j>=0;)p[j]=0}function Y(p){var j=p.state,q=j.pending;q>p.avail_out&&(q=p.avail_out),q!==0&&(e.arraySet(p.output,j.pending_buf,j.pending_out,q,p.next_out),p.next_out+=q,j.pending_out+=q,p.total_out+=q,p.avail_out-=q,j.pending-=q,j.pending===0&&(j.pending_out=0))}function ue(p,j){t._tr_flush_block(p,p.block_start>=0?p.block_start:-1,p.strstart-p.block_start,j),p.block_start=p.strstart,Y(p.strm)}function ne(p,j){p.pending_buf[p.pending++]=j}function de(p,j){p.pending_buf[p.pending++]=j>>>8&255,p.pending_buf[p.pending++]=j&255}function _e(p,j,q,P){var $=p.avail_in;return $>P&&($=P),$===0?0:(p.avail_in-=$,e.arraySet(j,p.input,p.next_in,$,q),p.state.wrap===1?p.adler=n(p.adler,j,$,q):p.state.wrap===2&&(p.adler=a(p.adler,j,$,q)),p.next_in+=$,p.total_in+=$,$)}function ye(p,j){var q=p.max_chain_length,P=p.strstart,$,U,ve=p.prev_length,pe=p.nice_match,he=p.strstart>p.w_size-W?p.strstart-(p.w_size-W):0,ke=p.window,Ue=p.w_mask,we=p.prev,Ne=p.strstart+D,Be=ke[P+ve-1],$e=ke[P+ve];p.prev_length>=p.good_match&&(q>>=2),pe>p.lookahead&&(pe=p.lookahead);do if($=j,!(ke[$+ve]!==$e||ke[$+ve-1]!==Be||ke[$]!==ke[P]||ke[++$]!==ke[P+1])){P+=2,$++;do;while(ke[++P]===ke[++$]&&ke[++P]===ke[++$]&&ke[++P]===ke[++$]&&ke[++P]===ke[++$]&&ke[++P]===ke[++$]&&ke[++P]===ke[++$]&&ke[++P]===ke[++$]&&ke[++P]===ke[++$]&&P<Ne);if(U=D-(Ne-P),P=Ne-D,U>ve){if(p.match_start=j,ve=U,U>=pe)break;Be=ke[P+ve-1],$e=ke[P+ve]}}while((j=we[j&Ue])>he&&--q!==0);return ve<=p.lookahead?ve:p.lookahead}function Te(p){var j=p.w_size,q,P,$,U,ve;do{if(U=p.window_size-p.lookahead-p.strstart,p.strstart>=j+(j-W)){e.arraySet(p.window,p.window,j,j,0),p.match_start-=j,p.strstart-=j,p.block_start-=j,P=p.hash_size,q=P;do $=p.head[--q],p.head[q]=$>=j?$-j:0;while(--P);P=j,q=P;do $=p.prev[--q],p.prev[q]=$>=j?$-j:0;while(--P);U+=j}if(p.strm.avail_in===0)break;if(P=_e(p.strm,p.window,p.strstart+p.lookahead,U),p.lookahead+=P,p.lookahead+p.insert>=B)for(ve=p.strstart-p.insert,p.ins_h=p.window[ve],p.ins_h=(p.ins_h<<p.hash_shift^p.window[ve+1])&p.hash_mask;p.insert&&(p.ins_h=(p.ins_h<<p.hash_shift^p.window[ve+B-1])&p.hash_mask,p.prev[ve&p.w_mask]=p.head[p.ins_h],p.head[p.ins_h]=ve,ve++,p.insert--,!(p.lookahead+p.insert<B)););}while(p.lookahead<W&&p.strm.avail_in!==0)}function Ee(p,j){var q=65535;for(q>p.pending_buf_size-5&&(q=p.pending_buf_size-5);;){if(p.lookahead<=1){if(Te(p),p.lookahead===0&&j===o)return Q;if(p.lookahead===0)break}p.strstart+=p.lookahead,p.lookahead=0;var P=p.block_start+q;if((p.strstart===0||p.strstart>=P)&&(p.lookahead=p.strstart-P,p.strstart=P,ue(p,!1),p.strm.avail_out===0)||p.strstart-p.block_start>=p.w_size-W&&(ue(p,!1),p.strm.avail_out===0))return Q}return p.insert=0,j===l?(ue(p,!0),p.strm.avail_out===0?ge:fe):(p.strstart>p.block_start&&(ue(p,!1),p.strm.avail_out===0),Q)}function Se(p,j){for(var q,P;;){if(p.lookahead<W){if(Te(p),p.lookahead<W&&j===o)return Q;if(p.lookahead===0)break}if(q=0,p.lookahead>=B&&(p.ins_h=(p.ins_h<<p.hash_shift^p.window[p.strstart+B-1])&p.hash_mask,q=p.prev[p.strstart&p.w_mask]=p.head[p.ins_h],p.head[p.ins_h]=p.strstart),q!==0&&p.strstart-q<=p.w_size-W&&(p.match_length=ye(p,q)),p.match_length>=B)if(P=t._tr_tally(p,p.strstart-p.match_start,p.match_length-B),p.lookahead-=p.match_length,p.match_length<=p.max_lazy_match&&p.lookahead>=B){p.match_length--;do p.strstart++,p.ins_h=(p.ins_h<<p.hash_shift^p.window[p.strstart+B-1])&p.hash_mask,q=p.prev[p.strstart&p.w_mask]=p.head[p.ins_h],p.head[p.ins_h]=p.strstart;while(--p.match_length!==0);p.strstart++}else p.strstart+=p.match_length,p.match_length=0,p.ins_h=p.window[p.strstart],p.ins_h=(p.ins_h<<p.hash_shift^p.window[p.strstart+1])&p.hash_mask;else P=t._tr_tally(p,0,p.window[p.strstart]),p.lookahead--,p.strstart++;if(P&&(ue(p,!1),p.strm.avail_out===0))return Q}return p.insert=p.strstart<B-1?p.strstart:B-1,j===l?(ue(p,!0),p.strm.avail_out===0?ge:fe):p.last_lit&&(ue(p,!1),p.strm.avail_out===0)?Q:G}function be(p,j){for(var q,P,$;;){if(p.lookahead<W){if(Te(p),p.lookahead<W&&j===o)return Q;if(p.lookahead===0)break}if(q=0,p.lookahead>=B&&(p.ins_h=(p.ins_h<<p.hash_shift^p.window[p.strstart+B-1])&p.hash_mask,q=p.prev[p.strstart&p.w_mask]=p.head[p.ins_h],p.head[p.ins_h]=p.strstart),p.prev_length=p.match_length,p.prev_match=p.match_start,p.match_length=B-1,q!==0&&p.prev_length<p.max_lazy_match&&p.strstart-q<=p.w_size-W&&(p.match_length=ye(p,q),p.match_length<=5&&(p.strategy===v||p.match_length===B&&p.strstart-p.match_start>4096)&&(p.match_length=B-1)),p.prev_length>=B&&p.match_length<=p.prev_length){$=p.strstart+p.lookahead-B,P=t._tr_tally(p,p.strstart-1-p.prev_match,p.prev_length-B),p.lookahead-=p.prev_length-1,p.prev_length-=2;do++p.strstart<=$&&(p.ins_h=(p.ins_h<<p.hash_shift^p.window[p.strstart+B-1])&p.hash_mask,q=p.prev[p.strstart&p.w_mask]=p.head[p.ins_h],p.head[p.ins_h]=p.strstart);while(--p.prev_length!==0);if(p.match_available=0,p.match_length=B-1,p.strstart++,P&&(ue(p,!1),p.strm.avail_out===0))return Q}else if(p.match_available){if(P=t._tr_tally(p,0,p.window[p.strstart-1]),P&&ue(p,!1),p.strstart++,p.lookahead--,p.strm.avail_out===0)return Q}else p.match_available=1,p.strstart++,p.lookahead--}return p.match_available&&(P=t._tr_tally(p,0,p.window[p.strstart-1]),p.match_available=0),p.insert=p.strstart<B-1?p.strstart:B-1,j===l?(ue(p,!0),p.strm.avail_out===0?ge:fe):p.last_lit&&(ue(p,!1),p.strm.avail_out===0)?Q:G}function Ae(p,j){for(var q,P,$,U,ve=p.window;;){if(p.lookahead<=D){if(Te(p),p.lookahead<=D&&j===o)return Q;if(p.lookahead===0)break}if(p.match_length=0,p.lookahead>=B&&p.strstart>0&&($=p.strstart-1,P=ve[$],P===ve[++$]&&P===ve[++$]&&P===ve[++$])){U=p.strstart+D;do;while(P===ve[++$]&&P===ve[++$]&&P===ve[++$]&&P===ve[++$]&&P===ve[++$]&&P===ve[++$]&&P===ve[++$]&&P===ve[++$]&&$<U);p.match_length=D-(U-$),p.match_length>p.lookahead&&(p.match_length=p.lookahead)}if(p.match_length>=B?(q=t._tr_tally(p,1,p.match_length-B),p.lookahead-=p.match_length,p.strstart+=p.match_length,p.match_length=0):(q=t._tr_tally(p,0,p.window[p.strstart]),p.lookahead--,p.strstart++),q&&(ue(p,!1),p.strm.avail_out===0))return Q}return p.insert=0,j===l?(ue(p,!0),p.strm.avail_out===0?ge:fe):p.last_lit&&(ue(p,!1),p.strm.avail_out===0)?Q:G}function Ie(p,j){for(var q;;){if(p.lookahead===0&&(Te(p),p.lookahead===0)){if(j===o)return Q;break}if(p.match_length=0,q=t._tr_tally(p,0,p.window[p.strstart]),p.lookahead--,p.strstart++,q&&(ue(p,!1),p.strm.avail_out===0))return Q}return p.insert=0,j===l?(ue(p,!0),p.strm.avail_out===0?ge:fe):p.last_lit&&(ue(p,!1),p.strm.avail_out===0)?Q:G}function Pe(p,j,q,P,$){this.good_length=p,this.max_lazy=j,this.nice_length=q,this.max_chain=P,this.func=$}var Oe;Oe=[new Pe(0,0,0,0,Ee),new Pe(4,4,8,4,Se),new Pe(4,5,16,8,Se),new Pe(4,6,32,32,Se),new Pe(4,4,16,16,be),new Pe(8,16,32,32,be),new Pe(8,16,128,128,be),new Pe(8,32,128,256,be),new Pe(32,128,258,1024,be),new Pe(32,258,258,4096,be)];function Fe(p){p.window_size=2*p.w_size,Ce(p.head),p.max_lazy_match=Oe[p.level].max_lazy,p.good_match=Oe[p.level].good_length,p.nice_match=Oe[p.level].nice_length,p.max_chain_length=Oe[p.level].max_chain,p.strstart=0,p.block_start=0,p.lookahead=0,p.insert=0,p.match_length=p.prev_length=B-1,p.match_available=0,p.ins_h=0}function M(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=b,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new e.Buf16(w*2),this.dyn_dtree=new e.Buf16((2*O+1)*2),this.bl_tree=new e.Buf16((2*F+1)*2),Ce(this.dyn_ltree),Ce(this.dyn_dtree),Ce(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new e.Buf16(L+1),this.heap=new e.Buf16(2*I+1),Ce(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new e.Buf16(2*I+1),Ce(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function re(p){var j;return!p||!p.state?J(p,d):(p.total_in=p.total_out=0,p.data_type=k,j=p.state,j.pending=0,j.pending_out=0,j.wrap<0&&(j.wrap=-j.wrap),j.status=j.wrap?ee:Z,p.adler=j.wrap===2?0:1,j.last_flush=o,t._tr_init(j),f)}function se(p){var j=re(p);return j===f&&Fe(p.state),j}function me(p,j){return!p||!p.state||p.state.wrap!==2?d:(p.state.gzhead=j,f)}function z(p,j,q,P,$,U){if(!p)return d;var ve=1;if(j===R&&(j=6),P<0?(ve=0,P=-P):P>15&&(ve=2,P-=16),$<1||$>C||q!==b||P<8||P>15||j<0||j>9||U<0||U>y)return J(p,d);P===8&&(P=9);var pe=new M;return p.state=pe,pe.strm=p,pe.wrap=ve,pe.gzhead=null,pe.w_bits=P,pe.w_size=1<<pe.w_bits,pe.w_mask=pe.w_size-1,pe.hash_bits=$+7,pe.hash_size=1<<pe.hash_bits,pe.hash_mask=pe.hash_size-1,pe.hash_shift=~~((pe.hash_bits+B-1)/B),pe.window=new e.Buf8(pe.w_size*2),pe.head=new e.Buf16(pe.hash_size),pe.prev=new e.Buf16(pe.w_size),pe.lit_bufsize=1<<$+6,pe.pending_buf_size=pe.lit_bufsize*4,pe.pending_buf=new e.Buf8(pe.pending_buf_size),pe.d_buf=1*pe.lit_bufsize,pe.l_buf=(1+2)*pe.lit_bufsize,pe.level=j,pe.strategy=U,pe.method=q,se(p)}function X(p,j){return z(p,j,b,_,A,E)}function T(p,j){var q,P,$,U;if(!p||!p.state||j>c||j<0)return p?J(p,d):d;if(P=p.state,!p.output||!p.input&&p.avail_in!==0||P.status===ce&&j!==l)return J(p,p.avail_out===0?m:d);if(P.strm=p,q=P.last_flush,P.last_flush=j,P.status===ee)if(P.wrap===2)p.adler=0,ne(P,31),ne(P,139),ne(P,8),P.gzhead?(ne(P,(P.gzhead.text?1:0)+(P.gzhead.hcrc?2:0)+(P.gzhead.extra?4:0)+(P.gzhead.name?8:0)+(P.gzhead.comment?16:0)),ne(P,P.gzhead.time&255),ne(P,P.gzhead.time>>8&255),ne(P,P.gzhead.time>>16&255),ne(P,P.gzhead.time>>24&255),ne(P,P.level===9?2:P.strategy>=g||P.level<2?4:0),ne(P,P.gzhead.os&255),P.gzhead.extra&&P.gzhead.extra.length&&(ne(P,P.gzhead.extra.length&255),ne(P,P.gzhead.extra.length>>8&255)),P.gzhead.hcrc&&(p.adler=a(p.adler,P.pending_buf,P.pending,0)),P.gzindex=0,P.status=H):(ne(P,0),ne(P,0),ne(P,0),ne(P,0),ne(P,0),ne(P,P.level===9?2:P.strategy>=g||P.level<2?4:0),ne(P,V),P.status=Z);else{var ve=b+(P.w_bits-8<<4)<<8,pe=-1;P.strategy>=g||P.level<2?pe=0:P.level<6?pe=1:P.level===6?pe=2:pe=3,ve|=pe<<6,P.strstart!==0&&(ve|=ae),ve+=31-ve%31,P.status=Z,de(P,ve),P.strstart!==0&&(de(P,p.adler>>>16),de(P,p.adler&65535)),p.adler=1}if(P.status===H)if(P.gzhead.extra){for($=P.pending;P.gzindex<(P.gzhead.extra.length&65535)&&!(P.pending===P.pending_buf_size&&(P.gzhead.hcrc&&P.pending>$&&(p.adler=a(p.adler,P.pending_buf,P.pending-$,$)),Y(p),$=P.pending,P.pending===P.pending_buf_size));)ne(P,P.gzhead.extra[P.gzindex]&255),P.gzindex++;P.gzhead.hcrc&&P.pending>$&&(p.adler=a(p.adler,P.pending_buf,P.pending-$,$)),P.gzindex===P.gzhead.extra.length&&(P.gzindex=0,P.status=oe)}else P.status=oe;if(P.status===oe)if(P.gzhead.name){$=P.pending;do{if(P.pending===P.pending_buf_size&&(P.gzhead.hcrc&&P.pending>$&&(p.adler=a(p.adler,P.pending_buf,P.pending-$,$)),Y(p),$=P.pending,P.pending===P.pending_buf_size)){U=1;break}P.gzindex<P.gzhead.name.length?U=P.gzhead.name.charCodeAt(P.gzindex++)&255:U=0,ne(P,U)}while(U!==0);P.gzhead.hcrc&&P.pending>$&&(p.adler=a(p.adler,P.pending_buf,P.pending-$,$)),U===0&&(P.gzindex=0,P.status=te)}else P.status=te;if(P.status===te)if(P.gzhead.comment){$=P.pending;do{if(P.pending===P.pending_buf_size&&(P.gzhead.hcrc&&P.pending>$&&(p.adler=a(p.adler,P.pending_buf,P.pending-$,$)),Y(p),$=P.pending,P.pending===P.pending_buf_size)){U=1;break}P.gzindex<P.gzhead.comment.length?U=P.gzhead.comment.charCodeAt(P.gzindex++)&255:U=0,ne(P,U)}while(U!==0);P.gzhead.hcrc&&P.pending>$&&(p.adler=a(p.adler,P.pending_buf,P.pending-$,$)),U===0&&(P.status=K)}else P.status=K;if(P.status===K&&(P.gzhead.hcrc?(P.pending+2>P.pending_buf_size&&Y(p),P.pending+2<=P.pending_buf_size&&(ne(P,p.adler&255),ne(P,p.adler>>8&255),p.adler=0,P.status=Z)):P.status=Z),P.pending!==0){if(Y(p),p.avail_out===0)return P.last_flush=-1,f}else if(p.avail_in===0&&Re(j)<=Re(q)&&j!==l)return J(p,m);if(P.status===ce&&p.avail_in!==0)return J(p,m);if(p.avail_in!==0||P.lookahead!==0||j!==o&&P.status!==ce){var he=P.strategy===g?Ie(P,j):P.strategy===x?Ae(P,j):Oe[P.level].func(P,j);if((he===ge||he===fe)&&(P.status=ce),he===Q||he===ge)return p.avail_out===0&&(P.last_flush=-1),f;if(he===G&&(j===i?t._tr_align(P):j!==c&&(t._tr_stored_block(P,0,0,!1),j===s&&(Ce(P.head),P.lookahead===0&&(P.strstart=0,P.block_start=0,P.insert=0))),Y(p),p.avail_out===0))return P.last_flush=-1,f}return j!==l?f:P.wrap<=0?u:(P.wrap===2?(ne(P,p.adler&255),ne(P,p.adler>>8&255),ne(P,p.adler>>16&255),ne(P,p.adler>>24&255),ne(P,p.total_in&255),ne(P,p.total_in>>8&255),ne(P,p.total_in>>16&255),ne(P,p.total_in>>24&255)):(de(P,p.adler>>>16),de(P,p.adler&65535)),Y(p),P.wrap>0&&(P.wrap=-P.wrap),P.pending!==0?f:u)}function ie(p){var j;return!p||!p.state?d:(j=p.state.status,j!==ee&&j!==H&&j!==oe&&j!==te&&j!==K&&j!==Z&&j!==ce?J(p,d):(p.state=null,j===Z?J(p,h):f))}function xe(p,j){var q=j.length,P,$,U,ve,pe,he,ke,Ue;if(!p||!p.state||(P=p.state,ve=P.wrap,ve===2||ve===1&&P.status!==ee||P.lookahead))return d;for(ve===1&&(p.adler=n(p.adler,j,q,0)),P.wrap=0,q>=P.w_size&&(ve===0&&(Ce(P.head),P.strstart=0,P.block_start=0,P.insert=0),Ue=new e.Buf8(P.w_size),e.arraySet(Ue,j,q-P.w_size,P.w_size,0),j=Ue,q=P.w_size),pe=p.avail_in,he=p.next_in,ke=p.input,p.avail_in=q,p.next_in=0,p.input=j,Te(P);P.lookahead>=B;){$=P.strstart,U=P.lookahead-(B-1);do P.ins_h=(P.ins_h<<P.hash_shift^P.window[$+B-1])&P.hash_mask,P.prev[$&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=$,$++;while(--U);P.strstart=$,P.lookahead=B-1,Te(P)}return P.strstart+=P.lookahead,P.block_start=P.strstart,P.insert=P.lookahead,P.lookahead=0,P.match_length=P.prev_length=B-1,P.match_available=0,p.next_in=he,p.input=ke,p.avail_in=pe,P.wrap=ve,f}return deflate.deflateInit=X,deflate.deflateInit2=z,deflate.deflateReset=se,deflate.deflateResetKeep=re,deflate.deflateSetHeader=me,deflate.deflate=T,deflate.deflateEnd=ie,deflate.deflateSetDictionary=xe,deflate.deflateInfo="pako deflate (from Nodeca project)",deflate}var strings={},hasRequiredStrings;function requireStrings(){if(hasRequiredStrings)return strings;hasRequiredStrings=1;var e=requireCommon(),t=!0,n=!0;try{String.fromCharCode.apply(null,[0])}catch(i){t=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(i){n=!1}for(var a=new e.Buf8(256),r=0;r<256;r++)a[r]=r>=252?6:r>=248?5:r>=240?4:r>=224?3:r>=192?2:1;a[254]=a[254]=1,strings.string2buf=function(i){var s,l,c,f,u,d=i.length,h=0;for(f=0;f<d;f++)l=i.charCodeAt(f),(l&64512)===55296&&f+1<d&&(c=i.charCodeAt(f+1),(c&64512)===56320&&(l=65536+(l-55296<<10)+(c-56320),f++)),h+=l<128?1:l<2048?2:l<65536?3:4;for(s=new e.Buf8(h),u=0,f=0;u<h;f++)l=i.charCodeAt(f),(l&64512)===55296&&f+1<d&&(c=i.charCodeAt(f+1),(c&64512)===56320&&(l=65536+(l-55296<<10)+(c-56320),f++)),l<128?s[u++]=l:l<2048?(s[u++]=192|l>>>6,s[u++]=128|l&63):l<65536?(s[u++]=224|l>>>12,s[u++]=128|l>>>6&63,s[u++]=128|l&63):(s[u++]=240|l>>>18,s[u++]=128|l>>>12&63,s[u++]=128|l>>>6&63,s[u++]=128|l&63);return s};function o(i,s){if(s<65534&&(i.subarray&&n||!i.subarray&&t))return String.fromCharCode.apply(null,e.shrinkBuf(i,s));for(var l="",c=0;c<s;c++)l+=String.fromCharCode(i[c]);return l}return strings.buf2binstring=function(i){return o(i,i.length)},strings.binstring2buf=function(i){for(var s=new e.Buf8(i.length),l=0,c=s.length;l<c;l++)s[l]=i.charCodeAt(l);return s},strings.buf2string=function(i,s){var l,c,f,u,d=s||i.length,h=new Array(d*2);for(c=0,l=0;l<d;){if(f=i[l++],f<128){h[c++]=f;continue}if(u=a[f],u>4){h[c++]=65533,l+=u-1;continue}for(f&=u===2?31:u===3?15:7;u>1&&l<d;)f=f<<6|i[l++]&63,u--;if(u>1){h[c++]=65533;continue}f<65536?h[c++]=f:(f-=65536,h[c++]=55296|f>>10&1023,h[c++]=56320|f&1023)}return o(h,c)},strings.utf8border=function(i,s){var l;for(s=s||i.length,s>i.length&&(s=i.length),l=s-1;l>=0&&(i[l]&192)===128;)l--;return l<0||l===0?s:l+a[i[l]]>s?l:s},strings}var zstream,hasRequiredZstream;function requireZstream(){if(hasRequiredZstream)return zstream;hasRequiredZstream=1;function e(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}return zstream=e,zstream}var hasRequiredDeflate;function requireDeflate(){if(hasRequiredDeflate)return deflate$1;hasRequiredDeflate=1;var e=requireDeflate$1(),t=requireCommon(),n=requireStrings(),a=requireMessages(),r=requireZstream(),o=Object.prototype.toString,i=0,s=4,l=0,c=1,f=2,u=-1,d=0,h=8;function m(x){if(!(this instanceof m))return new m(x);this.options=t.assign({level:u,method:h,chunkSize:16384,windowBits:15,memLevel:8,strategy:d,to:""},x||{});var y=this.options;y.raw&&y.windowBits>0?y.windowBits=-y.windowBits:y.gzip&&y.windowBits>0&&y.windowBits<16&&(y.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new r,this.strm.avail_out=0;var E=e.deflateInit2(this.strm,y.level,y.method,y.windowBits,y.memLevel,y.strategy);if(E!==l)throw new Error(a[E]);if(y.header&&e.deflateSetHeader(this.strm,y.header),y.dictionary){var k;if(typeof y.dictionary=="string"?k=n.string2buf(y.dictionary):o.call(y.dictionary)==="[object ArrayBuffer]"?k=new Uint8Array(y.dictionary):k=y.dictionary,E=e.deflateSetDictionary(this.strm,k),E!==l)throw new Error(a[E]);this._dict_set=!0}}m.prototype.push=function(x,y){var E=this.strm,k=this.options.chunkSize,b,C;if(this.ended)return!1;C=y===~~y?y:y===!0?s:i,typeof x=="string"?E.input=n.string2buf(x):o.call(x)==="[object ArrayBuffer]"?E.input=new Uint8Array(x):E.input=x,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new t.Buf8(k),E.next_out=0,E.avail_out=k),b=e.deflate(E,C),b!==c&&b!==l)return this.onEnd(b),this.ended=!0,!1;(E.avail_out===0||E.avail_in===0&&(C===s||C===f))&&(this.options.to==="string"?this.onData(n.buf2binstring(t.shrinkBuf(E.output,E.next_out))):this.onData(t.shrinkBuf(E.output,E.next_out)))}while((E.avail_in>0||E.avail_out===0)&&b!==c);return C===s?(b=e.deflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===l):(C===f&&(this.onEnd(l),E.avail_out=0),!0)},m.prototype.onData=function(x){this.chunks.push(x)},m.prototype.onEnd=function(x){x===l&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=t.flattenChunks(this.chunks)),this.chunks=[],this.err=x,this.msg=this.strm.msg};function R(x,y){var E=new m(y);if(E.push(x,!0),E.err)throw E.msg||a[E.err];return E.result}function v(x,y){return y=y||{},y.raw=!0,R(x,y)}function g(x,y){return y=y||{},y.gzip=!0,R(x,y)}return deflate$1.Deflate=m,deflate$1.deflate=R,deflate$1.deflateRaw=v,deflate$1.gzip=g,deflate$1}var inflate$1={},inflate={},inffast,hasRequiredInffast;function requireInffast(){if(hasRequiredInffast)return inffast;hasRequiredInffast=1;var e=30,t=12;return inffast=function(a,r){var o,i,s,l,c,f,u,d,h,m,R,v,g,x,y,E,k,b,C,_,A,N,S,I,O;o=a.state,i=a.next_in,I=a.input,s=i+(a.avail_in-5),l=a.next_out,O=a.output,c=l-(r-a.avail_out),f=l+(a.avail_out-257),u=o.dmax,d=o.wsize,h=o.whave,m=o.wnext,R=o.window,v=o.hold,g=o.bits,x=o.lencode,y=o.distcode,E=(1<<o.lenbits)-1,k=(1<<o.distbits)-1;e:do{g<15&&(v+=I[i++]<<g,g+=8,v+=I[i++]<<g,g+=8),b=x[v&E];t:for(;;){if(C=b>>>24,v>>>=C,g-=C,C=b>>>16&255,C===0)O[l++]=b&65535;else if(C&16){_=b&65535,C&=15,C&&(g<C&&(v+=I[i++]<<g,g+=8),_+=v&(1<<C)-1,v>>>=C,g-=C),g<15&&(v+=I[i++]<<g,g+=8,v+=I[i++]<<g,g+=8),b=y[v&k];n:for(;;){if(C=b>>>24,v>>>=C,g-=C,C=b>>>16&255,C&16){if(A=b&65535,C&=15,g<C&&(v+=I[i++]<<g,g+=8,g<C&&(v+=I[i++]<<g,g+=8)),A+=v&(1<<C)-1,A>u){a.msg="invalid distance too far back",o.mode=e;break e}if(v>>>=C,g-=C,C=l-c,A>C){if(C=A-C,C>h&&o.sane){a.msg="invalid distance too far back",o.mode=e;break e}if(N=0,S=R,m===0){if(N+=d-C,C<_){_-=C;do O[l++]=R[N++];while(--C);N=l-A,S=O}}else if(m<C){if(N+=d+m-C,C-=m,C<_){_-=C;do O[l++]=R[N++];while(--C);if(N=0,m<_){C=m,_-=C;do O[l++]=R[N++];while(--C);N=l-A,S=O}}}else if(N+=m-C,C<_){_-=C;do O[l++]=R[N++];while(--C);N=l-A,S=O}for(;_>2;)O[l++]=S[N++],O[l++]=S[N++],O[l++]=S[N++],_-=3;_&&(O[l++]=S[N++],_>1&&(O[l++]=S[N++]))}else{N=l-A;do O[l++]=O[N++],O[l++]=O[N++],O[l++]=O[N++],_-=3;while(_>2);_&&(O[l++]=O[N++],_>1&&(O[l++]=O[N++]))}}else if(C&64){a.msg="invalid distance code",o.mode=e;break e}else{b=y[(b&65535)+(v&(1<<C)-1)];continue n}break}}else if(C&64)if(C&32){o.mode=t;break e}else{a.msg="invalid literal/length code",o.mode=e;break e}else{b=x[(b&65535)+(v&(1<<C)-1)];continue t}break}}while(i<s&&l<f);_=g>>3,i-=_,g-=_<<3,v&=(1<<g)-1,a.next_in=i,a.next_out=l,a.avail_in=i<s?5+(s-i):5-(i-s),a.avail_out=l<f?257+(f-l):257-(l-f),o.hold=v,o.bits=g},inffast}var inftrees,hasRequiredInftrees;function requireInftrees(){if(hasRequiredInftrees)return inftrees;hasRequiredInftrees=1;var e=requireCommon(),t=15,n=852,a=592,r=0,o=1,i=2,s=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],f=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];return inftrees=function(d,h,m,R,v,g,x,y){var E=y.bits,k=0,b=0,C=0,_=0,A=0,N=0,S=0,I=0,O=0,F=0,w,L,B,D,W,ae=null,ee=0,H,oe=new e.Buf16(t+1),te=new e.Buf16(t+1),K=null,Z=0,ce,Q,G;for(k=0;k<=t;k++)oe[k]=0;for(b=0;b<R;b++)oe[h[m+b]]++;for(A=E,_=t;_>=1&&oe[_]===0;_--);if(A>_&&(A=_),_===0)return v[g++]=1<<24|64<<16|0,v[g++]=1<<24|64<<16|0,y.bits=1,0;for(C=1;C<_&&oe[C]===0;C++);for(A<C&&(A=C),I=1,k=1;k<=t;k++)if(I<<=1,I-=oe[k],I<0)return-1;if(I>0&&(d===r||_!==1))return-1;for(te[1]=0,k=1;k<t;k++)te[k+1]=te[k]+oe[k];for(b=0;b<R;b++)h[m+b]!==0&&(x[te[h[m+b]]++]=b);if(d===r?(ae=K=x,H=19):d===o?(ae=s,ee-=257,K=l,Z-=257,H=256):(ae=c,K=f,H=-1),F=0,b=0,k=C,W=g,N=A,S=0,B=-1,O=1<<A,D=O-1,d===o&&O>n||d===i&&O>a)return 1;for(;;){ce=k-S,x[b]<H?(Q=0,G=x[b]):x[b]>H?(Q=K[Z+x[b]],G=ae[ee+x[b]]):(Q=32+64,G=0),w=1<<k-S,L=1<<N,C=L;do L-=w,v[W+(F>>S)+L]=ce<<24|Q<<16|G|0;while(L!==0);for(w=1<<k-1;F&w;)w>>=1;if(w!==0?(F&=w-1,F+=w):F=0,b++,--oe[k]===0){if(k===_)break;k=h[m+x[b]]}if(k>A&&(F&D)!==B){for(S===0&&(S=A),W+=C,N=k-S,I=1<<N;N+S<_&&(I-=oe[N+S],!(I<=0));)N++,I<<=1;if(O+=1<<N,d===o&&O>n||d===i&&O>a)return 1;B=F&D,v[B]=A<<24|N<<16|W-g|0}}return F!==0&&(v[W+F]=k-S<<24|64<<16|0),y.bits=A,0},inftrees}var hasRequiredInflate$1;function requireInflate$1(){if(hasRequiredInflate$1)return inflate;hasRequiredInflate$1=1;var e=requireCommon(),t=requireAdler32(),n=requireCrc32(),a=requireInffast(),r=requireInftrees(),o=0,i=1,s=2,l=4,c=5,f=6,u=0,d=1,h=2,m=-2,R=-3,v=-4,g=-5,x=8,y=1,E=2,k=3,b=4,C=5,_=6,A=7,N=8,S=9,I=10,O=11,F=12,w=13,L=14,B=15,D=16,W=17,ae=18,ee=19,H=20,oe=21,te=22,K=23,Z=24,ce=25,Q=26,G=27,ge=28,fe=29,V=30,J=31,Re=32,Ce=852,Y=592,ue=15,ne=ue;function de(z){return(z>>>24&255)+(z>>>8&65280)+((z&65280)<<8)+((z&255)<<24)}function _e(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new e.Buf16(320),this.work=new e.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function ye(z){var X;return!z||!z.state?m:(X=z.state,z.total_in=z.total_out=X.total=0,z.msg="",X.wrap&&(z.adler=X.wrap&1),X.mode=y,X.last=0,X.havedict=0,X.dmax=32768,X.head=null,X.hold=0,X.bits=0,X.lencode=X.lendyn=new e.Buf32(Ce),X.distcode=X.distdyn=new e.Buf32(Y),X.sane=1,X.back=-1,u)}function Te(z){var X;return!z||!z.state?m:(X=z.state,X.wsize=0,X.whave=0,X.wnext=0,ye(z))}function Ee(z,X){var T,ie;return!z||!z.state||(ie=z.state,X<0?(T=0,X=-X):(T=(X>>4)+1,X<48&&(X&=15)),X&&(X<8||X>15))?m:(ie.window!==null&&ie.wbits!==X&&(ie.window=null),ie.wrap=T,ie.wbits=X,Te(z))}function Se(z,X){var T,ie;return z?(ie=new _e,z.state=ie,ie.window=null,T=Ee(z,X),T!==u&&(z.state=null),T):m}function be(z){return Se(z,ne)}var Ae=!0,Ie,Pe;function Oe(z){if(Ae){var X;for(Ie=new e.Buf32(512),Pe=new e.Buf32(32),X=0;X<144;)z.lens[X++]=8;for(;X<256;)z.lens[X++]=9;for(;X<280;)z.lens[X++]=7;for(;X<288;)z.lens[X++]=8;for(r(i,z.lens,0,288,Ie,0,z.work,{bits:9}),X=0;X<32;)z.lens[X++]=5;r(s,z.lens,0,32,Pe,0,z.work,{bits:5}),Ae=!1}z.lencode=Ie,z.lenbits=9,z.distcode=Pe,z.distbits=5}function Fe(z,X,T,ie){var xe,p=z.state;return p.window===null&&(p.wsize=1<<p.wbits,p.wnext=0,p.whave=0,p.window=new e.Buf8(p.wsize)),ie>=p.wsize?(e.arraySet(p.window,X,T-p.wsize,p.wsize,0),p.wnext=0,p.whave=p.wsize):(xe=p.wsize-p.wnext,xe>ie&&(xe=ie),e.arraySet(p.window,X,T-ie,xe,p.wnext),ie-=xe,ie?(e.arraySet(p.window,X,T-ie,ie,0),p.wnext=ie,p.whave=p.wsize):(p.wnext+=xe,p.wnext===p.wsize&&(p.wnext=0),p.whave<p.wsize&&(p.whave+=xe))),0}function M(z,X){var T,ie,xe,p,j,q,P,$,U,ve,pe,he,ke,Ue,we=0,Ne,Be,$e,Ve,Ge,je,Le,ze,De=new e.Buf8(4),He,We,Ze=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!z||!z.state||!z.output||!z.input&&z.avail_in!==0)return m;T=z.state,T.mode===F&&(T.mode=w),j=z.next_out,xe=z.output,P=z.avail_out,p=z.next_in,ie=z.input,q=z.avail_in,$=T.hold,U=T.bits,ve=q,pe=P,ze=u;e:for(;;)switch(T.mode){case y:if(T.wrap===0){T.mode=w;break}for(;U<16;){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}if(T.wrap&2&&$===35615){T.check=0,De[0]=$&255,De[1]=$>>>8&255,T.check=n(T.check,De,2,0),$=0,U=0,T.mode=E;break}if(T.flags=0,T.head&&(T.head.done=!1),!(T.wrap&1)||((($&255)<<8)+($>>8))%31){z.msg="incorrect header check",T.mode=V;break}if(($&15)!==x){z.msg="unknown compression method",T.mode=V;break}if($>>>=4,U-=4,Le=($&15)+8,T.wbits===0)T.wbits=Le;else if(Le>T.wbits){z.msg="invalid window size",T.mode=V;break}T.dmax=1<<Le,z.adler=T.check=1,T.mode=$&512?I:F,$=0,U=0;break;case E:for(;U<16;){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}if(T.flags=$,(T.flags&255)!==x){z.msg="unknown compression method",T.mode=V;break}if(T.flags&57344){z.msg="unknown header flags set",T.mode=V;break}T.head&&(T.head.text=$>>8&1),T.flags&512&&(De[0]=$&255,De[1]=$>>>8&255,T.check=n(T.check,De,2,0)),$=0,U=0,T.mode=k;case k:for(;U<32;){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}T.head&&(T.head.time=$),T.flags&512&&(De[0]=$&255,De[1]=$>>>8&255,De[2]=$>>>16&255,De[3]=$>>>24&255,T.check=n(T.check,De,4,0)),$=0,U=0,T.mode=b;case b:for(;U<16;){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}T.head&&(T.head.xflags=$&255,T.head.os=$>>8),T.flags&512&&(De[0]=$&255,De[1]=$>>>8&255,T.check=n(T.check,De,2,0)),$=0,U=0,T.mode=C;case C:if(T.flags&1024){for(;U<16;){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}T.length=$,T.head&&(T.head.extra_len=$),T.flags&512&&(De[0]=$&255,De[1]=$>>>8&255,T.check=n(T.check,De,2,0)),$=0,U=0}else T.head&&(T.head.extra=null);T.mode=_;case _:if(T.flags&1024&&(he=T.length,he>q&&(he=q),he&&(T.head&&(Le=T.head.extra_len-T.length,T.head.extra||(T.head.extra=new Array(T.head.extra_len)),e.arraySet(T.head.extra,ie,p,he,Le)),T.flags&512&&(T.check=n(T.check,ie,he,p)),q-=he,p+=he,T.length-=he),T.length))break e;T.length=0,T.mode=A;case A:if(T.flags&2048){if(q===0)break e;he=0;do Le=ie[p+he++],T.head&&Le&&T.length<65536&&(T.head.name+=String.fromCharCode(Le));while(Le&&he<q);if(T.flags&512&&(T.check=n(T.check,ie,he,p)),q-=he,p+=he,Le)break e}else T.head&&(T.head.name=null);T.length=0,T.mode=N;case N:if(T.flags&4096){if(q===0)break e;he=0;do Le=ie[p+he++],T.head&&Le&&T.length<65536&&(T.head.comment+=String.fromCharCode(Le));while(Le&&he<q);if(T.flags&512&&(T.check=n(T.check,ie,he,p)),q-=he,p+=he,Le)break e}else T.head&&(T.head.comment=null);T.mode=S;case S:if(T.flags&512){for(;U<16;){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}if($!==(T.check&65535)){z.msg="header crc mismatch",T.mode=V;break}$=0,U=0}T.head&&(T.head.hcrc=T.flags>>9&1,T.head.done=!0),z.adler=T.check=0,T.mode=F;break;case I:for(;U<32;){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}z.adler=T.check=de($),$=0,U=0,T.mode=O;case O:if(T.havedict===0)return z.next_out=j,z.avail_out=P,z.next_in=p,z.avail_in=q,T.hold=$,T.bits=U,h;z.adler=T.check=1,T.mode=F;case F:if(X===c||X===f)break e;case w:if(T.last){$>>>=U&7,U-=U&7,T.mode=G;break}for(;U<3;){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}switch(T.last=$&1,$>>>=1,U-=1,$&3){case 0:T.mode=L;break;case 1:if(Oe(T),T.mode=H,X===f){$>>>=2,U-=2;break e}break;case 2:T.mode=W;break;case 3:z.msg="invalid block type",T.mode=V}$>>>=2,U-=2;break;case L:for($>>>=U&7,U-=U&7;U<32;){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}if(($&65535)!==($>>>16^65535)){z.msg="invalid stored block lengths",T.mode=V;break}if(T.length=$&65535,$=0,U=0,T.mode=B,X===f)break e;case B:T.mode=D;case D:if(he=T.length,he){if(he>q&&(he=q),he>P&&(he=P),he===0)break e;e.arraySet(xe,ie,p,he,j),q-=he,p+=he,P-=he,j+=he,T.length-=he;break}T.mode=F;break;case W:for(;U<14;){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}if(T.nlen=($&31)+257,$>>>=5,U-=5,T.ndist=($&31)+1,$>>>=5,U-=5,T.ncode=($&15)+4,$>>>=4,U-=4,T.nlen>286||T.ndist>30){z.msg="too many length or distance symbols",T.mode=V;break}T.have=0,T.mode=ae;case ae:for(;T.have<T.ncode;){for(;U<3;){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}T.lens[Ze[T.have++]]=$&7,$>>>=3,U-=3}for(;T.have<19;)T.lens[Ze[T.have++]]=0;if(T.lencode=T.lendyn,T.lenbits=7,He={bits:T.lenbits},ze=r(o,T.lens,0,19,T.lencode,0,T.work,He),T.lenbits=He.bits,ze){z.msg="invalid code lengths set",T.mode=V;break}T.have=0,T.mode=ee;case ee:for(;T.have<T.nlen+T.ndist;){for(;we=T.lencode[$&(1<<T.lenbits)-1],Ne=we>>>24,Be=we>>>16&255,$e=we&65535,!(Ne<=U);){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}if($e<16)$>>>=Ne,U-=Ne,T.lens[T.have++]=$e;else{if($e===16){for(We=Ne+2;U<We;){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}if($>>>=Ne,U-=Ne,T.have===0){z.msg="invalid bit length repeat",T.mode=V;break}Le=T.lens[T.have-1],he=3+($&3),$>>>=2,U-=2}else if($e===17){for(We=Ne+3;U<We;){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}$>>>=Ne,U-=Ne,Le=0,he=3+($&7),$>>>=3,U-=3}else{for(We=Ne+7;U<We;){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}$>>>=Ne,U-=Ne,Le=0,he=11+($&127),$>>>=7,U-=7}if(T.have+he>T.nlen+T.ndist){z.msg="invalid bit length repeat",T.mode=V;break}for(;he--;)T.lens[T.have++]=Le}}if(T.mode===V)break;if(T.lens[256]===0){z.msg="invalid code -- missing end-of-block",T.mode=V;break}if(T.lenbits=9,He={bits:T.lenbits},ze=r(i,T.lens,0,T.nlen,T.lencode,0,T.work,He),T.lenbits=He.bits,ze){z.msg="invalid literal/lengths set",T.mode=V;break}if(T.distbits=6,T.distcode=T.distdyn,He={bits:T.distbits},ze=r(s,T.lens,T.nlen,T.ndist,T.distcode,0,T.work,He),T.distbits=He.bits,ze){z.msg="invalid distances set",T.mode=V;break}if(T.mode=H,X===f)break e;case H:T.mode=oe;case oe:if(q>=6&&P>=258){z.next_out=j,z.avail_out=P,z.next_in=p,z.avail_in=q,T.hold=$,T.bits=U,a(z,pe),j=z.next_out,xe=z.output,P=z.avail_out,p=z.next_in,ie=z.input,q=z.avail_in,$=T.hold,U=T.bits,T.mode===F&&(T.back=-1);break}for(T.back=0;we=T.lencode[$&(1<<T.lenbits)-1],Ne=we>>>24,Be=we>>>16&255,$e=we&65535,!(Ne<=U);){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}if(Be&&!(Be&240)){for(Ve=Ne,Ge=Be,je=$e;we=T.lencode[je+(($&(1<<Ve+Ge)-1)>>Ve)],Ne=we>>>24,Be=we>>>16&255,$e=we&65535,!(Ve+Ne<=U);){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}$>>>=Ve,U-=Ve,T.back+=Ve}if($>>>=Ne,U-=Ne,T.back+=Ne,T.length=$e,Be===0){T.mode=Q;break}if(Be&32){T.back=-1,T.mode=F;break}if(Be&64){z.msg="invalid literal/length code",T.mode=V;break}T.extra=Be&15,T.mode=te;case te:if(T.extra){for(We=T.extra;U<We;){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}T.length+=$&(1<<T.extra)-1,$>>>=T.extra,U-=T.extra,T.back+=T.extra}T.was=T.length,T.mode=K;case K:for(;we=T.distcode[$&(1<<T.distbits)-1],Ne=we>>>24,Be=we>>>16&255,$e=we&65535,!(Ne<=U);){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}if(!(Be&240)){for(Ve=Ne,Ge=Be,je=$e;we=T.distcode[je+(($&(1<<Ve+Ge)-1)>>Ve)],Ne=we>>>24,Be=we>>>16&255,$e=we&65535,!(Ve+Ne<=U);){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}$>>>=Ve,U-=Ve,T.back+=Ve}if($>>>=Ne,U-=Ne,T.back+=Ne,Be&64){z.msg="invalid distance code",T.mode=V;break}T.offset=$e,T.extra=Be&15,T.mode=Z;case Z:if(T.extra){for(We=T.extra;U<We;){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}T.offset+=$&(1<<T.extra)-1,$>>>=T.extra,U-=T.extra,T.back+=T.extra}if(T.offset>T.dmax){z.msg="invalid distance too far back",T.mode=V;break}T.mode=ce;case ce:if(P===0)break e;if(he=pe-P,T.offset>he){if(he=T.offset-he,he>T.whave&&T.sane){z.msg="invalid distance too far back",T.mode=V;break}he>T.wnext?(he-=T.wnext,ke=T.wsize-he):ke=T.wnext-he,he>T.length&&(he=T.length),Ue=T.window}else Ue=xe,ke=j-T.offset,he=T.length;he>P&&(he=P),P-=he,T.length-=he;do xe[j++]=Ue[ke++];while(--he);T.length===0&&(T.mode=oe);break;case Q:if(P===0)break e;xe[j++]=T.length,P--,T.mode=oe;break;case G:if(T.wrap){for(;U<32;){if(q===0)break e;q--,$|=ie[p++]<<U,U+=8}if(pe-=P,z.total_out+=pe,T.total+=pe,pe&&(z.adler=T.check=T.flags?n(T.check,xe,pe,j-pe):t(T.check,xe,pe,j-pe)),pe=P,(T.flags?$:de($))!==T.check){z.msg="incorrect data check",T.mode=V;break}$=0,U=0}T.mode=ge;case ge:if(T.wrap&&T.flags){for(;U<32;){if(q===0)break e;q--,$+=ie[p++]<<U,U+=8}if($!==(T.total&4294967295)){z.msg="incorrect length check",T.mode=V;break}$=0,U=0}T.mode=fe;case fe:ze=d;break e;case V:ze=R;break e;case J:return v;case Re:default:return m}return z.next_out=j,z.avail_out=P,z.next_in=p,z.avail_in=q,T.hold=$,T.bits=U,(T.wsize||pe!==z.avail_out&&T.mode<V&&(T.mode<G||X!==l))&&Fe(z,z.output,z.next_out,pe-z.avail_out),ve-=z.avail_in,pe-=z.avail_out,z.total_in+=ve,z.total_out+=pe,T.total+=pe,T.wrap&&pe&&(z.adler=T.check=T.flags?n(T.check,xe,pe,z.next_out-pe):t(T.check,xe,pe,z.next_out-pe)),z.data_type=T.bits+(T.last?64:0)+(T.mode===F?128:0)+(T.mode===H||T.mode===B?256:0),(ve===0&&pe===0||X===l)&&ze===u&&(ze=g),ze}function re(z){if(!z||!z.state)return m;var X=z.state;return X.window&&(X.window=null),z.state=null,u}function se(z,X){var T;return!z||!z.state||(T=z.state,!(T.wrap&2))?m:(T.head=X,X.done=!1,u)}function me(z,X){var T=X.length,ie,xe,p;return!z||!z.state||(ie=z.state,ie.wrap!==0&&ie.mode!==O)?m:ie.mode===O&&(xe=1,xe=t(xe,X,T,0),xe!==ie.check)?R:(p=Fe(z,X,T,T),p?(ie.mode=J,v):(ie.havedict=1,u))}return inflate.inflateReset=Te,inflate.inflateReset2=Ee,inflate.inflateResetKeep=ye,inflate.inflateInit=be,inflate.inflateInit2=Se,inflate.inflate=M,inflate.inflateEnd=re,inflate.inflateGetHeader=se,inflate.inflateSetDictionary=me,inflate.inflateInfo="pako inflate (from Nodeca project)",inflate}var constants,hasRequiredConstants;function requireConstants(){return hasRequiredConstants||(hasRequiredConstants=1,constants={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}),constants}var gzheader,hasRequiredGzheader;function requireGzheader(){if(hasRequiredGzheader)return gzheader;hasRequiredGzheader=1;function e(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}return gzheader=e,gzheader}var hasRequiredInflate;function requireInflate(){if(hasRequiredInflate)return inflate$1;hasRequiredInflate=1;var e=requireInflate$1(),t=requireCommon(),n=requireStrings(),a=requireConstants(),r=requireMessages(),o=requireZstream(),i=requireGzheader(),s=Object.prototype.toString;function l(u){if(!(this instanceof l))return new l(u);this.options=t.assign({chunkSize:16384,windowBits:0,to:""},u||{});var d=this.options;d.raw&&d.windowBits>=0&&d.windowBits<16&&(d.windowBits=-d.windowBits,d.windowBits===0&&(d.windowBits=-15)),d.windowBits>=0&&d.windowBits<16&&!(u&&u.windowBits)&&(d.windowBits+=32),d.windowBits>15&&d.windowBits<48&&(d.windowBits&15||(d.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new o,this.strm.avail_out=0;var h=e.inflateInit2(this.strm,d.windowBits);if(h!==a.Z_OK)throw new Error(r[h]);if(this.header=new i,e.inflateGetHeader(this.strm,this.header),d.dictionary&&(typeof d.dictionary=="string"?d.dictionary=n.string2buf(d.dictionary):s.call(d.dictionary)==="[object ArrayBuffer]"&&(d.dictionary=new Uint8Array(d.dictionary)),d.raw&&(h=e.inflateSetDictionary(this.strm,d.dictionary),h!==a.Z_OK)))throw new Error(r[h])}l.prototype.push=function(u,d){var h=this.strm,m=this.options.chunkSize,R=this.options.dictionary,v,g,x,y,E,k=!1;if(this.ended)return!1;g=d===~~d?d:d===!0?a.Z_FINISH:a.Z_NO_FLUSH,typeof u=="string"?h.input=n.binstring2buf(u):s.call(u)==="[object ArrayBuffer]"?h.input=new Uint8Array(u):h.input=u,h.next_in=0,h.avail_in=h.input.length;do{if(h.avail_out===0&&(h.output=new t.Buf8(m),h.next_out=0,h.avail_out=m),v=e.inflate(h,a.Z_NO_FLUSH),v===a.Z_NEED_DICT&&R&&(v=e.inflateSetDictionary(this.strm,R)),v===a.Z_BUF_ERROR&&k===!0&&(v=a.Z_OK,k=!1),v!==a.Z_STREAM_END&&v!==a.Z_OK)return this.onEnd(v),this.ended=!0,!1;h.next_out&&(h.avail_out===0||v===a.Z_STREAM_END||h.avail_in===0&&(g===a.Z_FINISH||g===a.Z_SYNC_FLUSH))&&(this.options.to==="string"?(x=n.utf8border(h.output,h.next_out),y=h.next_out-x,E=n.buf2string(h.output,x),h.next_out=y,h.avail_out=m-y,y&&t.arraySet(h.output,h.output,x,y,0),this.onData(E)):this.onData(t.shrinkBuf(h.output,h.next_out))),h.avail_in===0&&h.avail_out===0&&(k=!0)}while((h.avail_in>0||h.avail_out===0)&&v!==a.Z_STREAM_END);return v===a.Z_STREAM_END&&(g=a.Z_FINISH),g===a.Z_FINISH?(v=e.inflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===a.Z_OK):(g===a.Z_SYNC_FLUSH&&(this.onEnd(a.Z_OK),h.avail_out=0),!0)},l.prototype.onData=function(u){this.chunks.push(u)},l.prototype.onEnd=function(u){u===a.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=t.flattenChunks(this.chunks)),this.chunks=[],this.err=u,this.msg=this.strm.msg};function c(u,d){var h=new l(d);if(h.push(u,!0),h.err)throw h.msg||r[h.err];return h.result}function f(u,d){return d=d||{},d.raw=!0,c(u,d)}return inflate$1.Inflate=l,inflate$1.inflate=c,inflate$1.inflateRaw=f,inflate$1.ungzip=c,inflate$1}var pako_1,hasRequiredPako;function requirePako(){if(hasRequiredPako)return pako_1;hasRequiredPako=1;var e=requireCommon().assign,t=requireDeflate(),n=requireInflate(),a=requireConstants(),r={};return e(r,t,n,a),pako_1=r,pako_1}(function(e){(function(){var t={},n;e.exports=t,typeof commonjsRequire=="function"?n=requirePako():n=window.pako,function(a,r){a.toRGBA8=function(o){var i=o.width,s=o.height;if(o.tabs.acTL==null)return[a.toRGBA8.decodeImage(o.data,i,s,o).buffer];var l=[];o.frames[0].data==null&&(o.frames[0].data=o.data);for(var c,f=new Uint8Array(i*s*4),u=0;u<o.frames.length;u++){var d=o.frames[u],h=d.rect.x,m=d.rect.y,R=d.rect.width,v=d.rect.height,g=a.toRGBA8.decodeImage(d.data,R,v,o);if(u==0?c=g:d.blend==0?a._copyTile(g,R,v,c,i,s,h,m,0):d.blend==1&&a._copyTile(g,R,v,c,i,s,h,m,1),l.push(c.buffer),c=c.slice(0),d.dispose!=0){if(d.dispose==1)a._copyTile(f,R,v,c,i,s,h,m,0);else if(d.dispose==2){for(var x=u-1;o.frames[x].dispose==2;)x--;c=new Uint8Array(l[x]).slice(0)}}}return l},a.toRGBA8.decodeImage=function(o,i,s,l){var c=i*s,f=a.decode._getBPP(l),u=Math.ceil(i*f/8),d=new Uint8Array(c*4),h=new Uint32Array(d.buffer),m=l.ctype,R=l.depth,v=a._bin.readUshort;if(m==6){var g=c<<2;if(R==8)for(var x=0;x<g;x++)d[x]=o[x];if(R==16)for(var x=0;x<g;x++)d[x]=o[x<<1]}else if(m==2){var y=l.tabs.tRNS,E=-1,k=-1,b=-1;if(y&&(E=y[0],k=y[1],b=y[2]),R==8)for(var x=0;x<c;x++){var C=x<<2,_=x*3;d[C]=o[_],d[C+1]=o[_+1],d[C+2]=o[_+2],d[C+3]=255,E!=-1&&o[_]==E&&o[_+1]==k&&o[_+2]==b&&(d[C+3]=0)}if(R==16)for(var x=0;x<c;x++){var C=x<<2,_=x*6;d[C]=o[_],d[C+1]=o[_+2],d[C+2]=o[_+4],d[C+3]=255,E!=-1&&v(o,_)==E&&v(o,_+2)==k&&v(o,_+4)==b&&(d[C+3]=0)}}else if(m==3){var A=l.tabs.PLTE,N=l.tabs.tRNS,S=N?N.length:0;if(R==1)for(var I=0;I<s;I++)for(var O=I*u,F=I*i,x=0;x<i;x++){var C=F+x<<2,w=o[O+(x>>3)]>>7-((x&7)<<0)&1,L=3*w;d[C]=A[L],d[C+1]=A[L+1],d[C+2]=A[L+2],d[C+3]=w<S?N[w]:255}if(R==2)for(var I=0;I<s;I++)for(var O=I*u,F=I*i,x=0;x<i;x++){var C=F+x<<2,w=o[O+(x>>2)]>>6-((x&3)<<1)&3,L=3*w;d[C]=A[L],d[C+1]=A[L+1],d[C+2]=A[L+2],d[C+3]=w<S?N[w]:255}if(R==4)for(var I=0;I<s;I++)for(var O=I*u,F=I*i,x=0;x<i;x++){var C=F+x<<2,w=o[O+(x>>1)]>>4-((x&1)<<2)&15,L=3*w;d[C]=A[L],d[C+1]=A[L+1],d[C+2]=A[L+2],d[C+3]=w<S?N[w]:255}if(R==8)for(var x=0;x<c;x++){var C=x<<2,w=o[x],L=3*w;d[C]=A[L],d[C+1]=A[L+1],d[C+2]=A[L+2],d[C+3]=w<S?N[w]:255}}else if(m==4){if(R==8)for(var x=0;x<c;x++){var C=x<<2,B=x<<1,D=o[B];d[C]=D,d[C+1]=D,d[C+2]=D,d[C+3]=o[B+1]}if(R==16)for(var x=0;x<c;x++){var C=x<<2,B=x<<2,D=o[B];d[C]=D,d[C+1]=D,d[C+2]=D,d[C+3]=o[B+2]}}else if(m==0){var E=l.tabs.tRNS?l.tabs.tRNS:-1;if(R==1)for(var x=0;x<c;x++){var D=255*(o[x>>3]>>7-(x&7)&1),W=D==E*255?0:255;h[x]=W<<24|D<<16|D<<8|D}if(R==2)for(var x=0;x<c;x++){var D=85*(o[x>>2]>>6-((x&3)<<1)&3),W=D==E*85?0:255;h[x]=W<<24|D<<16|D<<8|D}if(R==4)for(var x=0;x<c;x++){var D=17*(o[x>>1]>>4-((x&1)<<2)&15),W=D==E*17?0:255;h[x]=W<<24|D<<16|D<<8|D}if(R==8)for(var x=0;x<c;x++){var D=o[x],W=D==E?0:255;h[x]=W<<24|D<<16|D<<8|D}if(R==16)for(var x=0;x<c;x++){var D=o[x<<1],W=v(o,x<<1)==E?0:255;h[x]=W<<24|D<<16|D<<8|D}}return d},a.decode=function(o){for(var i=new Uint8Array(o),s=8,l=a._bin,c=l.readUshort,f=l.readUint,u={tabs:{},frames:[]},d=new Uint8Array(i.length),h=0,m,R=0,v=[137,80,78,71,13,10,26,10],g=0;g<8;g++)if(i[g]!=v[g])throw"The input is not a PNG file!";for(;s<i.length;){var x=l.readUint(i,s);s+=4;var y=l.readASCII(i,s,4);if(s+=4,y=="IHDR")a.decode._IHDR(i,s,u);else if(y=="IDAT"){for(var g=0;g<x;g++)d[h+g]=i[s+g];h+=x}else if(y=="acTL")u.tabs[y]={num_frames:f(i,s),num_plays:f(i,s+4)},m=new Uint8Array(i.length);else if(y=="fcTL"){if(R!=0){var E=u.frames[u.frames.length-1];E.data=a.decode._decompress(u,m.slice(0,R),E.rect.width,E.rect.height),R=0}var k={x:f(i,s+12),y:f(i,s+16),width:f(i,s+4),height:f(i,s+8)},b=c(i,s+22);b=c(i,s+20)/(b==0?100:b);var C={rect:k,delay:Math.round(b*1e3),dispose:i[s+24],blend:i[s+25]};u.frames.push(C)}else if(y=="fdAT"){for(var g=0;g<x-4;g++)m[R+g]=i[s+g+4];R+=x-4}else if(y=="pHYs")u.tabs[y]=[l.readUint(i,s),l.readUint(i,s+4),i[s+8]];else if(y=="cHRM"){u.tabs[y]=[];for(var g=0;g<8;g++)u.tabs[y].push(l.readUint(i,s+g*4))}else if(y=="tEXt"){u.tabs[y]==null&&(u.tabs[y]={});var _=l.nextZero(i,s),A=l.readASCII(i,s,_-s),N=l.readASCII(i,_+1,s+x-_-1);u.tabs[y][A]=N}else if(y=="iTXt"){u.tabs[y]==null&&(u.tabs[y]={});var _=0,S=s;_=l.nextZero(i,S);var A=l.readASCII(i,S,_-S);S=_+1,i[S],i[S+1],S+=2,_=l.nextZero(i,S),l.readASCII(i,S,_-S),S=_+1,_=l.nextZero(i,S),l.readUTF8(i,S,_-S),S=_+1;var N=l.readUTF8(i,S,x-(S-s));u.tabs[y][A]=N}else if(y=="PLTE")u.tabs[y]=l.readBytes(i,s,x);else if(y=="hIST"){var I=u.tabs.PLTE.length/3;u.tabs[y]=[];for(var g=0;g<I;g++)u.tabs[y].push(c(i,s+g*2))}else if(y=="tRNS")u.ctype==3?u.tabs[y]=l.readBytes(i,s,x):u.ctype==0?u.tabs[y]=c(i,s):u.ctype==2&&(u.tabs[y]=[c(i,s),c(i,s+2),c(i,s+4)]);else if(y=="gAMA")u.tabs[y]=l.readUint(i,s)/1e5;else if(y=="sRGB")u.tabs[y]=i[s];else if(y=="bKGD")u.ctype==0||u.ctype==4?u.tabs[y]=[c(i,s)]:u.ctype==2||u.ctype==6?u.tabs[y]=[c(i,s),c(i,s+2),c(i,s+4)]:u.ctype==3&&(u.tabs[y]=i[s]);else if(y=="IEND"){if(R!=0){var E=u.frames[u.frames.length-1];E.data=a.decode._decompress(u,m.slice(0,R),E.rect.width,E.rect.height),R=0}u.data=a.decode._decompress(u,d,u.width,u.height);break}s+=x,l.readUint(i,s),s+=4}return delete u.compress,delete u.interlace,delete u.filter,u},a.decode._decompress=function(o,i,s,l){return o.compress==0&&(i=a.decode._inflate(i)),o.interlace==0?i=a.decode._filterZero(i,o,0,s,l):o.interlace==1&&(i=a.decode._readInterlace(i,o)),i},a.decode._inflate=function(o){return r.inflate(o)},a.decode._readInterlace=function(o,i){for(var s=i.width,l=i.height,c=a.decode._getBPP(i),f=c>>3,u=Math.ceil(s*c/8),d=new Uint8Array(l*u),h=0,m=[0,0,4,0,2,0,1],R=[0,4,0,2,0,1,0],v=[8,8,8,4,4,2,2],g=[8,8,4,4,2,2,1],x=0;x<7;){for(var y=v[x],E=g[x],k=0,b=0,C=m[x];C<l;)C+=y,b++;for(var _=R[x];_<s;)_+=E,k++;var A=Math.ceil(k*c/8);a.decode._filterZero(o,i,h,k,b);for(var N=0,S=m[x];S<l;){for(var I=R[x],O=h+N*A<<3;I<s;){if(c==1){var F=o[O>>3];F=F>>7-(O&7)&1,d[S*u+(I>>3)]|=F<<7-((I&3)<<0)}if(c==2){var F=o[O>>3];F=F>>6-(O&7)&3,d[S*u+(I>>2)]|=F<<6-((I&3)<<1)}if(c==4){var F=o[O>>3];F=F>>4-(O&7)&15,d[S*u+(I>>1)]|=F<<4-((I&1)<<2)}if(c>=8)for(var w=S*u+I*f,L=0;L<f;L++)d[w+L]=o[(O>>3)+L];O+=c,I+=E}N++,S+=y}k*b!=0&&(h+=b*(1+A)),x=x+1}return d},a.decode._getBPP=function(o){var i=[1,null,3,1,2,null,4][o.ctype];return i*o.depth},a.decode._filterZero=function(o,i,s,l,c){var f=a.decode._getBPP(i),u=Math.ceil(l*f/8),d=a.decode._paeth;f=Math.ceil(f/8);for(var h=0;h<c;h++){var m=s+h*u,R=m+h+1,v=o[R-1];if(v==0)for(var g=0;g<u;g++)o[m+g]=o[R+g];else if(v==1){for(var g=0;g<f;g++)o[m+g]=o[R+g];for(var g=f;g<u;g++)o[m+g]=o[R+g]+o[m+g-f]&255}else if(h==0){for(var g=0;g<f;g++)o[m+g]=o[R+g];if(v==2)for(var g=f;g<u;g++)o[m+g]=o[R+g]&255;if(v==3)for(var g=f;g<u;g++)o[m+g]=o[R+g]+(o[m+g-f]>>1)&255;if(v==4)for(var g=f;g<u;g++)o[m+g]=o[R+g]+d(o[m+g-f],0,0)&255}else{if(v==2)for(var g=0;g<u;g++)o[m+g]=o[R+g]+o[m+g-u]&255;if(v==3){for(var g=0;g<f;g++)o[m+g]=o[R+g]+(o[m+g-u]>>1)&255;for(var g=f;g<u;g++)o[m+g]=o[R+g]+(o[m+g-u]+o[m+g-f]>>1)&255}if(v==4){for(var g=0;g<f;g++)o[m+g]=o[R+g]+d(0,o[m+g-u],0)&255;for(var g=f;g<u;g++)o[m+g]=o[R+g]+d(o[m+g-f],o[m+g-u],o[m+g-f-u])&255}}}return o},a.decode._paeth=function(o,i,s){var l=o+i-s,c=Math.abs(l-o),f=Math.abs(l-i),u=Math.abs(l-s);return c<=f&&c<=u?o:f<=u?i:s},a.decode._IHDR=function(o,i,s){var l=a._bin;s.width=l.readUint(o,i),i+=4,s.height=l.readUint(o,i),i+=4,s.depth=o[i],i++,s.ctype=o[i],i++,s.compress=o[i],i++,s.filter=o[i],i++,s.interlace=o[i],i++},a._bin={nextZero:function(o,i){for(;o[i]!=0;)i++;return i},readUshort:function(o,i){return o[i]<<8|o[i+1]},writeUshort:function(o,i,s){o[i]=s>>8&255,o[i+1]=s&255},readUint:function(o,i){return o[i]*(256*256*256)+(o[i+1]<<16|o[i+2]<<8|o[i+3])},writeUint:function(o,i,s){o[i]=s>>24&255,o[i+1]=s>>16&255,o[i+2]=s>>8&255,o[i+3]=s&255},readASCII:function(o,i,s){for(var l="",c=0;c<s;c++)l+=String.fromCharCode(o[i+c]);return l},writeASCII:function(o,i,s){for(var l=0;l<s.length;l++)o[i+l]=s.charCodeAt(l)},readBytes:function(o,i,s){for(var l=[],c=0;c<s;c++)l.push(o[i+c]);return l},pad:function(o){return o.length<2?"0"+o:o},readUTF8:function(o,i,s){for(var l="",c,f=0;f<s;f++)l+="%"+a._bin.pad(o[i+f].toString(16));try{c=decodeURIComponent(l)}catch(u){return a._bin.readASCII(o,i,s)}return c}},a._copyTile=function(o,i,s,l,c,f,u,d,h){for(var m=Math.min(i,c),R=Math.min(s,f),v=0,g=0,x=0;x<R;x++)for(var y=0;y<m;y++)if(u>=0&&d>=0?(v=x*i+y<<2,g=(d+x)*c+u+y<<2):(v=(-d+x)*i-u+y<<2,g=x*c+y<<2),h==0)l[g]=o[v],l[g+1]=o[v+1],l[g+2]=o[v+2],l[g+3]=o[v+3];else if(h==1){var E=o[v+3]*.00392156862745098,k=o[v]*E,b=o[v+1]*E,C=o[v+2]*E,_=l[g+3]*(1/255),A=l[g]*_,N=l[g+1]*_,S=l[g+2]*_,I=1-E,O=E+_*I,F=O==0?0:1/O;l[g+3]=255*O,l[g+0]=(k+A*I)*F,l[g+1]=(b+N*I)*F,l[g+2]=(C+S*I)*F}else if(h==2){var E=o[v+3],k=o[v],b=o[v+1],C=o[v+2],_=l[g+3],A=l[g],N=l[g+1],S=l[g+2];E==_&&k==A&&b==N&&C==S?(l[g]=0,l[g+1]=0,l[g+2]=0,l[g+3]=0):(l[g]=k,l[g+1]=b,l[g+2]=C,l[g+3]=E)}else if(h==3){var E=o[v+3],k=o[v],b=o[v+1],C=o[v+2],_=l[g+3],A=l[g],N=l[g+1],S=l[g+2];if(E==_&&k==A&&b==N&&C==S)continue;if(E<220&&_>20)return!1}return!0},a.encode=function(o,i,s,l,c,f){l==null&&(l=0),f==null&&(f=!1);for(var u=new Uint8Array(o[0].byteLength*o.length+100),d=[137,80,78,71,13,10,26,10],h=0;h<8;h++)u[h]=d[h];var m=8,R=a._bin,v=a.crc.crc,g=R.writeUint,x=R.writeUshort,y=R.writeASCII,E=a.encode.compressPNG(o,i,s,l,f);g(u,m,13),m+=4,y(u,m,"IHDR"),m+=4,g(u,m,i),m+=4,g(u,m,s),m+=4,u[m]=E.depth,m++,u[m]=E.ctype,m++,u[m]=0,m++,u[m]=0,m++,u[m]=0,m++,g(u,m,v(u,m-17,17)),m+=4,g(u,m,1),m+=4,y(u,m,"sRGB"),m+=4,u[m]=1,m++,g(u,m,v(u,m-5,5)),m+=4;var k=o.length>1;if(k&&(g(u,m,8),m+=4,y(u,m,"acTL"),m+=4,g(u,m,o.length),m+=4,g(u,m,0),m+=4,g(u,m,v(u,m-12,12)),m+=4),E.ctype==3){var b=E.plte.length;g(u,m,b*3),m+=4,y(u,m,"PLTE"),m+=4;for(var h=0;h<b;h++){var C=h*3,_=E.plte[h],A=_&255,N=_>>8&255,S=_>>16&255;u[m+C+0]=A,u[m+C+1]=N,u[m+C+2]=S}if(m+=b*3,g(u,m,v(u,m-b*3-4,b*3+4)),m+=4,E.gotAlpha){g(u,m,b),m+=4,y(u,m,"tRNS"),m+=4;for(var h=0;h<b;h++)u[m+h]=E.plte[h]>>24&255;m+=b,g(u,m,v(u,m-b-4,b+4)),m+=4}}for(var I=0,O=0;O<E.frames.length;O++){var F=E.frames[O];k&&(g(u,m,26),m+=4,y(u,m,"fcTL"),m+=4,g(u,m,I++),m+=4,g(u,m,F.rect.width),m+=4,g(u,m,F.rect.height),m+=4,g(u,m,F.rect.x),m+=4,g(u,m,F.rect.y),m+=4,x(u,m,c[O]),m+=2,x(u,m,1e3),m+=2,u[m]=F.dispose,m++,u[m]=F.blend,m++,g(u,m,v(u,m-30,30)),m+=4);var w=F.cimg,b=w.length;g(u,m,b+(O==0?0:4)),m+=4;var L=m;y(u,m,O==0?"IDAT":"fdAT"),m+=4,O!=0&&(g(u,m,I++),m+=4);for(var h=0;h<b;h++)u[m+h]=w[h];m+=b,g(u,m,v(u,L,m-L)),m+=4}return g(u,m,0),m+=4,y(u,m,"IEND"),m+=4,g(u,m,v(u,m-4,4)),m+=4,u.buffer.slice(0,m)},a.encode.compressPNG=function(o,i,s,l,c){for(var f=a.encode.compress(o,i,s,l,!1,c),u=0;u<o.length;u++){var d=f.frames[u];d.rect.width;var h=d.rect.height,m=d.bpl,R=d.bpp,v=new Uint8Array(h*m+h);d.cimg=a.encode._filterZero(d.img,h,R,m,v)}return f},a.encode.compress=function(o,i,s,l,c,f){f==null&&(f=!1);for(var u=6,d=8,h=4,m=255,R=0;R<o.length;R++)for(var v=new Uint8Array(o[R]),g=v.length,x=0;x<g;x+=4)m&=v[x+3];var y=m!=255,E={},k=[];if(o.length!=0&&(E[0]=0,k.push(0),l!=0&&l--),l!=0){var b=a.quantize(o,l,c);o=b.bufs;for(var x=0;x<b.plte.length;x++){var C=b.plte[x].est.rgba;E[C]==null&&(E[C]=k.length,k.push(C))}}else for(var R=0;R<o.length;R++)for(var _=new Uint32Array(o[R]),g=_.length,x=0;x<g;x++){var C=_[x];if((x<i||C!=_[x-1]&&C!=_[x-i])&&E[C]==null&&(E[C]=k.length,k.push(C),k.length>=300))break}var A=y?c:!1,N=k.length;N<=256&&f==!1&&(N<=2?d=1:N<=4?d=2:N<=16?d=4:d=8,c&&(d=8),y=!0);for(var S=[],R=0;R<o.length;R++){var I=new Uint8Array(o[R]),O=new Uint32Array(I.buffer),F=0,w=0,L=i,B=s,D=0;if(R!=0&&!A){for(var W=c||R==1||S[S.length-2].dispose==2?1:2,ae=0,ee=1e9,H=0;H<W;H++){for(var fe=new Uint8Array(o[R-1-H]),oe=new Uint32Array(o[R-1-H]),te=i,K=s,Z=-1,ce=-1,Q=0;Q<s;Q++)for(var G=0;G<i;G++){var x=Q*i+G;O[x]!=oe[x]&&(G<te&&(te=G),G>Z&&(Z=G),Q<K&&(K=Q),Q>ce&&(ce=Q))}var ge=Z==-1?1:(Z-te+1)*(ce-K+1);ge<ee&&(ee=ge,ae=H,Z==-1?(F=w=0,L=B=1):(F=te,w=K,L=Z-te+1,B=ce-K+1))}var fe=new Uint8Array(o[R-1-ae]);ae==1&&(S[S.length-1].dispose=2);var V=new Uint8Array(L*B*4);new Uint32Array(V.buffer),a._copyTile(fe,i,s,V,L,B,-F,-w,0),a._copyTile(I,i,s,V,L,B,-F,-w,3)?(a._copyTile(I,i,s,V,L,B,-F,-w,2),D=1):(a._copyTile(I,i,s,V,L,B,-F,-w,0),D=0),I=V,O=new Uint32Array(I.buffer)}var J=4*L;if(N<=256&&f==!1){J=Math.ceil(d*L/8);for(var V=new Uint8Array(J*B),Q=0;Q<B;Q++){var x=Q*J,Re=Q*L;if(d==8)for(var G=0;G<L;G++)V[x+G]=E[O[Re+G]];else if(d==4)for(var G=0;G<L;G++)V[x+(G>>1)]|=E[O[Re+G]]<<4-(G&1)*4;else if(d==2)for(var G=0;G<L;G++)V[x+(G>>2)]|=E[O[Re+G]]<<6-(G&3)*2;else if(d==1)for(var G=0;G<L;G++)V[x+(G>>3)]|=E[O[Re+G]]<<7-(G&7)*1}I=V,u=3,h=1}else if(y==!1&&o.length==1){for(var V=new Uint8Array(L*B*3),Ce=L*B,x=0;x<Ce;x++){var Y=x*3,ue=x*4;V[Y]=I[ue],V[Y+1]=I[ue+1],V[Y+2]=I[ue+2]}I=V,u=2,h=3,J=3*L}S.push({rect:{x:F,y:w,width:L,height:B},img:I,bpl:J,bpp:h,blend:D,dispose:A?1:0})}return{ctype:u,depth:d,plte:k,gotAlpha:y,frames:S}},a.encode._filterZero=function(o,i,s,l,c){for(var f=[],u=0;u<5;u++)if(!(i*l>5e5&&(u==2||u==3||u==4))){for(var d=0;d<i;d++)a.encode._filterLine(c,o,d,l,s,u);if(f.push(r.deflate(c)),s==1)break}for(var h,m=1e9,R=0;R<f.length;R++)f[R].length<m&&(h=R,m=f[R].length);return f[h]},a.encode._filterLine=function(o,i,s,l,c,f){var u=s*l,d=u+s,h=a.decode._paeth;if(o[d]=f,d++,f==0)for(var m=0;m<l;m++)o[d+m]=i[u+m];else if(f==1){for(var m=0;m<c;m++)o[d+m]=i[u+m];for(var m=c;m<l;m++)o[d+m]=i[u+m]-i[u+m-c]+256&255}else if(s==0){for(var m=0;m<c;m++)o[d+m]=i[u+m];if(f==2)for(var m=c;m<l;m++)o[d+m]=i[u+m];if(f==3)for(var m=c;m<l;m++)o[d+m]=i[u+m]-(i[u+m-c]>>1)+256&255;if(f==4)for(var m=c;m<l;m++)o[d+m]=i[u+m]-h(i[u+m-c],0,0)+256&255}else{if(f==2)for(var m=0;m<l;m++)o[d+m]=i[u+m]+256-i[u+m-l]&255;if(f==3){for(var m=0;m<c;m++)o[d+m]=i[u+m]+256-(i[u+m-l]>>1)&255;for(var m=c;m<l;m++)o[d+m]=i[u+m]+256-(i[u+m-l]+i[u+m-c]>>1)&255}if(f==4){for(var m=0;m<c;m++)o[d+m]=i[u+m]+256-h(0,i[u+m-l],0)&255;for(var m=c;m<l;m++)o[d+m]=i[u+m]+256-h(i[u+m-c],i[u+m-l],i[u+m-c-l])&255}}},a.crc={table:function(){for(var o=new Uint32Array(256),i=0;i<256;i++){for(var s=i,l=0;l<8;l++)s&1?s=3988292384^s>>>1:s=s>>>1;o[i]=s}return o}(),update:function(o,i,s,l){for(var c=0;c<l;c++)o=a.crc.table[(o^i[s+c])&255]^o>>>8;return o},crc:function(o,i,s){return a.crc.update(4294967295,o,i,s)^4294967295}},a.quantize=function(o,i,s){for(var l=[],c=0,f=0;f<o.length;f++)l.push(a.encode.alphaMul(new Uint8Array(o[f]),s)),c+=o[f].byteLength;for(var u=new Uint8Array(c),d=new Uint32Array(u.buffer),h=0,f=0;f<l.length;f++){for(var m=l[f],R=m.length,v=0;v<R;v++)u[h+v]=m[v];h+=R}var g={i0:0,i1:u.length,bst:null,est:null,tdst:0,left:null,right:null};g.bst=a.quantize.stats(u,g.i0,g.i1),g.est=a.quantize.estats(g.bst);for(var x=[g];x.length<i;){for(var y=0,E=0,f=0;f<x.length;f++)x[f].est.L>y&&(y=x[f].est.L,E=f);if(y<.001)break;var k=x[E],b=a.quantize.splitPixels(u,d,k.i0,k.i1,k.est.e,k.est.eMq255),C={i0:k.i0,i1:b,bst:null,est:null,tdst:0,left:null,right:null};C.bst=a.quantize.stats(u,C.i0,C.i1),C.est=a.quantize.estats(C.bst);var _={i0:b,i1:k.i1,bst:null,est:null,tdst:0,left:null,right:null};_.bst={R:[],m:[],N:k.bst.N-C.bst.N};for(var f=0;f<16;f++)_.bst.R[f]=k.bst.R[f]-C.bst.R[f];for(var f=0;f<4;f++)_.bst.m[f]=k.bst.m[f]-C.bst.m[f];_.est=a.quantize.estats(_.bst),k.left=C,k.right=_,x[E]=C,x.push(_)}x.sort(function(W,ae){return ae.bst.N-W.bst.N});for(var A=0;A<l.length;A++){for(var N=a.quantize.planeDst,S=new Uint8Array(l[A].buffer),I=new Uint32Array(l[A].buffer),O=S.length,f=0;f<O;f+=4){for(var F=S[f]*.00392156862745098,w=S[f+1]*(1/255),L=S[f+2]*(1/255),B=S[f+3]*(1/255),D=g;D.left;)D=N(D.est,F,w,L,B)<=0?D.left:D.right;I[f>>2]=D.est.rgba}l[A]=I.buffer}return{bufs:l,plte:x}},a.quantize.getNearest=function(o,i,s,l,c){if(o.left==null)return o.tdst=a.quantize.dist(o.est.q,i,s,l,c),o;var f=a.quantize.planeDst(o.est,i,s,l,c),u=o.left,d=o.right;f>0&&(u=o.right,d=o.left);var h=a.quantize.getNearest(u,i,s,l,c);if(h.tdst<=f*f)return h;var m=a.quantize.getNearest(d,i,s,l,c);return m.tdst<h.tdst?m:h},a.quantize.planeDst=function(o,i,s,l,c){var f=o.e;return f[0]*i+f[1]*s+f[2]*l+f[3]*c-o.eMq},a.quantize.dist=function(o,i,s,l,c){var f=i-o[0],u=s-o[1],d=l-o[2],h=c-o[3];return f*f+u*u+d*d+h*h},a.quantize.splitPixels=function(o,i,s,l,c,f){var u=a.quantize.vecDot;for(l-=4;s<l;){for(;u(o,s,c)<=f;)s+=4;for(;u(o,l,c)>f;)l-=4;if(s>=l)break;var d=i[s>>2];i[s>>2]=i[l>>2],i[l>>2]=d,s+=4,l-=4}for(;u(o,s,c)>f;)s-=4;return s+4},a.quantize.vecDot=function(o,i,s){return o[i]*s[0]+o[i+1]*s[1]+o[i+2]*s[2]+o[i+3]*s[3]},a.quantize.stats=function(o,i,s){for(var l=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=[0,0,0,0],f=s-i>>2,u=i;u<s;u+=4){var d=o[u]*.00392156862745098,h=o[u+1]*(1/255),m=o[u+2]*(1/255),R=o[u+3]*(1/255);c[0]+=d,c[1]+=h,c[2]+=m,c[3]+=R,l[0]+=d*d,l[1]+=d*h,l[2]+=d*m,l[3]+=d*R,l[5]+=h*h,l[6]+=h*m,l[7]+=h*R,l[10]+=m*m,l[11]+=m*R,l[15]+=R*R}return l[4]=l[1],l[8]=l[2],l[12]=l[3],l[9]=l[6],l[13]=l[7],l[14]=l[11],{R:l,m:c,N:f}},a.quantize.estats=function(o){var i=o.R,s=o.m,l=o.N,c=s[0],f=s[1],u=s[2],d=s[3],h=l==0?0:1/l,m=[i[0]-c*c*h,i[1]-c*f*h,i[2]-c*u*h,i[3]-c*d*h,i[4]-f*c*h,i[5]-f*f*h,i[6]-f*u*h,i[7]-f*d*h,i[8]-u*c*h,i[9]-u*f*h,i[10]-u*u*h,i[11]-u*d*h,i[12]-d*c*h,i[13]-d*f*h,i[14]-d*u*h,i[15]-d*d*h],R=m,v=a.M4,g=[.5,.5,.5,.5],x=0,y=0;if(l!=0)for(var E=0;E<10&&(g=v.multVec(R,g),y=Math.sqrt(v.dot(g,g)),g=v.sml(1/y,g),!(Math.abs(y-x)<1e-9));E++)x=y;var k=[c*h,f*h,u*h,d*h],b=v.dot(v.sml(255,k),g),C=k[3]<.001?0:1/k[3];return{Cov:m,q:k,e:g,L:x,eMq255:b,eMq:v.dot(g,k),rgba:(Math.round(255*k[3])<<24|Math.round(255*k[2]*C)<<16|Math.round(255*k[1]*C)<<8|Math.round(255*k[0]*C)<<0)>>>0}},a.M4={multVec:function(o,i){return[o[0]*i[0]+o[1]*i[1]+o[2]*i[2]+o[3]*i[3],o[4]*i[0]+o[5]*i[1]+o[6]*i[2]+o[7]*i[3],o[8]*i[0]+o[9]*i[1]+o[10]*i[2]+o[11]*i[3],o[12]*i[0]+o[13]*i[1]+o[14]*i[2]+o[15]*i[3]]},dot:function(o,i){return o[0]*i[0]+o[1]*i[1]+o[2]*i[2]+o[3]*i[3]},sml:function(o,i){return[o*i[0],o*i[1],o*i[2],o*i[3]]}},a.encode.alphaMul=function(o,i){for(var s=new Uint8Array(o.length),l=o.length>>2,c=0;c<l;c++){var f=c<<2,u=o[f+3];i&&(u=u<128?0:255);var d=u*(1/255);s[f+0]=o[f+0]*d,s[f+1]=o[f+1]*d,s[f+2]=o[f+2]*d,s[f+3]=u}return s}}(t,n)})()})(UPNG$1);var UPNGExports=UPNG$1.exports;const UPNG=getDefaultExportFromCjs(UPNGExports),batchUpdate=reactDom.unstable_batchedUpdates,Common={batchUpdate},calcGUIScale=e=>new EngineCore.Vector3(1/(e&&e.scalePlane?e.scalePlane:1)*Math.min(e&&e.scalePlane?e.scalePlane:1,e&&e.scaleDepth?e.scaleDepth:1),1/(e&&e.scaleDepth?e.scaleDepth:1)*Math.min(e&&e.scalePlane?e.scalePlane:1,e&&e.scaleDepth?e.scaleDepth:1),1/(e&&e.scalePlane?e.scalePlane:1)*Math.min(e&&e.scalePlane?e.scalePlane:1,e&&e.scaleDepth?e.scaleDepth:1)),calcTransformNodeScale=e=>new EngineCore.Vector3(e?e.scalePlane:1,e?e.scaleDepth:1,e?e.scalePlane:1),calcInvTransformNodeScale=e=>e?new EngineCore.Vector3(1/(e.scalePlane?e.scalePlane:1),1/(e.scaleDepth?e.scaleDepth:1),1/(e.scalePlane?e.scalePlane:1)):EngineCore.Vector3.One(),calcCompass=e=>{if(e instanceof EngineCore.ArcRotateCamera){const t=e.alpha;return(t>0?t:Math.PI-t)/Math.PI*180%360}return 0},convertPositionArrayToVector3=e=>{const t=[];return e.forEach(n=>{t.push(convertPositionToVector3(n))}),t},convertPositionToVector3=e=>new EngineCore.Vector3(e.x,e.y,e.z),convertVertexToVector3=e=>new EngineCore.Vector3(e.x,e.y,e.z),convertColorToColor3=e=>new EngineCore.Color3(e.r,e.g,e.b);var HoverType=(e=>(e[e.START=0]="START",e[e.CONTINUE=1]="CONTINUE",e[e.END=2]="END",e))(HoverType||{}),MaterialType=(e=>(e[e.ONE_COLOR=0]="ONE_COLOR",e[e.COLOR_CODEC=1]="COLOR_CODEC",e[e.TEXTURE=2]="TEXTURE",e[e.COLOR_ID=3]="COLOR_ID",e))(MaterialType||{}),MaterialSideOrientation=(e=>(e[e.ClockWiseSideOrientation=EngineCore.Material.ClockWiseSideOrientation]="ClockWiseSideOrientation",e[e.CounterClockWiseSideOrientation=EngineCore.Material.CounterClockWiseSideOrientation]="CounterClockWiseSideOrientation",e))(MaterialSideOrientation||{}),ScaleMode=(e=>(e[e.PLANE=0]="PLANE",e[e.DEPTH=1]="DEPTH",e[e.NONE=2]="NONE",e))(ScaleMode||{});const WorkspaceMetaContext=React.createContext(void 0),ViewerCameraPropsContext=React.createContext({viewCamera:void 0,setViewCamera:()=>{},cameraRefObject:void 0}),ColorProviderContext=React.createContext({colorIDs:{},colorCodecs:{}}),ColorCodecImageContext=React.createContext(null);var LoadingScreen=(e=>(e[e.ENGINE_DEFAULT=0]="ENGINE_DEFAULT",e[e.NONE=1]="NONE",e))(LoadingScreen||{});const FetchAndCacheContext=React.createContext({onPreFetch:e=>new Promise(t=>{t(e)}),onFinish:()=>{console.log("Loaded")},onProgress:(e,t)=>{console.log(`Loading ${e}/${t}`)},useLoadingScreen:1,hideLoadingWhenPostCalculate:!0}),GPUPickingContext=React.createContext(null),Geo3DProvider=(e,t)=>{var fe,V,J,Re,Ce;const{children:n,workspaceMeta:a={max:new EngineCore.Vector3(Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER),min:new EngineCore.Vector3(Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER),scaleDepth:1,scalePlane:1,origin:EngineCore.Vector3.Zero(),_isDefault:!0},colorProvider:r={colorIDs:{},colorCodecs:{}},cacheProvider:o={onPreFetch:Y=>new Promise(ue=>{ue(Y)}),onFinish:()=>{console.log("Loaded")},onProgress:(Y,ue)=>{console.log(`Loading ${Y} of ${ue}`)},useLoadingScreen:1}}=e,i=reactBabylonjs.useScene(),s=reactBabylonjs.useCanvas(),[l,c]=React.useState(void 0),f=React.useRef({}),[u,d]=React.useState({}),h=React.useRef(0),m=React.useRef(0),R=React.useRef(new Set),v=React.useRef(new Map),g=React.useRef({lastReportedLoaded:-1,lastReportedTotal:-1}),[,x]=React.useState(0),y=React.useRef(null),E=React.useRef(null),k=React.useRef(!1),b=React.useRef(null),C=React.useRef([]),_=React.useRef(null),A=React.useRef(0),N=React.useRef(new WeakMap),S=React.useRef(1),I=React.useRef(new Map),O=React.useRef(0),F=React.useRef({isDown:!1,pointerId:-1,startX:0,startY:0,isDragging:!1});React.useEffect(()=>{if(r.colorCodecs){console.log("[Geo3DViewer] 开始色标刷新");const Y={};if(Object.keys(r.colorCodecs).forEach(ne=>{console.log(`[Geo3DViewer] 正在生成色标 ${ne}`);const de=r.colorCodecs[ne],_e=new Uint8Array(de.array.length*4);de.array.forEach((Ee,Se)=>{_e[Se*4+0]=Math.trunc(Ee.r*255),_e[Se*4+1]=Math.trunc(Ee.g*255),_e[Se*4+2]=Math.trunc(Ee.b*255),_e[Se*4+3]=255}),console.log(`[Geo3DViewer] 正在创建色标采样贴图 ${ne}`);const ye=EngineCore.RawTexture.CreateRGBATexture(_e,1,de.array.length,i,!0,!1);ye.name=`color-codec-${ne}`,console.log(`[Geo3DViewer] 正在创建色标图例 ${ne}`);const Te=URL.createObjectURL(new Blob([UPNG.encode([_e.buffer],1,de.array.length,0)]));console.log(`[Geo3DViewer] 正在构建色标 ${ne}`),Y[ne]={blobUrl:Te,min:de.min,max:de.max,texture:ye}}),i){console.log(`[Geo3DViewer] 正在移除原有色标 共 ${Object.keys(f.current).length} 个`),Object.keys(f.current).forEach(de=>{console.log(`[Geo3DViewer] 正在移除色标 ${de}`),i.removeTexture(f.current[de].texture),f.current[de].texture.dispose(),URL.revokeObjectURL(f.current[de].blobUrl)}),f.current=Y;const ne=i.getMaterialByTags("remap");console.log("[Geo3DViewer] 已完成色标刷新,正在更新关联的材质"),ne.forEach(de=>{de instanceof EngineCore.ShaderMaterial?de.setTexture("textureSampler",Y[de.metadata.colorCodec].texture):(de.getBlockByName("RemappedTexture").texture=Y[de.metadata.colorCodec].texture,de.markAsDirty(EngineCore.NodeMaterial.TextureDirtyFlag))}),console.log(`[Geo3DViewer] 已有 ${ne.length} 个材质执行了更新`)}}},[r.colorCodecs,i]);const w=React.useCallback(Y=>!Y||Y.isDisposed()||!Y.metadata||!("pickable"in Y.metadata)||!Y.metadata.pickable?null:Y.metadata.pickable,[]),L=React.useCallback(Y=>!!(Y&&(Y.onHover||Y.onLeftClick||Y.onMiddleClick||Y.onRightClick)),[]),B=React.useCallback(Y=>{if(s){if(Y&&(Y.onLeftClick||Y.onMiddleClick||Y.onRightClick)){s.style.setProperty("cursor","pointer");return}s.style.setProperty("cursor","default")}},[s]),D=React.useCallback(()=>{var ue;const Y=(ue=E.current)==null?void 0:ue._pickingTexture;y.current!==(Y!=null?Y:null)&&(y.current=Y!=null?Y:null,x(ne=>ne+1))},[]),W=React.useCallback(Y=>{const ue=N.current.get(Y);if(ue)return ue;const ne=S.current++;return N.current.set(Y,ne),ne},[]),ae=React.useCallback(()=>{const Y=[],ue=new Set;if(!i)return Y;i.meshes.forEach(de=>{if(!de||de.isDisposed())return;const _e=w(de);if(!(!(L(_e)&&de.isEnabled()&&de.isVisible&&de.isReady(!0)&&de.isPickable)||ue.has(de))&&(ue.add(de),Y.push(de),de.isAnInstance)){const Te=de.sourceMesh;Te&&!Te.isDisposed()&&Te.isEnabled()&&Te.isVisible&&Te.isReady(!0)&&!ue.has(Te)&&(ue.add(Te),Y.push(Te))}});const ne=C.current.length===Y.length&&C.current.every((de,_e)=>de===Y[_e]);return E.current||(E.current=new gpuPicker.GPUPicker),ne||(E.current.setPickingList(Y.length>0?Y.slice():null),C.current=Y,D()),Y},[w,L,i,D]),ee=React.useCallback(async(Y,ue)=>{if(!i)return null;if(!ae().length||!E.current)return D(),null;D();const de=await E.current.pickAsync(Y,ue,!1);return D(),de},[i,ae,D]);React.useEffect(()=>{if(!i)return;const Y=i.onBeforeRenderObservable.add(()=>{ae()});return()=>{i.onBeforeRenderObservable.remove(Y)}},[i,ae]);const H=React.useCallback((Y,ue,ne)=>i?i.pick(ue,ne,de=>de===Y,!1,void 0):null,[i]),oe=React.useCallback(()=>{A.current+=1,I.current.clear()},[]),te=React.useCallback(Y=>new Proxy({},{get:(ue,ne)=>{const de=Y();if(!de)return;const _e=de[ne];return typeof _e=="function"?_e.bind(de):_e},set:(ue,ne,de)=>{const _e=Y();return _e?(_e[ne]=de,!0):!1},has:(ue,ne)=>{const de=Y();return de?ne in de:!1},ownKeys:()=>{const ue=Y();return ue?Reflect.ownKeys(ue):[]},getOwnPropertyDescriptor:(ue,ne)=>{const de=Y();if(de)return Object.getOwnPropertyDescriptor(de,ne)}}),[]),K=React.useCallback((Y,ue,ne)=>{const de=A.current,_e=W(Y),ye=`${de}:${_e}:${Math.round(ue)}:${Math.round(ne)}`,Te=()=>{var Pe,Oe,Fe;const Ee=I.current.get(ye);if(Ee)return Ee;const Se=H(Y,ue,ne),be=(Pe=Se==null?void 0:Se.pickedPoint)!=null?Pe:null,Ae=(Fe=be==null?void 0:be.add((Oe=a.origin)!=null?Oe:EngineCore.Vector3.Zero()))!=null?Fe:null,Ie={raw:be,world:Ae};return I.current.set(ye,Ie),Ie};return{rawWorldPosition:te(()=>Te().raw),worldPosition:te(()=>Te().world)}},[te,W,H,a.origin]),Z=React.useCallback((Y,ue,ne,de,_e)=>{var be,Ae;const ye=w(Y);if(!ye||!ye.onHover)return;const Te=new EngineCore.Vector2(ne.clientX,ne.clientY),Ee=ue!==HoverType.END&&ye.needWorldPosition?K(Y,de,_e):null,Se=ye.valueCallback?ye.valueCallback(Te,(be=Ee==null?void 0:Ee.worldPosition)!=null?be:null,(Ae=Ee==null?void 0:Ee.rawWorldPosition)!=null?Ae:null):null;ye.onHover(ye.name,Te,Ee==null?void 0:Ee.worldPosition,ue,Se,ye.extra)},[K,w]),ce=React.useCallback((Y,ue)=>{const ne=Y&&w(Y)&&L(w(Y))?Y:null,de=b.current;de&&de!==ne&&Z(de,HoverType.END,ue.event,ue.x,ue.y),ne&&Z(ne,de===ne?HoverType.CONTINUE:HoverType.START,ue.event,ue.x,ue.y),b.current=ne,B(ne?w(ne):null)},[w,L,Z,B]),Q=React.useCallback(async()=>{var Y;if(!k.current){for(k.current=!0;_.current;){const ue=_.current;if(_.current=null,!i||i.skipPointerMovePicking){ce(null,ue);continue}const ne=await ee(ue.x,ue.y),de=(Y=ne==null?void 0:ne.mesh)!=null?Y:null;if(oe(),i.skipPointerMovePicking){ce(null,ue);continue}ce(de,ue)}k.current=!1}},[oe,ee,i,ce]),G=React.useCallback(async(Y,ue,ne)=>{var be;if(!i)return;for(;k.current;)await new Promise(Ae=>setTimeout(Ae,8));if(Date.now()-O.current<100){O.current=Date.now();return}O.current=Date.now();const de=await ee(ue,ne);oe();const _e=(be=de==null?void 0:de.mesh)!=null?be:null,ye=w(_e);if(console.log(`[Geo3DViewer] 指针拾取 ${!!_e} 于面 ${_e}`,ye,de),!_e||!ye)return;const Te=new EngineCore.Vector2(Y.clientX,Y.clientY),Ee=K(_e,ue,ne),Se=ye.valueCallback?ye.valueCallback(Te,Ee.worldPosition,Ee.rawWorldPosition):null;if(Y.button===0&&ye.onLeftClick){ye.onLeftClick(ye.name,Te,Ee.worldPosition,Se,ye.extra);return}if(Y.button===1&&ye.onMiddleClick){ye.onMiddleClick(ye.name,Te,Ee.worldPosition,Se,ye.extra);return}Y.button===2&&ye.onRightClick&&ye.onRightClick(ye.name,Te,Ee.worldPosition,Se,ye.extra)},[oe,K,w,ee,i]);React.useEffect(()=>{if(i)return i.skipPointerDownPicking=!0,i.skipPointerUpPicking=!0,()=>{i.skipPointerDownPicking=!1,i.skipPointerUpPicking=!1}},[i]),React.useEffect(()=>{if(!i)return;const Y=4,ue=i.onPointerObservable.add(ne=>{const de=ne.event;if(ne.type===EngineCore.PointerEventTypes.POINTERDOWN){F.current.isDown=!0,F.current.pointerId=de.pointerId,F.current.startX=i.pointerX,F.current.startY=i.pointerY,F.current.isDragging=!1;return}if(ne.type===EngineCore.PointerEventTypes.POINTERMOVE){if(F.current.isDown&&F.current.pointerId===de.pointerId&&!F.current.isDragging){const _e=i.pointerX-F.current.startX,ye=i.pointerY-F.current.startY;_e*_e+ye*ye>=Y*Y&&(F.current.isDragging=!0)}if(i.skipPointerMovePicking||F.current.isDragging){b.current&&ce(null,{event:de,x:i.pointerX,y:i.pointerY});return}_.current={event:de,x:i.pointerX,y:i.pointerY},Q();return}if(ne.type===EngineCore.PointerEventTypes.POINTERUP){const _e=F.current.isDragging;if(F.current.isDown=!1,F.current.pointerId=-1,F.current.isDragging=!1,i.skipPointerMovePicking||_e)return;G(de,i.pointerX,i.pointerY)}});return()=>{i.onPointerObservable.remove(ue),_.current=null,b.current=null,F.current.isDown=!1,F.current.pointerId=-1,F.current.isDragging=!1,B(null)}},[G,Q,i,B,ce]),React.useEffect(()=>()=>{var Y;_.current=null,C.current=[],b.current=null,I.current.clear(),(Y=E.current)==null||Y.dispose(),E.current=null,y.current=null},[]);const ge=React.useRef(void 0);return React.useImperativeHandle(t,()=>i,[i]),jsxRuntime.jsx(WorkspaceMetaContext.Provider,{value:{min:(fe=a.min)!=null?fe:new EngineCore.Vector3(Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER),max:(V=a.max)!=null?V:new EngineCore.Vector3(Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER),scaleDepth:(J=a.scaleDepth)!=null?J:1,scalePlane:(Re=a.scalePlane)!=null?Re:1,_isDefault:(Ce=a._isDefault)!=null?Ce:!0,origin:EngineCore.Vector3.Zero()},children:jsxRuntime.jsx(ViewerCameraPropsContext.Provider,{value:{viewCamera:l,setViewCamera:c,cameraRefObject:ge},children:jsxRuntime.jsx(FetchAndCacheContext.Provider,{value:o,children:jsxRuntime.jsxs(CacheProviderContext.Provider,{value:{cache:u,setCache:d,loadedCount:m,totalCount:h,pending:R,inflight:v,reported:g},children:[jsxRuntime.jsx(CacheCallback$1,{}),jsxRuntime.jsx(ColorCodecImageContext.Provider,{value:{colorCodecsImage:f},children:jsxRuntime.jsx(ColorProviderContext.Provider,{value:r,children:jsxRuntime.jsx(GPUPickingContext.Provider,{value:{gpuPickingTexture:y},children:n})})})]})})})})},Geo3DProvider$1=React.forwardRef(Geo3DProvider),jsonDecoder=new TextDecoder;var CacheType=(e=>(e[e.URL_PREFIX_MATCH=0]="URL_PREFIX_MATCH",e[e.EXACTLY_MATCH=1]="EXACTLY_MATCH",e))(CacheType||{}),AssetType=(e=>(e[e.BINARY=0]="BINARY",e[e.TEXTURE=1]="TEXTURE",e[e.MODEL=2]="MODEL",e[e.JSON=3]="JSON",e))(AssetType||{});const useCacheProvider=({url:e,cacheType:t=0,assetType:n=0})=>{var k,b,C,_,A,N;const a=reactBabylonjs.useScene(),{onPreFetch:r}=React.useContext(FetchAndCacheContext),o=React.useContext(CacheProviderContext),i=React.useRef(0),s=React.useRef(0),l=React.useRef(new Set),c=React.useRef(new Map),[f,u]=React.useState(void 0),d=(k=o==null?void 0:o.cache)!=null?k:{},h=(b=o==null?void 0:o.setCache)!=null?b:()=>{},m=(C=o==null?void 0:o.loadedCount)!=null?C:s,R=(_=o==null?void 0:o.totalCount)!=null?_:i,v=(A=o==null?void 0:o.pending)!=null?A:l,g=(N=o==null?void 0:o.inflight)!=null?N:c,x=React.useCallback(async S=>{let I=1,O;for(;I>=0;)try{return(await axios.get(S,{responseType:"arraybuffer",timeout:2e4})).data}catch(F){O=F,I-=1,I>=0&&await new Promise(w=>setTimeout(w,300))}throw O},[]),y=React.useCallback((S,I)=>{if(S){if(I===1)return d[S];if(I===0){const O=S.split("?")[0];return d[O]}}},[d]),E=React.useCallback(async(S,I,O)=>{const F=g.current.get(S);if(F){const L=await F;L&&u(L);return}const w=(async()=>{v.current.add(S),R.current=R.current+1;try{const L=await r(S),B=[];L!==S&&B.push(S),I===0?(B.push(L.split("?")[0]),B.push(L)):I===1&&B.push(L);const D=await x(L),W={};let ae;if(O===0)ae={buffer:D};else if(O===1){const ee=URL.createObjectURL(new Blob([D])),H=new EngineCore.Texture(ee,a,!0,!1,void 0,()=>{URL.revokeObjectURL(ee)},()=>{URL.revokeObjectURL(ee)});ae={buffer:D,texture:H}}else if(O===2){if(!a)throw new Error("Scene not ready for model loading");const ee=URL.createObjectURL(new Blob([D]));try{let H=L.split("?")[0];H=(H==null?void 0:H.split(".").pop())||"";const oe=await EngineCore.LoadAssetContainerAsync(ee,a,{pluginExtension:`.${H}`});ae={buffer:D,assets:oe}}finally{URL.revokeObjectURL(ee)}}else ae={buffer:D,json:JSON.parse(jsonDecoder.decode(D))};return B.forEach(ee=>{W[ee]=ae}),h(ee=>{let H=!1;const oe={...ee};return B.forEach(te=>{oe[te]||(oe[te]=ae,H=!0)}),H?oe:ee}),m.current=m.current+1,u(ae),ae}catch(L){console.error(L),m.current=m.current+1;return}finally{v.current.delete(S),g.current.delete(S)}})();g.current.set(S,w),await w},[x,r,g,m,v,h,R,a]);return React.useEffect(()=>{if(e){const S=y(e,t);if(S){u(S);return}v.current.has(e)||E(e,t,n)}},[n,t,E,y,v,e]),f},useCachedBinary=({url:e,cacheType:t=0})=>{const n=useCacheProvider({url:e,cacheType:t,assetType:0}),[a,r]=React.useState(void 0);return React.useEffect(()=>{r(o=>(n==null?void 0:n.buffer)!==o?n==null?void 0:n.buffer:o)},[n]),a},useCachedTexture=({url:e,cacheType:t=0})=>{const n=useCacheProvider({url:e,cacheType:t,assetType:1}),[a,r]=React.useState(void 0);return React.useEffect(()=>{r(o=>{if((n==null?void 0:n.texture)!==o){const i=n==null?void 0:n.texture;if(i)return i.hasAlpha=!0,i}return o})},[n]),a},useCachedModel=({url:e,cacheType:t=0})=>{const n=useCacheProvider({url:e,cacheType:t,assetType:2}),[a,r]=React.useState(void 0);return React.useEffect(()=>{r(o=>(n==null?void 0:n.assets)!==o?n==null?void 0:n.assets:o)},[n]),a},useCachedJSON=({url:e,cacheType:t=0})=>{const n=useCacheProvider({url:e,cacheType:t,assetType:3}),[a,r]=React.useState(void 0);return React.useEffect(()=>{r(o=>(n==null?void 0:n.json)!==o?n==null?void 0:n.json:o)},[n]),a},CacheProviderContext=React.createContext(void 0),CacheCallback=()=>{var y,E,k,b;const e=reactBabylonjs.useScene(),t=reactBabylonjs.useEngine(),{onFinish:n,onProgress:a,useLoadingScreen:r,hideLoadingWhenPostCalculate:o}=React.useContext(FetchAndCacheContext),i=React.useContext(CacheProviderContext),s=React.useRef(0),l=React.useRef(0),c=React.useRef({lastReportedLoaded:-1,lastReportedTotal:-1}),f=React.useRef([]),u=(y=i==null?void 0:i.totalCount)!=null?y:s,d=(E=i==null?void 0:i.loadedCount)!=null?E:l,h=(k=i==null?void 0:i.reported)!=null?k:c,m=(b=i==null?void 0:i.pending)!=null?b:f,R=React.useRef(null),v=Array.isArray(m.current)?m.current.length:m.current.size,g=React.useCallback(C=>{r===LoadingScreen.ENGINE_DEFAULT&&t&&(C?(R.current&&(clearTimeout(R.current),R.current=null),console.log("[Geo3DViewer] 显示加载界面"),t.displayLoadingUI()):R.current=setTimeout(()=>{console.log("[Geo3DViewer] 隐藏加载界面"),t.hideLoadingUI()},100))},[r,t]),x=React.useCallback(()=>{if(e&&h&&h.current){if(h.current.lastReportedLoaded!=d.current||h.current.lastReportedTotal!=u.current||v>0){console.log("[Geo3DViewer] 加载进度",d.current,u.current,v,"使用 Post 加载器",o,e.getMeshesByTags("loading").length+e.getTransformNodesByTags("loading").length);const C=a||(()=>{}),_=n||(()=>{});d.current<u.current||v>0||o&&e.getMeshesByTags("loading").length+e.getTransformNodesByTags("loading").length>0?(console.log("[Geo3DViewer] 加载进度",d.current,u.current),C(d.current,u.current),g(!0)):o?e.getMeshesByTags("loading").length+e.getTransformNodesByTags("loading").length===0&&(_(),g(!1)):d.current===u.current&&(_(),g(!1))}h.current.lastReportedLoaded=d.current,h.current.lastReportedTotal=u.current}},[h,d,u,a,m,g,o,e,n]);return React.useEffect(()=>{x();const C=setInterval(()=>{x()},1e3);return()=>clearInterval(C)},[x]),jsxRuntime.jsx(jsxRuntime.Fragment,{})},CacheCallback$1=CacheCallback,CachePreload=({url:e,cacheType:t,assetType:n=AssetType.BINARY})=>(useCacheProvider({url:e,cacheType:t,assetType:n}),jsxRuntime.jsx(jsxRuntime.Fragment,{})),CachePreload$1=CachePreload;class SimpleAnimationController{constructor(t){le(this,"_nodes",[]);le(this,"_speed",1);le(this,"_loop",!1);le(this,"_length",0);le(this,"_name","");le(this,"_stop",!1);le(this,"_handler");le(this,"_normalizedTime",0);le(this,"_currentTime",0);this._name=t}set speed(t){this._speed=t}get name(){return this._name}get speed(){return this._speed}set loop(t){this._loop=t}get loop(){return this._loop}get time(){return this._normalizedTime*this.length*1e3}get normalized(){return this._normalizedTime}get index(){return 0}get length(){return this._length}get isPlaying(){return!(this._normalizedTime==0||this._normalizedTime>=1)}set nodes(t){this._nodes=t;const n=this._nodes[this._nodes.length-1].curves[0];this._length=n.keys[n.keys.length-1].time}get nodes(){return this._nodes}stop(){this._stop=!0}play(t=0){this._normalizedTime=t/this._length,this._stop=!1,this._currentTime=Date.now(),this.startPlay()}startPlay(){const t=setInterval(()=>{this.update()},30);this._handler=t}update(){if(this._stop){clearInterval(this._handler);return}const t=Date.now()-this._currentTime;this._currentTime=Date.now(),this._normalizedTime+=t/this._length*this._speed;for(let n=0;n<this._nodes.length;n++)this._nodes[n].update(this._normalizedTime*this._length);if(this._normalizedTime>=1){clearInterval(this._handler),this._normalizedTime=1;for(let n=0;n<this._nodes.length;n++)this._nodes[n].reset();this._loop&&!this._stop&&this.play();return}}onDestory(){clearInterval(this._handler)}}var indexMinimal={},minimal$1={},aspromise=asPromise;function asPromise(e,t){for(var n=new Array(arguments.length-1),a=0,r=2,o=!0;r<arguments.length;)n[a++]=arguments[r++];return new Promise(function(s,l){n[a]=function(f){if(o)if(o=!1,f)l(f);else{for(var u=new Array(arguments.length-1),d=0;d<u.length;)u[d++]=arguments[d];s.apply(null,u)}};try{e.apply(t||null,n)}catch(c){o&&(o=!1,l(c))}})}var base64$1={};(function(e){var t=e;t.length=function(s){var l=s.length;if(!l)return 0;for(var c=0;--l%4>1&&s.charAt(l)==="=";)++c;return Math.ceil(s.length*3)/4-c};for(var n=new Array(64),a=new Array(123),r=0;r<64;)a[n[r]=r<26?r+65:r<52?r+71:r<62?r-4:r-59|43]=r++;t.encode=function(s,l,c){for(var f=null,u=[],d=0,h=0,m;l<c;){var R=s[l++];switch(h){case 0:u[d++]=n[R>>2],m=(R&3)<<4,h=1;break;case 1:u[d++]=n[m|R>>4],m=(R&15)<<2,h=2;break;case 2:u[d++]=n[m|R>>6],u[d++]=n[R&63],h=0;break}d>8191&&((f||(f=[])).push(String.fromCharCode.apply(String,u)),d=0)}return h&&(u[d++]=n[m],u[d++]=61,h===1&&(u[d++]=61)),f?(d&&f.push(String.fromCharCode.apply(String,u.slice(0,d))),f.join("")):String.fromCharCode.apply(String,u.slice(0,d))};var o="invalid encoding";t.decode=function(s,l,c){for(var f=c,u=0,d,h=0;h<s.length;){var m=s.charCodeAt(h++);if(m===61&&u>1)break;if((m=a[m])===void 0)throw Error(o);switch(u){case 0:d=m,u=1;break;case 1:l[c++]=d<<2|(m&48)>>4,d=m,u=2;break;case 2:l[c++]=(d&15)<<4|(m&60)>>2,d=m,u=3;break;case 3:l[c++]=(d&3)<<6|m,u=0;break}}if(u===1)throw Error(o);return c-f},t.test=function(s){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s)}})(base64$1);var eventemitter=EventEmitter;function EventEmitter(){this._listeners={}}EventEmitter.prototype.on=function(t,n,a){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:n,ctx:a||this}),this};EventEmitter.prototype.off=function(t,n){if(t===void 0)this._listeners={};else if(n===void 0)this._listeners[t]=[];else for(var a=this._listeners[t],r=0;r<a.length;)a[r].fn===n?a.splice(r,1):++r;return this};EventEmitter.prototype.emit=function(t){var n=this._listeners[t];if(n){for(var a=[],r=1;r<arguments.length;)a.push(arguments[r++]);for(r=0;r<n.length;)n[r].fn.apply(n[r++].ctx,a)}return this};var float=factory(factory);function factory(e){return typeof Float32Array!="undefined"?function(){var t=new Float32Array([-0]),n=new Uint8Array(t.buffer),a=n[3]===128;function r(l,c,f){t[0]=l,c[f]=n[0],c[f+1]=n[1],c[f+2]=n[2],c[f+3]=n[3]}function o(l,c,f){t[0]=l,c[f]=n[3],c[f+1]=n[2],c[f+2]=n[1],c[f+3]=n[0]}e.writeFloatLE=a?r:o,e.writeFloatBE=a?o:r;function i(l,c){return n[0]=l[c],n[1]=l[c+1],n[2]=l[c+2],n[3]=l[c+3],t[0]}function s(l,c){return n[3]=l[c],n[2]=l[c+1],n[1]=l[c+2],n[0]=l[c+3],t[0]}e.readFloatLE=a?i:s,e.readFloatBE=a?s:i}():function(){function t(a,r,o,i){var s=r<0?1:0;if(s&&(r=-r),r===0)a(1/r>0?0:2147483648,o,i);else if(isNaN(r))a(2143289344,o,i);else if(r>34028234663852886e22)a((s<<31|2139095040)>>>0,o,i);else if(r<11754943508222875e-54)a((s<<31|Math.round(r/1401298464324817e-60))>>>0,o,i);else{var l=Math.floor(Math.log(r)/Math.LN2),c=Math.round(r*Math.pow(2,-l)*8388608)&8388607;a((s<<31|l+127<<23|c)>>>0,o,i)}}e.writeFloatLE=t.bind(null,writeUintLE),e.writeFloatBE=t.bind(null,writeUintBE);function n(a,r,o){var i=a(r,o),s=(i>>31)*2+1,l=i>>>23&255,c=i&8388607;return l===255?c?NaN:s*(1/0):l===0?s*1401298464324817e-60*c:s*Math.pow(2,l-150)*(c+8388608)}e.readFloatLE=n.bind(null,readUintLE),e.readFloatBE=n.bind(null,readUintBE)}(),typeof Float64Array!="undefined"?function(){var t=new Float64Array([-0]),n=new Uint8Array(t.buffer),a=n[7]===128;function r(l,c,f){t[0]=l,c[f]=n[0],c[f+1]=n[1],c[f+2]=n[2],c[f+3]=n[3],c[f+4]=n[4],c[f+5]=n[5],c[f+6]=n[6],c[f+7]=n[7]}function o(l,c,f){t[0]=l,c[f]=n[7],c[f+1]=n[6],c[f+2]=n[5],c[f+3]=n[4],c[f+4]=n[3],c[f+5]=n[2],c[f+6]=n[1],c[f+7]=n[0]}e.writeDoubleLE=a?r:o,e.writeDoubleBE=a?o:r;function i(l,c){return n[0]=l[c],n[1]=l[c+1],n[2]=l[c+2],n[3]=l[c+3],n[4]=l[c+4],n[5]=l[c+5],n[6]=l[c+6],n[7]=l[c+7],t[0]}function s(l,c){return n[7]=l[c],n[6]=l[c+1],n[5]=l[c+2],n[4]=l[c+3],n[3]=l[c+4],n[2]=l[c+5],n[1]=l[c+6],n[0]=l[c+7],t[0]}e.readDoubleLE=a?i:s,e.readDoubleBE=a?s:i}():function(){function t(a,r,o,i,s,l){var c=i<0?1:0;if(c&&(i=-i),i===0)a(0,s,l+r),a(1/i>0?0:2147483648,s,l+o);else if(isNaN(i))a(0,s,l+r),a(2146959360,s,l+o);else if(i>17976931348623157e292)a(0,s,l+r),a((c<<31|2146435072)>>>0,s,l+o);else{var f;if(i<22250738585072014e-324)f=i/5e-324,a(f>>>0,s,l+r),a((c<<31|f/4294967296)>>>0,s,l+o);else{var u=Math.floor(Math.log(i)/Math.LN2);u===1024&&(u=1023),f=i*Math.pow(2,-u),a(f*4503599627370496>>>0,s,l+r),a((c<<31|u+1023<<20|f*1048576&1048575)>>>0,s,l+o)}}}e.writeDoubleLE=t.bind(null,writeUintLE,0,4),e.writeDoubleBE=t.bind(null,writeUintBE,4,0);function n(a,r,o,i,s){var l=a(i,s+r),c=a(i,s+o),f=(c>>31)*2+1,u=c>>>20&2047,d=4294967296*(c&1048575)+l;return u===2047?d?NaN:f*(1/0):u===0?f*5e-324*d:f*Math.pow(2,u-1075)*(d+4503599627370496)}e.readDoubleLE=n.bind(null,readUintLE,0,4),e.readDoubleBE=n.bind(null,readUintBE,4,0)}(),e}function writeUintLE(e,t,n){t[n]=e&255,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}function writeUintBE(e,t,n){t[n]=e>>>24,t[n+1]=e>>>16&255,t[n+2]=e>>>8&255,t[n+3]=e&255}function readUintLE(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function readUintBE(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}var inquire_1=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}var utf8$2={};(function(e){var t=e;t.length=function(a){for(var r=0,o=0,i=0;i<a.length;++i)o=a.charCodeAt(i),o<128?r+=1:o<2048?r+=2:(o&64512)===55296&&(a.charCodeAt(i+1)&64512)===56320?(++i,r+=4):r+=3;return r},t.read=function(a,r,o){var i=o-r;if(i<1)return"";for(var s=null,l=[],c=0,f;r<o;)f=a[r++],f<128?l[c++]=f:f>191&&f<224?l[c++]=(f&31)<<6|a[r++]&63:f>239&&f<365?(f=((f&7)<<18|(a[r++]&63)<<12|(a[r++]&63)<<6|a[r++]&63)-65536,l[c++]=55296+(f>>10),l[c++]=56320+(f&1023)):l[c++]=(f&15)<<12|(a[r++]&63)<<6|a[r++]&63,c>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,l)),c=0);return s?(c&&s.push(String.fromCharCode.apply(String,l.slice(0,c))),s.join("")):String.fromCharCode.apply(String,l.slice(0,c))},t.write=function(a,r,o){for(var i=o,s,l,c=0;c<a.length;++c)s=a.charCodeAt(c),s<128?r[o++]=s:s<2048?(r[o++]=s>>6|192,r[o++]=s&63|128):(s&64512)===55296&&((l=a.charCodeAt(c+1))&64512)===56320?(s=65536+((s&1023)<<10)+(l&1023),++c,r[o++]=s>>18|240,r[o++]=s>>12&63|128,r[o++]=s>>6&63|128,r[o++]=s&63|128):(r[o++]=s>>12|224,r[o++]=s>>6&63|128,r[o++]=s&63|128);return o-i}})(utf8$2);var pool_1=pool;function pool(e,t,n){var a=n||8192,r=a>>>1,o=null,i=a;return function(l){if(l<1||l>r)return e(l);i+l>a&&(o=e(a),i=0);var c=t.call(o,i,i+=l);return i&7&&(i=(i|7)+1),c}}var longbits,hasRequiredLongbits;function requireLongbits(){if(hasRequiredLongbits)return longbits;hasRequiredLongbits=1,longbits=t;var e=requireMinimal();function t(o,i){this.lo=o>>>0,this.hi=i>>>0}var n=t.zero=new t(0,0);n.toNumber=function(){return 0},n.zzEncode=n.zzDecode=function(){return this},n.length=function(){return 1};var a=t.zeroHash="\0\0\0\0\0\0\0\0";t.fromNumber=function(i){if(i===0)return n;var s=i<0;s&&(i=-i);var l=i>>>0,c=(i-l)/4294967296>>>0;return s&&(c=~c>>>0,l=~l>>>0,++l>4294967295&&(l=0,++c>4294967295&&(c=0))),new t(l,c)},t.from=function(i){if(typeof i=="number")return t.fromNumber(i);if(e.isString(i))if(e.Long)i=e.Long.fromString(i);else return t.fromNumber(parseInt(i,10));return i.low||i.high?new t(i.low>>>0,i.high>>>0):n},t.prototype.toNumber=function(i){if(!i&&this.hi>>>31){var s=~this.lo+1>>>0,l=~this.hi>>>0;return s||(l=l+1>>>0),-(s+l*4294967296)}return this.lo+this.hi*4294967296},t.prototype.toLong=function(i){return e.Long?new e.Long(this.lo|0,this.hi|0,!!i):{low:this.lo|0,high:this.hi|0,unsigned:!!i}};var r=String.prototype.charCodeAt;return t.fromHash=function(i){return i===a?n:new t((r.call(i,0)|r.call(i,1)<<8|r.call(i,2)<<16|r.call(i,3)<<24)>>>0,(r.call(i,4)|r.call(i,5)<<8|r.call(i,6)<<16|r.call(i,7)<<24)>>>0)},t.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},t.prototype.zzEncode=function(){var i=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^i)>>>0,this.lo=(this.lo<<1^i)>>>0,this},t.prototype.zzDecode=function(){var i=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^i)>>>0,this.hi=(this.hi>>>1^i)>>>0,this},t.prototype.length=function(){var i=this.lo,s=(this.lo>>>28|this.hi<<4)>>>0,l=this.hi>>>24;return l===0?s===0?i<16384?i<128?1:2:i<2097152?3:4:s<16384?s<128?5:6:s<2097152?7:8:l<128?9:10},longbits}var hasRequiredMinimal;function requireMinimal(){return hasRequiredMinimal||(hasRequiredMinimal=1,function(e){var t=e;t.asPromise=aspromise,t.base64=base64$1,t.EventEmitter=eventemitter,t.float=float,t.inquire=inquire_1,t.utf8=utf8$2,t.pool=pool_1,t.LongBits=requireLongbits(),t.isNode=!!(typeof commonjsGlobal!="undefined"&&commonjsGlobal&&commonjsGlobal.process&&commonjsGlobal.process.versions&&commonjsGlobal.process.versions.node),t.global=t.isNode&&commonjsGlobal||typeof window!="undefined"&&window||typeof self!="undefined"&&self||commonjsGlobal,t.emptyArray=Object.freeze?Object.freeze([]):[],t.emptyObject=Object.freeze?Object.freeze({}):{},t.isInteger=Number.isInteger||function(o){return typeof o=="number"&&isFinite(o)&&Math.floor(o)===o},t.isString=function(o){return typeof o=="string"||o instanceof String},t.isObject=function(o){return o&&typeof o=="object"},t.isset=t.isSet=function(o,i){var s=o[i];return s!=null&&o.hasOwnProperty(i)?typeof s!="object"||(Array.isArray(s)?s.length:Object.keys(s).length)>0:!1},t.Buffer=function(){try{var r=t.inquire("buffer").Buffer;return r.prototype.utf8Write?r:null}catch(o){return null}}(),t._Buffer_from=null,t._Buffer_allocUnsafe=null,t.newBuffer=function(o){return typeof o=="number"?t.Buffer?t._Buffer_allocUnsafe(o):new t.Array(o):t.Buffer?t._Buffer_from(o):typeof Uint8Array=="undefined"?o:new Uint8Array(o)},t.Array=typeof Uint8Array!="undefined"?Uint8Array:Array,t.Long=t.global.dcodeIO&&t.global.dcodeIO.Long||t.global.Long||t.inquire("long"),t.key2Re=/^true|false|0|1$/,t.key32Re=/^-?(?:0|[1-9][0-9]*)$/,t.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,t.longToHash=function(o){return o?t.LongBits.from(o).toHash():t.LongBits.zeroHash},t.longFromHash=function(o,i){var s=t.LongBits.fromHash(o);return t.Long?t.Long.fromBits(s.lo,s.hi,i):s.toNumber(!!i)};function n(r,o,i){for(var s=Object.keys(o),l=0;l<s.length;++l)(r[s[l]]===void 0||!i)&&(r[s[l]]=o[s[l]]);return r}t.merge=n,t.lcFirst=function(o){return o.charAt(0).toLowerCase()+o.substring(1)};function a(r){function o(i,s){if(!(this instanceof o))return new o(i,s);Object.defineProperty(this,"message",{get:function(){return i}}),Error.captureStackTrace?Error.captureStackTrace(this,o):Object.defineProperty(this,"stack",{value:new Error().stack||""}),s&&n(this,s)}return o.prototype=Object.create(Error.prototype,{constructor:{value:o,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return r},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),o}t.newError=a,t.ProtocolError=a("ProtocolError"),t.oneOfGetter=function(o){for(var i={},s=0;s<o.length;++s)i[o[s]]=1;return function(){for(var l=Object.keys(this),c=l.length-1;c>-1;--c)if(i[l[c]]===1&&this[l[c]]!==void 0&&this[l[c]]!==null)return l[c]}},t.oneOfSetter=function(o){return function(i){for(var s=0;s<o.length;++s)o[s]!==i&&delete this[o[s]]}},t.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},t._configure=function(){var r=t.Buffer;if(!r){t._Buffer_from=t._Buffer_allocUnsafe=null;return}t._Buffer_from=r.from!==Uint8Array.from&&r.from||function(i,s){return new r(i,s)},t._Buffer_allocUnsafe=r.allocUnsafe||function(i){return new r(i)}}}(minimal$1)),minimal$1}var writer=Writer$1,util$4=requireMinimal(),BufferWriter$1,LongBits$1=util$4.LongBits,base64=util$4.base64,utf8$1=util$4.utf8;function Op(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}function noop(){}function State(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function Writer$1(){this.len=0,this.head=new Op(noop,0,0),this.tail=this.head,this.states=null}var create$1=function e(){return util$4.Buffer?function(){return(Writer$1.create=function(){return new BufferWriter$1})()}:function(){return new Writer$1}};Writer$1.create=create$1();Writer$1.alloc=function e(t){return new util$4.Array(t)};util$4.Array!==Array&&(Writer$1.alloc=util$4.pool(Writer$1.alloc,util$4.Array.prototype.subarray));Writer$1.prototype._push=function e(t,n,a){return this.tail=this.tail.next=new Op(t,n,a),this.len+=n,this};function writeByte(e,t,n){t[n]=e&255}function writeVarint32(e,t,n){for(;e>127;)t[n++]=e&127|128,e>>>=7;t[n]=e}function VarintOp(e,t){this.len=e,this.next=void 0,this.val=t}VarintOp.prototype=Object.create(Op.prototype);VarintOp.prototype.fn=writeVarint32;Writer$1.prototype.uint32=function e(t){return this.len+=(this.tail=this.tail.next=new VarintOp((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this};Writer$1.prototype.int32=function e(t){return t<0?this._push(writeVarint64,10,LongBits$1.fromNumber(t)):this.uint32(t)};Writer$1.prototype.sint32=function e(t){return this.uint32((t<<1^t>>31)>>>0)};function writeVarint64(e,t,n){for(;e.hi;)t[n++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[n++]=e.lo&127|128,e.lo=e.lo>>>7;t[n++]=e.lo}Writer$1.prototype.uint64=function e(t){var n=LongBits$1.from(t);return this._push(writeVarint64,n.length(),n)};Writer$1.prototype.int64=Writer$1.prototype.uint64;Writer$1.prototype.sint64=function e(t){var n=LongBits$1.from(t).zzEncode();return this._push(writeVarint64,n.length(),n)};Writer$1.prototype.bool=function e(t){return this._push(writeByte,1,t?1:0)};function writeFixed32(e,t,n){t[n]=e&255,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}Writer$1.prototype.fixed32=function e(t){return this._push(writeFixed32,4,t>>>0)};Writer$1.prototype.sfixed32=Writer$1.prototype.fixed32;Writer$1.prototype.fixed64=function e(t){var n=LongBits$1.from(t);return this._push(writeFixed32,4,n.lo)._push(writeFixed32,4,n.hi)};Writer$1.prototype.sfixed64=Writer$1.prototype.fixed64;Writer$1.prototype.float=function e(t){return this._push(util$4.float.writeFloatLE,4,t)};Writer$1.prototype.double=function e(t){return this._push(util$4.float.writeDoubleLE,8,t)};var writeBytes=util$4.Array.prototype.set?function e(t,n,a){n.set(t,a)}:function e(t,n,a){for(var r=0;r<t.length;++r)n[a+r]=t[r]};Writer$1.prototype.bytes=function e(t){var n=t.length>>>0;if(!n)return this._push(writeByte,1,0);if(util$4.isString(t)){var a=Writer$1.alloc(n=base64.length(t));base64.decode(t,a,0),t=a}return this.uint32(n)._push(writeBytes,n,t)};Writer$1.prototype.string=function e(t){var n=utf8$1.length(t);return n?this.uint32(n)._push(utf8$1.write,n,t):this._push(writeByte,1,0)};Writer$1.prototype.fork=function e(){return this.states=new State(this),this.head=this.tail=new Op(noop,0,0),this.len=0,this};Writer$1.prototype.reset=function e(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Op(noop,0,0),this.len=0),this};Writer$1.prototype.ldelim=function e(){var t=this.head,n=this.tail,a=this.len;return this.reset().uint32(a),a&&(this.tail.next=t.next,this.tail=n,this.len+=a),this};Writer$1.prototype.finish=function e(){for(var t=this.head.next,n=this.constructor.alloc(this.len),a=0;t;)t.fn(t.val,n,a),a+=t.len,t=t.next;return n};Writer$1._configure=function(e){BufferWriter$1=e,Writer$1.create=create$1(),BufferWriter$1._configure()};var writer_buffer=BufferWriter,Writer=writer;(BufferWriter.prototype=Object.create(Writer.prototype)).constructor=BufferWriter;var util$3=requireMinimal();function BufferWriter(){Writer.call(this)}BufferWriter._configure=function(){BufferWriter.alloc=util$3._Buffer_allocUnsafe,BufferWriter.writeBytesBuffer=util$3.Buffer&&util$3.Buffer.prototype instanceof Uint8Array&&util$3.Buffer.prototype.set.name==="set"?function(t,n,a){n.set(t,a)}:function(t,n,a){if(t.copy)t.copy(n,a,0,t.length);else for(var r=0;r<t.length;)n[a++]=t[r++]}};BufferWriter.prototype.bytes=function e(t){util$3.isString(t)&&(t=util$3._Buffer_from(t,"base64"));var n=t.length>>>0;return this.uint32(n),n&&this._push(BufferWriter.writeBytesBuffer,n,t),this};function writeStringBuffer(e,t,n){e.length<40?util$3.utf8.write(e,t,n):t.utf8Write?t.utf8Write(e,n):t.write(e,n)}BufferWriter.prototype.string=function e(t){var n=util$3.Buffer.byteLength(t);return this.uint32(n),n&&this._push(writeStringBuffer,n,t),this};BufferWriter._configure();var reader=Reader$1,util$2=requireMinimal(),BufferReader$1,LongBits=util$2.LongBits,utf8=util$2.utf8;function indexOutOfRange(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function Reader$1(e){this.buf=e,this.pos=0,this.len=e.length}var create_array=typeof Uint8Array!="undefined"?function e(t){if(t instanceof Uint8Array||Array.isArray(t))return new Reader$1(t);throw Error("illegal buffer")}:function e(t){if(Array.isArray(t))return new Reader$1(t);throw Error("illegal buffer")},create=function e(){return util$2.Buffer?function(n){return(Reader$1.create=function(r){return util$2.Buffer.isBuffer(r)?new BufferReader$1(r):create_array(r)})(n)}:create_array};Reader$1.create=create();Reader$1.prototype._slice=util$2.Array.prototype.subarray||util$2.Array.prototype.slice;Reader$1.prototype.uint32=function e(){var t=4294967295;return function(){if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,indexOutOfRange(this,10);return t}}();Reader$1.prototype.int32=function e(){return this.uint32()|0};Reader$1.prototype.sint32=function e(){var t=this.uint32();return t>>>1^-(t&1)|0};function readLongVarint(){var e=new LongBits(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw indexOutOfRange(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw indexOutOfRange(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}Reader$1.prototype.bool=function e(){return this.uint32()!==0};function readFixed32_end(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}Reader$1.prototype.fixed32=function e(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)};Reader$1.prototype.sfixed32=function e(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)|0};function readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange(this,8);return new LongBits(readFixed32_end(this.buf,this.pos+=4),readFixed32_end(this.buf,this.pos+=4))}Reader$1.prototype.float=function e(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);var t=util$2.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t};Reader$1.prototype.double=function e(){if(this.pos+8>this.len)throw indexOutOfRange(this,4);var t=util$2.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t};Reader$1.prototype.bytes=function e(){var t=this.uint32(),n=this.pos,a=this.pos+t;if(a>this.len)throw indexOutOfRange(this,t);if(this.pos+=t,Array.isArray(this.buf))return this.buf.slice(n,a);if(n===a){var r=util$2.Buffer;return r?r.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,n,a)};Reader$1.prototype.string=function e(){var t=this.bytes();return utf8.read(t,0,t.length)};Reader$1.prototype.skip=function e(t){if(typeof t=="number"){if(this.pos+t>this.len)throw indexOutOfRange(this,t);this.pos+=t}else do if(this.pos>=this.len)throw indexOutOfRange(this);while(this.buf[this.pos++]&128);return this};Reader$1.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this};Reader$1._configure=function(e){BufferReader$1=e,Reader$1.create=create(),BufferReader$1._configure();var t=util$2.Long?"toLong":"toNumber";util$2.merge(Reader$1.prototype,{int64:function(){return readLongVarint.call(this)[t](!1)},uint64:function(){return readLongVarint.call(this)[t](!0)},sint64:function(){return readLongVarint.call(this).zzDecode()[t](!1)},fixed64:function(){return readFixed64.call(this)[t](!0)},sfixed64:function(){return readFixed64.call(this)[t](!1)}})};var reader_buffer=BufferReader,Reader=reader;(BufferReader.prototype=Object.create(Reader.prototype)).constructor=BufferReader;var util$1=requireMinimal();function BufferReader(e){Reader.call(this,e)}BufferReader._configure=function(){util$1.Buffer&&(BufferReader.prototype._slice=util$1.Buffer.prototype.slice)};BufferReader.prototype.string=function e(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))};BufferReader._configure();var rpc={},service=Service,util=requireMinimal();(Service.prototype=Object.create(util.EventEmitter.prototype)).constructor=Service;function Service(e,t,n){if(typeof e!="function")throw TypeError("rpcImpl must be a function");util.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=!!t,this.responseDelimited=!!n}Service.prototype.rpcCall=function e(t,n,a,r,o){if(!r)throw TypeError("request must be specified");var i=this;if(!o)return util.asPromise(e,i,t,n,a,r);if(!i.rpcImpl){setTimeout(function(){o(Error("already ended"))},0);return}try{return i.rpcImpl(t,n[i.requestDelimited?"encodeDelimited":"encode"](r).finish(),function(l,c){if(l)return i.emit("error",l,t),o(l);if(c===null){i.end(!0);return}if(!(c instanceof a))try{c=a[i.responseDelimited?"decodeDelimited":"decode"](c)}catch(f){return i.emit("error",f,t),o(f)}return i.emit("data",c,t),o(null,c)})}catch(s){i.emit("error",s,t),setTimeout(function(){o(s)},0);return}};Service.prototype.end=function e(t){return this.rpcImpl&&(t||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this};(function(e){var t=e;t.Service=service})(rpc);var roots={};(function(e){var t=e;t.build="minimal",t.Writer=writer,t.BufferWriter=writer_buffer,t.Reader=reader,t.BufferReader=reader_buffer,t.util=requireMinimal(),t.rpc=rpc,t.roots=roots,t.configure=n;function n(){t.util._configure(),t.Writer._configure(t.BufferWriter),t.Reader._configure(t.BufferReader)}n()})(indexMinimal);var minimal=indexMinimal;function dataTypeFromJSON(e){switch(e){case 0:case"UNKNOWN":return 0;case 4:case"ROADWAY":return 4;case-1:case"UNRECOGNIZED":default:return-1}}function dataTypeToJSON(e){switch(e){case 0:return"UNKNOWN";case 4:return"ROADWAY";case-1:default:return"UNRECOGNIZED"}}function createBaseVertex(){return{x:0,y:0,z:0}}const Vertex={encode(e,t=minimal.Writer.create()){return e.x!==0&&t.uint32(13).float(e.x),e.y!==0&&t.uint32(21).float(e.y),e.z!==0&&t.uint32(29).float(e.z),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseVertex();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==13)break;r.x=n.float();continue;case 2:if(o!==21)break;r.y=n.float();continue;case 3:if(o!==29)break;r.z=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{x:isSet$h(e.x)?globalThis.Number(e.x):0,y:isSet$h(e.y)?globalThis.Number(e.y):0,z:isSet$h(e.z)?globalThis.Number(e.z):0}},toJSON(e){const t={};return e.x!==0&&(t.x=e.x),e.y!==0&&(t.y=e.y),e.z!==0&&(t.z=e.z),t},create(e){return Vertex.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=createBaseVertex();return t.x=(n=e.x)!=null?n:0,t.y=(a=e.y)!=null?a:0,t.z=(r=e.z)!=null?r:0,t}};function createBaseColor(){return{r:0,g:0,b:0,a:0}}const Color={encode(e,t=minimal.Writer.create()){return e.r!==0&&t.uint32(13).float(e.r),e.g!==0&&t.uint32(21).float(e.g),e.b!==0&&t.uint32(29).float(e.b),e.a!==0&&t.uint32(37).float(e.a),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseColor();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==13)break;r.r=n.float();continue;case 2:if(o!==21)break;r.g=n.float();continue;case 3:if(o!==29)break;r.b=n.float();continue;case 4:if(o!==37)break;r.a=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{r:isSet$h(e.r)?globalThis.Number(e.r):0,g:isSet$h(e.g)?globalThis.Number(e.g):0,b:isSet$h(e.b)?globalThis.Number(e.b):0,a:isSet$h(e.a)?globalThis.Number(e.a):0}},toJSON(e){const t={};return e.r!==0&&(t.r=e.r),e.g!==0&&(t.g=e.g),e.b!==0&&(t.b=e.b),e.a!==0&&(t.a=e.a),t},create(e){return Color.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o;const t=createBaseColor();return t.r=(n=e.r)!=null?n:0,t.g=(a=e.g)!=null?a:0,t.b=(r=e.b)!=null?r:0,t.a=(o=e.a)!=null?o:0,t}};function createBasePosition(){return{x:0,y:0,z:0}}const Position={encode(e,t=minimal.Writer.create()){return e.x!==0&&t.uint32(13).float(e.x),e.y!==0&&t.uint32(21).float(e.y),e.z!==0&&t.uint32(29).float(e.z),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBasePosition();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==13)break;r.x=n.float();continue;case 2:if(o!==21)break;r.y=n.float();continue;case 3:if(o!==29)break;r.z=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{x:isSet$h(e.x)?globalThis.Number(e.x):0,y:isSet$h(e.y)?globalThis.Number(e.y):0,z:isSet$h(e.z)?globalThis.Number(e.z):0}},toJSON(e){const t={};return e.x!==0&&(t.x=e.x),e.y!==0&&(t.y=e.y),e.z!==0&&(t.z=e.z),t},create(e){return Position.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=createBasePosition();return t.x=(n=e.x)!=null?n:0,t.y=(a=e.y)!=null?a:0,t.z=(r=e.z)!=null?r:0,t}};function createBaseMesh(){return{vertices:[],normals:[],indices:[],colors:[],uv:[]}}const Mesh={encode(e,t=minimal.Writer.create()){t.uint32(10).fork();for(const n of e.vertices)t.float(n);t.ldelim(),t.uint32(18).fork();for(const n of e.normals)t.float(n);t.ldelim(),t.uint32(26).fork();for(const n of e.indices)t.uint32(n);t.ldelim(),t.uint32(34).fork();for(const n of e.colors)t.float(n);t.ldelim(),t.uint32(42).fork();for(const n of e.uv)t.float(n);return t.ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseMesh();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o===13){r.vertices.push(n.float());continue}if(o===10){const i=n.uint32()+n.pos;for(;n.pos<i;)r.vertices.push(n.float());continue}break;case 2:if(o===21){r.normals.push(n.float());continue}if(o===18){const i=n.uint32()+n.pos;for(;n.pos<i;)r.normals.push(n.float());continue}break;case 3:if(o===24){r.indices.push(n.uint32());continue}if(o===26){const i=n.uint32()+n.pos;for(;n.pos<i;)r.indices.push(n.uint32());continue}break;case 4:if(o===37){r.colors.push(n.float());continue}if(o===34){const i=n.uint32()+n.pos;for(;n.pos<i;)r.colors.push(n.float());continue}break;case 5:if(o===45){r.uv.push(n.float());continue}if(o===42){const i=n.uint32()+n.pos;for(;n.pos<i;)r.uv.push(n.float());continue}break}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{vertices:globalThis.Array.isArray(e==null?void 0:e.vertices)?e.vertices.map(t=>globalThis.Number(t)):[],normals:globalThis.Array.isArray(e==null?void 0:e.normals)?e.normals.map(t=>globalThis.Number(t)):[],indices:globalThis.Array.isArray(e==null?void 0:e.indices)?e.indices.map(t=>globalThis.Number(t)):[],colors:globalThis.Array.isArray(e==null?void 0:e.colors)?e.colors.map(t=>globalThis.Number(t)):[],uv:globalThis.Array.isArray(e==null?void 0:e.uv)?e.uv.map(t=>globalThis.Number(t)):[]}},toJSON(e){var n,a,r,o,i;const t={};return(n=e.vertices)!=null&&n.length&&(t.vertices=e.vertices),(a=e.normals)!=null&&a.length&&(t.normals=e.normals),(r=e.indices)!=null&&r.length&&(t.indices=e.indices.map(s=>Math.round(s))),(o=e.colors)!=null&&o.length&&(t.colors=e.colors),(i=e.uv)!=null&&i.length&&(t.uv=e.uv),t},create(e){return Mesh.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=createBaseMesh();return t.vertices=((n=e.vertices)==null?void 0:n.map(s=>s))||[],t.normals=((a=e.normals)==null?void 0:a.map(s=>s))||[],t.indices=((r=e.indices)==null?void 0:r.map(s=>s))||[],t.colors=((o=e.colors)==null?void 0:o.map(s=>s))||[],t.uv=((i=e.uv)==null?void 0:i.map(s=>s))||[],t}};function isSet$h(e){return e!=null}function roadWayTypeFromJSON(e){switch(e){case 0:case"RECTANGLE":return 0;case 1:case"CICLE":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function roadWayTypeToJSON(e){switch(e){case 0:return"RECTANGLE";case 1:return"CICLE";case-1:default:return"UNRECOGNIZED"}}function createBaseRoadWay(){return{dataType:0,name:"",position:void 0,boxes:[]}}const RoadWay$2={encode(e,t=minimal.Writer.create()){e.dataType!==0&&t.uint32(8).int32(e.dataType),e.name!==""&&t.uint32(26).string(e.name),e.position!==void 0&&Vertex.encode(e.position,t.uint32(34).fork()).ldelim();for(const n of e.boxes)RoadWay_RoadWayBox.encode(n,t.uint32(66).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWay();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==8)break;r.dataType=n.int32();continue;case 3:if(o!==26)break;r.name=n.string();continue;case 4:if(o!==34)break;r.position=Vertex.decode(n,n.uint32());continue;case 8:if(o!==66)break;r.boxes.push(RoadWay_RoadWayBox.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{dataType:isSet$g(e.dataType)?dataTypeFromJSON(e.dataType):0,name:isSet$g(e.name)?globalThis.String(e.name):"",position:isSet$g(e.position)?Vertex.fromJSON(e.position):void 0,boxes:globalThis.Array.isArray(e==null?void 0:e.boxes)?e.boxes.map(t=>RoadWay_RoadWayBox.fromJSON(t)):[]}},toJSON(e){var n;const t={};return e.dataType!==0&&(t.dataType=dataTypeToJSON(e.dataType)),e.name!==""&&(t.name=e.name),e.position!==void 0&&(t.position=Vertex.toJSON(e.position)),(n=e.boxes)!=null&&n.length&&(t.boxes=e.boxes.map(a=>RoadWay_RoadWayBox.toJSON(a))),t},create(e){return RoadWay$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=createBaseRoadWay();return t.dataType=(n=e.dataType)!=null?n:0,t.name=(a=e.name)!=null?a:"",t.position=e.position!==void 0&&e.position!==null?Vertex.fromPartial(e.position):void 0,t.boxes=((r=e.boxes)==null?void 0:r.map(o=>RoadWay_RoadWayBox.fromPartial(o)))||[],t}};function createBaseRoadWay_RoadWayBox(){return{name:"",leftSpace:0,rightSpace:0,startPosition:void 0,endPosition:void 0,type:0,topMesh:void 0,sideMesh:void 0,bottomMesh:void 0,width:0,height:0,startOutWidth:0,endOutWidth:0}}const RoadWay_RoadWayBox={encode(e,t=minimal.Writer.create()){return e.name!==""&&t.uint32(10).string(e.name),e.leftSpace!==0&&t.uint32(21).float(e.leftSpace),e.rightSpace!==0&&t.uint32(29).float(e.rightSpace),e.startPosition!==void 0&&Vertex.encode(e.startPosition,t.uint32(34).fork()).ldelim(),e.endPosition!==void 0&&Vertex.encode(e.endPosition,t.uint32(42).fork()).ldelim(),e.type!==0&&t.uint32(48).int32(e.type),e.topMesh!==void 0&&Mesh.encode(e.topMesh,t.uint32(58).fork()).ldelim(),e.sideMesh!==void 0&&Mesh.encode(e.sideMesh,t.uint32(66).fork()).ldelim(),e.bottomMesh!==void 0&&Mesh.encode(e.bottomMesh,t.uint32(74).fork()).ldelim(),e.width!==0&&t.uint32(85).float(e.width),e.height!==0&&t.uint32(93).float(e.height),e.startOutWidth!==0&&t.uint32(101).float(e.startOutWidth),e.endOutWidth!==0&&t.uint32(109).float(e.endOutWidth),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWay_RoadWayBox();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==21)break;r.leftSpace=n.float();continue;case 3:if(o!==29)break;r.rightSpace=n.float();continue;case 4:if(o!==34)break;r.startPosition=Vertex.decode(n,n.uint32());continue;case 5:if(o!==42)break;r.endPosition=Vertex.decode(n,n.uint32());continue;case 6:if(o!==48)break;r.type=n.int32();continue;case 7:if(o!==58)break;r.topMesh=Mesh.decode(n,n.uint32());continue;case 8:if(o!==66)break;r.sideMesh=Mesh.decode(n,n.uint32());continue;case 9:if(o!==74)break;r.bottomMesh=Mesh.decode(n,n.uint32());continue;case 10:if(o!==85)break;r.width=n.float();continue;case 11:if(o!==93)break;r.height=n.float();continue;case 12:if(o!==101)break;r.startOutWidth=n.float();continue;case 13:if(o!==109)break;r.endOutWidth=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$g(e.name)?globalThis.String(e.name):"",leftSpace:isSet$g(e.leftSpace)?globalThis.Number(e.leftSpace):0,rightSpace:isSet$g(e.rightSpace)?globalThis.Number(e.rightSpace):0,startPosition:isSet$g(e.startPosition)?Vertex.fromJSON(e.startPosition):void 0,endPosition:isSet$g(e.endPosition)?Vertex.fromJSON(e.endPosition):void 0,type:isSet$g(e.type)?roadWayTypeFromJSON(e.type):0,topMesh:isSet$g(e.topMesh)?Mesh.fromJSON(e.topMesh):void 0,sideMesh:isSet$g(e.sideMesh)?Mesh.fromJSON(e.sideMesh):void 0,bottomMesh:isSet$g(e.bottomMesh)?Mesh.fromJSON(e.bottomMesh):void 0,width:isSet$g(e.width)?globalThis.Number(e.width):0,height:isSet$g(e.height)?globalThis.Number(e.height):0,startOutWidth:isSet$g(e.startOutWidth)?globalThis.Number(e.startOutWidth):0,endOutWidth:isSet$g(e.endOutWidth)?globalThis.Number(e.endOutWidth):0}},toJSON(e){const t={};return e.name!==""&&(t.name=e.name),e.leftSpace!==0&&(t.leftSpace=e.leftSpace),e.rightSpace!==0&&(t.rightSpace=e.rightSpace),e.startPosition!==void 0&&(t.startPosition=Vertex.toJSON(e.startPosition)),e.endPosition!==void 0&&(t.endPosition=Vertex.toJSON(e.endPosition)),e.type!==0&&(t.type=roadWayTypeToJSON(e.type)),e.topMesh!==void 0&&(t.topMesh=Mesh.toJSON(e.topMesh)),e.sideMesh!==void 0&&(t.sideMesh=Mesh.toJSON(e.sideMesh)),e.bottomMesh!==void 0&&(t.bottomMesh=Mesh.toJSON(e.bottomMesh)),e.width!==0&&(t.width=e.width),e.height!==0&&(t.height=e.height),e.startOutWidth!==0&&(t.startOutWidth=e.startOutWidth),e.endOutWidth!==0&&(t.endOutWidth=e.endOutWidth),t},create(e){return RoadWay_RoadWayBox.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l,c;const t=createBaseRoadWay_RoadWayBox();return t.name=(n=e.name)!=null?n:"",t.leftSpace=(a=e.leftSpace)!=null?a:0,t.rightSpace=(r=e.rightSpace)!=null?r:0,t.startPosition=e.startPosition!==void 0&&e.startPosition!==null?Vertex.fromPartial(e.startPosition):void 0,t.endPosition=e.endPosition!==void 0&&e.endPosition!==null?Vertex.fromPartial(e.endPosition):void 0,t.type=(o=e.type)!=null?o:0,t.topMesh=e.topMesh!==void 0&&e.topMesh!==null?Mesh.fromPartial(e.topMesh):void 0,t.sideMesh=e.sideMesh!==void 0&&e.sideMesh!==null?Mesh.fromPartial(e.sideMesh):void 0,t.bottomMesh=e.bottomMesh!==void 0&&e.bottomMesh!==null?Mesh.fromPartial(e.bottomMesh):void 0,t.width=(i=e.width)!=null?i:0,t.height=(s=e.height)!=null?s:0,t.startOutWidth=(l=e.startOutWidth)!=null?l:0,t.endOutWidth=(c=e.endOutWidth)!=null?c:0,t}};function isSet$g(e){return e!=null}function roadWayAnim_FrameTypeFromJSON(e){switch(e){case 0:case"NORMAL_FRAME":return 0;case 1:case"KEY_FRAME":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function roadWayAnim_FrameTypeToJSON(e){switch(e){case 0:return"NORMAL_FRAME";case 1:return"KEY_FRAME";case-1:default:return"UNRECOGNIZED"}}var RoadWayAnim_AnimType=(e=>(e[e.RUN=0]="RUN",e[e.WATER=1]="WATER",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(RoadWayAnim_AnimType||{});function roadWayAnim_AnimTypeFromJSON(e){switch(e){case 0:case"RUN":return 0;case 1:case"WATER":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function roadWayAnim_AnimTypeToJSON(e){switch(e){case 0:return"RUN";case 1:return"WATER";case-1:default:return"UNRECOGNIZED"}}function createBaseRoadWayAnim(){return{name:"",frameRate:0,type:0,frames:[],boxes:[],animType:0,colors:[]}}const RoadWayAnim={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.frameRate!==0&&t.uint32(16).uint32(e.frameRate),e.type!==0&&t.uint32(24).int32(e.type);for(const n of e.frames)RoadWayAnim_Frame.encode(n,t.uint32(34).fork()).ldelim();for(const n of e.boxes)RoadWay_RoadWayBox.encode(n,t.uint32(42).fork()).ldelim();e.animType!==0&&t.uint32(48).int32(e.animType);for(const n of e.colors)Color.encode(n,t.uint32(58).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayAnim();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==16)break;r.frameRate=n.uint32();continue;case 3:if(o!==24)break;r.type=n.int32();continue;case 4:if(o!==34)break;r.frames.push(RoadWayAnim_Frame.decode(n,n.uint32()));continue;case 5:if(o!==42)break;r.boxes.push(RoadWay_RoadWayBox.decode(n,n.uint32()));continue;case 6:if(o!==48)break;r.animType=n.int32();continue;case 7:if(o!==58)break;r.colors.push(Color.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$f(e.name)?globalThis.String(e.name):"",frameRate:isSet$f(e.frameRate)?globalThis.Number(e.frameRate):0,type:isSet$f(e.type)?roadWayAnim_FrameTypeFromJSON(e.type):0,frames:globalThis.Array.isArray(e==null?void 0:e.frames)?e.frames.map(t=>RoadWayAnim_Frame.fromJSON(t)):[],boxes:globalThis.Array.isArray(e==null?void 0:e.boxes)?e.boxes.map(t=>RoadWay_RoadWayBox.fromJSON(t)):[],animType:isSet$f(e.animType)?roadWayAnim_AnimTypeFromJSON(e.animType):0,colors:globalThis.Array.isArray(e==null?void 0:e.colors)?e.colors.map(t=>Color.fromJSON(t)):[]}},toJSON(e){var n,a,r;const t={};return e.name!==""&&(t.name=e.name),e.frameRate!==0&&(t.frameRate=Math.round(e.frameRate)),e.type!==0&&(t.type=roadWayAnim_FrameTypeToJSON(e.type)),(n=e.frames)!=null&&n.length&&(t.frames=e.frames.map(o=>RoadWayAnim_Frame.toJSON(o))),(a=e.boxes)!=null&&a.length&&(t.boxes=e.boxes.map(o=>RoadWay_RoadWayBox.toJSON(o))),e.animType!==0&&(t.animType=roadWayAnim_AnimTypeToJSON(e.animType)),(r=e.colors)!=null&&r.length&&(t.colors=e.colors.map(o=>Color.toJSON(o))),t},create(e){return RoadWayAnim.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l;const t=createBaseRoadWayAnim();return t.name=(n=e.name)!=null?n:"",t.frameRate=(a=e.frameRate)!=null?a:0,t.type=(r=e.type)!=null?r:0,t.frames=((o=e.frames)==null?void 0:o.map(c=>RoadWayAnim_Frame.fromPartial(c)))||[],t.boxes=((i=e.boxes)==null?void 0:i.map(c=>RoadWay_RoadWayBox.fromPartial(c)))||[],t.animType=(s=e.animType)!=null?s:0,t.colors=((l=e.colors)==null?void 0:l.map(c=>Color.fromPartial(c)))||[],t}};function createBaseRoadWayAnim_Percent(){return{start:0,end:0}}const RoadWayAnim_Percent={encode(e,t=minimal.Writer.create()){return e.start!==0&&t.uint32(13).float(e.start),e.end!==0&&t.uint32(21).float(e.end),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayAnim_Percent();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==13)break;r.start=n.float();continue;case 2:if(o!==21)break;r.end=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{start:isSet$f(e.start)?globalThis.Number(e.start):0,end:isSet$f(e.end)?globalThis.Number(e.end):0}},toJSON(e){const t={};return e.start!==0&&(t.start=e.start),e.end!==0&&(t.end=e.end),t},create(e){return RoadWayAnim_Percent.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseRoadWayAnim_Percent();return t.start=(n=e.start)!=null?n:0,t.end=(a=e.end)!=null?a:0,t}};function createBaseRoadWayAnim_Node(){return{index:0,name:"",percent:[],colorPercent:[]}}const RoadWayAnim_Node={encode(e,t=minimal.Writer.create()){e.index!==0&&t.uint32(8).uint32(e.index),e.name!==""&&t.uint32(18).string(e.name);for(const n of e.percent)RoadWayAnim_Percent.encode(n,t.uint32(26).fork()).ldelim();for(const n of e.colorPercent)RoadWayAnim_Percent.encode(n,t.uint32(34).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayAnim_Node();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==8)break;r.index=n.uint32();continue;case 2:if(o!==18)break;r.name=n.string();continue;case 3:if(o!==26)break;r.percent.push(RoadWayAnim_Percent.decode(n,n.uint32()));continue;case 4:if(o!==34)break;r.colorPercent.push(RoadWayAnim_Percent.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{index:isSet$f(e.index)?globalThis.Number(e.index):0,name:isSet$f(e.name)?globalThis.String(e.name):"",percent:globalThis.Array.isArray(e==null?void 0:e.percent)?e.percent.map(t=>RoadWayAnim_Percent.fromJSON(t)):[],colorPercent:globalThis.Array.isArray(e==null?void 0:e.colorPercent)?e.colorPercent.map(t=>RoadWayAnim_Percent.fromJSON(t)):[]}},toJSON(e){var n,a;const t={};return e.index!==0&&(t.index=Math.round(e.index)),e.name!==""&&(t.name=e.name),(n=e.percent)!=null&&n.length&&(t.percent=e.percent.map(r=>RoadWayAnim_Percent.toJSON(r))),(a=e.colorPercent)!=null&&a.length&&(t.colorPercent=e.colorPercent.map(r=>RoadWayAnim_Percent.toJSON(r))),t},create(e){return RoadWayAnim_Node.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o;const t=createBaseRoadWayAnim_Node();return t.index=(n=e.index)!=null?n:0,t.name=(a=e.name)!=null?a:"",t.percent=((r=e.percent)==null?void 0:r.map(i=>RoadWayAnim_Percent.fromPartial(i)))||[],t.colorPercent=((o=e.colorPercent)==null?void 0:o.map(i=>RoadWayAnim_Percent.fromPartial(i)))||[],t}};function createBaseRoadWayAnim_Frame(){return{node:[],time:0}}const RoadWayAnim_Frame={encode(e,t=minimal.Writer.create()){for(const n of e.node)RoadWayAnim_Node.encode(n,t.uint32(10).fork()).ldelim();return e.time!==0&&t.uint32(21).float(e.time),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayAnim_Frame();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.node.push(RoadWayAnim_Node.decode(n,n.uint32()));continue;case 2:if(o!==21)break;r.time=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{node:globalThis.Array.isArray(e==null?void 0:e.node)?e.node.map(t=>RoadWayAnim_Node.fromJSON(t)):[],time:isSet$f(e.time)?globalThis.Number(e.time):0}},toJSON(e){var n;const t={};return(n=e.node)!=null&&n.length&&(t.node=e.node.map(a=>RoadWayAnim_Node.toJSON(a))),e.time!==0&&(t.time=e.time),t},create(e){return RoadWayAnim_Frame.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseRoadWayAnim_Frame();return t.node=((n=e.node)==null?void 0:n.map(r=>RoadWayAnim_Node.fromPartial(r)))||[],t.time=(a=e.time)!=null?a:0,t}};function isSet$f(e){return e!=null}function roadWayNearFlowAnim_FrameTypeFromJSON(e){switch(e){case 0:case"NORMAL_FRAME":return 0;case 1:case"KEY_FRAME":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function roadWayNearFlowAnim_FrameTypeToJSON(e){switch(e){case 0:return"NORMAL_FRAME";case 1:return"KEY_FRAME";case-1:default:return"UNRECOGNIZED"}}function createBaseRoadWayNearFlowAnim(){return{name:"",frameRate:0,type:0,nodes:[],boxes:[]}}const RoadWayNearFlowAnim={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.frameRate!==0&&t.uint32(16).uint32(e.frameRate),e.type!==0&&t.uint32(24).int32(e.type);for(const n of e.nodes)RoadWayNearFlowAnim_Node.encode(n,t.uint32(34).fork()).ldelim();for(const n of e.boxes)RoadWay_RoadWayBox.encode(n,t.uint32(42).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayNearFlowAnim();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==16)break;r.frameRate=n.uint32();continue;case 3:if(o!==24)break;r.type=n.int32();continue;case 4:if(o!==34)break;r.nodes.push(RoadWayNearFlowAnim_Node.decode(n,n.uint32()));continue;case 5:if(o!==42)break;r.boxes.push(RoadWay_RoadWayBox.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$e(e.name)?globalThis.String(e.name):"",frameRate:isSet$e(e.frameRate)?globalThis.Number(e.frameRate):0,type:isSet$e(e.type)?roadWayNearFlowAnim_FrameTypeFromJSON(e.type):0,nodes:globalThis.Array.isArray(e==null?void 0:e.nodes)?e.nodes.map(t=>RoadWayNearFlowAnim_Node.fromJSON(t)):[],boxes:globalThis.Array.isArray(e==null?void 0:e.boxes)?e.boxes.map(t=>RoadWay_RoadWayBox.fromJSON(t)):[]}},toJSON(e){var n,a;const t={};return e.name!==""&&(t.name=e.name),e.frameRate!==0&&(t.frameRate=Math.round(e.frameRate)),e.type!==0&&(t.type=roadWayNearFlowAnim_FrameTypeToJSON(e.type)),(n=e.nodes)!=null&&n.length&&(t.nodes=e.nodes.map(r=>RoadWayNearFlowAnim_Node.toJSON(r))),(a=e.boxes)!=null&&a.length&&(t.boxes=e.boxes.map(r=>RoadWay_RoadWayBox.toJSON(r))),t},create(e){return RoadWayNearFlowAnim.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=createBaseRoadWayNearFlowAnim();return t.name=(n=e.name)!=null?n:"",t.frameRate=(a=e.frameRate)!=null?a:0,t.type=(r=e.type)!=null?r:0,t.nodes=((o=e.nodes)==null?void 0:o.map(s=>RoadWayNearFlowAnim_Node.fromPartial(s)))||[],t.boxes=((i=e.boxes)==null?void 0:i.map(s=>RoadWay_RoadWayBox.fromPartial(s)))||[],t}};function createBaseRoadWayNearFlowAnim_Percent(){return{start:0,end:0}}const RoadWayNearFlowAnim_Percent={encode(e,t=minimal.Writer.create()){return e.start!==0&&t.uint32(13).float(e.start),e.end!==0&&t.uint32(21).float(e.end),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayNearFlowAnim_Percent();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==13)break;r.start=n.float();continue;case 2:if(o!==21)break;r.end=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{start:isSet$e(e.start)?globalThis.Number(e.start):0,end:isSet$e(e.end)?globalThis.Number(e.end):0}},toJSON(e){const t={};return e.start!==0&&(t.start=e.start),e.end!==0&&(t.end=e.end),t},create(e){return RoadWayNearFlowAnim_Percent.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseRoadWayNearFlowAnim_Percent();return t.start=(n=e.start)!=null?n:0,t.end=(a=e.end)!=null?a:0,t}};function createBaseRoadWayNearFlowAnim_Node(){return{index:0,name:"",frames:[]}}const RoadWayNearFlowAnim_Node={encode(e,t=minimal.Writer.create()){e.index!==0&&t.uint32(8).uint32(e.index),e.name!==""&&t.uint32(18).string(e.name);for(const n of e.frames)RoadWayNearFlowAnim_Frame.encode(n,t.uint32(26).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayNearFlowAnim_Node();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==8)break;r.index=n.uint32();continue;case 2:if(o!==18)break;r.name=n.string();continue;case 3:if(o!==26)break;r.frames.push(RoadWayNearFlowAnim_Frame.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{index:isSet$e(e.index)?globalThis.Number(e.index):0,name:isSet$e(e.name)?globalThis.String(e.name):"",frames:globalThis.Array.isArray(e==null?void 0:e.frames)?e.frames.map(t=>RoadWayNearFlowAnim_Frame.fromJSON(t)):[]}},toJSON(e){var n;const t={};return e.index!==0&&(t.index=Math.round(e.index)),e.name!==""&&(t.name=e.name),(n=e.frames)!=null&&n.length&&(t.frames=e.frames.map(a=>RoadWayNearFlowAnim_Frame.toJSON(a))),t},create(e){return RoadWayNearFlowAnim_Node.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=createBaseRoadWayNearFlowAnim_Node();return t.index=(n=e.index)!=null?n:0,t.name=(a=e.name)!=null?a:"",t.frames=((r=e.frames)==null?void 0:r.map(o=>RoadWayNearFlowAnim_Frame.fromPartial(o)))||[],t}};function createBaseRoadWayNearFlowAnim_Frame(){return{time:0,percent:[],colorPercent:[]}}const RoadWayNearFlowAnim_Frame={encode(e,t=minimal.Writer.create()){e.time!==0&&t.uint32(13).float(e.time);for(const n of e.percent)RoadWayNearFlowAnim_Percent.encode(n,t.uint32(18).fork()).ldelim();for(const n of e.colorPercent)RoadWayNearFlowAnim_Percent.encode(n,t.uint32(26).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayNearFlowAnim_Frame();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==13)break;r.time=n.float();continue;case 2:if(o!==18)break;r.percent.push(RoadWayNearFlowAnim_Percent.decode(n,n.uint32()));continue;case 3:if(o!==26)break;r.colorPercent.push(RoadWayNearFlowAnim_Percent.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{time:isSet$e(e.time)?globalThis.Number(e.time):0,percent:globalThis.Array.isArray(e==null?void 0:e.percent)?e.percent.map(t=>RoadWayNearFlowAnim_Percent.fromJSON(t)):[],colorPercent:globalThis.Array.isArray(e==null?void 0:e.colorPercent)?e.colorPercent.map(t=>RoadWayNearFlowAnim_Percent.fromJSON(t)):[]}},toJSON(e){var n,a;const t={};return e.time!==0&&(t.time=e.time),(n=e.percent)!=null&&n.length&&(t.percent=e.percent.map(r=>RoadWayNearFlowAnim_Percent.toJSON(r))),(a=e.colorPercent)!=null&&a.length&&(t.colorPercent=e.colorPercent.map(r=>RoadWayNearFlowAnim_Percent.toJSON(r))),t},create(e){return RoadWayNearFlowAnim_Frame.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=createBaseRoadWayNearFlowAnim_Frame();return t.time=(n=e.time)!=null?n:0,t.percent=((a=e.percent)==null?void 0:a.map(o=>RoadWayNearFlowAnim_Percent.fromPartial(o)))||[],t.colorPercent=((r=e.colorPercent)==null?void 0:r.map(o=>RoadWayNearFlowAnim_Percent.fromPartial(o)))||[],t}};function isSet$e(e){return e!=null}function roadWayNearAnim_FrameTypeFromJSON(e){switch(e){case 0:case"NORMAL_FRAME":return 0;case 1:case"KEY_FRAME":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function roadWayNearAnim_FrameTypeToJSON(e){switch(e){case 0:return"NORMAL_FRAME";case 1:return"KEY_FRAME";case-1:default:return"UNRECOGNIZED"}}function createBaseRoadWayNearAnim(){return{name:"",frameRate:0,type:0,frames:[],url:""}}const RoadWayNearAnim={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.frameRate!==0&&t.uint32(16).uint32(e.frameRate),e.type!==0&&t.uint32(24).int32(e.type);for(const n of e.frames)RoadWayNearAnim_Frame.encode(n,t.uint32(34).fork()).ldelim();return e.url!==""&&t.uint32(42).string(e.url),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayNearAnim();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==16)break;r.frameRate=n.uint32();continue;case 3:if(o!==24)break;r.type=n.int32();continue;case 4:if(o!==34)break;r.frames.push(RoadWayNearAnim_Frame.decode(n,n.uint32()));continue;case 5:if(o!==42)break;r.url=n.string();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$d(e.name)?globalThis.String(e.name):"",frameRate:isSet$d(e.frameRate)?globalThis.Number(e.frameRate):0,type:isSet$d(e.type)?roadWayNearAnim_FrameTypeFromJSON(e.type):0,frames:globalThis.Array.isArray(e==null?void 0:e.frames)?e.frames.map(t=>RoadWayNearAnim_Frame.fromJSON(t)):[],url:isSet$d(e.url)?globalThis.String(e.url):""}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),e.frameRate!==0&&(t.frameRate=Math.round(e.frameRate)),e.type!==0&&(t.type=roadWayNearAnim_FrameTypeToJSON(e.type)),(n=e.frames)!=null&&n.length&&(t.frames=e.frames.map(a=>RoadWayNearAnim_Frame.toJSON(a))),e.url!==""&&(t.url=e.url),t},create(e){return RoadWayNearAnim.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=createBaseRoadWayNearAnim();return t.name=(n=e.name)!=null?n:"",t.frameRate=(a=e.frameRate)!=null?a:0,t.type=(r=e.type)!=null?r:0,t.frames=((o=e.frames)==null?void 0:o.map(s=>RoadWayNearAnim_Frame.fromPartial(s)))||[],t.url=(i=e.url)!=null?i:"",t}};function createBaseRoadWayNearAnim_Node(){return{name:"",position:void 0}}const RoadWayNearAnim_Node={encode(e,t=minimal.Writer.create()){return e.name!==""&&t.uint32(10).string(e.name),e.position!==void 0&&Position.encode(e.position,t.uint32(18).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayNearAnim_Node();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.position=Position.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$d(e.name)?globalThis.String(e.name):"",position:isSet$d(e.position)?Position.fromJSON(e.position):void 0}},toJSON(e){const t={};return e.name!==""&&(t.name=e.name),e.position!==void 0&&(t.position=Position.toJSON(e.position)),t},create(e){return RoadWayNearAnim_Node.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=createBaseRoadWayNearAnim_Node();return t.name=(n=e.name)!=null?n:"",t.position=e.position!==void 0&&e.position!==null?Position.fromPartial(e.position):void 0,t}};function createBaseRoadWayNearAnim_Frame(){return{nodes:[],time:0}}const RoadWayNearAnim_Frame={encode(e,t=minimal.Writer.create()){for(const n of e.nodes)RoadWayNearAnim_Node.encode(n,t.uint32(10).fork()).ldelim();return e.time!==0&&t.uint32(21).float(e.time),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRoadWayNearAnim_Frame();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.nodes.push(RoadWayNearAnim_Node.decode(n,n.uint32()));continue;case 2:if(o!==21)break;r.time=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{nodes:globalThis.Array.isArray(e==null?void 0:e.nodes)?e.nodes.map(t=>RoadWayNearAnim_Node.fromJSON(t)):[],time:isSet$d(e.time)?globalThis.Number(e.time):0}},toJSON(e){var n;const t={};return(n=e.nodes)!=null&&n.length&&(t.nodes=e.nodes.map(a=>RoadWayNearAnim_Node.toJSON(a))),e.time!==0&&(t.time=e.time),t},create(e){return RoadWayNearAnim_Frame.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseRoadWayNearAnim_Frame();return t.nodes=((n=e.nodes)==null?void 0:n.map(r=>RoadWayNearAnim_Node.fromPartial(r)))||[],t.time=(a=e.time)!=null?a:0,t}};function isSet$d(e){return e!=null}class AnimationCurve{constructor(){le(this,"_keys",[]);le(this,"getLastKey",()=>this._keys[this._keys.length-1]);le(this,"getFirstKey",()=>this._keys[0])}get keys(){return this._keys}get length(){return this._keys[this._keys.length-1].time}evaluate(t){const n=this.getKeyIndex(t);if(n!=-1){const a=Math.max(n-1,0),r=(t-this._keys[a].time)/(this._keys[n].time-this._keys[a].time);return EngineCore.Scalar.Lerp(this._keys[a].value,this._keys[n].value,r)}}getKeyIndex(t){for(let n=0;n<this._keys.length;n++)if(t<=this._keys[n].time)return n;return-1}addKey(t){this._keys.push(t)}}class AnimationKeyFrame{constructor(t,n){le(this,"time");le(this,"value");this.time=t,this.value=n}}class AnimationNode{constructor(t){le(this,"_curves",[]);this._curves=t}get curves(){return this._curves}update(t){}reset(){}}class AnimationRoadWayNearNode extends AnimationNode{constructor(){super(...arguments);le(this,"_name","");le(this,"_url","");le(this,"_start");le(this,"_end");le(this,"_current")}set name(n){this._name=n}get name(){return this._name}set url(n){this._url=n}get url(){return this._url}set start(n){this._start=n}get start(){return this._start}set end(n){this._end=n}get end(){return this._end}set current(n){this._current=n}get current(){return this._current}getEndPosition(){var o,i,s;const n=(o=this.curves[0].getLastKey())==null?void 0:o.value,a=(i=this.curves[1].getLastKey())==null?void 0:i.value,r=(s=this.curves[2].getLastKey())==null?void 0:s.value;return new EngineCore.Vector3(n,a,r)}getStartPosition(){const n=this.curves[0].getFirstKey().value,a=this.curves[1].getFirstKey().value,r=this.curves[2].getFirstKey().value;return new EngineCore.Vector3(n,a,r)}update(n){var i,s,l;if(n<this.curves[0].length){const c=(i=this.curves[0].evaluate(n))!=null?i:0,f=(s=this.curves[1].evaluate(n))!=null?s:0,u=(l=this.curves[2].evaluate(n))!=null?l:0;this._start=this.getStartPosition(),this._current=new EngineCore.Vector3(c,f,u),this._end=this.getEndPosition();return}const a=this.curves[0].getLastKey().value,r=this.curves[1].getLastKey().value,o=this.curves[2].getLastKey().value;this._start=this.getStartPosition(),this._current=new EngineCore.Vector3(a,r,o),this._end=this.getEndPosition()}reset(){}}class AnimationRoadWayNode extends AnimationNode{constructor(){super(...arguments);le(this,"_range",[]);le(this,"_percent",[]);le(this,"_start");le(this,"_end");le(this,"_name","");le(this,"_meshs");le(this,"_colors",[]);le(this,"_type","run")}set percent(n){this._percent=n}get percent(){return this._percent}set start(n){this._start=n}get start(){return this._start}set end(n){this._end=n}get end(){return this._end}set meshs(n){this._meshs=n}get meshs(){return this._meshs}set name(n){this._name=n}get name(){return this._name}set range(n){this._range=n}get range(){return this._range}set colors(n){this._colors=n}get colors(){return this._colors}set type(n){this._type=n}get type(){return this._type}update(n){var a;this._range=[],this._percent=[];for(let r=0;r<this.curves.length;r++){const o=this.curves[r];if(n<o.length){this._range.push((a=o.evaluate(n))!=null?a:0);continue}this._range.push(o.getLastKey().value)}for(let r=0;r<this._range.length;r+=2)this._percent.push({start:this._range[r],end:this._range[r+1]})}reset(){}}class AnimationRoadWayWaterNode extends AnimationNode{constructor(){super(...arguments);le(this,"_range",[]);le(this,"_percent",[]);le(this,"_colorPercent",[]);le(this,"_start");le(this,"_end");le(this,"_name","");le(this,"_meshs");le(this,"_colors",[]);le(this,"_type","run");le(this,"_percentLength",2)}set percent(n){this._percent=n}get percent(){return this._percent}set colorPercent(n){this._colorPercent=n}get colorPercent(){return this._colorPercent}set percentLength(n){this._percentLength=n}get percentLength(){return this._percentLength}set start(n){this._start=n}get start(){return this._start}set end(n){this._end=n}get end(){return this._end}set meshs(n){this._meshs=n}get meshs(){return this._meshs}set name(n){this._name=n}get name(){return this._name}set range(n){this._range=n}get range(){return this._range}set rangeColors(n){this._range=n}get rangeColors(){return this._range}set colors(n){this._colors=n}get colors(){return this._colors}set type(n){this._type=n}get type(){return this._type}update(n){var a;this._range=[],this._percent=[],this._colorPercent=[];for(let r=0;r<this.curves.length;r++){const o=this.curves[r];if(n<o.length){this._range.push((a=o.evaluate(n))!=null?a:0);continue}this._range.push(o.getLastKey().value)}for(let r=0;r<this._percentLength;r+=2)this._percent.push({start:this._range[r],end:this._range[r+1]});for(let r=this._percentLength;r<this._range.length;r+=2)this._colorPercent.push({start:this._range[r],end:this._range[r+1]})}reset(){}}var a0,a1,a2,a3,b1,b2,left_corner,right_corner;function gaussCoef(e){e<.5&&(e=.5);var t=Math.exp(.726*.726)/e,n=Math.exp(-t),a=Math.exp(-2*t),r=(1-n)*(1-n)/(1+2*t*n-a);return a0=r,a1=r*(t-1)*n,a2=r*(t+1)*n,a3=-r*a,b1=2*n,b2=-a,left_corner=(a0+a1)/(1-b1-b2),right_corner=(a2+a3)/(1-b1-b2),new Float32Array([a0,a1,a2,a3,b1,b2,left_corner,right_corner])}function convolveRGBA(e,t,n,a,r,o){var i,s,l,c,f,u,d,h,m,R,v,g,x,y,E,k,b,C,_,A,N,S,I,O,F,w,L,B,D,W;for(F=0;F<o;F++){for(S=F*r,I=F,O=0,i=e[S],s=i&255,l=i>>8&255,c=i>>16&255,f=i>>24&255,C=s*a[6],_=l*a[6],A=c*a[6],N=f*a[6],y=C,E=_,k=A,b=N,L=a[0],B=a[1],D=a[4],W=a[5],w=0;w<r;w++)i=e[S],u=i&255,d=i>>8&255,h=i>>16&255,m=i>>24&255,R=u*L+s*B+y*D+C*W,v=d*L+l*B+E*D+_*W,g=h*L+c*B+k*D+A*W,x=m*L+f*B+b*D+N*W,C=y,_=E,A=k,N=b,y=R,E=v,k=g,b=x,s=u,l=d,c=h,f=m,n[O]=y,n[O+1]=E,n[O+2]=k,n[O+3]=b,O+=4,S++;for(S--,O-=4,I+=o*(r-1),i=e[S],s=i&255,l=i>>8&255,c=i>>16&255,f=i>>24&255,C=s*a[7],_=l*a[7],A=c*a[7],N=f*a[7],y=C,E=_,k=A,b=N,u=s,d=l,h=c,m=f,L=a[2],B=a[3],w=r-1;w>=0;w--)R=u*L+s*B+y*D+C*W,v=d*L+l*B+E*D+_*W,g=h*L+c*B+k*D+A*W,x=m*L+f*B+b*D+N*W,C=y,_=E,A=k,N=b,y=R,E=v,k=g,b=x,s=u,l=d,c=h,f=m,i=e[S],u=i&255,d=i>>8&255,h=i>>16&255,m=i>>24&255,i=(n[O]+y<<0)+(n[O+1]+E<<8)+(n[O+2]+k<<16)+(n[O+3]+b<<24),t[I]=i,S--,O-=4,I-=o}}function blurRGBA(e,t,n,a){if(a){var r=new Uint32Array(e.buffer),o=new Uint32Array(r.length),i=new Float32Array(Math.max(t,n)*4),s=gaussCoef(a);convolveRGBA(r,o,i,s,t,n),convolveRGBA(o,r,i,s,n,t)}}var glur=blurRGBA;const glur$1=getDefaultExportFromCjs(glur),FORCE_WATER_PULL_DOWN=!1;class AnimationWaterEffectNode extends AnimationNode{constructor(){super(...arguments);le(this,"_range",[]);le(this,"_percent",[]);le(this,"_colorPercent",[]);le(this,"_start");le(this,"_end");le(this,"_name","");le(this,"_width",0);le(this,"_height",0);le(this,"_waterHeight",0);le(this,"_waterLength",0);le(this,"_heightMapRaw",new Uint8Array([0,0,0,0]));le(this,"_lastHeightMapRaw",new Uint8Array([0,0,0,0]));le(this,"_bottomShape",[]);le(this,"_percentLength",2);le(this,"_time",0);le(this,"_glurMap",new Uint8Array([0,0,0,0]));le(this,"_startOutWidth",0);le(this,"_endOutWidth",0)}set start(n){this._start=n}get start(){return this._start}set end(n){this._end=n}get end(){return this._end}set name(n){this._name=n}get name(){return this._name}set percent(n){this._percent=n}get percent(){return this._percent}set colorPercent(n){this._colorPercent=n}get colorPercent(){return this._colorPercent}set percentLength(n){this._percentLength=n}get percentLength(){return this._percentLength}set width(n){this._width=n}get width(){return this._width}set height(n){this._height=n}get height(){return this._height}set waterHeight(n){this._waterHeight=n}get waterHeight(){return this._waterHeight}set waterLength(n){this._waterLength=n}get waterLength(){return this._waterLength}set time(n){this._time=n}get time(){return this._time}set startOutWidth(n){this._startOutWidth=n}get startOutWidth(){return this._startOutWidth}set endOutWidth(n){this._endOutWidth=n}get endOutWidth(){return this._endOutWidth}get center(){return EngineCore.Vector3.Center(this._start||EngineCore.Vector3.Zero(),this._end||EngineCore.Vector3.Zero())}equalArray(n,a){if(n.byteLength!=a.byteLength)return!1;const r=new Uint8Array(n),o=new Uint8Array(a);for(let i=0;i!=n.byteLength;i++)if(r[i]!=o[i])return!1;return!0}generateHeightMap(){const n=Math.floor(this._waterLength);if(n>0){let a=n;FORCE_WATER_PULL_DOWN&&(a+=2);const r=new Uint8Array(a*4);for(let o=0;o<r.length;o++){const i=o*4;r[i]=0,r[i+1]=0,r[i+2]=0,r[i+3]=0}this._heightMapRaw=r}}get bottomShape(){return this._bottomShape}set bottomShape(n){this._bottomShape=n}updateHeightMapByPercent(n,a,r){const o=this._heightMapRaw;let i=0;FORCE_WATER_PULL_DOWN&&(i=1);const s=i+Math.floor(n*this._waterLength),l=i+Math.floor(a*this._waterLength);for(let c=s;c<l;c++){const f=c*4;o[f]=Math.trunc(r*255),o[f+1]=Math.trunc(r*255),o[f+2]=Math.trunc(r*255),o[f+3]=Math.trunc(r*255)}this._heightMapRaw=o}get glurHeightMap(){return this._glurMap}update(n){var a;this._range=[],this._percent=[],this._colorPercent=[];for(let r=0;r<this.curves.length;r++){const o=this.curves[r];if(n<o.length){this._range.push((a=o.evaluate(n))!=null?a:0);continue}this._range.push(o.getLastKey().value)}for(let r=0;r<this._percentLength;r+=2){const o=this._range[r],i=this._range[r+1],s=Math.min(o,i),l=Math.max(o,i);s!=l&&this.updateHeightMapByPercent(s,l,.5)}for(let r=this._percentLength;r<this._range.length;r+=2){const o=this._range[r],i=this._range[r+1],s=Math.min(o,i),l=Math.max(o,i);s!=l&&this.updateHeightMapByPercent(s,l,1)}if(!this.equalArray(this._heightMapRaw,this._lastHeightMapRaw)){if(this.time=n,this._heightMapRaw.length===0)return new Uint8Array([0,0,0,0]);const r=new Uint8Array(this._heightMapRaw);let o=this._waterLength;FORCE_WATER_PULL_DOWN&&(o+=2),glur$1(r,1,o,5),FORCE_WATER_PULL_DOWN&&(r[0]=0,r[1]=0,r[2]=0,r[3]=0,r[r.length-4]=0,r[r.length-3]=0,r[r.length-2]=0,r[r.length-1]=0),this._lastHeightMapRaw=this._heightMapRaw.slice(0),this._glurMap=r}}reset(){}cross(n,a,r){return(a.x-n.x)*(r.y-n.y)-(a.y-n.y)*(r.x-n.x)}convexHull(n){n.sort((o,i)=>o.x===i.x?o.y-i.y:o.x-i.x);const a=[];for(const o of n){for(;a.length>=2&&this.cross(a[a.length-2],a[a.length-1],o)<=0;)a.pop();a.push(o)}const r=[];for(let o=n.length-1;o>=0;o--){const i=n[o];for(;r.length>=2&&this.cross(r[r.length-2],r[r.length-1],i)<=0;)r.pop();r.push(i)}return a.pop(),r.pop(),a.concat(r)}}const buildRoadWayAnimation=e=>{const t=RoadWayAnim.decode(new Uint8Array(e)),n=[];console.log(t);const a=[];for(let r=0;r<t.frames.length;r++)for(let o=0;o<t.frames[r].node.length;o++){const i=t.frames[r].node[o];a.findIndex(l=>l===i.name)===-1&&a.push(i.name)}for(let r=0;r<a.length;r++){const o=[],i=t.frames[0].node[0].percent.length,s=t.frames[0].node[0].colorPercent.length;for(let f=0;f<(i+s)*2;f++)o.push(new AnimationCurve);let l=0;for(let f=0;f<t.frames.length;f++){const u=t.frames[f],d=u.node.findIndex(h=>h.name===a[r]);if(d!==-1){for(let h=0;h<i;h++){const m=new AnimationKeyFrame(u.time*1e3,u.node[d].percent[h].start),R=new AnimationKeyFrame(u.time*1e3,u.node[d].percent[h].end);o[h*2].addKey(m),o[h*2+1].addKey(R)}for(let h=0;h<s;h++){const m=new AnimationKeyFrame(u.time*1e3,u.node[d].colorPercent[h].start),R=new AnimationKeyFrame(u.time*1e3,u.node[d].colorPercent[h].end);o[i*2+h*2].addKey(m),o[i*2+h*2+1].addKey(R)}l=u.node[d].index}}const c=t.animType===RoadWayAnim_AnimType.WATER?new AnimationRoadWayWaterNode(o):new AnimationRoadWayNode(o);c.meshs=[t.boxes[l].topMesh,t.boxes[l].bottomMesh,t.boxes[l].sideMesh],c.name=a[r],c.start=convertVertexToVector3(t.boxes[l].startPosition),c.end=convertVertexToVector3(t.boxes[l].endPosition),c.type=t.animType===RoadWayAnim_AnimType.RUN?"run":"water",c.colors=t.colors.map(f=>convertColorToColor3(f)),t.animType===RoadWayAnim_AnimType.WATER&&(c.percentLength=i*2);for(let f=0;f<c.curves.length;f++)if(c.curves[f].keys[0].time!==0){const u=c.curves[f].keys[0],d=new AnimationKeyFrame(0,u.value);d.time=0,c.curves[f].keys.unshift(d)}n.push(c)}return n},buildRoadWayNearAnimation=e=>{const t=RoadWayNearAnim.decode(new Uint8Array(e)),n=[];console.log(t);const a=[];for(let r=0;r<t.frames.length;r++)for(let o=0;o<t.frames[r].nodes.length;o++){const i=t.frames[r].nodes[o];a.findIndex(l=>l===i.name)===-1&&a.push(i.name)}for(let r=0;r<a.length;r++){const o=[];o.push(new AnimationCurve),o.push(new AnimationCurve),o.push(new AnimationCurve);for(let s=0;s<t.frames.length;s++){const l=t.frames[s],c=l.nodes.findIndex(f=>f.name===a[r]);if(c!==-1){const f=new AnimationKeyFrame(l.time*1e3,l.nodes[c].position.x),u=new AnimationKeyFrame(l.time*1e3,l.nodes[c].position.y),d=new AnimationKeyFrame(l.time*1e3,l.nodes[c].position.z);o[0].addKey(f),o[1].addKey(u),o[2].addKey(d)}}const i=new AnimationRoadWayNearNode(o);i.name=a[r],i.url=t.url;for(let s=0;s<i.curves.length;s++)if(i.curves[s].keys[0].time!==0){const l=i.curves[s].keys[0],c=new AnimationKeyFrame(0,l.value);c.time=0,i.curves[s].keys.unshift(c)}n.push(i)}return n},buildWaterEffectAnimation=e=>{const t=RoadWayNearFlowAnim.decode(new Uint8Array(e)),n=[];console.log(t);for(let a=0;a<t.nodes.length;a++){const r=[],o=t.nodes[0].frames[0].percent.length,i=t.nodes[0].frames[0].colorPercent.length;for(let m=0;m<(o+i)*2;m++)r.push(new AnimationCurve);for(let m=0;m<t.nodes[a].frames.length;m++){const R=t.nodes[a].frames[m];if("percent"in R&&"colorPercent"in R){for(let v=0;v<o;v++){const g=new AnimationKeyFrame(R.time*1e3,R.percent[v].start),x=new AnimationKeyFrame(R.time*1e3,R.percent[v].end);r[v*2].addKey(g),r[v*2+1].addKey(x)}for(let v=0;v<i;v++){const g=new AnimationKeyFrame(R.time*1e3,R.colorPercent[v].start),x=new AnimationKeyFrame(R.time*1e3,R.colorPercent[v].end);r[o*2+v*2].addKey(g),r[o*2+v*2+1].addKey(x)}}else console.error("[Geo3DViewer] 数据中缺少 percent 或 colorPercent ",t.nodes[a],R)}const s=t.nodes[a].index,l=new AnimationWaterEffectNode(r);l.name=t.nodes[a].name,l.start=convertVertexToVector3(t.boxes[s].startPosition),l.end=convertVertexToVector3(t.boxes[s].endPosition),l.startOutWidth=t.boxes[s].startOutWidth||0,l.endOutWidth=t.boxes[s].endOutWidth||0,l.waterHeight=.5,l.width=t.boxes[s].width||3.5,l.waterLength=EngineCore.Vector3.Distance(l.start,l.end)+.05+l.startOutWidth+l.endOutWidth,l.generateHeightMap();const c=[];for(let m=0;m<t.boxes[s].bottomMesh.vertices.length;m+=3)c.push(new EngineCore.Vector3(t.boxes[s].bottomMesh.vertices[m],t.boxes[s].bottomMesh.vertices[m+1],t.boxes[s].bottomMesh.vertices[m+2]));const f=new EngineCore.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),u=new EngineCore.Vector3(Number.MIN_VALUE,Number.MIN_VALUE,Number.MIN_VALUE);c.forEach(m=>{m.x<f.x&&(f.x=m.x),m.y<f.y&&(f.y=m.y),m.z<f.z&&(f.z=m.z),m.x>u.x&&(u.x=m.x),m.y>u.y&&(u.y=m.y),m.z>u.z&&(u.z=m.z)});const d=[];t.boxes[s].bottomMesh.indices.forEach(m=>{d.push(c[m].subtract(f).multiplyByFloats(1/(u.x-f.x),1/(u.y-f.y),1/(u.z-f.z)))});const h=[];for(let m=0;m<d.length;m+=3)h.push([d[m],d[m+1],d[m+2]]);l.bottomShape=h,l.height=t.boxes[s].height||t.boxes[s].topMesh.vertices[1]-t.boxes[s].bottomMesh.vertices[1],l.percentLength=o*2,console.log("[Geo3DViewer] 正在构建动画 ",l);for(let m=0;m<l.curves.length;m++)if(l.curves[m].keys[0].time!==0){const R=l.curves[m].keys[0],v=new AnimationKeyFrame(0,R.value);v.time=0,l.curves[m].keys.unshift(v)}n.push(l)}return n},Animation=e=>{const{name:t,children:n,url:a,type:r="roadway",speed:o=1}=e,i=React.useRef(null),[s,l]=React.useState(),c=React.useRef(!1),f=useCachedBinary({url:a,cacheType:CacheType.URL_PREFIX_MATCH}),u=(d,h)=>{let m=[];switch(d){case"roadway":m=buildRoadWayAnimation(h);break;case"roadwaynear":m=buildRoadWayNearAnimation(h);break;case"water":m=buildWaterEffectAnimation(h);break;default:m=buildRoadWayAnimation(h)}return m};return React.useEffect(()=>{if(f&&!c.current){c.current=!0;const d=u(r,f);console.log(d);const h=new SimpleAnimationController(t);h.nodes=d,i.current=h,i.current.speed=o,i.current.play(),c.current=!1}},[f,t,o,r]),React.useEffect(()=>()=>{i.current&&!c.current&&(console.log("destory animation!"),i.current.onDestory())},[]),React.useEffect(()=>{const d=setInterval(()=>{i.current&&i.current.normalized>0&&l({nodes:i.current.nodes})},100);return()=>{clearInterval(d)}},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:s&&React.isValidElement(n)?React.cloneElement(n,{nodes:s==null?void 0:s.nodes,speed:o}):n})},Animation$1=Animation;function createBaseVirtualVolume(){return{name:"",vMin:0,vMax:0,xMin:0,yMin:0,xMax:0,yMax:0,zMin:0,zMax:0,points:[],indices:[],value:[],center:void 0}}const VirtualVolume={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.vMin!==0&&t.uint32(21).float(e.vMin),e.vMax!==0&&t.uint32(29).float(e.vMax),e.xMin!==0&&t.uint32(37).float(e.xMin),e.yMin!==0&&t.uint32(45).float(e.yMin),e.xMax!==0&&t.uint32(53).float(e.xMax),e.yMax!==0&&t.uint32(61).float(e.yMax),e.zMin!==0&&t.uint32(69).float(e.zMin),e.zMax!==0&&t.uint32(77).float(e.zMax),t.uint32(90).fork();for(const n of e.points)t.float(n);t.ldelim(),t.uint32(98).fork();for(const n of e.indices)t.int32(n);t.ldelim(),t.uint32(106).fork();for(const n of e.value)t.float(n);return t.ldelim(),e.center!==void 0&&Vertex.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseVirtualVolume();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==21)break;r.vMin=n.float();continue;case 3:if(o!==29)break;r.vMax=n.float();continue;case 4:if(o!==37)break;r.xMin=n.float();continue;case 5:if(o!==45)break;r.yMin=n.float();continue;case 6:if(o!==53)break;r.xMax=n.float();continue;case 7:if(o!==61)break;r.yMax=n.float();continue;case 8:if(o!==69)break;r.zMin=n.float();continue;case 9:if(o!==77)break;r.zMax=n.float();continue;case 11:if(o===93){r.points.push(n.float());continue}if(o===90){const i=n.uint32()+n.pos;for(;n.pos<i;)r.points.push(n.float());continue}break;case 12:if(o===96){r.indices.push(n.int32());continue}if(o===98){const i=n.uint32()+n.pos;for(;n.pos<i;)r.indices.push(n.int32());continue}break;case 13:if(o===109){r.value.push(n.float());continue}if(o===106){const i=n.uint32()+n.pos;for(;n.pos<i;)r.value.push(n.float());continue}break;case 31:if(o!==250)break;r.center=Vertex.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$c(e.name)?globalThis.String(e.name):"",vMin:isSet$c(e.vMin)?globalThis.Number(e.vMin):0,vMax:isSet$c(e.vMax)?globalThis.Number(e.vMax):0,xMin:isSet$c(e.xMin)?globalThis.Number(e.xMin):0,yMin:isSet$c(e.yMin)?globalThis.Number(e.yMin):0,xMax:isSet$c(e.xMax)?globalThis.Number(e.xMax):0,yMax:isSet$c(e.yMax)?globalThis.Number(e.yMax):0,zMin:isSet$c(e.zMin)?globalThis.Number(e.zMin):0,zMax:isSet$c(e.zMax)?globalThis.Number(e.zMax):0,points:globalThis.Array.isArray(e==null?void 0:e.points)?e.points.map(t=>globalThis.Number(t)):[],indices:globalThis.Array.isArray(e==null?void 0:e.indices)?e.indices.map(t=>globalThis.Number(t)):[],value:globalThis.Array.isArray(e==null?void 0:e.value)?e.value.map(t=>globalThis.Number(t)):[],center:isSet$c(e.center)?Vertex.fromJSON(e.center):void 0}},toJSON(e){var n,a,r;const t={};return e.name!==""&&(t.name=e.name),e.vMin!==0&&(t.vMin=e.vMin),e.vMax!==0&&(t.vMax=e.vMax),e.xMin!==0&&(t.xMin=e.xMin),e.yMin!==0&&(t.yMin=e.yMin),e.xMax!==0&&(t.xMax=e.xMax),e.yMax!==0&&(t.yMax=e.yMax),e.zMin!==0&&(t.zMin=e.zMin),e.zMax!==0&&(t.zMax=e.zMax),(n=e.points)!=null&&n.length&&(t.points=e.points),(a=e.indices)!=null&&a.length&&(t.indices=e.indices.map(o=>Math.round(o))),(r=e.value)!=null&&r.length&&(t.value=e.value),e.center!==void 0&&(t.center=Vertex.toJSON(e.center)),t},create(e){return VirtualVolume.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l,c,f,u,d,h;const t=createBaseVirtualVolume();return t.name=(n=e.name)!=null?n:"",t.vMin=(a=e.vMin)!=null?a:0,t.vMax=(r=e.vMax)!=null?r:0,t.xMin=(o=e.xMin)!=null?o:0,t.yMin=(i=e.yMin)!=null?i:0,t.xMax=(s=e.xMax)!=null?s:0,t.yMax=(l=e.yMax)!=null?l:0,t.zMin=(c=e.zMin)!=null?c:0,t.zMax=(f=e.zMax)!=null?f:0,t.points=((u=e.points)==null?void 0:u.map(m=>m))||[],t.indices=((d=e.indices)==null?void 0:d.map(m=>m))||[],t.value=((h=e.value)==null?void 0:h.map(m=>m))||[],t.center=e.center!==void 0&&e.center!==null?Vertex.fromPartial(e.center):void 0,t}};function isSet$c(e){return e!=null}const CustomShader=(e,t)=>{const n=React.useRef(null),{name:a,vertex:r,fragment:o,needDepthPrePass:i=!1,backFaceCulling:s,transparencyMode:l=EngineCore.Material.MATERIAL_OPAQUE,alphaMode:c=EngineCore.Engine.ALPHA_COMBINE,alpha:f=1,options:u,zOffset:d=1,zOffsetUnits:h,disableDepthWrite:m=!1,clipPlane:R,depthFunction:v,sideOrientation:g=EngineCore.Material.ClockWiseSideOrientation}=e;return React.useImperativeHandle(t,()=>n.current,[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("shaderMaterial",{ref:n,name:`${a}-material`,sideOrientation:g,needDepthPrePass:i,backFaceCulling:s,transparencyMode:l,alphaMode:c,depthFunction:v,alpha:f,shaderPath:{vertexSource:r,fragmentSource:o},options:u,zOffset:d,zOffsetUnits:h,clipPlane:R,disableDepthWrite:m})})},CustomShader$1=React.forwardRef(CustomShader),terrainFragmentSource=`#ifdef GL_ES
|
|
2
2
|
precision highp float;
|
|
3
3
|
#endif
|
|
4
4
|
|
|
@@ -159,7 +159,7 @@ void main(void) {
|
|
|
159
159
|
overlayCoord = vec2(normalizedCoord.y, 1.0 - normalizedCoord.x);
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
}`,DiffuseTerrainMaterial=e=>{const t=reactBabylonjs.useScene(),[n,a]=React.useState(null),r=React.useRef(null),{boundingBox:o,counterLine:i,scaleDepth:s=1,scalePlane:l=1,color:c,alpha:f=1,lines:u=[],text:d=[],surfaceCanvasOptions:h={textureIncludeSide:!0},disableDepthWrite:m,lightPosition:R=new EngineCore.Vector3(0,3e5,1e5),intensity:v=1,contrast:g=3,sideIntensity:x=.3,cullFace:y=0,zOffset:E,zOffsetUnits:k}=e,{textureIncludeSide:b}=h;return React.useEffect(()=>{r.current&&(console.log("[Geo3DViewer] 设置材质 ",c,f),r.current.setColor3("color",c),r.current.setFloat("alpha",f),r.current.setFloat("textureIncludeSide",b==null?1:0),r.current.setFloat("intensity",v),r.current.setVector3("lightPosition",R),r.current.setFloat("contrast",g),r.current.setFloat("sideIntensity",x),r.current.setFloat("cullFace",y),E!==void 0&&k!==void 0&&(r.current.zOffset=E,r.current.zOffsetUnits=k))},[c,f,b,v,R,E,k,g,x,y]),React.useEffect(()=>{var _;const C=r.current;if(C&&o)if(i){const A=(_=i.startHeight)!=null?_:o.maximumWorld.y/s;return C.setFloat("contourLineStartHeight",A*s),C.setColor3("contourLineColor",i.color),C.setFloat("contourLineWidth",i.width),C.setFloat("contourLineStep",i.stepHeight*s),console.log("[Geo3DViewer] 等高线设置 ",i,o.centerWorld.y,A*s,A*s-16*i.stepHeight*s),()=>{C&&(C.setFloat("contourLineStartHeight",0),C.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),C.setFloat("contourLineWidth",0),C.setFloat("contourLineStep",0))}}else C.setFloat("contourLineStartHeight",0),C.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),C.setFloat("contourLineWidth",0),C.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[o,i,s,l]),React.useEffect(()=>{const C=r.current;t&&o&&C&&a(_=>{let A=(o.maximum.x-o.minimum.x)/l,N=(o.maximum.z-o.minimum.z)/l,S=0;if(A<N){const F=A;A=N,N=F,S=1}const I=A/N;A*N>2048*2048&&(A=2048,N=2048/I);let O;return _?(_.scaleTo(A,N),_.update(),O=_):O=new EngineCore.DynamicTexture("dynamic-texture",{width:A,height:N},t,!1),O.clear(),O.update(),console.log("[Geo3DViewer] 设置动态划线 ",o,A,N,l),C.setVector3("oMin",o.minimum),C.setVector3("oMax",o.maximum),C.setFloat("textureOverlayRotate",S),C.setTexture("textureOverlaySampler",O),O})},[o,l,t]),React.useEffect(()=>{if(n&&o&&(u.length>0||d.length>0)){n.clear();let C=(o.maximum.x-o.minimum.x)/l,_=(o.maximum.z-o.minimum.z)/l;if(C<_){const S=C;C=_,_=S}const A=C/_;C*_>2048*2048&&(C=2048,_=2048/A);const N=n.getContext();u.forEach(S=>{if(S.points.length<2)return;N.beginPath();const I=S.offset?S.offset:new EngineCore.Vector2(0,0),O=1-S.points[0].x+I.x,F=1-S.points[0].y+I.y;N.moveTo(O*C,F*_);for(let
|
|
162
|
+
}`,DiffuseTerrainMaterial=e=>{const t=reactBabylonjs.useScene(),[n,a]=React.useState(null),r=React.useRef(null),{boundingBox:o,counterLine:i,scaleDepth:s=1,scalePlane:l=1,color:c,alpha:f=1,lines:u=[],text:d=[],surfaceCanvasOptions:h={textureIncludeSide:!0},disableDepthWrite:m,lightPosition:R=new EngineCore.Vector3(0,3e5,1e5),intensity:v=1,contrast:g=3,sideIntensity:x=.3,cullFace:y=0,zOffset:E,zOffsetUnits:k}=e,{textureIncludeSide:b}=h;return React.useEffect(()=>{r.current&&(console.log("[Geo3DViewer] 设置材质 ",c,f),r.current.setColor3("color",c),r.current.setFloat("alpha",f),r.current.setFloat("textureIncludeSide",b==null?1:0),r.current.setFloat("intensity",v),r.current.setVector3("lightPosition",R),r.current.setFloat("contrast",g),r.current.setFloat("sideIntensity",x),r.current.setFloat("cullFace",y),E!==void 0&&k!==void 0&&(r.current.zOffset=E,r.current.zOffsetUnits=k))},[c,f,b,v,R,E,k,g,x,y]),React.useEffect(()=>{var _;const C=r.current;if(C&&o)if(i){const A=(_=i.startHeight)!=null?_:o.maximumWorld.y/s;return C.setFloat("contourLineStartHeight",A*s),C.setColor3("contourLineColor",i.color),C.setFloat("contourLineWidth",i.width),C.setFloat("contourLineStep",i.stepHeight*s),console.log("[Geo3DViewer] 等高线设置 ",i,o.centerWorld.y,A*s,A*s-16*i.stepHeight*s),()=>{C&&(C.setFloat("contourLineStartHeight",0),C.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),C.setFloat("contourLineWidth",0),C.setFloat("contourLineStep",0))}}else C.setFloat("contourLineStartHeight",0),C.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),C.setFloat("contourLineWidth",0),C.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[o,i,s,l]),React.useEffect(()=>{const C=r.current;t&&o&&C&&a(_=>{let A=(o.maximum.x-o.minimum.x)/l,N=(o.maximum.z-o.minimum.z)/l,S=0;if(A<N){const F=A;A=N,N=F,S=1}const I=A/N;A*N>2048*2048&&(A=2048,N=2048/I);let O;return _?(_.scaleTo(A,N),_.update(),O=_):O=new EngineCore.DynamicTexture("dynamic-texture",{width:A,height:N},t,!1),O.clear(),O.update(),console.log("[Geo3DViewer] 设置动态划线 ",o,A,N,l),C.setVector3("oMin",o.minimum),C.setVector3("oMax",o.maximum),C.setFloat("textureOverlayRotate",S),C.setTexture("textureOverlaySampler",O),O})},[o,l,t]),React.useEffect(()=>{if(n&&o&&(u.length>0||d.length>0)){n.clear();let C=(o.maximum.x-o.minimum.x)/l,_=(o.maximum.z-o.minimum.z)/l;if(C<_){const S=C;C=_,_=S}const A=C/_;C*_>2048*2048&&(C=2048,_=2048/A);const N=n.getContext();u.forEach(S=>{if(S.points.length<2)return;N.beginPath();const I=S.offset?S.offset:new EngineCore.Vector2(0,0),O=1-S.points[0].x+I.x,F=1-S.points[0].y+I.y;N.moveTo(O*C,F*_);for(let w=1;w<S.points.length;w++){const L=S.offset?S.offset:new EngineCore.Vector2(0,0),B=1-S.points[w].x+L.x,D=1-S.points[w].y+L.y;N.lineTo(B*C,D*_)}N.strokeStyle=`rgb(${S.color.r*255}, ${S.color.g*255}, ${S.color.b*255})`,C*_>2048*2048?N.lineWidth=S.width/A:N.lineWidth=S.width,N.stroke()}),d.forEach(S=>{var w,L;N.font=`${S.fontSize}px Arial`;const I=(w=S.color)!=null?w:EngineCore.Color3.White(),O=S.offset?S.offset:new EngineCore.Vector2(0,0),F=(L=S.rotation)!=null?L:0;if(N.save(),N.translate((1-S.position.x+O.x)*C,(1-S.position.y+O.y)*_),N.rotate(F),S.clearArea){const B=N.measureText(S.text);N.clearRect(-B.width*.15,.5*S.fontSize*(1-.3),B.width*1.3,-S.fontSize*1.3)}if(S.background){N.fillStyle=`rgba(${S.background.r*255}, ${S.background.g*255}, ${S.background.b*255})`;const B=N.measureText(S.text);N.fillRect(-B.width*.05,.5*(S.fontSize*(.5-.1)),B.width*1.1,-S.fontSize*1.1)}N.fillStyle=`rgb(${I.r*255}, ${I.g*255}, ${I.b*255})`,N.fillText(S.text,0,0),N.restore()}),n.update()}},[u,n,o,l,d]),jsxRuntime.jsx(CustomShader$1,{ref:r,name:e.name,backFaceCulling:e.backFaceCulling,needDepthPrePass:e.needDepthPrePass,vertex:terrainVertexSource,fragment:terrainFragmentSource,transparencyMode:e.transparencyMode,alphaMode:e.alphaMode,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","alpha","color","contourLineStartHeight","contourLineColor","contourLineWidth","contourLineStep","oMin","oMax","textureOverlayRotate","textureIncludeSide","contrast","lightPosition","intensity","sideIntensity","cullFace"],samplers:["textureOverlaySampler"],needAlphaBlending:!0,needAlphaTesting:!0},zOffset:e.zOffset,zOffsetUnits:e.zOffsetUnits,disableDepthWrite:m})},DiffuseTerrainMaterial$1=DiffuseTerrainMaterial,flatFragmentSource=`#version 300 es
|
|
163
163
|
precision highp float;
|
|
164
164
|
|
|
165
165
|
in vec2 vUV;
|
|
@@ -1190,7 +1190,7 @@ vPositionW = vec3(worldPos);
|
|
|
1190
1190
|
|
|
1191
1191
|
#define CUSTOM_VERTEX_MAIN_END
|
|
1192
1192
|
vColor = vec4(instanceColor.rgb, instanceColor.a);
|
|
1193
|
-
}`,LightMetalMaterial=({alpha:e,zOffset:t,zOffsetUnits:n,disableDepthWrite:a})=>jsxRuntime.jsx("pbrMaterial",{name:"metal-pbr-material",alpha:e,transparencyMode:e!==void 0&&e<1?EngineCore.Material.MATERIAL_ALPHABLEND:EngineCore.Material.MATERIAL_OPAQUE,alphaMode:EngineCore.Engine.ALPHA_COMBINE,roughness:.25,metallic:1,albedoColor:new EngineCore.Color3(.7,.7,.7),metallicF0Factor:.1,zOffset:t,zOffsetUnits:n,disableDepthWrite:a}),DarkMetalMaterial=({alpha:e,zOffset:t,zOffsetUnits:n,disableDepthWrite:a})=>jsxRuntime.jsx("pbrMaterial",{name:"metal-pbr-material",alpha:e,transparencyMode:e!==void 0&&e<1?EngineCore.Material.MATERIAL_ALPHABLEND:EngineCore.Material.MATERIAL_OPAQUE,alphaMode:EngineCore.Engine.ALPHA_COMBINE,roughness:.25,metallic:1,albedoColor:new EngineCore.Color3(.2,.2,.2),metallicF0Factor:.1,zOffsetUnits:n,zOffset:t,disableDepthWrite:a});var RepeatedTextureMode=(e=>(e[e.TRIGONOMETRIC=0]="TRIGONOMETRIC",e[e.PLANE=1]="PLANE",e[e.FLAT=2]="FLAT",e))(RepeatedTextureMode||{});const RepeatedTextureMaterial=e=>{const t=reactBabylonjs.useScene(),[n,a]=React.useState(null),[r,o]=React.useState(null),{tilingFactor:i=.1,sideTilingFactor:s=.1,texture:l,alpha:c=1,mode:f=0,zOffset:u,zOffsetUnits:d,sideTexture:h,uvOffset:m=EngineCore.Vector2.Zero(),counterLine:R=void 0,scalePlane:v=1,scaleDepth:g=1,boundingBox:x=void 0,lines:y=[],text:E=[],disableDepthWrite:k,flatModeRotate:b=0}=e,C=_=>{a(_)};return React.useEffect(()=>{n&&l&&(n.setTexture("textureSampler",l),n.setFloat("textureFlatRotate",b),n.setVector2("uvOffset",m))},[b,n,l,m]),React.useEffect(()=>{n&&n.setFloat("alpha",c)},[c,n]),React.useEffect(()=>{n&&n.setFloat("tilingFactor",i),n&&n.setFloat("sideTilingFactor",s)},[i,s,n]),React.useEffect(()=>{n&&n.setInt("mode",f)},[n,f]),React.useEffect(()=>{n&&(h?n.setTexture("textureSideSampler",h):n.setTexture("textureSideSampler",l))},[n,h,l]),React.useEffect(()=>{var _;if(n)if(R&&x){const A=(_=R.startHeight)!=null?_:x.minimumWorld.y/g;return n.setFloat("contourLineStartHeight",A*g),n.setColor3("contourLineColor",R.color),n.setFloat("contourLineWidth",R.width),n.setFloat("contourLineStep",R.stepHeight*g),console.log("[Geo3DViewer] 等高线设置 ",R,x.centerWorld.y,A*g,A*g+16*R.stepHeight*g),()=>{n&&(n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0))}}else n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[R,g,v,x,n]),React.useEffect(()=>{t&&n&&x&&o(_=>{_&&_.dispose();let A=(x.maximum.x-x.minimum.x)/v,N=(x.maximum.z-x.minimum.z)/v,S=0;if(A<N){const F=A;A=N,N=F,S=1}const I=A/N;A*N>2048*2048&&(A=2048,N=2048/I);const O=new EngineCore.DynamicTexture("dynamic-texture",{width:A,height:N},t,!1);return O.clear(),console.log("[Geo3DViewer] 设置动态划线 ",x,A,N,v),n.setVector3("oMin",x.minimum),n.setVector3("oMax",x.maximum),n.setFloat("textureOverlayRotate",S),n.setTexture("textureOverlaySampler",O),O})},[x,n,v,t]),React.useEffect(()=>{var _;if(r&&x)if((_=r.getScene())!=null&&_.getEngine()){r.clear();let A=(x.maximum.x-x.minimum.x)/v,N=(x.maximum.z-x.minimum.z)/v;if(A<N){const O=A;A=N,N=O}const S=A/N;A*N>2048*2048&&(A=2048,N=2048/S);const I=r.getContext();y.forEach(O=>{if(O.points.length<2)return;I.beginPath();const F=O.offset?O.offset:new EngineCore.Vector2(0,0),L=1-O.points[0].x+F.x,w=1-O.points[0].y+F.y;I.moveTo(L*A,w*N);for(let B=1;B<O.points.length;B++){const D=O.offset?O.offset:new EngineCore.Vector2(0,0),W=1-O.points[B].x+D.x,ae=1-O.points[B].y+D.y;I.lineTo(W*A,ae*N)}I.strokeStyle=`rgb(${O.color.r*255}, ${O.color.g*255}, ${O.color.b*255})`,A*N>2048*2048?I.lineWidth=O.width/S:I.lineWidth=O.width,I.stroke()}),E.forEach(O=>{var B,D;I.font=`${O.fontSize}px Arial`;const F=(B=O.color)!=null?B:EngineCore.Color3.White(),L=O.offset?O.offset:new EngineCore.Vector2(0,0),w=(D=O.rotation)!=null?D:0;if(I.save(),I.translate((1-O.position.x+L.x)*A,(1-O.position.y+L.y)*N),I.rotate(w),O.clearArea){const W=I.measureText(O.text);I.clearRect(-W.width*.15,.5*O.fontSize*(1-.3),W.width*1.3,-O.fontSize*1.3)}if(O.background){I.fillStyle=`rgba(${O.background.r*255}, ${O.background.g*255}, ${O.background.b*255})`;const W=I.measureText(O.text);I.fillRect(-W.width*.05,.5*(O.fontSize*(.5-.1)),W.width*1.1,-O.fontSize*1.1)}I.fillStyle=`rgb(${F.r*255}, ${F.g*255}, ${F.b*255})`,I.fillText(O.text,0,0),I.restore()}),r.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[y,E,r,x,v]),jsxRuntime.jsx(CustomShader$1,{...e,ref:C,vertex:repeatedTextureVertexSource,fragment:repeatedTextureFragmentSource,options:{attributes:["position","color","alpha","normal"],uniforms:["worldViewProjection","tilingFactor","sideTilingFactor","mode","uvOffset","contourLineStartHeight","contourLineColor","contourLineWidth","contourLineStep","oMin","oMax","textureOverlayRotate","textureFlatRotate"],samplers:["textureSampler","textureOverlaySampler","textureSideSampler"],needAlphaBlending:!0,needAlphaTesting:!0},zOffset:u,zOffsetUnits:d,disableDepthWrite:k})},RemapColorByRedChannelMaterial=e=>{const t=reactBabylonjs.useScene(),n=React.useRef(null),a=React.useContext(ColorCodecImageContext),[r,o]=React.useState(null),{name:i,colorCodec:s,alpha:l=1,backFaceCulling:c,needDepthPrePass:f=!1,transparencyMode:u=EngineCore.Material.MATERIAL_OPAQUE,alphaMode:d=EngineCore.Engine.ALPHA_COMBINE,zOffset:h,zOffsetUnits:m,clipPlane:R,counterLine:v=void 0,scalePlane:g=1,scaleDepth:x=1,boundingBox:y,lines:E=[],text:k=[],disableDepthWrite:b}=e;return React.useEffect(()=>{const C=n.current;C&&t&&(C.loadFromSerialization(remapNodeMaterialSource,""),C.build(!1,!0,!1))},[t]),React.useEffect(()=>{const C=n.current;C&&(C.name=`${i}-material`,C.backFaceCulling=c!=null?c:!0,C.needDepthPrePass=f,C.transparencyMode=u,C.alphaMode=d,C.alpha=l,C.zOffset=h!=null?h:1,C.zOffsetUnits=m!=null?m:0,C.clipPlane=R!=null?R:null,C.disableDepthWrite=b!=null?b:!1)},[l,d,c,R,b,i,f,u,h,m]),React.useEffect(()=>{if(s){const C=n.current;C&&(C.metadata={colorCodec:s},EngineCore.Tags.EnableFor(C),EngineCore.Tags.AddTagsTo(C,"remap"))}if(s&&a&&t&&a.colorCodecsImage.current[s]){const C=n.current;if(C){const _=C.getBlockByName("RemappedTexture");_&&(_.texture=a.colorCodecsImage.current[s].texture,C.markAsDirty(EngineCore.NodeMaterial.TextureDirtyFlag))}}},[s,t]),React.useEffect(()=>{n.current&&t&&(console.log("[Geo3DViewer] RemapColorByRedChannel 透明度更新 ",l),n.current.alpha=l)},[t,l]),React.useEffect(()=>{var _;const C=n.current;if(C){const A=C.getBlockByName("contourLineStartHeight"),N=C.getBlockByName("contourLineColor"),S=C.getBlockByName("contourLineWidth"),I=C.getBlockByName("contourLineStep");if(v&&y){const O=(_=v.startHeight)!=null?_:y.centerWorld.y/x;return A&&(A.value=O*x),N&&(N.value=v.color),S&&(S.value=v.width),I&&(I.value=v.stepHeight*x),console.log("[Geo3DViewer] 等高线设置 ",v,y.centerWorld,y.centerWorld.y,O*x,O*x+16*v.stepHeight*x),()=>{C&&(A&&(A.value=0),N&&(N.value=new EngineCore.Color3(0,0,0)),S&&(S.value=0),I&&(I.value=0))}}else A&&(A.value=0),N&&(N.value=new EngineCore.Color3(0,0,0)),S&&(S.value=0),I&&(I.value=0),console.log("[Geo3DViewer] 等高线设置 关闭");C.markAsDirty(EngineCore.NodeMaterial.MiscDirtyFlag)}},[v,x,g,y]),React.useEffect(()=>{t&&y&&o(C=>{var L,w;C&&C.dispose();let _=(y.maximum.x-y.minimum.x)/g,A=(y.maximum.z-y.minimum.z)/g,N=0;if(_<A){const B=_;_=A,A=B,N=1}const S=_/A;_*A>2048*2048&&(_=2048,A=2048/S);const I=new EngineCore.DynamicTexture("dynamic-texture",{width:_,height:A},t,!1);I.clear(),console.log("[Geo3DViewer] 设置动态划线 ",y,_,A,g);const O=(L=n.current)==null?void 0:L.getBlockByName("angle"),F=(w=n.current)==null?void 0:w.getBlockByName("OverlayTexture");return O&&(O.value=N*(Math.PI/2)),F&&(F.texture=I),I})},[y,g,t]),React.useEffect(()=>{var C;if(r&&y)if((C=r.getScene())!=null&&C.getEngine()){r.clear();let _=(y.maximum.x-y.minimum.x)/g,A=(y.maximum.z-y.minimum.z)/g;if(_<A){const I=_;_=A,A=I}const N=_/A;_*A>2048*2048&&(_=2048,A=2048/N);const S=r.getContext();E.forEach(I=>{if(I.points.length<2)return;S.beginPath();const O=I.offset?I.offset:new EngineCore.Vector2(0,0),F=1-I.points[0].x+O.x,L=1-I.points[0].y+O.y;S.moveTo(F*_,L*A);for(let w=1;w<I.points.length;w++){const B=I.offset?I.offset:new EngineCore.Vector2(0,0),D=1-I.points[w].x+B.x,W=1-I.points[w].y+B.y;S.lineTo(D*_,W*A)}S.strokeStyle=`rgb(${I.color.r*255}, ${I.color.g*255}, ${I.color.b*255})`,_*A>2048*2048?S.lineWidth=I.width/N:S.lineWidth=I.width,S.stroke()}),k.forEach(I=>{var w,B;S.font=`${I.fontSize}px Arial`;const O=(w=I.color)!=null?w:EngineCore.Color3.White(),F=I.offset?I.offset:new EngineCore.Vector2(0,0),L=(B=I.rotation)!=null?B:0;if(S.save(),S.translate((1-I.position.x+F.x)*_,(1-I.position.y+F.y)*A),S.rotate(L),I.clearArea){const D=S.measureText(I.text);S.clearRect(-D.width*.15,.5*I.fontSize*(1-.3),D.width*1.3,-I.fontSize*1.3)}if(I.background){S.fillStyle=`rgba(${I.background.r*255}, ${I.background.g*255}, ${I.background.b*255})`;const D=S.measureText(I.text);S.fillRect(-D.width*.05,.5*(I.fontSize*(.5-.1)),D.width*1.1,-I.fontSize*1.1)}S.fillStyle=`rgb(${O.r*255}, ${O.g*255}, ${O.b*255})`,S.fillText(I.text,0,0),S.restore()}),r.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[E,r,y,g,k]),jsxRuntime.jsx("nodeMaterial",{ref:n,name:`${i}-material`,backFaceCulling:c,needDepthPrePass:f,transparencyMode:u,alphaMode:d,alpha:l,zOffset:h,zOffsetUnits:m,clipPlane:R,disableDepthWrite:b})},ProgressedRemapColorByRedChannelMaterial=e=>{const t=reactBabylonjs.useScene(),n=React.useContext(ColorCodecImageContext),a=React.useRef(null),[r,o]=React.useState(null),[i,s]=React.useState(null),[l,c]=React.useState(null),[f,u]=React.useState(null),[d,h]=React.useState(null),[m,R]=React.useState(null),[v,g]=React.useState(null),[x,y]=React.useState(null),{boundingBox:E,colorCodec:k,alphaStage:b,cutNormal:C,value:_,zOffset:A,zOffsetUnits:N,counterLine:S=void 0,scaleDepth:I=1,scalePlane:O=1,lines:F=[],text:L=[],disableDepthWrite:w}=e;return React.useEffect(()=>{const B=(D,W,ae)=>{if(E){const ne=E.maximumWorld.multiply(W),U=E.minimumWorld.multiply(W),re=E.centerWorld.multiply(W),te=Math.max(ne.x,ne.y,ne.z),K=Math.max(U.x,U.y,U.z),Z=Math.max(re.x,re.y,re.z),de=Math.max(Math.abs(W.x),Math.abs(W.z));D(new EngineCore.Plane(W.x,W.y,W.z,((te-K)*(1-ae-.5)*de+Z)*-1))}else D(null)};E&&x&&(B(o,x.cutPlane1,_.value1),x.cutPlane2&&_.value2?B(s,x.cutPlane2,_.value2):s(null),x.cutPlane3&&_.value3?B(c,x.cutPlane3,_.value3):c(null),x.cutPlane4&&_.value4?B(u,x.cutPlane4,_.value4):u(null),x.cutPlane5&&_.value5?B(h,x.cutPlane5,_.value5):c(null),x.cutPlane6&&_.value6?B(R,x.cutPlane6,_.value6):R(null))},[E,x,_]),React.useEffect(()=>{y({cutPlane1:EngineCore.Vector3.Normalize(C.cutPlane1),cutPlane2:C.cutPlane2?EngineCore.Vector3.Normalize(C.cutPlane2):void 0,cutPlane3:C.cutPlane3?EngineCore.Vector3.Normalize(C.cutPlane3):void 0,cutPlane4:C.cutPlane4?EngineCore.Vector3.Normalize(C.cutPlane4):void 0,cutPlane5:C.cutPlane5?EngineCore.Vector3.Normalize(C.cutPlane5):void 0,cutPlane6:C.cutPlane6?EngineCore.Vector3.Normalize(C.cutPlane6):void 0})},[C]),React.useEffect(()=>{const B=a.current;B&&(B.clipPlane=r,B.clipPlane2=i,B.clipPlane3=l,B.clipPlane4=f,B.clipPlane5=d,B.clipPlane6=m)},[r,i,l,f,d,m]),React.useEffect(()=>{var B,D,W,ae,ne;a.current&&t&&(a.current.setFloat("alpha1",b.alpha1),a.current.setFloat("alpha2",(B=b.alpha2)!=null?B:1),a.current.setFloat("alpha3",(D=b.alpha3)!=null?D:1),a.current.setFloat("alpha4",(W=b.alpha4)!=null?W:1),a.current.setFloat("alpha5",(ae=b.alpha5)!=null?ae:1),a.current.setFloat("alpha6",(ne=b.alpha6)!=null?ne:1))},[t,b]),React.useEffect(()=>{if(k){const B=a.current;B&&(B.metadata={colorCodec:k},EngineCore.Tags.EnableFor(B),EngineCore.Tags.AddTagsTo(B,"remap"))}if(k&&n&&t&&n.colorCodecsImage.current[k]){const B=a.current;B&&(console.log(n.colorCodecsImage.current[k]),B.setTexture("textureSampler",n.colorCodecsImage.current[k].texture),B.metadata={colorCodec:k},EngineCore.Tags.EnableFor(B),EngineCore.Tags.AddTagsTo(B,"remap"))}},[k,t]),React.useEffect(()=>{var D;const B=a.current;if(B&&E)if(S){const W=(D=S.startHeight)!=null?D:E.minimumWorld.y/I;return B.setFloat("contourLineStartHeight",W*I),B.setColor3("contourLineColor",S.color),B.setFloat("contourLineWidth",S.width),B.setFloat("contourLineStep",S.stepHeight*I),console.log("[Geo3DViewer] 等高线设置 ",S,E.centerWorld.y,W*I,W*I+16*S.stepHeight*I),()=>{B&&(B.setFloat("contourLineStartHeight",0),B.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),B.setFloat("contourLineWidth",0),B.setFloat("contourLineStep",0))}}else B.setFloat("contourLineStartHeight",0),B.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),B.setFloat("contourLineWidth",0),B.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[S,I,O,E]),React.useEffect(()=>{t&&E&&g(B=>{var re,te,K,Z;B&&B.dispose();let D=(E.maximum.x-E.minimum.x)/O,W=(E.maximum.z-E.minimum.z)/O,ae=0;if(D<W){const de=D;D=W,W=de,ae=1}const ne=D/W;D*W>2048*2048&&(D=2048,W=2048/ne);const U=new EngineCore.DynamicTexture("dynamic-texture",{width:D,height:W},t,!1);return U.clear(),console.log("[Geo3DViewer] 设置动态划线 ",E,D,W,O),(re=a.current)==null||re.setVector3("oMin",E.minimum),(te=a.current)==null||te.setVector3("oMax",E.maximum),(K=a.current)==null||K.setFloat("textureOverlayRotate",ae),(Z=a.current)==null||Z.setTexture("textureOverlaySampler",U),U})},[E,O,t]),React.useEffect(()=>{var B;if(v&&E)if((B=v.getScene())!=null&&B.getEngine()){v.clear();let D=(E.maximum.x-E.minimum.x)/O,W=(E.maximum.z-E.minimum.z)/O;if(D<W){const U=D;D=W,W=U}const ae=D/W;D*W>2048*2048&&(D=2048,W=2048/ae);const ne=v.getContext();F.forEach(U=>{if(U.points.length<2)return;ne.beginPath();const re=U.offset?U.offset:new EngineCore.Vector2(0,0),te=1-U.points[0].x+re.x,K=1-U.points[0].y+re.y;ne.moveTo(te*D,K*W);for(let Z=1;Z<U.points.length;Z++){const de=U.offset?U.offset:new EngineCore.Vector2(0,0),ee=1-U.points[Z].x+de.x,G=1-U.points[Z].y+de.y;ne.lineTo(ee*D,G*W)}ne.strokeStyle=`rgb(${U.color.r*255}, ${U.color.g*255}, ${U.color.b*255})`,D*W>2048*2048?ne.lineWidth=U.width/ae:ne.lineWidth=U.width,ne.stroke()}),L.forEach(U=>{var Z,de;ne.font=`${U.fontSize}px Arial`;const re=(Z=U.color)!=null?Z:EngineCore.Color3.White(),te=U.offset?U.offset:new EngineCore.Vector2(0,0),K=(de=U.rotation)!=null?de:0;if(ne.save(),ne.translate((1-U.position.x+te.x)*D,(1-U.position.y+te.y)*W),ne.rotate(K),U.clearArea){const ee=ne.measureText(U.text);ne.clearRect(-ee.width*.15,.5*U.fontSize*(1-.3),ee.width*1.3,-U.fontSize*1.3)}if(U.background){ne.fillStyle=`rgba(${U.background.r*255}, ${U.background.g*255}, ${U.background.b*255})`;const ee=ne.measureText(U.text);ne.fillRect(-ee.width*.05,.5*(U.fontSize*(.5-.1)),ee.width*1.1,-U.fontSize*1.1)}ne.fillStyle=`rgb(${re.r*255}, ${re.g*255}, ${re.b*255})`,ne.fillText(U.text,0,0),ne.restore()}),v.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[F,v,E,O,L]),jsxRuntime.jsx(CustomShader$1,{...e,ref:a,vertex:remapProgressedVertexSource,fragment:remapProgressedFragmentSource,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","alpha1","alpha2","alpha3","alpha4","alpha5","alpha6","oMin","oMax","contourLineStartHeight","contourLineColor","contourLineWidth","contourLineStep","textureOverlayRotate"],samplers:["textureOverlaySampler","textureSampler"],needAlphaBlending:!0,needAlphaTesting:!0,useClipPlane:!0},disableDepthWrite:w,zOffset:A,zOffsetUnits:N})},ProgressedRepeatedTextureMaterial=e=>{const t=reactBabylonjs.useScene(),[n,a]=React.useState(null),[r,o]=React.useState(null),[i,s]=React.useState(null),[l,c]=React.useState(null),[f,u]=React.useState(null),[d,h]=React.useState(null),[m,R]=React.useState(null),[v,g]=React.useState(null),[x,y]=React.useState(null),{boundingBox:E=void 0,texture:k,sideTexture:b,alphaStage:C,cutNormal:_,value:A,tilingFactor:N=.1,sideTilingFactor:S=.1,mode:I=0,zOffset:O,zOffsetUnits:F,overlay:L={},counterLine:w=void 0,scalePlane:B=1,scaleDepth:D=1,lines:W=[],text:ae=[],disableDepthWrite:ne,textureFlatRotate:U=0}=e,re=te=>{a(te)};return React.useEffect(()=>{n&&n.setFloat("textureFlatRotate",U)},[n,U]),React.useEffect(()=>{const te=(K,Z,de)=>{if(E){const ee=E.maximumWorld.multiply(Z),G=E.minimumWorld.multiply(Z),ge=E.centerWorld.multiply(Z),fe=Math.max(ee.x,ee.y,ee.z),V=Math.max(G.x,G.y,G.z),J=Math.max(ge.x,ge.y,ge.z),Ce=Math.max(Math.abs(Z.x),Math.abs(Z.z)),Y=new EngineCore.Plane(Z.x,Z.y,Z.z,((fe-V)*(1-de-.5)*Ce+J)*-1);K(Y),console.log("[Geo3DViewer] 设置实际 CutPlane 为 ",Y,Ce)}else K(null)};E&&x&&(te(o,x.cutPlane1,A.value1),x.cutPlane2&&A.value2?te(s,x.cutPlane2,A.value2):s(null),x.cutPlane3&&A.value3?te(c,x.cutPlane3,A.value3):c(null),x.cutPlane4&&A.value4?te(u,x.cutPlane4,A.value4):u(null),x.cutPlane5&&A.value5?te(h,x.cutPlane5,A.value5):c(null),x.cutPlane6&&A.value6?te(R,x.cutPlane6,A.value6):R(null))},[x,E,A]),React.useEffect(()=>{y({cutPlane1:EngineCore.Vector3.Normalize(_.cutPlane1),cutPlane2:_.cutPlane2?EngineCore.Vector3.Normalize(_.cutPlane2):void 0,cutPlane3:_.cutPlane3?EngineCore.Vector3.Normalize(_.cutPlane3):void 0,cutPlane4:_.cutPlane4?EngineCore.Vector3.Normalize(_.cutPlane4):void 0,cutPlane5:_.cutPlane5?EngineCore.Vector3.Normalize(_.cutPlane5):void 0,cutPlane6:_.cutPlane6?EngineCore.Vector3.Normalize(_.cutPlane6):void 0})},[_]),React.useEffect(()=>{n&&(n.clipPlane=r,n.clipPlane2=i,n.clipPlane3=l,n.clipPlane4=f,n.clipPlane5=d,n.clipPlane6=m)},[n,r,i,l,f,d,m]),React.useEffect(()=>{var te,K,Z,de,ee;n&&t&&(n.setFloat("alpha1",C.alpha1),n.setFloat("alpha2",(te=C.alpha2)!=null?te:1),n.setFloat("alpha3",(K=C.alpha3)!=null?K:1),n.setFloat("alpha4",(Z=C.alpha4)!=null?Z:1),n.setFloat("alpha5",(de=C.alpha5)!=null?de:1),n.setFloat("alpha6",(ee=C.alpha6)!=null?ee:1))},[t,C,n]),React.useEffect(()=>{n&&k&&n.setTexture("textureSampler",k)},[n,k]),React.useEffect(()=>{n&&N&&n.setFloat("tilingFactor",N),n&&S&&n.setFloat("sideTilingFactor",S)},[N,S,n]),React.useEffect(()=>{n&&I&&n.setInt("mode",I)},[n,I]),React.useEffect(()=>{n&&(b?n.setTexture("textureSideSampler",b):n.setTexture("textureSideSampler",k))},[n,b,k]),React.useEffect(()=>{n&&(L.texture1?n.setTexture("textureSampler1",L.texture1):n.setTexture("textureSampler1",k),L.sideTexture1?n.setTexture("textureSideSampler1",L.sideTexture1):n.setTexture("textureSideSampler1",k),L.color1?n.setColor3("vColor1",L.color1):n.setColor3("vColor1",new EngineCore.Color3(1,1,1)),L.texture2?n.setTexture("textureSampler2",L.texture2):n.setTexture("textureSampler2",k),L.sideTexture2?n.setTexture("textureSideSampler2",L.sideTexture2):n.setTexture("textureSideSampler2",k),L.color2?n.setColor3("vColor2",L.color2):n.setColor3("vColor2",new EngineCore.Color3(1,1,1)),L.texture3?n.setTexture("textureSampler3",L.texture3):n.setTexture("textureSampler3",k),L.sideTexture3?n.setTexture("textureSideSampler3",L.sideTexture3):n.setTexture("textureSideSampler2",k),L.color3?n.setColor3("vColor3",L.color3):n.setColor3("vColor3",new EngineCore.Color3(1,1,1)),L.texture4?n.setTexture("textureSampler4",L.texture4):n.setTexture("textureSampler4",k),L.sideTexture4?n.setTexture("textureSideSampler4",L.sideTexture4):n.setTexture("textureSideSampler4",k),L.color4?n.setColor3("vColor4",L.color4):n.setColor3("vColor4",new EngineCore.Color3(1,1,1)),L.texture5?n.setTexture("textureSampler5",L.texture5):n.setTexture("textureSampler5",k),L.sideTexture5?n.setTexture("textureSideSampler5",L.sideTexture5):n.setTexture("textureSideSampler5",k),L.color5?n.setColor3("vColor5",L.color5):n.setColor3("vColor5",new EngineCore.Color3(1,1,1)),L.texture6?n.setTexture("textureSampler6",L.texture6):n.setTexture("textureSampler6",k),L.sideTexture6?n.setTexture("textureSideSampler6",L.sideTexture6):n.setTexture("textureSideSampler6",k),L.color6?n.setColor3("vColor6",L.color6):n.setColor3("vColor6",new EngineCore.Color3(1,1,1)))},[n,L,k]),React.useEffect(()=>{var te;if(n&&E)if(w){const K=(te=w.startHeight)!=null?te:E.minimumWorld.y/D;return n.setFloat("contourLineStartHeight",K*D),n.setColor3("contourLineColor",w.color),n.setFloat("contourLineWidth",w.width),n.setFloat("contourLineStep",w.stepHeight*D),console.log("[Geo3DViewer] 等高线设置 ",w,E.centerWorld.y,K*D,K*D+16*w.stepHeight*D),()=>{n&&(n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0))}}else n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[w,D,B,E,n]),React.useEffect(()=>{t&&n&&E&&g(te=>{te&&te.dispose();let K=(E.maximum.x-E.minimum.x)/B,Z=(E.maximum.z-E.minimum.z)/B,de=0;if(K<Z){const ge=K;K=Z,Z=ge,de=1}const ee=K/Z;K*Z>2048*2048&&(K=2048,Z=2048/ee);const G=new EngineCore.DynamicTexture("dynamic-texture",{width:K,height:Z},t,!1);return G.clear(),console.log("[Geo3DViewer] 设置动态划线 ",E,K,Z,B),n.setVector3("oMin",E.minimum),n.setVector3("oMax",E.maximum),n.setFloat("textureOverlayRotate",de),n.setTexture("textureOverlaySampler",G),G})},[E,n,B,t]),React.useEffect(()=>{var te;if(v&&E)if((te=v.getScene())!=null&&te.getEngine()){v.clear();let K=(E.maximum.x-E.minimum.x)/B,Z=(E.maximum.z-E.minimum.z)/B;if(K<Z){const G=K;K=Z,Z=G}const de=K/Z;K*Z>2048*2048&&(K=2048,Z=2048/de);const ee=v.getContext();W.forEach(G=>{if(G.points.length<2)return;ee.beginPath();const ge=G.offset?G.offset:new EngineCore.Vector2(0,0),fe=1-G.points[0].x+ge.x,V=1-G.points[0].y+ge.y;ee.moveTo(fe*K,V*Z);for(let J=1;J<G.points.length;J++){const Ce=G.offset?G.offset:new EngineCore.Vector2(0,0),Y=1-G.points[J].x+Ce.x,se=1-G.points[J].y+Ce.y;ee.lineTo(Y*K,se*Z)}ee.strokeStyle=`rgb(${G.color.r*255}, ${G.color.g*255}, ${G.color.b*255})`,K*Z>2048*2048?ee.lineWidth=G.width/de:ee.lineWidth=G.width,ee.stroke()}),ae.forEach(G=>{var J,Ce;ee.font=`${G.fontSize}px Arial`;const ge=(J=G.color)!=null?J:EngineCore.Color3.White(),fe=G.offset?G.offset:new EngineCore.Vector2(0,0),V=(Ce=G.rotation)!=null?Ce:0;if(ee.save(),ee.translate((1-G.position.x+fe.x)*K,(1-G.position.y+fe.y)*Z),ee.rotate(V),G.clearArea){const Y=ee.measureText(G.text);ee.clearRect(-Y.width*.15,.5*G.fontSize*(1-.3),Y.width*1.3,-G.fontSize*1.3)}if(G.background){ee.fillStyle=`rgba(${G.background.r*255}, ${G.background.g*255}, ${G.background.b*255})`;const Y=ee.measureText(G.text);ee.fillRect(-Y.width*.05,.5*(G.fontSize*(.5-.1)),Y.width*1.1,-G.fontSize*1.1)}ee.fillStyle=`rgb(${ge.r*255}, ${ge.g*255}, ${ge.b*255})`,ee.fillText(G.text,0,0),ee.restore()}),v.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[W,v,E,B,ae]),jsxRuntime.jsx(CustomShader$1,{...e,ref:re,vertex:repeatedTextureProgressedVertexSource,fragment:repeatedTextureProgressedFragmentSource,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","alpha1","alpha2","alpha3","alpha4","alpha5","alpha6","oMin","oMax","tilingFactor","sideTilingFactor","mode","vColor1","vColor2","vColor3","vColor4","vColor5","vColor6","contourLineStartHeight","contourLineColor","contourLineWidth","contourLineStep","textureOverlayRotate","textureFlatRotate"],samplers:["textureSampler","textureOverlaySampler","textureSideSampler","textureSampler1","textureSideSampler1","textureSampler2","textureSideSampler2","textureSampler3","textureSideSampler3","textureSampler4","textureSideSampler4","textureSampler5","textureSideSampler5","textureSampler6","textureSideSampler6"],needAlphaBlending:!0,needAlphaTesting:!0,useClipPlane:!0},zOffset:O,zOffsetUnits:F,disableDepthWrite:ne})},FlatMaterial=e=>jsxRuntime.jsx(CustomShader$1,{...e,vertex:flatVertexSource,fragment:flatFragmentSource,options:{needAlphaBlending:!0},zOffset:e.zOffset,zOffsetUnits:e.zOffsetUnits,disableDepthWrite:e.disableDepthWrite}),PickingMaterial=()=>jsxRuntime.jsx(CustomShader$1,{name:"picking-material",vertex:pickingVertexSource,fragment:pickingFragmentSource,backFaceCulling:!1,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","pickingColor","isPickable"]}}),createMultiStageWaterEffectMaterial=({name:e,scene:t})=>{const n=EngineCore.NodeMaterial.Parse(MultiStageWaterMaterial,t);return n.name=e,n.backFaceCulling=!1,n.build(!1,!0,!1),n},useIntersectingLineMaterial=({name:e,lineColor:t,lineWidth:n=.5})=>{const a=reactBabylonjs.useScene(),[r,o]=React.useState(null);return React.useEffect(()=>{if(a){const i=EngineCore.NodeMaterial.Parse(intersectingLineSource,a);return i.name=`${e}-material`,i.backFaceCulling=!1,i.build(!1,!0,!1),o(i),()=>{o(s=>(s==null||s.dispose(!0,!1),null))}}},[e,a]),React.useEffect(()=>{o(i=>i&&t?(i.getBlockByName("Color3").value=t,i.build(!1,!0,!1),i):null)},[t]),React.useEffect(()=>{o(i=>{if(i&&n!==void 0&&n!==null){let s=n;return n<1&&(s=1),i.getBlockByName("offset").value=1-s,i.build(!1,!0,!1),i}return null})},[n]),r},VoxelGridMaterial=(e,t)=>{const n=React.useRef(null);return React.useEffect(()=>{n.current&&(n.current.setVector4("typeAlpha1",new EngineCore.Vector4(e.typeAlpha.typeAlpha0===void 0?1:e.typeAlpha.typeAlpha0,e.typeAlpha.typeAlpha1,e.typeAlpha.typeAlpha2,e.typeAlpha.typeAlpha3)),n.current.setVector4("typeAlpha2",new EngineCore.Vector4(e.typeAlpha.typeAlpha4,e.typeAlpha.typeAlpha5,e.typeAlpha.typeAlpha6,e.typeAlpha.typeAlpha7)),n.current.setVector4("typeAlpha3",new EngineCore.Vector4(e.typeAlpha.typeAlpha8,e.typeAlpha.typeAlpha9,e.typeAlpha.typeAlpha10,e.typeAlpha.typeAlpha11)),n.current.setVector4("typeAlpha4",new EngineCore.Vector4(e.typeAlpha.typeAlpha12,e.typeAlpha.typeAlpha13,e.typeAlpha.typeAlpha14,e.typeAlpha.typeAlpha15)),n.current.setVector4("typeAlpha5",new EngineCore.Vector4(e.typeAlpha.typeAlpha16,e.typeAlpha.typeAlpha17,e.typeAlpha.typeAlpha18,e.typeAlpha.typeAlpha19)))},[e.typeAlpha]),React.useImperativeHandle(t,()=>n.current,[]),jsxRuntime.jsx(CustomShader$1,{ref:n,name:e.name,backFaceCulling:!0,needDepthPrePass:!1,vertex:voxelGridVertexSource,fragment:voxelGridFragmentSource,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,options:{attributes:["position","color","uv","normal","world0","world1","world2","world3","instanceColor"],uniforms:["world","worldViewProjection","view","viewProjection","typeAlpha1","typeAlpha2","typeAlpha3","typeAlpha4","worldView","projection","previousWorld","vEyePosition"],defines:["#define INSTANCESCOLOR","#define INSTANCES"],needAlphaBlending:!0,needAlphaTesting:!0}})},OneColorMaterial=e=>{const t=reactBabylonjs.useScene(),[n,a]=React.useState(null),r=React.useRef(null),{boundingBox:o,counterLine:i,scaleDepth:s=1,scalePlane:l=1,color:c,alpha:f=1,lines:u=[],text:d=[],surfaceCanvasOptions:h={textureIncludeSide:!0},disableDepthWrite:m,disableNormalShadow:R=!1}=e,{textureIncludeSide:v}=h;return React.useEffect(()=>{r.current&&(console.log("[Geo3DViewer] 设置材质 ",c,f),r.current.setColor3("vColor",c),r.current.setFloat("vAlpha",f),r.current.setFloat("textureIncludeSide",v==null?1:0))},[c,f,v]),React.useEffect(()=>{var x;const g=r.current;if(g&&o)if(i){const y=(x=i.startHeight)!=null?x:o.maximumWorld.y/s;return g.setFloat("contourLineStartHeight",y*s),g.setColor3("contourLineColor",i.color),g.setFloat("contourLineWidth",i.width),g.setFloat("contourLineStep",i.stepHeight*s),console.log("[Geo3DViewer] 等高线设置 ",i,o.centerWorld.y,y*s,y*s-16*i.stepHeight*s),()=>{g&&(g.setFloat("contourLineStartHeight",0),g.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),g.setFloat("contourLineWidth",0),g.setFloat("contourLineStep",0))}}else g.setFloat("contourLineStartHeight",0),g.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),g.setFloat("contourLineWidth",0),g.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[o,i,s,l]),React.useEffect(()=>{const g=r.current;t&&o&&g&&a(x=>{let y=(o.maximum.x-o.minimum.x)/l,E=(o.maximum.z-o.minimum.z)/l,k=0;if(y<E){const _=y;y=E,E=_,k=1}const b=y/E;y*E>2048*2048&&(y=2048,E=2048/b);let C;return x?(x.scaleTo(y,E),x.update(),C=x):C=new EngineCore.DynamicTexture("dynamic-texture",{width:y,height:E},t,!1),C.clear(),C.update(),console.log("[Geo3DViewer] 设置动态划线 ",o,y,E,l),g.setVector3("oMin",o.minimum),g.setVector3("oMax",o.maximum),g.setFloat("textureOverlayRotate",k),g.setTexture("textureOverlaySampler",C),C})},[o,l,t]),React.useEffect(()=>{var g;if(n&&o&&(u.length>0||d.length>0))if((g=n.getScene())!=null&&g.getEngine()){n.clear();let x=(o.maximum.x-o.minimum.x)/l,y=(o.maximum.z-o.minimum.z)/l;if(x<y){const b=x;x=y,y=b}const E=x/y;x*y>2048*2048&&(x=2048,y=2048/E);const k=n.getContext();u.forEach(b=>{if(b.points.length<2)return;k.beginPath();const C=b.offset?b.offset:new EngineCore.Vector2(0,0),_=1-b.points[0].x+C.x,A=1-b.points[0].y+C.y;k.moveTo(_*x,A*y);for(let N=1;N<b.points.length;N++){const S=b.offset?b.offset:new EngineCore.Vector2(0,0),I=1-b.points[N].x+S.x,O=1-b.points[N].y+S.y;k.lineTo(I*x,O*y)}k.strokeStyle=`rgb(${b.color.r*255}, ${b.color.g*255}, ${b.color.b*255})`,x*y>2048*2048?k.lineWidth=b.width/E:k.lineWidth=b.width,k.stroke()}),d.forEach(b=>{var N,S;k.font=`${b.fontSize}px Arial`;const C=(N=b.color)!=null?N:EngineCore.Color3.White(),_=b.offset?b.offset:new EngineCore.Vector2(0,0),A=(S=b.rotation)!=null?S:0;if(k.save(),k.translate((1-b.position.x+_.x)*x,(1-b.position.y+_.y)*y),k.rotate(A),b.clearArea){const I=k.measureText(b.text);k.clearRect(-I.width*.15,.5*b.fontSize*(1-.3),I.width*1.3,-b.fontSize*1.3)}if(b.background){k.fillStyle=`rgba(${b.background.r*255}, ${b.background.g*255}, ${b.background.b*255})`;const I=k.measureText(b.text);k.fillRect(-I.width*.05,.5*(b.fontSize*(.5-.1)),I.width*1.1,-b.fontSize*1.1)}k.fillStyle=`rgb(${C.r*255}, ${C.g*255}, ${C.b*255})`,k.fillText(b.text,0,0),k.restore()}),n.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[u,n,o,l,d]),React.useEffect(()=>{const g=r.current;if(g){if(R)return g.setFloat("disableNormalShadow",1),console.log("[Geo3DViewer] 禁用法向阴影 启用"),()=>{g&&g.setFloat("disableNormalShadow",0)};g.setFloat("disableNormalShadow",0),console.log("[Geo3DViewer] 禁用法向阴影 禁用")}},[R]),jsxRuntime.jsx(CustomShader$1,{ref:r,name:e.name,backFaceCulling:e.backFaceCulling,needDepthPrePass:e.needDepthPrePass,vertex:oneColorVertexSource,fragment:oneColorFragmentSource,transparencyMode:e.transparencyMode,alphaMode:e.alphaMode,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","vAlpha","vColor","contourLineStartHeight","contourLineColor","contourLineWidth","contourLineStep","oMin","oMax","textureOverlayRotate","textureIncludeSide","disableNormalShadow"],samplers:["textureOverlaySampler"],needAlphaBlending:!0,needAlphaTesting:!0},zOffset:e.zOffset,zOffsetUnits:e.zOffsetUnits,disableDepthWrite:m})},VoxelGridMaterialForwardRef=React.forwardRef(VoxelGridMaterial),AttributeBody=({name:e,url:t,offset:n=EngineCore.Vector3.Zero(),alpha:a=1,material:r,visible:o=!0,actions:i})=>{const s=reactBabylonjs.useScene(),l=React.useRef(null),c=React.useContext(WorkspaceMetaContext),f=useCachedBinary({url:t,cacheType:CacheType.URL_PREFIX_MATCH}),u=useCachedTexture({url:r.texture,cacheType:CacheType.URL_PREFIX_MATCH}),d=useCachedTexture({url:r.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),[h,m]=React.useState(EngineCore.Vector3.Zero()),[R,v]=React.useState();return React.useEffect(()=>{console.log("[Geo3DViewer] AttributeBody Loading: ",t)},[t]),React.useEffect(()=>{if(s&&l.current&&t&&f){EngineCore.Tags.EnableFor(l.current),EngineCore.Tags.AddTagsTo(l.current,"loading");const g=VirtualVolume.decode(new Uint8Array(f)),{points:x,indices:y,value:E,center:k}=g,b=new EngineCore.VertexData;b.positions=x,b.indices=y,b.colors=E;const C=[];EngineCore.VertexData.ComputeNormals(x,y,C),b.normals=C,k&&m(new EngineCore.Vector3(k.x,k.y,k.z));const _=l.current;_&&(b.applyToMesh(_),_.getScene().onAfterRenderObservable.addOnce(()=>{if(!_.isDisposed()){const N=_.getBoundingInfo();v(N.boundingBox)}})),EngineCore.Tags.RemoveTagsFrom(l.current,"loading")}},[t,s,f]),React.useEffect(()=>{l.current&&(l.current.metadata={pickable:i?{name:e,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null})},[i,e]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`transform-attribute-${e}`,position:h.add(n).multiplyByFloats(c&&c.scalePlane?c.scalePlane:1,c&&c.scaleDepth?c.scaleDepth:1,c&&c.scalePlane?c.scalePlane:1),scaling:new EngineCore.Vector3(c?c.scalePlane:1,c?c.scaleDepth:1,c?c.scalePlane:1),children:jsxRuntime.jsx("mesh",{name:`attributebody-${e}-mesh`,ref:l,setEnabled:o,useVertexColors:r.type===MaterialType.COLOR_CODEC,children:r.type===MaterialType.COLOR_CODEC&&r.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`attributebody-${e}-mat`,backFaceCulling:r.backFaceCulling===void 0?!0:r.backFaceCulling,needDepthPrePass:r.needDepthPrePass===void 0?!1:r.needDepthPrePass,alpha:r.alpha?r.alpha:a,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:r.colorCodec,boundingBox:R,lines:r.lines,text:r.text,scaleDepth:c?c.scaleDepth:1,scalePlane:c?c.scalePlane:1,disableDepthWrite:r.disableDepthWrite}):r.type===MaterialType.ONE_COLOR&&r.color?jsxRuntime.jsx("standardMaterial",{name:`attributebody-${e}-overwrite-mat`,backFaceCulling:r.backFaceCulling===void 0?!0:r.backFaceCulling,needDepthPrePass:r.needDepthPrePass===void 0?!1:r.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),diffuseColor:new EngineCore.Color3(r.color.r,r.color.g,r.color.b),emissiveColor:EngineCore.Color3.Black(),alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:r.alpha?r.alpha:a,zOffset:-3,disableDepthWrite:r.disableDepthWrite}):r.type===MaterialType.TEXTURE&&u?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`attributebody-${e}-texture-mat`,backFaceCulling:r.backFaceCulling===void 0?!0:r.backFaceCulling,needDepthPrePass:r.needDepthPrePass===void 0?!1:r.needDepthPrePass,alpha:r.alpha?r.alpha:a,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,texture:u,sideTexture:d,mode:r.textureMode===void 0?RepeatedTextureMode.PLANE:r.textureMode,boundingBox:R,disableDepthWrite:r.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{})})})})},AttributeBody$1=AttributeBody,ColorCodec=({codec:e,showValue:t=!1,showTitle:n=!0,width:a=80,height:r=200})=>{const o=React.useContext(ColorCodecImageContext);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("adtFullscreenUi",{name:`adt-color-codec-${e}`,children:[n?jsxRuntime.jsx("textBlock",{name:`color-codec-title-${e}`,text:e,color:"white",paddingBottomInPixels:r+40/200*r,paddingRightInPixels:30/80*a,textVerticalAlignment:EngineGui.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:EngineGui.Control.HORIZONTAL_ALIGNMENT_RIGHT}):jsxRuntime.jsx(jsxRuntime.Fragment,{}),jsxRuntime.jsx("babylon-image",{name:`color-codec-${e}`,source:o!=null&&o.colorCodecsImage.current[e]?o.colorCodecsImage.current[e].blobUrl:"",height:`${r}px`,width:`${a}px`,verticalAlignment:EngineGui.Control.VERTICAL_ALIGNMENT_CENTER,horizontalAlignment:EngineGui.Control.HORIZONTAL_ALIGNMENT_RIGHT,paddingRightInPixels:20}),t&&(o!=null&&o.colorCodecsImage.current[e])?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("textBlock",{name:"color-codec-value-min",text:o.colorCodecsImage.current[e].min.toFixed(1).toString(),color:"white",paddingBottomInPixels:-1*r,paddingRightInPixels:90,textVerticalAlignment:EngineGui.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:EngineGui.Control.HORIZONTAL_ALIGNMENT_RIGHT}),jsxRuntime.jsx("textBlock",{name:"color-codec-title-avg",text:((o.colorCodecsImage.current[e].max-o.colorCodecsImage.current[e].min)/2).toFixed(1).toString(),color:"white",paddingBottomInPixels:0,paddingRightInPixels:a+10,textVerticalAlignment:EngineGui.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:EngineGui.Control.HORIZONTAL_ALIGNMENT_RIGHT}),jsxRuntime.jsx("textBlock",{name:"color-codec-title-max",text:o.colorCodecsImage.current[e].max.toFixed(1).toString(),color:"white",paddingBottomInPixels:r,paddingRightInPixels:a+10,textVerticalAlignment:EngineGui.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:EngineGui.Control.HORIZONTAL_ALIGNMENT_RIGHT})]}):null]})})},ColorCodec$1=ColorCodec;function createBaseFormation(){return{name:"",colorId:0,points:[],indices:[],bottomIndices:[],value:[],vMin:0,vMax:0,border:[],side:[],sideIndices:[],sideValue:[],center:void 0}}const Formation={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.colorId!==0&&t.uint32(16).uint32(e.colorId),t.uint32(170).fork();for(const n of e.points)t.float(n);t.ldelim(),t.uint32(178).fork();for(const n of e.indices)t.uint32(n);t.ldelim(),t.uint32(186).fork();for(const n of e.bottomIndices)t.uint32(n);t.ldelim(),t.uint32(194).fork();for(const n of e.value)t.float(n);t.ldelim(),e.vMin!==0&&t.uint32(205).float(e.vMin),e.vMax!==0&&t.uint32(213).float(e.vMax),t.uint32(218).fork();for(const n of e.border)t.uint32(n);t.ldelim(),t.uint32(226).fork();for(const n of e.side)t.float(n);t.ldelim(),t.uint32(234).fork();for(const n of e.sideIndices)t.uint32(n);t.ldelim(),t.uint32(242).fork();for(const n of e.sideValue)t.float(n);return t.ldelim(),e.center!==void 0&&Vertex.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseFormation();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==16)break;r.colorId=n.uint32();continue;case 21:if(o===173){r.points.push(n.float());continue}if(o===170){const i=n.uint32()+n.pos;for(;n.pos<i;)r.points.push(n.float());continue}break;case 22:if(o===176){r.indices.push(n.uint32());continue}if(o===178){const i=n.uint32()+n.pos;for(;n.pos<i;)r.indices.push(n.uint32());continue}break;case 23:if(o===184){r.bottomIndices.push(n.uint32());continue}if(o===186){const i=n.uint32()+n.pos;for(;n.pos<i;)r.bottomIndices.push(n.uint32());continue}break;case 24:if(o===197){r.value.push(n.float());continue}if(o===194){const i=n.uint32()+n.pos;for(;n.pos<i;)r.value.push(n.float());continue}break;case 25:if(o!==205)break;r.vMin=n.float();continue;case 26:if(o!==213)break;r.vMax=n.float();continue;case 27:if(o===216){r.border.push(n.uint32());continue}if(o===218){const i=n.uint32()+n.pos;for(;n.pos<i;)r.border.push(n.uint32());continue}break;case 28:if(o===229){r.side.push(n.float());continue}if(o===226){const i=n.uint32()+n.pos;for(;n.pos<i;)r.side.push(n.float());continue}break;case 29:if(o===232){r.sideIndices.push(n.uint32());continue}if(o===234){const i=n.uint32()+n.pos;for(;n.pos<i;)r.sideIndices.push(n.uint32());continue}break;case 30:if(o===245){r.sideValue.push(n.float());continue}if(o===242){const i=n.uint32()+n.pos;for(;n.pos<i;)r.sideValue.push(n.float());continue}break;case 31:if(o!==250)break;r.center=Vertex.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$b(e.name)?globalThis.String(e.name):"",colorId:isSet$b(e.colorId)?globalThis.Number(e.colorId):0,points:globalThis.Array.isArray(e==null?void 0:e.points)?e.points.map(t=>globalThis.Number(t)):[],indices:globalThis.Array.isArray(e==null?void 0:e.indices)?e.indices.map(t=>globalThis.Number(t)):[],bottomIndices:globalThis.Array.isArray(e==null?void 0:e.bottomIndices)?e.bottomIndices.map(t=>globalThis.Number(t)):[],value:globalThis.Array.isArray(e==null?void 0:e.value)?e.value.map(t=>globalThis.Number(t)):[],vMin:isSet$b(e.vMin)?globalThis.Number(e.vMin):0,vMax:isSet$b(e.vMax)?globalThis.Number(e.vMax):0,border:globalThis.Array.isArray(e==null?void 0:e.border)?e.border.map(t=>globalThis.Number(t)):[],side:globalThis.Array.isArray(e==null?void 0:e.side)?e.side.map(t=>globalThis.Number(t)):[],sideIndices:globalThis.Array.isArray(e==null?void 0:e.sideIndices)?e.sideIndices.map(t=>globalThis.Number(t)):[],sideValue:globalThis.Array.isArray(e==null?void 0:e.sideValue)?e.sideValue.map(t=>globalThis.Number(t)):[],center:isSet$b(e.center)?Vertex.fromJSON(e.center):void 0}},toJSON(e){var n,a,r,o,i,s,l,c;const t={};return e.name!==""&&(t.name=e.name),e.colorId!==0&&(t.colorId=Math.round(e.colorId)),(n=e.points)!=null&&n.length&&(t.points=e.points),(a=e.indices)!=null&&a.length&&(t.indices=e.indices.map(f=>Math.round(f))),(r=e.bottomIndices)!=null&&r.length&&(t.bottomIndices=e.bottomIndices.map(f=>Math.round(f))),(o=e.value)!=null&&o.length&&(t.value=e.value),e.vMin!==0&&(t.vMin=e.vMin),e.vMax!==0&&(t.vMax=e.vMax),(i=e.border)!=null&&i.length&&(t.border=e.border.map(f=>Math.round(f))),(s=e.side)!=null&&s.length&&(t.side=e.side),(l=e.sideIndices)!=null&&l.length&&(t.sideIndices=e.sideIndices.map(f=>Math.round(f))),(c=e.sideValue)!=null&&c.length&&(t.sideValue=e.sideValue),e.center!==void 0&&(t.center=Vertex.toJSON(e.center)),t},create(e){return Formation.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l,c,f,u,d,h;const t=createBaseFormation();return t.name=(n=e.name)!=null?n:"",t.colorId=(a=e.colorId)!=null?a:0,t.points=((r=e.points)==null?void 0:r.map(m=>m))||[],t.indices=((o=e.indices)==null?void 0:o.map(m=>m))||[],t.bottomIndices=((i=e.bottomIndices)==null?void 0:i.map(m=>m))||[],t.value=((s=e.value)==null?void 0:s.map(m=>m))||[],t.vMin=(l=e.vMin)!=null?l:0,t.vMax=(c=e.vMax)!=null?c:0,t.border=((f=e.border)==null?void 0:f.map(m=>m))||[],t.side=((u=e.side)==null?void 0:u.map(m=>m))||[],t.sideIndices=((d=e.sideIndices)==null?void 0:d.map(m=>m))||[],t.sideValue=((h=e.sideValue)==null?void 0:h.map(m=>m))||[],t.center=e.center!==void 0&&e.center!==null?Vertex.fromPartial(e.center):void 0,t}};function isSet$b(e){return e!=null}function earcut(e,t,n=2){const a=t&&t.length,r=a?t[0]*n:e.length;let o=linkedList(e,0,r,n,!0);const i=[];if(!o||o.next===o.prev)return i;let s,l,c;if(a&&(o=eliminateHoles(e,t,o,n)),e.length>80*n){s=e[0],l=e[1];let f=s,u=l;for(let d=n;d<r;d+=n){const h=e[d],m=e[d+1];h<s&&(s=h),m<l&&(l=m),h>f&&(f=h),m>u&&(u=m)}c=Math.max(f-s,u-l),c=c!==0?32767/c:0}return earcutLinked(o,i,n,s,l,c,0),i}function linkedList(e,t,n,a,r){let o;if(r===signedArea(e,t,n,a)>0)for(let i=t;i<n;i+=a)o=insertNode(i/a|0,e[i],e[i+1],o);else for(let i=n-a;i>=t;i-=a)o=insertNode(i/a|0,e[i],e[i+1],o);return o&&equals(o,o.next)&&(removeNode(o),o=o.next),o}function filterPoints(e,t){if(!e)return e;t||(t=e);let n=e,a;do if(a=!1,!n.steiner&&(equals(n,n.next)||area(n.prev,n,n.next)===0)){if(removeNode(n),n=t=n.prev,n===n.next)break;a=!0}else n=n.next;while(a||n!==t);return t}function earcutLinked(e,t,n,a,r,o,i){if(!e)return;!i&&o&&indexCurve(e,a,r,o);let s=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(o?isEarHashed(e,a,r,o):isEar(e)){t.push(l.i,e.i,c.i),removeNode(e),e=c.next,s=c.next;continue}if(e=c,e===s){i?i===1?(e=cureLocalIntersections(filterPoints(e),t),earcutLinked(e,t,n,a,r,o,2)):i===2&&splitEarcut(e,t,n,a,r,o):earcutLinked(filterPoints(e),t,n,a,r,o,1);break}}}function isEar(e){const t=e.prev,n=e,a=e.next;if(area(t,n,a)>=0)return!1;const r=t.x,o=n.x,i=a.x,s=t.y,l=n.y,c=a.y,f=Math.min(r,o,i),u=Math.min(s,l,c),d=Math.max(r,o,i),h=Math.max(s,l,c);let m=a.next;for(;m!==t;){if(m.x>=f&&m.x<=d&&m.y>=u&&m.y<=h&&pointInTriangleExceptFirst(r,s,o,l,i,c,m.x,m.y)&&area(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function isEarHashed(e,t,n,a){const r=e.prev,o=e,i=e.next;if(area(r,o,i)>=0)return!1;const s=r.x,l=o.x,c=i.x,f=r.y,u=o.y,d=i.y,h=Math.min(s,l,c),m=Math.min(f,u,d),R=Math.max(s,l,c),v=Math.max(f,u,d),g=zOrder(h,m,t,n,a),x=zOrder(R,v,t,n,a);let y=e.prevZ,E=e.nextZ;for(;y&&y.z>=g&&E&&E.z<=x;){if(y.x>=h&&y.x<=R&&y.y>=m&&y.y<=v&&y!==r&&y!==i&&pointInTriangleExceptFirst(s,f,l,u,c,d,y.x,y.y)&&area(y.prev,y,y.next)>=0||(y=y.prevZ,E.x>=h&&E.x<=R&&E.y>=m&&E.y<=v&&E!==r&&E!==i&&pointInTriangleExceptFirst(s,f,l,u,c,d,E.x,E.y)&&area(E.prev,E,E.next)>=0))return!1;E=E.nextZ}for(;y&&y.z>=g;){if(y.x>=h&&y.x<=R&&y.y>=m&&y.y<=v&&y!==r&&y!==i&&pointInTriangleExceptFirst(s,f,l,u,c,d,y.x,y.y)&&area(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;E&&E.z<=x;){if(E.x>=h&&E.x<=R&&E.y>=m&&E.y<=v&&E!==r&&E!==i&&pointInTriangleExceptFirst(s,f,l,u,c,d,E.x,E.y)&&area(E.prev,E,E.next)>=0)return!1;E=E.nextZ}return!0}function cureLocalIntersections(e,t){let n=e;do{const a=n.prev,r=n.next.next;!equals(a,r)&&intersects(a,n,n.next,r)&&locallyInside(a,r)&&locallyInside(r,a)&&(t.push(a.i,n.i,r.i),removeNode(n),removeNode(n.next),n=e=r),n=n.next}while(n!==e);return filterPoints(n)}function splitEarcut(e,t,n,a,r,o){let i=e;do{let s=i.next.next;for(;s!==i.prev;){if(i.i!==s.i&&isValidDiagonal(i,s)){let l=splitPolygon(i,s);i=filterPoints(i,i.next),l=filterPoints(l,l.next),earcutLinked(i,t,n,a,r,o,0),earcutLinked(l,t,n,a,r,o,0);return}s=s.next}i=i.next}while(i!==e)}function eliminateHoles(e,t,n,a){const r=[];for(let o=0,i=t.length;o<i;o++){const s=t[o]*a,l=o<i-1?t[o+1]*a:e.length,c=linkedList(e,s,l,a,!1);c===c.next&&(c.steiner=!0),r.push(getLeftmost(c))}r.sort(compareXYSlope);for(let o=0;o<r.length;o++)n=eliminateHole(r[o],n);return n}function compareXYSlope(e,t){let n=e.x-t.x;if(n===0&&(n=e.y-t.y,n===0)){const a=(e.next.y-e.y)/(e.next.x-e.x),r=(t.next.y-t.y)/(t.next.x-t.x);n=a-r}return n}function eliminateHole(e,t){const n=findHoleBridge(e,t);if(!n)return t;const a=splitPolygon(n,e);return filterPoints(a,a.next),filterPoints(n,n.next)}function findHoleBridge(e,t){let n=t;const a=e.x,r=e.y;let o=-1/0,i;if(equals(e,n))return n;do{if(equals(e,n.next))return n.next;if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const u=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(u<=a&&u>o&&(o=u,i=n.x<n.next.x?n:n.next,u===a))return i}n=n.next}while(n!==t);if(!i)return null;const s=i,l=i.x,c=i.y;let f=1/0;n=i;do{if(a>=n.x&&n.x>=l&&a!==n.x&&pointInTriangle(r<c?a:o,r,l,c,r<c?o:a,r,n.x,n.y)){const u=Math.abs(r-n.y)/(a-n.x);locallyInside(n,e)&&(u<f||u===f&&(n.x>i.x||n.x===i.x&§orContainsSector(i,n)))&&(i=n,f=u)}n=n.next}while(n!==s);return i}function sectorContainsSector(e,t){return area(e.prev,e,t.prev)<0&&area(t.next,e,e.next)<0}function indexCurve(e,t,n,a){let r=e;do r.z===0&&(r.z=zOrder(r.x,r.y,t,n,a)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,sortLinked(r)}function sortLinked(e){let t,n=1;do{let a=e,r;e=null;let o=null;for(t=0;a;){t++;let i=a,s=0;for(let c=0;c<n&&(s++,i=i.nextZ,!!i);c++);let l=n;for(;s>0||l>0&&i;)s!==0&&(l===0||!i||a.z<=i.z)?(r=a,a=a.nextZ,s--):(r=i,i=i.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;a=i}o.nextZ=null,n*=2}while(t>1);return e}function zOrder(e,t,n,a,r){return e=(e-n)*r|0,t=(t-a)*r|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function getLeftmost(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function pointInTriangle(e,t,n,a,r,o,i,s){return(r-i)*(t-s)>=(e-i)*(o-s)&&(e-i)*(a-s)>=(n-i)*(t-s)&&(n-i)*(o-s)>=(r-i)*(a-s)}function pointInTriangleExceptFirst(e,t,n,a,r,o,i,s){return!(e===i&&t===s)&&pointInTriangle(e,t,n,a,r,o,i,s)}function isValidDiagonal(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!intersectsPolygon(e,t)&&(locallyInside(e,t)&&locallyInside(t,e)&&middleInside(e,t)&&(area(e.prev,e,t.prev)||area(e,t.prev,t))||equals(e,t)&&area(e.prev,e,e.next)>0&&area(t.prev,t,t.next)>0)}function area(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function equals(e,t){return e.x===t.x&&e.y===t.y}function intersects(e,t,n,a){const r=sign(area(e,t,n)),o=sign(area(e,t,a)),i=sign(area(n,a,e)),s=sign(area(n,a,t));return!!(r!==o&&i!==s||r===0&&onSegment(e,n,t)||o===0&&onSegment(e,a,t)||i===0&&onSegment(n,e,a)||s===0&&onSegment(n,t,a))}function onSegment(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function sign(e){return e>0?1:e<0?-1:0}function intersectsPolygon(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&intersects(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function locallyInside(e,t){return area(e.prev,e,e.next)<0?area(e,t,e.next)>=0&&area(e,e.prev,t)>=0:area(e,t,e.prev)<0||area(e,e.next,t)<0}function middleInside(e,t){let n=e,a=!1;const r=(e.x+t.x)/2,o=(e.y+t.y)/2;do n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(a=!a),n=n.next;while(n!==e);return a}function splitPolygon(e,t){const n=createNode(e.i,e.x,e.y),a=createNode(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,a.next=n,n.prev=a,o.next=a,a.prev=o,a}function insertNode(e,t,n,a){const r=createNode(e,t,n);return a?(r.next=a.next,r.prev=a,a.next.prev=r,a.next=r):(r.prev=r,r.next=r),r}function removeNode(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function createNode(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function signedArea(e,t,n,a){let r=0;for(let o=t,i=n-a;o<n;o+=a)r+=(e[i]-e[o])*(e[o+1]+e[i+1]),i=o;return r}const Be=class Be{constructor(t,n,a="",r={},o=EngineCore.EngineStore.LastCreatedScene){ue(this,"_name");ue(this,"_text","");ue(this,"_font");ue(this,"_mesh",null);ue(this,"_externalMesh");ue(this,"_color",new EngineCore.Color4(1,1,1,1));ue(this,"_fontSize",16);ue(this,"_resolution",64);ue(this,"_depth",10);ue(this,"_scene");ue(this,"_material");ue(this,"_lowPriority",!0);ue(this,"_disposed",!1);ue(this,"_buildVersion",0);var i,s;this._name=t,this._font=n,this._text=a,this._fontSize=r.fontSize||16,this._resolution=r.resolution||64,this._depth=r.depth||1,this._color=r.color||new EngineCore.Color4(1,1,1,1),this._lowPriority=(i=r.lowPriority)!=null?i:!0,this._scene=o,this._externalMesh=new EngineCore.Mesh(`${t}-external-mesh`,o),this._externalMesh.billboardMode=(s=r.billboardMode)!=null?s:EngineCore.Mesh.BILLBOARDMODE_ALL,this._material=new EngineCore.StandardMaterial(`${t}-material`,o),this._material.diffuseColor=EngineCore.Color3.FromArray(this._color.asArray()),this._material.specularColor=new EngineCore.Color3(0,0,0),this._material.emissiveColor=EngineCore.Color3.FromArray(this._color.asArray()),this._material.disableLighting=!0,this._material.alpha=this._color.a,this._material.transparencyMode=EngineCore.Material.MATERIAL_ALPHABLEND,this.rebuildTextMesh()}static scheduleFlush(){if(Be._flushHandle!==null)return;const t=globalThis;if(typeof t.requestAnimationFrame=="function"){Be._flushHandle=t.requestAnimationFrame(()=>{Be._flushHandle=null,Be.flushQueue(2)});return}Be._flushHandle=t.setTimeout(()=>{Be._flushHandle=null,Be.flushQueue(2)},16)}static flushQueue(t){let n=0;for(;Be._pendingTasks.length>0&&n<t;){const a=Be._pendingTasks.shift();a==null||a(),n+=1}Be._pendingTasks.length>0&&Be.scheduleFlush()}static enqueueTask(t){Be._pendingTasks.push(t),Be.scheduleFlush()}createTextMeshNow(){this._disposed||(this._mesh=EngineCore.MeshBuilder.CreateText(this._name,this._text,this._font,{size:this._fontSize,resolution:this._resolution,depth:this._depth},this._scene,earcut),this._mesh.parent=this._externalMesh,this._mesh.material=this._material,this._mesh.billboardMode=this._externalMesh.billboardMode)}rebuildTextMesh(){this._buildVersion+=1;const t=this._buildVersion;if(this._mesh&&(this._mesh.dispose(),this._mesh=null),!(this._disposed||this._text===void 0||this._text===null||this._text.trim()==="")){if(!this._lowPriority){this.createTextMeshNow();return}Be.enqueueTask(()=>{this._disposed||t!==this._buildVersion||this.createTextMeshNow()})}}set color(t){this._color=t,this._material&&(this._material.diffuseColor=EngineCore.Color3.FromArray(t.asArray()),this._material.emissiveColor=EngineCore.Color3.FromArray(t.asArray()),this._material.alpha=t.a)}get color(){return this._color}set text(t){this._text!==t&&(this._text=t,this.rebuildTextMesh())}get text(){return this._text}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.rebuildTextMesh())}get fontSize(){return this._fontSize}set resolution(t){this._resolution!==t&&(this._resolution=t,this.rebuildTextMesh())}get resolution(){return this._resolution}set depth(t){this._depth!==t&&(this._depth=t,this.rebuildTextMesh())}set billboardMode(t){this._externalMesh.billboardMode!==t&&(this._externalMesh.billboardMode=t,this._mesh&&(this._mesh.billboardMode=t))}get billboardMode(){return this._externalMesh.billboardMode}set lowPriority(t){const n=this._lowPriority!==t;this._lowPriority=t,n&&!t&&!this._mesh&&this._text.trim()!==""&&this.rebuildTextMesh()}get lowPriority(){return this._lowPriority}update(t){let n=!1;t.text!==void 0&&t.text!==this._text&&(this._text=t.text,n=!0),t.fontSize!==void 0&&t.fontSize!==this._fontSize&&(this._fontSize=t.fontSize,n=!0),t.resolution!==void 0&&t.resolution!==this._resolution&&(this._resolution=t.resolution,n=!0),t.depth!==void 0&&t.depth!==this._depth&&(this._depth=t.depth,n=!0),t.color!==void 0&&(this.color=t.color),t.billboardMode!==void 0&&(this.billboardMode=t.billboardMode),t.lowPriority!==void 0&&t.lowPriority!==this._lowPriority&&(this._lowPriority=t.lowPriority,!this._lowPriority&&!this._mesh&&this._text.trim()!==""&&(n=!0)),n&&this.rebuildTextMesh()}get depth(){return this._depth}get mesh(){return this._externalMesh}get textMesh(){return this._mesh}dispose(){this._disposed=!0,this._buildVersion+=1,this._mesh&&this._mesh.dispose(),this._material.dispose(),this._externalMesh.dispose(),this._mesh=null}};ue(Be,"_pendingTasks",[]),ue(Be,"_flushHandle",null);let FreeTypeText=Be;const FreeTypeText$1=FreeTypeText,GUIText=e=>{const t=reactBabylonjs.useScene(),n=React.useRef(null),a=React.useRef(null),r=useCachedJSON({url:"/Noto Sans SC_Regular.json"}),{name:o,text:i,fontSize:s,color:l,billboardMode:c=EngineCore.Mesh.BILLBOARDMODE_ALL,lowPriority:f=!0}=e;return React.useEffect(()=>{var u;if(a.current&&a.current.dispose(),r&&t)return a.current=new FreeTypeText$1((u=e.name)!=null?u:"gui-text-no-name",r,e.text,{fontSize:e.fontSize,color:typeof e.color=="string"?EngineCore.Color4.FromHexString(e.color):e.color,billboardMode:c,lowPriority:f},t),a.current.mesh.parent=n.current,a.current.mesh.onDisposeObservable.addOnce(()=>{a.current=null}),()=>{var d;(d=a.current)==null||d.dispose(),a.current=null}},[r,t]),React.useEffect(()=>{a.current&&(a.current.update({text:i,fontSize:s,color:typeof l=="string"?EngineCore.Color4.FromHexString(l):l,lowPriority:f}),a.current.mesh.parent=n.current)},[i,s,l,f]),React.useEffect(()=>{a.current&&c!==void 0&&(a.current.billboardMode=c)},[c]),jsxRuntime.jsx("transformNode",{name:o!=null?o:"no-name-text",ref:n})},GUIText$1=GUIText,FormationFace=({urlTopLayer:e,urlBottomLayer:t,showLayerLabel:n=!1,labelStyle:a,position:r=EngineCore.Vector3.Zero(),visible:o=!0,showBottomLayer:i=!1,actions:s,material:l={type:MaterialType.COLOR_ID,alpha:1}})=>{var O,F;const c=React.useRef(null),f=React.useRef(null),[u,d]=React.useState(""),[h,m]=React.useState(null),R=React.useContext(WorkspaceMetaContext),v=React.useContext(ColorProviderContext),[g,x]=React.useState(EngineCore.Color3.White()),y=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH}),E=useCachedBinary({url:t,cacheType:CacheType.URL_PREFIX_MATCH}),k=useCachedTexture({url:l==null?void 0:l.texture,cacheType:CacheType.URL_PREFIX_MATCH}),b=useCachedTexture({url:l==null?void 0:l.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH});React.useEffect(()=>{console.log("[Geo3DViewer] FormationFace Loading: ",e,t)},[e,t]);const[C,_]=React.useState(),[A,N]=React.useState(EngineCore.Vector3.Zero()),[S,I]=React.useState(void 0);return React.useEffect(()=>{if(y){const L=c.current;L&&(EngineCore.Tags.EnableFor(L),EngineCore.Tags.AddTagsTo(L,"loading"));let w=[],B=[],D=[];const W=Formation.decode(new Uint8Array(y));{const{name:U,points:re,indices:te,colorId:K,value:Z,center:de}=W;w=re,B=te,D=Z,m(K),d(U),de&&N(new EngineCore.Vector3(de.x,de.y,de.z))}const ae=new EngineCore.VertexData;ae.positions=w,ae.indices=B,ae.colors=D;const ne=[];if(EngineCore.VertexData.ComputeNormals(w,B,ne),ae.normals=ne,L){ae.applyToMesh(L);const U=L.getBoundingInfo();_(U.boundingBox.center.add(new EngineCore.Vector3(U.boundingBox.extendSize.x,0,0))),i||L.getScene().onAfterRenderObservable.addOnce(()=>{if(!L.isDisposed()){const te=L.getBoundingInfo();I(te.boundingBox)}})}return L&&EngineCore.Tags.RemoveTagsFrom(L,"loading"),()=>{L&&new EngineCore.VertexData().applyToMesh(L)}}},[y,i]),React.useEffect(()=>{if(y&&E){const L=f.current;L&&(EngineCore.Tags.EnableFor(L),EngineCore.Tags.AddTagsTo(L,"loading"));let w=[],B=[],D=[],W=[],ae=[],ne=[],U=[],re=[];{const fe=Formation.decode(new Uint8Array(y)),{points:V,indices:J,border:Ce,value:Y}=fe;w=V,B=J,W=Ce,D=Y}{const fe=Formation.decode(new Uint8Array(E)),{points:V,bottomIndices:J,border:Ce,value:Y}=fe;ae=V,ne=J,U=Ce,re=Y}const te=new EngineCore.VertexData,K=new Float32Array(w.length+ae.length);let Z=B.length+ne.length;Z=Z+(W.length-1)*6;const de=new Int32Array(Z),ee=new Float32Array(D.length+re.length);K.set(w),de.set(B),ee.set(D),K.set(ae,w.length),de.set(ne,B.length),ee.set(re,D.length);const G=[];for(let fe=0;fe<W.length-1;fe++)G.push(W[fe+1]),G.push(W[fe]),G.push(U[fe]+w.length/3),G.push(U[fe+1]+w.length/3),G.push(U[fe]+w.length/3),G.push(W[fe+1]);de.set(G,B.length+ne.length),te.positions=K,te.indices=de,te.colors=ee;const ge=[];return EngineCore.VertexData.ComputeNormals(K,de,ge),te.normals=ge,L&&(te.applyToMesh(L),i&&L.getScene().onAfterRenderObservable.addOnce(()=>{if(!L.isDisposed()){const V=L.getBoundingInfo();I(V.boundingBox)}})),L&&EngineCore.Tags.RemoveTagsFrom(L,"loading"),()=>{L&&new EngineCore.VertexData().applyToMesh(L)}}},[E,y,i]),React.useEffect(()=>{var L;x(l.type===MaterialType.ONE_COLOR?(L=l==null?void 0:l.color)!=null?L:EngineCore.Color3.Random():h&&v.colorIDs[h]?new EngineCore.Color3(v.colorIDs[h].r,v.colorIDs[h].g,v.colorIDs[h].b):EngineCore.Color3.Random())},[v.colorIDs,h,l==null?void 0:l.color,l.type]),React.useEffect(()=>{c.current&&(c.current.metadata={pickable:s?{name:u,onLeftClick:s.onLeftClick,onRightClick:s.onRightClick,onMiddleClick:s.onMiddleClick,onHover:s.onHover,extra:s.extra}:null}),f.current&&(f.current.metadata={pickable:s?{name:u,onLeftClick:s.onLeftClick,onRightClick:s.onRightClick,onMiddleClick:s.onMiddleClick,onHover:s.onHover,extra:s.extra}:null})},[s,u]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("transformNode",{name:`transform-formation-${u}-${e}`,position:A.add(r).multiplyByFloats(R&&R.scalePlane?R.scalePlane:1,R&&R.scaleDepth?R.scaleDepth:1,R&&R.scalePlane?R.scalePlane:1),scaling:new EngineCore.Vector3(R?R.scalePlane:1,R?R.scaleDepth:1,R?R.scalePlane:1),setEnabled:o,children:[jsxRuntime.jsx("mesh",{name:`formation-${u}-mesh-${e}`,ref:c,setEnabled:!i,useVertexColors:l.type===MaterialType.COLOR_CODEC,alwaysSelectAsActiveMesh:!0,children:l.type===MaterialType.TEXTURE?k?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`formation-${u}-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,texture:k,sideTexture:b,tilingFactor:l.tilingFactor,sideTilingFactor:(O=l==null?void 0:l.sideTilingFactor)!=null?O:l==null?void 0:l.tilingFactor,mode:l.textureMode===void 0?RepeatedTextureMode.PLANE:l.textureMode,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):l.type===MaterialType.COLOR_CODEC?l.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`formation-${u}-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,alpha:l.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:l.colorCodec,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):l.type===MaterialType.COLOR_ID?jsxRuntime.jsx(OneColorMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,surfaceCanvasOptions:l.surfaceCanvasOptions,color:g,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,boundingBox:S,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite,disableNormalShadow:l.disableNormalShadow}):jsxRuntime.jsx(OneColorMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,color:g,surfaceCanvasOptions:l.surfaceCanvasOptions,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,boundingBox:S,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite,disableNormalShadow:l.disableNormalShadow})}),jsxRuntime.jsx("mesh",{name:`formation-${u}-vol-${e}`,ref:f,setEnabled:i,useVertexColors:l.type===MaterialType.COLOR_CODEC,alwaysSelectAsActiveMesh:!0,children:l.type===MaterialType.TEXTURE?k?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,sideTexture:b,texture:k,tilingFactor:l.tilingFactor,sideTilingFactor:(F=l==null?void 0:l.sideTilingFactor)!=null?F:l==null?void 0:l.tilingFactor,mode:l.textureMode===void 0?RepeatedTextureMode.PLANE:l.textureMode,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):l.type===MaterialType.COLOR_CODEC?l.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,alpha:l.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:l.colorCodec,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):l.type===MaterialType.COLOR_ID?jsxRuntime.jsx(OneColorMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,surfaceCanvasOptions:l.surfaceCanvasOptions,color:g,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite,disableNormalShadow:l.disableNormalShadow}):jsxRuntime.jsx(OneColorMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,surfaceCanvasOptions:l.surfaceCanvasOptions,color:g,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite,disableNormalShadow:l.disableNormalShadow})}),u&&C&&jsxRuntime.jsx("transformNode",{name:`${u}-title-${e}`,position:C.add(a!=null&&a.offset?a.offset.multiplyByFloats(R!=null&&R.scalePlane?R==null?void 0:R.scalePlane:1,1,R!=null&&R.scalePlane?R==null?void 0:R.scalePlane:1):EngineCore.Vector3.Zero()),scaling:calcGUIScale(R).multiply(new EngineCore.Vector3(3,3,3)),setEnabled:n,children:jsxRuntime.jsx(GUIText$1,{text:u,fontSize:a!=null&&a.fontSize?a.fontSize:40,color:a!=null&&a.color?a.color:"white"})})]})})},FormationFace$1=FormationFace,FormationVolume=({url:e,showLayerLabel:t=!1,labelStyle:n,position:a=EngineCore.Vector3.Zero(),visible:r=!0,showBottomLayer:o=!1,actions:i,material:s={type:MaterialType.COLOR_ID,counterLine:void 0,alpha:1}})=>{var S,I;const l=React.useRef(null),c=React.useRef(null),[f,u]=React.useState(""),[d,h]=React.useState(null),[m,R]=React.useState(EngineCore.Color3.White()),v=React.useContext(WorkspaceMetaContext),g=React.useContext(ColorProviderContext),[x,y]=React.useState(EngineCore.Vector3.Zero()),[E,k]=React.useState(),b=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH}),C=useCachedTexture({url:s==null?void 0:s.texture,cacheType:CacheType.URL_PREFIX_MATCH}),_=useCachedTexture({url:s==null?void 0:s.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),[A,N]=React.useState(void 0);return React.useEffect(()=>{console.log("[Geo3DViewer] FormationVolume Loading: ",e)},[e]),React.useEffect(()=>{if(b){const O=l.current,F=c.current;EngineCore.Tags.EnableFor(O),EngineCore.Tags.AddTagsTo(O,"loading"),EngineCore.Tags.EnableFor(c),EngineCore.Tags.AddTagsTo(c,"loading");let L=[],w=[],B=[],D=[];const W=Formation.decode(new Uint8Array(b)),{name:ae,points:ne,indices:U,colorId:re,side:te,sideIndices:K,center:Z,value:de,sideValue:ee}=W;Z&&y(new EngineCore.Vector3(Z.x,Z.y,Z.z)),L=ne,w=U,B=te,D=K,h(re),u(ae);const G=new EngineCore.VertexData,ge=new EngineCore.VertexData,fe=new Float32Array(L.length+B.length),V=new Int32Array(w.length+D.length),J=new Float32Array(de.length+ee.length);G.positions=L,G.indices=w,G.colors=de;const Ce=[];EngineCore.VertexData.ComputeNormals(ne,U,Ce),G.normals=Ce,fe.set(L),V.set(w),J.set(de),fe.set(B,L.length),V.set(D,w.length),J.set(ee,de.length),ge.positions=fe,ge.indices=V,ge.colors=J;const Y=[];if(EngineCore.VertexData.ComputeNormals(fe,V,Y),ge.normals=Y,O){G.applyToMesh(O);const se=O.getBoundingInfo();k(se.boundingBox.center.add(new EngineCore.Vector3(se.boundingBox.extendSize.x,0,0))),o||O.getScene().onAfterRenderObservable.addOnce(()=>{if(!O.isDisposed()){const Q=O.getBoundingInfo();N(Q.boundingBox)}})}return F&&(ge.applyToMesh(F),o&&F.getScene().onAfterRenderObservable.addOnce(()=>{if(!F.isDisposed()){const ce=F.getBoundingInfo();N(ce.boundingBox)}})),EngineCore.Tags.RemoveTagsFrom(O,"loading"),EngineCore.Tags.RemoveTagsFrom(c,"loading"),()=>{O&&new EngineCore.VertexData().applyToMesh(O),F&&new EngineCore.VertexData().applyToMesh(F)}}},[b,o]),React.useEffect(()=>{var O;R(s.type===MaterialType.ONE_COLOR?(O=s==null?void 0:s.color)!=null?O:EngineCore.Color3.Random():d&&g.colorIDs[d]?new EngineCore.Color3(g.colorIDs[d].r,g.colorIDs[d].g,g.colorIDs[d].b):EngineCore.Color3.Random())},[g.colorIDs,d,s==null?void 0:s.color,s.type]),React.useEffect(()=>{l.current&&(l.current.metadata={pickable:i?{name:f,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null}),c.current&&(c.current.metadata={pickable:i?{name:f,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null})},[i,f]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("transformNode",{name:`transform-formation-${f}-${e}`,position:x.add(a).multiplyByFloats(v&&v.scalePlane?v.scalePlane:1,v&&v.scaleDepth?v.scaleDepth:1,v&&v.scalePlane?v.scalePlane:1),scaling:new EngineCore.Vector3(v?v.scalePlane:1,v?v.scaleDepth:1,v?v.scalePlane:1),setEnabled:r,children:[jsxRuntime.jsx("mesh",{name:`formation-${f}-mesh-${e}`,ref:l,setEnabled:!o,useVertexColors:s.type===MaterialType.COLOR_CODEC,children:s.type===MaterialType.TEXTURE?C?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`formation-${f}-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:s.alpha,flatModeRotate:s.flatModeRotate,sideTexture:_,texture:C,tilingFactor:s.tilingFactor,sideTilingFactor:(S=s==null?void 0:s.sideTilingFactor)!=null?S:s==null?void 0:s.tilingFactor,mode:s.textureMode===void 0?RepeatedTextureMode.PLANE:s.textureMode,counterLine:s.counterLine,boundingBox:A,lines:s.lines,text:s.text,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):s.type===MaterialType.COLOR_CODEC?s.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`formation-${f}-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,alpha:s.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:s.colorCodec,counterLine:s.counterLine,boundingBox:A,lines:s.lines,text:s.text,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):s.type===MaterialType.COLOR_ID?jsxRuntime.jsx(DiffuseTerrainMaterial$1,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,color:m,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:s.alpha,lightPosition:s.lightPosition,intensity:s.intensity,surfaceCanvasOptions:s.surfaceCanvasOptions,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:A,lines:s.lines,text:s.text,zOffset:s.zOffset,zOffsetUnits:s.zOffsetUnits,contrast:s.contrast,sideIntensity:s.sideIntensity,cullFace:s.cullFace,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(DiffuseTerrainMaterial$1,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,color:m,alphaMode:EngineCore.Engine.ALPHA_COMBINE,surfaceCanvasOptions:s.surfaceCanvasOptions,alpha:s.alpha,lightPosition:s.lightPosition,intensity:s.intensity,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:A,lines:s.lines,text:s.text,zOffset:s.zOffset,zOffsetUnits:s.zOffsetUnits,contrast:s.contrast,sideIntensity:s.sideIntensity,cullFace:s.cullFace,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite})}),jsxRuntime.jsx("mesh",{name:`formation-${f}-vol-${e}`,ref:c,setEnabled:o,useVertexColors:s.type===MaterialType.COLOR_CODEC,children:s.type===MaterialType.TEXTURE?C?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:s.alpha,sideTexture:_,texture:C,tilingFactor:s.tilingFactor,sideTilingFactor:(I=s==null?void 0:s.sideTilingFactor)!=null?I:s==null?void 0:s.tilingFactor,mode:s.textureMode===void 0?RepeatedTextureMode.PLANE:s.textureMode,flatModeRotate:s.flatModeRotate,counterLine:s.counterLine,boundingBox:A,lines:s.lines,text:s.text,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):s.type===MaterialType.COLOR_CODEC?s.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,alpha:s.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:s.colorCodec,counterLine:s.counterLine,boundingBox:A,lines:s.lines,text:s.text,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):s.type===MaterialType.COLOR_ID?jsxRuntime.jsx(DiffuseTerrainMaterial$1,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,color:m,surfaceCanvasOptions:s.surfaceCanvasOptions,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:s.alpha,lightPosition:s.lightPosition,intensity:s.intensity,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:A,lines:s.lines,text:s.text,zOffset:s.zOffset,zOffsetUnits:s.zOffsetUnits,contrast:s.contrast,sideIntensity:s.sideIntensity,cullFace:s.cullFace,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(DiffuseTerrainMaterial$1,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,color:m,surfaceCanvasOptions:s.surfaceCanvasOptions,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:s.alpha,lightPosition:s.lightPosition,intensity:s.intensity,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:A,lines:s.lines,text:s.text,zOffset:s.zOffset,zOffsetUnits:s.zOffsetUnits,contrast:s.contrast,sideIntensity:s.sideIntensity,cullFace:s.cullFace,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite})}),f&&E&&jsxRuntime.jsx("transformNode",{name:`${f}-title-${e}`,position:E.add(n!=null&&n.offset?n.offset.multiplyByFloats(v!=null&&v.scalePlane?v==null?void 0:v.scalePlane:1,1,v!=null&&v.scalePlane?v==null?void 0:v.scalePlane:1):EngineCore.Vector3.Zero()),scaling:calcGUIScale(v).multiply(new EngineCore.Vector3(3,3,3)),setEnabled:t,children:jsxRuntime.jsx(GUIText$1,{text:f,fontSize:n!=null&&n.fontSize?n.fontSize:40,color:n!=null&&n.color?n.color:"white"})})]})})},FormationVolume$1=FormationVolume;var FormationGroup_FormationMode=(e=>(e[e.FACE=0]="FACE",e[e.VOLUME=1]="VOLUME",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(FormationGroup_FormationMode||{});function formationGroup_FormationModeFromJSON(e){switch(e){case 0:case"FACE":return 0;case 1:case"VOLUME":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function formationGroup_FormationModeToJSON(e){switch(e){case 0:return"FACE";case 1:return"VOLUME";case-1:default:return"UNRECOGNIZED"}}function createBaseFormationGroup(){return{name:"",formations:[],mode:0,effectMeshs:[]}}const FormationGroup={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.formations)FormationGroup_FormationInfo.encode(n,t.uint32(34).fork()).ldelim();e.mode!==0&&t.uint32(40).int32(e.mode);for(const n of e.effectMeshs)Mesh.encode(n,t.uint32(50).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseFormationGroup();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 4:if(o!==34)break;r.formations.push(FormationGroup_FormationInfo.decode(n,n.uint32()));continue;case 5:if(o!==40)break;r.mode=n.int32();continue;case 6:if(o!==50)break;r.effectMeshs.push(Mesh.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$a(e.name)?globalThis.String(e.name):"",formations:globalThis.Array.isArray(e==null?void 0:e.formations)?e.formations.map(t=>FormationGroup_FormationInfo.fromJSON(t)):[],mode:isSet$a(e.mode)?formationGroup_FormationModeFromJSON(e.mode):0,effectMeshs:globalThis.Array.isArray(e==null?void 0:e.effectMeshs)?e.effectMeshs.map(t=>Mesh.fromJSON(t)):[]}},toJSON(e){var n,a;const t={};return e.name!==""&&(t.name=e.name),(n=e.formations)!=null&&n.length&&(t.formations=e.formations.map(r=>FormationGroup_FormationInfo.toJSON(r))),e.mode!==0&&(t.mode=formationGroup_FormationModeToJSON(e.mode)),(a=e.effectMeshs)!=null&&a.length&&(t.effectMeshs=e.effectMeshs.map(r=>Mesh.toJSON(r))),t},create(e){return FormationGroup.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o;const t=createBaseFormationGroup();return t.name=(n=e.name)!=null?n:"",t.formations=((a=e.formations)==null?void 0:a.map(i=>FormationGroup_FormationInfo.fromPartial(i)))||[],t.mode=(r=e.mode)!=null?r:0,t.effectMeshs=((o=e.effectMeshs)==null?void 0:o.map(i=>Mesh.fromPartial(i)))||[],t}};function createBaseFormationGroup_FormationInfo(){return{name:"",url:""}}const FormationGroup_FormationInfo={encode(e,t=minimal.Writer.create()){return e.name!==""&&t.uint32(10).string(e.name),e.url!==""&&t.uint32(18).string(e.url),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseFormationGroup_FormationInfo();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.url=n.string();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$a(e.name)?globalThis.String(e.name):"",url:isSet$a(e.url)?globalThis.String(e.url):""}},toJSON(e){const t={};return e.name!==""&&(t.name=e.name),e.url!==""&&(t.url=e.url),t},create(e){return FormationGroup_FormationInfo.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseFormationGroup_FormationInfo();return t.name=(n=e.name)!=null?n:"",t.url=(a=e.url)!=null?a:"",t}};function isSet$a(e){return e!=null}const StructureLayer=({url:e,alpha:t=1,position:n=EngineCore.Vector3.Zero(),visible:a=!0,colorCodec:r,actions:o,counterLine:i=void 0,lines:s,text:l,disableDepthWrite:c})=>{const f=React.useRef(null),[u,d]=React.useState(""),h=React.useContext(WorkspaceMetaContext),m=React.useContext(ColorProviderContext),[R,v]=React.useState(null),[g,x]=React.useState(EngineCore.Color3.White()),y=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH}),[E,k]=React.useState(EngineCore.Vector3.Zero()),[b,C]=React.useState();return React.useEffect(()=>{console.log("[Geo3DViewer] StructureLayer Loading: ",e)},[e]),React.useEffect(()=>{if(y){const _=f.current;EngineCore.Tags.EnableFor(_),EngineCore.Tags.AddTagsTo(_,"loading");const A=Formation.decode(new Uint8Array(y)),{name:N,points:S,indices:I,value:O,colorId:F,center:L}=A;L&&k(new EngineCore.Vector3(L.x,L.y,L.z));const w=new EngineCore.VertexData;w.positions=S,w.indices=I,w.colors=O;const B=[];return EngineCore.VertexData.ComputeNormals(S,I,B),w.normals=B,v(F),d(N),_&&(w.applyToMesh(_),_.getScene().onAfterRenderObservable.addOnce(()=>{if(!_.isDisposed()){const W=_.getBoundingInfo();C(W.boundingBox)}})),EngineCore.Tags.RemoveTagsFrom(_,"loading"),()=>{v(null),d(""),_&&new EngineCore.VertexData().applyToMesh(_)}}},[y]),React.useEffect(()=>{const _=R&&m.colorIDs[R]?m.colorIDs[R]:EngineCore.Color3.White();x(EngineCore.Color3.FromArray([_.r,_.g,_.b]))},[R,m.colorIDs]),React.useEffect(()=>{f.current&&(f.current.metadata={pickable:o?{name:u,onLeftClick:o.onLeftClick,onRightClick:o.onRightClick,onMiddleClick:o.onMiddleClick,onHover:o.onHover,extra:o.extra}:null})},[o,u]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("transformNode",{name:`transform-structurelayer-${u}`,position:E.add(n).multiplyByFloats(h&&h.scalePlane?h.scalePlane:1,h&&h.scaleDepth?h.scaleDepth:1,h&&h.scalePlane?h.scalePlane:1),scaling:new EngineCore.Vector3(h?h.scalePlane:1,h?h.scaleDepth:1,h?h.scalePlane:1),setEnabled:a,children:[jsxRuntime.jsx("transformNode",{name:`structurelayer-${u}-load`}),jsxRuntime.jsx("mesh",{name:`structurelayer-${u}-mesh`,ref:f,useVertexColors:r!=null,children:r?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`structurelayer-${u}-mat`,backFaceCulling:!1,alpha:t,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:r,needDepthPrePass:!0,counterLine:i,boundingBox:b,lines:s,scaleDepth:h?h.scaleDepth:1,scalePlane:h?h.scalePlane:1,text:l,disableDepthWrite:c}):jsxRuntime.jsx("standardMaterial",{name:`structurelayer-${u}-mat`,backFaceCulling:!1,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),diffuseColor:g,needDepthPrePass:!0,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:t,disableDepthWrite:c})})]})})},StructureLayer$1=StructureLayer,FormationEdgeEffect=e=>{const{id:t,visible:n=!0,position:a=EngineCore.Vector3.Zero(),diffuseTextureUrl:r,diffuseTextureSufaceUrl:o,bumpTextureUrl:i,mesh:s}=e,l=React.useRef(null),c=React.useContext(WorkspaceMetaContext),[f,u]=React.useState(),[d,h]=React.useState(),[m,R]=React.useState();return React.useEffect(()=>{const v=l.current;if(v&&s){const g=new EngineCore.VertexData;g.positions=s.vertices,g.indices=s.indices,g.uvs=s.uv;const x=[];EngineCore.VertexData.ComputeNormals(s.vertices,s.indices,x),g.normals=x,g.applyToMesh(v)}},[s,s==null?void 0:s.indices,s==null?void 0:s.uv,s==null?void 0:s.vertices]),React.useEffect(()=>{const v=new EngineCore.Texture(r);if(v.uScale=500,v.vScale=.5,u(v),o){const x=new EngineCore.Texture(o);x.uScale=500,x.vScale=.5,h(x)}const g=new EngineCore.Texture(i);g.uScale=500,g.vScale=.5,R(g)},[i,o,r]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`transform-formation-edge-${t}`,position:a.multiplyByFloats(c&&c.scalePlane?c.scalePlane:1,c&&c.scaleDepth?c.scaleDepth:1,c&&c.scalePlane?c.scalePlane:1),scaling:new EngineCore.Vector3(c?c.scalePlane:1,c?c.scaleDepth:1,c?c.scalePlane:1),setEnabled:n,children:jsxRuntime.jsx("mesh",{name:"mesh",ref:l,children:jsxRuntime.jsx("standardMaterial",{name:`edge-${t}-material`,zOffset:-1,zOffsetUnits:-1,diffuseTexture:o?d:f,bumpTexture:o?void 0:m})})})})},FormationEdgeEffect$1=FormationEdgeEffect,ComplexFormationManager=({url:e,visible:t=!0,filter:n,explodedView:a=0,showLayerLabel:r,labelStyle:o,offset:i=new EngineCore.Vector3(0,0,0),showTopLayerAsStructureLayer:s=!1,useColorCodecOnTopLayer:l=!1,colorCodec:c,actions:f,materials:u,topLayerCounterLine:d=void 0,topLayerHeightOffset:h=1,diffuseTextureUrl:m,diffuseTextureSufaceUrl:R,bumpTextureUrl:v,visibleEdgeEffect:g=!1})=>{var I,O;const[x,y]=React.useState(),E=React.useContext(WorkspaceMetaContext),[k,b]=React.useState(!0),[C,_]=React.useState(""),A=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH}),[N,S]=React.useState([]);return React.useEffect(()=>{console.log("[Geo3DViewer] ComplexFormationManager Loading: ",e)},[e]),React.useEffect(()=>{if(A){const F=FormationGroup.decode(new Uint8Array(A)),L=F.formations;if(F.mode==FormationGroup_FormationMode.FACE){b(!0),_(F.name);const w=[];L.forEach((B,D)=>{const W={name:B.name,topUrl:B.url,bottomUrl:L[D+1]?L[D+1].url:void 0};w.push(W)}),y(w)}else{b(!1),_(F.name);const w=[];L.forEach(B=>{const D={name:B.name,topUrl:B.url};w.push(D)}),y(w)}return console.log(F),S(F.effectMeshs),()=>{y([])}}},[A]),jsxRuntime.jsxs("abstractMesh",{name:`complexformationmanager-${C}`,children:[s&&x&&x.length>1?jsxRuntime.jsx(StructureLayer$1,{url:x[0].topUrl,alpha:(I=u==null?void 0:u[x[0].name])==null?void 0:I.alpha,position:new EngineCore.Vector3(0,h>=0?h*(E&&(O=E.scaleDepth)!=null?O:1):0,0).add(i),visible:t&&(n?n.includes(x[0].name):!0),colorCodec:c,counterLine:d},`${C}-${x[0].name}-SL`):null,x?x.map((F,L)=>k?s&&L===0?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx("transformNode",{name:`${C}-${F.name}-EV`,position:i.add(new EngineCore.Vector3(0,L*(-1*a*(E&&E.scaleDepth?E.scaleDepth:0)),0)),children:jsxRuntime.jsx(FormationFace$1,{showLayerLabel:r,labelStyle:o,urlTopLayer:F.topUrl,urlBottomLayer:F.bottomUrl,visible:t&&(n?n.includes(F.name):!0),showBottomLayer:x[L+1]?n?n.includes(x[L+1].name):!0:!1,actions:f,material:L===0&&l?{...u==null?void 0:u[F.name],colorCodec:c,type:MaterialType.COLOR_CODEC}:u==null?void 0:u[F.name]},`${C}-${F.name}`)},`${C}-${F.name}`):s&&L===0?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx("transformNode",{name:`${C}-${F.name}-EV`,position:i.add(new EngineCore.Vector3(0,L*(-1*a*(E&&E.scaleDepth?E.scaleDepth:0)),0)),children:jsxRuntime.jsx(FormationVolume$1,{url:F.topUrl,showLayerLabel:r,labelStyle:o,visible:t&&(n?n.includes(F.name):!0),showBottomLayer:x[L+1]?n?n.includes(x[L+1].name):!0:!1,actions:f,material:u==null?void 0:u[F.name]},`${C}-${F.name}`)},`${C}-${F.name}`)):null,N&&m&&v&&a===0&&N.map((F,L)=>jsxRuntime.jsx(FormationEdgeEffect$1,{visible:g,id:L,diffuseTextureUrl:m,diffuseTextureSufaceUrl:L===0?R:void 0,bumpTextureUrl:v,mesh:F},L))]})},ComplexFormationManager$1=ComplexFormationManager,Coordinate=({visible:e=!0,color:t=EngineCore.Color3.White(),fontSize:n=80,step:a=200,keyFrameDistance:r=[],keyFrameStep:o=[],keyFrameFontSize:i=[],textureSizeX:s=512,textureSizeY:l=512,init:c=!0})=>{const f=reactBabylonjs.useScene(),u=React.useRef(null),d=React.useContext(WorkspaceMetaContext),[h,m]=React.useState([]),[R,v]=React.useState([]),[g,x]=React.useState([]),[y,E]=React.useState(0),k=React.useCallback(b=>{if(f&&b){const C=new EngineMaterial.GridMaterial("axis-material",f);C.majorUnitFrequency=o.length>0?o[0]:50,C.minorUnitVisibility=0,C.gridRatio=2,C.sideOrientation=EngineCore.Material.ClockWiseSideOrientation,C.backFaceCulling=!0,C.mainColor=t,C.lineColor=t,C.opacity=.98,b.material=C}},[t,o,f]);return React.useEffect(()=>()=>{var b;(b=u.current)==null||b.dispose()},[]),React.useEffect(()=>{const b=()=>{const C=(f==null?void 0:f.activeCamera).radius;for(let _=0;_<r.length;_++)if(C<=r[_]){E(_);break}};return f&&f.activeCamera&&(f==null||f.activeCamera.onViewMatrixChangedObservable.add(b)),()=>{f&&f.activeCamera&&(f==null||f.activeCamera.onViewMatrixChangedObservable.removeCallback(b))}},[r,i,o,f,e]),React.useEffect(()=>{if(d&&d.min&&d.max&&c){const b=d.origin||EngineCore.Vector3.Zero(),C=[],_=[],A=[],N=[...o];N.length===0&&N.push(a);for(let S=0;S<N.length;S++){let I=N[S]/1;I<1&&(I=200);const O=[];for(let w=0;w<=d.max.x-d.min.x;w+=I)O.push({text:`${w+d.min.x+b.x}`,position:new EngineCore.Vector3(w,0,0)}),O.push({text:`${w+d.min.x+b.x}`,position:new EngineCore.Vector3(w,d.max.y-d.min.y,d.max.z-d.min.z)}),O.push({text:`${w+d.min.x+b.x}`,position:new EngineCore.Vector3(w,d.max.y-d.min.y,0)}),O.push({text:`${w+d.min.x+b.x}`,position:new EngineCore.Vector3(w,0,d.max.z-d.min.z)});C.push(O);const F=[];for(let w=0;w<=d.max.y-d.min.y;w+=I)F.push({text:`${w+d.min.y+b.y}`,position:new EngineCore.Vector3(0,w,0)}),F.push({text:`${w+d.min.y+b.y}`,position:new EngineCore.Vector3(d.max.x-d.min.x,w,d.max.z-d.min.z)}),F.push({text:`${w+d.min.y+b.y}`,position:new EngineCore.Vector3(d.max.x-d.min.x,w,0)}),F.push({text:`${w+d.min.y+b.y}`,position:new EngineCore.Vector3(0,w,d.max.z-d.min.z)});_.push(F);const L=[];for(let w=0;w<=d.max.z-d.min.z;w+=I)L.push({text:`${w+d.min.z+b.z}`,position:new EngineCore.Vector3(0,0,w)}),L.push({text:`${w+d.min.z+b.z}`,position:new EngineCore.Vector3(d.max.x-d.min.x,d.max.y-d.min.y,w)}),L.push({text:`${w+d.min.z+b.z}`,position:new EngineCore.Vector3(0,d.max.y-d.min.y,w)}),L.push({text:`${w+d.min.z+b.z}`,position:new EngineCore.Vector3(d.max.x-d.min.x,0,w)});A.push(L)}m(C),v(_),x(A)}},[c,o,d,a]),d&&d.min&&d.max&&d.max.x-d.min.x>0&&d.max.y-d.min.y>0&&d.max.z-d.min.z>0?jsxRuntime.jsxs("transformNode",{name:"coord",setEnabled:e,position:(d&&d.min&&d.max?EngineCore.Vector3.Center(d.min,d.max):EngineCore.Vector3.Zero()).multiply(calcTransformNodeScale(d)),scaling:new EngineCore.Vector3(calcTransformNodeScale(d).x,calcTransformNodeScale(d).y,calcTransformNodeScale(d).z),children:[jsxRuntime.jsx("box",{name:"axis",width:d&&d.min&&d.max?d.max.x-d.min.x:0,height:d&&d.min&&d.max?d.max.y-d.min.y:0,depth:d&&d.min&&d.max?d.max.z-d.min.z:0,ref:k,isPickable:!1,isBlocker:!1},`axis-${d.max.x-d.min.x}-${d.max.y-d.min.y}-${d.max.z-d.min.z}`),jsxRuntime.jsxs("transformNode",{name:"axis-offset",position:d&&d.min&&d.max?new EngineCore.Vector3(-(d.max.x-d.min.x)/2,-(d.max.y-d.min.y)/2,-(d.max.z-d.min.z)/2):EngineCore.Vector3.Zero(),children:[h.map((b,C)=>b.map((_,A)=>{var S;const N=_;return jsxRuntime.jsx("transformNode",{name:`axis-x-${C}-${A}`,position:N==null?void 0:N.position,setEnabled:C===y,scaling:new EngineCore.Vector3(1/calcTransformNodeScale(d).x,1/calcTransformNodeScale(d).y,1/calcTransformNodeScale(d).z),children:jsxRuntime.jsx(GUIText$1,{text:`${N?N.text:""}`,fontSize:(S=i[C])!=null?S:n,color:t.toHexString()})},`axis-x-${C}-${A}`)})),R.map((b,C)=>b.map((_,A)=>{var S;const N=_;return jsxRuntime.jsx("transformNode",{name:`axis-x-${C}-${A}`,position:N==null?void 0:N.position,setEnabled:C===y,scaling:new EngineCore.Vector3(1/calcTransformNodeScale(d).x,1/calcTransformNodeScale(d).y,1/calcTransformNodeScale(d).z),children:jsxRuntime.jsx(GUIText$1,{text:`${N?N.text:""}`,fontSize:(S=i[C])!=null?S:n,color:t.toHexString()})},`axis-x-${C}-${A}`)})),g.map((b,C)=>b.map((_,A)=>{var S;const N=_;return jsxRuntime.jsx("transformNode",{name:`axis-x-${C}-${A}`,position:N==null?void 0:N.position,setEnabled:C===y,scaling:new EngineCore.Vector3(1/calcTransformNodeScale(d).x,1/calcTransformNodeScale(d).y,1/calcTransformNodeScale(d).z),children:jsxRuntime.jsx(GUIText$1,{text:`${N?N.text:""}`,fontSize:(S=i[C])!=null?S:n,color:t.toHexString()})},`axis-x-${C}-${A}`)}))]})]},`coord-${d.min.x}-${d.min.y}-${d.min.z}-${d.max.x}-${d.max.y}-${d.max.z}-${Math.abs(d.max.x-d.min.x)}-${Math.abs(d.max.y-d.min.y)}-${Math.abs(d.max.z-d.min.z)}`):jsxRuntime.jsx(jsxRuntime.Fragment,{})},Coordinate$1=Coordinate;function contourLine_ContourLineTypeFromJSON(e){switch(e){case 0:case"NORMAL":return 0;case 1:case"CICLE":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function contourLine_ContourLineTypeToJSON(e){switch(e){case 0:return"NORMAL";case 1:return"CICLE";case-1:default:return"UNRECOGNIZED"}}function createBaseContourLine(){return{name:"",lines:[]}}const ContourLine$2={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.lines)ContourLine_Line.encode(n,t.uint32(18).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseContourLine();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.lines.push(ContourLine_Line.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$9(e.name)?globalThis.String(e.name):"",lines:globalThis.Array.isArray(e==null?void 0:e.lines)?e.lines.map(t=>ContourLine_Line.fromJSON(t)):[]}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),(n=e.lines)!=null&&n.length&&(t.lines=e.lines.map(a=>ContourLine_Line.toJSON(a))),t},create(e){return ContourLine$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseContourLine();return t.name=(n=e.name)!=null?n:"",t.lines=((a=e.lines)==null?void 0:a.map(r=>ContourLine_Line.fromPartial(r)))||[],t}};function createBaseContourLine_LineSegment(){return{positions:[]}}const ContourLine_LineSegment={encode(e,t=minimal.Writer.create()){for(const n of e.positions)Position.encode(n,t.uint32(10).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseContourLine_LineSegment();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.positions.push(Position.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{positions:globalThis.Array.isArray(e==null?void 0:e.positions)?e.positions.map(t=>Position.fromJSON(t)):[]}},toJSON(e){var n;const t={};return(n=e.positions)!=null&&n.length&&(t.positions=e.positions.map(a=>Position.toJSON(a))),t},create(e){return ContourLine_LineSegment.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=createBaseContourLine_LineSegment();return t.positions=((n=e.positions)==null?void 0:n.map(a=>Position.fromPartial(a)))||[],t}};function createBaseContourLine_Line(){return{segments:[],type:0,position:void 0}}const ContourLine_Line={encode(e,t=minimal.Writer.create()){for(const n of e.segments)ContourLine_LineSegment.encode(n,t.uint32(10).fork()).ldelim();return e.type!==0&&t.uint32(16).int32(e.type),e.position!==void 0&&Position.encode(e.position,t.uint32(26).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseContourLine_Line();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.segments.push(ContourLine_LineSegment.decode(n,n.uint32()));continue;case 2:if(o!==16)break;r.type=n.int32();continue;case 3:if(o!==26)break;r.position=Position.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{segments:globalThis.Array.isArray(e==null?void 0:e.segments)?e.segments.map(t=>ContourLine_LineSegment.fromJSON(t)):[],type:isSet$9(e.type)?contourLine_ContourLineTypeFromJSON(e.type):0,position:isSet$9(e.position)?Position.fromJSON(e.position):void 0}},toJSON(e){var n;const t={};return(n=e.segments)!=null&&n.length&&(t.segments=e.segments.map(a=>ContourLine_LineSegment.toJSON(a))),e.type!==0&&(t.type=contourLine_ContourLineTypeToJSON(e.type)),e.position!==void 0&&(t.position=Position.toJSON(e.position)),t},create(e){return ContourLine_Line.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseContourLine_Line();return t.segments=((n=e.segments)==null?void 0:n.map(r=>ContourLine_LineSegment.fromPartial(r)))||[],t.type=(a=e.type)!=null?a:0,t.position=e.position!==void 0&&e.position!==null?Position.fromPartial(e.position):void 0,t}};function isSet$9(e){return e!=null}const Line=({points:e=[],showPoint:t=!0,color:n=EngineCore.Color3.White(),pointSize:a=2,alwaysOnTop:r=!1,offset:o=EngineCore.Vector3.Zero(),alpha:i,lineWidth:s})=>{const l=reactBabylonjs.useScene(),c=React.useRef(null),f=React.useContext(WorkspaceMetaContext);return React.useEffect(()=>{if(l){const u=[],d=calcTransformNodeScale(f);if(e.forEach(h=>{u.push(h.add(o).multiply(d))}),s){const h={path:u,radius:s,updatable:!0};if(c.current)h.instance=c.current,EngineCore.MeshBuilder.CreateTube("line",h);else{c.current=EngineCore.MeshBuilder.CreateTube("line",h,l);const m=new EngineCore.StandardMaterial("line-mat");return m.diffuseColor=n,m.specularColor=EngineCore.Color3.Black(),m.emissiveColor=n,i!==void 0&&(m.alpha=i,m.transparencyMode=2),m.depthFunction=r?EngineCore.Constants.ALWAYS:0,c.current.material=m,()=>{c.current&&(l.removeMesh(c.current),c.current=null)}}}else{const h={points:u,updateable:!0};if(c.current)h.instance=c.current,EngineCore.MeshBuilder.CreateLines("line",h);else{c.current=EngineCore.MeshBuilder.CreateLines("line",h,l);const m=new EngineCore.StandardMaterial("line-mat");return m.diffuseColor=n,m.specularColor=EngineCore.Color3.Black(),m.emissiveColor=n,i!==void 0&&(m.alpha=i,m.transparencyMode=2),m.depthFunction=r?EngineCore.Constants.ALWAYS:0,()=>{c.current&&(l.removeMesh(c.current),c.current=null)}}}}},[r,n,f,o,e,l,s,c,i]),jsxRuntime.jsx("transformNode",{name:"transform-line",children:t?jsxRuntime.jsx("transformNode",{name:"lines-point",children:e.map((u,d)=>jsxRuntime.jsx("sphere",{diameter:a,name:`lines-point-${d}`,position:u.add(o).multiply(calcTransformNodeScale(f)),scalingDeterminant:s&&(f==null?void 0:f.scalePlane)||1,children:jsxRuntime.jsx("standardMaterial",{name:`lines-point-${d}-mat`,diffuseColor:n,emissiveColor:n,specularColor:EngineCore.Color3.White(),depthFunction:r?EngineCore.Constants.ALWAYS:void 0})},`lines-point-${u.x}-${u.y}-${u.z}`))}):jsxRuntime.jsx(jsxRuntime.Fragment,{})})},Line$1=Line,ContourText=e=>{const{name:t,prev:n,next:a,textColor:r,fontSize:o}=e,i=reactBabylonjs.useScene(),s=React.useRef(null);return React.useEffect(()=>{const l=i==null?void 0:i.activeCamera,c=i==null?void 0:i.getEngine();if(i&&l&&c&&s.current){const f=s.current.getChildren()[0],u=EngineCore.Vector3.Normalize(a.subtract(n)),d=new EngineCore.Vector3(1,0,0),h=Math.acos(EngineCore.Vector3.Dot(u,d)),m=EngineCore.Vector3.Cross(u,d);f.rotation.z=m.y>0?h:Math.PI*2-h,f.rotation.x=Math.PI/2,f.renderingGroupId=3}},[a,n,i]),jsxRuntime.jsx("transformNode",{name:`${t}`,position:EngineCore.Vector3.Lerp(n,a,.5),ref:s,children:jsxRuntime.jsx(GUIText$1,{text:t,fontSize:o,color:r,billboardMode:EngineCore.Mesh.BILLBOARDMODE_NONE})})},ContourText$1=ContourText,ContourLine=e=>{const{url:t,color:n,alpha:a,visible:r=!0,fontSize:o=30,textColor:i="red",linewidth:s=10}=e,l=reactBabylonjs.useScene(),[c,f]=React.useState([]),[u,d]=React.useState([]),h=React.useContext(WorkspaceMetaContext);return React.useEffect(()=>{axios.get(t,{responseType:"arraybuffer"}).then(m=>{const R=ContourLine$2.decode(new Uint8Array(m.data));console.log(R);const v=[],g=[];for(let x=0;x<R.lines.length;x++){const y=R.lines[x];if(y.segments.length<2)continue;const E=[];for(let k=0;k<y.segments.length;k++){const b=[...convertPositionArrayToVector3(y.segments[k].positions)];v.push([...b]),E.push(b[0]),E.push(b[b.length-1])}y.type===1&&E.push(convertPositionToVector3(y.segments[0].positions[0])),g.push(E)}f(v),d(g),console.log(g),console.log(v)})},[l,t]),jsxRuntime.jsxs("transformNode",{name:"contourline",setEnabled:r,children:[c.map((m,R)=>m.length<2||!r?null:jsxRuntime.jsx(Line$1,{points:m,showPoint:!1,color:n,alpha:a,lineWidth:s,alwaysOnTop:!0},R)),u.map(m=>m.map((R,v)=>v%2===0||v===m.length-1?null:jsxRuntime.jsx(ContourText$1,{name:R.y.toFixed(0),prev:calcTransformNodeScale(h).multiply(R),next:calcTransformNodeScale(h).multiply(m[v+1]),fontSize:o,textColor:i},v)))]})},ContourLine$1=ContourLine;function densitySlice_DirectionFromJSON(e){switch(e){case 0:case"X":return 0;case 1:case"Y":return 1;case 2:case"Z":return 2;case 3:case"FREE":return 3;case-1:case"UNRECOGNIZED":default:return-1}}function densitySlice_DirectionToJSON(e){switch(e){case 0:return"X";case 1:return"Y";case 2:return"Z";case 3:return"FREE";case-1:default:return"UNRECOGNIZED"}}function createBaseDensitySlice(){return{layer:0,direction:0,colorId:0,points:[],indices:[],value:[],vMin:0,vMax:0,center:void 0}}const DensitySlice$2={encode(e,t=minimal.Writer.create()){e.layer!==0&&t.uint32(8).uint32(e.layer),e.direction!==0&&t.uint32(16).int32(e.direction),e.colorId!==0&&t.uint32(24).uint32(e.colorId),t.uint32(170).fork();for(const n of e.points)t.float(n);t.ldelim(),t.uint32(178).fork();for(const n of e.indices)t.uint32(n);t.ldelim(),t.uint32(186).fork();for(const n of e.value)t.float(n);return t.ldelim(),e.vMin!==0&&t.uint32(205).float(e.vMin),e.vMax!==0&&t.uint32(213).float(e.vMax),e.center!==void 0&&Vertex.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseDensitySlice();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==8)break;r.layer=n.uint32();continue;case 2:if(o!==16)break;r.direction=n.int32();continue;case 3:if(o!==24)break;r.colorId=n.uint32();continue;case 21:if(o===173){r.points.push(n.float());continue}if(o===170){const i=n.uint32()+n.pos;for(;n.pos<i;)r.points.push(n.float());continue}break;case 22:if(o===176){r.indices.push(n.uint32());continue}if(o===178){const i=n.uint32()+n.pos;for(;n.pos<i;)r.indices.push(n.uint32());continue}break;case 23:if(o===189){r.value.push(n.float());continue}if(o===186){const i=n.uint32()+n.pos;for(;n.pos<i;)r.value.push(n.float());continue}break;case 25:if(o!==205)break;r.vMin=n.float();continue;case 26:if(o!==213)break;r.vMax=n.float();continue;case 31:if(o!==250)break;r.center=Vertex.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{layer:isSet$8(e.layer)?globalThis.Number(e.layer):0,direction:isSet$8(e.direction)?densitySlice_DirectionFromJSON(e.direction):0,colorId:isSet$8(e.colorId)?globalThis.Number(e.colorId):0,points:globalThis.Array.isArray(e==null?void 0:e.points)?e.points.map(t=>globalThis.Number(t)):[],indices:globalThis.Array.isArray(e==null?void 0:e.indices)?e.indices.map(t=>globalThis.Number(t)):[],value:globalThis.Array.isArray(e==null?void 0:e.value)?e.value.map(t=>globalThis.Number(t)):[],vMin:isSet$8(e.vMin)?globalThis.Number(e.vMin):0,vMax:isSet$8(e.vMax)?globalThis.Number(e.vMax):0,center:isSet$8(e.center)?Vertex.fromJSON(e.center):void 0}},toJSON(e){var n,a,r;const t={};return e.layer!==0&&(t.layer=Math.round(e.layer)),e.direction!==0&&(t.direction=densitySlice_DirectionToJSON(e.direction)),e.colorId!==0&&(t.colorId=Math.round(e.colorId)),(n=e.points)!=null&&n.length&&(t.points=e.points),(a=e.indices)!=null&&a.length&&(t.indices=e.indices.map(o=>Math.round(o))),(r=e.value)!=null&&r.length&&(t.value=e.value),e.vMin!==0&&(t.vMin=e.vMin),e.vMax!==0&&(t.vMax=e.vMax),e.center!==void 0&&(t.center=Vertex.toJSON(e.center)),t},create(e){return DensitySlice$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l,c;const t=createBaseDensitySlice();return t.layer=(n=e.layer)!=null?n:0,t.direction=(a=e.direction)!=null?a:0,t.colorId=(r=e.colorId)!=null?r:0,t.points=((o=e.points)==null?void 0:o.map(f=>f))||[],t.indices=((i=e.indices)==null?void 0:i.map(f=>f))||[],t.value=((s=e.value)==null?void 0:s.map(f=>f))||[],t.vMin=(l=e.vMin)!=null?l:0,t.vMax=(c=e.vMax)!=null?c:0,t.center=e.center!==void 0&&e.center!==null?Vertex.fromPartial(e.center):void 0,t}};function isSet$8(e){return e!=null}const DensitySlice=({name:e,url:t,visible:n=!0,colorCodec:a,alpha:r=1,position:o=EngineCore.Vector3.Zero(),actions:i})=>{const s=React.useRef(null),[l,c]=React.useState(""),[f,u]=React.useState(""),d=React.useContext(WorkspaceMetaContext),h=useCachedBinary({url:t,cacheType:CacheType.URL_PREFIX_MATCH}),[m,R]=React.useState(EngineCore.Vector3.Zero());return React.useEffect(()=>{if(h){EngineCore.Tags.EnableFor(s.current),EngineCore.Tags.AddTagsTo(s.current,"loading");const v=DensitySlice$2.decode(new Uint8Array(h)),{layer:g,direction:x,points:y,indices:E,value:k,center:b}=v,C=new EngineCore.VertexData;C.positions=y,C.indices=E,C.colors=k;const _=[];EngineCore.VertexData.ComputeNormals(y,E,_),C.normals=_,b&&R(new EngineCore.Vector3(b.x,b.y,b.z));const A=s.current;return A&&(C.applyToMesh(A),c(g.toString()),u(x.toString())),EngineCore.Tags.RemoveTagsFrom(A,"loading"),()=>{c(""),u(""),A&&new EngineCore.VertexData().applyToMesh(A)}}},[h]),React.useEffect(()=>{s.current&&(s.current.metadata={pickable:i?{name:e,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null})},[i,e]),React.useEffect(()=>{console.log("[Geo3DViewer] DensitySlice Loading: ",t)},[t]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`densityslice-${e}-${f}-${l}-transform`,position:m.add(o).multiplyByFloats(d&&d.scalePlane?d.scalePlane:1,d&&d.scaleDepth?d.scaleDepth:1,d&&d.scalePlane?d.scalePlane:1),scaling:new EngineCore.Vector3(d?d.scalePlane:1,d?d.scaleDepth:1,d?d.scalePlane:1),children:jsxRuntime.jsx("mesh",{name:`densityslice-${e}-${f}-${l}-mesh`,ref:s,setEnabled:n,children:jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`densityslice-${e}-${f}-${l}-mat`,backFaceCulling:!1,needDepthPrePass:!0,alpha:r,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:a})})})})},DensitySlice$1=DensitySlice,FPS=()=>{const e=reactBabylonjs.useScene(),t=React.useRef(void 0);return React.useEffect(()=>{const n=setInterval(()=>{if(e&&t.current){const a=e.getEngine().getFps();t.current.getControlByName("fps").text=a.toFixed(0)+"FPS"}},1e3);return()=>{clearInterval(n)}},[e]),React.useEffect(()=>{var n,a;if(e&&!t.current){const r=EngineGui.AdvancedDynamicTexture.CreateFullscreenUI("UI",!0,e);t.current=r;const o=new EngineGui.TextBlock("fps");o.text="0FPS",o.color="white",o.fontSize=15,o.width=100,o.height=50;const i=window.devicePixelRatio||1,s=(n=e.getEngine().getRenderingCanvas())==null?void 0:n.clientHeight,l=(a=e.getEngine().getRenderingCanvas())==null?void 0:a.clientWidth;o.left=l?-(l*i/2-50):0,o.top=s?-(s*i/2-25):0,r.addControl(o)}return()=>{e&&t.current}},[e]),null},FPS$1=FPS,FormationManager=({url:e,visible:t=!0,filter:n,explodedView:a=0,offset:r=new EngineCore.Vector3(0,0,0),showLayerLabel:o,labelStyle:i,actions:s,materials:l})=>{const[c,f]=React.useState(),u=React.useContext(WorkspaceMetaContext),[d,h]=React.useState(!0),[m,R]=React.useState(""),v=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH});return React.useEffect(()=>{console.log("[Geo3DViewer] FormationManager Loading: ",e)},[e]),React.useEffect(()=>{if(v){const g=FormationGroup.decode(new Uint8Array(v)),x=g.formations;if(g.mode==FormationGroup_FormationMode.FACE){h(!0),R(g.name);const y=[];x.forEach((E,k)=>{const b={name:E.name,topUrl:E.url,bottomUrl:x[k+1]?x[k+1].url:void 0};y.push(b)}),f(y)}else{h(!1),R(g.name);const y=[];x.forEach(E=>{const k={name:E.name,topUrl:E.url};y.push(k)}),f(y)}return console.log(x),()=>{R(""),f([])}}},[v]),jsxRuntime.jsx("abstractMesh",{name:`formationmanager-${m}`,children:c?c.map((g,x)=>d?jsxRuntime.jsx("transformNode",{name:`${m}-${g.name}-EV`,position:r.add(new EngineCore.Vector3(0,x*(-1*a*(u&&u.scaleDepth?u.scaleDepth:0)),0)),children:jsxRuntime.jsx(FormationFace$1,{showLayerLabel:o,labelStyle:i,urlTopLayer:g.topUrl,urlBottomLayer:g.bottomUrl,visible:t&&(n?n.includes(g.name):!0),showBottomLayer:c[x+1]?n?n.includes(c[x+1].name):!0:!1,actions:s,material:l==null?void 0:l[g.name]},`${m}-${g.name}`)},`${m}-${g.name}`):jsxRuntime.jsx("transformNode",{name:`${m}-${g.name}-EV`,position:r.add(new EngineCore.Vector3(0,x*(-1*a*(u&&u.scaleDepth?u.scaleDepth:0)),0)),children:jsxRuntime.jsx(FormationVolume$1,{url:g.topUrl,showLayerLabel:o,labelStyle:i,visible:t&&(n?n.includes(g.name):!0),showBottomLayer:c[x+1]?n?n.includes(c[x+1].name):!0:!1,actions:s,material:l==null?void 0:l[g.name]},`${m}-${g.name}`)},`${m}-${g.name}`)):null})},FormationManager$1=FormationManager;function createBaseFormationSlices(){return{name:"",slices:[],center:void 0}}const FormationSlices={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.slices)FormationSlices_Slice.encode(n,t.uint32(18).fork()).ldelim();return e.center!==void 0&&Vertex.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseFormationSlices();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.slices.push(FormationSlices_Slice.decode(n,n.uint32()));continue;case 31:if(o!==250)break;r.center=Vertex.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$7(e.name)?globalThis.String(e.name):"",slices:globalThis.Array.isArray(e==null?void 0:e.slices)?e.slices.map(t=>FormationSlices_Slice.fromJSON(t)):[],center:isSet$7(e.center)?Vertex.fromJSON(e.center):void 0}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),(n=e.slices)!=null&&n.length&&(t.slices=e.slices.map(a=>FormationSlices_Slice.toJSON(a))),e.center!==void 0&&(t.center=Vertex.toJSON(e.center)),t},create(e){return FormationSlices.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseFormationSlices();return t.name=(n=e.name)!=null?n:"",t.slices=((a=e.slices)==null?void 0:a.map(r=>FormationSlices_Slice.fromPartial(r)))||[],t.center=e.center!==void 0&&e.center!==null?Vertex.fromPartial(e.center):void 0,t}};function createBaseFormationSlices_Slice(){return{name:"",colorId:0,vertices:[],indices:[],edges:[]}}const FormationSlices_Slice={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.colorId!==0&&t.uint32(16).uint32(e.colorId),t.uint32(26).fork();for(const n of e.vertices)t.float(n);t.ldelim(),t.uint32(34).fork();for(const n of e.indices)t.uint32(n);t.ldelim();for(const n of e.edges)Vertex.encode(n,t.uint32(42).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseFormationSlices_Slice();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==16)break;r.colorId=n.uint32();continue;case 3:if(o===29){r.vertices.push(n.float());continue}if(o===26){const i=n.uint32()+n.pos;for(;n.pos<i;)r.vertices.push(n.float());continue}break;case 4:if(o===32){r.indices.push(n.uint32());continue}if(o===34){const i=n.uint32()+n.pos;for(;n.pos<i;)r.indices.push(n.uint32());continue}break;case 5:if(o!==42)break;r.edges.push(Vertex.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$7(e.name)?globalThis.String(e.name):"",colorId:isSet$7(e.colorId)?globalThis.Number(e.colorId):0,vertices:globalThis.Array.isArray(e==null?void 0:e.vertices)?e.vertices.map(t=>globalThis.Number(t)):[],indices:globalThis.Array.isArray(e==null?void 0:e.indices)?e.indices.map(t=>globalThis.Number(t)):[],edges:globalThis.Array.isArray(e==null?void 0:e.edges)?e.edges.map(t=>Vertex.fromJSON(t)):[]}},toJSON(e){var n,a,r;const t={};return e.name!==""&&(t.name=e.name),e.colorId!==0&&(t.colorId=Math.round(e.colorId)),(n=e.vertices)!=null&&n.length&&(t.vertices=e.vertices),(a=e.indices)!=null&&a.length&&(t.indices=e.indices.map(o=>Math.round(o))),(r=e.edges)!=null&&r.length&&(t.edges=e.edges.map(o=>Vertex.toJSON(o))),t},create(e){return FormationSlices_Slice.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=createBaseFormationSlices_Slice();return t.name=(n=e.name)!=null?n:"",t.colorId=(a=e.colorId)!=null?a:0,t.vertices=((r=e.vertices)==null?void 0:r.map(s=>s))||[],t.indices=((o=e.indices)==null?void 0:o.map(s=>s))||[],t.edges=((i=e.edges)==null?void 0:i.map(s=>Vertex.fromPartial(s)))||[],t}};function isSet$7(e){return e!=null}const FormationComponent=(e,t)=>{var O,F,L,w;const n=reactBabylonjs.useScene(),a=React.useRef(null),r=React.useRef(null),o=React.useContext(WorkspaceMetaContext),i=React.useContext(ColorProviderContext),[s,l]=React.useState(EngineCore.Color3.White()),{id:c,visible:f=!0,vertices:u,indices:d,colorId:h,position:m,normals:R,material:v={type:MaterialType.COLOR_ID},children:g,alpha:x=1,style:y,name:E="formation",highStyle:k,lowStyle:b,edges:C=[]}=e,_=useCachedTexture({url:v==null?void 0:v.texture,cacheType:CacheType.URL_PREFIX_MATCH}),A=useCachedTexture({url:v==null?void 0:v.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),[N,S]=React.useState();React.useImperativeHandle(t,()=>r.current,[]),React.useEffect(()=>{if(a&&a.current&&n){const B=new EngineCore.VertexData;B.positions=u,B.indices=d,B.normals=R;const D=a.current;B.applyToMesh(D),D.getScene().onAfterRenderObservable.addOnce(()=>{if(!D.isDisposed()){const ae=D.getBoundingInfo();S(ae.boundingBox)}})}},[d,u,n,c,R]),React.useEffect(()=>{var B;l(v.type===MaterialType.ONE_COLOR?(B=v==null?void 0:v.color)!=null?B:EngineCore.Color3.Random():h&&i.colorIDs[h]?new EngineCore.Color3(i.colorIDs[h].r,i.colorIDs[h].g,i.colorIDs[h].b):EngineCore.Color3.Random())},[i.colorIDs,h,v==null?void 0:v.color,v.type]);const I=(B,D,W)=>{const ae=D.subtract(B),ne=1+1e3/EngineCore.Vector3.Distance(B,D)*(W-1),U=ae.scale(ne);return B.add(U)};return jsxRuntime.jsxs("transformNode",{name:`node-${E}-${c}`,setEnabled:f,children:[jsxRuntime.jsxs("transformNode",{name:`${E}`,position:m?m.multiply(calcTransformNodeScale(o)):new EngineCore.Vector3(0,0,0),scaling:calcTransformNodeScale(o),ref:r,children:[jsxRuntime.jsx("mesh",{name:`${E}-mesh`,ref:a,children:v.type===MaterialType.TEXTURE?_?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`formationslice-${E}-mat`,backFaceCulling:!1,needDepthPrePass:v.needDepthPrePass===void 0?!1:v.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:x,sideTexture:A,texture:_,tilingFactor:v.tilingFactor,sideTilingFactor:(O=v==null?void 0:v.sideTilingFactor)!=null?O:v==null?void 0:v.tilingFactor,mode:v.textureMode===void 0?RepeatedTextureMode.PLANE:v.textureMode,boundingBox:N,lines:v.lines,text:v.text,scaleDepth:o?o.scaleDepth:1,scalePlane:o?o.scalePlane:1,disableDepthWrite:v.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):v.type===MaterialType.COLOR_CODEC?v.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`formation-${E}-mat`,backFaceCulling:!1,needDepthPrePass:v.needDepthPrePass===void 0?!1:v.needDepthPrePass,alpha:x,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:v.colorCodec,boundingBox:N,lines:v.lines,text:v.text,scaleDepth:o?o.scaleDepth:1,scalePlane:o?o.scalePlane:1,disableDepthWrite:v.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):v.type===MaterialType.COLOR_ID?jsxRuntime.jsx("standardMaterial",{name:`formation-${E}-mat`,backFaceCulling:!1,needDepthPrePass:v.needDepthPrePass===void 0?!1:v.needDepthPrePass,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),diffuseColor:s,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:x,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,disableDepthWrite:v.disableDepthWrite}):jsxRuntime.jsx("standardMaterial",{name:`formation-${E}-mat`,backFaceCulling:!1,needDepthPrePass:v.needDepthPrePass===void 0?!1:v.needDepthPrePass,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),diffuseColor:s,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:x,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,disableDepthWrite:v.disableDepthWrite})}),y.position&&jsxRuntime.jsx("transformNode",{name:`${E}-title`,position:I(convertVertexToVector3(y.basePosition==="left"?C[4]:C[5]),y.position,(F=y.offset)!=null?F:1),scaling:calcGUIScale(o),children:y.title&&jsxRuntime.jsx(GUIText$1,{text:y.title,fontSize:y.fontSize?y.fontSize:40,color:y.color?y.color:"black"})}),b&&b.position&&jsxRuntime.jsx("transformNode",{name:`${E}-up-title`,position:I(convertVertexToVector3(b.basePosition==="left"?C[4]:C[5]),b.position,(L=b.offset)!=null?L:1),scaling:calcGUIScale(o),children:b.title&&jsxRuntime.jsx(GUIText$1,{text:b.title,fontSize:b.fontSize?b.fontSize:40,color:b.color?b.color:"black"})}),k&&k.position&&jsxRuntime.jsx("transformNode",{name:`${E}-down-title`,position:I(convertVertexToVector3(k.basePosition==="left"?C[4]:C[5]),k.position,(w=k.offset)!=null?w:1),scaling:calcGUIScale(o),children:k.title&&jsxRuntime.jsx(GUIText$1,{text:k.title,fontSize:k.fontSize?k.fontSize:40,color:k.color?k.color:"black"})})]}),g]})},FormationComponent$1=React.forwardRef(FormationComponent),FormationSlice=e=>{const[t,n]=React.useState([]),[a,r]=React.useState(""),{url:o,visible:i=!0,materials:s,actions:l,style:c,highStyle:f,lowStyle:u,basePosition:d="left"}=e,h=React.useRef(null),m=React.useContext(WorkspaceMetaContext),R=useCachedBinary({url:o,cacheType:CacheType.URL_PREFIX_MATCH}),[v,g]=React.useState(EngineCore.Vector3.Zero());return React.useEffect(()=>{console.log("[Geo3DViewer] FormationSlice Loading: ",o)},[o]),React.useEffect(()=>{if(R){const x=FormationSlices.decode(new Uint8Array(R));x.center&&g(new EngineCore.Vector3(x.center.x,x.center.y,x.center.z));const y=x.slices.map(E=>{const k=[];return EngineCore.VertexData.ComputeNormals(E.vertices,E.indices,k),{name:E.name,colorId:E.colorId,vertices:E.vertices,indices:E.indices,edges:E.edges,normals:k}});return r(x.name),n(y),()=>{r(""),n([])}}},[R]),React.useEffect(()=>{var y;const x=(y=h.current)==null?void 0:y.getChildMeshes()[0];x&&(x.metadata={pickable:l?{name:a,onLeftClick:l.onLeftClick,onRightClick:l.onRightClick,onMiddleClick:l.onMiddleClick,onHover:l.onHover,extra:l.extra}:null})},[l,a]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`foramtionslice-${a}-holder`,setEnabled:i,position:v.multiply(calcTransformNodeScale(m)),children:t.map((x,y)=>{const E=x.edges.length>0?convertVertexToVector3(d==="left"?x.edges[0]:x.edges[2]):new EngineCore.Vector3(0,0,0),k=x.edges.length>0?convertVertexToVector3(d==="left"?x.edges[1]:x.edges[3]):new EngineCore.Vector3(0,0,0),b=EngineCore.Vector3.Lerp(E,k,.5);return jsxRuntime.jsx(FormationComponent$1,{id:y,vertices:x.vertices,indices:x.indices,colorId:x.colorId,normals:x.normals,name:x.name,edges:x.edges,style:c?{position:b,title:x.name,basePosition:d,...c}:{},lowStyle:u?{position:k,title:(v.y+k.y).toFixed(0).toString(),basePosition:d,...u}:{},highStyle:f&&y===t.length-1?{position:E,title:(v.y+E.y).toFixed(0).toString(),basePosition:d,...f}:{},material:s?{...s[x.name],backFaceCulling:!1}:void 0,ref:h},y)})})})},FormationSlice$1=FormationSlice,TransformGUIText=e=>{const{name:t="node",text:n,fontSize:a,color:r,position:o=EngineCore.Vector3.Zero(),scale:i=EngineCore.Vector3.One(),blink:s=!1}=e,[l,c]=React.useState(!0);return React.useEffect(()=>{const f=setInterval(()=>{s&&c(u=>!u)},1e3);return()=>{clearInterval(f)}},[s]),jsxRuntime.jsx("transformNode",{name:`${t}-text`,position:o,scaling:i,setEnabled:l,children:jsxRuntime.jsx(GUIText$1,{name:t,text:n,fontSize:a,color:r})})},TransformGUIText$1=TransformGUIText;var AxesViewerPosition=(e=>(e[e.NONE=0]="NONE",e[e.BOTTOM_LEFT=1]="BOTTOM_LEFT",e[e.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",e[e.TOP_LEFT=3]="TOP_LEFT",e[e.TOP_RIGHT=4]="TOP_RIGHT",e))(AxesViewerPosition||{});const Geo3DCamera=({target:e,radius:t,alpha:n,beta:a,axesViewerOffset:r=EngineCore.Vector3.Zero(),panningSensibility:o=2,wheelDeltaPercentage:i=0,axesViewer:s=0,farPlane:l=1e4,skipPickingWhenCameraMoves:c=!1})=>{const f=reactBabylonjs.useScene(),u=React.useContext(WorkspaceMetaContext),[d,h]=React.useState(null),[m,R]=React.useState(null),[v,g]=React.useState(n),[x,y]=React.useState(a),[,E]=React.useState(null),k=React.useCallback(N=>{R(N)},[]),{setViewCamera:b}=React.useContext(ViewerCameraPropsContext),C=React.useCallback(()=>{if(m&&d){const N=new EngineCore.Vector3;N.addInPlace(m.position),N.addInPlace(m.getDirection(new EngineCore.Vector3(0,0,25))),s==4?(N.addInPlace(m.getDirection(new EngineCore.Vector3(0,7+r.y,0))),N.addInPlace(m.getDirection(new EngineCore.Vector3(15+r.x,0,0)))):s==3?(N.addInPlace(m.getDirection(new EngineCore.Vector3(0,7+r.y,0))),N.addInPlace(m.getDirection(new EngineCore.Vector3(-15+r.x,0,0)))):s==2?(N.addInPlace(m.getDirection(new EngineCore.Vector3(0,-7+r.y,0))),N.addInPlace(m.getDirection(new EngineCore.Vector3(15+r.x,0,0)))):s==1&&(N.addInPlace(m.getDirection(new EngineCore.Vector3(0,-7+r.y,0))),N.addInPlace(m.getDirection(new EngineCore.Vector3(-15+r.x,0,0)))),d.xAxis.position=N.clone(),d.yAxis.position=N.clone(),d.zAxis.position=N.clone()}},[m,d,s,r.y,r.x]);React.useEffect(()=>{if(f&&s!=0){const N=new EngineCore.AxesViewer(f,2,null);return h(N),()=>{N==null||N.dispose(),h(null)}}},[f,s]),React.useEffect(()=>{C()},[C]);const _=React.useCallback(N=>{if(u&&u.min&&u.max)return EngineCore.Vector3.Clamp(N,u==null?void 0:u.min,u==null?void 0:u.max)},[u]),A=React.useCallback(N=>{f&&(f.skipPointerMovePicking=N)},[f]);return React.useEffect(()=>{if(!f||!m)return;const N=m.onViewMatrixChangedObservable.add(()=>{c&&(A(!0),E(S=>(S&&clearTimeout(S),setTimeout(()=>{A(!1),E(null)},250)))),g(m.alpha),y(m.beta),C()});return()=>{m.onViewMatrixChangedObservable.remove(N),E(S=>(S&&clearTimeout(S),null)),A(!1)}},[f,s,m,u,d,C,_,A,c]),React.useEffect(()=>{b(f&&m?m:void 0)},[f,m,b]),React.useEffect(()=>{},[_,u,e]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:e&&jsxRuntime.jsx("arcRotateCamera",{name:"rootCamera",target:e,radius:t,alpha:v,beta:x,maxZ:l,panningSensibility:o,wheelDeltaPercentage:i,ref:k,setActiveOnSceneIfNoneActive:!0})})},Geo3DCamera$1=Geo3DCamera,Geo3DUniversalCamera=(e,t)=>{const{position:n=EngineCore.Vector3.Zero(),axesViewer:a=AxesViewerPosition.NONE,axesViewerOffset:r=EngineCore.Vector3.Zero(),skipPickingWhenCameraMoves:o=!1,wheelDeltaPercentage:i=3,rotationSensibility:s=1,panningSensibility:l=10}=e,c=reactBabylonjs.useScene(),f=React.useContext(WorkspaceMetaContext),[u,d]=React.useState(null),[h,m]=React.useState(null),{setViewCamera:R,cameraRefObject:v}=React.useContext(ViewerCameraPropsContext),[,g]=React.useState(null),x=React.useRef(null),[y,E]=React.useState(null),k=React.useRef(null),b=React.useCallback(S=>{c&&(c.skipPointerMovePicking=S)},[c]);React.useEffect(()=>(k.current=new EngineCore.ArcRotateCamera("dummy-camera",0,0,.1,EngineCore.Vector3.Zero(),c||void 0,!1),()=>{var S;(S=k.current)==null||S.dispose()}),[c]),React.useEffect(()=>{if(c){const S=h,I=c.onPointerObservable.add(O=>{if(O.type===EngineCore.PointerEventTypes.POINTERDOWN&&(x.current=new EngineCore.Vector2(O.event.clientX,O.event.clientY)),O.type===EngineCore.PointerEventTypes.POINTERUP&&(x.current=null),O.type===EngineCore.PointerEventTypes.POINTERMOVE&&x.current){const F=O.event.clientX-x.current.x,L=O.event.clientY-x.current.y;if(O.event.buttons===1){let w=null;(S.lockedTarget||y)&&(S.lockedTarget&&(w=S.lockedTarget.position),y&&(w=y)),w&&k.current?(k.current.target=w,k.current.position=S.position.clone(),k.current.wheelDeltaPercentage=i,k.current.panningSensibility=l,k.current.alpha+=F/100*s,k.current.beta+=L/100*s,k.current.update(),S.position=k.current.position.clone(),S.rotation=k.current.rotation.clone()):(S.rotation.y-=F/100*s,S.rotation.x-=L/100*s)}O.event.buttons===2&&(S.position.x-=F/100*l,S.position.y+=L/100*l),x.current=new EngineCore.Vector2(O.event.clientX,O.event.clientY)}});return()=>{c.onPointerObservable.remove(I)}}},[y,l,h,s,c,i]);const C=React.useCallback(S=>{S&&(S.inputs.addMouseWheel(),S.inputs.removeMouse(),R(S),m(S))},[R]);React.useEffect(()=>{if(h){const S=h.inputs.attached.mousewheel;S.wheelPrecisionX=i,S.wheelPrecisionY=i,S.wheelPrecisionZ=i}},[h,i]);const _=React.useCallback(()=>{if(h&&u){const S=new EngineCore.Vector3;S.addInPlace(h.position),S.addInPlace(h.getDirection(new EngineCore.Vector3(0,0,25))),a==AxesViewerPosition.TOP_RIGHT?(S.addInPlace(h.getDirection(new EngineCore.Vector3(0,7+r.y,0))),S.addInPlace(h.getDirection(new EngineCore.Vector3(15+r.x,0,0)))):a==AxesViewerPosition.TOP_LEFT?(S.addInPlace(h.getDirection(new EngineCore.Vector3(0,7+r.y,0))),S.addInPlace(h.getDirection(new EngineCore.Vector3(-15+r.x,0,0)))):a==AxesViewerPosition.BOTTOM_RIGHT?(S.addInPlace(h.getDirection(new EngineCore.Vector3(0,-7+r.y,0))),S.addInPlace(h.getDirection(new EngineCore.Vector3(15+r.x,0,0)))):a==AxesViewerPosition.BOTTOM_LEFT&&(S.addInPlace(h.getDirection(new EngineCore.Vector3(0,-7+r.y,0))),S.addInPlace(h.getDirection(new EngineCore.Vector3(-15+r.x,0,0)))),u.xAxis.position=S.clone(),u.yAxis.position=S.clone(),u.zAxis.position=S.clone()}},[h,u,a,r.y,r.x]);React.useEffect(()=>{if(c&&a!=AxesViewerPosition.NONE){const S=new EngineCore.AxesViewer(c,2,null);return d(S),()=>{S==null||S.dispose(),d(null)}}},[c,a]),React.useEffect(()=>{_()},[_]),React.useEffect(()=>{R(c&&h?h:void 0)},[c,h,R]),React.useEffect(()=>{if(!c||!h)return;const S=h.onViewMatrixChangedObservable.add(()=>{o&&(b(!0),g(I=>(I&&clearTimeout(I),setTimeout(()=>{b(!1),g(null)},250)))),_()});return()=>{h.onViewMatrixChangedObservable.remove(S),g(I=>(I&&clearTimeout(I),null)),b(!1)}},[c,a,h,f,u,_,o,b]);const[A,N]=React.useState();return React.useEffect(()=>{if(h){const S={lookAt:I=>{h&&h.setTarget(I)},updatePosition:I=>{h&&(h.position=I)},lockTarget:I=>{h&&(E(null),h.lockedTarget=I)},lockTo:I=>{h&&(h.lockedTarget=null,E(I))}};N(S),v&&v.current&&(v.current.rawCamera=h,v.current.cameraTools=S)}},[v,h]),React.useImperativeHandle(t,()=>({rawCamera:h,cameraTools:A}),[A,h]),jsxRuntime.jsx("universalCamera",{name:"universal-main-camera",position:n,ref:C,maxZ:0})},Geo3DUniversalCamera$1=React.forwardRef(Geo3DUniversalCamera);class FreeCameraPointersInput extends EngineCore.BaseCameraPointersInput{constructor(){super(...arguments);ue(this,"camera");ue(this,"buttons",[0,1,2,4]);ue(this,"panningSensibility",10);ue(this,"angularSensibility",1e4);ue(this,"_isPanClick",!1);ue(this,"_isPinching",!1)}getClassName(){return"FreeCameraPointersInput"}onButtonDown(n){(n.buttons===1||n.buttons===4)&&(this._isPinching=!0),n.buttons===2&&(this._isPanClick=!0)}onButtonUp(n){n&&(this._isPanClick=!1,this._isPinching=!1)}onTouch(n,a,r){if(this.panningSensibility!==0&&this._isPanClick){const o=-a/this.panningSensibility,i=r/this.panningSensibility;this.camera._localDirection.copyFromFloats(o,i,0),this.camera.getViewMatrix().invertToRef(this.camera._cameraTransformMatrix),EngineCore.Vector3.TransformNormalToRef(this.camera._localDirection,this.camera._cameraTransformMatrix,this.camera._transformedDirection),this.camera.cameraDirection.addInPlace(this.camera._transformedDirection)}if(this.angularSensibility!==0&&this._isPinching){const o=EngineCore.Quaternion.FromEulerAngles(this.camera.rotation.x,this.camera.rotation.y,this.camera.rotation.z),i=EngineCore.Quaternion.RotationAxis(EngineCore.Axis.Y,EngineCore.Tools.ToDegrees(a/this.angularSensibility)),s=EngineCore.Quaternion.RotationAxis(EngineCore.Axis.X,EngineCore.Tools.ToDegrees(r/this.angularSensibility)),l=o.multiply(i).multiply(s);this.camera.rotation=l.toEulerAngles()}}onLostFocus(){this._isPanClick=!1,this._isPinching=!1}}const Geo3DFreeCamera=e=>{const{position:t,target:n=new EngineCore.Vector3(0,0,0),panningSensibility:a=5,angularSensibility:r=2e3,skipPickingWhenCameraMoves:o=!1}=e,i=reactBabylonjs.useScene(),s=React.useRef(null),l=React.useRef(null),c=React.useCallback(f=>{i&&(i.skipPointerMovePicking=f)},[i]);return React.useEffect(()=>{if(s.current){s.current.inputs.removeByType("FreeCameraMouseInput");const f=new FreeCameraPointersInput,u=new EngineCore.FreeCameraMouseWheelInput;s.current.inputs.add(f),s.current.inputs.add(u)}},[]),React.useEffect(()=>{s.current&&n&&s.current.setTarget(n)},[n]),React.useEffect(()=>{if(!i||!s.current)return;const f=s.current.onViewMatrixChangedObservable.add(()=>{o&&(c(!0),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{c(!1),l.current=null},250))});return()=>{var u;(u=s.current)==null||u.onViewMatrixChangedObservable.remove(f),l.current&&(clearTimeout(l.current),l.current=null),c(!1)}},[i,c,o]),React.useEffect(()=>{if(s.current){if(s.current.inputs.attached.pointers){const f=s.current.inputs.attached.pointers;f.panningSensibility=Math.abs(a),f.angularSensibility=Math.abs(r)}if(s.current.inputs.attached.pointersPanning){const f=s.current.inputs.attached.pointersPanning;f.panningSensibility=Math.abs(a)}if(s.current.inputs.attached.around){const f=s.current.inputs.attached.around;f.angularSensibility=Math.abs(r)}}},[r,a]),jsxRuntime.jsx("freeCamera",{name:"rootCamera",position:t,ref:s})},Geo3DFreeCamera$1=Geo3DFreeCamera;class DepthTextureDebuggerNode extends EngineCore.TransformNode{constructor(n,a,r){super(n,a);ue(this,"_showDepthTexture",!1);ue(this,"_postProcess");this._postProcess=r,this.showDepthTexture=!1,this.inspectableCustomProperties=[{label:"Show Depth Texture",propertyName:"showDepthTexture",type:EngineCore.InspectableType.Checkbox}]}set showDepthTexture(n){var a,r;this._showDepthTexture=n,this._postProcess&&(this._showDepthTexture?(a=this.getScene().activeCamera)==null||a.attachPostProcess(this._postProcess):(r=this.getScene().activeCamera)==null||r.detachPostProcess(this._postProcess))}get showDepthTexture(){return this._showDepthTexture}}const DepthTextureDebugger=()=>{const e=reactBabylonjs.useEngine(),t=reactBabylonjs.useScene();return React.useEffect(()=>{if(t&&e){EngineCore.Effect.ShadersStore.depthbufferPixelShader=`#ifdef GL_ES
|
|
1193
|
+
}`,LightMetalMaterial=({alpha:e,zOffset:t,zOffsetUnits:n,disableDepthWrite:a})=>jsxRuntime.jsx("pbrMaterial",{name:"metal-pbr-material",alpha:e,transparencyMode:e!==void 0&&e<1?EngineCore.Material.MATERIAL_ALPHABLEND:EngineCore.Material.MATERIAL_OPAQUE,alphaMode:EngineCore.Engine.ALPHA_COMBINE,roughness:.25,metallic:1,albedoColor:new EngineCore.Color3(.7,.7,.7),metallicF0Factor:.1,zOffset:t,zOffsetUnits:n,disableDepthWrite:a}),DarkMetalMaterial=({alpha:e,zOffset:t,zOffsetUnits:n,disableDepthWrite:a})=>jsxRuntime.jsx("pbrMaterial",{name:"metal-pbr-material",alpha:e,transparencyMode:e!==void 0&&e<1?EngineCore.Material.MATERIAL_ALPHABLEND:EngineCore.Material.MATERIAL_OPAQUE,alphaMode:EngineCore.Engine.ALPHA_COMBINE,roughness:.25,metallic:1,albedoColor:new EngineCore.Color3(.2,.2,.2),metallicF0Factor:.1,zOffsetUnits:n,zOffset:t,disableDepthWrite:a});var RepeatedTextureMode=(e=>(e[e.TRIGONOMETRIC=0]="TRIGONOMETRIC",e[e.PLANE=1]="PLANE",e[e.FLAT=2]="FLAT",e))(RepeatedTextureMode||{});const RepeatedTextureMaterial=e=>{const t=reactBabylonjs.useScene(),[n,a]=React.useState(null),[r,o]=React.useState(null),{tilingFactor:i=.1,sideTilingFactor:s=.1,texture:l,alpha:c=1,mode:f=0,zOffset:u,zOffsetUnits:d,sideTexture:h,uvOffset:m=EngineCore.Vector2.Zero(),counterLine:R=void 0,scalePlane:v=1,scaleDepth:g=1,boundingBox:x=void 0,lines:y=[],text:E=[],disableDepthWrite:k,flatModeRotate:b=0}=e,C=_=>{a(_)};return React.useEffect(()=>{n&&l&&(n.setTexture("textureSampler",l),n.setFloat("textureFlatRotate",b),n.setVector2("uvOffset",m))},[b,n,l,m]),React.useEffect(()=>{n&&n.setFloat("alpha",c)},[c,n]),React.useEffect(()=>{n&&n.setFloat("tilingFactor",i),n&&n.setFloat("sideTilingFactor",s)},[i,s,n]),React.useEffect(()=>{n&&n.setInt("mode",f)},[n,f]),React.useEffect(()=>{n&&(h?n.setTexture("textureSideSampler",h):n.setTexture("textureSideSampler",l))},[n,h,l]),React.useEffect(()=>{var _;if(n)if(R&&x){const A=(_=R.startHeight)!=null?_:x.minimumWorld.y/g;return n.setFloat("contourLineStartHeight",A*g),n.setColor3("contourLineColor",R.color),n.setFloat("contourLineWidth",R.width),n.setFloat("contourLineStep",R.stepHeight*g),console.log("[Geo3DViewer] 等高线设置 ",R,x.centerWorld.y,A*g,A*g+16*R.stepHeight*g),()=>{n&&(n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0))}}else n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[R,g,v,x,n]),React.useEffect(()=>{t&&n&&x&&o(_=>{_&&_.dispose();let A=(x.maximum.x-x.minimum.x)/v,N=(x.maximum.z-x.minimum.z)/v,S=0;if(A<N){const F=A;A=N,N=F,S=1}const I=A/N;A*N>2048*2048&&(A=2048,N=2048/I);const O=new EngineCore.DynamicTexture("dynamic-texture",{width:A,height:N},t,!1);return O.clear(),console.log("[Geo3DViewer] 设置动态划线 ",x,A,N,v),n.setVector3("oMin",x.minimum),n.setVector3("oMax",x.maximum),n.setFloat("textureOverlayRotate",S),n.setTexture("textureOverlaySampler",O),O})},[x,n,v,t]),React.useEffect(()=>{var _;if(r&&x)if((_=r.getScene())!=null&&_.getEngine()){r.clear();let A=(x.maximum.x-x.minimum.x)/v,N=(x.maximum.z-x.minimum.z)/v;if(A<N){const O=A;A=N,N=O}const S=A/N;A*N>2048*2048&&(A=2048,N=2048/S);const I=r.getContext();y.forEach(O=>{if(O.points.length<2)return;I.beginPath();const F=O.offset?O.offset:new EngineCore.Vector2(0,0),w=1-O.points[0].x+F.x,L=1-O.points[0].y+F.y;I.moveTo(w*A,L*N);for(let B=1;B<O.points.length;B++){const D=O.offset?O.offset:new EngineCore.Vector2(0,0),W=1-O.points[B].x+D.x,ae=1-O.points[B].y+D.y;I.lineTo(W*A,ae*N)}I.strokeStyle=`rgb(${O.color.r*255}, ${O.color.g*255}, ${O.color.b*255})`,A*N>2048*2048?I.lineWidth=O.width/S:I.lineWidth=O.width,I.stroke()}),E.forEach(O=>{var B,D;I.font=`${O.fontSize}px Arial`;const F=(B=O.color)!=null?B:EngineCore.Color3.White(),w=O.offset?O.offset:new EngineCore.Vector2(0,0),L=(D=O.rotation)!=null?D:0;if(I.save(),I.translate((1-O.position.x+w.x)*A,(1-O.position.y+w.y)*N),I.rotate(L),O.clearArea){const W=I.measureText(O.text);I.clearRect(-W.width*.15,.5*O.fontSize*(1-.3),W.width*1.3,-O.fontSize*1.3)}if(O.background){I.fillStyle=`rgba(${O.background.r*255}, ${O.background.g*255}, ${O.background.b*255})`;const W=I.measureText(O.text);I.fillRect(-W.width*.05,.5*(O.fontSize*(.5-.1)),W.width*1.1,-O.fontSize*1.1)}I.fillStyle=`rgb(${F.r*255}, ${F.g*255}, ${F.b*255})`,I.fillText(O.text,0,0),I.restore()}),r.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[y,E,r,x,v]),jsxRuntime.jsx(CustomShader$1,{...e,ref:C,vertex:repeatedTextureVertexSource,fragment:repeatedTextureFragmentSource,options:{attributes:["position","color","alpha","normal"],uniforms:["worldViewProjection","tilingFactor","sideTilingFactor","mode","uvOffset","contourLineStartHeight","contourLineColor","contourLineWidth","contourLineStep","oMin","oMax","textureOverlayRotate","textureFlatRotate"],samplers:["textureSampler","textureOverlaySampler","textureSideSampler"],needAlphaBlending:!0,needAlphaTesting:!0},zOffset:u,zOffsetUnits:d,disableDepthWrite:k})},RemapColorByRedChannelMaterial=e=>{const t=reactBabylonjs.useScene(),n=React.useRef(null),a=React.useContext(ColorCodecImageContext),[r,o]=React.useState(null),{name:i,colorCodec:s,alpha:l=1,backFaceCulling:c,needDepthPrePass:f=!1,transparencyMode:u=EngineCore.Material.MATERIAL_OPAQUE,alphaMode:d=EngineCore.Engine.ALPHA_COMBINE,zOffset:h,zOffsetUnits:m,clipPlane:R,counterLine:v=void 0,scalePlane:g=1,scaleDepth:x=1,boundingBox:y,lines:E=[],text:k=[],disableDepthWrite:b}=e;return React.useEffect(()=>{const C=n.current;C&&t&&(C.loadFromSerialization(remapNodeMaterialSource,""),C.build(!1,!0,!1))},[t]),React.useEffect(()=>{const C=n.current;C&&(C.name=`${i}-material`,C.backFaceCulling=c!=null?c:!0,C.needDepthPrePass=f,C.transparencyMode=u,C.alphaMode=d,C.alpha=l,C.zOffset=h!=null?h:1,C.zOffsetUnits=m!=null?m:0,C.clipPlane=R!=null?R:null,C.disableDepthWrite=b!=null?b:!1)},[l,d,c,R,b,i,f,u,h,m]),React.useEffect(()=>{if(s){const C=n.current;C&&(C.metadata={colorCodec:s},EngineCore.Tags.EnableFor(C),EngineCore.Tags.AddTagsTo(C,"remap"))}if(s&&a&&t&&a.colorCodecsImage.current[s]){const C=n.current;if(C){const _=C.getBlockByName("RemappedTexture");_&&(_.texture=a.colorCodecsImage.current[s].texture,C.markAsDirty(EngineCore.NodeMaterial.TextureDirtyFlag))}}},[s,t]),React.useEffect(()=>{n.current&&t&&(console.log("[Geo3DViewer] RemapColorByRedChannel 透明度更新 ",l),n.current.alpha=l)},[t,l]),React.useEffect(()=>{var _;const C=n.current;if(C){const A=C.getBlockByName("contourLineStartHeight"),N=C.getBlockByName("contourLineColor"),S=C.getBlockByName("contourLineWidth"),I=C.getBlockByName("contourLineStep");if(v&&y){const O=(_=v.startHeight)!=null?_:y.centerWorld.y/x;return A&&(A.value=O*x),N&&(N.value=v.color),S&&(S.value=v.width),I&&(I.value=v.stepHeight*x),console.log("[Geo3DViewer] 等高线设置 ",v,y.centerWorld,y.centerWorld.y,O*x,O*x+16*v.stepHeight*x),()=>{C&&(A&&(A.value=0),N&&(N.value=new EngineCore.Color3(0,0,0)),S&&(S.value=0),I&&(I.value=0))}}else A&&(A.value=0),N&&(N.value=new EngineCore.Color3(0,0,0)),S&&(S.value=0),I&&(I.value=0),console.log("[Geo3DViewer] 等高线设置 关闭");C.markAsDirty(EngineCore.NodeMaterial.MiscDirtyFlag)}},[v,x,g,y]),React.useEffect(()=>{t&&y&&o(C=>{var w,L;C&&C.dispose();let _=(y.maximum.x-y.minimum.x)/g,A=(y.maximum.z-y.minimum.z)/g,N=0;if(_<A){const B=_;_=A,A=B,N=1}const S=_/A;_*A>2048*2048&&(_=2048,A=2048/S);const I=new EngineCore.DynamicTexture("dynamic-texture",{width:_,height:A},t,!1);I.clear(),console.log("[Geo3DViewer] 设置动态划线 ",y,_,A,g);const O=(w=n.current)==null?void 0:w.getBlockByName("angle"),F=(L=n.current)==null?void 0:L.getBlockByName("OverlayTexture");return O&&(O.value=N*(Math.PI/2)),F&&(F.texture=I),I})},[y,g,t]),React.useEffect(()=>{var C;if(r&&y)if((C=r.getScene())!=null&&C.getEngine()){r.clear();let _=(y.maximum.x-y.minimum.x)/g,A=(y.maximum.z-y.minimum.z)/g;if(_<A){const I=_;_=A,A=I}const N=_/A;_*A>2048*2048&&(_=2048,A=2048/N);const S=r.getContext();E.forEach(I=>{if(I.points.length<2)return;S.beginPath();const O=I.offset?I.offset:new EngineCore.Vector2(0,0),F=1-I.points[0].x+O.x,w=1-I.points[0].y+O.y;S.moveTo(F*_,w*A);for(let L=1;L<I.points.length;L++){const B=I.offset?I.offset:new EngineCore.Vector2(0,0),D=1-I.points[L].x+B.x,W=1-I.points[L].y+B.y;S.lineTo(D*_,W*A)}S.strokeStyle=`rgb(${I.color.r*255}, ${I.color.g*255}, ${I.color.b*255})`,_*A>2048*2048?S.lineWidth=I.width/N:S.lineWidth=I.width,S.stroke()}),k.forEach(I=>{var L,B;S.font=`${I.fontSize}px Arial`;const O=(L=I.color)!=null?L:EngineCore.Color3.White(),F=I.offset?I.offset:new EngineCore.Vector2(0,0),w=(B=I.rotation)!=null?B:0;if(S.save(),S.translate((1-I.position.x+F.x)*_,(1-I.position.y+F.y)*A),S.rotate(w),I.clearArea){const D=S.measureText(I.text);S.clearRect(-D.width*.15,.5*I.fontSize*(1-.3),D.width*1.3,-I.fontSize*1.3)}if(I.background){S.fillStyle=`rgba(${I.background.r*255}, ${I.background.g*255}, ${I.background.b*255})`;const D=S.measureText(I.text);S.fillRect(-D.width*.05,.5*(I.fontSize*(.5-.1)),D.width*1.1,-I.fontSize*1.1)}S.fillStyle=`rgb(${O.r*255}, ${O.g*255}, ${O.b*255})`,S.fillText(I.text,0,0),S.restore()}),r.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[E,r,y,g,k]),jsxRuntime.jsx("nodeMaterial",{ref:n,name:`${i}-material`,backFaceCulling:c,needDepthPrePass:f,transparencyMode:u,alphaMode:d,alpha:l,zOffset:h,zOffsetUnits:m,clipPlane:R,disableDepthWrite:b})},ProgressedRemapColorByRedChannelMaterial=e=>{const t=reactBabylonjs.useScene(),n=React.useContext(ColorCodecImageContext),a=React.useRef(null),[r,o]=React.useState(null),[i,s]=React.useState(null),[l,c]=React.useState(null),[f,u]=React.useState(null),[d,h]=React.useState(null),[m,R]=React.useState(null),[v,g]=React.useState(null),[x,y]=React.useState(null),{boundingBox:E,colorCodec:k,alphaStage:b,cutNormal:C,value:_,zOffset:A,zOffsetUnits:N,counterLine:S=void 0,scaleDepth:I=1,scalePlane:O=1,lines:F=[],text:w=[],disableDepthWrite:L}=e;return React.useEffect(()=>{const B=(D,W,ae)=>{if(E){const ee=E.maximumWorld.multiply(W),H=E.minimumWorld.multiply(W),oe=E.centerWorld.multiply(W),te=Math.max(ee.x,ee.y,ee.z),K=Math.max(H.x,H.y,H.z),Z=Math.max(oe.x,oe.y,oe.z),ce=Math.max(Math.abs(W.x),Math.abs(W.z));D(new EngineCore.Plane(W.x,W.y,W.z,((te-K)*(1-ae-.5)*ce+Z)*-1))}else D(null)};E&&x&&(B(o,x.cutPlane1,_.value1),x.cutPlane2&&_.value2?B(s,x.cutPlane2,_.value2):s(null),x.cutPlane3&&_.value3?B(c,x.cutPlane3,_.value3):c(null),x.cutPlane4&&_.value4?B(u,x.cutPlane4,_.value4):u(null),x.cutPlane5&&_.value5?B(h,x.cutPlane5,_.value5):c(null),x.cutPlane6&&_.value6?B(R,x.cutPlane6,_.value6):R(null))},[E,x,_]),React.useEffect(()=>{y({cutPlane1:EngineCore.Vector3.Normalize(C.cutPlane1),cutPlane2:C.cutPlane2?EngineCore.Vector3.Normalize(C.cutPlane2):void 0,cutPlane3:C.cutPlane3?EngineCore.Vector3.Normalize(C.cutPlane3):void 0,cutPlane4:C.cutPlane4?EngineCore.Vector3.Normalize(C.cutPlane4):void 0,cutPlane5:C.cutPlane5?EngineCore.Vector3.Normalize(C.cutPlane5):void 0,cutPlane6:C.cutPlane6?EngineCore.Vector3.Normalize(C.cutPlane6):void 0})},[C]),React.useEffect(()=>{const B=a.current;B&&(B.clipPlane=r,B.clipPlane2=i,B.clipPlane3=l,B.clipPlane4=f,B.clipPlane5=d,B.clipPlane6=m)},[r,i,l,f,d,m]),React.useEffect(()=>{var B,D,W,ae,ee;a.current&&t&&(a.current.setFloat("alpha1",b.alpha1),a.current.setFloat("alpha2",(B=b.alpha2)!=null?B:1),a.current.setFloat("alpha3",(D=b.alpha3)!=null?D:1),a.current.setFloat("alpha4",(W=b.alpha4)!=null?W:1),a.current.setFloat("alpha5",(ae=b.alpha5)!=null?ae:1),a.current.setFloat("alpha6",(ee=b.alpha6)!=null?ee:1))},[t,b]),React.useEffect(()=>{if(k){const B=a.current;B&&(B.metadata={colorCodec:k},EngineCore.Tags.EnableFor(B),EngineCore.Tags.AddTagsTo(B,"remap"))}if(k&&n&&t&&n.colorCodecsImage.current[k]){const B=a.current;B&&(console.log(n.colorCodecsImage.current[k]),B.setTexture("textureSampler",n.colorCodecsImage.current[k].texture),B.metadata={colorCodec:k},EngineCore.Tags.EnableFor(B),EngineCore.Tags.AddTagsTo(B,"remap"))}},[k,t]),React.useEffect(()=>{var D;const B=a.current;if(B&&E)if(S){const W=(D=S.startHeight)!=null?D:E.minimumWorld.y/I;return B.setFloat("contourLineStartHeight",W*I),B.setColor3("contourLineColor",S.color),B.setFloat("contourLineWidth",S.width),B.setFloat("contourLineStep",S.stepHeight*I),console.log("[Geo3DViewer] 等高线设置 ",S,E.centerWorld.y,W*I,W*I+16*S.stepHeight*I),()=>{B&&(B.setFloat("contourLineStartHeight",0),B.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),B.setFloat("contourLineWidth",0),B.setFloat("contourLineStep",0))}}else B.setFloat("contourLineStartHeight",0),B.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),B.setFloat("contourLineWidth",0),B.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[S,I,O,E]),React.useEffect(()=>{t&&E&&g(B=>{var oe,te,K,Z;B&&B.dispose();let D=(E.maximum.x-E.minimum.x)/O,W=(E.maximum.z-E.minimum.z)/O,ae=0;if(D<W){const ce=D;D=W,W=ce,ae=1}const ee=D/W;D*W>2048*2048&&(D=2048,W=2048/ee);const H=new EngineCore.DynamicTexture("dynamic-texture",{width:D,height:W},t,!1);return H.clear(),console.log("[Geo3DViewer] 设置动态划线 ",E,D,W,O),(oe=a.current)==null||oe.setVector3("oMin",E.minimum),(te=a.current)==null||te.setVector3("oMax",E.maximum),(K=a.current)==null||K.setFloat("textureOverlayRotate",ae),(Z=a.current)==null||Z.setTexture("textureOverlaySampler",H),H})},[E,O,t]),React.useEffect(()=>{var B;if(v&&E)if((B=v.getScene())!=null&&B.getEngine()){v.clear();let D=(E.maximum.x-E.minimum.x)/O,W=(E.maximum.z-E.minimum.z)/O;if(D<W){const H=D;D=W,W=H}const ae=D/W;D*W>2048*2048&&(D=2048,W=2048/ae);const ee=v.getContext();F.forEach(H=>{if(H.points.length<2)return;ee.beginPath();const oe=H.offset?H.offset:new EngineCore.Vector2(0,0),te=1-H.points[0].x+oe.x,K=1-H.points[0].y+oe.y;ee.moveTo(te*D,K*W);for(let Z=1;Z<H.points.length;Z++){const ce=H.offset?H.offset:new EngineCore.Vector2(0,0),Q=1-H.points[Z].x+ce.x,G=1-H.points[Z].y+ce.y;ee.lineTo(Q*D,G*W)}ee.strokeStyle=`rgb(${H.color.r*255}, ${H.color.g*255}, ${H.color.b*255})`,D*W>2048*2048?ee.lineWidth=H.width/ae:ee.lineWidth=H.width,ee.stroke()}),w.forEach(H=>{var Z,ce;ee.font=`${H.fontSize}px Arial`;const oe=(Z=H.color)!=null?Z:EngineCore.Color3.White(),te=H.offset?H.offset:new EngineCore.Vector2(0,0),K=(ce=H.rotation)!=null?ce:0;if(ee.save(),ee.translate((1-H.position.x+te.x)*D,(1-H.position.y+te.y)*W),ee.rotate(K),H.clearArea){const Q=ee.measureText(H.text);ee.clearRect(-Q.width*.15,.5*H.fontSize*(1-.3),Q.width*1.3,-H.fontSize*1.3)}if(H.background){ee.fillStyle=`rgba(${H.background.r*255}, ${H.background.g*255}, ${H.background.b*255})`;const Q=ee.measureText(H.text);ee.fillRect(-Q.width*.05,.5*(H.fontSize*(.5-.1)),Q.width*1.1,-H.fontSize*1.1)}ee.fillStyle=`rgb(${oe.r*255}, ${oe.g*255}, ${oe.b*255})`,ee.fillText(H.text,0,0),ee.restore()}),v.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[F,v,E,O,w]),jsxRuntime.jsx(CustomShader$1,{...e,ref:a,vertex:remapProgressedVertexSource,fragment:remapProgressedFragmentSource,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","alpha1","alpha2","alpha3","alpha4","alpha5","alpha6","oMin","oMax","contourLineStartHeight","contourLineColor","contourLineWidth","contourLineStep","textureOverlayRotate"],samplers:["textureOverlaySampler","textureSampler"],needAlphaBlending:!0,needAlphaTesting:!0,useClipPlane:!0},disableDepthWrite:L,zOffset:A,zOffsetUnits:N})},ProgressedRepeatedTextureMaterial=e=>{const t=reactBabylonjs.useScene(),[n,a]=React.useState(null),[r,o]=React.useState(null),[i,s]=React.useState(null),[l,c]=React.useState(null),[f,u]=React.useState(null),[d,h]=React.useState(null),[m,R]=React.useState(null),[v,g]=React.useState(null),[x,y]=React.useState(null),{boundingBox:E=void 0,texture:k,sideTexture:b,alphaStage:C,cutNormal:_,value:A,tilingFactor:N=.1,sideTilingFactor:S=.1,mode:I=0,zOffset:O,zOffsetUnits:F,overlay:w={},counterLine:L=void 0,scalePlane:B=1,scaleDepth:D=1,lines:W=[],text:ae=[],disableDepthWrite:ee,textureFlatRotate:H=0}=e,oe=te=>{a(te)};return React.useEffect(()=>{n&&n.setFloat("textureFlatRotate",H)},[n,H]),React.useEffect(()=>{const te=(K,Z,ce)=>{if(E){const Q=E.maximumWorld.multiply(Z),G=E.minimumWorld.multiply(Z),ge=E.centerWorld.multiply(Z),fe=Math.max(Q.x,Q.y,Q.z),V=Math.max(G.x,G.y,G.z),J=Math.max(ge.x,ge.y,ge.z),Re=Math.max(Math.abs(Z.x),Math.abs(Z.z)),Ce=new EngineCore.Plane(Z.x,Z.y,Z.z,((fe-V)*(1-ce-.5)*Re+J)*-1);K(Ce),console.log("[Geo3DViewer] 设置实际 CutPlane 为 ",Ce,Re)}else K(null)};E&&x&&(te(o,x.cutPlane1,A.value1),x.cutPlane2&&A.value2?te(s,x.cutPlane2,A.value2):s(null),x.cutPlane3&&A.value3?te(c,x.cutPlane3,A.value3):c(null),x.cutPlane4&&A.value4?te(u,x.cutPlane4,A.value4):u(null),x.cutPlane5&&A.value5?te(h,x.cutPlane5,A.value5):c(null),x.cutPlane6&&A.value6?te(R,x.cutPlane6,A.value6):R(null))},[x,E,A]),React.useEffect(()=>{y({cutPlane1:EngineCore.Vector3.Normalize(_.cutPlane1),cutPlane2:_.cutPlane2?EngineCore.Vector3.Normalize(_.cutPlane2):void 0,cutPlane3:_.cutPlane3?EngineCore.Vector3.Normalize(_.cutPlane3):void 0,cutPlane4:_.cutPlane4?EngineCore.Vector3.Normalize(_.cutPlane4):void 0,cutPlane5:_.cutPlane5?EngineCore.Vector3.Normalize(_.cutPlane5):void 0,cutPlane6:_.cutPlane6?EngineCore.Vector3.Normalize(_.cutPlane6):void 0})},[_]),React.useEffect(()=>{n&&(n.clipPlane=r,n.clipPlane2=i,n.clipPlane3=l,n.clipPlane4=f,n.clipPlane5=d,n.clipPlane6=m)},[n,r,i,l,f,d,m]),React.useEffect(()=>{var te,K,Z,ce,Q;n&&t&&(n.setFloat("alpha1",C.alpha1),n.setFloat("alpha2",(te=C.alpha2)!=null?te:1),n.setFloat("alpha3",(K=C.alpha3)!=null?K:1),n.setFloat("alpha4",(Z=C.alpha4)!=null?Z:1),n.setFloat("alpha5",(ce=C.alpha5)!=null?ce:1),n.setFloat("alpha6",(Q=C.alpha6)!=null?Q:1))},[t,C,n]),React.useEffect(()=>{n&&k&&n.setTexture("textureSampler",k)},[n,k]),React.useEffect(()=>{n&&N&&n.setFloat("tilingFactor",N),n&&S&&n.setFloat("sideTilingFactor",S)},[N,S,n]),React.useEffect(()=>{n&&I&&n.setInt("mode",I)},[n,I]),React.useEffect(()=>{n&&(b?n.setTexture("textureSideSampler",b):n.setTexture("textureSideSampler",k))},[n,b,k]),React.useEffect(()=>{n&&(w.texture1?n.setTexture("textureSampler1",w.texture1):n.setTexture("textureSampler1",k),w.sideTexture1?n.setTexture("textureSideSampler1",w.sideTexture1):n.setTexture("textureSideSampler1",k),w.color1?n.setColor3("vColor1",w.color1):n.setColor3("vColor1",new EngineCore.Color3(1,1,1)),w.texture2?n.setTexture("textureSampler2",w.texture2):n.setTexture("textureSampler2",k),w.sideTexture2?n.setTexture("textureSideSampler2",w.sideTexture2):n.setTexture("textureSideSampler2",k),w.color2?n.setColor3("vColor2",w.color2):n.setColor3("vColor2",new EngineCore.Color3(1,1,1)),w.texture3?n.setTexture("textureSampler3",w.texture3):n.setTexture("textureSampler3",k),w.sideTexture3?n.setTexture("textureSideSampler3",w.sideTexture3):n.setTexture("textureSideSampler2",k),w.color3?n.setColor3("vColor3",w.color3):n.setColor3("vColor3",new EngineCore.Color3(1,1,1)),w.texture4?n.setTexture("textureSampler4",w.texture4):n.setTexture("textureSampler4",k),w.sideTexture4?n.setTexture("textureSideSampler4",w.sideTexture4):n.setTexture("textureSideSampler4",k),w.color4?n.setColor3("vColor4",w.color4):n.setColor3("vColor4",new EngineCore.Color3(1,1,1)),w.texture5?n.setTexture("textureSampler5",w.texture5):n.setTexture("textureSampler5",k),w.sideTexture5?n.setTexture("textureSideSampler5",w.sideTexture5):n.setTexture("textureSideSampler5",k),w.color5?n.setColor3("vColor5",w.color5):n.setColor3("vColor5",new EngineCore.Color3(1,1,1)),w.texture6?n.setTexture("textureSampler6",w.texture6):n.setTexture("textureSampler6",k),w.sideTexture6?n.setTexture("textureSideSampler6",w.sideTexture6):n.setTexture("textureSideSampler6",k),w.color6?n.setColor3("vColor6",w.color6):n.setColor3("vColor6",new EngineCore.Color3(1,1,1)))},[n,w,k]),React.useEffect(()=>{var te;if(n&&E)if(L){const K=(te=L.startHeight)!=null?te:E.minimumWorld.y/D;return n.setFloat("contourLineStartHeight",K*D),n.setColor3("contourLineColor",L.color),n.setFloat("contourLineWidth",L.width),n.setFloat("contourLineStep",L.stepHeight*D),console.log("[Geo3DViewer] 等高线设置 ",L,E.centerWorld.y,K*D,K*D+16*L.stepHeight*D),()=>{n&&(n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0))}}else n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[L,D,B,E,n]),React.useEffect(()=>{t&&n&&E&&g(te=>{te&&te.dispose();let K=(E.maximum.x-E.minimum.x)/B,Z=(E.maximum.z-E.minimum.z)/B,ce=0;if(K<Z){const ge=K;K=Z,Z=ge,ce=1}const Q=K/Z;K*Z>2048*2048&&(K=2048,Z=2048/Q);const G=new EngineCore.DynamicTexture("dynamic-texture",{width:K,height:Z},t,!1);return G.clear(),console.log("[Geo3DViewer] 设置动态划线 ",E,K,Z,B),n.setVector3("oMin",E.minimum),n.setVector3("oMax",E.maximum),n.setFloat("textureOverlayRotate",ce),n.setTexture("textureOverlaySampler",G),G})},[E,n,B,t]),React.useEffect(()=>{var te;if(v&&E)if((te=v.getScene())!=null&&te.getEngine()){v.clear();let K=(E.maximum.x-E.minimum.x)/B,Z=(E.maximum.z-E.minimum.z)/B;if(K<Z){const G=K;K=Z,Z=G}const ce=K/Z;K*Z>2048*2048&&(K=2048,Z=2048/ce);const Q=v.getContext();W.forEach(G=>{if(G.points.length<2)return;Q.beginPath();const ge=G.offset?G.offset:new EngineCore.Vector2(0,0),fe=1-G.points[0].x+ge.x,V=1-G.points[0].y+ge.y;Q.moveTo(fe*K,V*Z);for(let J=1;J<G.points.length;J++){const Re=G.offset?G.offset:new EngineCore.Vector2(0,0),Ce=1-G.points[J].x+Re.x,Y=1-G.points[J].y+Re.y;Q.lineTo(Ce*K,Y*Z)}Q.strokeStyle=`rgb(${G.color.r*255}, ${G.color.g*255}, ${G.color.b*255})`,K*Z>2048*2048?Q.lineWidth=G.width/ce:Q.lineWidth=G.width,Q.stroke()}),ae.forEach(G=>{var J,Re;Q.font=`${G.fontSize}px Arial`;const ge=(J=G.color)!=null?J:EngineCore.Color3.White(),fe=G.offset?G.offset:new EngineCore.Vector2(0,0),V=(Re=G.rotation)!=null?Re:0;if(Q.save(),Q.translate((1-G.position.x+fe.x)*K,(1-G.position.y+fe.y)*Z),Q.rotate(V),G.clearArea){const Ce=Q.measureText(G.text);Q.clearRect(-Ce.width*.15,.5*G.fontSize*(1-.3),Ce.width*1.3,-G.fontSize*1.3)}if(G.background){Q.fillStyle=`rgba(${G.background.r*255}, ${G.background.g*255}, ${G.background.b*255})`;const Ce=Q.measureText(G.text);Q.fillRect(-Ce.width*.05,.5*(G.fontSize*(.5-.1)),Ce.width*1.1,-G.fontSize*1.1)}Q.fillStyle=`rgb(${ge.r*255}, ${ge.g*255}, ${ge.b*255})`,Q.fillText(G.text,0,0),Q.restore()}),v.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[W,v,E,B,ae]),jsxRuntime.jsx(CustomShader$1,{...e,ref:oe,vertex:repeatedTextureProgressedVertexSource,fragment:repeatedTextureProgressedFragmentSource,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","alpha1","alpha2","alpha3","alpha4","alpha5","alpha6","oMin","oMax","tilingFactor","sideTilingFactor","mode","vColor1","vColor2","vColor3","vColor4","vColor5","vColor6","contourLineStartHeight","contourLineColor","contourLineWidth","contourLineStep","textureOverlayRotate","textureFlatRotate"],samplers:["textureSampler","textureOverlaySampler","textureSideSampler","textureSampler1","textureSideSampler1","textureSampler2","textureSideSampler2","textureSampler3","textureSideSampler3","textureSampler4","textureSideSampler4","textureSampler5","textureSideSampler5","textureSampler6","textureSideSampler6"],needAlphaBlending:!0,needAlphaTesting:!0,useClipPlane:!0},zOffset:O,zOffsetUnits:F,disableDepthWrite:ee})},FlatMaterial=e=>jsxRuntime.jsx(CustomShader$1,{...e,vertex:flatVertexSource,fragment:flatFragmentSource,options:{needAlphaBlending:!0},zOffset:e.zOffset,zOffsetUnits:e.zOffsetUnits,disableDepthWrite:e.disableDepthWrite}),PickingMaterial=()=>jsxRuntime.jsx(CustomShader$1,{name:"picking-material",vertex:pickingVertexSource,fragment:pickingFragmentSource,backFaceCulling:!1,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","pickingColor","isPickable"]}}),createMultiStageWaterEffectMaterial=({name:e,scene:t})=>{const n=EngineCore.NodeMaterial.Parse(MultiStageWaterMaterial,t);return n.name=e,n.backFaceCulling=!1,n.build(!1,!0,!1),n},useIntersectingLineMaterial=({name:e,lineColor:t,lineWidth:n=.5})=>{const a=reactBabylonjs.useScene(),[r,o]=React.useState(null);return React.useEffect(()=>{if(a){const i=EngineCore.NodeMaterial.Parse(intersectingLineSource,a);return i.name=`${e}-material`,i.backFaceCulling=!1,i.build(!1,!0,!1),o(i),()=>{o(s=>(s==null||s.dispose(!0,!1),null))}}},[e,a]),React.useEffect(()=>{o(i=>i&&t?(i.getBlockByName("Color3").value=t,i.build(!1,!0,!1),i):null)},[t]),React.useEffect(()=>{o(i=>{if(i&&n!==void 0&&n!==null){let s=n;return n<1&&(s=1),i.getBlockByName("offset").value=1-s,i.build(!1,!0,!1),i}return null})},[n]),r},VoxelGridMaterial=(e,t)=>{const n=React.useRef(null);return React.useEffect(()=>{n.current&&(n.current.setVector4("typeAlpha1",new EngineCore.Vector4(e.typeAlpha.typeAlpha0===void 0?1:e.typeAlpha.typeAlpha0,e.typeAlpha.typeAlpha1,e.typeAlpha.typeAlpha2,e.typeAlpha.typeAlpha3)),n.current.setVector4("typeAlpha2",new EngineCore.Vector4(e.typeAlpha.typeAlpha4,e.typeAlpha.typeAlpha5,e.typeAlpha.typeAlpha6,e.typeAlpha.typeAlpha7)),n.current.setVector4("typeAlpha3",new EngineCore.Vector4(e.typeAlpha.typeAlpha8,e.typeAlpha.typeAlpha9,e.typeAlpha.typeAlpha10,e.typeAlpha.typeAlpha11)),n.current.setVector4("typeAlpha4",new EngineCore.Vector4(e.typeAlpha.typeAlpha12,e.typeAlpha.typeAlpha13,e.typeAlpha.typeAlpha14,e.typeAlpha.typeAlpha15)),n.current.setVector4("typeAlpha5",new EngineCore.Vector4(e.typeAlpha.typeAlpha16,e.typeAlpha.typeAlpha17,e.typeAlpha.typeAlpha18,e.typeAlpha.typeAlpha19)))},[e.typeAlpha]),React.useImperativeHandle(t,()=>n.current,[]),jsxRuntime.jsx(CustomShader$1,{ref:n,name:e.name,backFaceCulling:!0,needDepthPrePass:!1,vertex:voxelGridVertexSource,fragment:voxelGridFragmentSource,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,options:{attributes:["position","color","uv","normal","world0","world1","world2","world3","instanceColor"],uniforms:["world","worldViewProjection","view","viewProjection","typeAlpha1","typeAlpha2","typeAlpha3","typeAlpha4","worldView","projection","previousWorld","vEyePosition"],defines:["#define INSTANCESCOLOR","#define INSTANCES"],needAlphaBlending:!0,needAlphaTesting:!0}})},OneColorMaterial=e=>{const t=reactBabylonjs.useScene(),[n,a]=React.useState(null),r=React.useRef(null),{boundingBox:o,counterLine:i,scaleDepth:s=1,scalePlane:l=1,color:c,alpha:f=1,lines:u=[],text:d=[],surfaceCanvasOptions:h={textureIncludeSide:!0},disableDepthWrite:m,disableNormalShadow:R=!1}=e,{textureIncludeSide:v}=h;return React.useEffect(()=>{r.current&&(console.log("[Geo3DViewer] 设置材质 ",c,f),r.current.setColor3("vColor",c),r.current.setFloat("vAlpha",f),r.current.setFloat("textureIncludeSide",v==null?1:0))},[c,f,v]),React.useEffect(()=>{var x;const g=r.current;if(g&&o)if(i){const y=(x=i.startHeight)!=null?x:o.maximumWorld.y/s;return g.setFloat("contourLineStartHeight",y*s),g.setColor3("contourLineColor",i.color),g.setFloat("contourLineWidth",i.width),g.setFloat("contourLineStep",i.stepHeight*s),console.log("[Geo3DViewer] 等高线设置 ",i,o.centerWorld.y,y*s,y*s-16*i.stepHeight*s),()=>{g&&(g.setFloat("contourLineStartHeight",0),g.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),g.setFloat("contourLineWidth",0),g.setFloat("contourLineStep",0))}}else g.setFloat("contourLineStartHeight",0),g.setColor3("contourLineColor",new EngineCore.Color3(0,0,0)),g.setFloat("contourLineWidth",0),g.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[o,i,s,l]),React.useEffect(()=>{const g=r.current;t&&o&&g&&a(x=>{let y=(o.maximum.x-o.minimum.x)/l,E=(o.maximum.z-o.minimum.z)/l,k=0;if(y<E){const _=y;y=E,E=_,k=1}const b=y/E;y*E>2048*2048&&(y=2048,E=2048/b);let C;return x?(x.scaleTo(y,E),x.update(),C=x):C=new EngineCore.DynamicTexture("dynamic-texture",{width:y,height:E},t,!1),C.clear(),C.update(),console.log("[Geo3DViewer] 设置动态划线 ",o,y,E,l),g.setVector3("oMin",o.minimum),g.setVector3("oMax",o.maximum),g.setFloat("textureOverlayRotate",k),g.setTexture("textureOverlaySampler",C),C})},[o,l,t]),React.useEffect(()=>{var g;if(n&&o&&(u.length>0||d.length>0))if((g=n.getScene())!=null&&g.getEngine()){n.clear();let x=(o.maximum.x-o.minimum.x)/l,y=(o.maximum.z-o.minimum.z)/l;if(x<y){const b=x;x=y,y=b}const E=x/y;x*y>2048*2048&&(x=2048,y=2048/E);const k=n.getContext();u.forEach(b=>{if(b.points.length<2)return;k.beginPath();const C=b.offset?b.offset:new EngineCore.Vector2(0,0),_=1-b.points[0].x+C.x,A=1-b.points[0].y+C.y;k.moveTo(_*x,A*y);for(let N=1;N<b.points.length;N++){const S=b.offset?b.offset:new EngineCore.Vector2(0,0),I=1-b.points[N].x+S.x,O=1-b.points[N].y+S.y;k.lineTo(I*x,O*y)}k.strokeStyle=`rgb(${b.color.r*255}, ${b.color.g*255}, ${b.color.b*255})`,x*y>2048*2048?k.lineWidth=b.width/E:k.lineWidth=b.width,k.stroke()}),d.forEach(b=>{var N,S;k.font=`${b.fontSize}px Arial`;const C=(N=b.color)!=null?N:EngineCore.Color3.White(),_=b.offset?b.offset:new EngineCore.Vector2(0,0),A=(S=b.rotation)!=null?S:0;if(k.save(),k.translate((1-b.position.x+_.x)*x,(1-b.position.y+_.y)*y),k.rotate(A),b.clearArea){const I=k.measureText(b.text);k.clearRect(-I.width*.15,.5*b.fontSize*(1-.3),I.width*1.3,-b.fontSize*1.3)}if(b.background){k.fillStyle=`rgba(${b.background.r*255}, ${b.background.g*255}, ${b.background.b*255})`;const I=k.measureText(b.text);k.fillRect(-I.width*.05,.5*(b.fontSize*(.5-.1)),I.width*1.1,-b.fontSize*1.1)}k.fillStyle=`rgb(${C.r*255}, ${C.g*255}, ${C.b*255})`,k.fillText(b.text,0,0),k.restore()}),n.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[u,n,o,l,d]),React.useEffect(()=>{const g=r.current;if(g){if(R)return g.setFloat("disableNormalShadow",1),console.log("[Geo3DViewer] 禁用法向阴影 启用"),()=>{g&&g.setFloat("disableNormalShadow",0)};g.setFloat("disableNormalShadow",0),console.log("[Geo3DViewer] 禁用法向阴影 禁用")}},[R]),jsxRuntime.jsx(CustomShader$1,{ref:r,name:e.name,backFaceCulling:e.backFaceCulling,needDepthPrePass:e.needDepthPrePass,vertex:oneColorVertexSource,fragment:oneColorFragmentSource,transparencyMode:e.transparencyMode,alphaMode:e.alphaMode,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","vAlpha","vColor","contourLineStartHeight","contourLineColor","contourLineWidth","contourLineStep","oMin","oMax","textureOverlayRotate","textureIncludeSide","disableNormalShadow"],samplers:["textureOverlaySampler"],needAlphaBlending:!0,needAlphaTesting:!0},zOffset:e.zOffset,zOffsetUnits:e.zOffsetUnits,disableDepthWrite:m})},VoxelGridMaterialForwardRef=React.forwardRef(VoxelGridMaterial),AttributeBody=({name:e,url:t,offset:n=EngineCore.Vector3.Zero(),alpha:a=1,material:r,visible:o=!0,actions:i})=>{const s=reactBabylonjs.useScene(),l=React.useRef(null),c=React.useContext(WorkspaceMetaContext),f=useCachedBinary({url:t,cacheType:CacheType.URL_PREFIX_MATCH}),u=useCachedTexture({url:r.texture,cacheType:CacheType.URL_PREFIX_MATCH}),d=useCachedTexture({url:r.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),[h,m]=React.useState(EngineCore.Vector3.Zero()),[R,v]=React.useState();return React.useEffect(()=>{console.log("[Geo3DViewer] AttributeBody Loading: ",t)},[t]),React.useEffect(()=>{if(s&&l.current&&t&&f){EngineCore.Tags.EnableFor(l.current),EngineCore.Tags.AddTagsTo(l.current,"loading");const g=VirtualVolume.decode(new Uint8Array(f)),{points:x,indices:y,value:E,center:k}=g,b=new EngineCore.VertexData;b.positions=x,b.indices=y,b.colors=E;const C=[];EngineCore.VertexData.ComputeNormals(x,y,C),b.normals=C,k&&m(new EngineCore.Vector3(k.x,k.y,k.z));const _=l.current;_&&(b.applyToMesh(_),_.getScene().onAfterRenderObservable.addOnce(()=>{if(!_.isDisposed()){const N=_.getBoundingInfo();v(N.boundingBox)}})),EngineCore.Tags.RemoveTagsFrom(l.current,"loading")}},[t,s,f]),React.useEffect(()=>{l.current&&(l.current.metadata={pickable:i?{name:e,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null})},[i,e]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`transform-attribute-${e}`,position:h.add(n).multiplyByFloats(c&&c.scalePlane?c.scalePlane:1,c&&c.scaleDepth?c.scaleDepth:1,c&&c.scalePlane?c.scalePlane:1),scaling:new EngineCore.Vector3(c?c.scalePlane:1,c?c.scaleDepth:1,c?c.scalePlane:1),children:jsxRuntime.jsx("mesh",{name:`attributebody-${e}-mesh`,ref:l,setEnabled:o,useVertexColors:r.type===MaterialType.COLOR_CODEC,children:r.type===MaterialType.COLOR_CODEC&&r.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`attributebody-${e}-mat`,backFaceCulling:r.backFaceCulling===void 0?!0:r.backFaceCulling,needDepthPrePass:r.needDepthPrePass===void 0?!1:r.needDepthPrePass,alpha:r.alpha?r.alpha:a,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:r.colorCodec,boundingBox:R,lines:r.lines,text:r.text,scaleDepth:c?c.scaleDepth:1,scalePlane:c?c.scalePlane:1,disableDepthWrite:r.disableDepthWrite}):r.type===MaterialType.ONE_COLOR&&r.color?jsxRuntime.jsx("standardMaterial",{name:`attributebody-${e}-overwrite-mat`,backFaceCulling:r.backFaceCulling===void 0?!0:r.backFaceCulling,needDepthPrePass:r.needDepthPrePass===void 0?!1:r.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),diffuseColor:new EngineCore.Color3(r.color.r,r.color.g,r.color.b),emissiveColor:EngineCore.Color3.Black(),alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:r.alpha?r.alpha:a,zOffset:-3,disableDepthWrite:r.disableDepthWrite}):r.type===MaterialType.TEXTURE&&u?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`attributebody-${e}-texture-mat`,backFaceCulling:r.backFaceCulling===void 0?!0:r.backFaceCulling,needDepthPrePass:r.needDepthPrePass===void 0?!1:r.needDepthPrePass,alpha:r.alpha?r.alpha:a,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,texture:u,sideTexture:d,mode:r.textureMode===void 0?RepeatedTextureMode.PLANE:r.textureMode,boundingBox:R,disableDepthWrite:r.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{})})})})},AttributeBody$1=AttributeBody,ColorCodec=({codec:e,showValue:t=!1,showTitle:n=!0,width:a=80,height:r=200})=>{const o=React.useContext(ColorCodecImageContext);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("adtFullscreenUi",{name:`adt-color-codec-${e}`,children:[n?jsxRuntime.jsx("textBlock",{name:`color-codec-title-${e}`,text:e,color:"white",paddingBottomInPixels:r+40/200*r,paddingRightInPixels:30/80*a,textVerticalAlignment:EngineGui.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:EngineGui.Control.HORIZONTAL_ALIGNMENT_RIGHT}):jsxRuntime.jsx(jsxRuntime.Fragment,{}),jsxRuntime.jsx("babylon-image",{name:`color-codec-${e}`,source:o!=null&&o.colorCodecsImage.current[e]?o.colorCodecsImage.current[e].blobUrl:"",height:`${r}px`,width:`${a}px`,verticalAlignment:EngineGui.Control.VERTICAL_ALIGNMENT_CENTER,horizontalAlignment:EngineGui.Control.HORIZONTAL_ALIGNMENT_RIGHT,paddingRightInPixels:20}),t&&(o!=null&&o.colorCodecsImage.current[e])?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("textBlock",{name:"color-codec-value-min",text:o.colorCodecsImage.current[e].min.toFixed(1).toString(),color:"white",paddingBottomInPixels:-1*r,paddingRightInPixels:90,textVerticalAlignment:EngineGui.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:EngineGui.Control.HORIZONTAL_ALIGNMENT_RIGHT}),jsxRuntime.jsx("textBlock",{name:"color-codec-title-avg",text:((o.colorCodecsImage.current[e].max-o.colorCodecsImage.current[e].min)/2).toFixed(1).toString(),color:"white",paddingBottomInPixels:0,paddingRightInPixels:a+10,textVerticalAlignment:EngineGui.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:EngineGui.Control.HORIZONTAL_ALIGNMENT_RIGHT}),jsxRuntime.jsx("textBlock",{name:"color-codec-title-max",text:o.colorCodecsImage.current[e].max.toFixed(1).toString(),color:"white",paddingBottomInPixels:r,paddingRightInPixels:a+10,textVerticalAlignment:EngineGui.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:EngineGui.Control.HORIZONTAL_ALIGNMENT_RIGHT})]}):null]})})},ColorCodec$1=ColorCodec;function createBaseFormation(){return{name:"",colorId:0,points:[],indices:[],bottomIndices:[],value:[],vMin:0,vMax:0,border:[],side:[],sideIndices:[],sideValue:[],center:void 0}}const Formation={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.colorId!==0&&t.uint32(16).uint32(e.colorId),t.uint32(170).fork();for(const n of e.points)t.float(n);t.ldelim(),t.uint32(178).fork();for(const n of e.indices)t.uint32(n);t.ldelim(),t.uint32(186).fork();for(const n of e.bottomIndices)t.uint32(n);t.ldelim(),t.uint32(194).fork();for(const n of e.value)t.float(n);t.ldelim(),e.vMin!==0&&t.uint32(205).float(e.vMin),e.vMax!==0&&t.uint32(213).float(e.vMax),t.uint32(218).fork();for(const n of e.border)t.uint32(n);t.ldelim(),t.uint32(226).fork();for(const n of e.side)t.float(n);t.ldelim(),t.uint32(234).fork();for(const n of e.sideIndices)t.uint32(n);t.ldelim(),t.uint32(242).fork();for(const n of e.sideValue)t.float(n);return t.ldelim(),e.center!==void 0&&Vertex.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseFormation();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==16)break;r.colorId=n.uint32();continue;case 21:if(o===173){r.points.push(n.float());continue}if(o===170){const i=n.uint32()+n.pos;for(;n.pos<i;)r.points.push(n.float());continue}break;case 22:if(o===176){r.indices.push(n.uint32());continue}if(o===178){const i=n.uint32()+n.pos;for(;n.pos<i;)r.indices.push(n.uint32());continue}break;case 23:if(o===184){r.bottomIndices.push(n.uint32());continue}if(o===186){const i=n.uint32()+n.pos;for(;n.pos<i;)r.bottomIndices.push(n.uint32());continue}break;case 24:if(o===197){r.value.push(n.float());continue}if(o===194){const i=n.uint32()+n.pos;for(;n.pos<i;)r.value.push(n.float());continue}break;case 25:if(o!==205)break;r.vMin=n.float();continue;case 26:if(o!==213)break;r.vMax=n.float();continue;case 27:if(o===216){r.border.push(n.uint32());continue}if(o===218){const i=n.uint32()+n.pos;for(;n.pos<i;)r.border.push(n.uint32());continue}break;case 28:if(o===229){r.side.push(n.float());continue}if(o===226){const i=n.uint32()+n.pos;for(;n.pos<i;)r.side.push(n.float());continue}break;case 29:if(o===232){r.sideIndices.push(n.uint32());continue}if(o===234){const i=n.uint32()+n.pos;for(;n.pos<i;)r.sideIndices.push(n.uint32());continue}break;case 30:if(o===245){r.sideValue.push(n.float());continue}if(o===242){const i=n.uint32()+n.pos;for(;n.pos<i;)r.sideValue.push(n.float());continue}break;case 31:if(o!==250)break;r.center=Vertex.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$b(e.name)?globalThis.String(e.name):"",colorId:isSet$b(e.colorId)?globalThis.Number(e.colorId):0,points:globalThis.Array.isArray(e==null?void 0:e.points)?e.points.map(t=>globalThis.Number(t)):[],indices:globalThis.Array.isArray(e==null?void 0:e.indices)?e.indices.map(t=>globalThis.Number(t)):[],bottomIndices:globalThis.Array.isArray(e==null?void 0:e.bottomIndices)?e.bottomIndices.map(t=>globalThis.Number(t)):[],value:globalThis.Array.isArray(e==null?void 0:e.value)?e.value.map(t=>globalThis.Number(t)):[],vMin:isSet$b(e.vMin)?globalThis.Number(e.vMin):0,vMax:isSet$b(e.vMax)?globalThis.Number(e.vMax):0,border:globalThis.Array.isArray(e==null?void 0:e.border)?e.border.map(t=>globalThis.Number(t)):[],side:globalThis.Array.isArray(e==null?void 0:e.side)?e.side.map(t=>globalThis.Number(t)):[],sideIndices:globalThis.Array.isArray(e==null?void 0:e.sideIndices)?e.sideIndices.map(t=>globalThis.Number(t)):[],sideValue:globalThis.Array.isArray(e==null?void 0:e.sideValue)?e.sideValue.map(t=>globalThis.Number(t)):[],center:isSet$b(e.center)?Vertex.fromJSON(e.center):void 0}},toJSON(e){var n,a,r,o,i,s,l,c;const t={};return e.name!==""&&(t.name=e.name),e.colorId!==0&&(t.colorId=Math.round(e.colorId)),(n=e.points)!=null&&n.length&&(t.points=e.points),(a=e.indices)!=null&&a.length&&(t.indices=e.indices.map(f=>Math.round(f))),(r=e.bottomIndices)!=null&&r.length&&(t.bottomIndices=e.bottomIndices.map(f=>Math.round(f))),(o=e.value)!=null&&o.length&&(t.value=e.value),e.vMin!==0&&(t.vMin=e.vMin),e.vMax!==0&&(t.vMax=e.vMax),(i=e.border)!=null&&i.length&&(t.border=e.border.map(f=>Math.round(f))),(s=e.side)!=null&&s.length&&(t.side=e.side),(l=e.sideIndices)!=null&&l.length&&(t.sideIndices=e.sideIndices.map(f=>Math.round(f))),(c=e.sideValue)!=null&&c.length&&(t.sideValue=e.sideValue),e.center!==void 0&&(t.center=Vertex.toJSON(e.center)),t},create(e){return Formation.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l,c,f,u,d,h;const t=createBaseFormation();return t.name=(n=e.name)!=null?n:"",t.colorId=(a=e.colorId)!=null?a:0,t.points=((r=e.points)==null?void 0:r.map(m=>m))||[],t.indices=((o=e.indices)==null?void 0:o.map(m=>m))||[],t.bottomIndices=((i=e.bottomIndices)==null?void 0:i.map(m=>m))||[],t.value=((s=e.value)==null?void 0:s.map(m=>m))||[],t.vMin=(l=e.vMin)!=null?l:0,t.vMax=(c=e.vMax)!=null?c:0,t.border=((f=e.border)==null?void 0:f.map(m=>m))||[],t.side=((u=e.side)==null?void 0:u.map(m=>m))||[],t.sideIndices=((d=e.sideIndices)==null?void 0:d.map(m=>m))||[],t.sideValue=((h=e.sideValue)==null?void 0:h.map(m=>m))||[],t.center=e.center!==void 0&&e.center!==null?Vertex.fromPartial(e.center):void 0,t}};function isSet$b(e){return e!=null}function earcut(e,t,n=2){const a=t&&t.length,r=a?t[0]*n:e.length;let o=linkedList(e,0,r,n,!0);const i=[];if(!o||o.next===o.prev)return i;let s,l,c;if(a&&(o=eliminateHoles(e,t,o,n)),e.length>80*n){s=e[0],l=e[1];let f=s,u=l;for(let d=n;d<r;d+=n){const h=e[d],m=e[d+1];h<s&&(s=h),m<l&&(l=m),h>f&&(f=h),m>u&&(u=m)}c=Math.max(f-s,u-l),c=c!==0?32767/c:0}return earcutLinked(o,i,n,s,l,c,0),i}function linkedList(e,t,n,a,r){let o;if(r===signedArea(e,t,n,a)>0)for(let i=t;i<n;i+=a)o=insertNode(i/a|0,e[i],e[i+1],o);else for(let i=n-a;i>=t;i-=a)o=insertNode(i/a|0,e[i],e[i+1],o);return o&&equals(o,o.next)&&(removeNode(o),o=o.next),o}function filterPoints(e,t){if(!e)return e;t||(t=e);let n=e,a;do if(a=!1,!n.steiner&&(equals(n,n.next)||area(n.prev,n,n.next)===0)){if(removeNode(n),n=t=n.prev,n===n.next)break;a=!0}else n=n.next;while(a||n!==t);return t}function earcutLinked(e,t,n,a,r,o,i){if(!e)return;!i&&o&&indexCurve(e,a,r,o);let s=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(o?isEarHashed(e,a,r,o):isEar(e)){t.push(l.i,e.i,c.i),removeNode(e),e=c.next,s=c.next;continue}if(e=c,e===s){i?i===1?(e=cureLocalIntersections(filterPoints(e),t),earcutLinked(e,t,n,a,r,o,2)):i===2&&splitEarcut(e,t,n,a,r,o):earcutLinked(filterPoints(e),t,n,a,r,o,1);break}}}function isEar(e){const t=e.prev,n=e,a=e.next;if(area(t,n,a)>=0)return!1;const r=t.x,o=n.x,i=a.x,s=t.y,l=n.y,c=a.y,f=Math.min(r,o,i),u=Math.min(s,l,c),d=Math.max(r,o,i),h=Math.max(s,l,c);let m=a.next;for(;m!==t;){if(m.x>=f&&m.x<=d&&m.y>=u&&m.y<=h&&pointInTriangleExceptFirst(r,s,o,l,i,c,m.x,m.y)&&area(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function isEarHashed(e,t,n,a){const r=e.prev,o=e,i=e.next;if(area(r,o,i)>=0)return!1;const s=r.x,l=o.x,c=i.x,f=r.y,u=o.y,d=i.y,h=Math.min(s,l,c),m=Math.min(f,u,d),R=Math.max(s,l,c),v=Math.max(f,u,d),g=zOrder(h,m,t,n,a),x=zOrder(R,v,t,n,a);let y=e.prevZ,E=e.nextZ;for(;y&&y.z>=g&&E&&E.z<=x;){if(y.x>=h&&y.x<=R&&y.y>=m&&y.y<=v&&y!==r&&y!==i&&pointInTriangleExceptFirst(s,f,l,u,c,d,y.x,y.y)&&area(y.prev,y,y.next)>=0||(y=y.prevZ,E.x>=h&&E.x<=R&&E.y>=m&&E.y<=v&&E!==r&&E!==i&&pointInTriangleExceptFirst(s,f,l,u,c,d,E.x,E.y)&&area(E.prev,E,E.next)>=0))return!1;E=E.nextZ}for(;y&&y.z>=g;){if(y.x>=h&&y.x<=R&&y.y>=m&&y.y<=v&&y!==r&&y!==i&&pointInTriangleExceptFirst(s,f,l,u,c,d,y.x,y.y)&&area(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;E&&E.z<=x;){if(E.x>=h&&E.x<=R&&E.y>=m&&E.y<=v&&E!==r&&E!==i&&pointInTriangleExceptFirst(s,f,l,u,c,d,E.x,E.y)&&area(E.prev,E,E.next)>=0)return!1;E=E.nextZ}return!0}function cureLocalIntersections(e,t){let n=e;do{const a=n.prev,r=n.next.next;!equals(a,r)&&intersects(a,n,n.next,r)&&locallyInside(a,r)&&locallyInside(r,a)&&(t.push(a.i,n.i,r.i),removeNode(n),removeNode(n.next),n=e=r),n=n.next}while(n!==e);return filterPoints(n)}function splitEarcut(e,t,n,a,r,o){let i=e;do{let s=i.next.next;for(;s!==i.prev;){if(i.i!==s.i&&isValidDiagonal(i,s)){let l=splitPolygon(i,s);i=filterPoints(i,i.next),l=filterPoints(l,l.next),earcutLinked(i,t,n,a,r,o,0),earcutLinked(l,t,n,a,r,o,0);return}s=s.next}i=i.next}while(i!==e)}function eliminateHoles(e,t,n,a){const r=[];for(let o=0,i=t.length;o<i;o++){const s=t[o]*a,l=o<i-1?t[o+1]*a:e.length,c=linkedList(e,s,l,a,!1);c===c.next&&(c.steiner=!0),r.push(getLeftmost(c))}r.sort(compareXYSlope);for(let o=0;o<r.length;o++)n=eliminateHole(r[o],n);return n}function compareXYSlope(e,t){let n=e.x-t.x;if(n===0&&(n=e.y-t.y,n===0)){const a=(e.next.y-e.y)/(e.next.x-e.x),r=(t.next.y-t.y)/(t.next.x-t.x);n=a-r}return n}function eliminateHole(e,t){const n=findHoleBridge(e,t);if(!n)return t;const a=splitPolygon(n,e);return filterPoints(a,a.next),filterPoints(n,n.next)}function findHoleBridge(e,t){let n=t;const a=e.x,r=e.y;let o=-1/0,i;if(equals(e,n))return n;do{if(equals(e,n.next))return n.next;if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const u=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(u<=a&&u>o&&(o=u,i=n.x<n.next.x?n:n.next,u===a))return i}n=n.next}while(n!==t);if(!i)return null;const s=i,l=i.x,c=i.y;let f=1/0;n=i;do{if(a>=n.x&&n.x>=l&&a!==n.x&&pointInTriangle(r<c?a:o,r,l,c,r<c?o:a,r,n.x,n.y)){const u=Math.abs(r-n.y)/(a-n.x);locallyInside(n,e)&&(u<f||u===f&&(n.x>i.x||n.x===i.x&§orContainsSector(i,n)))&&(i=n,f=u)}n=n.next}while(n!==s);return i}function sectorContainsSector(e,t){return area(e.prev,e,t.prev)<0&&area(t.next,e,e.next)<0}function indexCurve(e,t,n,a){let r=e;do r.z===0&&(r.z=zOrder(r.x,r.y,t,n,a)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,sortLinked(r)}function sortLinked(e){let t,n=1;do{let a=e,r;e=null;let o=null;for(t=0;a;){t++;let i=a,s=0;for(let c=0;c<n&&(s++,i=i.nextZ,!!i);c++);let l=n;for(;s>0||l>0&&i;)s!==0&&(l===0||!i||a.z<=i.z)?(r=a,a=a.nextZ,s--):(r=i,i=i.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;a=i}o.nextZ=null,n*=2}while(t>1);return e}function zOrder(e,t,n,a,r){return e=(e-n)*r|0,t=(t-a)*r|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function getLeftmost(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function pointInTriangle(e,t,n,a,r,o,i,s){return(r-i)*(t-s)>=(e-i)*(o-s)&&(e-i)*(a-s)>=(n-i)*(t-s)&&(n-i)*(o-s)>=(r-i)*(a-s)}function pointInTriangleExceptFirst(e,t,n,a,r,o,i,s){return!(e===i&&t===s)&&pointInTriangle(e,t,n,a,r,o,i,s)}function isValidDiagonal(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!intersectsPolygon(e,t)&&(locallyInside(e,t)&&locallyInside(t,e)&&middleInside(e,t)&&(area(e.prev,e,t.prev)||area(e,t.prev,t))||equals(e,t)&&area(e.prev,e,e.next)>0&&area(t.prev,t,t.next)>0)}function area(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function equals(e,t){return e.x===t.x&&e.y===t.y}function intersects(e,t,n,a){const r=sign(area(e,t,n)),o=sign(area(e,t,a)),i=sign(area(n,a,e)),s=sign(area(n,a,t));return!!(r!==o&&i!==s||r===0&&onSegment(e,n,t)||o===0&&onSegment(e,a,t)||i===0&&onSegment(n,e,a)||s===0&&onSegment(n,t,a))}function onSegment(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function sign(e){return e>0?1:e<0?-1:0}function intersectsPolygon(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&intersects(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function locallyInside(e,t){return area(e.prev,e,e.next)<0?area(e,t,e.next)>=0&&area(e,e.prev,t)>=0:area(e,t,e.prev)<0||area(e,e.next,t)<0}function middleInside(e,t){let n=e,a=!1;const r=(e.x+t.x)/2,o=(e.y+t.y)/2;do n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(a=!a),n=n.next;while(n!==e);return a}function splitPolygon(e,t){const n=createNode(e.i,e.x,e.y),a=createNode(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,a.next=n,n.prev=a,o.next=a,a.prev=o,a}function insertNode(e,t,n,a){const r=createNode(e,t,n);return a?(r.next=a.next,r.prev=a,a.next.prev=r,a.next=r):(r.prev=r,r.next=r),r}function removeNode(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function createNode(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function signedArea(e,t,n,a){let r=0;for(let o=t,i=n-a;o<n;o+=a)r+=(e[i]-e[o])*(e[o+1]+e[i+1]),i=o;return r}const Me=class Me{constructor(t,n,a="",r={},o=EngineCore.EngineStore.LastCreatedScene){le(this,"_name");le(this,"_text","");le(this,"_font");le(this,"_mesh",null);le(this,"_externalMesh");le(this,"_color",new EngineCore.Color4(1,1,1,1));le(this,"_fontSize",16);le(this,"_resolution",64);le(this,"_depth",10);le(this,"_scene");le(this,"_material");le(this,"_lowPriority",!0);le(this,"_disposed",!1);le(this,"_buildVersion",0);var i,s;this._name=t,this._font=n,this._text=a,this._fontSize=r.fontSize||16,this._resolution=r.resolution||64,this._depth=r.depth||1,this._color=r.color||new EngineCore.Color4(1,1,1,1),this._lowPriority=(i=r.lowPriority)!=null?i:!0,this._scene=o,this._externalMesh=new EngineCore.Mesh(`${t}-external-mesh`,o),this._externalMesh.billboardMode=(s=r.billboardMode)!=null?s:EngineCore.Mesh.BILLBOARDMODE_ALL,this._material=new EngineCore.StandardMaterial(`${t}-material`,o),this._material.diffuseColor=EngineCore.Color3.FromArray(this._color.asArray()),this._material.specularColor=new EngineCore.Color3(0,0,0),this._material.emissiveColor=EngineCore.Color3.FromArray(this._color.asArray()),this._material.disableLighting=!0,this._material.alpha=this._color.a,this._material.transparencyMode=EngineCore.Material.MATERIAL_ALPHABLEND,this.rebuildTextMesh()}static scheduleFlush(){if(Me._interactionPaused||Me._flushHandle!==null||Me._flushTimerHandle!==null)return;const t=globalThis;if(typeof t.requestIdleCallback=="function"){Me._flushHandle=t.requestIdleCallback(n=>{if(Me._flushHandle=null,!n.didTimeout&&n.timeRemaining()<3){Me.scheduleFlush();return}Me.flushQueue(1)},{timeout:120});return}if(typeof t.requestAnimationFrame=="function"){Me._flushHandle=t.requestAnimationFrame(()=>{Me._flushHandle=null,Me.flushQueue(1)});return}Me._flushTimerHandle=t.setTimeout(()=>{Me._flushTimerHandle=null,Me.flushQueue(1)},24)}static flushQueue(t){let n=0;for(;Me._pendingTasks.length>0&&n<t;){const a=Me._pendingTasks.shift();a==null||a(),n+=1}Me._pendingTasks.length>0&&Me.scheduleFlush()}static enqueueTask(t){Me._pendingTasks.push(t),Me.scheduleFlush()}static setInteractionPaused(t){Me._interactionPaused=t,t||Me.scheduleFlush()}createTextMeshNow(){this._disposed||(this._mesh=EngineCore.MeshBuilder.CreateText(this._name,this._text,this._font,{size:this._fontSize,resolution:this._resolution,depth:this._depth},this._scene,earcut),this._mesh.parent=this._externalMesh,this._mesh.material=this._material,this._mesh.billboardMode=this._externalMesh.billboardMode)}rebuildTextMesh(){this._buildVersion+=1;const t=this._buildVersion;if(this._mesh&&(this._mesh.dispose(),this._mesh=null),!(this._disposed||this._text===void 0||this._text===null||this._text.trim()==="")){if(!this._lowPriority){this.createTextMeshNow();return}Me.enqueueTask(()=>{this._disposed||t!==this._buildVersion||this.createTextMeshNow()})}}set color(t){this._color=t,this._material&&(this._material.diffuseColor=EngineCore.Color3.FromArray(t.asArray()),this._material.emissiveColor=EngineCore.Color3.FromArray(t.asArray()),this._material.alpha=t.a)}get color(){return this._color}set text(t){this._text!==t&&(this._text=t,this.rebuildTextMesh())}get text(){return this._text}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.rebuildTextMesh())}get fontSize(){return this._fontSize}set resolution(t){this._resolution!==t&&(this._resolution=t,this.rebuildTextMesh())}get resolution(){return this._resolution}set depth(t){this._depth!==t&&(this._depth=t,this.rebuildTextMesh())}set billboardMode(t){this._externalMesh.billboardMode!==t&&(this._externalMesh.billboardMode=t,this._mesh&&(this._mesh.billboardMode=t))}get billboardMode(){return this._externalMesh.billboardMode}set lowPriority(t){const n=this._lowPriority!==t;this._lowPriority=t,n&&!t&&!this._mesh&&this._text.trim()!==""&&this.rebuildTextMesh()}get lowPriority(){return this._lowPriority}update(t){let n=!1;t.text!==void 0&&t.text!==this._text&&(this._text=t.text,n=!0),t.fontSize!==void 0&&t.fontSize!==this._fontSize&&(this._fontSize=t.fontSize,n=!0),t.resolution!==void 0&&t.resolution!==this._resolution&&(this._resolution=t.resolution,n=!0),t.depth!==void 0&&t.depth!==this._depth&&(this._depth=t.depth,n=!0),t.color!==void 0&&(this.color=t.color),t.billboardMode!==void 0&&(this.billboardMode=t.billboardMode),t.lowPriority!==void 0&&t.lowPriority!==this._lowPriority&&(this._lowPriority=t.lowPriority,!this._lowPriority&&!this._mesh&&this._text.trim()!==""&&(n=!0)),n&&this.rebuildTextMesh()}get depth(){return this._depth}get mesh(){return this._externalMesh}get textMesh(){return this._mesh}dispose(){this._disposed=!0,this._buildVersion+=1,this._mesh&&this._mesh.dispose(),this._material.dispose(),this._externalMesh.dispose(),this._mesh=null}};le(Me,"_pendingTasks",[]),le(Me,"_flushHandle",null),le(Me,"_flushTimerHandle",null),le(Me,"_interactionPaused",!1);let FreeTypeText=Me;const FreeTypeText$1=FreeTypeText,GUIText=e=>{const t=reactBabylonjs.useScene(),n=React.useRef(null),a=React.useRef(null),r=useCachedJSON({url:"/Noto Sans SC_Regular.json"}),{name:o,text:i,fontSize:s,color:l,billboardMode:c=EngineCore.Mesh.BILLBOARDMODE_ALL,lowPriority:f=!0}=e;return React.useEffect(()=>{var u;if(a.current&&a.current.dispose(),r&&t)return a.current=new FreeTypeText$1((u=e.name)!=null?u:"gui-text-no-name",r,e.text,{fontSize:e.fontSize,color:typeof e.color=="string"?EngineCore.Color4.FromHexString(e.color):e.color,billboardMode:c,lowPriority:f},t),a.current.mesh.parent=n.current,a.current.mesh.onDisposeObservable.addOnce(()=>{a.current=null}),()=>{var d;(d=a.current)==null||d.dispose(),a.current=null}},[r,t]),React.useEffect(()=>{a.current&&(a.current.update({text:i,fontSize:s,color:typeof l=="string"?EngineCore.Color4.FromHexString(l):l,lowPriority:f}),a.current.mesh.parent=n.current)},[i,s,l,f]),React.useEffect(()=>{a.current&&c!==void 0&&(a.current.billboardMode=c)},[c]),React.useEffect(()=>{if(!t||!t.activeCamera)return;let u=null;const d=()=>{FreeTypeText$1.setInteractionPaused(!0),u&&clearTimeout(u),u=setTimeout(()=>{FreeTypeText$1.setInteractionPaused(!1)},150)},h=t.activeCamera.onViewMatrixChangedObservable.add(d);return()=>{var m;(m=t.activeCamera)==null||m.onViewMatrixChangedObservable.remove(h),u&&clearTimeout(u),FreeTypeText$1.setInteractionPaused(!1)}},[t]),jsxRuntime.jsx("transformNode",{name:o!=null?o:"no-name-text",ref:n})},GUIText$1=GUIText,FormationFace=({urlTopLayer:e,urlBottomLayer:t,showLayerLabel:n=!1,labelStyle:a,position:r=EngineCore.Vector3.Zero(),visible:o=!0,showBottomLayer:i=!1,actions:s,material:l={type:MaterialType.COLOR_ID,alpha:1}})=>{var O,F;const c=React.useRef(null),f=React.useRef(null),[u,d]=React.useState(""),[h,m]=React.useState(null),R=React.useContext(WorkspaceMetaContext),v=React.useContext(ColorProviderContext),[g,x]=React.useState(EngineCore.Color3.White()),y=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH}),E=useCachedBinary({url:t,cacheType:CacheType.URL_PREFIX_MATCH}),k=useCachedTexture({url:l==null?void 0:l.texture,cacheType:CacheType.URL_PREFIX_MATCH}),b=useCachedTexture({url:l==null?void 0:l.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH});React.useEffect(()=>{console.log("[Geo3DViewer] FormationFace Loading: ",e,t)},[e,t]);const[C,_]=React.useState(),[A,N]=React.useState(EngineCore.Vector3.Zero()),[S,I]=React.useState(void 0);return React.useEffect(()=>{if(y){const w=c.current;w&&(EngineCore.Tags.EnableFor(w),EngineCore.Tags.AddTagsTo(w,"loading"));let L=[],B=[],D=[];const W=Formation.decode(new Uint8Array(y));{const{name:H,points:oe,indices:te,colorId:K,value:Z,center:ce}=W;L=oe,B=te,D=Z,m(K),d(H),ce&&N(new EngineCore.Vector3(ce.x,ce.y,ce.z))}const ae=new EngineCore.VertexData;ae.positions=L,ae.indices=B,ae.colors=D;const ee=[];if(EngineCore.VertexData.ComputeNormals(L,B,ee),ae.normals=ee,w){ae.applyToMesh(w);const H=w.getBoundingInfo();_(H.boundingBox.center.add(new EngineCore.Vector3(H.boundingBox.extendSize.x,0,0))),i||w.getScene().onAfterRenderObservable.addOnce(()=>{if(!w.isDisposed()){const te=w.getBoundingInfo();I(te.boundingBox)}})}return w&&EngineCore.Tags.RemoveTagsFrom(w,"loading"),()=>{w&&new EngineCore.VertexData().applyToMesh(w)}}},[y,i]),React.useEffect(()=>{if(y&&E){const w=f.current;w&&(EngineCore.Tags.EnableFor(w),EngineCore.Tags.AddTagsTo(w,"loading"));let L=[],B=[],D=[],W=[],ae=[],ee=[],H=[],oe=[];{const fe=Formation.decode(new Uint8Array(y)),{points:V,indices:J,border:Re,value:Ce}=fe;L=V,B=J,W=Re,D=Ce}{const fe=Formation.decode(new Uint8Array(E)),{points:V,bottomIndices:J,border:Re,value:Ce}=fe;ae=V,ee=J,H=Re,oe=Ce}const te=new EngineCore.VertexData,K=new Float32Array(L.length+ae.length);let Z=B.length+ee.length;Z=Z+(W.length-1)*6;const ce=new Int32Array(Z),Q=new Float32Array(D.length+oe.length);K.set(L),ce.set(B),Q.set(D),K.set(ae,L.length),ce.set(ee,B.length),Q.set(oe,D.length);const G=[];for(let fe=0;fe<W.length-1;fe++)G.push(W[fe+1]),G.push(W[fe]),G.push(H[fe]+L.length/3),G.push(H[fe+1]+L.length/3),G.push(H[fe]+L.length/3),G.push(W[fe+1]);ce.set(G,B.length+ee.length),te.positions=K,te.indices=ce,te.colors=Q;const ge=[];return EngineCore.VertexData.ComputeNormals(K,ce,ge),te.normals=ge,w&&(te.applyToMesh(w),i&&w.getScene().onAfterRenderObservable.addOnce(()=>{if(!w.isDisposed()){const V=w.getBoundingInfo();I(V.boundingBox)}})),w&&EngineCore.Tags.RemoveTagsFrom(w,"loading"),()=>{w&&new EngineCore.VertexData().applyToMesh(w)}}},[E,y,i]),React.useEffect(()=>{var w;x(l.type===MaterialType.ONE_COLOR?(w=l==null?void 0:l.color)!=null?w:EngineCore.Color3.Random():h&&v.colorIDs[h]?new EngineCore.Color3(v.colorIDs[h].r,v.colorIDs[h].g,v.colorIDs[h].b):EngineCore.Color3.Random())},[v.colorIDs,h,l==null?void 0:l.color,l.type]),React.useEffect(()=>{c.current&&(c.current.metadata={pickable:s?{name:u,onLeftClick:s.onLeftClick,onRightClick:s.onRightClick,onMiddleClick:s.onMiddleClick,onHover:s.onHover,extra:s.extra}:null}),f.current&&(f.current.metadata={pickable:s?{name:u,onLeftClick:s.onLeftClick,onRightClick:s.onRightClick,onMiddleClick:s.onMiddleClick,onHover:s.onHover,extra:s.extra}:null})},[s,u]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("transformNode",{name:`transform-formation-${u}-${e}`,position:A.add(r).multiplyByFloats(R&&R.scalePlane?R.scalePlane:1,R&&R.scaleDepth?R.scaleDepth:1,R&&R.scalePlane?R.scalePlane:1),scaling:new EngineCore.Vector3(R?R.scalePlane:1,R?R.scaleDepth:1,R?R.scalePlane:1),setEnabled:o,children:[jsxRuntime.jsx("mesh",{name:`formation-${u}-mesh-${e}`,ref:c,setEnabled:!i,useVertexColors:l.type===MaterialType.COLOR_CODEC,alwaysSelectAsActiveMesh:!0,children:l.type===MaterialType.TEXTURE?k?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`formation-${u}-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,texture:k,sideTexture:b,tilingFactor:l.tilingFactor,sideTilingFactor:(O=l==null?void 0:l.sideTilingFactor)!=null?O:l==null?void 0:l.tilingFactor,mode:l.textureMode===void 0?RepeatedTextureMode.PLANE:l.textureMode,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):l.type===MaterialType.COLOR_CODEC?l.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`formation-${u}-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,alpha:l.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:l.colorCodec,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):l.type===MaterialType.COLOR_ID?jsxRuntime.jsx(OneColorMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,surfaceCanvasOptions:l.surfaceCanvasOptions,color:g,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,boundingBox:S,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite,disableNormalShadow:l.disableNormalShadow}):jsxRuntime.jsx(OneColorMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,color:g,surfaceCanvasOptions:l.surfaceCanvasOptions,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,boundingBox:S,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite,disableNormalShadow:l.disableNormalShadow})}),jsxRuntime.jsx("mesh",{name:`formation-${u}-vol-${e}`,ref:f,setEnabled:i,useVertexColors:l.type===MaterialType.COLOR_CODEC,alwaysSelectAsActiveMesh:!0,children:l.type===MaterialType.TEXTURE?k?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,sideTexture:b,texture:k,tilingFactor:l.tilingFactor,sideTilingFactor:(F=l==null?void 0:l.sideTilingFactor)!=null?F:l==null?void 0:l.tilingFactor,mode:l.textureMode===void 0?RepeatedTextureMode.PLANE:l.textureMode,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):l.type===MaterialType.COLOR_CODEC?l.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,alpha:l.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:l.colorCodec,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):l.type===MaterialType.COLOR_ID?jsxRuntime.jsx(OneColorMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,surfaceCanvasOptions:l.surfaceCanvasOptions,color:g,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite,disableNormalShadow:l.disableNormalShadow}):jsxRuntime.jsx(OneColorMaterial,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,surfaceCanvasOptions:l.surfaceCanvasOptions,color:g,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:l.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:S,lines:l.lines,text:l.text,scaleDepth:R?R.scaleDepth:1,scalePlane:R?R.scalePlane:1,disableDepthWrite:l.disableDepthWrite,disableNormalShadow:l.disableNormalShadow})}),u&&C&&jsxRuntime.jsx("transformNode",{name:`${u}-title-${e}`,position:C.add(a!=null&&a.offset?a.offset.multiplyByFloats(R!=null&&R.scalePlane?R==null?void 0:R.scalePlane:1,1,R!=null&&R.scalePlane?R==null?void 0:R.scalePlane:1):EngineCore.Vector3.Zero()),scaling:calcGUIScale(R).multiply(new EngineCore.Vector3(3,3,3)),setEnabled:n,children:jsxRuntime.jsx(GUIText$1,{text:u,fontSize:a!=null&&a.fontSize?a.fontSize:40,color:a!=null&&a.color?a.color:"white"})})]})})},FormationFace$1=FormationFace,FormationVolume=({url:e,showLayerLabel:t=!1,labelStyle:n,position:a=EngineCore.Vector3.Zero(),visible:r=!0,showBottomLayer:o=!1,actions:i,material:s={type:MaterialType.COLOR_ID,counterLine:void 0,alpha:1}})=>{var S,I;const l=React.useRef(null),c=React.useRef(null),[f,u]=React.useState(""),[d,h]=React.useState(null),[m,R]=React.useState(EngineCore.Color3.White()),v=React.useContext(WorkspaceMetaContext),g=React.useContext(ColorProviderContext),[x,y]=React.useState(EngineCore.Vector3.Zero()),[E,k]=React.useState(),b=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH}),C=useCachedTexture({url:s==null?void 0:s.texture,cacheType:CacheType.URL_PREFIX_MATCH}),_=useCachedTexture({url:s==null?void 0:s.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),[A,N]=React.useState(void 0);return React.useEffect(()=>{console.log("[Geo3DViewer] FormationVolume Loading: ",e)},[e]),React.useEffect(()=>{if(b){const O=l.current,F=c.current;EngineCore.Tags.EnableFor(O),EngineCore.Tags.AddTagsTo(O,"loading"),EngineCore.Tags.EnableFor(c),EngineCore.Tags.AddTagsTo(c,"loading");let w=[],L=[],B=[],D=[];const W=Formation.decode(new Uint8Array(b)),{name:ae,points:ee,indices:H,colorId:oe,side:te,sideIndices:K,center:Z,value:ce,sideValue:Q}=W;Z&&y(new EngineCore.Vector3(Z.x,Z.y,Z.z)),w=ee,L=H,B=te,D=K,h(oe),u(ae);const G=new EngineCore.VertexData,ge=new EngineCore.VertexData,fe=new Float32Array(w.length+B.length),V=new Int32Array(L.length+D.length),J=new Float32Array(ce.length+Q.length);G.positions=w,G.indices=L,G.colors=ce;const Re=[];EngineCore.VertexData.ComputeNormals(ee,H,Re),G.normals=Re,fe.set(w),V.set(L),J.set(ce),fe.set(B,w.length),V.set(D,L.length),J.set(Q,ce.length),ge.positions=fe,ge.indices=V,ge.colors=J;const Ce=[];if(EngineCore.VertexData.ComputeNormals(fe,V,Ce),ge.normals=Ce,O){G.applyToMesh(O);const Y=O.getBoundingInfo();k(Y.boundingBox.center.add(new EngineCore.Vector3(Y.boundingBox.extendSize.x,0,0))),o||O.getScene().onAfterRenderObservable.addOnce(()=>{if(!O.isDisposed()){const ne=O.getBoundingInfo();N(ne.boundingBox)}})}return F&&(ge.applyToMesh(F),o&&F.getScene().onAfterRenderObservable.addOnce(()=>{if(!F.isDisposed()){const ue=F.getBoundingInfo();N(ue.boundingBox)}})),EngineCore.Tags.RemoveTagsFrom(O,"loading"),EngineCore.Tags.RemoveTagsFrom(c,"loading"),()=>{O&&new EngineCore.VertexData().applyToMesh(O),F&&new EngineCore.VertexData().applyToMesh(F)}}},[b,o]),React.useEffect(()=>{var O;R(s.type===MaterialType.ONE_COLOR?(O=s==null?void 0:s.color)!=null?O:EngineCore.Color3.Random():d&&g.colorIDs[d]?new EngineCore.Color3(g.colorIDs[d].r,g.colorIDs[d].g,g.colorIDs[d].b):EngineCore.Color3.Random())},[g.colorIDs,d,s==null?void 0:s.color,s.type]),React.useEffect(()=>{l.current&&(l.current.metadata={pickable:i?{name:f,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null}),c.current&&(c.current.metadata={pickable:i?{name:f,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null})},[i,f]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("transformNode",{name:`transform-formation-${f}-${e}`,position:x.add(a).multiplyByFloats(v&&v.scalePlane?v.scalePlane:1,v&&v.scaleDepth?v.scaleDepth:1,v&&v.scalePlane?v.scalePlane:1),scaling:new EngineCore.Vector3(v?v.scalePlane:1,v?v.scaleDepth:1,v?v.scalePlane:1),setEnabled:r,children:[jsxRuntime.jsx("mesh",{name:`formation-${f}-mesh-${e}`,ref:l,setEnabled:!o,useVertexColors:s.type===MaterialType.COLOR_CODEC,children:s.type===MaterialType.TEXTURE?C?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`formation-${f}-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:s.alpha,flatModeRotate:s.flatModeRotate,sideTexture:_,texture:C,tilingFactor:s.tilingFactor,sideTilingFactor:(S=s==null?void 0:s.sideTilingFactor)!=null?S:s==null?void 0:s.tilingFactor,mode:s.textureMode===void 0?RepeatedTextureMode.PLANE:s.textureMode,counterLine:s.counterLine,boundingBox:A,lines:s.lines,text:s.text,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):s.type===MaterialType.COLOR_CODEC?s.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`formation-${f}-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,alpha:s.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:s.colorCodec,counterLine:s.counterLine,boundingBox:A,lines:s.lines,text:s.text,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):s.type===MaterialType.COLOR_ID?jsxRuntime.jsx(DiffuseTerrainMaterial$1,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,color:m,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:s.alpha,lightPosition:s.lightPosition,intensity:s.intensity,surfaceCanvasOptions:s.surfaceCanvasOptions,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:A,lines:s.lines,text:s.text,zOffset:s.zOffset,zOffsetUnits:s.zOffsetUnits,contrast:s.contrast,sideIntensity:s.sideIntensity,cullFace:s.cullFace,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(DiffuseTerrainMaterial$1,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,color:m,alphaMode:EngineCore.Engine.ALPHA_COMBINE,surfaceCanvasOptions:s.surfaceCanvasOptions,alpha:s.alpha,lightPosition:s.lightPosition,intensity:s.intensity,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:A,lines:s.lines,text:s.text,zOffset:s.zOffset,zOffsetUnits:s.zOffsetUnits,contrast:s.contrast,sideIntensity:s.sideIntensity,cullFace:s.cullFace,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite})}),jsxRuntime.jsx("mesh",{name:`formation-${f}-vol-${e}`,ref:c,setEnabled:o,useVertexColors:s.type===MaterialType.COLOR_CODEC,children:s.type===MaterialType.TEXTURE?C?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:s.alpha,sideTexture:_,texture:C,tilingFactor:s.tilingFactor,sideTilingFactor:(I=s==null?void 0:s.sideTilingFactor)!=null?I:s==null?void 0:s.tilingFactor,mode:s.textureMode===void 0?RepeatedTextureMode.PLANE:s.textureMode,flatModeRotate:s.flatModeRotate,counterLine:s.counterLine,boundingBox:A,lines:s.lines,text:s.text,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):s.type===MaterialType.COLOR_CODEC?s.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,alpha:s.alpha,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:s.colorCodec,counterLine:s.counterLine,boundingBox:A,lines:s.lines,text:s.text,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):s.type===MaterialType.COLOR_ID?jsxRuntime.jsx(DiffuseTerrainMaterial$1,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,color:m,surfaceCanvasOptions:s.surfaceCanvasOptions,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:s.alpha,lightPosition:s.lightPosition,intensity:s.intensity,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:A,lines:s.lines,text:s.text,zOffset:s.zOffset,zOffsetUnits:s.zOffsetUnits,contrast:s.contrast,sideIntensity:s.sideIntensity,cullFace:s.cullFace,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):jsxRuntime.jsx(DiffuseTerrainMaterial$1,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,color:m,surfaceCanvasOptions:s.surfaceCanvasOptions,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:s.alpha,lightPosition:s.lightPosition,intensity:s.intensity,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,boundingBox:A,lines:s.lines,text:s.text,zOffset:s.zOffset,zOffsetUnits:s.zOffsetUnits,contrast:s.contrast,sideIntensity:s.sideIntensity,cullFace:s.cullFace,scaleDepth:v?v.scaleDepth:1,scalePlane:v?v.scalePlane:1,disableDepthWrite:s.disableDepthWrite})}),f&&E&&jsxRuntime.jsx("transformNode",{name:`${f}-title-${e}`,position:E.add(n!=null&&n.offset?n.offset.multiplyByFloats(v!=null&&v.scalePlane?v==null?void 0:v.scalePlane:1,1,v!=null&&v.scalePlane?v==null?void 0:v.scalePlane:1):EngineCore.Vector3.Zero()),scaling:calcGUIScale(v).multiply(new EngineCore.Vector3(3,3,3)),setEnabled:t,children:jsxRuntime.jsx(GUIText$1,{text:f,fontSize:n!=null&&n.fontSize?n.fontSize:40,color:n!=null&&n.color?n.color:"white"})})]})})},FormationVolume$1=FormationVolume;var FormationGroup_FormationMode=(e=>(e[e.FACE=0]="FACE",e[e.VOLUME=1]="VOLUME",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(FormationGroup_FormationMode||{});function formationGroup_FormationModeFromJSON(e){switch(e){case 0:case"FACE":return 0;case 1:case"VOLUME":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function formationGroup_FormationModeToJSON(e){switch(e){case 0:return"FACE";case 1:return"VOLUME";case-1:default:return"UNRECOGNIZED"}}function createBaseFormationGroup(){return{name:"",formations:[],mode:0,effectMeshs:[]}}const FormationGroup={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.formations)FormationGroup_FormationInfo.encode(n,t.uint32(34).fork()).ldelim();e.mode!==0&&t.uint32(40).int32(e.mode);for(const n of e.effectMeshs)Mesh.encode(n,t.uint32(50).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseFormationGroup();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 4:if(o!==34)break;r.formations.push(FormationGroup_FormationInfo.decode(n,n.uint32()));continue;case 5:if(o!==40)break;r.mode=n.int32();continue;case 6:if(o!==50)break;r.effectMeshs.push(Mesh.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$a(e.name)?globalThis.String(e.name):"",formations:globalThis.Array.isArray(e==null?void 0:e.formations)?e.formations.map(t=>FormationGroup_FormationInfo.fromJSON(t)):[],mode:isSet$a(e.mode)?formationGroup_FormationModeFromJSON(e.mode):0,effectMeshs:globalThis.Array.isArray(e==null?void 0:e.effectMeshs)?e.effectMeshs.map(t=>Mesh.fromJSON(t)):[]}},toJSON(e){var n,a;const t={};return e.name!==""&&(t.name=e.name),(n=e.formations)!=null&&n.length&&(t.formations=e.formations.map(r=>FormationGroup_FormationInfo.toJSON(r))),e.mode!==0&&(t.mode=formationGroup_FormationModeToJSON(e.mode)),(a=e.effectMeshs)!=null&&a.length&&(t.effectMeshs=e.effectMeshs.map(r=>Mesh.toJSON(r))),t},create(e){return FormationGroup.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o;const t=createBaseFormationGroup();return t.name=(n=e.name)!=null?n:"",t.formations=((a=e.formations)==null?void 0:a.map(i=>FormationGroup_FormationInfo.fromPartial(i)))||[],t.mode=(r=e.mode)!=null?r:0,t.effectMeshs=((o=e.effectMeshs)==null?void 0:o.map(i=>Mesh.fromPartial(i)))||[],t}};function createBaseFormationGroup_FormationInfo(){return{name:"",url:""}}const FormationGroup_FormationInfo={encode(e,t=minimal.Writer.create()){return e.name!==""&&t.uint32(10).string(e.name),e.url!==""&&t.uint32(18).string(e.url),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseFormationGroup_FormationInfo();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.url=n.string();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$a(e.name)?globalThis.String(e.name):"",url:isSet$a(e.url)?globalThis.String(e.url):""}},toJSON(e){const t={};return e.name!==""&&(t.name=e.name),e.url!==""&&(t.url=e.url),t},create(e){return FormationGroup_FormationInfo.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseFormationGroup_FormationInfo();return t.name=(n=e.name)!=null?n:"",t.url=(a=e.url)!=null?a:"",t}};function isSet$a(e){return e!=null}const StructureLayer=({url:e,alpha:t=1,position:n=EngineCore.Vector3.Zero(),visible:a=!0,colorCodec:r,actions:o,counterLine:i=void 0,lines:s,text:l,disableDepthWrite:c})=>{const f=React.useRef(null),[u,d]=React.useState(""),h=React.useContext(WorkspaceMetaContext),m=React.useContext(ColorProviderContext),[R,v]=React.useState(null),[g,x]=React.useState(EngineCore.Color3.White()),y=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH}),[E,k]=React.useState(EngineCore.Vector3.Zero()),[b,C]=React.useState();return React.useEffect(()=>{console.log("[Geo3DViewer] StructureLayer Loading: ",e)},[e]),React.useEffect(()=>{if(y){const _=f.current;EngineCore.Tags.EnableFor(_),EngineCore.Tags.AddTagsTo(_,"loading");const A=Formation.decode(new Uint8Array(y)),{name:N,points:S,indices:I,value:O,colorId:F,center:w}=A;w&&k(new EngineCore.Vector3(w.x,w.y,w.z));const L=new EngineCore.VertexData;L.positions=S,L.indices=I,L.colors=O;const B=[];return EngineCore.VertexData.ComputeNormals(S,I,B),L.normals=B,v(F),d(N),_&&(L.applyToMesh(_),_.getScene().onAfterRenderObservable.addOnce(()=>{if(!_.isDisposed()){const W=_.getBoundingInfo();C(W.boundingBox)}})),EngineCore.Tags.RemoveTagsFrom(_,"loading"),()=>{v(null),d(""),_&&new EngineCore.VertexData().applyToMesh(_)}}},[y]),React.useEffect(()=>{const _=R&&m.colorIDs[R]?m.colorIDs[R]:EngineCore.Color3.White();x(EngineCore.Color3.FromArray([_.r,_.g,_.b]))},[R,m.colorIDs]),React.useEffect(()=>{f.current&&(f.current.metadata={pickable:o?{name:u,onLeftClick:o.onLeftClick,onRightClick:o.onRightClick,onMiddleClick:o.onMiddleClick,onHover:o.onHover,extra:o.extra}:null})},[o,u]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("transformNode",{name:`transform-structurelayer-${u}`,position:E.add(n).multiplyByFloats(h&&h.scalePlane?h.scalePlane:1,h&&h.scaleDepth?h.scaleDepth:1,h&&h.scalePlane?h.scalePlane:1),scaling:new EngineCore.Vector3(h?h.scalePlane:1,h?h.scaleDepth:1,h?h.scalePlane:1),setEnabled:a,children:[jsxRuntime.jsx("transformNode",{name:`structurelayer-${u}-load`}),jsxRuntime.jsx("mesh",{name:`structurelayer-${u}-mesh`,ref:f,useVertexColors:r!=null,children:r?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`structurelayer-${u}-mat`,backFaceCulling:!1,alpha:t,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:r,needDepthPrePass:!0,counterLine:i,boundingBox:b,lines:s,scaleDepth:h?h.scaleDepth:1,scalePlane:h?h.scalePlane:1,text:l,disableDepthWrite:c}):jsxRuntime.jsx("standardMaterial",{name:`structurelayer-${u}-mat`,backFaceCulling:!1,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),diffuseColor:g,needDepthPrePass:!0,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:t,disableDepthWrite:c})})]})})},StructureLayer$1=StructureLayer,FormationEdgeEffect=e=>{const{id:t,visible:n=!0,position:a=EngineCore.Vector3.Zero(),diffuseTextureUrl:r,diffuseTextureSufaceUrl:o,bumpTextureUrl:i,mesh:s}=e,l=React.useRef(null),c=React.useContext(WorkspaceMetaContext),[f,u]=React.useState(),[d,h]=React.useState(),[m,R]=React.useState();return React.useEffect(()=>{const v=l.current;if(v&&s){const g=new EngineCore.VertexData;g.positions=s.vertices,g.indices=s.indices,g.uvs=s.uv;const x=[];EngineCore.VertexData.ComputeNormals(s.vertices,s.indices,x),g.normals=x,g.applyToMesh(v)}},[s,s==null?void 0:s.indices,s==null?void 0:s.uv,s==null?void 0:s.vertices]),React.useEffect(()=>{const v=new EngineCore.Texture(r);if(v.uScale=500,v.vScale=.5,u(v),o){const x=new EngineCore.Texture(o);x.uScale=500,x.vScale=.5,h(x)}const g=new EngineCore.Texture(i);g.uScale=500,g.vScale=.5,R(g)},[i,o,r]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`transform-formation-edge-${t}`,position:a.multiplyByFloats(c&&c.scalePlane?c.scalePlane:1,c&&c.scaleDepth?c.scaleDepth:1,c&&c.scalePlane?c.scalePlane:1),scaling:new EngineCore.Vector3(c?c.scalePlane:1,c?c.scaleDepth:1,c?c.scalePlane:1),setEnabled:n,children:jsxRuntime.jsx("mesh",{name:"mesh",ref:l,children:jsxRuntime.jsx("standardMaterial",{name:`edge-${t}-material`,zOffset:-1,zOffsetUnits:-1,diffuseTexture:o?d:f,bumpTexture:o?void 0:m})})})})},FormationEdgeEffect$1=FormationEdgeEffect,ComplexFormationManager=({url:e,visible:t=!0,filter:n,explodedView:a=0,showLayerLabel:r,labelStyle:o,offset:i=new EngineCore.Vector3(0,0,0),showTopLayerAsStructureLayer:s=!1,useColorCodecOnTopLayer:l=!1,colorCodec:c,actions:f,materials:u,topLayerCounterLine:d=void 0,topLayerHeightOffset:h=1,diffuseTextureUrl:m,diffuseTextureSufaceUrl:R,bumpTextureUrl:v,visibleEdgeEffect:g=!1})=>{var I,O;const[x,y]=React.useState(),E=React.useContext(WorkspaceMetaContext),[k,b]=React.useState(!0),[C,_]=React.useState(""),A=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH}),[N,S]=React.useState([]);return React.useEffect(()=>{console.log("[Geo3DViewer] ComplexFormationManager Loading: ",e)},[e]),React.useEffect(()=>{if(A){const F=FormationGroup.decode(new Uint8Array(A)),w=F.formations;if(F.mode==FormationGroup_FormationMode.FACE){b(!0),_(F.name);const L=[];w.forEach((B,D)=>{const W={name:B.name,topUrl:B.url,bottomUrl:w[D+1]?w[D+1].url:void 0};L.push(W)}),y(L)}else{b(!1),_(F.name);const L=[];w.forEach(B=>{const D={name:B.name,topUrl:B.url};L.push(D)}),y(L)}return console.log(F),S(F.effectMeshs),()=>{y([])}}},[A]),jsxRuntime.jsxs("abstractMesh",{name:`complexformationmanager-${C}`,children:[s&&x&&x.length>1?jsxRuntime.jsx(StructureLayer$1,{url:x[0].topUrl,alpha:(I=u==null?void 0:u[x[0].name])==null?void 0:I.alpha,position:new EngineCore.Vector3(0,h>=0?h*(E&&(O=E.scaleDepth)!=null?O:1):0,0).add(i),visible:t&&(n?n.includes(x[0].name):!0),colorCodec:c,counterLine:d},`${C}-${x[0].name}-SL`):null,x?x.map((F,w)=>k?s&&w===0?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx("transformNode",{name:`${C}-${F.name}-EV`,position:i.add(new EngineCore.Vector3(0,w*(-1*a*(E&&E.scaleDepth?E.scaleDepth:0)),0)),children:jsxRuntime.jsx(FormationFace$1,{showLayerLabel:r,labelStyle:o,urlTopLayer:F.topUrl,urlBottomLayer:F.bottomUrl,visible:t&&(n?n.includes(F.name):!0),showBottomLayer:x[w+1]?n?n.includes(x[w+1].name):!0:!1,actions:f,material:w===0&&l?{...u==null?void 0:u[F.name],colorCodec:c,type:MaterialType.COLOR_CODEC}:u==null?void 0:u[F.name]},`${C}-${F.name}`)},`${C}-${F.name}`):s&&w===0?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx("transformNode",{name:`${C}-${F.name}-EV`,position:i.add(new EngineCore.Vector3(0,w*(-1*a*(E&&E.scaleDepth?E.scaleDepth:0)),0)),children:jsxRuntime.jsx(FormationVolume$1,{url:F.topUrl,showLayerLabel:r,labelStyle:o,visible:t&&(n?n.includes(F.name):!0),showBottomLayer:x[w+1]?n?n.includes(x[w+1].name):!0:!1,actions:f,material:u==null?void 0:u[F.name]},`${C}-${F.name}`)},`${C}-${F.name}`)):null,N&&m&&v&&a===0&&N.map((F,w)=>jsxRuntime.jsx(FormationEdgeEffect$1,{visible:g,id:w,diffuseTextureUrl:m,diffuseTextureSufaceUrl:w===0?R:void 0,bumpTextureUrl:v,mesh:F},w))]})},ComplexFormationManager$1=ComplexFormationManager,Coordinate=({visible:e=!0,color:t=EngineCore.Color3.White(),fontSize:n=80,step:a=200,keyFrameDistance:r=[],keyFrameStep:o=[],keyFrameFontSize:i=[],textureSizeX:s=512,textureSizeY:l=512,init:c=!0})=>{const f=reactBabylonjs.useScene(),u=React.useRef(null),d=React.useContext(WorkspaceMetaContext),[h,m]=React.useState([]),[R,v]=React.useState([]),[g,x]=React.useState([]),[y,E]=React.useState(0),k=React.useCallback(b=>{if(f&&b){const C=new EngineMaterial.GridMaterial("axis-material",f);C.majorUnitFrequency=o.length>0?o[0]:50,C.minorUnitVisibility=0,C.gridRatio=2,C.sideOrientation=EngineCore.Material.ClockWiseSideOrientation,C.backFaceCulling=!0,C.mainColor=t,C.lineColor=t,C.opacity=.98,b.material=C}},[t,o,f]);return React.useEffect(()=>()=>{var b;(b=u.current)==null||b.dispose()},[]),React.useEffect(()=>{const b=()=>{const C=(f==null?void 0:f.activeCamera).radius;for(let _=0;_<r.length;_++)if(C<=r[_]){E(_);break}};return f&&f.activeCamera&&(f==null||f.activeCamera.onViewMatrixChangedObservable.add(b)),()=>{f&&f.activeCamera&&(f==null||f.activeCamera.onViewMatrixChangedObservable.removeCallback(b))}},[r,i,o,f,e]),React.useEffect(()=>{if(d&&d.min&&d.max&&c){const b=d.origin||EngineCore.Vector3.Zero(),C=[],_=[],A=[],N=[...o];N.length===0&&N.push(a);for(let S=0;S<N.length;S++){let I=N[S]/1;I<1&&(I=200);const O=[];for(let L=0;L<=d.max.x-d.min.x;L+=I)O.push({text:`${L+d.min.x+b.x}`,position:new EngineCore.Vector3(L,0,0)}),O.push({text:`${L+d.min.x+b.x}`,position:new EngineCore.Vector3(L,d.max.y-d.min.y,d.max.z-d.min.z)}),O.push({text:`${L+d.min.x+b.x}`,position:new EngineCore.Vector3(L,d.max.y-d.min.y,0)}),O.push({text:`${L+d.min.x+b.x}`,position:new EngineCore.Vector3(L,0,d.max.z-d.min.z)});C.push(O);const F=[];for(let L=0;L<=d.max.y-d.min.y;L+=I)F.push({text:`${L+d.min.y+b.y}`,position:new EngineCore.Vector3(0,L,0)}),F.push({text:`${L+d.min.y+b.y}`,position:new EngineCore.Vector3(d.max.x-d.min.x,L,d.max.z-d.min.z)}),F.push({text:`${L+d.min.y+b.y}`,position:new EngineCore.Vector3(d.max.x-d.min.x,L,0)}),F.push({text:`${L+d.min.y+b.y}`,position:new EngineCore.Vector3(0,L,d.max.z-d.min.z)});_.push(F);const w=[];for(let L=0;L<=d.max.z-d.min.z;L+=I)w.push({text:`${L+d.min.z+b.z}`,position:new EngineCore.Vector3(0,0,L)}),w.push({text:`${L+d.min.z+b.z}`,position:new EngineCore.Vector3(d.max.x-d.min.x,d.max.y-d.min.y,L)}),w.push({text:`${L+d.min.z+b.z}`,position:new EngineCore.Vector3(0,d.max.y-d.min.y,L)}),w.push({text:`${L+d.min.z+b.z}`,position:new EngineCore.Vector3(d.max.x-d.min.x,0,L)});A.push(w)}m(C),v(_),x(A)}},[c,o,d,a]),d&&d.min&&d.max&&d.max.x-d.min.x>0&&d.max.y-d.min.y>0&&d.max.z-d.min.z>0?jsxRuntime.jsxs("transformNode",{name:"coord",setEnabled:e,position:(d&&d.min&&d.max?EngineCore.Vector3.Center(d.min,d.max):EngineCore.Vector3.Zero()).multiply(calcTransformNodeScale(d)),scaling:new EngineCore.Vector3(calcTransformNodeScale(d).x,calcTransformNodeScale(d).y,calcTransformNodeScale(d).z),children:[jsxRuntime.jsx("box",{name:"axis",width:d&&d.min&&d.max?d.max.x-d.min.x:0,height:d&&d.min&&d.max?d.max.y-d.min.y:0,depth:d&&d.min&&d.max?d.max.z-d.min.z:0,ref:k,isPickable:!1,isBlocker:!1},`axis-${d.max.x-d.min.x}-${d.max.y-d.min.y}-${d.max.z-d.min.z}`),jsxRuntime.jsxs("transformNode",{name:"axis-offset",position:d&&d.min&&d.max?new EngineCore.Vector3(-(d.max.x-d.min.x)/2,-(d.max.y-d.min.y)/2,-(d.max.z-d.min.z)/2):EngineCore.Vector3.Zero(),children:[h.map((b,C)=>b.map((_,A)=>{var S;const N=_;return jsxRuntime.jsx("transformNode",{name:`axis-x-${C}-${A}`,position:N==null?void 0:N.position,setEnabled:C===y,scaling:new EngineCore.Vector3(1/calcTransformNodeScale(d).x,1/calcTransformNodeScale(d).y,1/calcTransformNodeScale(d).z),children:jsxRuntime.jsx(GUIText$1,{text:`${N?N.text:""}`,fontSize:(S=i[C])!=null?S:n,color:t.toHexString()})},`axis-x-${C}-${A}`)})),R.map((b,C)=>b.map((_,A)=>{var S;const N=_;return jsxRuntime.jsx("transformNode",{name:`axis-x-${C}-${A}`,position:N==null?void 0:N.position,setEnabled:C===y,scaling:new EngineCore.Vector3(1/calcTransformNodeScale(d).x,1/calcTransformNodeScale(d).y,1/calcTransformNodeScale(d).z),children:jsxRuntime.jsx(GUIText$1,{text:`${N?N.text:""}`,fontSize:(S=i[C])!=null?S:n,color:t.toHexString()})},`axis-x-${C}-${A}`)})),g.map((b,C)=>b.map((_,A)=>{var S;const N=_;return jsxRuntime.jsx("transformNode",{name:`axis-x-${C}-${A}`,position:N==null?void 0:N.position,setEnabled:C===y,scaling:new EngineCore.Vector3(1/calcTransformNodeScale(d).x,1/calcTransformNodeScale(d).y,1/calcTransformNodeScale(d).z),children:jsxRuntime.jsx(GUIText$1,{text:`${N?N.text:""}`,fontSize:(S=i[C])!=null?S:n,color:t.toHexString()})},`axis-x-${C}-${A}`)}))]})]},`coord-${d.min.x}-${d.min.y}-${d.min.z}-${d.max.x}-${d.max.y}-${d.max.z}-${Math.abs(d.max.x-d.min.x)}-${Math.abs(d.max.y-d.min.y)}-${Math.abs(d.max.z-d.min.z)}`):jsxRuntime.jsx(jsxRuntime.Fragment,{})},Coordinate$1=Coordinate;function contourLine_ContourLineTypeFromJSON(e){switch(e){case 0:case"NORMAL":return 0;case 1:case"CICLE":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function contourLine_ContourLineTypeToJSON(e){switch(e){case 0:return"NORMAL";case 1:return"CICLE";case-1:default:return"UNRECOGNIZED"}}function createBaseContourLine(){return{name:"",lines:[]}}const ContourLine$2={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.lines)ContourLine_Line.encode(n,t.uint32(18).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseContourLine();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.lines.push(ContourLine_Line.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$9(e.name)?globalThis.String(e.name):"",lines:globalThis.Array.isArray(e==null?void 0:e.lines)?e.lines.map(t=>ContourLine_Line.fromJSON(t)):[]}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),(n=e.lines)!=null&&n.length&&(t.lines=e.lines.map(a=>ContourLine_Line.toJSON(a))),t},create(e){return ContourLine$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseContourLine();return t.name=(n=e.name)!=null?n:"",t.lines=((a=e.lines)==null?void 0:a.map(r=>ContourLine_Line.fromPartial(r)))||[],t}};function createBaseContourLine_LineSegment(){return{positions:[]}}const ContourLine_LineSegment={encode(e,t=minimal.Writer.create()){for(const n of e.positions)Position.encode(n,t.uint32(10).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseContourLine_LineSegment();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.positions.push(Position.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{positions:globalThis.Array.isArray(e==null?void 0:e.positions)?e.positions.map(t=>Position.fromJSON(t)):[]}},toJSON(e){var n;const t={};return(n=e.positions)!=null&&n.length&&(t.positions=e.positions.map(a=>Position.toJSON(a))),t},create(e){return ContourLine_LineSegment.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=createBaseContourLine_LineSegment();return t.positions=((n=e.positions)==null?void 0:n.map(a=>Position.fromPartial(a)))||[],t}};function createBaseContourLine_Line(){return{segments:[],type:0,position:void 0}}const ContourLine_Line={encode(e,t=minimal.Writer.create()){for(const n of e.segments)ContourLine_LineSegment.encode(n,t.uint32(10).fork()).ldelim();return e.type!==0&&t.uint32(16).int32(e.type),e.position!==void 0&&Position.encode(e.position,t.uint32(26).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseContourLine_Line();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.segments.push(ContourLine_LineSegment.decode(n,n.uint32()));continue;case 2:if(o!==16)break;r.type=n.int32();continue;case 3:if(o!==26)break;r.position=Position.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{segments:globalThis.Array.isArray(e==null?void 0:e.segments)?e.segments.map(t=>ContourLine_LineSegment.fromJSON(t)):[],type:isSet$9(e.type)?contourLine_ContourLineTypeFromJSON(e.type):0,position:isSet$9(e.position)?Position.fromJSON(e.position):void 0}},toJSON(e){var n;const t={};return(n=e.segments)!=null&&n.length&&(t.segments=e.segments.map(a=>ContourLine_LineSegment.toJSON(a))),e.type!==0&&(t.type=contourLine_ContourLineTypeToJSON(e.type)),e.position!==void 0&&(t.position=Position.toJSON(e.position)),t},create(e){return ContourLine_Line.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseContourLine_Line();return t.segments=((n=e.segments)==null?void 0:n.map(r=>ContourLine_LineSegment.fromPartial(r)))||[],t.type=(a=e.type)!=null?a:0,t.position=e.position!==void 0&&e.position!==null?Position.fromPartial(e.position):void 0,t}};function isSet$9(e){return e!=null}const Line=({points:e=[],showPoint:t=!0,color:n=EngineCore.Color3.White(),pointSize:a=2,alwaysOnTop:r=!1,offset:o=EngineCore.Vector3.Zero(),alpha:i,lineWidth:s})=>{const l=reactBabylonjs.useScene(),c=React.useRef(null),f=React.useContext(WorkspaceMetaContext);return React.useEffect(()=>{if(l){const u=[],d=calcTransformNodeScale(f);if(e.forEach(h=>{u.push(h.add(o).multiply(d))}),s){const h={path:u,radius:s,updatable:!0};if(c.current)h.instance=c.current,EngineCore.MeshBuilder.CreateTube("line",h);else{c.current=EngineCore.MeshBuilder.CreateTube("line",h,l);const m=new EngineCore.StandardMaterial("line-mat");return m.diffuseColor=n,m.specularColor=EngineCore.Color3.Black(),m.emissiveColor=n,i!==void 0&&(m.alpha=i,m.transparencyMode=2),m.depthFunction=r?EngineCore.Constants.ALWAYS:0,c.current.material=m,()=>{c.current&&(l.removeMesh(c.current),c.current=null)}}}else{const h={points:u,updateable:!0};if(c.current)h.instance=c.current,EngineCore.MeshBuilder.CreateLines("line",h);else{c.current=EngineCore.MeshBuilder.CreateLines("line",h,l);const m=new EngineCore.StandardMaterial("line-mat");return m.diffuseColor=n,m.specularColor=EngineCore.Color3.Black(),m.emissiveColor=n,i!==void 0&&(m.alpha=i,m.transparencyMode=2),m.depthFunction=r?EngineCore.Constants.ALWAYS:0,()=>{c.current&&(l.removeMesh(c.current),c.current=null)}}}}},[r,n,f,o,e,l,s,c,i]),jsxRuntime.jsx("transformNode",{name:"transform-line",children:t?jsxRuntime.jsx("transformNode",{name:"lines-point",children:e.map((u,d)=>jsxRuntime.jsx("sphere",{diameter:a,name:`lines-point-${d}`,position:u.add(o).multiply(calcTransformNodeScale(f)),scalingDeterminant:s&&(f==null?void 0:f.scalePlane)||1,children:jsxRuntime.jsx("standardMaterial",{name:`lines-point-${d}-mat`,diffuseColor:n,emissiveColor:n,specularColor:EngineCore.Color3.White(),depthFunction:r?EngineCore.Constants.ALWAYS:void 0})},`lines-point-${u.x}-${u.y}-${u.z}`))}):jsxRuntime.jsx(jsxRuntime.Fragment,{})})},Line$1=Line,ContourText=e=>{const{name:t,prev:n,next:a,textColor:r,fontSize:o}=e,i=reactBabylonjs.useScene(),s=React.useRef(null);return React.useEffect(()=>{const l=i==null?void 0:i.activeCamera,c=i==null?void 0:i.getEngine();if(i&&l&&c&&s.current){const f=s.current.getChildren()[0],u=EngineCore.Vector3.Normalize(a.subtract(n)),d=new EngineCore.Vector3(1,0,0),h=Math.acos(EngineCore.Vector3.Dot(u,d)),m=EngineCore.Vector3.Cross(u,d);f.rotation.z=m.y>0?h:Math.PI*2-h,f.rotation.x=Math.PI/2,f.renderingGroupId=3}},[a,n,i]),jsxRuntime.jsx("transformNode",{name:`${t}`,position:EngineCore.Vector3.Lerp(n,a,.5),ref:s,children:jsxRuntime.jsx(GUIText$1,{text:t,fontSize:o,color:r,billboardMode:EngineCore.Mesh.BILLBOARDMODE_NONE})})},ContourText$1=ContourText,ContourLine=e=>{const{url:t,color:n,alpha:a,visible:r=!0,fontSize:o=30,textColor:i="red",linewidth:s=10}=e,l=reactBabylonjs.useScene(),[c,f]=React.useState([]),[u,d]=React.useState([]),h=React.useContext(WorkspaceMetaContext);return React.useEffect(()=>{axios.get(t,{responseType:"arraybuffer"}).then(m=>{const R=ContourLine$2.decode(new Uint8Array(m.data));console.log(R);const v=[],g=[];for(let x=0;x<R.lines.length;x++){const y=R.lines[x];if(y.segments.length<2)continue;const E=[];for(let k=0;k<y.segments.length;k++){const b=[...convertPositionArrayToVector3(y.segments[k].positions)];v.push([...b]),E.push(b[0]),E.push(b[b.length-1])}y.type===1&&E.push(convertPositionToVector3(y.segments[0].positions[0])),g.push(E)}f(v),d(g),console.log(g),console.log(v)})},[l,t]),jsxRuntime.jsxs("transformNode",{name:"contourline",setEnabled:r,children:[c.map((m,R)=>m.length<2||!r?null:jsxRuntime.jsx(Line$1,{points:m,showPoint:!1,color:n,alpha:a,lineWidth:s,alwaysOnTop:!0},R)),u.map(m=>m.map((R,v)=>v%2===0||v===m.length-1?null:jsxRuntime.jsx(ContourText$1,{name:R.y.toFixed(0),prev:calcTransformNodeScale(h).multiply(R),next:calcTransformNodeScale(h).multiply(m[v+1]),fontSize:o,textColor:i},v)))]})},ContourLine$1=ContourLine;function densitySlice_DirectionFromJSON(e){switch(e){case 0:case"X":return 0;case 1:case"Y":return 1;case 2:case"Z":return 2;case 3:case"FREE":return 3;case-1:case"UNRECOGNIZED":default:return-1}}function densitySlice_DirectionToJSON(e){switch(e){case 0:return"X";case 1:return"Y";case 2:return"Z";case 3:return"FREE";case-1:default:return"UNRECOGNIZED"}}function createBaseDensitySlice(){return{layer:0,direction:0,colorId:0,points:[],indices:[],value:[],vMin:0,vMax:0,center:void 0}}const DensitySlice$2={encode(e,t=minimal.Writer.create()){e.layer!==0&&t.uint32(8).uint32(e.layer),e.direction!==0&&t.uint32(16).int32(e.direction),e.colorId!==0&&t.uint32(24).uint32(e.colorId),t.uint32(170).fork();for(const n of e.points)t.float(n);t.ldelim(),t.uint32(178).fork();for(const n of e.indices)t.uint32(n);t.ldelim(),t.uint32(186).fork();for(const n of e.value)t.float(n);return t.ldelim(),e.vMin!==0&&t.uint32(205).float(e.vMin),e.vMax!==0&&t.uint32(213).float(e.vMax),e.center!==void 0&&Vertex.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseDensitySlice();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==8)break;r.layer=n.uint32();continue;case 2:if(o!==16)break;r.direction=n.int32();continue;case 3:if(o!==24)break;r.colorId=n.uint32();continue;case 21:if(o===173){r.points.push(n.float());continue}if(o===170){const i=n.uint32()+n.pos;for(;n.pos<i;)r.points.push(n.float());continue}break;case 22:if(o===176){r.indices.push(n.uint32());continue}if(o===178){const i=n.uint32()+n.pos;for(;n.pos<i;)r.indices.push(n.uint32());continue}break;case 23:if(o===189){r.value.push(n.float());continue}if(o===186){const i=n.uint32()+n.pos;for(;n.pos<i;)r.value.push(n.float());continue}break;case 25:if(o!==205)break;r.vMin=n.float();continue;case 26:if(o!==213)break;r.vMax=n.float();continue;case 31:if(o!==250)break;r.center=Vertex.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{layer:isSet$8(e.layer)?globalThis.Number(e.layer):0,direction:isSet$8(e.direction)?densitySlice_DirectionFromJSON(e.direction):0,colorId:isSet$8(e.colorId)?globalThis.Number(e.colorId):0,points:globalThis.Array.isArray(e==null?void 0:e.points)?e.points.map(t=>globalThis.Number(t)):[],indices:globalThis.Array.isArray(e==null?void 0:e.indices)?e.indices.map(t=>globalThis.Number(t)):[],value:globalThis.Array.isArray(e==null?void 0:e.value)?e.value.map(t=>globalThis.Number(t)):[],vMin:isSet$8(e.vMin)?globalThis.Number(e.vMin):0,vMax:isSet$8(e.vMax)?globalThis.Number(e.vMax):0,center:isSet$8(e.center)?Vertex.fromJSON(e.center):void 0}},toJSON(e){var n,a,r;const t={};return e.layer!==0&&(t.layer=Math.round(e.layer)),e.direction!==0&&(t.direction=densitySlice_DirectionToJSON(e.direction)),e.colorId!==0&&(t.colorId=Math.round(e.colorId)),(n=e.points)!=null&&n.length&&(t.points=e.points),(a=e.indices)!=null&&a.length&&(t.indices=e.indices.map(o=>Math.round(o))),(r=e.value)!=null&&r.length&&(t.value=e.value),e.vMin!==0&&(t.vMin=e.vMin),e.vMax!==0&&(t.vMax=e.vMax),e.center!==void 0&&(t.center=Vertex.toJSON(e.center)),t},create(e){return DensitySlice$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l,c;const t=createBaseDensitySlice();return t.layer=(n=e.layer)!=null?n:0,t.direction=(a=e.direction)!=null?a:0,t.colorId=(r=e.colorId)!=null?r:0,t.points=((o=e.points)==null?void 0:o.map(f=>f))||[],t.indices=((i=e.indices)==null?void 0:i.map(f=>f))||[],t.value=((s=e.value)==null?void 0:s.map(f=>f))||[],t.vMin=(l=e.vMin)!=null?l:0,t.vMax=(c=e.vMax)!=null?c:0,t.center=e.center!==void 0&&e.center!==null?Vertex.fromPartial(e.center):void 0,t}};function isSet$8(e){return e!=null}const DensitySlice=({name:e,url:t,visible:n=!0,colorCodec:a,alpha:r=1,position:o=EngineCore.Vector3.Zero(),actions:i})=>{const s=React.useRef(null),[l,c]=React.useState(""),[f,u]=React.useState(""),d=React.useContext(WorkspaceMetaContext),h=useCachedBinary({url:t,cacheType:CacheType.URL_PREFIX_MATCH}),[m,R]=React.useState(EngineCore.Vector3.Zero());return React.useEffect(()=>{if(h){EngineCore.Tags.EnableFor(s.current),EngineCore.Tags.AddTagsTo(s.current,"loading");const v=DensitySlice$2.decode(new Uint8Array(h)),{layer:g,direction:x,points:y,indices:E,value:k,center:b}=v,C=new EngineCore.VertexData;C.positions=y,C.indices=E,C.colors=k;const _=[];EngineCore.VertexData.ComputeNormals(y,E,_),C.normals=_,b&&R(new EngineCore.Vector3(b.x,b.y,b.z));const A=s.current;return A&&(C.applyToMesh(A),c(g.toString()),u(x.toString())),EngineCore.Tags.RemoveTagsFrom(A,"loading"),()=>{c(""),u(""),A&&new EngineCore.VertexData().applyToMesh(A)}}},[h]),React.useEffect(()=>{s.current&&(s.current.metadata={pickable:i?{name:e,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null})},[i,e]),React.useEffect(()=>{console.log("[Geo3DViewer] DensitySlice Loading: ",t)},[t]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`densityslice-${e}-${f}-${l}-transform`,position:m.add(o).multiplyByFloats(d&&d.scalePlane?d.scalePlane:1,d&&d.scaleDepth?d.scaleDepth:1,d&&d.scalePlane?d.scalePlane:1),scaling:new EngineCore.Vector3(d?d.scalePlane:1,d?d.scaleDepth:1,d?d.scalePlane:1),children:jsxRuntime.jsx("mesh",{name:`densityslice-${e}-${f}-${l}-mesh`,ref:s,setEnabled:n,children:jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`densityslice-${e}-${f}-${l}-mat`,backFaceCulling:!1,needDepthPrePass:!0,alpha:r,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:a})})})})},DensitySlice$1=DensitySlice,FPS=()=>{const e=reactBabylonjs.useScene(),t=React.useRef(void 0);return React.useEffect(()=>{const n=setInterval(()=>{if(e&&t.current){const a=e.getEngine().getFps();t.current.getControlByName("fps").text=a.toFixed(0)+"FPS"}},1e3);return()=>{clearInterval(n)}},[e]),React.useEffect(()=>{var n,a;if(e&&!t.current){const r=EngineGui.AdvancedDynamicTexture.CreateFullscreenUI("UI",!0,e);t.current=r;const o=new EngineGui.TextBlock("fps");o.text="0FPS",o.color="white",o.fontSize=15,o.width=100,o.height=50;const i=window.devicePixelRatio||1,s=(n=e.getEngine().getRenderingCanvas())==null?void 0:n.clientHeight,l=(a=e.getEngine().getRenderingCanvas())==null?void 0:a.clientWidth;o.left=l?-(l*i/2-50):0,o.top=s?-(s*i/2-25):0,r.addControl(o)}return()=>{e&&t.current}},[e]),null},FPS$1=FPS,FormationManager=({url:e,visible:t=!0,filter:n,explodedView:a=0,offset:r=new EngineCore.Vector3(0,0,0),showLayerLabel:o,labelStyle:i,actions:s,materials:l})=>{const[c,f]=React.useState(),u=React.useContext(WorkspaceMetaContext),[d,h]=React.useState(!0),[m,R]=React.useState(""),v=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH});return React.useEffect(()=>{console.log("[Geo3DViewer] FormationManager Loading: ",e)},[e]),React.useEffect(()=>{if(v){const g=FormationGroup.decode(new Uint8Array(v)),x=g.formations;if(g.mode==FormationGroup_FormationMode.FACE){h(!0),R(g.name);const y=[];x.forEach((E,k)=>{const b={name:E.name,topUrl:E.url,bottomUrl:x[k+1]?x[k+1].url:void 0};y.push(b)}),f(y)}else{h(!1),R(g.name);const y=[];x.forEach(E=>{const k={name:E.name,topUrl:E.url};y.push(k)}),f(y)}return console.log(x),()=>{R(""),f([])}}},[v]),jsxRuntime.jsx("abstractMesh",{name:`formationmanager-${m}`,children:c?c.map((g,x)=>d?jsxRuntime.jsx("transformNode",{name:`${m}-${g.name}-EV`,position:r.add(new EngineCore.Vector3(0,x*(-1*a*(u&&u.scaleDepth?u.scaleDepth:0)),0)),children:jsxRuntime.jsx(FormationFace$1,{showLayerLabel:o,labelStyle:i,urlTopLayer:g.topUrl,urlBottomLayer:g.bottomUrl,visible:t&&(n?n.includes(g.name):!0),showBottomLayer:c[x+1]?n?n.includes(c[x+1].name):!0:!1,actions:s,material:l==null?void 0:l[g.name]},`${m}-${g.name}`)},`${m}-${g.name}`):jsxRuntime.jsx("transformNode",{name:`${m}-${g.name}-EV`,position:r.add(new EngineCore.Vector3(0,x*(-1*a*(u&&u.scaleDepth?u.scaleDepth:0)),0)),children:jsxRuntime.jsx(FormationVolume$1,{url:g.topUrl,showLayerLabel:o,labelStyle:i,visible:t&&(n?n.includes(g.name):!0),showBottomLayer:c[x+1]?n?n.includes(c[x+1].name):!0:!1,actions:s,material:l==null?void 0:l[g.name]},`${m}-${g.name}`)},`${m}-${g.name}`)):null})},FormationManager$1=FormationManager;function createBaseFormationSlices(){return{name:"",slices:[],center:void 0}}const FormationSlices={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.slices)FormationSlices_Slice.encode(n,t.uint32(18).fork()).ldelim();return e.center!==void 0&&Vertex.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseFormationSlices();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.slices.push(FormationSlices_Slice.decode(n,n.uint32()));continue;case 31:if(o!==250)break;r.center=Vertex.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$7(e.name)?globalThis.String(e.name):"",slices:globalThis.Array.isArray(e==null?void 0:e.slices)?e.slices.map(t=>FormationSlices_Slice.fromJSON(t)):[],center:isSet$7(e.center)?Vertex.fromJSON(e.center):void 0}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),(n=e.slices)!=null&&n.length&&(t.slices=e.slices.map(a=>FormationSlices_Slice.toJSON(a))),e.center!==void 0&&(t.center=Vertex.toJSON(e.center)),t},create(e){return FormationSlices.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseFormationSlices();return t.name=(n=e.name)!=null?n:"",t.slices=((a=e.slices)==null?void 0:a.map(r=>FormationSlices_Slice.fromPartial(r)))||[],t.center=e.center!==void 0&&e.center!==null?Vertex.fromPartial(e.center):void 0,t}};function createBaseFormationSlices_Slice(){return{name:"",colorId:0,vertices:[],indices:[],edges:[]}}const FormationSlices_Slice={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.colorId!==0&&t.uint32(16).uint32(e.colorId),t.uint32(26).fork();for(const n of e.vertices)t.float(n);t.ldelim(),t.uint32(34).fork();for(const n of e.indices)t.uint32(n);t.ldelim();for(const n of e.edges)Vertex.encode(n,t.uint32(42).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseFormationSlices_Slice();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==16)break;r.colorId=n.uint32();continue;case 3:if(o===29){r.vertices.push(n.float());continue}if(o===26){const i=n.uint32()+n.pos;for(;n.pos<i;)r.vertices.push(n.float());continue}break;case 4:if(o===32){r.indices.push(n.uint32());continue}if(o===34){const i=n.uint32()+n.pos;for(;n.pos<i;)r.indices.push(n.uint32());continue}break;case 5:if(o!==42)break;r.edges.push(Vertex.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$7(e.name)?globalThis.String(e.name):"",colorId:isSet$7(e.colorId)?globalThis.Number(e.colorId):0,vertices:globalThis.Array.isArray(e==null?void 0:e.vertices)?e.vertices.map(t=>globalThis.Number(t)):[],indices:globalThis.Array.isArray(e==null?void 0:e.indices)?e.indices.map(t=>globalThis.Number(t)):[],edges:globalThis.Array.isArray(e==null?void 0:e.edges)?e.edges.map(t=>Vertex.fromJSON(t)):[]}},toJSON(e){var n,a,r;const t={};return e.name!==""&&(t.name=e.name),e.colorId!==0&&(t.colorId=Math.round(e.colorId)),(n=e.vertices)!=null&&n.length&&(t.vertices=e.vertices),(a=e.indices)!=null&&a.length&&(t.indices=e.indices.map(o=>Math.round(o))),(r=e.edges)!=null&&r.length&&(t.edges=e.edges.map(o=>Vertex.toJSON(o))),t},create(e){return FormationSlices_Slice.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=createBaseFormationSlices_Slice();return t.name=(n=e.name)!=null?n:"",t.colorId=(a=e.colorId)!=null?a:0,t.vertices=((r=e.vertices)==null?void 0:r.map(s=>s))||[],t.indices=((o=e.indices)==null?void 0:o.map(s=>s))||[],t.edges=((i=e.edges)==null?void 0:i.map(s=>Vertex.fromPartial(s)))||[],t}};function isSet$7(e){return e!=null}const FormationComponent=(e,t)=>{var O,F,w,L;const n=reactBabylonjs.useScene(),a=React.useRef(null),r=React.useRef(null),o=React.useContext(WorkspaceMetaContext),i=React.useContext(ColorProviderContext),[s,l]=React.useState(EngineCore.Color3.White()),{id:c,visible:f=!0,vertices:u,indices:d,colorId:h,position:m,normals:R,material:v={type:MaterialType.COLOR_ID},children:g,alpha:x=1,style:y,name:E="formation",highStyle:k,lowStyle:b,edges:C=[]}=e,_=useCachedTexture({url:v==null?void 0:v.texture,cacheType:CacheType.URL_PREFIX_MATCH}),A=useCachedTexture({url:v==null?void 0:v.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),[N,S]=React.useState();React.useImperativeHandle(t,()=>r.current,[]),React.useEffect(()=>{if(a&&a.current&&n){const B=new EngineCore.VertexData;B.positions=u,B.indices=d,B.normals=R;const D=a.current;B.applyToMesh(D),D.getScene().onAfterRenderObservable.addOnce(()=>{if(!D.isDisposed()){const ae=D.getBoundingInfo();S(ae.boundingBox)}})}},[d,u,n,c,R]),React.useEffect(()=>{var B;l(v.type===MaterialType.ONE_COLOR?(B=v==null?void 0:v.color)!=null?B:EngineCore.Color3.Random():h&&i.colorIDs[h]?new EngineCore.Color3(i.colorIDs[h].r,i.colorIDs[h].g,i.colorIDs[h].b):EngineCore.Color3.Random())},[i.colorIDs,h,v==null?void 0:v.color,v.type]);const I=(B,D,W)=>{const ae=D.subtract(B),ee=1+1e3/EngineCore.Vector3.Distance(B,D)*(W-1),H=ae.scale(ee);return B.add(H)};return jsxRuntime.jsxs("transformNode",{name:`node-${E}-${c}`,setEnabled:f,children:[jsxRuntime.jsxs("transformNode",{name:`${E}`,position:m?m.multiply(calcTransformNodeScale(o)):new EngineCore.Vector3(0,0,0),scaling:calcTransformNodeScale(o),ref:r,children:[jsxRuntime.jsx("mesh",{name:`${E}-mesh`,ref:a,children:v.type===MaterialType.TEXTURE?_?jsxRuntime.jsx(RepeatedTextureMaterial,{name:`formationslice-${E}-mat`,backFaceCulling:!1,needDepthPrePass:v.needDepthPrePass===void 0?!1:v.needDepthPrePass,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:x,sideTexture:A,texture:_,tilingFactor:v.tilingFactor,sideTilingFactor:(O=v==null?void 0:v.sideTilingFactor)!=null?O:v==null?void 0:v.tilingFactor,mode:v.textureMode===void 0?RepeatedTextureMode.PLANE:v.textureMode,boundingBox:N,lines:v.lines,text:v.text,scaleDepth:o?o.scaleDepth:1,scalePlane:o?o.scalePlane:1,disableDepthWrite:v.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):v.type===MaterialType.COLOR_CODEC?v.colorCodec?jsxRuntime.jsx(RemapColorByRedChannelMaterial,{name:`formation-${E}-mat`,backFaceCulling:!1,needDepthPrePass:v.needDepthPrePass===void 0?!1:v.needDepthPrePass,alpha:x,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:v.colorCodec,boundingBox:N,lines:v.lines,text:v.text,scaleDepth:o?o.scaleDepth:1,scalePlane:o?o.scalePlane:1,disableDepthWrite:v.disableDepthWrite}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):v.type===MaterialType.COLOR_ID?jsxRuntime.jsx("standardMaterial",{name:`formation-${E}-mat`,backFaceCulling:!1,needDepthPrePass:v.needDepthPrePass===void 0?!1:v.needDepthPrePass,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),diffuseColor:s,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:x,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,disableDepthWrite:v.disableDepthWrite}):jsxRuntime.jsx("standardMaterial",{name:`formation-${E}-mat`,backFaceCulling:!1,needDepthPrePass:v.needDepthPrePass===void 0?!1:v.needDepthPrePass,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),diffuseColor:s,alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:x,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,disableDepthWrite:v.disableDepthWrite})}),y.position&&jsxRuntime.jsx("transformNode",{name:`${E}-title`,position:I(convertVertexToVector3(y.basePosition==="left"?C[4]:C[5]),y.position,(F=y.offset)!=null?F:1),scaling:calcGUIScale(o),children:y.title&&jsxRuntime.jsx(GUIText$1,{text:y.title,fontSize:y.fontSize?y.fontSize:40,color:y.color?y.color:"black"})}),b&&b.position&&jsxRuntime.jsx("transformNode",{name:`${E}-up-title`,position:I(convertVertexToVector3(b.basePosition==="left"?C[4]:C[5]),b.position,(w=b.offset)!=null?w:1),scaling:calcGUIScale(o),children:b.title&&jsxRuntime.jsx(GUIText$1,{text:b.title,fontSize:b.fontSize?b.fontSize:40,color:b.color?b.color:"black"})}),k&&k.position&&jsxRuntime.jsx("transformNode",{name:`${E}-down-title`,position:I(convertVertexToVector3(k.basePosition==="left"?C[4]:C[5]),k.position,(L=k.offset)!=null?L:1),scaling:calcGUIScale(o),children:k.title&&jsxRuntime.jsx(GUIText$1,{text:k.title,fontSize:k.fontSize?k.fontSize:40,color:k.color?k.color:"black"})})]}),g]})},FormationComponent$1=React.forwardRef(FormationComponent),FormationSlice=e=>{const[t,n]=React.useState([]),[a,r]=React.useState(""),{url:o,visible:i=!0,materials:s,actions:l,style:c,highStyle:f,lowStyle:u,basePosition:d="left"}=e,h=React.useRef(null),m=React.useContext(WorkspaceMetaContext),R=useCachedBinary({url:o,cacheType:CacheType.URL_PREFIX_MATCH}),[v,g]=React.useState(EngineCore.Vector3.Zero());return React.useEffect(()=>{console.log("[Geo3DViewer] FormationSlice Loading: ",o)},[o]),React.useEffect(()=>{if(R){const x=FormationSlices.decode(new Uint8Array(R));x.center&&g(new EngineCore.Vector3(x.center.x,x.center.y,x.center.z));const y=x.slices.map(E=>{const k=[];return EngineCore.VertexData.ComputeNormals(E.vertices,E.indices,k),{name:E.name,colorId:E.colorId,vertices:E.vertices,indices:E.indices,edges:E.edges,normals:k}});return r(x.name),n(y),()=>{r(""),n([])}}},[R]),React.useEffect(()=>{var y;const x=(y=h.current)==null?void 0:y.getChildMeshes()[0];x&&(x.metadata={pickable:l?{name:a,onLeftClick:l.onLeftClick,onRightClick:l.onRightClick,onMiddleClick:l.onMiddleClick,onHover:l.onHover,extra:l.extra}:null})},[l,a]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`foramtionslice-${a}-holder`,setEnabled:i,position:v.multiply(calcTransformNodeScale(m)),children:t.map((x,y)=>{const E=x.edges.length>0?convertVertexToVector3(d==="left"?x.edges[0]:x.edges[2]):new EngineCore.Vector3(0,0,0),k=x.edges.length>0?convertVertexToVector3(d==="left"?x.edges[1]:x.edges[3]):new EngineCore.Vector3(0,0,0),b=EngineCore.Vector3.Lerp(E,k,.5);return jsxRuntime.jsx(FormationComponent$1,{id:y,vertices:x.vertices,indices:x.indices,colorId:x.colorId,normals:x.normals,name:x.name,edges:x.edges,style:c?{position:b,title:x.name,basePosition:d,...c}:{},lowStyle:u?{position:k,title:(v.y+k.y).toFixed(0).toString(),basePosition:d,...u}:{},highStyle:f&&y===t.length-1?{position:E,title:(v.y+E.y).toFixed(0).toString(),basePosition:d,...f}:{},material:s?{...s[x.name],backFaceCulling:!1}:void 0,ref:h},y)})})})},FormationSlice$1=FormationSlice,TransformGUIText=e=>{const{name:t="node",text:n,fontSize:a,color:r,position:o=EngineCore.Vector3.Zero(),scale:i=EngineCore.Vector3.One(),blink:s=!1}=e,[l,c]=React.useState(!0);return React.useEffect(()=>{const f=setInterval(()=>{s&&c(u=>!u)},1e3);return()=>{clearInterval(f)}},[s]),jsxRuntime.jsx("transformNode",{name:`${t}-text`,position:o,scaling:i,setEnabled:l,children:jsxRuntime.jsx(GUIText$1,{name:t,text:n,fontSize:a,color:r})})},TransformGUIText$1=TransformGUIText;var AxesViewerPosition=(e=>(e[e.NONE=0]="NONE",e[e.BOTTOM_LEFT=1]="BOTTOM_LEFT",e[e.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",e[e.TOP_LEFT=3]="TOP_LEFT",e[e.TOP_RIGHT=4]="TOP_RIGHT",e))(AxesViewerPosition||{});const Geo3DCamera=({target:e,radius:t,alpha:n,beta:a,axesViewerOffset:r=EngineCore.Vector3.Zero(),panningSensibility:o=2,wheelDeltaPercentage:i=0,axesViewer:s=0,farPlane:l=1e4,skipPickingWhenCameraMoves:c=!1})=>{const f=reactBabylonjs.useScene(),u=React.useContext(WorkspaceMetaContext),[d,h]=React.useState(null),[m,R]=React.useState(null),[v,g]=React.useState(n),[x,y]=React.useState(a),[,E]=React.useState(null),k=React.useCallback(N=>{R(N)},[]),{setViewCamera:b}=React.useContext(ViewerCameraPropsContext),C=React.useCallback(()=>{if(m&&d){const N=new EngineCore.Vector3;N.addInPlace(m.position),N.addInPlace(m.getDirection(new EngineCore.Vector3(0,0,25))),s==4?(N.addInPlace(m.getDirection(new EngineCore.Vector3(0,7+r.y,0))),N.addInPlace(m.getDirection(new EngineCore.Vector3(15+r.x,0,0)))):s==3?(N.addInPlace(m.getDirection(new EngineCore.Vector3(0,7+r.y,0))),N.addInPlace(m.getDirection(new EngineCore.Vector3(-15+r.x,0,0)))):s==2?(N.addInPlace(m.getDirection(new EngineCore.Vector3(0,-7+r.y,0))),N.addInPlace(m.getDirection(new EngineCore.Vector3(15+r.x,0,0)))):s==1&&(N.addInPlace(m.getDirection(new EngineCore.Vector3(0,-7+r.y,0))),N.addInPlace(m.getDirection(new EngineCore.Vector3(-15+r.x,0,0)))),d.xAxis.position=N.clone(),d.yAxis.position=N.clone(),d.zAxis.position=N.clone()}},[m,d,s,r.y,r.x]);React.useEffect(()=>{if(f&&s!=0){const N=new EngineCore.AxesViewer(f,2,null);return h(N),()=>{N==null||N.dispose(),h(null)}}},[f,s]),React.useEffect(()=>{C()},[C]);const _=React.useCallback(N=>{if(u&&u.min&&u.max)return EngineCore.Vector3.Clamp(N,u==null?void 0:u.min,u==null?void 0:u.max)},[u]),A=React.useCallback(N=>{f&&(f.skipPointerMovePicking=N)},[f]);return React.useEffect(()=>{if(!f||!m)return;const N=m.onViewMatrixChangedObservable.add(()=>{c&&(A(!0),E(S=>(S&&clearTimeout(S),setTimeout(()=>{A(!1),E(null)},250)))),g(m.alpha),y(m.beta),C()});return()=>{m.onViewMatrixChangedObservable.remove(N),E(S=>(S&&clearTimeout(S),null)),A(!1)}},[f,s,m,u,d,C,_,A,c]),React.useEffect(()=>{b(f&&m?m:void 0)},[f,m,b]),React.useEffect(()=>{},[_,u,e]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:e&&jsxRuntime.jsx("arcRotateCamera",{name:"rootCamera",target:e,radius:t,alpha:v,beta:x,maxZ:l,panningSensibility:o,wheelDeltaPercentage:i,ref:k,setActiveOnSceneIfNoneActive:!0})})},Geo3DCamera$1=Geo3DCamera,Geo3DUniversalCamera=(e,t)=>{const{position:n=EngineCore.Vector3.Zero(),axesViewer:a=AxesViewerPosition.NONE,axesViewerOffset:r=EngineCore.Vector3.Zero(),skipPickingWhenCameraMoves:o=!1,wheelDeltaPercentage:i=3,rotationSensibility:s=1,panningSensibility:l=10}=e,c=reactBabylonjs.useScene(),f=React.useContext(WorkspaceMetaContext),[u,d]=React.useState(null),[h,m]=React.useState(null),{setViewCamera:R,cameraRefObject:v}=React.useContext(ViewerCameraPropsContext),[,g]=React.useState(null),x=React.useRef(null),[y,E]=React.useState(null),k=React.useRef(null),b=React.useCallback(S=>{c&&(c.skipPointerMovePicking=S)},[c]);React.useEffect(()=>(k.current=new EngineCore.ArcRotateCamera("dummy-camera",0,0,.1,EngineCore.Vector3.Zero(),c||void 0,!1),()=>{var S;(S=k.current)==null||S.dispose()}),[c]),React.useEffect(()=>{if(c){const S=h,I=c.onPointerObservable.add(O=>{if(O.type===EngineCore.PointerEventTypes.POINTERDOWN&&(x.current=new EngineCore.Vector2(O.event.clientX,O.event.clientY)),O.type===EngineCore.PointerEventTypes.POINTERUP&&(x.current=null),O.type===EngineCore.PointerEventTypes.POINTERMOVE&&x.current){const F=O.event.clientX-x.current.x,w=O.event.clientY-x.current.y;if(O.event.buttons===1){let L=null;(S.lockedTarget||y)&&(S.lockedTarget&&(L=S.lockedTarget.position),y&&(L=y)),L&&k.current?(k.current.target=L,k.current.position=S.position.clone(),k.current.wheelDeltaPercentage=i,k.current.panningSensibility=l,k.current.alpha+=F/100*s,k.current.beta+=w/100*s,k.current.update(),S.position=k.current.position.clone(),S.rotation=k.current.rotation.clone()):(S.rotation.y-=F/100*s,S.rotation.x-=w/100*s)}O.event.buttons===2&&(S.position.x-=F/100*l,S.position.y+=w/100*l),x.current=new EngineCore.Vector2(O.event.clientX,O.event.clientY)}});return()=>{c.onPointerObservable.remove(I)}}},[y,l,h,s,c,i]);const C=React.useCallback(S=>{S&&(S.inputs.addMouseWheel(),S.inputs.removeMouse(),R(S),m(S))},[R]);React.useEffect(()=>{if(h){const S=h.inputs.attached.mousewheel;S.wheelPrecisionX=i,S.wheelPrecisionY=i,S.wheelPrecisionZ=i}},[h,i]);const _=React.useCallback(()=>{if(h&&u){const S=new EngineCore.Vector3;S.addInPlace(h.position),S.addInPlace(h.getDirection(new EngineCore.Vector3(0,0,25))),a==AxesViewerPosition.TOP_RIGHT?(S.addInPlace(h.getDirection(new EngineCore.Vector3(0,7+r.y,0))),S.addInPlace(h.getDirection(new EngineCore.Vector3(15+r.x,0,0)))):a==AxesViewerPosition.TOP_LEFT?(S.addInPlace(h.getDirection(new EngineCore.Vector3(0,7+r.y,0))),S.addInPlace(h.getDirection(new EngineCore.Vector3(-15+r.x,0,0)))):a==AxesViewerPosition.BOTTOM_RIGHT?(S.addInPlace(h.getDirection(new EngineCore.Vector3(0,-7+r.y,0))),S.addInPlace(h.getDirection(new EngineCore.Vector3(15+r.x,0,0)))):a==AxesViewerPosition.BOTTOM_LEFT&&(S.addInPlace(h.getDirection(new EngineCore.Vector3(0,-7+r.y,0))),S.addInPlace(h.getDirection(new EngineCore.Vector3(-15+r.x,0,0)))),u.xAxis.position=S.clone(),u.yAxis.position=S.clone(),u.zAxis.position=S.clone()}},[h,u,a,r.y,r.x]);React.useEffect(()=>{if(c&&a!=AxesViewerPosition.NONE){const S=new EngineCore.AxesViewer(c,2,null);return d(S),()=>{S==null||S.dispose(),d(null)}}},[c,a]),React.useEffect(()=>{_()},[_]),React.useEffect(()=>{R(c&&h?h:void 0)},[c,h,R]),React.useEffect(()=>{if(!c||!h)return;const S=h.onViewMatrixChangedObservable.add(()=>{o&&(b(!0),g(I=>(I&&clearTimeout(I),setTimeout(()=>{b(!1),g(null)},250)))),_()});return()=>{h.onViewMatrixChangedObservable.remove(S),g(I=>(I&&clearTimeout(I),null)),b(!1)}},[c,a,h,f,u,_,o,b]);const[A,N]=React.useState();return React.useEffect(()=>{if(h){const S={lookAt:I=>{h&&h.setTarget(I)},updatePosition:I=>{h&&(h.position=I)},lockTarget:I=>{h&&(E(null),h.lockedTarget=I)},lockTo:I=>{h&&(h.lockedTarget=null,E(I))}};N(S),v&&v.current&&(v.current.rawCamera=h,v.current.cameraTools=S)}},[v,h]),React.useImperativeHandle(t,()=>({rawCamera:h,cameraTools:A}),[A,h]),jsxRuntime.jsx("universalCamera",{name:"universal-main-camera",position:n,ref:C,maxZ:0})},Geo3DUniversalCamera$1=React.forwardRef(Geo3DUniversalCamera);class FreeCameraPointersInput extends EngineCore.BaseCameraPointersInput{constructor(){super(...arguments);le(this,"camera");le(this,"buttons",[0,1,2,4]);le(this,"panningSensibility",10);le(this,"angularSensibility",1e4);le(this,"_isPanClick",!1);le(this,"_isPinching",!1)}getClassName(){return"FreeCameraPointersInput"}onButtonDown(n){(n.buttons===1||n.buttons===4)&&(this._isPinching=!0),n.buttons===2&&(this._isPanClick=!0)}onButtonUp(n){n&&(this._isPanClick=!1,this._isPinching=!1)}onTouch(n,a,r){if(this.panningSensibility!==0&&this._isPanClick){const o=-a/this.panningSensibility,i=r/this.panningSensibility;this.camera._localDirection.copyFromFloats(o,i,0),this.camera.getViewMatrix().invertToRef(this.camera._cameraTransformMatrix),EngineCore.Vector3.TransformNormalToRef(this.camera._localDirection,this.camera._cameraTransformMatrix,this.camera._transformedDirection),this.camera.cameraDirection.addInPlace(this.camera._transformedDirection)}if(this.angularSensibility!==0&&this._isPinching){const o=EngineCore.Quaternion.FromEulerAngles(this.camera.rotation.x,this.camera.rotation.y,this.camera.rotation.z),i=EngineCore.Quaternion.RotationAxis(EngineCore.Axis.Y,EngineCore.Tools.ToDegrees(a/this.angularSensibility)),s=EngineCore.Quaternion.RotationAxis(EngineCore.Axis.X,EngineCore.Tools.ToDegrees(r/this.angularSensibility)),l=o.multiply(i).multiply(s);this.camera.rotation=l.toEulerAngles()}}onLostFocus(){this._isPanClick=!1,this._isPinching=!1}}const Geo3DFreeCamera=e=>{const{position:t,target:n=new EngineCore.Vector3(0,0,0),panningSensibility:a=5,angularSensibility:r=2e3,skipPickingWhenCameraMoves:o=!1}=e,i=reactBabylonjs.useScene(),s=React.useRef(null),l=React.useRef(null),c=React.useCallback(f=>{i&&(i.skipPointerMovePicking=f)},[i]);return React.useEffect(()=>{if(s.current){s.current.inputs.removeByType("FreeCameraMouseInput");const f=new FreeCameraPointersInput,u=new EngineCore.FreeCameraMouseWheelInput;s.current.inputs.add(f),s.current.inputs.add(u)}},[]),React.useEffect(()=>{s.current&&n&&s.current.setTarget(n)},[n]),React.useEffect(()=>{if(!i||!s.current)return;const f=s.current.onViewMatrixChangedObservable.add(()=>{o&&(c(!0),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{c(!1),l.current=null},250))});return()=>{var u;(u=s.current)==null||u.onViewMatrixChangedObservable.remove(f),l.current&&(clearTimeout(l.current),l.current=null),c(!1)}},[i,c,o]),React.useEffect(()=>{if(s.current){if(s.current.inputs.attached.pointers){const f=s.current.inputs.attached.pointers;f.panningSensibility=Math.abs(a),f.angularSensibility=Math.abs(r)}if(s.current.inputs.attached.pointersPanning){const f=s.current.inputs.attached.pointersPanning;f.panningSensibility=Math.abs(a)}if(s.current.inputs.attached.around){const f=s.current.inputs.attached.around;f.angularSensibility=Math.abs(r)}}},[r,a]),jsxRuntime.jsx("freeCamera",{name:"rootCamera",position:t,ref:s})},Geo3DFreeCamera$1=Geo3DFreeCamera;class DepthTextureDebuggerNode extends EngineCore.TransformNode{constructor(n,a,r){super(n,a);le(this,"_showDepthTexture",!1);le(this,"_postProcess");this._postProcess=r,this.showDepthTexture=!1,this.inspectableCustomProperties=[{label:"Show Depth Texture",propertyName:"showDepthTexture",type:EngineCore.InspectableType.Checkbox}]}set showDepthTexture(n){var a,r;this._showDepthTexture=n,this._postProcess&&(this._showDepthTexture?(a=this.getScene().activeCamera)==null||a.attachPostProcess(this._postProcess):(r=this.getScene().activeCamera)==null||r.detachPostProcess(this._postProcess))}get showDepthTexture(){return this._showDepthTexture}}const DepthTextureDebugger=()=>{const e=reactBabylonjs.useEngine(),t=reactBabylonjs.useScene();return React.useEffect(()=>{if(t&&e){EngineCore.Effect.ShadersStore.depthbufferPixelShader=`#ifdef GL_ES
|
|
1194
1194
|
precision highp float;
|
|
1195
1195
|
#endif
|
|
1196
1196
|
|
|
@@ -1206,7 +1206,7 @@ precision highp float;
|
|
|
1206
1206
|
#endif
|
|
1207
1207
|
|
|
1208
1208
|
void main(void)
|
|
1209
|
-
{}`;const n=new EngineCore.PostProcess("Depth Display","depthbuffer",null,null,1,null,void 0,e,!0);n.onApply=o=>{o._bindTexture("textureSampler",t.enableDepthRenderer().getDepthMap().getInternalTexture())};const a=new DepthTextureDebuggerNode("Depth Texture Debugger",t,n),r=t.getTransformNodeByName("Debugger");return r&&(a.parent=r),()=>{var o;(o=t.activeCamera)==null||o.detachPostProcess(n),a&&t.removeTransformNode(a),a.dispose(),n.dispose()}}},[t,e]),jsxRuntime.jsx(jsxRuntime.Fragment,{})},DepthTextureDebugger$1=DepthTextureDebugger;class GPUPickingTextureDebuggerNode extends EngineCore.TransformNode{constructor(n,a,r){super(n,a);
|
|
1209
|
+
{}`;const n=new EngineCore.PostProcess("Depth Display","depthbuffer",null,null,1,null,void 0,e,!0);n.onApply=o=>{o._bindTexture("textureSampler",t.enableDepthRenderer().getDepthMap().getInternalTexture())};const a=new DepthTextureDebuggerNode("Depth Texture Debugger",t,n),r=t.getTransformNodeByName("Debugger");return r&&(a.parent=r),()=>{var o;(o=t.activeCamera)==null||o.detachPostProcess(n),a&&t.removeTransformNode(a),a.dispose(),n.dispose()}}},[t,e]),jsxRuntime.jsx(jsxRuntime.Fragment,{})},DepthTextureDebugger$1=DepthTextureDebugger;class GPUPickingTextureDebuggerNode extends EngineCore.TransformNode{constructor(n,a,r){super(n,a);le(this,"_showGPUPicking",!1);le(this,"_postProcess");this._postProcess=r,this.showGPUPicking=!1,this.inspectableCustomProperties=[{label:"Show GPU Picking Texture",propertyName:"showGPUPicking",type:EngineCore.InspectableType.Checkbox}]}set showGPUPicking(n){var a,r;this._showGPUPicking=n,this._postProcess&&(this._showGPUPicking?(a=this.getScene().activeCamera)==null||a.attachPostProcess(this._postProcess):(r=this.getScene().activeCamera)==null||r.detachPostProcess(this._postProcess))}get showGPUPicking(){return this._showGPUPicking}}const GPUPickingTextureDebugger=()=>{const e=reactBabylonjs.useEngine(),t=reactBabylonjs.useScene(),n=React.useContext(GPUPickingContext);return React.useEffect(()=>{if(t&&e&&n&&n&&n.gpuPickingTexture.current){EngineCore.Effect.ShadersStore.gpuPickingBufferPixelShader=`#ifdef GL_ES
|
|
1210
1210
|
precision highp float;
|
|
1211
1211
|
#endif
|
|
1212
1212
|
|
|
@@ -1222,9 +1222,9 @@ precision highp float;
|
|
|
1222
1222
|
#endif
|
|
1223
1223
|
|
|
1224
1224
|
void main(void)
|
|
1225
|
-
{}`;const a=new EngineCore.PostProcess("GPU Picking Display","gpuPickingBuffer",null,null,1,null,void 0,e,!0);a.onApply=i=>{i._bindTexture("textureSampler",n.gpuPickingTexture.current.getInternalTexture())};const r=new GPUPickingTextureDebuggerNode("GPU Picking Debugger",t,a),o=t.getTransformNodeByName("Debugger");return o&&(r.parent=o),()=>{var i;(i=t.activeCamera)==null||i.detachPostProcess(a),r&&t.removeTransformNode(r),r.dispose(),a.dispose()}}},[t,e,n]),jsxRuntime.jsx(jsxRuntime.Fragment,{})},GPUPickingTextureDebugger$1=GPUPickingTextureDebugger,DebugLayer=({showDebugLayer:e=!1})=>{const t=reactBabylonjs.useScene(),n=reactBabylonjs.useEngine();return React.useEffect(()=>{n&&t&&(e?(n.captureGPUFrameTime=a=>{},inspector.Inspector.Show(t,{embedMode:!0})):inspector.Inspector.Hide())},[n,t,e]),React.useEffect(()=>()=>{t&&inspector.Inspector.Hide()},[t]),jsxRuntime.jsxs("transformNode",{name:"Debugger",children:[jsxRuntime.jsx(DepthTextureDebugger$1,{}),jsxRuntime.jsx(GPUPickingTextureDebugger$1,{})]})},DebugLayer$1=DebugLayer,EngineFixer=()=>{const e=reactBabylonjs.useScene(),t=reactBabylonjs.useEngine();return React.useEffect(()=>{const n=t;if(window.BABYLON&&n)return window.BABYLON.EngineStore.Instances.push(n),dynamic.registerBuiltInLoaders(),()=>{if(window.BABYLON){const a=window.BABYLON.EngineStore.Instances.indexOf(n);a>-1&&window.BABYLON.EngineStore.Instances.splice(a,1)}}},[t]),React.useEffect(()=>{const n=t;if(n)return EngineCore.EngineStore.Instances.push(n),()=>{const a=window.BABYLON.EngineStore.Instances.indexOf(n);a>-1&&window.BABYLON.EngineStore.Instances.splice(a,1)}},[t]),React.useEffect(()=>{const n=e;if(window.BABYLON&&n)return window.BABYLON.EngineStore._LastCreatedScene=e,()=>{window.BABYLON&&window.BABYLON.EngineStore._LastCreatedScene===n&&(window.BABYLON.EngineStore._LastCreatedScene=null)}},[e]),React.useEffect(()=>{const n=e;if(n)return EngineCore.EngineStore._LastCreatedScene=e,()=>{EngineCore.EngineStore._LastCreatedScene===n&&(EngineCore.EngineStore._LastCreatedScene=null)}},[e]),React.useEffect(()=>{e&&(e._forceBlockMaterialDirtyMechanism=a=>{e._blockMaterialDirtyMechanism=a})},[e]),jsxRuntime.jsx(jsxRuntime.Fragment,{})},EngineFixer$1=EngineFixer;class ResourceManager{constructor(){
|
|
1226
|
-
%c Geo3DViewer Library %c Version: 1.7.
|
|
1227
|
-
`,"color:#e0e0e0;background:#873e23;padding:5px 0;border-top-left-radius:5px;border-bottom-left-radius:5px;","color:#455a64;background:#e0e0e0;padding:5px 0;","color:#455a64;background:#e0e0e0;padding:5px 0;border-top-right-radius:5px;border-bottom-right-radius:5px;")},[]),React.useImperativeHandle(t,()=>({scene:u,camera:null}),[u]),React.useEffect(()=>{a&&h(!0)},[a]),jsxRuntime.jsx(reactBabylonjs.Engine,{antialias:!0,adaptToDeviceRatio:!0,canvasId:"rootGeo3DCanvas",engineOptions:{useHighPrecisionFloats:!0,depth:!0,useHighPrecisionMatrix:!0,stencil:!0},children:jsxRuntime.jsxs(reactBabylonjs.Scene,{clearColor:s.backgroundColor,useRightHandedSystem:s.useRightHandedSystem,children:[jsxRuntime.jsx(EngineFixer$1,{}),jsxRuntime.jsx("ground",{name:"picking-material-holder",setEnabled:!1,children:jsxRuntime.jsx(PickingMaterial,{})}),jsxRuntime.jsx(ResourceContext.Provider,{value:new ResourceManager,children:jsxRuntime.jsxs(Geo3DProvider$1,{workspaceMeta:r,colorProvider:o,cacheProvider:i,ref:u,children:[d||a?jsxRuntime.jsx(DebugLayer$1,{showDebugLayer:a}):null,jsxRuntime.jsx("hemisphericLight",{name:"light",intensity:c,direction:f}),n]})}),s.environment?jsxRuntime.jsx("cubeTexture",{assignTo:"environmentTexture",rootUrl:s.environment}):jsxRuntime.jsx(jsxRuntime.Fragment,{})]})})},Geo3DViewer$1=React.forwardRef(Geo3DViewer);var GridDiagram_GridDiagramMode=(e=>(e[e.ATTRIBUTE=0]="ATTRIBUTE",e[e.COLOR=1]="COLOR",e[e.STATIC_ATTRIBUTE=2]="STATIC_ATTRIBUTE",e[e.STATIC_COLOR=3]="STATIC_COLOR",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(GridDiagram_GridDiagramMode||{});function gridDiagram_GridDiagramModeFromJSON(e){switch(e){case 0:case"ATTRIBUTE":return 0;case 1:case"COLOR":return 1;case 2:case"STATIC_ATTRIBUTE":return 2;case 3:case"STATIC_COLOR":return 3;case-1:case"UNRECOGNIZED":default:return-1}}function gridDiagram_GridDiagramModeToJSON(e){switch(e){case 0:return"ATTRIBUTE";case 1:return"COLOR";case 2:return"STATIC_ATTRIBUTE";case 3:return"STATIC_COLOR";case-1:default:return"UNRECOGNIZED"}}function createBaseGridDiagram(){return{name:"",step:0,xCount:0,yCount:0,zCount:0,xSliceUrl:"",ySliceUrl:"",zSliceUrl:"",mode:0}}const GridDiagram$2={encode(e,t=minimal.Writer.create()){return e.name!==""&&t.uint32(10).string(e.name),e.step!==0&&t.uint32(16).uint32(e.step),e.xCount!==0&&t.uint32(24).uint32(e.xCount),e.yCount!==0&&t.uint32(32).uint32(e.yCount),e.zCount!==0&&t.uint32(40).uint32(e.zCount),e.xSliceUrl!==""&&t.uint32(50).string(e.xSliceUrl),e.ySliceUrl!==""&&t.uint32(58).string(e.ySliceUrl),e.zSliceUrl!==""&&t.uint32(66).string(e.zSliceUrl),e.mode!==0&&t.uint32(72).int32(e.mode),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseGridDiagram();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==16)break;r.step=n.uint32();continue;case 3:if(o!==24)break;r.xCount=n.uint32();continue;case 4:if(o!==32)break;r.yCount=n.uint32();continue;case 5:if(o!==40)break;r.zCount=n.uint32();continue;case 6:if(o!==50)break;r.xSliceUrl=n.string();continue;case 7:if(o!==58)break;r.ySliceUrl=n.string();continue;case 8:if(o!==66)break;r.zSliceUrl=n.string();continue;case 9:if(o!==72)break;r.mode=n.int32();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$6(e.name)?globalThis.String(e.name):"",step:isSet$6(e.step)?globalThis.Number(e.step):0,xCount:isSet$6(e.xCount)?globalThis.Number(e.xCount):0,yCount:isSet$6(e.yCount)?globalThis.Number(e.yCount):0,zCount:isSet$6(e.zCount)?globalThis.Number(e.zCount):0,xSliceUrl:isSet$6(e.xSliceUrl)?globalThis.String(e.xSliceUrl):"",ySliceUrl:isSet$6(e.ySliceUrl)?globalThis.String(e.ySliceUrl):"",zSliceUrl:isSet$6(e.zSliceUrl)?globalThis.String(e.zSliceUrl):"",mode:isSet$6(e.mode)?gridDiagram_GridDiagramModeFromJSON(e.mode):0}},toJSON(e){const t={};return e.name!==""&&(t.name=e.name),e.step!==0&&(t.step=Math.round(e.step)),e.xCount!==0&&(t.xCount=Math.round(e.xCount)),e.yCount!==0&&(t.yCount=Math.round(e.yCount)),e.zCount!==0&&(t.zCount=Math.round(e.zCount)),e.xSliceUrl!==""&&(t.xSliceUrl=e.xSliceUrl),e.ySliceUrl!==""&&(t.ySliceUrl=e.ySliceUrl),e.zSliceUrl!==""&&(t.zSliceUrl=e.zSliceUrl),e.mode!==0&&(t.mode=gridDiagram_GridDiagramModeToJSON(e.mode)),t},create(e){return GridDiagram$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l,c,f;const t=createBaseGridDiagram();return t.name=(n=e.name)!=null?n:"",t.step=(a=e.step)!=null?a:0,t.xCount=(r=e.xCount)!=null?r:0,t.yCount=(o=e.yCount)!=null?o:0,t.zCount=(i=e.zCount)!=null?i:0,t.xSliceUrl=(s=e.xSliceUrl)!=null?s:"",t.ySliceUrl=(l=e.ySliceUrl)!=null?l:"",t.zSliceUrl=(c=e.zSliceUrl)!=null?c:"",t.mode=(f=e.mode)!=null?f:0,t}};function isSet$6(e){return e!=null}const GridDiagram=({name:e,url:t,step:n,visible:a=!0,colorCodec:r,alpha:o=1,actions:i,materials:s})=>{const[l,c]=React.useState(),[f,u]=React.useState(0),d=useCachedBinary({url:t,cacheType:CacheType.URL_PREFIX_MATCH});return React.useEffect(()=>{console.log("[Geo3DViewer] GriDDiagram Loading: ",t)},[t]),React.useEffect(()=>{if(d){const h=GridDiagram$2.decode(new Uint8Array(d)),{xCount:m,zCount:R,xSliceUrl:v,zSliceUrl:g}=h,x=[];if(h.mode===GridDiagram_GridDiagramMode.ATTRIBUTE||h.mode===GridDiagram_GridDiagramMode.COLOR){if(n<=0){console.error("[Geo3DViewer] 此文件为动态数据文件,step 值必须大于 0"),c([]),u(0);return}let y=0;for(let E=0;E<m;E+=n)x.push(v.replace("%s",E.toString())),y=E;y>=m&&x.push(v.replace("%s",(m-1).toString()));for(let E=0;E<R;E+=n)x.push(g.replace("%s",E.toString())),y=E;y>=R&&x.push(g.replace("%s",(R-1).toString()))}else if(h.mode===GridDiagram_GridDiagramMode.STATIC_ATTRIBUTE||h.mode===GridDiagram_GridDiagramMode.STATIC_COLOR){if(n!==0){console.error("[Geo3DViewer] 静态栅状图数据必须传入 step=0 以确认您明确此数据无法使用动态加载模式"),c([]),u(0);return}for(let y=0;y<m;y+=1)x.push(v.replace("%s",y.toString()))}return c(x),u(h.mode===GridDiagram_GridDiagramMode.ATTRIBUTE?1:h.mode===GridDiagram_GridDiagramMode.COLOR?2:h.mode===GridDiagram_GridDiagramMode.STATIC_ATTRIBUTE?1:h.mode===GridDiagram_GridDiagramMode.STATIC_COLOR?2:0),()=>{c([]),u(0)}}},[d,n]),jsxRuntime.jsx("abstractMesh",{name:`gridDiagram-${e}`,children:f===1?l?l.map((h,m)=>jsxRuntime.jsx(DensitySlice$1,{name:e,url:h,visible:a,colorCodec:r,alpha:o,actions:i},`densityslice-group-${e}-${h}-${m}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}):f===2?l?l.map((h,m)=>jsxRuntime.jsx(FormationSlice$1,{url:h,visible:a,materials:s,actions:i},`formationslice-group-${e}-${h}-${m}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{})})},GridDiagram$1=GridDiagram,IntersectingLine=({name:e,position:t,width:n,height:a,color:r,lineWidth:o,rotation:i,showDebugPlane:s=!1})=>{const l=React.useContext(WorkspaceMetaContext),c=React.useRef(null),f=useIntersectingLineMaterial({name:e,lineColor:r,lineWidth:o});return React.useEffect(()=>{c.current&&(c.current.material=f)},[f]),jsxRuntime.jsxs("transformNode",{name:`intersecting-line-${e}`,position:t.multiply(calcTransformNodeScale(l)),rotation:i||EngineCore.Vector3.Zero(),children:[jsxRuntime.jsx("plane",{name:e,width:n,height:a,isPickable:!1,isBlocker:!1,ref:c}),jsxRuntime.jsx("plane",{name:e,width:n,height:a,isPickable:!1,isBlocker:!1,setEnabled:s,children:jsxRuntime.jsx("standardMaterial",{name:"intersecting-line-material",diffuseColor:EngineCore.Color3.Gray(),backFaceCulling:!1,alpha:.5,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND})})]})},IntersectingLine$1=IntersectingLine,LookAt=e=>{const t=reactBabylonjs.useScene(),{target:n,distance:a}=e;return React.useEffect(()=>{if(t&&t.activeCamera&&n){const r=t.activeCamera;let o=new EngineCore.Vector3(0,0,0);if(typeof n=="string"){const i=t.getMeshById(n);i&&(o=i.getBoundingInfo().boundingBox.center)}else n.position?o=n.getBoundingInfo().boundingBox.center:o=n;if(r instanceof EngineCore.ArcRotateCamera){r.setTarget(o),r.radius=a;return}if(r instanceof EngineCore.FreeCamera){const i=o,s=r.position.clone(),l=a/EngineCore.Vector3.Distance(i,s),f=s.subtract(i).scale(l),u=i.add(f);r.position=u,r.setTarget(o)}return}},[a,t,n]),null},LookAt$1=LookAt,getChildBone=e=>{const t=e.getChildren();return t.length>0?[e,...getChildBone(t[0])]:[e]},ModelLoader=({name:e,url:t,position:n=EngineCore.Vector3.Zero(),rotation:a=EngineCore.Vector3.Zero(),localScale:r=1,visible:o=!0,showPickingBox:i=!1,useGlobalScale:s=!1,actions:l,alpha:c=1,boneRotation:f,pickingBoxScale:u=EngineCore.Vector3.One(),labelStyle:d},h)=>{const m=reactBabylonjs.useScene(),R=useCachedModel({url:t}),v=React.useRef(null),g=React.useRef(null),[x,y]=React.useState(null),[E,k]=React.useState(5),[b,C]=React.useState(5),[_,A]=React.useState(5),[N,S]=React.useState(EngineCore.Vector3.Zero()),[I,O]=React.useState(EngineCore.Vector3.One()),[F,L]=React.useState([]),w=React.useContext(WorkspaceMetaContext),{scaleWithParent:B=!0}=d||{};return React.useEffect(()=>{console.log("[Geo3DViewer] ModelLoader Loading: ",t)},[t]),React.useImperativeHandle(h,()=>g.current,[]),React.useEffect(()=>{if(R){const D=R.instantiateModelsToScene(W=>`${e}-${W}`,!0);return console.log("[Geo3DViewer] ModelLoader 实例化: ",e),y(D),()=>{console.log("[Geo3DViewer] ModelLoader 反实例化: ",e),y(null)}}},[R,e]),React.useEffect(()=>{if(x){const D=x,W=D.skeletons;if(W&&W.length>0){const ne=W[0].bones,U=[];ne.filter(re=>re.name==="MorphBoneBase").forEach((re,te)=>{if(te===0){const K=getChildBone(re);U.push(...K.map(Z=>{var de;return(de=Z.getTransformNode())!=null?de:Z}))}}),L(U),console.log("[Geo3DViewer] ModelLoader 设定 Morph 骨骼: ",U)}return()=>{console.log("[Geo3DViewer] ModelLoader 注销 Model"),D.dispose(),L([])}}},[x]),React.useEffect(()=>{f&&F&&(console.log("[Geo3DViewer] ModelLoader 设定骨骼旋转"),F.forEach((D,W)=>{f.length>W?D.rotation=f[W]:D.rotation=EngineCore.Vector3.Zero()}),(!f||f.length===0)&&console.log("[Geo3DViewer] ModelLoader 的鼠标拾取功能由于 boneRotation 被禁用"))},[f,F]),React.useEffect(()=>{v.current&&(v.current.metadata={pickable:l?{name:e,onLeftClick:l.onLeftClick,onRightClick:l.onRightClick,onMiddleClick:l.onMiddleClick,onHover:l.onHover,valueCallback:null,extra:l.extra}:null})},[l,e]),React.useEffect(()=>{if(m&&x&&g.current){console.log("[Geo3DViewer] ModelLoader 创建容器: ",e);const D=new EngineCore.TransformNode(`amesh-model-${e}`);D.parent=g.current,x.rootNodes.forEach(K=>{K&&(K.parent=D)}),D.computeWorldMatrix(!0),EngineCore.PivotTools._RemoveAndStorePivotPoint(D);const W=D.parent;D.parent=null;const ae=EngineCore.Quaternion.RotationYawPitchRoll(D.rotation.y,D.rotation.x,D.rotation.z),ne=new EngineCore.Vector3(D.position.x,D.position.y,D.position.z);D.rotation.set(0,0,0),D.position.set(0,0,0);const U=D.getHierarchyBoundingVectors(!0),re=U.max.subtract(U.min);k(re.y),C(re.z),A(re.x),O(ae.toEulerAngles());const te=new EngineCore.Vector3((U.max.x+U.min.x)/2,(U.max.y+U.min.y)/2,(U.max.z+U.min.z)/2);return S(te),D.position=ne,D.rotationQuaternion=ae,D.parent=W,EngineCore.PivotTools._RestorePivotPoint(D),console.log("[Geo3DViewer] 创建 ModelLoader 鼠标拾取外框 ",e," 于 ",te," 大小为 ",re.x,re.y,re.z),()=>{console.log("[Geo3DViewer] ModelLoader 注销容器: ",e),D.dispose()}}},[x,e,m]),React.useEffect(()=>{x&&x.rootNodes.forEach(D=>{D.getChildMeshes().forEach(W=>{W.material&&(W.material.transparencyMode=EngineCore.Material.MATERIAL_ALPHABLEND,W.material.alpha=c)})})},[x,c]),jsxRuntime.jsx("transformNode",{name:`transform-model-${e}`,position:n,rotation:a,scalingDeterminant:r,setEnabled:o,children:jsxRuntime.jsxs("transformNode",{name:`transform-model-global-${e}`,ref:g,scaling:s?new EngineCore.Vector3(w&&w.scalePlane?w.scalePlane:1,w&&w.scaleDepth?w.scaleDepth:1,w&&w.scalePlane?w.scalePlane:1):new EngineCore.Vector3(1,1,1),children:[d?jsxRuntime.jsx("transformNode",{name:`transform-model-label-${e}`,position:N.add(d!=null&&d.offset?d.offset.multiplyByFloats(w!=null&&w.scalePlane?w==null?void 0:w.scalePlane:1,1,w!=null&&w.scalePlane?w==null?void 0:w.scalePlane:1):EngineCore.Vector3.Zero()),scalingDeterminant:B?r*3:3,children:jsxRuntime.jsx(GUIText$1,{text:d.title,fontSize:d.fontSize?d.fontSize:40,color:d.color?d.color:"white"})}):jsxRuntime.jsx(jsxRuntime.Fragment,{}),jsxRuntime.jsx("box",{name:`pick-mesh-${e}`,ref:v,size:1,scaling:new EngineCore.Vector3(_,E,b).multiply(u),position:N,rotation:I,setEnabled:f?f.length===0:!0,children:jsxRuntime.jsx("standardMaterial",{name:`pick-mesh-${e}-mat`,alpha:i?.5:0})})]})})},ModelLoader$1=React.forwardRef(ModelLoader),ModelAnimationLoader=({name:e,url:t,position:n=EngineCore.Vector3.Zero(),rotation:a=EngineCore.Vector3.Zero(),localScale:r=1,visible:o=!0},i)=>{const s=reactBabylonjs.useScene(),l=useCachedModel({url:t}),c=React.useRef(null),[f,u]=React.useState(null);return React.useEffect(()=>{console.log("[Geo3DViewer] ModelLoader Loading: ",t)},[t]),React.useImperativeHandle(i,()=>c.current,[]),React.useEffect(()=>{if(l){const d=l.instantiateModelsToScene(h=>`${e}-${h}`,!0);return console.log("[Geo3DViewer] ModelLoader 实例化: ",e),u(d),()=>{console.log("[Geo3DViewer] ModelLoader 反实例化: ",e),u(null)}}},[l,e]),React.useEffect(()=>{s&&f&&c.current&&(s.animationGroups.forEach(d=>{console.log("play animtion:"+d.name),d.start(!0)}),f.rootNodes.forEach(d=>{d&&(d.parent=c.current)}))},[f,e,s]),jsxRuntime.jsx("transformNode",{name:`transform-model-${e}`,position:n,rotation:a,scalingDeterminant:r,setEnabled:o,ref:c})},ModleAnimationLoader=React.forwardRef(ModelAnimationLoader),Optimizer=()=>{const e=reactBabylonjs.useScene();return React.useEffect(()=>{if(e){const t=EngineCore.SceneOptimizerOptions.ModerateDegradationAllowed();t.optimizations;const n=new EngineCore.SceneOptimizer(e,t,!0,!0);return n.start(),console.log("[Geo3DViewer] 渐进式优化器已启动,如遭遇技术性渲染问题,请优先尝试禁用此优化器。"),()=>{n.stop(),n.dispose(),console.log("[Geo3DViewer] 渐进式优化器已停止。")}}},[e]),jsxRuntime.jsx(jsxRuntime.Fragment,{})},Optimizer$1=Optimizer,ParticleSystem=e=>{const{name:t,url:n,rootURL:a,doNotStart:r,capacity:o,position:i=new EngineCore.Vector3}=e,s=reactBabylonjs.useScene(),[l,c]=React.useState();return React.useEffect(()=>()=>{l&&l.dispose()},[l]),React.useEffect(()=>{if(s&&!l){const f=new EngineCore.AssetsManager(s),u=f.addTextFileTask(t!=null?t:"particle-system",n);f.load(),f.onFinish=function(d){console.log("task successful",d);const h=JSON.parse(u.text),m=EngineCore.ParticleSystem.Parse(h,s,a,r,o);m.emitter=i,c(m)}}return()=>{l&&(l.dispose(),console.log(t,"effect disposed!"))}},[o,r,t,l,i,a,s,n]),null},ParticleSystem$1=ParticleSystem,WaterEffect=e=>{const{id:t,position:n,useGPU:a=!0,renderAsFluid:r,numParticles:o=1e3,emitRate:i=1500*2,blendMode:s=EngineCore.ParticleSystem.BLENDMODE_ADD,color1:l,color2:c,colorDead:f,minSize:u,maxSize:d,minLifeTime:h,maxLifeTime:m,gravity:R,minEmitPower:v,maxEmitPower:g,updateSpeed:x,textureUrl:y,angle:E=Math.PI/2,radius:k=4,fluidRender:b}=e,C=reactBabylonjs.useScene(),[_,A]=React.useState(),N=React.useRef(null);return React.useEffect(()=>{_&&(_.blendMode=s,l&&(_.color1=l),c&&(_.color2=c),f&&(_.colorDead=f),u!==void 0&&(_.minSize=u),d!==void 0&&(_.maxSize=d),h!==void 0&&(_.minLifeTime=h),m!==void 0&&(_.maxLifeTime=m),v!==void 0&&(_.minEmitPower=v),g!==void 0&&(_.maxEmitPower=g),x!==void 0&&(_.updateSpeed=x),_.preWarmCycles=60*8,R&&(_.gravity=R),_.createConeEmitter(k,E),y&&(_.particleTexture=new EngineCore.Texture(y),_.particleTexture.onLoadObservable.add(()=>{_.start()})))},[E,s,l,c,f,R,g,m,d,v,h,u,_,k,y,x]),React.useEffect(()=>{if(!_&&C)if(a){const S=new EngineCore.GPUParticleSystem("particle-"+t,{capacity:o},C);A(S)}else{const S=new EngineCore.ParticleSystem("particle-"+t,o,C);A(S)}return()=>{console.log("particlesystem disposed!"),N.current&&(N.current.object.particleSize=0)}},[t,o,_,C,a]),React.useEffect(()=>{_&&(C==null||C.executeWhenReady(()=>{var S,I,O;if(C.updateTransformMatrix(!0),_==null||_.render(),r&&_){const F=C.enableFluidRenderer();if(F){F.addParticleSystem(_);const L=F.getRenderObjectFromParticleSystem(_);N.current=L,L&&(L.object.particleSize=(S=b==null?void 0:b.particleSize)!=null?S:.75,L.object.particleThicknessAlpha=.02,L.object.useTrueRenderingForDiffuseTexture=!0,L.targetRenderer.minimumThickness=L.object.particleThicknessAlpha,L.targetRenderer.blurDepthFilterSize=10,L.targetRenderer.blurDepthDepthScale=10,L.targetRenderer.thicknessMapSize=1024,L.targetRenderer.density=(I=b==null?void 0:b.density)!=null?I:8,L.targetRenderer.fresnelClamp=.04,L.targetRenderer.fluidColor=(O=b==null?void 0:b.fluidColor)!=null?O:new EngineCore.Color3(219/255,228/255,1),L.targetRenderer.generateDiffuseTexture=!1)}}}))},[b==null?void 0:b.density,b==null?void 0:b.fluidColor,b==null?void 0:b.particleSize,_,r,C]),React.useEffect(()=>{_&&(_.emitter=n,_.emitRate=i)},[i,_,n]),null},WaterEffect$1=WaterEffect,PlaneImage=(e,t)=>{var b,C,_;const n=reactBabylonjs.useScene(),a=React.useContext(WorkspaceMetaContext),{name:r,width:o,height:i,localScale:s=EngineCore.Vector3.One(),rotation:l=EngineCore.Vector3.Zero(),position:c=EngineCore.Vector3.Zero(),textureUrl:f,videoUrl:u,canvas:d,backFaceCulling:h=!0,billboard:m=!1,actions:R,labelStyle:v}=e,g=useCachedTexture({url:f}),x=React.useRef(null),y=React.useRef(null),[E,k]=React.useState(null);return React.useEffect(()=>{if(u)return k(A=>{A==null||A.dispose();const N=new EngineCore.VideoTexture("video-texture",u,n,!1,!1,void 0,{autoPlay:!0,autoUpdateTexture:!0});return N.hasAlpha=!0,N}),()=>{k(A=>(A==null||A.dispose(),null))}},[u]),React.useEffect(()=>{if(d){const A=new EngineCore.DynamicTexture("dyn-texture",d,n);return A.hasAlpha=!0,x.current=A,()=>{var N;(N=x.current)==null||N.dispose()}}},[d]),React.useEffect(()=>{x.current&&(x.current.name=r)},[r]),React.useImperativeHandle(t,()=>x,[x]),React.useEffect(()=>{var N;const A=(N=y.current)==null?void 0:N.getChildMeshes()[0];A&&(A.metadata={pickable:R?{name:r,onLeftClick:R.onLeftClick,onRightClick:R.onRightClick,onMiddleClick:R.onMiddleClick,onHover:R.onHover,extra:R.extra}:null})},[R,r]),jsxRuntime.jsxs("transformNode",{ref:y,name:`transform-planeimage-${r}`,position:c.multiply(a?new EngineCore.Vector3((b=a.scalePlane)!=null?b:1,(C=a.scaleDepth)!=null?C:1,(_=a.scalePlane)!=null?_:1):EngineCore.Vector3.One()),rotation:m?EngineCore.Vector3.Zero():l,billboardMode:m?EngineCore.Mesh.BILLBOARDMODE_ALL:EngineCore.Mesh.BILLBOARDMODE_NONE,children:[jsxRuntime.jsx("plane",{name:`plane-planeimage-${r}`,width:o,height:i,scaling:s,children:jsxRuntime.jsx("standardMaterial",{name:`plane-planeimage-${r}`,emissiveColor:EngineCore.Color3.White(),specularColor:EngineCore.Color3.Black(),diffuseTexture:x.current?x.current:E||g,useAlphaFromDiffuseTexture:!0,backFaceCulling:h,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND})}),v&&jsxRuntime.jsx(GUIText$1,{...v})]})},PlaneImage$1=React.forwardRef(PlaneImage);var PointClickZoneObjectType=(e=>(e[e.TETRAHEDRON=0]="TETRAHEDRON",e[e.OCTAHEDRON=1]="OCTAHEDRON",e[e.DODECAHEDRON=2]="DODECAHEDRON",e[e.ICOSAHEDRON=3]="ICOSAHEDRON",e[e.RHOMBICUBOCTAHEDRON=4]="RHOMBICUBOCTAHEDRON",e))(PointClickZoneObjectType||{});const PointClickZone=({size:e,alpha:t=1,position:n,visible:a,objectType:r,title:o,actions:i,labelStyle:s,color:l,scaleMode:c})=>{const f=React.useRef(null),u=React.useContext(WorkspaceMetaContext);React.useEffect(()=>{f.current&&(f.current.metadata={pickable:i?{name:o,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null})},[i,o]);const[d,h]=React.useState(1);return React.useEffect(()=>{switch(c){case ScaleMode.PLANE:h(u&&u.scalePlane?u.scalePlane:1);break;case ScaleMode.DEPTH:h(u&&u.scaleDepth?u.scaleDepth:1);break;case ScaleMode.NONE:h(1);break}},[u,c]),jsxRuntime.jsxs("transformNode",{setEnabled:a,name:`transform-spaceheat-${o}`,position:n.multiplyByFloats(u&&u.scalePlane?u.scalePlane:1,u&&u.scaleDepth?u.scaleDepth:1,u&&u.scalePlane?u.scalePlane:1),scalingDeterminant:d,children:[jsxRuntime.jsx("polyhedron",{ref:f,name:`point-${o}`,type:r,size:e,children:jsxRuntime.jsx("standardMaterial",{name:`point-${o}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),emissiveColor:EngineCore.Color3.Black(),alphaMode:EngineCore.Engine.ALPHA_COMBINE,diffuseColor:l,alpha:t})}),jsxRuntime.jsx("transformNode",{name:`${o}-title`,position:s!=null&&s.offset?s.offset.multiplyByFloats(u!=null&&u.scalePlane?u==null?void 0:u.scalePlane:1,1,u!=null&&u.scalePlane?u==null?void 0:u.scalePlane:1):EngineCore.Vector3.Zero(),scaling:calcGUIScale(u).multiply(new EngineCore.Vector3(3,3,3)),children:jsxRuntime.jsx(GUIText$1,{text:o,fontSize:s!=null&&s.fontSize?s.fontSize:10,color:s!=null&&s.color?s.color:"white"})})]})},PointClickZone$1=PointClickZone,ProgressedAttributeBody=({name:e,url:t,offset:n=EngineCore.Vector3.Zero(),alpha:a,color:r,visible:o=!0,cutNormal:i,value:s,actions:l,textureOverride:c,progressTexture:f={},counterLine:u=void 0,lines:d=[],text:h=[],disableDepthWrite:m=!1,checkLines:R=[],checkLineWidth:v=4})=>{var te,K,Z,de,ee,G,ge,fe,V,J,Ce,Y,se,ce,Q,ye,Re,Te,Ee;const g=reactBabylonjs.useScene(),x=React.useRef(null),y=React.useContext(WorkspaceMetaContext),E=useCachedBinary({url:t,cacheType:CacheType.URL_PREFIX_MATCH}),[k,b]=React.useState(EngineCore.Vector3.Zero()),[C,_]=React.useState(void 0),A=useCachedTexture({url:c==null?void 0:c.texture,cacheType:CacheType.URL_PREFIX_MATCH}),N=useCachedTexture({url:c==null?void 0:c.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),S=useCachedTexture({url:(te=f.segment1)==null?void 0:te.texture,cacheType:CacheType.URL_PREFIX_MATCH}),I=useCachedTexture({url:(K=f.segment1)==null?void 0:K.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),O=useCachedTexture({url:(Z=f.segment2)==null?void 0:Z.texture,cacheType:CacheType.URL_PREFIX_MATCH}),F=useCachedTexture({url:(de=f.segment2)==null?void 0:de.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),L=useCachedTexture({url:(ee=f.segment3)==null?void 0:ee.texture,cacheType:CacheType.URL_PREFIX_MATCH}),w=useCachedTexture({url:(G=f.segment3)==null?void 0:G.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),B=useCachedTexture({url:(ge=f.segment4)==null?void 0:ge.texture,cacheType:CacheType.URL_PREFIX_MATCH}),D=useCachedTexture({url:(fe=f.segment4)==null?void 0:fe.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),W=useCachedTexture({url:(V=f.segment5)==null?void 0:V.texture,cacheType:CacheType.URL_PREFIX_MATCH}),ae=useCachedTexture({url:(J=f.segment5)==null?void 0:J.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),ne=useCachedTexture({url:(Ce=f.segment6)==null?void 0:Ce.texture,cacheType:CacheType.URL_PREFIX_MATCH}),U=useCachedTexture({url:(Y=f.segment6)==null?void 0:Y.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH});React.useEffect(()=>{console.log("[Geo3DViewer] ProgressedAttributeBody Loading: ",t)},[t]),React.useEffect(()=>{if(g&&x.current&&t&&E){const _e=x.current;EngineCore.Tags.EnableFor(_e),EngineCore.Tags.AddTagsTo(_e,"loading");const Se=VirtualVolume.decode(new Uint8Array(E)),{points:Ne,indices:Ae,value:Me,center:be}=Se;be&&b(new EngineCore.Vector3(be.x,be.y,be.z));const Ie=new EngineCore.VertexData;Ie.positions=Ne,Ie.indices=Ae,Ie.colors=Me;const $e=[];EngineCore.VertexData.ComputeNormals(Ne,Ae,$e),Ie.normals=$e,_e&&(Ie.applyToMesh(_e),_e.getScene().onAfterRenderObservable.addOnce(()=>{if(!_e.isDisposed()){const oe=_e.getBoundingInfo();_(oe.boundingBox)}})),EngineCore.Tags.RemoveTagsFrom(_e,"loading")}},[t,g,E]);function re(_e,Se,Ne){const Ae=Ne.subtract(Se),Me=_e.subtract(Se),be=EngineCore.Vector3.Dot(EngineCore.Vector3.Normalize(Ae),EngineCore.Vector3.Normalize(Me)),Ie=Me.length()/be,$e=Se.add(Ae.scale(Ie/EngineCore.Vector3.Distance(Se,Ne)));return EngineCore.Vector3.Distance(_e,$e)}return React.useEffect(()=>{x.current&&(x.current.metadata={pickable:l?{name:e,valueCallback:(_e,Se,Ne)=>{if(console.log(e,_e,Se,Ne),x.current&&Se){const Ae=x.current.getBoundingInfo().boundingBox;console.log(Ae);for(let Me=0;Me<R.length;Me++){const be=R[Me];if(re(new EngineCore.Vector3(Se.x,0,Se.z),be.start,be.end)<v){const $e=[];for(let M=0;M<11;M++){const oe=be.end.subtract(be.start),le=be.start.add(oe.scale(M/10)),me=new EngineCore.Vector3(le.x,Se.y+Ae.extendSize.y*4,le.z),z=new EngineCore.Vector3(le.x,Se.y+Ae.extendSize.y*2,le.z),X=EngineCore.Vector3.Normalize(z.subtract(me)),T=Ae.extendSize.y*10,ie=new EngineCore.Ray(me,X,T),xe=g==null?void 0:g.pickWithRay(ie,p=>p===x.current);xe!=null&&xe.hit&&xe.pickedPoint&&$e.push(xe.pickedPoint)}for(let M=0;M<11;M++){const oe=be.end.subtract(be.start),le=be.start.add(oe.scale(M/10)),me=new EngineCore.Vector3(le.x,Se.y-Ae.extendSize.y*4,le.z),z=new EngineCore.Vector3(le.x,Se.y-Ae.extendSize.y*2,le.z),X=EngineCore.Vector3.Normalize(z.subtract(me)),T=Ae.extendSize.y*10,ie=new EngineCore.Ray(me,X,T),xe=g==null?void 0:g.pickWithRay(ie,p=>p===x.current);xe!=null&&xe.hit&&xe.pickedPoint&&$e.push(xe.pickedPoint)}return{value:Me,points:$e}}}}},onLeftClick:l.onLeftClick,onRightClick:l.onRightClick,onMiddleClick:l.onMiddleClick,onHover:l.onHover,extra:l.extra}:null})},[l,e,R]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`transform-progressedattribute-${e}`,position:k.add(n).multiplyByFloats(y&&y.scalePlane?y.scalePlane:1,y&&y.scaleDepth?y.scaleDepth:1,y&&y.scalePlane?y.scalePlane:1),scaling:new EngineCore.Vector3(y?y.scalePlane:1,y?y.scaleDepth:1,y?y.scalePlane:1),children:jsxRuntime.jsx("mesh",{name:`attributebody-${e}-mesh`,ref:x,setEnabled:o,useVertexColors:!A,alwaysSelectAsActiveMesh:!0,children:C&&origin?A?jsxRuntime.jsx(ProgressedRepeatedTextureMaterial,{name:`progressedattributebody-${e}-mat`,backFaceCulling:!0,needDepthPrePass:!1,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,texture:A,sideTexture:N,alphaStage:a,cutNormal:i,value:s,boundingBox:C,tilingFactor:c==null?void 0:c.tilingFactor,textureFlatRotate:c==null?void 0:c.flatModeRotate,sideTilingFactor:(se=c==null?void 0:c.sideTilingFactor)!=null?se:c==null?void 0:c.tilingFactor,mode:c==null?void 0:c.mode,overlay:{texture1:S,sideTexture1:I,texture2:O,sideTexture2:F,texture3:L,sideTexture3:w,texture4:B,sideTexture4:D,texture5:W,sideTexture5:ae,texture6:ne,sideTexture6:U,color1:(ce=f.segment1)==null?void 0:ce.color,color2:(Q=f.segment2)==null?void 0:Q.color,color3:(ye=f.segment3)==null?void 0:ye.color,color4:(Re=f.segment4)==null?void 0:Re.color,color5:(Te=f.segment5)==null?void 0:Te.color,color6:(Ee=f.segment6)==null?void 0:Ee.color},scaleDepth:y?y.scaleDepth:1,scalePlane:y?y.scalePlane:1,counterLine:u,lines:d,text:h,disableDepthWrite:m}):r?jsxRuntime.jsx(ProgressedRemapColorByRedChannelMaterial,{name:`progressedattributebody-${e}-mat`,backFaceCulling:!0,needDepthPrePass:!1,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:r,alphaStage:a,cutNormal:i,value:s,boundingBox:C,scaleDepth:y?y.scaleDepth:1,scalePlane:y?y.scalePlane:1,counterLine:u,lines:d,text:h,disableDepthWrite:m}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{})})})})},ProgressedAttributeBody$1=ProgressedAttributeBody,RayClick=({onPick:e,pickAll:t=!1})=>{const n=reactBabylonjs.useScene(),a=React.useContext(WorkspaceMetaContext),r=React.useRef(null),o=React.useRef([]),i=React.useRef(!1),s=React.useCallback(d=>{if(!d){e(null);return}let h=1,m=1;a&&(a.scalePlane&&(h=a.scalePlane),a.scaleDepth&&(m=a.scaleDepth)),e(new EngineCore.Vector3(d.x/h,d.y/m,d.z/h))},[a,e]),l=React.useCallback(()=>{if(!n)return[];const d=n.meshes.filter(m=>!!m&&!m.isDisposed()&&m.isPickable&&m.isVisible&&m.isEnabled()&&m.isReady(!0)),h=d.length!==o.current.length||d.some((m,R)=>o.current[R]!==m);return r.current||(r.current=new gpuPicker.GPUPicker),h&&(r.current.setPickingList(d.length>0?d.slice():null),o.current=d),d},[n]),c=React.useCallback(async()=>{if(!n||i.current||n.skipPointerMovePicking)return;if(!l().length||!r.current){e(null);return}i.current=!0;try{const h=await r.current.pickAsync(n.pointerX,n.pointerY,!1),m=h==null?void 0:h.mesh;if(!m){e(null);return}const R=n.pick(n.pointerX,n.pointerY,v=>v.uniqueId===m.uniqueId,!1,void 0);if(!(R!=null&&R.pickedPoint)){e(null);return}s(R.pickedPoint)}finally{i.current=!1}},[s,e,n,l]),f=React.useCallback(()=>{var h;if(!n||n.skipPointerMovePicking)return;const d=n.pick(n.pointerX,n.pointerY,void 0,!1,void 0);s((h=d==null?void 0:d.pickedPoint)!=null?h:null)},[s,n]),u=React.useCallback(d=>{switch(d.type){case EngineCore.PointerEventTypes.POINTERUP:{t?f():c();break}}},[t,f,c]);return React.useEffect(()=>{if(n){const d=n.onPointerObservable.add(u);return()=>{n.onPointerObservable.remove(d)}}},[u,n]),React.useEffect(()=>()=>{var d;(d=r.current)==null||d.dispose(),r.current=null,o.current=[],i.current=!1},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{})},RayClick$1=RayClick,RibbonLayer=({name:e,paths:t,color:n,alpha:a,sideOrientation:r=MaterialSideOrientation.CounterClockWiseSideOrientation,position:o=EngineCore.Vector3.Zero(),rotation:i=EngineCore.Vector3.Zero(),scaling:s=EngineCore.Vector3.One(),backFaceCulling:l=!1,labelStyle:c,showLayerLabel:f=!1,actions:u})=>{const d=React.useContext(WorkspaceMetaContext),h=calcTransformNodeScale(d),m=React.useRef(null),[R,v]=React.useState();return React.useEffect(()=>{if(m.current){const g=m.current.getBoundingInfo();v(g.boundingBox.centerWorld)}},[t,o,i,s]),React.useEffect(()=>{m.current&&(m.current.metadata={pickable:u?{name:e,onLeftClick:u.onLeftClick,onRightClick:u.onRightClick,onMiddleClick:u.onMiddleClick,onHover:u.onHover,extra:u.extra}:null})},[u,e]),jsxRuntime.jsxs("transformNode",{name:`${e}-transform`,position:o.multiply(h),rotation:i,scaling:s.multiply(h),children:[jsxRuntime.jsx("ribbon",{name:`${e}-transform`,pathArray:t,updatable:!0,ref:m,sideOrientation:r,children:jsxRuntime.jsx("standardMaterial",{name:`${e}-material`,diffuseColor:n,alpha:a,specularColor:EngineCore.Color3.Black(),ambientColor:EngineCore.Color3.White(),transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,backFaceCulling:l})}),e&&R&&jsxRuntime.jsx("transformNode",{name:`${e}-title`,position:R.add(c!=null&&c.offset?c.offset.multiplyByFloats(d!=null&&d.scalePlane?d==null?void 0:d.scalePlane:1,1,d!=null&&d.scalePlane?d==null?void 0:d.scalePlane:1):EngineCore.Vector3.Zero()),scaling:calcGUIScale(d).multiply(new EngineCore.Vector3(3,3,3)),setEnabled:f,children:jsxRuntime.jsx(GUIText$1,{text:e,fontSize:c!=null&&c.fontSize?c.fontSize:40,color:c!=null&&c.color?c.color:"white"})})]})},RibbonLayer$1=RibbonLayer,percentFragmentSource=`#ifdef GL_ES
|
|
1225
|
+
{}`;const a=new EngineCore.PostProcess("GPU Picking Display","gpuPickingBuffer",null,null,1,null,void 0,e,!0);a.onApply=i=>{i._bindTexture("textureSampler",n.gpuPickingTexture.current.getInternalTexture())};const r=new GPUPickingTextureDebuggerNode("GPU Picking Debugger",t,a),o=t.getTransformNodeByName("Debugger");return o&&(r.parent=o),()=>{var i;(i=t.activeCamera)==null||i.detachPostProcess(a),r&&t.removeTransformNode(r),r.dispose(),a.dispose()}}},[t,e,n]),jsxRuntime.jsx(jsxRuntime.Fragment,{})},GPUPickingTextureDebugger$1=GPUPickingTextureDebugger,DebugLayer=({showDebugLayer:e=!1})=>{const t=reactBabylonjs.useScene(),n=reactBabylonjs.useEngine();return React.useEffect(()=>{n&&t&&(e?(n.captureGPUFrameTime=a=>{},inspector.Inspector.Show(t,{embedMode:!0})):inspector.Inspector.Hide())},[n,t,e]),React.useEffect(()=>()=>{t&&inspector.Inspector.Hide()},[t]),jsxRuntime.jsxs("transformNode",{name:"Debugger",children:[jsxRuntime.jsx(DepthTextureDebugger$1,{}),jsxRuntime.jsx(GPUPickingTextureDebugger$1,{})]})},DebugLayer$1=DebugLayer,EngineFixer=()=>{const e=reactBabylonjs.useScene(),t=reactBabylonjs.useEngine();return React.useEffect(()=>{const n=t;if(window.BABYLON&&n)return window.BABYLON.EngineStore.Instances.push(n),dynamic.registerBuiltInLoaders(),()=>{if(window.BABYLON){const a=window.BABYLON.EngineStore.Instances.indexOf(n);a>-1&&window.BABYLON.EngineStore.Instances.splice(a,1)}}},[t]),React.useEffect(()=>{const n=t;if(n)return EngineCore.EngineStore.Instances.push(n),()=>{const a=window.BABYLON.EngineStore.Instances.indexOf(n);a>-1&&window.BABYLON.EngineStore.Instances.splice(a,1)}},[t]),React.useEffect(()=>{const n=e;if(window.BABYLON&&n)return window.BABYLON.EngineStore._LastCreatedScene=e,()=>{window.BABYLON&&window.BABYLON.EngineStore._LastCreatedScene===n&&(window.BABYLON.EngineStore._LastCreatedScene=null)}},[e]),React.useEffect(()=>{const n=e;if(n)return EngineCore.EngineStore._LastCreatedScene=e,()=>{EngineCore.EngineStore._LastCreatedScene===n&&(EngineCore.EngineStore._LastCreatedScene=null)}},[e]),React.useEffect(()=>{e&&(e._forceBlockMaterialDirtyMechanism=a=>{e._blockMaterialDirtyMechanism=a})},[e]),jsxRuntime.jsx(jsxRuntime.Fragment,{})},EngineFixer$1=EngineFixer;class ResourceManager{constructor(){le(this,"urls",[]);le(this,"resources",new Map);le(this,"listeners",new Map);this.urls=[]}addListener(t,n){var a;this.listeners.has(t)?(a=this.listeners.get(t))==null||a.push(n):this.listeners.set(t,[n])}removeListener(t,n){var a,r;if(this.listeners.has(t)){const o=(a=this.listeners.get(t))==null?void 0:a.findIndex(i=>i===n);o!==void 0&&o!==-1&&((r=this.listeners.get(t))==null||r.splice(o,1))}}notifyProgress(t,n){var a;(a=this.listeners.get(t))==null||a.forEach(r=>r.onProgress(n))}notifyComplete(t){var n;(n=this.listeners.get(t))==null||n.forEach(a=>a.onComplete(this.resources.get(t)))}notifyError(t,n){var a;(a=this.listeners.get(t))==null||a.forEach(r=>r.onError(n))}download(t,n="BIN"){if(n==="BIN"){axios.get(t,{responseType:"arraybuffer"}).then(a=>{console.log(a),this.resources.set(t,a.data),this.notifyComplete(t)}).catch(a=>{this.notifyError(t,a)});return}}load(t,n,a){this.urls.findIndex(o=>o===t)===-1?(this.urls.push(t),this.download(t,n),this.addListener(t,a)):this.resources.get(t)?this.notifyComplete(t):this.addListener(t,a)}}const ResourceContext=React.createContext(void 0),useAsset=(e,t="BIN")=>{const n=React.useContext(ResourceContext),[a,r]=React.useState(void 0),o=React.useMemo(()=>{const i={onProgress:function(s){console.log(s)},onComplete:function(s){console.log(e,s),r(s)},onError:function(s){console.log(s),n==null||n.removeListener(e,i)}};return i},[n,e]);return React.useEffect(()=>(n==null||n.load(e,t,o),()=>{n==null||n.removeListener(e,o)}),[o,n,t,e]),a},Geo3DViewer=(e,t)=>{const{children:n,showDebugLayer:a=!1,meta:r,colorProvider:o,cacheProvider:i,options:s={backgroundColor:EngineCore.Color4.FromArray([.2,.2,.3,1]),light:{intensity:1,direction:new EngineCore.Vector3(1,1,1)}}}=e,{light:l={intensity:1,direction:new EngineCore.Vector3(1,1,1)}}=s,{intensity:c=1,direction:f=new EngineCore.Vector3(1,1,1)}=l,u=React.useRef(null),[d,h]=React.useState(!1);return React.useEffect(()=>{console.log(`
|
|
1226
|
+
%c Geo3DViewer Library %c Version: 1.7.32 %c
|
|
1227
|
+
`,"color:#e0e0e0;background:#873e23;padding:5px 0;border-top-left-radius:5px;border-bottom-left-radius:5px;","color:#455a64;background:#e0e0e0;padding:5px 0;","color:#455a64;background:#e0e0e0;padding:5px 0;border-top-right-radius:5px;border-bottom-right-radius:5px;")},[]),React.useImperativeHandle(t,()=>({scene:u,camera:null}),[u]),React.useEffect(()=>{a&&h(!0)},[a]),jsxRuntime.jsx(reactBabylonjs.Engine,{antialias:!0,adaptToDeviceRatio:!0,canvasId:"rootGeo3DCanvas",engineOptions:{useHighPrecisionFloats:!0,depth:!0,useHighPrecisionMatrix:!0,stencil:!0},children:jsxRuntime.jsxs(reactBabylonjs.Scene,{clearColor:s.backgroundColor,useRightHandedSystem:s.useRightHandedSystem,children:[jsxRuntime.jsx(EngineFixer$1,{}),jsxRuntime.jsx("ground",{name:"picking-material-holder",setEnabled:!1,children:jsxRuntime.jsx(PickingMaterial,{})}),jsxRuntime.jsx(ResourceContext.Provider,{value:new ResourceManager,children:jsxRuntime.jsxs(Geo3DProvider$1,{workspaceMeta:r,colorProvider:o,cacheProvider:i,ref:u,children:[d||a?jsxRuntime.jsx(DebugLayer$1,{showDebugLayer:a}):null,jsxRuntime.jsx("hemisphericLight",{name:"light",intensity:c,direction:f}),n]})}),s.environment?jsxRuntime.jsx("cubeTexture",{assignTo:"environmentTexture",rootUrl:s.environment}):jsxRuntime.jsx(jsxRuntime.Fragment,{})]})})},Geo3DViewer$1=React.forwardRef(Geo3DViewer);var GridDiagram_GridDiagramMode=(e=>(e[e.ATTRIBUTE=0]="ATTRIBUTE",e[e.COLOR=1]="COLOR",e[e.STATIC_ATTRIBUTE=2]="STATIC_ATTRIBUTE",e[e.STATIC_COLOR=3]="STATIC_COLOR",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(GridDiagram_GridDiagramMode||{});function gridDiagram_GridDiagramModeFromJSON(e){switch(e){case 0:case"ATTRIBUTE":return 0;case 1:case"COLOR":return 1;case 2:case"STATIC_ATTRIBUTE":return 2;case 3:case"STATIC_COLOR":return 3;case-1:case"UNRECOGNIZED":default:return-1}}function gridDiagram_GridDiagramModeToJSON(e){switch(e){case 0:return"ATTRIBUTE";case 1:return"COLOR";case 2:return"STATIC_ATTRIBUTE";case 3:return"STATIC_COLOR";case-1:default:return"UNRECOGNIZED"}}function createBaseGridDiagram(){return{name:"",step:0,xCount:0,yCount:0,zCount:0,xSliceUrl:"",ySliceUrl:"",zSliceUrl:"",mode:0}}const GridDiagram$2={encode(e,t=minimal.Writer.create()){return e.name!==""&&t.uint32(10).string(e.name),e.step!==0&&t.uint32(16).uint32(e.step),e.xCount!==0&&t.uint32(24).uint32(e.xCount),e.yCount!==0&&t.uint32(32).uint32(e.yCount),e.zCount!==0&&t.uint32(40).uint32(e.zCount),e.xSliceUrl!==""&&t.uint32(50).string(e.xSliceUrl),e.ySliceUrl!==""&&t.uint32(58).string(e.ySliceUrl),e.zSliceUrl!==""&&t.uint32(66).string(e.zSliceUrl),e.mode!==0&&t.uint32(72).int32(e.mode),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseGridDiagram();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==16)break;r.step=n.uint32();continue;case 3:if(o!==24)break;r.xCount=n.uint32();continue;case 4:if(o!==32)break;r.yCount=n.uint32();continue;case 5:if(o!==40)break;r.zCount=n.uint32();continue;case 6:if(o!==50)break;r.xSliceUrl=n.string();continue;case 7:if(o!==58)break;r.ySliceUrl=n.string();continue;case 8:if(o!==66)break;r.zSliceUrl=n.string();continue;case 9:if(o!==72)break;r.mode=n.int32();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$6(e.name)?globalThis.String(e.name):"",step:isSet$6(e.step)?globalThis.Number(e.step):0,xCount:isSet$6(e.xCount)?globalThis.Number(e.xCount):0,yCount:isSet$6(e.yCount)?globalThis.Number(e.yCount):0,zCount:isSet$6(e.zCount)?globalThis.Number(e.zCount):0,xSliceUrl:isSet$6(e.xSliceUrl)?globalThis.String(e.xSliceUrl):"",ySliceUrl:isSet$6(e.ySliceUrl)?globalThis.String(e.ySliceUrl):"",zSliceUrl:isSet$6(e.zSliceUrl)?globalThis.String(e.zSliceUrl):"",mode:isSet$6(e.mode)?gridDiagram_GridDiagramModeFromJSON(e.mode):0}},toJSON(e){const t={};return e.name!==""&&(t.name=e.name),e.step!==0&&(t.step=Math.round(e.step)),e.xCount!==0&&(t.xCount=Math.round(e.xCount)),e.yCount!==0&&(t.yCount=Math.round(e.yCount)),e.zCount!==0&&(t.zCount=Math.round(e.zCount)),e.xSliceUrl!==""&&(t.xSliceUrl=e.xSliceUrl),e.ySliceUrl!==""&&(t.ySliceUrl=e.ySliceUrl),e.zSliceUrl!==""&&(t.zSliceUrl=e.zSliceUrl),e.mode!==0&&(t.mode=gridDiagram_GridDiagramModeToJSON(e.mode)),t},create(e){return GridDiagram$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l,c,f;const t=createBaseGridDiagram();return t.name=(n=e.name)!=null?n:"",t.step=(a=e.step)!=null?a:0,t.xCount=(r=e.xCount)!=null?r:0,t.yCount=(o=e.yCount)!=null?o:0,t.zCount=(i=e.zCount)!=null?i:0,t.xSliceUrl=(s=e.xSliceUrl)!=null?s:"",t.ySliceUrl=(l=e.ySliceUrl)!=null?l:"",t.zSliceUrl=(c=e.zSliceUrl)!=null?c:"",t.mode=(f=e.mode)!=null?f:0,t}};function isSet$6(e){return e!=null}const GridDiagram=({name:e,url:t,step:n,visible:a=!0,colorCodec:r,alpha:o=1,actions:i,materials:s})=>{const[l,c]=React.useState(),[f,u]=React.useState(0),d=useCachedBinary({url:t,cacheType:CacheType.URL_PREFIX_MATCH});return React.useEffect(()=>{console.log("[Geo3DViewer] GriDDiagram Loading: ",t)},[t]),React.useEffect(()=>{if(d){const h=GridDiagram$2.decode(new Uint8Array(d)),{xCount:m,zCount:R,xSliceUrl:v,zSliceUrl:g}=h,x=[];if(h.mode===GridDiagram_GridDiagramMode.ATTRIBUTE||h.mode===GridDiagram_GridDiagramMode.COLOR){if(n<=0){console.error("[Geo3DViewer] 此文件为动态数据文件,step 值必须大于 0"),c([]),u(0);return}let y=0;for(let E=0;E<m;E+=n)x.push(v.replace("%s",E.toString())),y=E;y>=m&&x.push(v.replace("%s",(m-1).toString()));for(let E=0;E<R;E+=n)x.push(g.replace("%s",E.toString())),y=E;y>=R&&x.push(g.replace("%s",(R-1).toString()))}else if(h.mode===GridDiagram_GridDiagramMode.STATIC_ATTRIBUTE||h.mode===GridDiagram_GridDiagramMode.STATIC_COLOR){if(n!==0){console.error("[Geo3DViewer] 静态栅状图数据必须传入 step=0 以确认您明确此数据无法使用动态加载模式"),c([]),u(0);return}for(let y=0;y<m;y+=1)x.push(v.replace("%s",y.toString()))}return c(x),u(h.mode===GridDiagram_GridDiagramMode.ATTRIBUTE?1:h.mode===GridDiagram_GridDiagramMode.COLOR?2:h.mode===GridDiagram_GridDiagramMode.STATIC_ATTRIBUTE?1:h.mode===GridDiagram_GridDiagramMode.STATIC_COLOR?2:0),()=>{c([]),u(0)}}},[d,n]),jsxRuntime.jsx("abstractMesh",{name:`gridDiagram-${e}`,children:f===1?l?l.map((h,m)=>jsxRuntime.jsx(DensitySlice$1,{name:e,url:h,visible:a,colorCodec:r,alpha:o,actions:i},`densityslice-group-${e}-${h}-${m}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}):f===2?l?l.map((h,m)=>jsxRuntime.jsx(FormationSlice$1,{url:h,visible:a,materials:s,actions:i},`formationslice-group-${e}-${h}-${m}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{})})},GridDiagram$1=GridDiagram,IntersectingLine=({name:e,position:t,width:n,height:a,color:r,lineWidth:o,rotation:i,showDebugPlane:s=!1})=>{const l=React.useContext(WorkspaceMetaContext),c=React.useRef(null),f=useIntersectingLineMaterial({name:e,lineColor:r,lineWidth:o});return React.useEffect(()=>{c.current&&(c.current.material=f)},[f]),jsxRuntime.jsxs("transformNode",{name:`intersecting-line-${e}`,position:t.multiply(calcTransformNodeScale(l)),rotation:i||EngineCore.Vector3.Zero(),children:[jsxRuntime.jsx("plane",{name:e,width:n,height:a,isPickable:!1,isBlocker:!1,ref:c}),jsxRuntime.jsx("plane",{name:e,width:n,height:a,isPickable:!1,isBlocker:!1,setEnabled:s,children:jsxRuntime.jsx("standardMaterial",{name:"intersecting-line-material",diffuseColor:EngineCore.Color3.Gray(),backFaceCulling:!1,alpha:.5,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND})})]})},IntersectingLine$1=IntersectingLine,LookAt=e=>{const t=reactBabylonjs.useScene(),{target:n,distance:a}=e;return React.useEffect(()=>{if(t&&t.activeCamera&&n){const r=t.activeCamera;let o=new EngineCore.Vector3(0,0,0);if(typeof n=="string"){const i=t.getMeshById(n);i&&(o=i.getBoundingInfo().boundingBox.center)}else n.position?o=n.getBoundingInfo().boundingBox.center:o=n;if(r instanceof EngineCore.ArcRotateCamera){r.setTarget(o),r.radius=a;return}if(r instanceof EngineCore.FreeCamera){const i=o,s=r.position.clone(),l=a/EngineCore.Vector3.Distance(i,s),f=s.subtract(i).scale(l),u=i.add(f);r.position=u,r.setTarget(o)}return}},[a,t,n]),null},LookAt$1=LookAt,getChildBone=e=>{const t=e.getChildren();return t.length>0?[e,...getChildBone(t[0])]:[e]},ModelLoader=({name:e,url:t,position:n=EngineCore.Vector3.Zero(),rotation:a=EngineCore.Vector3.Zero(),localScale:r=1,visible:o=!0,showPickingBox:i=!1,useGlobalScale:s=!1,actions:l,alpha:c=1,boneRotation:f,pickingBoxScale:u=EngineCore.Vector3.One(),labelStyle:d},h)=>{const m=reactBabylonjs.useScene(),R=useCachedModel({url:t}),v=React.useRef(null),g=React.useRef(null),[x,y]=React.useState(null),[E,k]=React.useState(5),[b,C]=React.useState(5),[_,A]=React.useState(5),[N,S]=React.useState(EngineCore.Vector3.Zero()),[I,O]=React.useState(EngineCore.Vector3.One()),[F,w]=React.useState([]),L=React.useContext(WorkspaceMetaContext),{scaleWithParent:B=!0}=d||{};return React.useEffect(()=>{console.log("[Geo3DViewer] ModelLoader Loading: ",t)},[t]),React.useImperativeHandle(h,()=>g.current,[]),React.useEffect(()=>{if(R){const D=R.instantiateModelsToScene(W=>`${e}-${W}`,!0);return console.log("[Geo3DViewer] ModelLoader 实例化: ",e),y(D),()=>{console.log("[Geo3DViewer] ModelLoader 反实例化: ",e),y(null)}}},[R,e]),React.useEffect(()=>{if(x){const D=x,W=D.skeletons;if(W&&W.length>0){const ee=W[0].bones,H=[];ee.filter(oe=>oe.name==="MorphBoneBase").forEach((oe,te)=>{if(te===0){const K=getChildBone(oe);H.push(...K.map(Z=>{var ce;return(ce=Z.getTransformNode())!=null?ce:Z}))}}),w(H),console.log("[Geo3DViewer] ModelLoader 设定 Morph 骨骼: ",H)}return()=>{console.log("[Geo3DViewer] ModelLoader 注销 Model"),D.dispose(),w([])}}},[x]),React.useEffect(()=>{f&&F&&(console.log("[Geo3DViewer] ModelLoader 设定骨骼旋转"),F.forEach((D,W)=>{f.length>W?D.rotation=f[W]:D.rotation=EngineCore.Vector3.Zero()}),(!f||f.length===0)&&console.log("[Geo3DViewer] ModelLoader 的鼠标拾取功能由于 boneRotation 被禁用"))},[f,F]),React.useEffect(()=>{v.current&&(v.current.metadata={pickable:l?{name:e,onLeftClick:l.onLeftClick,onRightClick:l.onRightClick,onMiddleClick:l.onMiddleClick,onHover:l.onHover,valueCallback:null,extra:l.extra}:null})},[l,e]),React.useEffect(()=>{if(m&&x&&g.current){console.log("[Geo3DViewer] ModelLoader 创建容器: ",e);const D=new EngineCore.TransformNode(`amesh-model-${e}`);D.parent=g.current,x.rootNodes.forEach(K=>{K&&(K.parent=D)}),D.computeWorldMatrix(!0),EngineCore.PivotTools._RemoveAndStorePivotPoint(D);const W=D.parent;D.parent=null;const ae=EngineCore.Quaternion.RotationYawPitchRoll(D.rotation.y,D.rotation.x,D.rotation.z),ee=new EngineCore.Vector3(D.position.x,D.position.y,D.position.z);D.rotation.set(0,0,0),D.position.set(0,0,0);const H=D.getHierarchyBoundingVectors(!0),oe=H.max.subtract(H.min);k(oe.y),C(oe.z),A(oe.x),O(ae.toEulerAngles());const te=new EngineCore.Vector3((H.max.x+H.min.x)/2,(H.max.y+H.min.y)/2,(H.max.z+H.min.z)/2);return S(te),D.position=ee,D.rotationQuaternion=ae,D.parent=W,EngineCore.PivotTools._RestorePivotPoint(D),console.log("[Geo3DViewer] 创建 ModelLoader 鼠标拾取外框 ",e," 于 ",te," 大小为 ",oe.x,oe.y,oe.z),()=>{console.log("[Geo3DViewer] ModelLoader 注销容器: ",e),D.dispose()}}},[x,e,m]),React.useEffect(()=>{x&&x.rootNodes.forEach(D=>{D.getChildMeshes().forEach(W=>{W.material&&(W.material.transparencyMode=EngineCore.Material.MATERIAL_ALPHABLEND,W.material.alpha=c)})})},[x,c]),jsxRuntime.jsx("transformNode",{name:`transform-model-${e}`,position:n,rotation:a,scalingDeterminant:r,setEnabled:o,children:jsxRuntime.jsxs("transformNode",{name:`transform-model-global-${e}`,ref:g,scaling:s?new EngineCore.Vector3(L&&L.scalePlane?L.scalePlane:1,L&&L.scaleDepth?L.scaleDepth:1,L&&L.scalePlane?L.scalePlane:1):new EngineCore.Vector3(1,1,1),children:[d?jsxRuntime.jsx("transformNode",{name:`transform-model-label-${e}`,position:N.add(d!=null&&d.offset?d.offset.multiplyByFloats(L!=null&&L.scalePlane?L==null?void 0:L.scalePlane:1,1,L!=null&&L.scalePlane?L==null?void 0:L.scalePlane:1):EngineCore.Vector3.Zero()),scalingDeterminant:B?r*3:3,children:jsxRuntime.jsx(GUIText$1,{text:d.title,fontSize:d.fontSize?d.fontSize:40,color:d.color?d.color:"white"})}):jsxRuntime.jsx(jsxRuntime.Fragment,{}),jsxRuntime.jsx("box",{name:`pick-mesh-${e}`,ref:v,size:1,scaling:new EngineCore.Vector3(_,E,b).multiply(u),position:N,rotation:I,setEnabled:f?f.length===0:!0,children:jsxRuntime.jsx("standardMaterial",{name:`pick-mesh-${e}-mat`,alpha:i?.5:0})})]})})},ModelLoader$1=React.forwardRef(ModelLoader),ModelAnimationLoader=({name:e,url:t,position:n=EngineCore.Vector3.Zero(),rotation:a=EngineCore.Vector3.Zero(),localScale:r=1,visible:o=!0},i)=>{const s=reactBabylonjs.useScene(),l=useCachedModel({url:t}),c=React.useRef(null),[f,u]=React.useState(null);return React.useEffect(()=>{console.log("[Geo3DViewer] ModelLoader Loading: ",t)},[t]),React.useImperativeHandle(i,()=>c.current,[]),React.useEffect(()=>{if(l){const d=l.instantiateModelsToScene(h=>`${e}-${h}`,!0);return console.log("[Geo3DViewer] ModelLoader 实例化: ",e),u(d),()=>{console.log("[Geo3DViewer] ModelLoader 反实例化: ",e),u(null)}}},[l,e]),React.useEffect(()=>{s&&f&&c.current&&(s.animationGroups.forEach(d=>{console.log("play animtion:"+d.name),d.start(!0)}),f.rootNodes.forEach(d=>{d&&(d.parent=c.current)}))},[f,e,s]),jsxRuntime.jsx("transformNode",{name:`transform-model-${e}`,position:n,rotation:a,scalingDeterminant:r,setEnabled:o,ref:c})},ModleAnimationLoader=React.forwardRef(ModelAnimationLoader),Optimizer=()=>{const e=reactBabylonjs.useScene();return React.useEffect(()=>{if(e){const t=EngineCore.SceneOptimizerOptions.ModerateDegradationAllowed();t.optimizations;const n=new EngineCore.SceneOptimizer(e,t,!0,!0);return n.start(),console.log("[Geo3DViewer] 渐进式优化器已启动,如遭遇技术性渲染问题,请优先尝试禁用此优化器。"),()=>{n.stop(),n.dispose(),console.log("[Geo3DViewer] 渐进式优化器已停止。")}}},[e]),jsxRuntime.jsx(jsxRuntime.Fragment,{})},Optimizer$1=Optimizer,ParticleSystem=e=>{const{name:t,url:n,rootURL:a,doNotStart:r,capacity:o,position:i=new EngineCore.Vector3}=e,s=reactBabylonjs.useScene(),[l,c]=React.useState();return React.useEffect(()=>()=>{l&&l.dispose()},[l]),React.useEffect(()=>{if(s&&!l){const f=new EngineCore.AssetsManager(s),u=f.addTextFileTask(t!=null?t:"particle-system",n);f.load(),f.onFinish=function(d){console.log("task successful",d);const h=JSON.parse(u.text),m=EngineCore.ParticleSystem.Parse(h,s,a,r,o);m.emitter=i,c(m)}}return()=>{l&&(l.dispose(),console.log(t,"effect disposed!"))}},[o,r,t,l,i,a,s,n]),null},ParticleSystem$1=ParticleSystem,WaterEffect=e=>{const{id:t,position:n,useGPU:a=!0,renderAsFluid:r,numParticles:o=1e3,emitRate:i=1500*2,blendMode:s=EngineCore.ParticleSystem.BLENDMODE_ADD,color1:l,color2:c,colorDead:f,minSize:u,maxSize:d,minLifeTime:h,maxLifeTime:m,gravity:R,minEmitPower:v,maxEmitPower:g,updateSpeed:x,textureUrl:y,angle:E=Math.PI/2,radius:k=4,fluidRender:b}=e,C=reactBabylonjs.useScene(),[_,A]=React.useState(),N=React.useRef(null);return React.useEffect(()=>{_&&(_.blendMode=s,l&&(_.color1=l),c&&(_.color2=c),f&&(_.colorDead=f),u!==void 0&&(_.minSize=u),d!==void 0&&(_.maxSize=d),h!==void 0&&(_.minLifeTime=h),m!==void 0&&(_.maxLifeTime=m),v!==void 0&&(_.minEmitPower=v),g!==void 0&&(_.maxEmitPower=g),x!==void 0&&(_.updateSpeed=x),_.preWarmCycles=60*8,R&&(_.gravity=R),_.createConeEmitter(k,E),y&&(_.particleTexture=new EngineCore.Texture(y),_.particleTexture.onLoadObservable.add(()=>{_.start()})))},[E,s,l,c,f,R,g,m,d,v,h,u,_,k,y,x]),React.useEffect(()=>{if(!_&&C)if(a){const S=new EngineCore.GPUParticleSystem("particle-"+t,{capacity:o},C);A(S)}else{const S=new EngineCore.ParticleSystem("particle-"+t,o,C);A(S)}return()=>{console.log("particlesystem disposed!"),N.current&&(N.current.object.particleSize=0)}},[t,o,_,C,a]),React.useEffect(()=>{_&&(C==null||C.executeWhenReady(()=>{var S,I,O;if(C.updateTransformMatrix(!0),_==null||_.render(),r&&_){const F=C.enableFluidRenderer();if(F){F.addParticleSystem(_);const w=F.getRenderObjectFromParticleSystem(_);N.current=w,w&&(w.object.particleSize=(S=b==null?void 0:b.particleSize)!=null?S:.75,w.object.particleThicknessAlpha=.02,w.object.useTrueRenderingForDiffuseTexture=!0,w.targetRenderer.minimumThickness=w.object.particleThicknessAlpha,w.targetRenderer.blurDepthFilterSize=10,w.targetRenderer.blurDepthDepthScale=10,w.targetRenderer.thicknessMapSize=1024,w.targetRenderer.density=(I=b==null?void 0:b.density)!=null?I:8,w.targetRenderer.fresnelClamp=.04,w.targetRenderer.fluidColor=(O=b==null?void 0:b.fluidColor)!=null?O:new EngineCore.Color3(219/255,228/255,1),w.targetRenderer.generateDiffuseTexture=!1)}}}))},[b==null?void 0:b.density,b==null?void 0:b.fluidColor,b==null?void 0:b.particleSize,_,r,C]),React.useEffect(()=>{_&&(_.emitter=n,_.emitRate=i)},[i,_,n]),null},WaterEffect$1=WaterEffect,PlaneImage=(e,t)=>{var b,C,_;const n=reactBabylonjs.useScene(),a=React.useContext(WorkspaceMetaContext),{name:r,width:o,height:i,localScale:s=EngineCore.Vector3.One(),rotation:l=EngineCore.Vector3.Zero(),position:c=EngineCore.Vector3.Zero(),textureUrl:f,videoUrl:u,canvas:d,backFaceCulling:h=!0,billboard:m=!1,actions:R,labelStyle:v}=e,g=useCachedTexture({url:f}),x=React.useRef(null),y=React.useRef(null),[E,k]=React.useState(null);return React.useEffect(()=>{if(u)return k(A=>{A==null||A.dispose();const N=new EngineCore.VideoTexture("video-texture",u,n,!1,!1,void 0,{autoPlay:!0,autoUpdateTexture:!0});return N.hasAlpha=!0,N}),()=>{k(A=>(A==null||A.dispose(),null))}},[u]),React.useEffect(()=>{if(d){const A=new EngineCore.DynamicTexture("dyn-texture",d,n);return A.hasAlpha=!0,x.current=A,()=>{var N;(N=x.current)==null||N.dispose()}}},[d]),React.useEffect(()=>{x.current&&(x.current.name=r)},[r]),React.useImperativeHandle(t,()=>x,[x]),React.useEffect(()=>{var N;const A=(N=y.current)==null?void 0:N.getChildMeshes()[0];A&&(A.metadata={pickable:R?{name:r,onLeftClick:R.onLeftClick,onRightClick:R.onRightClick,onMiddleClick:R.onMiddleClick,onHover:R.onHover,extra:R.extra}:null})},[R,r]),jsxRuntime.jsxs("transformNode",{ref:y,name:`transform-planeimage-${r}`,position:c.multiply(a?new EngineCore.Vector3((b=a.scalePlane)!=null?b:1,(C=a.scaleDepth)!=null?C:1,(_=a.scalePlane)!=null?_:1):EngineCore.Vector3.One()),rotation:m?EngineCore.Vector3.Zero():l,billboardMode:m?EngineCore.Mesh.BILLBOARDMODE_ALL:EngineCore.Mesh.BILLBOARDMODE_NONE,children:[jsxRuntime.jsx("plane",{name:`plane-planeimage-${r}`,width:o,height:i,scaling:s,children:jsxRuntime.jsx("standardMaterial",{name:`plane-planeimage-${r}`,emissiveColor:EngineCore.Color3.White(),specularColor:EngineCore.Color3.Black(),diffuseTexture:x.current?x.current:E||g,useAlphaFromDiffuseTexture:!0,backFaceCulling:h,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND})}),v&&jsxRuntime.jsx(GUIText$1,{...v})]})},PlaneImage$1=React.forwardRef(PlaneImage);var PointClickZoneObjectType=(e=>(e[e.TETRAHEDRON=0]="TETRAHEDRON",e[e.OCTAHEDRON=1]="OCTAHEDRON",e[e.DODECAHEDRON=2]="DODECAHEDRON",e[e.ICOSAHEDRON=3]="ICOSAHEDRON",e[e.RHOMBICUBOCTAHEDRON=4]="RHOMBICUBOCTAHEDRON",e))(PointClickZoneObjectType||{});const PointClickZone=({size:e,alpha:t=1,position:n,visible:a,objectType:r,title:o,actions:i,labelStyle:s,color:l,scaleMode:c})=>{const f=React.useRef(null),u=React.useContext(WorkspaceMetaContext);React.useEffect(()=>{f.current&&(f.current.metadata={pickable:i?{name:o,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null})},[i,o]);const[d,h]=React.useState(1);return React.useEffect(()=>{switch(c){case ScaleMode.PLANE:h(u&&u.scalePlane?u.scalePlane:1);break;case ScaleMode.DEPTH:h(u&&u.scaleDepth?u.scaleDepth:1);break;case ScaleMode.NONE:h(1);break}},[u,c]),jsxRuntime.jsxs("transformNode",{setEnabled:a,name:`transform-spaceheat-${o}`,position:n.multiplyByFloats(u&&u.scalePlane?u.scalePlane:1,u&&u.scaleDepth?u.scaleDepth:1,u&&u.scalePlane?u.scalePlane:1),scalingDeterminant:d,children:[jsxRuntime.jsx("polyhedron",{ref:f,name:`point-${o}`,type:r,size:e,children:jsxRuntime.jsx("standardMaterial",{name:`point-${o}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),emissiveColor:EngineCore.Color3.Black(),alphaMode:EngineCore.Engine.ALPHA_COMBINE,diffuseColor:l,alpha:t})}),jsxRuntime.jsx("transformNode",{name:`${o}-title`,position:s!=null&&s.offset?s.offset.multiplyByFloats(u!=null&&u.scalePlane?u==null?void 0:u.scalePlane:1,1,u!=null&&u.scalePlane?u==null?void 0:u.scalePlane:1):EngineCore.Vector3.Zero(),scaling:calcGUIScale(u).multiply(new EngineCore.Vector3(3,3,3)),children:jsxRuntime.jsx(GUIText$1,{text:o,fontSize:s!=null&&s.fontSize?s.fontSize:10,color:s!=null&&s.color?s.color:"white"})})]})},PointClickZone$1=PointClickZone,ProgressedAttributeBody=({name:e,url:t,offset:n=EngineCore.Vector3.Zero(),alpha:a,color:r,visible:o=!0,cutNormal:i,value:s,actions:l,textureOverride:c,progressTexture:f={},counterLine:u=void 0,lines:d=[],text:h=[],disableDepthWrite:m=!1,checkLines:R=[],checkLineWidth:v=4})=>{var te,K,Z,ce,Q,G,ge,fe,V,J,Re,Ce,Y,ue,ne,de,_e,ye,Te;const g=reactBabylonjs.useScene(),x=React.useRef(null),y=React.useContext(WorkspaceMetaContext),E=useCachedBinary({url:t,cacheType:CacheType.URL_PREFIX_MATCH}),[k,b]=React.useState(EngineCore.Vector3.Zero()),[C,_]=React.useState(void 0),A=useCachedTexture({url:c==null?void 0:c.texture,cacheType:CacheType.URL_PREFIX_MATCH}),N=useCachedTexture({url:c==null?void 0:c.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),S=useCachedTexture({url:(te=f.segment1)==null?void 0:te.texture,cacheType:CacheType.URL_PREFIX_MATCH}),I=useCachedTexture({url:(K=f.segment1)==null?void 0:K.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),O=useCachedTexture({url:(Z=f.segment2)==null?void 0:Z.texture,cacheType:CacheType.URL_PREFIX_MATCH}),F=useCachedTexture({url:(ce=f.segment2)==null?void 0:ce.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),w=useCachedTexture({url:(Q=f.segment3)==null?void 0:Q.texture,cacheType:CacheType.URL_PREFIX_MATCH}),L=useCachedTexture({url:(G=f.segment3)==null?void 0:G.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),B=useCachedTexture({url:(ge=f.segment4)==null?void 0:ge.texture,cacheType:CacheType.URL_PREFIX_MATCH}),D=useCachedTexture({url:(fe=f.segment4)==null?void 0:fe.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),W=useCachedTexture({url:(V=f.segment5)==null?void 0:V.texture,cacheType:CacheType.URL_PREFIX_MATCH}),ae=useCachedTexture({url:(J=f.segment5)==null?void 0:J.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH}),ee=useCachedTexture({url:(Re=f.segment6)==null?void 0:Re.texture,cacheType:CacheType.URL_PREFIX_MATCH}),H=useCachedTexture({url:(Ce=f.segment6)==null?void 0:Ce.sideTexture,cacheType:CacheType.URL_PREFIX_MATCH});React.useEffect(()=>{console.log("[Geo3DViewer] ProgressedAttributeBody Loading: ",t)},[t]),React.useEffect(()=>{if(g&&x.current&&t&&E){const Ee=x.current;EngineCore.Tags.EnableFor(Ee),EngineCore.Tags.AddTagsTo(Ee,"loading");const Se=VirtualVolume.decode(new Uint8Array(E)),{points:be,indices:Ae,value:Ie,center:Pe}=Se;Pe&&b(new EngineCore.Vector3(Pe.x,Pe.y,Pe.z));const Oe=new EngineCore.VertexData;Oe.positions=be,Oe.indices=Ae,Oe.colors=Ie;const Fe=[];EngineCore.VertexData.ComputeNormals(be,Ae,Fe),Oe.normals=Fe,Ee&&(Oe.applyToMesh(Ee),Ee.getScene().onAfterRenderObservable.addOnce(()=>{if(!Ee.isDisposed()){const re=Ee.getBoundingInfo();_(re.boundingBox)}})),EngineCore.Tags.RemoveTagsFrom(Ee,"loading")}},[t,g,E]);function oe(Ee,Se,be){const Ae=be.subtract(Se),Ie=Ee.subtract(Se),Pe=EngineCore.Vector3.Dot(EngineCore.Vector3.Normalize(Ae),EngineCore.Vector3.Normalize(Ie)),Oe=Ie.length()/Pe,Fe=Se.add(Ae.scale(Oe/EngineCore.Vector3.Distance(Se,be)));return EngineCore.Vector3.Distance(Ee,Fe)}return React.useEffect(()=>{x.current&&(x.current.metadata={pickable:l?{name:e,valueCallback:(Ee,Se,be)=>{if(console.log(e,Ee,Se,be),x.current&&Se){const Ae=x.current.getBoundingInfo().boundingBox;console.log(Ae);for(let Ie=0;Ie<R.length;Ie++){const Pe=R[Ie];if(oe(new EngineCore.Vector3(Se.x,0,Se.z),Pe.start,Pe.end)<v){const Fe=[];for(let M=0;M<11;M++){const re=Pe.end.subtract(Pe.start),se=Pe.start.add(re.scale(M/10)),me=new EngineCore.Vector3(se.x,Se.y+Ae.extendSize.y*4,se.z),z=new EngineCore.Vector3(se.x,Se.y+Ae.extendSize.y*2,se.z),X=EngineCore.Vector3.Normalize(z.subtract(me)),T=Ae.extendSize.y*10,ie=new EngineCore.Ray(me,X,T),xe=g==null?void 0:g.pickWithRay(ie,p=>p===x.current);xe!=null&&xe.hit&&xe.pickedPoint&&Fe.push(xe.pickedPoint)}for(let M=0;M<11;M++){const re=Pe.end.subtract(Pe.start),se=Pe.start.add(re.scale(M/10)),me=new EngineCore.Vector3(se.x,Se.y-Ae.extendSize.y*4,se.z),z=new EngineCore.Vector3(se.x,Se.y-Ae.extendSize.y*2,se.z),X=EngineCore.Vector3.Normalize(z.subtract(me)),T=Ae.extendSize.y*10,ie=new EngineCore.Ray(me,X,T),xe=g==null?void 0:g.pickWithRay(ie,p=>p===x.current);xe!=null&&xe.hit&&xe.pickedPoint&&Fe.push(xe.pickedPoint)}return{value:Ie,points:Fe}}}}},onLeftClick:l.onLeftClick,onRightClick:l.onRightClick,onMiddleClick:l.onMiddleClick,onHover:l.onHover,extra:l.extra}:null})},[l,e,R]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`transform-progressedattribute-${e}`,position:k.add(n).multiplyByFloats(y&&y.scalePlane?y.scalePlane:1,y&&y.scaleDepth?y.scaleDepth:1,y&&y.scalePlane?y.scalePlane:1),scaling:new EngineCore.Vector3(y?y.scalePlane:1,y?y.scaleDepth:1,y?y.scalePlane:1),children:jsxRuntime.jsx("mesh",{name:`attributebody-${e}-mesh`,ref:x,setEnabled:o,useVertexColors:!A,alwaysSelectAsActiveMesh:!0,children:C&&origin?A?jsxRuntime.jsx(ProgressedRepeatedTextureMaterial,{name:`progressedattributebody-${e}-mat`,backFaceCulling:!0,needDepthPrePass:!1,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,texture:A,sideTexture:N,alphaStage:a,cutNormal:i,value:s,boundingBox:C,tilingFactor:c==null?void 0:c.tilingFactor,textureFlatRotate:c==null?void 0:c.flatModeRotate,sideTilingFactor:(Y=c==null?void 0:c.sideTilingFactor)!=null?Y:c==null?void 0:c.tilingFactor,mode:c==null?void 0:c.mode,overlay:{texture1:S,sideTexture1:I,texture2:O,sideTexture2:F,texture3:w,sideTexture3:L,texture4:B,sideTexture4:D,texture5:W,sideTexture5:ae,texture6:ee,sideTexture6:H,color1:(ue=f.segment1)==null?void 0:ue.color,color2:(ne=f.segment2)==null?void 0:ne.color,color3:(de=f.segment3)==null?void 0:de.color,color4:(_e=f.segment4)==null?void 0:_e.color,color5:(ye=f.segment5)==null?void 0:ye.color,color6:(Te=f.segment6)==null?void 0:Te.color},scaleDepth:y?y.scaleDepth:1,scalePlane:y?y.scalePlane:1,counterLine:u,lines:d,text:h,disableDepthWrite:m}):r?jsxRuntime.jsx(ProgressedRemapColorByRedChannelMaterial,{name:`progressedattributebody-${e}-mat`,backFaceCulling:!0,needDepthPrePass:!1,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,alphaMode:EngineCore.Engine.ALPHA_COMBINE,colorCodec:r,alphaStage:a,cutNormal:i,value:s,boundingBox:C,scaleDepth:y?y.scaleDepth:1,scalePlane:y?y.scalePlane:1,counterLine:u,lines:d,text:h,disableDepthWrite:m}):jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{})})})})},ProgressedAttributeBody$1=ProgressedAttributeBody,RayClick=({onPick:e,pickAll:t=!1})=>{const n=reactBabylonjs.useScene(),a=React.useContext(WorkspaceMetaContext),r=React.useRef(null),o=React.useRef([]),i=React.useRef(!1),s=React.useCallback(d=>{if(!d){e(null);return}let h=1,m=1;a&&(a.scalePlane&&(h=a.scalePlane),a.scaleDepth&&(m=a.scaleDepth)),e(new EngineCore.Vector3(d.x/h,d.y/m,d.z/h))},[a,e]),l=React.useCallback(()=>{if(!n)return[];const d=n.meshes.filter(m=>!!m&&!m.isDisposed()&&m.isPickable&&m.isVisible&&m.isEnabled()&&m.isReady(!0)),h=d.length!==o.current.length||d.some((m,R)=>o.current[R]!==m);return r.current||(r.current=new gpuPicker.GPUPicker),h&&(r.current.setPickingList(d.length>0?d.slice():null),o.current=d),d},[n]),c=React.useCallback(async()=>{if(!n||i.current||n.skipPointerMovePicking)return;if(!l().length||!r.current){e(null);return}i.current=!0;try{const h=await r.current.pickAsync(n.pointerX,n.pointerY,!1),m=h==null?void 0:h.mesh;if(!m){e(null);return}const R=n.pick(n.pointerX,n.pointerY,v=>v.uniqueId===m.uniqueId,!1,void 0);if(!(R!=null&&R.pickedPoint)){e(null);return}s(R.pickedPoint)}finally{i.current=!1}},[s,e,n,l]),f=React.useCallback(()=>{var h;if(!n||n.skipPointerMovePicking)return;const d=n.pick(n.pointerX,n.pointerY,void 0,!1,void 0);s((h=d==null?void 0:d.pickedPoint)!=null?h:null)},[s,n]),u=React.useCallback(d=>{switch(d.type){case EngineCore.PointerEventTypes.POINTERUP:{t?f():c();break}}},[t,f,c]);return React.useEffect(()=>{if(n){const d=n.onPointerObservable.add(u);return()=>{n.onPointerObservable.remove(d)}}},[u,n]),React.useEffect(()=>()=>{var d;(d=r.current)==null||d.dispose(),r.current=null,o.current=[],i.current=!1},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{})},RayClick$1=RayClick,RibbonLayer=({name:e,paths:t,color:n,alpha:a,sideOrientation:r=MaterialSideOrientation.CounterClockWiseSideOrientation,position:o=EngineCore.Vector3.Zero(),rotation:i=EngineCore.Vector3.Zero(),scaling:s=EngineCore.Vector3.One(),backFaceCulling:l=!1,labelStyle:c,showLayerLabel:f=!1,actions:u})=>{const d=React.useContext(WorkspaceMetaContext),h=calcTransformNodeScale(d),m=React.useRef(null),[R,v]=React.useState();return React.useEffect(()=>{if(m.current){const g=m.current.getBoundingInfo();v(g.boundingBox.centerWorld)}},[t,o,i,s]),React.useEffect(()=>{m.current&&(m.current.metadata={pickable:u?{name:e,onLeftClick:u.onLeftClick,onRightClick:u.onRightClick,onMiddleClick:u.onMiddleClick,onHover:u.onHover,extra:u.extra}:null})},[u,e]),jsxRuntime.jsxs("transformNode",{name:`${e}-transform`,position:o.multiply(h),rotation:i,scaling:s.multiply(h),children:[jsxRuntime.jsx("ribbon",{name:`${e}-transform`,pathArray:t,updatable:!0,ref:m,sideOrientation:r,children:jsxRuntime.jsx("standardMaterial",{name:`${e}-material`,diffuseColor:n,alpha:a,specularColor:EngineCore.Color3.Black(),ambientColor:EngineCore.Color3.White(),transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,backFaceCulling:l})}),e&&R&&jsxRuntime.jsx("transformNode",{name:`${e}-title`,position:R.add(c!=null&&c.offset?c.offset.multiplyByFloats(d!=null&&d.scalePlane?d==null?void 0:d.scalePlane:1,1,d!=null&&d.scalePlane?d==null?void 0:d.scalePlane:1):EngineCore.Vector3.Zero()),scaling:calcGUIScale(d).multiply(new EngineCore.Vector3(3,3,3)),setEnabled:f,children:jsxRuntime.jsx(GUIText$1,{text:e,fontSize:c!=null&&c.fontSize?c.fontSize:40,color:c!=null&&c.color?c.color:"white"})})]})},RibbonLayer$1=RibbonLayer,percentFragmentSource=`#ifdef GL_ES
|
|
1228
1228
|
precision highp float;
|
|
1229
1229
|
#endif
|
|
1230
1230
|
|
|
@@ -1292,7 +1292,7 @@ void main(void) {
|
|
|
1292
1292
|
vPosition = vec3(world * vec4(position, 1.0));
|
|
1293
1293
|
//vNormal = normalize(mat3(world) * normal);
|
|
1294
1294
|
|
|
1295
|
-
}`,PercentMaterial=e=>{const t=React.useRef(null),{startPercent:n,endPercent:a,backgroundColor:r,color:o,zOffset:i,zOffsetUnits:s,start:l,end:c}=e;return React.useEffect(()=>{t.current&&(t.current.setColor3("color",o),t.current.setColor3("backgroundColor",r||EngineCore.Color3.Black()),t.current.setFloat("discardFragment",r?0:1),t.current.setFloat("startPercent",n),t.current.setFloat("endPercent",a),t.current.setVector3("start",l),t.current.setVector3("end",c),i!==void 0&&s!==void 0&&(t.current.zOffset=i,t.current.zOffsetUnits=s))},[r,o,c,a,l,n,i,s]),jsxRuntime.jsx(CustomShader$1,{ref:t,name:e.name,backFaceCulling:e.backFaceCulling,needDepthPrePass:e.needDepthPrePass,vertex:percentVertexSource,fragment:percentFragmentSource,transparencyMode:e.transparencyMode,alphaMode:e.alphaMode,options:{attributes:["position","normal"],uniforms:["world","worldViewProjection","color1","color2","start","end","startPercent","endPercent"],needAlphaBlending:!1},zOffset:e.zOffset,zOffsetUnits:e.zOffsetUnits,sideOrientation:EngineCore.Material.CounterClockWiseSideOrientation})},PercentMaterial$1=PercentMaterial,usePick=(e,t)=>{React.useEffect(()=>{e.current&&(e.current.metadata={pickable:t})},[t,e])},RoadWayComponent=(e,t)=>{const n=reactBabylonjs.useScene(),a=React.useRef(null),r=React.useRef(null),o=React.useContext(WorkspaceMetaContext),{id:i,visible:s=!0,vertices:l,indices:c,colors:f,backgroundColor:u,color:d,start:h=new EngineCore.Vector3,end:m=new EngineCore.Vector3,percent:R,position:v,materialType:g="custom",children:x,alphaBlend:y=!1,alpha:E=1,name:k="roadway",actions:b,gpuPick:C=!0}=e;React.useImperativeHandle(t,()=>r.current,[]),React.useEffect(()=>{if(a&&a.current&&n){const A=new EngineCore.VertexData;A.positions=l,A.indices=c,f&&g!=="pbr-dark"&&g!=="pbr-light"&&(A.colors=f),A.applyToMesh(a.current)}},[c,l,n,f,i,g]),usePick(a,b&&C?{onLeftClick:b.onLeftClick,onRightClick:b.onRightClick,onMiddleClick:b.onMiddleClick,onHover:b.onHover,extra:""}:void 0);const _=React.useCallback(()=>{if(g==="custom")return jsxRuntime.jsx(CustomShader$1,{name:`${k}-material-${i}`,vertex:flatVertexSource,fragment:flatFragmentSource,needDepthPrePass:!1,transparencyMode:y?EngineCore.Material.MATERIAL_ALPHABLEND:EngineCore.Material.MATERIAL_OPAQUE,options:{needAlphaBlending:!!y}});if(g==="percent")return jsxRuntime.jsx(PercentMaterial$1,{name:`${k}-percentmaterial-${i}`,backgroundColor:u,color:d!=null?d:EngineCore.Color3.Black(),startPercent:R?R[0]:1,endPercent:R?R[1]:1,zOffset:-2,zOffsetUnits:-10,start:h,end:m});if(g==="standard")return jsxRuntime.jsx("standardMaterial",{name:`${k}-material`,alphaMode:EngineCore.Engine.ALPHA_COMBINE,transparencyMode:y?EngineCore.Material.MATERIAL_ALPHABLEND:EngineCore.Material.MATERIAL_OPAQUE,alpha:E});if(g==="pbr-light")return jsxRuntime.jsx(LightMetalMaterial,{alpha:E});if(g==="pbr-dark")return jsxRuntime.jsx(DarkMetalMaterial,{alpha:E})},[E,y,u,d,m,i,g,k,R,h]);return jsxRuntime.jsxs("transformNode",{name:`node-${k}-${i}`,setEnabled:s,children:[jsxRuntime.jsxs("transformNode",{name:`${k}`,position:v?v.multiply(calcTransformNodeScale(o)):new EngineCore.Vector3(0,0,0),scaling:calcTransformNodeScale(o),ref:r,children:[jsxRuntime.jsx("mesh",{name:`roadway-${i}-mesh`,ref:a,isPickable:!0,children:_()}),jsxRuntime.jsx("transformNode",{name:`${k}-title`,position:e.style.position?e.style.position:new EngineCore.Vector3(0,0,0),scaling:calcGUIScale(o),children:e.style.title&&jsxRuntime.jsx(GUIText$1,{text:e.style.title,fontSize:e.style.fontSize?e.style.fontSize:40,color:e.style.color?e.style.color:"black"})})]}),x]})},RoadWayComponent$1=React.forwardRef(RoadWayComponent),RoadWay=e=>{const[t,n]=React.useState({top:{vertices:[],indices:[],colors:[]},side:{vertices:[],indices:[],colors:[]},bottom:{vertices:[],indices:[],colors:[]}}),a=reactBabylonjs.useScene(),[r,o]=React.useState(new EngineCore.Vector3(0,0,0)),i=React.useRef(!1),[s,l]=React.useState([]),[c,f]=React.useState(""),{id:u,url:d,visible:h=!0,offset:m=new EngineCore.Vector3(0,0,0),children:R,actions:v,rayPick:g,showRoadwayWall:x={top:!0,bottom:!0,side:!0},roadwayName:y={nameList:[],offset:new EngineCore.Vector3(0,0,0)}}=e,{top:E=!0,bottom:k=!0,side:b=!0}=x,C=useAsset(d);return React.useEffect(()=>{if(C&&!i.current){i.current=!0;const _=RoadWay$2.decode(new Uint8Array(C));console.log(_),f(_.name);const{boxes:A}=_,N=[],S=[],I=[],O=[],F=[],L=[],w=[],B=[],D=[];let W=0,ae=0,ne=0;const U=_.position?new EngineCore.Vector3(_.position.x,_.position.y,_.position.z):new EngineCore.Vector3(0,0,0);return A.forEach(re=>{var ge,fe,V,J,Ce,Y;const{topMesh:te,bottomMesh:K,sideMesh:Z}=re;let de=0;te&&te.vertices&&te.indices&&te.colors&&(N.push(...te.vertices),S.push(...te.indices.map(se=>se+W)),I.push(...te.colors),de=Math.max(...te.indices)),W+=de+1;let ee=0;Z&&Z.vertices&&Z.indices&&Z.colors&&(O.push(...Z.vertices),F.push(...Z.indices.map(se=>se+ae)),L.push(...Z.colors),ee=Math.max(...Z.indices)),ae+=ee+1;let G=0;if(K&&K.vertices&&K.indices&&K.colors&&(w.push(...K.vertices),B.push(...K.indices.map(se=>se+ne)),D.push(...K.colors),G=Math.max(...K.indices)),ne+=G+1,(y==null?void 0:y.nameList.length)>0&&re.name&&y.nameList.includes(re.name)){const se=new EngineCore.Vector3((ge=re.startPosition)==null?void 0:ge.x,(fe=re.startPosition)==null?void 0:fe.y,(V=re.startPosition)==null?void 0:V.z),ce=new EngineCore.Vector3((J=re.endPosition)==null?void 0:J.x,(Ce=re.endPosition)==null?void 0:Ce.y,(Y=re.endPosition)==null?void 0:Y.z),Q=se.add(ce).scale(.5);l(ye=>[...ye,{name:re.name,position:Q}])}}),n({top:{vertices:N,indices:S,colors:I},side:{vertices:O,indices:F,colors:L},bottom:{vertices:w,indices:B,colors:D}}),o(U),()=>{i.current=!1,n({top:{vertices:[],indices:[],colors:[]},side:{vertices:[],indices:[],colors:[]},bottom:{vertices:[],indices:[],colors:[]}}),o(new EngineCore.Vector3(0,0,0))}}},[C]),React.useEffect(()=>{const _=a==null?void 0:a.onPointerObservable.add(function(A){if(g)switch(A.type){case EngineCore.PointerEventTypes.POINTERUP:const N=a.pick(a.pointerX,a.pointerY);if(N.hit){const S=N.pickedMesh;(S==null?void 0:S.name)===`roadway-${u}-mesh`&&v!=null&&v.onLeftClick&&v.onLeftClick(S.name,void 0,N.pickedPoint)}break}});return()=>{a==null||a.onPointerObservable.remove(_)}},[v,u,c,g,a]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t.top.vertices.length>0&&t.top.indices.length>0&&jsxRuntime.jsx(RoadWayComponent$1,{id:u,name:c,visible:h&&E,vertices:t.top.vertices,indices:t.top.indices,position:r.add(m),colors:t.top.colors.length>0?t.top.colors:void 0,style:{},actions:v,materialType:"standard",gpuPick:!g,children:R}),t.side.vertices.length>0&&t.side.indices.length>0&&jsxRuntime.jsx(RoadWayComponent$1,{id:u,name:c,visible:h&&b,vertices:t.side.vertices,indices:t.side.indices,position:r.add(m),colors:t.side.colors.length>0?t.side.colors:void 0,style:{},actions:v,materialType:"standard",gpuPick:!g,children:R}),t.bottom.vertices.length>0&&t.bottom.indices.length>0&&jsxRuntime.jsx(RoadWayComponent$1,{id:u,name:c,visible:h&&k,vertices:t.bottom.vertices,indices:t.bottom.indices,position:r.add(m),colors:t.bottom.colors.length>0?t.bottom.colors:void 0,style:{},actions:v,gpuPick:!g,materialType:"standard",children:R}),s.map((_,A)=>jsxRuntime.jsxs("transformNode",{name:`roadway-name-${_.name}-${A}-root`,children:[jsxRuntime.jsx("transformNode",{name:`roadway-name-${_.name}-${A}`,position:_.position.add(m).add((y==null?void 0:y.offset)||new EngineCore.Vector3(0,0,0)),billboardMode:EngineCore.Mesh.BILLBOARDMODE_ALL,children:jsxRuntime.jsx(GUIText$1,{text:_.name,fontSize:(y==null?void 0:y.fontSize)||18,color:(y==null?void 0:y.color)||"#FFFFFF"})},A),y.offset&&y.offset.y!==0?jsxRuntime.jsx("lineSystem",{name:`roadway-name-${_.name}-${A}-line`,lines:[[_.position,_.position.add(y.offset)]],color:EngineCore.Color3.White()}):null]}))]})},RoadWay$1=RoadWay,RoadWayAnimationNode=e=>{const{id:t,node:n}=e,[a,r]=React.useState([]),[o,i]=React.useState([]),s=(c,f)=>{const u=[];let d=0;for(const[h,m]of c){let R=h;for(;d<f.length&&f[d][1]<=h;)d++;for(;d<f.length&&f[d][0]<m&&(f[d][0]>R&&u.push([R,f[d][0]]),R=Math.max(R,f[d][1]),!(f[d][1]>=m));)d++;R<m&&u.push([R,m])}return u};React.useEffect(()=>{if(n.range){const c=[],f=[];let u=[];const d=n,h=[],m=[];switch(n.type){case"run":c.push(l(n.percent[0].start,n.percent[0].end)),f.push(n.colors[0]);break;default:for(let R=0;R<n.percent.length;R++){const v=l(n.percent[R].start,n.percent[R].end);v[0]!==v[1]&&h.push(v)}for(let R=0;R<d.colorPercent.length;R++){const v=l(d.colorPercent[R].start,d.colorPercent[R].end);v[0]!==v[1]&&(m.push(v),c.push([v[0],v[1]]),f.push(n.colors[1]))}u=s(h,m),u.forEach(R=>{c.push(R),f.push(n.colors[0])})}r(c),i(f)}},[n,n.colors,n.percent,n.range,n.type]);const l=(c,f)=>c>f?[f,c]:[c,f];return jsxRuntime.jsx("transformNode",{name:`animation-node-${n.name}`,children:a.map((c,f)=>jsxRuntime.jsx("transformNode",{name:`child-${f}`,children:c[0]>=0&&c[1]>=0&&n.meshs&&n.meshs.map((u,d)=>c[0]===c[1]?null:jsxRuntime.jsx(RoadWayComponent$1,{id:t,visible:!0,vertices:u.vertices,indices:u.indices,position:new EngineCore.Vector3(0,0,0),color:o[f],percent:c,start:n.start,end:n.end,style:{},materialType:"percent"},d))},f))})},RoadWayAnimationNode$1=RoadWayAnimationNode,RoadWayAnimation=e=>{const{nodes:t}=e,n=React.useRef(null),a=React.useRef([]),[r,o]=React.useState(),i=s=>{const l=[];for(let f=0;f<s.length;f++)l.push(s[f].start),l.push(s[f].end);const c=l.sort((f,u)=>f-u);return c[0]===0&&c[3]===1&&c[1]===c[2]};return React.useEffect(()=>{const s=setInterval(()=>{n.current||(n.current={vertices:[],indices:[],colors:[],normals:[],uv:[]});let l=n.current.indices.length>0?Math.max(...n.current.indices)+1:0;t==null||t.map(c=>{if(c instanceof AnimationRoadWayWaterNode){const f=c.colorPercent;a.current.findIndex(d=>d===c.name)===-1&&c.meshs&&i(f)&&(a.current.push(c.name),c.meshs.forEach(d=>{var m,R;let h=0;d.vertices&&d.indices&&((m=n.current)==null||m.vertices.push(...d.vertices),(R=n.current)==null||R.indices.push(...d.indices.map(v=>v+l)),h=Math.max(...d.indices)),l+=h+1}))}}),o({vertices:[...n.current.vertices],indices:[...n.current.indices],colors:[],normals:[],uv:[]})},3e4);return()=>{clearInterval(s)}},[t]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t&&t.map((s,l)=>a.current.find(f=>f===s.name)?null:jsxRuntime.jsx(RoadWayAnimationNode$1,{id:l,node:s},s.name)),t&&r&&r.vertices.length>0&&jsxRuntime.jsx(RoadWayComponent$1,{id:0,name:"animation-merged-mesh",visible:!0,vertices:r.vertices,indices:r.indices,position:new EngineCore.Vector3(0,0,0),color:t[0].colors[1],percent:[0,1],start:t[0].start,end:t[0].end,style:{},materialType:"percent"})]})},RoadWayAnimation$1=RoadWayAnimation,BlinkMaterial=e=>{const{url:t,zOffset:n,zOffsetUnits:a,uScale:r,vScale:o,isBlink:i}=e,[s,l]=React.useState(),[c,f]=React.useState(1);return React.useEffect(()=>{const u=new EngineCore.Texture(t);u.hasAlpha=!0,u.uScale=r,u.vScale=o,l(u)},[t,r,o]),React.useEffect(()=>{const u=setInterval(()=>{i&&f(d=>d===0?1:0)},1e3);return()=>{clearInterval(u)}},[i]),jsxRuntime.jsx("standardMaterial",{name:e.name,backFaceCulling:e.backFaceCulling,needDepthPrePass:e.needDepthPrePass,transparencyMode:e.transparencyMode,alphaMode:e.alphaMode,alpha:c,diffuseTexture:s,emissiveTexture:s,useAlphaFromDiffuseTexture:!0,disableLighting:!0,zOffset:n,zOffsetUnits:a,sideOrientation:EngineCore.Material.CounterClockWiseSideOrientation})},BlinkMaterial$1=BlinkMaterial,RoadWayNearAnimationNode=e=>{const{node:t,roadwayWidth:n,textureLength:a,url:r,visible:o=!0,isBlink:i=!0}=e,[s,l]=React.useState(),c=React.useRef(null),[f,u]=React.useState(),[d,h]=React.useState(!1),[m,R]=React.useState(1),v=(g,x,y,E)=>{const b=EngineCore.Vector3.Distance(g,x)/E,C=EngineCore.Vector3.Distance(g,y),_=Math.floor(C/b);return Math.min(_,E-1)};return React.useEffect(()=>{if(t.start&&t.end&&t.current){const g=EngineCore.Vector3.Distance(t.start,t.end),x=Math.floor(g/a),y=v(t.start,t.end,t.current,x);if(t.end.equals(t.current)){l(0);return}l(x-y),R((x-y)/x)}},[t,t.end,t.start,a]),React.useEffect(()=>{if(t.end===t.current){u(void 0);return}if(t.start&&t.end&&t.current){const g=EngineCore.Vector3.Lerp(t.start,t.end,.5+(1-m)/2);u(g)}},[t,m]),React.useEffect(()=>{c.current&&t.end&&(c.current.lookAt(t.end),c.current.rotation.x=Math.PI/2+c.current.rotation.x,c.current.rotation.z=Math.PI/2,h(!0))},[t.end]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:f&&s&&t.start&&t.end&&jsxRuntime.jsx("plane",{name:`${t.name}-mesh`,width:EngineCore.Vector3.Distance(t.start,t.end),height:n,ref:c,position:f,setEnabled:d&&o,scaling:new EngineCore.Vector3(m,1,1),children:jsxRuntime.jsx(BlinkMaterial$1,{name:t.name,alphaMode:EngineCore.Engine.ALPHA_COMBINE,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,url:r,uScale:s,vScale:1,zOffset:-10,zOffsetUnits:-10,isBlink:i})})})},RoadWayNearAnimationNode$1=RoadWayNearAnimationNode,RoadWayNearAnimation=e=>{const{nodes:t,roadwayWidth:n=2,textureLength:a=4,url:r,visible:o=!0,isBlink:i=!0}=e;return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t&&t.map((s,l)=>{const c=s;return jsxRuntime.jsx(RoadWayNearAnimationNode$1,{node:c,roadwayWidth:n,textureLength:a,url:r,visible:o,isBlink:i},l)})})},RoadWayNearAnimation$1=RoadWayNearAnimation;class AnimationClipPlaneHelper{constructor(t,n,a){ue(this,"sourceVertex");ue(this,"targetVertex");ue(this,"meshCurrent");ue(this,"_influence",0);this.sourceVertex=t,this.targetVertex=n,this.meshCurrent=a}set influence(t){this.meshCurrent.updateMeshPositions(n=>{this.sourceVertex.length!==this.targetVertex.length&&console.log("[Geo3DViewer] 近景水模拟顶点数量不一致");for(let a=0;a<n.length;a++)n[a]=this.sourceVertex[a]+(this.targetVertex[a]-this.sourceVertex[a])*t}),this._influence=t}get influence(){return this._influence}}const RoadWayWaterEffectComponent=({position:e=EngineCore.Vector3.Zero(),id:t,node:n,timeSpeed:a=-6,perlinMultiply:r=.5,waterFlow:o=1,clippedHeight:i=0,alpha:s=1,colorSteps:l=[new EngineCore.GradientBlockColorStep(0,new EngineCore.Color3(25,92,255)),new EngineCore.GradientBlockColorStep(1,new EngineCore.Color3(127,223,252))],subdivideX:c=15,subdivideY:f=150})=>{const u=reactBabylonjs.useScene(),d=React.useContext(WorkspaceMetaContext),h=React.useRef(null),m=React.useRef(null),[R,v]=React.useState(EngineCore.Vector3.Zero()),g=React.useRef(null),x=React.useRef(null),y=React.useRef(null);return React.useEffect(()=>{const E=h.current;if(u&&E){g.current=createMultiStageWaterEffectMaterial({name:`waterMat-${t}-${n.name}`,scene:u}),g.current.getBlockByName("TimeSpeed").value=a,g.current.getBlockByName("PerlinMultiply").value=r,g.current.getBlockByName("waterFlow").value=o,g.current.getBlockByName("ClippedHeight").value=i,g.current.alpha=s,g.current.getBlockByName("Gradient").colorSteps=l;const k=g.current;k.getBlockByName("MaskEnabled").value=0,k.build(!1,!0,!0);const b=n.start,C=n.end,_=EngineCore.Vector3.Normalize(C.subtract(b)),A=Math.asin(_.y),N=Math.atan2(_.x,_.z),S=new EngineCore.Vector3(-A,N,0);return v(S),E.morphTargetManager=new EngineCore.MorphTargetManager,E.morphTargetManager.enableNormalMorphing=!0,y.current=E.getVerticesData(EngineCore.VertexBuffer.PositionKind).slice(0),y.current.length===0&&console.log("[Geo3DViewer] 水模拟,原始 SourceKind 为空",t,n.name),E.material=g.current,()=>{var I;(I=g.current)==null||I.dispose()}}},[t,n.end,n.name,n.start,u]),React.useEffect(()=>{const E=h.current,k=h.current;if(E&&k){console.log(`[Geo3DViewer] 正在更新 ${t} / ${n.name} 的进度 Time: ${n.time/1e3}`);const b=k.getVerticesData(EngineCore.VertexBuffer.PositionKind).slice(0);b.length===0&&console.log("[Geo3DViewer] 水模拟 SourceKind 为空",t,n.name),k.updateMeshPositions(N=>{for(let S=0;S<N.length;S++)N[S]=y.current[S]});const C=k.applyDisplacementMapFromBuffer(n.glurHeightMap,1,n.waterLength,0,n.height,EngineCore.Vector2.Zero(),EngineCore.Vector2.One(),!1).getVerticesData(EngineCore.VertexBuffer.PositionKind).slice(0);C.length===0&&console.log("[Geo3DViewer] 水模拟 SourceKind 为空",t,n.name),E.updateMeshPositions(N=>{for(let S=0;S<N.length;S++)N[S]=C[S]});const _=new AnimationClipPlaneHelper(b,C,E),A=new EngineCore.Animation("waterAnimation","influence",1e3/30,EngineCore.Animation.ANIMATIONTYPE_FLOAT,EngineCore.Animation.ANIMATIONLOOPMODE_CONSTANT);A.setKeys([{frame:0,value:0},{frame:10,value:1}]),u==null||u.beginDirectAnimation(_,[A],0,10,!1,10)}},[t,n.glurHeightMap,n.height,n.name,n.waterLength,n.time]),React.useEffect(()=>{const E=g.current;E&&(E.getBlockByName("TimeSpeed").value=a)},[a]),React.useEffect(()=>{const E=g.current;E&&(E.getBlockByName("PerlinMultiply").value=r)},[r]),React.useEffect(()=>{const E=g.current;E&&(E.getBlockByName("waterFlow").value=o)},[o]),React.useEffect(()=>{const E=g.current;E&&(E.getBlockByName("ClippedHeight").value=i)},[i]),React.useEffect(()=>{const E=g.current;E&&(E.alpha=s)},[s]),React.useEffect(()=>{const E=g.current;E&&(E.getBlockByName("Gradient").colorSteps=l,E.build(!1,!0,!0))},[l]),jsxRuntime.jsx("transformNode",{name:`water-simulation-${t}-${n.name}`,children:jsxRuntime.jsxs("transformNode",{name:`${name}`,position:e?e.multiply(calcTransformNodeScale(d)):new EngineCore.Vector3(0,0,0),scaling:calcTransformNodeScale(d),ref:m,children:[jsxRuntime.jsx("ground",{ref:h,name:`water-simulation-${t}-1`,position:n.center,rotation:R,subdivisionsX:c,subdivisionsY:f,updatable:!0,width:n.width,height:n.waterLength}),jsxRuntime.jsx("ground",{ref:x,name:`stub-water-simulation-${t}-1`,position:n.center,rotation:R,subdivisionsX:c,subdivisionsY:f,updatable:!0,width:n.width,height:n.waterLength,setEnabled:!1})]})})},RoadWayWaterEffectComponent$1=RoadWayWaterEffectComponent,RoadWayWaterEffectAnimationNode=e=>{const{nodes:t}=e;return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t&&t.map((n,a)=>jsxRuntime.jsx(RoadWayWaterEffectComponent$1,{id:a,node:n,timeSpeed:e.timeSpeed,perlinMultiply:e.perlinMultiply,waterFlow:e.waterFlow,clippedHeight:e.clippedHeight,alpha:e.alpha,colorSteps:e.colorSteps,subdivideX:e.subdivideX,subdivideY:e.subdivideY,maskSubdivide:e.maskSubdivide,speed:e.speed},n.name))})},RoadWayWaterEffectAnimationNode$1=RoadWayWaterEffectAnimationNode,SkyBox=e=>{const{rootUrl:t,size:n=1e3,name:a="skybox"}=e;return jsxRuntime.jsx(reactBabylonjs.Skybox,{rootUrl:t,size:n,name:a})},SkyBox$1=SkyBox;function createBaseSpaceHeat(){return{name:"",origin:void 0,dataPoints:[]}}const SpaceHeat$2={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.origin!==void 0&&Vertex.encode(e.origin,t.uint32(18).fork()).ldelim();for(const n of e.dataPoints)SpaceHeat_DataPoint.encode(n,t.uint32(26).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseSpaceHeat();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.origin=Vertex.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.dataPoints.push(SpaceHeat_DataPoint.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$5(e.name)?globalThis.String(e.name):"",origin:isSet$5(e.origin)?Vertex.fromJSON(e.origin):void 0,dataPoints:globalThis.Array.isArray(e==null?void 0:e.dataPoints)?e.dataPoints.map(t=>SpaceHeat_DataPoint.fromJSON(t)):[]}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),e.origin!==void 0&&(t.origin=Vertex.toJSON(e.origin)),(n=e.dataPoints)!=null&&n.length&&(t.dataPoints=e.dataPoints.map(a=>SpaceHeat_DataPoint.toJSON(a))),t},create(e){return SpaceHeat$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseSpaceHeat();return t.name=(n=e.name)!=null?n:"",t.origin=e.origin!==void 0&&e.origin!==null?Vertex.fromPartial(e.origin):void 0,t.dataPoints=((a=e.dataPoints)==null?void 0:a.map(r=>SpaceHeat_DataPoint.fromPartial(r)))||[],t}};function createBaseSpaceHeat_DataPoint(){return{point:void 0,colorId:0,vColor:0,vRadius:0}}const SpaceHeat_DataPoint={encode(e,t=minimal.Writer.create()){return e.point!==void 0&&Vertex.encode(e.point,t.uint32(10).fork()).ldelim(),e.colorId!==0&&t.uint32(16).uint32(e.colorId),e.vColor!==0&&t.uint32(29).float(e.vColor),e.vRadius!==0&&t.uint32(37).float(e.vRadius),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseSpaceHeat_DataPoint();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.point=Vertex.decode(n,n.uint32());continue;case 2:if(o!==16)break;r.colorId=n.uint32();continue;case 3:if(o!==29)break;r.vColor=n.float();continue;case 4:if(o!==37)break;r.vRadius=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{point:isSet$5(e.point)?Vertex.fromJSON(e.point):void 0,colorId:isSet$5(e.colorId)?globalThis.Number(e.colorId):0,vColor:isSet$5(e.vColor)?globalThis.Number(e.vColor):0,vRadius:isSet$5(e.vRadius)?globalThis.Number(e.vRadius):0}},toJSON(e){const t={};return e.point!==void 0&&(t.point=Vertex.toJSON(e.point)),e.colorId!==0&&(t.colorId=Math.round(e.colorId)),e.vColor!==0&&(t.vColor=e.vColor),e.vRadius!==0&&(t.vRadius=e.vRadius),t},create(e){return SpaceHeat_DataPoint.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=createBaseSpaceHeat_DataPoint();return t.point=e.point!==void 0&&e.point!==null?Vertex.fromPartial(e.point):void 0,t.colorId=(n=e.colorId)!=null?n:0,t.vColor=(a=e.vColor)!=null?a:0,t.vRadius=(r=e.vRadius)!=null?r:0,t}};function isSet$5(e){return e!=null}var SpaceHeatObjectType=(e=>(e[e.TETRAHEDRON=0]="TETRAHEDRON",e[e.OCTAHEDRON=1]="OCTAHEDRON",e[e.DODECAHEDRON=2]="DODECAHEDRON",e[e.ICOSAHEDRON=3]="ICOSAHEDRON",e[e.RHOMBICUBOCTAHEDRON=4]="RHOMBICUBOCTAHEDRON",e[e.SPECIAL_CIRCLE=5]="SPECIAL_CIRCLE",e))(SpaceHeatObjectType||{});const SpaceHeat=({url:e,colorCodec:t,alpha:n=1,visible:a=!0,offset:r=EngineCore.Vector3.Zero(),scale:o=1,objectType:i=2})=>{const s=reactBabylonjs.useScene(),l=React.useRef(null),c=React.useContext(WorkspaceMetaContext),f=React.useContext(ColorProviderContext),u=React.useRef(null),[d,h]=React.useState(""),[m,R]=React.useState(EngineCore.Vector3.Zero()),v=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH}),[g,x]=React.useState(null);return React.useEffect(()=>{console.log("[Geo3DViewer] SpaceHeat Loading: ",e)},[e]),React.useEffect(()=>{if(s&&l.current&&v){const y=l.current;EngineCore.Tags.EnableFor(y),EngineCore.Tags.AddTagsTo(y,"loading");const E=SpaceHeat$2.decode(new Uint8Array(v)),{name:k,origin:b,dataPoints:C}=E;if(b&&C){h(k),R(new EngineCore.Vector3(b.x,b.y,b.z));const _=new Float32Array(C.length*16),A=new Float32Array(C.length*4);return C.forEach((N,S)=>{if(N.point){const I=new EngineCore.Vector3(N.point.x,N.point.y,N.point.z).multiplyByFloats(c&&c.scalePlane?c.scalePlane:1,c&&c.scaleDepth?c.scaleDepth:1,c&&c.scalePlane?c.scalePlane:1),O=EngineCore.Quaternion.Identity(),F=new EngineCore.Vector3(N.vRadius*o,N.vRadius*o,N.vRadius*o);if(EngineCore.Matrix.Compose(F,O,I).copyToArray(_,S*16),t){const w=f.colorCodecs[t].array,B=w[Math.floor(N.vColor*(w.length-1))];A.set([B.r,B.g,B.b,n],S*4)}else{const w=f.colorIDs[N.colorId];A.set([w.r,w.g,w.b,n],S*4)}}}),y&&(y.thinInstanceSetBuffer("matrix",_),y.thinInstanceSetBuffer("color",A,4)),EngineCore.Tags.RemoveTagsFrom(y,"loading"),g==null||g.addMesh(y,EngineCore.Color3.White()),()=>{y&&(y.thinInstanceSetBuffer("matrix",new Float32Array),y.thinInstanceSetBuffer("color",new Float32Array))}}}},[n,t,f.colorCodecs,f.colorIDs,c==null?void 0:c.scalePlane,o,s,v,g,c==null?void 0:c.scaleDepth,c==null?void 0:c.scalePlane]),React.useEffect(()=>(u.current&&s&&n&&u.current.setFloat("alpha",n),s&&i===5&&x(new EngineCore.HighlightLayer(`highlight-layer-spaceheat-${d}`,s)),()=>{g&&g.dispose()}),[s,n,i]),jsxRuntime.jsx("transformNode",{setEnabled:a,name:`transform-spaceheat-${d}`,position:m.add(r).multiplyByFloats(c&&c.scalePlane?c.scalePlane:1,c&&c.scaleDepth?c.scaleDepth:1,c&&c.scalePlane?c.scalePlane:1),children:i===5?jsxRuntime.jsx("disc",{ref:l,name:`spaceheat-${d}`,radius:1,tessellation:32,sideOrientation:EngineCore.Mesh.DOUBLESIDE,billboardMode:EngineCore.Mesh.BILLBOARDMODE_ALL,children:t?jsxRuntime.jsx("standardMaterial",{name:`spaceheat-${d}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),emissiveColor:EngineCore.Color3.White(),alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:n,zOffset:-3}):jsxRuntime.jsx("standardMaterial",{name:`spaceheat-${d}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),emissiveColor:EngineCore.Color3.White(),alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:n,zOffset:-3})}):jsxRuntime.jsx("polyhedron",{ref:l,name:`spaceheat-${d}`,type:i,children:t?jsxRuntime.jsx("standardMaterial",{name:`spaceheat-${d}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),emissiveColor:EngineCore.Color3.Black(),alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:n,zOffset:-3}):jsxRuntime.jsx("standardMaterial",{name:`spaceheat-${d}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),emissiveColor:EngineCore.Color3.Black(),alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:n,zOffset:-3})})})},SpaceHeat$1=SpaceHeat;var TileMapMode=(e=>(e[e.OSM=1]="OSM",e[e.AMAP=2]="AMAP",e))(TileMapMode||{});const TileMap=({mode:e=1,baseUrl:t,visible:n=!0,xmin:a=-10,xmax:r=10,zmin:o=-10,zmax:i=10,zoom:s=12,xTileBase:l=2120,yTileBase:c=1498,precision:f={w:2,h:2},subdivisions:u={w:8,h:8},offset:d=EngineCore.Vector3.Zero(),scale:h=1})=>{const m=reactBabylonjs.useScene(),R=React.useRef(null),v=React.useRef(null),[g,x]=React.useState([]),[y,E]=React.useState([]);return React.useEffect(()=>{const k=R.current,b=v.current;if(k&&b){const C=k.getTotalVertices(),_=k.getIndices().length/(u.w*u.h),A=[];let N=0,S=0;for(let O=0;O<u.h;O++)for(let F=0;F<u.w;F++){const L=new EngineCore.SubMesh(N++,0,C,S,_,k);A.push(L),S+=_}const I=[];return[...Array(u.h).keys()].flatMap(O=>[...Array(u.w).keys()].map(F=>{const L=new EngineCore.StandardMaterial(`tileMap-material-${O}-${F}`),w=[`${t}/${s}/${l+F}/${c-O}.png`,`${t}/appmaptile?z=${s}&x=${l+F}&y=${c-O}&style=6`];return L.diffuseTexture=new EngineCore.Texture(w[w!=null&&w[e-1]?e-1:0],m),L.diffuseTexture.wrapU=EngineCore.Texture.CLAMP_ADDRESSMODE,L.diffuseTexture.wrapV=EngineCore.Texture.CLAMP_ADDRESSMODE,L.specularColor=EngineCore.Color3.Black(),L.backFaceCulling=!1,L})).forEach(O=>{I.push(O)}),E(A),x(I),k.subMeshes=A,b.subMaterials=I,()=>{b.subMaterials=[],k.subMeshes=[],x([]),E([])}}},[t,e,m,u.h,u.w,l,c,s]),jsxRuntime.jsx("transformNode",{name:"tileMap",setEnabled:n,position:d,scalingDeterminant:h,children:jsxRuntime.jsx("tiledGround",{name:"tileMap-ground",xmin:a,xmax:r,zmin:o,zmax:i,subdivisions:u,precision:f,subMeshes:y,ref:R,children:jsxRuntime.jsx("multiMaterial",{name:"submaterial-tile-map",subMaterials:g,ref:v})})})},TileMap$1=TileMap;function createBaseTube(){return{name:"",origin:void 0,type:"",sliceList:[],vertices:[],normals:[],indices:[],colors:[],uv:[],meshs:[]}}const Tube$2={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.origin!==void 0&&Vertex.encode(e.origin,t.uint32(18).fork()).ldelim(),e.type!==""&&t.uint32(26).string(e.type);for(const n of e.sliceList)Tube_Slice.encode(n,t.uint32(82).fork()).ldelim();t.uint32(90).fork();for(const n of e.vertices)t.float(n);t.ldelim(),t.uint32(98).fork();for(const n of e.normals)t.float(n);t.ldelim(),t.uint32(106).fork();for(const n of e.indices)t.uint32(n);t.ldelim(),t.uint32(114).fork();for(const n of e.colors)t.float(n);t.ldelim(),t.uint32(122).fork();for(const n of e.uv)t.float(n);t.ldelim();for(const n of e.meshs)Mesh.encode(n,t.uint32(130).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseTube();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.origin=Vertex.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.type=n.string();continue;case 10:if(o!==82)break;r.sliceList.push(Tube_Slice.decode(n,n.uint32()));continue;case 11:if(o===93){r.vertices.push(n.float());continue}if(o===90){const i=n.uint32()+n.pos;for(;n.pos<i;)r.vertices.push(n.float());continue}break;case 12:if(o===101){r.normals.push(n.float());continue}if(o===98){const i=n.uint32()+n.pos;for(;n.pos<i;)r.normals.push(n.float());continue}break;case 13:if(o===104){r.indices.push(n.uint32());continue}if(o===106){const i=n.uint32()+n.pos;for(;n.pos<i;)r.indices.push(n.uint32());continue}break;case 14:if(o===117){r.colors.push(n.float());continue}if(o===114){const i=n.uint32()+n.pos;for(;n.pos<i;)r.colors.push(n.float());continue}break;case 15:if(o===125){r.uv.push(n.float());continue}if(o===122){const i=n.uint32()+n.pos;for(;n.pos<i;)r.uv.push(n.float());continue}break;case 16:if(o!==130)break;r.meshs.push(Mesh.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$4(e.name)?globalThis.String(e.name):"",origin:isSet$4(e.origin)?Vertex.fromJSON(e.origin):void 0,type:isSet$4(e.type)?globalThis.String(e.type):"",sliceList:globalThis.Array.isArray(e==null?void 0:e.sliceList)?e.sliceList.map(t=>Tube_Slice.fromJSON(t)):[],vertices:globalThis.Array.isArray(e==null?void 0:e.vertices)?e.vertices.map(t=>globalThis.Number(t)):[],normals:globalThis.Array.isArray(e==null?void 0:e.normals)?e.normals.map(t=>globalThis.Number(t)):[],indices:globalThis.Array.isArray(e==null?void 0:e.indices)?e.indices.map(t=>globalThis.Number(t)):[],colors:globalThis.Array.isArray(e==null?void 0:e.colors)?e.colors.map(t=>globalThis.Number(t)):[],uv:globalThis.Array.isArray(e==null?void 0:e.uv)?e.uv.map(t=>globalThis.Number(t)):[],meshs:globalThis.Array.isArray(e==null?void 0:e.meshs)?e.meshs.map(t=>Mesh.fromJSON(t)):[]}},toJSON(e){var n,a,r,o,i,s,l;const t={};return e.name!==""&&(t.name=e.name),e.origin!==void 0&&(t.origin=Vertex.toJSON(e.origin)),e.type!==""&&(t.type=e.type),(n=e.sliceList)!=null&&n.length&&(t.sliceList=e.sliceList.map(c=>Tube_Slice.toJSON(c))),(a=e.vertices)!=null&&a.length&&(t.vertices=e.vertices),(r=e.normals)!=null&&r.length&&(t.normals=e.normals),(o=e.indices)!=null&&o.length&&(t.indices=e.indices.map(c=>Math.round(c))),(i=e.colors)!=null&&i.length&&(t.colors=e.colors),(s=e.uv)!=null&&s.length&&(t.uv=e.uv),(l=e.meshs)!=null&&l.length&&(t.meshs=e.meshs.map(c=>Mesh.toJSON(c))),t},create(e){return Tube$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l,c,f;const t=createBaseTube();return t.name=(n=e.name)!=null?n:"",t.origin=e.origin!==void 0&&e.origin!==null?Vertex.fromPartial(e.origin):void 0,t.type=(a=e.type)!=null?a:"",t.sliceList=((r=e.sliceList)==null?void 0:r.map(u=>Tube_Slice.fromPartial(u)))||[],t.vertices=((o=e.vertices)==null?void 0:o.map(u=>u))||[],t.normals=((i=e.normals)==null?void 0:i.map(u=>u))||[],t.indices=((s=e.indices)==null?void 0:s.map(u=>u))||[],t.colors=((l=e.colors)==null?void 0:l.map(u=>u))||[],t.uv=((c=e.uv)==null?void 0:c.map(u=>u))||[],t.meshs=((f=e.meshs)==null?void 0:f.map(u=>Mesh.fromPartial(u)))||[],t}};function createBaseTube_Slice(){return{position:void 0,start:void 0,end:void 0,color:void 0,angle:0,radius:0,innerRadius:0,texture:"",v:[]}}const Tube_Slice={encode(e,t=minimal.Writer.create()){e.position!==void 0&&Vertex.encode(e.position,t.uint32(10).fork()).ldelim(),e.start!==void 0&&Vertex.encode(e.start,t.uint32(18).fork()).ldelim(),e.end!==void 0&&Vertex.encode(e.end,t.uint32(26).fork()).ldelim(),e.color!==void 0&&Color.encode(e.color,t.uint32(34).fork()).ldelim(),e.angle!==0&&t.uint32(45).float(e.angle),e.radius!==0&&t.uint32(53).float(e.radius),e.innerRadius!==0&&t.uint32(69).float(e.innerRadius),e.texture!==""&&t.uint32(74).string(e.texture);for(const n of e.v)t.uint32(82).string(n);return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseTube_Slice();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.position=Vertex.decode(n,n.uint32());continue;case 2:if(o!==18)break;r.start=Vertex.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.end=Vertex.decode(n,n.uint32());continue;case 4:if(o!==34)break;r.color=Color.decode(n,n.uint32());continue;case 5:if(o!==45)break;r.angle=n.float();continue;case 6:if(o!==53)break;r.radius=n.float();continue;case 8:if(o!==69)break;r.innerRadius=n.float();continue;case 9:if(o!==74)break;r.texture=n.string();continue;case 10:if(o!==82)break;r.v.push(n.string());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{position:isSet$4(e.position)?Vertex.fromJSON(e.position):void 0,start:isSet$4(e.start)?Vertex.fromJSON(e.start):void 0,end:isSet$4(e.end)?Vertex.fromJSON(e.end):void 0,color:isSet$4(e.color)?Color.fromJSON(e.color):void 0,angle:isSet$4(e.angle)?globalThis.Number(e.angle):0,radius:isSet$4(e.radius)?globalThis.Number(e.radius):0,innerRadius:isSet$4(e.innerRadius)?globalThis.Number(e.innerRadius):0,texture:isSet$4(e.texture)?globalThis.String(e.texture):"",v:globalThis.Array.isArray(e==null?void 0:e.v)?e.v.map(t=>globalThis.String(t)):[]}},toJSON(e){var n;const t={};return e.position!==void 0&&(t.position=Vertex.toJSON(e.position)),e.start!==void 0&&(t.start=Vertex.toJSON(e.start)),e.end!==void 0&&(t.end=Vertex.toJSON(e.end)),e.color!==void 0&&(t.color=Color.toJSON(e.color)),e.angle!==0&&(t.angle=e.angle),e.radius!==0&&(t.radius=e.radius),e.innerRadius!==0&&(t.innerRadius=e.innerRadius),e.texture!==""&&(t.texture=e.texture),(n=e.v)!=null&&n.length&&(t.v=e.v),t},create(e){return Tube_Slice.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=createBaseTube_Slice();return t.position=e.position!==void 0&&e.position!==null?Vertex.fromPartial(e.position):void 0,t.start=e.start!==void 0&&e.start!==null?Vertex.fromPartial(e.start):void 0,t.end=e.end!==void 0&&e.end!==null?Vertex.fromPartial(e.end):void 0,t.color=e.color!==void 0&&e.color!==null?Color.fromPartial(e.color):void 0,t.angle=(n=e.angle)!=null?n:0,t.radius=(a=e.radius)!=null?a:0,t.innerRadius=(r=e.innerRadius)!=null?r:0,t.texture=(o=e.texture)!=null?o:"",t.v=((i=e.v)==null?void 0:i.map(s=>s))||[],t}};function isSet$4(e){return e!=null}const TubeComponent$2=(e,t)=>{const n=React.useRef(null),a=React.useContext(WorkspaceMetaContext),{id:r,name:o,visible:i=!0,position:s,children:l,isRegular:c=!0}=e;return React.useImperativeHandle(t,()=>n.current,[]),jsxRuntime.jsx("transformNode",{name:`node-${o}-${r}`,setEnabled:i,position:s?s.multiply(calcTransformNodeScale(a)):new EngineCore.Vector3(0,0,0),scaling:c?calcTransformNodeScale(a):EngineCore.Vector3.One(),ref:n,children:l})},TubeComponent$3=React.forwardRef(TubeComponent$2),TubeAction=e=>{const t=reactBabylonjs.useScene(),n=React.useRef(null),{title:a,url:r,color:o,v:i,actions:s,path:l,radius:c,mesh:f}=e;return React.useEffect(()=>{n.current&&(n.current.metadata={pickable:s?{name:a,onLeftClick:s.onLeftClick,onRightClick:s.onRightClick,onMiddleClick:s.onMiddleClick,onHover:s.onHover,extra:i}:null})},[s,a,i]),React.useEffect(()=>{if(n.current){const u=new EngineCore.VertexData;u.positions=f.vertices,u.indices=f.indices,u.normals=f.normals,u.uvs=f.uv,u.applyToMesh(n.current)}},[f.indices,f.normals,f.uv,f.vertices,l,c,t]),jsxRuntime.jsx("mesh",{name:"mesh",ref:n,children:jsxRuntime.jsx("standardMaterial",{name:"material",diffuseColor:r===""?new EngineCore.Color3(o.r,o.g,o.b):void 0,diffuseTexture:r!==""?new EngineCore.Texture(r):void 0})})},TubeAction$1=TubeAction,TubeLod=(e,t)=>{const{name:n,position:a,slices:r,meshs:o,actions:i}=e,s=React.useRef(null);return React.useImperativeHandle(t,()=>s.current,[]),jsxRuntime.jsx("transformNode",{name:"lod0",ref:s,setEnabled:!1,children:a&&r.map((l,c)=>{var f,u,d,h,m,R;return jsxRuntime.jsx(TubeAction$1,{id:c,v:l.v,position:a.add(new EngineCore.Vector3(0,0,0)),path:[new EngineCore.Vector3((f=l.start)==null?void 0:f.x,(u=l.start)==null?void 0:u.y,(d=l.start)==null?void 0:d.z),new EngineCore.Vector3((h=l.end)==null?void 0:h.x,(m=l.end)==null?void 0:m.y,(R=l.end)==null?void 0:R.z)],radius:l.radius,actions:i,mesh:o[c],title:n,color:l.color?new EngineCore.Color4(l.color.r,l.color.g,l.color.b,l.color.a):new EngineCore.Color4(0,0,0,1),url:l.texture},c)})})},TubeLod$1=React.forwardRef(TubeLod),TubeMain$2=e=>{const t=reactBabylonjs.useScene(),n=React.useRef(null),a=React.useContext(WorkspaceMetaContext),{id:r,vertices:o,indices:i,colors:s,color:l,materialType:c="custom",alphaBlend:f=!1,alpha:u=1,slices:d,position:h,name:m="tube",actions:R}=e;React.useEffect(()=>{n.current&&(n.current.metadata={pickable:R?{name:"",needWorldPosition:!0,onLeftClick:R.onLeftClick,onRightClick:R.onRightClick,onMiddleClick:R.onMiddleClick,onHover:(g,x,y,E,k)=>{var b,C,_,A,N,S;if(R.onHover&&t&&d&&y){const I=y;for(let O=0;O<d.length;O++){const F=new EngineCore.Vector3((b=d[O].start)==null?void 0:b.x,(C=d[O].start)==null?void 0:C.y,(_=d[O].start)==null?void 0:_.z).add(h).multiply(calcTransformNodeScale(a)),L=new EngineCore.Vector3((A=d[O].end)==null?void 0:A.x,(N=d[O].end)==null?void 0:N.y,(S=d[O].end)==null?void 0:S.z).add(h).multiply(calcTransformNodeScale(a)),w=EngineCore.MeshBuilder.CreateTube("boundingbox-tmp",{path:[F,L],radiusFunction:()=>{const D=d[O].radius;return D||1},cap:EngineCore.Mesh.NO_CAP,tessellation:8,sideOrientation:EngineCore.Mesh.DOUBLESIDE},t),B=w.getBoundingInfo().intersectsPoint(I);if(w.dispose(),B){R.onHover(g,new EngineCore.Vector2(t==null?void 0:t.pointerX,t==null?void 0:t.pointerY),y,E,k,d[O].v);break}}}}}:null})},[R,a,h,t,d]),React.useEffect(()=>{if(n&&n.current&&t){const g=new EngineCore.VertexData;g.positions=o,g.indices=i,s&&c!=="pbr-dark"&&c!=="standard"&&c!=="pbr-light"&&(g.colors=s),g.applyToMesh(n.current)}},[i,o,t,s,r,c]);const v=React.useCallback(()=>{if(c==="custom")return jsxRuntime.jsx(CustomShader$1,{name:`${m}-material-${r}`,vertex:flatVertexSource,fragment:flatFragmentSource,needDepthPrePass:!1,transparencyMode:f?EngineCore.Material.MATERIAL_ALPHABLEND:EngineCore.Material.MATERIAL_OPAQUE,options:{needAlphaBlending:!!f}});if(c==="standard")return jsxRuntime.jsx("standardMaterial",{name:`${m}-material`,alphaMode:EngineCore.Engine.ALPHA_COMBINE,transparencyMode:f?EngineCore.Material.MATERIAL_ALPHABLEND:EngineCore.Material.MATERIAL_OPAQUE,alpha:u,diffuseColor:l||void 0});if(c==="pbr-light")return jsxRuntime.jsx(LightMetalMaterial,{alpha:u});if(c==="pbr-dark")return jsxRuntime.jsx(DarkMetalMaterial,{alpha:u})},[u,f,l,r,c,m]);return jsxRuntime.jsx("transformNode",{name:`${m}-main-node`,children:jsxRuntime.jsx("mesh",{name:`${m}-mesh`,ref:n,isPickable:!0,children:v()})})},TubeMain$3=TubeMain$2,TubeLod1=(e,t)=>{const{id:n,visible:a=!0,materialType:r="custom",vertices:o,indices:i,colors:s,color:l,slices:c,position:f,actions:u}=e,d=React.useRef(null);return React.useImperativeHandle(t,()=>d.current,[]),jsxRuntime.jsx("transformNode",{name:"lod1",ref:d,setEnabled:!1,children:o.length>0&&jsxRuntime.jsx(TubeMain$3,{id:n,visible:a,vertices:o,indices:i,colors:s.length>0?s:void 0,materialType:r,alpha:1,color:l,alphaBlend:!1,position:f,actions:u,slices:c})})},TubeLod1$1=React.forwardRef(TubeLod1),TubeTitle=(e,t)=>{const n=React.useRef(null),a=React.useContext(WorkspaceMetaContext),{style:r,name:o="tube"}=e;return React.useImperativeHandle(t,()=>n.current,[]),jsxRuntime.jsx("transformNode",{name:`${o}-title`,position:r.position?r.position.add(r.offset?r.offset:new EngineCore.Vector3(0,0,0)):new EngineCore.Vector3(0,0,0).add(r.offset?r.offset:new EngineCore.Vector3(0,0,0)),scaling:calcGUIScale(a),ref:n,setEnabled:!1,children:r.title&&jsxRuntime.jsx(GUIText$1,{text:r.title,fontSize:r.fontSize?r.fontSize:40,color:r.color?r.color:"black"})})},TubeTitle$1=React.forwardRef(TubeTitle),Tube=e=>{var ee,G,ge,fe;const t=reactBabylonjs.useScene(),[n,a]=React.useState([]),[r,o]=React.useState([]),[i,s]=React.useState([]),l=React.useRef(null),c=React.useRef(null),f=React.useRef(null),[u,d]=React.useState(""),[h,m]=React.useState(new EngineCore.Vector3(0,0,0)),R=React.useRef(null),v=React.useRef(null),g=React.useRef(null),[x,y]=React.useState([]),E=React.useRef(!1),k=React.useContext(WorkspaceMetaContext),[b,C]=React.useState([]),[_,A]=React.useState(!1),[N,S]=React.useState(!1),{id:I,url:O,color:F,visible:L=!0,materialType:w="custom",children:B,style:D,actions:W,noLod:ae=!1,lodDistance:ne=[200,1e3],loadDistance:U=0,offset:re=new EngineCore.Vector3(0,0,0),position:te,topPosition:K,bottomPosition:Z,isRegular:de=!0}=e;return React.useEffect(()=>{te&&K&&Z?(l.current=te,c.current=K,f.current=Z):S(!0)},[Z,te,K]),React.useEffect(()=>{!E.current&&N&&(E.current=!0,axios.get(O,{responseType:"arraybuffer"}).then(V=>{var ce,Q,ye,Re,Te,Ee,_e,Se,Ne;const J=Tube$2.decode(new Uint8Array(V.data));console.log(J);const Ce=J.sliceList[0],Y=J.sliceList[J.sliceList.length-1];d(J.name);const se=e.style.basePosition&&e.style.basePosition==="top"?Ce.start:Y.end;m(new EngineCore.Vector3(se==null?void 0:se.x,se==null?void 0:se.y,se==null?void 0:se.z)),l.current=new EngineCore.Vector3((ce=J.origin)==null?void 0:ce.x,(Q=J.origin)==null?void 0:Q.y,(ye=J.origin)==null?void 0:ye.z).add(re),y(J.sliceList.filter(Ae=>Ae.v)),c.current=new EngineCore.Vector3((Re=Ce.start)==null?void 0:Re.x,(Te=Ce.start)==null?void 0:Te.y,(Ee=Ce.start)==null?void 0:Ee.z).add(l.current),f.current=new EngineCore.Vector3((_e=Y.end)==null?void 0:_e.x,(Se=Y.end)==null?void 0:Se.y,(Ne=Y.end)==null?void 0:Ne.z).add(l.current),C(J.meshs),a(J.vertices),o(w==="custom"?TubeUtil.correctTubeMainIndices(J.indices):J.indices),s(J.colors)}))},[O,t,F,w,e.style.basePosition,re,N,k]),React.useEffect(()=>{const V=setInterval(()=>{var J,Ce,Y,se,ce,Q,ye,Re,Te,Ee,_e,Se,Ne,Ae;if(t&&t.cameras.length>0&&t.activeCamera&&l.current&&c.current&&f.current){const Me=TubeUtil.calcLodDistance(c.current.multiply(calcTransformNodeScale(k)),l.current.multiply(calcTransformNodeScale(k)),f.current.multiply(calcTransformNodeScale(k)),t.activeCamera.position);Me>=U&&S(!0),ae?(b.length===0?((J=R.current)==null||J.setEnabled(!0),(Ce=v.current)==null||Ce.setEnabled(!1)):((Y=R.current)==null||Y.setEnabled(!1),(se=v.current)==null||se.setEnabled(!0)),(ce=g.current)==null||ce.setEnabled(!0)):Me<ne[0]?(A(!0),(Q=R.current)==null||Q.setEnabled(!0),(ye=v.current)==null||ye.setEnabled(b.length===0),(Re=g.current)==null||Re.setEnabled(!0)):ne[1]&&Me<ne[1]?((Te=R.current)==null||Te.setEnabled(!1),(Ee=v.current)==null||Ee.setEnabled(!0),(_e=g.current)==null||_e.setEnabled(!0)):((Se=R.current)==null||Se.setEnabled(!1),(Ne=v.current)==null||Ne.setEnabled(!1),(Ae=g.current)==null||Ae.setEnabled(!1))}},1e3);return()=>{clearInterval(V)}},[U,ne,b.length,k,t]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("transformNode",{name:`tube-${I} `,children:[jsxRuntime.jsxs(TubeComponent$3,{id:I,name:u,visible:L,position:(ee=l.current)!=null?ee:new EngineCore.Vector3(0,0,0),isRegular:de,children:[N&&jsxRuntime.jsx(TubeTitle$1,{id:I,style:{title:u,position:h,offset:(G=D.offset)==null?void 0:G.multiply(calcInvTransformNodeScale(k)),fontSize:D.fontSize,color:D.color},ref:g}),_&&N&&ne[0]&&b.length>0&&jsxRuntime.jsx(TubeLod$1,{id:I,name:u,meshs:b,position:(ge=l.current)!=null?ge:new EngineCore.Vector3(0,0,0),materialType:w,slices:x,actions:W,ref:R}),N&&jsxRuntime.jsx(TubeLod1$1,{id:I,name:u,position:(fe=l.current)!=null?fe:new EngineCore.Vector3(0,0,0),vertices:n,indices:r,colors:i,color:F?new EngineCore.Color3(F.r,F.g,F.b):void 0,slices:x,actions:W,materialType:w,ref:v})]}),B]})})},Tube$1=Tube;function createBaseTubeGroup(){return{group:[]}}const TubeGroup={encode(e,t=minimal.Writer.create()){for(const n of e.group)Tube$2.encode(n,t.uint32(10).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseTubeGroup();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.group.push(Tube$2.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{group:globalThis.Array.isArray(e==null?void 0:e.group)?e.group.map(t=>Tube$2.fromJSON(t)):[]}},toJSON(e){var n;const t={};return(n=e.group)!=null&&n.length&&(t.group=e.group.map(a=>Tube$2.toJSON(a))),t},create(e){return TubeGroup.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=createBaseTubeGroup();return t.group=((n=e.group)==null?void 0:n.map(a=>Tube$2.fromPartial(a)))||[],t}},TubeInstance=e=>{const t=reactBabylonjs.useScene(),[n,a]=React.useState([]),r=React.useRef(!1),o=React.useContext(WorkspaceMetaContext),{visible:i=!0,groupUrl:s,modelUrl:l,group:c,actions:f}=e,u=React.useCallback((d,h)=>h?new EngineCore.Color4(h==null?void 0:h.r,h==null?void 0:h.g,h==null?void 0:h.b,h==null?void 0:h.a):d||new EngineCore.Color4(1,1,1,1),[]);return React.useEffect(()=>{if(!r.current&&(r.current=!0,s&&axios.get(s,{responseType:"arraybuffer"}).then(d=>{const h=TubeGroup.decode(new Uint8Array(d.data)),m=[];for(let R=0;R<h.group.length;R++)m.push(h.group[R]);a(m)}),c&&c.length>0)){const d=[];for(let h=0;h<c.length;h++)d.push(axios.get(c[h].url,{responseType:"arraybuffer"}));Promise.all(d).then(h=>{const m=[];for(let R=0;R<h.length;R++){const v=Tube$2.decode(new Uint8Array(h[R].data));m.push(v)}a(m)})}}),React.useEffect(()=>{var h,m,R,v,g,x,y,E,k;let d;if(n.length>0){const b=[],C=[];for(let _=0;_<n.length;_++){const A=n[_],N=new EngineCore.Vector3((h=A.origin)==null?void 0:h.x,(m=A.origin)==null?void 0:m.y,(R=A.origin)==null?void 0:R.z),S=A.sliceList;if(S){const I=[],O=[];for(let F=0;F<S.length;F++)I.push(N.add(new EngineCore.Vector3((v=S[F].start)==null?void 0:v.x,(g=S[F].start)==null?void 0:g.y,(x=S[F].start)==null?void 0:x.z)).multiply(calcTransformNodeScale(o))),O.push(u(void 0,S[F].color)),F===S.length-1&&(I.push(N.add(new EngineCore.Vector3((y=S[F].end)==null?void 0:y.x,(E=S[F].end)==null?void 0:E.y,(k=S[F].end)==null?void 0:k.z)).multiply(calcTransformNodeScale(o))),O.push(u(void 0,S[F].color)));b.push(I),C.push(O)}}d=EngineCore.MeshBuilder.CreateLineSystem("linesystem",{lines:b,colors:C},t),d.setEnabled(i)}return()=>{d&&d.dispose()}},[u,o,t,n,i]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:l&&n&&n.length>0?n.map(d=>{var h,m,R,v,g,x;return jsxRuntime.jsx(ModelLoader$1,{position:new EngineCore.Vector3((h=d.origin)==null?void 0:h.x,(m=d.origin)==null?void 0:m.y,(R=d.origin)==null?void 0:R.z).add(new EngineCore.Vector3((v=d.sliceList[0].start)==null?void 0:v.x,(g=d.sliceList[0].start)==null?void 0:g.y,(x=d.sliceList[0].start)==null?void 0:x.z)).multiply(calcTransformNodeScale(o)),name:"model-tube-instance",url:l,visible:i,actions:f},d.name)}):jsxRuntime.jsx(jsxRuntime.Fragment,{})})},TubeInstance$1=TubeInstance,TubeTool=e=>{const t=React.useContext(WorkspaceMetaContext),{position:n=EngineCore.Vector3.Zero(),localScale:a=1,scaleMode:r=ScaleMode.NONE}=e,[o,i]=React.useState(1),{modelRoation:s=new EngineCore.Vector3(0,0,0)}=e,l=React.useRef(null);return React.useEffect(()=>{switch(r){case ScaleMode.PLANE:i((t&&t.scalePlane?t.scalePlane:1)*a);break;case ScaleMode.DEPTH:i((t&&t.scaleDepth?t.scaleDepth:1)*a);break;case ScaleMode.NONE:i(a);break}},[a,t,r]),React.useEffect(()=>{let c;return l.current&&(c=setInterval(()=>{var f;if(((f=l.current)==null?void 0:f.getChildren().length)===2){const u=l.current.getChildren()[1];u.rotation=s,c&&clearInterval(c)}},500)),()=>{c&&clearInterval(c)}},[s]),jsxRuntime.jsx(ModelLoader$1,{...e,position:n.multiplyByFloats(t&&t.scalePlane?t.scalePlane:1,t&&t.scaleDepth?t.scaleDepth:1,t&&t.scalePlane?t.scalePlane:1),localScale:o,ref:l})},TubeTool$1=TubeTool;function createBaseTubeChart(){return{name:"",tubeName:"",min:0,max:0,origin:void 0,chart:[]}}const TubeChart$2={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.tubeName!==""&&t.uint32(18).string(e.tubeName),e.min!==0&&t.uint32(29).float(e.min),e.max!==0&&t.uint32(37).float(e.max),e.origin!==void 0&&Vertex.encode(e.origin,t.uint32(42).fork()).ldelim();for(const n of e.chart)TubeChart_ChartData.encode(n,t.uint32(50).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseTubeChart();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.tubeName=n.string();continue;case 3:if(o!==29)break;r.min=n.float();continue;case 4:if(o!==37)break;r.max=n.float();continue;case 5:if(o!==42)break;r.origin=Vertex.decode(n,n.uint32());continue;case 6:if(o!==50)break;r.chart.push(TubeChart_ChartData.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$3(e.name)?globalThis.String(e.name):"",tubeName:isSet$3(e.tubeName)?globalThis.String(e.tubeName):"",min:isSet$3(e.min)?globalThis.Number(e.min):0,max:isSet$3(e.max)?globalThis.Number(e.max):0,origin:isSet$3(e.origin)?Vertex.fromJSON(e.origin):void 0,chart:globalThis.Array.isArray(e==null?void 0:e.chart)?e.chart.map(t=>TubeChart_ChartData.fromJSON(t)):[]}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),e.tubeName!==""&&(t.tubeName=e.tubeName),e.min!==0&&(t.min=e.min),e.max!==0&&(t.max=e.max),e.origin!==void 0&&(t.origin=Vertex.toJSON(e.origin)),(n=e.chart)!=null&&n.length&&(t.chart=e.chart.map(a=>TubeChart_ChartData.toJSON(a))),t},create(e){return TubeChart$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=createBaseTubeChart();return t.name=(n=e.name)!=null?n:"",t.tubeName=(a=e.tubeName)!=null?a:"",t.min=(r=e.min)!=null?r:0,t.max=(o=e.max)!=null?o:0,t.origin=e.origin!==void 0&&e.origin!==null?Vertex.fromPartial(e.origin):void 0,t.chart=((i=e.chart)==null?void 0:i.map(s=>TubeChart_ChartData.fromPartial(s)))||[],t}};function createBaseTubeChart_ChartData(){return{position:void 0,depth:0,value:0}}const TubeChart_ChartData={encode(e,t=minimal.Writer.create()){return e.position!==void 0&&Vertex.encode(e.position,t.uint32(10).fork()).ldelim(),e.depth!==0&&t.uint32(21).float(e.depth),e.value!==0&&t.uint32(29).float(e.value),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseTubeChart_ChartData();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.position=Vertex.decode(n,n.uint32());continue;case 2:if(o!==21)break;r.depth=n.float();continue;case 3:if(o!==29)break;r.value=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{position:isSet$3(e.position)?Vertex.fromJSON(e.position):void 0,depth:isSet$3(e.depth)?globalThis.Number(e.depth):0,value:isSet$3(e.value)?globalThis.Number(e.value):0}},toJSON(e){const t={};return e.position!==void 0&&(t.position=Vertex.toJSON(e.position)),e.depth!==0&&(t.depth=e.depth),e.value!==0&&(t.value=e.value),t},create(e){return TubeChart_ChartData.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseTubeChart_ChartData();return t.position=e.position!==void 0&&e.position!==null?Vertex.fromPartial(e.position):void 0,t.depth=(n=e.depth)!=null?n:0,t.value=(a=e.value)!=null?a:0,t}};function isSet$3(e){return e!=null}const billboardFragmentSource=`#version 300 es
|
|
1295
|
+
}`,PercentMaterial=e=>{const t=React.useRef(null),{startPercent:n,endPercent:a,backgroundColor:r,color:o,zOffset:i,zOffsetUnits:s,start:l,end:c}=e;return React.useEffect(()=>{t.current&&(t.current.setColor3("color",o),t.current.setColor3("backgroundColor",r||EngineCore.Color3.Black()),t.current.setFloat("discardFragment",r?0:1),t.current.setFloat("startPercent",n),t.current.setFloat("endPercent",a),t.current.setVector3("start",l),t.current.setVector3("end",c),i!==void 0&&s!==void 0&&(t.current.zOffset=i,t.current.zOffsetUnits=s))},[r,o,c,a,l,n,i,s]),jsxRuntime.jsx(CustomShader$1,{ref:t,name:e.name,backFaceCulling:e.backFaceCulling,needDepthPrePass:e.needDepthPrePass,vertex:percentVertexSource,fragment:percentFragmentSource,transparencyMode:e.transparencyMode,alphaMode:e.alphaMode,options:{attributes:["position","normal"],uniforms:["world","worldViewProjection","color1","color2","start","end","startPercent","endPercent"],needAlphaBlending:!1},zOffset:e.zOffset,zOffsetUnits:e.zOffsetUnits,sideOrientation:EngineCore.Material.CounterClockWiseSideOrientation})},PercentMaterial$1=PercentMaterial,usePick=(e,t)=>{React.useEffect(()=>{e.current&&(e.current.metadata={pickable:t})},[t,e])},RoadWayComponent=(e,t)=>{const n=reactBabylonjs.useScene(),a=React.useRef(null),r=React.useRef(null),o=React.useContext(WorkspaceMetaContext),{id:i,visible:s=!0,vertices:l,indices:c,colors:f,backgroundColor:u,color:d,start:h=new EngineCore.Vector3,end:m=new EngineCore.Vector3,percent:R,position:v,materialType:g="custom",children:x,alphaBlend:y=!1,alpha:E=1,name:k="roadway",actions:b,gpuPick:C=!0}=e;React.useImperativeHandle(t,()=>r.current,[]),React.useEffect(()=>{if(a&&a.current&&n){const A=new EngineCore.VertexData;A.positions=l,A.indices=c,f&&g!=="pbr-dark"&&g!=="pbr-light"&&(A.colors=f),A.applyToMesh(a.current)}},[c,l,n,f,i,g]),usePick(a,b&&C?{onLeftClick:b.onLeftClick,onRightClick:b.onRightClick,onMiddleClick:b.onMiddleClick,onHover:b.onHover,extra:""}:void 0);const _=React.useCallback(()=>{if(g==="custom")return jsxRuntime.jsx(CustomShader$1,{name:`${k}-material-${i}`,vertex:flatVertexSource,fragment:flatFragmentSource,needDepthPrePass:!1,transparencyMode:y?EngineCore.Material.MATERIAL_ALPHABLEND:EngineCore.Material.MATERIAL_OPAQUE,options:{needAlphaBlending:!!y}});if(g==="percent")return jsxRuntime.jsx(PercentMaterial$1,{name:`${k}-percentmaterial-${i}`,backgroundColor:u,color:d!=null?d:EngineCore.Color3.Black(),startPercent:R?R[0]:1,endPercent:R?R[1]:1,zOffset:-2,zOffsetUnits:-10,start:h,end:m});if(g==="standard")return jsxRuntime.jsx("standardMaterial",{name:`${k}-material`,alphaMode:EngineCore.Engine.ALPHA_COMBINE,transparencyMode:y?EngineCore.Material.MATERIAL_ALPHABLEND:EngineCore.Material.MATERIAL_OPAQUE,alpha:E});if(g==="pbr-light")return jsxRuntime.jsx(LightMetalMaterial,{alpha:E});if(g==="pbr-dark")return jsxRuntime.jsx(DarkMetalMaterial,{alpha:E})},[E,y,u,d,m,i,g,k,R,h]);return jsxRuntime.jsxs("transformNode",{name:`node-${k}-${i}`,setEnabled:s,children:[jsxRuntime.jsxs("transformNode",{name:`${k}`,position:v?v.multiply(calcTransformNodeScale(o)):new EngineCore.Vector3(0,0,0),scaling:calcTransformNodeScale(o),ref:r,children:[jsxRuntime.jsx("mesh",{name:`roadway-${i}-mesh`,ref:a,isPickable:!0,children:_()}),jsxRuntime.jsx("transformNode",{name:`${k}-title`,position:e.style.position?e.style.position:new EngineCore.Vector3(0,0,0),scaling:calcGUIScale(o),children:e.style.title&&jsxRuntime.jsx(GUIText$1,{text:e.style.title,fontSize:e.style.fontSize?e.style.fontSize:40,color:e.style.color?e.style.color:"black"})})]}),x]})},RoadWayComponent$1=React.forwardRef(RoadWayComponent),RoadWay=e=>{const[t,n]=React.useState({top:{vertices:[],indices:[],colors:[]},side:{vertices:[],indices:[],colors:[]},bottom:{vertices:[],indices:[],colors:[]}}),a=reactBabylonjs.useScene(),[r,o]=React.useState(new EngineCore.Vector3(0,0,0)),i=React.useRef(!1),[s,l]=React.useState([]),[c,f]=React.useState(""),{id:u,url:d,visible:h=!0,offset:m=new EngineCore.Vector3(0,0,0),children:R,actions:v,rayPick:g,showRoadwayWall:x={top:!0,bottom:!0,side:!0},roadwayName:y={nameList:[],offset:new EngineCore.Vector3(0,0,0)}}=e,{top:E=!0,bottom:k=!0,side:b=!0}=x,C=useAsset(d);return React.useEffect(()=>{if(C&&!i.current){i.current=!0;const _=RoadWay$2.decode(new Uint8Array(C));console.log(_),f(_.name);const{boxes:A}=_,N=[],S=[],I=[],O=[],F=[],w=[],L=[],B=[],D=[];let W=0,ae=0,ee=0;const H=_.position?new EngineCore.Vector3(_.position.x,_.position.y,_.position.z):new EngineCore.Vector3(0,0,0);return A.forEach(oe=>{var ge,fe,V,J,Re,Ce;const{topMesh:te,bottomMesh:K,sideMesh:Z}=oe;let ce=0;te&&te.vertices&&te.indices&&te.colors&&(N.push(...te.vertices),S.push(...te.indices.map(Y=>Y+W)),I.push(...te.colors),ce=Math.max(...te.indices)),W+=ce+1;let Q=0;Z&&Z.vertices&&Z.indices&&Z.colors&&(O.push(...Z.vertices),F.push(...Z.indices.map(Y=>Y+ae)),w.push(...Z.colors),Q=Math.max(...Z.indices)),ae+=Q+1;let G=0;if(K&&K.vertices&&K.indices&&K.colors&&(L.push(...K.vertices),B.push(...K.indices.map(Y=>Y+ee)),D.push(...K.colors),G=Math.max(...K.indices)),ee+=G+1,(y==null?void 0:y.nameList.length)>0&&oe.name&&y.nameList.includes(oe.name)){const Y=new EngineCore.Vector3((ge=oe.startPosition)==null?void 0:ge.x,(fe=oe.startPosition)==null?void 0:fe.y,(V=oe.startPosition)==null?void 0:V.z),ue=new EngineCore.Vector3((J=oe.endPosition)==null?void 0:J.x,(Re=oe.endPosition)==null?void 0:Re.y,(Ce=oe.endPosition)==null?void 0:Ce.z),ne=Y.add(ue).scale(.5);l(de=>[...de,{name:oe.name,position:ne}])}}),n({top:{vertices:N,indices:S,colors:I},side:{vertices:O,indices:F,colors:w},bottom:{vertices:L,indices:B,colors:D}}),o(H),()=>{i.current=!1,n({top:{vertices:[],indices:[],colors:[]},side:{vertices:[],indices:[],colors:[]},bottom:{vertices:[],indices:[],colors:[]}}),o(new EngineCore.Vector3(0,0,0))}}},[C]),React.useEffect(()=>{const _=a==null?void 0:a.onPointerObservable.add(function(A){if(g)switch(A.type){case EngineCore.PointerEventTypes.POINTERUP:const N=a.pick(a.pointerX,a.pointerY);if(N.hit){const S=N.pickedMesh;(S==null?void 0:S.name)===`roadway-${u}-mesh`&&v!=null&&v.onLeftClick&&v.onLeftClick(S.name,void 0,N.pickedPoint)}break}});return()=>{a==null||a.onPointerObservable.remove(_)}},[v,u,c,g,a]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t.top.vertices.length>0&&t.top.indices.length>0&&jsxRuntime.jsx(RoadWayComponent$1,{id:u,name:c,visible:h&&E,vertices:t.top.vertices,indices:t.top.indices,position:r.add(m),colors:t.top.colors.length>0?t.top.colors:void 0,style:{},actions:v,materialType:"standard",gpuPick:!g,children:R}),t.side.vertices.length>0&&t.side.indices.length>0&&jsxRuntime.jsx(RoadWayComponent$1,{id:u,name:c,visible:h&&b,vertices:t.side.vertices,indices:t.side.indices,position:r.add(m),colors:t.side.colors.length>0?t.side.colors:void 0,style:{},actions:v,materialType:"standard",gpuPick:!g,children:R}),t.bottom.vertices.length>0&&t.bottom.indices.length>0&&jsxRuntime.jsx(RoadWayComponent$1,{id:u,name:c,visible:h&&k,vertices:t.bottom.vertices,indices:t.bottom.indices,position:r.add(m),colors:t.bottom.colors.length>0?t.bottom.colors:void 0,style:{},actions:v,gpuPick:!g,materialType:"standard",children:R}),s.map((_,A)=>jsxRuntime.jsxs("transformNode",{name:`roadway-name-${_.name}-${A}-root`,children:[jsxRuntime.jsx("transformNode",{name:`roadway-name-${_.name}-${A}`,position:_.position.add(m).add((y==null?void 0:y.offset)||new EngineCore.Vector3(0,0,0)),billboardMode:EngineCore.Mesh.BILLBOARDMODE_ALL,children:jsxRuntime.jsx(GUIText$1,{text:_.name,fontSize:(y==null?void 0:y.fontSize)||18,color:(y==null?void 0:y.color)||"#FFFFFF"})},A),y.offset&&y.offset.y!==0?jsxRuntime.jsx("lineSystem",{name:`roadway-name-${_.name}-${A}-line`,lines:[[_.position,_.position.add(y.offset)]],color:EngineCore.Color3.White()}):null]}))]})},RoadWay$1=RoadWay,RoadWayAnimationNode=e=>{const{id:t,node:n}=e,[a,r]=React.useState([]),[o,i]=React.useState([]),s=(c,f)=>{const u=[];let d=0;for(const[h,m]of c){let R=h;for(;d<f.length&&f[d][1]<=h;)d++;for(;d<f.length&&f[d][0]<m&&(f[d][0]>R&&u.push([R,f[d][0]]),R=Math.max(R,f[d][1]),!(f[d][1]>=m));)d++;R<m&&u.push([R,m])}return u};React.useEffect(()=>{if(n.range){const c=[],f=[];let u=[];const d=n,h=[],m=[];switch(n.type){case"run":c.push(l(n.percent[0].start,n.percent[0].end)),f.push(n.colors[0]);break;default:for(let R=0;R<n.percent.length;R++){const v=l(n.percent[R].start,n.percent[R].end);v[0]!==v[1]&&h.push(v)}for(let R=0;R<d.colorPercent.length;R++){const v=l(d.colorPercent[R].start,d.colorPercent[R].end);v[0]!==v[1]&&(m.push(v),c.push([v[0],v[1]]),f.push(n.colors[1]))}u=s(h,m),u.forEach(R=>{c.push(R),f.push(n.colors[0])})}r(c),i(f)}},[n,n.colors,n.percent,n.range,n.type]);const l=(c,f)=>c>f?[f,c]:[c,f];return jsxRuntime.jsx("transformNode",{name:`animation-node-${n.name}`,children:a.map((c,f)=>jsxRuntime.jsx("transformNode",{name:`child-${f}`,children:c[0]>=0&&c[1]>=0&&n.meshs&&n.meshs.map((u,d)=>c[0]===c[1]?null:jsxRuntime.jsx(RoadWayComponent$1,{id:t,visible:!0,vertices:u.vertices,indices:u.indices,position:new EngineCore.Vector3(0,0,0),color:o[f],percent:c,start:n.start,end:n.end,style:{},materialType:"percent"},d))},f))})},RoadWayAnimationNode$1=RoadWayAnimationNode,RoadWayAnimation=e=>{const{nodes:t}=e,n=React.useRef(null),a=React.useRef([]),[r,o]=React.useState(),i=s=>{const l=[];for(let f=0;f<s.length;f++)l.push(s[f].start),l.push(s[f].end);const c=l.sort((f,u)=>f-u);return c[0]===0&&c[3]===1&&c[1]===c[2]};return React.useEffect(()=>{const s=setInterval(()=>{n.current||(n.current={vertices:[],indices:[],colors:[],normals:[],uv:[]});let l=n.current.indices.length>0?Math.max(...n.current.indices)+1:0;t==null||t.map(c=>{if(c instanceof AnimationRoadWayWaterNode){const f=c.colorPercent;a.current.findIndex(d=>d===c.name)===-1&&c.meshs&&i(f)&&(a.current.push(c.name),c.meshs.forEach(d=>{var m,R;let h=0;d.vertices&&d.indices&&((m=n.current)==null||m.vertices.push(...d.vertices),(R=n.current)==null||R.indices.push(...d.indices.map(v=>v+l)),h=Math.max(...d.indices)),l+=h+1}))}}),o({vertices:[...n.current.vertices],indices:[...n.current.indices],colors:[],normals:[],uv:[]})},3e4);return()=>{clearInterval(s)}},[t]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t&&t.map((s,l)=>a.current.find(f=>f===s.name)?null:jsxRuntime.jsx(RoadWayAnimationNode$1,{id:l,node:s},s.name)),t&&r&&r.vertices.length>0&&jsxRuntime.jsx(RoadWayComponent$1,{id:0,name:"animation-merged-mesh",visible:!0,vertices:r.vertices,indices:r.indices,position:new EngineCore.Vector3(0,0,0),color:t[0].colors[1],percent:[0,1],start:t[0].start,end:t[0].end,style:{},materialType:"percent"})]})},RoadWayAnimation$1=RoadWayAnimation,BlinkMaterial=e=>{const{url:t,zOffset:n,zOffsetUnits:a,uScale:r,vScale:o,isBlink:i}=e,[s,l]=React.useState(),[c,f]=React.useState(1);return React.useEffect(()=>{const u=new EngineCore.Texture(t);u.hasAlpha=!0,u.uScale=r,u.vScale=o,l(u)},[t,r,o]),React.useEffect(()=>{const u=setInterval(()=>{i&&f(d=>d===0?1:0)},1e3);return()=>{clearInterval(u)}},[i]),jsxRuntime.jsx("standardMaterial",{name:e.name,backFaceCulling:e.backFaceCulling,needDepthPrePass:e.needDepthPrePass,transparencyMode:e.transparencyMode,alphaMode:e.alphaMode,alpha:c,diffuseTexture:s,emissiveTexture:s,useAlphaFromDiffuseTexture:!0,disableLighting:!0,zOffset:n,zOffsetUnits:a,sideOrientation:EngineCore.Material.CounterClockWiseSideOrientation})},BlinkMaterial$1=BlinkMaterial,RoadWayNearAnimationNode=e=>{const{node:t,roadwayWidth:n,textureLength:a,url:r,visible:o=!0,isBlink:i=!0}=e,[s,l]=React.useState(),c=React.useRef(null),[f,u]=React.useState(),[d,h]=React.useState(!1),[m,R]=React.useState(1),v=(g,x,y,E)=>{const b=EngineCore.Vector3.Distance(g,x)/E,C=EngineCore.Vector3.Distance(g,y),_=Math.floor(C/b);return Math.min(_,E-1)};return React.useEffect(()=>{if(t.start&&t.end&&t.current){const g=EngineCore.Vector3.Distance(t.start,t.end),x=Math.floor(g/a),y=v(t.start,t.end,t.current,x);if(t.end.equals(t.current)){l(0);return}l(x-y),R((x-y)/x)}},[t,t.end,t.start,a]),React.useEffect(()=>{if(t.end===t.current){u(void 0);return}if(t.start&&t.end&&t.current){const g=EngineCore.Vector3.Lerp(t.start,t.end,.5+(1-m)/2);u(g)}},[t,m]),React.useEffect(()=>{c.current&&t.end&&(c.current.lookAt(t.end),c.current.rotation.x=Math.PI/2+c.current.rotation.x,c.current.rotation.z=Math.PI/2,h(!0))},[t.end]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:f&&s&&t.start&&t.end&&jsxRuntime.jsx("plane",{name:`${t.name}-mesh`,width:EngineCore.Vector3.Distance(t.start,t.end),height:n,ref:c,position:f,setEnabled:d&&o,scaling:new EngineCore.Vector3(m,1,1),children:jsxRuntime.jsx(BlinkMaterial$1,{name:t.name,alphaMode:EngineCore.Engine.ALPHA_COMBINE,transparencyMode:EngineCore.Material.MATERIAL_ALPHABLEND,url:r,uScale:s,vScale:1,zOffset:-10,zOffsetUnits:-10,isBlink:i})})})},RoadWayNearAnimationNode$1=RoadWayNearAnimationNode,RoadWayNearAnimation=e=>{const{nodes:t,roadwayWidth:n=2,textureLength:a=4,url:r,visible:o=!0,isBlink:i=!0}=e;return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t&&t.map((s,l)=>{const c=s;return jsxRuntime.jsx(RoadWayNearAnimationNode$1,{node:c,roadwayWidth:n,textureLength:a,url:r,visible:o,isBlink:i},l)})})},RoadWayNearAnimation$1=RoadWayNearAnimation;class AnimationClipPlaneHelper{constructor(t,n,a){le(this,"sourceVertex");le(this,"targetVertex");le(this,"meshCurrent");le(this,"_influence",0);this.sourceVertex=t,this.targetVertex=n,this.meshCurrent=a}set influence(t){this.meshCurrent.updateMeshPositions(n=>{this.sourceVertex.length!==this.targetVertex.length&&console.log("[Geo3DViewer] 近景水模拟顶点数量不一致");for(let a=0;a<n.length;a++)n[a]=this.sourceVertex[a]+(this.targetVertex[a]-this.sourceVertex[a])*t}),this._influence=t}get influence(){return this._influence}}const RoadWayWaterEffectComponent=({position:e=EngineCore.Vector3.Zero(),id:t,node:n,timeSpeed:a=-6,perlinMultiply:r=.5,waterFlow:o=1,clippedHeight:i=0,alpha:s=1,colorSteps:l=[new EngineCore.GradientBlockColorStep(0,new EngineCore.Color3(25,92,255)),new EngineCore.GradientBlockColorStep(1,new EngineCore.Color3(127,223,252))],subdivideX:c=15,subdivideY:f=150})=>{const u=reactBabylonjs.useScene(),d=React.useContext(WorkspaceMetaContext),h=React.useRef(null),m=React.useRef(null),[R,v]=React.useState(EngineCore.Vector3.Zero()),g=React.useRef(null),x=React.useRef(null),y=React.useRef(null);return React.useEffect(()=>{const E=h.current;if(u&&E){g.current=createMultiStageWaterEffectMaterial({name:`waterMat-${t}-${n.name}`,scene:u}),g.current.getBlockByName("TimeSpeed").value=a,g.current.getBlockByName("PerlinMultiply").value=r,g.current.getBlockByName("waterFlow").value=o,g.current.getBlockByName("ClippedHeight").value=i,g.current.alpha=s,g.current.getBlockByName("Gradient").colorSteps=l;const k=g.current;k.getBlockByName("MaskEnabled").value=0,k.build(!1,!0,!0);const b=n.start,C=n.end,_=EngineCore.Vector3.Normalize(C.subtract(b)),A=Math.asin(_.y),N=Math.atan2(_.x,_.z),S=new EngineCore.Vector3(-A,N,0);return v(S),E.morphTargetManager=new EngineCore.MorphTargetManager,E.morphTargetManager.enableNormalMorphing=!0,y.current=E.getVerticesData(EngineCore.VertexBuffer.PositionKind).slice(0),y.current.length===0&&console.log("[Geo3DViewer] 水模拟,原始 SourceKind 为空",t,n.name),E.material=g.current,()=>{var I;(I=g.current)==null||I.dispose()}}},[t,n.end,n.name,n.start,u]),React.useEffect(()=>{const E=h.current,k=h.current;if(E&&k){console.log(`[Geo3DViewer] 正在更新 ${t} / ${n.name} 的进度 Time: ${n.time/1e3}`);const b=k.getVerticesData(EngineCore.VertexBuffer.PositionKind).slice(0);b.length===0&&console.log("[Geo3DViewer] 水模拟 SourceKind 为空",t,n.name),k.updateMeshPositions(N=>{for(let S=0;S<N.length;S++)N[S]=y.current[S]});const C=k.applyDisplacementMapFromBuffer(n.glurHeightMap,1,n.waterLength,0,n.height,EngineCore.Vector2.Zero(),EngineCore.Vector2.One(),!1).getVerticesData(EngineCore.VertexBuffer.PositionKind).slice(0);C.length===0&&console.log("[Geo3DViewer] 水模拟 SourceKind 为空",t,n.name),E.updateMeshPositions(N=>{for(let S=0;S<N.length;S++)N[S]=C[S]});const _=new AnimationClipPlaneHelper(b,C,E),A=new EngineCore.Animation("waterAnimation","influence",1e3/30,EngineCore.Animation.ANIMATIONTYPE_FLOAT,EngineCore.Animation.ANIMATIONLOOPMODE_CONSTANT);A.setKeys([{frame:0,value:0},{frame:10,value:1}]),u==null||u.beginDirectAnimation(_,[A],0,10,!1,10)}},[t,n.glurHeightMap,n.height,n.name,n.waterLength,n.time]),React.useEffect(()=>{const E=g.current;E&&(E.getBlockByName("TimeSpeed").value=a)},[a]),React.useEffect(()=>{const E=g.current;E&&(E.getBlockByName("PerlinMultiply").value=r)},[r]),React.useEffect(()=>{const E=g.current;E&&(E.getBlockByName("waterFlow").value=o)},[o]),React.useEffect(()=>{const E=g.current;E&&(E.getBlockByName("ClippedHeight").value=i)},[i]),React.useEffect(()=>{const E=g.current;E&&(E.alpha=s)},[s]),React.useEffect(()=>{const E=g.current;E&&(E.getBlockByName("Gradient").colorSteps=l,E.build(!1,!0,!0))},[l]),jsxRuntime.jsx("transformNode",{name:`water-simulation-${t}-${n.name}`,children:jsxRuntime.jsxs("transformNode",{name:`${name}`,position:e?e.multiply(calcTransformNodeScale(d)):new EngineCore.Vector3(0,0,0),scaling:calcTransformNodeScale(d),ref:m,children:[jsxRuntime.jsx("ground",{ref:h,name:`water-simulation-${t}-1`,position:n.center,rotation:R,subdivisionsX:c,subdivisionsY:f,updatable:!0,width:n.width,height:n.waterLength}),jsxRuntime.jsx("ground",{ref:x,name:`stub-water-simulation-${t}-1`,position:n.center,rotation:R,subdivisionsX:c,subdivisionsY:f,updatable:!0,width:n.width,height:n.waterLength,setEnabled:!1})]})})},RoadWayWaterEffectComponent$1=RoadWayWaterEffectComponent,RoadWayWaterEffectAnimationNode=e=>{const{nodes:t}=e;return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t&&t.map((n,a)=>jsxRuntime.jsx(RoadWayWaterEffectComponent$1,{id:a,node:n,timeSpeed:e.timeSpeed,perlinMultiply:e.perlinMultiply,waterFlow:e.waterFlow,clippedHeight:e.clippedHeight,alpha:e.alpha,colorSteps:e.colorSteps,subdivideX:e.subdivideX,subdivideY:e.subdivideY,maskSubdivide:e.maskSubdivide,speed:e.speed},n.name))})},RoadWayWaterEffectAnimationNode$1=RoadWayWaterEffectAnimationNode,SkyBox=e=>{const{rootUrl:t,size:n=1e3,name:a="skybox"}=e;return jsxRuntime.jsx(reactBabylonjs.Skybox,{rootUrl:t,size:n,name:a})},SkyBox$1=SkyBox;function createBaseSpaceHeat(){return{name:"",origin:void 0,dataPoints:[]}}const SpaceHeat$2={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.origin!==void 0&&Vertex.encode(e.origin,t.uint32(18).fork()).ldelim();for(const n of e.dataPoints)SpaceHeat_DataPoint.encode(n,t.uint32(26).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseSpaceHeat();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.origin=Vertex.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.dataPoints.push(SpaceHeat_DataPoint.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$5(e.name)?globalThis.String(e.name):"",origin:isSet$5(e.origin)?Vertex.fromJSON(e.origin):void 0,dataPoints:globalThis.Array.isArray(e==null?void 0:e.dataPoints)?e.dataPoints.map(t=>SpaceHeat_DataPoint.fromJSON(t)):[]}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),e.origin!==void 0&&(t.origin=Vertex.toJSON(e.origin)),(n=e.dataPoints)!=null&&n.length&&(t.dataPoints=e.dataPoints.map(a=>SpaceHeat_DataPoint.toJSON(a))),t},create(e){return SpaceHeat$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseSpaceHeat();return t.name=(n=e.name)!=null?n:"",t.origin=e.origin!==void 0&&e.origin!==null?Vertex.fromPartial(e.origin):void 0,t.dataPoints=((a=e.dataPoints)==null?void 0:a.map(r=>SpaceHeat_DataPoint.fromPartial(r)))||[],t}};function createBaseSpaceHeat_DataPoint(){return{point:void 0,colorId:0,vColor:0,vRadius:0}}const SpaceHeat_DataPoint={encode(e,t=minimal.Writer.create()){return e.point!==void 0&&Vertex.encode(e.point,t.uint32(10).fork()).ldelim(),e.colorId!==0&&t.uint32(16).uint32(e.colorId),e.vColor!==0&&t.uint32(29).float(e.vColor),e.vRadius!==0&&t.uint32(37).float(e.vRadius),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseSpaceHeat_DataPoint();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.point=Vertex.decode(n,n.uint32());continue;case 2:if(o!==16)break;r.colorId=n.uint32();continue;case 3:if(o!==29)break;r.vColor=n.float();continue;case 4:if(o!==37)break;r.vRadius=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{point:isSet$5(e.point)?Vertex.fromJSON(e.point):void 0,colorId:isSet$5(e.colorId)?globalThis.Number(e.colorId):0,vColor:isSet$5(e.vColor)?globalThis.Number(e.vColor):0,vRadius:isSet$5(e.vRadius)?globalThis.Number(e.vRadius):0}},toJSON(e){const t={};return e.point!==void 0&&(t.point=Vertex.toJSON(e.point)),e.colorId!==0&&(t.colorId=Math.round(e.colorId)),e.vColor!==0&&(t.vColor=e.vColor),e.vRadius!==0&&(t.vRadius=e.vRadius),t},create(e){return SpaceHeat_DataPoint.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=createBaseSpaceHeat_DataPoint();return t.point=e.point!==void 0&&e.point!==null?Vertex.fromPartial(e.point):void 0,t.colorId=(n=e.colorId)!=null?n:0,t.vColor=(a=e.vColor)!=null?a:0,t.vRadius=(r=e.vRadius)!=null?r:0,t}};function isSet$5(e){return e!=null}var SpaceHeatObjectType=(e=>(e[e.TETRAHEDRON=0]="TETRAHEDRON",e[e.OCTAHEDRON=1]="OCTAHEDRON",e[e.DODECAHEDRON=2]="DODECAHEDRON",e[e.ICOSAHEDRON=3]="ICOSAHEDRON",e[e.RHOMBICUBOCTAHEDRON=4]="RHOMBICUBOCTAHEDRON",e[e.SPECIAL_CIRCLE=5]="SPECIAL_CIRCLE",e))(SpaceHeatObjectType||{});const SpaceHeat=({url:e,colorCodec:t,alpha:n=1,visible:a=!0,offset:r=EngineCore.Vector3.Zero(),scale:o=1,objectType:i=2})=>{const s=reactBabylonjs.useScene(),l=React.useRef(null),c=React.useContext(WorkspaceMetaContext),f=React.useContext(ColorProviderContext),u=React.useRef(null),[d,h]=React.useState(""),[m,R]=React.useState(EngineCore.Vector3.Zero()),v=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH}),[g,x]=React.useState(null);return React.useEffect(()=>{console.log("[Geo3DViewer] SpaceHeat Loading: ",e)},[e]),React.useEffect(()=>{if(s&&l.current&&v){const y=l.current;EngineCore.Tags.EnableFor(y),EngineCore.Tags.AddTagsTo(y,"loading");const E=SpaceHeat$2.decode(new Uint8Array(v)),{name:k,origin:b,dataPoints:C}=E;if(b&&C){h(k),R(new EngineCore.Vector3(b.x,b.y,b.z));const _=new Float32Array(C.length*16),A=new Float32Array(C.length*4);return C.forEach((N,S)=>{if(N.point){const I=new EngineCore.Vector3(N.point.x,N.point.y,N.point.z).multiplyByFloats(c&&c.scalePlane?c.scalePlane:1,c&&c.scaleDepth?c.scaleDepth:1,c&&c.scalePlane?c.scalePlane:1),O=EngineCore.Quaternion.Identity(),F=new EngineCore.Vector3(N.vRadius*o,N.vRadius*o,N.vRadius*o);if(EngineCore.Matrix.Compose(F,O,I).copyToArray(_,S*16),t){const L=f.colorCodecs[t].array,B=L[Math.floor(N.vColor*(L.length-1))];A.set([B.r,B.g,B.b,n],S*4)}else{const L=f.colorIDs[N.colorId];A.set([L.r,L.g,L.b,n],S*4)}}}),y&&(y.thinInstanceSetBuffer("matrix",_),y.thinInstanceSetBuffer("color",A,4)),EngineCore.Tags.RemoveTagsFrom(y,"loading"),g==null||g.addMesh(y,EngineCore.Color3.White()),()=>{y&&(y.thinInstanceSetBuffer("matrix",new Float32Array),y.thinInstanceSetBuffer("color",new Float32Array))}}}},[n,t,f.colorCodecs,f.colorIDs,c==null?void 0:c.scalePlane,o,s,v,g,c==null?void 0:c.scaleDepth,c==null?void 0:c.scalePlane]),React.useEffect(()=>(u.current&&s&&n&&u.current.setFloat("alpha",n),s&&i===5&&x(new EngineCore.HighlightLayer(`highlight-layer-spaceheat-${d}`,s)),()=>{g&&g.dispose()}),[s,n,i]),jsxRuntime.jsx("transformNode",{setEnabled:a,name:`transform-spaceheat-${d}`,position:m.add(r).multiplyByFloats(c&&c.scalePlane?c.scalePlane:1,c&&c.scaleDepth?c.scaleDepth:1,c&&c.scalePlane?c.scalePlane:1),children:i===5?jsxRuntime.jsx("disc",{ref:l,name:`spaceheat-${d}`,radius:1,tessellation:32,sideOrientation:EngineCore.Mesh.DOUBLESIDE,billboardMode:EngineCore.Mesh.BILLBOARDMODE_ALL,children:t?jsxRuntime.jsx("standardMaterial",{name:`spaceheat-${d}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),emissiveColor:EngineCore.Color3.White(),alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:n,zOffset:-3}):jsxRuntime.jsx("standardMaterial",{name:`spaceheat-${d}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),emissiveColor:EngineCore.Color3.White(),alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:n,zOffset:-3})}):jsxRuntime.jsx("polyhedron",{ref:l,name:`spaceheat-${d}`,type:i,children:t?jsxRuntime.jsx("standardMaterial",{name:`spaceheat-${d}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),emissiveColor:EngineCore.Color3.Black(),alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:n,zOffset:-3}):jsxRuntime.jsx("standardMaterial",{name:`spaceheat-${d}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new EngineCore.Color3(0,0,0),ambientColor:new EngineCore.Color3(1,1,1),emissiveColor:EngineCore.Color3.Black(),alphaMode:EngineCore.Engine.ALPHA_COMBINE,alpha:n,zOffset:-3})})})},SpaceHeat$1=SpaceHeat;var TileMapMode=(e=>(e[e.OSM=1]="OSM",e[e.AMAP=2]="AMAP",e))(TileMapMode||{});const TileMap=({mode:e=1,baseUrl:t,visible:n=!0,xmin:a=-10,xmax:r=10,zmin:o=-10,zmax:i=10,zoom:s=12,xTileBase:l=2120,yTileBase:c=1498,precision:f={w:2,h:2},subdivisions:u={w:8,h:8},offset:d=EngineCore.Vector3.Zero(),scale:h=1})=>{const m=reactBabylonjs.useScene(),R=React.useRef(null),v=React.useRef(null),[g,x]=React.useState([]),[y,E]=React.useState([]);return React.useEffect(()=>{const k=R.current,b=v.current;if(k&&b){const C=k.getTotalVertices(),_=k.getIndices().length/(u.w*u.h),A=[];let N=0,S=0;for(let O=0;O<u.h;O++)for(let F=0;F<u.w;F++){const w=new EngineCore.SubMesh(N++,0,C,S,_,k);A.push(w),S+=_}const I=[];return[...Array(u.h).keys()].flatMap(O=>[...Array(u.w).keys()].map(F=>{const w=new EngineCore.StandardMaterial(`tileMap-material-${O}-${F}`),L=[`${t}/${s}/${l+F}/${c-O}.png`,`${t}/appmaptile?z=${s}&x=${l+F}&y=${c-O}&style=6`];return w.diffuseTexture=new EngineCore.Texture(L[L!=null&&L[e-1]?e-1:0],m),w.diffuseTexture.wrapU=EngineCore.Texture.CLAMP_ADDRESSMODE,w.diffuseTexture.wrapV=EngineCore.Texture.CLAMP_ADDRESSMODE,w.specularColor=EngineCore.Color3.Black(),w.backFaceCulling=!1,w})).forEach(O=>{I.push(O)}),E(A),x(I),k.subMeshes=A,b.subMaterials=I,()=>{b.subMaterials=[],k.subMeshes=[],x([]),E([])}}},[t,e,m,u.h,u.w,l,c,s]),jsxRuntime.jsx("transformNode",{name:"tileMap",setEnabled:n,position:d,scalingDeterminant:h,children:jsxRuntime.jsx("tiledGround",{name:"tileMap-ground",xmin:a,xmax:r,zmin:o,zmax:i,subdivisions:u,precision:f,subMeshes:y,ref:R,children:jsxRuntime.jsx("multiMaterial",{name:"submaterial-tile-map",subMaterials:g,ref:v})})})},TileMap$1=TileMap;function createBaseTube(){return{name:"",origin:void 0,type:"",sliceList:[],vertices:[],normals:[],indices:[],colors:[],uv:[],meshs:[]}}const Tube$2={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.origin!==void 0&&Vertex.encode(e.origin,t.uint32(18).fork()).ldelim(),e.type!==""&&t.uint32(26).string(e.type);for(const n of e.sliceList)Tube_Slice.encode(n,t.uint32(82).fork()).ldelim();t.uint32(90).fork();for(const n of e.vertices)t.float(n);t.ldelim(),t.uint32(98).fork();for(const n of e.normals)t.float(n);t.ldelim(),t.uint32(106).fork();for(const n of e.indices)t.uint32(n);t.ldelim(),t.uint32(114).fork();for(const n of e.colors)t.float(n);t.ldelim(),t.uint32(122).fork();for(const n of e.uv)t.float(n);t.ldelim();for(const n of e.meshs)Mesh.encode(n,t.uint32(130).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseTube();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.origin=Vertex.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.type=n.string();continue;case 10:if(o!==82)break;r.sliceList.push(Tube_Slice.decode(n,n.uint32()));continue;case 11:if(o===93){r.vertices.push(n.float());continue}if(o===90){const i=n.uint32()+n.pos;for(;n.pos<i;)r.vertices.push(n.float());continue}break;case 12:if(o===101){r.normals.push(n.float());continue}if(o===98){const i=n.uint32()+n.pos;for(;n.pos<i;)r.normals.push(n.float());continue}break;case 13:if(o===104){r.indices.push(n.uint32());continue}if(o===106){const i=n.uint32()+n.pos;for(;n.pos<i;)r.indices.push(n.uint32());continue}break;case 14:if(o===117){r.colors.push(n.float());continue}if(o===114){const i=n.uint32()+n.pos;for(;n.pos<i;)r.colors.push(n.float());continue}break;case 15:if(o===125){r.uv.push(n.float());continue}if(o===122){const i=n.uint32()+n.pos;for(;n.pos<i;)r.uv.push(n.float());continue}break;case 16:if(o!==130)break;r.meshs.push(Mesh.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$4(e.name)?globalThis.String(e.name):"",origin:isSet$4(e.origin)?Vertex.fromJSON(e.origin):void 0,type:isSet$4(e.type)?globalThis.String(e.type):"",sliceList:globalThis.Array.isArray(e==null?void 0:e.sliceList)?e.sliceList.map(t=>Tube_Slice.fromJSON(t)):[],vertices:globalThis.Array.isArray(e==null?void 0:e.vertices)?e.vertices.map(t=>globalThis.Number(t)):[],normals:globalThis.Array.isArray(e==null?void 0:e.normals)?e.normals.map(t=>globalThis.Number(t)):[],indices:globalThis.Array.isArray(e==null?void 0:e.indices)?e.indices.map(t=>globalThis.Number(t)):[],colors:globalThis.Array.isArray(e==null?void 0:e.colors)?e.colors.map(t=>globalThis.Number(t)):[],uv:globalThis.Array.isArray(e==null?void 0:e.uv)?e.uv.map(t=>globalThis.Number(t)):[],meshs:globalThis.Array.isArray(e==null?void 0:e.meshs)?e.meshs.map(t=>Mesh.fromJSON(t)):[]}},toJSON(e){var n,a,r,o,i,s,l;const t={};return e.name!==""&&(t.name=e.name),e.origin!==void 0&&(t.origin=Vertex.toJSON(e.origin)),e.type!==""&&(t.type=e.type),(n=e.sliceList)!=null&&n.length&&(t.sliceList=e.sliceList.map(c=>Tube_Slice.toJSON(c))),(a=e.vertices)!=null&&a.length&&(t.vertices=e.vertices),(r=e.normals)!=null&&r.length&&(t.normals=e.normals),(o=e.indices)!=null&&o.length&&(t.indices=e.indices.map(c=>Math.round(c))),(i=e.colors)!=null&&i.length&&(t.colors=e.colors),(s=e.uv)!=null&&s.length&&(t.uv=e.uv),(l=e.meshs)!=null&&l.length&&(t.meshs=e.meshs.map(c=>Mesh.toJSON(c))),t},create(e){return Tube$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l,c,f;const t=createBaseTube();return t.name=(n=e.name)!=null?n:"",t.origin=e.origin!==void 0&&e.origin!==null?Vertex.fromPartial(e.origin):void 0,t.type=(a=e.type)!=null?a:"",t.sliceList=((r=e.sliceList)==null?void 0:r.map(u=>Tube_Slice.fromPartial(u)))||[],t.vertices=((o=e.vertices)==null?void 0:o.map(u=>u))||[],t.normals=((i=e.normals)==null?void 0:i.map(u=>u))||[],t.indices=((s=e.indices)==null?void 0:s.map(u=>u))||[],t.colors=((l=e.colors)==null?void 0:l.map(u=>u))||[],t.uv=((c=e.uv)==null?void 0:c.map(u=>u))||[],t.meshs=((f=e.meshs)==null?void 0:f.map(u=>Mesh.fromPartial(u)))||[],t}};function createBaseTube_Slice(){return{position:void 0,start:void 0,end:void 0,color:void 0,angle:0,radius:0,innerRadius:0,texture:"",v:[]}}const Tube_Slice={encode(e,t=minimal.Writer.create()){e.position!==void 0&&Vertex.encode(e.position,t.uint32(10).fork()).ldelim(),e.start!==void 0&&Vertex.encode(e.start,t.uint32(18).fork()).ldelim(),e.end!==void 0&&Vertex.encode(e.end,t.uint32(26).fork()).ldelim(),e.color!==void 0&&Color.encode(e.color,t.uint32(34).fork()).ldelim(),e.angle!==0&&t.uint32(45).float(e.angle),e.radius!==0&&t.uint32(53).float(e.radius),e.innerRadius!==0&&t.uint32(69).float(e.innerRadius),e.texture!==""&&t.uint32(74).string(e.texture);for(const n of e.v)t.uint32(82).string(n);return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseTube_Slice();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.position=Vertex.decode(n,n.uint32());continue;case 2:if(o!==18)break;r.start=Vertex.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.end=Vertex.decode(n,n.uint32());continue;case 4:if(o!==34)break;r.color=Color.decode(n,n.uint32());continue;case 5:if(o!==45)break;r.angle=n.float();continue;case 6:if(o!==53)break;r.radius=n.float();continue;case 8:if(o!==69)break;r.innerRadius=n.float();continue;case 9:if(o!==74)break;r.texture=n.string();continue;case 10:if(o!==82)break;r.v.push(n.string());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{position:isSet$4(e.position)?Vertex.fromJSON(e.position):void 0,start:isSet$4(e.start)?Vertex.fromJSON(e.start):void 0,end:isSet$4(e.end)?Vertex.fromJSON(e.end):void 0,color:isSet$4(e.color)?Color.fromJSON(e.color):void 0,angle:isSet$4(e.angle)?globalThis.Number(e.angle):0,radius:isSet$4(e.radius)?globalThis.Number(e.radius):0,innerRadius:isSet$4(e.innerRadius)?globalThis.Number(e.innerRadius):0,texture:isSet$4(e.texture)?globalThis.String(e.texture):"",v:globalThis.Array.isArray(e==null?void 0:e.v)?e.v.map(t=>globalThis.String(t)):[]}},toJSON(e){var n;const t={};return e.position!==void 0&&(t.position=Vertex.toJSON(e.position)),e.start!==void 0&&(t.start=Vertex.toJSON(e.start)),e.end!==void 0&&(t.end=Vertex.toJSON(e.end)),e.color!==void 0&&(t.color=Color.toJSON(e.color)),e.angle!==0&&(t.angle=e.angle),e.radius!==0&&(t.radius=e.radius),e.innerRadius!==0&&(t.innerRadius=e.innerRadius),e.texture!==""&&(t.texture=e.texture),(n=e.v)!=null&&n.length&&(t.v=e.v),t},create(e){return Tube_Slice.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=createBaseTube_Slice();return t.position=e.position!==void 0&&e.position!==null?Vertex.fromPartial(e.position):void 0,t.start=e.start!==void 0&&e.start!==null?Vertex.fromPartial(e.start):void 0,t.end=e.end!==void 0&&e.end!==null?Vertex.fromPartial(e.end):void 0,t.color=e.color!==void 0&&e.color!==null?Color.fromPartial(e.color):void 0,t.angle=(n=e.angle)!=null?n:0,t.radius=(a=e.radius)!=null?a:0,t.innerRadius=(r=e.innerRadius)!=null?r:0,t.texture=(o=e.texture)!=null?o:"",t.v=((i=e.v)==null?void 0:i.map(s=>s))||[],t}};function isSet$4(e){return e!=null}const TubeComponent$2=(e,t)=>{const n=React.useRef(null),a=React.useContext(WorkspaceMetaContext),{id:r,name:o,visible:i=!0,position:s,children:l,isRegular:c=!0}=e;return React.useImperativeHandle(t,()=>n.current,[]),jsxRuntime.jsx("transformNode",{name:`node-${o}-${r}`,setEnabled:i,position:s?s.multiply(calcTransformNodeScale(a)):new EngineCore.Vector3(0,0,0),scaling:c?calcTransformNodeScale(a):EngineCore.Vector3.One(),ref:n,children:l})},TubeComponent$3=React.forwardRef(TubeComponent$2),TubeAction=e=>{const t=reactBabylonjs.useScene(),n=React.useRef(null),{title:a,url:r,color:o,v:i,actions:s,path:l,radius:c,mesh:f}=e;return React.useEffect(()=>{n.current&&(n.current.metadata={pickable:s?{name:a,onLeftClick:s.onLeftClick,onRightClick:s.onRightClick,onMiddleClick:s.onMiddleClick,onHover:s.onHover,extra:i}:null})},[s,a,i]),React.useEffect(()=>{if(n.current){const u=new EngineCore.VertexData;u.positions=f.vertices,u.indices=f.indices,u.normals=f.normals,u.uvs=f.uv,u.applyToMesh(n.current)}},[f.indices,f.normals,f.uv,f.vertices,l,c,t]),jsxRuntime.jsx("mesh",{name:"mesh",ref:n,children:jsxRuntime.jsx("standardMaterial",{name:"material",diffuseColor:r===""?new EngineCore.Color3(o.r,o.g,o.b):void 0,diffuseTexture:r!==""?new EngineCore.Texture(r):void 0})})},TubeAction$1=TubeAction,TubeLod=(e,t)=>{const{name:n,position:a,slices:r,meshs:o,actions:i}=e,s=React.useRef(null);return React.useImperativeHandle(t,()=>s.current,[]),jsxRuntime.jsx("transformNode",{name:"lod0",ref:s,setEnabled:!1,children:a&&r.map((l,c)=>{var f,u,d,h,m,R;return jsxRuntime.jsx(TubeAction$1,{id:c,v:l.v,position:a.add(new EngineCore.Vector3(0,0,0)),path:[new EngineCore.Vector3((f=l.start)==null?void 0:f.x,(u=l.start)==null?void 0:u.y,(d=l.start)==null?void 0:d.z),new EngineCore.Vector3((h=l.end)==null?void 0:h.x,(m=l.end)==null?void 0:m.y,(R=l.end)==null?void 0:R.z)],radius:l.radius,actions:i,mesh:o[c],title:n,color:l.color?new EngineCore.Color4(l.color.r,l.color.g,l.color.b,l.color.a):new EngineCore.Color4(0,0,0,1),url:l.texture},c)})})},TubeLod$1=React.forwardRef(TubeLod),TubeMain$2=e=>{const t=reactBabylonjs.useScene(),n=React.useRef(null),a=React.useContext(WorkspaceMetaContext),{id:r,vertices:o,indices:i,colors:s,color:l,materialType:c="custom",alphaBlend:f=!1,alpha:u=1,slices:d,position:h,name:m="tube",actions:R}=e;React.useEffect(()=>{n.current&&(n.current.metadata={pickable:R?{name:"",needWorldPosition:!0,onLeftClick:R.onLeftClick,onRightClick:R.onRightClick,onMiddleClick:R.onMiddleClick,onHover:(g,x,y,E,k)=>{var b,C,_,A,N,S;if(R.onHover&&t&&d&&y){const I=y;for(let O=0;O<d.length;O++){const F=new EngineCore.Vector3((b=d[O].start)==null?void 0:b.x,(C=d[O].start)==null?void 0:C.y,(_=d[O].start)==null?void 0:_.z).add(h).multiply(calcTransformNodeScale(a)),w=new EngineCore.Vector3((A=d[O].end)==null?void 0:A.x,(N=d[O].end)==null?void 0:N.y,(S=d[O].end)==null?void 0:S.z).add(h).multiply(calcTransformNodeScale(a)),L=EngineCore.MeshBuilder.CreateTube("boundingbox-tmp",{path:[F,w],radiusFunction:()=>{const D=d[O].radius;return D||1},cap:EngineCore.Mesh.NO_CAP,tessellation:8,sideOrientation:EngineCore.Mesh.DOUBLESIDE},t),B=L.getBoundingInfo().intersectsPoint(I);if(L.dispose(),B){R.onHover(g,new EngineCore.Vector2(t==null?void 0:t.pointerX,t==null?void 0:t.pointerY),y,E,k,d[O].v);break}}}}}:null})},[R,a,h,t,d]),React.useEffect(()=>{if(n&&n.current&&t){const g=new EngineCore.VertexData;g.positions=o,g.indices=i,s&&c!=="pbr-dark"&&c!=="standard"&&c!=="pbr-light"&&(g.colors=s),g.applyToMesh(n.current)}},[i,o,t,s,r,c]);const v=React.useCallback(()=>{if(c==="custom")return jsxRuntime.jsx(CustomShader$1,{name:`${m}-material-${r}`,vertex:flatVertexSource,fragment:flatFragmentSource,needDepthPrePass:!1,transparencyMode:f?EngineCore.Material.MATERIAL_ALPHABLEND:EngineCore.Material.MATERIAL_OPAQUE,options:{needAlphaBlending:!!f}});if(c==="standard")return jsxRuntime.jsx("standardMaterial",{name:`${m}-material`,alphaMode:EngineCore.Engine.ALPHA_COMBINE,transparencyMode:f?EngineCore.Material.MATERIAL_ALPHABLEND:EngineCore.Material.MATERIAL_OPAQUE,alpha:u,diffuseColor:l||void 0});if(c==="pbr-light")return jsxRuntime.jsx(LightMetalMaterial,{alpha:u});if(c==="pbr-dark")return jsxRuntime.jsx(DarkMetalMaterial,{alpha:u})},[u,f,l,r,c,m]);return jsxRuntime.jsx("transformNode",{name:`${m}-main-node`,children:jsxRuntime.jsx("mesh",{name:`${m}-mesh`,ref:n,isPickable:!0,children:v()})})},TubeMain$3=TubeMain$2,TubeLod1=(e,t)=>{const{id:n,visible:a=!0,materialType:r="custom",vertices:o,indices:i,colors:s,color:l,slices:c,position:f,actions:u}=e,d=React.useRef(null);return React.useImperativeHandle(t,()=>d.current,[]),jsxRuntime.jsx("transformNode",{name:"lod1",ref:d,setEnabled:!1,children:o.length>0&&jsxRuntime.jsx(TubeMain$3,{id:n,visible:a,vertices:o,indices:i,colors:s.length>0?s:void 0,materialType:r,alpha:1,color:l,alphaBlend:!1,position:f,actions:u,slices:c})})},TubeLod1$1=React.forwardRef(TubeLod1),TubeTitle=(e,t)=>{const n=React.useRef(null),a=React.useContext(WorkspaceMetaContext),{style:r,name:o="tube"}=e;return React.useImperativeHandle(t,()=>n.current,[]),jsxRuntime.jsx("transformNode",{name:`${o}-title`,position:r.position?r.position.add(r.offset?r.offset:new EngineCore.Vector3(0,0,0)):new EngineCore.Vector3(0,0,0).add(r.offset?r.offset:new EngineCore.Vector3(0,0,0)),scaling:calcGUIScale(a),ref:n,setEnabled:!1,children:r.title&&jsxRuntime.jsx(GUIText$1,{text:r.title,fontSize:r.fontSize?r.fontSize:40,color:r.color?r.color:"black"})})},TubeTitle$1=React.forwardRef(TubeTitle),Tube=e=>{var Q,G,ge,fe;const t=reactBabylonjs.useScene(),[n,a]=React.useState([]),[r,o]=React.useState([]),[i,s]=React.useState([]),l=React.useRef(null),c=React.useRef(null),f=React.useRef(null),[u,d]=React.useState(""),[h,m]=React.useState(new EngineCore.Vector3(0,0,0)),R=React.useRef(null),v=React.useRef(null),g=React.useRef(null),[x,y]=React.useState([]),E=React.useRef(!1),k=React.useContext(WorkspaceMetaContext),[b,C]=React.useState([]),[_,A]=React.useState(!1),[N,S]=React.useState(!1),{id:I,url:O,color:F,visible:w=!0,materialType:L="custom",children:B,style:D,actions:W,noLod:ae=!1,lodDistance:ee=[200,1e3],loadDistance:H=0,offset:oe=new EngineCore.Vector3(0,0,0),position:te,topPosition:K,bottomPosition:Z,isRegular:ce=!0}=e;return React.useEffect(()=>{te&&K&&Z?(l.current=te,c.current=K,f.current=Z):S(!0)},[Z,te,K]),React.useEffect(()=>{!E.current&&N&&(E.current=!0,axios.get(O,{responseType:"arraybuffer"}).then(V=>{var ue,ne,de,_e,ye,Te,Ee,Se,be;const J=Tube$2.decode(new Uint8Array(V.data));console.log(J);const Re=J.sliceList[0],Ce=J.sliceList[J.sliceList.length-1];d(J.name);const Y=e.style.basePosition&&e.style.basePosition==="top"?Re.start:Ce.end;m(new EngineCore.Vector3(Y==null?void 0:Y.x,Y==null?void 0:Y.y,Y==null?void 0:Y.z)),l.current=new EngineCore.Vector3((ue=J.origin)==null?void 0:ue.x,(ne=J.origin)==null?void 0:ne.y,(de=J.origin)==null?void 0:de.z).add(oe),y(J.sliceList.filter(Ae=>Ae.v)),c.current=new EngineCore.Vector3((_e=Re.start)==null?void 0:_e.x,(ye=Re.start)==null?void 0:ye.y,(Te=Re.start)==null?void 0:Te.z).add(l.current),f.current=new EngineCore.Vector3((Ee=Ce.end)==null?void 0:Ee.x,(Se=Ce.end)==null?void 0:Se.y,(be=Ce.end)==null?void 0:be.z).add(l.current),C(J.meshs),a(J.vertices),o(L==="custom"?TubeUtil.correctTubeMainIndices(J.indices):J.indices),s(J.colors)}))},[O,t,F,L,e.style.basePosition,oe,N,k]),React.useEffect(()=>{const V=setInterval(()=>{var J,Re,Ce,Y,ue,ne,de,_e,ye,Te,Ee,Se,be,Ae;if(t&&t.cameras.length>0&&t.activeCamera&&l.current&&c.current&&f.current){const Ie=TubeUtil.calcLodDistance(c.current.multiply(calcTransformNodeScale(k)),l.current.multiply(calcTransformNodeScale(k)),f.current.multiply(calcTransformNodeScale(k)),t.activeCamera.position);Ie>=H&&S(!0),ae?(b.length===0?((J=R.current)==null||J.setEnabled(!0),(Re=v.current)==null||Re.setEnabled(!1)):((Ce=R.current)==null||Ce.setEnabled(!1),(Y=v.current)==null||Y.setEnabled(!0)),(ue=g.current)==null||ue.setEnabled(!0)):Ie<ee[0]?(A(!0),(ne=R.current)==null||ne.setEnabled(!0),(de=v.current)==null||de.setEnabled(b.length===0),(_e=g.current)==null||_e.setEnabled(!0)):ee[1]&&Ie<ee[1]?((ye=R.current)==null||ye.setEnabled(!1),(Te=v.current)==null||Te.setEnabled(!0),(Ee=g.current)==null||Ee.setEnabled(!0)):((Se=R.current)==null||Se.setEnabled(!1),(be=v.current)==null||be.setEnabled(!1),(Ae=g.current)==null||Ae.setEnabled(!1))}},1e3);return()=>{clearInterval(V)}},[H,ee,b.length,k,t]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("transformNode",{name:`tube-${I} `,children:[jsxRuntime.jsxs(TubeComponent$3,{id:I,name:u,visible:w,position:(Q=l.current)!=null?Q:new EngineCore.Vector3(0,0,0),isRegular:ce,children:[N&&jsxRuntime.jsx(TubeTitle$1,{id:I,style:{title:u,position:h,offset:(G=D.offset)==null?void 0:G.multiply(calcInvTransformNodeScale(k)),fontSize:D.fontSize,color:D.color},ref:g}),_&&N&&ee[0]&&b.length>0&&jsxRuntime.jsx(TubeLod$1,{id:I,name:u,meshs:b,position:(ge=l.current)!=null?ge:new EngineCore.Vector3(0,0,0),materialType:L,slices:x,actions:W,ref:R}),N&&jsxRuntime.jsx(TubeLod1$1,{id:I,name:u,position:(fe=l.current)!=null?fe:new EngineCore.Vector3(0,0,0),vertices:n,indices:r,colors:i,color:F?new EngineCore.Color3(F.r,F.g,F.b):void 0,slices:x,actions:W,materialType:L,ref:v})]}),B]})})},Tube$1=Tube;function createBaseTubeGroup(){return{group:[]}}const TubeGroup={encode(e,t=minimal.Writer.create()){for(const n of e.group)Tube$2.encode(n,t.uint32(10).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseTubeGroup();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.group.push(Tube$2.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{group:globalThis.Array.isArray(e==null?void 0:e.group)?e.group.map(t=>Tube$2.fromJSON(t)):[]}},toJSON(e){var n;const t={};return(n=e.group)!=null&&n.length&&(t.group=e.group.map(a=>Tube$2.toJSON(a))),t},create(e){return TubeGroup.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=createBaseTubeGroup();return t.group=((n=e.group)==null?void 0:n.map(a=>Tube$2.fromPartial(a)))||[],t}},TubeInstance=e=>{const t=reactBabylonjs.useScene(),[n,a]=React.useState([]),r=React.useRef(!1),o=React.useContext(WorkspaceMetaContext),{visible:i=!0,groupUrl:s,modelUrl:l,group:c,actions:f}=e,u=React.useCallback((d,h)=>h?new EngineCore.Color4(h==null?void 0:h.r,h==null?void 0:h.g,h==null?void 0:h.b,h==null?void 0:h.a):d||new EngineCore.Color4(1,1,1,1),[]);return React.useEffect(()=>{if(!r.current&&(r.current=!0,s&&axios.get(s,{responseType:"arraybuffer"}).then(d=>{const h=TubeGroup.decode(new Uint8Array(d.data)),m=[];for(let R=0;R<h.group.length;R++)m.push(h.group[R]);a(m)}),c&&c.length>0)){const d=[];for(let h=0;h<c.length;h++)d.push(axios.get(c[h].url,{responseType:"arraybuffer"}));Promise.all(d).then(h=>{const m=[];for(let R=0;R<h.length;R++){const v=Tube$2.decode(new Uint8Array(h[R].data));m.push(v)}a(m)})}}),React.useEffect(()=>{var h,m,R,v,g,x,y,E,k;let d;if(n.length>0){const b=[],C=[];for(let _=0;_<n.length;_++){const A=n[_],N=new EngineCore.Vector3((h=A.origin)==null?void 0:h.x,(m=A.origin)==null?void 0:m.y,(R=A.origin)==null?void 0:R.z),S=A.sliceList;if(S){const I=[],O=[];for(let F=0;F<S.length;F++)I.push(N.add(new EngineCore.Vector3((v=S[F].start)==null?void 0:v.x,(g=S[F].start)==null?void 0:g.y,(x=S[F].start)==null?void 0:x.z)).multiply(calcTransformNodeScale(o))),O.push(u(void 0,S[F].color)),F===S.length-1&&(I.push(N.add(new EngineCore.Vector3((y=S[F].end)==null?void 0:y.x,(E=S[F].end)==null?void 0:E.y,(k=S[F].end)==null?void 0:k.z)).multiply(calcTransformNodeScale(o))),O.push(u(void 0,S[F].color)));b.push(I),C.push(O)}}d=EngineCore.MeshBuilder.CreateLineSystem("linesystem",{lines:b,colors:C},t),d.setEnabled(i)}return()=>{d&&d.dispose()}},[u,o,t,n,i]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:l&&n&&n.length>0?n.map(d=>{var h,m,R,v,g,x;return jsxRuntime.jsx(ModelLoader$1,{position:new EngineCore.Vector3((h=d.origin)==null?void 0:h.x,(m=d.origin)==null?void 0:m.y,(R=d.origin)==null?void 0:R.z).add(new EngineCore.Vector3((v=d.sliceList[0].start)==null?void 0:v.x,(g=d.sliceList[0].start)==null?void 0:g.y,(x=d.sliceList[0].start)==null?void 0:x.z)).multiply(calcTransformNodeScale(o)),name:"model-tube-instance",url:l,visible:i,actions:f},d.name)}):jsxRuntime.jsx(jsxRuntime.Fragment,{})})},TubeInstance$1=TubeInstance,TubeTool=e=>{const t=React.useContext(WorkspaceMetaContext),{position:n=EngineCore.Vector3.Zero(),localScale:a=1,scaleMode:r=ScaleMode.NONE}=e,[o,i]=React.useState(1),{modelRoation:s=new EngineCore.Vector3(0,0,0)}=e,l=React.useRef(null);return React.useEffect(()=>{switch(r){case ScaleMode.PLANE:i((t&&t.scalePlane?t.scalePlane:1)*a);break;case ScaleMode.DEPTH:i((t&&t.scaleDepth?t.scaleDepth:1)*a);break;case ScaleMode.NONE:i(a);break}},[a,t,r]),React.useEffect(()=>{let c;return l.current&&(c=setInterval(()=>{var f;if(((f=l.current)==null?void 0:f.getChildren().length)===2){const u=l.current.getChildren()[1];u.rotation=s,c&&clearInterval(c)}},500)),()=>{c&&clearInterval(c)}},[s]),jsxRuntime.jsx(ModelLoader$1,{...e,position:n.multiplyByFloats(t&&t.scalePlane?t.scalePlane:1,t&&t.scaleDepth?t.scaleDepth:1,t&&t.scalePlane?t.scalePlane:1),localScale:o,ref:l})},TubeTool$1=TubeTool;function createBaseTubeChart(){return{name:"",tubeName:"",min:0,max:0,origin:void 0,chart:[]}}const TubeChart$2={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.tubeName!==""&&t.uint32(18).string(e.tubeName),e.min!==0&&t.uint32(29).float(e.min),e.max!==0&&t.uint32(37).float(e.max),e.origin!==void 0&&Vertex.encode(e.origin,t.uint32(42).fork()).ldelim();for(const n of e.chart)TubeChart_ChartData.encode(n,t.uint32(50).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseTubeChart();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.tubeName=n.string();continue;case 3:if(o!==29)break;r.min=n.float();continue;case 4:if(o!==37)break;r.max=n.float();continue;case 5:if(o!==42)break;r.origin=Vertex.decode(n,n.uint32());continue;case 6:if(o!==50)break;r.chart.push(TubeChart_ChartData.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$3(e.name)?globalThis.String(e.name):"",tubeName:isSet$3(e.tubeName)?globalThis.String(e.tubeName):"",min:isSet$3(e.min)?globalThis.Number(e.min):0,max:isSet$3(e.max)?globalThis.Number(e.max):0,origin:isSet$3(e.origin)?Vertex.fromJSON(e.origin):void 0,chart:globalThis.Array.isArray(e==null?void 0:e.chart)?e.chart.map(t=>TubeChart_ChartData.fromJSON(t)):[]}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),e.tubeName!==""&&(t.tubeName=e.tubeName),e.min!==0&&(t.min=e.min),e.max!==0&&(t.max=e.max),e.origin!==void 0&&(t.origin=Vertex.toJSON(e.origin)),(n=e.chart)!=null&&n.length&&(t.chart=e.chart.map(a=>TubeChart_ChartData.toJSON(a))),t},create(e){return TubeChart$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=createBaseTubeChart();return t.name=(n=e.name)!=null?n:"",t.tubeName=(a=e.tubeName)!=null?a:"",t.min=(r=e.min)!=null?r:0,t.max=(o=e.max)!=null?o:0,t.origin=e.origin!==void 0&&e.origin!==null?Vertex.fromPartial(e.origin):void 0,t.chart=((i=e.chart)==null?void 0:i.map(s=>TubeChart_ChartData.fromPartial(s)))||[],t}};function createBaseTubeChart_ChartData(){return{position:void 0,depth:0,value:0}}const TubeChart_ChartData={encode(e,t=minimal.Writer.create()){return e.position!==void 0&&Vertex.encode(e.position,t.uint32(10).fork()).ldelim(),e.depth!==0&&t.uint32(21).float(e.depth),e.value!==0&&t.uint32(29).float(e.value),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseTubeChart_ChartData();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.position=Vertex.decode(n,n.uint32());continue;case 2:if(o!==21)break;r.depth=n.float();continue;case 3:if(o!==29)break;r.value=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{position:isSet$3(e.position)?Vertex.fromJSON(e.position):void 0,depth:isSet$3(e.depth)?globalThis.Number(e.depth):0,value:isSet$3(e.value)?globalThis.Number(e.value):0}},toJSON(e){const t={};return e.position!==void 0&&(t.position=Vertex.toJSON(e.position)),e.depth!==0&&(t.depth=e.depth),e.value!==0&&(t.value=e.value),t},create(e){return TubeChart_ChartData.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseTubeChart_ChartData();return t.position=e.position!==void 0&&e.position!==null?Vertex.fromPartial(e.position):void 0,t.depth=(n=e.depth)!=null?n:0,t.value=(a=e.value)!=null?a:0,t}};function isSet$3(e){return e!=null}const billboardFragmentSource=`#version 300 es
|
|
1296
1296
|
precision highp float;
|
|
1297
1297
|
|
|
1298
1298
|
in vec2 vUV;
|
|
@@ -1331,4 +1331,4 @@ void main(void) {
|
|
|
1331
1331
|
vUV = uv;
|
|
1332
1332
|
|
|
1333
1333
|
vColor = color;
|
|
1334
|
-
}`,BillboardMaterial=e=>{const t=React.useRef(null),{billboardMode:n="All",zOffset:a,zOffsetUnits:r}=e,[o,i]=React.useState(),s=reactBabylonjs.useScene();return React.useEffect(()=>{const l=()=>{const c=s==null?void 0:s.activeCamera;i(c==null?void 0:c.getDirection(EngineCore.Vector3.Right()))};return s&&s.activeCamera&&(l(),s==null||s.activeCamera.onViewMatrixChangedObservable.add(l)),()=>{s&&s.activeCamera&&(s==null||s.activeCamera.onViewMatrixChangedObservable.removeCallback(l))}},[s]),React.useEffect(()=>{t.current&&o&&(t.current.setVector3("direction",o),t.current.setFloat("billboardMode",n==="all"?1:0),a!==void 0&&r!==void 0&&(t.current.zOffset=a,t.current.zOffsetUnits=r))},[n,o,a,r]),jsxRuntime.jsx(CustomShader$1,{ref:t,name:e.name,backFaceCulling:!1,needDepthPrePass:e.needDepthPrePass,vertex:billboardVertexSource,fragment:billboardFragmentSource,transparencyMode:e.transparencyMode,alphaMode:e.alphaMode,options:{attributes:["position","normal","uv"],uniforms:["world","worldViewProjection","textureSampler","direction"],needAlphaBlending:!0},zOffset:e.zOffset,zOffsetUnits:e.zOffsetUnits,sideOrientation:EngineCore.Material.CounterClockWiseSideOrientation})},BillboardMaterial$1=BillboardMaterial,TubeChartComponent=(e,t)=>{const n=reactBabylonjs.useScene(),a=React.useRef(null),r=React.useRef(null),o=React.useContext(WorkspaceMetaContext),{id:i,visible:s=!0,vertices:l,indices:c,colors:f,uvs:u,position:d,customMaterial:h}=e,{title:m,color:R,fontSize:v}=e.style;return React.useImperativeHandle(t,()=>r.current,[]),React.useEffect(()=>{if(n&&a.current){const g=new EngineCore.VertexData;g.positions=l,g.indices=c,g.colors=f,g.uvs=u,g.applyToMesh(a.current)}},[f,h,i,c,n,u,l]),jsxRuntime.jsxs("transformNode",{name:`node-curve-${i}`,position:d?d.multiply(new EngineCore.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1)):new EngineCore.Vector3(0,0,0),scaling:new EngineCore.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1),ref:r,setEnabled:s,children:[jsxRuntime.jsx("mesh",{name:"curve",ref:a,scaling:new EngineCore.Vector3(1,1,1),children:h?jsxRuntime.jsx(BillboardMaterial$1,{name:`material-${i}`,billboardMode:"none"}):jsxRuntime.jsx("standardMaterial",{name:`material-${i}`,backFaceCulling:!1})}),jsxRuntime.jsx("transformNode",{name:"title",position:e.style.position?e.style.position:new EngineCore.Vector3(0,0,0),scaling:calcGUIScale(o),children:m&&jsxRuntime.jsx(GUIText$1,{text:m,fontSize:v||40,color:R||"white"})})]})},TubeChartComponent$1=React.forwardRef(TubeChartComponent),TubeChart=e=>{var O,F;const t=reactBabylonjs.useScene(),[n,a]=React.useState([]),[r,o]=React.useState([]),[i,s]=React.useState([]),[l,c]=React.useState([]),[f,u]=React.useState(),[d,h]=React.useState(),[m,R]=React.useState(),{colorCodecs:v}=React.useContext(ColorProviderContext),{id:g,url:x,callback:y,visible:E=!0,customMaterial:k=!1,colorType:b,width:C=20,offset:_=new EngineCore.Vector3(0,0,0),direction:A="right"}=e,N=useCachedBinary({url:x,cacheType:CacheType.EXACTLY_MATCH}),S=React.useCallback((L,w,B,D,W=!0)=>{if(t){const ae=EngineCore.MeshBuilder.CreateRibbon("ribbon",{pathArray:[B,D],sideOrientation:W?EngineCore.Mesh.FRONTSIDE:EngineCore.Mesh.DOUBLESIDE},t),ne=ae.getVerticesData(EngineCore.VertexBuffer.PositionKind),U=ae.getIndices();if(ne&&U){const re=TubeUtil.buildTubeChartColors(ne,Z=>{if(b&&v&&v[b]){const de=L.max,ee=L.min;let G=new EngineCore.Color3(1,1,1);return ee===ee?G=v[b].array[v[b].array.length-1]:G=v[b].array[Math.trunc((L.chart[Z].value-ee)/(de-ee)*(v[b].array.length-1))],new EngineCore.Color4(G.r,G.g,G.b,1)}return y?y(w[Z],Z,L.max,L.min):TubeUtil.colorMapTubeChart()},W),te=[],K=ne.length/3;for(let Z=0;Z<K;Z++)Z>=K/2?te.push(D[Z-K/2].x-B[Z-K/2].x,1):te.push(0,1);a(ne.slice()),o(U.slice()),s(re),c(te)}t==null||t.removeMesh(ae)}},[y,v,b,t]);React.useEffect(()=>{var L,w,B,D,W;if(N){const ae=TubeChart$2.decode(new Uint8Array(N)),ne=C/(ae.max-ae.min),U=ae.min<0?-ae.min:0,re=A==="right"?C/2:C;console.log(ae);const te=[],K=ae.chart.map(G=>{const ge=G.position?G.position:{x:0,y:0,z:0};return te.push(G.value),new EngineCore.Vector3(ge.x-re,ge.y+10,ge.z)}),Z=ae.chart.map(G=>{const ge=G.position?G.position:{x:0,y:0,z:0},fe=A==="right"?(G.value+U)*ne:-(G.value+U)*ne;return new EngineCore.Vector3(ge.x+fe-re,ge.y+10,ge.z)});R(ae.name),u(new EngineCore.Vector3((L=ae.origin)==null?void 0:L.x,(w=ae.origin)==null?void 0:w.y,(B=ae.origin)==null?void 0:B.z).add(_));const de=C/2-((D=e.style)!=null&&D.fontSize?e.style.fontSize/2:0),ee=K[K.length-1].add(new EngineCore.Vector3(A==="right"?de:-de,0,0)).add((W=e.style)!=null&&W.offset?e.style.offset:new EngineCore.Vector3(0,0,0));h(new EngineCore.Vector3(ee.x,ee.y,ee.z)),S(ae,te,K.splice(0,K.length),Z.splice(0,Z.length),!0)}},[S,x,t,_,(O=e.style)==null?void 0:O.offset,C,(F=e.style)==null?void 0:F.fontSize,N,A]);const I=React.useCallback(()=>{},[]);return React.useEffect(()=>{const L=()=>{I()};return t&&t.activeCamera&&(L(),t==null||t.activeCamera.onViewMatrixChangedObservable.add(L)),()=>{t&&t.activeCamera&&(t==null||t.activeCamera.onViewMatrixChangedObservable.removeCallback(L))}},[I,t]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:E&&n.length>0&&i.length>0&&jsxRuntime.jsx(TubeChartComponent$1,{id:g,visible:E,vertices:n,colors:i,uvs:l,indices:r,position:f,style:{...e.style,title:m,position:d},customMaterial:k})})},TubeChart$1=TubeChart,TubeChartLineComponent=e=>{const t=React.useRef(null),n=React.useContext(WorkspaceMetaContext),{id:a,visible:r=!0,position:o}=e,{title:i,color:s,fontSize:l}=e.style;return jsxRuntime.jsx("transformNode",{name:`node-curve-${a}`,position:o?o.multiply(new EngineCore.Vector3(n?n.scalePlane:1,n?n.scaleDepth:1,n?n.scalePlane:1)):new EngineCore.Vector3(0,0,0),scaling:new EngineCore.Vector3(n?n.scalePlane:1,n?n.scaleDepth:1,n?n.scalePlane:1),ref:t,setEnabled:r,children:jsxRuntime.jsx("transformNode",{name:"title",position:e.style.position?e.style.position:new EngineCore.Vector3(0,0,0),scaling:calcGUIScale(n),children:i&&jsxRuntime.jsx(GUIText$1,{text:i,fontSize:l||40,color:s||"white"})})})},TubeChartLineComponent$1=TubeChartLineComponent,TubeChartLine=e=>{var x,y;const t=reactBabylonjs.useScene(),[n,a]=React.useState(),[r,o]=React.useState(),[i,s]=React.useState(),[l,c]=React.useState([]),{id:f,url:u,visible:d=!0,offset:h=new EngineCore.Vector3(0,0,0),color:m,width:R=20}=e,v=useCachedBinary({url:u,cacheType:CacheType.EXACTLY_MATCH}),g=React.useContext(WorkspaceMetaContext);return React.useEffect(()=>{var E,k,b,C,_,A,N,S;if(v){const I=TubeChart$2.decode(new Uint8Array(v)),O=R/(I.max-I.min),F=I.min<0?-I.min:0,L=new EngineCore.Vector3((E=I.origin)==null?void 0:E.x,(k=I.origin)==null?void 0:k.y,(b=I.origin)==null?void 0:b.z).add(h);a(L);const w=I.chart,B=[];for(let W=0;W<w.length;W++)B.push(L.add(new EngineCore.Vector3((C=w[W].position)==null?void 0:C.x,(_=w[W].position)==null?void 0:_.y,(A=w[W].position)==null?void 0:A.z)).add(new EngineCore.Vector3((w[W].value+F)*O,0,0)).multiply(calcTransformNodeScale(g)));c([B]);const D=w[w.length-1].position;if(D){const W=new EngineCore.Vector3(D.x,D.y,D.z).add(new EngineCore.Vector3(R/2-((N=e.style)!=null&&N.fontSize?e.style.fontSize/2:0),0,0)).add((S=e.style)!=null&&S.offset?e.style.offset:new EngineCore.Vector3(0,0,0));o(new EngineCore.Vector3(W.x,W.y,W.z))}s(I.name)}},[u,t,h,(x=e.style)==null?void 0:x.offset,(y=e.style)==null?void 0:y.fontSize,v,g,R]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TubeChartLineComponent$1,{id:f,visible:d,position:n,style:{...e.style,title:i,position:r}}),l.length>0&&jsxRuntime.jsx("lineSystem",{name:"line",lines:l,color:m,setEnabled:d})]})},TubeChartLine$1=TubeChartLine;function createBaseLayer(){return{name:"",origin:void 0,layerList:[]}}const Layer={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.origin!==void 0&&Vertex.encode(e.origin,t.uint32(18).fork()).ldelim();for(const n of e.layerList)Layer_LayerSlice.encode(n,t.uint32(26).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseLayer();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.origin=Vertex.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.layerList.push(Layer_LayerSlice.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$2(e.name)?globalThis.String(e.name):"",origin:isSet$2(e.origin)?Vertex.fromJSON(e.origin):void 0,layerList:globalThis.Array.isArray(e==null?void 0:e.layerList)?e.layerList.map(t=>Layer_LayerSlice.fromJSON(t)):[]}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),e.origin!==void 0&&(t.origin=Vertex.toJSON(e.origin)),(n=e.layerList)!=null&&n.length&&(t.layerList=e.layerList.map(a=>Layer_LayerSlice.toJSON(a))),t},create(e){return Layer.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseLayer();return t.name=(n=e.name)!=null?n:"",t.origin=e.origin!==void 0&&e.origin!==null?Vertex.fromPartial(e.origin):void 0,t.layerList=((a=e.layerList)==null?void 0:a.map(r=>Layer_LayerSlice.fromPartial(r)))||[],t}};function createBaseLayer_LayerSlice(){return{name:"",position:void 0,start:void 0,end:void 0,radius:0,colorId:0,v:[]}}const Layer_LayerSlice={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.position!==void 0&&Vertex.encode(e.position,t.uint32(18).fork()).ldelim(),e.start!==void 0&&Vertex.encode(e.start,t.uint32(26).fork()).ldelim(),e.end!==void 0&&Vertex.encode(e.end,t.uint32(34).fork()).ldelim(),e.radius!==0&&t.uint32(45).float(e.radius),e.colorId!==0&&t.uint32(53).float(e.colorId);for(const n of e.v)t.uint32(58).string(n);return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseLayer_LayerSlice();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.position=Vertex.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.start=Vertex.decode(n,n.uint32());continue;case 4:if(o!==34)break;r.end=Vertex.decode(n,n.uint32());continue;case 5:if(o!==45)break;r.radius=n.float();continue;case 6:if(o!==53)break;r.colorId=n.float();continue;case 7:if(o!==58)break;r.v.push(n.string());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$2(e.name)?globalThis.String(e.name):"",position:isSet$2(e.position)?Vertex.fromJSON(e.position):void 0,start:isSet$2(e.start)?Vertex.fromJSON(e.start):void 0,end:isSet$2(e.end)?Vertex.fromJSON(e.end):void 0,radius:isSet$2(e.radius)?globalThis.Number(e.radius):0,colorId:isSet$2(e.colorId)?globalThis.Number(e.colorId):0,v:globalThis.Array.isArray(e==null?void 0:e.v)?e.v.map(t=>globalThis.String(t)):[]}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),e.position!==void 0&&(t.position=Vertex.toJSON(e.position)),e.start!==void 0&&(t.start=Vertex.toJSON(e.start)),e.end!==void 0&&(t.end=Vertex.toJSON(e.end)),e.radius!==0&&(t.radius=e.radius),e.colorId!==0&&(t.colorId=e.colorId),(n=e.v)!=null&&n.length&&(t.v=e.v),t},create(e){return Layer_LayerSlice.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o;const t=createBaseLayer_LayerSlice();return t.name=(n=e.name)!=null?n:"",t.position=e.position!==void 0&&e.position!==null?Vertex.fromPartial(e.position):void 0,t.start=e.start!==void 0&&e.start!==null?Vertex.fromPartial(e.start):void 0,t.end=e.end!==void 0&&e.end!==null?Vertex.fromPartial(e.end):void 0,t.radius=(a=e.radius)!=null?a:0,t.colorId=(r=e.colorId)!=null?r:0,t.v=((o=e.v)==null?void 0:o.map(i=>i))||[],t}};function isSet$2(e){return e!=null}const TubeComponent=(e,t)=>{const n=reactBabylonjs.useScene(),a=React.useRef(null),r=React.useRef(null),o=React.useContext(WorkspaceMetaContext),{id:i,visible:s=!0,vertices:l,indices:c,colors:f,position:u,materialType:d="custom",children:h,alphaBlend:m=!1,alpha:R=1,name:v="tube",actions:g,slices:x}=e;React.useImperativeHandle(t,()=>r.current,[]),React.useEffect(()=>{a.current&&(a.current.metadata={pickable:g?{needWorldPosition:!0,name:v,onLeftClick:g.onLeftClick,onRightClick:g.onRightClick,onMiddleClick:g.onMiddleClick,onHover:(E,k,b,C,_)=>{var A,N,S,I,O,F;if(g.onHover&&n&&x&&b){const L=b;for(let w=0;w<x.length;w++){const B=new EngineCore.Vector3((A=x[w].start)==null?void 0:A.x,(N=x[w].start)==null?void 0:N.y,(S=x[w].start)==null?void 0:S.z).add(u).multiply(calcTransformNodeScale(o)),D=new EngineCore.Vector3((I=x[w].end)==null?void 0:I.x,(O=x[w].end)==null?void 0:O.y,(F=x[w].end)==null?void 0:F.z).add(u).multiply(calcTransformNodeScale(o)),W=Math.sqrt(Math.pow(B.x-D.x,2)+Math.pow(B.y-D.y,2)+Math.pow(B.z-D.z,2)),ae=new EngineCore.Vector3(B.x,B.y-W,B.z),ne=D.subtract(B),U=ae.subtract(B),re=L.subtract(B),te=EngineCore.Vector3.Cross(ne,U),K=Math.acos(EngineCore.Vector3.Dot(ne.normalize(),U.normalize())),Z=EngineCore.Matrix.RotationAxis(te,K),de=EngineCore.Vector3.TransformCoordinates(re,Z);if(0>=de.y&&-W<=de.y){g.onHover(E,k,b,C,x[w],_);break}}}},valueCallback:null,extra:g.extra}:null})},[g,o,u,n,x]),React.useEffect(()=>{if(a&&a.current&&n){const E=new EngineCore.VertexData;E.positions=l,E.indices=c,f&&d!=="pbr-dark"&&d!=="pbr-light"&&(E.colors=f),E.applyToMesh(a.current)}},[c,l,n,f,i,d]);const y=React.useCallback(()=>{if(d==="custom")return jsxRuntime.jsx(CustomShader$1,{name:`${v}-material-${i}`,vertex:flatVertexSource,fragment:flatFragmentSource,needDepthPrePass:!1,transparencyMode:m?EngineCore.Material.MATERIAL_ALPHABLEND:EngineCore.Material.MATERIAL_OPAQUE,options:{needAlphaBlending:!!m}});if(d==="standard")return jsxRuntime.jsx("standardMaterial",{name:`${v}-material`,alphaMode:EngineCore.Engine.ALPHA_COMBINE,transparencyMode:m?EngineCore.Material.MATERIAL_ALPHABLEND:EngineCore.Material.MATERIAL_OPAQUE,alpha:R});if(d==="pbr-light")return jsxRuntime.jsx(LightMetalMaterial,{alpha:R});if(d==="pbr-dark")return jsxRuntime.jsx(DarkMetalMaterial,{alpha:R})},[R,m,i,d,v]);return jsxRuntime.jsxs("transformNode",{name:`node-${v}-${i}`,setEnabled:s,children:[jsxRuntime.jsx("transformNode",{name:`${v}`,position:u?u.multiply(new EngineCore.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1)):new EngineCore.Vector3(0,0,0),scaling:new EngineCore.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1),ref:r,children:jsxRuntime.jsx("mesh",{name:`${v}-mesh`,ref:a,children:y()})}),h]})},TubeComponent$1=React.forwardRef(TubeComponent),TubeLayerComponent=(e,t)=>{const n=React.useRef(null),a=React.useContext(WorkspaceMetaContext);React.useImperativeHandle(t,()=>n.current,[]);const{id:r,visible:o=!0,position:i,data:s,offset:l=new EngineCore.Vector3(0,0,0),color:c="white",fontSize:f=40,showLabel:u=!0}=e;return jsxRuntime.jsx("transformNode",{name:`node-layer-${r}`,position:i?i.add(l).multiply(new EngineCore.Vector3(a?a.scalePlane:1,a?a.scaleDepth:1,a?a.scalePlane:1)):new EngineCore.Vector3(0,0,0).add(l),scaling:new EngineCore.Vector3(a?a.scalePlane:1,a?a.scaleDepth:1,a?a.scalePlane:1),ref:n,setEnabled:o,children:u?s.map((d,h)=>jsxRuntime.jsx("transformNode",{name:"layer-text",position:d.position,scaling:calcGUIScale(a),children:jsxRuntime.jsx(GUIText$1,{text:d.name,fontSize:f,color:c})},h)):jsxRuntime.jsx(jsxRuntime.Fragment,{})})},TubeLayerComponent$1=React.forwardRef(TubeLayerComponent),TubeLayer$2=e=>{var S,I,O,F,L;const t=reactBabylonjs.useScene(),[n,a]=React.useState([]),[r,o]=React.useState([]),[i,s]=React.useState([]),[l,c]=React.useState(),[f,u]=React.useState([]),[d,h]=React.useState(0),[m,R]=React.useState(),{colorIDs:v}=React.useContext(ColorProviderContext),{id:g,url:x,color:y,layers:E=[],visible:k=!0,tessellation:b=64,frontSide:C=!1,customMaterial:_=!1,actions:A}=e,N=useCachedBinary({url:x,cacheType:CacheType.EXACTLY_MATCH});return React.useEffect(()=>{var w,B,D,W,ae,ne;if(N){const U=Layer.decode(new Uint8Array(N)),re=[];U.layerList.forEach((fe,V)=>{var J,Ce,Y,se,ce,Q;re.push(fe),V<U.layerList.length&&re.push({...fe,name:fe.name+"opacity",start:{x:(Ce=(J=fe==null?void 0:fe.end)==null?void 0:J.x)!=null?Ce:0,y:(se=(Y=fe==null?void 0:fe.end)==null?void 0:Y.y)!=null?se:0,z:(Q=(ce=fe==null?void 0:fe.end)==null?void 0:ce.z)!=null?Q:0}})});const te=re.map(fe=>{const V=fe.start?fe.start:{x:0,y:0,z:0};return new EngineCore.Vector3(V.x,V.y,V.z)}),K=EngineCore.MeshBuilder.CreateTube("tube-tmp",{path:te,radiusFunction:fe=>{var J;const V=(J=re[fe])==null?void 0:J.radius;return V||1},cap:EngineCore.Mesh.NO_CAP,tessellation:b,sideOrientation:C?EngineCore.Mesh.FRONTSIDE:EngineCore.Mesh.DOUBLESIDE},t),Z=K.getVerticesData(EngineCore.VertexBuffer.PositionKind),de=_?TubeUtil.correctTubeMainIndices(K.getIndices()):K.getIndices(),ee=y;let G=[];Z&&(G=TubeUtil.buildTubeMainColors(Z,re.map(fe=>{const V=ee||(v&&v[fe.colorId]?v[fe.colorId]:TubeUtil.randomColorMap()),J=E.findIndex(Ce=>Ce===fe.name)!==-1?V.a:0;return new EngineCore.Color4(V.r,V.g,V.b,J)}),b,!!C)),R(U),a(Z?Z.slice():[]),o(de?de.slice():[]),s(G),c(new EngineCore.Vector3((w=U.origin)==null?void 0:w.x,(B=U.origin)==null?void 0:B.y,(D=U.origin)==null?void 0:D.z)),t==null||t.removeMesh(K);const ge=[];for(let fe=0;fe<U.layerList.length;fe++){const V=U.layerList[fe];E.findIndex(J=>J===V.name)!==-1&&ge.push({name:V.name,position:new EngineCore.Vector3((W=V.position)==null?void 0:W.x,(ae=V.position)==null?void 0:ae.y,(ne=V.position)==null?void 0:ne.z)})}u(ge),h(U.layerList?U.layerList[0].radius:0)}},[x,t,C,b,_,E,v,N,y]),jsxRuntime.jsxs("transformNode",{name:`node-layer-${g}`,children:[n.length>0&&r.length>0&&jsxRuntime.jsx(TubeComponent$1,{id:g,name:"tube-layer",visible:k,vertices:n,slices:m==null?void 0:m.layerList,indices:r,position:l,colors:i.length>0?i:void 0,materialType:_?"custom":"standard",alphaBlend:!0,actions:A}),f.length>0&&jsxRuntime.jsx(TubeLayerComponent$1,{id:g,data:f,visible:k,position:l,fontSize:(S=e.style)==null?void 0:S.fontSize,color:(I=e.style)==null?void 0:I.color,offset:(F=(O=e.style)==null?void 0:O.offset)==null?void 0:F.add(new EngineCore.Vector3(d,0,0)),showLabel:(L=e.style)==null?void 0:L.showLabel})]})},TubeLayer$3=TubeLayer$2,TubeRingCap=e=>{const t=reactBabylonjs.useScene(),n=React.useRef(null),[a,r]=React.useState([]),[o,i]=React.useState([]),[s,l]=React.useState([]),{color:c,type:f,name:u="cap",materialType:d,tessellation:h,data:m}=e,R=React.useCallback(()=>{const g=[],x=[];for(let A=0;A<2*h+1;A++)if(f==="start")g.push(new EngineCore.Vector3(m[A*3],m[A*3+1],m[A*3+2]));else{const N=m.length-2*h*3;g.push(new EngineCore.Vector3(m[A*3+N],m[A*3+1+N],m[A*3+2+N]))}const y=[],E=[];for(let A=0;A<h;A++)y.push(g[A]),E.push(g[2*h-A-1]);x.push(y,E);const k=EngineCore.MeshBuilder.CreateRibbon("ribbon-tmp",{pathArray:x,sideOrientation:EngineCore.Mesh.DOUBLESIDE},t),b=k.getVerticesData(EngineCore.VertexBuffer.PositionKind),C=k.getIndices(),_=k.getNormalsData();r(b?b.slice():[]),i(C?C.slice():[]),l(_?_.slice():[]),t==null||t.removeMesh(k)},[t,h,f,m]);React.useEffect(()=>{R()},[R]),React.useEffect(()=>{if(n&&n.current&&t){const g=new EngineCore.VertexData;g.positions=a,g.indices=o,g.normals=s,g.applyToMesh(n.current)}},[o,a,t,s]);const v=React.useCallback(()=>d==="pbr"?jsxRuntime.jsx("pbrMaterial",{name:"cap-pbr-material",alpha:.8,metallic:1,roughness:.03,albedoColor:new EngineCore.Color3(248/255,163/255,151/255),emissiveColor:new EngineCore.Color3(36/255,36/255,36/255),transparencyMode:EngineCore.Material.MATERIAL_OPAQUE}):jsxRuntime.jsx("standardMaterial",{name:`${u}-material`,alphaMode:EngineCore.Engine.ALPHA_COMBINE,transparencyMode:EngineCore.Material.MATERIAL_OPAQUE,diffuseColor:new EngineCore.Color3(c.r,c.g,c.b)}),[c.b,c.g,c.r,d,u]);return jsxRuntime.jsx("mesh",{name:`${u}-mesh`,ref:n,isPickable:!0,children:v()})},TubeRingCap$1=TubeRingCap,TubeMain=e=>{const t=reactBabylonjs.useScene(),n=React.useRef(null),[a,r]=React.useState(EngineCore.Vector3.Zero()),[o,i]=React.useState([]),[s,l]=React.useState([]),[c,f]=React.useState([]),[u,d]=React.useState(""),[h,m]=React.useState(new EngineCore.Vector3(0,0,0)),[R,v]=React.useState([]),g=React.useContext(WorkspaceMetaContext),{id:x,color:y,url:E,name:k="tube",children:b,materialType:C="standard",actions:_,tessellation:A=32,style:N}=e,S=React.useRef(!1),I=React.useCallback(F=>{var ne,U,re;const L=F.sliceList.filter(te=>!(te.v.length>0)).map(te=>{const K=te.start?te.start:{x:0,y:0,z:0};return new EngineCore.Vector3(K.x,K.y,K.z)}),w=F.sliceList[F.sliceList.length-1];if(L.length>0&&L.push(new EngineCore.Vector3((ne=w.end)==null?void 0:ne.x,(U=w.end)==null?void 0:U.y,(re=w.end)==null?void 0:re.z)),L.length<1)return;const B=EngineCore.MeshBuilder.ExtrudeShape("tmp",{path:L,sideOrientation:EngineCore.Mesh.DOUBLESIDE,shape:TubeUtil.buildSemiRing(w.innerRadius,w.radius,A),cap:EngineCore.Mesh.NO_CAP},t);v(B.getVerticesData(EngineCore.VertexBuffer.PositionKind)),B.convertToFlatShadedMesh(),B.computeWorldMatrix(!0),B._updateBoundingInfo();const D=B.getVerticesData(EngineCore.VertexBuffer.PositionKind),W=B.getIndices(),ae=B.getNormalsData();i(D?D.slice():[]),l(W?W.slice():[]),f(ae?ae.slice():[]),t==null||t.removeMesh(B)},[t,A]);React.useEffect(()=>{S.current||(S.current=!0,axios.get(E,{responseType:"arraybuffer"}).then(F=>{var B,D,W;const L=Tube$2.decode(new Uint8Array(F.data));if(console.log(L),L.sliceList.length===0)return;d(L.name);const w=N!=null&&N.basePosition&&N.basePosition==="top"?L.sliceList[0].start:L.sliceList[L.sliceList.length-1].end;m(new EngineCore.Vector3(w==null?void 0:w.x,w==null?void 0:w.y,w==null?void 0:w.z)),r(new EngineCore.Vector3((B=L.origin)==null?void 0:B.x,(D=L.origin)==null?void 0:D.y,(W=L.origin)==null?void 0:W.z)),I(L)}))},[I,N==null?void 0:N.basePosition,E]),React.useEffect(()=>{if(n&&n.current&&t){const F=new EngineCore.VertexData;F.positions=o,F.indices=s,F.normals=c,F.applyToMesh(n.current)}},[s,o,t,c]),React.useEffect(()=>{n.current&&(n.current.metadata={pickable:_?{name:k,value:x,onLeftClick:_.onLeftClick,valueCallback:()=>x,onRightClick:_.onRightClick,onMiddleClick:_.onMiddleClick,onHover:_.onHover}:null})},[_,x,g,k,a,t]);const O=React.useCallback(()=>C==="pbr"?jsxRuntime.jsx("pbrMaterial",{name:"main-pbr-material",alpha:1,metallic:1,roughness:.03,albedoColor:new EngineCore.Color3(230/255,230/255,230/255),emissiveColor:new EngineCore.Color3(71/255,71/255,71/255),transparencyMode:EngineCore.Material.MATERIAL_OPAQUE}):jsxRuntime.jsx("standardMaterial",{name:`${k}-material`,alphaMode:EngineCore.Engine.ALPHA_COMBINE,transparencyMode:EngineCore.Material.MATERIAL_OPAQUE,diffuseColor:new EngineCore.Color3(y.r,y.g,y.b)}),[y.b,y.g,y.r,C,k]);return jsxRuntime.jsxs("transformNode",{name:`${k}-main-node`,position:a.multiply(calcTransformNodeScale(g)),scaling:calcTransformNodeScale(g),children:[jsxRuntime.jsx("mesh",{name:`${k}-mesh`,ref:n,isPickable:!0,children:O()}),R.length>0&&jsxRuntime.jsx(TubeRingCap$1,{id:1,name:"start",color:y,type:"start",tessellation:A,data:R,materialType:C}),R.length>0&&jsxRuntime.jsx(TubeRingCap$1,{id:2,name:"end",color:y,type:"end",tessellation:A,data:R,materialType:C}),N&&jsxRuntime.jsx(TubeTitle$1,{id:x,style:{title:u,position:h,offset:N.offset,fontSize:N.fontSize,color:N.color}}),b]})},TubeMain$1=TubeMain,TubeOil=e=>{const{id:t,visible:n=!0,children:a,offset:r=new EngineCore.Vector3(0,0,0)}=e;return jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`tube-${t}`,setEnabled:n,position:r,children:a})})},TubeOil$1=TubeOil;function createBaseVoxelGrid(){return{name:"",origin:void 0,dataPoints:[],size:void 0}}const VoxelGrid$2={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.origin!==void 0&&Vertex.encode(e.origin,t.uint32(18).fork()).ldelim();for(const n of e.dataPoints)VoxelGrid_DataPoint.encode(n,t.uint32(26).fork()).ldelim();return e.size!==void 0&&Vertex.encode(e.size,t.uint32(34).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseVoxelGrid();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.origin=Vertex.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.dataPoints.push(VoxelGrid_DataPoint.decode(n,n.uint32()));continue;case 4:if(o!==34)break;r.size=Vertex.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$1(e.name)?globalThis.String(e.name):"",origin:isSet$1(e.origin)?Vertex.fromJSON(e.origin):void 0,dataPoints:globalThis.Array.isArray(e==null?void 0:e.dataPoints)?e.dataPoints.map(t=>VoxelGrid_DataPoint.fromJSON(t)):[],size:isSet$1(e.size)?Vertex.fromJSON(e.size):void 0}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),e.origin!==void 0&&(t.origin=Vertex.toJSON(e.origin)),(n=e.dataPoints)!=null&&n.length&&(t.dataPoints=e.dataPoints.map(a=>VoxelGrid_DataPoint.toJSON(a))),e.size!==void 0&&(t.size=Vertex.toJSON(e.size)),t},create(e){return VoxelGrid$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseVoxelGrid();return t.name=(n=e.name)!=null?n:"",t.origin=e.origin!==void 0&&e.origin!==null?Vertex.fromPartial(e.origin):void 0,t.dataPoints=((a=e.dataPoints)==null?void 0:a.map(r=>VoxelGrid_DataPoint.fromPartial(r)))||[],t.size=e.size!==void 0&&e.size!==null?Vertex.fromPartial(e.size):void 0,t}};function createBaseVoxelGrid_DataPoint(){return{point:void 0,colorId:0,vScale:0,rotation:void 0,pointType:0}}const VoxelGrid_DataPoint={encode(e,t=minimal.Writer.create()){return e.point!==void 0&&Vertex.encode(e.point,t.uint32(10).fork()).ldelim(),e.colorId!==0&&t.uint32(16).uint32(e.colorId),e.vScale!==0&&t.uint32(37).float(e.vScale),e.rotation!==void 0&&Vertex.encode(e.rotation,t.uint32(42).fork()).ldelim(),e.pointType!==0&&t.uint32(48).uint32(e.pointType),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseVoxelGrid_DataPoint();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.point=Vertex.decode(n,n.uint32());continue;case 2:if(o!==16)break;r.colorId=n.uint32();continue;case 4:if(o!==37)break;r.vScale=n.float();continue;case 5:if(o!==42)break;r.rotation=Vertex.decode(n,n.uint32());continue;case 6:if(o!==48)break;r.pointType=n.uint32();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{point:isSet$1(e.point)?Vertex.fromJSON(e.point):void 0,colorId:isSet$1(e.colorId)?globalThis.Number(e.colorId):0,vScale:isSet$1(e.vScale)?globalThis.Number(e.vScale):0,rotation:isSet$1(e.rotation)?Vertex.fromJSON(e.rotation):void 0,pointType:isSet$1(e.pointType)?globalThis.Number(e.pointType):0}},toJSON(e){const t={};return e.point!==void 0&&(t.point=Vertex.toJSON(e.point)),e.colorId!==0&&(t.colorId=Math.round(e.colorId)),e.vScale!==0&&(t.vScale=e.vScale),e.rotation!==void 0&&(t.rotation=Vertex.toJSON(e.rotation)),e.pointType!==0&&(t.pointType=Math.round(e.pointType)),t},create(e){return VoxelGrid_DataPoint.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=createBaseVoxelGrid_DataPoint();return t.point=e.point!==void 0&&e.point!==null?Vertex.fromPartial(e.point):void 0,t.colorId=(n=e.colorId)!=null?n:0,t.vScale=(a=e.vScale)!=null?a:0,t.rotation=e.rotation!==void 0&&e.rotation!==null?Vertex.fromPartial(e.rotation):void 0,t.pointType=(r=e.pointType)!=null?r:0,t}};function isSet$1(e){return e!=null}const POINT_TYPE_LOOKUP_TABLE=[0,.05,.1,.15,.2,.25,.3,.35,.4,.45,.5,.55,.6,.65,.7,.75,.8,.85,.9,.95,1],VoxelGrid=({url:e,alpha:t={typeAlpha0:1,typeAlpha1:1},offset:n=EngineCore.Vector3.Zero(),visible:a=!0})=>{const r=reactBabylonjs.useScene(),o=React.useContext(WorkspaceMetaContext),i=React.useContext(ColorProviderContext),[s,l]=React.useState(""),[c,f]=React.useState(EngineCore.Vector3.Zero()),u=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH}),d=React.useRef(null),h=React.useRef(null);React.useEffect(()=>{console.log("[Geo3DViewer] VoxelGrid Loading: ",e)},[e]);const m=R=>POINT_TYPE_LOOKUP_TABLE[R];return React.useEffect(()=>{if(r&&u){const R=VoxelGrid$2.decode(new Uint8Array(u)),{name:v,origin:g,dataPoints:x,size:y}=R;if(g&&x){l(v),f(new EngineCore.Vector3(g.x,g.y,g.z));let E=null;y&&(E=EngineCore.MeshBuilder.CreateBox("voxel",{width:y.x-1e-5,height:y.y-1e-5,depth:y.z-1e-5},r),E.material=d.current,EngineCore.Tags.EnableFor(E),EngineCore.Tags.AddTagsTo(E,"loading"));const k=new Float32Array(x.length*16),b=new Float32Array(x.length*4);return x.forEach((C,_)=>{if(C.point){const A=new EngineCore.Vector3(C.point.x,C.point.y,C.point.z),N=C.rotation?EngineCore.Quaternion.FromEulerAngles(C.rotation.x,C.rotation.y,C.rotation.z):EngineCore.Quaternion.Identity(),S=new EngineCore.Vector3(C.vScale+1,C.vScale+1,C.vScale+1);EngineCore.Matrix.Compose(S,N,A).copyToArray(k,_*16);let O=i.colorIDs[C.colorId];O||(O=EngineCore.Color4.FromColor3(EngineCore.Color3.Random())),b.set([O.r,O.g,O.b,m(C.pointType)],_*4)}}),E&&(E.thinInstanceSetBuffer("matrix",k),E.thinInstanceSetBuffer("color",b,4),E.parent=h.current),EngineCore.Tags.RemoveTagsFrom(E,"loading"),()=>{E&&(E.thinInstanceSetBuffer("matrix",new Float32Array),E.thinInstanceSetBuffer("color",new Float32Array),r.removeMesh(E))}}}},[i.colorIDs,r,u]),jsxRuntime.jsx("transformNode",{setEnabled:a,name:`transform-voxel-${s}`,position:c.add(n).multiplyByFloats(o&&o.scalePlane?o.scalePlane:1,o&&o.scaleDepth?o.scaleDepth:1,o&&o.scalePlane?o.scalePlane:1),scaling:new EngineCore.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1),ref:h,children:jsxRuntime.jsx(VoxelGridMaterialForwardRef,{name:`voxel-${s}-mat`,typeAlpha:t,ref:d})})},VoxelGrid$1=VoxelGrid,DataBinding=(e,t)=>{const{viewer:n,camera:a,useUniversalCamera:r=!1,lights:o,complexFormationManagers:i,formationManagers:s,formationFaces:l,formationVolumes:c,structureLayers:f,colorCodec:u,gridDiagrams:d,attributeBodies:h,tubes:m,roadways:R,densitySlices:v,formationSlices:g,rayClick:x,lines:y,spaceHeats:E,lookAt:k,fps:b,coordinate:C,tileMaps:_,pointClickZones:A,progressedAttributeBodies:N,ribbonLayers:S,intersectingLines:I,tubeInstances:O,optimizer:F,voxelGrids:L,planeImages:w,guiTexts:B,skybox:D,particleSystems:W,waterEffects:ae,modelLoaders:ne,modelAnimationLoaders:U,roadwayAnimations:re,roadwayNearAnimations:te,roadwayWaterAnimations:K,contourlines:Z,tubeTools:de,tubeOils:ee,tubeLayers:G,tubeChartLines:ge,tubeCharts:fe}=e;return jsxRuntime.jsxs(Geo3DViewer$1,{...n,ref:t,children:[r?jsxRuntime.jsx(Geo3DFreeCamera$1,{...a}):jsxRuntime.jsx(Geo3DCamera$1,{...a}),o?o.map((V,J)=>jsxRuntime.jsx("hemisphericLight",{...V,name:`extra-light-${J}`},`extra-light-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),i?i.map(V=>jsxRuntime.jsx(ComplexFormationManager$1,{...V},`complexFormationManager-${V.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),v?v.map(V=>jsxRuntime.jsx(DensitySlice$1,{...V},`densitySlice-${V.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),g?g.map(V=>jsxRuntime.jsx(FormationSlice$1,{...V},`formationSlice-${V.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),s?s.map(V=>jsxRuntime.jsx(FormationManager$1,{...V},`formationManager-${V.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),l?l.map(V=>jsxRuntime.jsx(FormationFace$1,{...V},`formation-face-${V.urlTopLayer}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),c?c.map(V=>jsxRuntime.jsx(FormationVolume$1,{...V},`formation-volume-${V.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),f?f.map(V=>jsxRuntime.jsx(StructureLayer$1,{...V},`structurelayer-${V.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),u?jsxRuntime.jsx(ColorCodec$1,{...u}):jsxRuntime.jsx(jsxRuntime.Fragment,{}),d?d.map(V=>jsxRuntime.jsx(GridDiagram$1,{...V},`gridDiagram-${V.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),h?h.map(V=>jsxRuntime.jsx(AttributeBody$1,{...V},`attributebody-${V.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),m?m.map(V=>jsxRuntime.jsxs(Tube$1,{...V,children:[V.charts?V.charts.map(J=>jsxRuntime.jsx(TubeChart$1,{...J},`tubechart-${J.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),V.layers?V.layers.map(J=>jsxRuntime.jsx(TubeLayer$3,{...J},`tubelayer-${J.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),V.tools?V.tools.map(J=>jsxRuntime.jsx(TubeTool$1,{...J},`tubelayer-${J.name}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{})]},`tube-${V.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),R?R.map(V=>jsxRuntime.jsx(RoadWay$1,{...V},`roadway-${V.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),x?x.map((V,J)=>jsxRuntime.jsx(RayClick$1,{...V},`rayclick-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),y?y.map((V,J)=>jsxRuntime.jsx(Line$1,{...V},`line-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),E?E.map((V,J)=>jsxRuntime.jsx(SpaceHeat$1,{...V},`spaceheat-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),k?jsxRuntime.jsx(LookAt$1,{target:void 0,distance:0}):jsxRuntime.jsx(jsxRuntime.Fragment,{}),b?jsxRuntime.jsx(FPS$1,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{}),C?jsxRuntime.jsx(Coordinate$1,{...C},"coordinate"):jsxRuntime.jsx(jsxRuntime.Fragment,{}),_?_.map((V,J)=>jsxRuntime.jsx(TileMap$1,{...V},`tilemap-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),A?A.map((V,J)=>jsxRuntime.jsx(PointClickZone$1,{...V},`pointClickZone-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),N?N.map((V,J)=>jsxRuntime.jsx(ProgressedAttributeBody$1,{...V},`progressedAttributeBody-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),S?S.map((V,J)=>jsxRuntime.jsx(RibbonLayer$1,{...V},`ribbonlayer-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),I?I.map((V,J)=>jsxRuntime.jsx(IntersectingLine$1,{...V},`intersectingLine-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),O?O.map((V,J)=>jsxRuntime.jsx(TubeInstance$1,{...V},`tubeinstance-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),F?jsxRuntime.jsx(Optimizer$1,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{}),L?L.map((V,J)=>jsxRuntime.jsx(VoxelGrid$1,{...V},`voxelgrid-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),w?w.map((V,J)=>jsxRuntime.jsx(PlaneImage$1,{...V},`planeimage-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),B?B.map((V,J)=>jsxRuntime.jsx(TransformGUIText$1,{...V},`guitext-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),D&&jsxRuntime.jsx(SkyBox$1,{...D}),W?W.map((V,J)=>jsxRuntime.jsx(ParticleSystem$1,{...V},`particlesystem-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),ae?ae.map((V,J)=>jsxRuntime.jsx(WaterEffect$1,{...V},`waterEffect-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),ne?ne.map((V,J)=>jsxRuntime.jsx(ModelLoader$1,{...V},`modelLoaders-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),U?U.map((V,J)=>jsxRuntime.jsx(ModleAnimationLoader,{...V},`modelanimtionloader-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),re?re.map((V,J)=>jsxRuntime.jsx(Animation$1,{...V,children:jsxRuntime.jsx(RoadWayAnimation$1,{})},`animation-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),te?te.map((V,J)=>jsxRuntime.jsx(Animation$1,{...V,children:jsxRuntime.jsx(RoadWayNearAnimation$1,{roadwayWidth:V.roadwayWidth,textureLength:V.textureLength,url:V.imageUrl,isBlink:V.isBlink,visible:V.visible})},`animation-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),K?K.map((V,J)=>jsxRuntime.jsx(Animation$1,{...V,children:jsxRuntime.jsx(RoadWayWaterEffectAnimationNode$1,{timeSpeed:V.timeSpeed,perlinMultiply:V.perlinMultiply,waterFlow:V.waterFlow,clippedHeight:V.clippedHeight,alpha:V.alpha,colorSteps:V.colorSteps,speed:V.speed})},`animation-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),Z?Z.map((V,J)=>jsxRuntime.jsx(ContourLine$1,{...V},`contourline-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),de?de.map((V,J)=>jsxRuntime.jsx(TubeTool$1,{...V},`tubeTool-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),ee?ee.map((V,J)=>jsxRuntime.jsx(TubeOil$1,{...V,children:V.main?V.main.map((Ce,Y)=>jsxRuntime.jsx(TubeMain$1,{...Ce},`tubeMain-${Y}`)):null},`tubeOil-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),G?G.map((V,J)=>jsxRuntime.jsx(TubeLayer$3,{...V},`tubeLayer-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),ge?ge.map((V,J)=>jsxRuntime.jsx(TubeChartLine$1,{...V},`tubeChartLine-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),fe?fe.map((V,J)=>jsxRuntime.jsx(TubeChart$1,{...V},`tubeChart-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{})]})},DataBinding$1=React.forwardRef(DataBinding),Roam=e=>{const t=reactBabylonjs.useScene(),n=React.useRef(null),{keyFrames:a,speed:r}=e;return React.useEffect(()=>{if(t&&n.current&&n.current.animations.length===0){const o=new EngineCore.Animation("roam","position",40,EngineCore.Animation.ANIMATIONTYPE_VECTOR3,EngineCore.Animation.ANIMATIONLOOPMODE_CONSTANT);for(let i=0;i<a.length;i++)i!==a.length-1&&o.addEvent(new EngineCore.AnimationEvent(a[i].frame,()=>{var s;(s=n.current)==null||s.setTarget(a[i+1].value)}));o.setKeys(a),n.current.animations.push(o),t==null||t.beginAnimation(n.current,0,a[a.length-1].frame,!1,Math.abs(r),()=>{n.current&&(n.current.position=a[0].value,n.current.setTarget(a[1].value))})}},[a,t,r]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("freeCamera",{name:"roam-camera",position:new EngineCore.Vector3(0,0,0),ref:n}),jsxRuntime.jsx("lines",{name:"",points:a.map(o=>o.value)}),a.map((o,i)=>jsxRuntime.jsx("sphere",{name:"roam-sphere-"+i,diameter:1,position:o.value,children:jsxRuntime.jsx("standardMaterial",{name:"roam-sphere-mat",diffuseColor:EngineCore.Color3.Red(),specularColor:EngineCore.Color3.Black(),alpha:1})},i))]})},Roam$1=Roam;function createBaseRod(){return{name:"",origin:void 0,type:"",sliceList:[],vertices:[],normals:[],indices:[],uv:[]}}const Rod={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.origin!==void 0&&Vertex.encode(e.origin,t.uint32(18).fork()).ldelim(),e.type!==""&&t.uint32(26).string(e.type);for(const n of e.sliceList)Rod_Slice.encode(n,t.uint32(34).fork()).ldelim();t.uint32(42).fork();for(const n of e.vertices)t.float(n);t.ldelim(),t.uint32(50).fork();for(const n of e.normals)t.float(n);t.ldelim(),t.uint32(58).fork();for(const n of e.indices)t.float(n);t.ldelim(),t.uint32(66).fork();for(const n of e.uv)t.float(n);return t.ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRod();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.origin=Vertex.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.type=n.string();continue;case 4:if(o!==34)break;r.sliceList.push(Rod_Slice.decode(n,n.uint32()));continue;case 5:if(o===45){r.vertices.push(n.float());continue}if(o===42){const i=n.uint32()+n.pos;for(;n.pos<i;)r.vertices.push(n.float());continue}break;case 6:if(o===53){r.normals.push(n.float());continue}if(o===50){const i=n.uint32()+n.pos;for(;n.pos<i;)r.normals.push(n.float());continue}break;case 7:if(o===61){r.indices.push(n.float());continue}if(o===58){const i=n.uint32()+n.pos;for(;n.pos<i;)r.indices.push(n.float());continue}break;case 8:if(o===69){r.uv.push(n.float());continue}if(o===66){const i=n.uint32()+n.pos;for(;n.pos<i;)r.uv.push(n.float());continue}break}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet(e.name)?globalThis.String(e.name):"",origin:isSet(e.origin)?Vertex.fromJSON(e.origin):void 0,type:isSet(e.type)?globalThis.String(e.type):"",sliceList:globalThis.Array.isArray(e==null?void 0:e.sliceList)?e.sliceList.map(t=>Rod_Slice.fromJSON(t)):[],vertices:globalThis.Array.isArray(e==null?void 0:e.vertices)?e.vertices.map(t=>globalThis.Number(t)):[],normals:globalThis.Array.isArray(e==null?void 0:e.normals)?e.normals.map(t=>globalThis.Number(t)):[],indices:globalThis.Array.isArray(e==null?void 0:e.indices)?e.indices.map(t=>globalThis.Number(t)):[],uv:globalThis.Array.isArray(e==null?void 0:e.uv)?e.uv.map(t=>globalThis.Number(t)):[]}},toJSON(e){var n,a,r,o,i;const t={};return e.name!==""&&(t.name=e.name),e.origin!==void 0&&(t.origin=Vertex.toJSON(e.origin)),e.type!==""&&(t.type=e.type),(n=e.sliceList)!=null&&n.length&&(t.sliceList=e.sliceList.map(s=>Rod_Slice.toJSON(s))),(a=e.vertices)!=null&&a.length&&(t.vertices=e.vertices),(r=e.normals)!=null&&r.length&&(t.normals=e.normals),(o=e.indices)!=null&&o.length&&(t.indices=e.indices),(i=e.uv)!=null&&i.length&&(t.uv=e.uv),t},create(e){return Rod.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l;const t=createBaseRod();return t.name=(n=e.name)!=null?n:"",t.origin=e.origin!==void 0&&e.origin!==null?Vertex.fromPartial(e.origin):void 0,t.type=(a=e.type)!=null?a:"",t.sliceList=((r=e.sliceList)==null?void 0:r.map(c=>Rod_Slice.fromPartial(c)))||[],t.vertices=((o=e.vertices)==null?void 0:o.map(c=>c))||[],t.normals=((i=e.normals)==null?void 0:i.map(c=>c))||[],t.indices=((s=e.indices)==null?void 0:s.map(c=>c))||[],t.uv=((l=e.uv)==null?void 0:l.map(c=>c))||[],t}};function createBaseRod_Slice(){return{position:void 0,start:void 0,end:void 0,color:void 0,angle:0,radius:0,bottomRadius:0,texture:"",v:[]}}const Rod_Slice={encode(e,t=minimal.Writer.create()){e.position!==void 0&&Vertex.encode(e.position,t.uint32(10).fork()).ldelim(),e.start!==void 0&&Vertex.encode(e.start,t.uint32(18).fork()).ldelim(),e.end!==void 0&&Vertex.encode(e.end,t.uint32(26).fork()).ldelim(),e.color!==void 0&&Color.encode(e.color,t.uint32(34).fork()).ldelim(),e.angle!==0&&t.uint32(45).float(e.angle),e.radius!==0&&t.uint32(53).float(e.radius),e.bottomRadius!==0&&t.uint32(61).float(e.bottomRadius),e.texture!==""&&t.uint32(66).string(e.texture);for(const n of e.v)t.uint32(74).string(n);return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRod_Slice();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.position=Vertex.decode(n,n.uint32());continue;case 2:if(o!==18)break;r.start=Vertex.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.end=Vertex.decode(n,n.uint32());continue;case 4:if(o!==34)break;r.color=Color.decode(n,n.uint32());continue;case 5:if(o!==45)break;r.angle=n.float();continue;case 6:if(o!==53)break;r.radius=n.float();continue;case 7:if(o!==61)break;r.bottomRadius=n.float();continue;case 8:if(o!==66)break;r.texture=n.string();continue;case 9:if(o!==74)break;r.v.push(n.string());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{position:isSet(e.position)?Vertex.fromJSON(e.position):void 0,start:isSet(e.start)?Vertex.fromJSON(e.start):void 0,end:isSet(e.end)?Vertex.fromJSON(e.end):void 0,color:isSet(e.color)?Color.fromJSON(e.color):void 0,angle:isSet(e.angle)?globalThis.Number(e.angle):0,radius:isSet(e.radius)?globalThis.Number(e.radius):0,bottomRadius:isSet(e.bottomRadius)?globalThis.Number(e.bottomRadius):0,texture:isSet(e.texture)?globalThis.String(e.texture):"",v:globalThis.Array.isArray(e==null?void 0:e.v)?e.v.map(t=>globalThis.String(t)):[]}},toJSON(e){var n;const t={};return e.position!==void 0&&(t.position=Vertex.toJSON(e.position)),e.start!==void 0&&(t.start=Vertex.toJSON(e.start)),e.end!==void 0&&(t.end=Vertex.toJSON(e.end)),e.color!==void 0&&(t.color=Color.toJSON(e.color)),e.angle!==0&&(t.angle=e.angle),e.radius!==0&&(t.radius=e.radius),e.bottomRadius!==0&&(t.bottomRadius=e.bottomRadius),e.texture!==""&&(t.texture=e.texture),(n=e.v)!=null&&n.length&&(t.v=e.v),t},create(e){return Rod_Slice.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=createBaseRod_Slice();return t.position=e.position!==void 0&&e.position!==null?Vertex.fromPartial(e.position):void 0,t.start=e.start!==void 0&&e.start!==null?Vertex.fromPartial(e.start):void 0,t.end=e.end!==void 0&&e.end!==null?Vertex.fromPartial(e.end):void 0,t.color=e.color!==void 0&&e.color!==null?Color.fromPartial(e.color):void 0,t.angle=(n=e.angle)!=null?n:0,t.radius=(a=e.radius)!=null?a:0,t.bottomRadius=(r=e.bottomRadius)!=null?r:0,t.texture=(o=e.texture)!=null?o:"",t.v=((i=e.v)==null?void 0:i.map(s=>s))||[],t}};function isSet(e){return e!=null}const TubeLayer=e=>{const t=reactBabylonjs.useScene(),[n,a]=React.useState([]),[r,o]=React.useState([]),[i,s]=React.useState(EngineCore.Vector3.Zero()),l=React.useContext(WorkspaceMetaContext),c=React.useRef(null),f=React.useRef(!1),[u,d]=React.useState([]),{url:h,name:m="rod",visible:R=!0,color:v}=e,g=React.useCallback(x=>{var _,A,N;const y=x.sliceList.filter(S=>!(S.v.length>0)).map(S=>{const I=S.start?S.start:{x:0,y:0,z:0};return new EngineCore.Vector3(I.x,I.y,I.z)}),E=x.sliceList[x.sliceList.length-1];if(y.length>0&&y.push(new EngineCore.Vector3((_=E.end)==null?void 0:_.x,(A=E.end)==null?void 0:A.y,(N=E.end)==null?void 0:N.z)),y.length<1)return;const k=EngineCore.MeshBuilder.CreateTube("tube-tmp",{path:y,radiusFunction:S=>{if(e.radius)return e.radius;const I=x.sliceList[S]?x.sliceList[S].radius:x.sliceList[S-1].radius;return I||1},cap:EngineCore.Mesh.CAP_ALL,tessellation:24,sideOrientation:EngineCore.Mesh.FRONTSIDE},t),b=k.getVerticesData(EngineCore.VertexBuffer.PositionKind),C=k.getIndices();a(b?b.slice():[]),o(C?C.slice():[]),t==null||t.removeMesh(k)},[e.radius,t]);return React.useEffect(()=>{f.current||(f.current=!0,axios.get(h,{responseType:"arraybuffer"}).then(x=>{var E,k,b;const y=Rod.decode(new Uint8Array(x.data));y.sliceList.length!==0&&(d(y.sliceList),s(new EngineCore.Vector3((E=y.origin)==null?void 0:E.x,(k=y.origin)==null?void 0:k.y,(b=y.origin)==null?void 0:b.z)),console.log(y),g(y))}))},[g,h]),React.useEffect(()=>{if(c&&c.current&&t){const x=new EngineCore.VertexData;x.positions=n,x.indices=r,x.applyToMesh(c.current)}},[r,n,t]),React.useEffect(()=>{var y,E,k;let x;if(u.length>0&&t){x=EngineCore.MeshBuilder.CreateSphere("top",{diameter:u[0].bottomRadius*2,segments:32},t);const b=new EngineCore.StandardMaterial("myMaterial",t);x.material=b,x.setEnabled(!1),b.diffuseColor=new EngineCore.Color3(v.r,v.g,v.b);for(let C=0;C<u.length;C++){const _=u[C],A=x.createInstance("tubeinstance-sphere-"+C);A.setEnabled(R);const N=i.multiply(calcTransformNodeScale(l));A.position=N.add(new EngineCore.Vector3((y=_.position)==null?void 0:y.x,(E=_.position)==null?void 0:E.y,(k=_.position)==null?void 0:k.z).multiply(calcTransformNodeScale(l)))}}return()=>{x&&x.dispose()}},[v.b,v.g,v.r,l,i,t,u,R]),jsxRuntime.jsx("transformNode",{name:`${m}-rod-node`,position:i.multiply(calcTransformNodeScale(l)),setEnabled:R,scaling:new EngineCore.Vector3(l?l.scalePlane:1,l?l.scaleDepth:1,l?l.scalePlane:1),children:jsxRuntime.jsx("mesh",{name:`${m}-mesh`,ref:c,isPickable:!1,children:jsxRuntime.jsx("standardMaterial",{name:`${m}-material`,diffuseColor:new EngineCore.Color3(v.r,v.g,v.b)})})})},TubeLayer$1=TubeLayer;class Scene{constructor(t){ue(this,"children",[]);ue(this,"params",{});ue(this,"ref",React.createRef());this.params=t}add(t){this.children.push(t.render()),window._export=this.children}getSceneObject(){return this.ref}create(){const t=document.getElementById("root"),n=client.createRoot(t);console.log("create root!");const a=React.createElement(Geo3DViewer$1,{ref:this.ref,...this.params},this.children);n.render(a)}}const Scene$1=Scene,UpdateComponent=(e,t)=>{const[n,a]=React.useState();return React.useEffect(()=>{a(e.props)},[e]),React.useImperativeHandle(t,()=>({update:r=>{a(r)}}),[]),n?jsxRuntime.jsx(e.type,{...n}):null},UpdateComponent$1=React.forwardRef(UpdateComponent);class ObjectComponent{constructor(t,n){ue(this,"value");ue(this,"type");ue(this,"ref",React.createRef());this.value=t,this.type=n}setProps(t){this.value=structuredClone(t),this.ref&&this.ref.current&&this.ref.current.update(this.value)}render(){var t;return React.createElement(UpdateComponent$1,{ref:this.ref,key:(t=this.value.id)!=null?t:0,props:this.value,type:this.type})}}function createComponentInstance(e,t){return new ObjectComponent(e,t)}exports.PureComponents=TubeUtil.PureComponents;exports.AttributeBody=AttributeBody$1;exports.AxesViewerPosition=AxesViewerPosition;exports.CachePreload=CachePreload$1;exports.CacheType=CacheType;exports.ColorCodec=ColorCodec$1;exports.ComplexFormationManager=ComplexFormationManager$1;exports.Coordinate=Coordinate$1;exports.CustomShader=CustomShader$1;exports.DarkMetalMaterial=DarkMetalMaterial;exports.DataBinding=DataBinding$1;exports.DensitySlice=DensitySlice$1;exports.FPS=FPS$1;exports.FlatMaterial=FlatMaterial;exports.FormationFace=FormationFace$1;exports.FormationManager=FormationManager$1;exports.FormationSlice=FormationSlice$1;exports.FormationVolume=FormationVolume$1;exports.GUIText=GUIText$1;exports.Geo3DCamera=Geo3DCamera$1;exports.Geo3DUniversalCamera=Geo3DUniversalCamera$1;exports.Geo3DViewer=Geo3DViewer$1;exports.GridDiagram=GridDiagram$1;exports.Ground=Animation$1;exports.HoverType=HoverType;exports.IntersectingLine=IntersectingLine$1;exports.LightMetalMaterial=LightMetalMaterial;exports.Line=Line$1;exports.LoadingScreen=LoadingScreen;exports.LookAt=LookAt$1;exports.MaterialType=MaterialType;exports.ModelLoader=ModelLoader$1;exports.Optimizer=Optimizer$1;exports.PlaneImage=PlaneImage$1;exports.PointClickZone=PointClickZone$1;exports.PointClickZoneObjectType=PointClickZoneObjectType;exports.ProgressedAttributeBody=ProgressedAttributeBody$1;exports.ProgressedRemapColorByRedChannelMaterial=ProgressedRemapColorByRedChannelMaterial;exports.ProgressedRepeatedTextureMaterial=ProgressedRepeatedTextureMaterial;exports.RayClick=RayClick$1;exports.RemapColorByRedChannelMaterial=RemapColorByRedChannelMaterial;exports.RepeatedTextureMaterial=RepeatedTextureMaterial;exports.RibbonLayer=RibbonLayer$1;exports.RoadWay=RoadWay$1;exports.Roam=Roam$1;exports.Rod=TubeLayer$1;exports.ScaleMode=ScaleMode;exports.Scene=Scene$1;exports.SkyBox=SkyBox$1;exports.SpaceHeat=SpaceHeat$1;exports.SpaceHeatObjectType=SpaceHeatObjectType;exports.StructureLayer=StructureLayer$1;exports.TileMap=TileMap$1;exports.TileMapMode=TileMapMode;exports.Tube=Tube$1;exports.TubeChart=TubeChart$1;exports.TubeChartLine=TubeChartLine$1;exports.TubeInstance=TubeInstance$1;exports.TubeLayer=TubeLayer$3;exports.TubeMain=TubeMain$1;exports.TubeOil=TubeOil$1;exports.TubeTool=TubeTool$1;exports.Utils=Common;exports.VoxelGrid=VoxelGrid$1;exports.calcCompass=calcCompass;exports.calcGUIScale=calcGUIScale;exports.calcInvTransformNodeScale=calcInvTransformNodeScale;exports.calcTransformNodeScale=calcTransformNodeScale;exports.createComponentInstance=createComponentInstance;
|
|
1334
|
+
}`,BillboardMaterial=e=>{const t=React.useRef(null),{billboardMode:n="All",zOffset:a,zOffsetUnits:r}=e,[o,i]=React.useState(),s=reactBabylonjs.useScene();return React.useEffect(()=>{const l=()=>{const c=s==null?void 0:s.activeCamera;i(c==null?void 0:c.getDirection(EngineCore.Vector3.Right()))};return s&&s.activeCamera&&(l(),s==null||s.activeCamera.onViewMatrixChangedObservable.add(l)),()=>{s&&s.activeCamera&&(s==null||s.activeCamera.onViewMatrixChangedObservable.removeCallback(l))}},[s]),React.useEffect(()=>{t.current&&o&&(t.current.setVector3("direction",o),t.current.setFloat("billboardMode",n==="all"?1:0),a!==void 0&&r!==void 0&&(t.current.zOffset=a,t.current.zOffsetUnits=r))},[n,o,a,r]),jsxRuntime.jsx(CustomShader$1,{ref:t,name:e.name,backFaceCulling:!1,needDepthPrePass:e.needDepthPrePass,vertex:billboardVertexSource,fragment:billboardFragmentSource,transparencyMode:e.transparencyMode,alphaMode:e.alphaMode,options:{attributes:["position","normal","uv"],uniforms:["world","worldViewProjection","textureSampler","direction"],needAlphaBlending:!0},zOffset:e.zOffset,zOffsetUnits:e.zOffsetUnits,sideOrientation:EngineCore.Material.CounterClockWiseSideOrientation})},BillboardMaterial$1=BillboardMaterial,TubeChartComponent=(e,t)=>{const n=reactBabylonjs.useScene(),a=React.useRef(null),r=React.useRef(null),o=React.useContext(WorkspaceMetaContext),{id:i,visible:s=!0,vertices:l,indices:c,colors:f,uvs:u,position:d,customMaterial:h}=e,{title:m,color:R,fontSize:v}=e.style;return React.useImperativeHandle(t,()=>r.current,[]),React.useEffect(()=>{if(n&&a.current){const g=new EngineCore.VertexData;g.positions=l,g.indices=c,g.colors=f,g.uvs=u,g.applyToMesh(a.current)}},[f,h,i,c,n,u,l]),jsxRuntime.jsxs("transformNode",{name:`node-curve-${i}`,position:d?d.multiply(new EngineCore.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1)):new EngineCore.Vector3(0,0,0),scaling:new EngineCore.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1),ref:r,setEnabled:s,children:[jsxRuntime.jsx("mesh",{name:"curve",ref:a,scaling:new EngineCore.Vector3(1,1,1),children:h?jsxRuntime.jsx(BillboardMaterial$1,{name:`material-${i}`,billboardMode:"none"}):jsxRuntime.jsx("standardMaterial",{name:`material-${i}`,backFaceCulling:!1})}),jsxRuntime.jsx("transformNode",{name:"title",position:e.style.position?e.style.position:new EngineCore.Vector3(0,0,0),scaling:calcGUIScale(o),children:m&&jsxRuntime.jsx(GUIText$1,{text:m,fontSize:v||40,color:R||"white"})})]})},TubeChartComponent$1=React.forwardRef(TubeChartComponent),TubeChart=e=>{var O,F;const t=reactBabylonjs.useScene(),[n,a]=React.useState([]),[r,o]=React.useState([]),[i,s]=React.useState([]),[l,c]=React.useState([]),[f,u]=React.useState(),[d,h]=React.useState(),[m,R]=React.useState(),{colorCodecs:v}=React.useContext(ColorProviderContext),{id:g,url:x,callback:y,visible:E=!0,customMaterial:k=!1,colorType:b,width:C=20,offset:_=new EngineCore.Vector3(0,0,0),direction:A="right"}=e,N=useCachedBinary({url:x,cacheType:CacheType.EXACTLY_MATCH}),S=React.useCallback((w,L,B,D,W=!0)=>{if(t){const ae=EngineCore.MeshBuilder.CreateRibbon("ribbon",{pathArray:[B,D],sideOrientation:W?EngineCore.Mesh.FRONTSIDE:EngineCore.Mesh.DOUBLESIDE},t),ee=ae.getVerticesData(EngineCore.VertexBuffer.PositionKind),H=ae.getIndices();if(ee&&H){const oe=TubeUtil.buildTubeChartColors(ee,Z=>{if(b&&v&&v[b]){const ce=w.max,Q=w.min;let G=new EngineCore.Color3(1,1,1);return Q===Q?G=v[b].array[v[b].array.length-1]:G=v[b].array[Math.trunc((w.chart[Z].value-Q)/(ce-Q)*(v[b].array.length-1))],new EngineCore.Color4(G.r,G.g,G.b,1)}return y?y(L[Z],Z,w.max,w.min):TubeUtil.colorMapTubeChart()},W),te=[],K=ee.length/3;for(let Z=0;Z<K;Z++)Z>=K/2?te.push(D[Z-K/2].x-B[Z-K/2].x,1):te.push(0,1);a(ee.slice()),o(H.slice()),s(oe),c(te)}t==null||t.removeMesh(ae)}},[y,v,b,t]);React.useEffect(()=>{var w,L,B,D,W;if(N){const ae=TubeChart$2.decode(new Uint8Array(N)),ee=C/(ae.max-ae.min),H=ae.min<0?-ae.min:0,oe=A==="right"?C/2:C;console.log(ae);const te=[],K=ae.chart.map(G=>{const ge=G.position?G.position:{x:0,y:0,z:0};return te.push(G.value),new EngineCore.Vector3(ge.x-oe,ge.y+10,ge.z)}),Z=ae.chart.map(G=>{const ge=G.position?G.position:{x:0,y:0,z:0},fe=A==="right"?(G.value+H)*ee:-(G.value+H)*ee;return new EngineCore.Vector3(ge.x+fe-oe,ge.y+10,ge.z)});R(ae.name),u(new EngineCore.Vector3((w=ae.origin)==null?void 0:w.x,(L=ae.origin)==null?void 0:L.y,(B=ae.origin)==null?void 0:B.z).add(_));const ce=C/2-((D=e.style)!=null&&D.fontSize?e.style.fontSize/2:0),Q=K[K.length-1].add(new EngineCore.Vector3(A==="right"?ce:-ce,0,0)).add((W=e.style)!=null&&W.offset?e.style.offset:new EngineCore.Vector3(0,0,0));h(new EngineCore.Vector3(Q.x,Q.y,Q.z)),S(ae,te,K.splice(0,K.length),Z.splice(0,Z.length),!0)}},[S,x,t,_,(O=e.style)==null?void 0:O.offset,C,(F=e.style)==null?void 0:F.fontSize,N,A]);const I=React.useCallback(()=>{},[]);return React.useEffect(()=>{const w=()=>{I()};return t&&t.activeCamera&&(w(),t==null||t.activeCamera.onViewMatrixChangedObservable.add(w)),()=>{t&&t.activeCamera&&(t==null||t.activeCamera.onViewMatrixChangedObservable.removeCallback(w))}},[I,t]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:E&&n.length>0&&i.length>0&&jsxRuntime.jsx(TubeChartComponent$1,{id:g,visible:E,vertices:n,colors:i,uvs:l,indices:r,position:f,style:{...e.style,title:m,position:d},customMaterial:k})})},TubeChart$1=TubeChart,TubeChartLineComponent=e=>{const t=React.useRef(null),n=React.useContext(WorkspaceMetaContext),{id:a,visible:r=!0,position:o}=e,{title:i,color:s,fontSize:l}=e.style;return jsxRuntime.jsx("transformNode",{name:`node-curve-${a}`,position:o?o.multiply(new EngineCore.Vector3(n?n.scalePlane:1,n?n.scaleDepth:1,n?n.scalePlane:1)):new EngineCore.Vector3(0,0,0),scaling:new EngineCore.Vector3(n?n.scalePlane:1,n?n.scaleDepth:1,n?n.scalePlane:1),ref:t,setEnabled:r,children:jsxRuntime.jsx("transformNode",{name:"title",position:e.style.position?e.style.position:new EngineCore.Vector3(0,0,0),scaling:calcGUIScale(n),children:i&&jsxRuntime.jsx(GUIText$1,{text:i,fontSize:l||40,color:s||"white"})})})},TubeChartLineComponent$1=TubeChartLineComponent,TubeChartLine=e=>{var x,y;const t=reactBabylonjs.useScene(),[n,a]=React.useState(),[r,o]=React.useState(),[i,s]=React.useState(),[l,c]=React.useState([]),{id:f,url:u,visible:d=!0,offset:h=new EngineCore.Vector3(0,0,0),color:m,width:R=20}=e,v=useCachedBinary({url:u,cacheType:CacheType.EXACTLY_MATCH}),g=React.useContext(WorkspaceMetaContext);return React.useEffect(()=>{var E,k,b,C,_,A,N,S;if(v){const I=TubeChart$2.decode(new Uint8Array(v)),O=R/(I.max-I.min),F=I.min<0?-I.min:0,w=new EngineCore.Vector3((E=I.origin)==null?void 0:E.x,(k=I.origin)==null?void 0:k.y,(b=I.origin)==null?void 0:b.z).add(h);a(w);const L=I.chart,B=[];for(let W=0;W<L.length;W++)B.push(w.add(new EngineCore.Vector3((C=L[W].position)==null?void 0:C.x,(_=L[W].position)==null?void 0:_.y,(A=L[W].position)==null?void 0:A.z)).add(new EngineCore.Vector3((L[W].value+F)*O,0,0)).multiply(calcTransformNodeScale(g)));c([B]);const D=L[L.length-1].position;if(D){const W=new EngineCore.Vector3(D.x,D.y,D.z).add(new EngineCore.Vector3(R/2-((N=e.style)!=null&&N.fontSize?e.style.fontSize/2:0),0,0)).add((S=e.style)!=null&&S.offset?e.style.offset:new EngineCore.Vector3(0,0,0));o(new EngineCore.Vector3(W.x,W.y,W.z))}s(I.name)}},[u,t,h,(x=e.style)==null?void 0:x.offset,(y=e.style)==null?void 0:y.fontSize,v,g,R]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TubeChartLineComponent$1,{id:f,visible:d,position:n,style:{...e.style,title:i,position:r}}),l.length>0&&jsxRuntime.jsx("lineSystem",{name:"line",lines:l,color:m,setEnabled:d})]})},TubeChartLine$1=TubeChartLine;function createBaseLayer(){return{name:"",origin:void 0,layerList:[]}}const Layer={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.origin!==void 0&&Vertex.encode(e.origin,t.uint32(18).fork()).ldelim();for(const n of e.layerList)Layer_LayerSlice.encode(n,t.uint32(26).fork()).ldelim();return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseLayer();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.origin=Vertex.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.layerList.push(Layer_LayerSlice.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$2(e.name)?globalThis.String(e.name):"",origin:isSet$2(e.origin)?Vertex.fromJSON(e.origin):void 0,layerList:globalThis.Array.isArray(e==null?void 0:e.layerList)?e.layerList.map(t=>Layer_LayerSlice.fromJSON(t)):[]}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),e.origin!==void 0&&(t.origin=Vertex.toJSON(e.origin)),(n=e.layerList)!=null&&n.length&&(t.layerList=e.layerList.map(a=>Layer_LayerSlice.toJSON(a))),t},create(e){return Layer.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseLayer();return t.name=(n=e.name)!=null?n:"",t.origin=e.origin!==void 0&&e.origin!==null?Vertex.fromPartial(e.origin):void 0,t.layerList=((a=e.layerList)==null?void 0:a.map(r=>Layer_LayerSlice.fromPartial(r)))||[],t}};function createBaseLayer_LayerSlice(){return{name:"",position:void 0,start:void 0,end:void 0,radius:0,colorId:0,v:[]}}const Layer_LayerSlice={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.position!==void 0&&Vertex.encode(e.position,t.uint32(18).fork()).ldelim(),e.start!==void 0&&Vertex.encode(e.start,t.uint32(26).fork()).ldelim(),e.end!==void 0&&Vertex.encode(e.end,t.uint32(34).fork()).ldelim(),e.radius!==0&&t.uint32(45).float(e.radius),e.colorId!==0&&t.uint32(53).float(e.colorId);for(const n of e.v)t.uint32(58).string(n);return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseLayer_LayerSlice();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.position=Vertex.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.start=Vertex.decode(n,n.uint32());continue;case 4:if(o!==34)break;r.end=Vertex.decode(n,n.uint32());continue;case 5:if(o!==45)break;r.radius=n.float();continue;case 6:if(o!==53)break;r.colorId=n.float();continue;case 7:if(o!==58)break;r.v.push(n.string());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$2(e.name)?globalThis.String(e.name):"",position:isSet$2(e.position)?Vertex.fromJSON(e.position):void 0,start:isSet$2(e.start)?Vertex.fromJSON(e.start):void 0,end:isSet$2(e.end)?Vertex.fromJSON(e.end):void 0,radius:isSet$2(e.radius)?globalThis.Number(e.radius):0,colorId:isSet$2(e.colorId)?globalThis.Number(e.colorId):0,v:globalThis.Array.isArray(e==null?void 0:e.v)?e.v.map(t=>globalThis.String(t)):[]}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),e.position!==void 0&&(t.position=Vertex.toJSON(e.position)),e.start!==void 0&&(t.start=Vertex.toJSON(e.start)),e.end!==void 0&&(t.end=Vertex.toJSON(e.end)),e.radius!==0&&(t.radius=e.radius),e.colorId!==0&&(t.colorId=e.colorId),(n=e.v)!=null&&n.length&&(t.v=e.v),t},create(e){return Layer_LayerSlice.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o;const t=createBaseLayer_LayerSlice();return t.name=(n=e.name)!=null?n:"",t.position=e.position!==void 0&&e.position!==null?Vertex.fromPartial(e.position):void 0,t.start=e.start!==void 0&&e.start!==null?Vertex.fromPartial(e.start):void 0,t.end=e.end!==void 0&&e.end!==null?Vertex.fromPartial(e.end):void 0,t.radius=(a=e.radius)!=null?a:0,t.colorId=(r=e.colorId)!=null?r:0,t.v=((o=e.v)==null?void 0:o.map(i=>i))||[],t}};function isSet$2(e){return e!=null}const TubeComponent=(e,t)=>{const n=reactBabylonjs.useScene(),a=React.useRef(null),r=React.useRef(null),o=React.useContext(WorkspaceMetaContext),{id:i,visible:s=!0,vertices:l,indices:c,colors:f,position:u,materialType:d="custom",children:h,alphaBlend:m=!1,alpha:R=1,name:v="tube",actions:g,slices:x}=e;React.useImperativeHandle(t,()=>r.current,[]),React.useEffect(()=>{a.current&&(a.current.metadata={pickable:g?{needWorldPosition:!0,name:v,onLeftClick:g.onLeftClick,onRightClick:g.onRightClick,onMiddleClick:g.onMiddleClick,onHover:(E,k,b,C,_)=>{var A,N,S,I,O,F;if(g.onHover&&n&&x&&b){const w=b;for(let L=0;L<x.length;L++){const B=new EngineCore.Vector3((A=x[L].start)==null?void 0:A.x,(N=x[L].start)==null?void 0:N.y,(S=x[L].start)==null?void 0:S.z).add(u).multiply(calcTransformNodeScale(o)),D=new EngineCore.Vector3((I=x[L].end)==null?void 0:I.x,(O=x[L].end)==null?void 0:O.y,(F=x[L].end)==null?void 0:F.z).add(u).multiply(calcTransformNodeScale(o)),W=Math.sqrt(Math.pow(B.x-D.x,2)+Math.pow(B.y-D.y,2)+Math.pow(B.z-D.z,2)),ae=new EngineCore.Vector3(B.x,B.y-W,B.z),ee=D.subtract(B),H=ae.subtract(B),oe=w.subtract(B),te=EngineCore.Vector3.Cross(ee,H),K=Math.acos(EngineCore.Vector3.Dot(ee.normalize(),H.normalize())),Z=EngineCore.Matrix.RotationAxis(te,K),ce=EngineCore.Vector3.TransformCoordinates(oe,Z);if(0>=ce.y&&-W<=ce.y){g.onHover(E,k,b,C,x[L],_);break}}}},valueCallback:null,extra:g.extra}:null})},[g,o,u,n,x]),React.useEffect(()=>{if(a&&a.current&&n){const E=new EngineCore.VertexData;E.positions=l,E.indices=c,f&&d!=="pbr-dark"&&d!=="pbr-light"&&(E.colors=f),E.applyToMesh(a.current)}},[c,l,n,f,i,d]);const y=React.useCallback(()=>{if(d==="custom")return jsxRuntime.jsx(CustomShader$1,{name:`${v}-material-${i}`,vertex:flatVertexSource,fragment:flatFragmentSource,needDepthPrePass:!1,transparencyMode:m?EngineCore.Material.MATERIAL_ALPHABLEND:EngineCore.Material.MATERIAL_OPAQUE,options:{needAlphaBlending:!!m}});if(d==="standard")return jsxRuntime.jsx("standardMaterial",{name:`${v}-material`,alphaMode:EngineCore.Engine.ALPHA_COMBINE,transparencyMode:m?EngineCore.Material.MATERIAL_ALPHABLEND:EngineCore.Material.MATERIAL_OPAQUE,alpha:R});if(d==="pbr-light")return jsxRuntime.jsx(LightMetalMaterial,{alpha:R});if(d==="pbr-dark")return jsxRuntime.jsx(DarkMetalMaterial,{alpha:R})},[R,m,i,d,v]);return jsxRuntime.jsxs("transformNode",{name:`node-${v}-${i}`,setEnabled:s,children:[jsxRuntime.jsx("transformNode",{name:`${v}`,position:u?u.multiply(new EngineCore.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1)):new EngineCore.Vector3(0,0,0),scaling:new EngineCore.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1),ref:r,children:jsxRuntime.jsx("mesh",{name:`${v}-mesh`,ref:a,children:y()})}),h]})},TubeComponent$1=React.forwardRef(TubeComponent),TubeLayerComponent=(e,t)=>{const n=React.useRef(null),a=React.useContext(WorkspaceMetaContext);React.useImperativeHandle(t,()=>n.current,[]);const{id:r,visible:o=!0,position:i,data:s,offset:l=new EngineCore.Vector3(0,0,0),color:c="white",fontSize:f=40,showLabel:u=!0}=e;return jsxRuntime.jsx("transformNode",{name:`node-layer-${r}`,position:i?i.add(l).multiply(new EngineCore.Vector3(a?a.scalePlane:1,a?a.scaleDepth:1,a?a.scalePlane:1)):new EngineCore.Vector3(0,0,0).add(l),scaling:new EngineCore.Vector3(a?a.scalePlane:1,a?a.scaleDepth:1,a?a.scalePlane:1),ref:n,setEnabled:o,children:u?s.map((d,h)=>jsxRuntime.jsx("transformNode",{name:"layer-text",position:d.position,scaling:calcGUIScale(a),children:jsxRuntime.jsx(GUIText$1,{text:d.name,fontSize:f,color:c})},h)):jsxRuntime.jsx(jsxRuntime.Fragment,{})})},TubeLayerComponent$1=React.forwardRef(TubeLayerComponent),TubeLayer$2=e=>{var S,I,O,F,w;const t=reactBabylonjs.useScene(),[n,a]=React.useState([]),[r,o]=React.useState([]),[i,s]=React.useState([]),[l,c]=React.useState(),[f,u]=React.useState([]),[d,h]=React.useState(0),[m,R]=React.useState(),{colorIDs:v}=React.useContext(ColorProviderContext),{id:g,url:x,color:y,layers:E=[],visible:k=!0,tessellation:b=64,frontSide:C=!1,customMaterial:_=!1,actions:A}=e,N=useCachedBinary({url:x,cacheType:CacheType.EXACTLY_MATCH});return React.useEffect(()=>{var L,B,D,W,ae,ee;if(N){const H=Layer.decode(new Uint8Array(N)),oe=[];H.layerList.forEach((fe,V)=>{var J,Re,Ce,Y,ue,ne;oe.push(fe),V<H.layerList.length&&oe.push({...fe,name:fe.name+"opacity",start:{x:(Re=(J=fe==null?void 0:fe.end)==null?void 0:J.x)!=null?Re:0,y:(Y=(Ce=fe==null?void 0:fe.end)==null?void 0:Ce.y)!=null?Y:0,z:(ne=(ue=fe==null?void 0:fe.end)==null?void 0:ue.z)!=null?ne:0}})});const te=oe.map(fe=>{const V=fe.start?fe.start:{x:0,y:0,z:0};return new EngineCore.Vector3(V.x,V.y,V.z)}),K=EngineCore.MeshBuilder.CreateTube("tube-tmp",{path:te,radiusFunction:fe=>{var J;const V=(J=oe[fe])==null?void 0:J.radius;return V||1},cap:EngineCore.Mesh.NO_CAP,tessellation:b,sideOrientation:C?EngineCore.Mesh.FRONTSIDE:EngineCore.Mesh.DOUBLESIDE},t),Z=K.getVerticesData(EngineCore.VertexBuffer.PositionKind),ce=_?TubeUtil.correctTubeMainIndices(K.getIndices()):K.getIndices(),Q=y;let G=[];Z&&(G=TubeUtil.buildTubeMainColors(Z,oe.map(fe=>{const V=Q||(v&&v[fe.colorId]?v[fe.colorId]:TubeUtil.randomColorMap()),J=E.findIndex(Re=>Re===fe.name)!==-1?V.a:0;return new EngineCore.Color4(V.r,V.g,V.b,J)}),b,!!C)),R(H),a(Z?Z.slice():[]),o(ce?ce.slice():[]),s(G),c(new EngineCore.Vector3((L=H.origin)==null?void 0:L.x,(B=H.origin)==null?void 0:B.y,(D=H.origin)==null?void 0:D.z)),t==null||t.removeMesh(K);const ge=[];for(let fe=0;fe<H.layerList.length;fe++){const V=H.layerList[fe];E.findIndex(J=>J===V.name)!==-1&&ge.push({name:V.name,position:new EngineCore.Vector3((W=V.position)==null?void 0:W.x,(ae=V.position)==null?void 0:ae.y,(ee=V.position)==null?void 0:ee.z)})}u(ge),h(H.layerList?H.layerList[0].radius:0)}},[x,t,C,b,_,E,v,N,y]),jsxRuntime.jsxs("transformNode",{name:`node-layer-${g}`,children:[n.length>0&&r.length>0&&jsxRuntime.jsx(TubeComponent$1,{id:g,name:"tube-layer",visible:k,vertices:n,slices:m==null?void 0:m.layerList,indices:r,position:l,colors:i.length>0?i:void 0,materialType:_?"custom":"standard",alphaBlend:!0,actions:A}),f.length>0&&jsxRuntime.jsx(TubeLayerComponent$1,{id:g,data:f,visible:k,position:l,fontSize:(S=e.style)==null?void 0:S.fontSize,color:(I=e.style)==null?void 0:I.color,offset:(F=(O=e.style)==null?void 0:O.offset)==null?void 0:F.add(new EngineCore.Vector3(d,0,0)),showLabel:(w=e.style)==null?void 0:w.showLabel})]})},TubeLayer$3=TubeLayer$2,TubeRingCap=e=>{const t=reactBabylonjs.useScene(),n=React.useRef(null),[a,r]=React.useState([]),[o,i]=React.useState([]),[s,l]=React.useState([]),{color:c,type:f,name:u="cap",materialType:d,tessellation:h,data:m}=e,R=React.useCallback(()=>{const g=[],x=[];for(let A=0;A<2*h+1;A++)if(f==="start")g.push(new EngineCore.Vector3(m[A*3],m[A*3+1],m[A*3+2]));else{const N=m.length-2*h*3;g.push(new EngineCore.Vector3(m[A*3+N],m[A*3+1+N],m[A*3+2+N]))}const y=[],E=[];for(let A=0;A<h;A++)y.push(g[A]),E.push(g[2*h-A-1]);x.push(y,E);const k=EngineCore.MeshBuilder.CreateRibbon("ribbon-tmp",{pathArray:x,sideOrientation:EngineCore.Mesh.DOUBLESIDE},t),b=k.getVerticesData(EngineCore.VertexBuffer.PositionKind),C=k.getIndices(),_=k.getNormalsData();r(b?b.slice():[]),i(C?C.slice():[]),l(_?_.slice():[]),t==null||t.removeMesh(k)},[t,h,f,m]);React.useEffect(()=>{R()},[R]),React.useEffect(()=>{if(n&&n.current&&t){const g=new EngineCore.VertexData;g.positions=a,g.indices=o,g.normals=s,g.applyToMesh(n.current)}},[o,a,t,s]);const v=React.useCallback(()=>d==="pbr"?jsxRuntime.jsx("pbrMaterial",{name:"cap-pbr-material",alpha:.8,metallic:1,roughness:.03,albedoColor:new EngineCore.Color3(248/255,163/255,151/255),emissiveColor:new EngineCore.Color3(36/255,36/255,36/255),transparencyMode:EngineCore.Material.MATERIAL_OPAQUE}):jsxRuntime.jsx("standardMaterial",{name:`${u}-material`,alphaMode:EngineCore.Engine.ALPHA_COMBINE,transparencyMode:EngineCore.Material.MATERIAL_OPAQUE,diffuseColor:new EngineCore.Color3(c.r,c.g,c.b)}),[c.b,c.g,c.r,d,u]);return jsxRuntime.jsx("mesh",{name:`${u}-mesh`,ref:n,isPickable:!0,children:v()})},TubeRingCap$1=TubeRingCap,TubeMain=e=>{const t=reactBabylonjs.useScene(),n=React.useRef(null),[a,r]=React.useState(EngineCore.Vector3.Zero()),[o,i]=React.useState([]),[s,l]=React.useState([]),[c,f]=React.useState([]),[u,d]=React.useState(""),[h,m]=React.useState(new EngineCore.Vector3(0,0,0)),[R,v]=React.useState([]),g=React.useContext(WorkspaceMetaContext),{id:x,color:y,url:E,name:k="tube",children:b,materialType:C="standard",actions:_,tessellation:A=32,style:N}=e,S=React.useRef(!1),I=React.useCallback(F=>{var ee,H,oe;const w=F.sliceList.filter(te=>!(te.v.length>0)).map(te=>{const K=te.start?te.start:{x:0,y:0,z:0};return new EngineCore.Vector3(K.x,K.y,K.z)}),L=F.sliceList[F.sliceList.length-1];if(w.length>0&&w.push(new EngineCore.Vector3((ee=L.end)==null?void 0:ee.x,(H=L.end)==null?void 0:H.y,(oe=L.end)==null?void 0:oe.z)),w.length<1)return;const B=EngineCore.MeshBuilder.ExtrudeShape("tmp",{path:w,sideOrientation:EngineCore.Mesh.DOUBLESIDE,shape:TubeUtil.buildSemiRing(L.innerRadius,L.radius,A),cap:EngineCore.Mesh.NO_CAP},t);v(B.getVerticesData(EngineCore.VertexBuffer.PositionKind)),B.convertToFlatShadedMesh(),B.computeWorldMatrix(!0),B._updateBoundingInfo();const D=B.getVerticesData(EngineCore.VertexBuffer.PositionKind),W=B.getIndices(),ae=B.getNormalsData();i(D?D.slice():[]),l(W?W.slice():[]),f(ae?ae.slice():[]),t==null||t.removeMesh(B)},[t,A]);React.useEffect(()=>{S.current||(S.current=!0,axios.get(E,{responseType:"arraybuffer"}).then(F=>{var B,D,W;const w=Tube$2.decode(new Uint8Array(F.data));if(console.log(w),w.sliceList.length===0)return;d(w.name);const L=N!=null&&N.basePosition&&N.basePosition==="top"?w.sliceList[0].start:w.sliceList[w.sliceList.length-1].end;m(new EngineCore.Vector3(L==null?void 0:L.x,L==null?void 0:L.y,L==null?void 0:L.z)),r(new EngineCore.Vector3((B=w.origin)==null?void 0:B.x,(D=w.origin)==null?void 0:D.y,(W=w.origin)==null?void 0:W.z)),I(w)}))},[I,N==null?void 0:N.basePosition,E]),React.useEffect(()=>{if(n&&n.current&&t){const F=new EngineCore.VertexData;F.positions=o,F.indices=s,F.normals=c,F.applyToMesh(n.current)}},[s,o,t,c]),React.useEffect(()=>{n.current&&(n.current.metadata={pickable:_?{name:k,value:x,onLeftClick:_.onLeftClick,valueCallback:()=>x,onRightClick:_.onRightClick,onMiddleClick:_.onMiddleClick,onHover:_.onHover}:null})},[_,x,g,k,a,t]);const O=React.useCallback(()=>C==="pbr"?jsxRuntime.jsx("pbrMaterial",{name:"main-pbr-material",alpha:1,metallic:1,roughness:.03,albedoColor:new EngineCore.Color3(230/255,230/255,230/255),emissiveColor:new EngineCore.Color3(71/255,71/255,71/255),transparencyMode:EngineCore.Material.MATERIAL_OPAQUE}):jsxRuntime.jsx("standardMaterial",{name:`${k}-material`,alphaMode:EngineCore.Engine.ALPHA_COMBINE,transparencyMode:EngineCore.Material.MATERIAL_OPAQUE,diffuseColor:new EngineCore.Color3(y.r,y.g,y.b)}),[y.b,y.g,y.r,C,k]);return jsxRuntime.jsxs("transformNode",{name:`${k}-main-node`,position:a.multiply(calcTransformNodeScale(g)),scaling:calcTransformNodeScale(g),children:[jsxRuntime.jsx("mesh",{name:`${k}-mesh`,ref:n,isPickable:!0,children:O()}),R.length>0&&jsxRuntime.jsx(TubeRingCap$1,{id:1,name:"start",color:y,type:"start",tessellation:A,data:R,materialType:C}),R.length>0&&jsxRuntime.jsx(TubeRingCap$1,{id:2,name:"end",color:y,type:"end",tessellation:A,data:R,materialType:C}),N&&jsxRuntime.jsx(TubeTitle$1,{id:x,style:{title:u,position:h,offset:N.offset,fontSize:N.fontSize,color:N.color}}),b]})},TubeMain$1=TubeMain,TubeOil=e=>{const{id:t,visible:n=!0,children:a,offset:r=new EngineCore.Vector3(0,0,0)}=e;return jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("transformNode",{name:`tube-${t}`,setEnabled:n,position:r,children:a})})},TubeOil$1=TubeOil;function createBaseVoxelGrid(){return{name:"",origin:void 0,dataPoints:[],size:void 0}}const VoxelGrid$2={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.origin!==void 0&&Vertex.encode(e.origin,t.uint32(18).fork()).ldelim();for(const n of e.dataPoints)VoxelGrid_DataPoint.encode(n,t.uint32(26).fork()).ldelim();return e.size!==void 0&&Vertex.encode(e.size,t.uint32(34).fork()).ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseVoxelGrid();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.origin=Vertex.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.dataPoints.push(VoxelGrid_DataPoint.decode(n,n.uint32()));continue;case 4:if(o!==34)break;r.size=Vertex.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet$1(e.name)?globalThis.String(e.name):"",origin:isSet$1(e.origin)?Vertex.fromJSON(e.origin):void 0,dataPoints:globalThis.Array.isArray(e==null?void 0:e.dataPoints)?e.dataPoints.map(t=>VoxelGrid_DataPoint.fromJSON(t)):[],size:isSet$1(e.size)?Vertex.fromJSON(e.size):void 0}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),e.origin!==void 0&&(t.origin=Vertex.toJSON(e.origin)),(n=e.dataPoints)!=null&&n.length&&(t.dataPoints=e.dataPoints.map(a=>VoxelGrid_DataPoint.toJSON(a))),e.size!==void 0&&(t.size=Vertex.toJSON(e.size)),t},create(e){return VoxelGrid$2.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=createBaseVoxelGrid();return t.name=(n=e.name)!=null?n:"",t.origin=e.origin!==void 0&&e.origin!==null?Vertex.fromPartial(e.origin):void 0,t.dataPoints=((a=e.dataPoints)==null?void 0:a.map(r=>VoxelGrid_DataPoint.fromPartial(r)))||[],t.size=e.size!==void 0&&e.size!==null?Vertex.fromPartial(e.size):void 0,t}};function createBaseVoxelGrid_DataPoint(){return{point:void 0,colorId:0,vScale:0,rotation:void 0,pointType:0}}const VoxelGrid_DataPoint={encode(e,t=minimal.Writer.create()){return e.point!==void 0&&Vertex.encode(e.point,t.uint32(10).fork()).ldelim(),e.colorId!==0&&t.uint32(16).uint32(e.colorId),e.vScale!==0&&t.uint32(37).float(e.vScale),e.rotation!==void 0&&Vertex.encode(e.rotation,t.uint32(42).fork()).ldelim(),e.pointType!==0&&t.uint32(48).uint32(e.pointType),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseVoxelGrid_DataPoint();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.point=Vertex.decode(n,n.uint32());continue;case 2:if(o!==16)break;r.colorId=n.uint32();continue;case 4:if(o!==37)break;r.vScale=n.float();continue;case 5:if(o!==42)break;r.rotation=Vertex.decode(n,n.uint32());continue;case 6:if(o!==48)break;r.pointType=n.uint32();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{point:isSet$1(e.point)?Vertex.fromJSON(e.point):void 0,colorId:isSet$1(e.colorId)?globalThis.Number(e.colorId):0,vScale:isSet$1(e.vScale)?globalThis.Number(e.vScale):0,rotation:isSet$1(e.rotation)?Vertex.fromJSON(e.rotation):void 0,pointType:isSet$1(e.pointType)?globalThis.Number(e.pointType):0}},toJSON(e){const t={};return e.point!==void 0&&(t.point=Vertex.toJSON(e.point)),e.colorId!==0&&(t.colorId=Math.round(e.colorId)),e.vScale!==0&&(t.vScale=e.vScale),e.rotation!==void 0&&(t.rotation=Vertex.toJSON(e.rotation)),e.pointType!==0&&(t.pointType=Math.round(e.pointType)),t},create(e){return VoxelGrid_DataPoint.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=createBaseVoxelGrid_DataPoint();return t.point=e.point!==void 0&&e.point!==null?Vertex.fromPartial(e.point):void 0,t.colorId=(n=e.colorId)!=null?n:0,t.vScale=(a=e.vScale)!=null?a:0,t.rotation=e.rotation!==void 0&&e.rotation!==null?Vertex.fromPartial(e.rotation):void 0,t.pointType=(r=e.pointType)!=null?r:0,t}};function isSet$1(e){return e!=null}const POINT_TYPE_LOOKUP_TABLE=[0,.05,.1,.15,.2,.25,.3,.35,.4,.45,.5,.55,.6,.65,.7,.75,.8,.85,.9,.95,1],VoxelGrid=({url:e,alpha:t={typeAlpha0:1,typeAlpha1:1},offset:n=EngineCore.Vector3.Zero(),visible:a=!0})=>{const r=reactBabylonjs.useScene(),o=React.useContext(WorkspaceMetaContext),i=React.useContext(ColorProviderContext),[s,l]=React.useState(""),[c,f]=React.useState(EngineCore.Vector3.Zero()),u=useCachedBinary({url:e,cacheType:CacheType.URL_PREFIX_MATCH}),d=React.useRef(null),h=React.useRef(null);React.useEffect(()=>{console.log("[Geo3DViewer] VoxelGrid Loading: ",e)},[e]);const m=R=>POINT_TYPE_LOOKUP_TABLE[R];return React.useEffect(()=>{if(r&&u){const R=VoxelGrid$2.decode(new Uint8Array(u)),{name:v,origin:g,dataPoints:x,size:y}=R;if(g&&x){l(v),f(new EngineCore.Vector3(g.x,g.y,g.z));let E=null;y&&(E=EngineCore.MeshBuilder.CreateBox("voxel",{width:y.x-1e-5,height:y.y-1e-5,depth:y.z-1e-5},r),E.material=d.current,EngineCore.Tags.EnableFor(E),EngineCore.Tags.AddTagsTo(E,"loading"));const k=new Float32Array(x.length*16),b=new Float32Array(x.length*4);return x.forEach((C,_)=>{if(C.point){const A=new EngineCore.Vector3(C.point.x,C.point.y,C.point.z),N=C.rotation?EngineCore.Quaternion.FromEulerAngles(C.rotation.x,C.rotation.y,C.rotation.z):EngineCore.Quaternion.Identity(),S=new EngineCore.Vector3(C.vScale+1,C.vScale+1,C.vScale+1);EngineCore.Matrix.Compose(S,N,A).copyToArray(k,_*16);let O=i.colorIDs[C.colorId];O||(O=EngineCore.Color4.FromColor3(EngineCore.Color3.Random())),b.set([O.r,O.g,O.b,m(C.pointType)],_*4)}}),E&&(E.thinInstanceSetBuffer("matrix",k),E.thinInstanceSetBuffer("color",b,4),E.parent=h.current),EngineCore.Tags.RemoveTagsFrom(E,"loading"),()=>{E&&(E.thinInstanceSetBuffer("matrix",new Float32Array),E.thinInstanceSetBuffer("color",new Float32Array),r.removeMesh(E))}}}},[i.colorIDs,r,u]),jsxRuntime.jsx("transformNode",{setEnabled:a,name:`transform-voxel-${s}`,position:c.add(n).multiplyByFloats(o&&o.scalePlane?o.scalePlane:1,o&&o.scaleDepth?o.scaleDepth:1,o&&o.scalePlane?o.scalePlane:1),scaling:new EngineCore.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1),ref:h,children:jsxRuntime.jsx(VoxelGridMaterialForwardRef,{name:`voxel-${s}-mat`,typeAlpha:t,ref:d})})},VoxelGrid$1=VoxelGrid,DataBinding=(e,t)=>{const{viewer:n,camera:a,useUniversalCamera:r=!1,lights:o,complexFormationManagers:i,formationManagers:s,formationFaces:l,formationVolumes:c,structureLayers:f,colorCodec:u,gridDiagrams:d,attributeBodies:h,tubes:m,roadways:R,densitySlices:v,formationSlices:g,rayClick:x,lines:y,spaceHeats:E,lookAt:k,fps:b,coordinate:C,tileMaps:_,pointClickZones:A,progressedAttributeBodies:N,ribbonLayers:S,intersectingLines:I,tubeInstances:O,optimizer:F,voxelGrids:w,planeImages:L,guiTexts:B,skybox:D,particleSystems:W,waterEffects:ae,modelLoaders:ee,modelAnimationLoaders:H,roadwayAnimations:oe,roadwayNearAnimations:te,roadwayWaterAnimations:K,contourlines:Z,tubeTools:ce,tubeOils:Q,tubeLayers:G,tubeChartLines:ge,tubeCharts:fe}=e;return jsxRuntime.jsxs(Geo3DViewer$1,{...n,ref:t,children:[r?jsxRuntime.jsx(Geo3DFreeCamera$1,{...a}):jsxRuntime.jsx(Geo3DCamera$1,{...a}),o?o.map((V,J)=>jsxRuntime.jsx("hemisphericLight",{...V,name:`extra-light-${J}`},`extra-light-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),i?i.map(V=>jsxRuntime.jsx(ComplexFormationManager$1,{...V},`complexFormationManager-${V.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),v?v.map(V=>jsxRuntime.jsx(DensitySlice$1,{...V},`densitySlice-${V.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),g?g.map(V=>jsxRuntime.jsx(FormationSlice$1,{...V},`formationSlice-${V.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),s?s.map(V=>jsxRuntime.jsx(FormationManager$1,{...V},`formationManager-${V.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),l?l.map(V=>jsxRuntime.jsx(FormationFace$1,{...V},`formation-face-${V.urlTopLayer}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),c?c.map(V=>jsxRuntime.jsx(FormationVolume$1,{...V},`formation-volume-${V.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),f?f.map(V=>jsxRuntime.jsx(StructureLayer$1,{...V},`structurelayer-${V.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),u?jsxRuntime.jsx(ColorCodec$1,{...u}):jsxRuntime.jsx(jsxRuntime.Fragment,{}),d?d.map(V=>jsxRuntime.jsx(GridDiagram$1,{...V},`gridDiagram-${V.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),h?h.map(V=>jsxRuntime.jsx(AttributeBody$1,{...V},`attributebody-${V.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),m?m.map(V=>jsxRuntime.jsxs(Tube$1,{...V,children:[V.charts?V.charts.map(J=>jsxRuntime.jsx(TubeChart$1,{...J},`tubechart-${J.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),V.layers?V.layers.map(J=>jsxRuntime.jsx(TubeLayer$3,{...J},`tubelayer-${J.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),V.tools?V.tools.map(J=>jsxRuntime.jsx(TubeTool$1,{...J},`tubelayer-${J.name}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{})]},`tube-${V.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),R?R.map(V=>jsxRuntime.jsx(RoadWay$1,{...V},`roadway-${V.url}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),x?x.map((V,J)=>jsxRuntime.jsx(RayClick$1,{...V},`rayclick-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),y?y.map((V,J)=>jsxRuntime.jsx(Line$1,{...V},`line-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),E?E.map((V,J)=>jsxRuntime.jsx(SpaceHeat$1,{...V},`spaceheat-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),k?jsxRuntime.jsx(LookAt$1,{target:void 0,distance:0}):jsxRuntime.jsx(jsxRuntime.Fragment,{}),b?jsxRuntime.jsx(FPS$1,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{}),C?jsxRuntime.jsx(Coordinate$1,{...C},"coordinate"):jsxRuntime.jsx(jsxRuntime.Fragment,{}),_?_.map((V,J)=>jsxRuntime.jsx(TileMap$1,{...V},`tilemap-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),A?A.map((V,J)=>jsxRuntime.jsx(PointClickZone$1,{...V},`pointClickZone-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),N?N.map((V,J)=>jsxRuntime.jsx(ProgressedAttributeBody$1,{...V},`progressedAttributeBody-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),S?S.map((V,J)=>jsxRuntime.jsx(RibbonLayer$1,{...V},`ribbonlayer-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),I?I.map((V,J)=>jsxRuntime.jsx(IntersectingLine$1,{...V},`intersectingLine-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),O?O.map((V,J)=>jsxRuntime.jsx(TubeInstance$1,{...V},`tubeinstance-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),F?jsxRuntime.jsx(Optimizer$1,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{}),w?w.map((V,J)=>jsxRuntime.jsx(VoxelGrid$1,{...V},`voxelgrid-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),L?L.map((V,J)=>jsxRuntime.jsx(PlaneImage$1,{...V},`planeimage-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),B?B.map((V,J)=>jsxRuntime.jsx(TransformGUIText$1,{...V},`guitext-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),D&&jsxRuntime.jsx(SkyBox$1,{...D}),W?W.map((V,J)=>jsxRuntime.jsx(ParticleSystem$1,{...V},`particlesystem-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),ae?ae.map((V,J)=>jsxRuntime.jsx(WaterEffect$1,{...V},`waterEffect-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),ee?ee.map((V,J)=>jsxRuntime.jsx(ModelLoader$1,{...V},`modelLoaders-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),H?H.map((V,J)=>jsxRuntime.jsx(ModleAnimationLoader,{...V},`modelanimtionloader-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),oe?oe.map((V,J)=>jsxRuntime.jsx(Animation$1,{...V,children:jsxRuntime.jsx(RoadWayAnimation$1,{})},`animation-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),te?te.map((V,J)=>jsxRuntime.jsx(Animation$1,{...V,children:jsxRuntime.jsx(RoadWayNearAnimation$1,{roadwayWidth:V.roadwayWidth,textureLength:V.textureLength,url:V.imageUrl,isBlink:V.isBlink,visible:V.visible})},`animation-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),K?K.map((V,J)=>jsxRuntime.jsx(Animation$1,{...V,children:jsxRuntime.jsx(RoadWayWaterEffectAnimationNode$1,{timeSpeed:V.timeSpeed,perlinMultiply:V.perlinMultiply,waterFlow:V.waterFlow,clippedHeight:V.clippedHeight,alpha:V.alpha,colorSteps:V.colorSteps,speed:V.speed})},`animation-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),Z?Z.map((V,J)=>jsxRuntime.jsx(ContourLine$1,{...V},`contourline-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),ce?ce.map((V,J)=>jsxRuntime.jsx(TubeTool$1,{...V},`tubeTool-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),Q?Q.map((V,J)=>jsxRuntime.jsx(TubeOil$1,{...V,children:V.main?V.main.map((Re,Ce)=>jsxRuntime.jsx(TubeMain$1,{...Re},`tubeMain-${Ce}`)):null},`tubeOil-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),G?G.map((V,J)=>jsxRuntime.jsx(TubeLayer$3,{...V},`tubeLayer-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),ge?ge.map((V,J)=>jsxRuntime.jsx(TubeChartLine$1,{...V},`tubeChartLine-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{}),fe?fe.map((V,J)=>jsxRuntime.jsx(TubeChart$1,{...V},`tubeChart-${J}`)):jsxRuntime.jsx(jsxRuntime.Fragment,{})]})},DataBinding$1=React.forwardRef(DataBinding),Roam=e=>{const t=reactBabylonjs.useScene(),n=React.useRef(null),{keyFrames:a,speed:r}=e;return React.useEffect(()=>{if(t&&n.current&&n.current.animations.length===0){const o=new EngineCore.Animation("roam","position",40,EngineCore.Animation.ANIMATIONTYPE_VECTOR3,EngineCore.Animation.ANIMATIONLOOPMODE_CONSTANT);for(let i=0;i<a.length;i++)i!==a.length-1&&o.addEvent(new EngineCore.AnimationEvent(a[i].frame,()=>{var s;(s=n.current)==null||s.setTarget(a[i+1].value)}));o.setKeys(a),n.current.animations.push(o),t==null||t.beginAnimation(n.current,0,a[a.length-1].frame,!1,Math.abs(r),()=>{n.current&&(n.current.position=a[0].value,n.current.setTarget(a[1].value))})}},[a,t,r]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("freeCamera",{name:"roam-camera",position:new EngineCore.Vector3(0,0,0),ref:n}),jsxRuntime.jsx("lines",{name:"",points:a.map(o=>o.value)}),a.map((o,i)=>jsxRuntime.jsx("sphere",{name:"roam-sphere-"+i,diameter:1,position:o.value,children:jsxRuntime.jsx("standardMaterial",{name:"roam-sphere-mat",diffuseColor:EngineCore.Color3.Red(),specularColor:EngineCore.Color3.Black(),alpha:1})},i))]})},Roam$1=Roam;function createBaseRod(){return{name:"",origin:void 0,type:"",sliceList:[],vertices:[],normals:[],indices:[],uv:[]}}const Rod={encode(e,t=minimal.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.origin!==void 0&&Vertex.encode(e.origin,t.uint32(18).fork()).ldelim(),e.type!==""&&t.uint32(26).string(e.type);for(const n of e.sliceList)Rod_Slice.encode(n,t.uint32(34).fork()).ldelim();t.uint32(42).fork();for(const n of e.vertices)t.float(n);t.ldelim(),t.uint32(50).fork();for(const n of e.normals)t.float(n);t.ldelim(),t.uint32(58).fork();for(const n of e.indices)t.float(n);t.ldelim(),t.uint32(66).fork();for(const n of e.uv)t.float(n);return t.ldelim(),t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRod();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.name=n.string();continue;case 2:if(o!==18)break;r.origin=Vertex.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.type=n.string();continue;case 4:if(o!==34)break;r.sliceList.push(Rod_Slice.decode(n,n.uint32()));continue;case 5:if(o===45){r.vertices.push(n.float());continue}if(o===42){const i=n.uint32()+n.pos;for(;n.pos<i;)r.vertices.push(n.float());continue}break;case 6:if(o===53){r.normals.push(n.float());continue}if(o===50){const i=n.uint32()+n.pos;for(;n.pos<i;)r.normals.push(n.float());continue}break;case 7:if(o===61){r.indices.push(n.float());continue}if(o===58){const i=n.uint32()+n.pos;for(;n.pos<i;)r.indices.push(n.float());continue}break;case 8:if(o===69){r.uv.push(n.float());continue}if(o===66){const i=n.uint32()+n.pos;for(;n.pos<i;)r.uv.push(n.float());continue}break}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:isSet(e.name)?globalThis.String(e.name):"",origin:isSet(e.origin)?Vertex.fromJSON(e.origin):void 0,type:isSet(e.type)?globalThis.String(e.type):"",sliceList:globalThis.Array.isArray(e==null?void 0:e.sliceList)?e.sliceList.map(t=>Rod_Slice.fromJSON(t)):[],vertices:globalThis.Array.isArray(e==null?void 0:e.vertices)?e.vertices.map(t=>globalThis.Number(t)):[],normals:globalThis.Array.isArray(e==null?void 0:e.normals)?e.normals.map(t=>globalThis.Number(t)):[],indices:globalThis.Array.isArray(e==null?void 0:e.indices)?e.indices.map(t=>globalThis.Number(t)):[],uv:globalThis.Array.isArray(e==null?void 0:e.uv)?e.uv.map(t=>globalThis.Number(t)):[]}},toJSON(e){var n,a,r,o,i;const t={};return e.name!==""&&(t.name=e.name),e.origin!==void 0&&(t.origin=Vertex.toJSON(e.origin)),e.type!==""&&(t.type=e.type),(n=e.sliceList)!=null&&n.length&&(t.sliceList=e.sliceList.map(s=>Rod_Slice.toJSON(s))),(a=e.vertices)!=null&&a.length&&(t.vertices=e.vertices),(r=e.normals)!=null&&r.length&&(t.normals=e.normals),(o=e.indices)!=null&&o.length&&(t.indices=e.indices),(i=e.uv)!=null&&i.length&&(t.uv=e.uv),t},create(e){return Rod.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,s,l;const t=createBaseRod();return t.name=(n=e.name)!=null?n:"",t.origin=e.origin!==void 0&&e.origin!==null?Vertex.fromPartial(e.origin):void 0,t.type=(a=e.type)!=null?a:"",t.sliceList=((r=e.sliceList)==null?void 0:r.map(c=>Rod_Slice.fromPartial(c)))||[],t.vertices=((o=e.vertices)==null?void 0:o.map(c=>c))||[],t.normals=((i=e.normals)==null?void 0:i.map(c=>c))||[],t.indices=((s=e.indices)==null?void 0:s.map(c=>c))||[],t.uv=((l=e.uv)==null?void 0:l.map(c=>c))||[],t}};function createBaseRod_Slice(){return{position:void 0,start:void 0,end:void 0,color:void 0,angle:0,radius:0,bottomRadius:0,texture:"",v:[]}}const Rod_Slice={encode(e,t=minimal.Writer.create()){e.position!==void 0&&Vertex.encode(e.position,t.uint32(10).fork()).ldelim(),e.start!==void 0&&Vertex.encode(e.start,t.uint32(18).fork()).ldelim(),e.end!==void 0&&Vertex.encode(e.end,t.uint32(26).fork()).ldelim(),e.color!==void 0&&Color.encode(e.color,t.uint32(34).fork()).ldelim(),e.angle!==0&&t.uint32(45).float(e.angle),e.radius!==0&&t.uint32(53).float(e.radius),e.bottomRadius!==0&&t.uint32(61).float(e.bottomRadius),e.texture!==""&&t.uint32(66).string(e.texture);for(const n of e.v)t.uint32(74).string(n);return t},decode(e,t){const n=e instanceof minimal.Reader?e:minimal.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=createBaseRod_Slice();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.position=Vertex.decode(n,n.uint32());continue;case 2:if(o!==18)break;r.start=Vertex.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.end=Vertex.decode(n,n.uint32());continue;case 4:if(o!==34)break;r.color=Color.decode(n,n.uint32());continue;case 5:if(o!==45)break;r.angle=n.float();continue;case 6:if(o!==53)break;r.radius=n.float();continue;case 7:if(o!==61)break;r.bottomRadius=n.float();continue;case 8:if(o!==66)break;r.texture=n.string();continue;case 9:if(o!==74)break;r.v.push(n.string());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{position:isSet(e.position)?Vertex.fromJSON(e.position):void 0,start:isSet(e.start)?Vertex.fromJSON(e.start):void 0,end:isSet(e.end)?Vertex.fromJSON(e.end):void 0,color:isSet(e.color)?Color.fromJSON(e.color):void 0,angle:isSet(e.angle)?globalThis.Number(e.angle):0,radius:isSet(e.radius)?globalThis.Number(e.radius):0,bottomRadius:isSet(e.bottomRadius)?globalThis.Number(e.bottomRadius):0,texture:isSet(e.texture)?globalThis.String(e.texture):"",v:globalThis.Array.isArray(e==null?void 0:e.v)?e.v.map(t=>globalThis.String(t)):[]}},toJSON(e){var n;const t={};return e.position!==void 0&&(t.position=Vertex.toJSON(e.position)),e.start!==void 0&&(t.start=Vertex.toJSON(e.start)),e.end!==void 0&&(t.end=Vertex.toJSON(e.end)),e.color!==void 0&&(t.color=Color.toJSON(e.color)),e.angle!==0&&(t.angle=e.angle),e.radius!==0&&(t.radius=e.radius),e.bottomRadius!==0&&(t.bottomRadius=e.bottomRadius),e.texture!==""&&(t.texture=e.texture),(n=e.v)!=null&&n.length&&(t.v=e.v),t},create(e){return Rod_Slice.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=createBaseRod_Slice();return t.position=e.position!==void 0&&e.position!==null?Vertex.fromPartial(e.position):void 0,t.start=e.start!==void 0&&e.start!==null?Vertex.fromPartial(e.start):void 0,t.end=e.end!==void 0&&e.end!==null?Vertex.fromPartial(e.end):void 0,t.color=e.color!==void 0&&e.color!==null?Color.fromPartial(e.color):void 0,t.angle=(n=e.angle)!=null?n:0,t.radius=(a=e.radius)!=null?a:0,t.bottomRadius=(r=e.bottomRadius)!=null?r:0,t.texture=(o=e.texture)!=null?o:"",t.v=((i=e.v)==null?void 0:i.map(s=>s))||[],t}};function isSet(e){return e!=null}const TubeLayer=e=>{const t=reactBabylonjs.useScene(),[n,a]=React.useState([]),[r,o]=React.useState([]),[i,s]=React.useState(EngineCore.Vector3.Zero()),l=React.useContext(WorkspaceMetaContext),c=React.useRef(null),f=React.useRef(!1),[u,d]=React.useState([]),{url:h,name:m="rod",visible:R=!0,color:v}=e,g=React.useCallback(x=>{var _,A,N;const y=x.sliceList.filter(S=>!(S.v.length>0)).map(S=>{const I=S.start?S.start:{x:0,y:0,z:0};return new EngineCore.Vector3(I.x,I.y,I.z)}),E=x.sliceList[x.sliceList.length-1];if(y.length>0&&y.push(new EngineCore.Vector3((_=E.end)==null?void 0:_.x,(A=E.end)==null?void 0:A.y,(N=E.end)==null?void 0:N.z)),y.length<1)return;const k=EngineCore.MeshBuilder.CreateTube("tube-tmp",{path:y,radiusFunction:S=>{if(e.radius)return e.radius;const I=x.sliceList[S]?x.sliceList[S].radius:x.sliceList[S-1].radius;return I||1},cap:EngineCore.Mesh.CAP_ALL,tessellation:24,sideOrientation:EngineCore.Mesh.FRONTSIDE},t),b=k.getVerticesData(EngineCore.VertexBuffer.PositionKind),C=k.getIndices();a(b?b.slice():[]),o(C?C.slice():[]),t==null||t.removeMesh(k)},[e.radius,t]);return React.useEffect(()=>{f.current||(f.current=!0,axios.get(h,{responseType:"arraybuffer"}).then(x=>{var E,k,b;const y=Rod.decode(new Uint8Array(x.data));y.sliceList.length!==0&&(d(y.sliceList),s(new EngineCore.Vector3((E=y.origin)==null?void 0:E.x,(k=y.origin)==null?void 0:k.y,(b=y.origin)==null?void 0:b.z)),console.log(y),g(y))}))},[g,h]),React.useEffect(()=>{if(c&&c.current&&t){const x=new EngineCore.VertexData;x.positions=n,x.indices=r,x.applyToMesh(c.current)}},[r,n,t]),React.useEffect(()=>{var y,E,k;let x;if(u.length>0&&t){x=EngineCore.MeshBuilder.CreateSphere("top",{diameter:u[0].bottomRadius*2,segments:32},t);const b=new EngineCore.StandardMaterial("myMaterial",t);x.material=b,x.setEnabled(!1),b.diffuseColor=new EngineCore.Color3(v.r,v.g,v.b);for(let C=0;C<u.length;C++){const _=u[C],A=x.createInstance("tubeinstance-sphere-"+C);A.setEnabled(R);const N=i.multiply(calcTransformNodeScale(l));A.position=N.add(new EngineCore.Vector3((y=_.position)==null?void 0:y.x,(E=_.position)==null?void 0:E.y,(k=_.position)==null?void 0:k.z).multiply(calcTransformNodeScale(l)))}}return()=>{x&&x.dispose()}},[v.b,v.g,v.r,l,i,t,u,R]),jsxRuntime.jsx("transformNode",{name:`${m}-rod-node`,position:i.multiply(calcTransformNodeScale(l)),setEnabled:R,scaling:new EngineCore.Vector3(l?l.scalePlane:1,l?l.scaleDepth:1,l?l.scalePlane:1),children:jsxRuntime.jsx("mesh",{name:`${m}-mesh`,ref:c,isPickable:!1,children:jsxRuntime.jsx("standardMaterial",{name:`${m}-material`,diffuseColor:new EngineCore.Color3(v.r,v.g,v.b)})})})},TubeLayer$1=TubeLayer;class Scene{constructor(t){le(this,"children",[]);le(this,"params",{});le(this,"ref",React.createRef());this.params=t}add(t){this.children.push(t.render()),window._export=this.children}getSceneObject(){return this.ref}create(){const t=document.getElementById("root"),n=client.createRoot(t);console.log("create root!");const a=React.createElement(Geo3DViewer$1,{ref:this.ref,...this.params},this.children);n.render(a)}}const Scene$1=Scene,UpdateComponent=(e,t)=>{const[n,a]=React.useState();return React.useEffect(()=>{a(e.props)},[e]),React.useImperativeHandle(t,()=>({update:r=>{a(r)}}),[]),n?jsxRuntime.jsx(e.type,{...n}):null},UpdateComponent$1=React.forwardRef(UpdateComponent);class ObjectComponent{constructor(t,n){le(this,"value");le(this,"type");le(this,"ref",React.createRef());this.value=t,this.type=n}setProps(t){this.value=structuredClone(t),this.ref&&this.ref.current&&this.ref.current.update(this.value)}render(){var t;return React.createElement(UpdateComponent$1,{ref:this.ref,key:(t=this.value.id)!=null?t:0,props:this.value,type:this.type})}}function createComponentInstance(e,t){return new ObjectComponent(e,t)}exports.PureComponents=TubeUtil.PureComponents;exports.AttributeBody=AttributeBody$1;exports.AxesViewerPosition=AxesViewerPosition;exports.CachePreload=CachePreload$1;exports.CacheType=CacheType;exports.ColorCodec=ColorCodec$1;exports.ComplexFormationManager=ComplexFormationManager$1;exports.Coordinate=Coordinate$1;exports.CustomShader=CustomShader$1;exports.DarkMetalMaterial=DarkMetalMaterial;exports.DataBinding=DataBinding$1;exports.DensitySlice=DensitySlice$1;exports.FPS=FPS$1;exports.FlatMaterial=FlatMaterial;exports.FormationFace=FormationFace$1;exports.FormationManager=FormationManager$1;exports.FormationSlice=FormationSlice$1;exports.FormationVolume=FormationVolume$1;exports.GUIText=GUIText$1;exports.Geo3DCamera=Geo3DCamera$1;exports.Geo3DUniversalCamera=Geo3DUniversalCamera$1;exports.Geo3DViewer=Geo3DViewer$1;exports.GridDiagram=GridDiagram$1;exports.Ground=Animation$1;exports.HoverType=HoverType;exports.IntersectingLine=IntersectingLine$1;exports.LightMetalMaterial=LightMetalMaterial;exports.Line=Line$1;exports.LoadingScreen=LoadingScreen;exports.LookAt=LookAt$1;exports.MaterialType=MaterialType;exports.ModelLoader=ModelLoader$1;exports.Optimizer=Optimizer$1;exports.PlaneImage=PlaneImage$1;exports.PointClickZone=PointClickZone$1;exports.PointClickZoneObjectType=PointClickZoneObjectType;exports.ProgressedAttributeBody=ProgressedAttributeBody$1;exports.ProgressedRemapColorByRedChannelMaterial=ProgressedRemapColorByRedChannelMaterial;exports.ProgressedRepeatedTextureMaterial=ProgressedRepeatedTextureMaterial;exports.RayClick=RayClick$1;exports.RemapColorByRedChannelMaterial=RemapColorByRedChannelMaterial;exports.RepeatedTextureMaterial=RepeatedTextureMaterial;exports.RibbonLayer=RibbonLayer$1;exports.RoadWay=RoadWay$1;exports.Roam=Roam$1;exports.Rod=TubeLayer$1;exports.ScaleMode=ScaleMode;exports.Scene=Scene$1;exports.SkyBox=SkyBox$1;exports.SpaceHeat=SpaceHeat$1;exports.SpaceHeatObjectType=SpaceHeatObjectType;exports.StructureLayer=StructureLayer$1;exports.TileMap=TileMap$1;exports.TileMapMode=TileMapMode;exports.Tube=Tube$1;exports.TubeChart=TubeChart$1;exports.TubeChartLine=TubeChartLine$1;exports.TubeInstance=TubeInstance$1;exports.TubeLayer=TubeLayer$3;exports.TubeMain=TubeMain$1;exports.TubeOil=TubeOil$1;exports.TubeTool=TubeTool$1;exports.Utils=Common;exports.VoxelGrid=VoxelGrid$1;exports.calcCompass=calcCompass;exports.calcGUIScale=calcGUIScale;exports.calcInvTransformNodeScale=calcInvTransformNodeScale;exports.calcTransformNodeScale=calcTransformNodeScale;exports.createComponentInstance=createComponentInstance;
|