@pan-ya/libgeo3dviewer 1.7.40 → 1.7.41

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.
@@ -1,4 +1,4 @@
1
- "use strict";var ns=Object.defineProperty;var os=(e,t,n)=>t in e?ns(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ve=(e,t,n)=>os(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("react/jsx-runtime"),u=require("@babylonjs/core"),Pi=require("@babylonjs/core/Collisions/gpuPicker"),m=require("react"),_e=require("react-babylonjs"),Ut=require("axios"),jn=require("@babylonjs/inspector");require("@babylonjs/core/Engines/Extensions/engine.query");require("@babylonjs/core/Legacy/legacy");const rs=require("@babylonjs/loaders/dynamic"),nt=require("@babylonjs/gui"),is=require("@babylonjs/materials");require("@babylonjs/materials/legacy/legacy-grid");const as=require("react-dom/client"),Ot=require("./TubeUtil-LB9dC5yJ.cjs");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 ss=require("react-dom");var Rt=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Si(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Po(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 Ti={exports:{}},eo={},Qo;function Ht(){return Qo||(Qo=1,function(e){var t=typeof Uint8Array!="undefined"&&typeof Uint16Array!="undefined"&&typeof Int32Array!="undefined";function n(o,r){return Object.prototype.hasOwnProperty.call(o,r)}e.assign=function(o){for(var r=Array.prototype.slice.call(arguments,1);r.length;){var l=r.shift();if(l){if(typeof l!="object")throw new TypeError(l+"must be non-object");for(var s in l)n(l,s)&&(o[s]=l[s])}}return o},e.shrinkBuf=function(o,r){return o.length===r?o:o.subarray?o.subarray(0,r):(o.length=r,o)};var a={arraySet:function(o,r,l,s,c){if(r.subarray&&o.subarray){o.set(r.subarray(l,l+s),c);return}for(var p=0;p<s;p++)o[c+p]=r[l+p]},flattenChunks:function(o){var r,l,s,c,p,f;for(s=0,r=0,l=o.length;r<l;r++)s+=o[r].length;for(f=new Uint8Array(s),c=0,r=0,l=o.length;r<l;r++)p=o[r],f.set(p,c),c+=p.length;return f}},i={arraySet:function(o,r,l,s,c){for(var p=0;p<s;p++)o[c+p]=r[l+p]},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,i))},e.setTyped(t)}(eo)),eo}var jt={},ht={},Zt={},jo;function ls(){if(jo)return Zt;jo=1;var e=Ht(),t=4,n=0,a=1,i=2;function o(z){for(var fe=z.length;--fe>=0;)z[fe]=0}var r=0,l=1,s=2,c=3,p=258,f=29,d=256,x=d+1+f,h=30,T=19,P=2*x+1,v=15,_=16,b=7,k=256,M=16,w=17,S=18,N=[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],F=[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],B=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],I=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],D=512,E=new Array((x+2)*2);o(E);var L=new Array(h*2);o(L);var y=new Array(D);o(y);var A=new Array(p-c+1);o(A);var V=new Array(f);o(V);var $=new Array(h);o($);function W(z,fe,he,xe,Z){this.static_tree=z,this.extra_bits=fe,this.extra_base=he,this.elems=xe,this.max_length=Z,this.has_stree=z&&z.length}var ne,ee,G;function le(z,fe){this.dyn_tree=z,this.max_code=0,this.stat_desc=fe}function re(z){return z<256?y[z]:y[256+(z>>>7)]}function oe(z,fe){z.pending_buf[z.pending++]=fe&255,z.pending_buf[z.pending++]=fe>>>8&255}function Y(z,fe,he){z.bi_valid>_-he?(z.bi_buf|=fe<<z.bi_valid&65535,oe(z,z.bi_buf),z.bi_buf=fe>>_-z.bi_valid,z.bi_valid+=he-_):(z.bi_buf|=fe<<z.bi_valid&65535,z.bi_valid+=he)}function ce(z,fe,he){Y(z,he[fe*2],he[fe*2+1])}function ae(z,fe){var he=0;do he|=z&1,z>>>=1,he<<=1;while(--fe>0);return he>>>1}function X(z){z.bi_valid===16?(oe(z,z.bi_buf),z.bi_buf=0,z.bi_valid=0):z.bi_valid>=8&&(z.pending_buf[z.pending++]=z.bi_buf&255,z.bi_buf>>=8,z.bi_valid-=8)}function Pe(z,fe){var he=fe.dyn_tree,xe=fe.max_code,Z=fe.stat_desc.static_tree,ie=fe.stat_desc.has_stree,O=fe.stat_desc.extra_bits,de=fe.stat_desc.extra_base,Se=fe.stat_desc.max_length,g,q,j,R,U,J,Te=0;for(R=0;R<=v;R++)z.bl_count[R]=0;for(he[z.heap[z.heap_max]*2+1]=0,g=z.heap_max+1;g<P;g++)q=z.heap[g],R=he[he[q*2+1]*2+1]+1,R>Se&&(R=Se,Te++),he[q*2+1]=R,!(q>xe)&&(z.bl_count[R]++,U=0,q>=de&&(U=O[q-de]),J=he[q*2],z.opt_len+=J*(R+U),ie&&(z.static_len+=J*(Z[q*2+1]+U)));if(Te!==0){do{for(R=Se-1;z.bl_count[R]===0;)R--;z.bl_count[R]--,z.bl_count[R+1]+=2,z.bl_count[Se]--,Te-=2}while(Te>0);for(R=Se;R!==0;R--)for(q=z.bl_count[R];q!==0;)j=z.heap[--g],!(j>xe)&&(he[j*2+1]!==R&&(z.opt_len+=(R-he[j*2+1])*he[j*2],he[j*2+1]=R),q--)}}function ge(z,fe,he){var xe=new Array(v+1),Z=0,ie,O;for(ie=1;ie<=v;ie++)xe[ie]=Z=Z+he[ie-1]<<1;for(O=0;O<=fe;O++){var de=z[O*2+1];de!==0&&(z[O*2]=ae(xe[de]++,de))}}function H(){var z,fe,he,xe,Z,ie=new Array(v+1);for(he=0,xe=0;xe<f-1;xe++)for(V[xe]=he,z=0;z<1<<N[xe];z++)A[he++]=xe;for(A[he-1]=xe,Z=0,xe=0;xe<16;xe++)for($[xe]=Z,z=0;z<1<<F[xe];z++)y[Z++]=xe;for(Z>>=7;xe<h;xe++)for($[xe]=Z<<7,z=0;z<1<<F[xe]-7;z++)y[256+Z++]=xe;for(fe=0;fe<=v;fe++)ie[fe]=0;for(z=0;z<=143;)E[z*2+1]=8,z++,ie[8]++;for(;z<=255;)E[z*2+1]=9,z++,ie[9]++;for(;z<=279;)E[z*2+1]=7,z++,ie[7]++;for(;z<=287;)E[z*2+1]=8,z++,ie[8]++;for(ge(E,x+1,ie),z=0;z<h;z++)L[z*2+1]=5,L[z*2]=ae(z,5);ne=new W(E,N,d+1,x,v),ee=new W(L,F,0,h,v),G=new W(new Array(0),B,0,T,b)}function Q(z){var fe;for(fe=0;fe<x;fe++)z.dyn_ltree[fe*2]=0;for(fe=0;fe<h;fe++)z.dyn_dtree[fe*2]=0;for(fe=0;fe<T;fe++)z.bl_tree[fe*2]=0;z.dyn_ltree[k*2]=1,z.opt_len=z.static_len=0,z.last_lit=z.matches=0}function Ee(z){z.bi_valid>8?oe(z,z.bi_buf):z.bi_valid>0&&(z.pending_buf[z.pending++]=z.bi_buf),z.bi_buf=0,z.bi_valid=0}function ke(z,fe,he,xe){Ee(z),oe(z,he),oe(z,~he),e.arraySet(z.pending_buf,z.window,fe,he,z.pending),z.pending+=he}function te(z,fe,he,xe){var Z=fe*2,ie=he*2;return z[Z]<z[ie]||z[Z]===z[ie]&&xe[fe]<=xe[he]}function me(z,fe,he){for(var xe=z.heap[he],Z=he<<1;Z<=z.heap_len&&(Z<z.heap_len&&te(fe,z.heap[Z+1],z.heap[Z],z.depth)&&Z++,!te(fe,xe,z.heap[Z],z.depth));)z.heap[he]=z.heap[Z],he=Z,Z<<=1;z.heap[he]=xe}function ue(z,fe,he){var xe,Z,ie=0,O,de;if(z.last_lit!==0)do xe=z.pending_buf[z.d_buf+ie*2]<<8|z.pending_buf[z.d_buf+ie*2+1],Z=z.pending_buf[z.l_buf+ie],ie++,xe===0?ce(z,Z,fe):(O=A[Z],ce(z,O+d+1,fe),de=N[O],de!==0&&(Z-=V[O],Y(z,Z,de)),xe--,O=re(xe),ce(z,O,he),de=F[O],de!==0&&(xe-=$[O],Y(z,xe,de)));while(ie<z.last_lit);ce(z,k,fe)}function pe(z,fe){var he=fe.dyn_tree,xe=fe.stat_desc.static_tree,Z=fe.stat_desc.has_stree,ie=fe.stat_desc.elems,O,de,Se=-1,g;for(z.heap_len=0,z.heap_max=P,O=0;O<ie;O++)he[O*2]!==0?(z.heap[++z.heap_len]=Se=O,z.depth[O]=0):he[O*2+1]=0;for(;z.heap_len<2;)g=z.heap[++z.heap_len]=Se<2?++Se:0,he[g*2]=1,z.depth[g]=0,z.opt_len--,Z&&(z.static_len-=xe[g*2+1]);for(fe.max_code=Se,O=z.heap_len>>1;O>=1;O--)me(z,he,O);g=ie;do O=z.heap[1],z.heap[1]=z.heap[z.heap_len--],me(z,he,1),de=z.heap[1],z.heap[--z.heap_max]=O,z.heap[--z.heap_max]=de,he[g*2]=he[O*2]+he[de*2],z.depth[g]=(z.depth[O]>=z.depth[de]?z.depth[O]:z.depth[de])+1,he[O*2+1]=he[de*2+1]=g,z.heap[1]=g++,me(z,he,1);while(z.heap_len>=2);z.heap[--z.heap_max]=z.heap[1],Pe(z,fe),ge(he,Se,z.bl_count)}function Ne(z,fe,he){var xe,Z=-1,ie,O=fe[0*2+1],de=0,Se=7,g=4;for(O===0&&(Se=138,g=3),fe[(he+1)*2+1]=65535,xe=0;xe<=he;xe++)ie=O,O=fe[(xe+1)*2+1],!(++de<Se&&ie===O)&&(de<g?z.bl_tree[ie*2]+=de:ie!==0?(ie!==Z&&z.bl_tree[ie*2]++,z.bl_tree[M*2]++):de<=10?z.bl_tree[w*2]++:z.bl_tree[S*2]++,de=0,Z=ie,O===0?(Se=138,g=3):ie===O?(Se=6,g=3):(Se=7,g=4))}function be(z,fe,he){var xe,Z=-1,ie,O=fe[0*2+1],de=0,Se=7,g=4;for(O===0&&(Se=138,g=3),xe=0;xe<=he;xe++)if(ie=O,O=fe[(xe+1)*2+1],!(++de<Se&&ie===O)){if(de<g)do ce(z,ie,z.bl_tree);while(--de!==0);else ie!==0?(ie!==Z&&(ce(z,ie,z.bl_tree),de--),ce(z,M,z.bl_tree),Y(z,de-3,2)):de<=10?(ce(z,w,z.bl_tree),Y(z,de-3,3)):(ce(z,S,z.bl_tree),Y(z,de-11,7));de=0,Z=ie,O===0?(Se=138,g=3):ie===O?(Se=6,g=3):(Se=7,g=4)}}function Ae(z){var fe;for(Ne(z,z.dyn_ltree,z.l_desc.max_code),Ne(z,z.dyn_dtree,z.d_desc.max_code),pe(z,z.bl_desc),fe=T-1;fe>=3&&z.bl_tree[I[fe]*2+1]===0;fe--);return z.opt_len+=3*(fe+1)+5+5+4,fe}function Ie(z,fe,he,xe){var Z;for(Y(z,fe-257,5),Y(z,he-1,5),Y(z,xe-4,4),Z=0;Z<xe;Z++)Y(z,z.bl_tree[I[Z]*2+1],3);be(z,z.dyn_ltree,fe-1),be(z,z.dyn_dtree,he-1)}function we(z){var fe=4093624447,he;for(he=0;he<=31;he++,fe>>>=1)if(fe&1&&z.dyn_ltree[he*2]!==0)return n;if(z.dyn_ltree[9*2]!==0||z.dyn_ltree[10*2]!==0||z.dyn_ltree[13*2]!==0)return a;for(he=32;he<d;he++)if(z.dyn_ltree[he*2]!==0)return a;return n}var Re=!1;function Ve(z){Re||(H(),Re=!0),z.l_desc=new le(z.dyn_ltree,ne),z.d_desc=new le(z.dyn_dtree,ee),z.bl_desc=new le(z.bl_tree,G),z.bi_buf=0,z.bi_valid=0,Q(z)}function Ue(z,fe,he,xe){Y(z,(r<<1)+(xe?1:0),3),ke(z,fe,he)}function Be(z){Y(z,l<<1,3),ce(z,k,E),X(z)}function Ge(z,fe,he,xe){var Z,ie,O=0;z.level>0?(z.strm.data_type===i&&(z.strm.data_type=we(z)),pe(z,z.l_desc),pe(z,z.d_desc),O=Ae(z),Z=z.opt_len+3+7>>>3,ie=z.static_len+3+7>>>3,ie<=Z&&(Z=ie)):Z=ie=he+5,he+4<=Z&&fe!==-1?Ue(z,fe,he,xe):z.strategy===t||ie===Z?(Y(z,(l<<1)+(xe?1:0),3),ue(z,E,L)):(Y(z,(s<<1)+(xe?1:0),3),Ie(z,z.l_desc.max_code+1,z.d_desc.max_code+1,O+1),ue(z,z.dyn_ltree,z.dyn_dtree)),Q(z),xe&&Ee(z)}function Ke(z,fe,he){return z.pending_buf[z.d_buf+z.last_lit*2]=fe>>>8&255,z.pending_buf[z.d_buf+z.last_lit*2+1]=fe&255,z.pending_buf[z.l_buf+z.last_lit]=he&255,z.last_lit++,fe===0?z.dyn_ltree[he*2]++:(z.matches++,fe--,z.dyn_ltree[(A[he]+d+1)*2]++,z.dyn_dtree[re(fe)*2]++),z.last_lit===z.lit_bufsize-1}return Zt._tr_init=Ve,Zt._tr_stored_block=Ue,Zt._tr_flush_block=Ge,Zt._tr_tally=Ke,Zt._tr_align=Be,Zt}var to,er;function bi(){if(er)return to;er=1;function e(t,n,a,i){for(var o=t&65535|0,r=t>>>16&65535|0,l=0;a!==0;){l=a>2e3?2e3:a,a-=l;do o=o+n[i++]|0,r=r+o|0;while(--l);o%=65521,r%=65521}return o|r<<16|0}return to=e,to}var no,tr;function ki(){if(tr)return no;tr=1;function e(){for(var a,i=[],o=0;o<256;o++){a=o;for(var r=0;r<8;r++)a=a&1?3988292384^a>>>1:a>>>1;i[o]=a}return i}var t=e();function n(a,i,o,r){var l=t,s=r+o;a^=-1;for(var c=r;c<s;c++)a=a>>>8^l[(a^i[c])&255];return a^-1}return no=n,no}var oo,nr;function wo(){return nr||(nr=1,oo={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"}),oo}var or;function cs(){if(or)return ht;or=1;var e=Ht(),t=ls(),n=bi(),a=ki(),i=wo(),o=0,r=1,l=3,s=4,c=5,p=0,f=1,d=-2,x=-3,h=-5,T=-1,P=1,v=2,_=3,b=4,k=0,M=2,w=8,S=9,N=15,F=8,B=29,I=256,D=I+1+B,E=30,L=19,y=2*D+1,A=15,V=3,$=258,W=$+V+1,ne=32,ee=42,G=69,le=73,re=91,oe=103,Y=113,ce=666,ae=1,X=2,Pe=3,ge=4,H=3;function Q(g,q){return g.msg=i[q],q}function Ee(g){return(g<<1)-(g>4?9:0)}function ke(g){for(var q=g.length;--q>=0;)g[q]=0}function te(g){var q=g.state,j=q.pending;j>g.avail_out&&(j=g.avail_out),j!==0&&(e.arraySet(g.output,q.pending_buf,q.pending_out,j,g.next_out),g.next_out+=j,q.pending_out+=j,g.total_out+=j,g.avail_out-=j,q.pending-=j,q.pending===0&&(q.pending_out=0))}function me(g,q){t._tr_flush_block(g,g.block_start>=0?g.block_start:-1,g.strstart-g.block_start,q),g.block_start=g.strstart,te(g.strm)}function ue(g,q){g.pending_buf[g.pending++]=q}function pe(g,q){g.pending_buf[g.pending++]=q>>>8&255,g.pending_buf[g.pending++]=q&255}function Ne(g,q,j,R){var U=g.avail_in;return U>R&&(U=R),U===0?0:(g.avail_in-=U,e.arraySet(q,g.input,g.next_in,U,j),g.state.wrap===1?g.adler=n(g.adler,q,U,j):g.state.wrap===2&&(g.adler=a(g.adler,q,U,j)),g.next_in+=U,g.total_in+=U,U)}function be(g,q){var j=g.max_chain_length,R=g.strstart,U,J,Te=g.prev_length,ye=g.nice_match,Ce=g.strstart>g.w_size-W?g.strstart-(g.w_size-W):0,Fe=g.window,Tt=g.w_mask,Ye=g.prev,De=g.strstart+$,qe=Fe[R+Te-1],et=Fe[R+Te];g.prev_length>=g.good_match&&(j>>=2),ye>g.lookahead&&(ye=g.lookahead);do if(U=q,!(Fe[U+Te]!==et||Fe[U+Te-1]!==qe||Fe[U]!==Fe[R]||Fe[++U]!==Fe[R+1])){R+=2,U++;do;while(Fe[++R]===Fe[++U]&&Fe[++R]===Fe[++U]&&Fe[++R]===Fe[++U]&&Fe[++R]===Fe[++U]&&Fe[++R]===Fe[++U]&&Fe[++R]===Fe[++U]&&Fe[++R]===Fe[++U]&&Fe[++R]===Fe[++U]&&R<De);if(J=$-(De-R),R=De-$,J>Te){if(g.match_start=q,Te=J,J>=ye)break;qe=Fe[R+Te-1],et=Fe[R+Te]}}while((q=Ye[q&Tt])>Ce&&--j!==0);return Te<=g.lookahead?Te:g.lookahead}function Ae(g){var q=g.w_size,j,R,U,J,Te;do{if(J=g.window_size-g.lookahead-g.strstart,g.strstart>=q+(q-W)){e.arraySet(g.window,g.window,q,q,0),g.match_start-=q,g.strstart-=q,g.block_start-=q,R=g.hash_size,j=R;do U=g.head[--j],g.head[j]=U>=q?U-q:0;while(--R);R=q,j=R;do U=g.prev[--j],g.prev[j]=U>=q?U-q:0;while(--R);J+=q}if(g.strm.avail_in===0)break;if(R=Ne(g.strm,g.window,g.strstart+g.lookahead,J),g.lookahead+=R,g.lookahead+g.insert>=V)for(Te=g.strstart-g.insert,g.ins_h=g.window[Te],g.ins_h=(g.ins_h<<g.hash_shift^g.window[Te+1])&g.hash_mask;g.insert&&(g.ins_h=(g.ins_h<<g.hash_shift^g.window[Te+V-1])&g.hash_mask,g.prev[Te&g.w_mask]=g.head[g.ins_h],g.head[g.ins_h]=Te,Te++,g.insert--,!(g.lookahead+g.insert<V)););}while(g.lookahead<W&&g.strm.avail_in!==0)}function Ie(g,q){var j=65535;for(j>g.pending_buf_size-5&&(j=g.pending_buf_size-5);;){if(g.lookahead<=1){if(Ae(g),g.lookahead===0&&q===o)return ae;if(g.lookahead===0)break}g.strstart+=g.lookahead,g.lookahead=0;var R=g.block_start+j;if((g.strstart===0||g.strstart>=R)&&(g.lookahead=g.strstart-R,g.strstart=R,me(g,!1),g.strm.avail_out===0)||g.strstart-g.block_start>=g.w_size-W&&(me(g,!1),g.strm.avail_out===0))return ae}return g.insert=0,q===s?(me(g,!0),g.strm.avail_out===0?Pe:ge):(g.strstart>g.block_start&&(me(g,!1),g.strm.avail_out===0),ae)}function we(g,q){for(var j,R;;){if(g.lookahead<W){if(Ae(g),g.lookahead<W&&q===o)return ae;if(g.lookahead===0)break}if(j=0,g.lookahead>=V&&(g.ins_h=(g.ins_h<<g.hash_shift^g.window[g.strstart+V-1])&g.hash_mask,j=g.prev[g.strstart&g.w_mask]=g.head[g.ins_h],g.head[g.ins_h]=g.strstart),j!==0&&g.strstart-j<=g.w_size-W&&(g.match_length=be(g,j)),g.match_length>=V)if(R=t._tr_tally(g,g.strstart-g.match_start,g.match_length-V),g.lookahead-=g.match_length,g.match_length<=g.max_lazy_match&&g.lookahead>=V){g.match_length--;do g.strstart++,g.ins_h=(g.ins_h<<g.hash_shift^g.window[g.strstart+V-1])&g.hash_mask,j=g.prev[g.strstart&g.w_mask]=g.head[g.ins_h],g.head[g.ins_h]=g.strstart;while(--g.match_length!==0);g.strstart++}else g.strstart+=g.match_length,g.match_length=0,g.ins_h=g.window[g.strstart],g.ins_h=(g.ins_h<<g.hash_shift^g.window[g.strstart+1])&g.hash_mask;else R=t._tr_tally(g,0,g.window[g.strstart]),g.lookahead--,g.strstart++;if(R&&(me(g,!1),g.strm.avail_out===0))return ae}return g.insert=g.strstart<V-1?g.strstart:V-1,q===s?(me(g,!0),g.strm.avail_out===0?Pe:ge):g.last_lit&&(me(g,!1),g.strm.avail_out===0)?ae:X}function Re(g,q){for(var j,R,U;;){if(g.lookahead<W){if(Ae(g),g.lookahead<W&&q===o)return ae;if(g.lookahead===0)break}if(j=0,g.lookahead>=V&&(g.ins_h=(g.ins_h<<g.hash_shift^g.window[g.strstart+V-1])&g.hash_mask,j=g.prev[g.strstart&g.w_mask]=g.head[g.ins_h],g.head[g.ins_h]=g.strstart),g.prev_length=g.match_length,g.prev_match=g.match_start,g.match_length=V-1,j!==0&&g.prev_length<g.max_lazy_match&&g.strstart-j<=g.w_size-W&&(g.match_length=be(g,j),g.match_length<=5&&(g.strategy===P||g.match_length===V&&g.strstart-g.match_start>4096)&&(g.match_length=V-1)),g.prev_length>=V&&g.match_length<=g.prev_length){U=g.strstart+g.lookahead-V,R=t._tr_tally(g,g.strstart-1-g.prev_match,g.prev_length-V),g.lookahead-=g.prev_length-1,g.prev_length-=2;do++g.strstart<=U&&(g.ins_h=(g.ins_h<<g.hash_shift^g.window[g.strstart+V-1])&g.hash_mask,j=g.prev[g.strstart&g.w_mask]=g.head[g.ins_h],g.head[g.ins_h]=g.strstart);while(--g.prev_length!==0);if(g.match_available=0,g.match_length=V-1,g.strstart++,R&&(me(g,!1),g.strm.avail_out===0))return ae}else if(g.match_available){if(R=t._tr_tally(g,0,g.window[g.strstart-1]),R&&me(g,!1),g.strstart++,g.lookahead--,g.strm.avail_out===0)return ae}else g.match_available=1,g.strstart++,g.lookahead--}return g.match_available&&(R=t._tr_tally(g,0,g.window[g.strstart-1]),g.match_available=0),g.insert=g.strstart<V-1?g.strstart:V-1,q===s?(me(g,!0),g.strm.avail_out===0?Pe:ge):g.last_lit&&(me(g,!1),g.strm.avail_out===0)?ae:X}function Ve(g,q){for(var j,R,U,J,Te=g.window;;){if(g.lookahead<=$){if(Ae(g),g.lookahead<=$&&q===o)return ae;if(g.lookahead===0)break}if(g.match_length=0,g.lookahead>=V&&g.strstart>0&&(U=g.strstart-1,R=Te[U],R===Te[++U]&&R===Te[++U]&&R===Te[++U])){J=g.strstart+$;do;while(R===Te[++U]&&R===Te[++U]&&R===Te[++U]&&R===Te[++U]&&R===Te[++U]&&R===Te[++U]&&R===Te[++U]&&R===Te[++U]&&U<J);g.match_length=$-(J-U),g.match_length>g.lookahead&&(g.match_length=g.lookahead)}if(g.match_length>=V?(j=t._tr_tally(g,1,g.match_length-V),g.lookahead-=g.match_length,g.strstart+=g.match_length,g.match_length=0):(j=t._tr_tally(g,0,g.window[g.strstart]),g.lookahead--,g.strstart++),j&&(me(g,!1),g.strm.avail_out===0))return ae}return g.insert=0,q===s?(me(g,!0),g.strm.avail_out===0?Pe:ge):g.last_lit&&(me(g,!1),g.strm.avail_out===0)?ae:X}function Ue(g,q){for(var j;;){if(g.lookahead===0&&(Ae(g),g.lookahead===0)){if(q===o)return ae;break}if(g.match_length=0,j=t._tr_tally(g,0,g.window[g.strstart]),g.lookahead--,g.strstart++,j&&(me(g,!1),g.strm.avail_out===0))return ae}return g.insert=0,q===s?(me(g,!0),g.strm.avail_out===0?Pe:ge):g.last_lit&&(me(g,!1),g.strm.avail_out===0)?ae:X}function Be(g,q,j,R,U){this.good_length=g,this.max_lazy=q,this.nice_length=j,this.max_chain=R,this.func=U}var Ge;Ge=[new Be(0,0,0,0,Ie),new Be(4,4,8,4,we),new Be(4,5,16,8,we),new Be(4,6,32,32,we),new Be(4,4,16,16,Re),new Be(8,16,32,32,Re),new Be(8,16,128,128,Re),new Be(8,32,128,256,Re),new Be(32,128,258,1024,Re),new Be(32,258,258,4096,Re)];function Ke(g){g.window_size=2*g.w_size,ke(g.head),g.max_lazy_match=Ge[g.level].max_lazy,g.good_match=Ge[g.level].good_length,g.nice_match=Ge[g.level].nice_length,g.max_chain_length=Ge[g.level].max_chain,g.strstart=0,g.block_start=0,g.lookahead=0,g.insert=0,g.match_length=g.prev_length=V-1,g.match_available=0,g.ins_h=0}function z(){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=w,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(y*2),this.dyn_dtree=new e.Buf16((2*E+1)*2),this.bl_tree=new e.Buf16((2*L+1)*2),ke(this.dyn_ltree),ke(this.dyn_dtree),ke(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new e.Buf16(A+1),this.heap=new e.Buf16(2*D+1),ke(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new e.Buf16(2*D+1),ke(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 fe(g){var q;return!g||!g.state?Q(g,d):(g.total_in=g.total_out=0,g.data_type=M,q=g.state,q.pending=0,q.pending_out=0,q.wrap<0&&(q.wrap=-q.wrap),q.status=q.wrap?ee:Y,g.adler=q.wrap===2?0:1,q.last_flush=o,t._tr_init(q),p)}function he(g){var q=fe(g);return q===p&&Ke(g.state),q}function xe(g,q){return!g||!g.state||g.state.wrap!==2?d:(g.state.gzhead=q,p)}function Z(g,q,j,R,U,J){if(!g)return d;var Te=1;if(q===T&&(q=6),R<0?(Te=0,R=-R):R>15&&(Te=2,R-=16),U<1||U>S||j!==w||R<8||R>15||q<0||q>9||J<0||J>b)return Q(g,d);R===8&&(R=9);var ye=new z;return g.state=ye,ye.strm=g,ye.wrap=Te,ye.gzhead=null,ye.w_bits=R,ye.w_size=1<<ye.w_bits,ye.w_mask=ye.w_size-1,ye.hash_bits=U+7,ye.hash_size=1<<ye.hash_bits,ye.hash_mask=ye.hash_size-1,ye.hash_shift=~~((ye.hash_bits+V-1)/V),ye.window=new e.Buf8(ye.w_size*2),ye.head=new e.Buf16(ye.hash_size),ye.prev=new e.Buf16(ye.w_size),ye.lit_bufsize=1<<U+6,ye.pending_buf_size=ye.lit_bufsize*4,ye.pending_buf=new e.Buf8(ye.pending_buf_size),ye.d_buf=1*ye.lit_bufsize,ye.l_buf=3*ye.lit_bufsize,ye.level=q,ye.strategy=J,ye.method=j,he(g)}function ie(g,q){return Z(g,q,w,N,F,k)}function O(g,q){var j,R,U,J;if(!g||!g.state||q>c||q<0)return g?Q(g,d):d;if(R=g.state,!g.output||!g.input&&g.avail_in!==0||R.status===ce&&q!==s)return Q(g,g.avail_out===0?h:d);if(R.strm=g,j=R.last_flush,R.last_flush=q,R.status===ee)if(R.wrap===2)g.adler=0,ue(R,31),ue(R,139),ue(R,8),R.gzhead?(ue(R,(R.gzhead.text?1:0)+(R.gzhead.hcrc?2:0)+(R.gzhead.extra?4:0)+(R.gzhead.name?8:0)+(R.gzhead.comment?16:0)),ue(R,R.gzhead.time&255),ue(R,R.gzhead.time>>8&255),ue(R,R.gzhead.time>>16&255),ue(R,R.gzhead.time>>24&255),ue(R,R.level===9?2:R.strategy>=v||R.level<2?4:0),ue(R,R.gzhead.os&255),R.gzhead.extra&&R.gzhead.extra.length&&(ue(R,R.gzhead.extra.length&255),ue(R,R.gzhead.extra.length>>8&255)),R.gzhead.hcrc&&(g.adler=a(g.adler,R.pending_buf,R.pending,0)),R.gzindex=0,R.status=G):(ue(R,0),ue(R,0),ue(R,0),ue(R,0),ue(R,0),ue(R,R.level===9?2:R.strategy>=v||R.level<2?4:0),ue(R,H),R.status=Y);else{var Te=w+(R.w_bits-8<<4)<<8,ye=-1;R.strategy>=v||R.level<2?ye=0:R.level<6?ye=1:R.level===6?ye=2:ye=3,Te|=ye<<6,R.strstart!==0&&(Te|=ne),Te+=31-Te%31,R.status=Y,pe(R,Te),R.strstart!==0&&(pe(R,g.adler>>>16),pe(R,g.adler&65535)),g.adler=1}if(R.status===G)if(R.gzhead.extra){for(U=R.pending;R.gzindex<(R.gzhead.extra.length&65535)&&!(R.pending===R.pending_buf_size&&(R.gzhead.hcrc&&R.pending>U&&(g.adler=a(g.adler,R.pending_buf,R.pending-U,U)),te(g),U=R.pending,R.pending===R.pending_buf_size));)ue(R,R.gzhead.extra[R.gzindex]&255),R.gzindex++;R.gzhead.hcrc&&R.pending>U&&(g.adler=a(g.adler,R.pending_buf,R.pending-U,U)),R.gzindex===R.gzhead.extra.length&&(R.gzindex=0,R.status=le)}else R.status=le;if(R.status===le)if(R.gzhead.name){U=R.pending;do{if(R.pending===R.pending_buf_size&&(R.gzhead.hcrc&&R.pending>U&&(g.adler=a(g.adler,R.pending_buf,R.pending-U,U)),te(g),U=R.pending,R.pending===R.pending_buf_size)){J=1;break}R.gzindex<R.gzhead.name.length?J=R.gzhead.name.charCodeAt(R.gzindex++)&255:J=0,ue(R,J)}while(J!==0);R.gzhead.hcrc&&R.pending>U&&(g.adler=a(g.adler,R.pending_buf,R.pending-U,U)),J===0&&(R.gzindex=0,R.status=re)}else R.status=re;if(R.status===re)if(R.gzhead.comment){U=R.pending;do{if(R.pending===R.pending_buf_size&&(R.gzhead.hcrc&&R.pending>U&&(g.adler=a(g.adler,R.pending_buf,R.pending-U,U)),te(g),U=R.pending,R.pending===R.pending_buf_size)){J=1;break}R.gzindex<R.gzhead.comment.length?J=R.gzhead.comment.charCodeAt(R.gzindex++)&255:J=0,ue(R,J)}while(J!==0);R.gzhead.hcrc&&R.pending>U&&(g.adler=a(g.adler,R.pending_buf,R.pending-U,U)),J===0&&(R.status=oe)}else R.status=oe;if(R.status===oe&&(R.gzhead.hcrc?(R.pending+2>R.pending_buf_size&&te(g),R.pending+2<=R.pending_buf_size&&(ue(R,g.adler&255),ue(R,g.adler>>8&255),g.adler=0,R.status=Y)):R.status=Y),R.pending!==0){if(te(g),g.avail_out===0)return R.last_flush=-1,p}else if(g.avail_in===0&&Ee(q)<=Ee(j)&&q!==s)return Q(g,h);if(R.status===ce&&g.avail_in!==0)return Q(g,h);if(g.avail_in!==0||R.lookahead!==0||q!==o&&R.status!==ce){var Ce=R.strategy===v?Ue(R,q):R.strategy===_?Ve(R,q):Ge[R.level].func(R,q);if((Ce===Pe||Ce===ge)&&(R.status=ce),Ce===ae||Ce===Pe)return g.avail_out===0&&(R.last_flush=-1),p;if(Ce===X&&(q===r?t._tr_align(R):q!==c&&(t._tr_stored_block(R,0,0,!1),q===l&&(ke(R.head),R.lookahead===0&&(R.strstart=0,R.block_start=0,R.insert=0))),te(g),g.avail_out===0))return R.last_flush=-1,p}return q!==s?p:R.wrap<=0?f:(R.wrap===2?(ue(R,g.adler&255),ue(R,g.adler>>8&255),ue(R,g.adler>>16&255),ue(R,g.adler>>24&255),ue(R,g.total_in&255),ue(R,g.total_in>>8&255),ue(R,g.total_in>>16&255),ue(R,g.total_in>>24&255)):(pe(R,g.adler>>>16),pe(R,g.adler&65535)),te(g),R.wrap>0&&(R.wrap=-R.wrap),R.pending!==0?p:f)}function de(g){var q;return!g||!g.state?d:(q=g.state.status,q!==ee&&q!==G&&q!==le&&q!==re&&q!==oe&&q!==Y&&q!==ce?Q(g,d):(g.state=null,q===Y?Q(g,x):p))}function Se(g,q){var j=q.length,R,U,J,Te,ye,Ce,Fe,Tt;if(!g||!g.state||(R=g.state,Te=R.wrap,Te===2||Te===1&&R.status!==ee||R.lookahead))return d;for(Te===1&&(g.adler=n(g.adler,q,j,0)),R.wrap=0,j>=R.w_size&&(Te===0&&(ke(R.head),R.strstart=0,R.block_start=0,R.insert=0),Tt=new e.Buf8(R.w_size),e.arraySet(Tt,q,j-R.w_size,R.w_size,0),q=Tt,j=R.w_size),ye=g.avail_in,Ce=g.next_in,Fe=g.input,g.avail_in=j,g.next_in=0,g.input=q,Ae(R);R.lookahead>=V;){U=R.strstart,J=R.lookahead-(V-1);do R.ins_h=(R.ins_h<<R.hash_shift^R.window[U+V-1])&R.hash_mask,R.prev[U&R.w_mask]=R.head[R.ins_h],R.head[R.ins_h]=U,U++;while(--J);R.strstart=U,R.lookahead=V-1,Ae(R)}return R.strstart+=R.lookahead,R.block_start=R.strstart,R.insert=R.lookahead,R.lookahead=0,R.match_length=R.prev_length=V-1,R.match_available=0,g.next_in=Ce,g.input=Fe,g.avail_in=ye,R.wrap=Te,p}return ht.deflateInit=ie,ht.deflateInit2=Z,ht.deflateReset=he,ht.deflateResetKeep=fe,ht.deflateSetHeader=xe,ht.deflate=O,ht.deflateEnd=de,ht.deflateSetDictionary=Se,ht.deflateInfo="pako deflate (from Nodeca project)",ht}var Gt={},rr;function Ei(){if(rr)return Gt;rr=1;var e=Ht(),t=!0,n=!0;try{String.fromCharCode.apply(null,[0])}catch(r){t=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(r){n=!1}for(var a=new e.Buf8(256),i=0;i<256;i++)a[i]=i>=252?6:i>=248?5:i>=240?4:i>=224?3:i>=192?2:1;a[254]=a[254]=1,Gt.string2buf=function(r){var l,s,c,p,f,d=r.length,x=0;for(p=0;p<d;p++)s=r.charCodeAt(p),(s&64512)===55296&&p+1<d&&(c=r.charCodeAt(p+1),(c&64512)===56320&&(s=65536+(s-55296<<10)+(c-56320),p++)),x+=s<128?1:s<2048?2:s<65536?3:4;for(l=new e.Buf8(x),f=0,p=0;f<x;p++)s=r.charCodeAt(p),(s&64512)===55296&&p+1<d&&(c=r.charCodeAt(p+1),(c&64512)===56320&&(s=65536+(s-55296<<10)+(c-56320),p++)),s<128?l[f++]=s:s<2048?(l[f++]=192|s>>>6,l[f++]=128|s&63):s<65536?(l[f++]=224|s>>>12,l[f++]=128|s>>>6&63,l[f++]=128|s&63):(l[f++]=240|s>>>18,l[f++]=128|s>>>12&63,l[f++]=128|s>>>6&63,l[f++]=128|s&63);return l};function o(r,l){if(l<65534&&(r.subarray&&n||!r.subarray&&t))return String.fromCharCode.apply(null,e.shrinkBuf(r,l));for(var s="",c=0;c<l;c++)s+=String.fromCharCode(r[c]);return s}return Gt.buf2binstring=function(r){return o(r,r.length)},Gt.binstring2buf=function(r){for(var l=new e.Buf8(r.length),s=0,c=l.length;s<c;s++)l[s]=r.charCodeAt(s);return l},Gt.buf2string=function(r,l){var s,c,p,f,d=l||r.length,x=new Array(d*2);for(c=0,s=0;s<d;){if(p=r[s++],p<128){x[c++]=p;continue}if(f=a[p],f>4){x[c++]=65533,s+=f-1;continue}for(p&=f===2?31:f===3?15:7;f>1&&s<d;)p=p<<6|r[s++]&63,f--;if(f>1){x[c++]=65533;continue}p<65536?x[c++]=p:(p-=65536,x[c++]=55296|p>>10&1023,x[c++]=56320|p&1023)}return o(x,c)},Gt.utf8border=function(r,l){var s;for(l=l||r.length,l>r.length&&(l=r.length),s=l-1;s>=0&&(r[s]&192)===128;)s--;return s<0||s===0?l:s+a[r[s]]>l?s:l},Gt}var ro,ir;function Ni(){if(ir)return ro;ir=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 ro=e,ro}var ar;function us(){if(ar)return jt;ar=1;var e=cs(),t=Ht(),n=Ei(),a=wo(),i=Ni(),o=Object.prototype.toString,r=0,l=4,s=0,c=1,p=2,f=-1,d=0,x=8;function h(_){if(!(this instanceof h))return new h(_);this.options=t.assign({level:f,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:d,to:""},_||{});var b=this.options;b.raw&&b.windowBits>0?b.windowBits=-b.windowBits:b.gzip&&b.windowBits>0&&b.windowBits<16&&(b.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new i,this.strm.avail_out=0;var k=e.deflateInit2(this.strm,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(k!==s)throw new Error(a[k]);if(b.header&&e.deflateSetHeader(this.strm,b.header),b.dictionary){var M;if(typeof b.dictionary=="string"?M=n.string2buf(b.dictionary):o.call(b.dictionary)==="[object ArrayBuffer]"?M=new Uint8Array(b.dictionary):M=b.dictionary,k=e.deflateSetDictionary(this.strm,M),k!==s)throw new Error(a[k]);this._dict_set=!0}}h.prototype.push=function(_,b){var k=this.strm,M=this.options.chunkSize,w,S;if(this.ended)return!1;S=b===~~b?b:b===!0?l:r,typeof _=="string"?k.input=n.string2buf(_):o.call(_)==="[object ArrayBuffer]"?k.input=new Uint8Array(_):k.input=_,k.next_in=0,k.avail_in=k.input.length;do{if(k.avail_out===0&&(k.output=new t.Buf8(M),k.next_out=0,k.avail_out=M),w=e.deflate(k,S),w!==c&&w!==s)return this.onEnd(w),this.ended=!0,!1;(k.avail_out===0||k.avail_in===0&&(S===l||S===p))&&(this.options.to==="string"?this.onData(n.buf2binstring(t.shrinkBuf(k.output,k.next_out))):this.onData(t.shrinkBuf(k.output,k.next_out)))}while((k.avail_in>0||k.avail_out===0)&&w!==c);return S===l?(w=e.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===s):(S===p&&(this.onEnd(s),k.avail_out=0),!0)},h.prototype.onData=function(_){this.chunks.push(_)},h.prototype.onEnd=function(_){_===s&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=t.flattenChunks(this.chunks)),this.chunks=[],this.err=_,this.msg=this.strm.msg};function T(_,b){var k=new h(b);if(k.push(_,!0),k.err)throw k.msg||a[k.err];return k.result}function P(_,b){return b=b||{},b.raw=!0,T(_,b)}function v(_,b){return b=b||{},b.gzip=!0,T(_,b)}return jt.Deflate=h,jt.deflate=T,jt.deflateRaw=P,jt.gzip=v,jt}var en={},ft={},io,sr;function fs(){if(sr)return io;sr=1;var e=30,t=12;return io=function(a,i){var o,r,l,s,c,p,f,d,x,h,T,P,v,_,b,k,M,w,S,N,F,B,I,D,E;o=a.state,r=a.next_in,D=a.input,l=r+(a.avail_in-5),s=a.next_out,E=a.output,c=s-(i-a.avail_out),p=s+(a.avail_out-257),f=o.dmax,d=o.wsize,x=o.whave,h=o.wnext,T=o.window,P=o.hold,v=o.bits,_=o.lencode,b=o.distcode,k=(1<<o.lenbits)-1,M=(1<<o.distbits)-1;e:do{v<15&&(P+=D[r++]<<v,v+=8,P+=D[r++]<<v,v+=8),w=_[P&k];t:for(;;){if(S=w>>>24,P>>>=S,v-=S,S=w>>>16&255,S===0)E[s++]=w&65535;else if(S&16){N=w&65535,S&=15,S&&(v<S&&(P+=D[r++]<<v,v+=8),N+=P&(1<<S)-1,P>>>=S,v-=S),v<15&&(P+=D[r++]<<v,v+=8,P+=D[r++]<<v,v+=8),w=b[P&M];n:for(;;){if(S=w>>>24,P>>>=S,v-=S,S=w>>>16&255,S&16){if(F=w&65535,S&=15,v<S&&(P+=D[r++]<<v,v+=8,v<S&&(P+=D[r++]<<v,v+=8)),F+=P&(1<<S)-1,F>f){a.msg="invalid distance too far back",o.mode=e;break e}if(P>>>=S,v-=S,S=s-c,F>S){if(S=F-S,S>x&&o.sane){a.msg="invalid distance too far back",o.mode=e;break e}if(B=0,I=T,h===0){if(B+=d-S,S<N){N-=S;do E[s++]=T[B++];while(--S);B=s-F,I=E}}else if(h<S){if(B+=d+h-S,S-=h,S<N){N-=S;do E[s++]=T[B++];while(--S);if(B=0,h<N){S=h,N-=S;do E[s++]=T[B++];while(--S);B=s-F,I=E}}}else if(B+=h-S,S<N){N-=S;do E[s++]=T[B++];while(--S);B=s-F,I=E}for(;N>2;)E[s++]=I[B++],E[s++]=I[B++],E[s++]=I[B++],N-=3;N&&(E[s++]=I[B++],N>1&&(E[s++]=I[B++]))}else{B=s-F;do E[s++]=E[B++],E[s++]=E[B++],E[s++]=E[B++],N-=3;while(N>2);N&&(E[s++]=E[B++],N>1&&(E[s++]=E[B++]))}}else if(S&64){a.msg="invalid distance code",o.mode=e;break e}else{w=b[(w&65535)+(P&(1<<S)-1)];continue n}break}}else if(S&64)if(S&32){o.mode=t;break e}else{a.msg="invalid literal/length code",o.mode=e;break e}else{w=_[(w&65535)+(P&(1<<S)-1)];continue t}break}}while(r<l&&s<p);N=v>>3,r-=N,v-=N<<3,P&=(1<<v)-1,a.next_in=r,a.next_out=s,a.avail_in=r<l?5+(l-r):5-(r-l),a.avail_out=s<p?257+(p-s):257-(s-p),o.hold=P,o.bits=v},io}var ao,lr;function ds(){if(lr)return ao;lr=1;var e=Ht(),t=15,n=852,a=592,i=0,o=1,r=2,l=[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],s=[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],p=[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 ao=function(d,x,h,T,P,v,_,b){var k=b.bits,M=0,w=0,S=0,N=0,F=0,B=0,I=0,D=0,E=0,L=0,y,A,V,$,W,ne=null,ee=0,G,le=new e.Buf16(t+1),re=new e.Buf16(t+1),oe=null,Y=0,ce,ae,X;for(M=0;M<=t;M++)le[M]=0;for(w=0;w<T;w++)le[x[h+w]]++;for(F=k,N=t;N>=1&&le[N]===0;N--);if(F>N&&(F=N),N===0)return P[v++]=1<<24|64<<16|0,P[v++]=1<<24|64<<16|0,b.bits=1,0;for(S=1;S<N&&le[S]===0;S++);for(F<S&&(F=S),D=1,M=1;M<=t;M++)if(D<<=1,D-=le[M],D<0)return-1;if(D>0&&(d===i||N!==1))return-1;for(re[1]=0,M=1;M<t;M++)re[M+1]=re[M]+le[M];for(w=0;w<T;w++)x[h+w]!==0&&(_[re[x[h+w]]++]=w);if(d===i?(ne=oe=_,G=19):d===o?(ne=l,ee-=257,oe=s,Y-=257,G=256):(ne=c,oe=p,G=-1),L=0,w=0,M=S,W=v,B=F,I=0,V=-1,E=1<<F,$=E-1,d===o&&E>n||d===r&&E>a)return 1;for(;;){ce=M-I,_[w]<G?(ae=0,X=_[w]):_[w]>G?(ae=oe[Y+_[w]],X=ne[ee+_[w]]):(ae=96,X=0),y=1<<M-I,A=1<<B,S=A;do A-=y,P[W+(L>>I)+A]=ce<<24|ae<<16|X|0;while(A!==0);for(y=1<<M-1;L&y;)y>>=1;if(y!==0?(L&=y-1,L+=y):L=0,w++,--le[M]===0){if(M===N)break;M=x[h+_[w]]}if(M>F&&(L&$)!==V){for(I===0&&(I=F),W+=S,B=M-I,D=1<<B;B+I<N&&(D-=le[B+I],!(D<=0));)B++,D<<=1;if(E+=1<<B,d===o&&E>n||d===r&&E>a)return 1;V=L&$,P[V]=F<<24|B<<16|W-v|0}}return L!==0&&(P[W+L]=M-I<<24|64<<16|0),b.bits=F,0},ao}var cr;function ps(){if(cr)return ft;cr=1;var e=Ht(),t=bi(),n=ki(),a=fs(),i=ds(),o=0,r=1,l=2,s=4,c=5,p=6,f=0,d=1,x=2,h=-2,T=-3,P=-4,v=-5,_=8,b=1,k=2,M=3,w=4,S=5,N=6,F=7,B=8,I=9,D=10,E=11,L=12,y=13,A=14,V=15,$=16,W=17,ne=18,ee=19,G=20,le=21,re=22,oe=23,Y=24,ce=25,ae=26,X=27,Pe=28,ge=29,H=30,Q=31,Ee=32,ke=852,te=592,me=15,ue=me;function pe(Z){return(Z>>>24&255)+(Z>>>8&65280)+((Z&65280)<<8)+((Z&255)<<24)}function Ne(){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 be(Z){var ie;return!Z||!Z.state?h:(ie=Z.state,Z.total_in=Z.total_out=ie.total=0,Z.msg="",ie.wrap&&(Z.adler=ie.wrap&1),ie.mode=b,ie.last=0,ie.havedict=0,ie.dmax=32768,ie.head=null,ie.hold=0,ie.bits=0,ie.lencode=ie.lendyn=new e.Buf32(ke),ie.distcode=ie.distdyn=new e.Buf32(te),ie.sane=1,ie.back=-1,f)}function Ae(Z){var ie;return!Z||!Z.state?h:(ie=Z.state,ie.wsize=0,ie.whave=0,ie.wnext=0,be(Z))}function Ie(Z,ie){var O,de;return!Z||!Z.state||(de=Z.state,ie<0?(O=0,ie=-ie):(O=(ie>>4)+1,ie<48&&(ie&=15)),ie&&(ie<8||ie>15))?h:(de.window!==null&&de.wbits!==ie&&(de.window=null),de.wrap=O,de.wbits=ie,Ae(Z))}function we(Z,ie){var O,de;return Z?(de=new Ne,Z.state=de,de.window=null,O=Ie(Z,ie),O!==f&&(Z.state=null),O):h}function Re(Z){return we(Z,ue)}var Ve=!0,Ue,Be;function Ge(Z){if(Ve){var ie;for(Ue=new e.Buf32(512),Be=new e.Buf32(32),ie=0;ie<144;)Z.lens[ie++]=8;for(;ie<256;)Z.lens[ie++]=9;for(;ie<280;)Z.lens[ie++]=7;for(;ie<288;)Z.lens[ie++]=8;for(i(r,Z.lens,0,288,Ue,0,Z.work,{bits:9}),ie=0;ie<32;)Z.lens[ie++]=5;i(l,Z.lens,0,32,Be,0,Z.work,{bits:5}),Ve=!1}Z.lencode=Ue,Z.lenbits=9,Z.distcode=Be,Z.distbits=5}function Ke(Z,ie,O,de){var Se,g=Z.state;return g.window===null&&(g.wsize=1<<g.wbits,g.wnext=0,g.whave=0,g.window=new e.Buf8(g.wsize)),de>=g.wsize?(e.arraySet(g.window,ie,O-g.wsize,g.wsize,0),g.wnext=0,g.whave=g.wsize):(Se=g.wsize-g.wnext,Se>de&&(Se=de),e.arraySet(g.window,ie,O-de,Se,g.wnext),de-=Se,de?(e.arraySet(g.window,ie,O-de,de,0),g.wnext=de,g.whave=g.wsize):(g.wnext+=Se,g.wnext===g.wsize&&(g.wnext=0),g.whave<g.wsize&&(g.whave+=Se))),0}function z(Z,ie){var O,de,Se,g,q,j,R,U,J,Te,ye,Ce,Fe,Tt,Ye=0,De,qe,et,at,En,Nn,Xe,ut,Qe=new e.Buf8(4),bt,Ct,Ko=[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 h;O=Z.state,O.mode===L&&(O.mode=y),q=Z.next_out,Se=Z.output,R=Z.avail_out,g=Z.next_in,de=Z.input,j=Z.avail_in,U=O.hold,J=O.bits,Te=j,ye=R,ut=f;e:for(;;)switch(O.mode){case b:if(O.wrap===0){O.mode=y;break}for(;J<16;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}if(O.wrap&2&&U===35615){O.check=0,Qe[0]=U&255,Qe[1]=U>>>8&255,O.check=n(O.check,Qe,2,0),U=0,J=0,O.mode=k;break}if(O.flags=0,O.head&&(O.head.done=!1),!(O.wrap&1)||(((U&255)<<8)+(U>>8))%31){Z.msg="incorrect header check",O.mode=H;break}if((U&15)!==_){Z.msg="unknown compression method",O.mode=H;break}if(U>>>=4,J-=4,Xe=(U&15)+8,O.wbits===0)O.wbits=Xe;else if(Xe>O.wbits){Z.msg="invalid window size",O.mode=H;break}O.dmax=1<<Xe,Z.adler=O.check=1,O.mode=U&512?D:L,U=0,J=0;break;case k:for(;J<16;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}if(O.flags=U,(O.flags&255)!==_){Z.msg="unknown compression method",O.mode=H;break}if(O.flags&57344){Z.msg="unknown header flags set",O.mode=H;break}O.head&&(O.head.text=U>>8&1),O.flags&512&&(Qe[0]=U&255,Qe[1]=U>>>8&255,O.check=n(O.check,Qe,2,0)),U=0,J=0,O.mode=M;case M:for(;J<32;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}O.head&&(O.head.time=U),O.flags&512&&(Qe[0]=U&255,Qe[1]=U>>>8&255,Qe[2]=U>>>16&255,Qe[3]=U>>>24&255,O.check=n(O.check,Qe,4,0)),U=0,J=0,O.mode=w;case w:for(;J<16;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}O.head&&(O.head.xflags=U&255,O.head.os=U>>8),O.flags&512&&(Qe[0]=U&255,Qe[1]=U>>>8&255,O.check=n(O.check,Qe,2,0)),U=0,J=0,O.mode=S;case S:if(O.flags&1024){for(;J<16;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}O.length=U,O.head&&(O.head.extra_len=U),O.flags&512&&(Qe[0]=U&255,Qe[1]=U>>>8&255,O.check=n(O.check,Qe,2,0)),U=0,J=0}else O.head&&(O.head.extra=null);O.mode=N;case N:if(O.flags&1024&&(Ce=O.length,Ce>j&&(Ce=j),Ce&&(O.head&&(Xe=O.head.extra_len-O.length,O.head.extra||(O.head.extra=new Array(O.head.extra_len)),e.arraySet(O.head.extra,de,g,Ce,Xe)),O.flags&512&&(O.check=n(O.check,de,Ce,g)),j-=Ce,g+=Ce,O.length-=Ce),O.length))break e;O.length=0,O.mode=F;case F:if(O.flags&2048){if(j===0)break e;Ce=0;do Xe=de[g+Ce++],O.head&&Xe&&O.length<65536&&(O.head.name+=String.fromCharCode(Xe));while(Xe&&Ce<j);if(O.flags&512&&(O.check=n(O.check,de,Ce,g)),j-=Ce,g+=Ce,Xe)break e}else O.head&&(O.head.name=null);O.length=0,O.mode=B;case B:if(O.flags&4096){if(j===0)break e;Ce=0;do Xe=de[g+Ce++],O.head&&Xe&&O.length<65536&&(O.head.comment+=String.fromCharCode(Xe));while(Xe&&Ce<j);if(O.flags&512&&(O.check=n(O.check,de,Ce,g)),j-=Ce,g+=Ce,Xe)break e}else O.head&&(O.head.comment=null);O.mode=I;case I:if(O.flags&512){for(;J<16;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}if(U!==(O.check&65535)){Z.msg="header crc mismatch",O.mode=H;break}U=0,J=0}O.head&&(O.head.hcrc=O.flags>>9&1,O.head.done=!0),Z.adler=O.check=0,O.mode=L;break;case D:for(;J<32;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}Z.adler=O.check=pe(U),U=0,J=0,O.mode=E;case E:if(O.havedict===0)return Z.next_out=q,Z.avail_out=R,Z.next_in=g,Z.avail_in=j,O.hold=U,O.bits=J,x;Z.adler=O.check=1,O.mode=L;case L:if(ie===c||ie===p)break e;case y:if(O.last){U>>>=J&7,J-=J&7,O.mode=X;break}for(;J<3;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}switch(O.last=U&1,U>>>=1,J-=1,U&3){case 0:O.mode=A;break;case 1:if(Ge(O),O.mode=G,ie===p){U>>>=2,J-=2;break e}break;case 2:O.mode=W;break;case 3:Z.msg="invalid block type",O.mode=H}U>>>=2,J-=2;break;case A:for(U>>>=J&7,J-=J&7;J<32;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}if((U&65535)!==(U>>>16^65535)){Z.msg="invalid stored block lengths",O.mode=H;break}if(O.length=U&65535,U=0,J=0,O.mode=V,ie===p)break e;case V:O.mode=$;case $:if(Ce=O.length,Ce){if(Ce>j&&(Ce=j),Ce>R&&(Ce=R),Ce===0)break e;e.arraySet(Se,de,g,Ce,q),j-=Ce,g+=Ce,R-=Ce,q+=Ce,O.length-=Ce;break}O.mode=L;break;case W:for(;J<14;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}if(O.nlen=(U&31)+257,U>>>=5,J-=5,O.ndist=(U&31)+1,U>>>=5,J-=5,O.ncode=(U&15)+4,U>>>=4,J-=4,O.nlen>286||O.ndist>30){Z.msg="too many length or distance symbols",O.mode=H;break}O.have=0,O.mode=ne;case ne:for(;O.have<O.ncode;){for(;J<3;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}O.lens[Ko[O.have++]]=U&7,U>>>=3,J-=3}for(;O.have<19;)O.lens[Ko[O.have++]]=0;if(O.lencode=O.lendyn,O.lenbits=7,bt={bits:O.lenbits},ut=i(o,O.lens,0,19,O.lencode,0,O.work,bt),O.lenbits=bt.bits,ut){Z.msg="invalid code lengths set",O.mode=H;break}O.have=0,O.mode=ee;case ee:for(;O.have<O.nlen+O.ndist;){for(;Ye=O.lencode[U&(1<<O.lenbits)-1],De=Ye>>>24,qe=Ye>>>16&255,et=Ye&65535,!(De<=J);){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}if(et<16)U>>>=De,J-=De,O.lens[O.have++]=et;else{if(et===16){for(Ct=De+2;J<Ct;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}if(U>>>=De,J-=De,O.have===0){Z.msg="invalid bit length repeat",O.mode=H;break}Xe=O.lens[O.have-1],Ce=3+(U&3),U>>>=2,J-=2}else if(et===17){for(Ct=De+3;J<Ct;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}U>>>=De,J-=De,Xe=0,Ce=3+(U&7),U>>>=3,J-=3}else{for(Ct=De+7;J<Ct;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}U>>>=De,J-=De,Xe=0,Ce=11+(U&127),U>>>=7,J-=7}if(O.have+Ce>O.nlen+O.ndist){Z.msg="invalid bit length repeat",O.mode=H;break}for(;Ce--;)O.lens[O.have++]=Xe}}if(O.mode===H)break;if(O.lens[256]===0){Z.msg="invalid code -- missing end-of-block",O.mode=H;break}if(O.lenbits=9,bt={bits:O.lenbits},ut=i(r,O.lens,0,O.nlen,O.lencode,0,O.work,bt),O.lenbits=bt.bits,ut){Z.msg="invalid literal/lengths set",O.mode=H;break}if(O.distbits=6,O.distcode=O.distdyn,bt={bits:O.distbits},ut=i(l,O.lens,O.nlen,O.ndist,O.distcode,0,O.work,bt),O.distbits=bt.bits,ut){Z.msg="invalid distances set",O.mode=H;break}if(O.mode=G,ie===p)break e;case G:O.mode=le;case le:if(j>=6&&R>=258){Z.next_out=q,Z.avail_out=R,Z.next_in=g,Z.avail_in=j,O.hold=U,O.bits=J,a(Z,ye),q=Z.next_out,Se=Z.output,R=Z.avail_out,g=Z.next_in,de=Z.input,j=Z.avail_in,U=O.hold,J=O.bits,O.mode===L&&(O.back=-1);break}for(O.back=0;Ye=O.lencode[U&(1<<O.lenbits)-1],De=Ye>>>24,qe=Ye>>>16&255,et=Ye&65535,!(De<=J);){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}if(qe&&!(qe&240)){for(at=De,En=qe,Nn=et;Ye=O.lencode[Nn+((U&(1<<at+En)-1)>>at)],De=Ye>>>24,qe=Ye>>>16&255,et=Ye&65535,!(at+De<=J);){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}U>>>=at,J-=at,O.back+=at}if(U>>>=De,J-=De,O.back+=De,O.length=et,qe===0){O.mode=ae;break}if(qe&32){O.back=-1,O.mode=L;break}if(qe&64){Z.msg="invalid literal/length code",O.mode=H;break}O.extra=qe&15,O.mode=re;case re:if(O.extra){for(Ct=O.extra;J<Ct;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}O.length+=U&(1<<O.extra)-1,U>>>=O.extra,J-=O.extra,O.back+=O.extra}O.was=O.length,O.mode=oe;case oe:for(;Ye=O.distcode[U&(1<<O.distbits)-1],De=Ye>>>24,qe=Ye>>>16&255,et=Ye&65535,!(De<=J);){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}if(!(qe&240)){for(at=De,En=qe,Nn=et;Ye=O.distcode[Nn+((U&(1<<at+En)-1)>>at)],De=Ye>>>24,qe=Ye>>>16&255,et=Ye&65535,!(at+De<=J);){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}U>>>=at,J-=at,O.back+=at}if(U>>>=De,J-=De,O.back+=De,qe&64){Z.msg="invalid distance code",O.mode=H;break}O.offset=et,O.extra=qe&15,O.mode=Y;case Y:if(O.extra){for(Ct=O.extra;J<Ct;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}O.offset+=U&(1<<O.extra)-1,U>>>=O.extra,J-=O.extra,O.back+=O.extra}if(O.offset>O.dmax){Z.msg="invalid distance too far back",O.mode=H;break}O.mode=ce;case ce:if(R===0)break e;if(Ce=ye-R,O.offset>Ce){if(Ce=O.offset-Ce,Ce>O.whave&&O.sane){Z.msg="invalid distance too far back",O.mode=H;break}Ce>O.wnext?(Ce-=O.wnext,Fe=O.wsize-Ce):Fe=O.wnext-Ce,Ce>O.length&&(Ce=O.length),Tt=O.window}else Tt=Se,Fe=q-O.offset,Ce=O.length;Ce>R&&(Ce=R),R-=Ce,O.length-=Ce;do Se[q++]=Tt[Fe++];while(--Ce);O.length===0&&(O.mode=le);break;case ae:if(R===0)break e;Se[q++]=O.length,R--,O.mode=le;break;case X:if(O.wrap){for(;J<32;){if(j===0)break e;j--,U|=de[g++]<<J,J+=8}if(ye-=R,Z.total_out+=ye,O.total+=ye,ye&&(Z.adler=O.check=O.flags?n(O.check,Se,ye,q-ye):t(O.check,Se,ye,q-ye)),ye=R,(O.flags?U:pe(U))!==O.check){Z.msg="incorrect data check",O.mode=H;break}U=0,J=0}O.mode=Pe;case Pe:if(O.wrap&&O.flags){for(;J<32;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}if(U!==(O.total&4294967295)){Z.msg="incorrect length check",O.mode=H;break}U=0,J=0}O.mode=ge;case ge:ut=d;break e;case H:ut=T;break e;case Q:return P;case Ee:default:return h}return Z.next_out=q,Z.avail_out=R,Z.next_in=g,Z.avail_in=j,O.hold=U,O.bits=J,(O.wsize||ye!==Z.avail_out&&O.mode<H&&(O.mode<X||ie!==s))&&Ke(Z,Z.output,Z.next_out,ye-Z.avail_out),Te-=Z.avail_in,ye-=Z.avail_out,Z.total_in+=Te,Z.total_out+=ye,O.total+=ye,O.wrap&&ye&&(Z.adler=O.check=O.flags?n(O.check,Se,ye,Z.next_out-ye):t(O.check,Se,ye,Z.next_out-ye)),Z.data_type=O.bits+(O.last?64:0)+(O.mode===L?128:0)+(O.mode===G||O.mode===V?256:0),(Te===0&&ye===0||ie===s)&&ut===f&&(ut=v),ut}function fe(Z){if(!Z||!Z.state)return h;var ie=Z.state;return ie.window&&(ie.window=null),Z.state=null,f}function he(Z,ie){var O;return!Z||!Z.state||(O=Z.state,!(O.wrap&2))?h:(O.head=ie,ie.done=!1,f)}function xe(Z,ie){var O=ie.length,de,Se,g;return!Z||!Z.state||(de=Z.state,de.wrap!==0&&de.mode!==E)?h:de.mode===E&&(Se=1,Se=t(Se,ie,O,0),Se!==de.check)?T:(g=Ke(Z,ie,O,O),g?(de.mode=Q,P):(de.havedict=1,f))}return ft.inflateReset=Ae,ft.inflateReset2=Ie,ft.inflateResetKeep=be,ft.inflateInit=Re,ft.inflateInit2=we,ft.inflate=z,ft.inflateEnd=fe,ft.inflateGetHeader=he,ft.inflateSetDictionary=xe,ft.inflateInfo="pako inflate (from Nodeca project)",ft}var so,ur;function Ii(){return ur||(ur=1,so={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}),so}var lo,fr;function hs(){if(fr)return lo;fr=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 lo=e,lo}var dr;function ms(){if(dr)return en;dr=1;var e=ps(),t=Ht(),n=Ei(),a=Ii(),i=wo(),o=Ni(),r=hs(),l=Object.prototype.toString;function s(f){if(!(this instanceof s))return new s(f);this.options=t.assign({chunkSize:16384,windowBits:0,to:""},f||{});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&&!(f&&f.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 x=e.inflateInit2(this.strm,d.windowBits);if(x!==a.Z_OK)throw new Error(i[x]);if(this.header=new r,e.inflateGetHeader(this.strm,this.header),d.dictionary&&(typeof d.dictionary=="string"?d.dictionary=n.string2buf(d.dictionary):l.call(d.dictionary)==="[object ArrayBuffer]"&&(d.dictionary=new Uint8Array(d.dictionary)),d.raw&&(x=e.inflateSetDictionary(this.strm,d.dictionary),x!==a.Z_OK)))throw new Error(i[x])}s.prototype.push=function(f,d){var x=this.strm,h=this.options.chunkSize,T=this.options.dictionary,P,v,_,b,k,M=!1;if(this.ended)return!1;v=d===~~d?d:d===!0?a.Z_FINISH:a.Z_NO_FLUSH,typeof f=="string"?x.input=n.binstring2buf(f):l.call(f)==="[object ArrayBuffer]"?x.input=new Uint8Array(f):x.input=f,x.next_in=0,x.avail_in=x.input.length;do{if(x.avail_out===0&&(x.output=new t.Buf8(h),x.next_out=0,x.avail_out=h),P=e.inflate(x,a.Z_NO_FLUSH),P===a.Z_NEED_DICT&&T&&(P=e.inflateSetDictionary(this.strm,T)),P===a.Z_BUF_ERROR&&M===!0&&(P=a.Z_OK,M=!1),P!==a.Z_STREAM_END&&P!==a.Z_OK)return this.onEnd(P),this.ended=!0,!1;x.next_out&&(x.avail_out===0||P===a.Z_STREAM_END||x.avail_in===0&&(v===a.Z_FINISH||v===a.Z_SYNC_FLUSH))&&(this.options.to==="string"?(_=n.utf8border(x.output,x.next_out),b=x.next_out-_,k=n.buf2string(x.output,_),x.next_out=b,x.avail_out=h-b,b&&t.arraySet(x.output,x.output,_,b,0),this.onData(k)):this.onData(t.shrinkBuf(x.output,x.next_out))),x.avail_in===0&&x.avail_out===0&&(M=!0)}while((x.avail_in>0||x.avail_out===0)&&P!==a.Z_STREAM_END);return P===a.Z_STREAM_END&&(v=a.Z_FINISH),v===a.Z_FINISH?(P=e.inflateEnd(this.strm),this.onEnd(P),this.ended=!0,P===a.Z_OK):(v===a.Z_SYNC_FLUSH&&(this.onEnd(a.Z_OK),x.avail_out=0),!0)},s.prototype.onData=function(f){this.chunks.push(f)},s.prototype.onEnd=function(f){f===a.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=t.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg};function c(f,d){var x=new s(d);if(x.push(f,!0),x.err)throw x.msg||i[x.err];return x.result}function p(f,d){return d=d||{},d.raw=!0,c(f,d)}return en.Inflate=s,en.inflate=c,en.inflateRaw=p,en.ungzip=c,en}var co,pr;function gs(){if(pr)return co;pr=1;var e=Ht().assign,t=us(),n=ms(),a=Ii(),i={};return e(i,t,n,a),co=i,co}(function(e){(function(){var t={},n;e.exports=t,typeof Po=="function"?n=gs():n=window.pako,function(a,i){a.toRGBA8=function(o){var r=o.width,l=o.height;if(o.tabs.acTL==null)return[a.toRGBA8.decodeImage(o.data,r,l,o).buffer];var s=[];o.frames[0].data==null&&(o.frames[0].data=o.data);for(var c,p=new Uint8Array(r*l*4),f=0;f<o.frames.length;f++){var d=o.frames[f],x=d.rect.x,h=d.rect.y,T=d.rect.width,P=d.rect.height,v=a.toRGBA8.decodeImage(d.data,T,P,o);if(f==0?c=v:d.blend==0?a._copyTile(v,T,P,c,r,l,x,h,0):d.blend==1&&a._copyTile(v,T,P,c,r,l,x,h,1),s.push(c.buffer),c=c.slice(0),d.dispose!=0){if(d.dispose==1)a._copyTile(p,T,P,c,r,l,x,h,0);else if(d.dispose==2){for(var _=f-1;o.frames[_].dispose==2;)_--;c=new Uint8Array(s[_]).slice(0)}}}return s},a.toRGBA8.decodeImage=function(o,r,l,s){var c=r*l,p=a.decode._getBPP(s),f=Math.ceil(r*p/8),d=new Uint8Array(c*4),x=new Uint32Array(d.buffer),h=s.ctype,T=s.depth,P=a._bin.readUshort;if(h==6){var v=c<<2;if(T==8)for(var _=0;_<v;_++)d[_]=o[_];if(T==16)for(var _=0;_<v;_++)d[_]=o[_<<1]}else if(h==2){var b=s.tabs.tRNS,k=-1,M=-1,w=-1;if(b&&(k=b[0],M=b[1],w=b[2]),T==8)for(var _=0;_<c;_++){var S=_<<2,N=_*3;d[S]=o[N],d[S+1]=o[N+1],d[S+2]=o[N+2],d[S+3]=255,k!=-1&&o[N]==k&&o[N+1]==M&&o[N+2]==w&&(d[S+3]=0)}if(T==16)for(var _=0;_<c;_++){var S=_<<2,N=_*6;d[S]=o[N],d[S+1]=o[N+2],d[S+2]=o[N+4],d[S+3]=255,k!=-1&&P(o,N)==k&&P(o,N+2)==M&&P(o,N+4)==w&&(d[S+3]=0)}}else if(h==3){var F=s.tabs.PLTE,B=s.tabs.tRNS,I=B?B.length:0;if(T==1)for(var D=0;D<l;D++)for(var E=D*f,L=D*r,_=0;_<r;_++){var S=L+_<<2,y=o[E+(_>>3)]>>7-((_&7)<<0)&1,A=3*y;d[S]=F[A],d[S+1]=F[A+1],d[S+2]=F[A+2],d[S+3]=y<I?B[y]:255}if(T==2)for(var D=0;D<l;D++)for(var E=D*f,L=D*r,_=0;_<r;_++){var S=L+_<<2,y=o[E+(_>>2)]>>6-((_&3)<<1)&3,A=3*y;d[S]=F[A],d[S+1]=F[A+1],d[S+2]=F[A+2],d[S+3]=y<I?B[y]:255}if(T==4)for(var D=0;D<l;D++)for(var E=D*f,L=D*r,_=0;_<r;_++){var S=L+_<<2,y=o[E+(_>>1)]>>4-((_&1)<<2)&15,A=3*y;d[S]=F[A],d[S+1]=F[A+1],d[S+2]=F[A+2],d[S+3]=y<I?B[y]:255}if(T==8)for(var _=0;_<c;_++){var S=_<<2,y=o[_],A=3*y;d[S]=F[A],d[S+1]=F[A+1],d[S+2]=F[A+2],d[S+3]=y<I?B[y]:255}}else if(h==4){if(T==8)for(var _=0;_<c;_++){var S=_<<2,V=_<<1,$=o[V];d[S]=$,d[S+1]=$,d[S+2]=$,d[S+3]=o[V+1]}if(T==16)for(var _=0;_<c;_++){var S=_<<2,V=_<<2,$=o[V];d[S]=$,d[S+1]=$,d[S+2]=$,d[S+3]=o[V+2]}}else if(h==0){var k=s.tabs.tRNS?s.tabs.tRNS:-1;if(T==1)for(var _=0;_<c;_++){var $=255*(o[_>>3]>>7-(_&7)&1),W=$==k*255?0:255;x[_]=W<<24|$<<16|$<<8|$}if(T==2)for(var _=0;_<c;_++){var $=85*(o[_>>2]>>6-((_&3)<<1)&3),W=$==k*85?0:255;x[_]=W<<24|$<<16|$<<8|$}if(T==4)for(var _=0;_<c;_++){var $=17*(o[_>>1]>>4-((_&1)<<2)&15),W=$==k*17?0:255;x[_]=W<<24|$<<16|$<<8|$}if(T==8)for(var _=0;_<c;_++){var $=o[_],W=$==k?0:255;x[_]=W<<24|$<<16|$<<8|$}if(T==16)for(var _=0;_<c;_++){var $=o[_<<1],W=P(o,_<<1)==k?0:255;x[_]=W<<24|$<<16|$<<8|$}}return d},a.decode=function(o){for(var r=new Uint8Array(o),l=8,s=a._bin,c=s.readUshort,p=s.readUint,f={tabs:{},frames:[]},d=new Uint8Array(r.length),x=0,h,T=0,P=[137,80,78,71,13,10,26,10],v=0;v<8;v++)if(r[v]!=P[v])throw"The input is not a PNG file!";for(;l<r.length;){var _=s.readUint(r,l);l+=4;var b=s.readASCII(r,l,4);if(l+=4,b=="IHDR")a.decode._IHDR(r,l,f);else if(b=="IDAT"){for(var v=0;v<_;v++)d[x+v]=r[l+v];x+=_}else if(b=="acTL")f.tabs[b]={num_frames:p(r,l),num_plays:p(r,l+4)},h=new Uint8Array(r.length);else if(b=="fcTL"){if(T!=0){var k=f.frames[f.frames.length-1];k.data=a.decode._decompress(f,h.slice(0,T),k.rect.width,k.rect.height),T=0}var M={x:p(r,l+12),y:p(r,l+16),width:p(r,l+4),height:p(r,l+8)},w=c(r,l+22);w=c(r,l+20)/(w==0?100:w);var S={rect:M,delay:Math.round(w*1e3),dispose:r[l+24],blend:r[l+25]};f.frames.push(S)}else if(b=="fdAT"){for(var v=0;v<_-4;v++)h[T+v]=r[l+v+4];T+=_-4}else if(b=="pHYs")f.tabs[b]=[s.readUint(r,l),s.readUint(r,l+4),r[l+8]];else if(b=="cHRM"){f.tabs[b]=[];for(var v=0;v<8;v++)f.tabs[b].push(s.readUint(r,l+v*4))}else if(b=="tEXt"){f.tabs[b]==null&&(f.tabs[b]={});var N=s.nextZero(r,l),F=s.readASCII(r,l,N-l),B=s.readASCII(r,N+1,l+_-N-1);f.tabs[b][F]=B}else if(b=="iTXt"){f.tabs[b]==null&&(f.tabs[b]={});var N=0,I=l;N=s.nextZero(r,I);var F=s.readASCII(r,I,N-I);I=N+1,r[I],r[I+1],I+=2,N=s.nextZero(r,I),s.readASCII(r,I,N-I),I=N+1,N=s.nextZero(r,I),s.readUTF8(r,I,N-I),I=N+1;var B=s.readUTF8(r,I,_-(I-l));f.tabs[b][F]=B}else if(b=="PLTE")f.tabs[b]=s.readBytes(r,l,_);else if(b=="hIST"){var D=f.tabs.PLTE.length/3;f.tabs[b]=[];for(var v=0;v<D;v++)f.tabs[b].push(c(r,l+v*2))}else if(b=="tRNS")f.ctype==3?f.tabs[b]=s.readBytes(r,l,_):f.ctype==0?f.tabs[b]=c(r,l):f.ctype==2&&(f.tabs[b]=[c(r,l),c(r,l+2),c(r,l+4)]);else if(b=="gAMA")f.tabs[b]=s.readUint(r,l)/1e5;else if(b=="sRGB")f.tabs[b]=r[l];else if(b=="bKGD")f.ctype==0||f.ctype==4?f.tabs[b]=[c(r,l)]:f.ctype==2||f.ctype==6?f.tabs[b]=[c(r,l),c(r,l+2),c(r,l+4)]:f.ctype==3&&(f.tabs[b]=r[l]);else if(b=="IEND"){if(T!=0){var k=f.frames[f.frames.length-1];k.data=a.decode._decompress(f,h.slice(0,T),k.rect.width,k.rect.height),T=0}f.data=a.decode._decompress(f,d,f.width,f.height);break}l+=_,s.readUint(r,l),l+=4}return delete f.compress,delete f.interlace,delete f.filter,f},a.decode._decompress=function(o,r,l,s){return o.compress==0&&(r=a.decode._inflate(r)),o.interlace==0?r=a.decode._filterZero(r,o,0,l,s):o.interlace==1&&(r=a.decode._readInterlace(r,o)),r},a.decode._inflate=function(o){return i.inflate(o)},a.decode._readInterlace=function(o,r){for(var l=r.width,s=r.height,c=a.decode._getBPP(r),p=c>>3,f=Math.ceil(l*c/8),d=new Uint8Array(s*f),x=0,h=[0,0,4,0,2,0,1],T=[0,4,0,2,0,1,0],P=[8,8,8,4,4,2,2],v=[8,8,4,4,2,2,1],_=0;_<7;){for(var b=P[_],k=v[_],M=0,w=0,S=h[_];S<s;)S+=b,w++;for(var N=T[_];N<l;)N+=k,M++;var F=Math.ceil(M*c/8);a.decode._filterZero(o,r,x,M,w);for(var B=0,I=h[_];I<s;){for(var D=T[_],E=x+B*F<<3;D<l;){if(c==1){var L=o[E>>3];L=L>>7-(E&7)&1,d[I*f+(D>>3)]|=L<<7-((D&3)<<0)}if(c==2){var L=o[E>>3];L=L>>6-(E&7)&3,d[I*f+(D>>2)]|=L<<6-((D&3)<<1)}if(c==4){var L=o[E>>3];L=L>>4-(E&7)&15,d[I*f+(D>>1)]|=L<<4-((D&1)<<2)}if(c>=8)for(var y=I*f+D*p,A=0;A<p;A++)d[y+A]=o[(E>>3)+A];E+=c,D+=k}B++,I+=b}M*w!=0&&(x+=w*(1+F)),_=_+1}return d},a.decode._getBPP=function(o){var r=[1,null,3,1,2,null,4][o.ctype];return r*o.depth},a.decode._filterZero=function(o,r,l,s,c){var p=a.decode._getBPP(r),f=Math.ceil(s*p/8),d=a.decode._paeth;p=Math.ceil(p/8);for(var x=0;x<c;x++){var h=l+x*f,T=h+x+1,P=o[T-1];if(P==0)for(var v=0;v<f;v++)o[h+v]=o[T+v];else if(P==1){for(var v=0;v<p;v++)o[h+v]=o[T+v];for(var v=p;v<f;v++)o[h+v]=o[T+v]+o[h+v-p]&255}else if(x==0){for(var v=0;v<p;v++)o[h+v]=o[T+v];if(P==2)for(var v=p;v<f;v++)o[h+v]=o[T+v]&255;if(P==3)for(var v=p;v<f;v++)o[h+v]=o[T+v]+(o[h+v-p]>>1)&255;if(P==4)for(var v=p;v<f;v++)o[h+v]=o[T+v]+d(o[h+v-p],0,0)&255}else{if(P==2)for(var v=0;v<f;v++)o[h+v]=o[T+v]+o[h+v-f]&255;if(P==3){for(var v=0;v<p;v++)o[h+v]=o[T+v]+(o[h+v-f]>>1)&255;for(var v=p;v<f;v++)o[h+v]=o[T+v]+(o[h+v-f]+o[h+v-p]>>1)&255}if(P==4){for(var v=0;v<p;v++)o[h+v]=o[T+v]+d(0,o[h+v-f],0)&255;for(var v=p;v<f;v++)o[h+v]=o[T+v]+d(o[h+v-p],o[h+v-f],o[h+v-p-f])&255}}}return o},a.decode._paeth=function(o,r,l){var s=o+r-l,c=Math.abs(s-o),p=Math.abs(s-r),f=Math.abs(s-l);return c<=p&&c<=f?o:p<=f?r:l},a.decode._IHDR=function(o,r,l){var s=a._bin;l.width=s.readUint(o,r),r+=4,l.height=s.readUint(o,r),r+=4,l.depth=o[r],r++,l.ctype=o[r],r++,l.compress=o[r],r++,l.filter=o[r],r++,l.interlace=o[r],r++},a._bin={nextZero:function(o,r){for(;o[r]!=0;)r++;return r},readUshort:function(o,r){return o[r]<<8|o[r+1]},writeUshort:function(o,r,l){o[r]=l>>8&255,o[r+1]=l&255},readUint:function(o,r){return o[r]*(256*256*256)+(o[r+1]<<16|o[r+2]<<8|o[r+3])},writeUint:function(o,r,l){o[r]=l>>24&255,o[r+1]=l>>16&255,o[r+2]=l>>8&255,o[r+3]=l&255},readASCII:function(o,r,l){for(var s="",c=0;c<l;c++)s+=String.fromCharCode(o[r+c]);return s},writeASCII:function(o,r,l){for(var s=0;s<l.length;s++)o[r+s]=l.charCodeAt(s)},readBytes:function(o,r,l){for(var s=[],c=0;c<l;c++)s.push(o[r+c]);return s},pad:function(o){return o.length<2?"0"+o:o},readUTF8:function(o,r,l){for(var s="",c,p=0;p<l;p++)s+="%"+a._bin.pad(o[r+p].toString(16));try{c=decodeURIComponent(s)}catch(f){return a._bin.readASCII(o,r,l)}return c}},a._copyTile=function(o,r,l,s,c,p,f,d,x){for(var h=Math.min(r,c),T=Math.min(l,p),P=0,v=0,_=0;_<T;_++)for(var b=0;b<h;b++)if(f>=0&&d>=0?(P=_*r+b<<2,v=(d+_)*c+f+b<<2):(P=(-d+_)*r-f+b<<2,v=_*c+b<<2),x==0)s[v]=o[P],s[v+1]=o[P+1],s[v+2]=o[P+2],s[v+3]=o[P+3];else if(x==1){var k=o[P+3]*.00392156862745098,M=o[P]*k,w=o[P+1]*k,S=o[P+2]*k,N=s[v+3]*(1/255),F=s[v]*N,B=s[v+1]*N,I=s[v+2]*N,D=1-k,E=k+N*D,L=E==0?0:1/E;s[v+3]=255*E,s[v+0]=(M+F*D)*L,s[v+1]=(w+B*D)*L,s[v+2]=(S+I*D)*L}else if(x==2){var k=o[P+3],M=o[P],w=o[P+1],S=o[P+2],N=s[v+3],F=s[v],B=s[v+1],I=s[v+2];k==N&&M==F&&w==B&&S==I?(s[v]=0,s[v+1]=0,s[v+2]=0,s[v+3]=0):(s[v]=M,s[v+1]=w,s[v+2]=S,s[v+3]=k)}else if(x==3){var k=o[P+3],M=o[P],w=o[P+1],S=o[P+2],N=s[v+3],F=s[v],B=s[v+1],I=s[v+2];if(k==N&&M==F&&w==B&&S==I)continue;if(k<220&&N>20)return!1}return!0},a.encode=function(o,r,l,s,c,p){s==null&&(s=0),p==null&&(p=!1);for(var f=new Uint8Array(o[0].byteLength*o.length+100),d=[137,80,78,71,13,10,26,10],x=0;x<8;x++)f[x]=d[x];var h=8,T=a._bin,P=a.crc.crc,v=T.writeUint,_=T.writeUshort,b=T.writeASCII,k=a.encode.compressPNG(o,r,l,s,p);v(f,h,13),h+=4,b(f,h,"IHDR"),h+=4,v(f,h,r),h+=4,v(f,h,l),h+=4,f[h]=k.depth,h++,f[h]=k.ctype,h++,f[h]=0,h++,f[h]=0,h++,f[h]=0,h++,v(f,h,P(f,h-17,17)),h+=4,v(f,h,1),h+=4,b(f,h,"sRGB"),h+=4,f[h]=1,h++,v(f,h,P(f,h-5,5)),h+=4;var M=o.length>1;if(M&&(v(f,h,8),h+=4,b(f,h,"acTL"),h+=4,v(f,h,o.length),h+=4,v(f,h,0),h+=4,v(f,h,P(f,h-12,12)),h+=4),k.ctype==3){var w=k.plte.length;v(f,h,w*3),h+=4,b(f,h,"PLTE"),h+=4;for(var x=0;x<w;x++){var S=x*3,N=k.plte[x],F=N&255,B=N>>8&255,I=N>>16&255;f[h+S+0]=F,f[h+S+1]=B,f[h+S+2]=I}if(h+=w*3,v(f,h,P(f,h-w*3-4,w*3+4)),h+=4,k.gotAlpha){v(f,h,w),h+=4,b(f,h,"tRNS"),h+=4;for(var x=0;x<w;x++)f[h+x]=k.plte[x]>>24&255;h+=w,v(f,h,P(f,h-w-4,w+4)),h+=4}}for(var D=0,E=0;E<k.frames.length;E++){var L=k.frames[E];M&&(v(f,h,26),h+=4,b(f,h,"fcTL"),h+=4,v(f,h,D++),h+=4,v(f,h,L.rect.width),h+=4,v(f,h,L.rect.height),h+=4,v(f,h,L.rect.x),h+=4,v(f,h,L.rect.y),h+=4,_(f,h,c[E]),h+=2,_(f,h,1e3),h+=2,f[h]=L.dispose,h++,f[h]=L.blend,h++,v(f,h,P(f,h-30,30)),h+=4);var y=L.cimg,w=y.length;v(f,h,w+(E==0?0:4)),h+=4;var A=h;b(f,h,E==0?"IDAT":"fdAT"),h+=4,E!=0&&(v(f,h,D++),h+=4);for(var x=0;x<w;x++)f[h+x]=y[x];h+=w,v(f,h,P(f,A,h-A)),h+=4}return v(f,h,0),h+=4,b(f,h,"IEND"),h+=4,v(f,h,P(f,h-4,4)),h+=4,f.buffer.slice(0,h)},a.encode.compressPNG=function(o,r,l,s,c){for(var p=a.encode.compress(o,r,l,s,!1,c),f=0;f<o.length;f++){var d=p.frames[f];d.rect.width;var x=d.rect.height,h=d.bpl,T=d.bpp,P=new Uint8Array(x*h+x);d.cimg=a.encode._filterZero(d.img,x,T,h,P)}return p},a.encode.compress=function(o,r,l,s,c,p){p==null&&(p=!1);for(var f=6,d=8,x=4,h=255,T=0;T<o.length;T++)for(var P=new Uint8Array(o[T]),v=P.length,_=0;_<v;_+=4)h&=P[_+3];var b=h!=255,k={},M=[];if(o.length!=0&&(k[0]=0,M.push(0),s!=0&&s--),s!=0){var w=a.quantize(o,s,c);o=w.bufs;for(var _=0;_<w.plte.length;_++){var S=w.plte[_].est.rgba;k[S]==null&&(k[S]=M.length,M.push(S))}}else for(var T=0;T<o.length;T++)for(var N=new Uint32Array(o[T]),v=N.length,_=0;_<v;_++){var S=N[_];if((_<r||S!=N[_-1]&&S!=N[_-r])&&k[S]==null&&(k[S]=M.length,M.push(S),M.length>=300))break}var F=b?c:!1,B=M.length;B<=256&&p==!1&&(B<=2?d=1:B<=4?d=2:B<=16?d=4:d=8,c&&(d=8),b=!0);for(var I=[],T=0;T<o.length;T++){var D=new Uint8Array(o[T]),E=new Uint32Array(D.buffer),L=0,y=0,A=r,V=l,$=0;if(T!=0&&!F){for(var W=c||T==1||I[I.length-2].dispose==2?1:2,ne=0,ee=1e9,G=0;G<W;G++){for(var ge=new Uint8Array(o[T-1-G]),le=new Uint32Array(o[T-1-G]),re=r,oe=l,Y=-1,ce=-1,ae=0;ae<l;ae++)for(var X=0;X<r;X++){var _=ae*r+X;E[_]!=le[_]&&(X<re&&(re=X),X>Y&&(Y=X),ae<oe&&(oe=ae),ae>ce&&(ce=ae))}var Pe=Y==-1?1:(Y-re+1)*(ce-oe+1);Pe<ee&&(ee=Pe,ne=G,Y==-1?(L=y=0,A=V=1):(L=re,y=oe,A=Y-re+1,V=ce-oe+1))}var ge=new Uint8Array(o[T-1-ne]);ne==1&&(I[I.length-1].dispose=2);var H=new Uint8Array(A*V*4);new Uint32Array(H.buffer),a._copyTile(ge,r,l,H,A,V,-L,-y,0),a._copyTile(D,r,l,H,A,V,-L,-y,3)?(a._copyTile(D,r,l,H,A,V,-L,-y,2),$=1):(a._copyTile(D,r,l,H,A,V,-L,-y,0),$=0),D=H,E=new Uint32Array(D.buffer)}var Q=4*A;if(B<=256&&p==!1){Q=Math.ceil(d*A/8);for(var H=new Uint8Array(Q*V),ae=0;ae<V;ae++){var _=ae*Q,Ee=ae*A;if(d==8)for(var X=0;X<A;X++)H[_+X]=k[E[Ee+X]];else if(d==4)for(var X=0;X<A;X++)H[_+(X>>1)]|=k[E[Ee+X]]<<4-(X&1)*4;else if(d==2)for(var X=0;X<A;X++)H[_+(X>>2)]|=k[E[Ee+X]]<<6-(X&3)*2;else if(d==1)for(var X=0;X<A;X++)H[_+(X>>3)]|=k[E[Ee+X]]<<7-(X&7)*1}D=H,f=3,x=1}else if(b==!1&&o.length==1){for(var H=new Uint8Array(A*V*3),ke=A*V,_=0;_<ke;_++){var te=_*3,me=_*4;H[te]=D[me],H[te+1]=D[me+1],H[te+2]=D[me+2]}D=H,f=2,x=3,Q=3*A}I.push({rect:{x:L,y,width:A,height:V},img:D,bpl:Q,bpp:x,blend:$,dispose:F?1:0})}return{ctype:f,depth:d,plte:M,gotAlpha:b,frames:I}},a.encode._filterZero=function(o,r,l,s,c){for(var p=[],f=0;f<5;f++)if(!(r*s>5e5&&(f==2||f==3||f==4))){for(var d=0;d<r;d++)a.encode._filterLine(c,o,d,s,l,f);if(p.push(i.deflate(c)),l==1)break}for(var x,h=1e9,T=0;T<p.length;T++)p[T].length<h&&(x=T,h=p[T].length);return p[x]},a.encode._filterLine=function(o,r,l,s,c,p){var f=l*s,d=f+l,x=a.decode._paeth;if(o[d]=p,d++,p==0)for(var h=0;h<s;h++)o[d+h]=r[f+h];else if(p==1){for(var h=0;h<c;h++)o[d+h]=r[f+h];for(var h=c;h<s;h++)o[d+h]=r[f+h]-r[f+h-c]+256&255}else if(l==0){for(var h=0;h<c;h++)o[d+h]=r[f+h];if(p==2)for(var h=c;h<s;h++)o[d+h]=r[f+h];if(p==3)for(var h=c;h<s;h++)o[d+h]=r[f+h]-(r[f+h-c]>>1)+256&255;if(p==4)for(var h=c;h<s;h++)o[d+h]=r[f+h]-x(r[f+h-c],0,0)+256&255}else{if(p==2)for(var h=0;h<s;h++)o[d+h]=r[f+h]+256-r[f+h-s]&255;if(p==3){for(var h=0;h<c;h++)o[d+h]=r[f+h]+256-(r[f+h-s]>>1)&255;for(var h=c;h<s;h++)o[d+h]=r[f+h]+256-(r[f+h-s]+r[f+h-c]>>1)&255}if(p==4){for(var h=0;h<c;h++)o[d+h]=r[f+h]+256-x(0,r[f+h-s],0)&255;for(var h=c;h<s;h++)o[d+h]=r[f+h]+256-x(r[f+h-c],r[f+h-s],r[f+h-c-s])&255}}},a.crc={table:function(){for(var o=new Uint32Array(256),r=0;r<256;r++){for(var l=r,s=0;s<8;s++)l&1?l=3988292384^l>>>1:l=l>>>1;o[r]=l}return o}(),update:function(o,r,l,s){for(var c=0;c<s;c++)o=a.crc.table[(o^r[l+c])&255]^o>>>8;return o},crc:function(o,r,l){return a.crc.update(4294967295,o,r,l)^4294967295}},a.quantize=function(o,r,l){for(var s=[],c=0,p=0;p<o.length;p++)s.push(a.encode.alphaMul(new Uint8Array(o[p]),l)),c+=o[p].byteLength;for(var f=new Uint8Array(c),d=new Uint32Array(f.buffer),x=0,p=0;p<s.length;p++){for(var h=s[p],T=h.length,P=0;P<T;P++)f[x+P]=h[P];x+=T}var v={i0:0,i1:f.length,bst:null,est:null,tdst:0,left:null,right:null};v.bst=a.quantize.stats(f,v.i0,v.i1),v.est=a.quantize.estats(v.bst);for(var _=[v];_.length<r;){for(var b=0,k=0,p=0;p<_.length;p++)_[p].est.L>b&&(b=_[p].est.L,k=p);if(b<.001)break;var M=_[k],w=a.quantize.splitPixels(f,d,M.i0,M.i1,M.est.e,M.est.eMq255),S={i0:M.i0,i1:w,bst:null,est:null,tdst:0,left:null,right:null};S.bst=a.quantize.stats(f,S.i0,S.i1),S.est=a.quantize.estats(S.bst);var N={i0:w,i1:M.i1,bst:null,est:null,tdst:0,left:null,right:null};N.bst={R:[],m:[],N:M.bst.N-S.bst.N};for(var p=0;p<16;p++)N.bst.R[p]=M.bst.R[p]-S.bst.R[p];for(var p=0;p<4;p++)N.bst.m[p]=M.bst.m[p]-S.bst.m[p];N.est=a.quantize.estats(N.bst),M.left=S,M.right=N,_[k]=S,_.push(N)}_.sort(function(W,ne){return ne.bst.N-W.bst.N});for(var F=0;F<s.length;F++){for(var B=a.quantize.planeDst,I=new Uint8Array(s[F].buffer),D=new Uint32Array(s[F].buffer),E=I.length,p=0;p<E;p+=4){for(var L=I[p]*.00392156862745098,y=I[p+1]*(1/255),A=I[p+2]*(1/255),V=I[p+3]*(1/255),$=v;$.left;)$=B($.est,L,y,A,V)<=0?$.left:$.right;D[p>>2]=$.est.rgba}s[F]=D.buffer}return{bufs:s,plte:_}},a.quantize.getNearest=function(o,r,l,s,c){if(o.left==null)return o.tdst=a.quantize.dist(o.est.q,r,l,s,c),o;var p=a.quantize.planeDst(o.est,r,l,s,c),f=o.left,d=o.right;p>0&&(f=o.right,d=o.left);var x=a.quantize.getNearest(f,r,l,s,c);if(x.tdst<=p*p)return x;var h=a.quantize.getNearest(d,r,l,s,c);return h.tdst<x.tdst?h:x},a.quantize.planeDst=function(o,r,l,s,c){var p=o.e;return p[0]*r+p[1]*l+p[2]*s+p[3]*c-o.eMq},a.quantize.dist=function(o,r,l,s,c){var p=r-o[0],f=l-o[1],d=s-o[2],x=c-o[3];return p*p+f*f+d*d+x*x},a.quantize.splitPixels=function(o,r,l,s,c,p){var f=a.quantize.vecDot;for(s-=4;l<s;){for(;f(o,l,c)<=p;)l+=4;for(;f(o,s,c)>p;)s-=4;if(l>=s)break;var d=r[l>>2];r[l>>2]=r[s>>2],r[s>>2]=d,l+=4,s-=4}for(;f(o,l,c)>p;)l-=4;return l+4},a.quantize.vecDot=function(o,r,l){return o[r]*l[0]+o[r+1]*l[1]+o[r+2]*l[2]+o[r+3]*l[3]},a.quantize.stats=function(o,r,l){for(var s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=[0,0,0,0],p=l-r>>2,f=r;f<l;f+=4){var d=o[f]*.00392156862745098,x=o[f+1]*(1/255),h=o[f+2]*(1/255),T=o[f+3]*(1/255);c[0]+=d,c[1]+=x,c[2]+=h,c[3]+=T,s[0]+=d*d,s[1]+=d*x,s[2]+=d*h,s[3]+=d*T,s[5]+=x*x,s[6]+=x*h,s[7]+=x*T,s[10]+=h*h,s[11]+=h*T,s[15]+=T*T}return s[4]=s[1],s[8]=s[2],s[12]=s[3],s[9]=s[6],s[13]=s[7],s[14]=s[11],{R:s,m:c,N:p}},a.quantize.estats=function(o){var r=o.R,l=o.m,s=o.N,c=l[0],p=l[1],f=l[2],d=l[3],x=s==0?0:1/s,h=[r[0]-c*c*x,r[1]-c*p*x,r[2]-c*f*x,r[3]-c*d*x,r[4]-p*c*x,r[5]-p*p*x,r[6]-p*f*x,r[7]-p*d*x,r[8]-f*c*x,r[9]-f*p*x,r[10]-f*f*x,r[11]-f*d*x,r[12]-d*c*x,r[13]-d*p*x,r[14]-d*f*x,r[15]-d*d*x],T=h,P=a.M4,v=[.5,.5,.5,.5],_=0,b=0;if(s!=0)for(var k=0;k<10&&(v=P.multVec(T,v),b=Math.sqrt(P.dot(v,v)),v=P.sml(1/b,v),!(Math.abs(b-_)<1e-9));k++)_=b;var M=[c*x,p*x,f*x,d*x],w=P.dot(P.sml(255,M),v),S=M[3]<.001?0:1/M[3];return{Cov:h,q:M,e:v,L:_,eMq255:w,eMq:P.dot(v,M),rgba:(Math.round(255*M[3])<<24|Math.round(255*M[2]*S)<<16|Math.round(255*M[1]*S)<<8|Math.round(255*M[0]*S)<<0)>>>0}},a.M4={multVec:function(o,r){return[o[0]*r[0]+o[1]*r[1]+o[2]*r[2]+o[3]*r[3],o[4]*r[0]+o[5]*r[1]+o[6]*r[2]+o[7]*r[3],o[8]*r[0]+o[9]*r[1]+o[10]*r[2]+o[11]*r[3],o[12]*r[0]+o[13]*r[1]+o[14]*r[2]+o[15]*r[3]]},dot:function(o,r){return o[0]*r[0]+o[1]*r[1]+o[2]*r[2]+o[3]*r[3]},sml:function(o,r){return[o*r[0],o*r[1],o*r[2],o*r[3]]}},a.encode.alphaMul=function(o,r){for(var l=new Uint8Array(o.length),s=o.length>>2,c=0;c<s;c++){var p=c<<2,f=o[p+3];r&&(f=f<128?0:255);var d=f*(1/255);l[p+0]=o[p+0]*d,l[p+1]=o[p+1]*d,l[p+2]=o[p+2]*d,l[p+3]=f}return l}}(t,n)})()})(Ti);var vs=Ti.exports;const xs=Si(vs),ys=ss.unstable_batchedUpdates,Cs={batchUpdate:ys},ct=e=>new u.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)),Oe=e=>new u.Vector3(e?e.scalePlane:1,e?e.scaleDepth:1,e?e.scalePlane:1),wi=e=>e?new u.Vector3(1/(e.scalePlane?e.scalePlane:1),1/(e.scaleDepth?e.scaleDepth:1),1/(e.scalePlane?e.scalePlane:1)):u.Vector3.One(),_s=e=>{if(e instanceof u.ArcRotateCamera){const t=e.alpha;return(t>0?t:Math.PI-t)/Math.PI*180%360}return 0},Ps=e=>{const t=[];return e.forEach(n=>{t.push(Oi(n))}),t},Oi=e=>new u.Vector3(e.x,e.y,e.z),At=e=>new u.Vector3(e.x,e.y,e.z),Ss=e=>new u.Color3(e.r,e.g,e.b);var yn=(e=>(e[e.START=0]="START",e[e.CONTINUE=1]="CONTINUE",e[e.END=2]="END",e))(yn||{}),$e=(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))($e||{}),Ai=(e=>(e[e.ClockWiseSideOrientation=u.Material.ClockWiseSideOrientation]="ClockWiseSideOrientation",e[e.CounterClockWiseSideOrientation=u.Material.CounterClockWiseSideOrientation]="CounterClockWiseSideOrientation",e))(Ai||{}),It=(e=>(e[e.PLANE=0]="PLANE",e[e.DEPTH=1]="DEPTH",e[e.NONE=2]="NONE",e))(It||{});const Le=m.createContext(void 0),Oo=m.createContext({viewCamera:void 0,setViewCamera:()=>{},cameraRefObject:void 0}),Lt=m.createContext({colorIDs:{},colorCodecs:{}}),Vn=m.createContext(null);var Ao=(e=>(e[e.ENGINE_DEFAULT=0]="ENGINE_DEFAULT",e[e.NONE=1]="NONE",e))(Ao||{});const Mo=m.createContext({onPreFetch:e=>new Promise(t=>{t(e)}),onFinish:()=>{console.log("Loaded")},onProgress:(e,t)=>{console.log(`Loading ${e}/${t}`)},useLoadingScreen:1,hideLoadingWhenPostCalculate:!0}),Mi=m.createContext(null),Ts=(e,t)=>{var ge,H,Q,Ee,ke;const{children:n,workspaceMeta:a={max:new u.Vector3(Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER),min:new u.Vector3(Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER),scaleDepth:1,scalePlane:1,origin:u.Vector3.Zero(),_isDefault:!0},colorProvider:i={colorIDs:{},colorCodecs:{}},cacheProvider:o={onPreFetch:te=>new Promise(me=>{me(te)}),onFinish:()=>{console.log("Loaded")},onProgress:(te,me)=>{console.log(`Loading ${te} of ${me}`)},useLoadingScreen:1}}=e,r=_e.useScene(),l=_e.useCanvas(),[s,c]=m.useState(void 0),p=m.useRef({}),[f,d]=m.useState({}),x=m.useRef(0),h=m.useRef(0),T=m.useRef(new Set),P=m.useRef(new Map),v=m.useRef({lastReportedLoaded:-1,lastReportedTotal:-1}),[,_]=m.useState(0),b=m.useRef(null),k=m.useRef(null),M=m.useRef(!1),w=m.useRef(null),S=m.useRef([]),N=m.useRef(null),F=m.useRef(0),B=m.useRef(new WeakMap),I=m.useRef(1),D=m.useRef(new Map),E=m.useRef(0),L=m.useRef({isDown:!1,pointerId:-1,startX:0,startY:0,isDragging:!1});m.useEffect(()=>{if(i.colorCodecs){console.log("[Geo3DViewer] 开始色标刷新");const te={};if(Object.keys(i.colorCodecs).forEach(ue=>{console.log(`[Geo3DViewer] 正在生成色标 ${ue}`);const pe=i.colorCodecs[ue],Ne=new Uint8Array(pe.array.length*4);pe.array.forEach((Ie,we)=>{Ne[we*4+0]=Math.trunc(Ie.r*255),Ne[we*4+1]=Math.trunc(Ie.g*255),Ne[we*4+2]=Math.trunc(Ie.b*255),Ne[we*4+3]=255}),console.log(`[Geo3DViewer] 正在创建色标采样贴图 ${ue}`);const be=u.RawTexture.CreateRGBATexture(Ne,1,pe.array.length,r,!0,!1);be.name=`color-codec-${ue}`,console.log(`[Geo3DViewer] 正在创建色标图例 ${ue}`);const Ae=URL.createObjectURL(new Blob([xs.encode([Ne.buffer],1,pe.array.length,0)]));console.log(`[Geo3DViewer] 正在构建色标 ${ue}`),te[ue]={blobUrl:Ae,min:pe.min,max:pe.max,texture:be}}),r){console.log(`[Geo3DViewer] 正在移除原有色标 共 ${Object.keys(p.current).length} 个`),Object.keys(p.current).forEach(pe=>{console.log(`[Geo3DViewer] 正在移除色标 ${pe}`),r.removeTexture(p.current[pe].texture),p.current[pe].texture.dispose(),URL.revokeObjectURL(p.current[pe].blobUrl)}),p.current=te;const ue=r.getMaterialByTags("remap");console.log("[Geo3DViewer] 已完成色标刷新,正在更新关联的材质"),ue.forEach(pe=>{pe instanceof u.ShaderMaterial?pe.setTexture("textureSampler",te[pe.metadata.colorCodec].texture):(pe.getBlockByName("RemappedTexture").texture=te[pe.metadata.colorCodec].texture,pe.markAsDirty(u.NodeMaterial.TextureDirtyFlag))}),console.log(`[Geo3DViewer] 已有 ${ue.length} 个材质执行了更新`)}}},[i.colorCodecs,r]);const y=m.useCallback(te=>!te||te.isDisposed()||!te.metadata||!("pickable"in te.metadata)||!te.metadata.pickable?null:te.metadata.pickable,[]),A=m.useCallback(te=>!!(te&&(te.onHover||te.onLeftClick||te.onMiddleClick||te.onRightClick)),[]),V=m.useCallback(te=>{if(l){if(te&&(te.onLeftClick||te.onMiddleClick||te.onRightClick)){l.style.setProperty("cursor","pointer");return}l.style.setProperty("cursor","default")}},[l]),$=m.useCallback(()=>{var me;const te=(me=k.current)==null?void 0:me._pickingTexture;b.current!==(te!=null?te:null)&&(b.current=te!=null?te:null,_(ue=>ue+1))},[]),W=m.useCallback(te=>{const me=B.current.get(te);if(me)return me;const ue=I.current++;return B.current.set(te,ue),ue},[]),ne=m.useCallback(()=>{const te=[],me=new Set;if(!r)return te;r.meshes.forEach(pe=>{if(!pe||pe.isDisposed())return;const Ne=y(pe);if(!(!(A(Ne)&&pe.isEnabled()&&pe.isVisible&&pe.isReady(!0)&&pe.isPickable)||me.has(pe))&&(me.add(pe),te.push(pe),pe.isAnInstance)){const Ae=pe.sourceMesh;Ae&&!Ae.isDisposed()&&Ae.isEnabled()&&Ae.isVisible&&Ae.isReady(!0)&&!me.has(Ae)&&(me.add(Ae),te.push(Ae))}});const ue=S.current.length===te.length&&S.current.every((pe,Ne)=>pe===te[Ne]);return k.current||(k.current=new Pi.GPUPicker),k.current.defaultRenderMaterial&&(k.current.defaultRenderMaterial.backFaceCulling=!1),ue||(k.current.setPickingList(te.length>0?te.slice():null),k.current.defaultRenderMaterial&&(k.current.defaultRenderMaterial.backFaceCulling=!1),S.current=te,$()),te},[y,A,r,$]),ee=m.useCallback(async(te,me)=>{if(!r)return null;if(!ne().length||!k.current)return $(),null;$();const pe=await k.current.pickAsync(te,me,!1);return $(),pe},[r,ne,$]);m.useEffect(()=>{if(!r)return;const te=r.onBeforeRenderObservable.add(()=>{ne()});return()=>{r.onBeforeRenderObservable.remove(te)}},[r,ne]);const G=m.useCallback((te,me,ue)=>r?r.pick(me,ue,pe=>pe===te,!1,void 0):null,[r]),le=m.useCallback(()=>{F.current+=1,D.current.clear()},[]),re=m.useCallback(te=>new Proxy({},{get:(me,ue)=>{const pe=te();if(!pe)return;const Ne=pe[ue];return typeof Ne=="function"?Ne.bind(pe):Ne},set:(me,ue,pe)=>{const Ne=te();return Ne?(Ne[ue]=pe,!0):!1},has:(me,ue)=>{const pe=te();return pe?ue in pe:!1},ownKeys:()=>{const me=te();return me?Reflect.ownKeys(me):[]},getOwnPropertyDescriptor:(me,ue)=>{const pe=te();if(pe)return Object.getOwnPropertyDescriptor(pe,ue)}}),[]),oe=m.useCallback((te,me,ue)=>{const pe=F.current,Ne=W(te),be=`${pe}:${Ne}:${Math.round(me)}:${Math.round(ue)}`,Ae=()=>{var Be,Ge,Ke;const Ie=D.current.get(be);if(Ie)return Ie;const we=G(te,me,ue),Re=(Be=we==null?void 0:we.pickedPoint)!=null?Be:null,Ve=(Ke=Re==null?void 0:Re.add((Ge=a.origin)!=null?Ge:u.Vector3.Zero()))!=null?Ke:null,Ue={raw:Re,world:Ve};return D.current.set(be,Ue),Ue};return{rawWorldPosition:re(()=>Ae().raw),worldPosition:re(()=>Ae().world)}},[re,W,G,a.origin]),Y=m.useCallback((te,me,ue,pe,Ne)=>{var Re,Ve;const be=y(te);if(!be||!be.onHover)return;const Ae=new u.Vector2(ue.clientX,ue.clientY),Ie=me!==yn.END&&be.needWorldPosition?oe(te,pe,Ne):null,we=be.valueCallback?be.valueCallback(Ae,(Re=Ie==null?void 0:Ie.worldPosition)!=null?Re:null,(Ve=Ie==null?void 0:Ie.rawWorldPosition)!=null?Ve:null):null;be.onHover(be.name,Ae,Ie==null?void 0:Ie.worldPosition,me,we,be.extra)},[oe,y]),ce=m.useCallback((te,me)=>{const ue=te&&y(te)&&A(y(te))?te:null,pe=w.current;pe&&pe!==ue&&Y(pe,yn.END,me.event,me.x,me.y),ue&&Y(ue,pe===ue?yn.CONTINUE:yn.START,me.event,me.x,me.y),w.current=ue,V(ue?y(ue):null)},[y,A,Y,V]),ae=m.useCallback(async()=>{var te;if(!M.current){for(M.current=!0;N.current;){const me=N.current;if(N.current=null,!r||r.skipPointerMovePicking){ce(null,me);continue}const ue=await ee(me.x,me.y),pe=(te=ue==null?void 0:ue.mesh)!=null?te:null;if(le(),r.skipPointerMovePicking){ce(null,me);continue}ce(pe,me)}M.current=!1}},[le,ee,r,ce]),X=m.useCallback(async(te,me,ue)=>{var Re;if(!r)return;for(;M.current;)await new Promise(Ve=>setTimeout(Ve,8));if(Date.now()-E.current<100){E.current=Date.now();return}E.current=Date.now();const pe=await ee(me,ue);le();const Ne=(Re=pe==null?void 0:pe.mesh)!=null?Re:null,be=y(Ne);if(console.log(`[Geo3DViewer] 指针拾取 ${!!Ne} 于面 ${Ne}`,be,pe),!Ne||!be)return;const Ae=new u.Vector2(te.clientX,te.clientY),Ie=oe(Ne,me,ue),we=be.valueCallback?be.valueCallback(Ae,Ie.worldPosition,Ie.rawWorldPosition):null;if(te.button===0&&be.onLeftClick){be.onLeftClick(be.name,Ae,Ie.worldPosition,we,be.extra);return}if(te.button===1&&be.onMiddleClick){be.onMiddleClick(be.name,Ae,Ie.worldPosition,we,be.extra);return}te.button===2&&be.onRightClick&&be.onRightClick(be.name,Ae,Ie.worldPosition,we,be.extra)},[le,oe,y,ee,r]);m.useEffect(()=>{if(r)return r.skipPointerDownPicking=!0,r.skipPointerUpPicking=!0,()=>{r.skipPointerDownPicking=!1,r.skipPointerUpPicking=!1}},[r]),m.useEffect(()=>{if(!r)return;const te=4,me=r.onPointerObservable.add(ue=>{const pe=ue.event;if(ue.type===u.PointerEventTypes.POINTERDOWN){L.current.isDown=!0,L.current.pointerId=pe.pointerId,L.current.startX=r.pointerX,L.current.startY=r.pointerY,L.current.isDragging=!1;return}if(ue.type===u.PointerEventTypes.POINTERMOVE){if(L.current.isDown&&L.current.pointerId===pe.pointerId&&!L.current.isDragging){const Ne=r.pointerX-L.current.startX,be=r.pointerY-L.current.startY;Ne*Ne+be*be>=te*te&&(L.current.isDragging=!0)}if(r.skipPointerMovePicking||L.current.isDragging){w.current&&ce(null,{event:pe,x:r.pointerX,y:r.pointerY});return}N.current={event:pe,x:r.pointerX,y:r.pointerY},ae();return}if(ue.type===u.PointerEventTypes.POINTERUP){const Ne=L.current.isDragging;if(L.current.isDown=!1,L.current.pointerId=-1,L.current.isDragging=!1,r.skipPointerMovePicking||Ne)return;X(pe,r.pointerX,r.pointerY)}});return()=>{r.onPointerObservable.remove(me),N.current=null,w.current=null,L.current.isDown=!1,L.current.pointerId=-1,L.current.isDragging=!1,V(null)}},[X,ae,r,V,ce]),m.useEffect(()=>()=>{var te;N.current=null,S.current=[],w.current=null,D.current.clear(),(te=k.current)==null||te.dispose(),k.current=null,b.current=null},[]);const Pe=m.useRef(void 0);return m.useImperativeHandle(t,()=>r,[r]),C.jsx(Le.Provider,{value:{min:(ge=a.min)!=null?ge:new u.Vector3(Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER),max:(H=a.max)!=null?H:new u.Vector3(Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER),scaleDepth:(Q=a.scaleDepth)!=null?Q:1,scalePlane:(Ee=a.scalePlane)!=null?Ee:1,_isDefault:(ke=a._isDefault)!=null?ke:!0,origin:u.Vector3.Zero()},children:C.jsx(Oo.Provider,{value:{viewCamera:s,setViewCamera:c,cameraRefObject:Pe},children:C.jsx(Mo.Provider,{value:o,children:C.jsxs(Lo.Provider,{value:{cache:f,setCache:d,loadedCount:h,totalCount:x,pending:T,inflight:P,reported:v},children:[C.jsx(Es,{}),C.jsx(Vn.Provider,{value:{colorCodecsImage:p},children:C.jsx(Lt.Provider,{value:i,children:C.jsx(Mi.Provider,{value:{gpuPickingTexture:b},children:n})})})]})})})})},bs=m.forwardRef(Ts),ks=new TextDecoder;var Me=(e=>(e[e.URL_PREFIX_MATCH=0]="URL_PREFIX_MATCH",e[e.EXACTLY_MATCH=1]="EXACTLY_MATCH",e))(Me||{}),Li=(e=>(e[e.BINARY=0]="BINARY",e[e.TEXTURE=1]="TEXTURE",e[e.MODEL=2]="MODEL",e[e.JSON=3]="JSON",e))(Li||{});const $n=({url:e,cacheType:t=0,assetType:n=0})=>{var M,w,S,N,F,B;const a=_e.useScene(),{onPreFetch:i}=m.useContext(Mo),o=m.useContext(Lo),r=m.useRef(0),l=m.useRef(0),s=m.useRef(new Set),c=m.useRef(new Map),[p,f]=m.useState(void 0),d=(M=o==null?void 0:o.cache)!=null?M:{},x=(w=o==null?void 0:o.setCache)!=null?w:()=>{},h=(S=o==null?void 0:o.loadedCount)!=null?S:l,T=(N=o==null?void 0:o.totalCount)!=null?N:r,P=(F=o==null?void 0:o.pending)!=null?F:s,v=(B=o==null?void 0:o.inflight)!=null?B:c,_=m.useCallback(async I=>{let D=1,E;for(;D>=0;)try{return(await Ut.get(I,{responseType:"arraybuffer",timeout:2e4})).data}catch(L){E=L,D-=1,D>=0&&await new Promise(y=>setTimeout(y,300))}throw E},[]),b=m.useCallback((I,D)=>{if(I){if(D===1)return d[I];if(D===0){const E=I.split("?")[0];return d[E]}}},[d]),k=m.useCallback(async(I,D,E)=>{const L=v.current.get(I);if(L){const A=await L;A&&f(A);return}const y=(async()=>{P.current.add(I),T.current=T.current+1;try{const A=await i(I),V=[];A!==I&&V.push(I),D===0?(V.push(A.split("?")[0]),V.push(A)):D===1&&V.push(A);const $=await _(A),W={};let ne;if(E===0)ne={buffer:$};else if(E===1){const ee=URL.createObjectURL(new Blob([$])),G=new u.Texture(ee,a,!0,!1,void 0,()=>{URL.revokeObjectURL(ee)},()=>{URL.revokeObjectURL(ee)});ne={buffer:$,texture:G}}else if(E===2){if(!a)throw new Error("Scene not ready for model loading");const ee=URL.createObjectURL(new Blob([$]));try{let G=A.split("?")[0];G=(G==null?void 0:G.split(".").pop())||"";const le=await u.LoadAssetContainerAsync(ee,a,{pluginExtension:`.${G}`});ne={buffer:$,assets:le}}finally{URL.revokeObjectURL(ee)}}else ne={buffer:$,json:JSON.parse(ks.decode($))};return V.forEach(ee=>{W[ee]=ne}),x(ee=>{let G=!1;const le={...ee};return V.forEach(re=>{le[re]||(le[re]=ne,G=!0)}),G?le:ee}),h.current=h.current+1,f(ne),ne}catch(A){console.error(A),h.current=h.current+1;return}finally{P.current.delete(I),v.current.delete(I)}})();v.current.set(I,y),await y},[_,i,v,h,P,x,T,a]);return m.useEffect(()=>{if(e){const I=b(e,t);if(I){f(I);return}P.current.has(e)||k(e,t,n)}},[n,t,k,b,P,e]),p},je=({url:e,cacheType:t=0})=>{const n=$n({url:e,cacheType:t,assetType:0}),[a,i]=m.useState(void 0);return m.useEffect(()=>{i(o=>(n==null?void 0:n.buffer)!==o?n==null?void 0:n.buffer:o)},[n]),a},He=({url:e,cacheType:t=0})=>{const n=$n({url:e,cacheType:t,assetType:1}),[a,i]=m.useState(void 0);return m.useEffect(()=>{i(o=>{if((n==null?void 0:n.texture)!==o){const r=n==null?void 0:n.texture;if(r)return r.hasAlpha=!0,r}return o})},[n]),a},Ri=({url:e,cacheType:t=0})=>{const n=$n({url:e,cacheType:t,assetType:2}),[a,i]=m.useState(void 0);return m.useEffect(()=>{i(o=>(n==null?void 0:n.assets)!==o?n==null?void 0:n.assets:o)},[n]),a},Lo=m.createContext(void 0),Es=()=>{var b,k,M,w;const e=_e.useScene(),t=_e.useEngine(),{onFinish:n,onProgress:a,useLoadingScreen:i,hideLoadingWhenPostCalculate:o}=m.useContext(Mo),r=m.useContext(Lo),l=m.useRef(0),s=m.useRef(0),c=m.useRef({lastReportedLoaded:-1,lastReportedTotal:-1}),p=m.useRef([]),f=(b=r==null?void 0:r.totalCount)!=null?b:l,d=(k=r==null?void 0:r.loadedCount)!=null?k:s,x=(M=r==null?void 0:r.reported)!=null?M:c,h=(w=r==null?void 0:r.pending)!=null?w:p,T=m.useRef(null),P=Array.isArray(h.current)?h.current.length:h.current.size,v=m.useCallback(S=>{i===Ao.ENGINE_DEFAULT&&t&&(S?(T.current&&(clearTimeout(T.current),T.current=null),console.log("[Geo3DViewer] 显示加载界面"),t.displayLoadingUI()):T.current=setTimeout(()=>{console.log("[Geo3DViewer] 隐藏加载界面"),t.hideLoadingUI()},100))},[i,t]),_=m.useCallback(()=>{if(e&&x&&x.current){if(x.current.lastReportedLoaded!=d.current||x.current.lastReportedTotal!=f.current||P>0){console.log("[Geo3DViewer] 加载进度",d.current,f.current,P,"使用 Post 加载器",o,e.getMeshesByTags("loading").length+e.getTransformNodesByTags("loading").length);const S=a||(()=>{}),N=n||(()=>{});d.current<f.current||P>0||o&&e.getMeshesByTags("loading").length+e.getTransformNodesByTags("loading").length>0?(console.log("[Geo3DViewer] 加载进度",d.current,f.current),S(d.current,f.current),v(!0)):o?e.getMeshesByTags("loading").length+e.getTransformNodesByTags("loading").length===0&&(N(),v(!1)):d.current===f.current&&(N(),v(!1))}x.current.lastReportedLoaded=d.current,x.current.lastReportedTotal=f.current}},[x,d,f,a,h,v,o,e,n]);return m.useEffect(()=>{_();const S=setInterval(()=>{_()},1e3);return()=>clearInterval(S)},[_]),C.jsx(C.Fragment,{})},Ns=({url:e,cacheType:t,assetType:n=Li.BINARY})=>($n({url:e,cacheType:t,assetType:n}),C.jsx(C.Fragment,{}));class Is{constructor(t){ve(this,"_nodes",[]);ve(this,"_speed",1);ve(this,"_loop",!1);ve(this,"_length",0);ve(this,"_name","");ve(this,"_stop",!1);ve(this,"_handler");ve(this,"_normalizedTime",0);ve(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 Bi={},uo={},ws=Os;function Os(e,t){for(var n=new Array(arguments.length-1),a=0,i=2,o=!0;i<arguments.length;)n[a++]=arguments[i++];return new Promise(function(l,s){n[a]=function(p){if(o)if(o=!1,p)s(p);else{for(var f=new Array(arguments.length-1),d=0;d<f.length;)f[d++]=arguments[d];l.apply(null,f)}};try{e.apply(t||null,n)}catch(c){o&&(o=!1,s(c))}})}var Fi={};(function(e){var t=e;t.length=function(l){var s=l.length;if(!s)return 0;for(var c=0;--s%4>1&&l.charAt(s)==="=";)++c;return Math.ceil(l.length*3)/4-c};for(var n=new Array(64),a=new Array(123),i=0;i<64;)a[n[i]=i<26?i+65:i<52?i+71:i<62?i-4:i-59|43]=i++;t.encode=function(l,s,c){for(var p=null,f=[],d=0,x=0,h;s<c;){var T=l[s++];switch(x){case 0:f[d++]=n[T>>2],h=(T&3)<<4,x=1;break;case 1:f[d++]=n[h|T>>4],h=(T&15)<<2,x=2;break;case 2:f[d++]=n[h|T>>6],f[d++]=n[T&63],x=0;break}d>8191&&((p||(p=[])).push(String.fromCharCode.apply(String,f)),d=0)}return x&&(f[d++]=n[h],f[d++]=61,x===1&&(f[d++]=61)),p?(d&&p.push(String.fromCharCode.apply(String,f.slice(0,d))),p.join("")):String.fromCharCode.apply(String,f.slice(0,d))};var o="invalid encoding";t.decode=function(l,s,c){for(var p=c,f=0,d,x=0;x<l.length;){var h=l.charCodeAt(x++);if(h===61&&f>1)break;if((h=a[h])===void 0)throw Error(o);switch(f){case 0:d=h,f=1;break;case 1:s[c++]=d<<2|(h&48)>>4,d=h,f=2;break;case 2:s[c++]=(d&15)<<4|(h&60)>>2,d=h,f=3;break;case 3:s[c++]=(d&3)<<6|h,f=0;break}}if(f===1)throw Error(o);return c-p},t.test=function(l){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(l)}})(Fi);var As=Wn;function Wn(){this._listeners=Object.create(null)}Wn.prototype.on=function(t,n,a){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:n,ctx:a||this}),this};Wn.prototype.off=function(t,n){if(t===void 0)this._listeners=Object.create(null);else if(n===void 0)this._listeners[t]=[];else{var a=this._listeners[t];if(!a)return this;for(var i=0;i<a.length;)a[i].fn===n?a.splice(i,1):++i}return this};Wn.prototype.emit=function(t){var n=this._listeners[t];if(n){for(var a=[],i=1;i<arguments.length;)a.push(arguments[i++]);for(i=0;i<n.length;)n[i].fn.apply(n[i++].ctx,a)}return this};var Ms=hr(hr);function hr(e){return typeof Float32Array!="undefined"?function(){var t=new Float32Array([-0]),n=new Uint8Array(t.buffer),a=n[3]===128;function i(s,c,p){t[0]=s,c[p]=n[0],c[p+1]=n[1],c[p+2]=n[2],c[p+3]=n[3]}function o(s,c,p){t[0]=s,c[p]=n[3],c[p+1]=n[2],c[p+2]=n[1],c[p+3]=n[0]}e.writeFloatLE=a?i:o,e.writeFloatBE=a?o:i;function r(s,c){return n[0]=s[c],n[1]=s[c+1],n[2]=s[c+2],n[3]=s[c+3],t[0]}function l(s,c){return n[3]=s[c],n[2]=s[c+1],n[1]=s[c+2],n[0]=s[c+3],t[0]}e.readFloatLE=a?r:l,e.readFloatBE=a?l:r}():function(){function t(a,i,o,r){var l=i<0?1:0;if(l&&(i=-i),i===0)a(1/i>0?0:2147483648,o,r);else if(isNaN(i))a(2143289344,o,r);else if(i>34028234663852886e22)a((l<<31|2139095040)>>>0,o,r);else if(i<11754943508222875e-54)a((l<<31|Math.round(i/1401298464324817e-60))>>>0,o,r);else{var s=Math.floor(Math.log(i)/Math.LN2),c=Math.round(i*Math.pow(2,-s)*8388608)&8388607;a((l<<31|s+127<<23|c)>>>0,o,r)}}e.writeFloatLE=t.bind(null,mr),e.writeFloatBE=t.bind(null,gr);function n(a,i,o){var r=a(i,o),l=(r>>31)*2+1,s=r>>>23&255,c=r&8388607;return s===255?c?NaN:l*(1/0):s===0?l*1401298464324817e-60*c:l*Math.pow(2,s-150)*(c+8388608)}e.readFloatLE=n.bind(null,vr),e.readFloatBE=n.bind(null,xr)}(),typeof Float64Array!="undefined"?function(){var t=new Float64Array([-0]),n=new Uint8Array(t.buffer),a=n[7]===128;function i(s,c,p){t[0]=s,c[p]=n[0],c[p+1]=n[1],c[p+2]=n[2],c[p+3]=n[3],c[p+4]=n[4],c[p+5]=n[5],c[p+6]=n[6],c[p+7]=n[7]}function o(s,c,p){t[0]=s,c[p]=n[7],c[p+1]=n[6],c[p+2]=n[5],c[p+3]=n[4],c[p+4]=n[3],c[p+5]=n[2],c[p+6]=n[1],c[p+7]=n[0]}e.writeDoubleLE=a?i:o,e.writeDoubleBE=a?o:i;function r(s,c){return n[0]=s[c],n[1]=s[c+1],n[2]=s[c+2],n[3]=s[c+3],n[4]=s[c+4],n[5]=s[c+5],n[6]=s[c+6],n[7]=s[c+7],t[0]}function l(s,c){return n[7]=s[c],n[6]=s[c+1],n[5]=s[c+2],n[4]=s[c+3],n[3]=s[c+4],n[2]=s[c+5],n[1]=s[c+6],n[0]=s[c+7],t[0]}e.readDoubleLE=a?r:l,e.readDoubleBE=a?l:r}():function(){function t(a,i,o,r,l,s){var c=r<0?1:0;if(c&&(r=-r),r===0)a(0,l,s+i),a(1/r>0?0:2147483648,l,s+o);else if(isNaN(r))a(0,l,s+i),a(2146959360,l,s+o);else if(r>17976931348623157e292)a(0,l,s+i),a((c<<31|2146435072)>>>0,l,s+o);else{var p;if(r<22250738585072014e-324)p=r/5e-324,a(p>>>0,l,s+i),a((c<<31|p/4294967296)>>>0,l,s+o);else{var f=Math.floor(Math.log(r)/Math.LN2);f===1024&&(f=1023),p=r*Math.pow(2,-f),a(p*4503599627370496>>>0,l,s+i),a((c<<31|f+1023<<20|p*1048576&1048575)>>>0,l,s+o)}}}e.writeDoubleLE=t.bind(null,mr,0,4),e.writeDoubleBE=t.bind(null,gr,4,0);function n(a,i,o,r,l){var s=a(r,l+i),c=a(r,l+o),p=(c>>31)*2+1,f=c>>>20&2047,d=4294967296*(c&1048575)+s;return f===2047?d?NaN:p*(1/0):f===0?p*5e-324*d:p*Math.pow(2,f-1075)*(d+4503599627370496)}e.readDoubleLE=n.bind(null,vr,0,4),e.readDoubleBE=n.bind(null,xr,4,0)}(),e}function mr(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 gr(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 vr(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function xr(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}var Ls=Rs;function Rs(e){try{if(typeof Po!="function")return null;var t=Po(e);return t&&(t.length||Object.keys(t).length)?t:null}catch(n){return null}}var Di={};(function(e){var t=e,n="�";t.length=function(i){for(var o=0,r=0,l=0;l<i.length;++l)r=i.charCodeAt(l),r<128?o+=1:r<2048?o+=2:(r&64512)===55296&&(i.charCodeAt(l+1)&64512)===56320?(++l,o+=4):o+=3;return o},t.read=function(i,o,r){if(r-o<1)return"";for(var l="",s=o;s<r;){var c=i[s++];if(c<=127)l+=String.fromCharCode(c);else if(c>=192&&c<224){var p=(c&31)<<6|i[s++]&63;l+=p>=128?String.fromCharCode(p):n}else if(c>=224&&c<240){var f=(c&15)<<12|(i[s++]&63)<<6|i[s++]&63;l+=f>=2048?String.fromCharCode(f):n}else if(c>=240){var d=(c&7)<<18|(i[s++]&63)<<12|(i[s++]&63)<<6|i[s++]&63;d<65536||d>1114111?l+=n:(d-=65536,l+=String.fromCharCode(55296+(d>>10)),l+=String.fromCharCode(56320+(d&1023)))}}return l},t.write=function(i,o,r){for(var l=r,s,c,p=0;p<i.length;++p)s=i.charCodeAt(p),s<128?o[r++]=s:s<2048?(o[r++]=s>>6|192,o[r++]=s&63|128):(s&64512)===55296&&((c=i.charCodeAt(p+1))&64512)===56320?(s=65536+((s&1023)<<10)+(c&1023),++p,o[r++]=s>>18|240,o[r++]=s>>12&63|128,o[r++]=s>>6&63|128,o[r++]=s&63|128):(o[r++]=s>>12|224,o[r++]=s>>6&63|128,o[r++]=s&63|128);return r-l}})(Di);var Bs=Fs;function Fs(e,t,n){var a=n||8192,i=a>>>1,o=null,r=a;return function(s){if(s<1||s>i)return e(s);r+s>a&&(o=e(a),r=0);var c=t.call(o,r,r+=s);return r&7&&(r=(r|7)+1),c}}var fo,yr;function Ds(){if(yr)return fo;yr=1,fo=t;var e=Qt();function t(o,r){this.lo=o>>>0,this.hi=r>>>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(r){if(r===0)return n;var l=r<0;l&&(r=-r);var s=r>>>0,c=(r-s)/4294967296>>>0;return l&&(c=~c>>>0,s=~s>>>0,++s>4294967295&&(s=0,++c>4294967295&&(c=0))),new t(s,c)},t.from=function(r){if(typeof r=="number")return t.fromNumber(r);if(e.isString(r))if(e.Long)r=e.Long.fromString(r);else return t.fromNumber(parseInt(r,10));return r.low||r.high?new t(r.low>>>0,r.high>>>0):n},t.prototype.toNumber=function(r){if(!r&&this.hi>>>31){var l=~this.lo+1>>>0,s=~this.hi>>>0;return l||(s=s+1>>>0),-(l+s*4294967296)}return this.lo+this.hi*4294967296},t.prototype.toLong=function(r){return e.Long?new e.Long(this.lo|0,this.hi|0,!!r):{low:this.lo|0,high:this.hi|0,unsigned:!!r}};var i=String.prototype.charCodeAt;return t.fromHash=function(r){return r===a?n:new t((i.call(r,0)|i.call(r,1)<<8|i.call(r,2)<<16|i.call(r,3)<<24)>>>0,(i.call(r,4)|i.call(r,5)<<8|i.call(r,6)<<16|i.call(r,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 r=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^r)>>>0,this.lo=(this.lo<<1^r)>>>0,this},t.prototype.zzDecode=function(){var r=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^r)>>>0,this.hi=(this.hi>>>1^r)>>>0,this},t.prototype.length=function(){var r=this.lo,l=(this.lo>>>28|this.hi<<4)>>>0,s=this.hi>>>24;return s===0?l===0?r<16384?r<128?1:2:r<2097152?3:4:l<16384?l<128?5:6:l<2097152?7:8:s<128?9:10},fo}var In={exports:{}},Cr;function zs(){return Cr||(Cr=1,function(e,t){(function(n,a){function i(o){return o.default||o}a(t),e.exports=i(t)})(typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:Rt,function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;/**
1
+ "use strict";var rs=Object.defineProperty;var is=(e,t,n)=>t in e?rs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ve=(e,t,n)=>is(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("react/jsx-runtime"),u=require("@babylonjs/core"),Pi=require("@babylonjs/core/Collisions/gpuPicker"),m=require("react"),_e=require("react-babylonjs"),Ut=require("axios"),jn=require("@babylonjs/inspector");require("@babylonjs/core/Engines/Extensions/engine.query");require("@babylonjs/core/Legacy/legacy");const as=require("@babylonjs/loaders/dynamic"),nt=require("@babylonjs/gui"),ss=require("@babylonjs/materials");require("@babylonjs/materials/legacy/legacy-grid");const ls=require("react-dom/client"),Ot=require("./TubeUtil-LB9dC5yJ.cjs");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 cs=require("react-dom");var Rt=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Si(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Po(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 Ti={exports:{}},eo={},er;function Ht(){return er||(er=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 l=i.shift();if(l){if(typeof l!="object")throw new TypeError(l+"must be non-object");for(var s in l)n(l,s)&&(o[s]=l[s])}}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,l,s,c){if(i.subarray&&o.subarray){o.set(i.subarray(l,l+s),c);return}for(var p=0;p<s;p++)o[c+p]=i[l+p]},flattenChunks:function(o){var i,l,s,c,p,f;for(s=0,i=0,l=o.length;i<l;i++)s+=o[i].length;for(f=new Uint8Array(s),c=0,i=0,l=o.length;i<l;i++)p=o[i],f.set(p,c),c+=p.length;return f}},r={arraySet:function(o,i,l,s,c){for(var p=0;p<s;p++)o[c+p]=i[l+p]},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)}(eo)),eo}var jt={},ht={},Zt={},tr;function us(){if(tr)return Zt;tr=1;var e=Ht(),t=4,n=0,a=1,r=2;function o(z){for(var fe=z.length;--fe>=0;)z[fe]=0}var i=0,l=1,s=2,c=3,p=258,f=29,d=256,x=d+1+f,h=30,T=19,P=2*x+1,v=15,_=16,b=7,k=256,M=16,w=17,S=18,N=[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],F=[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],B=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],I=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],D=512,E=new Array((x+2)*2);o(E);var L=new Array(h*2);o(L);var y=new Array(D);o(y);var A=new Array(p-c+1);o(A);var V=new Array(f);o(V);var $=new Array(h);o($);function W(z,fe,he,xe,Z){this.static_tree=z,this.extra_bits=fe,this.extra_base=he,this.elems=xe,this.max_length=Z,this.has_stree=z&&z.length}var ne,ee,G;function le(z,fe){this.dyn_tree=z,this.max_code=0,this.stat_desc=fe}function re(z){return z<256?y[z]:y[256+(z>>>7)]}function oe(z,fe){z.pending_buf[z.pending++]=fe&255,z.pending_buf[z.pending++]=fe>>>8&255}function Y(z,fe,he){z.bi_valid>_-he?(z.bi_buf|=fe<<z.bi_valid&65535,oe(z,z.bi_buf),z.bi_buf=fe>>_-z.bi_valid,z.bi_valid+=he-_):(z.bi_buf|=fe<<z.bi_valid&65535,z.bi_valid+=he)}function ce(z,fe,he){Y(z,he[fe*2],he[fe*2+1])}function ae(z,fe){var he=0;do he|=z&1,z>>>=1,he<<=1;while(--fe>0);return he>>>1}function X(z){z.bi_valid===16?(oe(z,z.bi_buf),z.bi_buf=0,z.bi_valid=0):z.bi_valid>=8&&(z.pending_buf[z.pending++]=z.bi_buf&255,z.bi_buf>>=8,z.bi_valid-=8)}function Pe(z,fe){var he=fe.dyn_tree,xe=fe.max_code,Z=fe.stat_desc.static_tree,ie=fe.stat_desc.has_stree,O=fe.stat_desc.extra_bits,de=fe.stat_desc.extra_base,Se=fe.stat_desc.max_length,g,q,j,R,U,J,Te=0;for(R=0;R<=v;R++)z.bl_count[R]=0;for(he[z.heap[z.heap_max]*2+1]=0,g=z.heap_max+1;g<P;g++)q=z.heap[g],R=he[he[q*2+1]*2+1]+1,R>Se&&(R=Se,Te++),he[q*2+1]=R,!(q>xe)&&(z.bl_count[R]++,U=0,q>=de&&(U=O[q-de]),J=he[q*2],z.opt_len+=J*(R+U),ie&&(z.static_len+=J*(Z[q*2+1]+U)));if(Te!==0){do{for(R=Se-1;z.bl_count[R]===0;)R--;z.bl_count[R]--,z.bl_count[R+1]+=2,z.bl_count[Se]--,Te-=2}while(Te>0);for(R=Se;R!==0;R--)for(q=z.bl_count[R];q!==0;)j=z.heap[--g],!(j>xe)&&(he[j*2+1]!==R&&(z.opt_len+=(R-he[j*2+1])*he[j*2],he[j*2+1]=R),q--)}}function ge(z,fe,he){var xe=new Array(v+1),Z=0,ie,O;for(ie=1;ie<=v;ie++)xe[ie]=Z=Z+he[ie-1]<<1;for(O=0;O<=fe;O++){var de=z[O*2+1];de!==0&&(z[O*2]=ae(xe[de]++,de))}}function H(){var z,fe,he,xe,Z,ie=new Array(v+1);for(he=0,xe=0;xe<f-1;xe++)for(V[xe]=he,z=0;z<1<<N[xe];z++)A[he++]=xe;for(A[he-1]=xe,Z=0,xe=0;xe<16;xe++)for($[xe]=Z,z=0;z<1<<F[xe];z++)y[Z++]=xe;for(Z>>=7;xe<h;xe++)for($[xe]=Z<<7,z=0;z<1<<F[xe]-7;z++)y[256+Z++]=xe;for(fe=0;fe<=v;fe++)ie[fe]=0;for(z=0;z<=143;)E[z*2+1]=8,z++,ie[8]++;for(;z<=255;)E[z*2+1]=9,z++,ie[9]++;for(;z<=279;)E[z*2+1]=7,z++,ie[7]++;for(;z<=287;)E[z*2+1]=8,z++,ie[8]++;for(ge(E,x+1,ie),z=0;z<h;z++)L[z*2+1]=5,L[z*2]=ae(z,5);ne=new W(E,N,d+1,x,v),ee=new W(L,F,0,h,v),G=new W(new Array(0),B,0,T,b)}function Q(z){var fe;for(fe=0;fe<x;fe++)z.dyn_ltree[fe*2]=0;for(fe=0;fe<h;fe++)z.dyn_dtree[fe*2]=0;for(fe=0;fe<T;fe++)z.bl_tree[fe*2]=0;z.dyn_ltree[k*2]=1,z.opt_len=z.static_len=0,z.last_lit=z.matches=0}function Ee(z){z.bi_valid>8?oe(z,z.bi_buf):z.bi_valid>0&&(z.pending_buf[z.pending++]=z.bi_buf),z.bi_buf=0,z.bi_valid=0}function ke(z,fe,he,xe){Ee(z),oe(z,he),oe(z,~he),e.arraySet(z.pending_buf,z.window,fe,he,z.pending),z.pending+=he}function te(z,fe,he,xe){var Z=fe*2,ie=he*2;return z[Z]<z[ie]||z[Z]===z[ie]&&xe[fe]<=xe[he]}function me(z,fe,he){for(var xe=z.heap[he],Z=he<<1;Z<=z.heap_len&&(Z<z.heap_len&&te(fe,z.heap[Z+1],z.heap[Z],z.depth)&&Z++,!te(fe,xe,z.heap[Z],z.depth));)z.heap[he]=z.heap[Z],he=Z,Z<<=1;z.heap[he]=xe}function ue(z,fe,he){var xe,Z,ie=0,O,de;if(z.last_lit!==0)do xe=z.pending_buf[z.d_buf+ie*2]<<8|z.pending_buf[z.d_buf+ie*2+1],Z=z.pending_buf[z.l_buf+ie],ie++,xe===0?ce(z,Z,fe):(O=A[Z],ce(z,O+d+1,fe),de=N[O],de!==0&&(Z-=V[O],Y(z,Z,de)),xe--,O=re(xe),ce(z,O,he),de=F[O],de!==0&&(xe-=$[O],Y(z,xe,de)));while(ie<z.last_lit);ce(z,k,fe)}function pe(z,fe){var he=fe.dyn_tree,xe=fe.stat_desc.static_tree,Z=fe.stat_desc.has_stree,ie=fe.stat_desc.elems,O,de,Se=-1,g;for(z.heap_len=0,z.heap_max=P,O=0;O<ie;O++)he[O*2]!==0?(z.heap[++z.heap_len]=Se=O,z.depth[O]=0):he[O*2+1]=0;for(;z.heap_len<2;)g=z.heap[++z.heap_len]=Se<2?++Se:0,he[g*2]=1,z.depth[g]=0,z.opt_len--,Z&&(z.static_len-=xe[g*2+1]);for(fe.max_code=Se,O=z.heap_len>>1;O>=1;O--)me(z,he,O);g=ie;do O=z.heap[1],z.heap[1]=z.heap[z.heap_len--],me(z,he,1),de=z.heap[1],z.heap[--z.heap_max]=O,z.heap[--z.heap_max]=de,he[g*2]=he[O*2]+he[de*2],z.depth[g]=(z.depth[O]>=z.depth[de]?z.depth[O]:z.depth[de])+1,he[O*2+1]=he[de*2+1]=g,z.heap[1]=g++,me(z,he,1);while(z.heap_len>=2);z.heap[--z.heap_max]=z.heap[1],Pe(z,fe),ge(he,Se,z.bl_count)}function Ne(z,fe,he){var xe,Z=-1,ie,O=fe[0*2+1],de=0,Se=7,g=4;for(O===0&&(Se=138,g=3),fe[(he+1)*2+1]=65535,xe=0;xe<=he;xe++)ie=O,O=fe[(xe+1)*2+1],!(++de<Se&&ie===O)&&(de<g?z.bl_tree[ie*2]+=de:ie!==0?(ie!==Z&&z.bl_tree[ie*2]++,z.bl_tree[M*2]++):de<=10?z.bl_tree[w*2]++:z.bl_tree[S*2]++,de=0,Z=ie,O===0?(Se=138,g=3):ie===O?(Se=6,g=3):(Se=7,g=4))}function be(z,fe,he){var xe,Z=-1,ie,O=fe[0*2+1],de=0,Se=7,g=4;for(O===0&&(Se=138,g=3),xe=0;xe<=he;xe++)if(ie=O,O=fe[(xe+1)*2+1],!(++de<Se&&ie===O)){if(de<g)do ce(z,ie,z.bl_tree);while(--de!==0);else ie!==0?(ie!==Z&&(ce(z,ie,z.bl_tree),de--),ce(z,M,z.bl_tree),Y(z,de-3,2)):de<=10?(ce(z,w,z.bl_tree),Y(z,de-3,3)):(ce(z,S,z.bl_tree),Y(z,de-11,7));de=0,Z=ie,O===0?(Se=138,g=3):ie===O?(Se=6,g=3):(Se=7,g=4)}}function Ae(z){var fe;for(Ne(z,z.dyn_ltree,z.l_desc.max_code),Ne(z,z.dyn_dtree,z.d_desc.max_code),pe(z,z.bl_desc),fe=T-1;fe>=3&&z.bl_tree[I[fe]*2+1]===0;fe--);return z.opt_len+=3*(fe+1)+5+5+4,fe}function Ie(z,fe,he,xe){var Z;for(Y(z,fe-257,5),Y(z,he-1,5),Y(z,xe-4,4),Z=0;Z<xe;Z++)Y(z,z.bl_tree[I[Z]*2+1],3);be(z,z.dyn_ltree,fe-1),be(z,z.dyn_dtree,he-1)}function we(z){var fe=4093624447,he;for(he=0;he<=31;he++,fe>>>=1)if(fe&1&&z.dyn_ltree[he*2]!==0)return n;if(z.dyn_ltree[9*2]!==0||z.dyn_ltree[10*2]!==0||z.dyn_ltree[13*2]!==0)return a;for(he=32;he<d;he++)if(z.dyn_ltree[he*2]!==0)return a;return n}var Re=!1;function Ve(z){Re||(H(),Re=!0),z.l_desc=new le(z.dyn_ltree,ne),z.d_desc=new le(z.dyn_dtree,ee),z.bl_desc=new le(z.bl_tree,G),z.bi_buf=0,z.bi_valid=0,Q(z)}function Ue(z,fe,he,xe){Y(z,(i<<1)+(xe?1:0),3),ke(z,fe,he)}function Be(z){Y(z,l<<1,3),ce(z,k,E),X(z)}function Ge(z,fe,he,xe){var Z,ie,O=0;z.level>0?(z.strm.data_type===r&&(z.strm.data_type=we(z)),pe(z,z.l_desc),pe(z,z.d_desc),O=Ae(z),Z=z.opt_len+3+7>>>3,ie=z.static_len+3+7>>>3,ie<=Z&&(Z=ie)):Z=ie=he+5,he+4<=Z&&fe!==-1?Ue(z,fe,he,xe):z.strategy===t||ie===Z?(Y(z,(l<<1)+(xe?1:0),3),ue(z,E,L)):(Y(z,(s<<1)+(xe?1:0),3),Ie(z,z.l_desc.max_code+1,z.d_desc.max_code+1,O+1),ue(z,z.dyn_ltree,z.dyn_dtree)),Q(z),xe&&Ee(z)}function Ke(z,fe,he){return z.pending_buf[z.d_buf+z.last_lit*2]=fe>>>8&255,z.pending_buf[z.d_buf+z.last_lit*2+1]=fe&255,z.pending_buf[z.l_buf+z.last_lit]=he&255,z.last_lit++,fe===0?z.dyn_ltree[he*2]++:(z.matches++,fe--,z.dyn_ltree[(A[he]+d+1)*2]++,z.dyn_dtree[re(fe)*2]++),z.last_lit===z.lit_bufsize-1}return Zt._tr_init=Ve,Zt._tr_stored_block=Ue,Zt._tr_flush_block=Ge,Zt._tr_tally=Ke,Zt._tr_align=Be,Zt}var to,nr;function bi(){if(nr)return to;nr=1;function e(t,n,a,r){for(var o=t&65535|0,i=t>>>16&65535|0,l=0;a!==0;){l=a>2e3?2e3:a,a-=l;do o=o+n[r++]|0,i=i+o|0;while(--l);o%=65521,i%=65521}return o|i<<16|0}return to=e,to}var no,or;function ki(){if(or)return no;or=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 l=t,s=i+o;a^=-1;for(var c=i;c<s;c++)a=a>>>8^l[(a^r[c])&255];return a^-1}return no=n,no}var oo,rr;function Ao(){return rr||(rr=1,oo={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"}),oo}var ir;function fs(){if(ir)return ht;ir=1;var e=Ht(),t=us(),n=bi(),a=ki(),r=Ao(),o=0,i=1,l=3,s=4,c=5,p=0,f=1,d=-2,x=-3,h=-5,T=-1,P=1,v=2,_=3,b=4,k=0,M=2,w=8,S=9,N=15,F=8,B=29,I=256,D=I+1+B,E=30,L=19,y=2*D+1,A=15,V=3,$=258,W=$+V+1,ne=32,ee=42,G=69,le=73,re=91,oe=103,Y=113,ce=666,ae=1,X=2,Pe=3,ge=4,H=3;function Q(g,q){return g.msg=r[q],q}function Ee(g){return(g<<1)-(g>4?9:0)}function ke(g){for(var q=g.length;--q>=0;)g[q]=0}function te(g){var q=g.state,j=q.pending;j>g.avail_out&&(j=g.avail_out),j!==0&&(e.arraySet(g.output,q.pending_buf,q.pending_out,j,g.next_out),g.next_out+=j,q.pending_out+=j,g.total_out+=j,g.avail_out-=j,q.pending-=j,q.pending===0&&(q.pending_out=0))}function me(g,q){t._tr_flush_block(g,g.block_start>=0?g.block_start:-1,g.strstart-g.block_start,q),g.block_start=g.strstart,te(g.strm)}function ue(g,q){g.pending_buf[g.pending++]=q}function pe(g,q){g.pending_buf[g.pending++]=q>>>8&255,g.pending_buf[g.pending++]=q&255}function Ne(g,q,j,R){var U=g.avail_in;return U>R&&(U=R),U===0?0:(g.avail_in-=U,e.arraySet(q,g.input,g.next_in,U,j),g.state.wrap===1?g.adler=n(g.adler,q,U,j):g.state.wrap===2&&(g.adler=a(g.adler,q,U,j)),g.next_in+=U,g.total_in+=U,U)}function be(g,q){var j=g.max_chain_length,R=g.strstart,U,J,Te=g.prev_length,ye=g.nice_match,Ce=g.strstart>g.w_size-W?g.strstart-(g.w_size-W):0,Fe=g.window,Tt=g.w_mask,Ye=g.prev,De=g.strstart+$,qe=Fe[R+Te-1],et=Fe[R+Te];g.prev_length>=g.good_match&&(j>>=2),ye>g.lookahead&&(ye=g.lookahead);do if(U=q,!(Fe[U+Te]!==et||Fe[U+Te-1]!==qe||Fe[U]!==Fe[R]||Fe[++U]!==Fe[R+1])){R+=2,U++;do;while(Fe[++R]===Fe[++U]&&Fe[++R]===Fe[++U]&&Fe[++R]===Fe[++U]&&Fe[++R]===Fe[++U]&&Fe[++R]===Fe[++U]&&Fe[++R]===Fe[++U]&&Fe[++R]===Fe[++U]&&Fe[++R]===Fe[++U]&&R<De);if(J=$-(De-R),R=De-$,J>Te){if(g.match_start=q,Te=J,J>=ye)break;qe=Fe[R+Te-1],et=Fe[R+Te]}}while((q=Ye[q&Tt])>Ce&&--j!==0);return Te<=g.lookahead?Te:g.lookahead}function Ae(g){var q=g.w_size,j,R,U,J,Te;do{if(J=g.window_size-g.lookahead-g.strstart,g.strstart>=q+(q-W)){e.arraySet(g.window,g.window,q,q,0),g.match_start-=q,g.strstart-=q,g.block_start-=q,R=g.hash_size,j=R;do U=g.head[--j],g.head[j]=U>=q?U-q:0;while(--R);R=q,j=R;do U=g.prev[--j],g.prev[j]=U>=q?U-q:0;while(--R);J+=q}if(g.strm.avail_in===0)break;if(R=Ne(g.strm,g.window,g.strstart+g.lookahead,J),g.lookahead+=R,g.lookahead+g.insert>=V)for(Te=g.strstart-g.insert,g.ins_h=g.window[Te],g.ins_h=(g.ins_h<<g.hash_shift^g.window[Te+1])&g.hash_mask;g.insert&&(g.ins_h=(g.ins_h<<g.hash_shift^g.window[Te+V-1])&g.hash_mask,g.prev[Te&g.w_mask]=g.head[g.ins_h],g.head[g.ins_h]=Te,Te++,g.insert--,!(g.lookahead+g.insert<V)););}while(g.lookahead<W&&g.strm.avail_in!==0)}function Ie(g,q){var j=65535;for(j>g.pending_buf_size-5&&(j=g.pending_buf_size-5);;){if(g.lookahead<=1){if(Ae(g),g.lookahead===0&&q===o)return ae;if(g.lookahead===0)break}g.strstart+=g.lookahead,g.lookahead=0;var R=g.block_start+j;if((g.strstart===0||g.strstart>=R)&&(g.lookahead=g.strstart-R,g.strstart=R,me(g,!1),g.strm.avail_out===0)||g.strstart-g.block_start>=g.w_size-W&&(me(g,!1),g.strm.avail_out===0))return ae}return g.insert=0,q===s?(me(g,!0),g.strm.avail_out===0?Pe:ge):(g.strstart>g.block_start&&(me(g,!1),g.strm.avail_out===0),ae)}function we(g,q){for(var j,R;;){if(g.lookahead<W){if(Ae(g),g.lookahead<W&&q===o)return ae;if(g.lookahead===0)break}if(j=0,g.lookahead>=V&&(g.ins_h=(g.ins_h<<g.hash_shift^g.window[g.strstart+V-1])&g.hash_mask,j=g.prev[g.strstart&g.w_mask]=g.head[g.ins_h],g.head[g.ins_h]=g.strstart),j!==0&&g.strstart-j<=g.w_size-W&&(g.match_length=be(g,j)),g.match_length>=V)if(R=t._tr_tally(g,g.strstart-g.match_start,g.match_length-V),g.lookahead-=g.match_length,g.match_length<=g.max_lazy_match&&g.lookahead>=V){g.match_length--;do g.strstart++,g.ins_h=(g.ins_h<<g.hash_shift^g.window[g.strstart+V-1])&g.hash_mask,j=g.prev[g.strstart&g.w_mask]=g.head[g.ins_h],g.head[g.ins_h]=g.strstart;while(--g.match_length!==0);g.strstart++}else g.strstart+=g.match_length,g.match_length=0,g.ins_h=g.window[g.strstart],g.ins_h=(g.ins_h<<g.hash_shift^g.window[g.strstart+1])&g.hash_mask;else R=t._tr_tally(g,0,g.window[g.strstart]),g.lookahead--,g.strstart++;if(R&&(me(g,!1),g.strm.avail_out===0))return ae}return g.insert=g.strstart<V-1?g.strstart:V-1,q===s?(me(g,!0),g.strm.avail_out===0?Pe:ge):g.last_lit&&(me(g,!1),g.strm.avail_out===0)?ae:X}function Re(g,q){for(var j,R,U;;){if(g.lookahead<W){if(Ae(g),g.lookahead<W&&q===o)return ae;if(g.lookahead===0)break}if(j=0,g.lookahead>=V&&(g.ins_h=(g.ins_h<<g.hash_shift^g.window[g.strstart+V-1])&g.hash_mask,j=g.prev[g.strstart&g.w_mask]=g.head[g.ins_h],g.head[g.ins_h]=g.strstart),g.prev_length=g.match_length,g.prev_match=g.match_start,g.match_length=V-1,j!==0&&g.prev_length<g.max_lazy_match&&g.strstart-j<=g.w_size-W&&(g.match_length=be(g,j),g.match_length<=5&&(g.strategy===P||g.match_length===V&&g.strstart-g.match_start>4096)&&(g.match_length=V-1)),g.prev_length>=V&&g.match_length<=g.prev_length){U=g.strstart+g.lookahead-V,R=t._tr_tally(g,g.strstart-1-g.prev_match,g.prev_length-V),g.lookahead-=g.prev_length-1,g.prev_length-=2;do++g.strstart<=U&&(g.ins_h=(g.ins_h<<g.hash_shift^g.window[g.strstart+V-1])&g.hash_mask,j=g.prev[g.strstart&g.w_mask]=g.head[g.ins_h],g.head[g.ins_h]=g.strstart);while(--g.prev_length!==0);if(g.match_available=0,g.match_length=V-1,g.strstart++,R&&(me(g,!1),g.strm.avail_out===0))return ae}else if(g.match_available){if(R=t._tr_tally(g,0,g.window[g.strstart-1]),R&&me(g,!1),g.strstart++,g.lookahead--,g.strm.avail_out===0)return ae}else g.match_available=1,g.strstart++,g.lookahead--}return g.match_available&&(R=t._tr_tally(g,0,g.window[g.strstart-1]),g.match_available=0),g.insert=g.strstart<V-1?g.strstart:V-1,q===s?(me(g,!0),g.strm.avail_out===0?Pe:ge):g.last_lit&&(me(g,!1),g.strm.avail_out===0)?ae:X}function Ve(g,q){for(var j,R,U,J,Te=g.window;;){if(g.lookahead<=$){if(Ae(g),g.lookahead<=$&&q===o)return ae;if(g.lookahead===0)break}if(g.match_length=0,g.lookahead>=V&&g.strstart>0&&(U=g.strstart-1,R=Te[U],R===Te[++U]&&R===Te[++U]&&R===Te[++U])){J=g.strstart+$;do;while(R===Te[++U]&&R===Te[++U]&&R===Te[++U]&&R===Te[++U]&&R===Te[++U]&&R===Te[++U]&&R===Te[++U]&&R===Te[++U]&&U<J);g.match_length=$-(J-U),g.match_length>g.lookahead&&(g.match_length=g.lookahead)}if(g.match_length>=V?(j=t._tr_tally(g,1,g.match_length-V),g.lookahead-=g.match_length,g.strstart+=g.match_length,g.match_length=0):(j=t._tr_tally(g,0,g.window[g.strstart]),g.lookahead--,g.strstart++),j&&(me(g,!1),g.strm.avail_out===0))return ae}return g.insert=0,q===s?(me(g,!0),g.strm.avail_out===0?Pe:ge):g.last_lit&&(me(g,!1),g.strm.avail_out===0)?ae:X}function Ue(g,q){for(var j;;){if(g.lookahead===0&&(Ae(g),g.lookahead===0)){if(q===o)return ae;break}if(g.match_length=0,j=t._tr_tally(g,0,g.window[g.strstart]),g.lookahead--,g.strstart++,j&&(me(g,!1),g.strm.avail_out===0))return ae}return g.insert=0,q===s?(me(g,!0),g.strm.avail_out===0?Pe:ge):g.last_lit&&(me(g,!1),g.strm.avail_out===0)?ae:X}function Be(g,q,j,R,U){this.good_length=g,this.max_lazy=q,this.nice_length=j,this.max_chain=R,this.func=U}var Ge;Ge=[new Be(0,0,0,0,Ie),new Be(4,4,8,4,we),new Be(4,5,16,8,we),new Be(4,6,32,32,we),new Be(4,4,16,16,Re),new Be(8,16,32,32,Re),new Be(8,16,128,128,Re),new Be(8,32,128,256,Re),new Be(32,128,258,1024,Re),new Be(32,258,258,4096,Re)];function Ke(g){g.window_size=2*g.w_size,ke(g.head),g.max_lazy_match=Ge[g.level].max_lazy,g.good_match=Ge[g.level].good_length,g.nice_match=Ge[g.level].nice_length,g.max_chain_length=Ge[g.level].max_chain,g.strstart=0,g.block_start=0,g.lookahead=0,g.insert=0,g.match_length=g.prev_length=V-1,g.match_available=0,g.ins_h=0}function z(){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=w,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(y*2),this.dyn_dtree=new e.Buf16((2*E+1)*2),this.bl_tree=new e.Buf16((2*L+1)*2),ke(this.dyn_ltree),ke(this.dyn_dtree),ke(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new e.Buf16(A+1),this.heap=new e.Buf16(2*D+1),ke(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new e.Buf16(2*D+1),ke(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 fe(g){var q;return!g||!g.state?Q(g,d):(g.total_in=g.total_out=0,g.data_type=M,q=g.state,q.pending=0,q.pending_out=0,q.wrap<0&&(q.wrap=-q.wrap),q.status=q.wrap?ee:Y,g.adler=q.wrap===2?0:1,q.last_flush=o,t._tr_init(q),p)}function he(g){var q=fe(g);return q===p&&Ke(g.state),q}function xe(g,q){return!g||!g.state||g.state.wrap!==2?d:(g.state.gzhead=q,p)}function Z(g,q,j,R,U,J){if(!g)return d;var Te=1;if(q===T&&(q=6),R<0?(Te=0,R=-R):R>15&&(Te=2,R-=16),U<1||U>S||j!==w||R<8||R>15||q<0||q>9||J<0||J>b)return Q(g,d);R===8&&(R=9);var ye=new z;return g.state=ye,ye.strm=g,ye.wrap=Te,ye.gzhead=null,ye.w_bits=R,ye.w_size=1<<ye.w_bits,ye.w_mask=ye.w_size-1,ye.hash_bits=U+7,ye.hash_size=1<<ye.hash_bits,ye.hash_mask=ye.hash_size-1,ye.hash_shift=~~((ye.hash_bits+V-1)/V),ye.window=new e.Buf8(ye.w_size*2),ye.head=new e.Buf16(ye.hash_size),ye.prev=new e.Buf16(ye.w_size),ye.lit_bufsize=1<<U+6,ye.pending_buf_size=ye.lit_bufsize*4,ye.pending_buf=new e.Buf8(ye.pending_buf_size),ye.d_buf=1*ye.lit_bufsize,ye.l_buf=3*ye.lit_bufsize,ye.level=q,ye.strategy=J,ye.method=j,he(g)}function ie(g,q){return Z(g,q,w,N,F,k)}function O(g,q){var j,R,U,J;if(!g||!g.state||q>c||q<0)return g?Q(g,d):d;if(R=g.state,!g.output||!g.input&&g.avail_in!==0||R.status===ce&&q!==s)return Q(g,g.avail_out===0?h:d);if(R.strm=g,j=R.last_flush,R.last_flush=q,R.status===ee)if(R.wrap===2)g.adler=0,ue(R,31),ue(R,139),ue(R,8),R.gzhead?(ue(R,(R.gzhead.text?1:0)+(R.gzhead.hcrc?2:0)+(R.gzhead.extra?4:0)+(R.gzhead.name?8:0)+(R.gzhead.comment?16:0)),ue(R,R.gzhead.time&255),ue(R,R.gzhead.time>>8&255),ue(R,R.gzhead.time>>16&255),ue(R,R.gzhead.time>>24&255),ue(R,R.level===9?2:R.strategy>=v||R.level<2?4:0),ue(R,R.gzhead.os&255),R.gzhead.extra&&R.gzhead.extra.length&&(ue(R,R.gzhead.extra.length&255),ue(R,R.gzhead.extra.length>>8&255)),R.gzhead.hcrc&&(g.adler=a(g.adler,R.pending_buf,R.pending,0)),R.gzindex=0,R.status=G):(ue(R,0),ue(R,0),ue(R,0),ue(R,0),ue(R,0),ue(R,R.level===9?2:R.strategy>=v||R.level<2?4:0),ue(R,H),R.status=Y);else{var Te=w+(R.w_bits-8<<4)<<8,ye=-1;R.strategy>=v||R.level<2?ye=0:R.level<6?ye=1:R.level===6?ye=2:ye=3,Te|=ye<<6,R.strstart!==0&&(Te|=ne),Te+=31-Te%31,R.status=Y,pe(R,Te),R.strstart!==0&&(pe(R,g.adler>>>16),pe(R,g.adler&65535)),g.adler=1}if(R.status===G)if(R.gzhead.extra){for(U=R.pending;R.gzindex<(R.gzhead.extra.length&65535)&&!(R.pending===R.pending_buf_size&&(R.gzhead.hcrc&&R.pending>U&&(g.adler=a(g.adler,R.pending_buf,R.pending-U,U)),te(g),U=R.pending,R.pending===R.pending_buf_size));)ue(R,R.gzhead.extra[R.gzindex]&255),R.gzindex++;R.gzhead.hcrc&&R.pending>U&&(g.adler=a(g.adler,R.pending_buf,R.pending-U,U)),R.gzindex===R.gzhead.extra.length&&(R.gzindex=0,R.status=le)}else R.status=le;if(R.status===le)if(R.gzhead.name){U=R.pending;do{if(R.pending===R.pending_buf_size&&(R.gzhead.hcrc&&R.pending>U&&(g.adler=a(g.adler,R.pending_buf,R.pending-U,U)),te(g),U=R.pending,R.pending===R.pending_buf_size)){J=1;break}R.gzindex<R.gzhead.name.length?J=R.gzhead.name.charCodeAt(R.gzindex++)&255:J=0,ue(R,J)}while(J!==0);R.gzhead.hcrc&&R.pending>U&&(g.adler=a(g.adler,R.pending_buf,R.pending-U,U)),J===0&&(R.gzindex=0,R.status=re)}else R.status=re;if(R.status===re)if(R.gzhead.comment){U=R.pending;do{if(R.pending===R.pending_buf_size&&(R.gzhead.hcrc&&R.pending>U&&(g.adler=a(g.adler,R.pending_buf,R.pending-U,U)),te(g),U=R.pending,R.pending===R.pending_buf_size)){J=1;break}R.gzindex<R.gzhead.comment.length?J=R.gzhead.comment.charCodeAt(R.gzindex++)&255:J=0,ue(R,J)}while(J!==0);R.gzhead.hcrc&&R.pending>U&&(g.adler=a(g.adler,R.pending_buf,R.pending-U,U)),J===0&&(R.status=oe)}else R.status=oe;if(R.status===oe&&(R.gzhead.hcrc?(R.pending+2>R.pending_buf_size&&te(g),R.pending+2<=R.pending_buf_size&&(ue(R,g.adler&255),ue(R,g.adler>>8&255),g.adler=0,R.status=Y)):R.status=Y),R.pending!==0){if(te(g),g.avail_out===0)return R.last_flush=-1,p}else if(g.avail_in===0&&Ee(q)<=Ee(j)&&q!==s)return Q(g,h);if(R.status===ce&&g.avail_in!==0)return Q(g,h);if(g.avail_in!==0||R.lookahead!==0||q!==o&&R.status!==ce){var Ce=R.strategy===v?Ue(R,q):R.strategy===_?Ve(R,q):Ge[R.level].func(R,q);if((Ce===Pe||Ce===ge)&&(R.status=ce),Ce===ae||Ce===Pe)return g.avail_out===0&&(R.last_flush=-1),p;if(Ce===X&&(q===i?t._tr_align(R):q!==c&&(t._tr_stored_block(R,0,0,!1),q===l&&(ke(R.head),R.lookahead===0&&(R.strstart=0,R.block_start=0,R.insert=0))),te(g),g.avail_out===0))return R.last_flush=-1,p}return q!==s?p:R.wrap<=0?f:(R.wrap===2?(ue(R,g.adler&255),ue(R,g.adler>>8&255),ue(R,g.adler>>16&255),ue(R,g.adler>>24&255),ue(R,g.total_in&255),ue(R,g.total_in>>8&255),ue(R,g.total_in>>16&255),ue(R,g.total_in>>24&255)):(pe(R,g.adler>>>16),pe(R,g.adler&65535)),te(g),R.wrap>0&&(R.wrap=-R.wrap),R.pending!==0?p:f)}function de(g){var q;return!g||!g.state?d:(q=g.state.status,q!==ee&&q!==G&&q!==le&&q!==re&&q!==oe&&q!==Y&&q!==ce?Q(g,d):(g.state=null,q===Y?Q(g,x):p))}function Se(g,q){var j=q.length,R,U,J,Te,ye,Ce,Fe,Tt;if(!g||!g.state||(R=g.state,Te=R.wrap,Te===2||Te===1&&R.status!==ee||R.lookahead))return d;for(Te===1&&(g.adler=n(g.adler,q,j,0)),R.wrap=0,j>=R.w_size&&(Te===0&&(ke(R.head),R.strstart=0,R.block_start=0,R.insert=0),Tt=new e.Buf8(R.w_size),e.arraySet(Tt,q,j-R.w_size,R.w_size,0),q=Tt,j=R.w_size),ye=g.avail_in,Ce=g.next_in,Fe=g.input,g.avail_in=j,g.next_in=0,g.input=q,Ae(R);R.lookahead>=V;){U=R.strstart,J=R.lookahead-(V-1);do R.ins_h=(R.ins_h<<R.hash_shift^R.window[U+V-1])&R.hash_mask,R.prev[U&R.w_mask]=R.head[R.ins_h],R.head[R.ins_h]=U,U++;while(--J);R.strstart=U,R.lookahead=V-1,Ae(R)}return R.strstart+=R.lookahead,R.block_start=R.strstart,R.insert=R.lookahead,R.lookahead=0,R.match_length=R.prev_length=V-1,R.match_available=0,g.next_in=Ce,g.input=Fe,g.avail_in=ye,R.wrap=Te,p}return ht.deflateInit=ie,ht.deflateInit2=Z,ht.deflateReset=he,ht.deflateResetKeep=fe,ht.deflateSetHeader=xe,ht.deflate=O,ht.deflateEnd=de,ht.deflateSetDictionary=Se,ht.deflateInfo="pako deflate (from Nodeca project)",ht}var Gt={},ar;function Ei(){if(ar)return Gt;ar=1;var e=Ht(),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,Gt.string2buf=function(i){var l,s,c,p,f,d=i.length,x=0;for(p=0;p<d;p++)s=i.charCodeAt(p),(s&64512)===55296&&p+1<d&&(c=i.charCodeAt(p+1),(c&64512)===56320&&(s=65536+(s-55296<<10)+(c-56320),p++)),x+=s<128?1:s<2048?2:s<65536?3:4;for(l=new e.Buf8(x),f=0,p=0;f<x;p++)s=i.charCodeAt(p),(s&64512)===55296&&p+1<d&&(c=i.charCodeAt(p+1),(c&64512)===56320&&(s=65536+(s-55296<<10)+(c-56320),p++)),s<128?l[f++]=s:s<2048?(l[f++]=192|s>>>6,l[f++]=128|s&63):s<65536?(l[f++]=224|s>>>12,l[f++]=128|s>>>6&63,l[f++]=128|s&63):(l[f++]=240|s>>>18,l[f++]=128|s>>>12&63,l[f++]=128|s>>>6&63,l[f++]=128|s&63);return l};function o(i,l){if(l<65534&&(i.subarray&&n||!i.subarray&&t))return String.fromCharCode.apply(null,e.shrinkBuf(i,l));for(var s="",c=0;c<l;c++)s+=String.fromCharCode(i[c]);return s}return Gt.buf2binstring=function(i){return o(i,i.length)},Gt.binstring2buf=function(i){for(var l=new e.Buf8(i.length),s=0,c=l.length;s<c;s++)l[s]=i.charCodeAt(s);return l},Gt.buf2string=function(i,l){var s,c,p,f,d=l||i.length,x=new Array(d*2);for(c=0,s=0;s<d;){if(p=i[s++],p<128){x[c++]=p;continue}if(f=a[p],f>4){x[c++]=65533,s+=f-1;continue}for(p&=f===2?31:f===3?15:7;f>1&&s<d;)p=p<<6|i[s++]&63,f--;if(f>1){x[c++]=65533;continue}p<65536?x[c++]=p:(p-=65536,x[c++]=55296|p>>10&1023,x[c++]=56320|p&1023)}return o(x,c)},Gt.utf8border=function(i,l){var s;for(l=l||i.length,l>i.length&&(l=i.length),s=l-1;s>=0&&(i[s]&192)===128;)s--;return s<0||s===0?l:s+a[i[s]]>l?s:l},Gt}var ro,sr;function Ni(){if(sr)return ro;sr=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 ro=e,ro}var lr;function ds(){if(lr)return jt;lr=1;var e=fs(),t=Ht(),n=Ei(),a=Ao(),r=Ni(),o=Object.prototype.toString,i=0,l=4,s=0,c=1,p=2,f=-1,d=0,x=8;function h(_){if(!(this instanceof h))return new h(_);this.options=t.assign({level:f,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:d,to:""},_||{});var b=this.options;b.raw&&b.windowBits>0?b.windowBits=-b.windowBits:b.gzip&&b.windowBits>0&&b.windowBits<16&&(b.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new r,this.strm.avail_out=0;var k=e.deflateInit2(this.strm,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(k!==s)throw new Error(a[k]);if(b.header&&e.deflateSetHeader(this.strm,b.header),b.dictionary){var M;if(typeof b.dictionary=="string"?M=n.string2buf(b.dictionary):o.call(b.dictionary)==="[object ArrayBuffer]"?M=new Uint8Array(b.dictionary):M=b.dictionary,k=e.deflateSetDictionary(this.strm,M),k!==s)throw new Error(a[k]);this._dict_set=!0}}h.prototype.push=function(_,b){var k=this.strm,M=this.options.chunkSize,w,S;if(this.ended)return!1;S=b===~~b?b:b===!0?l:i,typeof _=="string"?k.input=n.string2buf(_):o.call(_)==="[object ArrayBuffer]"?k.input=new Uint8Array(_):k.input=_,k.next_in=0,k.avail_in=k.input.length;do{if(k.avail_out===0&&(k.output=new t.Buf8(M),k.next_out=0,k.avail_out=M),w=e.deflate(k,S),w!==c&&w!==s)return this.onEnd(w),this.ended=!0,!1;(k.avail_out===0||k.avail_in===0&&(S===l||S===p))&&(this.options.to==="string"?this.onData(n.buf2binstring(t.shrinkBuf(k.output,k.next_out))):this.onData(t.shrinkBuf(k.output,k.next_out)))}while((k.avail_in>0||k.avail_out===0)&&w!==c);return S===l?(w=e.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===s):(S===p&&(this.onEnd(s),k.avail_out=0),!0)},h.prototype.onData=function(_){this.chunks.push(_)},h.prototype.onEnd=function(_){_===s&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=t.flattenChunks(this.chunks)),this.chunks=[],this.err=_,this.msg=this.strm.msg};function T(_,b){var k=new h(b);if(k.push(_,!0),k.err)throw k.msg||a[k.err];return k.result}function P(_,b){return b=b||{},b.raw=!0,T(_,b)}function v(_,b){return b=b||{},b.gzip=!0,T(_,b)}return jt.Deflate=h,jt.deflate=T,jt.deflateRaw=P,jt.gzip=v,jt}var en={},ft={},io,cr;function ps(){if(cr)return io;cr=1;var e=30,t=12;return io=function(a,r){var o,i,l,s,c,p,f,d,x,h,T,P,v,_,b,k,M,w,S,N,F,B,I,D,E;o=a.state,i=a.next_in,D=a.input,l=i+(a.avail_in-5),s=a.next_out,E=a.output,c=s-(r-a.avail_out),p=s+(a.avail_out-257),f=o.dmax,d=o.wsize,x=o.whave,h=o.wnext,T=o.window,P=o.hold,v=o.bits,_=o.lencode,b=o.distcode,k=(1<<o.lenbits)-1,M=(1<<o.distbits)-1;e:do{v<15&&(P+=D[i++]<<v,v+=8,P+=D[i++]<<v,v+=8),w=_[P&k];t:for(;;){if(S=w>>>24,P>>>=S,v-=S,S=w>>>16&255,S===0)E[s++]=w&65535;else if(S&16){N=w&65535,S&=15,S&&(v<S&&(P+=D[i++]<<v,v+=8),N+=P&(1<<S)-1,P>>>=S,v-=S),v<15&&(P+=D[i++]<<v,v+=8,P+=D[i++]<<v,v+=8),w=b[P&M];n:for(;;){if(S=w>>>24,P>>>=S,v-=S,S=w>>>16&255,S&16){if(F=w&65535,S&=15,v<S&&(P+=D[i++]<<v,v+=8,v<S&&(P+=D[i++]<<v,v+=8)),F+=P&(1<<S)-1,F>f){a.msg="invalid distance too far back",o.mode=e;break e}if(P>>>=S,v-=S,S=s-c,F>S){if(S=F-S,S>x&&o.sane){a.msg="invalid distance too far back",o.mode=e;break e}if(B=0,I=T,h===0){if(B+=d-S,S<N){N-=S;do E[s++]=T[B++];while(--S);B=s-F,I=E}}else if(h<S){if(B+=d+h-S,S-=h,S<N){N-=S;do E[s++]=T[B++];while(--S);if(B=0,h<N){S=h,N-=S;do E[s++]=T[B++];while(--S);B=s-F,I=E}}}else if(B+=h-S,S<N){N-=S;do E[s++]=T[B++];while(--S);B=s-F,I=E}for(;N>2;)E[s++]=I[B++],E[s++]=I[B++],E[s++]=I[B++],N-=3;N&&(E[s++]=I[B++],N>1&&(E[s++]=I[B++]))}else{B=s-F;do E[s++]=E[B++],E[s++]=E[B++],E[s++]=E[B++],N-=3;while(N>2);N&&(E[s++]=E[B++],N>1&&(E[s++]=E[B++]))}}else if(S&64){a.msg="invalid distance code",o.mode=e;break e}else{w=b[(w&65535)+(P&(1<<S)-1)];continue n}break}}else if(S&64)if(S&32){o.mode=t;break e}else{a.msg="invalid literal/length code",o.mode=e;break e}else{w=_[(w&65535)+(P&(1<<S)-1)];continue t}break}}while(i<l&&s<p);N=v>>3,i-=N,v-=N<<3,P&=(1<<v)-1,a.next_in=i,a.next_out=s,a.avail_in=i<l?5+(l-i):5-(i-l),a.avail_out=s<p?257+(p-s):257-(s-p),o.hold=P,o.bits=v},io}var ao,ur;function hs(){if(ur)return ao;ur=1;var e=Ht(),t=15,n=852,a=592,r=0,o=1,i=2,l=[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],s=[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],p=[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 ao=function(d,x,h,T,P,v,_,b){var k=b.bits,M=0,w=0,S=0,N=0,F=0,B=0,I=0,D=0,E=0,L=0,y,A,V,$,W,ne=null,ee=0,G,le=new e.Buf16(t+1),re=new e.Buf16(t+1),oe=null,Y=0,ce,ae,X;for(M=0;M<=t;M++)le[M]=0;for(w=0;w<T;w++)le[x[h+w]]++;for(F=k,N=t;N>=1&&le[N]===0;N--);if(F>N&&(F=N),N===0)return P[v++]=1<<24|64<<16|0,P[v++]=1<<24|64<<16|0,b.bits=1,0;for(S=1;S<N&&le[S]===0;S++);for(F<S&&(F=S),D=1,M=1;M<=t;M++)if(D<<=1,D-=le[M],D<0)return-1;if(D>0&&(d===r||N!==1))return-1;for(re[1]=0,M=1;M<t;M++)re[M+1]=re[M]+le[M];for(w=0;w<T;w++)x[h+w]!==0&&(_[re[x[h+w]]++]=w);if(d===r?(ne=oe=_,G=19):d===o?(ne=l,ee-=257,oe=s,Y-=257,G=256):(ne=c,oe=p,G=-1),L=0,w=0,M=S,W=v,B=F,I=0,V=-1,E=1<<F,$=E-1,d===o&&E>n||d===i&&E>a)return 1;for(;;){ce=M-I,_[w]<G?(ae=0,X=_[w]):_[w]>G?(ae=oe[Y+_[w]],X=ne[ee+_[w]]):(ae=96,X=0),y=1<<M-I,A=1<<B,S=A;do A-=y,P[W+(L>>I)+A]=ce<<24|ae<<16|X|0;while(A!==0);for(y=1<<M-1;L&y;)y>>=1;if(y!==0?(L&=y-1,L+=y):L=0,w++,--le[M]===0){if(M===N)break;M=x[h+_[w]]}if(M>F&&(L&$)!==V){for(I===0&&(I=F),W+=S,B=M-I,D=1<<B;B+I<N&&(D-=le[B+I],!(D<=0));)B++,D<<=1;if(E+=1<<B,d===o&&E>n||d===i&&E>a)return 1;V=L&$,P[V]=F<<24|B<<16|W-v|0}}return L!==0&&(P[W+L]=M-I<<24|64<<16|0),b.bits=F,0},ao}var fr;function ms(){if(fr)return ft;fr=1;var e=Ht(),t=bi(),n=ki(),a=ps(),r=hs(),o=0,i=1,l=2,s=4,c=5,p=6,f=0,d=1,x=2,h=-2,T=-3,P=-4,v=-5,_=8,b=1,k=2,M=3,w=4,S=5,N=6,F=7,B=8,I=9,D=10,E=11,L=12,y=13,A=14,V=15,$=16,W=17,ne=18,ee=19,G=20,le=21,re=22,oe=23,Y=24,ce=25,ae=26,X=27,Pe=28,ge=29,H=30,Q=31,Ee=32,ke=852,te=592,me=15,ue=me;function pe(Z){return(Z>>>24&255)+(Z>>>8&65280)+((Z&65280)<<8)+((Z&255)<<24)}function Ne(){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 be(Z){var ie;return!Z||!Z.state?h:(ie=Z.state,Z.total_in=Z.total_out=ie.total=0,Z.msg="",ie.wrap&&(Z.adler=ie.wrap&1),ie.mode=b,ie.last=0,ie.havedict=0,ie.dmax=32768,ie.head=null,ie.hold=0,ie.bits=0,ie.lencode=ie.lendyn=new e.Buf32(ke),ie.distcode=ie.distdyn=new e.Buf32(te),ie.sane=1,ie.back=-1,f)}function Ae(Z){var ie;return!Z||!Z.state?h:(ie=Z.state,ie.wsize=0,ie.whave=0,ie.wnext=0,be(Z))}function Ie(Z,ie){var O,de;return!Z||!Z.state||(de=Z.state,ie<0?(O=0,ie=-ie):(O=(ie>>4)+1,ie<48&&(ie&=15)),ie&&(ie<8||ie>15))?h:(de.window!==null&&de.wbits!==ie&&(de.window=null),de.wrap=O,de.wbits=ie,Ae(Z))}function we(Z,ie){var O,de;return Z?(de=new Ne,Z.state=de,de.window=null,O=Ie(Z,ie),O!==f&&(Z.state=null),O):h}function Re(Z){return we(Z,ue)}var Ve=!0,Ue,Be;function Ge(Z){if(Ve){var ie;for(Ue=new e.Buf32(512),Be=new e.Buf32(32),ie=0;ie<144;)Z.lens[ie++]=8;for(;ie<256;)Z.lens[ie++]=9;for(;ie<280;)Z.lens[ie++]=7;for(;ie<288;)Z.lens[ie++]=8;for(r(i,Z.lens,0,288,Ue,0,Z.work,{bits:9}),ie=0;ie<32;)Z.lens[ie++]=5;r(l,Z.lens,0,32,Be,0,Z.work,{bits:5}),Ve=!1}Z.lencode=Ue,Z.lenbits=9,Z.distcode=Be,Z.distbits=5}function Ke(Z,ie,O,de){var Se,g=Z.state;return g.window===null&&(g.wsize=1<<g.wbits,g.wnext=0,g.whave=0,g.window=new e.Buf8(g.wsize)),de>=g.wsize?(e.arraySet(g.window,ie,O-g.wsize,g.wsize,0),g.wnext=0,g.whave=g.wsize):(Se=g.wsize-g.wnext,Se>de&&(Se=de),e.arraySet(g.window,ie,O-de,Se,g.wnext),de-=Se,de?(e.arraySet(g.window,ie,O-de,de,0),g.wnext=de,g.whave=g.wsize):(g.wnext+=Se,g.wnext===g.wsize&&(g.wnext=0),g.whave<g.wsize&&(g.whave+=Se))),0}function z(Z,ie){var O,de,Se,g,q,j,R,U,J,Te,ye,Ce,Fe,Tt,Ye=0,De,qe,et,at,En,Nn,Xe,ut,Qe=new e.Buf8(4),bt,Ct,jo=[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 h;O=Z.state,O.mode===L&&(O.mode=y),q=Z.next_out,Se=Z.output,R=Z.avail_out,g=Z.next_in,de=Z.input,j=Z.avail_in,U=O.hold,J=O.bits,Te=j,ye=R,ut=f;e:for(;;)switch(O.mode){case b:if(O.wrap===0){O.mode=y;break}for(;J<16;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}if(O.wrap&2&&U===35615){O.check=0,Qe[0]=U&255,Qe[1]=U>>>8&255,O.check=n(O.check,Qe,2,0),U=0,J=0,O.mode=k;break}if(O.flags=0,O.head&&(O.head.done=!1),!(O.wrap&1)||(((U&255)<<8)+(U>>8))%31){Z.msg="incorrect header check",O.mode=H;break}if((U&15)!==_){Z.msg="unknown compression method",O.mode=H;break}if(U>>>=4,J-=4,Xe=(U&15)+8,O.wbits===0)O.wbits=Xe;else if(Xe>O.wbits){Z.msg="invalid window size",O.mode=H;break}O.dmax=1<<Xe,Z.adler=O.check=1,O.mode=U&512?D:L,U=0,J=0;break;case k:for(;J<16;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}if(O.flags=U,(O.flags&255)!==_){Z.msg="unknown compression method",O.mode=H;break}if(O.flags&57344){Z.msg="unknown header flags set",O.mode=H;break}O.head&&(O.head.text=U>>8&1),O.flags&512&&(Qe[0]=U&255,Qe[1]=U>>>8&255,O.check=n(O.check,Qe,2,0)),U=0,J=0,O.mode=M;case M:for(;J<32;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}O.head&&(O.head.time=U),O.flags&512&&(Qe[0]=U&255,Qe[1]=U>>>8&255,Qe[2]=U>>>16&255,Qe[3]=U>>>24&255,O.check=n(O.check,Qe,4,0)),U=0,J=0,O.mode=w;case w:for(;J<16;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}O.head&&(O.head.xflags=U&255,O.head.os=U>>8),O.flags&512&&(Qe[0]=U&255,Qe[1]=U>>>8&255,O.check=n(O.check,Qe,2,0)),U=0,J=0,O.mode=S;case S:if(O.flags&1024){for(;J<16;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}O.length=U,O.head&&(O.head.extra_len=U),O.flags&512&&(Qe[0]=U&255,Qe[1]=U>>>8&255,O.check=n(O.check,Qe,2,0)),U=0,J=0}else O.head&&(O.head.extra=null);O.mode=N;case N:if(O.flags&1024&&(Ce=O.length,Ce>j&&(Ce=j),Ce&&(O.head&&(Xe=O.head.extra_len-O.length,O.head.extra||(O.head.extra=new Array(O.head.extra_len)),e.arraySet(O.head.extra,de,g,Ce,Xe)),O.flags&512&&(O.check=n(O.check,de,Ce,g)),j-=Ce,g+=Ce,O.length-=Ce),O.length))break e;O.length=0,O.mode=F;case F:if(O.flags&2048){if(j===0)break e;Ce=0;do Xe=de[g+Ce++],O.head&&Xe&&O.length<65536&&(O.head.name+=String.fromCharCode(Xe));while(Xe&&Ce<j);if(O.flags&512&&(O.check=n(O.check,de,Ce,g)),j-=Ce,g+=Ce,Xe)break e}else O.head&&(O.head.name=null);O.length=0,O.mode=B;case B:if(O.flags&4096){if(j===0)break e;Ce=0;do Xe=de[g+Ce++],O.head&&Xe&&O.length<65536&&(O.head.comment+=String.fromCharCode(Xe));while(Xe&&Ce<j);if(O.flags&512&&(O.check=n(O.check,de,Ce,g)),j-=Ce,g+=Ce,Xe)break e}else O.head&&(O.head.comment=null);O.mode=I;case I:if(O.flags&512){for(;J<16;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}if(U!==(O.check&65535)){Z.msg="header crc mismatch",O.mode=H;break}U=0,J=0}O.head&&(O.head.hcrc=O.flags>>9&1,O.head.done=!0),Z.adler=O.check=0,O.mode=L;break;case D:for(;J<32;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}Z.adler=O.check=pe(U),U=0,J=0,O.mode=E;case E:if(O.havedict===0)return Z.next_out=q,Z.avail_out=R,Z.next_in=g,Z.avail_in=j,O.hold=U,O.bits=J,x;Z.adler=O.check=1,O.mode=L;case L:if(ie===c||ie===p)break e;case y:if(O.last){U>>>=J&7,J-=J&7,O.mode=X;break}for(;J<3;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}switch(O.last=U&1,U>>>=1,J-=1,U&3){case 0:O.mode=A;break;case 1:if(Ge(O),O.mode=G,ie===p){U>>>=2,J-=2;break e}break;case 2:O.mode=W;break;case 3:Z.msg="invalid block type",O.mode=H}U>>>=2,J-=2;break;case A:for(U>>>=J&7,J-=J&7;J<32;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}if((U&65535)!==(U>>>16^65535)){Z.msg="invalid stored block lengths",O.mode=H;break}if(O.length=U&65535,U=0,J=0,O.mode=V,ie===p)break e;case V:O.mode=$;case $:if(Ce=O.length,Ce){if(Ce>j&&(Ce=j),Ce>R&&(Ce=R),Ce===0)break e;e.arraySet(Se,de,g,Ce,q),j-=Ce,g+=Ce,R-=Ce,q+=Ce,O.length-=Ce;break}O.mode=L;break;case W:for(;J<14;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}if(O.nlen=(U&31)+257,U>>>=5,J-=5,O.ndist=(U&31)+1,U>>>=5,J-=5,O.ncode=(U&15)+4,U>>>=4,J-=4,O.nlen>286||O.ndist>30){Z.msg="too many length or distance symbols",O.mode=H;break}O.have=0,O.mode=ne;case ne:for(;O.have<O.ncode;){for(;J<3;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}O.lens[jo[O.have++]]=U&7,U>>>=3,J-=3}for(;O.have<19;)O.lens[jo[O.have++]]=0;if(O.lencode=O.lendyn,O.lenbits=7,bt={bits:O.lenbits},ut=r(o,O.lens,0,19,O.lencode,0,O.work,bt),O.lenbits=bt.bits,ut){Z.msg="invalid code lengths set",O.mode=H;break}O.have=0,O.mode=ee;case ee:for(;O.have<O.nlen+O.ndist;){for(;Ye=O.lencode[U&(1<<O.lenbits)-1],De=Ye>>>24,qe=Ye>>>16&255,et=Ye&65535,!(De<=J);){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}if(et<16)U>>>=De,J-=De,O.lens[O.have++]=et;else{if(et===16){for(Ct=De+2;J<Ct;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}if(U>>>=De,J-=De,O.have===0){Z.msg="invalid bit length repeat",O.mode=H;break}Xe=O.lens[O.have-1],Ce=3+(U&3),U>>>=2,J-=2}else if(et===17){for(Ct=De+3;J<Ct;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}U>>>=De,J-=De,Xe=0,Ce=3+(U&7),U>>>=3,J-=3}else{for(Ct=De+7;J<Ct;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}U>>>=De,J-=De,Xe=0,Ce=11+(U&127),U>>>=7,J-=7}if(O.have+Ce>O.nlen+O.ndist){Z.msg="invalid bit length repeat",O.mode=H;break}for(;Ce--;)O.lens[O.have++]=Xe}}if(O.mode===H)break;if(O.lens[256]===0){Z.msg="invalid code -- missing end-of-block",O.mode=H;break}if(O.lenbits=9,bt={bits:O.lenbits},ut=r(i,O.lens,0,O.nlen,O.lencode,0,O.work,bt),O.lenbits=bt.bits,ut){Z.msg="invalid literal/lengths set",O.mode=H;break}if(O.distbits=6,O.distcode=O.distdyn,bt={bits:O.distbits},ut=r(l,O.lens,O.nlen,O.ndist,O.distcode,0,O.work,bt),O.distbits=bt.bits,ut){Z.msg="invalid distances set",O.mode=H;break}if(O.mode=G,ie===p)break e;case G:O.mode=le;case le:if(j>=6&&R>=258){Z.next_out=q,Z.avail_out=R,Z.next_in=g,Z.avail_in=j,O.hold=U,O.bits=J,a(Z,ye),q=Z.next_out,Se=Z.output,R=Z.avail_out,g=Z.next_in,de=Z.input,j=Z.avail_in,U=O.hold,J=O.bits,O.mode===L&&(O.back=-1);break}for(O.back=0;Ye=O.lencode[U&(1<<O.lenbits)-1],De=Ye>>>24,qe=Ye>>>16&255,et=Ye&65535,!(De<=J);){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}if(qe&&!(qe&240)){for(at=De,En=qe,Nn=et;Ye=O.lencode[Nn+((U&(1<<at+En)-1)>>at)],De=Ye>>>24,qe=Ye>>>16&255,et=Ye&65535,!(at+De<=J);){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}U>>>=at,J-=at,O.back+=at}if(U>>>=De,J-=De,O.back+=De,O.length=et,qe===0){O.mode=ae;break}if(qe&32){O.back=-1,O.mode=L;break}if(qe&64){Z.msg="invalid literal/length code",O.mode=H;break}O.extra=qe&15,O.mode=re;case re:if(O.extra){for(Ct=O.extra;J<Ct;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}O.length+=U&(1<<O.extra)-1,U>>>=O.extra,J-=O.extra,O.back+=O.extra}O.was=O.length,O.mode=oe;case oe:for(;Ye=O.distcode[U&(1<<O.distbits)-1],De=Ye>>>24,qe=Ye>>>16&255,et=Ye&65535,!(De<=J);){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}if(!(qe&240)){for(at=De,En=qe,Nn=et;Ye=O.distcode[Nn+((U&(1<<at+En)-1)>>at)],De=Ye>>>24,qe=Ye>>>16&255,et=Ye&65535,!(at+De<=J);){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}U>>>=at,J-=at,O.back+=at}if(U>>>=De,J-=De,O.back+=De,qe&64){Z.msg="invalid distance code",O.mode=H;break}O.offset=et,O.extra=qe&15,O.mode=Y;case Y:if(O.extra){for(Ct=O.extra;J<Ct;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}O.offset+=U&(1<<O.extra)-1,U>>>=O.extra,J-=O.extra,O.back+=O.extra}if(O.offset>O.dmax){Z.msg="invalid distance too far back",O.mode=H;break}O.mode=ce;case ce:if(R===0)break e;if(Ce=ye-R,O.offset>Ce){if(Ce=O.offset-Ce,Ce>O.whave&&O.sane){Z.msg="invalid distance too far back",O.mode=H;break}Ce>O.wnext?(Ce-=O.wnext,Fe=O.wsize-Ce):Fe=O.wnext-Ce,Ce>O.length&&(Ce=O.length),Tt=O.window}else Tt=Se,Fe=q-O.offset,Ce=O.length;Ce>R&&(Ce=R),R-=Ce,O.length-=Ce;do Se[q++]=Tt[Fe++];while(--Ce);O.length===0&&(O.mode=le);break;case ae:if(R===0)break e;Se[q++]=O.length,R--,O.mode=le;break;case X:if(O.wrap){for(;J<32;){if(j===0)break e;j--,U|=de[g++]<<J,J+=8}if(ye-=R,Z.total_out+=ye,O.total+=ye,ye&&(Z.adler=O.check=O.flags?n(O.check,Se,ye,q-ye):t(O.check,Se,ye,q-ye)),ye=R,(O.flags?U:pe(U))!==O.check){Z.msg="incorrect data check",O.mode=H;break}U=0,J=0}O.mode=Pe;case Pe:if(O.wrap&&O.flags){for(;J<32;){if(j===0)break e;j--,U+=de[g++]<<J,J+=8}if(U!==(O.total&4294967295)){Z.msg="incorrect length check",O.mode=H;break}U=0,J=0}O.mode=ge;case ge:ut=d;break e;case H:ut=T;break e;case Q:return P;case Ee:default:return h}return Z.next_out=q,Z.avail_out=R,Z.next_in=g,Z.avail_in=j,O.hold=U,O.bits=J,(O.wsize||ye!==Z.avail_out&&O.mode<H&&(O.mode<X||ie!==s))&&Ke(Z,Z.output,Z.next_out,ye-Z.avail_out),Te-=Z.avail_in,ye-=Z.avail_out,Z.total_in+=Te,Z.total_out+=ye,O.total+=ye,O.wrap&&ye&&(Z.adler=O.check=O.flags?n(O.check,Se,ye,Z.next_out-ye):t(O.check,Se,ye,Z.next_out-ye)),Z.data_type=O.bits+(O.last?64:0)+(O.mode===L?128:0)+(O.mode===G||O.mode===V?256:0),(Te===0&&ye===0||ie===s)&&ut===f&&(ut=v),ut}function fe(Z){if(!Z||!Z.state)return h;var ie=Z.state;return ie.window&&(ie.window=null),Z.state=null,f}function he(Z,ie){var O;return!Z||!Z.state||(O=Z.state,!(O.wrap&2))?h:(O.head=ie,ie.done=!1,f)}function xe(Z,ie){var O=ie.length,de,Se,g;return!Z||!Z.state||(de=Z.state,de.wrap!==0&&de.mode!==E)?h:de.mode===E&&(Se=1,Se=t(Se,ie,O,0),Se!==de.check)?T:(g=Ke(Z,ie,O,O),g?(de.mode=Q,P):(de.havedict=1,f))}return ft.inflateReset=Ae,ft.inflateReset2=Ie,ft.inflateResetKeep=be,ft.inflateInit=Re,ft.inflateInit2=we,ft.inflate=z,ft.inflateEnd=fe,ft.inflateGetHeader=he,ft.inflateSetDictionary=xe,ft.inflateInfo="pako inflate (from Nodeca project)",ft}var so,dr;function Ii(){return dr||(dr=1,so={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}),so}var lo,pr;function gs(){if(pr)return lo;pr=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 lo=e,lo}var hr;function vs(){if(hr)return en;hr=1;var e=ms(),t=Ht(),n=Ei(),a=Ii(),r=Ao(),o=Ni(),i=gs(),l=Object.prototype.toString;function s(f){if(!(this instanceof s))return new s(f);this.options=t.assign({chunkSize:16384,windowBits:0,to:""},f||{});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&&!(f&&f.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 x=e.inflateInit2(this.strm,d.windowBits);if(x!==a.Z_OK)throw new Error(r[x]);if(this.header=new i,e.inflateGetHeader(this.strm,this.header),d.dictionary&&(typeof d.dictionary=="string"?d.dictionary=n.string2buf(d.dictionary):l.call(d.dictionary)==="[object ArrayBuffer]"&&(d.dictionary=new Uint8Array(d.dictionary)),d.raw&&(x=e.inflateSetDictionary(this.strm,d.dictionary),x!==a.Z_OK)))throw new Error(r[x])}s.prototype.push=function(f,d){var x=this.strm,h=this.options.chunkSize,T=this.options.dictionary,P,v,_,b,k,M=!1;if(this.ended)return!1;v=d===~~d?d:d===!0?a.Z_FINISH:a.Z_NO_FLUSH,typeof f=="string"?x.input=n.binstring2buf(f):l.call(f)==="[object ArrayBuffer]"?x.input=new Uint8Array(f):x.input=f,x.next_in=0,x.avail_in=x.input.length;do{if(x.avail_out===0&&(x.output=new t.Buf8(h),x.next_out=0,x.avail_out=h),P=e.inflate(x,a.Z_NO_FLUSH),P===a.Z_NEED_DICT&&T&&(P=e.inflateSetDictionary(this.strm,T)),P===a.Z_BUF_ERROR&&M===!0&&(P=a.Z_OK,M=!1),P!==a.Z_STREAM_END&&P!==a.Z_OK)return this.onEnd(P),this.ended=!0,!1;x.next_out&&(x.avail_out===0||P===a.Z_STREAM_END||x.avail_in===0&&(v===a.Z_FINISH||v===a.Z_SYNC_FLUSH))&&(this.options.to==="string"?(_=n.utf8border(x.output,x.next_out),b=x.next_out-_,k=n.buf2string(x.output,_),x.next_out=b,x.avail_out=h-b,b&&t.arraySet(x.output,x.output,_,b,0),this.onData(k)):this.onData(t.shrinkBuf(x.output,x.next_out))),x.avail_in===0&&x.avail_out===0&&(M=!0)}while((x.avail_in>0||x.avail_out===0)&&P!==a.Z_STREAM_END);return P===a.Z_STREAM_END&&(v=a.Z_FINISH),v===a.Z_FINISH?(P=e.inflateEnd(this.strm),this.onEnd(P),this.ended=!0,P===a.Z_OK):(v===a.Z_SYNC_FLUSH&&(this.onEnd(a.Z_OK),x.avail_out=0),!0)},s.prototype.onData=function(f){this.chunks.push(f)},s.prototype.onEnd=function(f){f===a.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=t.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg};function c(f,d){var x=new s(d);if(x.push(f,!0),x.err)throw x.msg||r[x.err];return x.result}function p(f,d){return d=d||{},d.raw=!0,c(f,d)}return en.Inflate=s,en.inflate=c,en.inflateRaw=p,en.ungzip=c,en}var co,mr;function xs(){if(mr)return co;mr=1;var e=Ht().assign,t=ds(),n=vs(),a=Ii(),r={};return e(r,t,n,a),co=r,co}(function(e){(function(){var t={},n;e.exports=t,typeof Po=="function"?n=xs():n=window.pako,function(a,r){a.toRGBA8=function(o){var i=o.width,l=o.height;if(o.tabs.acTL==null)return[a.toRGBA8.decodeImage(o.data,i,l,o).buffer];var s=[];o.frames[0].data==null&&(o.frames[0].data=o.data);for(var c,p=new Uint8Array(i*l*4),f=0;f<o.frames.length;f++){var d=o.frames[f],x=d.rect.x,h=d.rect.y,T=d.rect.width,P=d.rect.height,v=a.toRGBA8.decodeImage(d.data,T,P,o);if(f==0?c=v:d.blend==0?a._copyTile(v,T,P,c,i,l,x,h,0):d.blend==1&&a._copyTile(v,T,P,c,i,l,x,h,1),s.push(c.buffer),c=c.slice(0),d.dispose!=0){if(d.dispose==1)a._copyTile(p,T,P,c,i,l,x,h,0);else if(d.dispose==2){for(var _=f-1;o.frames[_].dispose==2;)_--;c=new Uint8Array(s[_]).slice(0)}}}return s},a.toRGBA8.decodeImage=function(o,i,l,s){var c=i*l,p=a.decode._getBPP(s),f=Math.ceil(i*p/8),d=new Uint8Array(c*4),x=new Uint32Array(d.buffer),h=s.ctype,T=s.depth,P=a._bin.readUshort;if(h==6){var v=c<<2;if(T==8)for(var _=0;_<v;_++)d[_]=o[_];if(T==16)for(var _=0;_<v;_++)d[_]=o[_<<1]}else if(h==2){var b=s.tabs.tRNS,k=-1,M=-1,w=-1;if(b&&(k=b[0],M=b[1],w=b[2]),T==8)for(var _=0;_<c;_++){var S=_<<2,N=_*3;d[S]=o[N],d[S+1]=o[N+1],d[S+2]=o[N+2],d[S+3]=255,k!=-1&&o[N]==k&&o[N+1]==M&&o[N+2]==w&&(d[S+3]=0)}if(T==16)for(var _=0;_<c;_++){var S=_<<2,N=_*6;d[S]=o[N],d[S+1]=o[N+2],d[S+2]=o[N+4],d[S+3]=255,k!=-1&&P(o,N)==k&&P(o,N+2)==M&&P(o,N+4)==w&&(d[S+3]=0)}}else if(h==3){var F=s.tabs.PLTE,B=s.tabs.tRNS,I=B?B.length:0;if(T==1)for(var D=0;D<l;D++)for(var E=D*f,L=D*i,_=0;_<i;_++){var S=L+_<<2,y=o[E+(_>>3)]>>7-((_&7)<<0)&1,A=3*y;d[S]=F[A],d[S+1]=F[A+1],d[S+2]=F[A+2],d[S+3]=y<I?B[y]:255}if(T==2)for(var D=0;D<l;D++)for(var E=D*f,L=D*i,_=0;_<i;_++){var S=L+_<<2,y=o[E+(_>>2)]>>6-((_&3)<<1)&3,A=3*y;d[S]=F[A],d[S+1]=F[A+1],d[S+2]=F[A+2],d[S+3]=y<I?B[y]:255}if(T==4)for(var D=0;D<l;D++)for(var E=D*f,L=D*i,_=0;_<i;_++){var S=L+_<<2,y=o[E+(_>>1)]>>4-((_&1)<<2)&15,A=3*y;d[S]=F[A],d[S+1]=F[A+1],d[S+2]=F[A+2],d[S+3]=y<I?B[y]:255}if(T==8)for(var _=0;_<c;_++){var S=_<<2,y=o[_],A=3*y;d[S]=F[A],d[S+1]=F[A+1],d[S+2]=F[A+2],d[S+3]=y<I?B[y]:255}}else if(h==4){if(T==8)for(var _=0;_<c;_++){var S=_<<2,V=_<<1,$=o[V];d[S]=$,d[S+1]=$,d[S+2]=$,d[S+3]=o[V+1]}if(T==16)for(var _=0;_<c;_++){var S=_<<2,V=_<<2,$=o[V];d[S]=$,d[S+1]=$,d[S+2]=$,d[S+3]=o[V+2]}}else if(h==0){var k=s.tabs.tRNS?s.tabs.tRNS:-1;if(T==1)for(var _=0;_<c;_++){var $=255*(o[_>>3]>>7-(_&7)&1),W=$==k*255?0:255;x[_]=W<<24|$<<16|$<<8|$}if(T==2)for(var _=0;_<c;_++){var $=85*(o[_>>2]>>6-((_&3)<<1)&3),W=$==k*85?0:255;x[_]=W<<24|$<<16|$<<8|$}if(T==4)for(var _=0;_<c;_++){var $=17*(o[_>>1]>>4-((_&1)<<2)&15),W=$==k*17?0:255;x[_]=W<<24|$<<16|$<<8|$}if(T==8)for(var _=0;_<c;_++){var $=o[_],W=$==k?0:255;x[_]=W<<24|$<<16|$<<8|$}if(T==16)for(var _=0;_<c;_++){var $=o[_<<1],W=P(o,_<<1)==k?0:255;x[_]=W<<24|$<<16|$<<8|$}}return d},a.decode=function(o){for(var i=new Uint8Array(o),l=8,s=a._bin,c=s.readUshort,p=s.readUint,f={tabs:{},frames:[]},d=new Uint8Array(i.length),x=0,h,T=0,P=[137,80,78,71,13,10,26,10],v=0;v<8;v++)if(i[v]!=P[v])throw"The input is not a PNG file!";for(;l<i.length;){var _=s.readUint(i,l);l+=4;var b=s.readASCII(i,l,4);if(l+=4,b=="IHDR")a.decode._IHDR(i,l,f);else if(b=="IDAT"){for(var v=0;v<_;v++)d[x+v]=i[l+v];x+=_}else if(b=="acTL")f.tabs[b]={num_frames:p(i,l),num_plays:p(i,l+4)},h=new Uint8Array(i.length);else if(b=="fcTL"){if(T!=0){var k=f.frames[f.frames.length-1];k.data=a.decode._decompress(f,h.slice(0,T),k.rect.width,k.rect.height),T=0}var M={x:p(i,l+12),y:p(i,l+16),width:p(i,l+4),height:p(i,l+8)},w=c(i,l+22);w=c(i,l+20)/(w==0?100:w);var S={rect:M,delay:Math.round(w*1e3),dispose:i[l+24],blend:i[l+25]};f.frames.push(S)}else if(b=="fdAT"){for(var v=0;v<_-4;v++)h[T+v]=i[l+v+4];T+=_-4}else if(b=="pHYs")f.tabs[b]=[s.readUint(i,l),s.readUint(i,l+4),i[l+8]];else if(b=="cHRM"){f.tabs[b]=[];for(var v=0;v<8;v++)f.tabs[b].push(s.readUint(i,l+v*4))}else if(b=="tEXt"){f.tabs[b]==null&&(f.tabs[b]={});var N=s.nextZero(i,l),F=s.readASCII(i,l,N-l),B=s.readASCII(i,N+1,l+_-N-1);f.tabs[b][F]=B}else if(b=="iTXt"){f.tabs[b]==null&&(f.tabs[b]={});var N=0,I=l;N=s.nextZero(i,I);var F=s.readASCII(i,I,N-I);I=N+1,i[I],i[I+1],I+=2,N=s.nextZero(i,I),s.readASCII(i,I,N-I),I=N+1,N=s.nextZero(i,I),s.readUTF8(i,I,N-I),I=N+1;var B=s.readUTF8(i,I,_-(I-l));f.tabs[b][F]=B}else if(b=="PLTE")f.tabs[b]=s.readBytes(i,l,_);else if(b=="hIST"){var D=f.tabs.PLTE.length/3;f.tabs[b]=[];for(var v=0;v<D;v++)f.tabs[b].push(c(i,l+v*2))}else if(b=="tRNS")f.ctype==3?f.tabs[b]=s.readBytes(i,l,_):f.ctype==0?f.tabs[b]=c(i,l):f.ctype==2&&(f.tabs[b]=[c(i,l),c(i,l+2),c(i,l+4)]);else if(b=="gAMA")f.tabs[b]=s.readUint(i,l)/1e5;else if(b=="sRGB")f.tabs[b]=i[l];else if(b=="bKGD")f.ctype==0||f.ctype==4?f.tabs[b]=[c(i,l)]:f.ctype==2||f.ctype==6?f.tabs[b]=[c(i,l),c(i,l+2),c(i,l+4)]:f.ctype==3&&(f.tabs[b]=i[l]);else if(b=="IEND"){if(T!=0){var k=f.frames[f.frames.length-1];k.data=a.decode._decompress(f,h.slice(0,T),k.rect.width,k.rect.height),T=0}f.data=a.decode._decompress(f,d,f.width,f.height);break}l+=_,s.readUint(i,l),l+=4}return delete f.compress,delete f.interlace,delete f.filter,f},a.decode._decompress=function(o,i,l,s){return o.compress==0&&(i=a.decode._inflate(i)),o.interlace==0?i=a.decode._filterZero(i,o,0,l,s):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 l=i.width,s=i.height,c=a.decode._getBPP(i),p=c>>3,f=Math.ceil(l*c/8),d=new Uint8Array(s*f),x=0,h=[0,0,4,0,2,0,1],T=[0,4,0,2,0,1,0],P=[8,8,8,4,4,2,2],v=[8,8,4,4,2,2,1],_=0;_<7;){for(var b=P[_],k=v[_],M=0,w=0,S=h[_];S<s;)S+=b,w++;for(var N=T[_];N<l;)N+=k,M++;var F=Math.ceil(M*c/8);a.decode._filterZero(o,i,x,M,w);for(var B=0,I=h[_];I<s;){for(var D=T[_],E=x+B*F<<3;D<l;){if(c==1){var L=o[E>>3];L=L>>7-(E&7)&1,d[I*f+(D>>3)]|=L<<7-((D&3)<<0)}if(c==2){var L=o[E>>3];L=L>>6-(E&7)&3,d[I*f+(D>>2)]|=L<<6-((D&3)<<1)}if(c==4){var L=o[E>>3];L=L>>4-(E&7)&15,d[I*f+(D>>1)]|=L<<4-((D&1)<<2)}if(c>=8)for(var y=I*f+D*p,A=0;A<p;A++)d[y+A]=o[(E>>3)+A];E+=c,D+=k}B++,I+=b}M*w!=0&&(x+=w*(1+F)),_=_+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,l,s,c){var p=a.decode._getBPP(i),f=Math.ceil(s*p/8),d=a.decode._paeth;p=Math.ceil(p/8);for(var x=0;x<c;x++){var h=l+x*f,T=h+x+1,P=o[T-1];if(P==0)for(var v=0;v<f;v++)o[h+v]=o[T+v];else if(P==1){for(var v=0;v<p;v++)o[h+v]=o[T+v];for(var v=p;v<f;v++)o[h+v]=o[T+v]+o[h+v-p]&255}else if(x==0){for(var v=0;v<p;v++)o[h+v]=o[T+v];if(P==2)for(var v=p;v<f;v++)o[h+v]=o[T+v]&255;if(P==3)for(var v=p;v<f;v++)o[h+v]=o[T+v]+(o[h+v-p]>>1)&255;if(P==4)for(var v=p;v<f;v++)o[h+v]=o[T+v]+d(o[h+v-p],0,0)&255}else{if(P==2)for(var v=0;v<f;v++)o[h+v]=o[T+v]+o[h+v-f]&255;if(P==3){for(var v=0;v<p;v++)o[h+v]=o[T+v]+(o[h+v-f]>>1)&255;for(var v=p;v<f;v++)o[h+v]=o[T+v]+(o[h+v-f]+o[h+v-p]>>1)&255}if(P==4){for(var v=0;v<p;v++)o[h+v]=o[T+v]+d(0,o[h+v-f],0)&255;for(var v=p;v<f;v++)o[h+v]=o[T+v]+d(o[h+v-p],o[h+v-f],o[h+v-p-f])&255}}}return o},a.decode._paeth=function(o,i,l){var s=o+i-l,c=Math.abs(s-o),p=Math.abs(s-i),f=Math.abs(s-l);return c<=p&&c<=f?o:p<=f?i:l},a.decode._IHDR=function(o,i,l){var s=a._bin;l.width=s.readUint(o,i),i+=4,l.height=s.readUint(o,i),i+=4,l.depth=o[i],i++,l.ctype=o[i],i++,l.compress=o[i],i++,l.filter=o[i],i++,l.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,l){o[i]=l>>8&255,o[i+1]=l&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,l){o[i]=l>>24&255,o[i+1]=l>>16&255,o[i+2]=l>>8&255,o[i+3]=l&255},readASCII:function(o,i,l){for(var s="",c=0;c<l;c++)s+=String.fromCharCode(o[i+c]);return s},writeASCII:function(o,i,l){for(var s=0;s<l.length;s++)o[i+s]=l.charCodeAt(s)},readBytes:function(o,i,l){for(var s=[],c=0;c<l;c++)s.push(o[i+c]);return s},pad:function(o){return o.length<2?"0"+o:o},readUTF8:function(o,i,l){for(var s="",c,p=0;p<l;p++)s+="%"+a._bin.pad(o[i+p].toString(16));try{c=decodeURIComponent(s)}catch(f){return a._bin.readASCII(o,i,l)}return c}},a._copyTile=function(o,i,l,s,c,p,f,d,x){for(var h=Math.min(i,c),T=Math.min(l,p),P=0,v=0,_=0;_<T;_++)for(var b=0;b<h;b++)if(f>=0&&d>=0?(P=_*i+b<<2,v=(d+_)*c+f+b<<2):(P=(-d+_)*i-f+b<<2,v=_*c+b<<2),x==0)s[v]=o[P],s[v+1]=o[P+1],s[v+2]=o[P+2],s[v+3]=o[P+3];else if(x==1){var k=o[P+3]*.00392156862745098,M=o[P]*k,w=o[P+1]*k,S=o[P+2]*k,N=s[v+3]*(1/255),F=s[v]*N,B=s[v+1]*N,I=s[v+2]*N,D=1-k,E=k+N*D,L=E==0?0:1/E;s[v+3]=255*E,s[v+0]=(M+F*D)*L,s[v+1]=(w+B*D)*L,s[v+2]=(S+I*D)*L}else if(x==2){var k=o[P+3],M=o[P],w=o[P+1],S=o[P+2],N=s[v+3],F=s[v],B=s[v+1],I=s[v+2];k==N&&M==F&&w==B&&S==I?(s[v]=0,s[v+1]=0,s[v+2]=0,s[v+3]=0):(s[v]=M,s[v+1]=w,s[v+2]=S,s[v+3]=k)}else if(x==3){var k=o[P+3],M=o[P],w=o[P+1],S=o[P+2],N=s[v+3],F=s[v],B=s[v+1],I=s[v+2];if(k==N&&M==F&&w==B&&S==I)continue;if(k<220&&N>20)return!1}return!0},a.encode=function(o,i,l,s,c,p){s==null&&(s=0),p==null&&(p=!1);for(var f=new Uint8Array(o[0].byteLength*o.length+100),d=[137,80,78,71,13,10,26,10],x=0;x<8;x++)f[x]=d[x];var h=8,T=a._bin,P=a.crc.crc,v=T.writeUint,_=T.writeUshort,b=T.writeASCII,k=a.encode.compressPNG(o,i,l,s,p);v(f,h,13),h+=4,b(f,h,"IHDR"),h+=4,v(f,h,i),h+=4,v(f,h,l),h+=4,f[h]=k.depth,h++,f[h]=k.ctype,h++,f[h]=0,h++,f[h]=0,h++,f[h]=0,h++,v(f,h,P(f,h-17,17)),h+=4,v(f,h,1),h+=4,b(f,h,"sRGB"),h+=4,f[h]=1,h++,v(f,h,P(f,h-5,5)),h+=4;var M=o.length>1;if(M&&(v(f,h,8),h+=4,b(f,h,"acTL"),h+=4,v(f,h,o.length),h+=4,v(f,h,0),h+=4,v(f,h,P(f,h-12,12)),h+=4),k.ctype==3){var w=k.plte.length;v(f,h,w*3),h+=4,b(f,h,"PLTE"),h+=4;for(var x=0;x<w;x++){var S=x*3,N=k.plte[x],F=N&255,B=N>>8&255,I=N>>16&255;f[h+S+0]=F,f[h+S+1]=B,f[h+S+2]=I}if(h+=w*3,v(f,h,P(f,h-w*3-4,w*3+4)),h+=4,k.gotAlpha){v(f,h,w),h+=4,b(f,h,"tRNS"),h+=4;for(var x=0;x<w;x++)f[h+x]=k.plte[x]>>24&255;h+=w,v(f,h,P(f,h-w-4,w+4)),h+=4}}for(var D=0,E=0;E<k.frames.length;E++){var L=k.frames[E];M&&(v(f,h,26),h+=4,b(f,h,"fcTL"),h+=4,v(f,h,D++),h+=4,v(f,h,L.rect.width),h+=4,v(f,h,L.rect.height),h+=4,v(f,h,L.rect.x),h+=4,v(f,h,L.rect.y),h+=4,_(f,h,c[E]),h+=2,_(f,h,1e3),h+=2,f[h]=L.dispose,h++,f[h]=L.blend,h++,v(f,h,P(f,h-30,30)),h+=4);var y=L.cimg,w=y.length;v(f,h,w+(E==0?0:4)),h+=4;var A=h;b(f,h,E==0?"IDAT":"fdAT"),h+=4,E!=0&&(v(f,h,D++),h+=4);for(var x=0;x<w;x++)f[h+x]=y[x];h+=w,v(f,h,P(f,A,h-A)),h+=4}return v(f,h,0),h+=4,b(f,h,"IEND"),h+=4,v(f,h,P(f,h-4,4)),h+=4,f.buffer.slice(0,h)},a.encode.compressPNG=function(o,i,l,s,c){for(var p=a.encode.compress(o,i,l,s,!1,c),f=0;f<o.length;f++){var d=p.frames[f];d.rect.width;var x=d.rect.height,h=d.bpl,T=d.bpp,P=new Uint8Array(x*h+x);d.cimg=a.encode._filterZero(d.img,x,T,h,P)}return p},a.encode.compress=function(o,i,l,s,c,p){p==null&&(p=!1);for(var f=6,d=8,x=4,h=255,T=0;T<o.length;T++)for(var P=new Uint8Array(o[T]),v=P.length,_=0;_<v;_+=4)h&=P[_+3];var b=h!=255,k={},M=[];if(o.length!=0&&(k[0]=0,M.push(0),s!=0&&s--),s!=0){var w=a.quantize(o,s,c);o=w.bufs;for(var _=0;_<w.plte.length;_++){var S=w.plte[_].est.rgba;k[S]==null&&(k[S]=M.length,M.push(S))}}else for(var T=0;T<o.length;T++)for(var N=new Uint32Array(o[T]),v=N.length,_=0;_<v;_++){var S=N[_];if((_<i||S!=N[_-1]&&S!=N[_-i])&&k[S]==null&&(k[S]=M.length,M.push(S),M.length>=300))break}var F=b?c:!1,B=M.length;B<=256&&p==!1&&(B<=2?d=1:B<=4?d=2:B<=16?d=4:d=8,c&&(d=8),b=!0);for(var I=[],T=0;T<o.length;T++){var D=new Uint8Array(o[T]),E=new Uint32Array(D.buffer),L=0,y=0,A=i,V=l,$=0;if(T!=0&&!F){for(var W=c||T==1||I[I.length-2].dispose==2?1:2,ne=0,ee=1e9,G=0;G<W;G++){for(var ge=new Uint8Array(o[T-1-G]),le=new Uint32Array(o[T-1-G]),re=i,oe=l,Y=-1,ce=-1,ae=0;ae<l;ae++)for(var X=0;X<i;X++){var _=ae*i+X;E[_]!=le[_]&&(X<re&&(re=X),X>Y&&(Y=X),ae<oe&&(oe=ae),ae>ce&&(ce=ae))}var Pe=Y==-1?1:(Y-re+1)*(ce-oe+1);Pe<ee&&(ee=Pe,ne=G,Y==-1?(L=y=0,A=V=1):(L=re,y=oe,A=Y-re+1,V=ce-oe+1))}var ge=new Uint8Array(o[T-1-ne]);ne==1&&(I[I.length-1].dispose=2);var H=new Uint8Array(A*V*4);new Uint32Array(H.buffer),a._copyTile(ge,i,l,H,A,V,-L,-y,0),a._copyTile(D,i,l,H,A,V,-L,-y,3)?(a._copyTile(D,i,l,H,A,V,-L,-y,2),$=1):(a._copyTile(D,i,l,H,A,V,-L,-y,0),$=0),D=H,E=new Uint32Array(D.buffer)}var Q=4*A;if(B<=256&&p==!1){Q=Math.ceil(d*A/8);for(var H=new Uint8Array(Q*V),ae=0;ae<V;ae++){var _=ae*Q,Ee=ae*A;if(d==8)for(var X=0;X<A;X++)H[_+X]=k[E[Ee+X]];else if(d==4)for(var X=0;X<A;X++)H[_+(X>>1)]|=k[E[Ee+X]]<<4-(X&1)*4;else if(d==2)for(var X=0;X<A;X++)H[_+(X>>2)]|=k[E[Ee+X]]<<6-(X&3)*2;else if(d==1)for(var X=0;X<A;X++)H[_+(X>>3)]|=k[E[Ee+X]]<<7-(X&7)*1}D=H,f=3,x=1}else if(b==!1&&o.length==1){for(var H=new Uint8Array(A*V*3),ke=A*V,_=0;_<ke;_++){var te=_*3,me=_*4;H[te]=D[me],H[te+1]=D[me+1],H[te+2]=D[me+2]}D=H,f=2,x=3,Q=3*A}I.push({rect:{x:L,y,width:A,height:V},img:D,bpl:Q,bpp:x,blend:$,dispose:F?1:0})}return{ctype:f,depth:d,plte:M,gotAlpha:b,frames:I}},a.encode._filterZero=function(o,i,l,s,c){for(var p=[],f=0;f<5;f++)if(!(i*s>5e5&&(f==2||f==3||f==4))){for(var d=0;d<i;d++)a.encode._filterLine(c,o,d,s,l,f);if(p.push(r.deflate(c)),l==1)break}for(var x,h=1e9,T=0;T<p.length;T++)p[T].length<h&&(x=T,h=p[T].length);return p[x]},a.encode._filterLine=function(o,i,l,s,c,p){var f=l*s,d=f+l,x=a.decode._paeth;if(o[d]=p,d++,p==0)for(var h=0;h<s;h++)o[d+h]=i[f+h];else if(p==1){for(var h=0;h<c;h++)o[d+h]=i[f+h];for(var h=c;h<s;h++)o[d+h]=i[f+h]-i[f+h-c]+256&255}else if(l==0){for(var h=0;h<c;h++)o[d+h]=i[f+h];if(p==2)for(var h=c;h<s;h++)o[d+h]=i[f+h];if(p==3)for(var h=c;h<s;h++)o[d+h]=i[f+h]-(i[f+h-c]>>1)+256&255;if(p==4)for(var h=c;h<s;h++)o[d+h]=i[f+h]-x(i[f+h-c],0,0)+256&255}else{if(p==2)for(var h=0;h<s;h++)o[d+h]=i[f+h]+256-i[f+h-s]&255;if(p==3){for(var h=0;h<c;h++)o[d+h]=i[f+h]+256-(i[f+h-s]>>1)&255;for(var h=c;h<s;h++)o[d+h]=i[f+h]+256-(i[f+h-s]+i[f+h-c]>>1)&255}if(p==4){for(var h=0;h<c;h++)o[d+h]=i[f+h]+256-x(0,i[f+h-s],0)&255;for(var h=c;h<s;h++)o[d+h]=i[f+h]+256-x(i[f+h-c],i[f+h-s],i[f+h-c-s])&255}}},a.crc={table:function(){for(var o=new Uint32Array(256),i=0;i<256;i++){for(var l=i,s=0;s<8;s++)l&1?l=3988292384^l>>>1:l=l>>>1;o[i]=l}return o}(),update:function(o,i,l,s){for(var c=0;c<s;c++)o=a.crc.table[(o^i[l+c])&255]^o>>>8;return o},crc:function(o,i,l){return a.crc.update(4294967295,o,i,l)^4294967295}},a.quantize=function(o,i,l){for(var s=[],c=0,p=0;p<o.length;p++)s.push(a.encode.alphaMul(new Uint8Array(o[p]),l)),c+=o[p].byteLength;for(var f=new Uint8Array(c),d=new Uint32Array(f.buffer),x=0,p=0;p<s.length;p++){for(var h=s[p],T=h.length,P=0;P<T;P++)f[x+P]=h[P];x+=T}var v={i0:0,i1:f.length,bst:null,est:null,tdst:0,left:null,right:null};v.bst=a.quantize.stats(f,v.i0,v.i1),v.est=a.quantize.estats(v.bst);for(var _=[v];_.length<i;){for(var b=0,k=0,p=0;p<_.length;p++)_[p].est.L>b&&(b=_[p].est.L,k=p);if(b<.001)break;var M=_[k],w=a.quantize.splitPixels(f,d,M.i0,M.i1,M.est.e,M.est.eMq255),S={i0:M.i0,i1:w,bst:null,est:null,tdst:0,left:null,right:null};S.bst=a.quantize.stats(f,S.i0,S.i1),S.est=a.quantize.estats(S.bst);var N={i0:w,i1:M.i1,bst:null,est:null,tdst:0,left:null,right:null};N.bst={R:[],m:[],N:M.bst.N-S.bst.N};for(var p=0;p<16;p++)N.bst.R[p]=M.bst.R[p]-S.bst.R[p];for(var p=0;p<4;p++)N.bst.m[p]=M.bst.m[p]-S.bst.m[p];N.est=a.quantize.estats(N.bst),M.left=S,M.right=N,_[k]=S,_.push(N)}_.sort(function(W,ne){return ne.bst.N-W.bst.N});for(var F=0;F<s.length;F++){for(var B=a.quantize.planeDst,I=new Uint8Array(s[F].buffer),D=new Uint32Array(s[F].buffer),E=I.length,p=0;p<E;p+=4){for(var L=I[p]*.00392156862745098,y=I[p+1]*(1/255),A=I[p+2]*(1/255),V=I[p+3]*(1/255),$=v;$.left;)$=B($.est,L,y,A,V)<=0?$.left:$.right;D[p>>2]=$.est.rgba}s[F]=D.buffer}return{bufs:s,plte:_}},a.quantize.getNearest=function(o,i,l,s,c){if(o.left==null)return o.tdst=a.quantize.dist(o.est.q,i,l,s,c),o;var p=a.quantize.planeDst(o.est,i,l,s,c),f=o.left,d=o.right;p>0&&(f=o.right,d=o.left);var x=a.quantize.getNearest(f,i,l,s,c);if(x.tdst<=p*p)return x;var h=a.quantize.getNearest(d,i,l,s,c);return h.tdst<x.tdst?h:x},a.quantize.planeDst=function(o,i,l,s,c){var p=o.e;return p[0]*i+p[1]*l+p[2]*s+p[3]*c-o.eMq},a.quantize.dist=function(o,i,l,s,c){var p=i-o[0],f=l-o[1],d=s-o[2],x=c-o[3];return p*p+f*f+d*d+x*x},a.quantize.splitPixels=function(o,i,l,s,c,p){var f=a.quantize.vecDot;for(s-=4;l<s;){for(;f(o,l,c)<=p;)l+=4;for(;f(o,s,c)>p;)s-=4;if(l>=s)break;var d=i[l>>2];i[l>>2]=i[s>>2],i[s>>2]=d,l+=4,s-=4}for(;f(o,l,c)>p;)l-=4;return l+4},a.quantize.vecDot=function(o,i,l){return o[i]*l[0]+o[i+1]*l[1]+o[i+2]*l[2]+o[i+3]*l[3]},a.quantize.stats=function(o,i,l){for(var s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=[0,0,0,0],p=l-i>>2,f=i;f<l;f+=4){var d=o[f]*.00392156862745098,x=o[f+1]*(1/255),h=o[f+2]*(1/255),T=o[f+3]*(1/255);c[0]+=d,c[1]+=x,c[2]+=h,c[3]+=T,s[0]+=d*d,s[1]+=d*x,s[2]+=d*h,s[3]+=d*T,s[5]+=x*x,s[6]+=x*h,s[7]+=x*T,s[10]+=h*h,s[11]+=h*T,s[15]+=T*T}return s[4]=s[1],s[8]=s[2],s[12]=s[3],s[9]=s[6],s[13]=s[7],s[14]=s[11],{R:s,m:c,N:p}},a.quantize.estats=function(o){var i=o.R,l=o.m,s=o.N,c=l[0],p=l[1],f=l[2],d=l[3],x=s==0?0:1/s,h=[i[0]-c*c*x,i[1]-c*p*x,i[2]-c*f*x,i[3]-c*d*x,i[4]-p*c*x,i[5]-p*p*x,i[6]-p*f*x,i[7]-p*d*x,i[8]-f*c*x,i[9]-f*p*x,i[10]-f*f*x,i[11]-f*d*x,i[12]-d*c*x,i[13]-d*p*x,i[14]-d*f*x,i[15]-d*d*x],T=h,P=a.M4,v=[.5,.5,.5,.5],_=0,b=0;if(s!=0)for(var k=0;k<10&&(v=P.multVec(T,v),b=Math.sqrt(P.dot(v,v)),v=P.sml(1/b,v),!(Math.abs(b-_)<1e-9));k++)_=b;var M=[c*x,p*x,f*x,d*x],w=P.dot(P.sml(255,M),v),S=M[3]<.001?0:1/M[3];return{Cov:h,q:M,e:v,L:_,eMq255:w,eMq:P.dot(v,M),rgba:(Math.round(255*M[3])<<24|Math.round(255*M[2]*S)<<16|Math.round(255*M[1]*S)<<8|Math.round(255*M[0]*S)<<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 l=new Uint8Array(o.length),s=o.length>>2,c=0;c<s;c++){var p=c<<2,f=o[p+3];i&&(f=f<128?0:255);var d=f*(1/255);l[p+0]=o[p+0]*d,l[p+1]=o[p+1]*d,l[p+2]=o[p+2]*d,l[p+3]=f}return l}}(t,n)})()})(Ti);var ys=Ti.exports;const Cs=Si(ys),_s=cs.unstable_batchedUpdates,Ps={batchUpdate:_s},ct=e=>new u.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)),Oe=e=>new u.Vector3(e?e.scalePlane:1,e?e.scaleDepth:1,e?e.scalePlane:1),wi=e=>e?new u.Vector3(1/(e.scalePlane?e.scalePlane:1),1/(e.scaleDepth?e.scaleDepth:1),1/(e.scalePlane?e.scalePlane:1)):u.Vector3.One(),Ss=e=>{if(e instanceof u.ArcRotateCamera){const t=e.alpha;return(t>0?t:Math.PI-t)/Math.PI*180%360}return 0},Ts=e=>{const t=[];return e.forEach(n=>{t.push(Oi(n))}),t},Oi=e=>new u.Vector3(e.x,e.y,e.z),At=e=>new u.Vector3(e.x,e.y,e.z),bs=e=>new u.Color3(e.r,e.g,e.b);var yn=(e=>(e[e.START=0]="START",e[e.CONTINUE=1]="CONTINUE",e[e.END=2]="END",e))(yn||{}),$e=(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))($e||{}),Ai=(e=>(e[e.ClockWiseSideOrientation=u.Material.ClockWiseSideOrientation]="ClockWiseSideOrientation",e[e.CounterClockWiseSideOrientation=u.Material.CounterClockWiseSideOrientation]="CounterClockWiseSideOrientation",e))(Ai||{}),It=(e=>(e[e.PLANE=0]="PLANE",e[e.DEPTH=1]="DEPTH",e[e.NONE=2]="NONE",e))(It||{});const Le=m.createContext(void 0),Mo=m.createContext({viewCamera:void 0,setViewCamera:()=>{},cameraRefObject:void 0}),Lt=m.createContext({colorIDs:{},colorCodecs:{}}),Vn=m.createContext(null);var Lo=(e=>(e[e.ENGINE_DEFAULT=0]="ENGINE_DEFAULT",e[e.NONE=1]="NONE",e))(Lo||{});const Ro=m.createContext({onPreFetch:e=>new Promise(t=>{t(e)}),onFinish:()=>{console.log("Loaded")},onProgress:(e,t)=>{console.log(`Loading ${e}/${t}`)},useLoadingScreen:1,hideLoadingWhenPostCalculate:!0}),Mi=m.createContext(null),ks=(e,t)=>{var ge,H,Q,Ee,ke;const{children:n,workspaceMeta:a={max:new u.Vector3(Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER),min:new u.Vector3(Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER),scaleDepth:1,scalePlane:1,origin:u.Vector3.Zero(),_isDefault:!0},colorProvider:r={colorIDs:{},colorCodecs:{}},cacheProvider:o={onPreFetch:te=>new Promise(me=>{me(te)}),onFinish:()=>{console.log("Loaded")},onProgress:(te,me)=>{console.log(`Loading ${te} of ${me}`)},useLoadingScreen:1}}=e,i=_e.useScene(),l=_e.useCanvas(),[s,c]=m.useState(void 0),p=m.useRef({}),[f,d]=m.useState({}),x=m.useRef(0),h=m.useRef(0),T=m.useRef(new Set),P=m.useRef(new Map),v=m.useRef({lastReportedLoaded:-1,lastReportedTotal:-1}),[,_]=m.useState(0),b=m.useRef(null),k=m.useRef(null),M=m.useRef(!1),w=m.useRef(null),S=m.useRef([]),N=m.useRef(null),F=m.useRef(0),B=m.useRef(new WeakMap),I=m.useRef(1),D=m.useRef(new Map),E=m.useRef(0),L=m.useRef({isDown:!1,pointerId:-1,startX:0,startY:0,isDragging:!1});m.useEffect(()=>{if(r.colorCodecs){console.log("[Geo3DViewer] 开始色标刷新");const te={};if(Object.keys(r.colorCodecs).forEach(ue=>{console.log(`[Geo3DViewer] 正在生成色标 ${ue}`);const pe=r.colorCodecs[ue],Ne=new Uint8Array(pe.array.length*4);pe.array.forEach((Ie,we)=>{Ne[we*4+0]=Math.trunc(Ie.r*255),Ne[we*4+1]=Math.trunc(Ie.g*255),Ne[we*4+2]=Math.trunc(Ie.b*255),Ne[we*4+3]=255}),console.log(`[Geo3DViewer] 正在创建色标采样贴图 ${ue}`);const be=u.RawTexture.CreateRGBATexture(Ne,1,pe.array.length,i,!0,!1);be.name=`color-codec-${ue}`,console.log(`[Geo3DViewer] 正在创建色标图例 ${ue}`);const Ae=URL.createObjectURL(new Blob([Cs.encode([Ne.buffer],1,pe.array.length,0)]));console.log(`[Geo3DViewer] 正在构建色标 ${ue}`),te[ue]={blobUrl:Ae,min:pe.min,max:pe.max,texture:be}}),i){console.log(`[Geo3DViewer] 正在移除原有色标 共 ${Object.keys(p.current).length} 个`),Object.keys(p.current).forEach(pe=>{console.log(`[Geo3DViewer] 正在移除色标 ${pe}`),i.removeTexture(p.current[pe].texture),p.current[pe].texture.dispose(),URL.revokeObjectURL(p.current[pe].blobUrl)}),p.current=te;const ue=i.getMaterialByTags("remap");console.log("[Geo3DViewer] 已完成色标刷新,正在更新关联的材质"),ue.forEach(pe=>{pe instanceof u.ShaderMaterial?pe.setTexture("textureSampler",te[pe.metadata.colorCodec].texture):(pe.getBlockByName("RemappedTexture").texture=te[pe.metadata.colorCodec].texture,pe.markAsDirty(u.NodeMaterial.TextureDirtyFlag))}),console.log(`[Geo3DViewer] 已有 ${ue.length} 个材质执行了更新`)}}},[r.colorCodecs,i]);const y=m.useCallback(te=>!te||te.isDisposed()||!te.metadata||!("pickable"in te.metadata)||!te.metadata.pickable?null:te.metadata.pickable,[]),A=m.useCallback(te=>!!(te&&(te.onHover||te.onLeftClick||te.onMiddleClick||te.onRightClick)),[]),V=m.useCallback(te=>{if(l){if(te&&(te.onLeftClick||te.onMiddleClick||te.onRightClick)){l.style.setProperty("cursor","pointer");return}l.style.setProperty("cursor","default")}},[l]),$=m.useCallback(()=>{var me;const te=(me=k.current)==null?void 0:me._pickingTexture;b.current!==(te!=null?te:null)&&(b.current=te!=null?te:null,_(ue=>ue+1))},[]),W=m.useCallback(te=>{const me=B.current.get(te);if(me)return me;const ue=I.current++;return B.current.set(te,ue),ue},[]),ne=m.useCallback(()=>{const te=[],me=new Set;if(!i)return te;i.meshes.forEach(pe=>{if(!pe||pe.isDisposed())return;const Ne=y(pe);if(!(!(A(Ne)&&pe.isEnabled()&&pe.isVisible&&pe.isReady(!0)&&pe.isPickable)||me.has(pe))&&(me.add(pe),te.push(pe),pe.isAnInstance)){const Ae=pe.sourceMesh;Ae&&!Ae.isDisposed()&&Ae.isEnabled()&&Ae.isVisible&&Ae.isReady(!0)&&!me.has(Ae)&&(me.add(Ae),te.push(Ae))}});const ue=S.current.length===te.length&&S.current.every((pe,Ne)=>pe===te[Ne]);return k.current||(k.current=new Pi.GPUPicker),k.current.defaultRenderMaterial&&(k.current.defaultRenderMaterial.backFaceCulling=!1),ue||(k.current.setPickingList(te.length>0?te.slice():null),k.current.defaultRenderMaterial&&(k.current.defaultRenderMaterial.backFaceCulling=!1),S.current=te,$()),te},[y,A,i,$]),ee=m.useCallback(async(te,me)=>{if(!i)return null;if(!ne().length||!k.current)return $(),null;$();const pe=await k.current.pickAsync(te,me,!1);return $(),pe},[i,ne,$]);m.useEffect(()=>{if(!i)return;const te=i.onBeforeRenderObservable.add(()=>{ne()});return()=>{i.onBeforeRenderObservable.remove(te)}},[i,ne]);const G=m.useCallback((te,me,ue)=>i?i.pick(me,ue,pe=>pe===te,!1,void 0):null,[i]),le=m.useCallback(()=>{F.current+=1,D.current.clear()},[]),re=m.useCallback(te=>new Proxy({},{get:(me,ue)=>{const pe=te();if(!pe)return;const Ne=pe[ue];return typeof Ne=="function"?Ne.bind(pe):Ne},set:(me,ue,pe)=>{const Ne=te();return Ne?(Ne[ue]=pe,!0):!1},has:(me,ue)=>{const pe=te();return pe?ue in pe:!1},ownKeys:()=>{const me=te();return me?Reflect.ownKeys(me):[]},getOwnPropertyDescriptor:(me,ue)=>{const pe=te();if(pe)return Object.getOwnPropertyDescriptor(pe,ue)}}),[]),oe=m.useCallback((te,me,ue)=>{const pe=F.current,Ne=W(te),be=`${pe}:${Ne}:${Math.round(me)}:${Math.round(ue)}`,Ae=()=>{var Be,Ge,Ke;const Ie=D.current.get(be);if(Ie)return Ie;const we=G(te,me,ue),Re=(Be=we==null?void 0:we.pickedPoint)!=null?Be:null,Ve=(Ke=Re==null?void 0:Re.add((Ge=a.origin)!=null?Ge:u.Vector3.Zero()))!=null?Ke:null,Ue={raw:Re,world:Ve};return D.current.set(be,Ue),Ue};return{rawWorldPosition:re(()=>Ae().raw),worldPosition:re(()=>Ae().world)}},[re,W,G,a.origin]),Y=m.useCallback((te,me,ue,pe,Ne)=>{var Re,Ve;const be=y(te);if(!be||!be.onHover)return;const Ae=new u.Vector2(ue.clientX,ue.clientY),Ie=me!==yn.END&&be.needWorldPosition?oe(te,pe,Ne):null,we=be.valueCallback?be.valueCallback(Ae,(Re=Ie==null?void 0:Ie.worldPosition)!=null?Re:null,(Ve=Ie==null?void 0:Ie.rawWorldPosition)!=null?Ve:null):null;be.onHover(be.name,Ae,Ie==null?void 0:Ie.worldPosition,me,we,be.extra)},[oe,y]),ce=m.useCallback((te,me)=>{const ue=te&&y(te)&&A(y(te))?te:null,pe=w.current;pe&&pe!==ue&&Y(pe,yn.END,me.event,me.x,me.y),ue&&Y(ue,pe===ue?yn.CONTINUE:yn.START,me.event,me.x,me.y),w.current=ue,V(ue?y(ue):null)},[y,A,Y,V]),ae=m.useCallback(async()=>{var te;if(!M.current){for(M.current=!0;N.current;){const me=N.current;if(N.current=null,!i||i.skipPointerMovePicking){ce(null,me);continue}const ue=await ee(me.x,me.y),pe=(te=ue==null?void 0:ue.mesh)!=null?te:null;if(le(),i.skipPointerMovePicking){ce(null,me);continue}ce(pe,me)}M.current=!1}},[le,ee,i,ce]),X=m.useCallback(async(te,me,ue)=>{var Re;if(!i)return;for(;M.current;)await new Promise(Ve=>setTimeout(Ve,8));if(Date.now()-E.current<100){E.current=Date.now();return}E.current=Date.now();const pe=await ee(me,ue);le();const Ne=(Re=pe==null?void 0:pe.mesh)!=null?Re:null,be=y(Ne);if(console.log(`[Geo3DViewer] 指针拾取 ${!!Ne} 于面 ${Ne}`,be,pe),!Ne||!be)return;const Ae=new u.Vector2(te.clientX,te.clientY),Ie=oe(Ne,me,ue),we=be.valueCallback?be.valueCallback(Ae,Ie.worldPosition,Ie.rawWorldPosition):null;if(te.button===0&&be.onLeftClick){be.onLeftClick(be.name,Ae,Ie.worldPosition,we,be.extra);return}if(te.button===1&&be.onMiddleClick){be.onMiddleClick(be.name,Ae,Ie.worldPosition,we,be.extra);return}te.button===2&&be.onRightClick&&be.onRightClick(be.name,Ae,Ie.worldPosition,we,be.extra)},[le,oe,y,ee,i]);m.useEffect(()=>{if(i)return i.skipPointerDownPicking=!0,i.skipPointerUpPicking=!0,()=>{i.skipPointerDownPicking=!1,i.skipPointerUpPicking=!1}},[i]),m.useEffect(()=>{if(!i)return;const te=4,me=i.onPointerObservable.add(ue=>{const pe=ue.event;if(ue.type===u.PointerEventTypes.POINTERDOWN){L.current.isDown=!0,L.current.pointerId=pe.pointerId,L.current.startX=i.pointerX,L.current.startY=i.pointerY,L.current.isDragging=!1;return}if(ue.type===u.PointerEventTypes.POINTERMOVE){if(L.current.isDown&&L.current.pointerId===pe.pointerId&&!L.current.isDragging){const Ne=i.pointerX-L.current.startX,be=i.pointerY-L.current.startY;Ne*Ne+be*be>=te*te&&(L.current.isDragging=!0)}if(i.skipPointerMovePicking||L.current.isDragging){w.current&&ce(null,{event:pe,x:i.pointerX,y:i.pointerY});return}N.current={event:pe,x:i.pointerX,y:i.pointerY},ae();return}if(ue.type===u.PointerEventTypes.POINTERUP){const Ne=L.current.isDragging;if(L.current.isDown=!1,L.current.pointerId=-1,L.current.isDragging=!1,i.skipPointerMovePicking||Ne)return;X(pe,i.pointerX,i.pointerY)}});return()=>{i.onPointerObservable.remove(me),N.current=null,w.current=null,L.current.isDown=!1,L.current.pointerId=-1,L.current.isDragging=!1,V(null)}},[X,ae,i,V,ce]),m.useEffect(()=>()=>{var te;N.current=null,S.current=[],w.current=null,D.current.clear(),(te=k.current)==null||te.dispose(),k.current=null,b.current=null},[]);const Pe=m.useRef(void 0);return m.useImperativeHandle(t,()=>i,[i]),C.jsx(Le.Provider,{value:{min:(ge=a.min)!=null?ge:new u.Vector3(Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER),max:(H=a.max)!=null?H:new u.Vector3(Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER),scaleDepth:(Q=a.scaleDepth)!=null?Q:1,scalePlane:(Ee=a.scalePlane)!=null?Ee:1,_isDefault:(ke=a._isDefault)!=null?ke:!0,origin:u.Vector3.Zero()},children:C.jsx(Mo.Provider,{value:{viewCamera:s,setViewCamera:c,cameraRefObject:Pe},children:C.jsx(Ro.Provider,{value:o,children:C.jsxs(Bo.Provider,{value:{cache:f,setCache:d,loadedCount:h,totalCount:x,pending:T,inflight:P,reported:v},children:[C.jsx(Is,{}),C.jsx(Vn.Provider,{value:{colorCodecsImage:p},children:C.jsx(Lt.Provider,{value:r,children:C.jsx(Mi.Provider,{value:{gpuPickingTexture:b},children:n})})})]})})})})},Es=m.forwardRef(ks),Ns=new TextDecoder;var Me=(e=>(e[e.URL_PREFIX_MATCH=0]="URL_PREFIX_MATCH",e[e.EXACTLY_MATCH=1]="EXACTLY_MATCH",e))(Me||{}),Li=(e=>(e[e.BINARY=0]="BINARY",e[e.TEXTURE=1]="TEXTURE",e[e.MODEL=2]="MODEL",e[e.JSON=3]="JSON",e))(Li||{});const $n=({url:e,cacheType:t=0,assetType:n=0})=>{var M,w,S,N,F,B;const a=_e.useScene(),{onPreFetch:r}=m.useContext(Ro),o=m.useContext(Bo),i=m.useRef(0),l=m.useRef(0),s=m.useRef(new Set),c=m.useRef(new Map),[p,f]=m.useState(void 0),d=(M=o==null?void 0:o.cache)!=null?M:{},x=(w=o==null?void 0:o.setCache)!=null?w:()=>{},h=(S=o==null?void 0:o.loadedCount)!=null?S:l,T=(N=o==null?void 0:o.totalCount)!=null?N:i,P=(F=o==null?void 0:o.pending)!=null?F:s,v=(B=o==null?void 0:o.inflight)!=null?B:c,_=m.useCallback(async I=>{let D=1,E;for(;D>=0;)try{return(await Ut.get(I,{responseType:"arraybuffer",timeout:2e4})).data}catch(L){E=L,D-=1,D>=0&&await new Promise(y=>setTimeout(y,300))}throw E},[]),b=m.useCallback((I,D)=>{if(I){if(D===1)return d[I];if(D===0){const E=I.split("?")[0];return d[E]}}},[d]),k=m.useCallback(async(I,D,E)=>{const L=v.current.get(I);if(L){const A=await L;A&&f(A);return}const y=(async()=>{P.current.add(I),T.current=T.current+1;try{const A=await r(I),V=[];A!==I&&V.push(I),D===0?(V.push(A.split("?")[0]),V.push(A)):D===1&&V.push(A);const $=await _(A),W={};let ne;if(E===0)ne={buffer:$};else if(E===1){const ee=URL.createObjectURL(new Blob([$])),G=new u.Texture(ee,a,!0,!1,void 0,()=>{URL.revokeObjectURL(ee)},()=>{URL.revokeObjectURL(ee)});ne={buffer:$,texture:G}}else if(E===2){if(!a)throw new Error("Scene not ready for model loading");const ee=URL.createObjectURL(new Blob([$]));try{let G=A.split("?")[0];G=(G==null?void 0:G.split(".").pop())||"";const le=await u.LoadAssetContainerAsync(ee,a,{pluginExtension:`.${G}`});ne={buffer:$,assets:le}}finally{URL.revokeObjectURL(ee)}}else ne={buffer:$,json:JSON.parse(Ns.decode($))};return V.forEach(ee=>{W[ee]=ne}),x(ee=>{let G=!1;const le={...ee};return V.forEach(re=>{le[re]||(le[re]=ne,G=!0)}),G?le:ee}),h.current=h.current+1,f(ne),ne}catch(A){console.error(A),h.current=h.current+1;return}finally{P.current.delete(I),v.current.delete(I)}})();v.current.set(I,y),await y},[_,r,v,h,P,x,T,a]);return m.useEffect(()=>{if(e){const I=b(e,t);if(I){f(I);return}P.current.has(e)||k(e,t,n)}},[n,t,k,b,P,e]),p},je=({url:e,cacheType:t=0})=>{const n=$n({url:e,cacheType:t,assetType:0}),[a,r]=m.useState(void 0);return m.useEffect(()=>{r(o=>(n==null?void 0:n.buffer)!==o?n==null?void 0:n.buffer:o)},[n]),a},He=({url:e,cacheType:t=0})=>{const n=$n({url:e,cacheType:t,assetType:1}),[a,r]=m.useState(void 0);return m.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},Ri=({url:e,cacheType:t=0})=>{const n=$n({url:e,cacheType:t,assetType:2}),[a,r]=m.useState(void 0);return m.useEffect(()=>{r(o=>(n==null?void 0:n.assets)!==o?n==null?void 0:n.assets:o)},[n]),a},Bo=m.createContext(void 0),Is=()=>{var b,k,M,w;const e=_e.useScene(),t=_e.useEngine(),{onFinish:n,onProgress:a,useLoadingScreen:r,hideLoadingWhenPostCalculate:o}=m.useContext(Ro),i=m.useContext(Bo),l=m.useRef(0),s=m.useRef(0),c=m.useRef({lastReportedLoaded:-1,lastReportedTotal:-1}),p=m.useRef([]),f=(b=i==null?void 0:i.totalCount)!=null?b:l,d=(k=i==null?void 0:i.loadedCount)!=null?k:s,x=(M=i==null?void 0:i.reported)!=null?M:c,h=(w=i==null?void 0:i.pending)!=null?w:p,T=m.useRef(null),P=Array.isArray(h.current)?h.current.length:h.current.size,v=m.useCallback(S=>{r===Lo.ENGINE_DEFAULT&&t&&(S?(T.current&&(clearTimeout(T.current),T.current=null),console.log("[Geo3DViewer] 显示加载界面"),t.displayLoadingUI()):T.current=setTimeout(()=>{console.log("[Geo3DViewer] 隐藏加载界面"),t.hideLoadingUI()},100))},[r,t]),_=m.useCallback(()=>{if(e&&x&&x.current){if(x.current.lastReportedLoaded!=d.current||x.current.lastReportedTotal!=f.current||P>0){console.log("[Geo3DViewer] 加载进度",d.current,f.current,P,"使用 Post 加载器",o,e.getMeshesByTags("loading").length+e.getTransformNodesByTags("loading").length);const S=a||(()=>{}),N=n||(()=>{});d.current<f.current||P>0||o&&e.getMeshesByTags("loading").length+e.getTransformNodesByTags("loading").length>0?(console.log("[Geo3DViewer] 加载进度",d.current,f.current),S(d.current,f.current),v(!0)):o?e.getMeshesByTags("loading").length+e.getTransformNodesByTags("loading").length===0&&(N(),v(!1)):d.current===f.current&&(N(),v(!1))}x.current.lastReportedLoaded=d.current,x.current.lastReportedTotal=f.current}},[x,d,f,a,h,v,o,e,n]);return m.useEffect(()=>{_();const S=setInterval(()=>{_()},1e3);return()=>clearInterval(S)},[_]),C.jsx(C.Fragment,{})},ws=({url:e,cacheType:t,assetType:n=Li.BINARY})=>($n({url:e,cacheType:t,assetType:n}),C.jsx(C.Fragment,{}));class Os{constructor(t){ve(this,"_nodes",[]);ve(this,"_speed",1);ve(this,"_loop",!1);ve(this,"_length",0);ve(this,"_name","");ve(this,"_stop",!1);ve(this,"_handler");ve(this,"_normalizedTime",0);ve(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 Bi={},uo={},As=Ms;function Ms(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(l,s){n[a]=function(p){if(o)if(o=!1,p)s(p);else{for(var f=new Array(arguments.length-1),d=0;d<f.length;)f[d++]=arguments[d];l.apply(null,f)}};try{e.apply(t||null,n)}catch(c){o&&(o=!1,s(c))}})}var Fi={};(function(e){var t=e;t.length=function(l){var s=l.length;if(!s)return 0;for(var c=0;--s%4>1&&l.charAt(s)==="=";)++c;return Math.ceil(l.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(l,s,c){for(var p=null,f=[],d=0,x=0,h;s<c;){var T=l[s++];switch(x){case 0:f[d++]=n[T>>2],h=(T&3)<<4,x=1;break;case 1:f[d++]=n[h|T>>4],h=(T&15)<<2,x=2;break;case 2:f[d++]=n[h|T>>6],f[d++]=n[T&63],x=0;break}d>8191&&((p||(p=[])).push(String.fromCharCode.apply(String,f)),d=0)}return x&&(f[d++]=n[h],f[d++]=61,x===1&&(f[d++]=61)),p?(d&&p.push(String.fromCharCode.apply(String,f.slice(0,d))),p.join("")):String.fromCharCode.apply(String,f.slice(0,d))};var o="invalid encoding";t.decode=function(l,s,c){for(var p=c,f=0,d,x=0;x<l.length;){var h=l.charCodeAt(x++);if(h===61&&f>1)break;if((h=a[h])===void 0)throw Error(o);switch(f){case 0:d=h,f=1;break;case 1:s[c++]=d<<2|(h&48)>>4,d=h,f=2;break;case 2:s[c++]=(d&15)<<4|(h&60)>>2,d=h,f=3;break;case 3:s[c++]=(d&3)<<6|h,f=0;break}}if(f===1)throw Error(o);return c-p},t.test=function(l){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(l)}})(Fi);var Ls=Wn;function Wn(){this._listeners=Object.create(null)}Wn.prototype.on=function(t,n,a){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:n,ctx:a||this}),this};Wn.prototype.off=function(t,n){if(t===void 0)this._listeners=Object.create(null);else if(n===void 0)this._listeners[t]=[];else{var a=this._listeners[t];if(!a)return this;for(var r=0;r<a.length;)a[r].fn===n?a.splice(r,1):++r}return this};Wn.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 Rs=gr(gr);function gr(e){return typeof Float32Array!="undefined"?function(){var t=new Float32Array([-0]),n=new Uint8Array(t.buffer),a=n[3]===128;function r(s,c,p){t[0]=s,c[p]=n[0],c[p+1]=n[1],c[p+2]=n[2],c[p+3]=n[3]}function o(s,c,p){t[0]=s,c[p]=n[3],c[p+1]=n[2],c[p+2]=n[1],c[p+3]=n[0]}e.writeFloatLE=a?r:o,e.writeFloatBE=a?o:r;function i(s,c){return n[0]=s[c],n[1]=s[c+1],n[2]=s[c+2],n[3]=s[c+3],t[0]}function l(s,c){return n[3]=s[c],n[2]=s[c+1],n[1]=s[c+2],n[0]=s[c+3],t[0]}e.readFloatLE=a?i:l,e.readFloatBE=a?l:i}():function(){function t(a,r,o,i){var l=r<0?1:0;if(l&&(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((l<<31|2139095040)>>>0,o,i);else if(r<11754943508222875e-54)a((l<<31|Math.round(r/1401298464324817e-60))>>>0,o,i);else{var s=Math.floor(Math.log(r)/Math.LN2),c=Math.round(r*Math.pow(2,-s)*8388608)&8388607;a((l<<31|s+127<<23|c)>>>0,o,i)}}e.writeFloatLE=t.bind(null,vr),e.writeFloatBE=t.bind(null,xr);function n(a,r,o){var i=a(r,o),l=(i>>31)*2+1,s=i>>>23&255,c=i&8388607;return s===255?c?NaN:l*(1/0):s===0?l*1401298464324817e-60*c:l*Math.pow(2,s-150)*(c+8388608)}e.readFloatLE=n.bind(null,yr),e.readFloatBE=n.bind(null,Cr)}(),typeof Float64Array!="undefined"?function(){var t=new Float64Array([-0]),n=new Uint8Array(t.buffer),a=n[7]===128;function r(s,c,p){t[0]=s,c[p]=n[0],c[p+1]=n[1],c[p+2]=n[2],c[p+3]=n[3],c[p+4]=n[4],c[p+5]=n[5],c[p+6]=n[6],c[p+7]=n[7]}function o(s,c,p){t[0]=s,c[p]=n[7],c[p+1]=n[6],c[p+2]=n[5],c[p+3]=n[4],c[p+4]=n[3],c[p+5]=n[2],c[p+6]=n[1],c[p+7]=n[0]}e.writeDoubleLE=a?r:o,e.writeDoubleBE=a?o:r;function i(s,c){return n[0]=s[c],n[1]=s[c+1],n[2]=s[c+2],n[3]=s[c+3],n[4]=s[c+4],n[5]=s[c+5],n[6]=s[c+6],n[7]=s[c+7],t[0]}function l(s,c){return n[7]=s[c],n[6]=s[c+1],n[5]=s[c+2],n[4]=s[c+3],n[3]=s[c+4],n[2]=s[c+5],n[1]=s[c+6],n[0]=s[c+7],t[0]}e.readDoubleLE=a?i:l,e.readDoubleBE=a?l:i}():function(){function t(a,r,o,i,l,s){var c=i<0?1:0;if(c&&(i=-i),i===0)a(0,l,s+r),a(1/i>0?0:2147483648,l,s+o);else if(isNaN(i))a(0,l,s+r),a(2146959360,l,s+o);else if(i>17976931348623157e292)a(0,l,s+r),a((c<<31|2146435072)>>>0,l,s+o);else{var p;if(i<22250738585072014e-324)p=i/5e-324,a(p>>>0,l,s+r),a((c<<31|p/4294967296)>>>0,l,s+o);else{var f=Math.floor(Math.log(i)/Math.LN2);f===1024&&(f=1023),p=i*Math.pow(2,-f),a(p*4503599627370496>>>0,l,s+r),a((c<<31|f+1023<<20|p*1048576&1048575)>>>0,l,s+o)}}}e.writeDoubleLE=t.bind(null,vr,0,4),e.writeDoubleBE=t.bind(null,xr,4,0);function n(a,r,o,i,l){var s=a(i,l+r),c=a(i,l+o),p=(c>>31)*2+1,f=c>>>20&2047,d=4294967296*(c&1048575)+s;return f===2047?d?NaN:p*(1/0):f===0?p*5e-324*d:p*Math.pow(2,f-1075)*(d+4503599627370496)}e.readDoubleLE=n.bind(null,yr,0,4),e.readDoubleBE=n.bind(null,Cr,4,0)}(),e}function vr(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 xr(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 yr(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function Cr(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}var Bs=Fs;function Fs(e){try{if(typeof Po!="function")return null;var t=Po(e);return t&&(t.length||Object.keys(t).length)?t:null}catch(n){return null}}var Di={};(function(e){var t=e,n="�";t.length=function(r){for(var o=0,i=0,l=0;l<r.length;++l)i=r.charCodeAt(l),i<128?o+=1:i<2048?o+=2:(i&64512)===55296&&(r.charCodeAt(l+1)&64512)===56320?(++l,o+=4):o+=3;return o},t.read=function(r,o,i){if(i-o<1)return"";for(var l="",s=o;s<i;){var c=r[s++];if(c<=127)l+=String.fromCharCode(c);else if(c>=192&&c<224){var p=(c&31)<<6|r[s++]&63;l+=p>=128?String.fromCharCode(p):n}else if(c>=224&&c<240){var f=(c&15)<<12|(r[s++]&63)<<6|r[s++]&63;l+=f>=2048?String.fromCharCode(f):n}else if(c>=240){var d=(c&7)<<18|(r[s++]&63)<<12|(r[s++]&63)<<6|r[s++]&63;d<65536||d>1114111?l+=n:(d-=65536,l+=String.fromCharCode(55296+(d>>10)),l+=String.fromCharCode(56320+(d&1023)))}}return l},t.write=function(r,o,i){for(var l=i,s,c,p=0;p<r.length;++p)s=r.charCodeAt(p),s<128?o[i++]=s:s<2048?(o[i++]=s>>6|192,o[i++]=s&63|128):(s&64512)===55296&&((c=r.charCodeAt(p+1))&64512)===56320?(s=65536+((s&1023)<<10)+(c&1023),++p,o[i++]=s>>18|240,o[i++]=s>>12&63|128,o[i++]=s>>6&63|128,o[i++]=s&63|128):(o[i++]=s>>12|224,o[i++]=s>>6&63|128,o[i++]=s&63|128);return i-l}})(Di);var Ds=zs;function zs(e,t,n){var a=n||8192,r=a>>>1,o=null,i=a;return function(s){if(s<1||s>r)return e(s);i+s>a&&(o=e(a),i=0);var c=t.call(o,i,i+=s);return i&7&&(i=(i|7)+1),c}}var fo,_r;function Vs(){if(_r)return fo;_r=1,fo=t;var e=Qt();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 l=i<0;l&&(i=-i);var s=i>>>0,c=(i-s)/4294967296>>>0;return l&&(c=~c>>>0,s=~s>>>0,++s>4294967295&&(s=0,++c>4294967295&&(c=0))),new t(s,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 l=~this.lo+1>>>0,s=~this.hi>>>0;return l||(s=s+1>>>0),-(l+s*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,l=(this.lo>>>28|this.hi<<4)>>>0,s=this.hi>>>24;return s===0?l===0?i<16384?i<128?1:2:i<2097152?3:4:l<16384?l<128?5:6:l<2097152?7:8:s<128?9:10},fo}var In={exports:{}},Pr;function $s(){return Pr||(Pr=1,function(e,t){(function(n,a){function r(o){return o.default||o}a(t),e.exports=r(t)})(typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:Rt,function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;/**
2
2
  * @license
3
3
  * Copyright 2009 The Closure Library Authors
4
4
  * Copyright 2020 Daniel Wirtz / The long.js Authors.
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  *
18
18
  * SPDX-License-Identifier: Apache-2.0
19
- */var a=null;try{a=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(L){}function i(L,y,A){this.low=L|0,this.high=y|0,this.unsigned=!!A}i.prototype.__isLong__,Object.defineProperty(i.prototype,"__isLong__",{value:!0});function o(L){return(L&&L.__isLong__)===!0}function r(L){var y=Math.clz32(L&-L);return L?31-y:y}i.isLong=o;var l={},s={};function c(L,y){var A,V,$;return y?(L>>>=0,($=0<=L&&L<256)&&(V=s[L],V)?V:(A=f(L,0,!0),$&&(s[L]=A),A)):(L|=0,($=-128<=L&&L<128)&&(V=l[L],V)?V:(A=f(L,L<0?-1:0,!1),$&&(l[L]=A),A))}i.fromInt=c;function p(L,y){if(isNaN(L))return y?w:M;if(y){if(L<0)return w;if(L>=_)return I}else{if(L<=-b)return D;if(L+1>=b)return B}return L<0?p(-L,y).neg():f(L%v|0,L/v|0,y)}i.fromNumber=p;function f(L,y,A){return new i(L,y,A)}i.fromBits=f;var d=Math.pow;function x(L,y,A){if(L.length===0)throw Error("empty string");if(typeof y=="number"?(A=y,y=!1):y=!!y,L==="NaN"||L==="Infinity"||L==="+Infinity"||L==="-Infinity")return y?w:M;if(A=A||10,A<2||36<A)throw RangeError("radix");var V;if((V=L.indexOf("-"))>0)throw Error("interior hyphen");if(V===0)return x(L.substring(1),y,A).neg();for(var $=p(d(A,8)),W=M,ne=0;ne<L.length;ne+=8){var ee=Math.min(8,L.length-ne),G=parseInt(L.substring(ne,ne+ee),A);if(ee<8){var le=p(d(A,ee));W=W.mul(le).add(p(G))}else W=W.mul($),W=W.add(p(G))}return W.unsigned=y,W}i.fromString=x;function h(L,y){return typeof L=="number"?p(L,y):typeof L=="string"?x(L,y):f(L.low,L.high,typeof y=="boolean"?y:L.unsigned)}i.fromValue=h;var T=65536,P=1<<24,v=T*T,_=v*v,b=_/2,k=c(P),M=c(0);i.ZERO=M;var w=c(0,!0);i.UZERO=w;var S=c(1);i.ONE=S;var N=c(1,!0);i.UONE=N;var F=c(-1);i.NEG_ONE=F;var B=f(-1,2147483647,!1);i.MAX_VALUE=B;var I=f(-1,-1,!0);i.MAX_UNSIGNED_VALUE=I;var D=f(0,-2147483648,!1);i.MIN_VALUE=D;var E=i.prototype;E.toInt=function(){return this.unsigned?this.low>>>0:this.low},E.toNumber=function(){return this.unsigned?(this.high>>>0)*v+(this.low>>>0):this.high*v+(this.low>>>0)},E.toString=function(y){if(y=y||10,y<2||36<y)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(D)){var A=p(y),V=this.div(A),$=V.mul(A).sub(this);return V.toString(y)+$.toInt().toString(y)}else return"-"+this.neg().toString(y);for(var W=p(d(y,6),this.unsigned),ne=this,ee="";;){var G=ne.div(W),le=ne.sub(G.mul(W)).toInt()>>>0,re=le.toString(y);if(ne=G,ne.isZero())return re+ee;for(;re.length<6;)re="0"+re;ee=""+re+ee}},E.getHighBits=function(){return this.high},E.getHighBitsUnsigned=function(){return this.high>>>0},E.getLowBits=function(){return this.low},E.getLowBitsUnsigned=function(){return this.low>>>0},E.getNumBitsAbs=function(){if(this.isNegative())return this.eq(D)?64:this.neg().getNumBitsAbs();for(var y=this.high!=0?this.high:this.low,A=31;A>0&&!(y&1<<A);A--);return this.high!=0?A+33:A+1},E.isSafeInteger=function(){var y=this.high>>21;return y?this.unsigned?!1:y===-1&&!(this.low===0&&this.high===-2097152):!0},E.isZero=function(){return this.high===0&&this.low===0},E.eqz=E.isZero,E.isNegative=function(){return!this.unsigned&&this.high<0},E.isPositive=function(){return this.unsigned||this.high>=0},E.isOdd=function(){return(this.low&1)===1},E.isEven=function(){return(this.low&1)===0},E.equals=function(y){return o(y)||(y=h(y)),this.unsigned!==y.unsigned&&this.high>>>31===1&&y.high>>>31===1?!1:this.high===y.high&&this.low===y.low},E.eq=E.equals,E.notEquals=function(y){return!this.eq(y)},E.neq=E.notEquals,E.ne=E.notEquals,E.lessThan=function(y){return this.comp(y)<0},E.lt=E.lessThan,E.lessThanOrEqual=function(y){return this.comp(y)<=0},E.lte=E.lessThanOrEqual,E.le=E.lessThanOrEqual,E.greaterThan=function(y){return this.comp(y)>0},E.gt=E.greaterThan,E.greaterThanOrEqual=function(y){return this.comp(y)>=0},E.gte=E.greaterThanOrEqual,E.ge=E.greaterThanOrEqual,E.compare=function(y){if(o(y)||(y=h(y)),this.eq(y))return 0;var A=this.isNegative(),V=y.isNegative();return A&&!V?-1:!A&&V?1:this.unsigned?y.high>>>0>this.high>>>0||y.high===this.high&&y.low>>>0>this.low>>>0?-1:1:this.sub(y).isNegative()?-1:1},E.comp=E.compare,E.negate=function(){return!this.unsigned&&this.eq(D)?D:this.not().add(S)},E.neg=E.negate,E.add=function(y){o(y)||(y=h(y));var A=this.high>>>16,V=this.high&65535,$=this.low>>>16,W=this.low&65535,ne=y.high>>>16,ee=y.high&65535,G=y.low>>>16,le=y.low&65535,re=0,oe=0,Y=0,ce=0;return ce+=W+le,Y+=ce>>>16,ce&=65535,Y+=$+G,oe+=Y>>>16,Y&=65535,oe+=V+ee,re+=oe>>>16,oe&=65535,re+=A+ne,re&=65535,f(Y<<16|ce,re<<16|oe,this.unsigned)},E.subtract=function(y){return o(y)||(y=h(y)),this.add(y.neg())},E.sub=E.subtract,E.multiply=function(y){if(this.isZero())return this;if(o(y)||(y=h(y)),a){var A=a.mul(this.low,this.high,y.low,y.high);return f(A,a.get_high(),this.unsigned)}if(y.isZero())return this.unsigned?w:M;if(this.eq(D))return y.isOdd()?D:M;if(y.eq(D))return this.isOdd()?D:M;if(this.isNegative())return y.isNegative()?this.neg().mul(y.neg()):this.neg().mul(y).neg();if(y.isNegative())return this.mul(y.neg()).neg();if(this.lt(k)&&y.lt(k))return p(this.toNumber()*y.toNumber(),this.unsigned);var V=this.high>>>16,$=this.high&65535,W=this.low>>>16,ne=this.low&65535,ee=y.high>>>16,G=y.high&65535,le=y.low>>>16,re=y.low&65535,oe=0,Y=0,ce=0,ae=0;return ae+=ne*re,ce+=ae>>>16,ae&=65535,ce+=W*re,Y+=ce>>>16,ce&=65535,ce+=ne*le,Y+=ce>>>16,ce&=65535,Y+=$*re,oe+=Y>>>16,Y&=65535,Y+=W*le,oe+=Y>>>16,Y&=65535,Y+=ne*G,oe+=Y>>>16,Y&=65535,oe+=V*re+$*le+W*G+ne*ee,oe&=65535,f(ce<<16|ae,oe<<16|Y,this.unsigned)},E.mul=E.multiply,E.divide=function(y){if(o(y)||(y=h(y)),y.isZero())throw Error("division by zero");if(a){if(!this.unsigned&&this.high===-2147483648&&y.low===-1&&y.high===-1)return this;var A=(this.unsigned?a.div_u:a.div_s)(this.low,this.high,y.low,y.high);return f(A,a.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?w:M;var V,$,W;if(this.unsigned){if(y.unsigned||(y=y.toUnsigned()),y.gt(this))return w;if(y.gt(this.shru(1)))return N;W=w}else{if(this.eq(D)){if(y.eq(S)||y.eq(F))return D;if(y.eq(D))return S;var ne=this.shr(1);return V=ne.div(y).shl(1),V.eq(M)?y.isNegative()?S:F:($=this.sub(y.mul(V)),W=V.add($.div(y)),W)}else if(y.eq(D))return this.unsigned?w:M;if(this.isNegative())return y.isNegative()?this.neg().div(y.neg()):this.neg().div(y).neg();if(y.isNegative())return this.div(y.neg()).neg();W=M}for($=this;$.gte(y);){V=Math.max(1,Math.floor($.toNumber()/y.toNumber()));for(var ee=Math.ceil(Math.log(V)/Math.LN2),G=ee<=48?1:d(2,ee-48),le=p(V),re=le.mul(y);re.isNegative()||re.gt($);)V-=G,le=p(V,this.unsigned),re=le.mul(y);le.isZero()&&(le=S),W=W.add(le),$=$.sub(re)}return W},E.div=E.divide,E.modulo=function(y){if(o(y)||(y=h(y)),a){var A=(this.unsigned?a.rem_u:a.rem_s)(this.low,this.high,y.low,y.high);return f(A,a.get_high(),this.unsigned)}return this.sub(this.div(y).mul(y))},E.mod=E.modulo,E.rem=E.modulo,E.not=function(){return f(~this.low,~this.high,this.unsigned)},E.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},E.clz=E.countLeadingZeros,E.countTrailingZeros=function(){return this.low?r(this.low):r(this.high)+32},E.ctz=E.countTrailingZeros,E.and=function(y){return o(y)||(y=h(y)),f(this.low&y.low,this.high&y.high,this.unsigned)},E.or=function(y){return o(y)||(y=h(y)),f(this.low|y.low,this.high|y.high,this.unsigned)},E.xor=function(y){return o(y)||(y=h(y)),f(this.low^y.low,this.high^y.high,this.unsigned)},E.shiftLeft=function(y){return o(y)&&(y=y.toInt()),(y&=63)===0?this:y<32?f(this.low<<y,this.high<<y|this.low>>>32-y,this.unsigned):f(0,this.low<<y-32,this.unsigned)},E.shl=E.shiftLeft,E.shiftRight=function(y){return o(y)&&(y=y.toInt()),(y&=63)===0?this:y<32?f(this.low>>>y|this.high<<32-y,this.high>>y,this.unsigned):f(this.high>>y-32,this.high>=0?0:-1,this.unsigned)},E.shr=E.shiftRight,E.shiftRightUnsigned=function(y){return o(y)&&(y=y.toInt()),(y&=63)===0?this:y<32?f(this.low>>>y|this.high<<32-y,this.high>>>y,this.unsigned):y===32?f(this.high,0,this.unsigned):f(this.high>>>y-32,0,this.unsigned)},E.shru=E.shiftRightUnsigned,E.shr_u=E.shiftRightUnsigned,E.rotateLeft=function(y){var A;return o(y)&&(y=y.toInt()),(y&=63)===0?this:y===32?f(this.high,this.low,this.unsigned):y<32?(A=32-y,f(this.low<<y|this.high>>>A,this.high<<y|this.low>>>A,this.unsigned)):(y-=32,A=32-y,f(this.high<<y|this.low>>>A,this.low<<y|this.high>>>A,this.unsigned))},E.rotl=E.rotateLeft,E.rotateRight=function(y){var A;return o(y)&&(y=y.toInt()),(y&=63)===0?this:y===32?f(this.high,this.low,this.unsigned):y<32?(A=32-y,f(this.high<<A|this.low>>>y,this.low<<A|this.high>>>y,this.unsigned)):(y-=32,A=32-y,f(this.low<<A|this.high>>>y,this.high<<A|this.low>>>y,this.unsigned))},E.rotr=E.rotateRight,E.toSigned=function(){return this.unsigned?f(this.low,this.high,!1):this},E.toUnsigned=function(){return this.unsigned?this:f(this.low,this.high,!0)},E.toBytes=function(y){return y?this.toBytesLE():this.toBytesBE()},E.toBytesLE=function(){var y=this.high,A=this.low;return[A&255,A>>>8&255,A>>>16&255,A>>>24,y&255,y>>>8&255,y>>>16&255,y>>>24]},E.toBytesBE=function(){var y=this.high,A=this.low;return[y>>>24,y>>>16&255,y>>>8&255,y&255,A>>>24,A>>>16&255,A>>>8&255,A&255]},i.fromBytes=function(y,A,V){return V?i.fromBytesLE(y,A):i.fromBytesBE(y,A)},i.fromBytesLE=function(y,A){return new i(y[0]|y[1]<<8|y[2]<<16|y[3]<<24,y[4]|y[5]<<8|y[6]<<16|y[7]<<24,A)},i.fromBytesBE=function(y,A){return new i(y[4]<<24|y[5]<<16|y[6]<<8|y[7],y[0]<<24|y[1]<<16|y[2]<<8|y[3],A)},typeof BigInt=="function"&&(i.fromBigInt=function(y,A){var V=Number(BigInt.asIntN(32,y)),$=Number(BigInt.asIntN(32,y>>BigInt(32)));return f(V,$,A)},i.fromValue=function(y,A){return typeof y=="bigint"?i.fromBigInt(y,A):h(y,A)},E.toBigInt=function(){var y=BigInt(this.low>>>0),A=BigInt(this.unsigned?this.high>>>0:this.high);return A<<BigInt(32)|y}),n.default=i})}(In,In.exports)),In.exports}var _r;function Qt(){return _r||(_r=1,function(e){var t=e;t.asPromise=ws,t.base64=Fi,t.EventEmitter=As,t.float=Ms,t.inquire=Ls,t.utf8=Di,t.pool=Bs,t.LongBits=Ds();function n(o){return o==="__proto__"||o==="prototype"||o==="constructor"}t.isUnsafeProperty=n,t.isNode=!!(typeof Rt!="undefined"&&Rt&&Rt.process&&Rt.process.versions&&Rt.process.versions.node),t.global=t.isNode&&Rt||typeof window!="undefined"&&window||typeof self!="undefined"&&self||Rt,t.emptyArray=Object.freeze?Object.freeze([]):[],t.emptyObject=Object.freeze?Object.freeze({}):{},t.isInteger=Number.isInteger||function(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r},t.isString=function(r){return typeof r=="string"||r instanceof String},t.isObject=function(r){return r&&typeof r=="object"},t.isset=t.isSet=function(r,l){var s=r[l];return s!=null&&r.hasOwnProperty(l)?typeof s!="object"||(Array.isArray(s)?s.length:Object.keys(s).length)>0:!1},t.Buffer=function(){try{var o=t.global.Buffer;return o.prototype.utf8Write?o:null}catch(r){return null}}(),t._Buffer_from=null,t._Buffer_allocUnsafe=null,t.newBuffer=function(r){return typeof r=="number"?t.Buffer?t._Buffer_allocUnsafe(r):new t.Array(r):t.Buffer?t._Buffer_from(r):typeof Uint8Array=="undefined"?r:new Uint8Array(r)},t.Array=typeof Uint8Array!="undefined"?Uint8Array:Array,t.Long=t.global.dcodeIO&&t.global.dcodeIO.Long||t.global.Long||function(){try{var o=zs();return o&&o.isLong?o:null}catch(r){return null}}(),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(r){return r?t.LongBits.from(r).toHash():t.LongBits.zeroHash},t.longFromHash=function(r,l){var s=t.LongBits.fromHash(r);return t.Long?t.Long.fromBits(s.lo,s.hi,l):s.toNumber(!!l)};function a(o){var r=typeof arguments[arguments.length-1]=="boolean",l=r?arguments.length-1:arguments.length;r=r&&arguments[arguments.length-1];for(var s=1;s<l;++s){var c=arguments[s];if(c)for(var p=Object.keys(c),f=0;f<p.length;++f)!n(p[f])&&(o[p[f]]===void 0||!r)&&(o[p[f]]=c[p[f]])}return o}t.merge=a,t.nestingLimit=32,t.recursionLimit=100,t.makeProp=function(r,l){Object.defineProperty(r,l,{enumerable:!0,configurable:!0,writable:!0})},t.lcFirst=function(r){return r.charAt(0).toLowerCase()+r.substring(1)};function i(o){function r(l,s){if(!(this instanceof r))return new r(l,s);Object.defineProperty(this,"message",{get:function(){return l}}),Error.captureStackTrace?Error.captureStackTrace(this,r):Object.defineProperty(this,"stack",{value:new Error().stack||""}),s&&a(this,s)}return r.prototype=Object.create(Error.prototype,{constructor:{value:r,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return o},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),r}t.newError=i,t.ProtocolError=i("ProtocolError"),t.oneOfGetter=function(r){for(var l={},s=0;s<r.length;++s)l[r[s]]=1;return function(){for(var c=Object.keys(this),p=c.length-1;p>-1;--p)if(l[c[p]]===1&&this[c[p]]!==void 0&&this[c[p]]!==null)return c[p]}},t.oneOfSetter=function(r){return function(l){for(var s=0;s<r.length;++s)r[s]!==l&&delete this[r[s]]}},t.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},t._configure=function(){var o=t.Buffer;if(!o){t._Buffer_from=t._Buffer_allocUnsafe=null;return}t._Buffer_from=o.from!==Uint8Array.from&&o.from||function(l,s){return new o(l,s)},t._Buffer_allocUnsafe=o.allocUnsafe||function(l){return new o(l)}}}(uo)),uo}var zi=ze,dt=Qt(),So,Un=dt.LongBits,Pr=dt.base64,Sr=dt.utf8;function bn(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}function Ro(){}function Vs(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function ze(){this.len=0,this.head=new bn(Ro,0,0),this.tail=this.head,this.states=null}var Vi=function(){return dt.Buffer?function(){return(ze.create=function(){return new So})()}:function(){return new ze}};ze.create=Vi();ze.alloc=function(t){return new dt.Array(t)};dt.Array!==Array&&(ze.alloc=dt.pool(ze.alloc,dt.Array.prototype.subarray));ze.prototype._push=function(t,n,a){return this.tail=this.tail.next=new bn(t,n,a),this.len+=n,this};function Bo(e,t,n){t[n]=e&255}function $s(e,t,n){for(;e>127;)t[n++]=e&127|128,e>>>=7;t[n]=e}function Fo(e,t){this.len=e,this.next=void 0,this.val=t}Fo.prototype=Object.create(bn.prototype);Fo.prototype.fn=$s;ze.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new Fo((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this};ze.prototype.int32=function(t){return(t|=0)<0?this._push(Do,10,Un.fromNumber(t)):this.uint32(t)};ze.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)};function Do(e,t,n){for(var a=e.lo,i=e.hi;i;)t[n++]=a&127|128,a=(a>>>7|i<<25)>>>0,i>>>=7;for(;a>127;)t[n++]=a&127|128,a=a>>>7;t[n++]=a}ze.prototype.uint64=function(t){var n=Un.from(t);return this._push(Do,n.length(),n)};ze.prototype.int64=ze.prototype.uint64;ze.prototype.sint64=function(t){var n=Un.from(t).zzEncode();return this._push(Do,n.length(),n)};ze.prototype.bool=function(t){return this._push(Bo,1,t?1:0)};function To(e,t,n){t[n]=e&255,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}ze.prototype.fixed32=function(t){return this._push(To,4,t>>>0)};ze.prototype.sfixed32=ze.prototype.fixed32;ze.prototype.fixed64=function(t){var n=Un.from(t);return this._push(To,4,n.lo)._push(To,4,n.hi)};ze.prototype.sfixed64=ze.prototype.fixed64;ze.prototype.float=function(t){return this._push(dt.float.writeFloatLE,4,t)};ze.prototype.double=function(t){return this._push(dt.float.writeDoubleLE,8,t)};var Ws=dt.Array.prototype.set?function(t,n,a){n.set(t,a)}:function(t,n,a){for(var i=0;i<t.length;++i)n[a+i]=t[i]};ze.prototype.bytes=function(t){var n=t.length>>>0;if(!n)return this._push(Bo,1,0);if(dt.isString(t)){var a=ze.alloc(n=Pr.length(t));Pr.decode(t,a,0),t=a}return this.uint32(n)._push(Ws,n,t)};ze.prototype.string=function(t){var n=Sr.length(t);return n?this.uint32(n)._push(Sr.write,n,t):this._push(Bo,1,0)};ze.prototype.fork=function(){return this.states=new Vs(this),this.head=this.tail=new bn(Ro,0,0),this.len=0,this};ze.prototype.reset=function(){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 bn(Ro,0,0),this.len=0),this};ze.prototype.ldelim=function(){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};ze.prototype.finish=function(){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};ze._configure=function(e){So=e,ze.create=Vi(),So._configure()};var Us=St,$i=zi;(St.prototype=Object.create($i.prototype)).constructor=St;var Vt=Qt();function St(){$i.call(this)}St._configure=function(){St.alloc=Vt._Buffer_allocUnsafe,St.writeBytesBuffer=Vt.Buffer&&Vt.Buffer.prototype instanceof Uint8Array&&Vt.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 i=0;i<t.length;)n[a++]=t[i++]}};St.prototype.bytes=function(t){Vt.isString(t)&&(t=Vt._Buffer_from(t,"base64"));var n=t.length>>>0;return this.uint32(n),n&&this._push(St.writeBytesBuffer,n,t),this};function Hs(e,t,n){e.length<40?Vt.utf8.write(e,t,n):t.utf8Write?t.utf8Write(e,n):t.write(e,n)}St.prototype.string=function(t){var n=Vt.Buffer.byteLength(t);return this.uint32(n),n&&this._push(Hs,n,t),this};St._configure();var Wi=Ze,pt=Qt(),bo,Ui=pt.LongBits,Zs=pt.utf8;function yt(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function Ze(e){this.buf=e,this.pos=0,this.len=e.length}var Tr=typeof Uint8Array!="undefined"?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new Ze(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new Ze(t);throw Error("illegal buffer")},Hi=function(){return pt.Buffer?function(n){return(Ze.create=function(i){return pt.Buffer.isBuffer(i)?new bo(i):Tr(i)})(n)}:Tr};Ze.create=Hi();Ze.prototype._slice=pt.Array.prototype.subarray||pt.Array.prototype.slice;Ze.prototype.uint32=function(){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,yt(this,10);return t}}();Ze.prototype.int32=function(){return this.uint32()|0};Ze.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(t&1)|0};function po(){var e=new Ui(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 yt(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 yt(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")}Ze.prototype.bool=function(){return this.uint32()!==0};function Fn(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}Ze.prototype.fixed32=function(){if(this.pos+4>this.len)throw yt(this,4);return Fn(this.buf,this.pos+=4)};Ze.prototype.sfixed32=function(){if(this.pos+4>this.len)throw yt(this,4);return Fn(this.buf,this.pos+=4)|0};function br(){if(this.pos+8>this.len)throw yt(this,8);return new Ui(Fn(this.buf,this.pos+=4),Fn(this.buf,this.pos+=4))}Ze.prototype.float=function(){if(this.pos+4>this.len)throw yt(this,4);var t=pt.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t};Ze.prototype.double=function(){if(this.pos+8>this.len)throw yt(this,4);var t=pt.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t};Ze.prototype.bytes=function(){var t=this.uint32(),n=this.pos,a=this.pos+t;if(a>this.len)throw yt(this,t);if(this.pos+=t,Array.isArray(this.buf))return this.buf.slice(n,a);if(n===a){var i=pt.Buffer;return i?i.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,n,a)};Ze.prototype.string=function(){var t=this.bytes();return Zs.read(t,0,t.length)};Ze.prototype.skip=function(t){if(typeof t=="number"){if(this.pos+t>this.len)throw yt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw yt(this);while(this.buf[this.pos++]&128);return this};Ze.recursionLimit=pt.recursionLimit;Ze.prototype.skipType=function(e,t){if(t===void 0&&(t=0),t>Ze.recursionLimit)throw Error("maximum nesting depth exceeded");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,t+1);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this};Ze._configure=function(e){bo=e,Ze.create=Hi(),bo._configure();var t=pt.Long?"toLong":"toNumber";pt.merge(Ze.prototype,{int64:function(){return po.call(this)[t](!1)},uint64:function(){return po.call(this)[t](!0)},sint64:function(){return po.call(this).zzDecode()[t](!1)},fixed64:function(){return br.call(this)[t](!0)},sfixed64:function(){return br.call(this)[t](!1)}})};var Gs=Xt,Zi=Wi;(Xt.prototype=Object.create(Zi.prototype)).constructor=Xt;var kr=Qt();function Xt(e){Zi.call(this,e)}Xt._configure=function(){kr.Buffer&&(Xt.prototype._slice=kr.Buffer.prototype.slice)};Xt.prototype.string=function(){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))};Xt._configure();var Gi={},Ys=Tn,zo=Qt();(Tn.prototype=Object.create(zo.EventEmitter.prototype)).constructor=Tn;function Tn(e,t,n){if(typeof e!="function")throw TypeError("rpcImpl must be a function");zo.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=!!t,this.responseDelimited=!!n}Tn.prototype.rpcCall=function e(t,n,a,i,o){if(!i)throw TypeError("request must be specified");var r=this;if(!o)return zo.asPromise(e,r,t,n,a,i);if(!r.rpcImpl){setTimeout(function(){o(Error("already ended"))},0);return}try{return r.rpcImpl(t,n[r.requestDelimited?"encodeDelimited":"encode"](i).finish(),function(s,c){if(s)return r.emit("error",s,t),o(s);if(c===null){r.end(!0);return}if(!(c instanceof a))try{c=a[r.responseDelimited?"decodeDelimited":"decode"](c)}catch(p){return r.emit("error",p,t),o(p)}return r.emit("data",c,t),o(null,c)})}catch(l){r.emit("error",l,t),setTimeout(function(){o(l)},0);return}};Tn.prototype.end=function(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=Ys})(Gi);var Js=Object.create(null);(function(e){var t=e;t.build="minimal",t.Writer=zi,t.BufferWriter=Us,t.Reader=Wi,t.BufferReader=Gs,t.util=Qt(),t.rpc=Gi,t.roots=Js,t.configure=n;function n(){t.util._configure(),t.Writer._configure(t.BufferWriter),t.Reader._configure(t.BufferReader)}n()})(Bi);var se=Bi;function Xs(e){switch(e){case 0:case"UNKNOWN":return 0;case 4:case"ROADWAY":return 4;case-1:case"UNRECOGNIZED":default:return-1}}function qs(e){switch(e){case 0:return"UNKNOWN";case 4:return"ROADWAY";case-1:default:return"UNRECOGNIZED"}}function Er(){return{x:0,y:0,z:0}}const K={encode(e,t=se.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=Er();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==13)break;i.x=n.float();continue;case 2:if(o!==21)break;i.y=n.float();continue;case 3:if(o!==29)break;i.z=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{x:Pt(e.x)?globalThis.Number(e.x):0,y:Pt(e.y)?globalThis.Number(e.y):0,z:Pt(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 K.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i;const t=Er();return t.x=(n=e.x)!=null?n:0,t.y=(a=e.y)!=null?a:0,t.z=(i=e.z)!=null?i:0,t}};function Nr(){return{r:0,g:0,b:0,a:0}}const ot={encode(e,t=se.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=Nr();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==13)break;i.r=n.float();continue;case 2:if(o!==21)break;i.g=n.float();continue;case 3:if(o!==29)break;i.b=n.float();continue;case 4:if(o!==37)break;i.a=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{r:Pt(e.r)?globalThis.Number(e.r):0,g:Pt(e.g)?globalThis.Number(e.g):0,b:Pt(e.b)?globalThis.Number(e.b):0,a:Pt(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 ot.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i,o;const t=Nr();return t.r=(n=e.r)!=null?n:0,t.g=(a=e.g)!=null?a:0,t.b=(i=e.b)!=null?i:0,t.a=(o=e.a)!=null?o:0,t}};function Ir(){return{x:0,y:0,z:0}}const rt={encode(e,t=se.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=Ir();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==13)break;i.x=n.float();continue;case 2:if(o!==21)break;i.y=n.float();continue;case 3:if(o!==29)break;i.z=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{x:Pt(e.x)?globalThis.Number(e.x):0,y:Pt(e.y)?globalThis.Number(e.y):0,z:Pt(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 rt.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i;const t=Ir();return t.x=(n=e.x)!=null?n:0,t.y=(a=e.y)!=null?a:0,t.z=(i=e.z)!=null?i:0,t}};function wr(){return{vertices:[],normals:[],indices:[],colors:[],uv:[]}}const We={encode(e,t=se.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=wr();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o===13){i.vertices.push(n.float());continue}if(o===10){const r=n.uint32()+n.pos;for(;n.pos<r;)i.vertices.push(n.float());continue}break;case 2:if(o===21){i.normals.push(n.float());continue}if(o===18){const r=n.uint32()+n.pos;for(;n.pos<r;)i.normals.push(n.float());continue}break;case 3:if(o===24){i.indices.push(n.uint32());continue}if(o===26){const r=n.uint32()+n.pos;for(;n.pos<r;)i.indices.push(n.uint32());continue}break;case 4:if(o===37){i.colors.push(n.float());continue}if(o===34){const r=n.uint32()+n.pos;for(;n.pos<r;)i.colors.push(n.float());continue}break;case 5:if(o===45){i.uv.push(n.float());continue}if(o===42){const r=n.uint32()+n.pos;for(;n.pos<r;)i.uv.push(n.float());continue}break}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},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,i,o,r;const t={};return(n=e.vertices)!=null&&n.length&&(t.vertices=e.vertices),(a=e.normals)!=null&&a.length&&(t.normals=e.normals),(i=e.indices)!=null&&i.length&&(t.indices=e.indices.map(l=>Math.round(l))),(o=e.colors)!=null&&o.length&&(t.colors=e.colors),(r=e.uv)!=null&&r.length&&(t.uv=e.uv),t},create(e){return We.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i,o,r;const t=wr();return t.vertices=((n=e.vertices)==null?void 0:n.map(l=>l))||[],t.normals=((a=e.normals)==null?void 0:a.map(l=>l))||[],t.indices=((i=e.indices)==null?void 0:i.map(l=>l))||[],t.colors=((o=e.colors)==null?void 0:o.map(l=>l))||[],t.uv=((r=e.uv)==null?void 0:r.map(l=>l))||[],t}};function Pt(e){return e!=null}function Ks(e){switch(e){case 0:case"RECTANGLE":return 0;case 1:case"CICLE":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function Qs(e){switch(e){case 0:return"RECTANGLE";case 1:return"CICLE";case-1:default:return"UNRECOGNIZED"}}function Or(){return{dataType:0,name:"",position:void 0,boxes:[]}}const Yi={encode(e,t=se.Writer.create()){e.dataType!==0&&t.uint32(8).int32(e.dataType),e.name!==""&&t.uint32(26).string(e.name),e.position!==void 0&&K.encode(e.position,t.uint32(34).fork()).ldelim();for(const n of e.boxes)it.encode(n,t.uint32(66).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=Or();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==8)break;i.dataType=n.int32();continue;case 3:if(o!==26)break;i.name=n.string();continue;case 4:if(o!==34)break;i.position=K.decode(n,n.uint32());continue;case 8:if(o!==66)break;i.boxes.push(it.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{dataType:tt(e.dataType)?Xs(e.dataType):0,name:tt(e.name)?globalThis.String(e.name):"",position:tt(e.position)?K.fromJSON(e.position):void 0,boxes:globalThis.Array.isArray(e==null?void 0:e.boxes)?e.boxes.map(t=>it.fromJSON(t)):[]}},toJSON(e){var n;const t={};return e.dataType!==0&&(t.dataType=qs(e.dataType)),e.name!==""&&(t.name=e.name),e.position!==void 0&&(t.position=K.toJSON(e.position)),(n=e.boxes)!=null&&n.length&&(t.boxes=e.boxes.map(a=>it.toJSON(a))),t},create(e){return Yi.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i;const t=Or();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?K.fromPartial(e.position):void 0,t.boxes=((i=e.boxes)==null?void 0:i.map(o=>it.fromPartial(o)))||[],t}};function Ar(){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 it={encode(e,t=se.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&&K.encode(e.startPosition,t.uint32(34).fork()).ldelim(),e.endPosition!==void 0&&K.encode(e.endPosition,t.uint32(42).fork()).ldelim(),e.type!==0&&t.uint32(48).int32(e.type),e.topMesh!==void 0&&We.encode(e.topMesh,t.uint32(58).fork()).ldelim(),e.sideMesh!==void 0&&We.encode(e.sideMesh,t.uint32(66).fork()).ldelim(),e.bottomMesh!==void 0&&We.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=Ar();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 2:if(o!==21)break;i.leftSpace=n.float();continue;case 3:if(o!==29)break;i.rightSpace=n.float();continue;case 4:if(o!==34)break;i.startPosition=K.decode(n,n.uint32());continue;case 5:if(o!==42)break;i.endPosition=K.decode(n,n.uint32());continue;case 6:if(o!==48)break;i.type=n.int32();continue;case 7:if(o!==58)break;i.topMesh=We.decode(n,n.uint32());continue;case 8:if(o!==66)break;i.sideMesh=We.decode(n,n.uint32());continue;case 9:if(o!==74)break;i.bottomMesh=We.decode(n,n.uint32());continue;case 10:if(o!==85)break;i.width=n.float();continue;case 11:if(o!==93)break;i.height=n.float();continue;case 12:if(o!==101)break;i.startOutWidth=n.float();continue;case 13:if(o!==109)break;i.endOutWidth=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{name:tt(e.name)?globalThis.String(e.name):"",leftSpace:tt(e.leftSpace)?globalThis.Number(e.leftSpace):0,rightSpace:tt(e.rightSpace)?globalThis.Number(e.rightSpace):0,startPosition:tt(e.startPosition)?K.fromJSON(e.startPosition):void 0,endPosition:tt(e.endPosition)?K.fromJSON(e.endPosition):void 0,type:tt(e.type)?Ks(e.type):0,topMesh:tt(e.topMesh)?We.fromJSON(e.topMesh):void 0,sideMesh:tt(e.sideMesh)?We.fromJSON(e.sideMesh):void 0,bottomMesh:tt(e.bottomMesh)?We.fromJSON(e.bottomMesh):void 0,width:tt(e.width)?globalThis.Number(e.width):0,height:tt(e.height)?globalThis.Number(e.height):0,startOutWidth:tt(e.startOutWidth)?globalThis.Number(e.startOutWidth):0,endOutWidth:tt(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=K.toJSON(e.startPosition)),e.endPosition!==void 0&&(t.endPosition=K.toJSON(e.endPosition)),e.type!==0&&(t.type=Qs(e.type)),e.topMesh!==void 0&&(t.topMesh=We.toJSON(e.topMesh)),e.sideMesh!==void 0&&(t.sideMesh=We.toJSON(e.sideMesh)),e.bottomMesh!==void 0&&(t.bottomMesh=We.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 it.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i,o,r,l,s,c;const t=Ar();return t.name=(n=e.name)!=null?n:"",t.leftSpace=(a=e.leftSpace)!=null?a:0,t.rightSpace=(i=e.rightSpace)!=null?i:0,t.startPosition=e.startPosition!==void 0&&e.startPosition!==null?K.fromPartial(e.startPosition):void 0,t.endPosition=e.endPosition!==void 0&&e.endPosition!==null?K.fromPartial(e.endPosition):void 0,t.type=(o=e.type)!=null?o:0,t.topMesh=e.topMesh!==void 0&&e.topMesh!==null?We.fromPartial(e.topMesh):void 0,t.sideMesh=e.sideMesh!==void 0&&e.sideMesh!==null?We.fromPartial(e.sideMesh):void 0,t.bottomMesh=e.bottomMesh!==void 0&&e.bottomMesh!==null?We.fromPartial(e.bottomMesh):void 0,t.width=(r=e.width)!=null?r:0,t.height=(l=e.height)!=null?l:0,t.startOutWidth=(s=e.startOutWidth)!=null?s:0,t.endOutWidth=(c=e.endOutWidth)!=null?c:0,t}};function tt(e){return e!=null}function js(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 el(e){switch(e){case 0:return"NORMAL_FRAME";case 1:return"KEY_FRAME";case-1:default:return"UNRECOGNIZED"}}var Ln=(e=>(e[e.RUN=0]="RUN",e[e.WATER=1]="WATER",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Ln||{});function tl(e){switch(e){case 0:case"RUN":return 0;case 1:case"WATER":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function nl(e){switch(e){case 0:return"RUN";case 1:return"WATER";case-1:default:return"UNRECOGNIZED"}}function Mr(){return{name:"",frameRate:0,type:0,frames:[],boxes:[],animType:0,colors:[]}}const Ji={encode(e,t=se.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)on.encode(n,t.uint32(34).fork()).ldelim();for(const n of e.boxes)it.encode(n,t.uint32(42).fork()).ldelim();e.animType!==0&&t.uint32(48).int32(e.animType);for(const n of e.colors)ot.encode(n,t.uint32(58).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=Mr();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 2:if(o!==16)break;i.frameRate=n.uint32();continue;case 3:if(o!==24)break;i.type=n.int32();continue;case 4:if(o!==34)break;i.frames.push(on.decode(n,n.uint32()));continue;case 5:if(o!==42)break;i.boxes.push(it.decode(n,n.uint32()));continue;case 6:if(o!==48)break;i.animType=n.int32();continue;case 7:if(o!==58)break;i.colors.push(ot.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{name:wt(e.name)?globalThis.String(e.name):"",frameRate:wt(e.frameRate)?globalThis.Number(e.frameRate):0,type:wt(e.type)?js(e.type):0,frames:globalThis.Array.isArray(e==null?void 0:e.frames)?e.frames.map(t=>on.fromJSON(t)):[],boxes:globalThis.Array.isArray(e==null?void 0:e.boxes)?e.boxes.map(t=>it.fromJSON(t)):[],animType:wt(e.animType)?tl(e.animType):0,colors:globalThis.Array.isArray(e==null?void 0:e.colors)?e.colors.map(t=>ot.fromJSON(t)):[]}},toJSON(e){var n,a,i;const t={};return e.name!==""&&(t.name=e.name),e.frameRate!==0&&(t.frameRate=Math.round(e.frameRate)),e.type!==0&&(t.type=el(e.type)),(n=e.frames)!=null&&n.length&&(t.frames=e.frames.map(o=>on.toJSON(o))),(a=e.boxes)!=null&&a.length&&(t.boxes=e.boxes.map(o=>it.toJSON(o))),e.animType!==0&&(t.animType=nl(e.animType)),(i=e.colors)!=null&&i.length&&(t.colors=e.colors.map(o=>ot.toJSON(o))),t},create(e){return Ji.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i,o,r,l,s;const t=Mr();return t.name=(n=e.name)!=null?n:"",t.frameRate=(a=e.frameRate)!=null?a:0,t.type=(i=e.type)!=null?i:0,t.frames=((o=e.frames)==null?void 0:o.map(c=>on.fromPartial(c)))||[],t.boxes=((r=e.boxes)==null?void 0:r.map(c=>it.fromPartial(c)))||[],t.animType=(l=e.animType)!=null?l:0,t.colors=((s=e.colors)==null?void 0:s.map(c=>ot.fromPartial(c)))||[],t}};function Lr(){return{start:0,end:0}}const mt={encode(e,t=se.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=Lr();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==13)break;i.start=n.float();continue;case 2:if(o!==21)break;i.end=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{start:wt(e.start)?globalThis.Number(e.start):0,end:wt(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 mt.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=Lr();return t.start=(n=e.start)!=null?n:0,t.end=(a=e.end)!=null?a:0,t}};function Rr(){return{index:0,name:"",percent:[],colorPercent:[]}}const nn={encode(e,t=se.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)mt.encode(n,t.uint32(26).fork()).ldelim();for(const n of e.colorPercent)mt.encode(n,t.uint32(34).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=Rr();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==8)break;i.index=n.uint32();continue;case 2:if(o!==18)break;i.name=n.string();continue;case 3:if(o!==26)break;i.percent.push(mt.decode(n,n.uint32()));continue;case 4:if(o!==34)break;i.colorPercent.push(mt.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{index:wt(e.index)?globalThis.Number(e.index):0,name:wt(e.name)?globalThis.String(e.name):"",percent:globalThis.Array.isArray(e==null?void 0:e.percent)?e.percent.map(t=>mt.fromJSON(t)):[],colorPercent:globalThis.Array.isArray(e==null?void 0:e.colorPercent)?e.colorPercent.map(t=>mt.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(i=>mt.toJSON(i))),(a=e.colorPercent)!=null&&a.length&&(t.colorPercent=e.colorPercent.map(i=>mt.toJSON(i))),t},create(e){return nn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i,o;const t=Rr();return t.index=(n=e.index)!=null?n:0,t.name=(a=e.name)!=null?a:"",t.percent=((i=e.percent)==null?void 0:i.map(r=>mt.fromPartial(r)))||[],t.colorPercent=((o=e.colorPercent)==null?void 0:o.map(r=>mt.fromPartial(r)))||[],t}};function Br(){return{node:[],time:0}}const on={encode(e,t=se.Writer.create()){for(const n of e.node)nn.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=Br();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.node.push(nn.decode(n,n.uint32()));continue;case 2:if(o!==21)break;i.time=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{node:globalThis.Array.isArray(e==null?void 0:e.node)?e.node.map(t=>nn.fromJSON(t)):[],time:wt(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=>nn.toJSON(a))),e.time!==0&&(t.time=e.time),t},create(e){return on.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=Br();return t.node=((n=e.node)==null?void 0:n.map(i=>nn.fromPartial(i)))||[],t.time=(a=e.time)!=null?a:0,t}};function wt(e){return e!=null}function ol(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 rl(e){switch(e){case 0:return"NORMAL_FRAME";case 1:return"KEY_FRAME";case-1:default:return"UNRECOGNIZED"}}function Fr(){return{name:"",frameRate:0,type:0,nodes:[],boxes:[]}}const Xi={encode(e,t=se.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)rn.encode(n,t.uint32(34).fork()).ldelim();for(const n of e.boxes)it.encode(n,t.uint32(42).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=Fr();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 2:if(o!==16)break;i.frameRate=n.uint32();continue;case 3:if(o!==24)break;i.type=n.int32();continue;case 4:if(o!==34)break;i.nodes.push(rn.decode(n,n.uint32()));continue;case 5:if(o!==42)break;i.boxes.push(it.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{name:$t(e.name)?globalThis.String(e.name):"",frameRate:$t(e.frameRate)?globalThis.Number(e.frameRate):0,type:$t(e.type)?ol(e.type):0,nodes:globalThis.Array.isArray(e==null?void 0:e.nodes)?e.nodes.map(t=>rn.fromJSON(t)):[],boxes:globalThis.Array.isArray(e==null?void 0:e.boxes)?e.boxes.map(t=>it.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=rl(e.type)),(n=e.nodes)!=null&&n.length&&(t.nodes=e.nodes.map(i=>rn.toJSON(i))),(a=e.boxes)!=null&&a.length&&(t.boxes=e.boxes.map(i=>it.toJSON(i))),t},create(e){return Xi.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i,o,r;const t=Fr();return t.name=(n=e.name)!=null?n:"",t.frameRate=(a=e.frameRate)!=null?a:0,t.type=(i=e.type)!=null?i:0,t.nodes=((o=e.nodes)==null?void 0:o.map(l=>rn.fromPartial(l)))||[],t.boxes=((r=e.boxes)==null?void 0:r.map(l=>it.fromPartial(l)))||[],t}};function Dr(){return{start:0,end:0}}const gt={encode(e,t=se.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=Dr();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==13)break;i.start=n.float();continue;case 2:if(o!==21)break;i.end=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{start:$t(e.start)?globalThis.Number(e.start):0,end:$t(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 gt.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=Dr();return t.start=(n=e.start)!=null?n:0,t.end=(a=e.end)!=null?a:0,t}};function zr(){return{index:0,name:"",frames:[]}}const rn={encode(e,t=se.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)an.encode(n,t.uint32(26).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=zr();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==8)break;i.index=n.uint32();continue;case 2:if(o!==18)break;i.name=n.string();continue;case 3:if(o!==26)break;i.frames.push(an.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{index:$t(e.index)?globalThis.Number(e.index):0,name:$t(e.name)?globalThis.String(e.name):"",frames:globalThis.Array.isArray(e==null?void 0:e.frames)?e.frames.map(t=>an.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=>an.toJSON(a))),t},create(e){return rn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i;const t=zr();return t.index=(n=e.index)!=null?n:0,t.name=(a=e.name)!=null?a:"",t.frames=((i=e.frames)==null?void 0:i.map(o=>an.fromPartial(o)))||[],t}};function Vr(){return{time:0,percent:[],colorPercent:[]}}const an={encode(e,t=se.Writer.create()){e.time!==0&&t.uint32(13).float(e.time);for(const n of e.percent)gt.encode(n,t.uint32(18).fork()).ldelim();for(const n of e.colorPercent)gt.encode(n,t.uint32(26).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=Vr();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==13)break;i.time=n.float();continue;case 2:if(o!==18)break;i.percent.push(gt.decode(n,n.uint32()));continue;case 3:if(o!==26)break;i.colorPercent.push(gt.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{time:$t(e.time)?globalThis.Number(e.time):0,percent:globalThis.Array.isArray(e==null?void 0:e.percent)?e.percent.map(t=>gt.fromJSON(t)):[],colorPercent:globalThis.Array.isArray(e==null?void 0:e.colorPercent)?e.colorPercent.map(t=>gt.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(i=>gt.toJSON(i))),(a=e.colorPercent)!=null&&a.length&&(t.colorPercent=e.colorPercent.map(i=>gt.toJSON(i))),t},create(e){return an.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i;const t=Vr();return t.time=(n=e.time)!=null?n:0,t.percent=((a=e.percent)==null?void 0:a.map(o=>gt.fromPartial(o)))||[],t.colorPercent=((i=e.colorPercent)==null?void 0:i.map(o=>gt.fromPartial(o)))||[],t}};function $t(e){return e!=null}function il(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 al(e){switch(e){case 0:return"NORMAL_FRAME";case 1:return"KEY_FRAME";case-1:default:return"UNRECOGNIZED"}}function $r(){return{name:"",frameRate:0,type:0,frames:[],url:""}}const qi={encode(e,t=se.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)ln.encode(n,t.uint32(34).fork()).ldelim();return e.url!==""&&t.uint32(42).string(e.url),t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=$r();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 2:if(o!==16)break;i.frameRate=n.uint32();continue;case 3:if(o!==24)break;i.type=n.int32();continue;case 4:if(o!==34)break;i.frames.push(ln.decode(n,n.uint32()));continue;case 5:if(o!==42)break;i.url=n.string();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{name:Jt(e.name)?globalThis.String(e.name):"",frameRate:Jt(e.frameRate)?globalThis.Number(e.frameRate):0,type:Jt(e.type)?il(e.type):0,frames:globalThis.Array.isArray(e==null?void 0:e.frames)?e.frames.map(t=>ln.fromJSON(t)):[],url:Jt(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=al(e.type)),(n=e.frames)!=null&&n.length&&(t.frames=e.frames.map(a=>ln.toJSON(a))),e.url!==""&&(t.url=e.url),t},create(e){return qi.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i,o,r;const t=$r();return t.name=(n=e.name)!=null?n:"",t.frameRate=(a=e.frameRate)!=null?a:0,t.type=(i=e.type)!=null?i:0,t.frames=((o=e.frames)==null?void 0:o.map(l=>ln.fromPartial(l)))||[],t.url=(r=e.url)!=null?r:"",t}};function Wr(){return{name:"",position:void 0}}const sn={encode(e,t=se.Writer.create()){return e.name!==""&&t.uint32(10).string(e.name),e.position!==void 0&&rt.encode(e.position,t.uint32(18).fork()).ldelim(),t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=Wr();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 2:if(o!==18)break;i.position=rt.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{name:Jt(e.name)?globalThis.String(e.name):"",position:Jt(e.position)?rt.fromJSON(e.position):void 0}},toJSON(e){const t={};return e.name!==""&&(t.name=e.name),e.position!==void 0&&(t.position=rt.toJSON(e.position)),t},create(e){return sn.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=Wr();return t.name=(n=e.name)!=null?n:"",t.position=e.position!==void 0&&e.position!==null?rt.fromPartial(e.position):void 0,t}};function Ur(){return{nodes:[],time:0}}const ln={encode(e,t=se.Writer.create()){for(const n of e.nodes)sn.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=Ur();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.nodes.push(sn.decode(n,n.uint32()));continue;case 2:if(o!==21)break;i.time=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{nodes:globalThis.Array.isArray(e==null?void 0:e.nodes)?e.nodes.map(t=>sn.fromJSON(t)):[],time:Jt(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=>sn.toJSON(a))),e.time!==0&&(t.time=e.time),t},create(e){return ln.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=Ur();return t.nodes=((n=e.nodes)==null?void 0:n.map(i=>sn.fromPartial(i)))||[],t.time=(a=e.time)!=null?a:0,t}};function Jt(e){return e!=null}class Pn{constructor(){ve(this,"_keys",[]);ve(this,"getLastKey",()=>this._keys[this._keys.length-1]);ve(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),i=(t-this._keys[a].time)/(this._keys[n].time-this._keys[a].time);return u.Scalar.Lerp(this._keys[a].value,this._keys[n].value,i)}}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 st{constructor(t,n){ve(this,"time");ve(this,"value");this.time=t,this.value=n}}class Hn{constructor(t){ve(this,"_curves",[]);this._curves=t}get curves(){return this._curves}update(t){}reset(){}}class sl extends Hn{constructor(){super(...arguments);ve(this,"_name","");ve(this,"_url","");ve(this,"_start");ve(this,"_end");ve(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,r,l;const n=(o=this.curves[0].getLastKey())==null?void 0:o.value,a=(r=this.curves[1].getLastKey())==null?void 0:r.value,i=(l=this.curves[2].getLastKey())==null?void 0:l.value;return new u.Vector3(n,a,i)}getStartPosition(){const n=this.curves[0].getFirstKey().value,a=this.curves[1].getFirstKey().value,i=this.curves[2].getFirstKey().value;return new u.Vector3(n,a,i)}update(n){var r,l,s;if(n<this.curves[0].length){const c=(r=this.curves[0].evaluate(n))!=null?r:0,p=(l=this.curves[1].evaluate(n))!=null?l:0,f=(s=this.curves[2].evaluate(n))!=null?s:0;this._start=this.getStartPosition(),this._current=new u.Vector3(c,p,f),this._end=this.getEndPosition();return}const a=this.curves[0].getLastKey().value,i=this.curves[1].getLastKey().value,o=this.curves[2].getLastKey().value;this._start=this.getStartPosition(),this._current=new u.Vector3(a,i,o),this._end=this.getEndPosition()}reset(){}}class ll extends Hn{constructor(){super(...arguments);ve(this,"_range",[]);ve(this,"_percent",[]);ve(this,"_start");ve(this,"_end");ve(this,"_name","");ve(this,"_meshs");ve(this,"_colors",[]);ve(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 i=0;i<this.curves.length;i++){const o=this.curves[i];if(n<o.length){this._range.push((a=o.evaluate(n))!=null?a:0);continue}this._range.push(o.getLastKey().value)}for(let i=0;i<this._range.length;i+=2)this._percent.push({start:this._range[i],end:this._range[i+1]})}reset(){}}class Ki extends Hn{constructor(){super(...arguments);ve(this,"_range",[]);ve(this,"_percent",[]);ve(this,"_colorPercent",[]);ve(this,"_start");ve(this,"_end");ve(this,"_name","");ve(this,"_meshs");ve(this,"_colors",[]);ve(this,"_type","run");ve(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 i=0;i<this.curves.length;i++){const o=this.curves[i];if(n<o.length){this._range.push((a=o.evaluate(n))!=null?a:0);continue}this._range.push(o.getLastKey().value)}for(let i=0;i<this._percentLength;i+=2)this._percent.push({start:this._range[i],end:this._range[i+1]});for(let i=this._percentLength;i<this._range.length;i+=2)this._colorPercent.push({start:this._range[i],end:this._range[i+1]})}reset(){}}var ho,mo,go,vo,wn,On,Hr,Zr;function cl(e){e<.5&&(e=.5);var t=Math.exp(.726*.726)/e,n=Math.exp(-t),a=Math.exp(-2*t),i=(1-n)*(1-n)/(1+2*t*n-a);return ho=i,mo=i*(t-1)*n,go=i*(t+1)*n,vo=-i*a,wn=2*n,On=-a,Hr=(ho+mo)/(1-wn-On),Zr=(go+vo)/(1-wn-On),new Float32Array([ho,mo,go,vo,wn,On,Hr,Zr])}function Gr(e,t,n,a,i,o){var r,l,s,c,p,f,d,x,h,T,P,v,_,b,k,M,w,S,N,F,B,I,D,E,L,y,A,V,$,W;for(L=0;L<o;L++){for(I=L*i,D=L,E=0,r=e[I],l=r&255,s=r>>8&255,c=r>>16&255,p=r>>24&255,S=l*a[6],N=s*a[6],F=c*a[6],B=p*a[6],b=S,k=N,M=F,w=B,A=a[0],V=a[1],$=a[4],W=a[5],y=0;y<i;y++)r=e[I],f=r&255,d=r>>8&255,x=r>>16&255,h=r>>24&255,T=f*A+l*V+b*$+S*W,P=d*A+s*V+k*$+N*W,v=x*A+c*V+M*$+F*W,_=h*A+p*V+w*$+B*W,S=b,N=k,F=M,B=w,b=T,k=P,M=v,w=_,l=f,s=d,c=x,p=h,n[E]=b,n[E+1]=k,n[E+2]=M,n[E+3]=w,E+=4,I++;for(I--,E-=4,D+=o*(i-1),r=e[I],l=r&255,s=r>>8&255,c=r>>16&255,p=r>>24&255,S=l*a[7],N=s*a[7],F=c*a[7],B=p*a[7],b=S,k=N,M=F,w=B,f=l,d=s,x=c,h=p,A=a[2],V=a[3],y=i-1;y>=0;y--)T=f*A+l*V+b*$+S*W,P=d*A+s*V+k*$+N*W,v=x*A+c*V+M*$+F*W,_=h*A+p*V+w*$+B*W,S=b,N=k,F=M,B=w,b=T,k=P,M=v,w=_,l=f,s=d,c=x,p=h,r=e[I],f=r&255,d=r>>8&255,x=r>>16&255,h=r>>24&255,r=(n[E]+b<<0)+(n[E+1]+k<<8)+(n[E+2]+M<<16)+(n[E+3]+w<<24),t[D]=r,I--,E-=4,D-=o}}function ul(e,t,n,a){if(a){var i=new Uint32Array(e.buffer),o=new Uint32Array(i.length),r=new Float32Array(Math.max(t,n)*4),l=cl(a);Gr(i,o,r,l,t,n),Gr(o,i,r,l,n,t)}}var fl=ul;const dl=Si(fl);class pl extends Hn{constructor(){super(...arguments);ve(this,"_range",[]);ve(this,"_percent",[]);ve(this,"_colorPercent",[]);ve(this,"_start");ve(this,"_end");ve(this,"_name","");ve(this,"_width",0);ve(this,"_height",0);ve(this,"_waterHeight",0);ve(this,"_waterLength",0);ve(this,"_heightMapRaw",new Uint8Array([0,0,0,0]));ve(this,"_lastHeightMapRaw",new Uint8Array([0,0,0,0]));ve(this,"_bottomShape",[]);ve(this,"_percentLength",2);ve(this,"_time",0);ve(this,"_glurMap",new Uint8Array([0,0,0,0]));ve(this,"_startOutWidth",0);ve(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 u.Vector3.Center(this._start||u.Vector3.Zero(),this._end||u.Vector3.Zero())}equalArray(n,a){if(n.byteLength!=a.byteLength)return!1;const i=new Uint8Array(n),o=new Uint8Array(a);for(let r=0;r!=n.byteLength;r++)if(i[r]!=o[r])return!1;return!0}generateHeightMap(){const n=Math.floor(this._waterLength);if(n>0){let a=n;const i=new Uint8Array(a*4);for(let o=0;o<i.length;o++){const r=o*4;i[r]=0,i[r+1]=0,i[r+2]=0,i[r+3]=0}this._heightMapRaw=i}}get bottomShape(){return this._bottomShape}set bottomShape(n){this._bottomShape=n}updateHeightMapByPercent(n,a,i){const o=this._heightMapRaw;let r=0;const l=r+Math.floor(n*this._waterLength),s=r+Math.floor(a*this._waterLength);for(let c=l;c<s;c++){const p=c*4;o[p]=Math.trunc(i*255),o[p+1]=Math.trunc(i*255),o[p+2]=Math.trunc(i*255),o[p+3]=Math.trunc(i*255)}this._heightMapRaw=o}get glurHeightMap(){return this._glurMap}update(n){var a;this._range=[],this._percent=[],this._colorPercent=[];for(let i=0;i<this.curves.length;i++){const o=this.curves[i];if(n<o.length){this._range.push((a=o.evaluate(n))!=null?a:0);continue}this._range.push(o.getLastKey().value)}for(let i=0;i<this._percentLength;i+=2){const o=this._range[i],r=this._range[i+1],l=Math.min(o,r),s=Math.max(o,r);l!=s&&this.updateHeightMapByPercent(l,s,.5)}for(let i=this._percentLength;i<this._range.length;i+=2){const o=this._range[i],r=this._range[i+1],l=Math.min(o,r),s=Math.max(o,r);l!=s&&this.updateHeightMapByPercent(l,s,1)}if(!this.equalArray(this._heightMapRaw,this._lastHeightMapRaw)){if(this.time=n,this._heightMapRaw.length===0)return new Uint8Array([0,0,0,0]);const i=new Uint8Array(this._heightMapRaw);let o=this._waterLength;dl(i,1,o,5),this._lastHeightMapRaw=this._heightMapRaw.slice(0),this._glurMap=i}}reset(){}cross(n,a,i){return(a.x-n.x)*(i.y-n.y)-(a.y-n.y)*(i.x-n.x)}convexHull(n){n.sort((o,r)=>o.x===r.x?o.y-r.y:o.x-r.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 i=[];for(let o=n.length-1;o>=0;o--){const r=n[o];for(;i.length>=2&&this.cross(i[i.length-2],i[i.length-1],r)<=0;)i.pop();i.push(r)}return a.pop(),i.pop(),a.concat(i)}}const Yr=e=>{const t=Ji.decode(new Uint8Array(e)),n=[];console.log(t);const a=[];for(let i=0;i<t.frames.length;i++)for(let o=0;o<t.frames[i].node.length;o++){const r=t.frames[i].node[o];a.findIndex(s=>s===r.name)===-1&&a.push(r.name)}for(let i=0;i<a.length;i++){const o=[],r=t.frames[0].node[0].percent.length,l=t.frames[0].node[0].colorPercent.length;for(let p=0;p<(r+l)*2;p++)o.push(new Pn);let s=0;for(let p=0;p<t.frames.length;p++){const f=t.frames[p],d=f.node.findIndex(x=>x.name===a[i]);if(d!==-1){for(let x=0;x<r;x++){const h=new st(f.time*1e3,f.node[d].percent[x].start),T=new st(f.time*1e3,f.node[d].percent[x].end);o[x*2].addKey(h),o[x*2+1].addKey(T)}for(let x=0;x<l;x++){const h=new st(f.time*1e3,f.node[d].colorPercent[x].start),T=new st(f.time*1e3,f.node[d].colorPercent[x].end);o[r*2+x*2].addKey(h),o[r*2+x*2+1].addKey(T)}s=f.node[d].index}}const c=t.animType===Ln.WATER?new Ki(o):new ll(o);c.meshs=[t.boxes[s].topMesh,t.boxes[s].bottomMesh,t.boxes[s].sideMesh],c.name=a[i],c.start=At(t.boxes[s].startPosition),c.end=At(t.boxes[s].endPosition),c.type=t.animType===Ln.RUN?"run":"water",c.colors=t.colors.map(p=>Ss(p)),t.animType===Ln.WATER&&(c.percentLength=r*2);for(let p=0;p<c.curves.length;p++)if(c.curves[p].keys[0].time!==0){const f=c.curves[p].keys[0],d=new st(0,f.value);d.time=0,c.curves[p].keys.unshift(d)}n.push(c)}return n},hl=e=>{const t=qi.decode(new Uint8Array(e)),n=[];console.log(t);const a=[];for(let i=0;i<t.frames.length;i++)for(let o=0;o<t.frames[i].nodes.length;o++){const r=t.frames[i].nodes[o];a.findIndex(s=>s===r.name)===-1&&a.push(r.name)}for(let i=0;i<a.length;i++){const o=[];o.push(new Pn),o.push(new Pn),o.push(new Pn);for(let l=0;l<t.frames.length;l++){const s=t.frames[l],c=s.nodes.findIndex(p=>p.name===a[i]);if(c!==-1){const p=new st(s.time*1e3,s.nodes[c].position.x),f=new st(s.time*1e3,s.nodes[c].position.y),d=new st(s.time*1e3,s.nodes[c].position.z);o[0].addKey(p),o[1].addKey(f),o[2].addKey(d)}}const r=new sl(o);r.name=a[i],r.url=t.url;for(let l=0;l<r.curves.length;l++)if(r.curves[l].keys[0].time!==0){const s=r.curves[l].keys[0],c=new st(0,s.value);c.time=0,r.curves[l].keys.unshift(c)}n.push(r)}return n},ml=e=>{const t=Xi.decode(new Uint8Array(e)),n=[];console.log(t);for(let a=0;a<t.nodes.length;a++){const i=[],o=t.nodes[0].frames[0].percent.length,r=t.nodes[0].frames[0].colorPercent.length;for(let h=0;h<(o+r)*2;h++)i.push(new Pn);for(let h=0;h<t.nodes[a].frames.length;h++){const T=t.nodes[a].frames[h];if("percent"in T&&"colorPercent"in T){for(let P=0;P<o;P++){const v=new st(T.time*1e3,T.percent[P].start),_=new st(T.time*1e3,T.percent[P].end);i[P*2].addKey(v),i[P*2+1].addKey(_)}for(let P=0;P<r;P++){const v=new st(T.time*1e3,T.colorPercent[P].start),_=new st(T.time*1e3,T.colorPercent[P].end);i[o*2+P*2].addKey(v),i[o*2+P*2+1].addKey(_)}}else console.error("[Geo3DViewer] 数据中缺少 percent 或 colorPercent ",t.nodes[a],T)}const l=t.nodes[a].index,s=new pl(i);s.name=t.nodes[a].name,s.start=At(t.boxes[l].startPosition),s.end=At(t.boxes[l].endPosition),s.startOutWidth=t.boxes[l].startOutWidth||0,s.endOutWidth=t.boxes[l].endOutWidth||0,s.waterHeight=.5,s.width=t.boxes[l].width||3.5,s.waterLength=u.Vector3.Distance(s.start,s.end)+.05+s.startOutWidth+s.endOutWidth,s.generateHeightMap();const c=[];for(let h=0;h<t.boxes[l].bottomMesh.vertices.length;h+=3)c.push(new u.Vector3(t.boxes[l].bottomMesh.vertices[h],t.boxes[l].bottomMesh.vertices[h+1],t.boxes[l].bottomMesh.vertices[h+2]));const p=new u.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),f=new u.Vector3(Number.MIN_VALUE,Number.MIN_VALUE,Number.MIN_VALUE);c.forEach(h=>{h.x<p.x&&(p.x=h.x),h.y<p.y&&(p.y=h.y),h.z<p.z&&(p.z=h.z),h.x>f.x&&(f.x=h.x),h.y>f.y&&(f.y=h.y),h.z>f.z&&(f.z=h.z)});const d=[];t.boxes[l].bottomMesh.indices.forEach(h=>{d.push(c[h].subtract(p).multiplyByFloats(1/(f.x-p.x),1/(f.y-p.y),1/(f.z-p.z)))});const x=[];for(let h=0;h<d.length;h+=3)x.push([d[h],d[h+1],d[h+2]]);s.bottomShape=x,s.height=t.boxes[l].height||t.boxes[l].topMesh.vertices[1]-t.boxes[l].bottomMesh.vertices[1],s.percentLength=o*2,console.log("[Geo3DViewer] 正在构建动画 ",s);for(let h=0;h<s.curves.length;h++)if(s.curves[h].keys[0].time!==0){const T=s.curves[h].keys[0],P=new st(0,T.value);P.time=0,s.curves[h].keys.unshift(P)}n.push(s)}return n},Rn=e=>{const{name:t,children:n,url:a,type:i="roadway",speed:o=1}=e,r=m.useRef(null),[l,s]=m.useState(),c=m.useRef(!1),p=je({url:a,cacheType:Me.URL_PREFIX_MATCH}),f=(d,x)=>{let h=[];switch(d){case"roadway":h=Yr(x);break;case"roadwaynear":h=hl(x);break;case"water":h=ml(x);break;default:h=Yr(x)}return h};return m.useEffect(()=>{if(p&&!c.current){c.current=!0;const d=f(i,p);console.log(d);const x=new Is(t);x.nodes=d,r.current=x,r.current.speed=o,r.current.play(),c.current=!1}},[p,t,o,i]),m.useEffect(()=>()=>{r.current&&!c.current&&(console.log("destory animation!"),r.current.onDestory())},[]),m.useEffect(()=>{const d=setInterval(()=>{r.current&&r.current.normalized>0&&s({nodes:r.current.nodes})},100);return()=>{clearInterval(d)}},[]),C.jsx(C.Fragment,{children:l&&m.isValidElement(n)?m.cloneElement(n,{nodes:l==null?void 0:l.nodes,speed:o}):n})};function Jr(){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 Vo={encode(e,t=se.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&&K.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=Jr();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 2:if(o!==21)break;i.vMin=n.float();continue;case 3:if(o!==29)break;i.vMax=n.float();continue;case 4:if(o!==37)break;i.xMin=n.float();continue;case 5:if(o!==45)break;i.yMin=n.float();continue;case 6:if(o!==53)break;i.xMax=n.float();continue;case 7:if(o!==61)break;i.yMax=n.float();continue;case 8:if(o!==69)break;i.zMin=n.float();continue;case 9:if(o!==77)break;i.zMax=n.float();continue;case 11:if(o===93){i.points.push(n.float());continue}if(o===90){const r=n.uint32()+n.pos;for(;n.pos<r;)i.points.push(n.float());continue}break;case 12:if(o===96){i.indices.push(n.int32());continue}if(o===98){const r=n.uint32()+n.pos;for(;n.pos<r;)i.indices.push(n.int32());continue}break;case 13:if(o===109){i.value.push(n.float());continue}if(o===106){const r=n.uint32()+n.pos;for(;n.pos<r;)i.value.push(n.float());continue}break;case 31:if(o!==250)break;i.center=K.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{name:_t(e.name)?globalThis.String(e.name):"",vMin:_t(e.vMin)?globalThis.Number(e.vMin):0,vMax:_t(e.vMax)?globalThis.Number(e.vMax):0,xMin:_t(e.xMin)?globalThis.Number(e.xMin):0,yMin:_t(e.yMin)?globalThis.Number(e.yMin):0,xMax:_t(e.xMax)?globalThis.Number(e.xMax):0,yMax:_t(e.yMax)?globalThis.Number(e.yMax):0,zMin:_t(e.zMin)?globalThis.Number(e.zMin):0,zMax:_t(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:_t(e.center)?K.fromJSON(e.center):void 0}},toJSON(e){var n,a,i;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))),(i=e.value)!=null&&i.length&&(t.value=e.value),e.center!==void 0&&(t.center=K.toJSON(e.center)),t},create(e){return Vo.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i,o,r,l,s,c,p,f,d,x;const t=Jr();return t.name=(n=e.name)!=null?n:"",t.vMin=(a=e.vMin)!=null?a:0,t.vMax=(i=e.vMax)!=null?i:0,t.xMin=(o=e.xMin)!=null?o:0,t.yMin=(r=e.yMin)!=null?r:0,t.xMax=(l=e.xMax)!=null?l:0,t.yMax=(s=e.yMax)!=null?s:0,t.zMin=(c=e.zMin)!=null?c:0,t.zMax=(p=e.zMax)!=null?p:0,t.points=((f=e.points)==null?void 0:f.map(h=>h))||[],t.indices=((d=e.indices)==null?void 0:d.map(h=>h))||[],t.value=((x=e.value)==null?void 0:x.map(h=>h))||[],t.center=e.center!==void 0&&e.center!==null?K.fromPartial(e.center):void 0,t}};function _t(e){return e!=null}const gl=(e,t)=>{const n=m.useRef(null),{name:a,vertex:i,fragment:o,needDepthPrePass:r=!1,backFaceCulling:l,transparencyMode:s=u.Material.MATERIAL_OPAQUE,alphaMode:c=u.Engine.ALPHA_COMBINE,alpha:p=1,options:f,zOffset:d=1,zOffsetUnits:x,disableDepthWrite:h=!1,clipPlane:T,depthFunction:P,sideOrientation:v=u.Material.ClockWiseSideOrientation}=e;return m.useImperativeHandle(t,()=>n.current,[]),C.jsx(C.Fragment,{children:C.jsx("shaderMaterial",{ref:n,name:`${a}-material`,sideOrientation:v,needDepthPrePass:r,backFaceCulling:l,transparencyMode:s,alphaMode:c,depthFunction:P,alpha:p,shaderPath:{vertexSource:i,fragmentSource:o},options:f,zOffset:d,zOffsetUnits:x,clipPlane:T,disableDepthWrite:h})})},lt=m.forwardRef(gl),vl=`#ifdef GL_ES
19
+ */var a=null;try{a=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(L){}function r(L,y,A){this.low=L|0,this.high=y|0,this.unsigned=!!A}r.prototype.__isLong__,Object.defineProperty(r.prototype,"__isLong__",{value:!0});function o(L){return(L&&L.__isLong__)===!0}function i(L){var y=Math.clz32(L&-L);return L?31-y:y}r.isLong=o;var l={},s={};function c(L,y){var A,V,$;return y?(L>>>=0,($=0<=L&&L<256)&&(V=s[L],V)?V:(A=f(L,0,!0),$&&(s[L]=A),A)):(L|=0,($=-128<=L&&L<128)&&(V=l[L],V)?V:(A=f(L,L<0?-1:0,!1),$&&(l[L]=A),A))}r.fromInt=c;function p(L,y){if(isNaN(L))return y?w:M;if(y){if(L<0)return w;if(L>=_)return I}else{if(L<=-b)return D;if(L+1>=b)return B}return L<0?p(-L,y).neg():f(L%v|0,L/v|0,y)}r.fromNumber=p;function f(L,y,A){return new r(L,y,A)}r.fromBits=f;var d=Math.pow;function x(L,y,A){if(L.length===0)throw Error("empty string");if(typeof y=="number"?(A=y,y=!1):y=!!y,L==="NaN"||L==="Infinity"||L==="+Infinity"||L==="-Infinity")return y?w:M;if(A=A||10,A<2||36<A)throw RangeError("radix");var V;if((V=L.indexOf("-"))>0)throw Error("interior hyphen");if(V===0)return x(L.substring(1),y,A).neg();for(var $=p(d(A,8)),W=M,ne=0;ne<L.length;ne+=8){var ee=Math.min(8,L.length-ne),G=parseInt(L.substring(ne,ne+ee),A);if(ee<8){var le=p(d(A,ee));W=W.mul(le).add(p(G))}else W=W.mul($),W=W.add(p(G))}return W.unsigned=y,W}r.fromString=x;function h(L,y){return typeof L=="number"?p(L,y):typeof L=="string"?x(L,y):f(L.low,L.high,typeof y=="boolean"?y:L.unsigned)}r.fromValue=h;var T=65536,P=1<<24,v=T*T,_=v*v,b=_/2,k=c(P),M=c(0);r.ZERO=M;var w=c(0,!0);r.UZERO=w;var S=c(1);r.ONE=S;var N=c(1,!0);r.UONE=N;var F=c(-1);r.NEG_ONE=F;var B=f(-1,2147483647,!1);r.MAX_VALUE=B;var I=f(-1,-1,!0);r.MAX_UNSIGNED_VALUE=I;var D=f(0,-2147483648,!1);r.MIN_VALUE=D;var E=r.prototype;E.toInt=function(){return this.unsigned?this.low>>>0:this.low},E.toNumber=function(){return this.unsigned?(this.high>>>0)*v+(this.low>>>0):this.high*v+(this.low>>>0)},E.toString=function(y){if(y=y||10,y<2||36<y)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(D)){var A=p(y),V=this.div(A),$=V.mul(A).sub(this);return V.toString(y)+$.toInt().toString(y)}else return"-"+this.neg().toString(y);for(var W=p(d(y,6),this.unsigned),ne=this,ee="";;){var G=ne.div(W),le=ne.sub(G.mul(W)).toInt()>>>0,re=le.toString(y);if(ne=G,ne.isZero())return re+ee;for(;re.length<6;)re="0"+re;ee=""+re+ee}},E.getHighBits=function(){return this.high},E.getHighBitsUnsigned=function(){return this.high>>>0},E.getLowBits=function(){return this.low},E.getLowBitsUnsigned=function(){return this.low>>>0},E.getNumBitsAbs=function(){if(this.isNegative())return this.eq(D)?64:this.neg().getNumBitsAbs();for(var y=this.high!=0?this.high:this.low,A=31;A>0&&!(y&1<<A);A--);return this.high!=0?A+33:A+1},E.isSafeInteger=function(){var y=this.high>>21;return y?this.unsigned?!1:y===-1&&!(this.low===0&&this.high===-2097152):!0},E.isZero=function(){return this.high===0&&this.low===0},E.eqz=E.isZero,E.isNegative=function(){return!this.unsigned&&this.high<0},E.isPositive=function(){return this.unsigned||this.high>=0},E.isOdd=function(){return(this.low&1)===1},E.isEven=function(){return(this.low&1)===0},E.equals=function(y){return o(y)||(y=h(y)),this.unsigned!==y.unsigned&&this.high>>>31===1&&y.high>>>31===1?!1:this.high===y.high&&this.low===y.low},E.eq=E.equals,E.notEquals=function(y){return!this.eq(y)},E.neq=E.notEquals,E.ne=E.notEquals,E.lessThan=function(y){return this.comp(y)<0},E.lt=E.lessThan,E.lessThanOrEqual=function(y){return this.comp(y)<=0},E.lte=E.lessThanOrEqual,E.le=E.lessThanOrEqual,E.greaterThan=function(y){return this.comp(y)>0},E.gt=E.greaterThan,E.greaterThanOrEqual=function(y){return this.comp(y)>=0},E.gte=E.greaterThanOrEqual,E.ge=E.greaterThanOrEqual,E.compare=function(y){if(o(y)||(y=h(y)),this.eq(y))return 0;var A=this.isNegative(),V=y.isNegative();return A&&!V?-1:!A&&V?1:this.unsigned?y.high>>>0>this.high>>>0||y.high===this.high&&y.low>>>0>this.low>>>0?-1:1:this.sub(y).isNegative()?-1:1},E.comp=E.compare,E.negate=function(){return!this.unsigned&&this.eq(D)?D:this.not().add(S)},E.neg=E.negate,E.add=function(y){o(y)||(y=h(y));var A=this.high>>>16,V=this.high&65535,$=this.low>>>16,W=this.low&65535,ne=y.high>>>16,ee=y.high&65535,G=y.low>>>16,le=y.low&65535,re=0,oe=0,Y=0,ce=0;return ce+=W+le,Y+=ce>>>16,ce&=65535,Y+=$+G,oe+=Y>>>16,Y&=65535,oe+=V+ee,re+=oe>>>16,oe&=65535,re+=A+ne,re&=65535,f(Y<<16|ce,re<<16|oe,this.unsigned)},E.subtract=function(y){return o(y)||(y=h(y)),this.add(y.neg())},E.sub=E.subtract,E.multiply=function(y){if(this.isZero())return this;if(o(y)||(y=h(y)),a){var A=a.mul(this.low,this.high,y.low,y.high);return f(A,a.get_high(),this.unsigned)}if(y.isZero())return this.unsigned?w:M;if(this.eq(D))return y.isOdd()?D:M;if(y.eq(D))return this.isOdd()?D:M;if(this.isNegative())return y.isNegative()?this.neg().mul(y.neg()):this.neg().mul(y).neg();if(y.isNegative())return this.mul(y.neg()).neg();if(this.lt(k)&&y.lt(k))return p(this.toNumber()*y.toNumber(),this.unsigned);var V=this.high>>>16,$=this.high&65535,W=this.low>>>16,ne=this.low&65535,ee=y.high>>>16,G=y.high&65535,le=y.low>>>16,re=y.low&65535,oe=0,Y=0,ce=0,ae=0;return ae+=ne*re,ce+=ae>>>16,ae&=65535,ce+=W*re,Y+=ce>>>16,ce&=65535,ce+=ne*le,Y+=ce>>>16,ce&=65535,Y+=$*re,oe+=Y>>>16,Y&=65535,Y+=W*le,oe+=Y>>>16,Y&=65535,Y+=ne*G,oe+=Y>>>16,Y&=65535,oe+=V*re+$*le+W*G+ne*ee,oe&=65535,f(ce<<16|ae,oe<<16|Y,this.unsigned)},E.mul=E.multiply,E.divide=function(y){if(o(y)||(y=h(y)),y.isZero())throw Error("division by zero");if(a){if(!this.unsigned&&this.high===-2147483648&&y.low===-1&&y.high===-1)return this;var A=(this.unsigned?a.div_u:a.div_s)(this.low,this.high,y.low,y.high);return f(A,a.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?w:M;var V,$,W;if(this.unsigned){if(y.unsigned||(y=y.toUnsigned()),y.gt(this))return w;if(y.gt(this.shru(1)))return N;W=w}else{if(this.eq(D)){if(y.eq(S)||y.eq(F))return D;if(y.eq(D))return S;var ne=this.shr(1);return V=ne.div(y).shl(1),V.eq(M)?y.isNegative()?S:F:($=this.sub(y.mul(V)),W=V.add($.div(y)),W)}else if(y.eq(D))return this.unsigned?w:M;if(this.isNegative())return y.isNegative()?this.neg().div(y.neg()):this.neg().div(y).neg();if(y.isNegative())return this.div(y.neg()).neg();W=M}for($=this;$.gte(y);){V=Math.max(1,Math.floor($.toNumber()/y.toNumber()));for(var ee=Math.ceil(Math.log(V)/Math.LN2),G=ee<=48?1:d(2,ee-48),le=p(V),re=le.mul(y);re.isNegative()||re.gt($);)V-=G,le=p(V,this.unsigned),re=le.mul(y);le.isZero()&&(le=S),W=W.add(le),$=$.sub(re)}return W},E.div=E.divide,E.modulo=function(y){if(o(y)||(y=h(y)),a){var A=(this.unsigned?a.rem_u:a.rem_s)(this.low,this.high,y.low,y.high);return f(A,a.get_high(),this.unsigned)}return this.sub(this.div(y).mul(y))},E.mod=E.modulo,E.rem=E.modulo,E.not=function(){return f(~this.low,~this.high,this.unsigned)},E.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},E.clz=E.countLeadingZeros,E.countTrailingZeros=function(){return this.low?i(this.low):i(this.high)+32},E.ctz=E.countTrailingZeros,E.and=function(y){return o(y)||(y=h(y)),f(this.low&y.low,this.high&y.high,this.unsigned)},E.or=function(y){return o(y)||(y=h(y)),f(this.low|y.low,this.high|y.high,this.unsigned)},E.xor=function(y){return o(y)||(y=h(y)),f(this.low^y.low,this.high^y.high,this.unsigned)},E.shiftLeft=function(y){return o(y)&&(y=y.toInt()),(y&=63)===0?this:y<32?f(this.low<<y,this.high<<y|this.low>>>32-y,this.unsigned):f(0,this.low<<y-32,this.unsigned)},E.shl=E.shiftLeft,E.shiftRight=function(y){return o(y)&&(y=y.toInt()),(y&=63)===0?this:y<32?f(this.low>>>y|this.high<<32-y,this.high>>y,this.unsigned):f(this.high>>y-32,this.high>=0?0:-1,this.unsigned)},E.shr=E.shiftRight,E.shiftRightUnsigned=function(y){return o(y)&&(y=y.toInt()),(y&=63)===0?this:y<32?f(this.low>>>y|this.high<<32-y,this.high>>>y,this.unsigned):y===32?f(this.high,0,this.unsigned):f(this.high>>>y-32,0,this.unsigned)},E.shru=E.shiftRightUnsigned,E.shr_u=E.shiftRightUnsigned,E.rotateLeft=function(y){var A;return o(y)&&(y=y.toInt()),(y&=63)===0?this:y===32?f(this.high,this.low,this.unsigned):y<32?(A=32-y,f(this.low<<y|this.high>>>A,this.high<<y|this.low>>>A,this.unsigned)):(y-=32,A=32-y,f(this.high<<y|this.low>>>A,this.low<<y|this.high>>>A,this.unsigned))},E.rotl=E.rotateLeft,E.rotateRight=function(y){var A;return o(y)&&(y=y.toInt()),(y&=63)===0?this:y===32?f(this.high,this.low,this.unsigned):y<32?(A=32-y,f(this.high<<A|this.low>>>y,this.low<<A|this.high>>>y,this.unsigned)):(y-=32,A=32-y,f(this.low<<A|this.high>>>y,this.high<<A|this.low>>>y,this.unsigned))},E.rotr=E.rotateRight,E.toSigned=function(){return this.unsigned?f(this.low,this.high,!1):this},E.toUnsigned=function(){return this.unsigned?this:f(this.low,this.high,!0)},E.toBytes=function(y){return y?this.toBytesLE():this.toBytesBE()},E.toBytesLE=function(){var y=this.high,A=this.low;return[A&255,A>>>8&255,A>>>16&255,A>>>24,y&255,y>>>8&255,y>>>16&255,y>>>24]},E.toBytesBE=function(){var y=this.high,A=this.low;return[y>>>24,y>>>16&255,y>>>8&255,y&255,A>>>24,A>>>16&255,A>>>8&255,A&255]},r.fromBytes=function(y,A,V){return V?r.fromBytesLE(y,A):r.fromBytesBE(y,A)},r.fromBytesLE=function(y,A){return new r(y[0]|y[1]<<8|y[2]<<16|y[3]<<24,y[4]|y[5]<<8|y[6]<<16|y[7]<<24,A)},r.fromBytesBE=function(y,A){return new r(y[4]<<24|y[5]<<16|y[6]<<8|y[7],y[0]<<24|y[1]<<16|y[2]<<8|y[3],A)},typeof BigInt=="function"&&(r.fromBigInt=function(y,A){var V=Number(BigInt.asIntN(32,y)),$=Number(BigInt.asIntN(32,y>>BigInt(32)));return f(V,$,A)},r.fromValue=function(y,A){return typeof y=="bigint"?r.fromBigInt(y,A):h(y,A)},E.toBigInt=function(){var y=BigInt(this.low>>>0),A=BigInt(this.unsigned?this.high>>>0:this.high);return A<<BigInt(32)|y}),n.default=r})}(In,In.exports)),In.exports}var Sr;function Qt(){return Sr||(Sr=1,function(e){var t=e;t.asPromise=As,t.base64=Fi,t.EventEmitter=Ls,t.float=Rs,t.inquire=Bs,t.utf8=Di,t.pool=Ds,t.LongBits=Vs();function n(o){return o==="__proto__"||o==="prototype"||o==="constructor"}t.isUnsafeProperty=n,t.isNode=!!(typeof Rt!="undefined"&&Rt&&Rt.process&&Rt.process.versions&&Rt.process.versions.node),t.global=t.isNode&&Rt||typeof window!="undefined"&&window||typeof self!="undefined"&&self||Rt,t.emptyArray=Object.freeze?Object.freeze([]):[],t.emptyObject=Object.freeze?Object.freeze({}):{},t.isInteger=Number.isInteger||function(i){return typeof i=="number"&&isFinite(i)&&Math.floor(i)===i},t.isString=function(i){return typeof i=="string"||i instanceof String},t.isObject=function(i){return i&&typeof i=="object"},t.isset=t.isSet=function(i,l){var s=i[l];return s!=null&&i.hasOwnProperty(l)?typeof s!="object"||(Array.isArray(s)?s.length:Object.keys(s).length)>0:!1},t.Buffer=function(){try{var o=t.global.Buffer;return o.prototype.utf8Write?o:null}catch(i){return null}}(),t._Buffer_from=null,t._Buffer_allocUnsafe=null,t.newBuffer=function(i){return typeof i=="number"?t.Buffer?t._Buffer_allocUnsafe(i):new t.Array(i):t.Buffer?t._Buffer_from(i):typeof Uint8Array=="undefined"?i:new Uint8Array(i)},t.Array=typeof Uint8Array!="undefined"?Uint8Array:Array,t.Long=t.global.dcodeIO&&t.global.dcodeIO.Long||t.global.Long||function(){try{var o=$s();return o&&o.isLong?o:null}catch(i){return null}}(),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(i){return i?t.LongBits.from(i).toHash():t.LongBits.zeroHash},t.longFromHash=function(i,l){var s=t.LongBits.fromHash(i);return t.Long?t.Long.fromBits(s.lo,s.hi,l):s.toNumber(!!l)};function a(o){var i=typeof arguments[arguments.length-1]=="boolean",l=i?arguments.length-1:arguments.length;i=i&&arguments[arguments.length-1];for(var s=1;s<l;++s){var c=arguments[s];if(c)for(var p=Object.keys(c),f=0;f<p.length;++f)!n(p[f])&&(o[p[f]]===void 0||!i)&&(o[p[f]]=c[p[f]])}return o}t.merge=a,t.nestingLimit=32,t.recursionLimit=100,t.makeProp=function(i,l){Object.defineProperty(i,l,{enumerable:!0,configurable:!0,writable:!0})},t.lcFirst=function(i){return i.charAt(0).toLowerCase()+i.substring(1)};function r(o){function i(l,s){if(!(this instanceof i))return new i(l,s);Object.defineProperty(this,"message",{get:function(){return l}}),Error.captureStackTrace?Error.captureStackTrace(this,i):Object.defineProperty(this,"stack",{value:new Error().stack||""}),s&&a(this,s)}return i.prototype=Object.create(Error.prototype,{constructor:{value:i,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return o},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),i}t.newError=r,t.ProtocolError=r("ProtocolError"),t.oneOfGetter=function(i){for(var l={},s=0;s<i.length;++s)l[i[s]]=1;return function(){for(var c=Object.keys(this),p=c.length-1;p>-1;--p)if(l[c[p]]===1&&this[c[p]]!==void 0&&this[c[p]]!==null)return c[p]}},t.oneOfSetter=function(i){return function(l){for(var s=0;s<i.length;++s)i[s]!==l&&delete this[i[s]]}},t.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},t._configure=function(){var o=t.Buffer;if(!o){t._Buffer_from=t._Buffer_allocUnsafe=null;return}t._Buffer_from=o.from!==Uint8Array.from&&o.from||function(l,s){return new o(l,s)},t._Buffer_allocUnsafe=o.allocUnsafe||function(l){return new o(l)}}}(uo)),uo}var zi=ze,dt=Qt(),So,Un=dt.LongBits,Tr=dt.base64,br=dt.utf8;function bn(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}function Fo(){}function Ws(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function ze(){this.len=0,this.head=new bn(Fo,0,0),this.tail=this.head,this.states=null}var Vi=function(){return dt.Buffer?function(){return(ze.create=function(){return new So})()}:function(){return new ze}};ze.create=Vi();ze.alloc=function(t){return new dt.Array(t)};dt.Array!==Array&&(ze.alloc=dt.pool(ze.alloc,dt.Array.prototype.subarray));ze.prototype._push=function(t,n,a){return this.tail=this.tail.next=new bn(t,n,a),this.len+=n,this};function Do(e,t,n){t[n]=e&255}function Us(e,t,n){for(;e>127;)t[n++]=e&127|128,e>>>=7;t[n]=e}function zo(e,t){this.len=e,this.next=void 0,this.val=t}zo.prototype=Object.create(bn.prototype);zo.prototype.fn=Us;ze.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new zo((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this};ze.prototype.int32=function(t){return(t|=0)<0?this._push(Vo,10,Un.fromNumber(t)):this.uint32(t)};ze.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)};function Vo(e,t,n){for(var a=e.lo,r=e.hi;r;)t[n++]=a&127|128,a=(a>>>7|r<<25)>>>0,r>>>=7;for(;a>127;)t[n++]=a&127|128,a=a>>>7;t[n++]=a}ze.prototype.uint64=function(t){var n=Un.from(t);return this._push(Vo,n.length(),n)};ze.prototype.int64=ze.prototype.uint64;ze.prototype.sint64=function(t){var n=Un.from(t).zzEncode();return this._push(Vo,n.length(),n)};ze.prototype.bool=function(t){return this._push(Do,1,t?1:0)};function To(e,t,n){t[n]=e&255,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}ze.prototype.fixed32=function(t){return this._push(To,4,t>>>0)};ze.prototype.sfixed32=ze.prototype.fixed32;ze.prototype.fixed64=function(t){var n=Un.from(t);return this._push(To,4,n.lo)._push(To,4,n.hi)};ze.prototype.sfixed64=ze.prototype.fixed64;ze.prototype.float=function(t){return this._push(dt.float.writeFloatLE,4,t)};ze.prototype.double=function(t){return this._push(dt.float.writeDoubleLE,8,t)};var Hs=dt.Array.prototype.set?function(t,n,a){n.set(t,a)}:function(t,n,a){for(var r=0;r<t.length;++r)n[a+r]=t[r]};ze.prototype.bytes=function(t){var n=t.length>>>0;if(!n)return this._push(Do,1,0);if(dt.isString(t)){var a=ze.alloc(n=Tr.length(t));Tr.decode(t,a,0),t=a}return this.uint32(n)._push(Hs,n,t)};ze.prototype.string=function(t){var n=br.length(t);return n?this.uint32(n)._push(br.write,n,t):this._push(Do,1,0)};ze.prototype.fork=function(){return this.states=new Ws(this),this.head=this.tail=new bn(Fo,0,0),this.len=0,this};ze.prototype.reset=function(){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 bn(Fo,0,0),this.len=0),this};ze.prototype.ldelim=function(){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};ze.prototype.finish=function(){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};ze._configure=function(e){So=e,ze.create=Vi(),So._configure()};var Zs=St,$i=zi;(St.prototype=Object.create($i.prototype)).constructor=St;var Vt=Qt();function St(){$i.call(this)}St._configure=function(){St.alloc=Vt._Buffer_allocUnsafe,St.writeBytesBuffer=Vt.Buffer&&Vt.Buffer.prototype instanceof Uint8Array&&Vt.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++]}};St.prototype.bytes=function(t){Vt.isString(t)&&(t=Vt._Buffer_from(t,"base64"));var n=t.length>>>0;return this.uint32(n),n&&this._push(St.writeBytesBuffer,n,t),this};function Gs(e,t,n){e.length<40?Vt.utf8.write(e,t,n):t.utf8Write?t.utf8Write(e,n):t.write(e,n)}St.prototype.string=function(t){var n=Vt.Buffer.byteLength(t);return this.uint32(n),n&&this._push(Gs,n,t),this};St._configure();var Wi=Ze,pt=Qt(),bo,Ui=pt.LongBits,Ys=pt.utf8;function yt(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function Ze(e){this.buf=e,this.pos=0,this.len=e.length}var kr=typeof Uint8Array!="undefined"?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new Ze(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new Ze(t);throw Error("illegal buffer")},Hi=function(){return pt.Buffer?function(n){return(Ze.create=function(r){return pt.Buffer.isBuffer(r)?new bo(r):kr(r)})(n)}:kr};Ze.create=Hi();Ze.prototype._slice=pt.Array.prototype.subarray||pt.Array.prototype.slice;Ze.prototype.uint32=function(){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,yt(this,10);return t}}();Ze.prototype.int32=function(){return this.uint32()|0};Ze.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(t&1)|0};function po(){var e=new Ui(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 yt(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 yt(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")}Ze.prototype.bool=function(){return this.uint32()!==0};function Fn(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}Ze.prototype.fixed32=function(){if(this.pos+4>this.len)throw yt(this,4);return Fn(this.buf,this.pos+=4)};Ze.prototype.sfixed32=function(){if(this.pos+4>this.len)throw yt(this,4);return Fn(this.buf,this.pos+=4)|0};function Er(){if(this.pos+8>this.len)throw yt(this,8);return new Ui(Fn(this.buf,this.pos+=4),Fn(this.buf,this.pos+=4))}Ze.prototype.float=function(){if(this.pos+4>this.len)throw yt(this,4);var t=pt.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t};Ze.prototype.double=function(){if(this.pos+8>this.len)throw yt(this,4);var t=pt.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t};Ze.prototype.bytes=function(){var t=this.uint32(),n=this.pos,a=this.pos+t;if(a>this.len)throw yt(this,t);if(this.pos+=t,Array.isArray(this.buf))return this.buf.slice(n,a);if(n===a){var r=pt.Buffer;return r?r.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,n,a)};Ze.prototype.string=function(){var t=this.bytes();return Ys.read(t,0,t.length)};Ze.prototype.skip=function(t){if(typeof t=="number"){if(this.pos+t>this.len)throw yt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw yt(this);while(this.buf[this.pos++]&128);return this};Ze.recursionLimit=pt.recursionLimit;Ze.prototype.skipType=function(e,t){if(t===void 0&&(t=0),t>Ze.recursionLimit)throw Error("maximum nesting depth exceeded");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,t+1);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this};Ze._configure=function(e){bo=e,Ze.create=Hi(),bo._configure();var t=pt.Long?"toLong":"toNumber";pt.merge(Ze.prototype,{int64:function(){return po.call(this)[t](!1)},uint64:function(){return po.call(this)[t](!0)},sint64:function(){return po.call(this).zzDecode()[t](!1)},fixed64:function(){return Er.call(this)[t](!0)},sfixed64:function(){return Er.call(this)[t](!1)}})};var Js=Xt,Zi=Wi;(Xt.prototype=Object.create(Zi.prototype)).constructor=Xt;var Nr=Qt();function Xt(e){Zi.call(this,e)}Xt._configure=function(){Nr.Buffer&&(Xt.prototype._slice=Nr.Buffer.prototype.slice)};Xt.prototype.string=function(){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))};Xt._configure();var Gi={},Xs=Tn,$o=Qt();(Tn.prototype=Object.create($o.EventEmitter.prototype)).constructor=Tn;function Tn(e,t,n){if(typeof e!="function")throw TypeError("rpcImpl must be a function");$o.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=!!t,this.responseDelimited=!!n}Tn.prototype.rpcCall=function e(t,n,a,r,o){if(!r)throw TypeError("request must be specified");var i=this;if(!o)return $o.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(s,c){if(s)return i.emit("error",s,t),o(s);if(c===null){i.end(!0);return}if(!(c instanceof a))try{c=a[i.responseDelimited?"decodeDelimited":"decode"](c)}catch(p){return i.emit("error",p,t),o(p)}return i.emit("data",c,t),o(null,c)})}catch(l){i.emit("error",l,t),setTimeout(function(){o(l)},0);return}};Tn.prototype.end=function(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=Xs})(Gi);var qs=Object.create(null);(function(e){var t=e;t.build="minimal",t.Writer=zi,t.BufferWriter=Zs,t.Reader=Wi,t.BufferReader=Js,t.util=Qt(),t.rpc=Gi,t.roots=qs,t.configure=n;function n(){t.util._configure(),t.Writer._configure(t.BufferWriter),t.Reader._configure(t.BufferReader)}n()})(Bi);var se=Bi;function Ks(e){switch(e){case 0:case"UNKNOWN":return 0;case 4:case"ROADWAY":return 4;case-1:case"UNRECOGNIZED":default:return-1}}function Qs(e){switch(e){case 0:return"UNKNOWN";case 4:return"ROADWAY";case-1:default:return"UNRECOGNIZED"}}function Ir(){return{x:0,y:0,z:0}}const K={encode(e,t=se.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=Ir();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:Pt(e.x)?globalThis.Number(e.x):0,y:Pt(e.y)?globalThis.Number(e.y):0,z:Pt(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 K.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=Ir();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 wr(){return{r:0,g:0,b:0,a:0}}const ot={encode(e,t=se.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=wr();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:Pt(e.r)?globalThis.Number(e.r):0,g:Pt(e.g)?globalThis.Number(e.g):0,b:Pt(e.b)?globalThis.Number(e.b):0,a:Pt(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 ot.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o;const t=wr();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 Or(){return{x:0,y:0,z:0}}const rt={encode(e,t=se.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=Or();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:Pt(e.x)?globalThis.Number(e.x):0,y:Pt(e.y)?globalThis.Number(e.y):0,z:Pt(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 rt.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=Or();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 Ar(){return{vertices:[],normals:[],indices:[],colors:[],uv:[]}}const We={encode(e,t=se.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=Ar();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(l=>Math.round(l))),(o=e.colors)!=null&&o.length&&(t.colors=e.colors),(i=e.uv)!=null&&i.length&&(t.uv=e.uv),t},create(e){return We.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=Ar();return t.vertices=((n=e.vertices)==null?void 0:n.map(l=>l))||[],t.normals=((a=e.normals)==null?void 0:a.map(l=>l))||[],t.indices=((r=e.indices)==null?void 0:r.map(l=>l))||[],t.colors=((o=e.colors)==null?void 0:o.map(l=>l))||[],t.uv=((i=e.uv)==null?void 0:i.map(l=>l))||[],t}};function Pt(e){return e!=null}function js(e){switch(e){case 0:case"RECTANGLE":return 0;case 1:case"CICLE":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function el(e){switch(e){case 0:return"RECTANGLE";case 1:return"CICLE";case-1:default:return"UNRECOGNIZED"}}function Mr(){return{dataType:0,name:"",position:void 0,boxes:[]}}const Yi={encode(e,t=se.Writer.create()){e.dataType!==0&&t.uint32(8).int32(e.dataType),e.name!==""&&t.uint32(26).string(e.name),e.position!==void 0&&K.encode(e.position,t.uint32(34).fork()).ldelim();for(const n of e.boxes)it.encode(n,t.uint32(66).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=Mr();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=K.decode(n,n.uint32());continue;case 8:if(o!==66)break;r.boxes.push(it.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{dataType:tt(e.dataType)?Ks(e.dataType):0,name:tt(e.name)?globalThis.String(e.name):"",position:tt(e.position)?K.fromJSON(e.position):void 0,boxes:globalThis.Array.isArray(e==null?void 0:e.boxes)?e.boxes.map(t=>it.fromJSON(t)):[]}},toJSON(e){var n;const t={};return e.dataType!==0&&(t.dataType=Qs(e.dataType)),e.name!==""&&(t.name=e.name),e.position!==void 0&&(t.position=K.toJSON(e.position)),(n=e.boxes)!=null&&n.length&&(t.boxes=e.boxes.map(a=>it.toJSON(a))),t},create(e){return Yi.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=Mr();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?K.fromPartial(e.position):void 0,t.boxes=((r=e.boxes)==null?void 0:r.map(o=>it.fromPartial(o)))||[],t}};function Lr(){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 it={encode(e,t=se.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&&K.encode(e.startPosition,t.uint32(34).fork()).ldelim(),e.endPosition!==void 0&&K.encode(e.endPosition,t.uint32(42).fork()).ldelim(),e.type!==0&&t.uint32(48).int32(e.type),e.topMesh!==void 0&&We.encode(e.topMesh,t.uint32(58).fork()).ldelim(),e.sideMesh!==void 0&&We.encode(e.sideMesh,t.uint32(66).fork()).ldelim(),e.bottomMesh!==void 0&&We.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=Lr();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=K.decode(n,n.uint32());continue;case 5:if(o!==42)break;r.endPosition=K.decode(n,n.uint32());continue;case 6:if(o!==48)break;r.type=n.int32();continue;case 7:if(o!==58)break;r.topMesh=We.decode(n,n.uint32());continue;case 8:if(o!==66)break;r.sideMesh=We.decode(n,n.uint32());continue;case 9:if(o!==74)break;r.bottomMesh=We.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:tt(e.name)?globalThis.String(e.name):"",leftSpace:tt(e.leftSpace)?globalThis.Number(e.leftSpace):0,rightSpace:tt(e.rightSpace)?globalThis.Number(e.rightSpace):0,startPosition:tt(e.startPosition)?K.fromJSON(e.startPosition):void 0,endPosition:tt(e.endPosition)?K.fromJSON(e.endPosition):void 0,type:tt(e.type)?js(e.type):0,topMesh:tt(e.topMesh)?We.fromJSON(e.topMesh):void 0,sideMesh:tt(e.sideMesh)?We.fromJSON(e.sideMesh):void 0,bottomMesh:tt(e.bottomMesh)?We.fromJSON(e.bottomMesh):void 0,width:tt(e.width)?globalThis.Number(e.width):0,height:tt(e.height)?globalThis.Number(e.height):0,startOutWidth:tt(e.startOutWidth)?globalThis.Number(e.startOutWidth):0,endOutWidth:tt(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=K.toJSON(e.startPosition)),e.endPosition!==void 0&&(t.endPosition=K.toJSON(e.endPosition)),e.type!==0&&(t.type=el(e.type)),e.topMesh!==void 0&&(t.topMesh=We.toJSON(e.topMesh)),e.sideMesh!==void 0&&(t.sideMesh=We.toJSON(e.sideMesh)),e.bottomMesh!==void 0&&(t.bottomMesh=We.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 it.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,l,s,c;const t=Lr();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?K.fromPartial(e.startPosition):void 0,t.endPosition=e.endPosition!==void 0&&e.endPosition!==null?K.fromPartial(e.endPosition):void 0,t.type=(o=e.type)!=null?o:0,t.topMesh=e.topMesh!==void 0&&e.topMesh!==null?We.fromPartial(e.topMesh):void 0,t.sideMesh=e.sideMesh!==void 0&&e.sideMesh!==null?We.fromPartial(e.sideMesh):void 0,t.bottomMesh=e.bottomMesh!==void 0&&e.bottomMesh!==null?We.fromPartial(e.bottomMesh):void 0,t.width=(i=e.width)!=null?i:0,t.height=(l=e.height)!=null?l:0,t.startOutWidth=(s=e.startOutWidth)!=null?s:0,t.endOutWidth=(c=e.endOutWidth)!=null?c:0,t}};function tt(e){return e!=null}function tl(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 nl(e){switch(e){case 0:return"NORMAL_FRAME";case 1:return"KEY_FRAME";case-1:default:return"UNRECOGNIZED"}}var Ln=(e=>(e[e.RUN=0]="RUN",e[e.WATER=1]="WATER",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Ln||{});function ol(e){switch(e){case 0:case"RUN":return 0;case 1:case"WATER":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function rl(e){switch(e){case 0:return"RUN";case 1:return"WATER";case-1:default:return"UNRECOGNIZED"}}function Rr(){return{name:"",frameRate:0,type:0,frames:[],boxes:[],animType:0,colors:[]}}const Ji={encode(e,t=se.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)on.encode(n,t.uint32(34).fork()).ldelim();for(const n of e.boxes)it.encode(n,t.uint32(42).fork()).ldelim();e.animType!==0&&t.uint32(48).int32(e.animType);for(const n of e.colors)ot.encode(n,t.uint32(58).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=Rr();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(on.decode(n,n.uint32()));continue;case 5:if(o!==42)break;r.boxes.push(it.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(ot.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:wt(e.name)?globalThis.String(e.name):"",frameRate:wt(e.frameRate)?globalThis.Number(e.frameRate):0,type:wt(e.type)?tl(e.type):0,frames:globalThis.Array.isArray(e==null?void 0:e.frames)?e.frames.map(t=>on.fromJSON(t)):[],boxes:globalThis.Array.isArray(e==null?void 0:e.boxes)?e.boxes.map(t=>it.fromJSON(t)):[],animType:wt(e.animType)?ol(e.animType):0,colors:globalThis.Array.isArray(e==null?void 0:e.colors)?e.colors.map(t=>ot.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=nl(e.type)),(n=e.frames)!=null&&n.length&&(t.frames=e.frames.map(o=>on.toJSON(o))),(a=e.boxes)!=null&&a.length&&(t.boxes=e.boxes.map(o=>it.toJSON(o))),e.animType!==0&&(t.animType=rl(e.animType)),(r=e.colors)!=null&&r.length&&(t.colors=e.colors.map(o=>ot.toJSON(o))),t},create(e){return Ji.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,l,s;const t=Rr();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=>on.fromPartial(c)))||[],t.boxes=((i=e.boxes)==null?void 0:i.map(c=>it.fromPartial(c)))||[],t.animType=(l=e.animType)!=null?l:0,t.colors=((s=e.colors)==null?void 0:s.map(c=>ot.fromPartial(c)))||[],t}};function Br(){return{start:0,end:0}}const mt={encode(e,t=se.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=Br();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:wt(e.start)?globalThis.Number(e.start):0,end:wt(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 mt.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=Br();return t.start=(n=e.start)!=null?n:0,t.end=(a=e.end)!=null?a:0,t}};function Fr(){return{index:0,name:"",percent:[],colorPercent:[]}}const nn={encode(e,t=se.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)mt.encode(n,t.uint32(26).fork()).ldelim();for(const n of e.colorPercent)mt.encode(n,t.uint32(34).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=Fr();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(mt.decode(n,n.uint32()));continue;case 4:if(o!==34)break;r.colorPercent.push(mt.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{index:wt(e.index)?globalThis.Number(e.index):0,name:wt(e.name)?globalThis.String(e.name):"",percent:globalThis.Array.isArray(e==null?void 0:e.percent)?e.percent.map(t=>mt.fromJSON(t)):[],colorPercent:globalThis.Array.isArray(e==null?void 0:e.colorPercent)?e.colorPercent.map(t=>mt.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=>mt.toJSON(r))),(a=e.colorPercent)!=null&&a.length&&(t.colorPercent=e.colorPercent.map(r=>mt.toJSON(r))),t},create(e){return nn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o;const t=Fr();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=>mt.fromPartial(i)))||[],t.colorPercent=((o=e.colorPercent)==null?void 0:o.map(i=>mt.fromPartial(i)))||[],t}};function Dr(){return{node:[],time:0}}const on={encode(e,t=se.Writer.create()){for(const n of e.node)nn.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=Dr();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.node.push(nn.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=>nn.fromJSON(t)):[],time:wt(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=>nn.toJSON(a))),e.time!==0&&(t.time=e.time),t},create(e){return on.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=Dr();return t.node=((n=e.node)==null?void 0:n.map(r=>nn.fromPartial(r)))||[],t.time=(a=e.time)!=null?a:0,t}};function wt(e){return e!=null}function il(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 al(e){switch(e){case 0:return"NORMAL_FRAME";case 1:return"KEY_FRAME";case-1:default:return"UNRECOGNIZED"}}function zr(){return{name:"",frameRate:0,type:0,nodes:[],boxes:[]}}const Xi={encode(e,t=se.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)rn.encode(n,t.uint32(34).fork()).ldelim();for(const n of e.boxes)it.encode(n,t.uint32(42).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=zr();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(rn.decode(n,n.uint32()));continue;case 5:if(o!==42)break;r.boxes.push(it.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:$t(e.name)?globalThis.String(e.name):"",frameRate:$t(e.frameRate)?globalThis.Number(e.frameRate):0,type:$t(e.type)?il(e.type):0,nodes:globalThis.Array.isArray(e==null?void 0:e.nodes)?e.nodes.map(t=>rn.fromJSON(t)):[],boxes:globalThis.Array.isArray(e==null?void 0:e.boxes)?e.boxes.map(t=>it.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=al(e.type)),(n=e.nodes)!=null&&n.length&&(t.nodes=e.nodes.map(r=>rn.toJSON(r))),(a=e.boxes)!=null&&a.length&&(t.boxes=e.boxes.map(r=>it.toJSON(r))),t},create(e){return Xi.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=zr();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(l=>rn.fromPartial(l)))||[],t.boxes=((i=e.boxes)==null?void 0:i.map(l=>it.fromPartial(l)))||[],t}};function Vr(){return{start:0,end:0}}const gt={encode(e,t=se.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=Vr();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:$t(e.start)?globalThis.Number(e.start):0,end:$t(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 gt.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=Vr();return t.start=(n=e.start)!=null?n:0,t.end=(a=e.end)!=null?a:0,t}};function $r(){return{index:0,name:"",frames:[]}}const rn={encode(e,t=se.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)an.encode(n,t.uint32(26).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=$r();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(an.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{index:$t(e.index)?globalThis.Number(e.index):0,name:$t(e.name)?globalThis.String(e.name):"",frames:globalThis.Array.isArray(e==null?void 0:e.frames)?e.frames.map(t=>an.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=>an.toJSON(a))),t},create(e){return rn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=$r();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=>an.fromPartial(o)))||[],t}};function Wr(){return{time:0,percent:[],colorPercent:[]}}const an={encode(e,t=se.Writer.create()){e.time!==0&&t.uint32(13).float(e.time);for(const n of e.percent)gt.encode(n,t.uint32(18).fork()).ldelim();for(const n of e.colorPercent)gt.encode(n,t.uint32(26).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=Wr();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(gt.decode(n,n.uint32()));continue;case 3:if(o!==26)break;r.colorPercent.push(gt.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{time:$t(e.time)?globalThis.Number(e.time):0,percent:globalThis.Array.isArray(e==null?void 0:e.percent)?e.percent.map(t=>gt.fromJSON(t)):[],colorPercent:globalThis.Array.isArray(e==null?void 0:e.colorPercent)?e.colorPercent.map(t=>gt.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=>gt.toJSON(r))),(a=e.colorPercent)!=null&&a.length&&(t.colorPercent=e.colorPercent.map(r=>gt.toJSON(r))),t},create(e){return an.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=Wr();return t.time=(n=e.time)!=null?n:0,t.percent=((a=e.percent)==null?void 0:a.map(o=>gt.fromPartial(o)))||[],t.colorPercent=((r=e.colorPercent)==null?void 0:r.map(o=>gt.fromPartial(o)))||[],t}};function $t(e){return e!=null}function sl(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 ll(e){switch(e){case 0:return"NORMAL_FRAME";case 1:return"KEY_FRAME";case-1:default:return"UNRECOGNIZED"}}function Ur(){return{name:"",frameRate:0,type:0,frames:[],url:""}}const qi={encode(e,t=se.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)ln.encode(n,t.uint32(34).fork()).ldelim();return e.url!==""&&t.uint32(42).string(e.url),t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=Ur();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(ln.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:Jt(e.name)?globalThis.String(e.name):"",frameRate:Jt(e.frameRate)?globalThis.Number(e.frameRate):0,type:Jt(e.type)?sl(e.type):0,frames:globalThis.Array.isArray(e==null?void 0:e.frames)?e.frames.map(t=>ln.fromJSON(t)):[],url:Jt(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=ll(e.type)),(n=e.frames)!=null&&n.length&&(t.frames=e.frames.map(a=>ln.toJSON(a))),e.url!==""&&(t.url=e.url),t},create(e){return qi.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=Ur();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(l=>ln.fromPartial(l)))||[],t.url=(i=e.url)!=null?i:"",t}};function Hr(){return{name:"",position:void 0}}const sn={encode(e,t=se.Writer.create()){return e.name!==""&&t.uint32(10).string(e.name),e.position!==void 0&&rt.encode(e.position,t.uint32(18).fork()).ldelim(),t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=Hr();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=rt.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:Jt(e.name)?globalThis.String(e.name):"",position:Jt(e.position)?rt.fromJSON(e.position):void 0}},toJSON(e){const t={};return e.name!==""&&(t.name=e.name),e.position!==void 0&&(t.position=rt.toJSON(e.position)),t},create(e){return sn.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=Hr();return t.name=(n=e.name)!=null?n:"",t.position=e.position!==void 0&&e.position!==null?rt.fromPartial(e.position):void 0,t}};function Zr(){return{nodes:[],time:0}}const ln={encode(e,t=se.Writer.create()){for(const n of e.nodes)sn.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=Zr();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.nodes.push(sn.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=>sn.fromJSON(t)):[],time:Jt(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=>sn.toJSON(a))),e.time!==0&&(t.time=e.time),t},create(e){return ln.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=Zr();return t.nodes=((n=e.nodes)==null?void 0:n.map(r=>sn.fromPartial(r)))||[],t.time=(a=e.time)!=null?a:0,t}};function Jt(e){return e!=null}class Pn{constructor(){ve(this,"_keys",[]);ve(this,"getLastKey",()=>this._keys[this._keys.length-1]);ve(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 u.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 st{constructor(t,n){ve(this,"time");ve(this,"value");this.time=t,this.value=n}}class Hn{constructor(t){ve(this,"_curves",[]);this._curves=t}get curves(){return this._curves}update(t){}reset(){}}class cl extends Hn{constructor(){super(...arguments);ve(this,"_name","");ve(this,"_url","");ve(this,"_start");ve(this,"_end");ve(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,l;const n=(o=this.curves[0].getLastKey())==null?void 0:o.value,a=(i=this.curves[1].getLastKey())==null?void 0:i.value,r=(l=this.curves[2].getLastKey())==null?void 0:l.value;return new u.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 u.Vector3(n,a,r)}update(n){var i,l,s;if(n<this.curves[0].length){const c=(i=this.curves[0].evaluate(n))!=null?i:0,p=(l=this.curves[1].evaluate(n))!=null?l:0,f=(s=this.curves[2].evaluate(n))!=null?s:0;this._start=this.getStartPosition(),this._current=new u.Vector3(c,p,f),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 u.Vector3(a,r,o),this._end=this.getEndPosition()}reset(){}}class ul extends Hn{constructor(){super(...arguments);ve(this,"_range",[]);ve(this,"_percent",[]);ve(this,"_start");ve(this,"_end");ve(this,"_name","");ve(this,"_meshs");ve(this,"_colors",[]);ve(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 Ki extends Hn{constructor(){super(...arguments);ve(this,"_range",[]);ve(this,"_percent",[]);ve(this,"_colorPercent",[]);ve(this,"_start");ve(this,"_end");ve(this,"_name","");ve(this,"_meshs");ve(this,"_colors",[]);ve(this,"_type","run");ve(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 ho,mo,go,vo,wn,On,Gr,Yr;function fl(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 ho=r,mo=r*(t-1)*n,go=r*(t+1)*n,vo=-r*a,wn=2*n,On=-a,Gr=(ho+mo)/(1-wn-On),Yr=(go+vo)/(1-wn-On),new Float32Array([ho,mo,go,vo,wn,On,Gr,Yr])}function Jr(e,t,n,a,r,o){var i,l,s,c,p,f,d,x,h,T,P,v,_,b,k,M,w,S,N,F,B,I,D,E,L,y,A,V,$,W;for(L=0;L<o;L++){for(I=L*r,D=L,E=0,i=e[I],l=i&255,s=i>>8&255,c=i>>16&255,p=i>>24&255,S=l*a[6],N=s*a[6],F=c*a[6],B=p*a[6],b=S,k=N,M=F,w=B,A=a[0],V=a[1],$=a[4],W=a[5],y=0;y<r;y++)i=e[I],f=i&255,d=i>>8&255,x=i>>16&255,h=i>>24&255,T=f*A+l*V+b*$+S*W,P=d*A+s*V+k*$+N*W,v=x*A+c*V+M*$+F*W,_=h*A+p*V+w*$+B*W,S=b,N=k,F=M,B=w,b=T,k=P,M=v,w=_,l=f,s=d,c=x,p=h,n[E]=b,n[E+1]=k,n[E+2]=M,n[E+3]=w,E+=4,I++;for(I--,E-=4,D+=o*(r-1),i=e[I],l=i&255,s=i>>8&255,c=i>>16&255,p=i>>24&255,S=l*a[7],N=s*a[7],F=c*a[7],B=p*a[7],b=S,k=N,M=F,w=B,f=l,d=s,x=c,h=p,A=a[2],V=a[3],y=r-1;y>=0;y--)T=f*A+l*V+b*$+S*W,P=d*A+s*V+k*$+N*W,v=x*A+c*V+M*$+F*W,_=h*A+p*V+w*$+B*W,S=b,N=k,F=M,B=w,b=T,k=P,M=v,w=_,l=f,s=d,c=x,p=h,i=e[I],f=i&255,d=i>>8&255,x=i>>16&255,h=i>>24&255,i=(n[E]+b<<0)+(n[E+1]+k<<8)+(n[E+2]+M<<16)+(n[E+3]+w<<24),t[D]=i,I--,E-=4,D-=o}}function dl(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),l=fl(a);Jr(r,o,i,l,t,n),Jr(o,r,i,l,n,t)}}var pl=dl;const hl=Si(pl);class ml extends Hn{constructor(){super(...arguments);ve(this,"_range",[]);ve(this,"_percent",[]);ve(this,"_colorPercent",[]);ve(this,"_start");ve(this,"_end");ve(this,"_name","");ve(this,"_width",0);ve(this,"_height",0);ve(this,"_waterHeight",0);ve(this,"_waterLength",0);ve(this,"_heightMapRaw",new Uint8Array([0,0,0,0]));ve(this,"_lastHeightMapRaw",new Uint8Array([0,0,0,0]));ve(this,"_bottomShape",[]);ve(this,"_percentLength",2);ve(this,"_time",0);ve(this,"_glurMap",new Uint8Array([0,0,0,0]));ve(this,"_startOutWidth",0);ve(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 u.Vector3.Center(this._start||u.Vector3.Zero(),this._end||u.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;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;const l=i+Math.floor(n*this._waterLength),s=i+Math.floor(a*this._waterLength);for(let c=l;c<s;c++){const p=c*4;o[p]=Math.trunc(r*255),o[p+1]=Math.trunc(r*255),o[p+2]=Math.trunc(r*255),o[p+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],l=Math.min(o,i),s=Math.max(o,i);l!=s&&this.updateHeightMapByPercent(l,s,.5)}for(let r=this._percentLength;r<this._range.length;r+=2){const o=this._range[r],i=this._range[r+1],l=Math.min(o,i),s=Math.max(o,i);l!=s&&this.updateHeightMapByPercent(l,s,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;hl(r,1,o,5),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 Xr=e=>{const t=Ji.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(s=>s===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,l=t.frames[0].node[0].colorPercent.length;for(let p=0;p<(i+l)*2;p++)o.push(new Pn);let s=0;for(let p=0;p<t.frames.length;p++){const f=t.frames[p],d=f.node.findIndex(x=>x.name===a[r]);if(d!==-1){for(let x=0;x<i;x++){const h=new st(f.time*1e3,f.node[d].percent[x].start),T=new st(f.time*1e3,f.node[d].percent[x].end);o[x*2].addKey(h),o[x*2+1].addKey(T)}for(let x=0;x<l;x++){const h=new st(f.time*1e3,f.node[d].colorPercent[x].start),T=new st(f.time*1e3,f.node[d].colorPercent[x].end);o[i*2+x*2].addKey(h),o[i*2+x*2+1].addKey(T)}s=f.node[d].index}}const c=t.animType===Ln.WATER?new Ki(o):new ul(o);c.meshs=[t.boxes[s].topMesh,t.boxes[s].bottomMesh,t.boxes[s].sideMesh],c.name=a[r],c.start=At(t.boxes[s].startPosition),c.end=At(t.boxes[s].endPosition),c.type=t.animType===Ln.RUN?"run":"water",c.colors=t.colors.map(p=>bs(p)),t.animType===Ln.WATER&&(c.percentLength=i*2);for(let p=0;p<c.curves.length;p++)if(c.curves[p].keys[0].time!==0){const f=c.curves[p].keys[0],d=new st(0,f.value);d.time=0,c.curves[p].keys.unshift(d)}n.push(c)}return n},gl=e=>{const t=qi.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(s=>s===i.name)===-1&&a.push(i.name)}for(let r=0;r<a.length;r++){const o=[];o.push(new Pn),o.push(new Pn),o.push(new Pn);for(let l=0;l<t.frames.length;l++){const s=t.frames[l],c=s.nodes.findIndex(p=>p.name===a[r]);if(c!==-1){const p=new st(s.time*1e3,s.nodes[c].position.x),f=new st(s.time*1e3,s.nodes[c].position.y),d=new st(s.time*1e3,s.nodes[c].position.z);o[0].addKey(p),o[1].addKey(f),o[2].addKey(d)}}const i=new cl(o);i.name=a[r],i.url=t.url;for(let l=0;l<i.curves.length;l++)if(i.curves[l].keys[0].time!==0){const s=i.curves[l].keys[0],c=new st(0,s.value);c.time=0,i.curves[l].keys.unshift(c)}n.push(i)}return n},vl=e=>{const t=Xi.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 h=0;h<(o+i)*2;h++)r.push(new Pn);for(let h=0;h<t.nodes[a].frames.length;h++){const T=t.nodes[a].frames[h];if("percent"in T&&"colorPercent"in T){for(let P=0;P<o;P++){const v=new st(T.time*1e3,T.percent[P].start),_=new st(T.time*1e3,T.percent[P].end);r[P*2].addKey(v),r[P*2+1].addKey(_)}for(let P=0;P<i;P++){const v=new st(T.time*1e3,T.colorPercent[P].start),_=new st(T.time*1e3,T.colorPercent[P].end);r[o*2+P*2].addKey(v),r[o*2+P*2+1].addKey(_)}}else console.error("[Geo3DViewer] 数据中缺少 percent 或 colorPercent ",t.nodes[a],T)}const l=t.nodes[a].index,s=new ml(r);s.name=t.nodes[a].name,s.start=At(t.boxes[l].startPosition),s.end=At(t.boxes[l].endPosition),s.startOutWidth=t.boxes[l].startOutWidth||0,s.endOutWidth=t.boxes[l].endOutWidth||0,s.waterHeight=.5,s.width=t.boxes[l].width||3.5,s.waterLength=u.Vector3.Distance(s.start,s.end)+.05+s.startOutWidth+s.endOutWidth,s.generateHeightMap();const c=[];for(let h=0;h<t.boxes[l].bottomMesh.vertices.length;h+=3)c.push(new u.Vector3(t.boxes[l].bottomMesh.vertices[h],t.boxes[l].bottomMesh.vertices[h+1],t.boxes[l].bottomMesh.vertices[h+2]));const p=new u.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),f=new u.Vector3(Number.MIN_VALUE,Number.MIN_VALUE,Number.MIN_VALUE);c.forEach(h=>{h.x<p.x&&(p.x=h.x),h.y<p.y&&(p.y=h.y),h.z<p.z&&(p.z=h.z),h.x>f.x&&(f.x=h.x),h.y>f.y&&(f.y=h.y),h.z>f.z&&(f.z=h.z)});const d=[];t.boxes[l].bottomMesh.indices.forEach(h=>{d.push(c[h].subtract(p).multiplyByFloats(1/(f.x-p.x),1/(f.y-p.y),1/(f.z-p.z)))});const x=[];for(let h=0;h<d.length;h+=3)x.push([d[h],d[h+1],d[h+2]]);s.bottomShape=x,s.height=t.boxes[l].height||t.boxes[l].topMesh.vertices[1]-t.boxes[l].bottomMesh.vertices[1],s.percentLength=o*2,console.log("[Geo3DViewer] 正在构建动画 ",s);for(let h=0;h<s.curves.length;h++)if(s.curves[h].keys[0].time!==0){const T=s.curves[h].keys[0],P=new st(0,T.value);P.time=0,s.curves[h].keys.unshift(P)}n.push(s)}return n},Rn=e=>{const{name:t,children:n,url:a,type:r="roadway",speed:o=1}=e,i=m.useRef(null),[l,s]=m.useState(),c=m.useRef(!1),p=je({url:a,cacheType:Me.URL_PREFIX_MATCH}),f=(d,x)=>{let h=[];switch(d){case"roadway":h=Xr(x);break;case"roadwaynear":h=gl(x);break;case"water":h=vl(x);break;default:h=Xr(x)}return h};return m.useEffect(()=>{if(p&&!c.current){c.current=!0;const d=f(r,p);console.log(d);const x=new Os(t);x.nodes=d,i.current=x,i.current.speed=o,i.current.play(),c.current=!1}},[p,t,o,r]),m.useEffect(()=>()=>{i.current&&!c.current&&(console.log("destory animation!"),i.current.onDestory())},[]),m.useEffect(()=>{const d=setInterval(()=>{i.current&&i.current.normalized>0&&s({nodes:i.current.nodes})},100);return()=>{clearInterval(d)}},[]),C.jsx(C.Fragment,{children:l&&m.isValidElement(n)?m.cloneElement(n,{nodes:l==null?void 0:l.nodes,speed:o}):n})};function qr(){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 Wo={encode(e,t=se.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&&K.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=qr();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=K.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:_t(e.name)?globalThis.String(e.name):"",vMin:_t(e.vMin)?globalThis.Number(e.vMin):0,vMax:_t(e.vMax)?globalThis.Number(e.vMax):0,xMin:_t(e.xMin)?globalThis.Number(e.xMin):0,yMin:_t(e.yMin)?globalThis.Number(e.yMin):0,xMax:_t(e.xMax)?globalThis.Number(e.xMax):0,yMax:_t(e.yMax)?globalThis.Number(e.yMax):0,zMin:_t(e.zMin)?globalThis.Number(e.zMin):0,zMax:_t(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:_t(e.center)?K.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=K.toJSON(e.center)),t},create(e){return Wo.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,l,s,c,p,f,d,x;const t=qr();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=(l=e.xMax)!=null?l:0,t.yMax=(s=e.yMax)!=null?s:0,t.zMin=(c=e.zMin)!=null?c:0,t.zMax=(p=e.zMax)!=null?p:0,t.points=((f=e.points)==null?void 0:f.map(h=>h))||[],t.indices=((d=e.indices)==null?void 0:d.map(h=>h))||[],t.value=((x=e.value)==null?void 0:x.map(h=>h))||[],t.center=e.center!==void 0&&e.center!==null?K.fromPartial(e.center):void 0,t}};function _t(e){return e!=null}const xl=(e,t)=>{const n=m.useRef(null),{name:a,vertex:r,fragment:o,needDepthPrePass:i=!1,backFaceCulling:l,transparencyMode:s=u.Material.MATERIAL_OPAQUE,alphaMode:c=u.Engine.ALPHA_COMBINE,alpha:p=1,options:f,zOffset:d=1,zOffsetUnits:x,disableDepthWrite:h=!1,clipPlane:T,depthFunction:P,sideOrientation:v=u.Material.ClockWiseSideOrientation}=e;return m.useImperativeHandle(t,()=>n.current,[]),C.jsx(C.Fragment,{children:C.jsx("shaderMaterial",{ref:n,name:`${a}-material`,sideOrientation:v,needDepthPrePass:i,backFaceCulling:l,transparencyMode:s,alphaMode:c,depthFunction:P,alpha:p,shaderPath:{vertexSource:r,fragmentSource:o},options:f,zOffset:d,zOffsetUnits:x,clipPlane:T,disableDepthWrite:h})})},lt=m.forwardRef(xl),yl=`#ifdef GL_ES
20
20
  precision highp float;
21
21
  #endif
22
22
 
@@ -115,7 +115,7 @@ void main(void) {
115
115
  backColor += color;
116
116
  }
117
117
  #endif
118
- }`,xl=`#ifdef GL_ES
118
+ }`,Cl=`#ifdef GL_ES
119
119
  precision highp float;
120
120
  #endif
121
121
 
@@ -177,7 +177,7 @@ void main(void) {
177
177
  overlayCoord = vec2(normalizedCoord.y, 1.0 - normalizedCoord.x);
178
178
  }
179
179
 
180
- }`,An=e=>{const t=_e.useScene(),[n,a]=m.useState(null),i=m.useRef(null),{boundingBox:o,counterLine:r,scaleDepth:l=1,scalePlane:s=1,color:c,alpha:p=1,lines:f=[],text:d=[],surfaceCanvasOptions:x={textureIncludeSide:!0},disableDepthWrite:h,lightPosition:T=new u.Vector3(0,3e5,1e5),intensity:P=1,contrast:v=3,sideIntensity:_=.3,cullFace:b=0,zOffset:k,zOffsetUnits:M}=e,{textureIncludeSide:w}=x;return m.useEffect(()=>{i.current&&(console.log("[Geo3DViewer] 设置材质 ",c,p),i.current.setColor3("color",c),i.current.setFloat("alpha",p),i.current.setFloat("textureIncludeSide",w==null?1:0),i.current.setFloat("intensity",P),i.current.setVector3("lightPosition",T),i.current.setFloat("contrast",v),i.current.setFloat("sideIntensity",_),i.current.setFloat("cullFace",b),k!==void 0&&M!==void 0&&(i.current.zOffset=k,i.current.zOffsetUnits=M))},[c,p,w,P,T,k,M,v,_,b]),m.useEffect(()=>{var N;const S=i.current;if(S&&o)if(r){const F=(N=r.startHeight)!=null?N:o.maximumWorld.y/l;return S.setFloat("contourLineStartHeight",F*l),S.setColor3("contourLineColor",r.color),S.setFloat("contourLineWidth",r.width),S.setFloat("contourLineStep",r.stepHeight*l),console.log("[Geo3DViewer] 等高线设置 ",r,o.centerWorld.y,F*l,F*l-16*r.stepHeight*l),()=>{S&&(S.setFloat("contourLineStartHeight",0),S.setColor3("contourLineColor",new u.Color3(0,0,0)),S.setFloat("contourLineWidth",0),S.setFloat("contourLineStep",0))}}else S.setFloat("contourLineStartHeight",0),S.setColor3("contourLineColor",new u.Color3(0,0,0)),S.setFloat("contourLineWidth",0),S.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[o,r,l,s]),m.useEffect(()=>{const S=i.current;t&&o&&S&&a(N=>{let F=(o.maximum.x-o.minimum.x)/s,B=(o.maximum.z-o.minimum.z)/s,I=0;if(F<B){const L=F;F=B,B=L,I=1}const D=F/B;F*B>2048*2048&&(F=2048,B=2048/D);let E;return N?(N.scaleTo(F,B),N.update(),E=N):E=new u.DynamicTexture("dynamic-texture",{width:F,height:B},t,!1),E.clear(),E.update(),console.log("[Geo3DViewer] 设置动态划线 ",o,F,B,s),S.setVector3("oMin",o.minimum),S.setVector3("oMax",o.maximum),S.setFloat("textureOverlayRotate",I),S.setTexture("textureOverlaySampler",E),E})},[o,s,t]),m.useEffect(()=>{if(n&&o&&(f.length>0||d.length>0)){n.clear();let S=(o.maximum.x-o.minimum.x)/s,N=(o.maximum.z-o.minimum.z)/s;if(S<N){const I=S;S=N,N=I}const F=S/N;S*N>2048*2048&&(S=2048,N=2048/F);const B=n.getContext();f.forEach(I=>{if(I.points.length<2)return;B.beginPath();const D=I.offset?I.offset:new u.Vector2(0,0),E=1-I.points[0].x+D.x,L=1-I.points[0].y+D.y;B.moveTo(E*S,L*N);for(let y=1;y<I.points.length;y++){const A=I.offset?I.offset:new u.Vector2(0,0),V=1-I.points[y].x+A.x,$=1-I.points[y].y+A.y;B.lineTo(V*S,$*N)}B.strokeStyle=`rgb(${I.color.r*255}, ${I.color.g*255}, ${I.color.b*255})`,S*N>2048*2048?B.lineWidth=I.width/F:B.lineWidth=I.width,B.stroke()}),d.forEach(I=>{var y,A;B.font=`${I.fontSize}px Arial`;const D=(y=I.color)!=null?y:u.Color3.White(),E=I.offset?I.offset:new u.Vector2(0,0),L=(A=I.rotation)!=null?A:0;if(B.save(),B.translate((1-I.position.x+E.x)*S,(1-I.position.y+E.y)*N),B.rotate(L),I.clearArea){const V=B.measureText(I.text);B.clearRect(-V.width*.15,.5*I.fontSize*(1-.3),V.width*1.3,-I.fontSize*1.3)}if(I.background){B.fillStyle=`rgba(${I.background.r*255}, ${I.background.g*255}, ${I.background.b*255})`;const V=B.measureText(I.text);B.fillRect(-V.width*.05,.5*(I.fontSize*(.5-.1)),V.width*1.1,-I.fontSize*1.1)}B.fillStyle=`rgb(${D.r*255}, ${D.g*255}, ${D.b*255})`,B.fillText(I.text,0,0),B.restore()}),n.update()}},[f,n,o,s,d]),C.jsx(lt,{ref:i,name:e.name,backFaceCulling:e.backFaceCulling,needDepthPrePass:e.needDepthPrePass,vertex:xl,fragment:vl,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:h})},Zn=`#version 300 es
180
+ }`,An=e=>{const t=_e.useScene(),[n,a]=m.useState(null),r=m.useRef(null),{boundingBox:o,counterLine:i,scaleDepth:l=1,scalePlane:s=1,color:c,alpha:p=1,lines:f=[],text:d=[],surfaceCanvasOptions:x={textureIncludeSide:!0},disableDepthWrite:h,lightPosition:T=new u.Vector3(0,3e5,1e5),intensity:P=1,contrast:v=3,sideIntensity:_=.3,cullFace:b=0,zOffset:k,zOffsetUnits:M}=e,{textureIncludeSide:w}=x;return m.useEffect(()=>{r.current&&(console.log("[Geo3DViewer] 设置材质 ",c,p),r.current.setColor3("color",c),r.current.setFloat("alpha",p),r.current.setFloat("textureIncludeSide",w==null?1:0),r.current.setFloat("intensity",P),r.current.setVector3("lightPosition",T),r.current.setFloat("contrast",v),r.current.setFloat("sideIntensity",_),r.current.setFloat("cullFace",b),k!==void 0&&M!==void 0&&(r.current.zOffset=k,r.current.zOffsetUnits=M))},[c,p,w,P,T,k,M,v,_,b]),m.useEffect(()=>{var N;const S=r.current;if(S&&o)if(i){const F=(N=i.startHeight)!=null?N:o.maximumWorld.y/l;return S.setFloat("contourLineStartHeight",F*l),S.setColor3("contourLineColor",i.color),S.setFloat("contourLineWidth",i.width),S.setFloat("contourLineStep",i.stepHeight*l),console.log("[Geo3DViewer] 等高线设置 ",i,o.centerWorld.y,F*l,F*l-16*i.stepHeight*l),()=>{S&&(S.setFloat("contourLineStartHeight",0),S.setColor3("contourLineColor",new u.Color3(0,0,0)),S.setFloat("contourLineWidth",0),S.setFloat("contourLineStep",0))}}else S.setFloat("contourLineStartHeight",0),S.setColor3("contourLineColor",new u.Color3(0,0,0)),S.setFloat("contourLineWidth",0),S.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[o,i,l,s]),m.useEffect(()=>{const S=r.current;t&&o&&S&&a(N=>{let F=(o.maximum.x-o.minimum.x)/s,B=(o.maximum.z-o.minimum.z)/s,I=0;if(F<B){const L=F;F=B,B=L,I=1}const D=F/B;F*B>2048*2048&&(F=2048,B=2048/D);let E;return N?(N.scaleTo(F,B),N.update(),E=N):E=new u.DynamicTexture("dynamic-texture",{width:F,height:B},t,!1),E.clear(),E.update(),console.log("[Geo3DViewer] 设置动态划线 ",o,F,B,s),S.setVector3("oMin",o.minimum),S.setVector3("oMax",o.maximum),S.setFloat("textureOverlayRotate",I),S.setTexture("textureOverlaySampler",E),E})},[o,s,t]),m.useEffect(()=>{if(n&&o&&(f.length>0||d.length>0)){n.clear();let S=(o.maximum.x-o.minimum.x)/s,N=(o.maximum.z-o.minimum.z)/s;if(S<N){const I=S;S=N,N=I}const F=S/N;S*N>2048*2048&&(S=2048,N=2048/F);const B=n.getContext();f.forEach(I=>{if(I.points.length<2)return;B.beginPath();const D=I.offset?I.offset:new u.Vector2(0,0),E=1-I.points[0].x+D.x,L=1-I.points[0].y+D.y;B.moveTo(E*S,L*N);for(let y=1;y<I.points.length;y++){const A=I.offset?I.offset:new u.Vector2(0,0),V=1-I.points[y].x+A.x,$=1-I.points[y].y+A.y;B.lineTo(V*S,$*N)}B.strokeStyle=`rgb(${I.color.r*255}, ${I.color.g*255}, ${I.color.b*255})`,S*N>2048*2048?B.lineWidth=I.width/F:B.lineWidth=I.width,B.stroke()}),d.forEach(I=>{var y,A;B.font=`${I.fontSize}px Arial`;const D=(y=I.color)!=null?y:u.Color3.White(),E=I.offset?I.offset:new u.Vector2(0,0),L=(A=I.rotation)!=null?A:0;if(B.save(),B.translate((1-I.position.x+E.x)*S,(1-I.position.y+E.y)*N),B.rotate(L),I.clearArea){const V=B.measureText(I.text);B.clearRect(-V.width*.15,.5*I.fontSize*(1-.3),V.width*1.3,-I.fontSize*1.3)}if(I.background){B.fillStyle=`rgba(${I.background.r*255}, ${I.background.g*255}, ${I.background.b*255})`;const V=B.measureText(I.text);B.fillRect(-V.width*.05,.5*(I.fontSize*(.5-.1)),V.width*1.1,-I.fontSize*1.1)}B.fillStyle=`rgb(${D.r*255}, ${D.g*255}, ${D.b*255})`,B.fillText(I.text,0,0),B.restore()}),n.update()}},[f,n,o,s,d]),C.jsx(lt,{ref:r,name:e.name,backFaceCulling:e.backFaceCulling,needDepthPrePass:e.needDepthPrePass,vertex:Cl,fragment:yl,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:h})},Zn=`#version 300 es
181
181
  precision highp float;
182
182
 
183
183
  in vec2 vUV;
@@ -207,7 +207,7 @@ void main(void) {
207
207
 
208
208
  vUV = uv;
209
209
  vColor = color;
210
- }`,yl=null,Cl=!1,_l=4,Pl=0,Sl=!1,Tl="node",bl="node",kl=!1,El=!1,Nl="",Il=1,wl=!0,Ol=!0,Al=1,Ml=2,Ll=!1,Rl=!1,Bl=!1,Fl=!1,Dl=0,zl=!1,Vl=!0,$l=1,Wl=0,Ul=0,Hl=!1,Zl=0,Gl={locations:[{blockId:5,x:860,y:-60},{blockId:6,x:560,y:-80},{blockId:7,x:240,y:-200},{blockId:8,x:-140,y:-260},{blockId:9,x:-180,y:120},{blockId:10,x:200,y:60},{blockId:11,x:2780,y:460},{blockId:12,x:1860,y:660},{blockId:13,x:1800,y:360},{blockId:14,x:1480,y:320},{blockId:15,x:940,y:540},{blockId:16,x:660,y:500},{blockId:17,x:380,y:500},{blockId:18,x:60,y:420},{blockId:19,x:60,y:660},{blockId:20,x:700,y:680},{blockId:21,x:380,y:640},{blockId:22,x:380,y:760},{blockId:23,x:1260,y:640},{blockId:24,x:1260,y:820},{blockId:25,x:3100,y:440},{blockId:26,x:2760,y:600}],frames:[],x:121.93012702972425,y:646.223787765485,zoom:.5310839686650568},Yl="BABYLON.NodeMaterial",Jl=[5,11,25],Xl=[{customType:"BABYLON.VertexOutputBlock",id:5,name:"VertexOutput",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:6,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[]},{customType:"BABYLON.TransformBlock",id:6,name:"WorldPos * ViewProjectionTransform",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:7,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"transform",inputName:"transform",targetBlockId:10,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"},{name:"xyz"}],complementZ:0,complementW:1},{customType:"BABYLON.TransformBlock",id:7,name:"WorldPos",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:8,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"transform",inputName:"transform",targetBlockId:9,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"},{name:"xyz"}],complementZ:0,complementW:1},{customType:"BABYLON.InputBlock",id:8,name:"position",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:8,mode:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:9,name:"World",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:128,mode:0,systemValue:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:10,name:"ViewProjection",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:128,mode:0,systemValue:4,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.FragmentOutputBlock",id:11,name:"FragmentOutput",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:2,inputs:[{name:"rgba"},{name:"rgb",inputName:"rgb",targetBlockId:12,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"a",inputName:"a",targetBlockId:13,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[],convertToGammaSpace:!1,convertToLinearSpace:!1,useLogarithmicDepth:!1},{customType:"BABYLON.InputBlock",id:12,name:"Color3",comments:"",visibleInInspector:!0,visibleOnFrame:!0,target:1,inputs:[],outputs:[{name:"output"}],type:32,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"BABYLON.Color3",value:[1,1,1]},{customType:"BABYLON.SmoothStepBlock",id:13,name:"Smooth step",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"value",inputName:"value",targetBlockId:14,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"edge0",inputName:"edge0",targetBlockId:23,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"edge1",inputName:"edge1",targetBlockId:24,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.OneMinusBlock",id:14,name:"One minus",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"input",inputName:"input",targetBlockId:15,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.SubtractBlock",id:15,name:"Subtract",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:16,targetConnectionName:"depth",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:20,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.SceneDepthBlock",id:16,name:"SceneDepth",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:2,inputs:[{name:"uv",inputName:"uv",targetBlockId:17,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"depth"}],useNonLinearDepth:!1,storeCameraSpaceZ:!0,force32itsFloat:!1},{customType:"BABYLON.DivideBlock",id:17,name:"Divide",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:18,targetConnectionName:"xy",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:19,targetConnectionName:"xy",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.FragCoordBlock",id:18,name:"FragCoord",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:2,inputs:[],outputs:[{name:"xy"},{name:"xyz"},{name:"xyzw"},{name:"x"},{name:"y"},{name:"z"},{name:"w"}]},{customType:"BABYLON.ScreenSizeBlock",id:19,name:"ScreenSize",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:2,inputs:[],outputs:[{name:"xy"},{name:"x"},{name:"y"}]},{customType:"BABYLON.SubtractBlock",id:20,name:"Subtract",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:21,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:22,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.ReciprocalBlock",id:21,name:"z cam space",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"input",inputName:"input",targetBlockId:18,targetConnectionName:"w",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.InputBlock",id:22,name:"offset",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:-1e4,max:1,isBoolean:!1,matrixMode:0,isConstant:!0,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:.53},{customType:"BABYLON.InputBlock",id:23,name:"maxf",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!0,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.InputBlock",id:24,name:"minf",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:1,isBoolean:!1,matrixMode:0,isConstant:!0,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:1},{customType:"BABYLON.DiscardBlock",id:25,name:"Discard",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:2,inputs:[{name:"value",inputName:"value",targetBlockId:13,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"cutoff",inputName:"cutoff",targetBlockId:26,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[]},{customType:"BABYLON.InputBlock",id:26,name:"cutoff",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,systemValue:null,animationType:0,min:0,max:1,isBoolean:!1,matrixMode:0,isConstant:!0,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:.4}],ql={tags:yl,ignoreAlpha:Cl,maxSimultaneousLights:_l,mode:Pl,forceAlphaBlending:Sl,id:Tl,name:bl,checkReadyOnEveryCall:kl,checkReadyOnlyOnce:El,state:Nl,alpha:Il,backFaceCulling:wl,cullBackFaces:Ol,sideOrientation:Al,alphaMode:Ml,_needDepthPrePass:Ll,disableDepthWrite:Rl,disableColorWrite:Bl,forceDepthWrite:Fl,depthFunction:Dl,separateCullingPass:zl,fogEnabled:Vl,pointSize:$l,zOffset:Wl,zOffsetUnits:Ul,pointsCloud:Hl,fillMode:Zl,editorData:Gl,customType:Yl,outputNodes:Jl,blocks:Xl},Kl=null,Ql=!1,jl=4,ec=0,tc=!1,nc="node",oc="node",rc=!1,ic=!1,ac="",sc=1,lc=!0,cc=!0,uc=2,fc=!1,dc=!1,pc=!1,hc=!1,mc=0,gc=!1,vc=!0,xc=1,yc=0,Cc=0,_c=!1,Pc=0,Sc={locations:[{blockId:49,x:4700,y:1460},{blockId:50,x:4440,y:1440},{blockId:51,x:2160,y:820},{blockId:52,x:1860,y:720},{blockId:53,x:900,y:-140},{blockId:54,x:-500,y:160},{blockId:55,x:1600,y:880},{blockId:56,x:1320,y:640},{blockId:57,x:1140,y:340},{blockId:58,x:800,y:340},{blockId:59,x:140,y:580},{blockId:60,x:60,y:-20},{blockId:61,x:-400,y:740},{blockId:62,x:140,y:700},{blockId:63,x:140,y:820},{blockId:64,x:140,y:420},{blockId:65,x:-100,y:420},{blockId:66,x:-400,y:360},{blockId:67,x:-400,y:480},{blockId:68,x:1300,y:1020},{blockId:69,x:1840,y:580},{blockId:70,x:4140,y:1560},{blockId:71,x:4400,y:760},{blockId:72,x:3640,y:360},{blockId:73,x:2760,y:20},{blockId:74,x:2460,y:0},{blockId:75,x:2160,y:120},{blockId:76,x:1860,y:80},{blockId:77,x:2140,y:20},{blockId:78,x:2460,y:240},{blockId:79,x:2160,y:340},{blockId:80,x:1840,y:300},{blockId:81,x:2140,y:480},{blockId:82,x:3360,y:620},{blockId:83,x:3060,y:660},{blockId:84,x:2760,y:540},{blockId:85,x:2440,y:620},{blockId:86,x:2740,y:680},{blockId:87,x:4280,y:180},{blockId:88,x:3960,y:-80},{blockId:89,x:3960,y:180},{blockId:90,x:3140,y:1160},{blockId:91,x:2540,y:920},{blockId:92,x:2240,y:1100},{blockId:93,x:2240,y:1200},{blockId:94,x:2720,y:1160},{blockId:95,x:1980,y:1080},{blockId:96,x:2240,y:1300},{blockId:97,x:3620,y:-120},{blockId:98,x:2880,y:-560},{blockId:99,x:2580,y:-560},{blockId:100,x:3260,y:-80},{blockId:262,x:-180,y:-120},{blockId:371,x:-560,y:-120}],frames:[],x:690.8594510838803,y:368.9023673045632,zoom:.544139652156414},Tc="BABYLON.NodeMaterial",bc=[49,71],kc=[{customType:"BABYLON.VertexOutputBlock",id:49,name:"VertexOutput",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:50,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[]},{customType:"BABYLON.TransformBlock",id:50,name:"WorldPos * ViewProjectionTransform",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:51,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"transform",inputName:"transform",targetBlockId:70,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"},{name:"xyz"}],complementZ:0,complementW:1},{customType:"BABYLON.TransformBlock",id:51,name:"WorldPos",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:52,targetConnectionName:"xyz",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"transform",inputName:"transform",targetBlockId:69,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"},{name:"xyz"}],complementZ:0,complementW:1},{customType:"BABYLON.VectorMergerBlock",id:52,name:"VectorMerger",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"xyzw "},{name:"xyz "},{name:"xy "},{name:"zw "},{name:"x",inputName:"x",targetBlockId:53,targetConnectionName:"x",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"y",inputName:"y",targetBlockId:55,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"z",inputName:"z",targetBlockId:53,targetConnectionName:"z",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"w"}],outputs:[{name:"xyzw"},{name:"xyz"},{name:"xy"},{name:"zw"}],xSwizzle:"x",ySwizzle:"y",zSwizzle:"z",wSwizzle:"w"},{customType:"BABYLON.VectorSplitterBlock",id:53,name:"VectorSplitter",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"xyzw"},{name:"xyz ",inputName:"xyz ",targetBlockId:54,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"xy "}],outputs:[{name:"xyz"},{name:"xy"},{name:"zw"},{name:"x"},{name:"y"},{name:"z"},{name:"w"}]},{customType:"BABYLON.InputBlock",id:54,name:"position",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:8,mode:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.MultiplyBlock",id:55,name:"Multiply",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:56,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:68,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.AddBlock",id:56,name:"Add",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:53,targetConnectionName:"y",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:57,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.SimplexPerlin3DBlock",id:57,name:"SimplexPerlin3D",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"seed",inputName:"seed",targetBlockId:58,targetConnectionName:"xyz",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.VectorMergerBlock",id:58,name:"VectorMerger",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"xyzw "},{name:"xyz "},{name:"xy "},{name:"zw "},{name:"x",inputName:"x",targetBlockId:59,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"y",inputName:"y",targetBlockId:62,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"z",inputName:"z",targetBlockId:63,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"w"}],outputs:[{name:"xyzw"},{name:"xyz"},{name:"xy"},{name:"zw"}],xSwizzle:"x",ySwizzle:"y",zSwizzle:"z",wSwizzle:"w"},{customType:"BABYLON.MultiplyBlock",id:59,name:"Multiply",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:60,targetConnectionName:"x",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:61,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.VectorSplitterBlock",id:60,name:"VectorSplitter",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"xyzw"},{name:"xyz ",inputName:"xyz ",targetBlockId:262,targetConnectionName:"xyz",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"xy "}],outputs:[{name:"xyz"},{name:"xy"},{name:"zw"},{name:"x"},{name:"y"},{name:"z"},{name:"w"}]},{customType:"BABYLON.TransformBlock",id:262,name:"WorldPos",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:54,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"transform",inputName:"transform",targetBlockId:371,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"},{name:"xyz"}],complementZ:0,complementW:1},{customType:"BABYLON.InputBlock",id:371,name:"World",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:128,mode:0,systemValue:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:61,name:"PerlinMultiply",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:.5},{customType:"BABYLON.MultiplyBlock",id:62,name:"Multiply",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:60,targetConnectionName:"y",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:61,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.MultiplyBlock",id:63,name:"Multiply",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:64,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:61,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.AddBlock",id:64,name:"Add",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:60,targetConnectionName:"z",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:65,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.MultiplyBlock",id:65,name:"Multiply",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:66,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:67,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.InputBlock",id:66,name:"Time",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:1,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.InputBlock",id:67,name:"TimeSpeed",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:-6},{customType:"BABYLON.InputBlock",id:68,name:"waterFlow",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:1},{customType:"BABYLON.InputBlock",id:69,name:"World",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:128,mode:0,systemValue:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:70,name:"ViewProjection",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:128,mode:0,systemValue:4,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.FragmentOutputBlock",id:71,name:"FragmentOutput",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:2,inputs:[{name:"rgba"},{name:"rgb",inputName:"rgb",targetBlockId:72,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"a",inputName:"a",targetBlockId:87,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[],convertToGammaSpace:!1,convertToLinearSpace:!1,useLogarithmicDepth:!1},{customType:"BABYLON.MultiplyBlock",id:72,name:"Multiply",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:73,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:82,targetConnectionName:"rgb",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.AddBlock",id:73,name:"Add",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:74,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:78,targetConnectionName:"diffuseOutput",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.MultiplyBlock",id:74,name:"Multiply",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:75,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:77,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.GradientBlock",id:75,name:"Gradient",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:4,inputs:[{name:"gradient",inputName:"gradient",targetBlockId:76,targetConnectionName:"rgb",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}],colorSteps:[{step:0,color:{r:.09803921568627451,g:.3607843137254902,b:1}},{step:1,color:{r:.4980392156862745,g:.8745098039215686,b:.9882352941176471}}]},{customType:"BABYLON.ColorMergerBlock",id:76,name:"ColorMerger",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"rgb "},{name:"r",inputName:"r",targetBlockId:57,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"g"},{name:"b"},{name:"a"}],outputs:[{name:"rgba"},{name:"rgb"}],rSwizzle:"r",gSwizzle:"g",bSwizzle:"b",aSwizzle:"a"},{customType:"BABYLON.InputBlock",id:77,name:"ShadowColor",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:32,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"BABYLON.Color3",value:[.0196078431372549,.0196078431372549,.0196078431372549]},{customType:"BABYLON.LightBlock",id:78,name:"Lights",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:3,inputs:[{name:"worldPosition",inputName:"worldPosition",targetBlockId:51,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"worldNormal",inputName:"worldNormal",targetBlockId:79,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"cameraPosition",inputName:"cameraPosition",targetBlockId:81,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"glossiness"},{name:"glossPower"},{name:"diffuseColor",inputName:"diffuseColor",targetBlockId:75,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"specularColor"},{name:"view"}],outputs:[{name:"diffuseOutput"},{name:"specularOutput"},{name:"shadow"}],generateOnlyFragmentCode:!1},{customType:"BABYLON.TransformBlock",id:79,name:"World normal",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:80,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"transform",inputName:"transform",targetBlockId:69,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"},{name:"xyz"}],complementZ:0,complementW:0},{customType:"BABYLON.InputBlock",id:80,name:"normal",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:8,mode:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:81,name:"cameraPosition",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:8,mode:0,systemValue:7,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.ColorMergerBlock",id:82,name:"ColorMerger",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"rgb "},{name:"r",inputName:"r",targetBlockId:83,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"g",inputName:"g",targetBlockId:83,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"b",inputName:"b",targetBlockId:83,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"a"}],outputs:[{name:"rgba"},{name:"rgb"}],rSwizzle:"r",gSwizzle:"g",bSwizzle:"b",aSwizzle:"a"},{customType:"BABYLON.AddBlock",id:83,name:"Add",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:84,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:86,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.MultiplyBlock",id:84,name:"Multiply",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:78,targetConnectionName:"shadow",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:85,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.InputBlock",id:85,name:"ShadowMultiply",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:1,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:.28},{customType:"BABYLON.InputBlock",id:86,name:"ShadowAdd",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:1},{customType:"BABYLON.ConditionalBlock",id:87,name:"LessOrEqual",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"a",inputName:"a",targetBlockId:88,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"b",inputName:"b",targetBlockId:89,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"true",inputName:"true",targetBlockId:90,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"false",inputName:"false",targetBlockId:97,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}],condition:4},{customType:"BABYLON.InputBlock",id:88,name:"MaskEnabled",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:1,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.InputBlock",id:89,name:"Float",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:.5},{customType:"BABYLON.ConditionalBlock",id:90,name:"LessOrEqual",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"a",inputName:"a",targetBlockId:91,targetConnectionName:"y",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"b",inputName:"b",targetBlockId:92,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"true",inputName:"true",targetBlockId:93,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"false",inputName:"false",targetBlockId:94,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}],condition:4},{customType:"BABYLON.VectorSplitterBlock",id:91,name:"VectorSplitter",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"xyzw"},{name:"xyz ",inputName:"xyz ",targetBlockId:52,targetConnectionName:"xyz",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"xy "}],outputs:[{name:"xyz"},{name:"xy"},{name:"zw"},{name:"x"},{name:"y"},{name:"z"},{name:"w"}]},{customType:"BABYLON.InputBlock",id:92,name:"ClippedHeight",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.InputBlock",id:93,name:"ClippedAlpha",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.ConditionalBlock",id:94,name:"LessOrEqual",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"a",inputName:"a",targetBlockId:95,targetConnectionName:"y",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"b",inputName:"b",targetBlockId:92,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"true",inputName:"true",targetBlockId:93,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"false",inputName:"false",targetBlockId:96,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}],condition:4},{customType:"BABYLON.VectorSplitterBlock",id:95,name:"VectorSplitter",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"xyzw"},{name:"xyz ",inputName:"xyz ",targetBlockId:54,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"xy "}],outputs:[{name:"xyz"},{name:"xy"},{name:"zw"},{name:"x"},{name:"y"},{name:"z"},{name:"w"}]},{customType:"BABYLON.InputBlock",id:96,name:"Alpha",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,systemValue:11,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.ConditionalBlock",id:97,name:"LessOrEqual",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"a",inputName:"a",targetBlockId:98,targetConnectionName:"r",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"b",inputName:"b",targetBlockId:100,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"true",inputName:"true",targetBlockId:93,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"false",inputName:"false",targetBlockId:90,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}],condition:4},{customType:"BABYLON.TextureBlock",id:98,name:"MatteTexture",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:3,inputs:[{name:"uv",inputName:"uv",targetBlockId:99,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"source",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"layer"},{name:"lod"}],outputs:[{name:"rgba"},{name:"rgb"},{name:"r"},{name:"g"},{name:"b"},{name:"a"},{name:"level"}],convertToGammaSpace:!1,convertToLinearSpace:!1,fragmentOnly:!1,disableLevelMultiplication:!1},{customType:"BABYLON.InputBlock",id:99,name:"uv",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:4,mode:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:100,name:"ClippedMatte",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0}],Ec=4,Nc={tags:Kl,ignoreAlpha:Ql,maxSimultaneousLights:jl,mode:ec,forceAlphaBlending:tc,id:nc,name:oc,checkReadyOnEveryCall:rc,checkReadyOnlyOnce:ic,state:ac,alpha:sc,backFaceCulling:lc,cullBackFaces:cc,alphaMode:uc,_needDepthPrePass:fc,disableDepthWrite:dc,disableColorWrite:pc,forceDepthWrite:hc,depthFunction:mc,separateCullingPass:gc,fogEnabled:vc,pointSize:xc,zOffset:yc,zOffsetUnits:Cc,pointsCloud:_c,fillMode:Pc,editorData:Sc,customType:Tc,outputNodes:bc,blocks:kc,uniqueId:Ec},Ic=`#ifdef GL_ES
210
+ }`,_l=null,Pl=!1,Sl=4,Tl=0,bl=!1,kl="node",El="node",Nl=!1,Il=!1,wl="",Ol=1,Al=!0,Ml=!0,Ll=1,Rl=2,Bl=!1,Fl=!1,Dl=!1,zl=!1,Vl=0,$l=!1,Wl=!0,Ul=1,Hl=0,Zl=0,Gl=!1,Yl=0,Jl={locations:[{blockId:5,x:860,y:-60},{blockId:6,x:560,y:-80},{blockId:7,x:240,y:-200},{blockId:8,x:-140,y:-260},{blockId:9,x:-180,y:120},{blockId:10,x:200,y:60},{blockId:11,x:2780,y:460},{blockId:12,x:1860,y:660},{blockId:13,x:1800,y:360},{blockId:14,x:1480,y:320},{blockId:15,x:940,y:540},{blockId:16,x:660,y:500},{blockId:17,x:380,y:500},{blockId:18,x:60,y:420},{blockId:19,x:60,y:660},{blockId:20,x:700,y:680},{blockId:21,x:380,y:640},{blockId:22,x:380,y:760},{blockId:23,x:1260,y:640},{blockId:24,x:1260,y:820},{blockId:25,x:3100,y:440},{blockId:26,x:2760,y:600}],frames:[],x:121.93012702972425,y:646.223787765485,zoom:.5310839686650568},Xl="BABYLON.NodeMaterial",ql=[5,11,25],Kl=[{customType:"BABYLON.VertexOutputBlock",id:5,name:"VertexOutput",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:6,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[]},{customType:"BABYLON.TransformBlock",id:6,name:"WorldPos * ViewProjectionTransform",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:7,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"transform",inputName:"transform",targetBlockId:10,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"},{name:"xyz"}],complementZ:0,complementW:1},{customType:"BABYLON.TransformBlock",id:7,name:"WorldPos",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:8,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"transform",inputName:"transform",targetBlockId:9,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"},{name:"xyz"}],complementZ:0,complementW:1},{customType:"BABYLON.InputBlock",id:8,name:"position",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:8,mode:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:9,name:"World",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:128,mode:0,systemValue:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:10,name:"ViewProjection",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:128,mode:0,systemValue:4,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.FragmentOutputBlock",id:11,name:"FragmentOutput",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:2,inputs:[{name:"rgba"},{name:"rgb",inputName:"rgb",targetBlockId:12,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"a",inputName:"a",targetBlockId:13,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[],convertToGammaSpace:!1,convertToLinearSpace:!1,useLogarithmicDepth:!1},{customType:"BABYLON.InputBlock",id:12,name:"Color3",comments:"",visibleInInspector:!0,visibleOnFrame:!0,target:1,inputs:[],outputs:[{name:"output"}],type:32,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"BABYLON.Color3",value:[1,1,1]},{customType:"BABYLON.SmoothStepBlock",id:13,name:"Smooth step",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"value",inputName:"value",targetBlockId:14,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"edge0",inputName:"edge0",targetBlockId:23,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"edge1",inputName:"edge1",targetBlockId:24,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.OneMinusBlock",id:14,name:"One minus",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"input",inputName:"input",targetBlockId:15,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.SubtractBlock",id:15,name:"Subtract",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:16,targetConnectionName:"depth",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:20,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.SceneDepthBlock",id:16,name:"SceneDepth",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:2,inputs:[{name:"uv",inputName:"uv",targetBlockId:17,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"depth"}],useNonLinearDepth:!1,storeCameraSpaceZ:!0,force32itsFloat:!1},{customType:"BABYLON.DivideBlock",id:17,name:"Divide",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:18,targetConnectionName:"xy",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:19,targetConnectionName:"xy",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.FragCoordBlock",id:18,name:"FragCoord",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:2,inputs:[],outputs:[{name:"xy"},{name:"xyz"},{name:"xyzw"},{name:"x"},{name:"y"},{name:"z"},{name:"w"}]},{customType:"BABYLON.ScreenSizeBlock",id:19,name:"ScreenSize",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:2,inputs:[],outputs:[{name:"xy"},{name:"x"},{name:"y"}]},{customType:"BABYLON.SubtractBlock",id:20,name:"Subtract",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:21,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:22,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.ReciprocalBlock",id:21,name:"z cam space",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"input",inputName:"input",targetBlockId:18,targetConnectionName:"w",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.InputBlock",id:22,name:"offset",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:-1e4,max:1,isBoolean:!1,matrixMode:0,isConstant:!0,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:.53},{customType:"BABYLON.InputBlock",id:23,name:"maxf",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!0,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.InputBlock",id:24,name:"minf",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:1,isBoolean:!1,matrixMode:0,isConstant:!0,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:1},{customType:"BABYLON.DiscardBlock",id:25,name:"Discard",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:2,inputs:[{name:"value",inputName:"value",targetBlockId:13,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"cutoff",inputName:"cutoff",targetBlockId:26,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[]},{customType:"BABYLON.InputBlock",id:26,name:"cutoff",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,systemValue:null,animationType:0,min:0,max:1,isBoolean:!1,matrixMode:0,isConstant:!0,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:.4}],Ql={tags:_l,ignoreAlpha:Pl,maxSimultaneousLights:Sl,mode:Tl,forceAlphaBlending:bl,id:kl,name:El,checkReadyOnEveryCall:Nl,checkReadyOnlyOnce:Il,state:wl,alpha:Ol,backFaceCulling:Al,cullBackFaces:Ml,sideOrientation:Ll,alphaMode:Rl,_needDepthPrePass:Bl,disableDepthWrite:Fl,disableColorWrite:Dl,forceDepthWrite:zl,depthFunction:Vl,separateCullingPass:$l,fogEnabled:Wl,pointSize:Ul,zOffset:Hl,zOffsetUnits:Zl,pointsCloud:Gl,fillMode:Yl,editorData:Jl,customType:Xl,outputNodes:ql,blocks:Kl},jl=null,ec=!1,tc=4,nc=0,oc=!1,rc="node",ic="node",ac=!1,sc=!1,lc="",cc=1,uc=!0,fc=!0,dc=2,pc=!1,hc=!1,mc=!1,gc=!1,vc=0,xc=!1,yc=!0,Cc=1,_c=0,Pc=0,Sc=!1,Tc=0,bc={locations:[{blockId:49,x:4700,y:1460},{blockId:50,x:4440,y:1440},{blockId:51,x:2160,y:820},{blockId:52,x:1860,y:720},{blockId:53,x:900,y:-140},{blockId:54,x:-500,y:160},{blockId:55,x:1600,y:880},{blockId:56,x:1320,y:640},{blockId:57,x:1140,y:340},{blockId:58,x:800,y:340},{blockId:59,x:140,y:580},{blockId:60,x:60,y:-20},{blockId:61,x:-400,y:740},{blockId:62,x:140,y:700},{blockId:63,x:140,y:820},{blockId:64,x:140,y:420},{blockId:65,x:-100,y:420},{blockId:66,x:-400,y:360},{blockId:67,x:-400,y:480},{blockId:68,x:1300,y:1020},{blockId:69,x:1840,y:580},{blockId:70,x:4140,y:1560},{blockId:71,x:4400,y:760},{blockId:72,x:3640,y:360},{blockId:73,x:2760,y:20},{blockId:74,x:2460,y:0},{blockId:75,x:2160,y:120},{blockId:76,x:1860,y:80},{blockId:77,x:2140,y:20},{blockId:78,x:2460,y:240},{blockId:79,x:2160,y:340},{blockId:80,x:1840,y:300},{blockId:81,x:2140,y:480},{blockId:82,x:3360,y:620},{blockId:83,x:3060,y:660},{blockId:84,x:2760,y:540},{blockId:85,x:2440,y:620},{blockId:86,x:2740,y:680},{blockId:87,x:4280,y:180},{blockId:88,x:3960,y:-80},{blockId:89,x:3960,y:180},{blockId:90,x:3140,y:1160},{blockId:91,x:2540,y:920},{blockId:92,x:2240,y:1100},{blockId:93,x:2240,y:1200},{blockId:94,x:2720,y:1160},{blockId:95,x:1980,y:1080},{blockId:96,x:2240,y:1300},{blockId:97,x:3620,y:-120},{blockId:98,x:2880,y:-560},{blockId:99,x:2580,y:-560},{blockId:100,x:3260,y:-80},{blockId:262,x:-180,y:-120},{blockId:371,x:-560,y:-120}],frames:[],x:690.8594510838803,y:368.9023673045632,zoom:.544139652156414},kc="BABYLON.NodeMaterial",Ec=[49,71],Nc=[{customType:"BABYLON.VertexOutputBlock",id:49,name:"VertexOutput",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:50,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[]},{customType:"BABYLON.TransformBlock",id:50,name:"WorldPos * ViewProjectionTransform",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:51,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"transform",inputName:"transform",targetBlockId:70,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"},{name:"xyz"}],complementZ:0,complementW:1},{customType:"BABYLON.TransformBlock",id:51,name:"WorldPos",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:52,targetConnectionName:"xyz",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"transform",inputName:"transform",targetBlockId:69,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"},{name:"xyz"}],complementZ:0,complementW:1},{customType:"BABYLON.VectorMergerBlock",id:52,name:"VectorMerger",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"xyzw "},{name:"xyz "},{name:"xy "},{name:"zw "},{name:"x",inputName:"x",targetBlockId:53,targetConnectionName:"x",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"y",inputName:"y",targetBlockId:55,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"z",inputName:"z",targetBlockId:53,targetConnectionName:"z",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"w"}],outputs:[{name:"xyzw"},{name:"xyz"},{name:"xy"},{name:"zw"}],xSwizzle:"x",ySwizzle:"y",zSwizzle:"z",wSwizzle:"w"},{customType:"BABYLON.VectorSplitterBlock",id:53,name:"VectorSplitter",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"xyzw"},{name:"xyz ",inputName:"xyz ",targetBlockId:54,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"xy "}],outputs:[{name:"xyz"},{name:"xy"},{name:"zw"},{name:"x"},{name:"y"},{name:"z"},{name:"w"}]},{customType:"BABYLON.InputBlock",id:54,name:"position",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:8,mode:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.MultiplyBlock",id:55,name:"Multiply",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:56,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:68,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.AddBlock",id:56,name:"Add",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:53,targetConnectionName:"y",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:57,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.SimplexPerlin3DBlock",id:57,name:"SimplexPerlin3D",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"seed",inputName:"seed",targetBlockId:58,targetConnectionName:"xyz",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.VectorMergerBlock",id:58,name:"VectorMerger",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"xyzw "},{name:"xyz "},{name:"xy "},{name:"zw "},{name:"x",inputName:"x",targetBlockId:59,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"y",inputName:"y",targetBlockId:62,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"z",inputName:"z",targetBlockId:63,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"w"}],outputs:[{name:"xyzw"},{name:"xyz"},{name:"xy"},{name:"zw"}],xSwizzle:"x",ySwizzle:"y",zSwizzle:"z",wSwizzle:"w"},{customType:"BABYLON.MultiplyBlock",id:59,name:"Multiply",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:60,targetConnectionName:"x",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:61,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.VectorSplitterBlock",id:60,name:"VectorSplitter",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"xyzw"},{name:"xyz ",inputName:"xyz ",targetBlockId:262,targetConnectionName:"xyz",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"xy "}],outputs:[{name:"xyz"},{name:"xy"},{name:"zw"},{name:"x"},{name:"y"},{name:"z"},{name:"w"}]},{customType:"BABYLON.TransformBlock",id:262,name:"WorldPos",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:54,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"transform",inputName:"transform",targetBlockId:371,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"},{name:"xyz"}],complementZ:0,complementW:1},{customType:"BABYLON.InputBlock",id:371,name:"World",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:128,mode:0,systemValue:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:61,name:"PerlinMultiply",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:.5},{customType:"BABYLON.MultiplyBlock",id:62,name:"Multiply",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:60,targetConnectionName:"y",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:61,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.MultiplyBlock",id:63,name:"Multiply",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:64,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:61,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.AddBlock",id:64,name:"Add",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:60,targetConnectionName:"z",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:65,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.MultiplyBlock",id:65,name:"Multiply",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:66,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:67,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.InputBlock",id:66,name:"Time",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:1,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.InputBlock",id:67,name:"TimeSpeed",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:-6},{customType:"BABYLON.InputBlock",id:68,name:"waterFlow",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:1},{customType:"BABYLON.InputBlock",id:69,name:"World",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:128,mode:0,systemValue:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:70,name:"ViewProjection",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:128,mode:0,systemValue:4,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.FragmentOutputBlock",id:71,name:"FragmentOutput",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:2,inputs:[{name:"rgba"},{name:"rgb",inputName:"rgb",targetBlockId:72,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"a",inputName:"a",targetBlockId:87,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[],convertToGammaSpace:!1,convertToLinearSpace:!1,useLogarithmicDepth:!1},{customType:"BABYLON.MultiplyBlock",id:72,name:"Multiply",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:73,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:82,targetConnectionName:"rgb",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.AddBlock",id:73,name:"Add",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:74,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:78,targetConnectionName:"diffuseOutput",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.MultiplyBlock",id:74,name:"Multiply",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:75,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:77,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.GradientBlock",id:75,name:"Gradient",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:4,inputs:[{name:"gradient",inputName:"gradient",targetBlockId:76,targetConnectionName:"rgb",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}],colorSteps:[{step:0,color:{r:.09803921568627451,g:.3607843137254902,b:1}},{step:1,color:{r:.4980392156862745,g:.8745098039215686,b:.9882352941176471}}]},{customType:"BABYLON.ColorMergerBlock",id:76,name:"ColorMerger",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"rgb "},{name:"r",inputName:"r",targetBlockId:57,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"g"},{name:"b"},{name:"a"}],outputs:[{name:"rgba"},{name:"rgb"}],rSwizzle:"r",gSwizzle:"g",bSwizzle:"b",aSwizzle:"a"},{customType:"BABYLON.InputBlock",id:77,name:"ShadowColor",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:32,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"BABYLON.Color3",value:[.0196078431372549,.0196078431372549,.0196078431372549]},{customType:"BABYLON.LightBlock",id:78,name:"Lights",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:3,inputs:[{name:"worldPosition",inputName:"worldPosition",targetBlockId:51,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"worldNormal",inputName:"worldNormal",targetBlockId:79,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"cameraPosition",inputName:"cameraPosition",targetBlockId:81,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"glossiness"},{name:"glossPower"},{name:"diffuseColor",inputName:"diffuseColor",targetBlockId:75,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"specularColor"},{name:"view"}],outputs:[{name:"diffuseOutput"},{name:"specularOutput"},{name:"shadow"}],generateOnlyFragmentCode:!1},{customType:"BABYLON.TransformBlock",id:79,name:"World normal",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:80,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"transform",inputName:"transform",targetBlockId:69,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"},{name:"xyz"}],complementZ:0,complementW:0},{customType:"BABYLON.InputBlock",id:80,name:"normal",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:8,mode:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:81,name:"cameraPosition",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:8,mode:0,systemValue:7,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.ColorMergerBlock",id:82,name:"ColorMerger",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"rgb "},{name:"r",inputName:"r",targetBlockId:83,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"g",inputName:"g",targetBlockId:83,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"b",inputName:"b",targetBlockId:83,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"a"}],outputs:[{name:"rgba"},{name:"rgb"}],rSwizzle:"r",gSwizzle:"g",bSwizzle:"b",aSwizzle:"a"},{customType:"BABYLON.AddBlock",id:83,name:"Add",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:84,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:86,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.MultiplyBlock",id:84,name:"Multiply",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:78,targetConnectionName:"shadow",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:85,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.InputBlock",id:85,name:"ShadowMultiply",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:1,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:.28},{customType:"BABYLON.InputBlock",id:86,name:"ShadowAdd",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:1},{customType:"BABYLON.ConditionalBlock",id:87,name:"LessOrEqual",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"a",inputName:"a",targetBlockId:88,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"b",inputName:"b",targetBlockId:89,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"true",inputName:"true",targetBlockId:90,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"false",inputName:"false",targetBlockId:97,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}],condition:4},{customType:"BABYLON.InputBlock",id:88,name:"MaskEnabled",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:1,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.InputBlock",id:89,name:"Float",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:.5},{customType:"BABYLON.ConditionalBlock",id:90,name:"LessOrEqual",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"a",inputName:"a",targetBlockId:91,targetConnectionName:"y",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"b",inputName:"b",targetBlockId:92,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"true",inputName:"true",targetBlockId:93,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"false",inputName:"false",targetBlockId:94,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}],condition:4},{customType:"BABYLON.VectorSplitterBlock",id:91,name:"VectorSplitter",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"xyzw"},{name:"xyz ",inputName:"xyz ",targetBlockId:52,targetConnectionName:"xyz",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"xy "}],outputs:[{name:"xyz"},{name:"xy"},{name:"zw"},{name:"x"},{name:"y"},{name:"z"},{name:"w"}]},{customType:"BABYLON.InputBlock",id:92,name:"ClippedHeight",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.InputBlock",id:93,name:"ClippedAlpha",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.ConditionalBlock",id:94,name:"LessOrEqual",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"a",inputName:"a",targetBlockId:95,targetConnectionName:"y",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"b",inputName:"b",targetBlockId:92,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"true",inputName:"true",targetBlockId:93,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"false",inputName:"false",targetBlockId:96,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}],condition:4},{customType:"BABYLON.VectorSplitterBlock",id:95,name:"VectorSplitter",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"xyzw"},{name:"xyz ",inputName:"xyz ",targetBlockId:54,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"xy "}],outputs:[{name:"xyz"},{name:"xy"},{name:"zw"},{name:"x"},{name:"y"},{name:"z"},{name:"w"}]},{customType:"BABYLON.InputBlock",id:96,name:"Alpha",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,systemValue:11,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.ConditionalBlock",id:97,name:"LessOrEqual",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"a",inputName:"a",targetBlockId:98,targetConnectionName:"r",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"b",inputName:"b",targetBlockId:100,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"true",inputName:"true",targetBlockId:93,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"false",inputName:"false",targetBlockId:90,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}],condition:4},{customType:"BABYLON.TextureBlock",id:98,name:"MatteTexture",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:3,inputs:[{name:"uv",inputName:"uv",targetBlockId:99,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"source",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"layer"},{name:"lod"}],outputs:[{name:"rgba"},{name:"rgb"},{name:"r"},{name:"g"},{name:"b"},{name:"a"},{name:"level"}],convertToGammaSpace:!1,convertToLinearSpace:!1,fragmentOnly:!1,disableLevelMultiplication:!1},{customType:"BABYLON.InputBlock",id:99,name:"uv",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:4,mode:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:100,name:"ClippedMatte",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0}],Ic=4,wc={tags:jl,ignoreAlpha:ec,maxSimultaneousLights:tc,mode:nc,forceAlphaBlending:oc,id:rc,name:ic,checkReadyOnEveryCall:ac,checkReadyOnlyOnce:sc,state:lc,alpha:cc,backFaceCulling:uc,cullBackFaces:fc,alphaMode:dc,_needDepthPrePass:pc,disableDepthWrite:hc,disableColorWrite:mc,forceDepthWrite:gc,depthFunction:vc,separateCullingPass:xc,fogEnabled:yc,pointSize:Cc,zOffset:_c,zOffsetUnits:Pc,pointsCloud:Sc,fillMode:Tc,editorData:bc,customType:kc,outputNodes:Ec,blocks:Nc,uniqueId:Ic},Oc=`#ifdef GL_ES
211
211
  precision highp float;
212
212
  #endif
213
213
 
@@ -294,7 +294,7 @@ void main(void) {
294
294
  backColor += color;
295
295
  }
296
296
  #endif
297
- }`,wc=`#ifdef GL_ES
297
+ }`,Ac=`#ifdef GL_ES
298
298
  precision highp float;
299
299
  #endif
300
300
 
@@ -355,7 +355,7 @@ void main(void) {
355
355
  overlayCoord = vec2(normalizedCoord.y, 1.0 - normalizedCoord.x);
356
356
  }
357
357
 
358
- }`,Oc=`precision highp float;
358
+ }`,Mc=`precision highp float;
359
359
 
360
360
  uniform vec3 pickableColor;
361
361
  uniform float isPickable;
@@ -366,7 +366,7 @@ void main(void) {
366
366
  } else {
367
367
  discard;
368
368
  }
369
- }`,Ac=`precision highp float;
369
+ }`,Lc=`precision highp float;
370
370
 
371
371
  attribute vec3 position;
372
372
 
@@ -374,7 +374,7 @@ uniform mat4 worldViewProjection;
374
374
 
375
375
  void main(void) {
376
376
  gl_Position = worldViewProjection * vec4(position, 1.0);
377
- }`,Mc=null,Lc=!1,Rc=4,Bc=0,Fc=!1,Dc={tags:null,colorCurves:{tags:null,_globalHue:30,_globalDensity:0,_globalSaturation:0,_globalExposure:0,_highlightsHue:30,_highlightsDensity:0,_highlightsSaturation:0,_highlightsExposure:0,_midtonesHue:30,_midtonesDensity:0,_midtonesSaturation:0,_midtonesExposure:0},_colorCurvesEnabled:!1,_colorGradingEnabled:!1,_colorGradingWithGreenDepth:!0,_colorGradingBGR:!0,_exposure:1,_toneMappingEnabled:!1,_toneMappingType:0,_contrast:1,vignetteStretch:0,vignetteCenterX:0,vignetteCenterY:0,vignetteWeight:1.5,vignetteColor:[0,0,0,0],vignetteCameraFov:.5,_vignetteBlendMode:0,_vignetteEnabled:!1,_ditheringEnabled:!1,_ditheringIntensity:.00392156862745098,_skipFinalColorClamp:!1,_applyByPostProcess:!1,_isEnabled:!0,outputTextureWidth:0,outputTextureHeight:0},zc="node",Vc="remap",$c=!1,Wc=!1,Uc="",Hc=1,Zc=!0,Gc=!0,Yc=[2],Jc=!1,Xc=!1,qc=!1,Kc=!1,Qc=0,jc=!1,eu=!0,tu=1,nu=0,ou=0,ru=!1,iu=0,au=!1,su={locations:[{blockId:152,x:840,y:140,isCollapsed:!1},{blockId:153,x:600,y:80,isCollapsed:!1},{blockId:154,x:320,y:0,isCollapsed:!1},{blockId:155,x:-540,y:480,isCollapsed:!1},{blockId:156,x:-1040,y:520,isCollapsed:!1},{blockId:157,x:-1040,y:660,isCollapsed:!1},{blockId:158,x:-1040,y:780,isCollapsed:!1},{blockId:159,x:-1040,y:860,isCollapsed:!1},{blockId:160,x:-1040,y:920,isCollapsed:!1},{blockId:161,x:-1040,y:1060,isCollapsed:!1},{blockId:163,x:300,y:220,isCollapsed:!1},{blockId:164,x:2960,y:960,isCollapsed:!1},{blockId:166,x:1200,y:1040,isCollapsed:!1},{blockId:167,x:860,y:1140,isCollapsed:!1},{blockId:168,x:1460,y:940,isCollapsed:!1},{blockId:169,x:-540,y:180,isCollapsed:!1},{blockId:189,x:2080,y:980,isCollapsed:!1},{blockId:192,x:1700,y:1140,isCollapsed:!1},{blockId:494,x:-1060,y:60,isCollapsed:!1},{blockId:495,x:-1580,y:60,isCollapsed:!1},{blockId:496,x:-1580,y:200,isCollapsed:!1},{blockId:497,x:-1580,y:340,isCollapsed:!1},{blockId:498,x:-1580,y:480,isCollapsed:!1},{blockId:499,x:-1580,y:620,isCollapsed:!1},{blockId:664,x:-100,y:1420,isCollapsed:!1},{blockId:854,x:-380,y:1440,isCollapsed:!1},{blockId:855,x:-680,y:1580,isCollapsed:!1},{blockId:885,x:-700,y:1440,isCollapsed:!1},{blockId:1097,x:800,y:1440,isCollapsed:!1},{blockId:1098,x:600,y:380,isCollapsed:!1},{blockId:1195,x:200,y:1720,isCollapsed:!1},{blockId:1460,x:200,y:1800,isCollapsed:!1},{blockId:1631,x:200,y:1880,isCollapsed:!1},{blockId:2017,x:200,y:1960,isCollapsed:!1},{blockId:2198,x:1200,y:1540,isCollapsed:!1},{blockId:2275,x:860,y:1660,isCollapsed:!1},{blockId:2504,x:1500,y:1560,isCollapsed:!1},{blockId:2544,x:1200,y:1780,isCollapsed:!1},{blockId:2665,x:820,y:2e3,isCollapsed:!1},{blockId:3118,x:2360,y:1180,isCollapsed:!1},{blockId:3162,x:2380,y:960,isCollapsed:!1},{blockId:3163,x:2680,y:1140,isCollapsed:!1}],frames:[{x:800,y:820,width:1524.27,height:485.146,color:[.2823529411764706,.2823529411764706,.2823529411764706],name:"OverlayTexture",isCollapsed:!1,blocks:[167,166,168,189,192]},{x:174.342,y:1340,width:1725.67,height:760.152,color:[.2823529411764706,.2823529411764706,.2823529411764706],name:"ContourLine",isCollapsed:!1,blocks:[1097,2198,2275,2504,2544,2665,1195,1460,1631,2017]}],x:-511.7386087106099,y:-367.3393470321812,zoom:.7285102450823819},lu="BABYLON.NodeMaterial",cu=[152,164],uu=[{customType:"BABYLON.VertexOutputBlock",id:152,name:"VertexOutput",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:153,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[]},{customType:"BABYLON.TransformBlock",id:153,name:"WorldPos * ViewProjectionTransform",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:154,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"transform",inputName:"transform",targetBlockId:163,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"},{name:"xyz"}],complementZ:0,complementW:1},{customType:"BABYLON.TransformBlock",id:154,name:"WorldPos",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:155,targetConnectionName:"positionOutput",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"transform",inputName:"transform",targetBlockId:494,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"},{name:"xyz"}],complementZ:0,complementW:1},{customType:"BABYLON.MorphTargetsBlock",id:155,name:"MorphTargets",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"position",inputName:"position",targetBlockId:156,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"normal",inputName:"normal",targetBlockId:157,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"tangent",inputName:"tangent",targetBlockId:158,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"uv",inputName:"uv",targetBlockId:159,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"uv2",inputName:"uv2",targetBlockId:160,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"color",inputName:"color",targetBlockId:161,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"positionOutput"},{name:"normalOutput"},{name:"tangentOutput"},{name:"uvOutput"},{name:"uv2Output"},{name:"colorOutput"}]},{customType:"BABYLON.InputBlock",id:156,name:"position",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:8,mode:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:157,name:"normal",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:8,mode:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:158,name:"tangent",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:16,mode:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:159,name:"uv",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:4,mode:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:160,name:"uv2",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:4,mode:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:161,name:"color",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:64,mode:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InstancesBlock",id:494,name:"Instances",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"world0",inputName:"world0",targetBlockId:495,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"world1",inputName:"world1",targetBlockId:496,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"world2",inputName:"world2",targetBlockId:497,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"world3",inputName:"world3",targetBlockId:498,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"world",inputName:"world",targetBlockId:499,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"},{name:"instanceID"}]},{customType:"BABYLON.InputBlock",id:495,name:"world0",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:16,mode:1,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:496,name:"world1",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:16,mode:1,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:497,name:"world2",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:16,mode:1,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:498,name:"world3",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:16,mode:1,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:499,name:"world",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:128,mode:0,systemValue:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:163,name:"ViewProjection",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:128,mode:0,systemValue:4,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.FragmentOutputBlock",id:164,name:"FragmentOutput",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:2,inputs:[{name:"rgba",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"rgb",inputName:"rgb",targetBlockId:3162,targetConnectionName:"rgb",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"a",inputName:"a",targetBlockId:3163,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"glow"}],outputs:[],convertToGammaSpace:!1,convertToLinearSpace:!1,useLogarithmicDepth:!1},{customType:"BABYLON.ColorSplitterBlock",id:3162,name:"ColorSplitter",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"rgba",inputName:"rgba",targetBlockId:189,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"rgb "}],outputs:[{name:"rgb"},{name:"r"},{name:"g"},{name:"b"},{name:"a"}]},{customType:"BABYLON.ConditionalBlock",id:189,name:"GreaterThan",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"a",displayName:"a",inputName:"a",targetBlockId:168,targetConnectionName:"a",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"b",displayName:"b",inputName:"b",targetBlockId:192,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"true",displayName:"true",inputName:"true",targetBlockId:168,targetConnectionName:"rgba",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"false",displayName:"false",inputName:"false",targetBlockId:2504,targetConnectionName:"rgba",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output",displayName:"output"}],condition:3},{customType:"BABYLON.TextureBlock",id:168,name:"OverlayTexture",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:3,inputs:[{name:"uv",displayName:"uv",inputName:"uv",targetBlockId:166,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"source",displayName:"source"},{name:"layer",displayName:"layer"},{name:"lod",displayName:"lod"}],outputs:[{name:"rgba",displayName:"rgba"},{name:"rgb",displayName:"rgb"},{name:"r",displayName:"r"},{name:"g",displayName:"g"},{name:"b",displayName:"b"},{name:"a",displayName:"a"},{name:"level",displayName:"level"}],convertToGammaSpace:!1,convertToLinearSpace:!1,fragmentOnly:!1,disableLevelMultiplication:!1},{customType:"BABYLON.Rotate2dBlock",id:166,name:"Rotate2d",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"input",displayName:"input",inputName:"input",targetBlockId:155,targetConnectionName:"uvOutput",isExposedOnFrame:!0,exposedPortPosition:0},{name:"angle",displayName:"angle",inputName:"angle",targetBlockId:167,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output",displayName:"output"}]},{customType:"BABYLON.InputBlock",id:167,name:"angle",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.InputBlock",id:192,name:"Float",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!0,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.ColorMergerBlock",id:2504,name:"ColorMerger",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"rgb ",inputName:"rgb ",targetBlockId:2198,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"r"},{name:"g"},{name:"b"},{name:"a",inputName:"a",targetBlockId:2544,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"rgba"},{name:"rgb"}],rSwizzle:"r",gSwizzle:"g",bSwizzle:"b",aSwizzle:"a"},{customType:"BABYLON.ConditionalBlock",id:2198,name:"GreaterThan",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"a",inputName:"a",targetBlockId:2017,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"b",inputName:"b",targetBlockId:2275,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"true",inputName:"true",targetBlockId:1097,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"false",inputName:"false",targetBlockId:664,targetConnectionName:"rgb",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}],condition:3},{customType:"BABYLON.InputBlock",id:2017,name:"contourLineWidth",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.InputBlock",id:2275,name:"Float",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!0,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.CustomBlock",id:1097,name:"ContourLineMarkerColor",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:2,inputs:[{name:"baseColor",inputName:"baseColor",targetBlockId:664,targetConnectionName:"rgb",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"worldPosY",inputName:"worldPosY",targetBlockId:1098,targetConnectionName:"y",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"contourLineStartHeight",inputName:"contourLineStartHeight",targetBlockId:1460,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"contourLineStep",inputName:"contourLineStep",targetBlockId:1631,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"contourLineWidth",inputName:"contourLineWidth",targetBlockId:2017,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"markerColor",inputName:"markerColor",targetBlockId:1195,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}],options:{name:"ContourLineMarkerColor",comments:"Outputs a marker color on contour lines so ReplaceColor can swap it later.",target:"Fragment",inParameters:[{name:"baseColor",type:"Color3"},{name:"worldPosY",type:"Float"},{name:"contourLineStartHeight",type:"Float"},{name:"contourLineStep",type:"Float"},{name:"contourLineWidth",type:"Float"},{name:"markerColor",type:"Color3"}],outParameters:[{name:"output",type:"Color3"}],functionName:"contourLineMarkerColor",code:["void contourLineMarkerColor(vec3 baseColor, float worldPosY, float contourLineStartHeight, float contourLineStep, float contourLineWidth, vec3 markerColor, out vec3 result) {"," vec3 color = baseColor;"," if (contourLineWidth > 0.0) {"," for (int i = 0; i < 16; i++) {"," float d = worldPosY - ((contourLineStartHeight * -1.0) + float(i) * contourLineStep);"," if (abs(d) < contourLineWidth) {"," color = markerColor;"," }"," }"," }"," result = color;","}"]}},{customType:"BABYLON.TextureBlock",id:664,name:"RemappedTexture",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:3,inputs:[{name:"uv",inputName:"uv",targetBlockId:854,targetConnectionName:"xy",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"source"},{name:"layer"},{name:"lod"}],outputs:[{name:"rgba"},{name:"rgb"},{name:"r"},{name:"g"},{name:"b"},{name:"a"},{name:"level"}],convertToGammaSpace:!1,convertToLinearSpace:!1,fragmentOnly:!1,disableLevelMultiplication:!1,texture:null},{customType:"BABYLON.VectorMergerBlock",id:854,name:"VectorMerger",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"xyzw "},{name:"xyz "},{name:"xy "},{name:"zw "},{name:"x",inputName:"x",targetBlockId:885,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"y",inputName:"y",targetBlockId:855,targetConnectionName:"x",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"z"},{name:"w"}],outputs:[{name:"xyzw"},{name:"xyz"},{name:"xy"},{name:"zw"}],xSwizzle:"x",ySwizzle:"y",zSwizzle:"z",wSwizzle:"w"},{customType:"BABYLON.InputBlock",id:885,name:"Float",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!0,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.VectorSplitterBlock",id:855,name:"VectorSplitter",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"xyzw",inputName:"xyzw",targetBlockId:155,targetConnectionName:"colorOutput",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"xyz "},{name:"xy "}],outputs:[{name:"xyz"},{name:"xy"},{name:"zw"},{name:"x"},{name:"y"},{name:"z"},{name:"w"}]},{customType:"BABYLON.VectorSplitterBlock",id:1098,name:"VectorSplitter",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"xyzw",inputName:"xyzw",targetBlockId:154,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"xyz "},{name:"xy "}],outputs:[{name:"xyz"},{name:"xy"},{name:"zw"},{name:"x"},{name:"y"},{name:"z"},{name:"w"}]},{customType:"BABYLON.InputBlock",id:1460,name:"contourLineStartHeight",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.InputBlock",id:1631,name:"contourLineStep",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.InputBlock",id:1195,name:"contourLineColor",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:32,mode:0,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"BABYLON.Color3",value:[1,1,1]},{customType:"BABYLON.ConditionalBlock",id:2544,name:"GreaterThan",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"a",inputName:"a",targetBlockId:2017,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"b",inputName:"b",targetBlockId:2275,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"true",inputName:"true",targetBlockId:2665,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"false",inputName:"false",targetBlockId:664,targetConnectionName:"a",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}],condition:3},{customType:"BABYLON.InputBlock",id:2665,name:"Float",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!0,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:1},{customType:"BABYLON.MultiplyBlock",id:3163,name:"Multiply",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:3162,targetConnectionName:"a",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:3118,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.InputBlock",id:3118,name:"Material alpha",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,systemValue:11,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.TransformBlock",id:169,name:"World normal",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:157,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"transform",inputName:"transform",targetBlockId:494,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"},{name:"xyz"}],complementZ:0,complementW:0}],fu=5,du={tags:Mc,ignoreAlpha:Lc,maxSimultaneousLights:Rc,mode:Bc,forceAlphaBlending:Fc,_imageProcessingConfiguration:Dc,id:zc,name:Vc,checkReadyOnEveryCall:$c,checkReadyOnlyOnce:Wc,state:Uc,alpha:Hc,backFaceCulling:Zc,cullBackFaces:Gc,_alphaMode:Yc,_needDepthPrePass:Jc,disableDepthWrite:Xc,disableColorWrite:qc,forceDepthWrite:Kc,depthFunction:Qc,separateCullingPass:jc,fogEnabled:eu,pointSize:tu,zOffset:nu,zOffsetUnits:ou,pointsCloud:ru,fillMode:iu,_isVertexOutputInvariant:au,editorData:su,customType:lu,outputNodes:cu,blocks:uu,uniqueId:fu},pu=`
377
+ }`,Rc=null,Bc=!1,Fc=4,Dc=0,zc=!1,Vc={tags:null,colorCurves:{tags:null,_globalHue:30,_globalDensity:0,_globalSaturation:0,_globalExposure:0,_highlightsHue:30,_highlightsDensity:0,_highlightsSaturation:0,_highlightsExposure:0,_midtonesHue:30,_midtonesDensity:0,_midtonesSaturation:0,_midtonesExposure:0},_colorCurvesEnabled:!1,_colorGradingEnabled:!1,_colorGradingWithGreenDepth:!0,_colorGradingBGR:!0,_exposure:1,_toneMappingEnabled:!1,_toneMappingType:0,_contrast:1,vignetteStretch:0,vignetteCenterX:0,vignetteCenterY:0,vignetteWeight:1.5,vignetteColor:[0,0,0,0],vignetteCameraFov:.5,_vignetteBlendMode:0,_vignetteEnabled:!1,_ditheringEnabled:!1,_ditheringIntensity:.00392156862745098,_skipFinalColorClamp:!1,_applyByPostProcess:!1,_isEnabled:!0,outputTextureWidth:0,outputTextureHeight:0},$c="node",Wc="remap",Uc=!1,Hc=!1,Zc="",Gc=1,Yc=!0,Jc=!0,Xc=[2],qc=!1,Kc=!1,Qc=!1,jc=!1,eu=0,tu=!1,nu=!0,ou=1,ru=0,iu=0,au=!1,su=0,lu=!1,cu={locations:[{blockId:152,x:840,y:140,isCollapsed:!1},{blockId:153,x:600,y:80,isCollapsed:!1},{blockId:154,x:320,y:0,isCollapsed:!1},{blockId:155,x:-540,y:480,isCollapsed:!1},{blockId:156,x:-1040,y:520,isCollapsed:!1},{blockId:157,x:-1040,y:660,isCollapsed:!1},{blockId:158,x:-1040,y:780,isCollapsed:!1},{blockId:159,x:-1040,y:860,isCollapsed:!1},{blockId:160,x:-1040,y:920,isCollapsed:!1},{blockId:161,x:-1040,y:1060,isCollapsed:!1},{blockId:163,x:300,y:220,isCollapsed:!1},{blockId:164,x:2960,y:960,isCollapsed:!1},{blockId:166,x:1200,y:1040,isCollapsed:!1},{blockId:167,x:860,y:1140,isCollapsed:!1},{blockId:168,x:1460,y:940,isCollapsed:!1},{blockId:169,x:-540,y:180,isCollapsed:!1},{blockId:189,x:2080,y:980,isCollapsed:!1},{blockId:192,x:1700,y:1140,isCollapsed:!1},{blockId:494,x:-1060,y:60,isCollapsed:!1},{blockId:495,x:-1580,y:60,isCollapsed:!1},{blockId:496,x:-1580,y:200,isCollapsed:!1},{blockId:497,x:-1580,y:340,isCollapsed:!1},{blockId:498,x:-1580,y:480,isCollapsed:!1},{blockId:499,x:-1580,y:620,isCollapsed:!1},{blockId:664,x:-100,y:1420,isCollapsed:!1},{blockId:854,x:-380,y:1440,isCollapsed:!1},{blockId:855,x:-680,y:1580,isCollapsed:!1},{blockId:885,x:-700,y:1440,isCollapsed:!1},{blockId:1097,x:800,y:1440,isCollapsed:!1},{blockId:1098,x:600,y:380,isCollapsed:!1},{blockId:1195,x:200,y:1720,isCollapsed:!1},{blockId:1460,x:200,y:1800,isCollapsed:!1},{blockId:1631,x:200,y:1880,isCollapsed:!1},{blockId:2017,x:200,y:1960,isCollapsed:!1},{blockId:2198,x:1200,y:1540,isCollapsed:!1},{blockId:2275,x:860,y:1660,isCollapsed:!1},{blockId:2504,x:1500,y:1560,isCollapsed:!1},{blockId:2544,x:1200,y:1780,isCollapsed:!1},{blockId:2665,x:820,y:2e3,isCollapsed:!1},{blockId:3118,x:2360,y:1180,isCollapsed:!1},{blockId:3162,x:2380,y:960,isCollapsed:!1},{blockId:3163,x:2680,y:1140,isCollapsed:!1}],frames:[{x:800,y:820,width:1524.27,height:485.146,color:[.2823529411764706,.2823529411764706,.2823529411764706],name:"OverlayTexture",isCollapsed:!1,blocks:[167,166,168,189,192]},{x:174.342,y:1340,width:1725.67,height:760.152,color:[.2823529411764706,.2823529411764706,.2823529411764706],name:"ContourLine",isCollapsed:!1,blocks:[1097,2198,2275,2504,2544,2665,1195,1460,1631,2017]}],x:-511.7386087106099,y:-367.3393470321812,zoom:.7285102450823819},uu="BABYLON.NodeMaterial",fu=[152,164],du=[{customType:"BABYLON.VertexOutputBlock",id:152,name:"VertexOutput",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:153,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[]},{customType:"BABYLON.TransformBlock",id:153,name:"WorldPos * ViewProjectionTransform",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:154,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"transform",inputName:"transform",targetBlockId:163,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"},{name:"xyz"}],complementZ:0,complementW:1},{customType:"BABYLON.TransformBlock",id:154,name:"WorldPos",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:155,targetConnectionName:"positionOutput",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"transform",inputName:"transform",targetBlockId:494,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"},{name:"xyz"}],complementZ:0,complementW:1},{customType:"BABYLON.MorphTargetsBlock",id:155,name:"MorphTargets",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"position",inputName:"position",targetBlockId:156,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"normal",inputName:"normal",targetBlockId:157,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"tangent",inputName:"tangent",targetBlockId:158,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"uv",inputName:"uv",targetBlockId:159,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"uv2",inputName:"uv2",targetBlockId:160,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"color",inputName:"color",targetBlockId:161,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"positionOutput"},{name:"normalOutput"},{name:"tangentOutput"},{name:"uvOutput"},{name:"uv2Output"},{name:"colorOutput"}]},{customType:"BABYLON.InputBlock",id:156,name:"position",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:8,mode:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:157,name:"normal",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:8,mode:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:158,name:"tangent",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:16,mode:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:159,name:"uv",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:4,mode:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:160,name:"uv2",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:4,mode:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:161,name:"color",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:64,mode:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InstancesBlock",id:494,name:"Instances",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"world0",inputName:"world0",targetBlockId:495,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"world1",inputName:"world1",targetBlockId:496,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"world2",inputName:"world2",targetBlockId:497,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"world3",inputName:"world3",targetBlockId:498,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"world",inputName:"world",targetBlockId:499,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"},{name:"instanceID"}]},{customType:"BABYLON.InputBlock",id:495,name:"world0",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:16,mode:1,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:496,name:"world1",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:16,mode:1,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:497,name:"world2",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:16,mode:1,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:498,name:"world3",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:16,mode:1,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:499,name:"world",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:128,mode:0,systemValue:1,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.InputBlock",id:163,name:"ViewProjection",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:128,mode:0,systemValue:4,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.FragmentOutputBlock",id:164,name:"FragmentOutput",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:2,inputs:[{name:"rgba",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"rgb",inputName:"rgb",targetBlockId:3162,targetConnectionName:"rgb",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"a",inputName:"a",targetBlockId:3163,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"glow"}],outputs:[],convertToGammaSpace:!1,convertToLinearSpace:!1,useLogarithmicDepth:!1},{customType:"BABYLON.ColorSplitterBlock",id:3162,name:"ColorSplitter",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"rgba",inputName:"rgba",targetBlockId:189,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"rgb "}],outputs:[{name:"rgb"},{name:"r"},{name:"g"},{name:"b"},{name:"a"}]},{customType:"BABYLON.ConditionalBlock",id:189,name:"GreaterThan",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"a",displayName:"a",inputName:"a",targetBlockId:168,targetConnectionName:"a",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"b",displayName:"b",inputName:"b",targetBlockId:192,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"true",displayName:"true",inputName:"true",targetBlockId:168,targetConnectionName:"rgba",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"false",displayName:"false",inputName:"false",targetBlockId:2504,targetConnectionName:"rgba",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output",displayName:"output"}],condition:3},{customType:"BABYLON.TextureBlock",id:168,name:"OverlayTexture",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:3,inputs:[{name:"uv",displayName:"uv",inputName:"uv",targetBlockId:166,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"source",displayName:"source"},{name:"layer",displayName:"layer"},{name:"lod",displayName:"lod"}],outputs:[{name:"rgba",displayName:"rgba"},{name:"rgb",displayName:"rgb"},{name:"r",displayName:"r"},{name:"g",displayName:"g"},{name:"b",displayName:"b"},{name:"a",displayName:"a"},{name:"level",displayName:"level"}],convertToGammaSpace:!1,convertToLinearSpace:!1,fragmentOnly:!1,disableLevelMultiplication:!1},{customType:"BABYLON.Rotate2dBlock",id:166,name:"Rotate2d",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"input",displayName:"input",inputName:"input",targetBlockId:155,targetConnectionName:"uvOutput",isExposedOnFrame:!0,exposedPortPosition:0},{name:"angle",displayName:"angle",inputName:"angle",targetBlockId:167,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output",displayName:"output"}]},{customType:"BABYLON.InputBlock",id:167,name:"angle",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.InputBlock",id:192,name:"Float",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!0,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.ColorMergerBlock",id:2504,name:"ColorMerger",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"rgb ",inputName:"rgb ",targetBlockId:2198,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"r"},{name:"g"},{name:"b"},{name:"a",inputName:"a",targetBlockId:2544,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"rgba"},{name:"rgb"}],rSwizzle:"r",gSwizzle:"g",bSwizzle:"b",aSwizzle:"a"},{customType:"BABYLON.ConditionalBlock",id:2198,name:"GreaterThan",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"a",inputName:"a",targetBlockId:2017,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"b",inputName:"b",targetBlockId:2275,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"true",inputName:"true",targetBlockId:1097,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"false",inputName:"false",targetBlockId:664,targetConnectionName:"rgb",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}],condition:3},{customType:"BABYLON.InputBlock",id:2017,name:"contourLineWidth",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.InputBlock",id:2275,name:"Float",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!0,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.CustomBlock",id:1097,name:"ContourLineMarkerColor",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:2,inputs:[{name:"baseColor",inputName:"baseColor",targetBlockId:664,targetConnectionName:"rgb",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"worldPosY",inputName:"worldPosY",targetBlockId:1098,targetConnectionName:"y",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"contourLineStartHeight",inputName:"contourLineStartHeight",targetBlockId:1460,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"contourLineStep",inputName:"contourLineStep",targetBlockId:1631,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"contourLineWidth",inputName:"contourLineWidth",targetBlockId:2017,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"markerColor",inputName:"markerColor",targetBlockId:1195,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}],options:{name:"ContourLineMarkerColor",comments:"Outputs a marker color on contour lines so ReplaceColor can swap it later.",target:"Fragment",inParameters:[{name:"baseColor",type:"Color3"},{name:"worldPosY",type:"Float"},{name:"contourLineStartHeight",type:"Float"},{name:"contourLineStep",type:"Float"},{name:"contourLineWidth",type:"Float"},{name:"markerColor",type:"Color3"}],outParameters:[{name:"output",type:"Color3"}],functionName:"contourLineMarkerColor",code:["void contourLineMarkerColor(vec3 baseColor, float worldPosY, float contourLineStartHeight, float contourLineStep, float contourLineWidth, vec3 markerColor, out vec3 result) {"," vec3 color = baseColor;"," if (contourLineWidth > 0.0) {"," for (int i = 0; i < 16; i++) {"," float d = worldPosY - ((contourLineStartHeight * -1.0) + float(i) * contourLineStep);"," if (abs(d) < contourLineWidth) {"," color = markerColor;"," }"," }"," }"," result = color;","}"]}},{customType:"BABYLON.TextureBlock",id:664,name:"RemappedTexture",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:3,inputs:[{name:"uv",inputName:"uv",targetBlockId:854,targetConnectionName:"xy",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"source"},{name:"layer"},{name:"lod"}],outputs:[{name:"rgba"},{name:"rgb"},{name:"r"},{name:"g"},{name:"b"},{name:"a"},{name:"level"}],convertToGammaSpace:!1,convertToLinearSpace:!1,fragmentOnly:!1,disableLevelMultiplication:!1,texture:null},{customType:"BABYLON.VectorMergerBlock",id:854,name:"VectorMerger",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"xyzw "},{name:"xyz "},{name:"xy "},{name:"zw "},{name:"x",inputName:"x",targetBlockId:885,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"y",inputName:"y",targetBlockId:855,targetConnectionName:"x",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"z"},{name:"w"}],outputs:[{name:"xyzw"},{name:"xyz"},{name:"xy"},{name:"zw"}],xSwizzle:"x",ySwizzle:"y",zSwizzle:"z",wSwizzle:"w"},{customType:"BABYLON.InputBlock",id:885,name:"Float",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!0,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.VectorSplitterBlock",id:855,name:"VectorSplitter",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"xyzw",inputName:"xyzw",targetBlockId:155,targetConnectionName:"colorOutput",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"xyz "},{name:"xy "}],outputs:[{name:"xyz"},{name:"xy"},{name:"zw"},{name:"x"},{name:"y"},{name:"z"},{name:"w"}]},{customType:"BABYLON.VectorSplitterBlock",id:1098,name:"VectorSplitter",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"xyzw",inputName:"xyzw",targetBlockId:154,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"xyz "},{name:"xy "}],outputs:[{name:"xyz"},{name:"xy"},{name:"zw"},{name:"x"},{name:"y"},{name:"z"},{name:"w"}]},{customType:"BABYLON.InputBlock",id:1460,name:"contourLineStartHeight",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.InputBlock",id:1631,name:"contourLineStep",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:0},{customType:"BABYLON.InputBlock",id:1195,name:"contourLineColor",comments:"",visibleInInspector:!0,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:32,mode:0,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"BABYLON.Color3",value:[1,1,1]},{customType:"BABYLON.ConditionalBlock",id:2544,name:"GreaterThan",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"a",inputName:"a",targetBlockId:2017,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"b",inputName:"b",targetBlockId:2275,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"true",inputName:"true",targetBlockId:2665,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"false",inputName:"false",targetBlockId:664,targetConnectionName:"a",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}],condition:3},{customType:"BABYLON.InputBlock",id:2665,name:"Float",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,systemValue:null,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!0,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1,valueType:"number",value:1},{customType:"BABYLON.MultiplyBlock",id:3163,name:"Multiply",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:4,inputs:[{name:"left",inputName:"left",targetBlockId:3162,targetConnectionName:"a",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"right",inputName:"right",targetBlockId:3118,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"}]},{customType:"BABYLON.InputBlock",id:3118,name:"Material alpha",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[],outputs:[{name:"output"}],type:1,mode:0,systemValue:11,animationType:0,min:0,max:0,isBoolean:!1,matrixMode:0,isConstant:!1,groupInInspector:"",convertToGammaSpace:!1,convertToLinearSpace:!1},{customType:"BABYLON.TransformBlock",id:169,name:"World normal",comments:"",visibleInInspector:!1,visibleOnFrame:!1,target:1,inputs:[{name:"vector",inputName:"vector",targetBlockId:157,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1},{name:"transform",inputName:"transform",targetBlockId:494,targetConnectionName:"output",isExposedOnFrame:!0,exposedPortPosition:-1}],outputs:[{name:"output"},{name:"xyz"}],complementZ:0,complementW:0}],pu=5,hu={tags:Rc,ignoreAlpha:Bc,maxSimultaneousLights:Fc,mode:Dc,forceAlphaBlending:zc,_imageProcessingConfiguration:Vc,id:$c,name:Wc,checkReadyOnEveryCall:Uc,checkReadyOnlyOnce:Hc,state:Zc,alpha:Gc,backFaceCulling:Yc,cullBackFaces:Jc,_alphaMode:Xc,_needDepthPrePass:qc,disableDepthWrite:Kc,disableColorWrite:Qc,forceDepthWrite:jc,depthFunction:eu,separateCullingPass:tu,fogEnabled:nu,pointSize:ou,zOffset:ru,zOffsetUnits:iu,pointsCloud:au,fillMode:su,_isVertexOutputInvariant:lu,editorData:cu,customType:uu,outputNodes:fu,blocks:du,uniqueId:pu},mu=`
378
378
  #ifdef GL_ES
379
379
  precision highp float;
380
380
  #endif
@@ -459,7 +459,7 @@ void main(void) {
459
459
  backColor += color;
460
460
  }
461
461
  #endif
462
- }`,hu=`#ifdef GL_ES
462
+ }`,gu=`#ifdef GL_ES
463
463
  precision highp float;
464
464
  #endif
465
465
 
@@ -537,7 +537,7 @@ void main(void) {
537
537
  } else if (textureOverlayRotate > 2.5 && textureOverlayRotate <= 3.5) {
538
538
  overlayCoord = vec2(normalizedCoord.y, 1.0 - normalizedCoord.x);
539
539
  }
540
- }`,mu=`#ifdef GL_ES
540
+ }`,vu=`#ifdef GL_ES
541
541
  precision highp float;
542
542
  #endif
543
543
 
@@ -664,7 +664,7 @@ void main(void) {
664
664
  backColor += color;
665
665
  }
666
666
  #endif
667
- }`,gu=`#ifdef GL_ES
667
+ }`,xu=`#ifdef GL_ES
668
668
  precision highp float;
669
669
  #endif
670
670
 
@@ -730,7 +730,7 @@ void main(void) {
730
730
  } else if (textureFlatRotate > 2.5 && textureFlatRotate <= 3.5) {
731
731
  flatCoord = vec2(normalizedCoord.y, 1.0 - normalizedCoord.x);
732
732
  }
733
- }`,vu=`#ifdef GL_ES
733
+ }`,yu=`#ifdef GL_ES
734
734
  precision highp float;
735
735
  #endif
736
736
 
@@ -970,7 +970,7 @@ void main(void) {
970
970
  backColor += color;
971
971
  }
972
972
  #endif
973
- }`,xu=`#ifdef GL_ES
973
+ }`,Cu=`#ifdef GL_ES
974
974
  precision highp float;
975
975
  #endif
976
976
 
@@ -1059,7 +1059,7 @@ void main(void) {
1059
1059
  } else if (textureFlatRotate > 2.5 && textureFlatRotate <= 3.5) {
1060
1060
  flatCoord = vec2(normalizedCoord.y, 1.0 - normalizedCoord.x);
1061
1061
  }
1062
- }`,yu=`\uFEFF#ifdef GL_ES
1062
+ }`,_u=`\uFEFF#ifdef GL_ES
1063
1063
  precision highp float;
1064
1064
  #endif
1065
1065
  uniform vec4 vEyePosition;
@@ -1123,7 +1123,7 @@ vec3 viewDirectionW = normalize(vEyePosition.xyz - vPositionW);
1123
1123
  }
1124
1124
  #endif
1125
1125
 
1126
- }`,Cu=`\uFEFF
1126
+ }`,Pu=`\uFEFF
1127
1127
  // Attributes
1128
1128
  #define CUSTOM_VERTEX_BEGIN
1129
1129
 
@@ -1208,7 +1208,7 @@ vPositionW = vec3(worldPos);
1208
1208
 
1209
1209
  #define CUSTOM_VERTEX_MAIN_END
1210
1210
  vColor = vec4(instanceColor.rgb, instanceColor.a);
1211
- }`,Yn=({alpha:e,zOffset:t,zOffsetUnits:n,disableDepthWrite:a})=>C.jsx("pbrMaterial",{name:"metal-pbr-material",alpha:e,transparencyMode:e!==void 0&&e<1?u.Material.MATERIAL_ALPHABLEND:u.Material.MATERIAL_OPAQUE,alphaMode:u.Engine.ALPHA_COMBINE,roughness:.25,metallic:1,albedoColor:new u.Color3(.7,.7,.7),metallicF0Factor:.1,zOffset:t,zOffsetUnits:n,disableDepthWrite:a}),Jn=({alpha:e,zOffset:t,zOffsetUnits:n,disableDepthWrite:a})=>C.jsx("pbrMaterial",{name:"metal-pbr-material",alpha:e,transparencyMode:e!==void 0&&e<1?u.Material.MATERIAL_ALPHABLEND:u.Material.MATERIAL_OPAQUE,alphaMode:u.Engine.ALPHA_COMBINE,roughness:.25,metallic:1,albedoColor:new u.Color3(.2,.2,.2),metallicF0Factor:.1,zOffsetUnits:n,zOffset:t,disableDepthWrite:a});var qt=(e=>(e[e.TRIGONOMETRIC=0]="TRIGONOMETRIC",e[e.PLANE=1]="PLANE",e[e.FLAT=2]="FLAT",e))(qt||{});const Kt=e=>{const t=_e.useScene(),[n,a]=m.useState(null),[i,o]=m.useState(null),{tilingFactor:r=.1,sideTilingFactor:l=.1,texture:s,alpha:c=1,mode:p=0,zOffset:f,zOffsetUnits:d,sideTexture:x,uvOffset:h=u.Vector2.Zero(),counterLine:T=void 0,scalePlane:P=1,scaleDepth:v=1,boundingBox:_=void 0,lines:b=[],text:k=[],disableDepthWrite:M,flatModeRotate:w=0}=e,S=N=>{a(N)};return m.useEffect(()=>{n&&s&&(n.setTexture("textureSampler",s),n.setFloat("textureFlatRotate",w),n.setVector2("uvOffset",h))},[w,n,s,h]),m.useEffect(()=>{n&&n.setFloat("alpha",c)},[c,n]),m.useEffect(()=>{n&&n.setFloat("tilingFactor",r),n&&n.setFloat("sideTilingFactor",l)},[r,l,n]),m.useEffect(()=>{n&&n.setInt("mode",p)},[n,p]),m.useEffect(()=>{n&&(x?n.setTexture("textureSideSampler",x):n.setTexture("textureSideSampler",s))},[n,x,s]),m.useEffect(()=>{var N;if(n)if(T&&_){const F=(N=T.startHeight)!=null?N:_.minimumWorld.y/v;return n.setFloat("contourLineStartHeight",F*v),n.setColor3("contourLineColor",T.color),n.setFloat("contourLineWidth",T.width),n.setFloat("contourLineStep",T.stepHeight*v),console.log("[Geo3DViewer] 等高线设置 ",T,_.centerWorld.y,F*v,F*v+16*T.stepHeight*v),()=>{n&&(n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new u.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0))}}else n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new u.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[T,v,P,_,n]),m.useEffect(()=>{t&&n&&_&&o(N=>{N&&N.dispose();let F=(_.maximum.x-_.minimum.x)/P,B=(_.maximum.z-_.minimum.z)/P,I=0;if(F<B){const L=F;F=B,B=L,I=1}const D=F/B;F*B>2048*2048&&(F=2048,B=2048/D);const E=new u.DynamicTexture("dynamic-texture",{width:F,height:B},t,!1);return E.clear(),console.log("[Geo3DViewer] 设置动态划线 ",_,F,B,P),n.setVector3("oMin",_.minimum),n.setVector3("oMax",_.maximum),n.setFloat("textureOverlayRotate",I),n.setTexture("textureOverlaySampler",E),E})},[_,n,P,t]),m.useEffect(()=>{var N;if(i&&_)if((N=i.getScene())!=null&&N.getEngine()){i.clear();let F=(_.maximum.x-_.minimum.x)/P,B=(_.maximum.z-_.minimum.z)/P;if(F<B){const E=F;F=B,B=E}const I=F/B;F*B>2048*2048&&(F=2048,B=2048/I);const D=i.getContext();b.forEach(E=>{if(E.points.length<2)return;D.beginPath();const L=E.offset?E.offset:new u.Vector2(0,0),y=1-E.points[0].x+L.x,A=1-E.points[0].y+L.y;D.moveTo(y*F,A*B);for(let V=1;V<E.points.length;V++){const $=E.offset?E.offset:new u.Vector2(0,0),W=1-E.points[V].x+$.x,ne=1-E.points[V].y+$.y;D.lineTo(W*F,ne*B)}D.strokeStyle=`rgb(${E.color.r*255}, ${E.color.g*255}, ${E.color.b*255})`,F*B>2048*2048?D.lineWidth=E.width/I:D.lineWidth=E.width,D.stroke()}),k.forEach(E=>{var V,$;D.font=`${E.fontSize}px Arial`;const L=(V=E.color)!=null?V:u.Color3.White(),y=E.offset?E.offset:new u.Vector2(0,0),A=($=E.rotation)!=null?$:0;if(D.save(),D.translate((1-E.position.x+y.x)*F,(1-E.position.y+y.y)*B),D.rotate(A),E.clearArea){const W=D.measureText(E.text);D.clearRect(-W.width*.15,.5*E.fontSize*(1-.3),W.width*1.3,-E.fontSize*1.3)}if(E.background){D.fillStyle=`rgba(${E.background.r*255}, ${E.background.g*255}, ${E.background.b*255})`;const W=D.measureText(E.text);D.fillRect(-W.width*.05,.5*(E.fontSize*(.5-.1)),W.width*1.1,-E.fontSize*1.1)}D.fillStyle=`rgb(${L.r*255}, ${L.g*255}, ${L.b*255})`,D.fillText(E.text,0,0),D.restore()}),i.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[b,k,i,_,P]),C.jsx(lt,{...e,ref:S,vertex:gu,fragment:mu,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:f,zOffsetUnits:d,disableDepthWrite:M})},Mt=e=>{const t=_e.useScene(),n=m.useRef(null),a=m.useContext(Vn),[i,o]=m.useState(null),{name:r,colorCodec:l,alpha:s=1,backFaceCulling:c,needDepthPrePass:p=!1,transparencyMode:f=u.Material.MATERIAL_OPAQUE,alphaMode:d=u.Engine.ALPHA_COMBINE,zOffset:x,zOffsetUnits:h,clipPlane:T,counterLine:P=void 0,scalePlane:v=1,scaleDepth:_=1,boundingBox:b,lines:k=[],text:M=[],disableDepthWrite:w}=e;return m.useEffect(()=>{const S=n.current;S&&t&&(S.loadFromSerialization(du,""),S.build(!1,!0,!1))},[t]),m.useEffect(()=>{const S=n.current;S&&(S.name=`${r}-material`,S.backFaceCulling=c!=null?c:!0,S.needDepthPrePass=p,S.transparencyMode=f,S.alphaMode=d,S.alpha=s,S.zOffset=x!=null?x:1,S.zOffsetUnits=h!=null?h:0,S.clipPlane=T!=null?T:null,S.disableDepthWrite=w!=null?w:!1)},[s,d,c,T,w,r,p,f,x,h]),m.useEffect(()=>{if(l){const S=n.current;S&&(S.metadata={colorCodec:l},u.Tags.EnableFor(S),u.Tags.AddTagsTo(S,"remap"))}if(l&&a&&t&&a.colorCodecsImage.current[l]){const S=n.current;if(S){const N=S.getBlockByName("RemappedTexture");N&&(N.texture=a.colorCodecsImage.current[l].texture,S.markAsDirty(u.NodeMaterial.TextureDirtyFlag))}}},[l,t]),m.useEffect(()=>{n.current&&t&&(console.log("[Geo3DViewer] RemapColorByRedChannel 透明度更新 ",s),n.current.alpha=s)},[t,s]),m.useEffect(()=>{var N;const S=n.current;if(S){const F=S.getBlockByName("contourLineStartHeight"),B=S.getBlockByName("contourLineColor"),I=S.getBlockByName("contourLineWidth"),D=S.getBlockByName("contourLineStep");if(P&&b){const E=(N=P.startHeight)!=null?N:b.centerWorld.y/_;return F&&(F.value=E*_),B&&(B.value=P.color),I&&(I.value=P.width),D&&(D.value=P.stepHeight*_),console.log("[Geo3DViewer] 等高线设置 ",P,b.centerWorld,b.centerWorld.y,E*_,E*_+16*P.stepHeight*_),()=>{S&&(F&&(F.value=0),B&&(B.value=new u.Color3(0,0,0)),I&&(I.value=0),D&&(D.value=0))}}else F&&(F.value=0),B&&(B.value=new u.Color3(0,0,0)),I&&(I.value=0),D&&(D.value=0),console.log("[Geo3DViewer] 等高线设置 关闭");S.markAsDirty(u.NodeMaterial.MiscDirtyFlag)}},[P,_,v,b]),m.useEffect(()=>{t&&b&&o(S=>{var y,A;S&&S.dispose();let N=(b.maximum.x-b.minimum.x)/v,F=(b.maximum.z-b.minimum.z)/v,B=0;if(N<F){const V=N;N=F,F=V,B=1}const I=N/F;N*F>2048*2048&&(N=2048,F=2048/I);const D=new u.DynamicTexture("dynamic-texture",{width:N,height:F},t,!1);D.clear(),console.log("[Geo3DViewer] 设置动态划线 ",b,N,F,v);const E=(y=n.current)==null?void 0:y.getBlockByName("angle"),L=(A=n.current)==null?void 0:A.getBlockByName("OverlayTexture");return E&&(E.value=B*(Math.PI/2)),L&&(L.texture=D),D})},[b,v,t]),m.useEffect(()=>{var S;if(i&&b)if((S=i.getScene())!=null&&S.getEngine()){i.clear();let N=(b.maximum.x-b.minimum.x)/v,F=(b.maximum.z-b.minimum.z)/v;if(N<F){const D=N;N=F,F=D}const B=N/F;N*F>2048*2048&&(N=2048,F=2048/B);const I=i.getContext();k.forEach(D=>{if(D.points.length<2)return;I.beginPath();const E=D.offset?D.offset:new u.Vector2(0,0),L=1-D.points[0].x+E.x,y=1-D.points[0].y+E.y;I.moveTo(L*N,y*F);for(let A=1;A<D.points.length;A++){const V=D.offset?D.offset:new u.Vector2(0,0),$=1-D.points[A].x+V.x,W=1-D.points[A].y+V.y;I.lineTo($*N,W*F)}I.strokeStyle=`rgb(${D.color.r*255}, ${D.color.g*255}, ${D.color.b*255})`,N*F>2048*2048?I.lineWidth=D.width/B:I.lineWidth=D.width,I.stroke()}),M.forEach(D=>{var A,V;I.font=`${D.fontSize}px Arial`;const E=(A=D.color)!=null?A:u.Color3.White(),L=D.offset?D.offset:new u.Vector2(0,0),y=(V=D.rotation)!=null?V:0;if(I.save(),I.translate((1-D.position.x+L.x)*N,(1-D.position.y+L.y)*F),I.rotate(y),D.clearArea){const $=I.measureText(D.text);I.clearRect(-$.width*.15,.5*D.fontSize*(1-.3),$.width*1.3,-D.fontSize*1.3)}if(D.background){I.fillStyle=`rgba(${D.background.r*255}, ${D.background.g*255}, ${D.background.b*255})`;const $=I.measureText(D.text);I.fillRect(-$.width*.05,.5*(D.fontSize*(.5-.1)),$.width*1.1,-D.fontSize*1.1)}I.fillStyle=`rgb(${E.r*255}, ${E.g*255}, ${E.b*255})`,I.fillText(D.text,0,0),I.restore()}),i.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[k,i,b,v,M]),C.jsx("nodeMaterial",{ref:n,name:`${r}-material`,backFaceCulling:c,needDepthPrePass:p,transparencyMode:f,alphaMode:d,alpha:s,zOffset:x,zOffsetUnits:h,clipPlane:T,disableDepthWrite:w})},Qi=e=>{const t=_e.useScene(),n=m.useContext(Vn),a=m.useRef(null),[i,o]=m.useState(null),[r,l]=m.useState(null),[s,c]=m.useState(null),[p,f]=m.useState(null),[d,x]=m.useState(null),[h,T]=m.useState(null),[P,v]=m.useState(null),[_,b]=m.useState(null),{boundingBox:k,colorCodec:M,alphaStage:w,cutNormal:S,value:N,zOffset:F,zOffsetUnits:B,counterLine:I=void 0,scaleDepth:D=1,scalePlane:E=1,lines:L=[],text:y=[],disableDepthWrite:A}=e;return m.useEffect(()=>{const V=($,W,ne)=>{if(k){const ee=k.maximumWorld.multiply(W),G=k.minimumWorld.multiply(W),le=k.centerWorld.multiply(W),re=Math.max(ee.x,ee.y,ee.z),oe=Math.max(G.x,G.y,G.z),Y=Math.max(le.x,le.y,le.z),ce=Math.max(Math.abs(W.x),Math.abs(W.z));$(new u.Plane(W.x,W.y,W.z,((re-oe)*(1-ne-.5)*ce+Y)*-1))}else $(null)};k&&_&&(V(o,_.cutPlane1,N.value1),_.cutPlane2&&N.value2?V(l,_.cutPlane2,N.value2):l(null),_.cutPlane3&&N.value3?V(c,_.cutPlane3,N.value3):c(null),_.cutPlane4&&N.value4?V(f,_.cutPlane4,N.value4):f(null),_.cutPlane5&&N.value5?V(x,_.cutPlane5,N.value5):c(null),_.cutPlane6&&N.value6?V(T,_.cutPlane6,N.value6):T(null))},[k,_,N]),m.useEffect(()=>{b({cutPlane1:u.Vector3.Normalize(S.cutPlane1),cutPlane2:S.cutPlane2?u.Vector3.Normalize(S.cutPlane2):void 0,cutPlane3:S.cutPlane3?u.Vector3.Normalize(S.cutPlane3):void 0,cutPlane4:S.cutPlane4?u.Vector3.Normalize(S.cutPlane4):void 0,cutPlane5:S.cutPlane5?u.Vector3.Normalize(S.cutPlane5):void 0,cutPlane6:S.cutPlane6?u.Vector3.Normalize(S.cutPlane6):void 0})},[S]),m.useEffect(()=>{const V=a.current;V&&(V.clipPlane=i,V.clipPlane2=r,V.clipPlane3=s,V.clipPlane4=p,V.clipPlane5=d,V.clipPlane6=h)},[i,r,s,p,d,h]),m.useEffect(()=>{var V,$,W,ne,ee;a.current&&t&&(a.current.setFloat("alpha1",w.alpha1),a.current.setFloat("alpha2",(V=w.alpha2)!=null?V:1),a.current.setFloat("alpha3",($=w.alpha3)!=null?$:1),a.current.setFloat("alpha4",(W=w.alpha4)!=null?W:1),a.current.setFloat("alpha5",(ne=w.alpha5)!=null?ne:1),a.current.setFloat("alpha6",(ee=w.alpha6)!=null?ee:1))},[t,w]),m.useEffect(()=>{if(M){const V=a.current;V&&(V.metadata={colorCodec:M},u.Tags.EnableFor(V),u.Tags.AddTagsTo(V,"remap"))}if(M&&n&&t&&n.colorCodecsImage.current[M]){const V=a.current;V&&(console.log(n.colorCodecsImage.current[M]),V.setTexture("textureSampler",n.colorCodecsImage.current[M].texture),V.metadata={colorCodec:M},u.Tags.EnableFor(V),u.Tags.AddTagsTo(V,"remap"))}},[M,t]),m.useEffect(()=>{var $;const V=a.current;if(V&&k)if(I){const W=($=I.startHeight)!=null?$:k.minimumWorld.y/D;return V.setFloat("contourLineStartHeight",W*D),V.setColor3("contourLineColor",I.color),V.setFloat("contourLineWidth",I.width),V.setFloat("contourLineStep",I.stepHeight*D),console.log("[Geo3DViewer] 等高线设置 ",I,k.centerWorld.y,W*D,W*D+16*I.stepHeight*D),()=>{V&&(V.setFloat("contourLineStartHeight",0),V.setColor3("contourLineColor",new u.Color3(0,0,0)),V.setFloat("contourLineWidth",0),V.setFloat("contourLineStep",0))}}else V.setFloat("contourLineStartHeight",0),V.setColor3("contourLineColor",new u.Color3(0,0,0)),V.setFloat("contourLineWidth",0),V.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[I,D,E,k]),m.useEffect(()=>{t&&k&&v(V=>{var le,re,oe,Y;V&&V.dispose();let $=(k.maximum.x-k.minimum.x)/E,W=(k.maximum.z-k.minimum.z)/E,ne=0;if($<W){const ce=$;$=W,W=ce,ne=1}const ee=$/W;$*W>2048*2048&&($=2048,W=2048/ee);const G=new u.DynamicTexture("dynamic-texture",{width:$,height:W},t,!1);return G.clear(),console.log("[Geo3DViewer] 设置动态划线 ",k,$,W,E),(le=a.current)==null||le.setVector3("oMin",k.minimum),(re=a.current)==null||re.setVector3("oMax",k.maximum),(oe=a.current)==null||oe.setFloat("textureOverlayRotate",ne),(Y=a.current)==null||Y.setTexture("textureOverlaySampler",G),G})},[k,E,t]),m.useEffect(()=>{var V;if(P&&k)if((V=P.getScene())!=null&&V.getEngine()){P.clear();let $=(k.maximum.x-k.minimum.x)/E,W=(k.maximum.z-k.minimum.z)/E;if($<W){const G=$;$=W,W=G}const ne=$/W;$*W>2048*2048&&($=2048,W=2048/ne);const ee=P.getContext();L.forEach(G=>{if(G.points.length<2)return;ee.beginPath();const le=G.offset?G.offset:new u.Vector2(0,0),re=1-G.points[0].x+le.x,oe=1-G.points[0].y+le.y;ee.moveTo(re*$,oe*W);for(let Y=1;Y<G.points.length;Y++){const ce=G.offset?G.offset:new u.Vector2(0,0),ae=1-G.points[Y].x+ce.x,X=1-G.points[Y].y+ce.y;ee.lineTo(ae*$,X*W)}ee.strokeStyle=`rgb(${G.color.r*255}, ${G.color.g*255}, ${G.color.b*255})`,$*W>2048*2048?ee.lineWidth=G.width/ne:ee.lineWidth=G.width,ee.stroke()}),y.forEach(G=>{var Y,ce;ee.font=`${G.fontSize}px Arial`;const le=(Y=G.color)!=null?Y:u.Color3.White(),re=G.offset?G.offset:new u.Vector2(0,0),oe=(ce=G.rotation)!=null?ce:0;if(ee.save(),ee.translate((1-G.position.x+re.x)*$,(1-G.position.y+re.y)*W),ee.rotate(oe),G.clearArea){const ae=ee.measureText(G.text);ee.clearRect(-ae.width*.15,.5*G.fontSize*(1-.3),ae.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 ae=ee.measureText(G.text);ee.fillRect(-ae.width*.05,.5*(G.fontSize*(.5-.1)),ae.width*1.1,-G.fontSize*1.1)}ee.fillStyle=`rgb(${le.r*255}, ${le.g*255}, ${le.b*255})`,ee.fillText(G.text,0,0),ee.restore()}),P.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[L,P,k,E,y]),C.jsx(lt,{...e,ref:a,vertex:hu,fragment:pu,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:A,zOffset:F,zOffsetUnits:B})},ji=e=>{const t=_e.useScene(),[n,a]=m.useState(null),[i,o]=m.useState(null),[r,l]=m.useState(null),[s,c]=m.useState(null),[p,f]=m.useState(null),[d,x]=m.useState(null),[h,T]=m.useState(null),[P,v]=m.useState(null),[_,b]=m.useState(null),{boundingBox:k=void 0,texture:M,sideTexture:w,alphaStage:S,cutNormal:N,value:F,tilingFactor:B=.1,sideTilingFactor:I=.1,mode:D=0,zOffset:E,zOffsetUnits:L,overlay:y={},counterLine:A=void 0,scalePlane:V=1,scaleDepth:$=1,lines:W=[],text:ne=[],disableDepthWrite:ee,textureFlatRotate:G=0}=e,le=re=>{a(re)};return m.useEffect(()=>{n&&n.setFloat("textureFlatRotate",G)},[n,G]),m.useEffect(()=>{const re=(oe,Y,ce)=>{if(k){const ae=k.maximumWorld.multiply(Y),X=k.minimumWorld.multiply(Y),Pe=k.centerWorld.multiply(Y),ge=Math.max(ae.x,ae.y,ae.z),H=Math.max(X.x,X.y,X.z),Q=Math.max(Pe.x,Pe.y,Pe.z),Ee=Math.max(Math.abs(Y.x),Math.abs(Y.z)),ke=new u.Plane(Y.x,Y.y,Y.z,((ge-H)*(1-ce-.5)*Ee+Q)*-1);oe(ke),console.log("[Geo3DViewer] 设置实际 CutPlane 为 ",ke,Ee)}else oe(null)};k&&_&&(re(o,_.cutPlane1,F.value1),_.cutPlane2&&F.value2?re(l,_.cutPlane2,F.value2):l(null),_.cutPlane3&&F.value3?re(c,_.cutPlane3,F.value3):c(null),_.cutPlane4&&F.value4?re(f,_.cutPlane4,F.value4):f(null),_.cutPlane5&&F.value5?re(x,_.cutPlane5,F.value5):c(null),_.cutPlane6&&F.value6?re(T,_.cutPlane6,F.value6):T(null))},[_,k,F]),m.useEffect(()=>{b({cutPlane1:u.Vector3.Normalize(N.cutPlane1),cutPlane2:N.cutPlane2?u.Vector3.Normalize(N.cutPlane2):void 0,cutPlane3:N.cutPlane3?u.Vector3.Normalize(N.cutPlane3):void 0,cutPlane4:N.cutPlane4?u.Vector3.Normalize(N.cutPlane4):void 0,cutPlane5:N.cutPlane5?u.Vector3.Normalize(N.cutPlane5):void 0,cutPlane6:N.cutPlane6?u.Vector3.Normalize(N.cutPlane6):void 0})},[N]),m.useEffect(()=>{n&&(n.clipPlane=i,n.clipPlane2=r,n.clipPlane3=s,n.clipPlane4=p,n.clipPlane5=d,n.clipPlane6=h)},[n,i,r,s,p,d,h]),m.useEffect(()=>{var re,oe,Y,ce,ae;n&&t&&(n.setFloat("alpha1",S.alpha1),n.setFloat("alpha2",(re=S.alpha2)!=null?re:1),n.setFloat("alpha3",(oe=S.alpha3)!=null?oe:1),n.setFloat("alpha4",(Y=S.alpha4)!=null?Y:1),n.setFloat("alpha5",(ce=S.alpha5)!=null?ce:1),n.setFloat("alpha6",(ae=S.alpha6)!=null?ae:1))},[t,S,n]),m.useEffect(()=>{n&&M&&n.setTexture("textureSampler",M)},[n,M]),m.useEffect(()=>{n&&B&&n.setFloat("tilingFactor",B),n&&I&&n.setFloat("sideTilingFactor",I)},[B,I,n]),m.useEffect(()=>{n&&D&&n.setInt("mode",D)},[n,D]),m.useEffect(()=>{n&&(w?n.setTexture("textureSideSampler",w):n.setTexture("textureSideSampler",M))},[n,w,M]),m.useEffect(()=>{n&&(y.texture1?n.setTexture("textureSampler1",y.texture1):n.setTexture("textureSampler1",M),y.sideTexture1?n.setTexture("textureSideSampler1",y.sideTexture1):n.setTexture("textureSideSampler1",M),y.color1?n.setColor3("vColor1",y.color1):n.setColor3("vColor1",new u.Color3(1,1,1)),y.texture2?n.setTexture("textureSampler2",y.texture2):n.setTexture("textureSampler2",M),y.sideTexture2?n.setTexture("textureSideSampler2",y.sideTexture2):n.setTexture("textureSideSampler2",M),y.color2?n.setColor3("vColor2",y.color2):n.setColor3("vColor2",new u.Color3(1,1,1)),y.texture3?n.setTexture("textureSampler3",y.texture3):n.setTexture("textureSampler3",M),y.sideTexture3?n.setTexture("textureSideSampler3",y.sideTexture3):n.setTexture("textureSideSampler2",M),y.color3?n.setColor3("vColor3",y.color3):n.setColor3("vColor3",new u.Color3(1,1,1)),y.texture4?n.setTexture("textureSampler4",y.texture4):n.setTexture("textureSampler4",M),y.sideTexture4?n.setTexture("textureSideSampler4",y.sideTexture4):n.setTexture("textureSideSampler4",M),y.color4?n.setColor3("vColor4",y.color4):n.setColor3("vColor4",new u.Color3(1,1,1)),y.texture5?n.setTexture("textureSampler5",y.texture5):n.setTexture("textureSampler5",M),y.sideTexture5?n.setTexture("textureSideSampler5",y.sideTexture5):n.setTexture("textureSideSampler5",M),y.color5?n.setColor3("vColor5",y.color5):n.setColor3("vColor5",new u.Color3(1,1,1)),y.texture6?n.setTexture("textureSampler6",y.texture6):n.setTexture("textureSampler6",M),y.sideTexture6?n.setTexture("textureSideSampler6",y.sideTexture6):n.setTexture("textureSideSampler6",M),y.color6?n.setColor3("vColor6",y.color6):n.setColor3("vColor6",new u.Color3(1,1,1)))},[n,y,M]),m.useEffect(()=>{var re;if(n&&k)if(A){const oe=(re=A.startHeight)!=null?re:k.minimumWorld.y/$;return n.setFloat("contourLineStartHeight",oe*$),n.setColor3("contourLineColor",A.color),n.setFloat("contourLineWidth",A.width),n.setFloat("contourLineStep",A.stepHeight*$),console.log("[Geo3DViewer] 等高线设置 ",A,k.centerWorld.y,oe*$,oe*$+16*A.stepHeight*$),()=>{n&&(n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new u.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0))}}else n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new u.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[A,$,V,k,n]),m.useEffect(()=>{t&&n&&k&&v(re=>{re&&re.dispose();let oe=(k.maximum.x-k.minimum.x)/V,Y=(k.maximum.z-k.minimum.z)/V,ce=0;if(oe<Y){const Pe=oe;oe=Y,Y=Pe,ce=1}const ae=oe/Y;oe*Y>2048*2048&&(oe=2048,Y=2048/ae);const X=new u.DynamicTexture("dynamic-texture",{width:oe,height:Y},t,!1);return X.clear(),console.log("[Geo3DViewer] 设置动态划线 ",k,oe,Y,V),n.setVector3("oMin",k.minimum),n.setVector3("oMax",k.maximum),n.setFloat("textureOverlayRotate",ce),n.setTexture("textureOverlaySampler",X),X})},[k,n,V,t]),m.useEffect(()=>{var re;if(P&&k)if((re=P.getScene())!=null&&re.getEngine()){P.clear();let oe=(k.maximum.x-k.minimum.x)/V,Y=(k.maximum.z-k.minimum.z)/V;if(oe<Y){const X=oe;oe=Y,Y=X}const ce=oe/Y;oe*Y>2048*2048&&(oe=2048,Y=2048/ce);const ae=P.getContext();W.forEach(X=>{if(X.points.length<2)return;ae.beginPath();const Pe=X.offset?X.offset:new u.Vector2(0,0),ge=1-X.points[0].x+Pe.x,H=1-X.points[0].y+Pe.y;ae.moveTo(ge*oe,H*Y);for(let Q=1;Q<X.points.length;Q++){const Ee=X.offset?X.offset:new u.Vector2(0,0),ke=1-X.points[Q].x+Ee.x,te=1-X.points[Q].y+Ee.y;ae.lineTo(ke*oe,te*Y)}ae.strokeStyle=`rgb(${X.color.r*255}, ${X.color.g*255}, ${X.color.b*255})`,oe*Y>2048*2048?ae.lineWidth=X.width/ce:ae.lineWidth=X.width,ae.stroke()}),ne.forEach(X=>{var Q,Ee;ae.font=`${X.fontSize}px Arial`;const Pe=(Q=X.color)!=null?Q:u.Color3.White(),ge=X.offset?X.offset:new u.Vector2(0,0),H=(Ee=X.rotation)!=null?Ee:0;if(ae.save(),ae.translate((1-X.position.x+ge.x)*oe,(1-X.position.y+ge.y)*Y),ae.rotate(H),X.clearArea){const ke=ae.measureText(X.text);ae.clearRect(-ke.width*.15,.5*X.fontSize*(1-.3),ke.width*1.3,-X.fontSize*1.3)}if(X.background){ae.fillStyle=`rgba(${X.background.r*255}, ${X.background.g*255}, ${X.background.b*255})`;const ke=ae.measureText(X.text);ae.fillRect(-ke.width*.05,.5*(X.fontSize*(.5-.1)),ke.width*1.1,-X.fontSize*1.1)}ae.fillStyle=`rgb(${Pe.r*255}, ${Pe.g*255}, ${Pe.b*255})`,ae.fillText(X.text,0,0),ae.restore()}),P.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[W,P,k,V,ne]),C.jsx(lt,{...e,ref:le,vertex:xu,fragment:vu,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:E,zOffsetUnits:L,disableDepthWrite:ee})},_u=e=>C.jsx(lt,{...e,vertex:Gn,fragment:Zn,options:{needAlphaBlending:!0},zOffset:e.zOffset,zOffsetUnits:e.zOffsetUnits,disableDepthWrite:e.disableDepthWrite}),Pu=()=>C.jsx(lt,{name:"picking-material",vertex:Ac,fragment:Oc,backFaceCulling:!1,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","pickingColor","isPickable"]}}),Su=({name:e,scene:t})=>{const n=u.NodeMaterial.Parse(Nc,t);return n.name=e,n.backFaceCulling=!1,n.build(!1,!0,!1),n},Tu=({name:e,lineColor:t,lineWidth:n=.5})=>{const a=_e.useScene(),[i,o]=m.useState(null);return m.useEffect(()=>{if(a){const r=u.NodeMaterial.Parse(ql,a);return r.name=`${e}-material`,r.backFaceCulling=!1,r.build(!1,!0,!1),o(r),()=>{o(l=>(l==null||l.dispose(!0,!1),null))}}},[e,a]),m.useEffect(()=>{o(r=>r&&t?(r.getBlockByName("Color3").value=t,r.build(!1,!0,!1),r):null)},[t]),m.useEffect(()=>{o(r=>{if(r&&n!==void 0&&n!==null){let l=n;return n<1&&(l=1),r.getBlockByName("offset").value=1-l,r.build(!1,!0,!1),r}return null})},[n]),i},bu=(e,t)=>{const n=m.useRef(null);return m.useEffect(()=>{n.current&&(n.current.setVector4("typeAlpha1",new u.Vector4(e.typeAlpha.typeAlpha0===void 0?1:e.typeAlpha.typeAlpha0,e.typeAlpha.typeAlpha1,e.typeAlpha.typeAlpha2,e.typeAlpha.typeAlpha3)),n.current.setVector4("typeAlpha2",new u.Vector4(e.typeAlpha.typeAlpha4,e.typeAlpha.typeAlpha5,e.typeAlpha.typeAlpha6,e.typeAlpha.typeAlpha7)),n.current.setVector4("typeAlpha3",new u.Vector4(e.typeAlpha.typeAlpha8,e.typeAlpha.typeAlpha9,e.typeAlpha.typeAlpha10,e.typeAlpha.typeAlpha11)),n.current.setVector4("typeAlpha4",new u.Vector4(e.typeAlpha.typeAlpha12,e.typeAlpha.typeAlpha13,e.typeAlpha.typeAlpha14,e.typeAlpha.typeAlpha15)),n.current.setVector4("typeAlpha5",new u.Vector4(e.typeAlpha.typeAlpha16,e.typeAlpha.typeAlpha17,e.typeAlpha.typeAlpha18,e.typeAlpha.typeAlpha19)))},[e.typeAlpha]),m.useImperativeHandle(t,()=>n.current,[]),C.jsx(lt,{ref:n,name:e.name,backFaceCulling:!0,needDepthPrePass:!1,vertex:Cu,fragment:yu,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.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}})},Mn=e=>{const t=_e.useScene(),[n,a]=m.useState(null),i=m.useRef(null),{boundingBox:o,counterLine:r,scaleDepth:l=1,scalePlane:s=1,color:c,alpha:p=1,lines:f=[],text:d=[],surfaceCanvasOptions:x={textureIncludeSide:!0},disableDepthWrite:h,disableNormalShadow:T=!1}=e,{textureIncludeSide:P}=x;return m.useEffect(()=>{i.current&&(console.log("[Geo3DViewer] 设置材质 ",c,p),i.current.setColor3("vColor",c),i.current.setFloat("vAlpha",p),i.current.setFloat("textureIncludeSide",P==null?1:0))},[c,p,P]),m.useEffect(()=>{var _;const v=i.current;if(v&&o)if(r){const b=(_=r.startHeight)!=null?_:o.maximumWorld.y/l;return v.setFloat("contourLineStartHeight",b*l),v.setColor3("contourLineColor",r.color),v.setFloat("contourLineWidth",r.width),v.setFloat("contourLineStep",r.stepHeight*l),console.log("[Geo3DViewer] 等高线设置 ",r,o.centerWorld.y,b*l,b*l-16*r.stepHeight*l),()=>{v&&(v.setFloat("contourLineStartHeight",0),v.setColor3("contourLineColor",new u.Color3(0,0,0)),v.setFloat("contourLineWidth",0),v.setFloat("contourLineStep",0))}}else v.setFloat("contourLineStartHeight",0),v.setColor3("contourLineColor",new u.Color3(0,0,0)),v.setFloat("contourLineWidth",0),v.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[o,r,l,s]),m.useEffect(()=>{const v=i.current;t&&o&&v&&a(_=>{let b=(o.maximum.x-o.minimum.x)/s,k=(o.maximum.z-o.minimum.z)/s,M=0;if(b<k){const N=b;b=k,k=N,M=1}const w=b/k;b*k>2048*2048&&(b=2048,k=2048/w);let S;return _?(_.scaleTo(b,k),_.update(),S=_):S=new u.DynamicTexture("dynamic-texture",{width:b,height:k},t,!1),S.clear(),S.update(),console.log("[Geo3DViewer] 设置动态划线 ",o,b,k,s),v.setVector3("oMin",o.minimum),v.setVector3("oMax",o.maximum),v.setFloat("textureOverlayRotate",M),v.setTexture("textureOverlaySampler",S),S})},[o,s,t]),m.useEffect(()=>{var v;if(n&&o&&(f.length>0||d.length>0))if((v=n.getScene())!=null&&v.getEngine()){n.clear();let _=(o.maximum.x-o.minimum.x)/s,b=(o.maximum.z-o.minimum.z)/s;if(_<b){const w=_;_=b,b=w}const k=_/b;_*b>2048*2048&&(_=2048,b=2048/k);const M=n.getContext();f.forEach(w=>{if(w.points.length<2)return;M.beginPath();const S=w.offset?w.offset:new u.Vector2(0,0),N=1-w.points[0].x+S.x,F=1-w.points[0].y+S.y;M.moveTo(N*_,F*b);for(let B=1;B<w.points.length;B++){const I=w.offset?w.offset:new u.Vector2(0,0),D=1-w.points[B].x+I.x,E=1-w.points[B].y+I.y;M.lineTo(D*_,E*b)}M.strokeStyle=`rgb(${w.color.r*255}, ${w.color.g*255}, ${w.color.b*255})`,_*b>2048*2048?M.lineWidth=w.width/k:M.lineWidth=w.width,M.stroke()}),d.forEach(w=>{var B,I;M.font=`${w.fontSize}px Arial`;const S=(B=w.color)!=null?B:u.Color3.White(),N=w.offset?w.offset:new u.Vector2(0,0),F=(I=w.rotation)!=null?I:0;if(M.save(),M.translate((1-w.position.x+N.x)*_,(1-w.position.y+N.y)*b),M.rotate(F),w.clearArea){const D=M.measureText(w.text);M.clearRect(-D.width*.15,.5*w.fontSize*(1-.3),D.width*1.3,-w.fontSize*1.3)}if(w.background){M.fillStyle=`rgba(${w.background.r*255}, ${w.background.g*255}, ${w.background.b*255})`;const D=M.measureText(w.text);M.fillRect(-D.width*.05,.5*(w.fontSize*(.5-.1)),D.width*1.1,-w.fontSize*1.1)}M.fillStyle=`rgb(${S.r*255}, ${S.g*255}, ${S.b*255})`,M.fillText(w.text,0,0),M.restore()}),n.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[f,n,o,s,d]),m.useEffect(()=>{const v=i.current;if(v){if(T)return v.setFloat("disableNormalShadow",1),console.log("[Geo3DViewer] 禁用法向阴影 启用"),()=>{v&&v.setFloat("disableNormalShadow",0)};v.setFloat("disableNormalShadow",0),console.log("[Geo3DViewer] 禁用法向阴影 禁用")}},[T]),C.jsx(lt,{ref:i,name:e.name,backFaceCulling:e.backFaceCulling,needDepthPrePass:e.needDepthPrePass,vertex:wc,fragment:Ic,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:h})},ku=m.forwardRef(bu),ea=({name:e,url:t,offset:n=u.Vector3.Zero(),alpha:a=1,material:i,visible:o=!0,actions:r})=>{const l=_e.useScene(),s=m.useRef(null),c=m.useContext(Le),p=je({url:t,cacheType:Me.URL_PREFIX_MATCH}),f=He({url:i.texture,cacheType:Me.URL_PREFIX_MATCH}),d=He({url:i.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),[x,h]=m.useState(u.Vector3.Zero()),[T,P]=m.useState();return m.useEffect(()=>{console.log("[Geo3DViewer] AttributeBody Loading: ",t)},[t]),m.useEffect(()=>{if(l&&s.current&&t&&p){u.Tags.EnableFor(s.current),u.Tags.AddTagsTo(s.current,"loading");const v=Vo.decode(new Uint8Array(p)),{points:_,indices:b,value:k,center:M}=v,w=new u.VertexData;w.positions=_,w.indices=b,w.colors=k;const S=[];u.VertexData.ComputeNormals(_,b,S),w.normals=S,M&&h(new u.Vector3(M.x,M.y,M.z));const N=s.current;N&&(w.applyToMesh(N),N.getScene().onAfterRenderObservable.addOnce(()=>{if(!N.isDisposed()){const B=N.getBoundingInfo();P(B.boundingBox)}})),u.Tags.RemoveTagsFrom(s.current,"loading")}},[t,l,p]),m.useEffect(()=>{s.current&&(s.current.metadata={pickable:r?{name:e,onLeftClick:r.onLeftClick,onRightClick:r.onRightClick,onMiddleClick:r.onMiddleClick,onHover:r.onHover,needWorldPosition:r.needWorldPosition,extra:r.extra}:null})},[r,e]),C.jsx(C.Fragment,{children:C.jsx("transformNode",{name:`transform-attribute-${e}`,position:x.add(n).multiplyByFloats(c&&c.scalePlane?c.scalePlane:1,c&&c.scaleDepth?c.scaleDepth:1,c&&c.scalePlane?c.scalePlane:1),scaling:new u.Vector3(c?c.scalePlane:1,c?c.scaleDepth:1,c?c.scalePlane:1),children:C.jsx("mesh",{name:`attributebody-${e}-mesh`,ref:s,setEnabled:o,useVertexColors:i.type===$e.COLOR_CODEC,children:i.type===$e.COLOR_CODEC&&i.colorCodec?C.jsx(Mt,{name:`attributebody-${e}-mat`,backFaceCulling:i.backFaceCulling===void 0?!0:i.backFaceCulling,needDepthPrePass:i.needDepthPrePass===void 0?!1:i.needDepthPrePass,alpha:i.alpha?i.alpha:a,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,colorCodec:i.colorCodec,boundingBox:T,lines:i.lines,text:i.text,scaleDepth:c?c.scaleDepth:1,scalePlane:c?c.scalePlane:1,disableDepthWrite:i.disableDepthWrite}):i.type===$e.ONE_COLOR&&i.color?C.jsx("standardMaterial",{name:`attributebody-${e}-overwrite-mat`,backFaceCulling:i.backFaceCulling===void 0?!0:i.backFaceCulling,needDepthPrePass:i.needDepthPrePass===void 0?!1:i.needDepthPrePass,transparencyMode:u.Material.MATERIAL_ALPHABLEND,specularColor:new u.Color3(0,0,0),ambientColor:new u.Color3(1,1,1),diffuseColor:new u.Color3(i.color.r,i.color.g,i.color.b),emissiveColor:u.Color3.Black(),alphaMode:u.Engine.ALPHA_COMBINE,alpha:i.alpha?i.alpha:a,zOffset:-3,disableDepthWrite:i.disableDepthWrite}):i.type===$e.TEXTURE&&f?C.jsx(Kt,{name:`attributebody-${e}-texture-mat`,backFaceCulling:i.backFaceCulling===void 0?!0:i.backFaceCulling,needDepthPrePass:i.needDepthPrePass===void 0?!1:i.needDepthPrePass,alpha:i.alpha?i.alpha:a,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,texture:f,sideTexture:d,mode:i.textureMode===void 0?qt.PLANE:i.textureMode,boundingBox:T,disableDepthWrite:i.disableDepthWrite}):C.jsx(C.Fragment,{})})})})},ta=({codec:e,showValue:t=!1,showTitle:n=!0,width:a=80,height:i=200})=>{const o=m.useContext(Vn);return C.jsx(C.Fragment,{children:C.jsxs("adtFullscreenUi",{name:`adt-color-codec-${e}`,children:[n?C.jsx("textBlock",{name:`color-codec-title-${e}`,text:e,color:"white",paddingBottomInPixels:i+40/200*i,paddingRightInPixels:30/80*a,textVerticalAlignment:nt.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:nt.Control.HORIZONTAL_ALIGNMENT_RIGHT}):C.jsx(C.Fragment,{}),C.jsx("babylon-image",{name:`color-codec-${e}`,source:o!=null&&o.colorCodecsImage.current[e]?o.colorCodecsImage.current[e].blobUrl:"",height:`${i}px`,width:`${a}px`,verticalAlignment:nt.Control.VERTICAL_ALIGNMENT_CENTER,horizontalAlignment:nt.Control.HORIZONTAL_ALIGNMENT_RIGHT,paddingRightInPixels:20}),t&&(o!=null&&o.colorCodecsImage.current[e])?C.jsxs(C.Fragment,{children:[C.jsx("textBlock",{name:"color-codec-value-min",text:o.colorCodecsImage.current[e].min.toFixed(1).toString(),color:"white",paddingBottomInPixels:-1*i,paddingRightInPixels:90,textVerticalAlignment:nt.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:nt.Control.HORIZONTAL_ALIGNMENT_RIGHT}),C.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:nt.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:nt.Control.HORIZONTAL_ALIGNMENT_RIGHT}),C.jsx("textBlock",{name:"color-codec-title-max",text:o.colorCodecsImage.current[e].max.toFixed(1).toString(),color:"white",paddingBottomInPixels:i,paddingRightInPixels:a+10,textVerticalAlignment:nt.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:nt.Control.HORIZONTAL_ALIGNMENT_RIGHT})]}):null]})})};function Xr(){return{name:"",colorId:0,points:[],indices:[],bottomIndices:[],value:[],vMin:0,vMax:0,border:[],side:[],sideIndices:[],sideValue:[],center:void 0}}const Wt={encode(e,t=se.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&&K.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=Xr();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 2:if(o!==16)break;i.colorId=n.uint32();continue;case 21:if(o===173){i.points.push(n.float());continue}if(o===170){const r=n.uint32()+n.pos;for(;n.pos<r;)i.points.push(n.float());continue}break;case 22:if(o===176){i.indices.push(n.uint32());continue}if(o===178){const r=n.uint32()+n.pos;for(;n.pos<r;)i.indices.push(n.uint32());continue}break;case 23:if(o===184){i.bottomIndices.push(n.uint32());continue}if(o===186){const r=n.uint32()+n.pos;for(;n.pos<r;)i.bottomIndices.push(n.uint32());continue}break;case 24:if(o===197){i.value.push(n.float());continue}if(o===194){const r=n.uint32()+n.pos;for(;n.pos<r;)i.value.push(n.float());continue}break;case 25:if(o!==205)break;i.vMin=n.float();continue;case 26:if(o!==213)break;i.vMax=n.float();continue;case 27:if(o===216){i.border.push(n.uint32());continue}if(o===218){const r=n.uint32()+n.pos;for(;n.pos<r;)i.border.push(n.uint32());continue}break;case 28:if(o===229){i.side.push(n.float());continue}if(o===226){const r=n.uint32()+n.pos;for(;n.pos<r;)i.side.push(n.float());continue}break;case 29:if(o===232){i.sideIndices.push(n.uint32());continue}if(o===234){const r=n.uint32()+n.pos;for(;n.pos<r;)i.sideIndices.push(n.uint32());continue}break;case 30:if(o===245){i.sideValue.push(n.float());continue}if(o===242){const r=n.uint32()+n.pos;for(;n.pos<r;)i.sideValue.push(n.float());continue}break;case 31:if(o!==250)break;i.center=K.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{name:_n(e.name)?globalThis.String(e.name):"",colorId:_n(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:_n(e.vMin)?globalThis.Number(e.vMin):0,vMax:_n(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:_n(e.center)?K.fromJSON(e.center):void 0}},toJSON(e){var n,a,i,o,r,l,s,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(p=>Math.round(p))),(i=e.bottomIndices)!=null&&i.length&&(t.bottomIndices=e.bottomIndices.map(p=>Math.round(p))),(o=e.value)!=null&&o.length&&(t.value=e.value),e.vMin!==0&&(t.vMin=e.vMin),e.vMax!==0&&(t.vMax=e.vMax),(r=e.border)!=null&&r.length&&(t.border=e.border.map(p=>Math.round(p))),(l=e.side)!=null&&l.length&&(t.side=e.side),(s=e.sideIndices)!=null&&s.length&&(t.sideIndices=e.sideIndices.map(p=>Math.round(p))),(c=e.sideValue)!=null&&c.length&&(t.sideValue=e.sideValue),e.center!==void 0&&(t.center=K.toJSON(e.center)),t},create(e){return Wt.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i,o,r,l,s,c,p,f,d,x;const t=Xr();return t.name=(n=e.name)!=null?n:"",t.colorId=(a=e.colorId)!=null?a:0,t.points=((i=e.points)==null?void 0:i.map(h=>h))||[],t.indices=((o=e.indices)==null?void 0:o.map(h=>h))||[],t.bottomIndices=((r=e.bottomIndices)==null?void 0:r.map(h=>h))||[],t.value=((l=e.value)==null?void 0:l.map(h=>h))||[],t.vMin=(s=e.vMin)!=null?s:0,t.vMax=(c=e.vMax)!=null?c:0,t.border=((p=e.border)==null?void 0:p.map(h=>h))||[],t.side=((f=e.side)==null?void 0:f.map(h=>h))||[],t.sideIndices=((d=e.sideIndices)==null?void 0:d.map(h=>h))||[],t.sideValue=((x=e.sideValue)==null?void 0:x.map(h=>h))||[],t.center=e.center!==void 0&&e.center!==null?K.fromPartial(e.center):void 0,t}};function _n(e){return e!=null}const Eu=64,Nu=32,na='"Noto Sans SC", sans-serif';function Iu(e,t){if(typeof document=="undefined")return{textureWidth:256,textureHeight:128};const a=document.createElement("canvas").getContext("2d");if(!a)return{textureWidth:256,textureHeight:128};const i=Math.max(8,Math.round(t*.35)),o=Math.max(6,Math.round(t*.25));a.font=`600 ${t}px ${na}`;const r=Math.ceil(a.measureText(e||" ").width),l=Math.ceil(t*1.6);return{textureWidth:Math.max(Eu,qr(r+i*2)),textureHeight:Math.max(Nu,qr(l+o*2))}}function qr(e){let t=1;for(;t<e;)t<<=1;return t}function wu(e){if(typeof e=="string")return e;const t=Math.round(e.r*255),n=Math.round(e.g*255),a=Math.round(e.b*255);return`rgba(${t}, ${n}, ${a}, ${e.a})`}const Je=e=>{const t=_e.useScene(),n=m.useRef(null),a=m.useRef(null),{name:i,text:o,fontSize:r,color:l,billboardMode:s=u.Mesh.BILLBOARDMODE_ALL,lowPriority:c=!0}=e;return m.useEffect(()=>{if(!t)return;const p=i!=null?i:"gui-text-no-name",{textureWidth:f,textureHeight:d}=Iu(o,r),x=u.MeshBuilder.CreatePlane(p,{width:1,height:1},t);x.parent=n.current,x.isPickable=!1,x.billboardMode=s,x.alwaysSelectAsActiveMesh=!0;const h=Math.max(r,1);x.scaling.x=h*(f/d),x.scaling.y=h;const T=nt.AdvancedDynamicTexture.CreateForMesh(x,f,d,!1,!1);T.rootContainer.isPointerBlocker=!1;const P=new nt.TextBlock(`${p}-text`,o);P.color=wu(l),P.fontFamily=na,P.fontWeight="600",P.fontSize=`${r}px`,P.resizeToFit=!1,P.textWrapping=!1,P.textHorizontalAlignment=nt.Control.HORIZONTAL_ALIGNMENT_CENTER,P.textVerticalAlignment=nt.Control.VERTICAL_ALIGNMENT_CENTER,T.addControl(P);const v=x.material;return v&&v instanceof u.StandardMaterial&&(v.backFaceCulling=!1,v.disableLighting=!0,v.forceDepthWrite=!1,v.needDepthPrePass=!1,v.transparencyMode=u.Material.MATERIAL_ALPHABLEND,v.zOffset=-2),x.renderingGroupId=2,a.current={plane:x,texture:T},()=>{var _,b;(_=a.current)==null||_.texture.dispose(),(b=a.current)==null||b.plane.dispose(),a.current=null}},[t,i,o,r,l,s,c]),m.useEffect(()=>{a.current&&(a.current.plane.parent=n.current)}),C.jsx("transformNode",{name:i!=null?i:"no-name-text",ref:n})},Xn=({urlTopLayer:e,urlBottomLayer:t,showLayerLabel:n=!1,labelStyle:a,position:i=u.Vector3.Zero(),visible:o=!0,showBottomLayer:r=!1,actions:l,material:s={type:$e.COLOR_ID,alpha:1}})=>{var E,L;const c=m.useRef(null),p=m.useRef(null),[f,d]=m.useState(""),[x,h]=m.useState(null),T=m.useContext(Le),P=m.useContext(Lt),[v,_]=m.useState(u.Color3.White()),b=je({url:e,cacheType:Me.URL_PREFIX_MATCH}),k=je({url:t,cacheType:Me.URL_PREFIX_MATCH}),M=He({url:s==null?void 0:s.texture,cacheType:Me.URL_PREFIX_MATCH}),w=He({url:s==null?void 0:s.sideTexture,cacheType:Me.URL_PREFIX_MATCH});m.useEffect(()=>{console.log("[Geo3DViewer] FormationFace Loading: ",e,t)},[e,t]);const[S,N]=m.useState(),[F,B]=m.useState(u.Vector3.Zero()),[I,D]=m.useState(void 0);return m.useEffect(()=>{if(b){const y=c.current;y&&(u.Tags.EnableFor(y),u.Tags.AddTagsTo(y,"loading"));let A=[],V=[],$=[];const W=Wt.decode(new Uint8Array(b));{const{name:G,points:le,indices:re,colorId:oe,value:Y,center:ce}=W;A=le,V=re,$=Y,h(oe),d(G),ce&&B(new u.Vector3(ce.x,ce.y,ce.z))}const ne=new u.VertexData;ne.positions=A,ne.indices=V,ne.colors=$;const ee=[];if(u.VertexData.ComputeNormals(A,V,ee),ne.normals=ee,y){ne.applyToMesh(y);const G=y.getBoundingInfo();N(G.boundingBox.center.add(new u.Vector3(G.boundingBox.extendSize.x,0,0))),r||y.getScene().onAfterRenderObservable.addOnce(()=>{if(!y.isDisposed()){const re=y.getBoundingInfo();D(re.boundingBox)}})}return y&&u.Tags.RemoveTagsFrom(y,"loading"),()=>{y&&new u.VertexData().applyToMesh(y)}}},[b,r]),m.useEffect(()=>{if(b&&k){const y=p.current;y&&(u.Tags.EnableFor(y),u.Tags.AddTagsTo(y,"loading"));let A=[],V=[],$=[],W=[],ne=[],ee=[],G=[],le=[];{const ge=Wt.decode(new Uint8Array(b)),{points:H,indices:Q,border:Ee,value:ke}=ge;A=H,V=Q,W=Ee,$=ke}{const ge=Wt.decode(new Uint8Array(k)),{points:H,bottomIndices:Q,border:Ee,value:ke}=ge;ne=H,ee=Q,G=Ee,le=ke}const re=new u.VertexData,oe=new Float32Array(A.length+ne.length);let Y=V.length+ee.length;Y=Y+((W.length<1?1:W.length)-1)*6;const ce=new Int32Array(Y),ae=new Float32Array($.length+le.length);oe.set(A),ce.set(V),ae.set($),oe.set(ne,A.length),ce.set(ee,V.length),ae.set(le,$.length);const X=[];for(let ge=0;ge<W.length-1;ge++)X.push(W[ge+1]),X.push(W[ge]),X.push(G[ge]+A.length/3),X.push(G[ge+1]+A.length/3),X.push(G[ge]+A.length/3),X.push(W[ge+1]);ce.set(X,V.length+ee.length),re.positions=oe,re.indices=ce,re.colors=ae;const Pe=[];return u.VertexData.ComputeNormals(oe,ce,Pe),re.normals=Pe,y&&(re.applyToMesh(y),r&&y.getScene().onAfterRenderObservable.addOnce(()=>{if(!y.isDisposed()){const H=y.getBoundingInfo();D(H.boundingBox)}})),y&&u.Tags.RemoveTagsFrom(y,"loading"),()=>{y&&new u.VertexData().applyToMesh(y)}}},[k,b,r]),m.useEffect(()=>{var y;_(s.type===$e.ONE_COLOR?(y=s==null?void 0:s.color)!=null?y:u.Color3.Random():x&&P.colorIDs[x]?new u.Color3(P.colorIDs[x].r,P.colorIDs[x].g,P.colorIDs[x].b):u.Color3.Random())},[P.colorIDs,x,s==null?void 0:s.color,s.type]),m.useEffect(()=>{c.current&&(c.current.metadata={pickable:l?{name:f,onLeftClick:l.onLeftClick,onRightClick:l.onRightClick,onMiddleClick:l.onMiddleClick,onHover:l.onHover,needWorldPosition:l.needWorldPosition,extra:l.extra}:null}),p.current&&(p.current.metadata={pickable:l?{name:f,onLeftClick:l.onLeftClick,onRightClick:l.onRightClick,onMiddleClick:l.onMiddleClick,onHover:l.onHover,needWorldPosition:l.needWorldPosition,extra:l.extra}:null})},[l,f]),C.jsx(C.Fragment,{children:C.jsxs("transformNode",{name:`transform-formation-${f}-${e}`,position:F.add(i).multiplyByFloats(T&&T.scalePlane?T.scalePlane:1,T&&T.scaleDepth?T.scaleDepth:1,T&&T.scalePlane?T.scalePlane:1),scaling:new u.Vector3(T?T.scalePlane:1,T?T.scaleDepth:1,T?T.scalePlane:1),setEnabled:o,children:[C.jsx("mesh",{name:`formation-${f}-mesh-${e}`,ref:c,setEnabled:!r,useVertexColors:s.type===$e.COLOR_CODEC,alwaysSelectAsActiveMesh:!0,children:s.type===$e.TEXTURE?M?C.jsx(Kt,{name:`formation-${f}-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,alpha:s.alpha,texture:M,sideTexture:w,tilingFactor:s.tilingFactor,sideTilingFactor:(E=s==null?void 0:s.sideTilingFactor)!=null?E:s==null?void 0:s.tilingFactor,mode:s.textureMode===void 0?qt.PLANE:s.textureMode,boundingBox:I,lines:s.lines,text:s.text,scaleDepth:T?T.scaleDepth:1,scalePlane:T?T.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):C.jsx(C.Fragment,{}):s.type===$e.COLOR_CODEC?s.colorCodec?C.jsx(Mt,{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:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,colorCodec:s.colorCodec,boundingBox:I,lines:s.lines,text:s.text,scaleDepth:T?T.scaleDepth:1,scalePlane:T?T.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):C.jsx(C.Fragment,{}):s.type===$e.COLOR_ID?C.jsx(Mn,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,surfaceCanvasOptions:s.surfaceCanvasOptions,color:v,alphaMode:u.Engine.ALPHA_COMBINE,alpha:s.alpha,boundingBox:I,transparencyMode:u.Material.MATERIAL_ALPHABLEND,lines:s.lines,text:s.text,scaleDepth:T?T.scaleDepth:1,scalePlane:T?T.scalePlane:1,disableDepthWrite:s.disableDepthWrite,disableNormalShadow:s.disableNormalShadow}):C.jsx(Mn,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,color:v,surfaceCanvasOptions:s.surfaceCanvasOptions,alphaMode:u.Engine.ALPHA_COMBINE,alpha:s.alpha,boundingBox:I,transparencyMode:u.Material.MATERIAL_ALPHABLEND,lines:s.lines,text:s.text,scaleDepth:T?T.scaleDepth:1,scalePlane:T?T.scalePlane:1,disableDepthWrite:s.disableDepthWrite,disableNormalShadow:s.disableNormalShadow})}),C.jsx("mesh",{name:`formation-${f}-vol-${e}`,ref:p,setEnabled:r,useVertexColors:s.type===$e.COLOR_CODEC,alwaysSelectAsActiveMesh:!0,children:s.type===$e.TEXTURE?M?C.jsx(Kt,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,alpha:s.alpha,sideTexture:w,texture:M,tilingFactor:s.tilingFactor,sideTilingFactor:(L=s==null?void 0:s.sideTilingFactor)!=null?L:s==null?void 0:s.tilingFactor,mode:s.textureMode===void 0?qt.PLANE:s.textureMode,boundingBox:I,lines:s.lines,text:s.text,scaleDepth:T?T.scaleDepth:1,scalePlane:T?T.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):C.jsx(C.Fragment,{}):s.type===$e.COLOR_CODEC?s.colorCodec?C.jsx(Mt,{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:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,colorCodec:s.colorCodec,boundingBox:I,lines:s.lines,text:s.text,scaleDepth:T?T.scaleDepth:1,scalePlane:T?T.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):C.jsx(C.Fragment,{}):s.type===$e.COLOR_ID?C.jsx(Mn,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,surfaceCanvasOptions:s.surfaceCanvasOptions,color:v,alphaMode:u.Engine.ALPHA_COMBINE,alpha:s.alpha,transparencyMode:u.Material.MATERIAL_ALPHABLEND,boundingBox:I,lines:s.lines,text:s.text,scaleDepth:T?T.scaleDepth:1,scalePlane:T?T.scalePlane:1,disableDepthWrite:s.disableDepthWrite,disableNormalShadow:s.disableNormalShadow}):C.jsx(Mn,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,surfaceCanvasOptions:s.surfaceCanvasOptions,color:v,alphaMode:u.Engine.ALPHA_COMBINE,alpha:s.alpha,transparencyMode:u.Material.MATERIAL_ALPHABLEND,boundingBox:I,lines:s.lines,text:s.text,scaleDepth:T?T.scaleDepth:1,scalePlane:T?T.scalePlane:1,disableDepthWrite:s.disableDepthWrite,disableNormalShadow:s.disableNormalShadow})}),f&&S&&C.jsx("transformNode",{name:`${f}-title-${e}`,position:S.add(a!=null&&a.offset?a.offset.multiplyByFloats(T!=null&&T.scalePlane?T==null?void 0:T.scalePlane:1,1,T!=null&&T.scalePlane?T==null?void 0:T.scalePlane:1):u.Vector3.Zero()),scaling:ct(T).multiply(new u.Vector3(3,3,3)),setEnabled:n,children:C.jsx(Je,{text:f,fontSize:a!=null&&a.fontSize?a.fontSize:40,color:a!=null&&a.color?a.color:"white"})})]})})},qn=({url:e,showLayerLabel:t=!1,labelStyle:n,position:a=u.Vector3.Zero(),visible:i=!0,showBottomLayer:o=!1,actions:r,material:l={type:$e.COLOR_ID,counterLine:void 0,alpha:1}})=>{var I,D;const s=m.useRef(null),c=m.useRef(null),[p,f]=m.useState(""),[d,x]=m.useState(null),[h,T]=m.useState(u.Color3.White()),P=m.useContext(Le),v=m.useContext(Lt),[_,b]=m.useState(u.Vector3.Zero()),[k,M]=m.useState(),w=je({url:e,cacheType:Me.URL_PREFIX_MATCH}),S=He({url:l==null?void 0:l.texture,cacheType:Me.URL_PREFIX_MATCH}),N=He({url:l==null?void 0:l.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),[F,B]=m.useState(void 0);return m.useEffect(()=>{console.log("[Geo3DViewer] FormationVolume Loading: ",e)},[e]),m.useEffect(()=>{if(w){const E=s.current,L=c.current;u.Tags.EnableFor(E),u.Tags.AddTagsTo(E,"loading"),u.Tags.EnableFor(c),u.Tags.AddTagsTo(c,"loading");let y=[],A=[],V=[],$=[];const W=Wt.decode(new Uint8Array(w)),{name:ne,points:ee,indices:G,colorId:le,side:re,sideIndices:oe,center:Y,value:ce,sideValue:ae}=W;Y&&b(new u.Vector3(Y.x,Y.y,Y.z)),y=ee,A=G,V=re,$=oe,x(le),f(ne);const X=new u.VertexData,Pe=new u.VertexData,ge=new Float32Array(y.length+V.length),H=new Int32Array(A.length+$.length),Q=new Float32Array(ce.length+ae.length);X.positions=y,X.indices=A,X.colors=ce;const Ee=[];u.VertexData.ComputeNormals(ee,G,Ee),X.normals=Ee,ge.set(y),H.set(A),Q.set(ce),ge.set(V,y.length),H.set($,A.length),Q.set(ae,ce.length),Pe.positions=ge,Pe.indices=H,Pe.colors=Q;const ke=[];if(u.VertexData.ComputeNormals(ge,H,ke),Pe.normals=ke,E){X.applyToMesh(E);const te=E.getBoundingInfo();M(te.boundingBox.center.add(new u.Vector3(te.boundingBox.extendSize.x,0,0))),o||E.getScene().onAfterRenderObservable.addOnce(()=>{if(!E.isDisposed()){const ue=E.getBoundingInfo();B(ue.boundingBox)}})}return L&&(Pe.applyToMesh(L),o&&L.getScene().onAfterRenderObservable.addOnce(()=>{if(!L.isDisposed()){const me=L.getBoundingInfo();B(me.boundingBox)}})),u.Tags.RemoveTagsFrom(E,"loading"),u.Tags.RemoveTagsFrom(c,"loading"),()=>{E&&new u.VertexData().applyToMesh(E),L&&new u.VertexData().applyToMesh(L)}}},[w,o]),m.useEffect(()=>{var E;T(l.type===$e.ONE_COLOR?(E=l==null?void 0:l.color)!=null?E:u.Color3.Random():d&&v.colorIDs[d]?new u.Color3(v.colorIDs[d].r,v.colorIDs[d].g,v.colorIDs[d].b):u.Color3.Random())},[v.colorIDs,d,l==null?void 0:l.color,l.type]),m.useEffect(()=>{s.current&&(s.current.metadata={pickable:r?{name:p,onLeftClick:r.onLeftClick,onRightClick:r.onRightClick,onMiddleClick:r.onMiddleClick,onHover:r.onHover,needWorldPosition:r.needWorldPosition,extra:r.extra}:null}),c.current&&(c.current.metadata={pickable:r?{name:p,onLeftClick:r.onLeftClick,onRightClick:r.onRightClick,onMiddleClick:r.onMiddleClick,onHover:r.onHover,needWorldPosition:r.needWorldPosition,extra:r.extra}:null})},[r,p]),C.jsx(C.Fragment,{children:C.jsxs("transformNode",{name:`transform-formation-${p}-${e}`,position:_.add(a).multiplyByFloats(P&&P.scalePlane?P.scalePlane:1,P&&P.scaleDepth?P.scaleDepth:1,P&&P.scalePlane?P.scalePlane:1),scaling:new u.Vector3(P?P.scalePlane:1,P?P.scaleDepth:1,P?P.scalePlane:1),setEnabled:i,children:[C.jsx("mesh",{name:`formation-${p}-mesh-${e}`,ref:s,setEnabled:!o,useVertexColors:l.type===$e.COLOR_CODEC,children:l.type===$e.TEXTURE?S?C.jsx(Kt,{name:`formation-${p}-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,alpha:l.alpha,flatModeRotate:l.flatModeRotate,sideTexture:N,texture:S,tilingFactor:l.tilingFactor,sideTilingFactor:(I=l==null?void 0:l.sideTilingFactor)!=null?I:l==null?void 0:l.tilingFactor,mode:l.textureMode===void 0?qt.PLANE:l.textureMode,counterLine:l.counterLine,boundingBox:F,lines:l.lines,text:l.text,scaleDepth:P?P.scaleDepth:1,scalePlane:P?P.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):C.jsx(C.Fragment,{}):l.type===$e.COLOR_CODEC?l.colorCodec?C.jsx(Mt,{name:`formation-${p}-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,alpha:l.alpha,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,colorCodec:l.colorCodec,counterLine:l.counterLine,boundingBox:F,lines:l.lines,text:l.text,scaleDepth:P?P.scaleDepth:1,scalePlane:P?P.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):C.jsx(C.Fragment,{}):l.type===$e.COLOR_ID?C.jsx(An,{name:`formation-${p}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,color:h,alphaMode:u.Engine.ALPHA_COMBINE,alpha:l.alpha,lightPosition:l.lightPosition,intensity:l.intensity,surfaceCanvasOptions:l.surfaceCanvasOptions,transparencyMode:u.Material.MATERIAL_ALPHABLEND,boundingBox:F,lines:l.lines,text:l.text,zOffset:l.zOffset,zOffsetUnits:l.zOffsetUnits,contrast:l.contrast,sideIntensity:l.sideIntensity,cullFace:l.cullFace,scaleDepth:P?P.scaleDepth:1,scalePlane:P?P.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):C.jsx(An,{name:`formation-${p}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,color:h,alphaMode:u.Engine.ALPHA_COMBINE,surfaceCanvasOptions:l.surfaceCanvasOptions,alpha:l.alpha,lightPosition:l.lightPosition,intensity:l.intensity,transparencyMode:u.Material.MATERIAL_ALPHABLEND,boundingBox:F,lines:l.lines,text:l.text,zOffset:l.zOffset,zOffsetUnits:l.zOffsetUnits,contrast:l.contrast,sideIntensity:l.sideIntensity,cullFace:l.cullFace,scaleDepth:P?P.scaleDepth:1,scalePlane:P?P.scalePlane:1,disableDepthWrite:l.disableDepthWrite})}),C.jsx("mesh",{name:`formation-${p}-vol-${e}`,ref:c,setEnabled:o,useVertexColors:l.type===$e.COLOR_CODEC,children:l.type===$e.TEXTURE?S?C.jsx(Kt,{name:`formation-${p}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,alpha:l.alpha,sideTexture:N,texture:S,tilingFactor:l.tilingFactor,sideTilingFactor:(D=l==null?void 0:l.sideTilingFactor)!=null?D:l==null?void 0:l.tilingFactor,mode:l.textureMode===void 0?qt.PLANE:l.textureMode,flatModeRotate:l.flatModeRotate,counterLine:l.counterLine,boundingBox:F,lines:l.lines,text:l.text,scaleDepth:P?P.scaleDepth:1,scalePlane:P?P.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):C.jsx(C.Fragment,{}):l.type===$e.COLOR_CODEC?l.colorCodec?C.jsx(Mt,{name:`formation-${p}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,alpha:l.alpha,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,colorCodec:l.colorCodec,counterLine:l.counterLine,boundingBox:F,lines:l.lines,text:l.text,scaleDepth:P?P.scaleDepth:1,scalePlane:P?P.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):C.jsx(C.Fragment,{}):l.type===$e.COLOR_ID?C.jsx(An,{name:`formation-${p}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,color:h,surfaceCanvasOptions:l.surfaceCanvasOptions,alphaMode:u.Engine.ALPHA_COMBINE,alpha:l.alpha,lightPosition:l.lightPosition,intensity:l.intensity,transparencyMode:u.Material.MATERIAL_ALPHABLEND,boundingBox:F,lines:l.lines,text:l.text,zOffset:l.zOffset,zOffsetUnits:l.zOffsetUnits,contrast:l.contrast,sideIntensity:l.sideIntensity,cullFace:l.cullFace,scaleDepth:P?P.scaleDepth:1,scalePlane:P?P.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):C.jsx(An,{name:`formation-${p}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,color:h,surfaceCanvasOptions:l.surfaceCanvasOptions,alphaMode:u.Engine.ALPHA_COMBINE,alpha:l.alpha,lightPosition:l.lightPosition,intensity:l.intensity,transparencyMode:u.Material.MATERIAL_ALPHABLEND,boundingBox:F,lines:l.lines,text:l.text,zOffset:l.zOffset,zOffsetUnits:l.zOffsetUnits,contrast:l.contrast,sideIntensity:l.sideIntensity,cullFace:l.cullFace,scaleDepth:P?P.scaleDepth:1,scalePlane:P?P.scalePlane:1,disableDepthWrite:l.disableDepthWrite})}),p&&k&&C.jsx("transformNode",{name:`${p}-title-${e}`,position:k.add(n!=null&&n.offset?n.offset.multiplyByFloats(P!=null&&P.scalePlane?P==null?void 0:P.scalePlane:1,1,P!=null&&P.scalePlane?P==null?void 0:P.scalePlane:1):u.Vector3.Zero()),scaling:ct(P).multiply(new u.Vector3(3,3,3)),setEnabled:t,children:C.jsx(Je,{text:p,fontSize:n!=null&&n.fontSize?n.fontSize:40,color:n!=null&&n.color?n.color:"white"})})]})})};var $o=(e=>(e[e.FACE=0]="FACE",e[e.VOLUME=1]="VOLUME",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))($o||{});function Ou(e){switch(e){case 0:case"FACE":return 0;case 1:case"VOLUME":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function Au(e){switch(e){case 0:return"FACE";case 1:return"VOLUME";case-1:default:return"UNRECOGNIZED"}}function Kr(){return{name:"",formations:[],mode:0,effectMeshs:[]}}const kn={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.formations)cn.encode(n,t.uint32(34).fork()).ldelim();e.mode!==0&&t.uint32(40).int32(e.mode);for(const n of e.effectMeshs)We.encode(n,t.uint32(50).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=Kr();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 4:if(o!==34)break;i.formations.push(cn.decode(n,n.uint32()));continue;case 5:if(o!==40)break;i.mode=n.int32();continue;case 6:if(o!==50)break;i.effectMeshs.push(We.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{name:Dn(e.name)?globalThis.String(e.name):"",formations:globalThis.Array.isArray(e==null?void 0:e.formations)?e.formations.map(t=>cn.fromJSON(t)):[],mode:Dn(e.mode)?Ou(e.mode):0,effectMeshs:globalThis.Array.isArray(e==null?void 0:e.effectMeshs)?e.effectMeshs.map(t=>We.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(i=>cn.toJSON(i))),e.mode!==0&&(t.mode=Au(e.mode)),(a=e.effectMeshs)!=null&&a.length&&(t.effectMeshs=e.effectMeshs.map(i=>We.toJSON(i))),t},create(e){return kn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i,o;const t=Kr();return t.name=(n=e.name)!=null?n:"",t.formations=((a=e.formations)==null?void 0:a.map(r=>cn.fromPartial(r)))||[],t.mode=(i=e.mode)!=null?i:0,t.effectMeshs=((o=e.effectMeshs)==null?void 0:o.map(r=>We.fromPartial(r)))||[],t}};function Qr(){return{name:"",url:""}}const cn={encode(e,t=se.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=Qr();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 2:if(o!==18)break;i.url=n.string();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{name:Dn(e.name)?globalThis.String(e.name):"",url:Dn(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 cn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=Qr();return t.name=(n=e.name)!=null?n:"",t.url=(a=e.url)!=null?a:"",t}};function Dn(e){return e!=null}const Wo=({url:e,alpha:t=1,position:n=u.Vector3.Zero(),visible:a=!0,colorCodec:i,actions:o,counterLine:r=void 0,lines:l,text:s,disableDepthWrite:c})=>{const p=m.useRef(null),[f,d]=m.useState(""),x=m.useContext(Le),h=m.useContext(Lt),[T,P]=m.useState(null),[v,_]=m.useState(u.Color3.White()),b=je({url:e,cacheType:Me.URL_PREFIX_MATCH}),[k,M]=m.useState(u.Vector3.Zero()),[w,S]=m.useState();return m.useEffect(()=>{console.log("[Geo3DViewer] StructureLayer Loading: ",e)},[e]),m.useEffect(()=>{if(b){const N=p.current;u.Tags.EnableFor(N),u.Tags.AddTagsTo(N,"loading");const F=Wt.decode(new Uint8Array(b)),{name:B,points:I,indices:D,value:E,colorId:L,center:y}=F;y&&M(new u.Vector3(y.x,y.y,y.z));const A=new u.VertexData;A.positions=I,A.indices=D,A.colors=E;const V=[];return u.VertexData.ComputeNormals(I,D,V),A.normals=V,P(L),d(B),N&&(A.applyToMesh(N),N.getScene().onAfterRenderObservable.addOnce(()=>{if(!N.isDisposed()){const W=N.getBoundingInfo();S(W.boundingBox)}})),u.Tags.RemoveTagsFrom(N,"loading"),()=>{P(null),d(""),N&&new u.VertexData().applyToMesh(N)}}},[b]),m.useEffect(()=>{const N=T&&h.colorIDs[T]?h.colorIDs[T]:u.Color3.White();_(u.Color3.FromArray([N.r,N.g,N.b]))},[T,h.colorIDs]),m.useEffect(()=>{p.current&&(p.current.metadata={pickable:o?{name:f,onLeftClick:o.onLeftClick,onRightClick:o.onRightClick,onMiddleClick:o.onMiddleClick,onHover:o.onHover,needWorldPosition:o.needWorldPosition,extra:o.extra}:null})},[o,f]),C.jsx(C.Fragment,{children:C.jsxs("transformNode",{name:`transform-structurelayer-${f}`,position:k.add(n).multiplyByFloats(x&&x.scalePlane?x.scalePlane:1,x&&x.scaleDepth?x.scaleDepth:1,x&&x.scalePlane?x.scalePlane:1),scaling:new u.Vector3(x?x.scalePlane:1,x?x.scaleDepth:1,x?x.scalePlane:1),setEnabled:a,children:[C.jsx("transformNode",{name:`structurelayer-${f}-load`}),C.jsx("mesh",{name:`structurelayer-${f}-mesh`,ref:p,useVertexColors:i!=null,children:i?C.jsx(Mt,{name:`structurelayer-${f}-mat`,backFaceCulling:!1,alpha:t,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,colorCodec:i,needDepthPrePass:!0,counterLine:r,boundingBox:w,lines:l,scaleDepth:x?x.scaleDepth:1,scalePlane:x?x.scalePlane:1,text:s,disableDepthWrite:c}):C.jsx("standardMaterial",{name:`structurelayer-${f}-mat`,backFaceCulling:!1,specularColor:new u.Color3(0,0,0),ambientColor:new u.Color3(1,1,1),diffuseColor:v,needDepthPrePass:!0,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,alpha:t,disableDepthWrite:c})})]})})},Mu=e=>{const{id:t,visible:n=!0,position:a=u.Vector3.Zero(),diffuseTextureUrl:i,diffuseTextureSufaceUrl:o,bumpTextureUrl:r,mesh:l}=e,s=m.useRef(null),c=m.useContext(Le),[p,f]=m.useState(),[d,x]=m.useState(),[h,T]=m.useState();return m.useEffect(()=>{const P=s.current;if(P&&l){const v=new u.VertexData;v.positions=l.vertices,v.indices=l.indices,v.uvs=l.uv;const _=[];u.VertexData.ComputeNormals(l.vertices,l.indices,_),v.normals=_,v.applyToMesh(P)}},[l,l==null?void 0:l.indices,l==null?void 0:l.uv,l==null?void 0:l.vertices]),m.useEffect(()=>{const P=new u.Texture(i);if(P.uScale=500,P.vScale=.5,f(P),o){const _=new u.Texture(o);_.uScale=500,_.vScale=.5,x(_)}const v=new u.Texture(r);v.uScale=500,v.vScale=.5,T(v)},[r,o,i]),C.jsx(C.Fragment,{children:C.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 u.Vector3(c?c.scalePlane:1,c?c.scaleDepth:1,c?c.scalePlane:1),setEnabled:n,children:C.jsx("mesh",{name:"mesh",ref:s,children:C.jsx("standardMaterial",{name:`edge-${t}-material`,zOffset:-1,zOffsetUnits:-1,diffuseTexture:o?d:p,bumpTexture:o?void 0:h})})})})},oa=({url:e,visible:t=!0,filter:n,explodedView:a=0,showLayerLabel:i,labelStyle:o,offset:r=new u.Vector3(0,0,0),showTopLayerAsStructureLayer:l=!1,useColorCodecOnTopLayer:s=!1,colorCodec:c,actions:p,materials:f,topLayerCounterLine:d=void 0,topLayerHeightOffset:x=1,diffuseTextureUrl:h,diffuseTextureSufaceUrl:T,bumpTextureUrl:P,visibleEdgeEffect:v=!1})=>{var D,E;const[_,b]=m.useState(),k=m.useContext(Le),[M,w]=m.useState(!0),[S,N]=m.useState(""),F=je({url:e,cacheType:Me.URL_PREFIX_MATCH}),[B,I]=m.useState([]);return m.useEffect(()=>{console.log("[Geo3DViewer] ComplexFormationManager Loading: ",e)},[e]),m.useEffect(()=>{if(F){const L=kn.decode(new Uint8Array(F)),y=L.formations;if(L.mode==$o.FACE){w(!0),N(L.name);const A=[];y.forEach((V,$)=>{const W={name:V.name,topUrl:V.url,bottomUrl:y[$+1]?y[$+1].url:void 0};A.push(W)}),b(A)}else{w(!1),N(L.name);const A=[];y.forEach(V=>{const $={name:V.name,topUrl:V.url};A.push($)}),b(A)}return console.log(L),I(L.effectMeshs),()=>{b([])}}},[F]),C.jsxs("abstractMesh",{name:`complexformationmanager-${S}`,children:[l&&_&&_.length>1?C.jsx(Wo,{url:_[0].topUrl,alpha:(D=f==null?void 0:f[_[0].name])==null?void 0:D.alpha,position:new u.Vector3(0,x>=0?x*(k&&(E=k.scaleDepth)!=null?E:1):0,0).add(r),visible:t&&(n?n.includes(_[0].name):!0),colorCodec:c,counterLine:d},`${S}-${_[0].name}-SL`):null,_?_.map((L,y)=>M?l&&y===0?C.jsx(C.Fragment,{}):C.jsx("transformNode",{name:`${S}-${L.name}-EV`,position:r.add(new u.Vector3(0,y*(-1*a*(k&&k.scaleDepth?k.scaleDepth:0)),0)),children:C.jsx(Xn,{showLayerLabel:i,labelStyle:o,urlTopLayer:L.topUrl,urlBottomLayer:L.bottomUrl,visible:t&&(n?n.includes(L.name):!0),showBottomLayer:_[y+1]?n?n.includes(_[y+1].name):!0:!1,actions:p,material:y===0&&s?{...f==null?void 0:f[L.name],colorCodec:c,type:$e.COLOR_CODEC}:f==null?void 0:f[L.name]},`${S}-${L.name}`)},`${S}-${L.name}`):l&&y===0?C.jsx(C.Fragment,{}):C.jsx("transformNode",{name:`${S}-${L.name}-EV`,position:r.add(new u.Vector3(0,y*(-1*a*(k&&k.scaleDepth?k.scaleDepth:0)),0)),children:C.jsx(qn,{url:L.topUrl,showLayerLabel:i,labelStyle:o,visible:t&&(n?n.includes(L.name):!0),showBottomLayer:_[y+1]?n?n.includes(_[y+1].name):!0:!1,actions:p,material:f==null?void 0:f[L.name]},`${S}-${L.name}`)},`${S}-${L.name}`)):null,B&&h&&P&&a===0&&B.map((L,y)=>C.jsx(Mu,{visible:v,id:y,diffuseTextureUrl:h,diffuseTextureSufaceUrl:y===0?T:void 0,bumpTextureUrl:P,mesh:L},y))]})},ra=({visible:e=!0,color:t=u.Color3.White(),fontSize:n=80,step:a=200,keyFrameDistance:i=[],keyFrameStep:o=[],keyFrameFontSize:r=[],textureSizeX:l=512,textureSizeY:s=512,init:c=!0})=>{const p=_e.useScene(),f=m.useRef(null),d=m.useContext(Le),[x,h]=m.useState([]),[T,P]=m.useState([]),[v,_]=m.useState([]),[b,k]=m.useState(0),M=m.useCallback(w=>{if(p&&w){const S=new is.GridMaterial("axis-material",p);S.majorUnitFrequency=o.length>0?o[0]:50,S.minorUnitVisibility=0,S.gridRatio=2,S.sideOrientation=u.Material.ClockWiseSideOrientation,S.backFaceCulling=!0,S.mainColor=t,S.lineColor=t,S.opacity=.98,w.material=S}},[t,o,p]);return m.useEffect(()=>()=>{var w;(w=f.current)==null||w.dispose()},[]),m.useEffect(()=>{const w=()=>{const S=(p==null?void 0:p.activeCamera).radius;for(let N=0;N<i.length;N++)if(S<=i[N]){k(N);break}};return p&&p.activeCamera&&(p==null||p.activeCamera.onViewMatrixChangedObservable.add(w)),()=>{p&&p.activeCamera&&(p==null||p.activeCamera.onViewMatrixChangedObservable.removeCallback(w))}},[i,r,o,p,e]),m.useEffect(()=>{if(d&&d.min&&d.max&&c){const w=d.origin||u.Vector3.Zero(),S=[],N=[],F=[],B=[...o];B.length===0&&B.push(a);for(let I=0;I<B.length;I++){let D=B[I]/1;D<1&&(D=200);const E=[];for(let A=0;A<=d.max.x-d.min.x;A+=D)E.push({text:`${A+d.min.x+w.x}`,position:new u.Vector3(A,0,0)}),E.push({text:`${A+d.min.x+w.x}`,position:new u.Vector3(A,d.max.y-d.min.y,d.max.z-d.min.z)}),E.push({text:`${A+d.min.x+w.x}`,position:new u.Vector3(A,d.max.y-d.min.y,0)}),E.push({text:`${A+d.min.x+w.x}`,position:new u.Vector3(A,0,d.max.z-d.min.z)});S.push(E);const L=[];for(let A=0;A<=d.max.y-d.min.y;A+=D)L.push({text:`${A+d.min.y+w.y}`,position:new u.Vector3(0,A,0)}),L.push({text:`${A+d.min.y+w.y}`,position:new u.Vector3(d.max.x-d.min.x,A,d.max.z-d.min.z)}),L.push({text:`${A+d.min.y+w.y}`,position:new u.Vector3(d.max.x-d.min.x,A,0)}),L.push({text:`${A+d.min.y+w.y}`,position:new u.Vector3(0,A,d.max.z-d.min.z)});N.push(L);const y=[];for(let A=0;A<=d.max.z-d.min.z;A+=D)y.push({text:`${A+d.min.z+w.z}`,position:new u.Vector3(0,0,A)}),y.push({text:`${A+d.min.z+w.z}`,position:new u.Vector3(d.max.x-d.min.x,d.max.y-d.min.y,A)}),y.push({text:`${A+d.min.z+w.z}`,position:new u.Vector3(0,d.max.y-d.min.y,A)}),y.push({text:`${A+d.min.z+w.z}`,position:new u.Vector3(d.max.x-d.min.x,0,A)});F.push(y)}h(S),P(N),_(F)}},[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?C.jsxs("transformNode",{name:"coord",setEnabled:e,position:(d&&d.min&&d.max?u.Vector3.Center(d.min,d.max):u.Vector3.Zero()).multiply(Oe(d)),scaling:new u.Vector3(Oe(d).x,Oe(d).y,Oe(d).z),children:[C.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:M,isPickable:!1,isBlocker:!1},`axis-${d.max.x-d.min.x}-${d.max.y-d.min.y}-${d.max.z-d.min.z}`),C.jsxs("transformNode",{name:"axis-offset",position:d&&d.min&&d.max?new u.Vector3(-(d.max.x-d.min.x)/2,-(d.max.y-d.min.y)/2,-(d.max.z-d.min.z)/2):u.Vector3.Zero(),children:[x.map((w,S)=>w.map((N,F)=>{var I;const B=N;return C.jsx("transformNode",{name:`axis-x-${S}-${F}`,position:B==null?void 0:B.position,setEnabled:S===b,scaling:new u.Vector3(1/Oe(d).x,1/Oe(d).y,1/Oe(d).z),children:C.jsx(Je,{text:`${B?B.text:""}`,fontSize:(I=r[S])!=null?I:n,color:t.toHexString()})},`axis-x-${S}-${F}`)})),T.map((w,S)=>w.map((N,F)=>{var I;const B=N;return C.jsx("transformNode",{name:`axis-x-${S}-${F}`,position:B==null?void 0:B.position,setEnabled:S===b,scaling:new u.Vector3(1/Oe(d).x,1/Oe(d).y,1/Oe(d).z),children:C.jsx(Je,{text:`${B?B.text:""}`,fontSize:(I=r[S])!=null?I:n,color:t.toHexString()})},`axis-x-${S}-${F}`)})),v.map((w,S)=>w.map((N,F)=>{var I;const B=N;return C.jsx("transformNode",{name:`axis-x-${S}-${F}`,position:B==null?void 0:B.position,setEnabled:S===b,scaling:new u.Vector3(1/Oe(d).x,1/Oe(d).y,1/Oe(d).z),children:C.jsx(Je,{text:`${B?B.text:""}`,fontSize:(I=r[S])!=null?I:n,color:t.toHexString()})},`axis-x-${S}-${F}`)}))]})]},`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)}`):C.jsx(C.Fragment,{})};function Lu(e){switch(e){case 0:case"NORMAL":return 0;case 1:case"CICLE":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function Ru(e){switch(e){case 0:return"NORMAL";case 1:return"CICLE";case-1:default:return"UNRECOGNIZED"}}function jr(){return{name:"",lines:[]}}const ia={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.lines)fn.encode(n,t.uint32(18).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=jr();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 2:if(o!==18)break;i.lines.push(fn.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{name:ko(e.name)?globalThis.String(e.name):"",lines:globalThis.Array.isArray(e==null?void 0:e.lines)?e.lines.map(t=>fn.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=>fn.toJSON(a))),t},create(e){return ia.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=jr();return t.name=(n=e.name)!=null?n:"",t.lines=((a=e.lines)==null?void 0:a.map(i=>fn.fromPartial(i)))||[],t}};function ei(){return{positions:[]}}const un={encode(e,t=se.Writer.create()){for(const n of e.positions)rt.encode(n,t.uint32(10).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=ei();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.positions.push(rt.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{positions:globalThis.Array.isArray(e==null?void 0:e.positions)?e.positions.map(t=>rt.fromJSON(t)):[]}},toJSON(e){var n;const t={};return(n=e.positions)!=null&&n.length&&(t.positions=e.positions.map(a=>rt.toJSON(a))),t},create(e){return un.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=ei();return t.positions=((n=e.positions)==null?void 0:n.map(a=>rt.fromPartial(a)))||[],t}};function ti(){return{segments:[],type:0,position:void 0}}const fn={encode(e,t=se.Writer.create()){for(const n of e.segments)un.encode(n,t.uint32(10).fork()).ldelim();return e.type!==0&&t.uint32(16).int32(e.type),e.position!==void 0&&rt.encode(e.position,t.uint32(26).fork()).ldelim(),t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=ti();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.segments.push(un.decode(n,n.uint32()));continue;case 2:if(o!==16)break;i.type=n.int32();continue;case 3:if(o!==26)break;i.position=rt.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{segments:globalThis.Array.isArray(e==null?void 0:e.segments)?e.segments.map(t=>un.fromJSON(t)):[],type:ko(e.type)?Lu(e.type):0,position:ko(e.position)?rt.fromJSON(e.position):void 0}},toJSON(e){var n;const t={};return(n=e.segments)!=null&&n.length&&(t.segments=e.segments.map(a=>un.toJSON(a))),e.type!==0&&(t.type=Ru(e.type)),e.position!==void 0&&(t.position=rt.toJSON(e.position)),t},create(e){return fn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=ti();return t.segments=((n=e.segments)==null?void 0:n.map(i=>un.fromPartial(i)))||[],t.type=(a=e.type)!=null?a:0,t.position=e.position!==void 0&&e.position!==null?rt.fromPartial(e.position):void 0,t}};function ko(e){return e!=null}const Uo=({points:e=[],showPoint:t=!0,color:n=u.Color3.White(),pointSize:a=2,alwaysOnTop:i=!1,offset:o=u.Vector3.Zero(),alpha:r,lineWidth:l})=>{const s=_e.useScene(),c=m.useRef(null),p=m.useContext(Le);return m.useEffect(()=>{if(s){const f=[],d=Oe(p);if(e.forEach(x=>{f.push(x.add(o).multiply(d))}),l){const x={path:f,radius:l,updatable:!0};if(c.current)x.instance=c.current,u.MeshBuilder.CreateTube("line",x);else{c.current=u.MeshBuilder.CreateTube("line",x,s);const h=new u.StandardMaterial("line-mat");return h.diffuseColor=n,h.specularColor=u.Color3.Black(),h.emissiveColor=n,r!==void 0&&(h.alpha=r,h.transparencyMode=2),h.depthFunction=i?u.Constants.ALWAYS:0,c.current.material=h,()=>{c.current&&(s.removeMesh(c.current),c.current=null)}}}else{const x={points:f,updateable:!0};if(c.current)x.instance=c.current,u.MeshBuilder.CreateLines("line",x);else{c.current=u.MeshBuilder.CreateLines("line",x,s);const h=new u.StandardMaterial("line-mat");return h.diffuseColor=n,h.specularColor=u.Color3.Black(),h.emissiveColor=n,r!==void 0&&(h.alpha=r,h.transparencyMode=2),h.depthFunction=i?u.Constants.ALWAYS:0,()=>{c.current&&(s.removeMesh(c.current),c.current=null)}}}}},[i,n,p,o,e,s,l,c,r]),C.jsx("transformNode",{name:"transform-line",children:t?C.jsx("transformNode",{name:"lines-point",children:e.map((f,d)=>C.jsx("sphere",{diameter:a,name:`lines-point-${d}`,position:f.add(o).multiply(Oe(p)),scalingDeterminant:l&&(p==null?void 0:p.scalePlane)||1,children:C.jsx("standardMaterial",{name:`lines-point-${d}-mat`,diffuseColor:n,emissiveColor:n,specularColor:u.Color3.White(),depthFunction:i?u.Constants.ALWAYS:void 0})},`lines-point-${f.x}-${f.y}-${f.z}`))}):C.jsx(C.Fragment,{})})},Bu=e=>{const{name:t,prev:n,next:a,textColor:i,fontSize:o}=e,r=_e.useScene(),l=m.useRef(null);return m.useEffect(()=>{const s=r==null?void 0:r.activeCamera,c=r==null?void 0:r.getEngine();if(r&&s&&c&&l.current){const p=l.current.getChildren()[0],f=u.Vector3.Normalize(a.subtract(n)),d=new u.Vector3(1,0,0),x=Math.acos(u.Vector3.Dot(f,d)),h=u.Vector3.Cross(f,d);p.rotation.z=h.y>0?x:Math.PI*2-x,p.rotation.x=Math.PI/2,p.renderingGroupId=3}},[a,n,r]),C.jsx("transformNode",{name:`${t}`,position:u.Vector3.Lerp(n,a,.5),ref:l,children:C.jsx(Je,{text:t,fontSize:o,color:i,billboardMode:u.Mesh.BILLBOARDMODE_NONE})})},Fu=e=>{const{url:t,color:n,alpha:a,visible:i=!0,fontSize:o=30,textColor:r="red",linewidth:l=10}=e,s=_e.useScene(),[c,p]=m.useState([]),[f,d]=m.useState([]),x=m.useContext(Le);return m.useEffect(()=>{Ut.get(t,{responseType:"arraybuffer"}).then(h=>{const T=ia.decode(new Uint8Array(h.data));console.log(T);const P=[],v=[];for(let _=0;_<T.lines.length;_++){const b=T.lines[_];if(b.segments.length<2)continue;const k=[];for(let M=0;M<b.segments.length;M++){const w=[...Ps(b.segments[M].positions)];P.push([...w]),k.push(w[0]),k.push(w[w.length-1])}b.type===1&&k.push(Oi(b.segments[0].positions[0])),v.push(k)}p(P),d(v),console.log(v),console.log(P)})},[s,t]),C.jsxs("transformNode",{name:"contourline",setEnabled:i,children:[c.map((h,T)=>h.length<2||!i?null:C.jsx(Uo,{points:h,showPoint:!1,color:n,alpha:a,lineWidth:l,alwaysOnTop:!0},T)),f.map(h=>h.map((T,P)=>P%2===0||P===h.length-1?null:C.jsx(Bu,{name:T.y.toFixed(0),prev:Oe(x).multiply(T),next:Oe(x).multiply(h[P+1]),fontSize:o,textColor:r},P)))]})};function Du(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 zu(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 ni(){return{layer:0,direction:0,colorId:0,points:[],indices:[],value:[],vMin:0,vMax:0,center:void 0}}const Ho={encode(e,t=se.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&&K.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=ni();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==8)break;i.layer=n.uint32();continue;case 2:if(o!==16)break;i.direction=n.int32();continue;case 3:if(o!==24)break;i.colorId=n.uint32();continue;case 21:if(o===173){i.points.push(n.float());continue}if(o===170){const r=n.uint32()+n.pos;for(;n.pos<r;)i.points.push(n.float());continue}break;case 22:if(o===176){i.indices.push(n.uint32());continue}if(o===178){const r=n.uint32()+n.pos;for(;n.pos<r;)i.indices.push(n.uint32());continue}break;case 23:if(o===189){i.value.push(n.float());continue}if(o===186){const r=n.uint32()+n.pos;for(;n.pos<r;)i.value.push(n.float());continue}break;case 25:if(o!==205)break;i.vMin=n.float();continue;case 26:if(o!==213)break;i.vMax=n.float();continue;case 31:if(o!==250)break;i.center=K.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{layer:tn(e.layer)?globalThis.Number(e.layer):0,direction:tn(e.direction)?Du(e.direction):0,colorId:tn(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:tn(e.vMin)?globalThis.Number(e.vMin):0,vMax:tn(e.vMax)?globalThis.Number(e.vMax):0,center:tn(e.center)?K.fromJSON(e.center):void 0}},toJSON(e){var n,a,i;const t={};return e.layer!==0&&(t.layer=Math.round(e.layer)),e.direction!==0&&(t.direction=zu(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))),(i=e.value)!=null&&i.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=K.toJSON(e.center)),t},create(e){return Ho.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i,o,r,l,s,c;const t=ni();return t.layer=(n=e.layer)!=null?n:0,t.direction=(a=e.direction)!=null?a:0,t.colorId=(i=e.colorId)!=null?i:0,t.points=((o=e.points)==null?void 0:o.map(p=>p))||[],t.indices=((r=e.indices)==null?void 0:r.map(p=>p))||[],t.value=((l=e.value)==null?void 0:l.map(p=>p))||[],t.vMin=(s=e.vMin)!=null?s:0,t.vMax=(c=e.vMax)!=null?c:0,t.center=e.center!==void 0&&e.center!==null?K.fromPartial(e.center):void 0,t}};function tn(e){return e!=null}const Zo=({name:e,url:t,visible:n=!0,colorCodec:a,alpha:i=1,position:o=u.Vector3.Zero(),actions:r})=>{const l=m.useRef(null),[s,c]=m.useState(""),[p,f]=m.useState(""),d=m.useContext(Le),x=je({url:t,cacheType:Me.URL_PREFIX_MATCH}),[h,T]=m.useState(u.Vector3.Zero());return m.useEffect(()=>{const P=l.current;if(!x||!P)return;u.Tags.EnableFor(P),u.Tags.AddTagsTo(P,"loading");const v=Ho.decode(new Uint8Array(x)),{layer:_,direction:b,points:k,indices:M,value:w,center:S}=v,N=new u.VertexData;N.positions=k,N.indices=M,N.colors=w;const F=[];u.VertexData.ComputeNormals(k,M,F),N.normals=F,S&&T(new u.Vector3(S.x,S.y,S.z)),N.applyToMesh(P),c(_.toString()),f(b.toString()),u.Tags.RemoveTagsFrom(P,"loading")},[x]),m.useEffect(()=>{l.current&&(l.current.metadata={pickable:r?{name:e,onLeftClick:r.onLeftClick,onRightClick:r.onRightClick,onMiddleClick:r.onMiddleClick,onHover:r.onHover,needWorldPosition:r.needWorldPosition,extra:r.extra}:null})},[r,e]),m.useEffect(()=>{console.log("[Geo3DViewer] DensitySlice Loading: ",t)},[t]),C.jsx(C.Fragment,{children:C.jsx("transformNode",{name:`densityslice-${e}-${p}-${s}-transform`,position:h.add(o).multiplyByFloats(d&&d.scalePlane?d.scalePlane:1,d&&d.scaleDepth?d.scaleDepth:1,d&&d.scalePlane?d.scalePlane:1),scaling:new u.Vector3(d?d.scalePlane:1,d?d.scaleDepth:1,d?d.scalePlane:1),children:C.jsx("mesh",{name:`densityslice-${e}-${p}-${s}-mesh`,ref:l,setEnabled:n,useVertexColors:!0,children:C.jsx(Mt,{name:`densityslice-${e}-${p}-${s}-mat`,backFaceCulling:!1,needDepthPrePass:!0,alpha:i,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,colorCodec:a})})})})},aa=()=>{const e=_e.useScene(),t=m.useRef(void 0);return m.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]),m.useEffect(()=>{var n,a;if(e&&!t.current){const i=nt.AdvancedDynamicTexture.CreateFullscreenUI("UI",!0,e);t.current=i;const o=new nt.TextBlock("fps");o.text="0FPS",o.color="white",o.fontSize=15,o.width=100,o.height=50;const r=window.devicePixelRatio||1,l=(n=e.getEngine().getRenderingCanvas())==null?void 0:n.clientHeight,s=(a=e.getEngine().getRenderingCanvas())==null?void 0:a.clientWidth;o.left=s?-(s*r/2-50):0,o.top=l?-(l*r/2-25):0,i.addControl(o)}return()=>{e&&t.current}},[e]),null},sa=({url:e,visible:t=!0,filter:n,explodedView:a=0,offset:i=new u.Vector3(0,0,0),showLayerLabel:o,labelStyle:r,actions:l,materials:s})=>{const[c,p]=m.useState(),f=m.useContext(Le),[d,x]=m.useState(!0),[h,T]=m.useState(""),P=je({url:e,cacheType:Me.URL_PREFIX_MATCH});return m.useEffect(()=>{console.log("[Geo3DViewer] FormationManager Loading: ",e)},[e]),m.useEffect(()=>{if(P){const v=kn.decode(new Uint8Array(P)),_=v.formations;if(v.mode==$o.FACE){x(!0),T(v.name);const b=[];_.forEach((k,M)=>{const w={name:k.name,topUrl:k.url,bottomUrl:_[M+1]?_[M+1].url:void 0};b.push(w)}),p(b)}else{x(!1),T(v.name);const b=[];_.forEach(k=>{const M={name:k.name,topUrl:k.url};b.push(M)}),p(b)}return console.log(_),()=>{T(""),p([])}}},[P]),C.jsx("abstractMesh",{name:`formationmanager-${h}`,children:c?c.map((v,_)=>d?C.jsx("transformNode",{name:`${h}-${v.name}-EV`,position:i.add(new u.Vector3(0,_*(-1*a*(f&&f.scaleDepth?f.scaleDepth:0)),0)),children:C.jsx(Xn,{showLayerLabel:o,labelStyle:r,urlTopLayer:v.topUrl,urlBottomLayer:v.bottomUrl,visible:t&&(n?n.includes(v.name):!0),showBottomLayer:c[_+1]?n?n.includes(c[_+1].name):!0:!1,actions:l,material:s==null?void 0:s[v.name]},`${h}-${v.name}`)},`${h}-${v.name}`):C.jsx("transformNode",{name:`${h}-${v.name}-EV`,position:i.add(new u.Vector3(0,_*(-1*a*(f&&f.scaleDepth?f.scaleDepth:0)),0)),children:C.jsx(qn,{url:v.topUrl,showLayerLabel:o,labelStyle:r,visible:t&&(n?n.includes(v.name):!0),showBottomLayer:c[_+1]?n?n.includes(c[_+1].name):!0:!1,actions:l,material:s==null?void 0:s[v.name]},`${h}-${v.name}`)},`${h}-${v.name}`)):null})};function oi(){return{name:"",slices:[],center:void 0}}const Go={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.slices)dn.encode(n,t.uint32(18).fork()).ldelim();return e.center!==void 0&&K.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=oi();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 2:if(o!==18)break;i.slices.push(dn.decode(n,n.uint32()));continue;case 31:if(o!==250)break;i.center=K.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{name:zn(e.name)?globalThis.String(e.name):"",slices:globalThis.Array.isArray(e==null?void 0:e.slices)?e.slices.map(t=>dn.fromJSON(t)):[],center:zn(e.center)?K.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=>dn.toJSON(a))),e.center!==void 0&&(t.center=K.toJSON(e.center)),t},create(e){return Go.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=oi();return t.name=(n=e.name)!=null?n:"",t.slices=((a=e.slices)==null?void 0:a.map(i=>dn.fromPartial(i)))||[],t.center=e.center!==void 0&&e.center!==null?K.fromPartial(e.center):void 0,t}};function ri(){return{name:"",colorId:0,vertices:[],indices:[],edges:[]}}const dn={encode(e,t=se.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)K.encode(n,t.uint32(42).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=ri();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 2:if(o!==16)break;i.colorId=n.uint32();continue;case 3:if(o===29){i.vertices.push(n.float());continue}if(o===26){const r=n.uint32()+n.pos;for(;n.pos<r;)i.vertices.push(n.float());continue}break;case 4:if(o===32){i.indices.push(n.uint32());continue}if(o===34){const r=n.uint32()+n.pos;for(;n.pos<r;)i.indices.push(n.uint32());continue}break;case 5:if(o!==42)break;i.edges.push(K.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{name:zn(e.name)?globalThis.String(e.name):"",colorId:zn(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=>K.fromJSON(t)):[]}},toJSON(e){var n,a,i;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))),(i=e.edges)!=null&&i.length&&(t.edges=e.edges.map(o=>K.toJSON(o))),t},create(e){return dn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i,o,r;const t=ri();return t.name=(n=e.name)!=null?n:"",t.colorId=(a=e.colorId)!=null?a:0,t.vertices=((i=e.vertices)==null?void 0:i.map(l=>l))||[],t.indices=((o=e.indices)==null?void 0:o.map(l=>l))||[],t.edges=((r=e.edges)==null?void 0:r.map(l=>K.fromPartial(l)))||[],t}};function zn(e){return e!=null}const Vu=(e,t)=>{var y,A,V,$;const n=_e.useScene(),a=m.useRef(null),i=m.useRef(null),o=m.useContext(Le),r=m.useContext(Lt),[l,s]=m.useState(u.Color3.White()),{id:c,visible:p=!0,vertices:f,indices:d,colorId:x,position:h,normals:T,material:P={type:$e.COLOR_ID},children:v,alpha:_=1,style:b,name:k="formation",highStyle:M,lowStyle:w,edges:S=[],actions:N,actionName:F}=e,B=He({url:P==null?void 0:P.texture,cacheType:Me.URL_PREFIX_MATCH}),I=He({url:P==null?void 0:P.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),[D,E]=m.useState();m.useImperativeHandle(t,()=>i.current,[]),m.useEffect(()=>{if(a&&a.current&&n){const W=new u.VertexData;W.positions=f,W.indices=d,W.normals=T;const ne=a.current;W.applyToMesh(ne),ne.getScene().onAfterRenderObservable.addOnce(()=>{if(!ne.isDisposed()){const G=ne.getBoundingInfo();E(G.boundingBox)}})}},[d,f,n,c,T]),m.useEffect(()=>{a.current&&(a.current.metadata={pickable:N?{name:F!=null?F:k,onLeftClick:N.onLeftClick,onRightClick:N.onRightClick,onMiddleClick:N.onMiddleClick,onHover:N.onHover,extra:N.extra,needWorldPosition:N.needWorldPosition}:null})},[F,N,k]),m.useEffect(()=>{var W;s(P.type===$e.ONE_COLOR?(W=P==null?void 0:P.color)!=null?W:u.Color3.Random():x&&r.colorIDs[x]?new u.Color3(r.colorIDs[x].r,r.colorIDs[x].g,r.colorIDs[x].b):u.Color3.Random())},[r.colorIDs,x,P==null?void 0:P.color,P.type]);const L=(W,ne,ee)=>{const G=ne.subtract(W),le=1+1e3/u.Vector3.Distance(W,ne)*(ee-1),re=G.scale(le);return W.add(re)};return C.jsxs("transformNode",{name:`node-${k}-${c}`,setEnabled:p,children:[C.jsxs("transformNode",{name:`${k}`,position:h?h.multiply(Oe(o)):new u.Vector3(0,0,0),scaling:Oe(o),ref:i,children:[C.jsx("mesh",{name:`${k}-mesh`,ref:a,children:P.type===$e.TEXTURE?B?C.jsx(Kt,{name:`formationslice-${k}-mat`,backFaceCulling:!1,needDepthPrePass:P.needDepthPrePass===void 0?!1:P.needDepthPrePass,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,alpha:_,sideTexture:I,texture:B,tilingFactor:P.tilingFactor,sideTilingFactor:(y=P==null?void 0:P.sideTilingFactor)!=null?y:P==null?void 0:P.tilingFactor,mode:P.textureMode===void 0?qt.PLANE:P.textureMode,boundingBox:D,lines:P.lines,text:P.text,scaleDepth:o?o.scaleDepth:1,scalePlane:o?o.scalePlane:1,disableDepthWrite:P.disableDepthWrite}):C.jsx(C.Fragment,{}):P.type===$e.COLOR_CODEC?P.colorCodec?C.jsx(Mt,{name:`formation-${k}-mat`,backFaceCulling:!1,needDepthPrePass:P.needDepthPrePass===void 0?!1:P.needDepthPrePass,alpha:_,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,colorCodec:P.colorCodec,boundingBox:D,lines:P.lines,text:P.text,scaleDepth:o?o.scaleDepth:1,scalePlane:o?o.scalePlane:1,disableDepthWrite:P.disableDepthWrite}):C.jsx(C.Fragment,{}):P.type===$e.COLOR_ID?C.jsx("standardMaterial",{name:`formation-${k}-mat`,backFaceCulling:!1,needDepthPrePass:P.needDepthPrePass===void 0?!1:P.needDepthPrePass,specularColor:new u.Color3(0,0,0),ambientColor:new u.Color3(1,1,1),diffuseColor:l,alphaMode:u.Engine.ALPHA_COMBINE,alpha:_,transparencyMode:u.Material.MATERIAL_ALPHABLEND,disableDepthWrite:P.disableDepthWrite}):C.jsx("standardMaterial",{name:`formation-${k}-mat`,backFaceCulling:!1,needDepthPrePass:P.needDepthPrePass===void 0?!1:P.needDepthPrePass,specularColor:new u.Color3(0,0,0),ambientColor:new u.Color3(1,1,1),diffuseColor:l,alphaMode:u.Engine.ALPHA_COMBINE,alpha:_,transparencyMode:u.Material.MATERIAL_ALPHABLEND,disableDepthWrite:P.disableDepthWrite})}),b.position&&C.jsx("transformNode",{name:`${k}-title`,position:L(At(b.basePosition==="left"?S[4]:S[5]),b.position,(A=b.offset)!=null?A:1),scaling:ct(o),children:b.title&&C.jsx(Je,{text:b.title,fontSize:b.fontSize?b.fontSize:40,color:b.color?b.color:"black"})}),w&&w.position&&C.jsx("transformNode",{name:`${k}-up-title`,position:L(At(w.basePosition==="left"?S[4]:S[5]),w.position,(V=w.offset)!=null?V:1),scaling:ct(o),children:w.title&&C.jsx(Je,{text:w.title,fontSize:w.fontSize?w.fontSize:40,color:w.color?w.color:"black"})}),M&&M.position&&C.jsx("transformNode",{name:`${k}-down-title`,position:L(At(M.basePosition==="left"?S[4]:S[5]),M.position,($=M.offset)!=null?$:1),scaling:ct(o),children:M.title&&C.jsx(Je,{text:M.title,fontSize:M.fontSize?M.fontSize:40,color:M.color?M.color:"black"})})]}),v]})},$u=m.forwardRef(Vu),Yo=e=>{const[t,n]=m.useState([]),[a,i]=m.useState(""),{url:o,visible:r=!0,materials:l,actions:s,style:c,highStyle:p,lowStyle:f,basePosition:d="left"}=e,x=m.useContext(Le),h=je({url:o,cacheType:Me.URL_PREFIX_MATCH}),[T,P]=m.useState(u.Vector3.Zero());return m.useEffect(()=>{console.log("[Geo3DViewer] FormationSlice Loading: ",o)},[o]),m.useEffect(()=>{if(h){const v=Go.decode(new Uint8Array(h));v.center&&P(new u.Vector3(v.center.x,v.center.y,v.center.z));const _=v.slices.map(b=>{const k=[];return u.VertexData.ComputeNormals(b.vertices,b.indices,k),{name:b.name,colorId:b.colorId,vertices:b.vertices,indices:b.indices,edges:b.edges,normals:k}});return i(v.name),n(_),()=>{i(""),n([])}}},[h]),C.jsx(C.Fragment,{children:C.jsx("transformNode",{name:`foramtionslice-${a}-holder`,setEnabled:r,position:T.multiply(Oe(x)),children:t.map((v,_)=>{const b=v.edges.length>0?At(d==="left"?v.edges[0]:v.edges[2]):new u.Vector3(0,0,0),k=v.edges.length>0?At(d==="left"?v.edges[1]:v.edges[3]):new u.Vector3(0,0,0),M=u.Vector3.Lerp(b,k,.5);return C.jsx($u,{id:_,vertices:v.vertices,indices:v.indices,colorId:v.colorId,normals:v.normals,name:v.name,edges:v.edges,style:c?{position:M,title:v.name,basePosition:d,...c}:{},lowStyle:f?{position:k,title:(T.y+k.y).toFixed(0).toString(),basePosition:d,...f}:{},highStyle:p&&_===t.length-1?{position:b,title:(T.y+b.y).toFixed(0).toString(),basePosition:d,...p}:{},material:l?{...l[v.name],backFaceCulling:!1}:void 0,actions:s,actionName:a},_)})})})},Wu=e=>{const{name:t="node",text:n,fontSize:a,color:i,position:o=u.Vector3.Zero(),scale:r=u.Vector3.One(),blink:l=!1}=e,[s,c]=m.useState(!0);return m.useEffect(()=>{const p=setInterval(()=>{l&&c(f=>!f)},1e3);return()=>{clearInterval(p)}},[l]),C.jsx("transformNode",{name:`${t}-text`,position:o,scaling:r,setEnabled:s,children:C.jsx(Je,{name:t,text:n,fontSize:a,color:i})})};var Bt=(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))(Bt||{});const la=({target:e,radius:t,alpha:n,beta:a,axesViewerOffset:i=u.Vector3.Zero(),panningSensibility:o=2,wheelDeltaPercentage:r=0,axesViewer:l=0,farPlane:s=1e4,skipPickingWhenCameraMoves:c=!1})=>{const p=_e.useScene(),f=m.useContext(Le),[d,x]=m.useState(null),[h,T]=m.useState(null),[P,v]=m.useState(n),[_,b]=m.useState(a),[,k]=m.useState(null),M=m.useCallback(B=>{T(B)},[]),{setViewCamera:w}=m.useContext(Oo),S=m.useCallback(()=>{if(h&&d){const B=new u.Vector3;B.addInPlace(h.position),B.addInPlace(h.getDirection(new u.Vector3(0,0,25))),l==4?(B.addInPlace(h.getDirection(new u.Vector3(0,7+i.y,0))),B.addInPlace(h.getDirection(new u.Vector3(15+i.x,0,0)))):l==3?(B.addInPlace(h.getDirection(new u.Vector3(0,7+i.y,0))),B.addInPlace(h.getDirection(new u.Vector3(-15+i.x,0,0)))):l==2?(B.addInPlace(h.getDirection(new u.Vector3(0,-7+i.y,0))),B.addInPlace(h.getDirection(new u.Vector3(15+i.x,0,0)))):l==1&&(B.addInPlace(h.getDirection(new u.Vector3(0,-7+i.y,0))),B.addInPlace(h.getDirection(new u.Vector3(-15+i.x,0,0)))),d.xAxis.position=B.clone(),d.yAxis.position=B.clone(),d.zAxis.position=B.clone()}},[h,d,l,i.y,i.x]);m.useEffect(()=>{if(p&&l!=0){const B=new u.AxesViewer(p,2,null);return x(B),()=>{B==null||B.dispose(),x(null)}}},[p,l]),m.useEffect(()=>{S()},[S]);const N=m.useCallback(B=>{if(f&&f.min&&f.max)return u.Vector3.Clamp(B,f==null?void 0:f.min,f==null?void 0:f.max)},[f]),F=m.useCallback(B=>{p&&(p.skipPointerMovePicking=B)},[p]);return m.useEffect(()=>{if(!p||!h)return;const B=h.onViewMatrixChangedObservable.add(()=>{c&&(F(!0),k(I=>(I&&clearTimeout(I),setTimeout(()=>{F(!1),k(null)},250)))),v(h.alpha),b(h.beta),S()});return()=>{h.onViewMatrixChangedObservable.remove(B),k(I=>(I&&clearTimeout(I),null)),F(!1)}},[p,l,h,f,d,S,N,F,c]),m.useEffect(()=>{w(p&&h?h:void 0)},[p,h,w]),m.useEffect(()=>{},[N,f,e]),C.jsx(C.Fragment,{children:e&&C.jsx("arcRotateCamera",{name:"rootCamera",target:e,radius:t,alpha:P,beta:_,maxZ:s,panningSensibility:o,wheelDeltaPercentage:r,ref:M,setActiveOnSceneIfNoneActive:!0})})},Uu=(e,t)=>{const{position:n=u.Vector3.Zero(),axesViewer:a=Bt.NONE,axesViewerOffset:i=u.Vector3.Zero(),skipPickingWhenCameraMoves:o=!1,wheelDeltaPercentage:r=3,rotationSensibility:l=1,panningSensibility:s=10}=e,c=_e.useScene(),p=m.useContext(Le),[f,d]=m.useState(null),[x,h]=m.useState(null),{setViewCamera:T,cameraRefObject:P}=m.useContext(Oo),[,v]=m.useState(null),_=m.useRef(null),[b,k]=m.useState(null),M=m.useRef(null),w=m.useCallback(I=>{c&&(c.skipPointerMovePicking=I)},[c]);m.useEffect(()=>(M.current=new u.ArcRotateCamera("dummy-camera",0,0,.1,u.Vector3.Zero(),c||void 0,!1),()=>{var I;(I=M.current)==null||I.dispose()}),[c]),m.useEffect(()=>{if(c){const I=x,D=c.onPointerObservable.add(E=>{if(E.type===u.PointerEventTypes.POINTERDOWN&&(_.current=new u.Vector2(E.event.clientX,E.event.clientY)),E.type===u.PointerEventTypes.POINTERUP&&(_.current=null),E.type===u.PointerEventTypes.POINTERMOVE&&_.current){const L=E.event.clientX-_.current.x,y=E.event.clientY-_.current.y;if(E.event.buttons===1){let A=null;(I.lockedTarget||b)&&(I.lockedTarget&&(A=I.lockedTarget.position),b&&(A=b)),A&&M.current?(M.current.target=A,M.current.position=I.position.clone(),M.current.wheelDeltaPercentage=r,M.current.panningSensibility=s,M.current.alpha+=L/100*l,M.current.beta+=y/100*l,M.current.update(),I.position=M.current.position.clone(),I.rotation=M.current.rotation.clone()):(I.rotation.y-=L/100*l,I.rotation.x-=y/100*l)}E.event.buttons===2&&(I.position.x-=L/100*s,I.position.y+=y/100*s),_.current=new u.Vector2(E.event.clientX,E.event.clientY)}});return()=>{c.onPointerObservable.remove(D)}}},[b,s,x,l,c,r]);const S=m.useCallback(I=>{I&&(I.inputs.addMouseWheel(),I.inputs.removeMouse(),T(I),h(I))},[T]);m.useEffect(()=>{if(x){const I=x.inputs.attached.mousewheel;I.wheelPrecisionX=r,I.wheelPrecisionY=r,I.wheelPrecisionZ=r}},[x,r]);const N=m.useCallback(()=>{if(x&&f){const I=new u.Vector3;I.addInPlace(x.position),I.addInPlace(x.getDirection(new u.Vector3(0,0,25))),a==Bt.TOP_RIGHT?(I.addInPlace(x.getDirection(new u.Vector3(0,7+i.y,0))),I.addInPlace(x.getDirection(new u.Vector3(15+i.x,0,0)))):a==Bt.TOP_LEFT?(I.addInPlace(x.getDirection(new u.Vector3(0,7+i.y,0))),I.addInPlace(x.getDirection(new u.Vector3(-15+i.x,0,0)))):a==Bt.BOTTOM_RIGHT?(I.addInPlace(x.getDirection(new u.Vector3(0,-7+i.y,0))),I.addInPlace(x.getDirection(new u.Vector3(15+i.x,0,0)))):a==Bt.BOTTOM_LEFT&&(I.addInPlace(x.getDirection(new u.Vector3(0,-7+i.y,0))),I.addInPlace(x.getDirection(new u.Vector3(-15+i.x,0,0)))),f.xAxis.position=I.clone(),f.yAxis.position=I.clone(),f.zAxis.position=I.clone()}},[x,f,a,i.y,i.x]);m.useEffect(()=>{if(c&&a!=Bt.NONE){const I=new u.AxesViewer(c,2,null);return d(I),()=>{I==null||I.dispose(),d(null)}}},[c,a]),m.useEffect(()=>{N()},[N]),m.useEffect(()=>{T(c&&x?x:void 0)},[c,x,T]),m.useEffect(()=>{if(!c||!x)return;const I=x.onViewMatrixChangedObservable.add(()=>{o&&(w(!0),v(D=>(D&&clearTimeout(D),setTimeout(()=>{w(!1),v(null)},250)))),N()});return()=>{x.onViewMatrixChangedObservable.remove(I),v(D=>(D&&clearTimeout(D),null)),w(!1)}},[c,a,x,p,f,N,o,w]);const[F,B]=m.useState();return m.useEffect(()=>{if(x){const I={lookAt:D=>{x&&x.setTarget(D)},updatePosition:D=>{x&&(x.position=D)},lockTarget:D=>{x&&(k(null),x.lockedTarget=D)},lockTo:D=>{x&&(x.lockedTarget=null,k(D))}};B(I),P&&P.current&&(P.current.rawCamera=x,P.current.cameraTools=I)}},[P,x]),m.useImperativeHandle(t,()=>({rawCamera:x,cameraTools:F}),[F,x]),C.jsx("universalCamera",{name:"universal-main-camera",position:n,ref:S,maxZ:0})},Hu=m.forwardRef(Uu);class Zu extends u.BaseCameraPointersInput{constructor(){super(...arguments);ve(this,"camera");ve(this,"buttons",[0,1,2,4]);ve(this,"panningSensibility",10);ve(this,"angularSensibility",1e4);ve(this,"_isPanClick",!1);ve(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,i){if(this.panningSensibility!==0&&this._isPanClick){const o=-a/this.panningSensibility,r=i/this.panningSensibility;this.camera._localDirection.copyFromFloats(o,r,0),this.camera.getViewMatrix().invertToRef(this.camera._cameraTransformMatrix),u.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=u.Quaternion.FromEulerAngles(this.camera.rotation.x,this.camera.rotation.y,this.camera.rotation.z),r=u.Quaternion.RotationAxis(u.Axis.Y,u.Tools.ToDegrees(a/this.angularSensibility)),l=u.Quaternion.RotationAxis(u.Axis.X,u.Tools.ToDegrees(i/this.angularSensibility)),s=o.multiply(r).multiply(l);this.camera.rotation=s.toEulerAngles()}}onLostFocus(){this._isPanClick=!1,this._isPinching=!1}}const Gu=e=>{const{position:t,target:n=new u.Vector3(0,0,0),panningSensibility:a=5,angularSensibility:i=2e3,skipPickingWhenCameraMoves:o=!1}=e,r=_e.useScene(),l=m.useRef(null),s=m.useRef(null),c=m.useCallback(p=>{r&&(r.skipPointerMovePicking=p)},[r]);return m.useEffect(()=>{if(l.current){l.current.inputs.removeByType("FreeCameraMouseInput");const p=new Zu,f=new u.FreeCameraMouseWheelInput;l.current.inputs.add(p),l.current.inputs.add(f)}},[]),m.useEffect(()=>{l.current&&n&&l.current.setTarget(n)},[n]),m.useEffect(()=>{if(!r||!l.current)return;const p=l.current.onViewMatrixChangedObservable.add(()=>{o&&(c(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{c(!1),s.current=null},250))});return()=>{var f;(f=l.current)==null||f.onViewMatrixChangedObservable.remove(p),s.current&&(clearTimeout(s.current),s.current=null),c(!1)}},[r,c,o]),m.useEffect(()=>{if(l.current){if(l.current.inputs.attached.pointers){const p=l.current.inputs.attached.pointers;p.panningSensibility=Math.abs(a),p.angularSensibility=Math.abs(i)}if(l.current.inputs.attached.pointersPanning){const p=l.current.inputs.attached.pointersPanning;p.panningSensibility=Math.abs(a)}if(l.current.inputs.attached.around){const p=l.current.inputs.attached.around;p.angularSensibility=Math.abs(i)}}},[i,a]),C.jsx("freeCamera",{name:"rootCamera",position:t,ref:l})};class Yu extends u.TransformNode{constructor(n,a,i){super(n,a);ve(this,"_showDepthTexture",!1);ve(this,"_postProcess");this._postProcess=i,this.showDepthTexture=!1,this.inspectableCustomProperties=[{label:"Show Depth Texture",propertyName:"showDepthTexture",type:u.InspectableType.Checkbox}]}set showDepthTexture(n){var a,i;this._showDepthTexture=n,this._postProcess&&(this._showDepthTexture?(a=this.getScene().activeCamera)==null||a.attachPostProcess(this._postProcess):(i=this.getScene().activeCamera)==null||i.detachPostProcess(this._postProcess))}get showDepthTexture(){return this._showDepthTexture}}const Ju=()=>{const e=_e.useEngine(),t=_e.useScene();return m.useEffect(()=>{if(t&&e){u.Effect.ShadersStore.depthbufferPixelShader=`#ifdef GL_ES
1211
+ }`,Yn=({alpha:e,zOffset:t,zOffsetUnits:n,disableDepthWrite:a})=>C.jsx("pbrMaterial",{name:"metal-pbr-material",alpha:e,transparencyMode:e!==void 0&&e<1?u.Material.MATERIAL_ALPHABLEND:u.Material.MATERIAL_OPAQUE,alphaMode:u.Engine.ALPHA_COMBINE,roughness:.25,metallic:1,albedoColor:new u.Color3(.7,.7,.7),metallicF0Factor:.1,zOffset:t,zOffsetUnits:n,disableDepthWrite:a}),Jn=({alpha:e,zOffset:t,zOffsetUnits:n,disableDepthWrite:a})=>C.jsx("pbrMaterial",{name:"metal-pbr-material",alpha:e,transparencyMode:e!==void 0&&e<1?u.Material.MATERIAL_ALPHABLEND:u.Material.MATERIAL_OPAQUE,alphaMode:u.Engine.ALPHA_COMBINE,roughness:.25,metallic:1,albedoColor:new u.Color3(.2,.2,.2),metallicF0Factor:.1,zOffsetUnits:n,zOffset:t,disableDepthWrite:a});var qt=(e=>(e[e.TRIGONOMETRIC=0]="TRIGONOMETRIC",e[e.PLANE=1]="PLANE",e[e.FLAT=2]="FLAT",e))(qt||{});const Kt=e=>{const t=_e.useScene(),[n,a]=m.useState(null),[r,o]=m.useState(null),{tilingFactor:i=.1,sideTilingFactor:l=.1,texture:s,alpha:c=1,mode:p=0,zOffset:f,zOffsetUnits:d,sideTexture:x,uvOffset:h=u.Vector2.Zero(),counterLine:T=void 0,scalePlane:P=1,scaleDepth:v=1,boundingBox:_=void 0,lines:b=[],text:k=[],disableDepthWrite:M,flatModeRotate:w=0}=e,S=N=>{a(N)};return m.useEffect(()=>{n&&s&&(n.setTexture("textureSampler",s),n.setFloat("textureFlatRotate",w),n.setVector2("uvOffset",h))},[w,n,s,h]),m.useEffect(()=>{n&&n.setFloat("alpha",c)},[c,n]),m.useEffect(()=>{n&&n.setFloat("tilingFactor",i),n&&n.setFloat("sideTilingFactor",l)},[i,l,n]),m.useEffect(()=>{n&&n.setInt("mode",p)},[n,p]),m.useEffect(()=>{n&&(x?n.setTexture("textureSideSampler",x):n.setTexture("textureSideSampler",s))},[n,x,s]),m.useEffect(()=>{var N;if(n)if(T&&_){const F=(N=T.startHeight)!=null?N:_.minimumWorld.y/v;return n.setFloat("contourLineStartHeight",F*v),n.setColor3("contourLineColor",T.color),n.setFloat("contourLineWidth",T.width),n.setFloat("contourLineStep",T.stepHeight*v),console.log("[Geo3DViewer] 等高线设置 ",T,_.centerWorld.y,F*v,F*v+16*T.stepHeight*v),()=>{n&&(n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new u.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0))}}else n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new u.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[T,v,P,_,n]),m.useEffect(()=>{t&&n&&_&&o(N=>{N&&N.dispose();let F=(_.maximum.x-_.minimum.x)/P,B=(_.maximum.z-_.minimum.z)/P,I=0;if(F<B){const L=F;F=B,B=L,I=1}const D=F/B;F*B>2048*2048&&(F=2048,B=2048/D);const E=new u.DynamicTexture("dynamic-texture",{width:F,height:B},t,!1);return E.clear(),console.log("[Geo3DViewer] 设置动态划线 ",_,F,B,P),n.setVector3("oMin",_.minimum),n.setVector3("oMax",_.maximum),n.setFloat("textureOverlayRotate",I),n.setTexture("textureOverlaySampler",E),E})},[_,n,P,t]),m.useEffect(()=>{var N;if(r&&_)if((N=r.getScene())!=null&&N.getEngine()){r.clear();let F=(_.maximum.x-_.minimum.x)/P,B=(_.maximum.z-_.minimum.z)/P;if(F<B){const E=F;F=B,B=E}const I=F/B;F*B>2048*2048&&(F=2048,B=2048/I);const D=r.getContext();b.forEach(E=>{if(E.points.length<2)return;D.beginPath();const L=E.offset?E.offset:new u.Vector2(0,0),y=1-E.points[0].x+L.x,A=1-E.points[0].y+L.y;D.moveTo(y*F,A*B);for(let V=1;V<E.points.length;V++){const $=E.offset?E.offset:new u.Vector2(0,0),W=1-E.points[V].x+$.x,ne=1-E.points[V].y+$.y;D.lineTo(W*F,ne*B)}D.strokeStyle=`rgb(${E.color.r*255}, ${E.color.g*255}, ${E.color.b*255})`,F*B>2048*2048?D.lineWidth=E.width/I:D.lineWidth=E.width,D.stroke()}),k.forEach(E=>{var V,$;D.font=`${E.fontSize}px Arial`;const L=(V=E.color)!=null?V:u.Color3.White(),y=E.offset?E.offset:new u.Vector2(0,0),A=($=E.rotation)!=null?$:0;if(D.save(),D.translate((1-E.position.x+y.x)*F,(1-E.position.y+y.y)*B),D.rotate(A),E.clearArea){const W=D.measureText(E.text);D.clearRect(-W.width*.15,.5*E.fontSize*(1-.3),W.width*1.3,-E.fontSize*1.3)}if(E.background){D.fillStyle=`rgba(${E.background.r*255}, ${E.background.g*255}, ${E.background.b*255})`;const W=D.measureText(E.text);D.fillRect(-W.width*.05,.5*(E.fontSize*(.5-.1)),W.width*1.1,-E.fontSize*1.1)}D.fillStyle=`rgb(${L.r*255}, ${L.g*255}, ${L.b*255})`,D.fillText(E.text,0,0),D.restore()}),r.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[b,k,r,_,P]),C.jsx(lt,{...e,ref:S,vertex:xu,fragment:vu,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:f,zOffsetUnits:d,disableDepthWrite:M})},Mt=e=>{const t=_e.useScene(),n=m.useRef(null),a=m.useContext(Vn),[r,o]=m.useState(null),{name:i,colorCodec:l,alpha:s=1,backFaceCulling:c,needDepthPrePass:p=!1,transparencyMode:f=u.Material.MATERIAL_OPAQUE,alphaMode:d=u.Engine.ALPHA_COMBINE,zOffset:x,zOffsetUnits:h,clipPlane:T,counterLine:P=void 0,scalePlane:v=1,scaleDepth:_=1,boundingBox:b,lines:k=[],text:M=[],disableDepthWrite:w}=e;return m.useEffect(()=>{const S=n.current;S&&t&&(S.loadFromSerialization(hu,""),S.build(!1,!0,!1))},[t]),m.useEffect(()=>{const S=n.current;S&&(S.name=`${i}-material`,S.backFaceCulling=c!=null?c:!0,S.needDepthPrePass=p,S.transparencyMode=f,S.alphaMode=d,S.alpha=s,S.zOffset=x!=null?x:1,S.zOffsetUnits=h!=null?h:0,S.clipPlane=T!=null?T:null,S.disableDepthWrite=w!=null?w:!1)},[s,d,c,T,w,i,p,f,x,h]),m.useEffect(()=>{if(l){const S=n.current;S&&(S.metadata={colorCodec:l},u.Tags.EnableFor(S),u.Tags.AddTagsTo(S,"remap"))}if(l&&a&&t&&a.colorCodecsImage.current[l]){const S=n.current;if(S){const N=S.getBlockByName("RemappedTexture");N&&(N.texture=a.colorCodecsImage.current[l].texture,S.markAsDirty(u.NodeMaterial.TextureDirtyFlag))}}},[l,t]),m.useEffect(()=>{n.current&&t&&(console.log("[Geo3DViewer] RemapColorByRedChannel 透明度更新 ",s),n.current.alpha=s)},[t,s]),m.useEffect(()=>{var N;const S=n.current;if(S){const F=S.getBlockByName("contourLineStartHeight"),B=S.getBlockByName("contourLineColor"),I=S.getBlockByName("contourLineWidth"),D=S.getBlockByName("contourLineStep");if(P&&b){const E=(N=P.startHeight)!=null?N:b.centerWorld.y/_;return F&&(F.value=E*_),B&&(B.value=P.color),I&&(I.value=P.width),D&&(D.value=P.stepHeight*_),console.log("[Geo3DViewer] 等高线设置 ",P,b.centerWorld,b.centerWorld.y,E*_,E*_+16*P.stepHeight*_),()=>{S&&(F&&(F.value=0),B&&(B.value=new u.Color3(0,0,0)),I&&(I.value=0),D&&(D.value=0))}}else F&&(F.value=0),B&&(B.value=new u.Color3(0,0,0)),I&&(I.value=0),D&&(D.value=0),console.log("[Geo3DViewer] 等高线设置 关闭");S.markAsDirty(u.NodeMaterial.MiscDirtyFlag)}},[P,_,v,b]),m.useEffect(()=>{t&&b&&o(S=>{var y,A;S&&S.dispose();let N=(b.maximum.x-b.minimum.x)/v,F=(b.maximum.z-b.minimum.z)/v,B=0;if(N<F){const V=N;N=F,F=V,B=1}const I=N/F;N*F>2048*2048&&(N=2048,F=2048/I);const D=new u.DynamicTexture("dynamic-texture",{width:N,height:F},t,!1);D.clear(),console.log("[Geo3DViewer] 设置动态划线 ",b,N,F,v);const E=(y=n.current)==null?void 0:y.getBlockByName("angle"),L=(A=n.current)==null?void 0:A.getBlockByName("OverlayTexture");return E&&(E.value=B*(Math.PI/2)),L&&(L.texture=D),D})},[b,v,t]),m.useEffect(()=>{var S;if(r&&b)if((S=r.getScene())!=null&&S.getEngine()){r.clear();let N=(b.maximum.x-b.minimum.x)/v,F=(b.maximum.z-b.minimum.z)/v;if(N<F){const D=N;N=F,F=D}const B=N/F;N*F>2048*2048&&(N=2048,F=2048/B);const I=r.getContext();k.forEach(D=>{if(D.points.length<2)return;I.beginPath();const E=D.offset?D.offset:new u.Vector2(0,0),L=1-D.points[0].x+E.x,y=1-D.points[0].y+E.y;I.moveTo(L*N,y*F);for(let A=1;A<D.points.length;A++){const V=D.offset?D.offset:new u.Vector2(0,0),$=1-D.points[A].x+V.x,W=1-D.points[A].y+V.y;I.lineTo($*N,W*F)}I.strokeStyle=`rgb(${D.color.r*255}, ${D.color.g*255}, ${D.color.b*255})`,N*F>2048*2048?I.lineWidth=D.width/B:I.lineWidth=D.width,I.stroke()}),M.forEach(D=>{var A,V;I.font=`${D.fontSize}px Arial`;const E=(A=D.color)!=null?A:u.Color3.White(),L=D.offset?D.offset:new u.Vector2(0,0),y=(V=D.rotation)!=null?V:0;if(I.save(),I.translate((1-D.position.x+L.x)*N,(1-D.position.y+L.y)*F),I.rotate(y),D.clearArea){const $=I.measureText(D.text);I.clearRect(-$.width*.15,.5*D.fontSize*(1-.3),$.width*1.3,-D.fontSize*1.3)}if(D.background){I.fillStyle=`rgba(${D.background.r*255}, ${D.background.g*255}, ${D.background.b*255})`;const $=I.measureText(D.text);I.fillRect(-$.width*.05,.5*(D.fontSize*(.5-.1)),$.width*1.1,-D.fontSize*1.1)}I.fillStyle=`rgb(${E.r*255}, ${E.g*255}, ${E.b*255})`,I.fillText(D.text,0,0),I.restore()}),r.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[k,r,b,v,M]),C.jsx("nodeMaterial",{ref:n,name:`${i}-material`,backFaceCulling:c,needDepthPrePass:p,transparencyMode:f,alphaMode:d,alpha:s,zOffset:x,zOffsetUnits:h,clipPlane:T,disableDepthWrite:w})},Qi=e=>{const t=_e.useScene(),n=m.useContext(Vn),a=m.useRef(null),[r,o]=m.useState(null),[i,l]=m.useState(null),[s,c]=m.useState(null),[p,f]=m.useState(null),[d,x]=m.useState(null),[h,T]=m.useState(null),[P,v]=m.useState(null),[_,b]=m.useState(null),{boundingBox:k,colorCodec:M,alphaStage:w,cutNormal:S,value:N,zOffset:F,zOffsetUnits:B,counterLine:I=void 0,scaleDepth:D=1,scalePlane:E=1,lines:L=[],text:y=[],disableDepthWrite:A}=e;return m.useEffect(()=>{const V=($,W,ne)=>{if(k){const ee=k.maximumWorld.multiply(W),G=k.minimumWorld.multiply(W),le=k.centerWorld.multiply(W),re=Math.max(ee.x,ee.y,ee.z),oe=Math.max(G.x,G.y,G.z),Y=Math.max(le.x,le.y,le.z),ce=Math.max(Math.abs(W.x),Math.abs(W.z));$(new u.Plane(W.x,W.y,W.z,((re-oe)*(1-ne-.5)*ce+Y)*-1))}else $(null)};k&&_&&(V(o,_.cutPlane1,N.value1),_.cutPlane2&&N.value2?V(l,_.cutPlane2,N.value2):l(null),_.cutPlane3&&N.value3?V(c,_.cutPlane3,N.value3):c(null),_.cutPlane4&&N.value4?V(f,_.cutPlane4,N.value4):f(null),_.cutPlane5&&N.value5?V(x,_.cutPlane5,N.value5):c(null),_.cutPlane6&&N.value6?V(T,_.cutPlane6,N.value6):T(null))},[k,_,N]),m.useEffect(()=>{b({cutPlane1:u.Vector3.Normalize(S.cutPlane1),cutPlane2:S.cutPlane2?u.Vector3.Normalize(S.cutPlane2):void 0,cutPlane3:S.cutPlane3?u.Vector3.Normalize(S.cutPlane3):void 0,cutPlane4:S.cutPlane4?u.Vector3.Normalize(S.cutPlane4):void 0,cutPlane5:S.cutPlane5?u.Vector3.Normalize(S.cutPlane5):void 0,cutPlane6:S.cutPlane6?u.Vector3.Normalize(S.cutPlane6):void 0})},[S]),m.useEffect(()=>{const V=a.current;V&&(V.clipPlane=r,V.clipPlane2=i,V.clipPlane3=s,V.clipPlane4=p,V.clipPlane5=d,V.clipPlane6=h)},[r,i,s,p,d,h]),m.useEffect(()=>{var V,$,W,ne,ee;a.current&&t&&(a.current.setFloat("alpha1",w.alpha1),a.current.setFloat("alpha2",(V=w.alpha2)!=null?V:1),a.current.setFloat("alpha3",($=w.alpha3)!=null?$:1),a.current.setFloat("alpha4",(W=w.alpha4)!=null?W:1),a.current.setFloat("alpha5",(ne=w.alpha5)!=null?ne:1),a.current.setFloat("alpha6",(ee=w.alpha6)!=null?ee:1))},[t,w]),m.useEffect(()=>{if(M){const V=a.current;V&&(V.metadata={colorCodec:M},u.Tags.EnableFor(V),u.Tags.AddTagsTo(V,"remap"))}if(M&&n&&t&&n.colorCodecsImage.current[M]){const V=a.current;V&&(console.log(n.colorCodecsImage.current[M]),V.setTexture("textureSampler",n.colorCodecsImage.current[M].texture),V.metadata={colorCodec:M},u.Tags.EnableFor(V),u.Tags.AddTagsTo(V,"remap"))}},[M,t]),m.useEffect(()=>{var $;const V=a.current;if(V&&k)if(I){const W=($=I.startHeight)!=null?$:k.minimumWorld.y/D;return V.setFloat("contourLineStartHeight",W*D),V.setColor3("contourLineColor",I.color),V.setFloat("contourLineWidth",I.width),V.setFloat("contourLineStep",I.stepHeight*D),console.log("[Geo3DViewer] 等高线设置 ",I,k.centerWorld.y,W*D,W*D+16*I.stepHeight*D),()=>{V&&(V.setFloat("contourLineStartHeight",0),V.setColor3("contourLineColor",new u.Color3(0,0,0)),V.setFloat("contourLineWidth",0),V.setFloat("contourLineStep",0))}}else V.setFloat("contourLineStartHeight",0),V.setColor3("contourLineColor",new u.Color3(0,0,0)),V.setFloat("contourLineWidth",0),V.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[I,D,E,k]),m.useEffect(()=>{t&&k&&v(V=>{var le,re,oe,Y;V&&V.dispose();let $=(k.maximum.x-k.minimum.x)/E,W=(k.maximum.z-k.minimum.z)/E,ne=0;if($<W){const ce=$;$=W,W=ce,ne=1}const ee=$/W;$*W>2048*2048&&($=2048,W=2048/ee);const G=new u.DynamicTexture("dynamic-texture",{width:$,height:W},t,!1);return G.clear(),console.log("[Geo3DViewer] 设置动态划线 ",k,$,W,E),(le=a.current)==null||le.setVector3("oMin",k.minimum),(re=a.current)==null||re.setVector3("oMax",k.maximum),(oe=a.current)==null||oe.setFloat("textureOverlayRotate",ne),(Y=a.current)==null||Y.setTexture("textureOverlaySampler",G),G})},[k,E,t]),m.useEffect(()=>{var V;if(P&&k)if((V=P.getScene())!=null&&V.getEngine()){P.clear();let $=(k.maximum.x-k.minimum.x)/E,W=(k.maximum.z-k.minimum.z)/E;if($<W){const G=$;$=W,W=G}const ne=$/W;$*W>2048*2048&&($=2048,W=2048/ne);const ee=P.getContext();L.forEach(G=>{if(G.points.length<2)return;ee.beginPath();const le=G.offset?G.offset:new u.Vector2(0,0),re=1-G.points[0].x+le.x,oe=1-G.points[0].y+le.y;ee.moveTo(re*$,oe*W);for(let Y=1;Y<G.points.length;Y++){const ce=G.offset?G.offset:new u.Vector2(0,0),ae=1-G.points[Y].x+ce.x,X=1-G.points[Y].y+ce.y;ee.lineTo(ae*$,X*W)}ee.strokeStyle=`rgb(${G.color.r*255}, ${G.color.g*255}, ${G.color.b*255})`,$*W>2048*2048?ee.lineWidth=G.width/ne:ee.lineWidth=G.width,ee.stroke()}),y.forEach(G=>{var Y,ce;ee.font=`${G.fontSize}px Arial`;const le=(Y=G.color)!=null?Y:u.Color3.White(),re=G.offset?G.offset:new u.Vector2(0,0),oe=(ce=G.rotation)!=null?ce:0;if(ee.save(),ee.translate((1-G.position.x+re.x)*$,(1-G.position.y+re.y)*W),ee.rotate(oe),G.clearArea){const ae=ee.measureText(G.text);ee.clearRect(-ae.width*.15,.5*G.fontSize*(1-.3),ae.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 ae=ee.measureText(G.text);ee.fillRect(-ae.width*.05,.5*(G.fontSize*(.5-.1)),ae.width*1.1,-G.fontSize*1.1)}ee.fillStyle=`rgb(${le.r*255}, ${le.g*255}, ${le.b*255})`,ee.fillText(G.text,0,0),ee.restore()}),P.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[L,P,k,E,y]),C.jsx(lt,{...e,ref:a,vertex:gu,fragment:mu,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:A,zOffset:F,zOffsetUnits:B})},ji=e=>{const t=_e.useScene(),[n,a]=m.useState(null),[r,o]=m.useState(null),[i,l]=m.useState(null),[s,c]=m.useState(null),[p,f]=m.useState(null),[d,x]=m.useState(null),[h,T]=m.useState(null),[P,v]=m.useState(null),[_,b]=m.useState(null),{boundingBox:k=void 0,texture:M,sideTexture:w,alphaStage:S,cutNormal:N,value:F,tilingFactor:B=.1,sideTilingFactor:I=.1,mode:D=0,zOffset:E,zOffsetUnits:L,overlay:y={},counterLine:A=void 0,scalePlane:V=1,scaleDepth:$=1,lines:W=[],text:ne=[],disableDepthWrite:ee,textureFlatRotate:G=0}=e,le=re=>{a(re)};return m.useEffect(()=>{n&&n.setFloat("textureFlatRotate",G)},[n,G]),m.useEffect(()=>{const re=(oe,Y,ce)=>{if(k){const ae=k.maximumWorld.multiply(Y),X=k.minimumWorld.multiply(Y),Pe=k.centerWorld.multiply(Y),ge=Math.max(ae.x,ae.y,ae.z),H=Math.max(X.x,X.y,X.z),Q=Math.max(Pe.x,Pe.y,Pe.z),Ee=Math.max(Math.abs(Y.x),Math.abs(Y.z)),ke=new u.Plane(Y.x,Y.y,Y.z,((ge-H)*(1-ce-.5)*Ee+Q)*-1);oe(ke),console.log("[Geo3DViewer] 设置实际 CutPlane 为 ",ke,Ee)}else oe(null)};k&&_&&(re(o,_.cutPlane1,F.value1),_.cutPlane2&&F.value2?re(l,_.cutPlane2,F.value2):l(null),_.cutPlane3&&F.value3?re(c,_.cutPlane3,F.value3):c(null),_.cutPlane4&&F.value4?re(f,_.cutPlane4,F.value4):f(null),_.cutPlane5&&F.value5?re(x,_.cutPlane5,F.value5):c(null),_.cutPlane6&&F.value6?re(T,_.cutPlane6,F.value6):T(null))},[_,k,F]),m.useEffect(()=>{b({cutPlane1:u.Vector3.Normalize(N.cutPlane1),cutPlane2:N.cutPlane2?u.Vector3.Normalize(N.cutPlane2):void 0,cutPlane3:N.cutPlane3?u.Vector3.Normalize(N.cutPlane3):void 0,cutPlane4:N.cutPlane4?u.Vector3.Normalize(N.cutPlane4):void 0,cutPlane5:N.cutPlane5?u.Vector3.Normalize(N.cutPlane5):void 0,cutPlane6:N.cutPlane6?u.Vector3.Normalize(N.cutPlane6):void 0})},[N]),m.useEffect(()=>{n&&(n.clipPlane=r,n.clipPlane2=i,n.clipPlane3=s,n.clipPlane4=p,n.clipPlane5=d,n.clipPlane6=h)},[n,r,i,s,p,d,h]),m.useEffect(()=>{var re,oe,Y,ce,ae;n&&t&&(n.setFloat("alpha1",S.alpha1),n.setFloat("alpha2",(re=S.alpha2)!=null?re:1),n.setFloat("alpha3",(oe=S.alpha3)!=null?oe:1),n.setFloat("alpha4",(Y=S.alpha4)!=null?Y:1),n.setFloat("alpha5",(ce=S.alpha5)!=null?ce:1),n.setFloat("alpha6",(ae=S.alpha6)!=null?ae:1))},[t,S,n]),m.useEffect(()=>{n&&M&&n.setTexture("textureSampler",M)},[n,M]),m.useEffect(()=>{n&&B&&n.setFloat("tilingFactor",B),n&&I&&n.setFloat("sideTilingFactor",I)},[B,I,n]),m.useEffect(()=>{n&&D&&n.setInt("mode",D)},[n,D]),m.useEffect(()=>{n&&(w?n.setTexture("textureSideSampler",w):n.setTexture("textureSideSampler",M))},[n,w,M]),m.useEffect(()=>{n&&(y.texture1?n.setTexture("textureSampler1",y.texture1):n.setTexture("textureSampler1",M),y.sideTexture1?n.setTexture("textureSideSampler1",y.sideTexture1):n.setTexture("textureSideSampler1",M),y.color1?n.setColor3("vColor1",y.color1):n.setColor3("vColor1",new u.Color3(1,1,1)),y.texture2?n.setTexture("textureSampler2",y.texture2):n.setTexture("textureSampler2",M),y.sideTexture2?n.setTexture("textureSideSampler2",y.sideTexture2):n.setTexture("textureSideSampler2",M),y.color2?n.setColor3("vColor2",y.color2):n.setColor3("vColor2",new u.Color3(1,1,1)),y.texture3?n.setTexture("textureSampler3",y.texture3):n.setTexture("textureSampler3",M),y.sideTexture3?n.setTexture("textureSideSampler3",y.sideTexture3):n.setTexture("textureSideSampler2",M),y.color3?n.setColor3("vColor3",y.color3):n.setColor3("vColor3",new u.Color3(1,1,1)),y.texture4?n.setTexture("textureSampler4",y.texture4):n.setTexture("textureSampler4",M),y.sideTexture4?n.setTexture("textureSideSampler4",y.sideTexture4):n.setTexture("textureSideSampler4",M),y.color4?n.setColor3("vColor4",y.color4):n.setColor3("vColor4",new u.Color3(1,1,1)),y.texture5?n.setTexture("textureSampler5",y.texture5):n.setTexture("textureSampler5",M),y.sideTexture5?n.setTexture("textureSideSampler5",y.sideTexture5):n.setTexture("textureSideSampler5",M),y.color5?n.setColor3("vColor5",y.color5):n.setColor3("vColor5",new u.Color3(1,1,1)),y.texture6?n.setTexture("textureSampler6",y.texture6):n.setTexture("textureSampler6",M),y.sideTexture6?n.setTexture("textureSideSampler6",y.sideTexture6):n.setTexture("textureSideSampler6",M),y.color6?n.setColor3("vColor6",y.color6):n.setColor3("vColor6",new u.Color3(1,1,1)))},[n,y,M]),m.useEffect(()=>{var re;if(n&&k)if(A){const oe=(re=A.startHeight)!=null?re:k.minimumWorld.y/$;return n.setFloat("contourLineStartHeight",oe*$),n.setColor3("contourLineColor",A.color),n.setFloat("contourLineWidth",A.width),n.setFloat("contourLineStep",A.stepHeight*$),console.log("[Geo3DViewer] 等高线设置 ",A,k.centerWorld.y,oe*$,oe*$+16*A.stepHeight*$),()=>{n&&(n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new u.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0))}}else n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new u.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[A,$,V,k,n]),m.useEffect(()=>{t&&n&&k&&v(re=>{re&&re.dispose();let oe=(k.maximum.x-k.minimum.x)/V,Y=(k.maximum.z-k.minimum.z)/V,ce=0;if(oe<Y){const Pe=oe;oe=Y,Y=Pe,ce=1}const ae=oe/Y;oe*Y>2048*2048&&(oe=2048,Y=2048/ae);const X=new u.DynamicTexture("dynamic-texture",{width:oe,height:Y},t,!1);return X.clear(),console.log("[Geo3DViewer] 设置动态划线 ",k,oe,Y,V),n.setVector3("oMin",k.minimum),n.setVector3("oMax",k.maximum),n.setFloat("textureOverlayRotate",ce),n.setTexture("textureOverlaySampler",X),X})},[k,n,V,t]),m.useEffect(()=>{var re;if(P&&k)if((re=P.getScene())!=null&&re.getEngine()){P.clear();let oe=(k.maximum.x-k.minimum.x)/V,Y=(k.maximum.z-k.minimum.z)/V;if(oe<Y){const X=oe;oe=Y,Y=X}const ce=oe/Y;oe*Y>2048*2048&&(oe=2048,Y=2048/ce);const ae=P.getContext();W.forEach(X=>{if(X.points.length<2)return;ae.beginPath();const Pe=X.offset?X.offset:new u.Vector2(0,0),ge=1-X.points[0].x+Pe.x,H=1-X.points[0].y+Pe.y;ae.moveTo(ge*oe,H*Y);for(let Q=1;Q<X.points.length;Q++){const Ee=X.offset?X.offset:new u.Vector2(0,0),ke=1-X.points[Q].x+Ee.x,te=1-X.points[Q].y+Ee.y;ae.lineTo(ke*oe,te*Y)}ae.strokeStyle=`rgb(${X.color.r*255}, ${X.color.g*255}, ${X.color.b*255})`,oe*Y>2048*2048?ae.lineWidth=X.width/ce:ae.lineWidth=X.width,ae.stroke()}),ne.forEach(X=>{var Q,Ee;ae.font=`${X.fontSize}px Arial`;const Pe=(Q=X.color)!=null?Q:u.Color3.White(),ge=X.offset?X.offset:new u.Vector2(0,0),H=(Ee=X.rotation)!=null?Ee:0;if(ae.save(),ae.translate((1-X.position.x+ge.x)*oe,(1-X.position.y+ge.y)*Y),ae.rotate(H),X.clearArea){const ke=ae.measureText(X.text);ae.clearRect(-ke.width*.15,.5*X.fontSize*(1-.3),ke.width*1.3,-X.fontSize*1.3)}if(X.background){ae.fillStyle=`rgba(${X.background.r*255}, ${X.background.g*255}, ${X.background.b*255})`;const ke=ae.measureText(X.text);ae.fillRect(-ke.width*.05,.5*(X.fontSize*(.5-.1)),ke.width*1.1,-X.fontSize*1.1)}ae.fillStyle=`rgb(${Pe.r*255}, ${Pe.g*255}, ${Pe.b*255})`,ae.fillText(X.text,0,0),ae.restore()}),P.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[W,P,k,V,ne]),C.jsx(lt,{...e,ref:le,vertex:Cu,fragment:yu,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:E,zOffsetUnits:L,disableDepthWrite:ee})},Su=e=>C.jsx(lt,{...e,vertex:Gn,fragment:Zn,options:{needAlphaBlending:!0},zOffset:e.zOffset,zOffsetUnits:e.zOffsetUnits,disableDepthWrite:e.disableDepthWrite}),Tu=()=>C.jsx(lt,{name:"picking-material",vertex:Lc,fragment:Mc,backFaceCulling:!1,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","pickingColor","isPickable"]}}),bu=({name:e,scene:t})=>{const n=u.NodeMaterial.Parse(wc,t);return n.name=e,n.backFaceCulling=!1,n.build(!1,!0,!1),n},ku=({name:e,lineColor:t,lineWidth:n=.5})=>{const a=_e.useScene(),[r,o]=m.useState(null);return m.useEffect(()=>{if(a){const i=u.NodeMaterial.Parse(Ql,a);return i.name=`${e}-material`,i.backFaceCulling=!1,i.build(!1,!0,!1),o(i),()=>{o(l=>(l==null||l.dispose(!0,!1),null))}}},[e,a]),m.useEffect(()=>{o(i=>i&&t?(i.getBlockByName("Color3").value=t,i.build(!1,!0,!1),i):null)},[t]),m.useEffect(()=>{o(i=>{if(i&&n!==void 0&&n!==null){let l=n;return n<1&&(l=1),i.getBlockByName("offset").value=1-l,i.build(!1,!0,!1),i}return null})},[n]),r},Eu=(e,t)=>{const n=m.useRef(null);return m.useEffect(()=>{n.current&&(n.current.setVector4("typeAlpha1",new u.Vector4(e.typeAlpha.typeAlpha0===void 0?1:e.typeAlpha.typeAlpha0,e.typeAlpha.typeAlpha1,e.typeAlpha.typeAlpha2,e.typeAlpha.typeAlpha3)),n.current.setVector4("typeAlpha2",new u.Vector4(e.typeAlpha.typeAlpha4,e.typeAlpha.typeAlpha5,e.typeAlpha.typeAlpha6,e.typeAlpha.typeAlpha7)),n.current.setVector4("typeAlpha3",new u.Vector4(e.typeAlpha.typeAlpha8,e.typeAlpha.typeAlpha9,e.typeAlpha.typeAlpha10,e.typeAlpha.typeAlpha11)),n.current.setVector4("typeAlpha4",new u.Vector4(e.typeAlpha.typeAlpha12,e.typeAlpha.typeAlpha13,e.typeAlpha.typeAlpha14,e.typeAlpha.typeAlpha15)),n.current.setVector4("typeAlpha5",new u.Vector4(e.typeAlpha.typeAlpha16,e.typeAlpha.typeAlpha17,e.typeAlpha.typeAlpha18,e.typeAlpha.typeAlpha19)))},[e.typeAlpha]),m.useImperativeHandle(t,()=>n.current,[]),C.jsx(lt,{ref:n,name:e.name,backFaceCulling:!0,needDepthPrePass:!1,vertex:Pu,fragment:_u,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.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}})},Mn=e=>{const t=_e.useScene(),[n,a]=m.useState(null),r=m.useRef(null),{boundingBox:o,counterLine:i,scaleDepth:l=1,scalePlane:s=1,color:c,alpha:p=1,lines:f=[],text:d=[],surfaceCanvasOptions:x={textureIncludeSide:!0},disableDepthWrite:h,disableNormalShadow:T=!1}=e,{textureIncludeSide:P}=x;return m.useEffect(()=>{r.current&&(console.log("[Geo3DViewer] 设置材质 ",c,p),r.current.setColor3("vColor",c),r.current.setFloat("vAlpha",p),r.current.setFloat("textureIncludeSide",P==null?1:0))},[c,p,P]),m.useEffect(()=>{var _;const v=r.current;if(v&&o)if(i){const b=(_=i.startHeight)!=null?_:o.maximumWorld.y/l;return v.setFloat("contourLineStartHeight",b*l),v.setColor3("contourLineColor",i.color),v.setFloat("contourLineWidth",i.width),v.setFloat("contourLineStep",i.stepHeight*l),console.log("[Geo3DViewer] 等高线设置 ",i,o.centerWorld.y,b*l,b*l-16*i.stepHeight*l),()=>{v&&(v.setFloat("contourLineStartHeight",0),v.setColor3("contourLineColor",new u.Color3(0,0,0)),v.setFloat("contourLineWidth",0),v.setFloat("contourLineStep",0))}}else v.setFloat("contourLineStartHeight",0),v.setColor3("contourLineColor",new u.Color3(0,0,0)),v.setFloat("contourLineWidth",0),v.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[o,i,l,s]),m.useEffect(()=>{const v=r.current;t&&o&&v&&a(_=>{let b=(o.maximum.x-o.minimum.x)/s,k=(o.maximum.z-o.minimum.z)/s,M=0;if(b<k){const N=b;b=k,k=N,M=1}const w=b/k;b*k>2048*2048&&(b=2048,k=2048/w);let S;return _?(_.scaleTo(b,k),_.update(),S=_):S=new u.DynamicTexture("dynamic-texture",{width:b,height:k},t,!1),S.clear(),S.update(),console.log("[Geo3DViewer] 设置动态划线 ",o,b,k,s),v.setVector3("oMin",o.minimum),v.setVector3("oMax",o.maximum),v.setFloat("textureOverlayRotate",M),v.setTexture("textureOverlaySampler",S),S})},[o,s,t]),m.useEffect(()=>{var v;if(n&&o&&(f.length>0||d.length>0))if((v=n.getScene())!=null&&v.getEngine()){n.clear();let _=(o.maximum.x-o.minimum.x)/s,b=(o.maximum.z-o.minimum.z)/s;if(_<b){const w=_;_=b,b=w}const k=_/b;_*b>2048*2048&&(_=2048,b=2048/k);const M=n.getContext();f.forEach(w=>{if(w.points.length<2)return;M.beginPath();const S=w.offset?w.offset:new u.Vector2(0,0),N=1-w.points[0].x+S.x,F=1-w.points[0].y+S.y;M.moveTo(N*_,F*b);for(let B=1;B<w.points.length;B++){const I=w.offset?w.offset:new u.Vector2(0,0),D=1-w.points[B].x+I.x,E=1-w.points[B].y+I.y;M.lineTo(D*_,E*b)}M.strokeStyle=`rgb(${w.color.r*255}, ${w.color.g*255}, ${w.color.b*255})`,_*b>2048*2048?M.lineWidth=w.width/k:M.lineWidth=w.width,M.stroke()}),d.forEach(w=>{var B,I;M.font=`${w.fontSize}px Arial`;const S=(B=w.color)!=null?B:u.Color3.White(),N=w.offset?w.offset:new u.Vector2(0,0),F=(I=w.rotation)!=null?I:0;if(M.save(),M.translate((1-w.position.x+N.x)*_,(1-w.position.y+N.y)*b),M.rotate(F),w.clearArea){const D=M.measureText(w.text);M.clearRect(-D.width*.15,.5*w.fontSize*(1-.3),D.width*1.3,-w.fontSize*1.3)}if(w.background){M.fillStyle=`rgba(${w.background.r*255}, ${w.background.g*255}, ${w.background.b*255})`;const D=M.measureText(w.text);M.fillRect(-D.width*.05,.5*(w.fontSize*(.5-.1)),D.width*1.1,-w.fontSize*1.1)}M.fillStyle=`rgb(${S.r*255}, ${S.g*255}, ${S.b*255})`,M.fillText(w.text,0,0),M.restore()}),n.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[f,n,o,s,d]),m.useEffect(()=>{const v=r.current;if(v){if(T)return v.setFloat("disableNormalShadow",1),console.log("[Geo3DViewer] 禁用法向阴影 启用"),()=>{v&&v.setFloat("disableNormalShadow",0)};v.setFloat("disableNormalShadow",0),console.log("[Geo3DViewer] 禁用法向阴影 禁用")}},[T]),C.jsx(lt,{ref:r,name:e.name,backFaceCulling:e.backFaceCulling,needDepthPrePass:e.needDepthPrePass,vertex:Ac,fragment:Oc,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:h})},Nu=m.forwardRef(Eu),ea=({name:e,url:t,offset:n=u.Vector3.Zero(),alpha:a=1,material:r,visible:o=!0,actions:i})=>{const l=_e.useScene(),s=m.useRef(null),c=m.useContext(Le),p=je({url:t,cacheType:Me.URL_PREFIX_MATCH}),f=He({url:r.texture,cacheType:Me.URL_PREFIX_MATCH}),d=He({url:r.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),[x,h]=m.useState(u.Vector3.Zero()),[T,P]=m.useState();return m.useEffect(()=>{console.log("[Geo3DViewer] AttributeBody Loading: ",t)},[t]),m.useEffect(()=>{if(l&&s.current&&t&&p){u.Tags.EnableFor(s.current),u.Tags.AddTagsTo(s.current,"loading");const v=Wo.decode(new Uint8Array(p)),{points:_,indices:b,value:k,center:M}=v,w=new u.VertexData;w.positions=_,w.indices=b,w.colors=k;const S=[];u.VertexData.ComputeNormals(_,b,S),w.normals=S,M&&h(new u.Vector3(M.x,M.y,M.z));const N=s.current;N&&(w.applyToMesh(N),N.getScene().onAfterRenderObservable.addOnce(()=>{if(!N.isDisposed()){const B=N.getBoundingInfo();P(B.boundingBox)}})),u.Tags.RemoveTagsFrom(s.current,"loading")}},[t,l,p]),m.useEffect(()=>{s.current&&(s.current.metadata={pickable:i?{name:e,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,needWorldPosition:i.needWorldPosition,extra:i.extra}:null})},[i,e]),C.jsx(C.Fragment,{children:C.jsx("transformNode",{name:`transform-attribute-${e}`,position:x.add(n).multiplyByFloats(c&&c.scalePlane?c.scalePlane:1,c&&c.scaleDepth?c.scaleDepth:1,c&&c.scalePlane?c.scalePlane:1),scaling:new u.Vector3(c?c.scalePlane:1,c?c.scaleDepth:1,c?c.scalePlane:1),children:C.jsx("mesh",{name:`attributebody-${e}-mesh`,ref:s,setEnabled:o,useVertexColors:r.type===$e.COLOR_CODEC,children:r.type===$e.COLOR_CODEC&&r.colorCodec?C.jsx(Mt,{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:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,colorCodec:r.colorCodec,boundingBox:T,lines:r.lines,text:r.text,scaleDepth:c?c.scaleDepth:1,scalePlane:c?c.scalePlane:1,disableDepthWrite:r.disableDepthWrite}):r.type===$e.ONE_COLOR&&r.color?C.jsx("standardMaterial",{name:`attributebody-${e}-overwrite-mat`,backFaceCulling:r.backFaceCulling===void 0?!0:r.backFaceCulling,needDepthPrePass:r.needDepthPrePass===void 0?!1:r.needDepthPrePass,transparencyMode:u.Material.MATERIAL_ALPHABLEND,specularColor:new u.Color3(0,0,0),ambientColor:new u.Color3(1,1,1),diffuseColor:new u.Color3(r.color.r,r.color.g,r.color.b),emissiveColor:u.Color3.Black(),alphaMode:u.Engine.ALPHA_COMBINE,alpha:r.alpha?r.alpha:a,zOffset:-3,disableDepthWrite:r.disableDepthWrite}):r.type===$e.TEXTURE&&f?C.jsx(Kt,{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:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,texture:f,sideTexture:d,mode:r.textureMode===void 0?qt.PLANE:r.textureMode,boundingBox:T,disableDepthWrite:r.disableDepthWrite}):C.jsx(C.Fragment,{})})})})},ta=({codec:e,showValue:t=!1,showTitle:n=!0,width:a=80,height:r=200})=>{const o=m.useContext(Vn);return C.jsx(C.Fragment,{children:C.jsxs("adtFullscreenUi",{name:`adt-color-codec-${e}`,children:[n?C.jsx("textBlock",{name:`color-codec-title-${e}`,text:e,color:"white",paddingBottomInPixels:r+40/200*r,paddingRightInPixels:30/80*a,textVerticalAlignment:nt.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:nt.Control.HORIZONTAL_ALIGNMENT_RIGHT}):C.jsx(C.Fragment,{}),C.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:nt.Control.VERTICAL_ALIGNMENT_CENTER,horizontalAlignment:nt.Control.HORIZONTAL_ALIGNMENT_RIGHT,paddingRightInPixels:20}),t&&(o!=null&&o.colorCodecsImage.current[e])?C.jsxs(C.Fragment,{children:[C.jsx("textBlock",{name:"color-codec-value-min",text:o.colorCodecsImage.current[e].min.toFixed(1).toString(),color:"white",paddingBottomInPixels:-1*r,paddingRightInPixels:90,textVerticalAlignment:nt.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:nt.Control.HORIZONTAL_ALIGNMENT_RIGHT}),C.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:nt.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:nt.Control.HORIZONTAL_ALIGNMENT_RIGHT}),C.jsx("textBlock",{name:"color-codec-title-max",text:o.colorCodecsImage.current[e].max.toFixed(1).toString(),color:"white",paddingBottomInPixels:r,paddingRightInPixels:a+10,textVerticalAlignment:nt.Control.VERTICAL_ALIGNMENT_CENTER,textHorizontalAlignment:nt.Control.HORIZONTAL_ALIGNMENT_RIGHT})]}):null]})})};function Kr(){return{name:"",colorId:0,points:[],indices:[],bottomIndices:[],value:[],vMin:0,vMax:0,border:[],side:[],sideIndices:[],sideValue:[],center:void 0}}const Wt={encode(e,t=se.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&&K.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=Kr();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=K.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:_n(e.name)?globalThis.String(e.name):"",colorId:_n(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:_n(e.vMin)?globalThis.Number(e.vMin):0,vMax:_n(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:_n(e.center)?K.fromJSON(e.center):void 0}},toJSON(e){var n,a,r,o,i,l,s,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(p=>Math.round(p))),(r=e.bottomIndices)!=null&&r.length&&(t.bottomIndices=e.bottomIndices.map(p=>Math.round(p))),(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(p=>Math.round(p))),(l=e.side)!=null&&l.length&&(t.side=e.side),(s=e.sideIndices)!=null&&s.length&&(t.sideIndices=e.sideIndices.map(p=>Math.round(p))),(c=e.sideValue)!=null&&c.length&&(t.sideValue=e.sideValue),e.center!==void 0&&(t.center=K.toJSON(e.center)),t},create(e){return Wt.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,l,s,c,p,f,d,x;const t=Kr();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(h=>h))||[],t.indices=((o=e.indices)==null?void 0:o.map(h=>h))||[],t.bottomIndices=((i=e.bottomIndices)==null?void 0:i.map(h=>h))||[],t.value=((l=e.value)==null?void 0:l.map(h=>h))||[],t.vMin=(s=e.vMin)!=null?s:0,t.vMax=(c=e.vMax)!=null?c:0,t.border=((p=e.border)==null?void 0:p.map(h=>h))||[],t.side=((f=e.side)==null?void 0:f.map(h=>h))||[],t.sideIndices=((d=e.sideIndices)==null?void 0:d.map(h=>h))||[],t.sideValue=((x=e.sideValue)==null?void 0:x.map(h=>h))||[],t.center=e.center!==void 0&&e.center!==null?K.fromPartial(e.center):void 0,t}};function _n(e){return e!=null}const Iu=64,wu=32,na='"Noto Sans SC", sans-serif';function Ou(e,t){if(typeof document=="undefined")return{textureWidth:256,textureHeight:128};const a=document.createElement("canvas").getContext("2d");if(!a)return{textureWidth:256,textureHeight:128};const r=Math.max(8,Math.round(t*.35)),o=Math.max(6,Math.round(t*.25));a.font=`600 ${t}px ${na}`;const i=Math.ceil(a.measureText(e||" ").width),l=Math.ceil(t*1.6);return{textureWidth:Math.max(Iu,Qr(i+r*2)),textureHeight:Math.max(wu,Qr(l+o*2))}}function Qr(e){let t=1;for(;t<e;)t<<=1;return t}function Au(e){if(typeof e=="string")return e;const t=Math.round(e.r*255),n=Math.round(e.g*255),a=Math.round(e.b*255);return`rgba(${t}, ${n}, ${a}, ${e.a})`}const Je=e=>{const t=_e.useScene(),n=m.useRef(null),a=m.useRef(null),{name:r,text:o,fontSize:i,color:l,billboardMode:s=u.Mesh.BILLBOARDMODE_ALL,lowPriority:c=!0}=e;return m.useEffect(()=>{if(!t)return;const p=r!=null?r:"gui-text-no-name",{textureWidth:f,textureHeight:d}=Ou(o,i),x=u.MeshBuilder.CreatePlane(p,{width:1,height:1},t);x.parent=n.current,x.isPickable=!1,x.billboardMode=s,x.alwaysSelectAsActiveMesh=!0;const h=Math.max(i,1);x.scaling.x=h*(f/d),x.scaling.y=h;const T=nt.AdvancedDynamicTexture.CreateForMesh(x,f,d,!1,!1);T.rootContainer.isPointerBlocker=!1;const P=new nt.TextBlock(`${p}-text`,o);P.color=Au(l),P.fontFamily=na,P.fontWeight="600",P.fontSize=`${i}px`,P.resizeToFit=!1,P.textWrapping=!1,P.textHorizontalAlignment=nt.Control.HORIZONTAL_ALIGNMENT_CENTER,P.textVerticalAlignment=nt.Control.VERTICAL_ALIGNMENT_CENTER,T.addControl(P);const v=x.material;return v&&v instanceof u.StandardMaterial&&(v.backFaceCulling=!1,v.disableLighting=!0,v.forceDepthWrite=!1,v.needDepthPrePass=!1,v.transparencyMode=u.Material.MATERIAL_ALPHABLEND,v.zOffset=-2),x.renderingGroupId=2,a.current={plane:x,texture:T},()=>{var _,b;(_=a.current)==null||_.texture.dispose(),(b=a.current)==null||b.plane.dispose(),a.current=null}},[t,r,o,i,l,s,c]),m.useEffect(()=>{a.current&&(a.current.plane.parent=n.current)}),C.jsx("transformNode",{name:r!=null?r:"no-name-text",ref:n})},Xn=({urlTopLayer:e,urlBottomLayer:t,showLayerLabel:n=!1,labelStyle:a,position:r=u.Vector3.Zero(),visible:o=!0,showBottomLayer:i=!1,actions:l,material:s={type:$e.COLOR_ID,alpha:1}})=>{var E,L;const c=m.useRef(null),p=m.useRef(null),[f,d]=m.useState(""),[x,h]=m.useState(null),T=m.useContext(Le),P=m.useContext(Lt),[v,_]=m.useState(u.Color3.White()),b=je({url:e,cacheType:Me.URL_PREFIX_MATCH}),k=je({url:t,cacheType:Me.URL_PREFIX_MATCH}),M=He({url:s==null?void 0:s.texture,cacheType:Me.URL_PREFIX_MATCH}),w=He({url:s==null?void 0:s.sideTexture,cacheType:Me.URL_PREFIX_MATCH});m.useEffect(()=>{console.log("[Geo3DViewer] FormationFace Loading: ",e,t)},[e,t]);const[S,N]=m.useState(),[F,B]=m.useState(u.Vector3.Zero()),[I,D]=m.useState(void 0);return m.useEffect(()=>{if(b){const y=c.current;y&&(u.Tags.EnableFor(y),u.Tags.AddTagsTo(y,"loading"));let A=[],V=[],$=[];const W=Wt.decode(new Uint8Array(b));{const{name:G,points:le,indices:re,colorId:oe,value:Y,center:ce}=W;A=le,V=re,$=Y,h(oe),d(G),ce&&B(new u.Vector3(ce.x,ce.y,ce.z))}const ne=new u.VertexData;ne.positions=A,ne.indices=V,ne.colors=$;const ee=[];if(u.VertexData.ComputeNormals(A,V,ee),ne.normals=ee,y){ne.applyToMesh(y);const G=y.getBoundingInfo();N(G.boundingBox.center.add(new u.Vector3(G.boundingBox.extendSize.x,0,0))),i||y.getScene().onAfterRenderObservable.addOnce(()=>{if(!y.isDisposed()){const re=y.getBoundingInfo();D(re.boundingBox)}})}return y&&u.Tags.RemoveTagsFrom(y,"loading"),()=>{y&&new u.VertexData().applyToMesh(y)}}},[b,i]),m.useEffect(()=>{if(b&&k){const y=p.current;y&&(u.Tags.EnableFor(y),u.Tags.AddTagsTo(y,"loading"));let A=[],V=[],$=[],W=[],ne=[],ee=[],G=[],le=[];{const ge=Wt.decode(new Uint8Array(b)),{points:H,indices:Q,border:Ee,value:ke}=ge;A=H,V=Q,W=Ee,$=ke}{const ge=Wt.decode(new Uint8Array(k)),{points:H,bottomIndices:Q,border:Ee,value:ke}=ge;ne=H,ee=Q,G=Ee,le=ke}const re=new u.VertexData,oe=new Float32Array(A.length+ne.length);let Y=V.length+ee.length;Y=Y+((W.length<1?1:W.length)-1)*6;const ce=new Int32Array(Y),ae=new Float32Array($.length+le.length);oe.set(A),ce.set(V),ae.set($),oe.set(ne,A.length),ce.set(ee,V.length),ae.set(le,$.length);const X=[];for(let ge=0;ge<W.length-1;ge++)X.push(W[ge+1]),X.push(W[ge]),X.push(G[ge]+A.length/3),X.push(G[ge+1]+A.length/3),X.push(G[ge]+A.length/3),X.push(W[ge+1]);ce.set(X,V.length+ee.length),re.positions=oe,re.indices=ce,re.colors=ae;const Pe=[];return u.VertexData.ComputeNormals(oe,ce,Pe),re.normals=Pe,y&&(re.applyToMesh(y),i&&y.getScene().onAfterRenderObservable.addOnce(()=>{if(!y.isDisposed()){const H=y.getBoundingInfo();D(H.boundingBox)}})),y&&u.Tags.RemoveTagsFrom(y,"loading"),()=>{y&&new u.VertexData().applyToMesh(y)}}},[k,b,i]),m.useEffect(()=>{var y;_(s.type===$e.ONE_COLOR?(y=s==null?void 0:s.color)!=null?y:u.Color3.Random():x&&P.colorIDs[x]?new u.Color3(P.colorIDs[x].r,P.colorIDs[x].g,P.colorIDs[x].b):u.Color3.Random())},[P.colorIDs,x,s==null?void 0:s.color,s.type]),m.useEffect(()=>{c.current&&(c.current.metadata={pickable:l?{name:f,onLeftClick:l.onLeftClick,onRightClick:l.onRightClick,onMiddleClick:l.onMiddleClick,onHover:l.onHover,needWorldPosition:l.needWorldPosition,extra:l.extra}:null}),p.current&&(p.current.metadata={pickable:l?{name:f,onLeftClick:l.onLeftClick,onRightClick:l.onRightClick,onMiddleClick:l.onMiddleClick,onHover:l.onHover,needWorldPosition:l.needWorldPosition,extra:l.extra}:null})},[l,f]),C.jsx(C.Fragment,{children:C.jsxs("transformNode",{name:`transform-formation-${f}-${e}`,position:F.add(r).multiplyByFloats(T&&T.scalePlane?T.scalePlane:1,T&&T.scaleDepth?T.scaleDepth:1,T&&T.scalePlane?T.scalePlane:1),scaling:new u.Vector3(T?T.scalePlane:1,T?T.scaleDepth:1,T?T.scalePlane:1),setEnabled:o,children:[C.jsx("mesh",{name:`formation-${f}-mesh-${e}`,ref:c,setEnabled:!i,useVertexColors:s.type===$e.COLOR_CODEC,alwaysSelectAsActiveMesh:!0,children:s.type===$e.TEXTURE?M?C.jsx(Kt,{name:`formation-${f}-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,alpha:s.alpha,texture:M,sideTexture:w,tilingFactor:s.tilingFactor,sideTilingFactor:(E=s==null?void 0:s.sideTilingFactor)!=null?E:s==null?void 0:s.tilingFactor,mode:s.textureMode===void 0?qt.PLANE:s.textureMode,boundingBox:I,lines:s.lines,text:s.text,scaleDepth:T?T.scaleDepth:1,scalePlane:T?T.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):C.jsx(C.Fragment,{}):s.type===$e.COLOR_CODEC?s.colorCodec?C.jsx(Mt,{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:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,colorCodec:s.colorCodec,boundingBox:I,lines:s.lines,text:s.text,scaleDepth:T?T.scaleDepth:1,scalePlane:T?T.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):C.jsx(C.Fragment,{}):s.type===$e.COLOR_ID?C.jsx(Mn,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,surfaceCanvasOptions:s.surfaceCanvasOptions,color:v,alphaMode:u.Engine.ALPHA_COMBINE,alpha:s.alpha,boundingBox:I,transparencyMode:u.Material.MATERIAL_ALPHABLEND,lines:s.lines,text:s.text,scaleDepth:T?T.scaleDepth:1,scalePlane:T?T.scalePlane:1,disableDepthWrite:s.disableDepthWrite,disableNormalShadow:s.disableNormalShadow}):C.jsx(Mn,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,color:v,surfaceCanvasOptions:s.surfaceCanvasOptions,alphaMode:u.Engine.ALPHA_COMBINE,alpha:s.alpha,boundingBox:I,transparencyMode:u.Material.MATERIAL_ALPHABLEND,lines:s.lines,text:s.text,scaleDepth:T?T.scaleDepth:1,scalePlane:T?T.scalePlane:1,disableDepthWrite:s.disableDepthWrite,disableNormalShadow:s.disableNormalShadow})}),C.jsx("mesh",{name:`formation-${f}-vol-${e}`,ref:p,setEnabled:i,useVertexColors:s.type===$e.COLOR_CODEC,alwaysSelectAsActiveMesh:!0,children:s.type===$e.TEXTURE?M?C.jsx(Kt,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,alpha:s.alpha,sideTexture:w,texture:M,tilingFactor:s.tilingFactor,sideTilingFactor:(L=s==null?void 0:s.sideTilingFactor)!=null?L:s==null?void 0:s.tilingFactor,mode:s.textureMode===void 0?qt.PLANE:s.textureMode,boundingBox:I,lines:s.lines,text:s.text,scaleDepth:T?T.scaleDepth:1,scalePlane:T?T.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):C.jsx(C.Fragment,{}):s.type===$e.COLOR_CODEC?s.colorCodec?C.jsx(Mt,{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:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,colorCodec:s.colorCodec,boundingBox:I,lines:s.lines,text:s.text,scaleDepth:T?T.scaleDepth:1,scalePlane:T?T.scalePlane:1,disableDepthWrite:s.disableDepthWrite}):C.jsx(C.Fragment,{}):s.type===$e.COLOR_ID?C.jsx(Mn,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,surfaceCanvasOptions:s.surfaceCanvasOptions,color:v,alphaMode:u.Engine.ALPHA_COMBINE,alpha:s.alpha,transparencyMode:u.Material.MATERIAL_ALPHABLEND,boundingBox:I,lines:s.lines,text:s.text,scaleDepth:T?T.scaleDepth:1,scalePlane:T?T.scalePlane:1,disableDepthWrite:s.disableDepthWrite,disableNormalShadow:s.disableNormalShadow}):C.jsx(Mn,{name:`formation-${f}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,surfaceCanvasOptions:s.surfaceCanvasOptions,color:v,alphaMode:u.Engine.ALPHA_COMBINE,alpha:s.alpha,transparencyMode:u.Material.MATERIAL_ALPHABLEND,boundingBox:I,lines:s.lines,text:s.text,scaleDepth:T?T.scaleDepth:1,scalePlane:T?T.scalePlane:1,disableDepthWrite:s.disableDepthWrite,disableNormalShadow:s.disableNormalShadow})}),f&&S&&C.jsx("transformNode",{name:`${f}-title-${e}`,position:S.add(a!=null&&a.offset?a.offset.multiplyByFloats(T!=null&&T.scalePlane?T==null?void 0:T.scalePlane:1,1,T!=null&&T.scalePlane?T==null?void 0:T.scalePlane:1):u.Vector3.Zero()),scaling:ct(T).multiply(new u.Vector3(3,3,3)),setEnabled:n,children:C.jsx(Je,{text:f,fontSize:a!=null&&a.fontSize?a.fontSize:40,color:a!=null&&a.color?a.color:"white"})})]})})},qn=({url:e,showLayerLabel:t=!1,labelStyle:n,position:a=u.Vector3.Zero(),visible:r=!0,showBottomLayer:o=!1,actions:i,material:l={type:$e.COLOR_ID,counterLine:void 0,alpha:1}})=>{var I,D;const s=m.useRef(null),c=m.useRef(null),[p,f]=m.useState(""),[d,x]=m.useState(null),[h,T]=m.useState(u.Color3.White()),P=m.useContext(Le),v=m.useContext(Lt),[_,b]=m.useState(u.Vector3.Zero()),[k,M]=m.useState(),w=je({url:e,cacheType:Me.URL_PREFIX_MATCH}),S=He({url:l==null?void 0:l.texture,cacheType:Me.URL_PREFIX_MATCH}),N=He({url:l==null?void 0:l.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),[F,B]=m.useState(void 0);return m.useEffect(()=>{console.log("[Geo3DViewer] FormationVolume Loading: ",e)},[e]),m.useEffect(()=>{if(w){const E=s.current,L=c.current;u.Tags.EnableFor(E),u.Tags.AddTagsTo(E,"loading"),u.Tags.EnableFor(c),u.Tags.AddTagsTo(c,"loading");let y=[],A=[],V=[],$=[];const W=Wt.decode(new Uint8Array(w)),{name:ne,points:ee,indices:G,colorId:le,side:re,sideIndices:oe,center:Y,value:ce,sideValue:ae}=W;Y&&b(new u.Vector3(Y.x,Y.y,Y.z)),y=ee,A=G,V=re,$=oe,x(le),f(ne);const X=new u.VertexData,Pe=new u.VertexData,ge=new Float32Array(y.length+V.length),H=new Int32Array(A.length+$.length),Q=new Float32Array(ce.length+ae.length);X.positions=y,X.indices=A,X.colors=ce;const Ee=[];u.VertexData.ComputeNormals(ee,G,Ee),X.normals=Ee,ge.set(y),H.set(A),Q.set(ce),ge.set(V,y.length),H.set($,A.length),Q.set(ae,ce.length),Pe.positions=ge,Pe.indices=H,Pe.colors=Q;const ke=[];if(u.VertexData.ComputeNormals(ge,H,ke),Pe.normals=ke,E){X.applyToMesh(E);const te=E.getBoundingInfo();M(te.boundingBox.center.add(new u.Vector3(te.boundingBox.extendSize.x,0,0))),o||E.getScene().onAfterRenderObservable.addOnce(()=>{if(!E.isDisposed()){const ue=E.getBoundingInfo();B(ue.boundingBox)}})}return L&&(Pe.applyToMesh(L),o&&L.getScene().onAfterRenderObservable.addOnce(()=>{if(!L.isDisposed()){const me=L.getBoundingInfo();B(me.boundingBox)}})),u.Tags.RemoveTagsFrom(E,"loading"),u.Tags.RemoveTagsFrom(c,"loading"),()=>{E&&new u.VertexData().applyToMesh(E),L&&new u.VertexData().applyToMesh(L)}}},[w,o]),m.useEffect(()=>{var E;T(l.type===$e.ONE_COLOR?(E=l==null?void 0:l.color)!=null?E:u.Color3.Random():d&&v.colorIDs[d]?new u.Color3(v.colorIDs[d].r,v.colorIDs[d].g,v.colorIDs[d].b):u.Color3.Random())},[v.colorIDs,d,l==null?void 0:l.color,l.type]),m.useEffect(()=>{s.current&&(s.current.metadata={pickable:i?{name:p,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,needWorldPosition:i.needWorldPosition,extra:i.extra}:null}),c.current&&(c.current.metadata={pickable:i?{name:p,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,needWorldPosition:i.needWorldPosition,extra:i.extra}:null})},[i,p]),C.jsx(C.Fragment,{children:C.jsxs("transformNode",{name:`transform-formation-${p}-${e}`,position:_.add(a).multiplyByFloats(P&&P.scalePlane?P.scalePlane:1,P&&P.scaleDepth?P.scaleDepth:1,P&&P.scalePlane?P.scalePlane:1),scaling:new u.Vector3(P?P.scalePlane:1,P?P.scaleDepth:1,P?P.scalePlane:1),setEnabled:r,children:[C.jsx("mesh",{name:`formation-${p}-mesh-${e}`,ref:s,setEnabled:!o,useVertexColors:l.type===$e.COLOR_CODEC,children:l.type===$e.TEXTURE?S?C.jsx(Kt,{name:`formation-${p}-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,alpha:l.alpha,flatModeRotate:l.flatModeRotate,sideTexture:N,texture:S,tilingFactor:l.tilingFactor,sideTilingFactor:(I=l==null?void 0:l.sideTilingFactor)!=null?I:l==null?void 0:l.tilingFactor,mode:l.textureMode===void 0?qt.PLANE:l.textureMode,counterLine:l.counterLine,boundingBox:F,lines:l.lines,text:l.text,scaleDepth:P?P.scaleDepth:1,scalePlane:P?P.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):C.jsx(C.Fragment,{}):l.type===$e.COLOR_CODEC?l.colorCodec?C.jsx(Mt,{name:`formation-${p}-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,alpha:l.alpha,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,colorCodec:l.colorCodec,counterLine:l.counterLine,boundingBox:F,lines:l.lines,text:l.text,scaleDepth:P?P.scaleDepth:1,scalePlane:P?P.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):C.jsx(C.Fragment,{}):l.type===$e.COLOR_ID?C.jsx(An,{name:`formation-${p}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,color:h,alphaMode:u.Engine.ALPHA_COMBINE,alpha:l.alpha,lightPosition:l.lightPosition,intensity:l.intensity,surfaceCanvasOptions:l.surfaceCanvasOptions,transparencyMode:u.Material.MATERIAL_ALPHABLEND,boundingBox:F,lines:l.lines,text:l.text,zOffset:l.zOffset,zOffsetUnits:l.zOffsetUnits,contrast:l.contrast,sideIntensity:l.sideIntensity,cullFace:l.cullFace,scaleDepth:P?P.scaleDepth:1,scalePlane:P?P.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):C.jsx(An,{name:`formation-${p}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,color:h,alphaMode:u.Engine.ALPHA_COMBINE,surfaceCanvasOptions:l.surfaceCanvasOptions,alpha:l.alpha,lightPosition:l.lightPosition,intensity:l.intensity,transparencyMode:u.Material.MATERIAL_ALPHABLEND,boundingBox:F,lines:l.lines,text:l.text,zOffset:l.zOffset,zOffsetUnits:l.zOffsetUnits,contrast:l.contrast,sideIntensity:l.sideIntensity,cullFace:l.cullFace,scaleDepth:P?P.scaleDepth:1,scalePlane:P?P.scalePlane:1,disableDepthWrite:l.disableDepthWrite})}),C.jsx("mesh",{name:`formation-${p}-vol-${e}`,ref:c,setEnabled:o,useVertexColors:l.type===$e.COLOR_CODEC,children:l.type===$e.TEXTURE?S?C.jsx(Kt,{name:`formation-${p}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,alpha:l.alpha,sideTexture:N,texture:S,tilingFactor:l.tilingFactor,sideTilingFactor:(D=l==null?void 0:l.sideTilingFactor)!=null?D:l==null?void 0:l.tilingFactor,mode:l.textureMode===void 0?qt.PLANE:l.textureMode,flatModeRotate:l.flatModeRotate,counterLine:l.counterLine,boundingBox:F,lines:l.lines,text:l.text,scaleDepth:P?P.scaleDepth:1,scalePlane:P?P.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):C.jsx(C.Fragment,{}):l.type===$e.COLOR_CODEC?l.colorCodec?C.jsx(Mt,{name:`formation-${p}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,alpha:l.alpha,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,colorCodec:l.colorCodec,counterLine:l.counterLine,boundingBox:F,lines:l.lines,text:l.text,scaleDepth:P?P.scaleDepth:1,scalePlane:P?P.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):C.jsx(C.Fragment,{}):l.type===$e.COLOR_ID?C.jsx(An,{name:`formation-${p}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,color:h,surfaceCanvasOptions:l.surfaceCanvasOptions,alphaMode:u.Engine.ALPHA_COMBINE,alpha:l.alpha,lightPosition:l.lightPosition,intensity:l.intensity,transparencyMode:u.Material.MATERIAL_ALPHABLEND,boundingBox:F,lines:l.lines,text:l.text,zOffset:l.zOffset,zOffsetUnits:l.zOffsetUnits,contrast:l.contrast,sideIntensity:l.sideIntensity,cullFace:l.cullFace,scaleDepth:P?P.scaleDepth:1,scalePlane:P?P.scalePlane:1,disableDepthWrite:l.disableDepthWrite}):C.jsx(An,{name:`formation-${p}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,color:h,surfaceCanvasOptions:l.surfaceCanvasOptions,alphaMode:u.Engine.ALPHA_COMBINE,alpha:l.alpha,lightPosition:l.lightPosition,intensity:l.intensity,transparencyMode:u.Material.MATERIAL_ALPHABLEND,boundingBox:F,lines:l.lines,text:l.text,zOffset:l.zOffset,zOffsetUnits:l.zOffsetUnits,contrast:l.contrast,sideIntensity:l.sideIntensity,cullFace:l.cullFace,scaleDepth:P?P.scaleDepth:1,scalePlane:P?P.scalePlane:1,disableDepthWrite:l.disableDepthWrite})}),p&&k&&C.jsx("transformNode",{name:`${p}-title-${e}`,position:k.add(n!=null&&n.offset?n.offset.multiplyByFloats(P!=null&&P.scalePlane?P==null?void 0:P.scalePlane:1,1,P!=null&&P.scalePlane?P==null?void 0:P.scalePlane:1):u.Vector3.Zero()),scaling:ct(P).multiply(new u.Vector3(3,3,3)),setEnabled:t,children:C.jsx(Je,{text:p,fontSize:n!=null&&n.fontSize?n.fontSize:40,color:n!=null&&n.color?n.color:"white"})})]})})};var Uo=(e=>(e[e.FACE=0]="FACE",e[e.VOLUME=1]="VOLUME",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Uo||{});function Mu(e){switch(e){case 0:case"FACE":return 0;case 1:case"VOLUME":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function Lu(e){switch(e){case 0:return"FACE";case 1:return"VOLUME";case-1:default:return"UNRECOGNIZED"}}function jr(){return{name:"",formations:[],mode:0,effectMeshs:[]}}const kn={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.formations)cn.encode(n,t.uint32(34).fork()).ldelim();e.mode!==0&&t.uint32(40).int32(e.mode);for(const n of e.effectMeshs)We.encode(n,t.uint32(50).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=jr();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(cn.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(We.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:Dn(e.name)?globalThis.String(e.name):"",formations:globalThis.Array.isArray(e==null?void 0:e.formations)?e.formations.map(t=>cn.fromJSON(t)):[],mode:Dn(e.mode)?Mu(e.mode):0,effectMeshs:globalThis.Array.isArray(e==null?void 0:e.effectMeshs)?e.effectMeshs.map(t=>We.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=>cn.toJSON(r))),e.mode!==0&&(t.mode=Lu(e.mode)),(a=e.effectMeshs)!=null&&a.length&&(t.effectMeshs=e.effectMeshs.map(r=>We.toJSON(r))),t},create(e){return kn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o;const t=jr();return t.name=(n=e.name)!=null?n:"",t.formations=((a=e.formations)==null?void 0:a.map(i=>cn.fromPartial(i)))||[],t.mode=(r=e.mode)!=null?r:0,t.effectMeshs=((o=e.effectMeshs)==null?void 0:o.map(i=>We.fromPartial(i)))||[],t}};function ei(){return{name:"",url:""}}const cn={encode(e,t=se.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=ei();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:Dn(e.name)?globalThis.String(e.name):"",url:Dn(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 cn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=ei();return t.name=(n=e.name)!=null?n:"",t.url=(a=e.url)!=null?a:"",t}};function Dn(e){return e!=null}const Ho=({url:e,alpha:t=1,position:n=u.Vector3.Zero(),visible:a=!0,colorCodec:r,actions:o,counterLine:i=void 0,lines:l,text:s,disableDepthWrite:c})=>{const p=m.useRef(null),[f,d]=m.useState(""),x=m.useContext(Le),h=m.useContext(Lt),[T,P]=m.useState(null),[v,_]=m.useState(u.Color3.White()),b=je({url:e,cacheType:Me.URL_PREFIX_MATCH}),[k,M]=m.useState(u.Vector3.Zero()),[w,S]=m.useState();return m.useEffect(()=>{console.log("[Geo3DViewer] StructureLayer Loading: ",e)},[e]),m.useEffect(()=>{if(b){const N=p.current;u.Tags.EnableFor(N),u.Tags.AddTagsTo(N,"loading");const F=Wt.decode(new Uint8Array(b)),{name:B,points:I,indices:D,value:E,colorId:L,center:y}=F;y&&M(new u.Vector3(y.x,y.y,y.z));const A=new u.VertexData;A.positions=I,A.indices=D,A.colors=E;const V=[];return u.VertexData.ComputeNormals(I,D,V),A.normals=V,P(L),d(B),N&&(A.applyToMesh(N),N.getScene().onAfterRenderObservable.addOnce(()=>{if(!N.isDisposed()){const W=N.getBoundingInfo();S(W.boundingBox)}})),u.Tags.RemoveTagsFrom(N,"loading"),()=>{P(null),d(""),N&&new u.VertexData().applyToMesh(N)}}},[b]),m.useEffect(()=>{const N=T&&h.colorIDs[T]?h.colorIDs[T]:u.Color3.White();_(u.Color3.FromArray([N.r,N.g,N.b]))},[T,h.colorIDs]),m.useEffect(()=>{p.current&&(p.current.metadata={pickable:o?{name:f,onLeftClick:o.onLeftClick,onRightClick:o.onRightClick,onMiddleClick:o.onMiddleClick,onHover:o.onHover,needWorldPosition:o.needWorldPosition,extra:o.extra}:null})},[o,f]),C.jsx(C.Fragment,{children:C.jsxs("transformNode",{name:`transform-structurelayer-${f}`,position:k.add(n).multiplyByFloats(x&&x.scalePlane?x.scalePlane:1,x&&x.scaleDepth?x.scaleDepth:1,x&&x.scalePlane?x.scalePlane:1),scaling:new u.Vector3(x?x.scalePlane:1,x?x.scaleDepth:1,x?x.scalePlane:1),setEnabled:a,children:[C.jsx("transformNode",{name:`structurelayer-${f}-load`}),C.jsx("mesh",{name:`structurelayer-${f}-mesh`,ref:p,useVertexColors:r!=null,children:r?C.jsx(Mt,{name:`structurelayer-${f}-mat`,backFaceCulling:!1,alpha:t,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,colorCodec:r,needDepthPrePass:!0,counterLine:i,boundingBox:w,lines:l,scaleDepth:x?x.scaleDepth:1,scalePlane:x?x.scalePlane:1,text:s,disableDepthWrite:c}):C.jsx("standardMaterial",{name:`structurelayer-${f}-mat`,backFaceCulling:!1,specularColor:new u.Color3(0,0,0),ambientColor:new u.Color3(1,1,1),diffuseColor:v,needDepthPrePass:!0,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,alpha:t,disableDepthWrite:c})})]})})},Ru=e=>{const{id:t,visible:n=!0,position:a=u.Vector3.Zero(),diffuseTextureUrl:r,diffuseTextureSufaceUrl:o,bumpTextureUrl:i,mesh:l}=e,s=m.useRef(null),c=m.useContext(Le),[p,f]=m.useState(),[d,x]=m.useState(),[h,T]=m.useState();return m.useEffect(()=>{const P=s.current;if(P&&l){const v=new u.VertexData;v.positions=l.vertices,v.indices=l.indices,v.uvs=l.uv;const _=[];u.VertexData.ComputeNormals(l.vertices,l.indices,_),v.normals=_,v.applyToMesh(P)}},[l,l==null?void 0:l.indices,l==null?void 0:l.uv,l==null?void 0:l.vertices]),m.useEffect(()=>{const P=new u.Texture(r);if(P.uScale=500,P.vScale=.5,f(P),o){const _=new u.Texture(o);_.uScale=500,_.vScale=.5,x(_)}const v=new u.Texture(i);v.uScale=500,v.vScale=.5,T(v)},[i,o,r]),C.jsx(C.Fragment,{children:C.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 u.Vector3(c?c.scalePlane:1,c?c.scaleDepth:1,c?c.scalePlane:1),setEnabled:n,children:C.jsx("mesh",{name:"mesh",ref:s,children:C.jsx("standardMaterial",{name:`edge-${t}-material`,zOffset:-1,zOffsetUnits:-1,diffuseTexture:o?d:p,bumpTexture:o?void 0:h})})})})},oa=({url:e,visible:t=!0,filter:n,explodedView:a=0,showLayerLabel:r,labelStyle:o,offset:i=new u.Vector3(0,0,0),showTopLayerAsStructureLayer:l=!1,useColorCodecOnTopLayer:s=!1,colorCodec:c,actions:p,materials:f,topLayerCounterLine:d=void 0,topLayerHeightOffset:x=1,diffuseTextureUrl:h,diffuseTextureSufaceUrl:T,bumpTextureUrl:P,visibleEdgeEffect:v=!1})=>{var D,E;const[_,b]=m.useState(),k=m.useContext(Le),[M,w]=m.useState(!0),[S,N]=m.useState(""),F=je({url:e,cacheType:Me.URL_PREFIX_MATCH}),[B,I]=m.useState([]);return m.useEffect(()=>{console.log("[Geo3DViewer] ComplexFormationManager Loading: ",e)},[e]),m.useEffect(()=>{if(F){const L=kn.decode(new Uint8Array(F)),y=L.formations;if(L.mode==Uo.FACE){w(!0),N(L.name);const A=[];y.forEach((V,$)=>{const W={name:V.name,topUrl:V.url,bottomUrl:y[$+1]?y[$+1].url:void 0};A.push(W)}),b(A)}else{w(!1),N(L.name);const A=[];y.forEach(V=>{const $={name:V.name,topUrl:V.url};A.push($)}),b(A)}return console.log(L),I(L.effectMeshs),()=>{b([])}}},[F]),C.jsxs("abstractMesh",{name:`complexformationmanager-${S}`,children:[l&&_&&_.length>1?C.jsx(Ho,{url:_[0].topUrl,alpha:(D=f==null?void 0:f[_[0].name])==null?void 0:D.alpha,position:new u.Vector3(0,x>=0?x*(k&&(E=k.scaleDepth)!=null?E:1):0,0).add(i),visible:t&&(n?n.includes(_[0].name):!0),colorCodec:c,counterLine:d},`${S}-${_[0].name}-SL`):null,_?_.map((L,y)=>M?l&&y===0?C.jsx(C.Fragment,{}):C.jsx("transformNode",{name:`${S}-${L.name}-EV`,position:i.add(new u.Vector3(0,y*(-1*a*(k&&k.scaleDepth?k.scaleDepth:0)),0)),children:C.jsx(Xn,{showLayerLabel:r,labelStyle:o,urlTopLayer:L.topUrl,urlBottomLayer:L.bottomUrl,visible:t&&(n?n.includes(L.name):!0),showBottomLayer:_[y+1]?n?n.includes(_[y+1].name):!0:!1,actions:p,material:y===0&&s?{...f==null?void 0:f[L.name],colorCodec:c,type:$e.COLOR_CODEC}:f==null?void 0:f[L.name]},`${S}-${L.name}`)},`${S}-${L.name}`):l&&y===0?C.jsx(C.Fragment,{}):C.jsx("transformNode",{name:`${S}-${L.name}-EV`,position:i.add(new u.Vector3(0,y*(-1*a*(k&&k.scaleDepth?k.scaleDepth:0)),0)),children:C.jsx(qn,{url:L.topUrl,showLayerLabel:r,labelStyle:o,visible:t&&(n?n.includes(L.name):!0),showBottomLayer:_[y+1]?n?n.includes(_[y+1].name):!0:!1,actions:p,material:f==null?void 0:f[L.name]},`${S}-${L.name}`)},`${S}-${L.name}`)):null,B&&h&&P&&a===0&&B.map((L,y)=>C.jsx(Ru,{visible:v,id:y,diffuseTextureUrl:h,diffuseTextureSufaceUrl:y===0?T:void 0,bumpTextureUrl:P,mesh:L},y))]})},ra=({visible:e=!0,color:t=u.Color3.White(),fontSize:n=80,step:a=200,keyFrameDistance:r=[],keyFrameStep:o=[],keyFrameFontSize:i=[],textureSizeX:l=512,textureSizeY:s=512,init:c=!0})=>{const p=_e.useScene(),f=m.useRef(null),d=m.useContext(Le),[x,h]=m.useState([]),[T,P]=m.useState([]),[v,_]=m.useState([]),[b,k]=m.useState(0),M=m.useCallback(w=>{if(p&&w){const S=new ss.GridMaterial("axis-material",p);S.majorUnitFrequency=o.length>0?o[0]:50,S.minorUnitVisibility=0,S.gridRatio=2,S.sideOrientation=u.Material.ClockWiseSideOrientation,S.backFaceCulling=!0,S.mainColor=t,S.lineColor=t,S.opacity=.98,w.material=S}},[t,o,p]);return m.useEffect(()=>()=>{var w;(w=f.current)==null||w.dispose()},[]),m.useEffect(()=>{const w=()=>{const S=(p==null?void 0:p.activeCamera).radius;for(let N=0;N<r.length;N++)if(S<=r[N]){k(N);break}};return p&&p.activeCamera&&(p==null||p.activeCamera.onViewMatrixChangedObservable.add(w)),()=>{p&&p.activeCamera&&(p==null||p.activeCamera.onViewMatrixChangedObservable.removeCallback(w))}},[r,i,o,p,e]),m.useEffect(()=>{if(d&&d.min&&d.max&&c){const w=d.origin||u.Vector3.Zero(),S=[],N=[],F=[],B=[...o];B.length===0&&B.push(a);for(let I=0;I<B.length;I++){let D=B[I]/1;D<1&&(D=200);const E=[];for(let A=0;A<=d.max.x-d.min.x;A+=D)E.push({text:`${A+d.min.x+w.x}`,position:new u.Vector3(A,0,0)}),E.push({text:`${A+d.min.x+w.x}`,position:new u.Vector3(A,d.max.y-d.min.y,d.max.z-d.min.z)}),E.push({text:`${A+d.min.x+w.x}`,position:new u.Vector3(A,d.max.y-d.min.y,0)}),E.push({text:`${A+d.min.x+w.x}`,position:new u.Vector3(A,0,d.max.z-d.min.z)});S.push(E);const L=[];for(let A=0;A<=d.max.y-d.min.y;A+=D)L.push({text:`${A+d.min.y+w.y}`,position:new u.Vector3(0,A,0)}),L.push({text:`${A+d.min.y+w.y}`,position:new u.Vector3(d.max.x-d.min.x,A,d.max.z-d.min.z)}),L.push({text:`${A+d.min.y+w.y}`,position:new u.Vector3(d.max.x-d.min.x,A,0)}),L.push({text:`${A+d.min.y+w.y}`,position:new u.Vector3(0,A,d.max.z-d.min.z)});N.push(L);const y=[];for(let A=0;A<=d.max.z-d.min.z;A+=D)y.push({text:`${A+d.min.z+w.z}`,position:new u.Vector3(0,0,A)}),y.push({text:`${A+d.min.z+w.z}`,position:new u.Vector3(d.max.x-d.min.x,d.max.y-d.min.y,A)}),y.push({text:`${A+d.min.z+w.z}`,position:new u.Vector3(0,d.max.y-d.min.y,A)}),y.push({text:`${A+d.min.z+w.z}`,position:new u.Vector3(d.max.x-d.min.x,0,A)});F.push(y)}h(S),P(N),_(F)}},[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?C.jsxs("transformNode",{name:"coord",setEnabled:e,position:(d&&d.min&&d.max?u.Vector3.Center(d.min,d.max):u.Vector3.Zero()).multiply(Oe(d)),scaling:new u.Vector3(Oe(d).x,Oe(d).y,Oe(d).z),children:[C.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:M,isPickable:!1,isBlocker:!1},`axis-${d.max.x-d.min.x}-${d.max.y-d.min.y}-${d.max.z-d.min.z}`),C.jsxs("transformNode",{name:"axis-offset",position:d&&d.min&&d.max?new u.Vector3(-(d.max.x-d.min.x)/2,-(d.max.y-d.min.y)/2,-(d.max.z-d.min.z)/2):u.Vector3.Zero(),children:[x.map((w,S)=>w.map((N,F)=>{var I;const B=N;return C.jsx("transformNode",{name:`axis-x-${S}-${F}`,position:B==null?void 0:B.position,setEnabled:S===b,scaling:new u.Vector3(1/Oe(d).x,1/Oe(d).y,1/Oe(d).z),children:C.jsx(Je,{text:`${B?B.text:""}`,fontSize:(I=i[S])!=null?I:n,color:t.toHexString()})},`axis-x-${S}-${F}`)})),T.map((w,S)=>w.map((N,F)=>{var I;const B=N;return C.jsx("transformNode",{name:`axis-x-${S}-${F}`,position:B==null?void 0:B.position,setEnabled:S===b,scaling:new u.Vector3(1/Oe(d).x,1/Oe(d).y,1/Oe(d).z),children:C.jsx(Je,{text:`${B?B.text:""}`,fontSize:(I=i[S])!=null?I:n,color:t.toHexString()})},`axis-x-${S}-${F}`)})),v.map((w,S)=>w.map((N,F)=>{var I;const B=N;return C.jsx("transformNode",{name:`axis-x-${S}-${F}`,position:B==null?void 0:B.position,setEnabled:S===b,scaling:new u.Vector3(1/Oe(d).x,1/Oe(d).y,1/Oe(d).z),children:C.jsx(Je,{text:`${B?B.text:""}`,fontSize:(I=i[S])!=null?I:n,color:t.toHexString()})},`axis-x-${S}-${F}`)}))]})]},`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)}`):C.jsx(C.Fragment,{})};function Bu(e){switch(e){case 0:case"NORMAL":return 0;case 1:case"CICLE":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function Fu(e){switch(e){case 0:return"NORMAL";case 1:return"CICLE";case-1:default:return"UNRECOGNIZED"}}function ti(){return{name:"",lines:[]}}const ia={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.lines)fn.encode(n,t.uint32(18).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=ti();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(fn.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:ko(e.name)?globalThis.String(e.name):"",lines:globalThis.Array.isArray(e==null?void 0:e.lines)?e.lines.map(t=>fn.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=>fn.toJSON(a))),t},create(e){return ia.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=ti();return t.name=(n=e.name)!=null?n:"",t.lines=((a=e.lines)==null?void 0:a.map(r=>fn.fromPartial(r)))||[],t}};function ni(){return{positions:[]}}const un={encode(e,t=se.Writer.create()){for(const n of e.positions)rt.encode(n,t.uint32(10).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=ni();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.positions.push(rt.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=>rt.fromJSON(t)):[]}},toJSON(e){var n;const t={};return(n=e.positions)!=null&&n.length&&(t.positions=e.positions.map(a=>rt.toJSON(a))),t},create(e){return un.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=ni();return t.positions=((n=e.positions)==null?void 0:n.map(a=>rt.fromPartial(a)))||[],t}};function oi(){return{segments:[],type:0,position:void 0}}const fn={encode(e,t=se.Writer.create()){for(const n of e.segments)un.encode(n,t.uint32(10).fork()).ldelim();return e.type!==0&&t.uint32(16).int32(e.type),e.position!==void 0&&rt.encode(e.position,t.uint32(26).fork()).ldelim(),t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=oi();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.segments.push(un.decode(n,n.uint32()));continue;case 2:if(o!==16)break;r.type=n.int32();continue;case 3:if(o!==26)break;r.position=rt.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=>un.fromJSON(t)):[],type:ko(e.type)?Bu(e.type):0,position:ko(e.position)?rt.fromJSON(e.position):void 0}},toJSON(e){var n;const t={};return(n=e.segments)!=null&&n.length&&(t.segments=e.segments.map(a=>un.toJSON(a))),e.type!==0&&(t.type=Fu(e.type)),e.position!==void 0&&(t.position=rt.toJSON(e.position)),t},create(e){return fn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=oi();return t.segments=((n=e.segments)==null?void 0:n.map(r=>un.fromPartial(r)))||[],t.type=(a=e.type)!=null?a:0,t.position=e.position!==void 0&&e.position!==null?rt.fromPartial(e.position):void 0,t}};function ko(e){return e!=null}const Zo=({points:e=[],showPoint:t=!0,color:n=u.Color3.White(),pointSize:a=2,alwaysOnTop:r=!1,offset:o=u.Vector3.Zero(),alpha:i,lineWidth:l})=>{const s=_e.useScene(),c=m.useRef(null),p=m.useContext(Le);return m.useEffect(()=>{if(s){const f=[],d=Oe(p);if(e.forEach(x=>{f.push(x.add(o).multiply(d))}),l){const x={path:f,radius:l,updatable:!0};if(c.current)x.instance=c.current,u.MeshBuilder.CreateTube("line",x);else{c.current=u.MeshBuilder.CreateTube("line",x,s);const h=new u.StandardMaterial("line-mat");return h.diffuseColor=n,h.specularColor=u.Color3.Black(),h.emissiveColor=n,i!==void 0&&(h.alpha=i,h.transparencyMode=2),h.depthFunction=r?u.Constants.ALWAYS:0,c.current.material=h,()=>{c.current&&(s.removeMesh(c.current),c.current=null)}}}else{const x={points:f,updateable:!0};if(c.current)x.instance=c.current,u.MeshBuilder.CreateLines("line",x);else{c.current=u.MeshBuilder.CreateLines("line",x,s);const h=new u.StandardMaterial("line-mat");return h.diffuseColor=n,h.specularColor=u.Color3.Black(),h.emissiveColor=n,i!==void 0&&(h.alpha=i,h.transparencyMode=2),h.depthFunction=r?u.Constants.ALWAYS:0,()=>{c.current&&(s.removeMesh(c.current),c.current=null)}}}}},[r,n,p,o,e,s,l,c,i]),C.jsx("transformNode",{name:"transform-line",children:t?C.jsx("transformNode",{name:"lines-point",children:e.map((f,d)=>C.jsx("sphere",{diameter:a,name:`lines-point-${d}`,position:f.add(o).multiply(Oe(p)),scalingDeterminant:l&&(p==null?void 0:p.scalePlane)||1,children:C.jsx("standardMaterial",{name:`lines-point-${d}-mat`,diffuseColor:n,emissiveColor:n,specularColor:u.Color3.White(),depthFunction:r?u.Constants.ALWAYS:void 0})},`lines-point-${f.x}-${f.y}-${f.z}`))}):C.jsx(C.Fragment,{})})},Du=e=>{const{name:t,prev:n,next:a,textColor:r,fontSize:o}=e,i=_e.useScene(),l=m.useRef(null);return m.useEffect(()=>{const s=i==null?void 0:i.activeCamera,c=i==null?void 0:i.getEngine();if(i&&s&&c&&l.current){const p=l.current.getChildren()[0],f=u.Vector3.Normalize(a.subtract(n)),d=new u.Vector3(1,0,0),x=Math.acos(u.Vector3.Dot(f,d)),h=u.Vector3.Cross(f,d);p.rotation.z=h.y>0?x:Math.PI*2-x,p.rotation.x=Math.PI/2,p.renderingGroupId=3}},[a,n,i]),C.jsx("transformNode",{name:`${t}`,position:u.Vector3.Lerp(n,a,.5),ref:l,children:C.jsx(Je,{text:t,fontSize:o,color:r,billboardMode:u.Mesh.BILLBOARDMODE_NONE})})},zu=e=>{const{url:t,color:n,alpha:a,visible:r=!0,fontSize:o=30,textColor:i="red",linewidth:l=10}=e,s=_e.useScene(),[c,p]=m.useState([]),[f,d]=m.useState([]),x=m.useContext(Le);return m.useEffect(()=>{Ut.get(t,{responseType:"arraybuffer"}).then(h=>{const T=ia.decode(new Uint8Array(h.data));console.log(T);const P=[],v=[];for(let _=0;_<T.lines.length;_++){const b=T.lines[_];if(b.segments.length<2)continue;const k=[];for(let M=0;M<b.segments.length;M++){const w=[...Ts(b.segments[M].positions)];P.push([...w]),k.push(w[0]),k.push(w[w.length-1])}b.type===1&&k.push(Oi(b.segments[0].positions[0])),v.push(k)}p(P),d(v),console.log(v),console.log(P)})},[s,t]),C.jsxs("transformNode",{name:"contourline",setEnabled:r,children:[c.map((h,T)=>h.length<2||!r?null:C.jsx(Zo,{points:h,showPoint:!1,color:n,alpha:a,lineWidth:l,alwaysOnTop:!0},T)),f.map(h=>h.map((T,P)=>P%2===0||P===h.length-1?null:C.jsx(Du,{name:T.y.toFixed(0),prev:Oe(x).multiply(T),next:Oe(x).multiply(h[P+1]),fontSize:o,textColor:i},P)))]})};function Vu(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 $u(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 ri(){return{layer:0,direction:0,colorId:0,points:[],indices:[],value:[],vMin:0,vMax:0,center:void 0}}const Go={encode(e,t=se.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&&K.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=ri();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=K.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{layer:tn(e.layer)?globalThis.Number(e.layer):0,direction:tn(e.direction)?Vu(e.direction):0,colorId:tn(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:tn(e.vMin)?globalThis.Number(e.vMin):0,vMax:tn(e.vMax)?globalThis.Number(e.vMax):0,center:tn(e.center)?K.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=$u(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=K.toJSON(e.center)),t},create(e){return Go.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,l,s,c;const t=ri();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(p=>p))||[],t.indices=((i=e.indices)==null?void 0:i.map(p=>p))||[],t.value=((l=e.value)==null?void 0:l.map(p=>p))||[],t.vMin=(s=e.vMin)!=null?s:0,t.vMax=(c=e.vMax)!=null?c:0,t.center=e.center!==void 0&&e.center!==null?K.fromPartial(e.center):void 0,t}};function tn(e){return e!=null}const Yo=({name:e,url:t,visible:n=!0,colorCodec:a,alpha:r=1,position:o=u.Vector3.Zero(),actions:i})=>{const l=m.useRef(null),[s,c]=m.useState(""),[p,f]=m.useState(""),d=m.useContext(Le),x=je({url:t,cacheType:Me.URL_PREFIX_MATCH}),[h,T]=m.useState(u.Vector3.Zero());return m.useEffect(()=>{const P=l.current;if(!x||!P)return;u.Tags.EnableFor(P),u.Tags.AddTagsTo(P,"loading");const v=Go.decode(new Uint8Array(x)),{layer:_,direction:b,points:k,indices:M,value:w,center:S}=v,N=new u.VertexData;N.positions=k,N.indices=M,N.colors=w;const F=[];u.VertexData.ComputeNormals(k,M,F),N.normals=F,S&&T(new u.Vector3(S.x,S.y,S.z)),N.applyToMesh(P),c(_.toString()),f(b.toString()),u.Tags.RemoveTagsFrom(P,"loading")},[x]),m.useEffect(()=>{l.current&&(l.current.metadata={pickable:i?{name:e,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,needWorldPosition:i.needWorldPosition,extra:i.extra}:null})},[i,e]),m.useEffect(()=>{console.log("[Geo3DViewer] DensitySlice Loading: ",t)},[t]),C.jsx(C.Fragment,{children:C.jsx("transformNode",{name:`densityslice-${e}-${p}-${s}-transform`,position:h.add(o).multiplyByFloats(d&&d.scalePlane?d.scalePlane:1,d&&d.scaleDepth?d.scaleDepth:1,d&&d.scalePlane?d.scalePlane:1),scaling:new u.Vector3(d?d.scalePlane:1,d?d.scaleDepth:1,d?d.scalePlane:1),children:C.jsx("mesh",{name:`densityslice-${e}-${p}-${s}-mesh`,ref:l,setEnabled:n,useVertexColors:!0,children:C.jsx(Mt,{name:`densityslice-${e}-${p}-${s}-mat`,backFaceCulling:!1,needDepthPrePass:!0,alpha:r,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,colorCodec:a})})})})},aa=()=>{const e=_e.useScene(),t=m.useRef(void 0);return m.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]),m.useEffect(()=>{var n,a;if(e&&!t.current){const r=nt.AdvancedDynamicTexture.CreateFullscreenUI("UI",!0,e);t.current=r;const o=new nt.TextBlock("fps");o.text="0FPS",o.color="white",o.fontSize=15,o.width=100,o.height=50;const i=window.devicePixelRatio||1,l=(n=e.getEngine().getRenderingCanvas())==null?void 0:n.clientHeight,s=(a=e.getEngine().getRenderingCanvas())==null?void 0:a.clientWidth;o.left=s?-(s*i/2-50):0,o.top=l?-(l*i/2-25):0,r.addControl(o)}return()=>{e&&t.current}},[e]),null},sa=({url:e,visible:t=!0,filter:n,explodedView:a=0,offset:r=new u.Vector3(0,0,0),showLayerLabel:o,labelStyle:i,actions:l,materials:s})=>{const[c,p]=m.useState(),f=m.useContext(Le),[d,x]=m.useState(!0),[h,T]=m.useState(""),P=je({url:e,cacheType:Me.URL_PREFIX_MATCH});return m.useEffect(()=>{console.log("[Geo3DViewer] FormationManager Loading: ",e)},[e]),m.useEffect(()=>{if(P){const v=kn.decode(new Uint8Array(P)),_=v.formations;if(v.mode==Uo.FACE){x(!0),T(v.name);const b=[];_.forEach((k,M)=>{const w={name:k.name,topUrl:k.url,bottomUrl:_[M+1]?_[M+1].url:void 0};b.push(w)}),p(b)}else{x(!1),T(v.name);const b=[];_.forEach(k=>{const M={name:k.name,topUrl:k.url};b.push(M)}),p(b)}return console.log(_),()=>{T(""),p([])}}},[P]),C.jsx("abstractMesh",{name:`formationmanager-${h}`,children:c?c.map((v,_)=>d?C.jsx("transformNode",{name:`${h}-${v.name}-EV`,position:r.add(new u.Vector3(0,_*(-1*a*(f&&f.scaleDepth?f.scaleDepth:0)),0)),children:C.jsx(Xn,{showLayerLabel:o,labelStyle:i,urlTopLayer:v.topUrl,urlBottomLayer:v.bottomUrl,visible:t&&(n?n.includes(v.name):!0),showBottomLayer:c[_+1]?n?n.includes(c[_+1].name):!0:!1,actions:l,material:s==null?void 0:s[v.name]},`${h}-${v.name}`)},`${h}-${v.name}`):C.jsx("transformNode",{name:`${h}-${v.name}-EV`,position:r.add(new u.Vector3(0,_*(-1*a*(f&&f.scaleDepth?f.scaleDepth:0)),0)),children:C.jsx(qn,{url:v.topUrl,showLayerLabel:o,labelStyle:i,visible:t&&(n?n.includes(v.name):!0),showBottomLayer:c[_+1]?n?n.includes(c[_+1].name):!0:!1,actions:l,material:s==null?void 0:s[v.name]},`${h}-${v.name}`)},`${h}-${v.name}`)):null})};function ii(){return{name:"",slices:[],center:void 0}}const Jo={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.slices)dn.encode(n,t.uint32(18).fork()).ldelim();return e.center!==void 0&&K.encode(e.center,t.uint32(250).fork()).ldelim(),t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=ii();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(dn.decode(n,n.uint32()));continue;case 31:if(o!==250)break;r.center=K.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:zn(e.name)?globalThis.String(e.name):"",slices:globalThis.Array.isArray(e==null?void 0:e.slices)?e.slices.map(t=>dn.fromJSON(t)):[],center:zn(e.center)?K.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=>dn.toJSON(a))),e.center!==void 0&&(t.center=K.toJSON(e.center)),t},create(e){return Jo.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=ii();return t.name=(n=e.name)!=null?n:"",t.slices=((a=e.slices)==null?void 0:a.map(r=>dn.fromPartial(r)))||[],t.center=e.center!==void 0&&e.center!==null?K.fromPartial(e.center):void 0,t}};function ai(){return{name:"",colorId:0,vertices:[],indices:[],edges:[]}}const dn={encode(e,t=se.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)K.encode(n,t.uint32(42).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=ai();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(K.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:zn(e.name)?globalThis.String(e.name):"",colorId:zn(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=>K.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=>K.toJSON(o))),t},create(e){return dn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=ai();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(l=>l))||[],t.indices=((o=e.indices)==null?void 0:o.map(l=>l))||[],t.edges=((i=e.edges)==null?void 0:i.map(l=>K.fromPartial(l)))||[],t}};function zn(e){return e!=null}const Wu=(e,t)=>{var y,A,V,$;const n=_e.useScene(),a=m.useRef(null),r=m.useRef(null),o=m.useContext(Le),i=m.useContext(Lt),[l,s]=m.useState(u.Color3.White()),{id:c,visible:p=!0,vertices:f,indices:d,colorId:x,position:h,normals:T,material:P={type:$e.COLOR_ID},children:v,alpha:_=1,style:b,name:k="formation",highStyle:M,lowStyle:w,edges:S=[],actions:N,actionName:F}=e,B=He({url:P==null?void 0:P.texture,cacheType:Me.URL_PREFIX_MATCH}),I=He({url:P==null?void 0:P.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),[D,E]=m.useState();m.useImperativeHandle(t,()=>r.current,[]),m.useEffect(()=>{if(a&&a.current&&n){const W=new u.VertexData;W.positions=f,W.indices=d,W.normals=T;const ne=a.current;W.applyToMesh(ne),ne.getScene().onAfterRenderObservable.addOnce(()=>{if(!ne.isDisposed()){const G=ne.getBoundingInfo();E(G.boundingBox)}})}},[d,f,n,c,T]),m.useEffect(()=>{a.current&&(a.current.metadata={pickable:N?{name:F!=null?F:k,onLeftClick:N.onLeftClick,onRightClick:N.onRightClick,onMiddleClick:N.onMiddleClick,onHover:N.onHover,extra:N.extra,needWorldPosition:N.needWorldPosition}:null})},[F,N,k]),m.useEffect(()=>{var W;s(P.type===$e.ONE_COLOR?(W=P==null?void 0:P.color)!=null?W:u.Color3.Random():x&&i.colorIDs[x]?new u.Color3(i.colorIDs[x].r,i.colorIDs[x].g,i.colorIDs[x].b):u.Color3.Random())},[i.colorIDs,x,P==null?void 0:P.color,P.type]);const L=(W,ne,ee)=>{const G=ne.subtract(W),le=1+1e3/u.Vector3.Distance(W,ne)*(ee-1),re=G.scale(le);return W.add(re)};return C.jsxs("transformNode",{name:`node-${k}-${c}`,setEnabled:p,children:[C.jsxs("transformNode",{name:`${k}`,position:h?h.multiply(Oe(o)):new u.Vector3(0,0,0),scaling:Oe(o),ref:r,children:[C.jsx("mesh",{name:`${k}-mesh`,ref:a,children:P.type===$e.TEXTURE?B?C.jsx(Kt,{name:`formationslice-${k}-mat`,backFaceCulling:!1,needDepthPrePass:P.needDepthPrePass===void 0?!1:P.needDepthPrePass,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,alpha:_,sideTexture:I,texture:B,tilingFactor:P.tilingFactor,sideTilingFactor:(y=P==null?void 0:P.sideTilingFactor)!=null?y:P==null?void 0:P.tilingFactor,mode:P.textureMode===void 0?qt.PLANE:P.textureMode,boundingBox:D,lines:P.lines,text:P.text,scaleDepth:o?o.scaleDepth:1,scalePlane:o?o.scalePlane:1,disableDepthWrite:P.disableDepthWrite}):C.jsx(C.Fragment,{}):P.type===$e.COLOR_CODEC?P.colorCodec?C.jsx(Mt,{name:`formation-${k}-mat`,backFaceCulling:!1,needDepthPrePass:P.needDepthPrePass===void 0?!1:P.needDepthPrePass,alpha:_,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,colorCodec:P.colorCodec,boundingBox:D,lines:P.lines,text:P.text,scaleDepth:o?o.scaleDepth:1,scalePlane:o?o.scalePlane:1,disableDepthWrite:P.disableDepthWrite}):C.jsx(C.Fragment,{}):P.type===$e.COLOR_ID?C.jsx("standardMaterial",{name:`formation-${k}-mat`,backFaceCulling:!1,needDepthPrePass:P.needDepthPrePass===void 0?!1:P.needDepthPrePass,specularColor:new u.Color3(0,0,0),ambientColor:new u.Color3(1,1,1),diffuseColor:l,alphaMode:u.Engine.ALPHA_COMBINE,alpha:_,transparencyMode:u.Material.MATERIAL_ALPHABLEND,disableDepthWrite:P.disableDepthWrite}):C.jsx("standardMaterial",{name:`formation-${k}-mat`,backFaceCulling:!1,needDepthPrePass:P.needDepthPrePass===void 0?!1:P.needDepthPrePass,specularColor:new u.Color3(0,0,0),ambientColor:new u.Color3(1,1,1),diffuseColor:l,alphaMode:u.Engine.ALPHA_COMBINE,alpha:_,transparencyMode:u.Material.MATERIAL_ALPHABLEND,disableDepthWrite:P.disableDepthWrite})}),b.position&&C.jsx("transformNode",{name:`${k}-title`,position:L(At(b.basePosition==="left"?S[4]:S[5]),b.position,(A=b.offset)!=null?A:1),scaling:ct(o),children:b.title&&C.jsx(Je,{text:b.title,fontSize:b.fontSize?b.fontSize:40,color:b.color?b.color:"black"})}),w&&w.position&&C.jsx("transformNode",{name:`${k}-up-title`,position:L(At(w.basePosition==="left"?S[4]:S[5]),w.position,(V=w.offset)!=null?V:1),scaling:ct(o),children:w.title&&C.jsx(Je,{text:w.title,fontSize:w.fontSize?w.fontSize:40,color:w.color?w.color:"black"})}),M&&M.position&&C.jsx("transformNode",{name:`${k}-down-title`,position:L(At(M.basePosition==="left"?S[4]:S[5]),M.position,($=M.offset)!=null?$:1),scaling:ct(o),children:M.title&&C.jsx(Je,{text:M.title,fontSize:M.fontSize?M.fontSize:40,color:M.color?M.color:"black"})})]}),v]})},Uu=m.forwardRef(Wu),Xo=e=>{const[t,n]=m.useState([]),[a,r]=m.useState(""),{url:o,visible:i=!0,materials:l,actions:s,style:c,highStyle:p,lowStyle:f,basePosition:d="left"}=e,x=m.useContext(Le),h=je({url:o,cacheType:Me.URL_PREFIX_MATCH}),[T,P]=m.useState(u.Vector3.Zero());return m.useEffect(()=>{console.log("[Geo3DViewer] FormationSlice Loading: ",o)},[o]),m.useEffect(()=>{if(h){const v=Jo.decode(new Uint8Array(h));v.center&&P(new u.Vector3(v.center.x,v.center.y,v.center.z));const _=v.slices.map(b=>{const k=[];return u.VertexData.ComputeNormals(b.vertices,b.indices,k),{name:b.name,colorId:b.colorId,vertices:b.vertices,indices:b.indices,edges:b.edges,normals:k}});return r(v.name),n(_),()=>{r(""),n([])}}},[h]),C.jsx(C.Fragment,{children:C.jsx("transformNode",{name:`foramtionslice-${a}-holder`,setEnabled:i,position:T.multiply(Oe(x)),children:t.map((v,_)=>{const b=v.edges.length>0?At(d==="left"?v.edges[0]:v.edges[2]):new u.Vector3(0,0,0),k=v.edges.length>0?At(d==="left"?v.edges[1]:v.edges[3]):new u.Vector3(0,0,0),M=u.Vector3.Lerp(b,k,.5);return C.jsx(Uu,{id:_,vertices:v.vertices,indices:v.indices,colorId:v.colorId,normals:v.normals,name:v.name,edges:v.edges,style:c?{position:M,title:v.name,basePosition:d,...c}:{},lowStyle:f?{position:k,title:(T.y+k.y).toFixed(0).toString(),basePosition:d,...f}:{},highStyle:p&&_===t.length-1?{position:b,title:(T.y+b.y).toFixed(0).toString(),basePosition:d,...p}:{},material:l?{...l[v.name],backFaceCulling:!1}:void 0,actions:s,actionName:a},_)})})})},Hu=e=>{const{name:t="node",text:n,fontSize:a,color:r,position:o=u.Vector3.Zero(),scale:i=u.Vector3.One(),blink:l=!1}=e,[s,c]=m.useState(!0);return m.useEffect(()=>{const p=setInterval(()=>{l&&c(f=>!f)},1e3);return()=>{clearInterval(p)}},[l]),C.jsx("transformNode",{name:`${t}-text`,position:o,scaling:i,setEnabled:s,children:C.jsx(Je,{name:t,text:n,fontSize:a,color:r})})};var Bt=(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))(Bt||{});const la=({target:e,radius:t,alpha:n,beta:a,axesViewerOffset:r=u.Vector3.Zero(),panningSensibility:o=2,wheelDeltaPercentage:i=0,axesViewer:l=0,farPlane:s=1e4,skipPickingWhenCameraMoves:c=!1})=>{const p=_e.useScene(),f=m.useContext(Le),[d,x]=m.useState(null),[h,T]=m.useState(null),[P,v]=m.useState(n),[_,b]=m.useState(a),[,k]=m.useState(null),M=m.useCallback(B=>{T(B)},[]),{setViewCamera:w}=m.useContext(Mo),S=m.useCallback(()=>{if(h&&d){const B=new u.Vector3;B.addInPlace(h.position),B.addInPlace(h.getDirection(new u.Vector3(0,0,25))),l==4?(B.addInPlace(h.getDirection(new u.Vector3(0,7+r.y,0))),B.addInPlace(h.getDirection(new u.Vector3(15+r.x,0,0)))):l==3?(B.addInPlace(h.getDirection(new u.Vector3(0,7+r.y,0))),B.addInPlace(h.getDirection(new u.Vector3(-15+r.x,0,0)))):l==2?(B.addInPlace(h.getDirection(new u.Vector3(0,-7+r.y,0))),B.addInPlace(h.getDirection(new u.Vector3(15+r.x,0,0)))):l==1&&(B.addInPlace(h.getDirection(new u.Vector3(0,-7+r.y,0))),B.addInPlace(h.getDirection(new u.Vector3(-15+r.x,0,0)))),d.xAxis.position=B.clone(),d.yAxis.position=B.clone(),d.zAxis.position=B.clone()}},[h,d,l,r.y,r.x]);m.useEffect(()=>{if(p&&l!=0){const B=new u.AxesViewer(p,2,null);return x(B),()=>{B==null||B.dispose(),x(null)}}},[p,l]),m.useEffect(()=>{S()},[S]);const N=m.useCallback(B=>{if(f&&f.min&&f.max)return u.Vector3.Clamp(B,f==null?void 0:f.min,f==null?void 0:f.max)},[f]),F=m.useCallback(B=>{p&&(p.skipPointerMovePicking=B)},[p]);return m.useEffect(()=>{if(!p||!h)return;const B=h.onViewMatrixChangedObservable.add(()=>{c&&(F(!0),k(I=>(I&&clearTimeout(I),setTimeout(()=>{F(!1),k(null)},250)))),v(h.alpha),b(h.beta),S()});return()=>{h.onViewMatrixChangedObservable.remove(B),k(I=>(I&&clearTimeout(I),null)),F(!1)}},[p,l,h,f,d,S,N,F,c]),m.useEffect(()=>{w(p&&h?h:void 0)},[p,h,w]),m.useEffect(()=>{},[N,f,e]),C.jsx(C.Fragment,{children:e&&C.jsx("arcRotateCamera",{name:"rootCamera",target:e,radius:t,alpha:P,beta:_,maxZ:s,panningSensibility:o,wheelDeltaPercentage:i,ref:M,setActiveOnSceneIfNoneActive:!0})})},Zu=(e,t)=>{const{position:n=u.Vector3.Zero(),axesViewer:a=Bt.NONE,axesViewerOffset:r=u.Vector3.Zero(),skipPickingWhenCameraMoves:o=!1,wheelDeltaPercentage:i=3,rotationSensibility:l=1,panningSensibility:s=10}=e,c=_e.useScene(),p=m.useContext(Le),[f,d]=m.useState(null),[x,h]=m.useState(null),{setViewCamera:T,cameraRefObject:P}=m.useContext(Mo),[,v]=m.useState(null),_=m.useRef(null),[b,k]=m.useState(null),M=m.useRef(null),w=m.useCallback(I=>{c&&(c.skipPointerMovePicking=I)},[c]);m.useEffect(()=>(M.current=new u.ArcRotateCamera("dummy-camera",0,0,.1,u.Vector3.Zero(),c||void 0,!1),()=>{var I;(I=M.current)==null||I.dispose()}),[c]),m.useEffect(()=>{if(c){const I=x,D=c.onPointerObservable.add(E=>{if(E.type===u.PointerEventTypes.POINTERDOWN&&(_.current=new u.Vector2(E.event.clientX,E.event.clientY)),E.type===u.PointerEventTypes.POINTERUP&&(_.current=null),E.type===u.PointerEventTypes.POINTERMOVE&&_.current){const L=E.event.clientX-_.current.x,y=E.event.clientY-_.current.y;if(E.event.buttons===1){let A=null;(I.lockedTarget||b)&&(I.lockedTarget&&(A=I.lockedTarget.position),b&&(A=b)),A&&M.current?(M.current.target=A,M.current.position=I.position.clone(),M.current.wheelDeltaPercentage=i,M.current.panningSensibility=s,M.current.alpha+=L/100*l,M.current.beta+=y/100*l,M.current.update(),I.position=M.current.position.clone(),I.rotation=M.current.rotation.clone()):(I.rotation.y-=L/100*l,I.rotation.x-=y/100*l)}E.event.buttons===2&&(I.position.x-=L/100*s,I.position.y+=y/100*s),_.current=new u.Vector2(E.event.clientX,E.event.clientY)}});return()=>{c.onPointerObservable.remove(D)}}},[b,s,x,l,c,i]);const S=m.useCallback(I=>{I&&(I.inputs.addMouseWheel(),I.inputs.removeMouse(),T(I),h(I))},[T]);m.useEffect(()=>{if(x){const I=x.inputs.attached.mousewheel;I.wheelPrecisionX=i,I.wheelPrecisionY=i,I.wheelPrecisionZ=i}},[x,i]);const N=m.useCallback(()=>{if(x&&f){const I=new u.Vector3;I.addInPlace(x.position),I.addInPlace(x.getDirection(new u.Vector3(0,0,25))),a==Bt.TOP_RIGHT?(I.addInPlace(x.getDirection(new u.Vector3(0,7+r.y,0))),I.addInPlace(x.getDirection(new u.Vector3(15+r.x,0,0)))):a==Bt.TOP_LEFT?(I.addInPlace(x.getDirection(new u.Vector3(0,7+r.y,0))),I.addInPlace(x.getDirection(new u.Vector3(-15+r.x,0,0)))):a==Bt.BOTTOM_RIGHT?(I.addInPlace(x.getDirection(new u.Vector3(0,-7+r.y,0))),I.addInPlace(x.getDirection(new u.Vector3(15+r.x,0,0)))):a==Bt.BOTTOM_LEFT&&(I.addInPlace(x.getDirection(new u.Vector3(0,-7+r.y,0))),I.addInPlace(x.getDirection(new u.Vector3(-15+r.x,0,0)))),f.xAxis.position=I.clone(),f.yAxis.position=I.clone(),f.zAxis.position=I.clone()}},[x,f,a,r.y,r.x]);m.useEffect(()=>{if(c&&a!=Bt.NONE){const I=new u.AxesViewer(c,2,null);return d(I),()=>{I==null||I.dispose(),d(null)}}},[c,a]),m.useEffect(()=>{N()},[N]),m.useEffect(()=>{T(c&&x?x:void 0)},[c,x,T]),m.useEffect(()=>{if(!c||!x)return;const I=x.onViewMatrixChangedObservable.add(()=>{o&&(w(!0),v(D=>(D&&clearTimeout(D),setTimeout(()=>{w(!1),v(null)},250)))),N()});return()=>{x.onViewMatrixChangedObservable.remove(I),v(D=>(D&&clearTimeout(D),null)),w(!1)}},[c,a,x,p,f,N,o,w]);const[F,B]=m.useState();return m.useEffect(()=>{if(x){const I={lookAt:D=>{x&&x.setTarget(D)},updatePosition:D=>{x&&(x.position=D)},lockTarget:D=>{x&&(k(null),x.lockedTarget=D)},lockTo:D=>{x&&(x.lockedTarget=null,k(D))}};B(I),P&&P.current&&(P.current.rawCamera=x,P.current.cameraTools=I)}},[P,x]),m.useImperativeHandle(t,()=>({rawCamera:x,cameraTools:F}),[F,x]),C.jsx("universalCamera",{name:"universal-main-camera",position:n,ref:S,maxZ:0})},Gu=m.forwardRef(Zu);class Yu extends u.BaseCameraPointersInput{constructor(){super(...arguments);ve(this,"camera");ve(this,"buttons",[0,1,2,4]);ve(this,"panningSensibility",10);ve(this,"angularSensibility",1e4);ve(this,"_isPanClick",!1);ve(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),u.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=u.Quaternion.FromEulerAngles(this.camera.rotation.x,this.camera.rotation.y,this.camera.rotation.z),i=u.Quaternion.RotationAxis(u.Axis.Y,u.Tools.ToDegrees(a/this.angularSensibility)),l=u.Quaternion.RotationAxis(u.Axis.X,u.Tools.ToDegrees(r/this.angularSensibility)),s=o.multiply(i).multiply(l);this.camera.rotation=s.toEulerAngles()}}onLostFocus(){this._isPanClick=!1,this._isPinching=!1}}const Ju=e=>{const{position:t,target:n=new u.Vector3(0,0,0),panningSensibility:a=5,angularSensibility:r=2e3,skipPickingWhenCameraMoves:o=!1}=e,i=_e.useScene(),l=m.useRef(null),s=m.useRef(null),c=m.useCallback(p=>{i&&(i.skipPointerMovePicking=p)},[i]);return m.useEffect(()=>{if(l.current){l.current.inputs.removeByType("FreeCameraMouseInput");const p=new Yu,f=new u.FreeCameraMouseWheelInput;l.current.inputs.add(p),l.current.inputs.add(f)}},[]),m.useEffect(()=>{l.current&&n&&l.current.setTarget(n)},[n]),m.useEffect(()=>{if(!i||!l.current)return;const p=l.current.onViewMatrixChangedObservable.add(()=>{o&&(c(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{c(!1),s.current=null},250))});return()=>{var f;(f=l.current)==null||f.onViewMatrixChangedObservable.remove(p),s.current&&(clearTimeout(s.current),s.current=null),c(!1)}},[i,c,o]),m.useEffect(()=>{if(l.current){if(l.current.inputs.attached.pointers){const p=l.current.inputs.attached.pointers;p.panningSensibility=Math.abs(a),p.angularSensibility=Math.abs(r)}if(l.current.inputs.attached.pointersPanning){const p=l.current.inputs.attached.pointersPanning;p.panningSensibility=Math.abs(a)}if(l.current.inputs.attached.around){const p=l.current.inputs.attached.around;p.angularSensibility=Math.abs(r)}}},[r,a]),C.jsx("freeCamera",{name:"rootCamera",position:t,ref:l})};class Xu extends u.TransformNode{constructor(n,a,r){super(n,a);ve(this,"_showDepthTexture",!1);ve(this,"_postProcess");this._postProcess=r,this.showDepthTexture=!1,this.inspectableCustomProperties=[{label:"Show Depth Texture",propertyName:"showDepthTexture",type:u.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 qu=()=>{const e=_e.useEngine(),t=_e.useScene();return m.useEffect(()=>{if(t&&e){u.Effect.ShadersStore.depthbufferPixelShader=`#ifdef GL_ES
1212
1212
  precision highp float;
1213
1213
  #endif
1214
1214
 
@@ -1224,7 +1224,7 @@ precision highp float;
1224
1224
  #endif
1225
1225
 
1226
1226
  void main(void)
1227
- {}`;const n=new u.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 Yu("Depth Texture Debugger",t,n),i=t.getTransformNodeByName("Debugger");return i&&(a.parent=i),()=>{var o;(o=t.activeCamera)==null||o.detachPostProcess(n),a&&t.removeTransformNode(a),a.dispose(),n.dispose()}}},[t,e]),C.jsx(C.Fragment,{})};class Xu extends u.TransformNode{constructor(n,a,i){super(n,a);ve(this,"_showGPUPicking",!1);ve(this,"_postProcess");this._postProcess=i,this.showGPUPicking=!1,this.inspectableCustomProperties=[{label:"Show GPU Picking Texture",propertyName:"showGPUPicking",type:u.InspectableType.Checkbox}]}set showGPUPicking(n){var a,i;this._showGPUPicking=n,this._postProcess&&(this._showGPUPicking?(a=this.getScene().activeCamera)==null||a.attachPostProcess(this._postProcess):(i=this.getScene().activeCamera)==null||i.detachPostProcess(this._postProcess))}get showGPUPicking(){return this._showGPUPicking}}const qu=()=>{const e=_e.useEngine(),t=_e.useScene(),n=m.useContext(Mi);return m.useEffect(()=>{if(t&&e&&n&&n&&n.gpuPickingTexture.current){u.Effect.ShadersStore.gpuPickingBufferPixelShader=`#ifdef GL_ES
1227
+ {}`;const n=new u.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 Xu("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]),C.jsx(C.Fragment,{})};class Ku extends u.TransformNode{constructor(n,a,r){super(n,a);ve(this,"_showGPUPicking",!1);ve(this,"_postProcess");this._postProcess=r,this.showGPUPicking=!1,this.inspectableCustomProperties=[{label:"Show GPU Picking Texture",propertyName:"showGPUPicking",type:u.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 Qu=()=>{const e=_e.useEngine(),t=_e.useScene(),n=m.useContext(Mi);return m.useEffect(()=>{if(t&&e&&n&&n&&n.gpuPickingTexture.current){u.Effect.ShadersStore.gpuPickingBufferPixelShader=`#ifdef GL_ES
1228
1228
  precision highp float;
1229
1229
  #endif
1230
1230
 
@@ -1240,9 +1240,9 @@ precision highp float;
1240
1240
  #endif
1241
1241
 
1242
1242
  void main(void)
1243
- {}`;const a=new u.PostProcess("GPU Picking Display","gpuPickingBuffer",null,null,1,null,void 0,e,!0);a.onApply=r=>{r._bindTexture("textureSampler",n.gpuPickingTexture.current.getInternalTexture())};const i=new Xu("GPU Picking Debugger",t,a),o=t.getTransformNodeByName("Debugger");return o&&(i.parent=o),()=>{var r;(r=t.activeCamera)==null||r.detachPostProcess(a),i&&t.removeTransformNode(i),i.dispose(),a.dispose()}}},[t,e,n]),C.jsx(C.Fragment,{})},Ku=({showDebugLayer:e=!1})=>{const t=_e.useScene(),n=_e.useEngine();return m.useEffect(()=>{n&&t&&(e?(n.captureGPUFrameTime=a=>{},jn.Inspector.Show(t,{embedMode:!0})):jn.Inspector.Hide())},[n,t,e]),m.useEffect(()=>()=>{t&&jn.Inspector.Hide()},[t]),C.jsxs("transformNode",{name:"Debugger",children:[C.jsx(Ju,{}),C.jsx(qu,{})]})},Qu=()=>{const e=_e.useScene(),t=_e.useEngine();return m.useEffect(()=>{const n=t;if(window.BABYLON&&n)return window.BABYLON.EngineStore.Instances.push(n),rs.registerBuiltInLoaders(),()=>{if(window.BABYLON){const a=window.BABYLON.EngineStore.Instances.indexOf(n);a>-1&&window.BABYLON.EngineStore.Instances.splice(a,1)}}},[t]),m.useEffect(()=>{const n=t;if(n)return u.EngineStore.Instances.push(n),()=>{const a=window.BABYLON.EngineStore.Instances.indexOf(n);a>-1&&window.BABYLON.EngineStore.Instances.splice(a,1)}},[t]),m.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]),m.useEffect(()=>{const n=e;if(n)return u.EngineStore._LastCreatedScene=e,()=>{u.EngineStore._LastCreatedScene===n&&(u.EngineStore._LastCreatedScene=null)}},[e]),m.useEffect(()=>{e&&(e._forceBlockMaterialDirtyMechanism=a=>{e._blockMaterialDirtyMechanism=a})},[e]),C.jsx(C.Fragment,{})};class ju{constructor(){ve(this,"urls",[]);ve(this,"resources",new Map);ve(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,i;if(this.listeners.has(t)){const o=(a=this.listeners.get(t))==null?void 0:a.findIndex(r=>r===n);o!==void 0&&o!==-1&&((i=this.listeners.get(t))==null||i.splice(o,1))}}notifyProgress(t,n){var a;(a=this.listeners.get(t))==null||a.forEach(i=>i.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(i=>i.onError(n))}download(t,n="BIN"){if(n==="BIN"){Ut.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 ca=m.createContext(void 0),ef=(e,t="BIN")=>{const n=m.useContext(ca),[a,i]=m.useState(void 0),o=m.useMemo(()=>{const r={onProgress:function(l){console.log(l)},onComplete:function(l){console.log(e,l),i(l)},onError:function(l){console.log(l),n==null||n.removeListener(e,r)}};return r},[n,e]);return m.useEffect(()=>(n==null||n.load(e,t,o),()=>{n==null||n.removeListener(e,o)}),[o,n,t,e]),a},tf=(e,t)=>{const{children:n,showDebugLayer:a=!1,meta:i,colorProvider:o,cacheProvider:r,options:l={backgroundColor:u.Color4.FromArray([.2,.2,.3,1]),light:{intensity:1,direction:new u.Vector3(1,1,1)}}}=e,{light:s={intensity:1,direction:new u.Vector3(1,1,1)}}=l,{intensity:c=1,direction:p=new u.Vector3(1,1,1)}=s,f=m.useRef(null),[d,x]=m.useState(!1);return m.useEffect(()=>{console.log(`
1244
- %c Geo3DViewer Library %c Version: 1.7.40 %c
1245
- `,"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;")},[]),m.useImperativeHandle(t,()=>({scene:f,camera:null}),[f]),m.useEffect(()=>{a&&x(!0)},[a]),C.jsx(_e.Engine,{antialias:!0,adaptToDeviceRatio:!0,canvasId:"rootGeo3DCanvas",engineOptions:{useHighPrecisionFloats:!0,depth:!0,useHighPrecisionMatrix:!0,stencil:!0},children:C.jsxs(_e.Scene,{clearColor:l.backgroundColor,useRightHandedSystem:l.useRightHandedSystem,children:[C.jsx(Qu,{}),C.jsx("ground",{name:"picking-material-holder",setEnabled:!1,children:C.jsx(Pu,{})}),C.jsx(ca.Provider,{value:new ju,children:C.jsxs(bs,{workspaceMeta:i,colorProvider:o,cacheProvider:r,ref:f,children:[d||a?C.jsx(Ku,{showDebugLayer:a}):null,C.jsx("hemisphericLight",{name:"light",intensity:c,direction:p}),n]})}),l.environment?C.jsx("cubeTexture",{assignTo:"environmentTexture",rootUrl:l.environment}):C.jsx(C.Fragment,{})]})})},Jo=m.forwardRef(tf);var Et=(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))(Et||{});function nf(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 of(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 ii(){return{name:"",step:0,xCount:0,yCount:0,zCount:0,xSliceUrl:"",ySliceUrl:"",zSliceUrl:"",mode:0}}const ua={encode(e,t=se.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=ii();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 2:if(o!==16)break;i.step=n.uint32();continue;case 3:if(o!==24)break;i.xCount=n.uint32();continue;case 4:if(o!==32)break;i.yCount=n.uint32();continue;case 5:if(o!==40)break;i.zCount=n.uint32();continue;case 6:if(o!==50)break;i.xSliceUrl=n.string();continue;case 7:if(o!==58)break;i.ySliceUrl=n.string();continue;case 8:if(o!==66)break;i.zSliceUrl=n.string();continue;case 9:if(o!==72)break;i.mode=n.int32();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{name:kt(e.name)?globalThis.String(e.name):"",step:kt(e.step)?globalThis.Number(e.step):0,xCount:kt(e.xCount)?globalThis.Number(e.xCount):0,yCount:kt(e.yCount)?globalThis.Number(e.yCount):0,zCount:kt(e.zCount)?globalThis.Number(e.zCount):0,xSliceUrl:kt(e.xSliceUrl)?globalThis.String(e.xSliceUrl):"",ySliceUrl:kt(e.ySliceUrl)?globalThis.String(e.ySliceUrl):"",zSliceUrl:kt(e.zSliceUrl)?globalThis.String(e.zSliceUrl):"",mode:kt(e.mode)?nf(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=of(e.mode)),t},create(e){return ua.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i,o,r,l,s,c,p;const t=ii();return t.name=(n=e.name)!=null?n:"",t.step=(a=e.step)!=null?a:0,t.xCount=(i=e.xCount)!=null?i:0,t.yCount=(o=e.yCount)!=null?o:0,t.zCount=(r=e.zCount)!=null?r:0,t.xSliceUrl=(l=e.xSliceUrl)!=null?l:"",t.ySliceUrl=(s=e.ySliceUrl)!=null?s:"",t.zSliceUrl=(c=e.zSliceUrl)!=null?c:"",t.mode=(p=e.mode)!=null?p:0,t}};function kt(e){return e!=null}const fa=({name:e,url:t,step:n,visible:a=!0,colorCodec:i,alpha:o=1,actions:r,materials:l})=>{const[s,c]=m.useState(),[p,f]=m.useState(0),d=je({url:t,cacheType:Me.URL_PREFIX_MATCH});return m.useEffect(()=>{console.log("[Geo3DViewer] GriDDiagram Loading: ",t)},[t]),m.useEffect(()=>{if(d){const x=ua.decode(new Uint8Array(d)),{xCount:h,zCount:T,xSliceUrl:P,zSliceUrl:v}=x,_=[];if(x.mode===Et.ATTRIBUTE||x.mode===Et.COLOR){if(n<=0){console.error("[Geo3DViewer] 此文件为动态数据文件,step 值必须大于 0"),c([]),f(0);return}let b=0;for(let k=0;k<h;k+=n)_.push(P.replace("%s",k.toString())),b=k;b>=h&&_.push(P.replace("%s",(h-1).toString()));for(let k=0;k<T;k+=n)_.push(v.replace("%s",k.toString())),b=k;b>=T&&_.push(v.replace("%s",(T-1).toString()))}else if(x.mode===Et.STATIC_ATTRIBUTE||x.mode===Et.STATIC_COLOR){if(n!==0){console.error("[Geo3DViewer] 静态栅状图数据必须传入 step=0 以确认您明确此数据无法使用动态加载模式"),c([]),f(0);return}for(let b=0;b<h;b+=1)_.push(P.replace("%s",b.toString()))}return c(_),f(x.mode===Et.ATTRIBUTE?1:x.mode===Et.COLOR?2:x.mode===Et.STATIC_ATTRIBUTE?1:x.mode===Et.STATIC_COLOR?2:0),()=>{c([]),f(0)}}},[d,n]),C.jsx("abstractMesh",{name:`gridDiagram-${e}`,children:p===1?s?s.map((x,h)=>C.jsx(Zo,{name:e,url:x,visible:a,colorCodec:i,alpha:o,actions:r},`densityslice-group-${e}-${x}-${h}`)):C.jsx(C.Fragment,{}):p===2?s?s.map((x,h)=>C.jsx(Yo,{url:x,visible:a,materials:l,actions:r},`formationslice-group-${e}-${x}-${h}`)):C.jsx(C.Fragment,{}):C.jsx(C.Fragment,{})})},da=({name:e,position:t,width:n,height:a,color:i,lineWidth:o,rotation:r,showDebugPlane:l=!1})=>{const s=m.useContext(Le),c=m.useRef(null),p=Tu({name:e,lineColor:i,lineWidth:o});return m.useEffect(()=>{c.current&&(c.current.material=p)},[p]),C.jsxs("transformNode",{name:`intersecting-line-${e}`,position:t.multiply(Oe(s)),rotation:r||u.Vector3.Zero(),children:[C.jsx("plane",{name:e,width:n,height:a,isPickable:!1,isBlocker:!1,ref:c}),C.jsx("plane",{name:e,width:n,height:a,isPickable:!1,isBlocker:!1,setEnabled:l,children:C.jsx("standardMaterial",{name:"intersecting-line-material",diffuseColor:u.Color3.Gray(),backFaceCulling:!1,alpha:.5,transparencyMode:u.Material.MATERIAL_ALPHABLEND})})]})},pa=e=>{const t=_e.useScene(),{target:n,distance:a}=e;return m.useEffect(()=>{if(t&&t.activeCamera&&n){const i=t.activeCamera;let o=new u.Vector3(0,0,0);if(typeof n=="string"){const r=t.getMeshById(n);r&&(o=r.getBoundingInfo().boundingBox.center)}else n.position?o=n.getBoundingInfo().boundingBox.center:o=n;if(i instanceof u.ArcRotateCamera){i.setTarget(o),i.radius=a;return}if(i instanceof u.FreeCamera){const r=o,l=i.position.clone(),s=a/u.Vector3.Distance(r,l),p=l.subtract(r).scale(s),f=r.add(p);i.position=f,i.setTarget(o)}return}},[a,t,n]),null},ha=e=>{const t=e.getChildren();return t.length>0?[e,...ha(t[0])]:[e]},rf=e=>{if(!e.hasVertexAlpha)return!1;const t=e.getVertexBuffer(u.VertexBuffer.ColorKind),n=e.getVerticesData(u.VertexBuffer.ColorKind);if(!t||!n)return!1;const a=t.getSize();if(a<4)return!1;let i=!1,o=!1;for(let r=3;r<n.length;r+=a){const l=n[r];if(!Number.isFinite(l))return!0;if(i=!0,l>1/255){o=!0;break}}return i&&!o},af=({name:e,url:t,position:n=u.Vector3.Zero(),rotation:a=u.Vector3.Zero(),localScale:i=1,visible:o=!0,showPickingBox:r=!1,useGlobalScale:l=!1,actions:s,alpha:c=1,boneRotation:p,pickingBoxScale:f=u.Vector3.One(),labelStyle:d},x)=>{const h=_e.useScene(),T=Ri({url:t}),P=m.useRef(null),v=m.useRef(null),[_,b]=m.useState(null),[k,M]=m.useState(5),[w,S]=m.useState(5),[N,F]=m.useState(5),[B,I]=m.useState(u.Vector3.Zero()),[D,E]=m.useState(u.Vector3.One()),[L,y]=m.useState([]),A=m.useContext(Le),{scaleWithParent:V=!0}=d||{};return m.useEffect(()=>{console.log("[Geo3DViewer] ModelLoader Loading: ",t)},[t]),m.useImperativeHandle(x,()=>v.current,[]),m.useEffect(()=>{if(T){const $=T.instantiateModelsToScene(W=>`${e}-${W}`,!0);return console.log("[Geo3DViewer] ModelLoader 实例化: ",e),b($),()=>{console.log("[Geo3DViewer] ModelLoader 反实例化: ",e),b(null)}}},[T,e]),m.useEffect(()=>{if(_){const $=_,W=$.skeletons;if(W&&W.length>0){const ee=W[0].bones,G=[];ee.filter(le=>le.name==="MorphBoneBase").forEach((le,re)=>{if(re===0){const oe=ha(le);G.push(...oe.map(Y=>{var ce;return(ce=Y.getTransformNode())!=null?ce:Y}))}}),y(G),console.log("[Geo3DViewer] ModelLoader 设定 Morph 骨骼: ",G)}return()=>{console.log("[Geo3DViewer] ModelLoader 注销 Model"),$.dispose(),y([])}}},[_]),m.useEffect(()=>{p&&L&&(console.log("[Geo3DViewer] ModelLoader 设定骨骼旋转"),L.forEach(($,W)=>{p.length>W?$.rotation=p[W]:$.rotation=u.Vector3.Zero()}),(!p||p.length===0)&&console.log("[Geo3DViewer] ModelLoader 的鼠标拾取功能由于 boneRotation 被禁用"))},[p,L]),m.useEffect(()=>{P.current&&(P.current.metadata={pickable:s?{name:e,onLeftClick:s.onLeftClick,onRightClick:s.onRightClick,onMiddleClick:s.onMiddleClick,onHover:s.onHover,needWorldPosition:s.needWorldPosition,valueCallback:null,extra:s.extra}:null})},[s,e]),m.useEffect(()=>{if(h&&_&&v.current){console.log("[Geo3DViewer] ModelLoader 创建容器: ",e);const $=new u.TransformNode(`amesh-model-${e}`);$.parent=v.current,_.rootNodes.forEach(oe=>{oe&&(oe.parent=$)}),$.computeWorldMatrix(!0),u.PivotTools._RemoveAndStorePivotPoint($);const W=$.parent;$.parent=null;const ne=u.Quaternion.RotationYawPitchRoll($.rotation.y,$.rotation.x,$.rotation.z),ee=new u.Vector3($.position.x,$.position.y,$.position.z);$.rotation.set(0,0,0),$.position.set(0,0,0);const G=$.getHierarchyBoundingVectors(!0),le=G.max.subtract(G.min);M(le.y),S(le.z),F(le.x),E(ne.toEulerAngles());const re=new u.Vector3((G.max.x+G.min.x)/2,(G.max.y+G.min.y)/2,(G.max.z+G.min.z)/2);return I(re),$.position=ee,$.rotationQuaternion=ne,$.parent=W,u.PivotTools._RestorePivotPoint($),console.log("[Geo3DViewer] 创建 ModelLoader 鼠标拾取外框 ",e," 于 ",re," 大小为 ",le.x,le.y,le.z),()=>{console.log("[Geo3DViewer] ModelLoader 注销容器: ",e),$.dispose()}}},[_,e,h]),m.useEffect(()=>{_&&_.rootNodes.forEach($=>{$.getChildMeshes().forEach(W=>{rf(W)&&(console.warn(`[Geo3DViewer] ModelLoader disabled broken vertex alpha for ${W.name||e}`),W.hasVertexAlpha=!1),W.material&&(W.material.alpha=c,W.material.transparencyMode=c<1?u.Material.MATERIAL_ALPHABLEND:u.Material.MATERIAL_OPAQUE)})})},[_,c]),C.jsx("transformNode",{name:`transform-model-${e}`,position:n,rotation:a,scalingDeterminant:i,setEnabled:o,children:C.jsxs("transformNode",{name:`transform-model-global-${e}`,ref:v,scaling:l?new u.Vector3(A&&A.scalePlane?A.scalePlane:1,A&&A.scaleDepth?A.scaleDepth:1,A&&A.scalePlane?A.scalePlane:1):new u.Vector3(1,1,1),children:[d?C.jsx("transformNode",{name:`transform-model-label-${e}`,position:B.add(d!=null&&d.offset?d.offset.multiplyByFloats(A!=null&&A.scalePlane?A==null?void 0:A.scalePlane:1,1,A!=null&&A.scalePlane?A==null?void 0:A.scalePlane:1):u.Vector3.Zero()),scalingDeterminant:V?i*3:3,children:C.jsx(Je,{text:d.title,fontSize:d.fontSize?d.fontSize:40,color:d.color?d.color:"white"})}):C.jsx(C.Fragment,{}),C.jsx("box",{name:`pick-mesh-${e}`,ref:P,size:1,scaling:new u.Vector3(N,k,w).multiply(f),position:B,rotation:D,setEnabled:p?p.length===0:!0,children:C.jsx("standardMaterial",{name:`pick-mesh-${e}-mat`,alpha:r?.5:0})})]})})},Kn=m.forwardRef(af),sf=({name:e,url:t,position:n=u.Vector3.Zero(),rotation:a=u.Vector3.Zero(),localScale:i=1,visible:o=!0},r)=>{const l=_e.useScene(),s=Ri({url:t}),c=m.useRef(null),[p,f]=m.useState(null);return m.useEffect(()=>{console.log("[Geo3DViewer] ModelLoader Loading: ",t)},[t]),m.useImperativeHandle(r,()=>c.current,[]),m.useEffect(()=>{if(s){const d=s.instantiateModelsToScene(x=>`${e}-${x}`,!0);return console.log("[Geo3DViewer] ModelLoader 实例化: ",e),f(d),()=>{console.log("[Geo3DViewer] ModelLoader 反实例化: ",e),f(null)}}},[s,e]),m.useEffect(()=>{l&&p&&c.current&&(l.animationGroups.forEach(d=>{console.log("play animtion:"+d.name),d.start(!0)}),p.rootNodes.forEach(d=>{d&&(d.parent=c.current)}))},[p,e,l]),C.jsx("transformNode",{name:`transform-model-${e}`,position:n,rotation:a,scalingDeterminant:i,setEnabled:o,ref:c})},lf=m.forwardRef(sf),ma=()=>{const e=_e.useScene();return m.useEffect(()=>{if(e){const t=u.SceneOptimizerOptions.ModerateDegradationAllowed();t.optimizations;const n=new u.SceneOptimizer(e,t,!0,!0);return n.start(),console.log("[Geo3DViewer] 渐进式优化器已启动,如遭遇技术性渲染问题,请优先尝试禁用此优化器。"),()=>{n.stop(),n.dispose(),console.log("[Geo3DViewer] 渐进式优化器已停止。")}}},[e]),C.jsx(C.Fragment,{})},cf=e=>{const{name:t,url:n,rootURL:a,doNotStart:i,capacity:o,position:r=new u.Vector3}=e,l=_e.useScene(),[s,c]=m.useState();return m.useEffect(()=>()=>{s&&s.dispose()},[s]),m.useEffect(()=>{if(l&&!s){const p=new u.AssetsManager(l),f=p.addTextFileTask(t!=null?t:"particle-system",n);p.load(),p.onFinish=function(d){console.log("task successful",d);const x=JSON.parse(f.text),h=u.ParticleSystem.Parse(x,l,a,i,o);h.emitter=r,c(h)}}return()=>{s&&(s.dispose(),console.log(t,"effect disposed!"))}},[o,i,t,s,r,a,l,n]),null},uf=e=>{const{id:t,position:n,useGPU:a=!0,renderAsFluid:i,numParticles:o=1e3,emitRate:r=1500*2,blendMode:l=u.ParticleSystem.BLENDMODE_ADD,color1:s,color2:c,colorDead:p,minSize:f,maxSize:d,minLifeTime:x,maxLifeTime:h,gravity:T,minEmitPower:P,maxEmitPower:v,updateSpeed:_,textureUrl:b,angle:k=Math.PI/2,radius:M=4,fluidRender:w}=e,S=_e.useScene(),[N,F]=m.useState(),B=m.useRef(null);return m.useEffect(()=>{N&&(N.blendMode=l,s&&(N.color1=s),c&&(N.color2=c),p&&(N.colorDead=p),f!==void 0&&(N.minSize=f),d!==void 0&&(N.maxSize=d),x!==void 0&&(N.minLifeTime=x),h!==void 0&&(N.maxLifeTime=h),P!==void 0&&(N.minEmitPower=P),v!==void 0&&(N.maxEmitPower=v),_!==void 0&&(N.updateSpeed=_),N.preWarmCycles=60*8,T&&(N.gravity=T),N.createConeEmitter(M,k),b&&(N.particleTexture=new u.Texture(b),N.particleTexture.onLoadObservable.add(()=>{N.start()})))},[k,l,s,c,p,T,v,h,d,P,x,f,N,M,b,_]),m.useEffect(()=>{if(!N&&S)if(a){const I=new u.GPUParticleSystem("particle-"+t,{capacity:o},S);F(I)}else{const I=new u.ParticleSystem("particle-"+t,o,S);F(I)}return()=>{console.log("particlesystem disposed!"),B.current&&(B.current.object.particleSize=0)}},[t,o,N,S,a]),m.useEffect(()=>{N&&(S==null||S.executeWhenReady(()=>{var I,D,E;if(S.updateTransformMatrix(!0),N==null||N.render(),i&&N){const L=S.enableFluidRenderer();if(L){L.addParticleSystem(N);const y=L.getRenderObjectFromParticleSystem(N);B.current=y,y&&(y.object.particleSize=(I=w==null?void 0:w.particleSize)!=null?I:.75,y.object.particleThicknessAlpha=.02,y.object.useTrueRenderingForDiffuseTexture=!0,y.targetRenderer.minimumThickness=y.object.particleThicknessAlpha,y.targetRenderer.blurDepthFilterSize=10,y.targetRenderer.blurDepthDepthScale=10,y.targetRenderer.thicknessMapSize=1024,y.targetRenderer.density=(D=w==null?void 0:w.density)!=null?D:8,y.targetRenderer.fresnelClamp=.04,y.targetRenderer.fluidColor=(E=w==null?void 0:w.fluidColor)!=null?E:new u.Color3(219/255,228/255,1),y.targetRenderer.generateDiffuseTexture=!1)}}}))},[w==null?void 0:w.density,w==null?void 0:w.fluidColor,w==null?void 0:w.particleSize,N,i,S]),m.useEffect(()=>{N&&(N.emitter=n,N.emitRate=r)},[r,N,n]),null},ff=(e,t)=>{var w,S,N;const n=_e.useScene(),a=m.useContext(Le),{name:i,width:o,height:r,localScale:l=u.Vector3.One(),rotation:s=u.Vector3.Zero(),position:c=u.Vector3.Zero(),textureUrl:p,videoUrl:f,canvas:d,backFaceCulling:x=!0,billboard:h=!1,actions:T,labelStyle:P}=e,v=He({url:p}),_=m.useRef(null),b=m.useRef(null),[k,M]=m.useState(null);return m.useEffect(()=>{if(f)return M(F=>{F==null||F.dispose();const B=new u.VideoTexture("video-texture",f,n,!1,!1,void 0,{autoPlay:!0,autoUpdateTexture:!0});return B.hasAlpha=!0,B}),()=>{M(F=>(F==null||F.dispose(),null))}},[f]),m.useEffect(()=>{if(d){const F=new u.DynamicTexture("dyn-texture",d,n);return F.hasAlpha=!0,_.current=F,()=>{var B;(B=_.current)==null||B.dispose()}}},[d]),m.useEffect(()=>{_.current&&(_.current.name=i)},[i]),m.useImperativeHandle(t,()=>_,[_]),m.useEffect(()=>{var B;const F=(B=b.current)==null?void 0:B.getChildMeshes()[0];F&&(F.metadata={pickable:T?{name:i,onLeftClick:T.onLeftClick,onRightClick:T.onRightClick,onMiddleClick:T.onMiddleClick,onHover:T.onHover,needWorldPosition:T.needWorldPosition,extra:T.extra}:null})},[T,i]),C.jsxs("transformNode",{ref:b,name:`transform-planeimage-${i}`,position:c.multiply(a?new u.Vector3((w=a.scalePlane)!=null?w:1,(S=a.scaleDepth)!=null?S:1,(N=a.scalePlane)!=null?N:1):u.Vector3.One()),rotation:h?u.Vector3.Zero():s,billboardMode:h?u.Mesh.BILLBOARDMODE_ALL:u.Mesh.BILLBOARDMODE_NONE,children:[C.jsx("plane",{name:`plane-planeimage-${i}`,width:o,height:r,scaling:l,children:C.jsx("standardMaterial",{name:`plane-planeimage-${i}`,emissiveColor:u.Color3.White(),specularColor:u.Color3.Black(),diffuseTexture:_.current?_.current:k||v,useAlphaFromDiffuseTexture:!0,backFaceCulling:x,transparencyMode:u.Material.MATERIAL_ALPHABLEND})}),P&&C.jsx(Je,{...P})]})},ga=m.forwardRef(ff);var va=(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))(va||{});const xa=({size:e,alpha:t=1,position:n,visible:a,objectType:i,title:o,actions:r,labelStyle:l,color:s,scaleMode:c})=>{const p=m.useRef(null),f=m.useContext(Le);m.useEffect(()=>{p.current&&(p.current.metadata={pickable:r?{name:o,onLeftClick:r.onLeftClick,onRightClick:r.onRightClick,onMiddleClick:r.onMiddleClick,onHover:r.onHover,needWorldPosition:r.needWorldPosition,extra:r.extra}:null})},[r,o]);const[d,x]=m.useState(1);return m.useEffect(()=>{switch(c){case It.PLANE:x(f&&f.scalePlane?f.scalePlane:1);break;case It.DEPTH:x(f&&f.scaleDepth?f.scaleDepth:1);break;case It.NONE:x(1);break}},[f,c]),C.jsxs("transformNode",{setEnabled:a,name:`transform-spaceheat-${o}`,position:n.multiplyByFloats(f&&f.scalePlane?f.scalePlane:1,f&&f.scaleDepth?f.scaleDepth:1,f&&f.scalePlane?f.scalePlane:1),scalingDeterminant:d,children:[C.jsx("polyhedron",{ref:p,name:`point-${o}`,type:i,size:e,children:C.jsx("standardMaterial",{name:`point-${o}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new u.Color3(0,0,0),ambientColor:new u.Color3(1,1,1),emissiveColor:u.Color3.Black(),alphaMode:u.Engine.ALPHA_COMBINE,diffuseColor:s,alpha:t})}),C.jsx("transformNode",{name:`${o}-title`,position:l!=null&&l.offset?l.offset.multiplyByFloats(f!=null&&f.scalePlane?f==null?void 0:f.scalePlane:1,1,f!=null&&f.scalePlane?f==null?void 0:f.scalePlane:1):u.Vector3.Zero(),scaling:ct(f).multiply(new u.Vector3(3,3,3)),children:C.jsx(Je,{text:o,fontSize:l!=null&&l.fontSize?l.fontSize:10,color:l!=null&&l.color?l.color:"white"})})]})},ya=({name:e,url:t,offset:n=u.Vector3.Zero(),alpha:a,color:i,visible:o=!0,cutNormal:r,value:l,actions:s,textureOverride:c,progressTexture:p={},counterLine:f=void 0,lines:d=[],text:x=[],disableDepthWrite:h=!1,checkLines:T=[],checkLineWidth:P=4})=>{var re,oe,Y,ce,ae,X,Pe,ge,H,Q,Ee,ke,te,me,ue,pe,Ne,be,Ae;const v=_e.useScene(),_=m.useRef(null),b=m.useContext(Le),k=je({url:t,cacheType:Me.URL_PREFIX_MATCH}),[M,w]=m.useState(u.Vector3.Zero()),[S,N]=m.useState(void 0),F=He({url:c==null?void 0:c.texture,cacheType:Me.URL_PREFIX_MATCH}),B=He({url:c==null?void 0:c.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),I=He({url:(re=p.segment1)==null?void 0:re.texture,cacheType:Me.URL_PREFIX_MATCH}),D=He({url:(oe=p.segment1)==null?void 0:oe.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),E=He({url:(Y=p.segment2)==null?void 0:Y.texture,cacheType:Me.URL_PREFIX_MATCH}),L=He({url:(ce=p.segment2)==null?void 0:ce.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),y=He({url:(ae=p.segment3)==null?void 0:ae.texture,cacheType:Me.URL_PREFIX_MATCH}),A=He({url:(X=p.segment3)==null?void 0:X.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),V=He({url:(Pe=p.segment4)==null?void 0:Pe.texture,cacheType:Me.URL_PREFIX_MATCH}),$=He({url:(ge=p.segment4)==null?void 0:ge.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),W=He({url:(H=p.segment5)==null?void 0:H.texture,cacheType:Me.URL_PREFIX_MATCH}),ne=He({url:(Q=p.segment5)==null?void 0:Q.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),ee=He({url:(Ee=p.segment6)==null?void 0:Ee.texture,cacheType:Me.URL_PREFIX_MATCH}),G=He({url:(ke=p.segment6)==null?void 0:ke.sideTexture,cacheType:Me.URL_PREFIX_MATCH});m.useEffect(()=>{console.log("[Geo3DViewer] ProgressedAttributeBody Loading: ",t)},[t]),m.useEffect(()=>{if(v&&_.current&&t&&k){const Ie=_.current;u.Tags.EnableFor(Ie),u.Tags.AddTagsTo(Ie,"loading");const we=Vo.decode(new Uint8Array(k)),{points:Re,indices:Ve,value:Ue,center:Be}=we;Be&&w(new u.Vector3(Be.x,Be.y,Be.z));const Ge=new u.VertexData;Ge.positions=Re,Ge.indices=Ve,Ge.colors=Ue;const Ke=[];u.VertexData.ComputeNormals(Re,Ve,Ke),Ge.normals=Ke,Ie&&(Ge.applyToMesh(Ie),Ie.getScene().onAfterRenderObservable.addOnce(()=>{if(!Ie.isDisposed()){const fe=Ie.getBoundingInfo();N(fe.boundingBox)}})),u.Tags.RemoveTagsFrom(Ie,"loading")}},[t,v,k]);function le(Ie,we,Re){const Ve=Re.subtract(we),Ue=Ie.subtract(we),Be=u.Vector3.Dot(u.Vector3.Normalize(Ve),u.Vector3.Normalize(Ue)),Ge=Ue.length()/Be,Ke=we.add(Ve.scale(Ge/u.Vector3.Distance(we,Re)));return u.Vector3.Distance(Ie,Ke)}return m.useEffect(()=>{_.current&&(_.current.metadata={pickable:s?{name:e,valueCallback:(Ie,we,Re)=>{if(console.log(e,Ie,we,Re),_.current&&we){const Ve=_.current.getBoundingInfo().boundingBox;console.log(Ve);for(let Ue=0;Ue<T.length;Ue++){const Be=T[Ue];if(le(new u.Vector3(we.x,0,we.z),Be.start,Be.end)<P){const Ke=[];for(let z=0;z<11;z++){const fe=Be.end.subtract(Be.start),he=Be.start.add(fe.scale(z/10)),xe=new u.Vector3(he.x,we.y+Ve.extendSize.y*4,he.z),Z=new u.Vector3(he.x,we.y+Ve.extendSize.y*2,he.z),ie=u.Vector3.Normalize(Z.subtract(xe)),O=Ve.extendSize.y*10,de=new u.Ray(xe,ie,O),Se=v==null?void 0:v.pickWithRay(de,g=>g===_.current);Se!=null&&Se.hit&&Se.pickedPoint&&Ke.push(Se.pickedPoint)}for(let z=0;z<11;z++){const fe=Be.end.subtract(Be.start),he=Be.start.add(fe.scale(z/10)),xe=new u.Vector3(he.x,we.y-Ve.extendSize.y*4,he.z),Z=new u.Vector3(he.x,we.y-Ve.extendSize.y*2,he.z),ie=u.Vector3.Normalize(Z.subtract(xe)),O=Ve.extendSize.y*10,de=new u.Ray(xe,ie,O),Se=v==null?void 0:v.pickWithRay(de,g=>g===_.current);Se!=null&&Se.hit&&Se.pickedPoint&&Ke.push(Se.pickedPoint)}return{value:Ue,points:Ke}}}}},onLeftClick:s.onLeftClick,onRightClick:s.onRightClick,onMiddleClick:s.onMiddleClick,onHover:s.onHover,needWorldPosition:s.needWorldPosition,extra:s.extra}:null})},[s,e,T]),C.jsx(C.Fragment,{children:C.jsx("transformNode",{name:`transform-progressedattribute-${e}`,position:M.add(n).multiplyByFloats(b&&b.scalePlane?b.scalePlane:1,b&&b.scaleDepth?b.scaleDepth:1,b&&b.scalePlane?b.scalePlane:1),scaling:new u.Vector3(b?b.scalePlane:1,b?b.scaleDepth:1,b?b.scalePlane:1),children:C.jsx("mesh",{name:`attributebody-${e}-mesh`,ref:_,setEnabled:o,useVertexColors:!F,alwaysSelectAsActiveMesh:!0,children:S&&origin?F?C.jsx(ji,{name:`progressedattributebody-${e}-mat`,backFaceCulling:!0,needDepthPrePass:!1,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,texture:F,sideTexture:B,alphaStage:a,cutNormal:r,value:l,boundingBox:S,tilingFactor:c==null?void 0:c.tilingFactor,textureFlatRotate:c==null?void 0:c.flatModeRotate,sideTilingFactor:(te=c==null?void 0:c.sideTilingFactor)!=null?te:c==null?void 0:c.tilingFactor,mode:c==null?void 0:c.mode,overlay:{texture1:I,sideTexture1:D,texture2:E,sideTexture2:L,texture3:y,sideTexture3:A,texture4:V,sideTexture4:$,texture5:W,sideTexture5:ne,texture6:ee,sideTexture6:G,color1:(me=p.segment1)==null?void 0:me.color,color2:(ue=p.segment2)==null?void 0:ue.color,color3:(pe=p.segment3)==null?void 0:pe.color,color4:(Ne=p.segment4)==null?void 0:Ne.color,color5:(be=p.segment5)==null?void 0:be.color,color6:(Ae=p.segment6)==null?void 0:Ae.color},scaleDepth:b?b.scaleDepth:1,scalePlane:b?b.scalePlane:1,counterLine:f,lines:d,text:x,disableDepthWrite:h}):i?C.jsx(Qi,{name:`progressedattributebody-${e}-mat`,backFaceCulling:!0,needDepthPrePass:!1,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,colorCodec:i,alphaStage:a,cutNormal:r,value:l,boundingBox:S,scaleDepth:b?b.scaleDepth:1,scalePlane:b?b.scalePlane:1,counterLine:f,lines:d,text:x,disableDepthWrite:h}):C.jsx(C.Fragment,{}):C.jsx(C.Fragment,{})})})})},Ca=({onPick:e,pickAll:t=!1})=>{const n=_e.useScene(),a=m.useContext(Le),i=m.useRef(null),o=m.useRef([]),r=m.useRef(!1),l=m.useCallback(d=>{if(!d){e(null);return}let x=1,h=1;a&&(a.scalePlane&&(x=a.scalePlane),a.scaleDepth&&(h=a.scaleDepth)),e(new u.Vector3(d.x/x,d.y/h,d.z/x))},[a,e]),s=m.useCallback(()=>{if(!n)return[];const d=n.meshes.filter(h=>!!h&&!h.isDisposed()&&h.isPickable&&h.isVisible&&h.isEnabled()&&h.isReady(!0)),x=d.length!==o.current.length||d.some((h,T)=>o.current[T]!==h);return i.current||(i.current=new Pi.GPUPicker),x&&(i.current.setPickingList(d.length>0?d.slice():null),o.current=d),d},[n]),c=m.useCallback(async()=>{if(!n||r.current||n.skipPointerMovePicking)return;if(!s().length||!i.current){e(null);return}r.current=!0;try{const x=await i.current.pickAsync(n.pointerX,n.pointerY,!1),h=x==null?void 0:x.mesh;if(!h){e(null);return}const T=n.pick(n.pointerX,n.pointerY,P=>P.uniqueId===h.uniqueId,!1,void 0);if(!(T!=null&&T.pickedPoint)){e(null);return}l(T.pickedPoint)}finally{r.current=!1}},[l,e,n,s]),p=m.useCallback(()=>{var x;if(!n||n.skipPointerMovePicking)return;const d=n.pick(n.pointerX,n.pointerY,void 0,!1,void 0);l((x=d==null?void 0:d.pickedPoint)!=null?x:null)},[l,n]),f=m.useCallback(d=>{switch(d.type){case u.PointerEventTypes.POINTERUP:{t?p():c();break}}},[t,p,c]);return m.useEffect(()=>{if(n){const d=n.onPointerObservable.add(f);return()=>{n.onPointerObservable.remove(d)}}},[f,n]),m.useEffect(()=>()=>{var d;(d=i.current)==null||d.dispose(),i.current=null,o.current=[],r.current=!1},[]),C.jsx(C.Fragment,{})},_a=({name:e,paths:t,color:n,alpha:a,sideOrientation:i=Ai.CounterClockWiseSideOrientation,position:o=u.Vector3.Zero(),rotation:r=u.Vector3.Zero(),scaling:l=u.Vector3.One(),backFaceCulling:s=!1,labelStyle:c,showLayerLabel:p=!1,actions:f})=>{const d=m.useContext(Le),x=Oe(d),h=m.useRef(null),[T,P]=m.useState();return m.useEffect(()=>{if(h.current){const v=h.current.getBoundingInfo();P(v.boundingBox.centerWorld)}},[t,o,r,l]),m.useEffect(()=>{h.current&&(h.current.metadata={pickable:f?{name:e,onLeftClick:f.onLeftClick,onRightClick:f.onRightClick,onMiddleClick:f.onMiddleClick,onHover:f.onHover,needWorldPosition:f.needWorldPosition,extra:f.extra}:null})},[f,e]),C.jsxs("transformNode",{name:`${e}-transform`,position:o.multiply(x),rotation:r,scaling:l.multiply(x),children:[C.jsx("ribbon",{name:`${e}-transform`,pathArray:t,updatable:!0,ref:h,sideOrientation:i,children:C.jsx("standardMaterial",{name:`${e}-material`,diffuseColor:n,alpha:a,specularColor:u.Color3.Black(),ambientColor:u.Color3.White(),transparencyMode:u.Material.MATERIAL_ALPHABLEND,backFaceCulling:s})}),e&&T&&C.jsx("transformNode",{name:`${e}-title`,position:T.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):u.Vector3.Zero()),scaling:ct(d).multiply(new u.Vector3(3,3,3)),setEnabled:p,children:C.jsx(Je,{text:e,fontSize:c!=null&&c.fontSize?c.fontSize:40,color:c!=null&&c.color?c.color:"white"})})]})},df=`#ifdef GL_ES
1243
+ {}`;const a=new u.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 Ku("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]),C.jsx(C.Fragment,{})},ju=({showDebugLayer:e=!1})=>{const t=_e.useScene(),n=_e.useEngine();return m.useEffect(()=>{n&&t&&(e?(n.captureGPUFrameTime=a=>{},jn.Inspector.Show(t,{embedMode:!0})):jn.Inspector.Hide())},[n,t,e]),m.useEffect(()=>()=>{t&&jn.Inspector.Hide()},[t]),C.jsxs("transformNode",{name:"Debugger",children:[C.jsx(qu,{}),C.jsx(Qu,{})]})},ef=()=>{const e=_e.useScene(),t=_e.useEngine();return m.useEffect(()=>{const n=t;if(window.BABYLON&&n)return window.BABYLON.EngineStore.Instances.push(n),as.registerBuiltInLoaders(),()=>{if(window.BABYLON){const a=window.BABYLON.EngineStore.Instances.indexOf(n);a>-1&&window.BABYLON.EngineStore.Instances.splice(a,1)}}},[t]),m.useEffect(()=>{const n=t;if(n)return u.EngineStore.Instances.push(n),()=>{const a=window.BABYLON.EngineStore.Instances.indexOf(n);a>-1&&window.BABYLON.EngineStore.Instances.splice(a,1)}},[t]),m.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]),m.useEffect(()=>{const n=e;if(n)return u.EngineStore._LastCreatedScene=e,()=>{u.EngineStore._LastCreatedScene===n&&(u.EngineStore._LastCreatedScene=null)}},[e]),m.useEffect(()=>{e&&(e._forceBlockMaterialDirtyMechanism=a=>{e._blockMaterialDirtyMechanism=a})},[e]),C.jsx(C.Fragment,{})};class tf{constructor(){ve(this,"urls",[]);ve(this,"resources",new Map);ve(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"){Ut.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 ca=m.createContext(void 0),nf=(e,t="BIN")=>{const n=m.useContext(ca),[a,r]=m.useState(void 0),o=m.useMemo(()=>{const i={onProgress:function(l){console.log(l)},onComplete:function(l){console.log(e,l),r(l)},onError:function(l){console.log(l),n==null||n.removeListener(e,i)}};return i},[n,e]);return m.useEffect(()=>(n==null||n.load(e,t,o),()=>{n==null||n.removeListener(e,o)}),[o,n,t,e]),a},of=(e,t)=>{const{children:n,showDebugLayer:a=!1,meta:r,colorProvider:o,cacheProvider:i,options:l={backgroundColor:u.Color4.FromArray([.2,.2,.3,1]),light:{intensity:1,direction:new u.Vector3(1,1,1)}}}=e,{light:s={intensity:1,direction:new u.Vector3(1,1,1)}}=l,{intensity:c=1,direction:p=new u.Vector3(1,1,1)}=s,f=m.useRef(null),[d,x]=m.useState(!1);return m.useEffect(()=>{console.log(`
1244
+ %c Geo3DViewer Library %c Version: 1.7.41 %c
1245
+ `,"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;")},[]),m.useImperativeHandle(t,()=>({scene:f,camera:null}),[f]),m.useEffect(()=>{a&&x(!0)},[a]),C.jsx(_e.Engine,{antialias:!0,adaptToDeviceRatio:!0,canvasId:"rootGeo3DCanvas",engineOptions:{useHighPrecisionFloats:!0,depth:!0,useHighPrecisionMatrix:!0,stencil:!0},children:C.jsxs(_e.Scene,{clearColor:l.backgroundColor,useRightHandedSystem:l.useRightHandedSystem,children:[C.jsx(ef,{}),C.jsx("ground",{name:"picking-material-holder",setEnabled:!1,children:C.jsx(Tu,{})}),C.jsx(ca.Provider,{value:new tf,children:C.jsxs(Es,{workspaceMeta:r,colorProvider:o,cacheProvider:i,ref:f,children:[d||a?C.jsx(ju,{showDebugLayer:a}):null,C.jsx("hemisphericLight",{name:"light",intensity:c,direction:p}),n]})}),l.environment?C.jsx("cubeTexture",{assignTo:"environmentTexture",rootUrl:l.environment}):C.jsx(C.Fragment,{})]})})},qo=m.forwardRef(of);var Et=(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))(Et||{});function rf(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 af(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 si(){return{name:"",step:0,xCount:0,yCount:0,zCount:0,xSliceUrl:"",ySliceUrl:"",zSliceUrl:"",mode:0}}const ua={encode(e,t=se.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=si();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:kt(e.name)?globalThis.String(e.name):"",step:kt(e.step)?globalThis.Number(e.step):0,xCount:kt(e.xCount)?globalThis.Number(e.xCount):0,yCount:kt(e.yCount)?globalThis.Number(e.yCount):0,zCount:kt(e.zCount)?globalThis.Number(e.zCount):0,xSliceUrl:kt(e.xSliceUrl)?globalThis.String(e.xSliceUrl):"",ySliceUrl:kt(e.ySliceUrl)?globalThis.String(e.ySliceUrl):"",zSliceUrl:kt(e.zSliceUrl)?globalThis.String(e.zSliceUrl):"",mode:kt(e.mode)?rf(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=af(e.mode)),t},create(e){return ua.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,l,s,c,p;const t=si();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=(l=e.xSliceUrl)!=null?l:"",t.ySliceUrl=(s=e.ySliceUrl)!=null?s:"",t.zSliceUrl=(c=e.zSliceUrl)!=null?c:"",t.mode=(p=e.mode)!=null?p:0,t}};function kt(e){return e!=null}const fa=({name:e,url:t,step:n,visible:a=!0,colorCodec:r,alpha:o=1,actions:i,materials:l})=>{const[s,c]=m.useState(),[p,f]=m.useState(0),d=je({url:t,cacheType:Me.URL_PREFIX_MATCH});return m.useEffect(()=>{console.log("[Geo3DViewer] GriDDiagram Loading: ",t)},[t]),m.useEffect(()=>{if(d){const x=ua.decode(new Uint8Array(d)),{xCount:h,zCount:T,xSliceUrl:P,zSliceUrl:v}=x,_=[];if(x.mode===Et.ATTRIBUTE||x.mode===Et.COLOR){if(n<=0){console.error("[Geo3DViewer] 此文件为动态数据文件,step 值必须大于 0"),c([]),f(0);return}let b=0;for(let k=0;k<h;k+=n)_.push(P.replace("%s",k.toString())),b=k;b>=h&&_.push(P.replace("%s",(h-1).toString()));for(let k=0;k<T;k+=n)_.push(v.replace("%s",k.toString())),b=k;b>=T&&_.push(v.replace("%s",(T-1).toString()))}else if(x.mode===Et.STATIC_ATTRIBUTE||x.mode===Et.STATIC_COLOR){if(n!==0){console.error("[Geo3DViewer] 静态栅状图数据必须传入 step=0 以确认您明确此数据无法使用动态加载模式"),c([]),f(0);return}for(let b=0;b<h;b+=1)_.push(P.replace("%s",b.toString()))}return c(_),f(x.mode===Et.ATTRIBUTE?1:x.mode===Et.COLOR?2:x.mode===Et.STATIC_ATTRIBUTE?1:x.mode===Et.STATIC_COLOR?2:0),()=>{c([]),f(0)}}},[d,n]),C.jsx("abstractMesh",{name:`gridDiagram-${e}`,children:p===1?s?s.map((x,h)=>C.jsx(Yo,{name:e,url:x,visible:a,colorCodec:r,alpha:o,actions:i},`densityslice-group-${e}-${x}-${h}`)):C.jsx(C.Fragment,{}):p===2?s?s.map((x,h)=>C.jsx(Xo,{url:x,visible:a,materials:l,actions:i},`formationslice-group-${e}-${x}-${h}`)):C.jsx(C.Fragment,{}):C.jsx(C.Fragment,{})})},da=({name:e,position:t,width:n,height:a,color:r,lineWidth:o,rotation:i,showDebugPlane:l=!1})=>{const s=m.useContext(Le),c=m.useRef(null),p=ku({name:e,lineColor:r,lineWidth:o});return m.useEffect(()=>{c.current&&(c.current.material=p)},[p]),C.jsxs("transformNode",{name:`intersecting-line-${e}`,position:t.multiply(Oe(s)),rotation:i||u.Vector3.Zero(),children:[C.jsx("plane",{name:e,width:n,height:a,isPickable:!1,isBlocker:!1,ref:c}),C.jsx("plane",{name:e,width:n,height:a,isPickable:!1,isBlocker:!1,setEnabled:l,children:C.jsx("standardMaterial",{name:"intersecting-line-material",diffuseColor:u.Color3.Gray(),backFaceCulling:!1,alpha:.5,transparencyMode:u.Material.MATERIAL_ALPHABLEND})})]})},pa=e=>{const t=_e.useScene(),{target:n,distance:a}=e;return m.useEffect(()=>{if(t&&t.activeCamera&&n){const r=t.activeCamera;let o=new u.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 u.ArcRotateCamera){r.setTarget(o),r.radius=a;return}if(r instanceof u.FreeCamera){const i=o,l=r.position.clone(),s=a/u.Vector3.Distance(i,l),p=l.subtract(i).scale(s),f=i.add(p);r.position=f,r.setTarget(o)}return}},[a,t,n]),null},ha=e=>{const t=e.getChildren();return t.length>0?[e,...ha(t[0])]:[e]},sf=e=>{if(!e.hasVertexAlpha)return!1;const t=e.getVertexBuffer(u.VertexBuffer.ColorKind),n=e.getVerticesData(u.VertexBuffer.ColorKind);if(!t||!n)return!1;const a=t.getSize();if(a<4)return!1;let r=!1,o=!1;for(let i=3;i<n.length;i+=a){const l=n[i];if(!Number.isFinite(l))return!0;if(r=!0,l>1/255){o=!0;break}}return r&&!o},lf=({name:e,url:t,position:n=u.Vector3.Zero(),rotation:a=u.Vector3.Zero(),localScale:r=1,visible:o=!0,showPickingBox:i=!1,useGlobalScale:l=!1,actions:s,alpha:c=1,boneRotation:p,pickingBoxScale:f=u.Vector3.One(),labelStyle:d},x)=>{const h=_e.useScene(),T=Ri({url:t}),P=m.useRef(null),v=m.useRef(null),[_,b]=m.useState(null),[k,M]=m.useState(5),[w,S]=m.useState(5),[N,F]=m.useState(5),[B,I]=m.useState(u.Vector3.Zero()),[D,E]=m.useState(u.Vector3.One()),[L,y]=m.useState([]),A=m.useContext(Le),{scaleWithParent:V=!0}=d||{};return m.useEffect(()=>{console.log("[Geo3DViewer] ModelLoader Loading: ",t)},[t]),m.useImperativeHandle(x,()=>v.current,[]),m.useEffect(()=>{if(T){const $=T.instantiateModelsToScene(W=>`${e}-${W}`,!0);return console.log("[Geo3DViewer] ModelLoader 实例化: ",e),b($),()=>{console.log("[Geo3DViewer] ModelLoader 反实例化: ",e),b(null)}}},[T,e]),m.useEffect(()=>{if(_){const $=_,W=$.skeletons;if(W&&W.length>0){const ee=W[0].bones,G=[];ee.filter(le=>le.name==="MorphBoneBase").forEach((le,re)=>{if(re===0){const oe=ha(le);G.push(...oe.map(Y=>{var ce;return(ce=Y.getTransformNode())!=null?ce:Y}))}}),y(G),console.log("[Geo3DViewer] ModelLoader 设定 Morph 骨骼: ",G)}return()=>{console.log("[Geo3DViewer] ModelLoader 注销 Model"),$.dispose(),y([])}}},[_]),m.useEffect(()=>{p&&L&&(console.log("[Geo3DViewer] ModelLoader 设定骨骼旋转"),L.forEach(($,W)=>{p.length>W?$.rotation=p[W]:$.rotation=u.Vector3.Zero()}),(!p||p.length===0)&&console.log("[Geo3DViewer] ModelLoader 的鼠标拾取功能由于 boneRotation 被禁用"))},[p,L]),m.useEffect(()=>{P.current&&(P.current.metadata={pickable:s?{name:e,onLeftClick:s.onLeftClick,onRightClick:s.onRightClick,onMiddleClick:s.onMiddleClick,onHover:s.onHover,needWorldPosition:s.needWorldPosition,valueCallback:null,extra:s.extra}:null})},[s,e]),m.useEffect(()=>{if(h&&_&&v.current){console.log("[Geo3DViewer] ModelLoader 创建容器: ",e);const $=new u.TransformNode(`amesh-model-${e}`);$.parent=v.current,_.rootNodes.forEach(oe=>{oe&&(oe.parent=$)}),$.computeWorldMatrix(!0),u.PivotTools._RemoveAndStorePivotPoint($);const W=$.parent;$.parent=null;const ne=u.Quaternion.RotationYawPitchRoll($.rotation.y,$.rotation.x,$.rotation.z),ee=new u.Vector3($.position.x,$.position.y,$.position.z);$.rotation.set(0,0,0),$.position.set(0,0,0);const G=$.getHierarchyBoundingVectors(!0),le=G.max.subtract(G.min);M(le.y),S(le.z),F(le.x),E(ne.toEulerAngles());const re=new u.Vector3((G.max.x+G.min.x)/2,(G.max.y+G.min.y)/2,(G.max.z+G.min.z)/2);return I(re),$.position=ee,$.rotationQuaternion=ne,$.parent=W,u.PivotTools._RestorePivotPoint($),console.log("[Geo3DViewer] 创建 ModelLoader 鼠标拾取外框 ",e," 于 ",re," 大小为 ",le.x,le.y,le.z),()=>{console.log("[Geo3DViewer] ModelLoader 注销容器: ",e),$.dispose()}}},[_,e,h]),m.useEffect(()=>{_&&_.rootNodes.forEach($=>{$.getChildMeshes().forEach(W=>{sf(W)&&(console.warn(`[Geo3DViewer] ModelLoader disabled broken vertex alpha for ${W.name||e}`),W.hasVertexAlpha=!1),W.material&&(W.material.alpha=c,W.material.transparencyMode=c<1?u.Material.MATERIAL_ALPHABLEND:u.Material.MATERIAL_OPAQUE)})})},[_,c]),C.jsx("transformNode",{name:`transform-model-${e}`,position:n,rotation:a,scalingDeterminant:r,setEnabled:o,children:C.jsxs("transformNode",{name:`transform-model-global-${e}`,ref:v,scaling:l?new u.Vector3(A&&A.scalePlane?A.scalePlane:1,A&&A.scaleDepth?A.scaleDepth:1,A&&A.scalePlane?A.scalePlane:1):new u.Vector3(1,1,1),children:[d?C.jsx("transformNode",{name:`transform-model-label-${e}`,position:B.add(d!=null&&d.offset?d.offset.multiplyByFloats(A!=null&&A.scalePlane?A==null?void 0:A.scalePlane:1,1,A!=null&&A.scalePlane?A==null?void 0:A.scalePlane:1):u.Vector3.Zero()),scalingDeterminant:V?r*3:3,children:C.jsx(Je,{text:d.title,fontSize:d.fontSize?d.fontSize:40,color:d.color?d.color:"white"})}):C.jsx(C.Fragment,{}),C.jsx("box",{name:`pick-mesh-${e}`,ref:P,size:1,scaling:new u.Vector3(N,k,w).multiply(f),position:B,rotation:D,setEnabled:p?p.length===0:!0,children:C.jsx("standardMaterial",{name:`pick-mesh-${e}-mat`,alpha:i?.5:0})})]})})},Kn=m.forwardRef(lf),cf=({name:e,url:t,position:n=u.Vector3.Zero(),rotation:a=u.Vector3.Zero(),localScale:r=1,visible:o=!0},i)=>{const l=_e.useScene(),s=Ri({url:t}),c=m.useRef(null),[p,f]=m.useState(null);return m.useEffect(()=>{console.log("[Geo3DViewer] ModelLoader Loading: ",t)},[t]),m.useImperativeHandle(i,()=>c.current,[]),m.useEffect(()=>{if(s){const d=s.instantiateModelsToScene(x=>`${e}-${x}`,!0);return console.log("[Geo3DViewer] ModelLoader 实例化: ",e),f(d),()=>{console.log("[Geo3DViewer] ModelLoader 反实例化: ",e),f(null)}}},[s,e]),m.useEffect(()=>{l&&p&&c.current&&(l.animationGroups.forEach(d=>{console.log("play animtion:"+d.name),d.start(!0)}),p.rootNodes.forEach(d=>{d&&(d.parent=c.current)}))},[p,e,l]),C.jsx("transformNode",{name:`transform-model-${e}`,position:n,rotation:a,scalingDeterminant:r,setEnabled:o,ref:c})},uf=m.forwardRef(cf),ma=()=>{const e=_e.useScene();return m.useEffect(()=>{if(e){const t=u.SceneOptimizerOptions.ModerateDegradationAllowed();t.optimizations;const n=new u.SceneOptimizer(e,t,!0,!0);return n.start(),console.log("[Geo3DViewer] 渐进式优化器已启动,如遭遇技术性渲染问题,请优先尝试禁用此优化器。"),()=>{n.stop(),n.dispose(),console.log("[Geo3DViewer] 渐进式优化器已停止。")}}},[e]),C.jsx(C.Fragment,{})},ff=e=>{const{name:t,url:n,rootURL:a,doNotStart:r,capacity:o,position:i=new u.Vector3}=e,l=_e.useScene(),[s,c]=m.useState();return m.useEffect(()=>()=>{s&&s.dispose()},[s]),m.useEffect(()=>{if(l&&!s){const p=new u.AssetsManager(l),f=p.addTextFileTask(t!=null?t:"particle-system",n);p.load(),p.onFinish=function(d){console.log("task successful",d);const x=JSON.parse(f.text),h=u.ParticleSystem.Parse(x,l,a,r,o);h.emitter=i,c(h)}}return()=>{s&&(s.dispose(),console.log(t,"effect disposed!"))}},[o,r,t,s,i,a,l,n]),null},df=e=>{const{id:t,position:n,useGPU:a=!0,renderAsFluid:r,numParticles:o=1e3,emitRate:i=1500*2,blendMode:l=u.ParticleSystem.BLENDMODE_ADD,color1:s,color2:c,colorDead:p,minSize:f,maxSize:d,minLifeTime:x,maxLifeTime:h,gravity:T,minEmitPower:P,maxEmitPower:v,updateSpeed:_,textureUrl:b,angle:k=Math.PI/2,radius:M=4,fluidRender:w}=e,S=_e.useScene(),[N,F]=m.useState(),B=m.useRef(null);return m.useEffect(()=>{N&&(N.blendMode=l,s&&(N.color1=s),c&&(N.color2=c),p&&(N.colorDead=p),f!==void 0&&(N.minSize=f),d!==void 0&&(N.maxSize=d),x!==void 0&&(N.minLifeTime=x),h!==void 0&&(N.maxLifeTime=h),P!==void 0&&(N.minEmitPower=P),v!==void 0&&(N.maxEmitPower=v),_!==void 0&&(N.updateSpeed=_),N.preWarmCycles=60*8,T&&(N.gravity=T),N.createConeEmitter(M,k),b&&(N.particleTexture=new u.Texture(b),N.particleTexture.onLoadObservable.add(()=>{N.start()})))},[k,l,s,c,p,T,v,h,d,P,x,f,N,M,b,_]),m.useEffect(()=>{if(!N&&S)if(a){const I=new u.GPUParticleSystem("particle-"+t,{capacity:o},S);F(I)}else{const I=new u.ParticleSystem("particle-"+t,o,S);F(I)}return()=>{console.log("particlesystem disposed!"),B.current&&(B.current.object.particleSize=0)}},[t,o,N,S,a]),m.useEffect(()=>{N&&(S==null||S.executeWhenReady(()=>{var I,D,E;if(S.updateTransformMatrix(!0),N==null||N.render(),r&&N){const L=S.enableFluidRenderer();if(L){L.addParticleSystem(N);const y=L.getRenderObjectFromParticleSystem(N);B.current=y,y&&(y.object.particleSize=(I=w==null?void 0:w.particleSize)!=null?I:.75,y.object.particleThicknessAlpha=.02,y.object.useTrueRenderingForDiffuseTexture=!0,y.targetRenderer.minimumThickness=y.object.particleThicknessAlpha,y.targetRenderer.blurDepthFilterSize=10,y.targetRenderer.blurDepthDepthScale=10,y.targetRenderer.thicknessMapSize=1024,y.targetRenderer.density=(D=w==null?void 0:w.density)!=null?D:8,y.targetRenderer.fresnelClamp=.04,y.targetRenderer.fluidColor=(E=w==null?void 0:w.fluidColor)!=null?E:new u.Color3(219/255,228/255,1),y.targetRenderer.generateDiffuseTexture=!1)}}}))},[w==null?void 0:w.density,w==null?void 0:w.fluidColor,w==null?void 0:w.particleSize,N,r,S]),m.useEffect(()=>{N&&(N.emitter=n,N.emitRate=i)},[i,N,n]),null},pf=(e,t)=>{var w,S,N;const n=_e.useScene(),a=m.useContext(Le),{name:r,width:o,height:i,localScale:l=u.Vector3.One(),rotation:s=u.Vector3.Zero(),position:c=u.Vector3.Zero(),textureUrl:p,videoUrl:f,canvas:d,backFaceCulling:x=!0,billboard:h=!1,actions:T,labelStyle:P}=e,v=He({url:p}),_=m.useRef(null),b=m.useRef(null),[k,M]=m.useState(null);return m.useEffect(()=>{if(f)return M(F=>{F==null||F.dispose();const B=new u.VideoTexture("video-texture",f,n,!1,!1,void 0,{autoPlay:!0,autoUpdateTexture:!0});return B.hasAlpha=!0,B}),()=>{M(F=>(F==null||F.dispose(),null))}},[f]),m.useEffect(()=>{if(d){const F=new u.DynamicTexture("dyn-texture",d,n);return F.hasAlpha=!0,_.current=F,()=>{var B;(B=_.current)==null||B.dispose()}}},[d]),m.useEffect(()=>{_.current&&(_.current.name=r)},[r]),m.useImperativeHandle(t,()=>_,[_]),m.useEffect(()=>{var B;const F=(B=b.current)==null?void 0:B.getChildMeshes()[0];F&&(F.metadata={pickable:T?{name:r,onLeftClick:T.onLeftClick,onRightClick:T.onRightClick,onMiddleClick:T.onMiddleClick,onHover:T.onHover,needWorldPosition:T.needWorldPosition,extra:T.extra}:null})},[T,r]),C.jsxs("transformNode",{ref:b,name:`transform-planeimage-${r}`,position:c.multiply(a?new u.Vector3((w=a.scalePlane)!=null?w:1,(S=a.scaleDepth)!=null?S:1,(N=a.scalePlane)!=null?N:1):u.Vector3.One()),rotation:h?u.Vector3.Zero():s,billboardMode:h?u.Mesh.BILLBOARDMODE_ALL:u.Mesh.BILLBOARDMODE_NONE,children:[C.jsx("plane",{name:`plane-planeimage-${r}`,width:o,height:i,scaling:l,children:C.jsx("standardMaterial",{name:`plane-planeimage-${r}`,emissiveColor:u.Color3.White(),specularColor:u.Color3.Black(),diffuseTexture:_.current?_.current:k||v,useAlphaFromDiffuseTexture:!0,backFaceCulling:x,transparencyMode:u.Material.MATERIAL_ALPHABLEND})}),P&&C.jsx(Je,{...P})]})},ga=m.forwardRef(pf);var va=(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))(va||{});const xa=({size:e,alpha:t=1,position:n,visible:a,objectType:r,title:o,actions:i,labelStyle:l,color:s,scaleMode:c})=>{const p=m.useRef(null),f=m.useContext(Le);m.useEffect(()=>{p.current&&(p.current.metadata={pickable:i?{name:o,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,needWorldPosition:i.needWorldPosition,extra:i.extra}:null})},[i,o]);const[d,x]=m.useState(1);return m.useEffect(()=>{switch(c){case It.PLANE:x(f&&f.scalePlane?f.scalePlane:1);break;case It.DEPTH:x(f&&f.scaleDepth?f.scaleDepth:1);break;case It.NONE:x(1);break}},[f,c]),C.jsxs("transformNode",{setEnabled:a,name:`transform-spaceheat-${o}`,position:n.multiplyByFloats(f&&f.scalePlane?f.scalePlane:1,f&&f.scaleDepth?f.scaleDepth:1,f&&f.scalePlane?f.scalePlane:1),scalingDeterminant:d,children:[C.jsx("polyhedron",{ref:p,name:`point-${o}`,type:r,size:e,children:C.jsx("standardMaterial",{name:`point-${o}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new u.Color3(0,0,0),ambientColor:new u.Color3(1,1,1),emissiveColor:u.Color3.Black(),alphaMode:u.Engine.ALPHA_COMBINE,diffuseColor:s,alpha:t})}),C.jsx("transformNode",{name:`${o}-title`,position:l!=null&&l.offset?l.offset.multiplyByFloats(f!=null&&f.scalePlane?f==null?void 0:f.scalePlane:1,1,f!=null&&f.scalePlane?f==null?void 0:f.scalePlane:1):u.Vector3.Zero(),scaling:ct(f).multiply(new u.Vector3(3,3,3)),children:C.jsx(Je,{text:o,fontSize:l!=null&&l.fontSize?l.fontSize:10,color:l!=null&&l.color?l.color:"white"})})]})},ya=({name:e,url:t,offset:n=u.Vector3.Zero(),alpha:a,color:r,visible:o=!0,cutNormal:i,value:l,actions:s,textureOverride:c,progressTexture:p={},counterLine:f=void 0,lines:d=[],text:x=[],disableDepthWrite:h=!1,checkLines:T=[],checkLineWidth:P=4})=>{var re,oe,Y,ce,ae,X,Pe,ge,H,Q,Ee,ke,te,me,ue,pe,Ne,be,Ae;const v=_e.useScene(),_=m.useRef(null),b=m.useContext(Le),k=je({url:t,cacheType:Me.URL_PREFIX_MATCH}),[M,w]=m.useState(u.Vector3.Zero()),[S,N]=m.useState(void 0),F=He({url:c==null?void 0:c.texture,cacheType:Me.URL_PREFIX_MATCH}),B=He({url:c==null?void 0:c.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),I=He({url:(re=p.segment1)==null?void 0:re.texture,cacheType:Me.URL_PREFIX_MATCH}),D=He({url:(oe=p.segment1)==null?void 0:oe.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),E=He({url:(Y=p.segment2)==null?void 0:Y.texture,cacheType:Me.URL_PREFIX_MATCH}),L=He({url:(ce=p.segment2)==null?void 0:ce.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),y=He({url:(ae=p.segment3)==null?void 0:ae.texture,cacheType:Me.URL_PREFIX_MATCH}),A=He({url:(X=p.segment3)==null?void 0:X.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),V=He({url:(Pe=p.segment4)==null?void 0:Pe.texture,cacheType:Me.URL_PREFIX_MATCH}),$=He({url:(ge=p.segment4)==null?void 0:ge.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),W=He({url:(H=p.segment5)==null?void 0:H.texture,cacheType:Me.URL_PREFIX_MATCH}),ne=He({url:(Q=p.segment5)==null?void 0:Q.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),ee=He({url:(Ee=p.segment6)==null?void 0:Ee.texture,cacheType:Me.URL_PREFIX_MATCH}),G=He({url:(ke=p.segment6)==null?void 0:ke.sideTexture,cacheType:Me.URL_PREFIX_MATCH});m.useEffect(()=>{console.log("[Geo3DViewer] ProgressedAttributeBody Loading: ",t)},[t]),m.useEffect(()=>{if(v&&_.current&&t&&k){const Ie=_.current;u.Tags.EnableFor(Ie),u.Tags.AddTagsTo(Ie,"loading");const we=Wo.decode(new Uint8Array(k)),{points:Re,indices:Ve,value:Ue,center:Be}=we;Be&&w(new u.Vector3(Be.x,Be.y,Be.z));const Ge=new u.VertexData;Ge.positions=Re,Ge.indices=Ve,Ge.colors=Ue;const Ke=[];u.VertexData.ComputeNormals(Re,Ve,Ke),Ge.normals=Ke,Ie&&(Ge.applyToMesh(Ie),Ie.getScene().onAfterRenderObservable.addOnce(()=>{if(!Ie.isDisposed()){const fe=Ie.getBoundingInfo();N(fe.boundingBox)}})),u.Tags.RemoveTagsFrom(Ie,"loading")}},[t,v,k]);function le(Ie,we,Re){const Ve=Re.subtract(we),Ue=Ie.subtract(we),Be=u.Vector3.Dot(u.Vector3.Normalize(Ve),u.Vector3.Normalize(Ue)),Ge=Ue.length()/Be,Ke=we.add(Ve.scale(Ge/u.Vector3.Distance(we,Re)));return u.Vector3.Distance(Ie,Ke)}return m.useEffect(()=>{_.current&&(_.current.metadata={pickable:s?{name:e,valueCallback:(Ie,we,Re)=>{if(console.log(e,Ie,we,Re),_.current&&we){const Ve=_.current.getBoundingInfo().boundingBox;console.log(Ve);for(let Ue=0;Ue<T.length;Ue++){const Be=T[Ue];if(le(new u.Vector3(we.x,0,we.z),Be.start,Be.end)<P){const Ke=[];for(let z=0;z<11;z++){const fe=Be.end.subtract(Be.start),he=Be.start.add(fe.scale(z/10)),xe=new u.Vector3(he.x,we.y+Ve.extendSize.y*4,he.z),Z=new u.Vector3(he.x,we.y+Ve.extendSize.y*2,he.z),ie=u.Vector3.Normalize(Z.subtract(xe)),O=Ve.extendSize.y*10,de=new u.Ray(xe,ie,O),Se=v==null?void 0:v.pickWithRay(de,g=>g===_.current);Se!=null&&Se.hit&&Se.pickedPoint&&Ke.push(Se.pickedPoint)}for(let z=0;z<11;z++){const fe=Be.end.subtract(Be.start),he=Be.start.add(fe.scale(z/10)),xe=new u.Vector3(he.x,we.y-Ve.extendSize.y*4,he.z),Z=new u.Vector3(he.x,we.y-Ve.extendSize.y*2,he.z),ie=u.Vector3.Normalize(Z.subtract(xe)),O=Ve.extendSize.y*10,de=new u.Ray(xe,ie,O),Se=v==null?void 0:v.pickWithRay(de,g=>g===_.current);Se!=null&&Se.hit&&Se.pickedPoint&&Ke.push(Se.pickedPoint)}return{value:Ue,points:Ke}}}}},onLeftClick:s.onLeftClick,onRightClick:s.onRightClick,onMiddleClick:s.onMiddleClick,onHover:s.onHover,needWorldPosition:s.needWorldPosition,extra:s.extra}:null})},[s,e,T]),C.jsx(C.Fragment,{children:C.jsx("transformNode",{name:`transform-progressedattribute-${e}`,position:M.add(n).multiplyByFloats(b&&b.scalePlane?b.scalePlane:1,b&&b.scaleDepth?b.scaleDepth:1,b&&b.scalePlane?b.scalePlane:1),scaling:new u.Vector3(b?b.scalePlane:1,b?b.scaleDepth:1,b?b.scalePlane:1),children:C.jsx("mesh",{name:`attributebody-${e}-mesh`,ref:_,setEnabled:o,useVertexColors:!F,alwaysSelectAsActiveMesh:!0,children:S&&origin?F?C.jsx(ji,{name:`progressedattributebody-${e}-mat`,backFaceCulling:!0,needDepthPrePass:!1,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,texture:F,sideTexture:B,alphaStage:a,cutNormal:i,value:l,boundingBox:S,tilingFactor:c==null?void 0:c.tilingFactor,textureFlatRotate:c==null?void 0:c.flatModeRotate,sideTilingFactor:(te=c==null?void 0:c.sideTilingFactor)!=null?te:c==null?void 0:c.tilingFactor,mode:c==null?void 0:c.mode,overlay:{texture1:I,sideTexture1:D,texture2:E,sideTexture2:L,texture3:y,sideTexture3:A,texture4:V,sideTexture4:$,texture5:W,sideTexture5:ne,texture6:ee,sideTexture6:G,color1:(me=p.segment1)==null?void 0:me.color,color2:(ue=p.segment2)==null?void 0:ue.color,color3:(pe=p.segment3)==null?void 0:pe.color,color4:(Ne=p.segment4)==null?void 0:Ne.color,color5:(be=p.segment5)==null?void 0:be.color,color6:(Ae=p.segment6)==null?void 0:Ae.color},scaleDepth:b?b.scaleDepth:1,scalePlane:b?b.scalePlane:1,counterLine:f,lines:d,text:x,disableDepthWrite:h}):r?C.jsx(Qi,{name:`progressedattributebody-${e}-mat`,backFaceCulling:!0,needDepthPrePass:!1,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,colorCodec:r,alphaStage:a,cutNormal:i,value:l,boundingBox:S,scaleDepth:b?b.scaleDepth:1,scalePlane:b?b.scalePlane:1,counterLine:f,lines:d,text:x,disableDepthWrite:h}):C.jsx(C.Fragment,{}):C.jsx(C.Fragment,{})})})})},Ca=({onPick:e,pickAll:t=!1})=>{const n=_e.useScene(),a=m.useContext(Le),r=m.useRef(null),o=m.useRef([]),i=m.useRef(!1),l=m.useCallback(d=>{if(!d){e(null);return}let x=1,h=1;a&&(a.scalePlane&&(x=a.scalePlane),a.scaleDepth&&(h=a.scaleDepth)),e(new u.Vector3(d.x/x,d.y/h,d.z/x))},[a,e]),s=m.useCallback(()=>{if(!n)return[];const d=n.meshes.filter(h=>!!h&&!h.isDisposed()&&h.isPickable&&h.isVisible&&h.isEnabled()&&h.isReady(!0)),x=d.length!==o.current.length||d.some((h,T)=>o.current[T]!==h);return r.current||(r.current=new Pi.GPUPicker),x&&(r.current.setPickingList(d.length>0?d.slice():null),o.current=d),d},[n]),c=m.useCallback(async()=>{if(!n||i.current||n.skipPointerMovePicking)return;if(!s().length||!r.current){e(null);return}i.current=!0;try{const x=await r.current.pickAsync(n.pointerX,n.pointerY,!1),h=x==null?void 0:x.mesh;if(!h){e(null);return}const T=n.pick(n.pointerX,n.pointerY,P=>P.uniqueId===h.uniqueId,!1,void 0);if(!(T!=null&&T.pickedPoint)){e(null);return}l(T.pickedPoint)}finally{i.current=!1}},[l,e,n,s]),p=m.useCallback(()=>{var x;if(!n||n.skipPointerMovePicking)return;const d=n.pick(n.pointerX,n.pointerY,void 0,!1,void 0);l((x=d==null?void 0:d.pickedPoint)!=null?x:null)},[l,n]),f=m.useCallback(d=>{switch(d.type){case u.PointerEventTypes.POINTERUP:{t?p():c();break}}},[t,p,c]);return m.useEffect(()=>{if(n){const d=n.onPointerObservable.add(f);return()=>{n.onPointerObservable.remove(d)}}},[f,n]),m.useEffect(()=>()=>{var d;(d=r.current)==null||d.dispose(),r.current=null,o.current=[],i.current=!1},[]),C.jsx(C.Fragment,{})},_a=({name:e,paths:t,color:n,alpha:a,sideOrientation:r=Ai.CounterClockWiseSideOrientation,position:o=u.Vector3.Zero(),rotation:i=u.Vector3.Zero(),scaling:l=u.Vector3.One(),backFaceCulling:s=!1,labelStyle:c,showLayerLabel:p=!1,actions:f})=>{const d=m.useContext(Le),x=Oe(d),h=m.useRef(null),[T,P]=m.useState();return m.useEffect(()=>{if(h.current){const v=h.current.getBoundingInfo();P(v.boundingBox.centerWorld)}},[t,o,i,l]),m.useEffect(()=>{h.current&&(h.current.metadata={pickable:f?{name:e,onLeftClick:f.onLeftClick,onRightClick:f.onRightClick,onMiddleClick:f.onMiddleClick,onHover:f.onHover,needWorldPosition:f.needWorldPosition,extra:f.extra}:null})},[f,e]),C.jsxs("transformNode",{name:`${e}-transform`,position:o.multiply(x),rotation:i,scaling:l.multiply(x),children:[C.jsx("ribbon",{name:`${e}-transform`,pathArray:t,updatable:!0,ref:h,sideOrientation:r,children:C.jsx("standardMaterial",{name:`${e}-material`,diffuseColor:n,alpha:a,specularColor:u.Color3.Black(),ambientColor:u.Color3.White(),transparencyMode:u.Material.MATERIAL_ALPHABLEND,backFaceCulling:s})}),e&&T&&C.jsx("transformNode",{name:`${e}-title`,position:T.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):u.Vector3.Zero()),scaling:ct(d).multiply(new u.Vector3(3,3,3)),setEnabled:p,children:C.jsx(Je,{text:e,fontSize:c!=null&&c.fontSize?c.fontSize:40,color:c!=null&&c.color?c.color:"white"})})]})},hf=`#ifdef GL_ES
1246
1246
  precision highp float;
1247
1247
  #endif
1248
1248
 
@@ -1284,7 +1284,7 @@ void main(void) {
1284
1284
  }
1285
1285
 
1286
1286
  gl_FragColor = vec4(frag, 1.0);
1287
- }`,pf=`#ifdef GL_ES
1287
+ }`,mf=`#ifdef GL_ES
1288
1288
  precision highp float;
1289
1289
  #endif
1290
1290
 
@@ -1310,7 +1310,7 @@ void main(void) {
1310
1310
  vPosition = vec3(world * vec4(position, 1.0));
1311
1311
  //vNormal = normalize(mat3(world) * normal);
1312
1312
 
1313
- }`,hf=e=>{const t=m.useRef(null),{startPercent:n,endPercent:a,backgroundColor:i,color:o,zOffset:r,zOffsetUnits:l,start:s,end:c}=e;return m.useEffect(()=>{t.current&&(t.current.setColor3("color",o),t.current.setColor3("backgroundColor",i||u.Color3.Black()),t.current.setFloat("discardFragment",i?0:1),t.current.setFloat("startPercent",n),t.current.setFloat("endPercent",a),t.current.setVector3("start",s),t.current.setVector3("end",c),r!==void 0&&l!==void 0&&(t.current.zOffset=r,t.current.zOffsetUnits=l))},[i,o,c,a,s,n,r,l]),C.jsx(lt,{ref:t,name:e.name,backFaceCulling:e.backFaceCulling,needDepthPrePass:e.needDepthPrePass,vertex:pf,fragment:df,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:u.Material.CounterClockWiseSideOrientation})},mf=(e,t)=>{m.useEffect(()=>{e.current&&(e.current.metadata={pickable:t})},[t,e])},gf=(e,t)=>{const n=_e.useScene(),a=m.useRef(null),i=m.useRef(null),o=m.useContext(Le),{id:r,visible:l=!0,vertices:s,indices:c,colors:p,backgroundColor:f,color:d,start:x=new u.Vector3,end:h=new u.Vector3,percent:T,position:P,materialType:v="custom",children:_,alphaBlend:b=!1,alpha:k=1,name:M="roadway",actions:w,gpuPick:S=!0}=e;m.useImperativeHandle(t,()=>i.current,[]),m.useEffect(()=>{if(a&&a.current&&n){const F=new u.VertexData;F.positions=s,F.indices=c,p&&v!=="pbr-dark"&&v!=="pbr-light"&&(F.colors=p),F.applyToMesh(a.current)}},[c,s,n,p,r,v]),mf(a,w&&S?{onLeftClick:w.onLeftClick,onRightClick:w.onRightClick,onMiddleClick:w.onMiddleClick,onHover:w.onHover,needWorldPosition:w.needWorldPosition,extra:""}:void 0);const N=m.useCallback(()=>{if(v==="custom")return C.jsx(lt,{name:`${M}-material-${r}`,vertex:Gn,fragment:Zn,needDepthPrePass:!1,transparencyMode:b?u.Material.MATERIAL_ALPHABLEND:u.Material.MATERIAL_OPAQUE,options:{needAlphaBlending:!!b}});if(v==="percent")return C.jsx(hf,{name:`${M}-percentmaterial-${r}`,backgroundColor:f,color:d!=null?d:u.Color3.Black(),startPercent:T?T[0]:1,endPercent:T?T[1]:1,zOffset:-2,zOffsetUnits:-10,start:x,end:h});if(v==="standard")return C.jsx("standardMaterial",{name:`${M}-material`,alphaMode:u.Engine.ALPHA_COMBINE,transparencyMode:b?u.Material.MATERIAL_ALPHABLEND:u.Material.MATERIAL_OPAQUE,alpha:k});if(v==="pbr-light")return C.jsx(Yn,{alpha:k});if(v==="pbr-dark")return C.jsx(Jn,{alpha:k})},[k,b,f,d,h,r,v,M,T,x]);return C.jsxs("transformNode",{name:`node-${M}-${r}`,setEnabled:l,children:[C.jsxs("transformNode",{name:`${M}`,position:P?P.multiply(Oe(o)):new u.Vector3(0,0,0),scaling:Oe(o),ref:i,children:[C.jsx("mesh",{name:`roadway-${r}-mesh`,ref:a,isPickable:!0,children:N()}),C.jsx("transformNode",{name:`${M}-title`,position:e.style.position?e.style.position:new u.Vector3(0,0,0),scaling:ct(o),children:e.style.title&&C.jsx(Je,{text:e.style.title,fontSize:e.style.fontSize?e.style.fontSize:40,color:e.style.color?e.style.color:"black"})})]}),_]})},Sn=m.forwardRef(gf);function vf(e,t){if(typeof t=="string")return t===e;if(t.mode==="prefix")return e.startsWith(t.value);try{return new RegExp(t.value,t.flags).test(e)}catch(n){return!1}}const Pa=e=>{const[t,n]=m.useState({top:{vertices:[],indices:[],colors:[]},side:{vertices:[],indices:[],colors:[]},bottom:{vertices:[],indices:[],colors:[]}}),a=_e.useScene(),[i,o]=m.useState(new u.Vector3(0,0,0)),r=m.useRef(!1),[l,s]=m.useState([]),[c,p]=m.useState(""),[f,d]=m.useState([]),{id:x,url:h,visible:T=!0,offset:P=new u.Vector3(0,0,0),children:v,actions:_,rayPick:b,showRoadwayWall:k={top:!0,bottom:!0,side:!0},roadwayName:M={nameList:[],offset:new u.Vector3(0,0,0)}}=e,{top:w=!0,bottom:S=!0,side:N=!0}=k,F=ef(h);return m.useEffect(()=>{if(F&&!r.current){r.current=!0;let B=[];const I=Yi.decode(new Uint8Array(F));console.log(I),p(I.name);const{boxes:D}=I,E=[],L=[],y=[],A=[],V=[],$=[],W=[],ne=[],ee=[];let G=0,le=0,re=0;const oe=I.position?new u.Vector3(I.position.x,I.position.y,I.position.z):new u.Vector3(0,0,0);return D.forEach(Y=>{var Q,Ee,ke,te,me,ue;const{topMesh:ce,bottomMesh:ae,sideMesh:X}=Y;let Pe=0;ce&&ce.vertices&&ce.indices&&ce.colors&&(E.push(...ce.vertices),L.push(...ce.indices.map(pe=>pe+G)),y.push(...ce.colors),Pe=Math.max(...ce.indices)),G+=Pe+1;let ge=0;X&&X.vertices&&X.indices&&X.colors&&(A.push(...X.vertices),V.push(...X.indices.map(pe=>pe+le)),$.push(...X.colors),ge=Math.max(...X.indices)),le+=ge+1;let H=0;if(ae&&ae.vertices&&ae.indices&&ae.colors&&(W.push(...ae.vertices),ne.push(...ae.indices.map(pe=>pe+re)),ee.push(...ae.colors),H=Math.max(...ae.indices)),re+=H+1,Y.name){const pe=new u.Vector3((Q=Y.startPosition)==null?void 0:Q.x,(Ee=Y.startPosition)==null?void 0:Ee.y,(ke=Y.startPosition)==null?void 0:ke.z),Ne=new u.Vector3((te=Y.endPosition)==null?void 0:te.x,(me=Y.endPosition)==null?void 0:me.y,(ue=Y.endPosition)==null?void 0:ue.z),be=pe.add(Ne).scale(.5);B.push({name:Y.name,position:be})}}),n({top:{vertices:E,indices:L,colors:y},side:{vertices:A,indices:V,colors:$},bottom:{vertices:W,indices:ne,colors:ee}}),o(oe),d(B),()=>{r.current=!1,n({top:{vertices:[],indices:[],colors:[]},side:{vertices:[],indices:[],colors:[]},bottom:{vertices:[],indices:[],colors:[]}}),o(new u.Vector3(0,0,0)),d([])}}},[F]),m.useEffect(()=>{const B=a==null?void 0:a.onPointerObservable.add(function(I){if(b)switch(I.type){case u.PointerEventTypes.POINTERUP:const D=a.pick(a.pointerX,a.pointerY);if(D.hit){const E=D.pickedMesh;(E==null?void 0:E.name)===`roadway-${x}-mesh`&&_!=null&&_.onLeftClick&&_.onLeftClick(E.name,void 0,D.pickedPoint)}break}});return()=>{a==null||a.onPointerObservable.remove(B)}},[_,x,c,b,a]),m.useEffect(()=>{if(!(M!=null&&M.nameList.length)){s([]);return}s(f.filter(B=>M.nameList.some(I=>vf(B.name,I))))},[M,f]),C.jsxs(C.Fragment,{children:[t.top.vertices.length>0&&t.top.indices.length>0&&C.jsx(Sn,{id:x,name:c,visible:T&&w,vertices:t.top.vertices,indices:t.top.indices,position:i.add(P),colors:t.top.colors.length>0?t.top.colors:void 0,style:{},actions:_,materialType:"standard",gpuPick:!b,children:v}),t.side.vertices.length>0&&t.side.indices.length>0&&C.jsx(Sn,{id:x,name:c,visible:T&&N,vertices:t.side.vertices,indices:t.side.indices,position:i.add(P),colors:t.side.colors.length>0?t.side.colors:void 0,style:{},actions:_,materialType:"standard",gpuPick:!b,children:v}),t.bottom.vertices.length>0&&t.bottom.indices.length>0&&C.jsx(Sn,{id:x,name:c,visible:T&&S,vertices:t.bottom.vertices,indices:t.bottom.indices,position:i.add(P),colors:t.bottom.colors.length>0?t.bottom.colors:void 0,style:{},actions:_,gpuPick:!b,materialType:"standard",children:v}),l.map((B,I)=>C.jsxs("transformNode",{name:`roadway-name-${B.name}-${I}-root`,children:[C.jsx("transformNode",{name:`roadway-name-${B.name}-${I}`,position:B.position.add(P).add((M==null?void 0:M.offset)||new u.Vector3(0,0,0)),billboardMode:u.Mesh.BILLBOARDMODE_ALL,children:C.jsx(Je,{text:B.name,fontSize:(M==null?void 0:M.fontSize)||18,color:(M==null?void 0:M.color)||"#FFFFFF"})},I),M.offset&&M.offset.y!==0?C.jsx("lineSystem",{name:`roadway-name-${B.name}-${I}-line`,lines:[[B.position,B.position.add(M.offset)]],color:u.Color3.White()}):null]}))]})},xf=e=>{const{id:t,node:n}=e,[a,i]=m.useState([]),[o,r]=m.useState([]),l=(c,p)=>{const f=[];let d=0;for(const[x,h]of c){let T=x;for(;d<p.length&&p[d][1]<=x;)d++;for(;d<p.length&&p[d][0]<h&&(p[d][0]>T&&f.push([T,p[d][0]]),T=Math.max(T,p[d][1]),!(p[d][1]>=h));)d++;T<h&&f.push([T,h])}return f};m.useEffect(()=>{if(n.range){const c=[],p=[];let f=[];const d=n,x=[],h=[];switch(n.type){case"run":c.push(s(n.percent[0].start,n.percent[0].end)),p.push(n.colors[0]);break;default:for(let T=0;T<n.percent.length;T++){const P=s(n.percent[T].start,n.percent[T].end);P[0]!==P[1]&&x.push(P)}for(let T=0;T<d.colorPercent.length;T++){const P=s(d.colorPercent[T].start,d.colorPercent[T].end);P[0]!==P[1]&&(h.push(P),c.push([P[0],P[1]]),p.push(n.colors[1]))}f=l(x,h),f.forEach(T=>{c.push(T),p.push(n.colors[0])})}i(c),r(p)}},[n,n.colors,n.percent,n.range,n.type]);const s=(c,p)=>c>p?[p,c]:[c,p];return C.jsx("transformNode",{name:`animation-node-${n.name}`,children:a.map((c,p)=>C.jsx("transformNode",{name:`child-${p}`,children:c[0]>=0&&c[1]>=0&&n.meshs&&n.meshs.map((f,d)=>c[0]===c[1]?null:C.jsx(Sn,{id:t,visible:!0,vertices:f.vertices,indices:f.indices,position:new u.Vector3(0,0,0),color:o[p],percent:c,start:n.start,end:n.end,style:{},materialType:"percent"},d))},p))})},yf=e=>{const{nodes:t}=e,n=m.useRef(null),a=m.useRef([]),[i,o]=m.useState(),r=l=>{const s=[];for(let p=0;p<l.length;p++)s.push(l[p].start),s.push(l[p].end);const c=s.sort((p,f)=>p-f);return c[0]===0&&c[3]===1&&c[1]===c[2]};return m.useEffect(()=>{const l=setInterval(()=>{n.current||(n.current={vertices:[],indices:[],colors:[],normals:[],uv:[]});let s=n.current.indices.length>0?Math.max(...n.current.indices)+1:0;t==null||t.map(c=>{if(c instanceof Ki){const p=c.colorPercent;a.current.findIndex(d=>d===c.name)===-1&&c.meshs&&r(p)&&(a.current.push(c.name),c.meshs.forEach(d=>{var h,T;let x=0;d.vertices&&d.indices&&((h=n.current)==null||h.vertices.push(...d.vertices),(T=n.current)==null||T.indices.push(...d.indices.map(P=>P+s)),x=Math.max(...d.indices)),s+=x+1}))}}),o({vertices:[...n.current.vertices],indices:[...n.current.indices],colors:[],normals:[],uv:[]})},3e4);return()=>{clearInterval(l)}},[t]),C.jsxs(C.Fragment,{children:[t&&t.map((l,s)=>a.current.find(p=>p===l.name)?null:C.jsx(xf,{id:s,node:l},l.name)),t&&i&&i.vertices.length>0&&C.jsx(Sn,{id:0,name:"animation-merged-mesh",visible:!0,vertices:i.vertices,indices:i.indices,position:new u.Vector3(0,0,0),color:t[0].colors[1],percent:[0,1],start:t[0].start,end:t[0].end,style:{},materialType:"percent"})]})},Cf=e=>{const{url:t,zOffset:n,zOffsetUnits:a,uScale:i,vScale:o,isBlink:r}=e,[l,s]=m.useState(),[c,p]=m.useState(1);return m.useEffect(()=>{const f=new u.Texture(t);f.hasAlpha=!0,f.uScale=i,f.vScale=o,s(f)},[t,i,o]),m.useEffect(()=>{const f=setInterval(()=>{r&&p(d=>d===0?1:0)},1e3);return()=>{clearInterval(f)}},[r]),C.jsx("standardMaterial",{name:e.name,backFaceCulling:e.backFaceCulling,needDepthPrePass:e.needDepthPrePass,transparencyMode:e.transparencyMode,alphaMode:e.alphaMode,alpha:c,diffuseTexture:l,emissiveTexture:l,useAlphaFromDiffuseTexture:!0,disableLighting:!0,zOffset:n,zOffsetUnits:a,sideOrientation:u.Material.CounterClockWiseSideOrientation})},_f=e=>{const{node:t,roadwayWidth:n,textureLength:a,url:i,visible:o=!0,isBlink:r=!0}=e,[l,s]=m.useState(),c=m.useRef(null),[p,f]=m.useState(),[d,x]=m.useState(!1),[h,T]=m.useState(1),P=(v,_,b,k)=>{const w=u.Vector3.Distance(v,_)/k,S=u.Vector3.Distance(v,b),N=Math.floor(S/w);return Math.min(N,k-1)};return m.useEffect(()=>{if(t.start&&t.end&&t.current){const v=u.Vector3.Distance(t.start,t.end),_=Math.floor(v/a),b=P(t.start,t.end,t.current,_);if(t.end.equals(t.current)){s(0);return}s(_-b),T((_-b)/_)}},[t,t.end,t.start,a]),m.useEffect(()=>{if(t.end===t.current){f(void 0);return}if(t.start&&t.end&&t.current){const v=u.Vector3.Lerp(t.start,t.end,.5+(1-h)/2);f(v)}},[t,h]),m.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,x(!0))},[t.end]),C.jsx(C.Fragment,{children:p&&l&&t.start&&t.end&&C.jsx("plane",{name:`${t.name}-mesh`,width:u.Vector3.Distance(t.start,t.end),height:n,ref:c,position:p,setEnabled:d&&o,scaling:new u.Vector3(h,1,1),children:C.jsx(Cf,{name:t.name,alphaMode:u.Engine.ALPHA_COMBINE,transparencyMode:u.Material.MATERIAL_ALPHABLEND,url:i,uScale:l,vScale:1,zOffset:-10,zOffsetUnits:-10,isBlink:r})})})},Pf=e=>{const{nodes:t,roadwayWidth:n=2,textureLength:a=4,url:i,visible:o=!0,isBlink:r=!0}=e;return C.jsx(C.Fragment,{children:t&&t.map((l,s)=>{const c=l;return C.jsx(_f,{node:c,roadwayWidth:n,textureLength:a,url:i,visible:o,isBlink:r},s)})})};class Sf{constructor(t,n,a){ve(this,"sourceVertex");ve(this,"targetVertex");ve(this,"meshCurrent");ve(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 Tf=({position:e=u.Vector3.Zero(),id:t,node:n,timeSpeed:a=-6,perlinMultiply:i=.5,waterFlow:o=1,clippedHeight:r=0,alpha:l=1,colorSteps:s=[new u.GradientBlockColorStep(0,new u.Color3(25,92,255)),new u.GradientBlockColorStep(1,new u.Color3(127,223,252))],subdivideX:c=15,subdivideY:p=150})=>{const f=_e.useScene(),d=m.useContext(Le),x=m.useRef(null),h=m.useRef(null),[T,P]=m.useState(u.Vector3.Zero()),v=m.useRef(null),_=m.useRef(null),b=m.useRef(null);return m.useEffect(()=>{const k=x.current;if(f&&k){v.current=Su({name:`waterMat-${t}-${n.name}`,scene:f}),v.current.getBlockByName("TimeSpeed").value=a,v.current.getBlockByName("PerlinMultiply").value=i,v.current.getBlockByName("waterFlow").value=o,v.current.getBlockByName("ClippedHeight").value=r,v.current.alpha=l,v.current.getBlockByName("Gradient").colorSteps=s;const M=v.current;M.getBlockByName("MaskEnabled").value=0,M.build(!1,!0,!0);const w=n.start,S=n.end,N=u.Vector3.Normalize(S.subtract(w)),F=Math.asin(N.y),B=Math.atan2(N.x,N.z),I=new u.Vector3(-F,B,0);return P(I),k.morphTargetManager=new u.MorphTargetManager,k.morphTargetManager.enableNormalMorphing=!0,b.current=k.getVerticesData(u.VertexBuffer.PositionKind).slice(0),b.current.length===0&&console.log("[Geo3DViewer] 水模拟,原始 SourceKind 为空",t,n.name),k.material=v.current,()=>{var D;(D=v.current)==null||D.dispose()}}},[t,n.end,n.name,n.start,f]),m.useEffect(()=>{const k=x.current,M=x.current;if(k&&M){console.log(`[Geo3DViewer] 正在更新 ${t} / ${n.name} 的进度 Time: ${n.time/1e3}`);const w=M.getVerticesData(u.VertexBuffer.PositionKind).slice(0);w.length===0&&console.log("[Geo3DViewer] 水模拟 SourceKind 为空",t,n.name),M.updateMeshPositions(B=>{for(let I=0;I<B.length;I++)B[I]=b.current[I]});const S=M.applyDisplacementMapFromBuffer(n.glurHeightMap,1,n.waterLength,0,n.height,u.Vector2.Zero(),u.Vector2.One(),!1).getVerticesData(u.VertexBuffer.PositionKind).slice(0);S.length===0&&console.log("[Geo3DViewer] 水模拟 SourceKind 为空",t,n.name),k.updateMeshPositions(B=>{for(let I=0;I<B.length;I++)B[I]=S[I]});const N=new Sf(w,S,k),F=new u.Animation("waterAnimation","influence",1e3/30,u.Animation.ANIMATIONTYPE_FLOAT,u.Animation.ANIMATIONLOOPMODE_CONSTANT);F.setKeys([{frame:0,value:0},{frame:10,value:1}]),f==null||f.beginDirectAnimation(N,[F],0,10,!1,10)}},[t,n.glurHeightMap,n.height,n.name,n.waterLength,n.time]),m.useEffect(()=>{const k=v.current;k&&(k.getBlockByName("TimeSpeed").value=a)},[a]),m.useEffect(()=>{const k=v.current;k&&(k.getBlockByName("PerlinMultiply").value=i)},[i]),m.useEffect(()=>{const k=v.current;k&&(k.getBlockByName("waterFlow").value=o)},[o]),m.useEffect(()=>{const k=v.current;k&&(k.getBlockByName("ClippedHeight").value=r)},[r]),m.useEffect(()=>{const k=v.current;k&&(k.alpha=l)},[l]),m.useEffect(()=>{const k=v.current;k&&(k.getBlockByName("Gradient").colorSteps=s,k.build(!1,!0,!0))},[s]),C.jsx("transformNode",{name:`water-simulation-${t}-${n.name}`,children:C.jsxs("transformNode",{name:`${name}`,position:e?e.multiply(Oe(d)):new u.Vector3(0,0,0),scaling:Oe(d),ref:h,children:[C.jsx("ground",{ref:x,name:`water-simulation-${t}-1`,position:n.center,rotation:T,subdivisionsX:c,subdivisionsY:p,updatable:!0,width:n.width,height:n.waterLength}),C.jsx("ground",{ref:_,name:`stub-water-simulation-${t}-1`,position:n.center,rotation:T,subdivisionsX:c,subdivisionsY:p,updatable:!0,width:n.width,height:n.waterLength,setEnabled:!1})]})})},bf=e=>{const{nodes:t}=e;return C.jsx(C.Fragment,{children:t&&t.map((n,a)=>C.jsx(Tf,{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))})},Sa=e=>{const{rootUrl:t,size:n=1e3,name:a="skybox"}=e;return C.jsx(_e.Skybox,{rootUrl:t,size:n,name:a})};function ai(){return{name:"",origin:void 0,dataPoints:[]}}const Ta={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.origin!==void 0&&K.encode(e.origin,t.uint32(18).fork()).ldelim();for(const n of e.dataPoints)pn.encode(n,t.uint32(26).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=ai();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 2:if(o!==18)break;i.origin=K.decode(n,n.uint32());continue;case 3:if(o!==26)break;i.dataPoints.push(pn.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{name:Cn(e.name)?globalThis.String(e.name):"",origin:Cn(e.origin)?K.fromJSON(e.origin):void 0,dataPoints:globalThis.Array.isArray(e==null?void 0:e.dataPoints)?e.dataPoints.map(t=>pn.fromJSON(t)):[]}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),e.origin!==void 0&&(t.origin=K.toJSON(e.origin)),(n=e.dataPoints)!=null&&n.length&&(t.dataPoints=e.dataPoints.map(a=>pn.toJSON(a))),t},create(e){return Ta.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=ai();return t.name=(n=e.name)!=null?n:"",t.origin=e.origin!==void 0&&e.origin!==null?K.fromPartial(e.origin):void 0,t.dataPoints=((a=e.dataPoints)==null?void 0:a.map(i=>pn.fromPartial(i)))||[],t}};function si(){return{point:void 0,colorId:0,vColor:0,vRadius:0}}const pn={encode(e,t=se.Writer.create()){return e.point!==void 0&&K.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=si();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.point=K.decode(n,n.uint32());continue;case 2:if(o!==16)break;i.colorId=n.uint32();continue;case 3:if(o!==29)break;i.vColor=n.float();continue;case 4:if(o!==37)break;i.vRadius=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{point:Cn(e.point)?K.fromJSON(e.point):void 0,colorId:Cn(e.colorId)?globalThis.Number(e.colorId):0,vColor:Cn(e.vColor)?globalThis.Number(e.vColor):0,vRadius:Cn(e.vRadius)?globalThis.Number(e.vRadius):0}},toJSON(e){const t={};return e.point!==void 0&&(t.point=K.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 pn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i;const t=si();return t.point=e.point!==void 0&&e.point!==null?K.fromPartial(e.point):void 0,t.colorId=(n=e.colorId)!=null?n:0,t.vColor=(a=e.vColor)!=null?a:0,t.vRadius=(i=e.vRadius)!=null?i:0,t}};function Cn(e){return e!=null}var ba=(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))(ba||{});const ka=({url:e,colorCodec:t,alpha:n=1,visible:a=!0,offset:i=u.Vector3.Zero(),scale:o=1,objectType:r=2})=>{const l=_e.useScene(),s=m.useRef(null),c=m.useContext(Le),p=m.useContext(Lt),f=m.useRef(null),[d,x]=m.useState(""),[h,T]=m.useState(u.Vector3.Zero()),P=je({url:e,cacheType:Me.URL_PREFIX_MATCH}),[v,_]=m.useState(null);return m.useEffect(()=>{console.log("[Geo3DViewer] SpaceHeat Loading: ",e)},[e]),m.useEffect(()=>{if(l&&s.current&&P){const b=s.current;u.Tags.EnableFor(b),u.Tags.AddTagsTo(b,"loading");const k=Ta.decode(new Uint8Array(P)),{name:M,origin:w,dataPoints:S}=k;if(w&&S){x(M),T(new u.Vector3(w.x,w.y,w.z));const N=new Float32Array(S.length*16),F=new Float32Array(S.length*4);return S.forEach((B,I)=>{if(B.point){const D=new u.Vector3(B.point.x,B.point.y,B.point.z).multiplyByFloats(c&&c.scalePlane?c.scalePlane:1,c&&c.scaleDepth?c.scaleDepth:1,c&&c.scalePlane?c.scalePlane:1),E=u.Quaternion.Identity(),L=new u.Vector3(B.vRadius*o,B.vRadius*o,B.vRadius*o);if(u.Matrix.Compose(L,E,D).copyToArray(N,I*16),t){const A=p.colorCodecs[t].array,V=A[Math.floor(B.vColor*(A.length-1))];F.set([V.r,V.g,V.b,n],I*4)}else{const A=p.colorIDs[B.colorId];F.set([A.r,A.g,A.b,n],I*4)}}}),b&&(b.thinInstanceSetBuffer("matrix",N),b.thinInstanceSetBuffer("color",F,4)),u.Tags.RemoveTagsFrom(b,"loading"),v==null||v.addMesh(b,u.Color3.White()),()=>{b&&(b.thinInstanceSetBuffer("matrix",new Float32Array),b.thinInstanceSetBuffer("color",new Float32Array))}}}},[n,t,p.colorCodecs,p.colorIDs,c==null?void 0:c.scalePlane,o,l,P,v,c==null?void 0:c.scaleDepth,c==null?void 0:c.scalePlane]),m.useEffect(()=>(f.current&&l&&n&&f.current.setFloat("alpha",n),l&&r===5&&_(new u.HighlightLayer(`highlight-layer-spaceheat-${d}`,l)),()=>{v&&v.dispose()}),[l,n,r]),C.jsx("transformNode",{setEnabled:a,name:`transform-spaceheat-${d}`,position:h.add(i).multiplyByFloats(c&&c.scalePlane?c.scalePlane:1,c&&c.scaleDepth?c.scaleDepth:1,c&&c.scalePlane?c.scalePlane:1),children:r===5?C.jsx("disc",{ref:s,name:`spaceheat-${d}`,radius:1,tessellation:32,sideOrientation:u.Mesh.DOUBLESIDE,billboardMode:u.Mesh.BILLBOARDMODE_ALL,children:t?C.jsx("standardMaterial",{name:`spaceheat-${d}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new u.Color3(0,0,0),ambientColor:new u.Color3(1,1,1),emissiveColor:u.Color3.White(),alphaMode:u.Engine.ALPHA_COMBINE,alpha:n,zOffset:-3}):C.jsx("standardMaterial",{name:`spaceheat-${d}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new u.Color3(0,0,0),ambientColor:new u.Color3(1,1,1),emissiveColor:u.Color3.White(),alphaMode:u.Engine.ALPHA_COMBINE,alpha:n,zOffset:-3})}):C.jsx("polyhedron",{ref:s,name:`spaceheat-${d}`,type:r,children:t?C.jsx("standardMaterial",{name:`spaceheat-${d}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new u.Color3(0,0,0),ambientColor:new u.Color3(1,1,1),emissiveColor:u.Color3.Black(),alphaMode:u.Engine.ALPHA_COMBINE,alpha:n,zOffset:-3}):C.jsx("standardMaterial",{name:`spaceheat-${d}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new u.Color3(0,0,0),ambientColor:new u.Color3(1,1,1),emissiveColor:u.Color3.Black(),alphaMode:u.Engine.ALPHA_COMBINE,alpha:n,zOffset:-3})})})};var Ea=(e=>(e[e.OSM=1]="OSM",e[e.AMAP=2]="AMAP",e))(Ea||{});const Na=({mode:e=1,baseUrl:t,visible:n=!0,xmin:a=-10,xmax:i=10,zmin:o=-10,zmax:r=10,zoom:l=12,xTileBase:s=2120,yTileBase:c=1498,precision:p={w:2,h:2},subdivisions:f={w:8,h:8},offset:d=u.Vector3.Zero(),scale:x=1})=>{const h=_e.useScene(),T=m.useRef(null),P=m.useRef(null),[v,_]=m.useState([]),[b,k]=m.useState([]);return m.useEffect(()=>{const M=T.current,w=P.current;if(M&&w){const S=M.getTotalVertices(),N=M.getIndices().length/(f.w*f.h),F=[];let B=0,I=0;for(let E=0;E<f.h;E++)for(let L=0;L<f.w;L++){const y=new u.SubMesh(B++,0,S,I,N,M);F.push(y),I+=N}const D=[];return[...Array(f.h).keys()].flatMap(E=>[...Array(f.w).keys()].map(L=>{const y=new u.StandardMaterial(`tileMap-material-${E}-${L}`),A=[`${t}/${l}/${s+L}/${c-E}.png`,`${t}/appmaptile?z=${l}&x=${s+L}&y=${c-E}&style=6`];return y.diffuseTexture=new u.Texture(A[A!=null&&A[e-1]?e-1:0],h),y.diffuseTexture.wrapU=u.Texture.CLAMP_ADDRESSMODE,y.diffuseTexture.wrapV=u.Texture.CLAMP_ADDRESSMODE,y.specularColor=u.Color3.Black(),y.backFaceCulling=!1,y})).forEach(E=>{D.push(E)}),k(F),_(D),M.subMeshes=F,w.subMaterials=D,()=>{w.subMaterials=[],M.subMeshes=[],_([]),k([])}}},[t,e,h,f.h,f.w,s,c,l]),C.jsx("transformNode",{name:"tileMap",setEnabled:n,position:d,scalingDeterminant:x,children:C.jsx("tiledGround",{name:"tileMap-ground",xmin:a,xmax:i,zmin:o,zmax:r,subdivisions:f,precision:p,subMeshes:b,ref:T,children:C.jsx("multiMaterial",{name:"submaterial-tile-map",subMaterials:v,ref:P})})})};function li(){return{name:"",origin:void 0,type:"",sliceList:[],vertices:[],normals:[],indices:[],colors:[],uv:[],meshs:[]}}const Nt={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.origin!==void 0&&K.encode(e.origin,t.uint32(18).fork()).ldelim(),e.type!==""&&t.uint32(26).string(e.type);for(const n of e.sliceList)hn.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)We.encode(n,t.uint32(130).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=li();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 2:if(o!==18)break;i.origin=K.decode(n,n.uint32());continue;case 3:if(o!==26)break;i.type=n.string();continue;case 10:if(o!==82)break;i.sliceList.push(hn.decode(n,n.uint32()));continue;case 11:if(o===93){i.vertices.push(n.float());continue}if(o===90){const r=n.uint32()+n.pos;for(;n.pos<r;)i.vertices.push(n.float());continue}break;case 12:if(o===101){i.normals.push(n.float());continue}if(o===98){const r=n.uint32()+n.pos;for(;n.pos<r;)i.normals.push(n.float());continue}break;case 13:if(o===104){i.indices.push(n.uint32());continue}if(o===106){const r=n.uint32()+n.pos;for(;n.pos<r;)i.indices.push(n.uint32());continue}break;case 14:if(o===117){i.colors.push(n.float());continue}if(o===114){const r=n.uint32()+n.pos;for(;n.pos<r;)i.colors.push(n.float());continue}break;case 15:if(o===125){i.uv.push(n.float());continue}if(o===122){const r=n.uint32()+n.pos;for(;n.pos<r;)i.uv.push(n.float());continue}break;case 16:if(o!==130)break;i.meshs.push(We.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{name:vt(e.name)?globalThis.String(e.name):"",origin:vt(e.origin)?K.fromJSON(e.origin):void 0,type:vt(e.type)?globalThis.String(e.type):"",sliceList:globalThis.Array.isArray(e==null?void 0:e.sliceList)?e.sliceList.map(t=>hn.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=>We.fromJSON(t)):[]}},toJSON(e){var n,a,i,o,r,l,s;const t={};return e.name!==""&&(t.name=e.name),e.origin!==void 0&&(t.origin=K.toJSON(e.origin)),e.type!==""&&(t.type=e.type),(n=e.sliceList)!=null&&n.length&&(t.sliceList=e.sliceList.map(c=>hn.toJSON(c))),(a=e.vertices)!=null&&a.length&&(t.vertices=e.vertices),(i=e.normals)!=null&&i.length&&(t.normals=e.normals),(o=e.indices)!=null&&o.length&&(t.indices=e.indices.map(c=>Math.round(c))),(r=e.colors)!=null&&r.length&&(t.colors=e.colors),(l=e.uv)!=null&&l.length&&(t.uv=e.uv),(s=e.meshs)!=null&&s.length&&(t.meshs=e.meshs.map(c=>We.toJSON(c))),t},create(e){return Nt.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i,o,r,l,s,c,p;const t=li();return t.name=(n=e.name)!=null?n:"",t.origin=e.origin!==void 0&&e.origin!==null?K.fromPartial(e.origin):void 0,t.type=(a=e.type)!=null?a:"",t.sliceList=((i=e.sliceList)==null?void 0:i.map(f=>hn.fromPartial(f)))||[],t.vertices=((o=e.vertices)==null?void 0:o.map(f=>f))||[],t.normals=((r=e.normals)==null?void 0:r.map(f=>f))||[],t.indices=((l=e.indices)==null?void 0:l.map(f=>f))||[],t.colors=((s=e.colors)==null?void 0:s.map(f=>f))||[],t.uv=((c=e.uv)==null?void 0:c.map(f=>f))||[],t.meshs=((p=e.meshs)==null?void 0:p.map(f=>We.fromPartial(f)))||[],t}};function ci(){return{position:void 0,start:void 0,end:void 0,color:void 0,angle:0,radius:0,innerRadius:0,texture:"",v:[]}}const hn={encode(e,t=se.Writer.create()){e.position!==void 0&&K.encode(e.position,t.uint32(10).fork()).ldelim(),e.start!==void 0&&K.encode(e.start,t.uint32(18).fork()).ldelim(),e.end!==void 0&&K.encode(e.end,t.uint32(26).fork()).ldelim(),e.color!==void 0&&ot.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=ci();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.position=K.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.start=K.decode(n,n.uint32());continue;case 3:if(o!==26)break;i.end=K.decode(n,n.uint32());continue;case 4:if(o!==34)break;i.color=ot.decode(n,n.uint32());continue;case 5:if(o!==45)break;i.angle=n.float();continue;case 6:if(o!==53)break;i.radius=n.float();continue;case 8:if(o!==69)break;i.innerRadius=n.float();continue;case 9:if(o!==74)break;i.texture=n.string();continue;case 10:if(o!==82)break;i.v.push(n.string());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{position:vt(e.position)?K.fromJSON(e.position):void 0,start:vt(e.start)?K.fromJSON(e.start):void 0,end:vt(e.end)?K.fromJSON(e.end):void 0,color:vt(e.color)?ot.fromJSON(e.color):void 0,angle:vt(e.angle)?globalThis.Number(e.angle):0,radius:vt(e.radius)?globalThis.Number(e.radius):0,innerRadius:vt(e.innerRadius)?globalThis.Number(e.innerRadius):0,texture:vt(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=K.toJSON(e.position)),e.start!==void 0&&(t.start=K.toJSON(e.start)),e.end!==void 0&&(t.end=K.toJSON(e.end)),e.color!==void 0&&(t.color=ot.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 hn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i,o,r;const t=ci();return t.position=e.position!==void 0&&e.position!==null?K.fromPartial(e.position):void 0,t.start=e.start!==void 0&&e.start!==null?K.fromPartial(e.start):void 0,t.end=e.end!==void 0&&e.end!==null?K.fromPartial(e.end):void 0,t.color=e.color!==void 0&&e.color!==null?ot.fromPartial(e.color):void 0,t.angle=(n=e.angle)!=null?n:0,t.radius=(a=e.radius)!=null?a:0,t.innerRadius=(i=e.innerRadius)!=null?i:0,t.texture=(o=e.texture)!=null?o:"",t.v=((r=e.v)==null?void 0:r.map(l=>l))||[],t}};function vt(e){return e!=null}const kf=(e,t)=>{const n=m.useRef(null),a=m.useContext(Le),{id:i,name:o,visible:r=!0,position:l,children:s,isRegular:c=!0}=e;return m.useImperativeHandle(t,()=>n.current,[]),C.jsx("transformNode",{name:`node-${o}-${i}`,setEnabled:r,position:l?l.multiply(Oe(a)):new u.Vector3(0,0,0),scaling:c?Oe(a):u.Vector3.One(),ref:n,children:s})},Ef=m.forwardRef(kf),Nf=e=>{const t=_e.useScene(),n=m.useRef(null),{title:a,url:i,color:o,v:r,actions:l,path:s,radius:c,mesh:p}=e;return m.useEffect(()=>{n.current&&(n.current.metadata={pickable:l?{name:a,onLeftClick:l.onLeftClick,onRightClick:l.onRightClick,onMiddleClick:l.onMiddleClick,onHover:l.onHover,needWorldPosition:l.needWorldPosition,extra:r}:null})},[l,a,r]),m.useEffect(()=>{if(n.current){const f=new u.VertexData;f.positions=p.vertices,f.indices=p.indices,f.normals=p.normals,f.uvs=p.uv,f.applyToMesh(n.current)}},[p.indices,p.normals,p.uv,p.vertices,s,c,t]),C.jsx("mesh",{name:"mesh",ref:n,children:C.jsx("standardMaterial",{name:"material",diffuseColor:i===""?new u.Color3(o.r,o.g,o.b):void 0,diffuseTexture:i!==""?new u.Texture(i):void 0})})},If=(e,t)=>{const{name:n,position:a,slices:i,meshs:o,actions:r}=e,l=m.useRef(null);return m.useImperativeHandle(t,()=>l.current,[]),C.jsx("transformNode",{name:"lod0",ref:l,setEnabled:!1,children:a&&i.map((s,c)=>{var p,f,d,x,h,T;return C.jsx(Nf,{id:c,v:s.v,position:a.add(new u.Vector3(0,0,0)),path:[new u.Vector3((p=s.start)==null?void 0:p.x,(f=s.start)==null?void 0:f.y,(d=s.start)==null?void 0:d.z),new u.Vector3((x=s.end)==null?void 0:x.x,(h=s.end)==null?void 0:h.y,(T=s.end)==null?void 0:T.z)],radius:s.radius,actions:r,mesh:o[c],title:n,color:s.color?new u.Color4(s.color.r,s.color.g,s.color.b,s.color.a):new u.Color4(0,0,0,1),url:s.texture},c)})})},wf=m.forwardRef(If),Of=e=>{const t=_e.useScene(),n=m.useRef(null),a=m.useContext(Le),{id:i,vertices:o,indices:r,colors:l,color:s,materialType:c="custom",alphaBlend:p=!1,alpha:f=1,slices:d,position:x,name:h="tube",actions:T}=e;m.useEffect(()=>{n.current&&(n.current.metadata={pickable:T?{name:"",needWorldPosition:!0,onLeftClick:T.onLeftClick,onRightClick:T.onRightClick,onMiddleClick:T.onMiddleClick,onHover:(v,_,b,k,M)=>{var w,S,N,F,B,I;if(T.onHover&&t&&d&&b){const D=b;for(let E=0;E<d.length;E++){const L=new u.Vector3((w=d[E].start)==null?void 0:w.x,(S=d[E].start)==null?void 0:S.y,(N=d[E].start)==null?void 0:N.z).add(x).multiply(Oe(a)),y=new u.Vector3((F=d[E].end)==null?void 0:F.x,(B=d[E].end)==null?void 0:B.y,(I=d[E].end)==null?void 0:I.z).add(x).multiply(Oe(a)),A=u.MeshBuilder.CreateTube("boundingbox-tmp",{path:[L,y],radiusFunction:()=>{const $=d[E].radius;return $||1},cap:u.Mesh.NO_CAP,tessellation:8,sideOrientation:u.Mesh.DOUBLESIDE},t),V=A.getBoundingInfo().intersectsPoint(D);if(A.dispose(),V){T.onHover(v,new u.Vector2(t==null?void 0:t.pointerX,t==null?void 0:t.pointerY),b,k,M,d[E].v);break}}}}}:null})},[T,a,x,t,d]),m.useEffect(()=>{if(n&&n.current&&t){const v=new u.VertexData;v.positions=o,v.indices=r,l&&c!=="pbr-dark"&&c!=="standard"&&c!=="pbr-light"&&(v.colors=l),v.applyToMesh(n.current)}},[r,o,t,l,i,c]);const P=m.useCallback(()=>{if(c==="custom")return C.jsx(lt,{name:`${h}-material-${i}`,vertex:Gn,fragment:Zn,needDepthPrePass:!1,transparencyMode:p?u.Material.MATERIAL_ALPHABLEND:u.Material.MATERIAL_OPAQUE,options:{needAlphaBlending:!!p}});if(c==="standard")return C.jsx("standardMaterial",{name:`${h}-material`,alphaMode:u.Engine.ALPHA_COMBINE,transparencyMode:p?u.Material.MATERIAL_ALPHABLEND:u.Material.MATERIAL_OPAQUE,alpha:f,diffuseColor:s||void 0});if(c==="pbr-light")return C.jsx(Yn,{alpha:f});if(c==="pbr-dark")return C.jsx(Jn,{alpha:f})},[f,p,s,i,c,h]);return C.jsx("transformNode",{name:`${h}-main-node`,children:C.jsx("mesh",{name:`${h}-mesh`,ref:n,isPickable:!0,children:P()})})},Af=(e,t)=>{const{id:n,visible:a=!0,materialType:i="custom",vertices:o,indices:r,colors:l,color:s,slices:c,position:p,actions:f}=e,d=m.useRef(null);return m.useImperativeHandle(t,()=>d.current,[]),C.jsx("transformNode",{name:"lod1",ref:d,setEnabled:!1,children:o.length>0&&C.jsx(Of,{id:n,visible:a,vertices:o,indices:r,colors:l.length>0?l:void 0,materialType:i,alpha:1,color:s,alphaBlend:!1,position:p,actions:f,slices:c})})},Mf=m.forwardRef(Af),Lf=(e,t)=>{const n=m.useRef(null),a=m.useContext(Le),{style:i,name:o="tube"}=e;return m.useImperativeHandle(t,()=>n.current,[]),C.jsx("transformNode",{name:`${o}-title`,position:i.position?i.position.add(i.offset?i.offset:new u.Vector3(0,0,0)):new u.Vector3(0,0,0).add(i.offset?i.offset:new u.Vector3(0,0,0)),scaling:ct(a),ref:n,setEnabled:!1,children:i.title&&C.jsx(Je,{text:i.title,fontSize:i.fontSize?i.fontSize:40,color:i.color?i.color:"black"})})},Ia=m.forwardRef(Lf),wa=e=>{var ae,X,Pe,ge;const t=_e.useScene(),[n,a]=m.useState([]),[i,o]=m.useState([]),[r,l]=m.useState([]),s=m.useRef(null),c=m.useRef(null),p=m.useRef(null),[f,d]=m.useState(""),[x,h]=m.useState(new u.Vector3(0,0,0)),T=m.useRef(null),P=m.useRef(null),v=m.useRef(null),[_,b]=m.useState([]),k=m.useRef(!1),M=m.useContext(Le),[w,S]=m.useState([]),[N,F]=m.useState(!1),[B,I]=m.useState(!1),{id:D,url:E,color:L,visible:y=!0,materialType:A="custom",children:V,style:$,actions:W,noLod:ne=!1,lodDistance:ee=[200,1e3],loadDistance:G=0,offset:le=new u.Vector3(0,0,0),position:re,topPosition:oe,bottomPosition:Y,isRegular:ce=!0}=e;return m.useEffect(()=>{re&&oe&&Y?(s.current=re,c.current=oe,p.current=Y):I(!0)},[Y,re,oe]),m.useEffect(()=>{!k.current&&B&&(k.current=!0,Ut.get(E,{responseType:"arraybuffer"}).then(H=>{var me,ue,pe,Ne,be,Ae,Ie,we,Re;const Q=Nt.decode(new Uint8Array(H.data));console.log(Q);const Ee=Q.sliceList[0],ke=Q.sliceList[Q.sliceList.length-1];d(Q.name);const te=e.style.basePosition&&e.style.basePosition==="top"?Ee.start:ke.end;h(new u.Vector3(te==null?void 0:te.x,te==null?void 0:te.y,te==null?void 0:te.z)),s.current=new u.Vector3((me=Q.origin)==null?void 0:me.x,(ue=Q.origin)==null?void 0:ue.y,(pe=Q.origin)==null?void 0:pe.z).add(le),b(Q.sliceList.filter(Ve=>Ve.v)),c.current=new u.Vector3((Ne=Ee.start)==null?void 0:Ne.x,(be=Ee.start)==null?void 0:be.y,(Ae=Ee.start)==null?void 0:Ae.z).add(s.current),p.current=new u.Vector3((Ie=ke.end)==null?void 0:Ie.x,(we=ke.end)==null?void 0:we.y,(Re=ke.end)==null?void 0:Re.z).add(s.current),S(Q.meshs),a(Q.vertices),o(A==="custom"?Ot.correctTubeMainIndices(Q.indices):Q.indices),l(Q.colors)}))},[E,t,L,A,e.style.basePosition,le,B,M]),m.useEffect(()=>{const H=setInterval(()=>{var Q,Ee,ke,te,me,ue,pe,Ne,be,Ae,Ie,we,Re,Ve;if(t&&t.cameras.length>0&&t.activeCamera&&s.current&&c.current&&p.current){const Ue=Ot.calcLodDistance(c.current.multiply(Oe(M)),s.current.multiply(Oe(M)),p.current.multiply(Oe(M)),t.activeCamera.position);Ue>=G&&I(!0),ne?(w.length===0?((Q=T.current)==null||Q.setEnabled(!0),(Ee=P.current)==null||Ee.setEnabled(!1)):((ke=T.current)==null||ke.setEnabled(!1),(te=P.current)==null||te.setEnabled(!0)),(me=v.current)==null||me.setEnabled(!0)):Ue<ee[0]?(F(!0),(ue=T.current)==null||ue.setEnabled(!0),(pe=P.current)==null||pe.setEnabled(w.length===0),(Ne=v.current)==null||Ne.setEnabled(!0)):ee[1]&&Ue<ee[1]?((be=T.current)==null||be.setEnabled(!1),(Ae=P.current)==null||Ae.setEnabled(!0),(Ie=v.current)==null||Ie.setEnabled(!0)):((we=T.current)==null||we.setEnabled(!1),(Re=P.current)==null||Re.setEnabled(!1),(Ve=v.current)==null||Ve.setEnabled(!1))}},1e3);return()=>{clearInterval(H)}},[G,ee,w.length,M,t]),C.jsx(C.Fragment,{children:C.jsxs("transformNode",{name:`tube-${D} `,children:[C.jsxs(Ef,{id:D,name:f,visible:y,position:(ae=s.current)!=null?ae:new u.Vector3(0,0,0),isRegular:ce,children:[B&&C.jsx(Ia,{id:D,style:{title:f,position:x,offset:(X=$.offset)==null?void 0:X.multiply(wi(M)),fontSize:$.fontSize,color:$.color},ref:v}),N&&B&&ee[0]&&w.length>0&&C.jsx(wf,{id:D,name:f,meshs:w,position:(Pe=s.current)!=null?Pe:new u.Vector3(0,0,0),materialType:A,slices:_,actions:W,ref:T}),B&&C.jsx(Mf,{id:D,name:f,position:(ge=s.current)!=null?ge:new u.Vector3(0,0,0),vertices:n,indices:i,colors:r,color:L?new u.Color3(L.r,L.g,L.b):void 0,slices:_,actions:W,materialType:A,ref:P})]}),V]})})};function ui(){return{group:[]}}const Oa={encode(e,t=se.Writer.create()){for(const n of e.group)Nt.encode(n,t.uint32(10).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=ui();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.group.push(Nt.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{group:globalThis.Array.isArray(e==null?void 0:e.group)?e.group.map(t=>Nt.fromJSON(t)):[]}},toJSON(e){var n;const t={};return(n=e.group)!=null&&n.length&&(t.group=e.group.map(a=>Nt.toJSON(a))),t},create(e){return Oa.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=ui();return t.group=((n=e.group)==null?void 0:n.map(a=>Nt.fromPartial(a)))||[],t}},Aa=e=>{const t=_e.useScene(),[n,a]=m.useState([]),i=m.useRef(!1),o=m.useContext(Le),{visible:r=!0,groupUrl:l,modelUrl:s,group:c,actions:p}=e,f=m.useCallback((d,x)=>x?new u.Color4(x==null?void 0:x.r,x==null?void 0:x.g,x==null?void 0:x.b,x==null?void 0:x.a):d||new u.Color4(1,1,1,1),[]);return m.useEffect(()=>{if(!i.current&&(i.current=!0,l&&Ut.get(l,{responseType:"arraybuffer"}).then(d=>{const x=Oa.decode(new Uint8Array(d.data)),h=[];for(let T=0;T<x.group.length;T++)h.push(x.group[T]);a(h)}),c&&c.length>0)){const d=[];for(let x=0;x<c.length;x++)d.push(Ut.get(c[x].url,{responseType:"arraybuffer"}));Promise.all(d).then(x=>{const h=[];for(let T=0;T<x.length;T++){const P=Nt.decode(new Uint8Array(x[T].data));h.push(P)}a(h)})}}),m.useEffect(()=>{var x,h,T,P,v,_,b,k,M;let d;if(n.length>0){const w=[],S=[];for(let N=0;N<n.length;N++){const F=n[N],B=new u.Vector3((x=F.origin)==null?void 0:x.x,(h=F.origin)==null?void 0:h.y,(T=F.origin)==null?void 0:T.z),I=F.sliceList;if(I){const D=[],E=[];for(let L=0;L<I.length;L++)D.push(B.add(new u.Vector3((P=I[L].start)==null?void 0:P.x,(v=I[L].start)==null?void 0:v.y,(_=I[L].start)==null?void 0:_.z)).multiply(Oe(o))),E.push(f(void 0,I[L].color)),L===I.length-1&&(D.push(B.add(new u.Vector3((b=I[L].end)==null?void 0:b.x,(k=I[L].end)==null?void 0:k.y,(M=I[L].end)==null?void 0:M.z)).multiply(Oe(o))),E.push(f(void 0,I[L].color)));w.push(D),S.push(E)}}d=u.MeshBuilder.CreateLineSystem("linesystem",{lines:w,colors:S},t),d.setEnabled(r)}return()=>{d&&d.dispose()}},[f,o,t,n,r]),C.jsx(C.Fragment,{children:s&&n&&n.length>0?n.map(d=>{var x,h,T,P,v,_;return C.jsx(Kn,{position:new u.Vector3((x=d.origin)==null?void 0:x.x,(h=d.origin)==null?void 0:h.y,(T=d.origin)==null?void 0:T.z).add(new u.Vector3((P=d.sliceList[0].start)==null?void 0:P.x,(v=d.sliceList[0].start)==null?void 0:v.y,(_=d.sliceList[0].start)==null?void 0:_.z)).multiply(Oe(o)),name:"model-tube-instance",url:s,visible:r,actions:p},d.name)}):C.jsx(C.Fragment,{})})},Eo=e=>{const t=m.useContext(Le),{position:n=u.Vector3.Zero(),localScale:a=1,scaleMode:i=It.NONE}=e,[o,r]=m.useState(1),{modelRoation:l=new u.Vector3(0,0,0)}=e,s=m.useRef(null);return m.useEffect(()=>{switch(i){case It.PLANE:r((t&&t.scalePlane?t.scalePlane:1)*a);break;case It.DEPTH:r((t&&t.scaleDepth?t.scaleDepth:1)*a);break;case It.NONE:r(a);break}},[a,t,i]),m.useEffect(()=>{let c;return s.current&&(c=setInterval(()=>{var p;if(((p=s.current)==null?void 0:p.getChildren().length)===2){const f=s.current.getChildren()[1];f.rotation=l,c&&clearInterval(c)}},500)),()=>{c&&clearInterval(c)}},[l]),C.jsx(Kn,{...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:s})};function fi(){return{name:"",tubeName:"",min:0,max:0,origin:void 0,chart:[]}}const Xo={encode(e,t=se.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&&K.encode(e.origin,t.uint32(42).fork()).ldelim();for(const n of e.chart)mn.encode(n,t.uint32(50).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=fi();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 2:if(o!==18)break;i.tubeName=n.string();continue;case 3:if(o!==29)break;i.min=n.float();continue;case 4:if(o!==37)break;i.max=n.float();continue;case 5:if(o!==42)break;i.origin=K.decode(n,n.uint32());continue;case 6:if(o!==50)break;i.chart.push(mn.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{name:Dt(e.name)?globalThis.String(e.name):"",tubeName:Dt(e.tubeName)?globalThis.String(e.tubeName):"",min:Dt(e.min)?globalThis.Number(e.min):0,max:Dt(e.max)?globalThis.Number(e.max):0,origin:Dt(e.origin)?K.fromJSON(e.origin):void 0,chart:globalThis.Array.isArray(e==null?void 0:e.chart)?e.chart.map(t=>mn.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=K.toJSON(e.origin)),(n=e.chart)!=null&&n.length&&(t.chart=e.chart.map(a=>mn.toJSON(a))),t},create(e){return Xo.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i,o,r;const t=fi();return t.name=(n=e.name)!=null?n:"",t.tubeName=(a=e.tubeName)!=null?a:"",t.min=(i=e.min)!=null?i:0,t.max=(o=e.max)!=null?o:0,t.origin=e.origin!==void 0&&e.origin!==null?K.fromPartial(e.origin):void 0,t.chart=((r=e.chart)==null?void 0:r.map(l=>mn.fromPartial(l)))||[],t}};function di(){return{position:void 0,depth:0,value:0}}const mn={encode(e,t=se.Writer.create()){return e.position!==void 0&&K.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=di();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.position=K.decode(n,n.uint32());continue;case 2:if(o!==21)break;i.depth=n.float();continue;case 3:if(o!==29)break;i.value=n.float();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{position:Dt(e.position)?K.fromJSON(e.position):void 0,depth:Dt(e.depth)?globalThis.Number(e.depth):0,value:Dt(e.value)?globalThis.Number(e.value):0}},toJSON(e){const t={};return e.position!==void 0&&(t.position=K.toJSON(e.position)),e.depth!==0&&(t.depth=e.depth),e.value!==0&&(t.value=e.value),t},create(e){return mn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=di();return t.position=e.position!==void 0&&e.position!==null?K.fromPartial(e.position):void 0,t.depth=(n=e.depth)!=null?n:0,t.value=(a=e.value)!=null?a:0,t}};function Dt(e){return e!=null}const Rf=`#version 300 es
1313
+ }`,gf=e=>{const t=m.useRef(null),{startPercent:n,endPercent:a,backgroundColor:r,color:o,zOffset:i,zOffsetUnits:l,start:s,end:c}=e;return m.useEffect(()=>{t.current&&(t.current.setColor3("color",o),t.current.setColor3("backgroundColor",r||u.Color3.Black()),t.current.setFloat("discardFragment",r?0:1),t.current.setFloat("startPercent",n),t.current.setFloat("endPercent",a),t.current.setVector3("start",s),t.current.setVector3("end",c),i!==void 0&&l!==void 0&&(t.current.zOffset=i,t.current.zOffsetUnits=l))},[r,o,c,a,s,n,i,l]),C.jsx(lt,{ref:t,name:e.name,backFaceCulling:e.backFaceCulling,needDepthPrePass:e.needDepthPrePass,vertex:mf,fragment:hf,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:u.Material.CounterClockWiseSideOrientation})},vf=(e,t)=>{m.useEffect(()=>{e.current&&(e.current.metadata={pickable:t})},[t,e])},xf=(e,t)=>{const n=_e.useScene(),a=m.useRef(null),r=m.useRef(null),o=m.useContext(Le),{id:i,visible:l=!0,vertices:s,indices:c,colors:p,backgroundColor:f,color:d,start:x=new u.Vector3,end:h=new u.Vector3,percent:T,position:P,materialType:v="custom",children:_,alphaBlend:b=!1,alpha:k=1,name:M="roadway",actions:w,gpuPick:S=!0}=e;m.useImperativeHandle(t,()=>r.current,[]),m.useEffect(()=>{if(a&&a.current&&n){const F=new u.VertexData;F.positions=s,F.indices=c,p&&v!=="pbr-dark"&&v!=="pbr-light"&&(F.colors=p),F.applyToMesh(a.current)}},[c,s,n,p,i,v]),vf(a,w&&S?{onLeftClick:w.onLeftClick,onRightClick:w.onRightClick,onMiddleClick:w.onMiddleClick,onHover:w.onHover,needWorldPosition:w.needWorldPosition,extra:""}:void 0);const N=m.useCallback(()=>{if(v==="custom")return C.jsx(lt,{name:`${M}-material-${i}`,vertex:Gn,fragment:Zn,needDepthPrePass:!1,transparencyMode:b?u.Material.MATERIAL_ALPHABLEND:u.Material.MATERIAL_OPAQUE,options:{needAlphaBlending:!!b}});if(v==="percent")return C.jsx(gf,{name:`${M}-percentmaterial-${i}`,backgroundColor:f,color:d!=null?d:u.Color3.Black(),startPercent:T?T[0]:1,endPercent:T?T[1]:1,zOffset:-2,zOffsetUnits:-10,start:x,end:h});if(v==="standard")return C.jsx("standardMaterial",{name:`${M}-material`,alphaMode:u.Engine.ALPHA_COMBINE,transparencyMode:b?u.Material.MATERIAL_ALPHABLEND:u.Material.MATERIAL_OPAQUE,alpha:k});if(v==="pbr-light")return C.jsx(Yn,{alpha:k});if(v==="pbr-dark")return C.jsx(Jn,{alpha:k})},[k,b,f,d,h,i,v,M,T,x]);return C.jsxs("transformNode",{name:`node-${M}-${i}`,setEnabled:l,children:[C.jsxs("transformNode",{name:`${M}`,position:P?P.multiply(Oe(o)):new u.Vector3(0,0,0),scaling:Oe(o),ref:r,children:[C.jsx("mesh",{name:`roadway-${i}-mesh`,ref:a,isPickable:!0,children:N()}),C.jsx("transformNode",{name:`${M}-title`,position:e.style.position?e.style.position:new u.Vector3(0,0,0),scaling:ct(o),children:e.style.title&&C.jsx(Je,{text:e.style.title,fontSize:e.style.fontSize?e.style.fontSize:40,color:e.style.color?e.style.color:"black"})})]}),_]})},Sn=m.forwardRef(xf);function yf(e,t){if(typeof t=="string")return t===e;if(t.mode==="prefix")return e.startsWith(t.value);try{return new RegExp(t.value,t.flags).test(e)}catch(n){return!1}}const Pa=e=>{const[t,n]=m.useState({top:{vertices:[],indices:[],colors:[]},side:{vertices:[],indices:[],colors:[]},bottom:{vertices:[],indices:[],colors:[]}}),a=_e.useScene(),[r,o]=m.useState(new u.Vector3(0,0,0)),i=m.useRef(!1),[l,s]=m.useState([]),[c,p]=m.useState(""),[f,d]=m.useState([]),{id:x,url:h,visible:T=!0,offset:P=new u.Vector3(0,0,0),children:v,actions:_,rayPick:b,showRoadwayWall:k={top:!0,bottom:!0,side:!0},roadwayName:M={nameList:[],offset:new u.Vector3(0,0,0)}}=e,{top:w=!0,bottom:S=!0,side:N=!0}=k,F=nf(h);return m.useEffect(()=>{if(F&&!i.current){i.current=!0;let B=[];const I=Yi.decode(new Uint8Array(F));console.log(I),p(I.name);const{boxes:D}=I,E=[],L=[],y=[],A=[],V=[],$=[],W=[],ne=[],ee=[];let G=0,le=0,re=0;const oe=I.position?new u.Vector3(I.position.x,I.position.y,I.position.z):new u.Vector3(0,0,0);return D.forEach(Y=>{var Q,Ee,ke,te,me,ue;const{topMesh:ce,bottomMesh:ae,sideMesh:X}=Y;let Pe=0;ce&&ce.vertices&&ce.indices&&ce.colors&&(E.push(...ce.vertices),L.push(...ce.indices.map(pe=>pe+G)),y.push(...ce.colors),Pe=Math.max(...ce.indices)),G+=Pe+1;let ge=0;X&&X.vertices&&X.indices&&X.colors&&(A.push(...X.vertices),V.push(...X.indices.map(pe=>pe+le)),$.push(...X.colors),ge=Math.max(...X.indices)),le+=ge+1;let H=0;if(ae&&ae.vertices&&ae.indices&&ae.colors&&(W.push(...ae.vertices),ne.push(...ae.indices.map(pe=>pe+re)),ee.push(...ae.colors),H=Math.max(...ae.indices)),re+=H+1,Y.name){const pe=new u.Vector3((Q=Y.startPosition)==null?void 0:Q.x,(Ee=Y.startPosition)==null?void 0:Ee.y,(ke=Y.startPosition)==null?void 0:ke.z),Ne=new u.Vector3((te=Y.endPosition)==null?void 0:te.x,(me=Y.endPosition)==null?void 0:me.y,(ue=Y.endPosition)==null?void 0:ue.z),be=pe.add(Ne).scale(.5);B.push({name:Y.name,position:be})}}),n({top:{vertices:E,indices:L,colors:y},side:{vertices:A,indices:V,colors:$},bottom:{vertices:W,indices:ne,colors:ee}}),o(oe),d(B),()=>{i.current=!1,n({top:{vertices:[],indices:[],colors:[]},side:{vertices:[],indices:[],colors:[]},bottom:{vertices:[],indices:[],colors:[]}}),o(new u.Vector3(0,0,0)),d([])}}},[F]),m.useEffect(()=>{const B=a==null?void 0:a.onPointerObservable.add(function(I){if(b)switch(I.type){case u.PointerEventTypes.POINTERUP:const D=a.pick(a.pointerX,a.pointerY);if(D.hit){const E=D.pickedMesh;(E==null?void 0:E.name)===`roadway-${x}-mesh`&&_!=null&&_.onLeftClick&&_.onLeftClick(E.name,void 0,D.pickedPoint)}break}});return()=>{a==null||a.onPointerObservable.remove(B)}},[_,x,c,b,a]),m.useEffect(()=>{if(!(M!=null&&M.nameList.length)){s([]);return}s(f.filter(B=>M.nameList.some(I=>yf(B.name,I))))},[M,f]),C.jsxs(C.Fragment,{children:[t.top.vertices.length>0&&t.top.indices.length>0&&C.jsx(Sn,{id:x,name:c,visible:T&&w,vertices:t.top.vertices,indices:t.top.indices,position:r.add(P),colors:t.top.colors.length>0?t.top.colors:void 0,style:{},actions:_,materialType:"standard",gpuPick:!b,children:v}),t.side.vertices.length>0&&t.side.indices.length>0&&C.jsx(Sn,{id:x,name:c,visible:T&&N,vertices:t.side.vertices,indices:t.side.indices,position:r.add(P),colors:t.side.colors.length>0?t.side.colors:void 0,style:{},actions:_,materialType:"standard",gpuPick:!b,children:v}),t.bottom.vertices.length>0&&t.bottom.indices.length>0&&C.jsx(Sn,{id:x,name:c,visible:T&&S,vertices:t.bottom.vertices,indices:t.bottom.indices,position:r.add(P),colors:t.bottom.colors.length>0?t.bottom.colors:void 0,style:{},actions:_,gpuPick:!b,materialType:"standard",children:v}),l.map((B,I)=>C.jsxs("transformNode",{name:`roadway-name-${B.name}-${I}-root`,children:[C.jsx("transformNode",{name:`roadway-name-${B.name}-${I}`,position:B.position.add(P).add((M==null?void 0:M.offset)||new u.Vector3(0,0,0)),billboardMode:u.Mesh.BILLBOARDMODE_ALL,children:C.jsx(Je,{text:B.name,fontSize:(M==null?void 0:M.fontSize)||18,color:(M==null?void 0:M.color)||"#FFFFFF"})},I),M.offset&&M.offset.y!==0?C.jsx("lineSystem",{name:`roadway-name-${B.name}-${I}-line`,lines:[[B.position,B.position.add(M.offset)]],color:u.Color3.White()}):null]}))]})},Cf=e=>{const{id:t,node:n}=e,[a,r]=m.useState([]),[o,i]=m.useState([]),l=(c,p)=>{const f=[];let d=0;for(const[x,h]of c){let T=x;for(;d<p.length&&p[d][1]<=x;)d++;for(;d<p.length&&p[d][0]<h&&(p[d][0]>T&&f.push([T,p[d][0]]),T=Math.max(T,p[d][1]),!(p[d][1]>=h));)d++;T<h&&f.push([T,h])}return f};m.useEffect(()=>{if(n.range){const c=[],p=[];let f=[];const d=n,x=[],h=[];switch(n.type){case"run":c.push(s(n.percent[0].start,n.percent[0].end)),p.push(n.colors[0]);break;default:for(let T=0;T<n.percent.length;T++){const P=s(n.percent[T].start,n.percent[T].end);P[0]!==P[1]&&x.push(P)}for(let T=0;T<d.colorPercent.length;T++){const P=s(d.colorPercent[T].start,d.colorPercent[T].end);P[0]!==P[1]&&(h.push(P),c.push([P[0],P[1]]),p.push(n.colors[1]))}f=l(x,h),f.forEach(T=>{c.push(T),p.push(n.colors[0])})}r(c),i(p)}},[n,n.colors,n.percent,n.range,n.type]);const s=(c,p)=>c>p?[p,c]:[c,p];return C.jsx("transformNode",{name:`animation-node-${n.name}`,children:a.map((c,p)=>C.jsx("transformNode",{name:`child-${p}`,children:c[0]>=0&&c[1]>=0&&n.meshs&&n.meshs.map((f,d)=>c[0]===c[1]?null:C.jsx(Sn,{id:t,visible:!0,vertices:f.vertices,indices:f.indices,position:new u.Vector3(0,0,0),color:o[p],percent:c,start:n.start,end:n.end,style:{},materialType:"percent"},d))},p))})},_f=e=>{const{nodes:t}=e,n=m.useRef(null),a=m.useRef([]),[r,o]=m.useState(),i=l=>{const s=[];for(let p=0;p<l.length;p++)s.push(l[p].start),s.push(l[p].end);const c=s.sort((p,f)=>p-f);return c[0]===0&&c[3]===1&&c[1]===c[2]};return m.useEffect(()=>{const l=setInterval(()=>{n.current||(n.current={vertices:[],indices:[],colors:[],normals:[],uv:[]});let s=n.current.indices.length>0?Math.max(...n.current.indices)+1:0;t==null||t.map(c=>{if(c instanceof Ki){const p=c.colorPercent;a.current.findIndex(d=>d===c.name)===-1&&c.meshs&&i(p)&&(a.current.push(c.name),c.meshs.forEach(d=>{var h,T;let x=0;d.vertices&&d.indices&&((h=n.current)==null||h.vertices.push(...d.vertices),(T=n.current)==null||T.indices.push(...d.indices.map(P=>P+s)),x=Math.max(...d.indices)),s+=x+1}))}}),o({vertices:[...n.current.vertices],indices:[...n.current.indices],colors:[],normals:[],uv:[]})},3e4);return()=>{clearInterval(l)}},[t]),C.jsxs(C.Fragment,{children:[t&&t.map((l,s)=>a.current.find(p=>p===l.name)?null:C.jsx(Cf,{id:s,node:l},l.name)),t&&r&&r.vertices.length>0&&C.jsx(Sn,{id:0,name:"animation-merged-mesh",visible:!0,vertices:r.vertices,indices:r.indices,position:new u.Vector3(0,0,0),color:t[0].colors[1],percent:[0,1],start:t[0].start,end:t[0].end,style:{},materialType:"percent"})]})},Pf=e=>{const{url:t,zOffset:n,zOffsetUnits:a,uScale:r,vScale:o,isBlink:i}=e,[l,s]=m.useState(),[c,p]=m.useState(1);return m.useEffect(()=>{const f=new u.Texture(t);f.hasAlpha=!0,f.uScale=r,f.vScale=o,s(f)},[t,r,o]),m.useEffect(()=>{const f=setInterval(()=>{i&&p(d=>d===0?1:0)},1e3);return()=>{clearInterval(f)}},[i]),C.jsx("standardMaterial",{name:e.name,backFaceCulling:e.backFaceCulling,needDepthPrePass:e.needDepthPrePass,transparencyMode:e.transparencyMode,alphaMode:e.alphaMode,alpha:c,diffuseTexture:l,emissiveTexture:l,useAlphaFromDiffuseTexture:!0,disableLighting:!0,zOffset:n,zOffsetUnits:a,sideOrientation:u.Material.CounterClockWiseSideOrientation})},Sf=e=>{const{node:t,roadwayWidth:n,textureLength:a,url:r,visible:o=!0,isBlink:i=!0}=e,[l,s]=m.useState(),c=m.useRef(null),[p,f]=m.useState(),[d,x]=m.useState(!1),[h,T]=m.useState(1),P=(v,_,b,k)=>{const w=u.Vector3.Distance(v,_)/k,S=u.Vector3.Distance(v,b),N=Math.floor(S/w);return Math.min(N,k-1)};return m.useEffect(()=>{if(t.start&&t.end&&t.current){const v=u.Vector3.Distance(t.start,t.end),_=Math.floor(v/a),b=P(t.start,t.end,t.current,_);if(t.end.equals(t.current)){s(0);return}s(_-b),T((_-b)/_)}},[t,t.end,t.start,a]),m.useEffect(()=>{if(t.end===t.current){f(void 0);return}if(t.start&&t.end&&t.current){const v=u.Vector3.Lerp(t.start,t.end,.5+(1-h)/2);f(v)}},[t,h]),m.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,x(!0))},[t.end]),C.jsx(C.Fragment,{children:p&&l&&t.start&&t.end&&C.jsx("plane",{name:`${t.name}-mesh`,width:u.Vector3.Distance(t.start,t.end),height:n,ref:c,position:p,setEnabled:d&&o,scaling:new u.Vector3(h,1,1),children:C.jsx(Pf,{name:t.name,alphaMode:u.Engine.ALPHA_COMBINE,transparencyMode:u.Material.MATERIAL_ALPHABLEND,url:r,uScale:l,vScale:1,zOffset:-10,zOffsetUnits:-10,isBlink:i})})})},Tf=e=>{const{nodes:t,roadwayWidth:n=2,textureLength:a=4,url:r,visible:o=!0,isBlink:i=!0}=e;return C.jsx(C.Fragment,{children:t&&t.map((l,s)=>{const c=l;return C.jsx(Sf,{node:c,roadwayWidth:n,textureLength:a,url:r,visible:o,isBlink:i},s)})})};class bf{constructor(t,n,a){ve(this,"sourceVertex");ve(this,"targetVertex");ve(this,"meshCurrent");ve(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 kf=({position:e=u.Vector3.Zero(),id:t,node:n,timeSpeed:a=-6,perlinMultiply:r=.5,waterFlow:o=1,clippedHeight:i=0,alpha:l=1,colorSteps:s=[new u.GradientBlockColorStep(0,new u.Color3(25,92,255)),new u.GradientBlockColorStep(1,new u.Color3(127,223,252))],subdivideX:c=15,subdivideY:p=150})=>{const f=_e.useScene(),d=m.useContext(Le),x=m.useRef(null),h=m.useRef(null),[T,P]=m.useState(u.Vector3.Zero()),v=m.useRef(null),_=m.useRef(null),b=m.useRef(null);return m.useEffect(()=>{const k=x.current;if(f&&k){v.current=bu({name:`waterMat-${t}-${n.name}`,scene:f}),v.current.getBlockByName("TimeSpeed").value=a,v.current.getBlockByName("PerlinMultiply").value=r,v.current.getBlockByName("waterFlow").value=o,v.current.getBlockByName("ClippedHeight").value=i,v.current.alpha=l,v.current.getBlockByName("Gradient").colorSteps=s;const M=v.current;M.getBlockByName("MaskEnabled").value=0,M.build(!1,!0,!0);const w=n.start,S=n.end,N=u.Vector3.Normalize(S.subtract(w)),F=Math.asin(N.y),B=Math.atan2(N.x,N.z),I=new u.Vector3(-F,B,0);return P(I),k.morphTargetManager=new u.MorphTargetManager,k.morphTargetManager.enableNormalMorphing=!0,b.current=k.getVerticesData(u.VertexBuffer.PositionKind).slice(0),b.current.length===0&&console.log("[Geo3DViewer] 水模拟,原始 SourceKind 为空",t,n.name),k.material=v.current,()=>{var D;(D=v.current)==null||D.dispose()}}},[t,n.end,n.name,n.start,f]),m.useEffect(()=>{const k=x.current,M=x.current;if(k&&M){console.log(`[Geo3DViewer] 正在更新 ${t} / ${n.name} 的进度 Time: ${n.time/1e3}`);const w=M.getVerticesData(u.VertexBuffer.PositionKind).slice(0);w.length===0&&console.log("[Geo3DViewer] 水模拟 SourceKind 为空",t,n.name),M.updateMeshPositions(B=>{for(let I=0;I<B.length;I++)B[I]=b.current[I]});const S=M.applyDisplacementMapFromBuffer(n.glurHeightMap,1,n.waterLength,0,n.height,u.Vector2.Zero(),u.Vector2.One(),!1).getVerticesData(u.VertexBuffer.PositionKind).slice(0);S.length===0&&console.log("[Geo3DViewer] 水模拟 SourceKind 为空",t,n.name),k.updateMeshPositions(B=>{for(let I=0;I<B.length;I++)B[I]=S[I]});const N=new bf(w,S,k),F=new u.Animation("waterAnimation","influence",1e3/30,u.Animation.ANIMATIONTYPE_FLOAT,u.Animation.ANIMATIONLOOPMODE_CONSTANT);F.setKeys([{frame:0,value:0},{frame:10,value:1}]),f==null||f.beginDirectAnimation(N,[F],0,10,!1,10)}},[t,n.glurHeightMap,n.height,n.name,n.waterLength,n.time]),m.useEffect(()=>{const k=v.current;k&&(k.getBlockByName("TimeSpeed").value=a)},[a]),m.useEffect(()=>{const k=v.current;k&&(k.getBlockByName("PerlinMultiply").value=r)},[r]),m.useEffect(()=>{const k=v.current;k&&(k.getBlockByName("waterFlow").value=o)},[o]),m.useEffect(()=>{const k=v.current;k&&(k.getBlockByName("ClippedHeight").value=i)},[i]),m.useEffect(()=>{const k=v.current;k&&(k.alpha=l)},[l]),m.useEffect(()=>{const k=v.current;k&&(k.getBlockByName("Gradient").colorSteps=s,k.build(!1,!0,!0))},[s]),C.jsx("transformNode",{name:`water-simulation-${t}-${n.name}`,children:C.jsxs("transformNode",{name:`${name}`,position:e?e.multiply(Oe(d)):new u.Vector3(0,0,0),scaling:Oe(d),ref:h,children:[C.jsx("ground",{ref:x,name:`water-simulation-${t}-1`,position:n.center,rotation:T,subdivisionsX:c,subdivisionsY:p,updatable:!0,width:n.width,height:n.waterLength}),C.jsx("ground",{ref:_,name:`stub-water-simulation-${t}-1`,position:n.center,rotation:T,subdivisionsX:c,subdivisionsY:p,updatable:!0,width:n.width,height:n.waterLength,setEnabled:!1})]})})},Ef=e=>{const{nodes:t}=e;return C.jsx(C.Fragment,{children:t&&t.map((n,a)=>C.jsx(kf,{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))})},Sa=e=>{const{rootUrl:t,size:n=1e3,name:a="skybox"}=e;return C.jsx(_e.Skybox,{rootUrl:t,size:n,name:a})};function li(){return{name:"",origin:void 0,dataPoints:[]}}const Ta={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.origin!==void 0&&K.encode(e.origin,t.uint32(18).fork()).ldelim();for(const n of e.dataPoints)pn.encode(n,t.uint32(26).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=li();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=K.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.dataPoints.push(pn.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:Cn(e.name)?globalThis.String(e.name):"",origin:Cn(e.origin)?K.fromJSON(e.origin):void 0,dataPoints:globalThis.Array.isArray(e==null?void 0:e.dataPoints)?e.dataPoints.map(t=>pn.fromJSON(t)):[]}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),e.origin!==void 0&&(t.origin=K.toJSON(e.origin)),(n=e.dataPoints)!=null&&n.length&&(t.dataPoints=e.dataPoints.map(a=>pn.toJSON(a))),t},create(e){return Ta.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=li();return t.name=(n=e.name)!=null?n:"",t.origin=e.origin!==void 0&&e.origin!==null?K.fromPartial(e.origin):void 0,t.dataPoints=((a=e.dataPoints)==null?void 0:a.map(r=>pn.fromPartial(r)))||[],t}};function ci(){return{point:void 0,colorId:0,vColor:0,vRadius:0}}const pn={encode(e,t=se.Writer.create()){return e.point!==void 0&&K.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=ci();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.point=K.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:Cn(e.point)?K.fromJSON(e.point):void 0,colorId:Cn(e.colorId)?globalThis.Number(e.colorId):0,vColor:Cn(e.vColor)?globalThis.Number(e.vColor):0,vRadius:Cn(e.vRadius)?globalThis.Number(e.vRadius):0}},toJSON(e){const t={};return e.point!==void 0&&(t.point=K.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 pn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=ci();return t.point=e.point!==void 0&&e.point!==null?K.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 Cn(e){return e!=null}var ba=(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))(ba||{});const ka=({url:e,colorCodec:t,alpha:n=1,visible:a=!0,offset:r=u.Vector3.Zero(),scale:o=1,objectType:i=2})=>{const l=_e.useScene(),s=m.useRef(null),c=m.useContext(Le),p=m.useContext(Lt),f=m.useRef(null),[d,x]=m.useState(""),[h,T]=m.useState(u.Vector3.Zero()),P=je({url:e,cacheType:Me.URL_PREFIX_MATCH}),[v,_]=m.useState(null);return m.useEffect(()=>{console.log("[Geo3DViewer] SpaceHeat Loading: ",e)},[e]),m.useEffect(()=>{if(l&&s.current&&P){const b=s.current;u.Tags.EnableFor(b),u.Tags.AddTagsTo(b,"loading");const k=Ta.decode(new Uint8Array(P)),{name:M,origin:w,dataPoints:S}=k;if(w&&S){x(M),T(new u.Vector3(w.x,w.y,w.z));const N=new Float32Array(S.length*16),F=new Float32Array(S.length*4);return S.forEach((B,I)=>{if(B.point){const D=new u.Vector3(B.point.x,B.point.y,B.point.z).multiplyByFloats(c&&c.scalePlane?c.scalePlane:1,c&&c.scaleDepth?c.scaleDepth:1,c&&c.scalePlane?c.scalePlane:1),E=u.Quaternion.Identity(),L=new u.Vector3(B.vRadius*o,B.vRadius*o,B.vRadius*o);if(u.Matrix.Compose(L,E,D).copyToArray(N,I*16),t){const A=p.colorCodecs[t].array,V=A[Math.floor(B.vColor*(A.length-1))];F.set([V.r,V.g,V.b,n],I*4)}else{const A=p.colorIDs[B.colorId];F.set([A.r,A.g,A.b,n],I*4)}}}),b&&(b.thinInstanceSetBuffer("matrix",N),b.thinInstanceSetBuffer("color",F,4)),u.Tags.RemoveTagsFrom(b,"loading"),v==null||v.addMesh(b,u.Color3.White()),()=>{b&&(b.thinInstanceSetBuffer("matrix",new Float32Array),b.thinInstanceSetBuffer("color",new Float32Array))}}}},[n,t,p.colorCodecs,p.colorIDs,c==null?void 0:c.scalePlane,o,l,P,v,c==null?void 0:c.scaleDepth,c==null?void 0:c.scalePlane]),m.useEffect(()=>(f.current&&l&&n&&f.current.setFloat("alpha",n),l&&i===5&&_(new u.HighlightLayer(`highlight-layer-spaceheat-${d}`,l)),()=>{v&&v.dispose()}),[l,n,i]),C.jsx("transformNode",{setEnabled:a,name:`transform-spaceheat-${d}`,position:h.add(r).multiplyByFloats(c&&c.scalePlane?c.scalePlane:1,c&&c.scaleDepth?c.scaleDepth:1,c&&c.scalePlane?c.scalePlane:1),children:i===5?C.jsx("disc",{ref:s,name:`spaceheat-${d}`,radius:1,tessellation:32,sideOrientation:u.Mesh.DOUBLESIDE,billboardMode:u.Mesh.BILLBOARDMODE_ALL,children:t?C.jsx("standardMaterial",{name:`spaceheat-${d}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new u.Color3(0,0,0),ambientColor:new u.Color3(1,1,1),emissiveColor:u.Color3.White(),alphaMode:u.Engine.ALPHA_COMBINE,alpha:n,zOffset:-3}):C.jsx("standardMaterial",{name:`spaceheat-${d}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new u.Color3(0,0,0),ambientColor:new u.Color3(1,1,1),emissiveColor:u.Color3.White(),alphaMode:u.Engine.ALPHA_COMBINE,alpha:n,zOffset:-3})}):C.jsx("polyhedron",{ref:s,name:`spaceheat-${d}`,type:i,children:t?C.jsx("standardMaterial",{name:`spaceheat-${d}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new u.Color3(0,0,0),ambientColor:new u.Color3(1,1,1),emissiveColor:u.Color3.Black(),alphaMode:u.Engine.ALPHA_COMBINE,alpha:n,zOffset:-3}):C.jsx("standardMaterial",{name:`spaceheat-${d}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new u.Color3(0,0,0),ambientColor:new u.Color3(1,1,1),emissiveColor:u.Color3.Black(),alphaMode:u.Engine.ALPHA_COMBINE,alpha:n,zOffset:-3})})})};var Ea=(e=>(e[e.OSM=1]="OSM",e[e.AMAP=2]="AMAP",e))(Ea||{});const Na=({mode:e=1,baseUrl:t,visible:n=!0,xmin:a=-10,xmax:r=10,zmin:o=-10,zmax:i=10,zoom:l=12,xTileBase:s=2120,yTileBase:c=1498,precision:p={w:2,h:2},subdivisions:f={w:8,h:8},offset:d=u.Vector3.Zero(),scale:x=1})=>{const h=_e.useScene(),T=m.useRef(null),P=m.useRef(null),[v,_]=m.useState([]),[b,k]=m.useState([]);return m.useEffect(()=>{const M=T.current,w=P.current;if(M&&w){const S=M.getTotalVertices(),N=M.getIndices().length/(f.w*f.h),F=[];let B=0,I=0;for(let E=0;E<f.h;E++)for(let L=0;L<f.w;L++){const y=new u.SubMesh(B++,0,S,I,N,M);F.push(y),I+=N}const D=[];return[...Array(f.h).keys()].flatMap(E=>[...Array(f.w).keys()].map(L=>{const y=new u.StandardMaterial(`tileMap-material-${E}-${L}`),A=[`${t}/${l}/${s+L}/${c-E}.png`,`${t}/appmaptile?z=${l}&x=${s+L}&y=${c-E}&style=6`];return y.diffuseTexture=new u.Texture(A[A!=null&&A[e-1]?e-1:0],h),y.diffuseTexture.wrapU=u.Texture.CLAMP_ADDRESSMODE,y.diffuseTexture.wrapV=u.Texture.CLAMP_ADDRESSMODE,y.specularColor=u.Color3.Black(),y.backFaceCulling=!1,y})).forEach(E=>{D.push(E)}),k(F),_(D),M.subMeshes=F,w.subMaterials=D,()=>{w.subMaterials=[],M.subMeshes=[],_([]),k([])}}},[t,e,h,f.h,f.w,s,c,l]),C.jsx("transformNode",{name:"tileMap",setEnabled:n,position:d,scalingDeterminant:x,children:C.jsx("tiledGround",{name:"tileMap-ground",xmin:a,xmax:r,zmin:o,zmax:i,subdivisions:f,precision:p,subMeshes:b,ref:T,children:C.jsx("multiMaterial",{name:"submaterial-tile-map",subMaterials:v,ref:P})})})};function ui(){return{name:"",origin:void 0,type:"",sliceList:[],vertices:[],normals:[],indices:[],colors:[],uv:[],meshs:[]}}const Nt={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.origin!==void 0&&K.encode(e.origin,t.uint32(18).fork()).ldelim(),e.type!==""&&t.uint32(26).string(e.type);for(const n of e.sliceList)hn.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)We.encode(n,t.uint32(130).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=ui();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=K.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(hn.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(We.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:vt(e.name)?globalThis.String(e.name):"",origin:vt(e.origin)?K.fromJSON(e.origin):void 0,type:vt(e.type)?globalThis.String(e.type):"",sliceList:globalThis.Array.isArray(e==null?void 0:e.sliceList)?e.sliceList.map(t=>hn.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=>We.fromJSON(t)):[]}},toJSON(e){var n,a,r,o,i,l,s;const t={};return e.name!==""&&(t.name=e.name),e.origin!==void 0&&(t.origin=K.toJSON(e.origin)),e.type!==""&&(t.type=e.type),(n=e.sliceList)!=null&&n.length&&(t.sliceList=e.sliceList.map(c=>hn.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),(l=e.uv)!=null&&l.length&&(t.uv=e.uv),(s=e.meshs)!=null&&s.length&&(t.meshs=e.meshs.map(c=>We.toJSON(c))),t},create(e){return Nt.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,l,s,c,p;const t=ui();return t.name=(n=e.name)!=null?n:"",t.origin=e.origin!==void 0&&e.origin!==null?K.fromPartial(e.origin):void 0,t.type=(a=e.type)!=null?a:"",t.sliceList=((r=e.sliceList)==null?void 0:r.map(f=>hn.fromPartial(f)))||[],t.vertices=((o=e.vertices)==null?void 0:o.map(f=>f))||[],t.normals=((i=e.normals)==null?void 0:i.map(f=>f))||[],t.indices=((l=e.indices)==null?void 0:l.map(f=>f))||[],t.colors=((s=e.colors)==null?void 0:s.map(f=>f))||[],t.uv=((c=e.uv)==null?void 0:c.map(f=>f))||[],t.meshs=((p=e.meshs)==null?void 0:p.map(f=>We.fromPartial(f)))||[],t}};function fi(){return{position:void 0,start:void 0,end:void 0,color:void 0,angle:0,radius:0,innerRadius:0,texture:"",v:[]}}const hn={encode(e,t=se.Writer.create()){e.position!==void 0&&K.encode(e.position,t.uint32(10).fork()).ldelim(),e.start!==void 0&&K.encode(e.start,t.uint32(18).fork()).ldelim(),e.end!==void 0&&K.encode(e.end,t.uint32(26).fork()).ldelim(),e.color!==void 0&&ot.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=fi();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.position=K.decode(n,n.uint32());continue;case 2:if(o!==18)break;r.start=K.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.end=K.decode(n,n.uint32());continue;case 4:if(o!==34)break;r.color=ot.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:vt(e.position)?K.fromJSON(e.position):void 0,start:vt(e.start)?K.fromJSON(e.start):void 0,end:vt(e.end)?K.fromJSON(e.end):void 0,color:vt(e.color)?ot.fromJSON(e.color):void 0,angle:vt(e.angle)?globalThis.Number(e.angle):0,radius:vt(e.radius)?globalThis.Number(e.radius):0,innerRadius:vt(e.innerRadius)?globalThis.Number(e.innerRadius):0,texture:vt(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=K.toJSON(e.position)),e.start!==void 0&&(t.start=K.toJSON(e.start)),e.end!==void 0&&(t.end=K.toJSON(e.end)),e.color!==void 0&&(t.color=ot.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 hn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=fi();return t.position=e.position!==void 0&&e.position!==null?K.fromPartial(e.position):void 0,t.start=e.start!==void 0&&e.start!==null?K.fromPartial(e.start):void 0,t.end=e.end!==void 0&&e.end!==null?K.fromPartial(e.end):void 0,t.color=e.color!==void 0&&e.color!==null?ot.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(l=>l))||[],t}};function vt(e){return e!=null}const Nf=(e,t)=>{const n=m.useRef(null),a=m.useContext(Le),{id:r,name:o,visible:i=!0,position:l,children:s,isRegular:c=!0}=e;return m.useImperativeHandle(t,()=>n.current,[]),C.jsx("transformNode",{name:`node-${o}-${r}`,setEnabled:i,position:l?l.multiply(Oe(a)):new u.Vector3(0,0,0),scaling:c?Oe(a):u.Vector3.One(),ref:n,children:s})},If=m.forwardRef(Nf),wf=e=>{const t=_e.useScene(),n=m.useRef(null),{title:a,url:r,color:o,v:i,actions:l,path:s,radius:c,mesh:p}=e;return m.useEffect(()=>{n.current&&(n.current.metadata={pickable:l?{name:a,onLeftClick:l.onLeftClick,onRightClick:l.onRightClick,onMiddleClick:l.onMiddleClick,onHover:l.onHover,needWorldPosition:l.needWorldPosition,extra:i}:null})},[l,a,i]),m.useEffect(()=>{if(n.current){const f=new u.VertexData;f.positions=p.vertices,f.indices=p.indices,f.normals=p.normals,f.uvs=p.uv,f.applyToMesh(n.current)}},[p.indices,p.normals,p.uv,p.vertices,s,c,t]),C.jsx("mesh",{name:"mesh",ref:n,children:C.jsx("standardMaterial",{name:"material",diffuseColor:r===""?new u.Color3(o.r,o.g,o.b):void 0,diffuseTexture:r!==""?new u.Texture(r):void 0})})},Of=(e,t)=>{const{name:n,position:a,slices:r,meshs:o,actions:i}=e,l=m.useRef(null);return m.useImperativeHandle(t,()=>l.current,[]),C.jsx("transformNode",{name:"lod0",ref:l,setEnabled:!1,children:a&&r.map((s,c)=>{var p,f,d,x,h,T;return C.jsx(wf,{id:c,v:s.v,position:a.add(new u.Vector3(0,0,0)),path:[new u.Vector3((p=s.start)==null?void 0:p.x,(f=s.start)==null?void 0:f.y,(d=s.start)==null?void 0:d.z),new u.Vector3((x=s.end)==null?void 0:x.x,(h=s.end)==null?void 0:h.y,(T=s.end)==null?void 0:T.z)],radius:s.radius,actions:i,mesh:o[c],title:n,color:s.color?new u.Color4(s.color.r,s.color.g,s.color.b,s.color.a):new u.Color4(0,0,0,1),url:s.texture},c)})})},Af=m.forwardRef(Of),Mf=e=>{const t=_e.useScene(),n=m.useRef(null),a=m.useContext(Le),{id:r,vertices:o,indices:i,colors:l,color:s,materialType:c="custom",alphaBlend:p=!1,alpha:f=1,slices:d,position:x,name:h="tube",actions:T}=e;m.useEffect(()=>{n.current&&(n.current.metadata={pickable:T?{name:"",needWorldPosition:!0,onLeftClick:T.onLeftClick,onRightClick:T.onRightClick,onMiddleClick:T.onMiddleClick,onHover:(v,_,b,k,M)=>{var w,S,N,F,B,I;if(T.onHover&&t&&d&&b){const D=b;for(let E=0;E<d.length;E++){const L=new u.Vector3((w=d[E].start)==null?void 0:w.x,(S=d[E].start)==null?void 0:S.y,(N=d[E].start)==null?void 0:N.z).add(x).multiply(Oe(a)),y=new u.Vector3((F=d[E].end)==null?void 0:F.x,(B=d[E].end)==null?void 0:B.y,(I=d[E].end)==null?void 0:I.z).add(x).multiply(Oe(a)),A=u.MeshBuilder.CreateTube("boundingbox-tmp",{path:[L,y],radiusFunction:()=>{const $=d[E].radius;return $||1},cap:u.Mesh.NO_CAP,tessellation:8,sideOrientation:u.Mesh.DOUBLESIDE},t),V=A.getBoundingInfo().intersectsPoint(D);if(A.dispose(),V){T.onHover(v,new u.Vector2(t==null?void 0:t.pointerX,t==null?void 0:t.pointerY),b,k,M,d[E].v);break}}}}}:null})},[T,a,x,t,d]),m.useEffect(()=>{if(n&&n.current&&t){const v=new u.VertexData;v.positions=o,v.indices=i,l&&c!=="pbr-dark"&&c!=="standard"&&c!=="pbr-light"&&(v.colors=l),v.applyToMesh(n.current)}},[i,o,t,l,r,c]);const P=m.useCallback(()=>{if(c==="custom")return C.jsx(lt,{name:`${h}-material-${r}`,vertex:Gn,fragment:Zn,needDepthPrePass:!1,transparencyMode:p?u.Material.MATERIAL_ALPHABLEND:u.Material.MATERIAL_OPAQUE,options:{needAlphaBlending:!!p}});if(c==="standard")return C.jsx("standardMaterial",{name:`${h}-material`,alphaMode:u.Engine.ALPHA_COMBINE,transparencyMode:p?u.Material.MATERIAL_ALPHABLEND:u.Material.MATERIAL_OPAQUE,alpha:f,diffuseColor:s||void 0});if(c==="pbr-light")return C.jsx(Yn,{alpha:f});if(c==="pbr-dark")return C.jsx(Jn,{alpha:f})},[f,p,s,r,c,h]);return C.jsx("transformNode",{name:`${h}-main-node`,children:C.jsx("mesh",{name:`${h}-mesh`,ref:n,isPickable:!0,children:P()})})},Lf=(e,t)=>{const{id:n,visible:a=!0,materialType:r="custom",vertices:o,indices:i,colors:l,color:s,slices:c,position:p,actions:f}=e,d=m.useRef(null);return m.useImperativeHandle(t,()=>d.current,[]),C.jsx("transformNode",{name:"lod1",ref:d,setEnabled:!1,children:o.length>0&&C.jsx(Mf,{id:n,visible:a,vertices:o,indices:i,colors:l.length>0?l:void 0,materialType:r,alpha:1,color:s,alphaBlend:!1,position:p,actions:f,slices:c})})},Rf=m.forwardRef(Lf),Bf=(e,t)=>{const n=m.useRef(null),a=m.useContext(Le),{style:r,name:o="tube"}=e;return m.useImperativeHandle(t,()=>n.current,[]),C.jsx("transformNode",{name:`${o}-title`,position:r.position?r.position.add(r.offset?r.offset:new u.Vector3(0,0,0)):new u.Vector3(0,0,0).add(r.offset?r.offset:new u.Vector3(0,0,0)),scaling:ct(a),ref:n,setEnabled:!1,children:r.title&&C.jsx(Je,{text:r.title,fontSize:r.fontSize?r.fontSize:40,color:r.color?r.color:"black"})})},Ia=m.forwardRef(Bf),wa=e=>{var ae,X,Pe,ge;const t=_e.useScene(),[n,a]=m.useState([]),[r,o]=m.useState([]),[i,l]=m.useState([]),s=m.useRef(null),c=m.useRef(null),p=m.useRef(null),[f,d]=m.useState(""),[x,h]=m.useState(new u.Vector3(0,0,0)),T=m.useRef(null),P=m.useRef(null),v=m.useRef(null),[_,b]=m.useState([]),k=m.useRef(!1),M=m.useContext(Le),[w,S]=m.useState([]),[N,F]=m.useState(!1),[B,I]=m.useState(!1),{id:D,url:E,color:L,visible:y=!0,materialType:A="custom",children:V,style:$,actions:W,noLod:ne=!1,lodDistance:ee=[200,1e3],loadDistance:G=0,offset:le=new u.Vector3(0,0,0),position:re,topPosition:oe,bottomPosition:Y,isRegular:ce=!0}=e;return m.useEffect(()=>{re&&oe&&Y?(s.current=re,c.current=oe,p.current=Y):I(!0)},[Y,re,oe]),m.useEffect(()=>{!k.current&&B&&(k.current=!0,Ut.get(E,{responseType:"arraybuffer"}).then(H=>{var me,ue,pe,Ne,be,Ae,Ie,we,Re;const Q=Nt.decode(new Uint8Array(H.data));console.log(Q);const Ee=Q.sliceList[0],ke=Q.sliceList[Q.sliceList.length-1];d(Q.name);const te=e.style.basePosition&&e.style.basePosition==="top"?Ee.start:ke.end;h(new u.Vector3(te==null?void 0:te.x,te==null?void 0:te.y,te==null?void 0:te.z)),s.current=new u.Vector3((me=Q.origin)==null?void 0:me.x,(ue=Q.origin)==null?void 0:ue.y,(pe=Q.origin)==null?void 0:pe.z).add(le),b(Q.sliceList.filter(Ve=>Ve.v)),c.current=new u.Vector3((Ne=Ee.start)==null?void 0:Ne.x,(be=Ee.start)==null?void 0:be.y,(Ae=Ee.start)==null?void 0:Ae.z).add(s.current),p.current=new u.Vector3((Ie=ke.end)==null?void 0:Ie.x,(we=ke.end)==null?void 0:we.y,(Re=ke.end)==null?void 0:Re.z).add(s.current),S(Q.meshs),a(Q.vertices),o(A==="custom"?Ot.correctTubeMainIndices(Q.indices):Q.indices),l(Q.colors)}))},[E,t,L,A,e.style.basePosition,le,B,M]),m.useEffect(()=>{const H=setInterval(()=>{var Q,Ee,ke,te,me,ue,pe,Ne,be,Ae,Ie,we,Re,Ve;if(t&&t.cameras.length>0&&t.activeCamera&&s.current&&c.current&&p.current){const Ue=Ot.calcLodDistance(c.current.multiply(Oe(M)),s.current.multiply(Oe(M)),p.current.multiply(Oe(M)),t.activeCamera.position);Ue>=G&&I(!0),ne?(w.length===0?((Q=T.current)==null||Q.setEnabled(!0),(Ee=P.current)==null||Ee.setEnabled(!1)):((ke=T.current)==null||ke.setEnabled(!1),(te=P.current)==null||te.setEnabled(!0)),(me=v.current)==null||me.setEnabled(!0)):Ue<ee[0]?(F(!0),(ue=T.current)==null||ue.setEnabled(!0),(pe=P.current)==null||pe.setEnabled(w.length===0),(Ne=v.current)==null||Ne.setEnabled(!0)):ee[1]&&Ue<ee[1]?((be=T.current)==null||be.setEnabled(!1),(Ae=P.current)==null||Ae.setEnabled(!0),(Ie=v.current)==null||Ie.setEnabled(!0)):((we=T.current)==null||we.setEnabled(!1),(Re=P.current)==null||Re.setEnabled(!1),(Ve=v.current)==null||Ve.setEnabled(!1))}},1e3);return()=>{clearInterval(H)}},[G,ee,w.length,M,t]),C.jsx(C.Fragment,{children:C.jsxs("transformNode",{name:`tube-${D} `,children:[C.jsxs(If,{id:D,name:f,visible:y,position:(ae=s.current)!=null?ae:new u.Vector3(0,0,0),isRegular:ce,children:[B&&C.jsx(Ia,{id:D,style:{title:f,position:x,offset:(X=$.offset)==null?void 0:X.multiply(wi(M)),fontSize:$.fontSize,color:$.color},ref:v}),N&&B&&ee[0]&&w.length>0&&C.jsx(Af,{id:D,name:f,meshs:w,position:(Pe=s.current)!=null?Pe:new u.Vector3(0,0,0),materialType:A,slices:_,actions:W,ref:T}),B&&C.jsx(Rf,{id:D,name:f,position:(ge=s.current)!=null?ge:new u.Vector3(0,0,0),vertices:n,indices:r,colors:i,color:L?new u.Color3(L.r,L.g,L.b):void 0,slices:_,actions:W,materialType:A,ref:P})]}),V]})})};function di(){return{group:[]}}const Oa={encode(e,t=se.Writer.create()){for(const n of e.group)Nt.encode(n,t.uint32(10).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=di();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.group.push(Nt.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=>Nt.fromJSON(t)):[]}},toJSON(e){var n;const t={};return(n=e.group)!=null&&n.length&&(t.group=e.group.map(a=>Nt.toJSON(a))),t},create(e){return Oa.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=di();return t.group=((n=e.group)==null?void 0:n.map(a=>Nt.fromPartial(a)))||[],t}},Aa=e=>{const t=_e.useScene(),[n,a]=m.useState([]),r=m.useRef(!1),o=m.useContext(Le),{visible:i=!0,groupUrl:l,modelUrl:s,group:c,actions:p}=e,f=m.useCallback((d,x)=>x?new u.Color4(x==null?void 0:x.r,x==null?void 0:x.g,x==null?void 0:x.b,x==null?void 0:x.a):d||new u.Color4(1,1,1,1),[]);return m.useEffect(()=>{if(!r.current&&(r.current=!0,l&&Ut.get(l,{responseType:"arraybuffer"}).then(d=>{const x=Oa.decode(new Uint8Array(d.data)),h=[];for(let T=0;T<x.group.length;T++)h.push(x.group[T]);a(h)}),c&&c.length>0)){const d=[];for(let x=0;x<c.length;x++)d.push(Ut.get(c[x].url,{responseType:"arraybuffer"}));Promise.all(d).then(x=>{const h=[];for(let T=0;T<x.length;T++){const P=Nt.decode(new Uint8Array(x[T].data));h.push(P)}a(h)})}}),m.useEffect(()=>{var x,h,T,P,v,_,b,k,M;let d;if(n.length>0){const w=[],S=[];for(let N=0;N<n.length;N++){const F=n[N],B=new u.Vector3((x=F.origin)==null?void 0:x.x,(h=F.origin)==null?void 0:h.y,(T=F.origin)==null?void 0:T.z),I=F.sliceList;if(I){const D=[],E=[];for(let L=0;L<I.length;L++)D.push(B.add(new u.Vector3((P=I[L].start)==null?void 0:P.x,(v=I[L].start)==null?void 0:v.y,(_=I[L].start)==null?void 0:_.z)).multiply(Oe(o))),E.push(f(void 0,I[L].color)),L===I.length-1&&(D.push(B.add(new u.Vector3((b=I[L].end)==null?void 0:b.x,(k=I[L].end)==null?void 0:k.y,(M=I[L].end)==null?void 0:M.z)).multiply(Oe(o))),E.push(f(void 0,I[L].color)));w.push(D),S.push(E)}}d=u.MeshBuilder.CreateLineSystem("linesystem",{lines:w,colors:S},t),d.setEnabled(i)}return()=>{d&&d.dispose()}},[f,o,t,n,i]),C.jsx(C.Fragment,{children:s&&n&&n.length>0?n.map(d=>{var x,h,T,P,v,_;return C.jsx(Kn,{position:new u.Vector3((x=d.origin)==null?void 0:x.x,(h=d.origin)==null?void 0:h.y,(T=d.origin)==null?void 0:T.z).add(new u.Vector3((P=d.sliceList[0].start)==null?void 0:P.x,(v=d.sliceList[0].start)==null?void 0:v.y,(_=d.sliceList[0].start)==null?void 0:_.z)).multiply(Oe(o)),name:"model-tube-instance",url:s,visible:i,actions:p},d.name)}):C.jsx(C.Fragment,{})})},Eo=e=>{const t=m.useContext(Le),{position:n=u.Vector3.Zero(),localScale:a=1,scaleMode:r=It.NONE}=e,[o,i]=m.useState(1),{modelRoation:l=new u.Vector3(0,0,0)}=e,s=m.useRef(null);return m.useEffect(()=>{switch(r){case It.PLANE:i((t&&t.scalePlane?t.scalePlane:1)*a);break;case It.DEPTH:i((t&&t.scaleDepth?t.scaleDepth:1)*a);break;case It.NONE:i(a);break}},[a,t,r]),m.useEffect(()=>{let c;return s.current&&(c=setInterval(()=>{var p;if(((p=s.current)==null?void 0:p.getChildren().length)===2){const f=s.current.getChildren()[1];f.rotation=l,c&&clearInterval(c)}},500)),()=>{c&&clearInterval(c)}},[l]),C.jsx(Kn,{...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:s})};function pi(){return{name:"",tubeName:"",min:0,max:0,origin:void 0,chart:[]}}const Ko={encode(e,t=se.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&&K.encode(e.origin,t.uint32(42).fork()).ldelim();for(const n of e.chart)mn.encode(n,t.uint32(50).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=pi();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=K.decode(n,n.uint32());continue;case 6:if(o!==50)break;r.chart.push(mn.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:Dt(e.name)?globalThis.String(e.name):"",tubeName:Dt(e.tubeName)?globalThis.String(e.tubeName):"",min:Dt(e.min)?globalThis.Number(e.min):0,max:Dt(e.max)?globalThis.Number(e.max):0,origin:Dt(e.origin)?K.fromJSON(e.origin):void 0,chart:globalThis.Array.isArray(e==null?void 0:e.chart)?e.chart.map(t=>mn.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=K.toJSON(e.origin)),(n=e.chart)!=null&&n.length&&(t.chart=e.chart.map(a=>mn.toJSON(a))),t},create(e){return Ko.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=pi();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?K.fromPartial(e.origin):void 0,t.chart=((i=e.chart)==null?void 0:i.map(l=>mn.fromPartial(l)))||[],t}};function hi(){return{position:void 0,depth:0,value:0}}const mn={encode(e,t=se.Writer.create()){return e.position!==void 0&&K.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=hi();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.position=K.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:Dt(e.position)?K.fromJSON(e.position):void 0,depth:Dt(e.depth)?globalThis.Number(e.depth):0,value:Dt(e.value)?globalThis.Number(e.value):0}},toJSON(e){const t={};return e.position!==void 0&&(t.position=K.toJSON(e.position)),e.depth!==0&&(t.depth=e.depth),e.value!==0&&(t.value=e.value),t},create(e){return mn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=hi();return t.position=e.position!==void 0&&e.position!==null?K.fromPartial(e.position):void 0,t.depth=(n=e.depth)!=null?n:0,t.value=(a=e.value)!=null?a:0,t}};function Dt(e){return e!=null}const Ff=`#version 300 es
1314
1314
  precision highp float;
1315
1315
 
1316
1316
  in vec2 vUV;
@@ -1321,7 +1321,7 @@ out vec4 fragColor;
1321
1321
 
1322
1322
  void main(void) {
1323
1323
  fragColor = vColor;
1324
- }`,Bf=`#version 300 es
1324
+ }`,Df=`#version 300 es
1325
1325
  precision highp float;
1326
1326
 
1327
1327
  // Attributes
@@ -1349,4 +1349,4 @@ void main(void) {
1349
1349
  vUV = uv;
1350
1350
 
1351
1351
  vColor = color;
1352
- }`,Ff=e=>{const t=m.useRef(null),{billboardMode:n="All",zOffset:a,zOffsetUnits:i}=e,[o,r]=m.useState(),l=_e.useScene();return m.useEffect(()=>{const s=()=>{const c=l==null?void 0:l.activeCamera;r(c==null?void 0:c.getDirection(u.Vector3.Right()))};return l&&l.activeCamera&&(s(),l==null||l.activeCamera.onViewMatrixChangedObservable.add(s)),()=>{l&&l.activeCamera&&(l==null||l.activeCamera.onViewMatrixChangedObservable.removeCallback(s))}},[l]),m.useEffect(()=>{t.current&&o&&(t.current.setVector3("direction",o),t.current.setFloat("billboardMode",n==="all"?1:0),a!==void 0&&i!==void 0&&(t.current.zOffset=a,t.current.zOffsetUnits=i))},[n,o,a,i]),C.jsx(lt,{ref:t,name:e.name,backFaceCulling:!1,needDepthPrePass:e.needDepthPrePass,vertex:Bf,fragment:Rf,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:u.Material.CounterClockWiseSideOrientation})},Df=(e,t)=>{const n=_e.useScene(),a=m.useRef(null),i=m.useRef(null),o=m.useContext(Le),{id:r,visible:l=!0,vertices:s,indices:c,colors:p,uvs:f,position:d,customMaterial:x}=e,{title:h,color:T,fontSize:P}=e.style;return m.useImperativeHandle(t,()=>i.current,[]),m.useEffect(()=>{if(n&&a.current){const v=new u.VertexData;v.positions=s,v.indices=c,v.colors=p,v.uvs=f,v.applyToMesh(a.current)}},[p,x,r,c,n,f,s]),C.jsxs("transformNode",{name:`node-curve-${r}`,position:d?d.multiply(new u.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1)):new u.Vector3(0,0,0),scaling:new u.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1),ref:i,setEnabled:l,children:[C.jsx("mesh",{name:"curve",ref:a,scaling:new u.Vector3(1,1,1),children:x?C.jsx(Ff,{name:`material-${r}`,billboardMode:"none"}):C.jsx("standardMaterial",{name:`material-${r}`,backFaceCulling:!1})}),C.jsx("transformNode",{name:"title",position:e.style.position?e.style.position:new u.Vector3(0,0,0),scaling:ct(o),children:h&&C.jsx(Je,{text:h,fontSize:P||40,color:T||"white"})})]})},zf=m.forwardRef(Df),No=e=>{var E,L;const t=_e.useScene(),[n,a]=m.useState([]),[i,o]=m.useState([]),[r,l]=m.useState([]),[s,c]=m.useState([]),[p,f]=m.useState(),[d,x]=m.useState(),[h,T]=m.useState(),{colorCodecs:P}=m.useContext(Lt),{id:v,url:_,callback:b,visible:k=!0,customMaterial:M=!1,colorType:w,width:S=20,offset:N=new u.Vector3(0,0,0),direction:F="right"}=e,B=je({url:_,cacheType:Me.EXACTLY_MATCH}),I=m.useCallback((y,A,V,$,W=!0)=>{if(t){const ne=u.MeshBuilder.CreateRibbon("ribbon",{pathArray:[V,$],sideOrientation:W?u.Mesh.FRONTSIDE:u.Mesh.DOUBLESIDE},t),ee=ne.getVerticesData(u.VertexBuffer.PositionKind),G=ne.getIndices();if(ee&&G){const le=Ot.buildTubeChartColors(ee,Y=>{if(w&&P&&P[w]){const ce=y.max,ae=y.min;let X=new u.Color3(1,1,1);return ae===ae?X=P[w].array[P[w].array.length-1]:X=P[w].array[Math.trunc((y.chart[Y].value-ae)/(ce-ae)*(P[w].array.length-1))],new u.Color4(X.r,X.g,X.b,1)}return b?b(A[Y],Y,y.max,y.min):Ot.colorMapTubeChart()},W),re=[],oe=ee.length/3;for(let Y=0;Y<oe;Y++)Y>=oe/2?re.push($[Y-oe/2].x-V[Y-oe/2].x,1):re.push(0,1);a(ee.slice()),o(G.slice()),l(le),c(re)}t==null||t.removeMesh(ne)}},[b,P,w,t]);m.useEffect(()=>{var y,A,V,$,W;if(B){const ne=Xo.decode(new Uint8Array(B)),ee=S/(ne.max-ne.min),G=ne.min<0?-ne.min:0,le=F==="right"?S/2:S;console.log(ne);const re=[],oe=ne.chart.map(X=>{const Pe=X.position?X.position:{x:0,y:0,z:0};return re.push(X.value),new u.Vector3(Pe.x-le,Pe.y+10,Pe.z)}),Y=ne.chart.map(X=>{const Pe=X.position?X.position:{x:0,y:0,z:0},ge=F==="right"?(X.value+G)*ee:-(X.value+G)*ee;return new u.Vector3(Pe.x+ge-le,Pe.y+10,Pe.z)});T(ne.name),f(new u.Vector3((y=ne.origin)==null?void 0:y.x,(A=ne.origin)==null?void 0:A.y,(V=ne.origin)==null?void 0:V.z).add(N));const ce=S/2-(($=e.style)!=null&&$.fontSize?e.style.fontSize/2:0),ae=oe[oe.length-1].add(new u.Vector3(F==="right"?ce:-ce,0,0)).add((W=e.style)!=null&&W.offset?e.style.offset:new u.Vector3(0,0,0));x(new u.Vector3(ae.x,ae.y,ae.z)),I(ne,re,oe.splice(0,oe.length),Y.splice(0,Y.length),!0)}},[I,_,t,N,(E=e.style)==null?void 0:E.offset,S,(L=e.style)==null?void 0:L.fontSize,B,F]);const D=m.useCallback(()=>{},[]);return m.useEffect(()=>{const y=()=>{D()};return t&&t.activeCamera&&(y(),t==null||t.activeCamera.onViewMatrixChangedObservable.add(y)),()=>{t&&t.activeCamera&&(t==null||t.activeCamera.onViewMatrixChangedObservable.removeCallback(y))}},[D,t]),C.jsx(C.Fragment,{children:k&&n.length>0&&r.length>0&&C.jsx(zf,{id:v,visible:k,vertices:n,colors:r,uvs:s,indices:i,position:p,style:{...e.style,title:h,position:d},customMaterial:M})})},Vf=e=>{const t=m.useRef(null),n=m.useContext(Le),{id:a,visible:i=!0,position:o}=e,{title:r,color:l,fontSize:s}=e.style;return C.jsx("transformNode",{name:`node-curve-${a}`,position:o?o.multiply(new u.Vector3(n?n.scalePlane:1,n?n.scaleDepth:1,n?n.scalePlane:1)):new u.Vector3(0,0,0),scaling:new u.Vector3(n?n.scalePlane:1,n?n.scaleDepth:1,n?n.scalePlane:1),ref:t,setEnabled:i,children:C.jsx("transformNode",{name:"title",position:e.style.position?e.style.position:new u.Vector3(0,0,0),scaling:ct(n),children:r&&C.jsx(Je,{text:r,fontSize:s||40,color:l||"white"})})})},Ma=e=>{var _,b;const t=_e.useScene(),[n,a]=m.useState(),[i,o]=m.useState(),[r,l]=m.useState(),[s,c]=m.useState([]),{id:p,url:f,visible:d=!0,offset:x=new u.Vector3(0,0,0),color:h,width:T=20}=e,P=je({url:f,cacheType:Me.EXACTLY_MATCH}),v=m.useContext(Le);return m.useEffect(()=>{var k,M,w,S,N,F,B,I;if(P){const D=Xo.decode(new Uint8Array(P)),E=T/(D.max-D.min),L=D.min<0?-D.min:0,y=new u.Vector3((k=D.origin)==null?void 0:k.x,(M=D.origin)==null?void 0:M.y,(w=D.origin)==null?void 0:w.z).add(x);a(y);const A=D.chart,V=[];for(let W=0;W<A.length;W++)V.push(y.add(new u.Vector3((S=A[W].position)==null?void 0:S.x,(N=A[W].position)==null?void 0:N.y,(F=A[W].position)==null?void 0:F.z)).add(new u.Vector3((A[W].value+L)*E,0,0)).multiply(Oe(v)));c([V]);const $=A[A.length-1].position;if($){const W=new u.Vector3($.x,$.y,$.z).add(new u.Vector3(T/2-((B=e.style)!=null&&B.fontSize?e.style.fontSize/2:0),0,0)).add((I=e.style)!=null&&I.offset?e.style.offset:new u.Vector3(0,0,0));o(new u.Vector3(W.x,W.y,W.z))}l(D.name)}},[f,t,x,(_=e.style)==null?void 0:_.offset,(b=e.style)==null?void 0:b.fontSize,P,v,T]),C.jsxs(C.Fragment,{children:[C.jsx(Vf,{id:p,visible:d,position:n,style:{...e.style,title:r,position:i}}),s.length>0&&C.jsx("lineSystem",{name:"line",lines:s,color:h,setEnabled:d})]})};function pi(){return{name:"",origin:void 0,layerList:[]}}const La={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.origin!==void 0&&K.encode(e.origin,t.uint32(18).fork()).ldelim();for(const n of e.layerList)gn.encode(n,t.uint32(26).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=pi();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 2:if(o!==18)break;i.origin=K.decode(n,n.uint32());continue;case 3:if(o!==26)break;i.layerList.push(gn.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{name:Ft(e.name)?globalThis.String(e.name):"",origin:Ft(e.origin)?K.fromJSON(e.origin):void 0,layerList:globalThis.Array.isArray(e==null?void 0:e.layerList)?e.layerList.map(t=>gn.fromJSON(t)):[]}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),e.origin!==void 0&&(t.origin=K.toJSON(e.origin)),(n=e.layerList)!=null&&n.length&&(t.layerList=e.layerList.map(a=>gn.toJSON(a))),t},create(e){return La.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=pi();return t.name=(n=e.name)!=null?n:"",t.origin=e.origin!==void 0&&e.origin!==null?K.fromPartial(e.origin):void 0,t.layerList=((a=e.layerList)==null?void 0:a.map(i=>gn.fromPartial(i)))||[],t}};function hi(){return{name:"",position:void 0,start:void 0,end:void 0,radius:0,colorId:0,v:[]}}const gn={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.position!==void 0&&K.encode(e.position,t.uint32(18).fork()).ldelim(),e.start!==void 0&&K.encode(e.start,t.uint32(26).fork()).ldelim(),e.end!==void 0&&K.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=hi();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 2:if(o!==18)break;i.position=K.decode(n,n.uint32());continue;case 3:if(o!==26)break;i.start=K.decode(n,n.uint32());continue;case 4:if(o!==34)break;i.end=K.decode(n,n.uint32());continue;case 5:if(o!==45)break;i.radius=n.float();continue;case 6:if(o!==53)break;i.colorId=n.float();continue;case 7:if(o!==58)break;i.v.push(n.string());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{name:Ft(e.name)?globalThis.String(e.name):"",position:Ft(e.position)?K.fromJSON(e.position):void 0,start:Ft(e.start)?K.fromJSON(e.start):void 0,end:Ft(e.end)?K.fromJSON(e.end):void 0,radius:Ft(e.radius)?globalThis.Number(e.radius):0,colorId:Ft(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=K.toJSON(e.position)),e.start!==void 0&&(t.start=K.toJSON(e.start)),e.end!==void 0&&(t.end=K.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 gn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i,o;const t=hi();return t.name=(n=e.name)!=null?n:"",t.position=e.position!==void 0&&e.position!==null?K.fromPartial(e.position):void 0,t.start=e.start!==void 0&&e.start!==null?K.fromPartial(e.start):void 0,t.end=e.end!==void 0&&e.end!==null?K.fromPartial(e.end):void 0,t.radius=(a=e.radius)!=null?a:0,t.colorId=(i=e.colorId)!=null?i:0,t.v=((o=e.v)==null?void 0:o.map(r=>r))||[],t}};function Ft(e){return e!=null}const $f=(e,t)=>{const n=_e.useScene(),a=m.useRef(null),i=m.useRef(null),o=m.useContext(Le),{id:r,visible:l=!0,vertices:s,indices:c,colors:p,position:f,materialType:d="custom",children:x,alphaBlend:h=!1,alpha:T=1,name:P="tube",actions:v,slices:_}=e;m.useImperativeHandle(t,()=>i.current,[]),m.useEffect(()=>{a.current&&(a.current.metadata={pickable:v?{needWorldPosition:!0,name:P,onLeftClick:v.onLeftClick,onRightClick:v.onRightClick,onMiddleClick:v.onMiddleClick,onHover:(k,M,w,S,N)=>{var F,B,I,D,E,L;if(v.onHover&&n&&_&&w){const y=w;for(let A=0;A<_.length;A++){const V=new u.Vector3((F=_[A].start)==null?void 0:F.x,(B=_[A].start)==null?void 0:B.y,(I=_[A].start)==null?void 0:I.z).add(f).multiply(Oe(o)),$=new u.Vector3((D=_[A].end)==null?void 0:D.x,(E=_[A].end)==null?void 0:E.y,(L=_[A].end)==null?void 0:L.z).add(f).multiply(Oe(o)),W=Math.sqrt(Math.pow(V.x-$.x,2)+Math.pow(V.y-$.y,2)+Math.pow(V.z-$.z,2)),ne=new u.Vector3(V.x,V.y-W,V.z),ee=$.subtract(V),G=ne.subtract(V),le=y.subtract(V),re=u.Vector3.Cross(ee,G),oe=Math.acos(u.Vector3.Dot(ee.normalize(),G.normalize())),Y=u.Matrix.RotationAxis(re,oe),ce=u.Vector3.TransformCoordinates(le,Y);if(0>=ce.y&&-W<=ce.y){v.onHover(k,M,w,S,_[A],N);break}}}},valueCallback:null,extra:v.extra}:null})},[v,o,f,n,_]),m.useEffect(()=>{if(a&&a.current&&n){const k=new u.VertexData;k.positions=s,k.indices=c,p&&d!=="pbr-dark"&&d!=="pbr-light"&&(k.colors=p),k.applyToMesh(a.current)}},[c,s,n,p,r,d]);const b=m.useCallback(()=>{if(d==="custom")return C.jsx(lt,{name:`${P}-material-${r}`,vertex:Gn,fragment:Zn,needDepthPrePass:!1,transparencyMode:h?u.Material.MATERIAL_ALPHABLEND:u.Material.MATERIAL_OPAQUE,options:{needAlphaBlending:!!h}});if(d==="standard")return C.jsx("standardMaterial",{name:`${P}-material`,alphaMode:u.Engine.ALPHA_COMBINE,transparencyMode:h?u.Material.MATERIAL_ALPHABLEND:u.Material.MATERIAL_OPAQUE,alpha:T});if(d==="pbr-light")return C.jsx(Yn,{alpha:T});if(d==="pbr-dark")return C.jsx(Jn,{alpha:T})},[T,h,r,d,P]);return C.jsxs("transformNode",{name:`node-${P}-${r}`,setEnabled:l,children:[C.jsx("transformNode",{name:`${P}`,position:f?f.multiply(new u.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1)):new u.Vector3(0,0,0),scaling:new u.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1),ref:i,children:C.jsx("mesh",{name:`${P}-mesh`,ref:a,children:b()})}),x]})},Wf=m.forwardRef($f),Uf=(e,t)=>{const n=m.useRef(null),a=m.useContext(Le);m.useImperativeHandle(t,()=>n.current,[]);const{id:i,visible:o=!0,position:r,data:l,offset:s=new u.Vector3(0,0,0),color:c="white",fontSize:p=40,showLabel:f=!0}=e;return C.jsx("transformNode",{name:`node-layer-${i}`,position:r?r.add(s).multiply(new u.Vector3(a?a.scalePlane:1,a?a.scaleDepth:1,a?a.scalePlane:1)):new u.Vector3(0,0,0).add(s),scaling:new u.Vector3(a?a.scalePlane:1,a?a.scaleDepth:1,a?a.scalePlane:1),ref:n,setEnabled:o,children:f?l.map((d,x)=>C.jsx("transformNode",{name:"layer-text",position:d.position,scaling:ct(a),children:C.jsx(Je,{text:d.name,fontSize:p,color:c})},x)):C.jsx(C.Fragment,{})})},Hf=m.forwardRef(Uf),Io=e=>{var I,D,E,L,y;const t=_e.useScene(),[n,a]=m.useState([]),[i,o]=m.useState([]),[r,l]=m.useState([]),[s,c]=m.useState(),[p,f]=m.useState([]),[d,x]=m.useState(0),[h,T]=m.useState(),{colorIDs:P}=m.useContext(Lt),{id:v,url:_,color:b,layers:k=[],visible:M=!0,tessellation:w=64,frontSide:S=!1,customMaterial:N=!1,actions:F}=e,B=je({url:_,cacheType:Me.EXACTLY_MATCH});return m.useEffect(()=>{var A,V,$,W,ne,ee;if(B){const G=La.decode(new Uint8Array(B)),le=[];G.layerList.forEach((ge,H)=>{var Q,Ee,ke,te,me,ue;le.push(ge),H<G.layerList.length&&le.push({...ge,name:ge.name+"opacity",start:{x:(Ee=(Q=ge==null?void 0:ge.end)==null?void 0:Q.x)!=null?Ee:0,y:(te=(ke=ge==null?void 0:ge.end)==null?void 0:ke.y)!=null?te:0,z:(ue=(me=ge==null?void 0:ge.end)==null?void 0:me.z)!=null?ue:0}})});const re=le.map(ge=>{const H=ge.start?ge.start:{x:0,y:0,z:0};return new u.Vector3(H.x,H.y,H.z)}),oe=u.MeshBuilder.CreateTube("tube-tmp",{path:re,radiusFunction:ge=>{var Q;const H=(Q=le[ge])==null?void 0:Q.radius;return H||1},cap:u.Mesh.NO_CAP,tessellation:w,sideOrientation:S?u.Mesh.FRONTSIDE:u.Mesh.DOUBLESIDE},t),Y=oe.getVerticesData(u.VertexBuffer.PositionKind),ce=N?Ot.correctTubeMainIndices(oe.getIndices()):oe.getIndices(),ae=b;let X=[];Y&&(X=Ot.buildTubeMainColors(Y,le.map(ge=>{const H=ae||(P&&P[ge.colorId]?P[ge.colorId]:Ot.randomColorMap()),Q=k.findIndex(Ee=>Ee===ge.name)!==-1?H.a:0;return new u.Color4(H.r,H.g,H.b,Q)}),w,!!S)),T(G),a(Y?Y.slice():[]),o(ce?ce.slice():[]),l(X),c(new u.Vector3((A=G.origin)==null?void 0:A.x,(V=G.origin)==null?void 0:V.y,($=G.origin)==null?void 0:$.z)),t==null||t.removeMesh(oe);const Pe=[];for(let ge=0;ge<G.layerList.length;ge++){const H=G.layerList[ge];k.findIndex(Q=>Q===H.name)!==-1&&Pe.push({name:H.name,position:new u.Vector3((W=H.position)==null?void 0:W.x,(ne=H.position)==null?void 0:ne.y,(ee=H.position)==null?void 0:ee.z)})}f(Pe),x(G.layerList?G.layerList[0].radius:0)}},[_,t,S,w,N,k,P,B,b]),C.jsxs("transformNode",{name:`node-layer-${v}`,children:[n.length>0&&i.length>0&&C.jsx(Wf,{id:v,name:"tube-layer",visible:M,vertices:n,slices:h==null?void 0:h.layerList,indices:i,position:s,colors:r.length>0?r:void 0,materialType:N?"custom":"standard",alphaBlend:!0,actions:F}),p.length>0&&C.jsx(Hf,{id:v,data:p,visible:M,position:s,fontSize:(I=e.style)==null?void 0:I.fontSize,color:(D=e.style)==null?void 0:D.color,offset:(L=(E=e.style)==null?void 0:E.offset)==null?void 0:L.add(new u.Vector3(d,0,0)),showLabel:(y=e.style)==null?void 0:y.showLabel})]})},mi=e=>{const t=_e.useScene(),n=m.useRef(null),[a,i]=m.useState([]),[o,r]=m.useState([]),[l,s]=m.useState([]),{color:c,type:p,name:f="cap",materialType:d,tessellation:x,data:h}=e,T=m.useCallback(()=>{const v=[],_=[];for(let F=0;F<2*x+1;F++)if(p==="start")v.push(new u.Vector3(h[F*3],h[F*3+1],h[F*3+2]));else{const B=h.length-2*x*3;v.push(new u.Vector3(h[F*3+B],h[F*3+1+B],h[F*3+2+B]))}const b=[],k=[];for(let F=0;F<x;F++)b.push(v[F]),k.push(v[2*x-F-1]);_.push(b,k);const M=u.MeshBuilder.CreateRibbon("ribbon-tmp",{pathArray:_,sideOrientation:u.Mesh.DOUBLESIDE},t),w=M.getVerticesData(u.VertexBuffer.PositionKind),S=M.getIndices(),N=M.getNormalsData();i(w?w.slice():[]),r(S?S.slice():[]),s(N?N.slice():[]),t==null||t.removeMesh(M)},[t,x,p,h]);m.useEffect(()=>{T()},[T]),m.useEffect(()=>{if(n&&n.current&&t){const v=new u.VertexData;v.positions=a,v.indices=o,v.normals=l,v.applyToMesh(n.current)}},[o,a,t,l]);const P=m.useCallback(()=>d==="pbr"?C.jsx("pbrMaterial",{name:"cap-pbr-material",alpha:.8,metallic:1,roughness:.03,albedoColor:new u.Color3(248/255,163/255,151/255),emissiveColor:new u.Color3(36/255,36/255,36/255),transparencyMode:u.Material.MATERIAL_OPAQUE}):C.jsx("standardMaterial",{name:`${f}-material`,alphaMode:u.Engine.ALPHA_COMBINE,transparencyMode:u.Material.MATERIAL_OPAQUE,diffuseColor:new u.Color3(c.r,c.g,c.b)}),[c.b,c.g,c.r,d,f]);return C.jsx("mesh",{name:`${f}-mesh`,ref:n,isPickable:!0,children:P()})},Ra=e=>{const t=_e.useScene(),n=m.useRef(null),[a,i]=m.useState(u.Vector3.Zero()),[o,r]=m.useState([]),[l,s]=m.useState([]),[c,p]=m.useState([]),[f,d]=m.useState(""),[x,h]=m.useState(new u.Vector3(0,0,0)),[T,P]=m.useState([]),v=m.useContext(Le),{id:_,color:b,url:k,name:M="tube",children:w,materialType:S="standard",actions:N,tessellation:F=32,style:B}=e,I=m.useRef(!1),D=m.useCallback(L=>{var ee,G,le;const y=L.sliceList.filter(re=>!(re.v.length>0)).map(re=>{const oe=re.start?re.start:{x:0,y:0,z:0};return new u.Vector3(oe.x,oe.y,oe.z)}),A=L.sliceList[L.sliceList.length-1];if(y.length>0&&y.push(new u.Vector3((ee=A.end)==null?void 0:ee.x,(G=A.end)==null?void 0:G.y,(le=A.end)==null?void 0:le.z)),y.length<1)return;const V=u.MeshBuilder.ExtrudeShape("tmp",{path:y,sideOrientation:u.Mesh.DOUBLESIDE,shape:Ot.buildSemiRing(A.innerRadius,A.radius,F),cap:u.Mesh.NO_CAP},t);P(V.getVerticesData(u.VertexBuffer.PositionKind)),V.convertToFlatShadedMesh(),V.computeWorldMatrix(!0),V._updateBoundingInfo();const $=V.getVerticesData(u.VertexBuffer.PositionKind),W=V.getIndices(),ne=V.getNormalsData();r($?$.slice():[]),s(W?W.slice():[]),p(ne?ne.slice():[]),t==null||t.removeMesh(V)},[t,F]);m.useEffect(()=>{I.current||(I.current=!0,Ut.get(k,{responseType:"arraybuffer"}).then(L=>{var V,$,W;const y=Nt.decode(new Uint8Array(L.data));if(console.log(y),y.sliceList.length===0)return;d(y.name);const A=B!=null&&B.basePosition&&B.basePosition==="top"?y.sliceList[0].start:y.sliceList[y.sliceList.length-1].end;h(new u.Vector3(A==null?void 0:A.x,A==null?void 0:A.y,A==null?void 0:A.z)),i(new u.Vector3((V=y.origin)==null?void 0:V.x,($=y.origin)==null?void 0:$.y,(W=y.origin)==null?void 0:W.z)),D(y)}))},[D,B==null?void 0:B.basePosition,k]),m.useEffect(()=>{if(n&&n.current&&t){const L=new u.VertexData;L.positions=o,L.indices=l,L.normals=c,L.applyToMesh(n.current)}},[l,o,t,c]),m.useEffect(()=>{n.current&&(n.current.metadata={pickable:N?{name:M,value:_,onLeftClick:N.onLeftClick,valueCallback:()=>_,onRightClick:N.onRightClick,onMiddleClick:N.onMiddleClick,onHover:N.onHover,needWorldPosition:N.needWorldPosition}:null})},[N,_,v,M,a,t]);const E=m.useCallback(()=>S==="pbr"?C.jsx("pbrMaterial",{name:"main-pbr-material",alpha:1,metallic:1,roughness:.03,albedoColor:new u.Color3(230/255,230/255,230/255),emissiveColor:new u.Color3(71/255,71/255,71/255),transparencyMode:u.Material.MATERIAL_OPAQUE}):C.jsx("standardMaterial",{name:`${M}-material`,alphaMode:u.Engine.ALPHA_COMBINE,transparencyMode:u.Material.MATERIAL_OPAQUE,diffuseColor:new u.Color3(b.r,b.g,b.b)}),[b.b,b.g,b.r,S,M]);return C.jsxs("transformNode",{name:`${M}-main-node`,position:a.multiply(Oe(v)),scaling:Oe(v),children:[C.jsx("mesh",{name:`${M}-mesh`,ref:n,isPickable:!0,children:E()}),T.length>0&&C.jsx(mi,{id:1,name:"start",color:b,type:"start",tessellation:F,data:T,materialType:S}),T.length>0&&C.jsx(mi,{id:2,name:"end",color:b,type:"end",tessellation:F,data:T,materialType:S}),B&&C.jsx(Ia,{id:_,style:{title:f,position:x,offset:B.offset,fontSize:B.fontSize,color:B.color}}),w]})},Ba=e=>{const{id:t,visible:n=!0,children:a,offset:i=new u.Vector3(0,0,0)}=e;return C.jsx(C.Fragment,{children:C.jsx("transformNode",{name:`tube-${t}`,setEnabled:n,position:i,children:a})})};function gi(){return{name:"",origin:void 0,dataPoints:[],size:void 0}}const Fa={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.origin!==void 0&&K.encode(e.origin,t.uint32(18).fork()).ldelim();for(const n of e.dataPoints)vn.encode(n,t.uint32(26).fork()).ldelim();return e.size!==void 0&&K.encode(e.size,t.uint32(34).fork()).ldelim(),t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=gi();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 2:if(o!==18)break;i.origin=K.decode(n,n.uint32());continue;case 3:if(o!==26)break;i.dataPoints.push(vn.decode(n,n.uint32()));continue;case 4:if(o!==34)break;i.size=K.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{name:zt(e.name)?globalThis.String(e.name):"",origin:zt(e.origin)?K.fromJSON(e.origin):void 0,dataPoints:globalThis.Array.isArray(e==null?void 0:e.dataPoints)?e.dataPoints.map(t=>vn.fromJSON(t)):[],size:zt(e.size)?K.fromJSON(e.size):void 0}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),e.origin!==void 0&&(t.origin=K.toJSON(e.origin)),(n=e.dataPoints)!=null&&n.length&&(t.dataPoints=e.dataPoints.map(a=>vn.toJSON(a))),e.size!==void 0&&(t.size=K.toJSON(e.size)),t},create(e){return Fa.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=gi();return t.name=(n=e.name)!=null?n:"",t.origin=e.origin!==void 0&&e.origin!==null?K.fromPartial(e.origin):void 0,t.dataPoints=((a=e.dataPoints)==null?void 0:a.map(i=>vn.fromPartial(i)))||[],t.size=e.size!==void 0&&e.size!==null?K.fromPartial(e.size):void 0,t}};function vi(){return{point:void 0,colorId:0,vScale:0,rotation:void 0,pointType:0}}const vn={encode(e,t=se.Writer.create()){return e.point!==void 0&&K.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&&K.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=vi();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.point=K.decode(n,n.uint32());continue;case 2:if(o!==16)break;i.colorId=n.uint32();continue;case 4:if(o!==37)break;i.vScale=n.float();continue;case 5:if(o!==42)break;i.rotation=K.decode(n,n.uint32());continue;case 6:if(o!==48)break;i.pointType=n.uint32();continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{point:zt(e.point)?K.fromJSON(e.point):void 0,colorId:zt(e.colorId)?globalThis.Number(e.colorId):0,vScale:zt(e.vScale)?globalThis.Number(e.vScale):0,rotation:zt(e.rotation)?K.fromJSON(e.rotation):void 0,pointType:zt(e.pointType)?globalThis.Number(e.pointType):0}},toJSON(e){const t={};return e.point!==void 0&&(t.point=K.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=K.toJSON(e.rotation)),e.pointType!==0&&(t.pointType=Math.round(e.pointType)),t},create(e){return vn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i;const t=vi();return t.point=e.point!==void 0&&e.point!==null?K.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?K.fromPartial(e.rotation):void 0,t.pointType=(i=e.pointType)!=null?i:0,t}};function zt(e){return e!=null}const Zf=[0,.05,.1,.15,.2,.25,.3,.35,.4,.45,.5,.55,.6,.65,.7,.75,.8,.85,.9,.95,1],Da=({url:e,alpha:t={typeAlpha0:1,typeAlpha1:1},offset:n=u.Vector3.Zero(),visible:a=!0})=>{const i=_e.useScene(),o=m.useContext(Le),r=m.useContext(Lt),[l,s]=m.useState(""),[c,p]=m.useState(u.Vector3.Zero()),f=je({url:e,cacheType:Me.URL_PREFIX_MATCH}),d=m.useRef(null),x=m.useRef(null);m.useEffect(()=>{console.log("[Geo3DViewer] VoxelGrid Loading: ",e)},[e]);const h=T=>Zf[T];return m.useEffect(()=>{if(i&&f){const T=Fa.decode(new Uint8Array(f)),{name:P,origin:v,dataPoints:_,size:b}=T;if(v&&_){s(P),p(new u.Vector3(v.x,v.y,v.z));let k=null;b&&(k=u.MeshBuilder.CreateBox("voxel",{width:b.x-1e-5,height:b.y-1e-5,depth:b.z-1e-5},i),k.material=d.current,u.Tags.EnableFor(k),u.Tags.AddTagsTo(k,"loading"));const M=new Float32Array(_.length*16),w=new Float32Array(_.length*4);return _.forEach((S,N)=>{if(S.point){const F=new u.Vector3(S.point.x,S.point.y,S.point.z),B=S.rotation?u.Quaternion.FromEulerAngles(S.rotation.x,S.rotation.y,S.rotation.z):u.Quaternion.Identity(),I=new u.Vector3(S.vScale+1,S.vScale+1,S.vScale+1);u.Matrix.Compose(I,B,F).copyToArray(M,N*16);let E=r.colorIDs[S.colorId];E||(E=u.Color4.FromColor3(u.Color3.Random())),w.set([E.r,E.g,E.b,h(S.pointType)],N*4)}}),k&&(k.thinInstanceSetBuffer("matrix",M),k.thinInstanceSetBuffer("color",w,4),k.parent=x.current),u.Tags.RemoveTagsFrom(k,"loading"),()=>{k&&(k.thinInstanceSetBuffer("matrix",new Float32Array),k.thinInstanceSetBuffer("color",new Float32Array),i.removeMesh(k))}}}},[r.colorIDs,i,f]),C.jsx("transformNode",{setEnabled:a,name:`transform-voxel-${l}`,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 u.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1),ref:x,children:C.jsx(ku,{name:`voxel-${l}-mat`,typeAlpha:t,ref:d})})},Gf=(e,t)=>{const{viewer:n,camera:a,useUniversalCamera:i=!1,lights:o,complexFormationManagers:r,formationManagers:l,formationFaces:s,formationVolumes:c,structureLayers:p,colorCodec:f,gridDiagrams:d,attributeBodies:x,tubes:h,roadways:T,densitySlices:P,formationSlices:v,rayClick:_,lines:b,spaceHeats:k,lookAt:M,fps:w,coordinate:S,tileMaps:N,pointClickZones:F,progressedAttributeBodies:B,ribbonLayers:I,intersectingLines:D,tubeInstances:E,optimizer:L,voxelGrids:y,planeImages:A,guiTexts:V,skybox:$,particleSystems:W,waterEffects:ne,modelLoaders:ee,modelAnimationLoaders:G,roadwayAnimations:le,roadwayNearAnimations:re,roadwayWaterAnimations:oe,contourlines:Y,tubeTools:ce,tubeOils:ae,tubeLayers:X,tubeChartLines:Pe,tubeCharts:ge}=e;return C.jsxs(Jo,{...n,ref:t,children:[i?C.jsx(Gu,{...a}):C.jsx(la,{...a}),o?o.map((H,Q)=>C.jsx("hemisphericLight",{...H,name:`extra-light-${Q}`},`extra-light-${Q}`)):C.jsx(C.Fragment,{}),r?r.map(H=>C.jsx(oa,{...H},`complexFormationManager-${H.url}`)):C.jsx(C.Fragment,{}),P?P.map(H=>C.jsx(Zo,{...H},`densitySlice-${H.url}`)):C.jsx(C.Fragment,{}),v?v.map(H=>C.jsx(Yo,{...H},`formationSlice-${H.url}`)):C.jsx(C.Fragment,{}),l?l.map(H=>C.jsx(sa,{...H},`formationManager-${H.url}`)):C.jsx(C.Fragment,{}),s?s.map(H=>C.jsx(Xn,{...H},`formation-face-${H.urlTopLayer}`)):C.jsx(C.Fragment,{}),c?c.map(H=>C.jsx(qn,{...H},`formation-volume-${H.url}`)):C.jsx(C.Fragment,{}),p?p.map(H=>C.jsx(Wo,{...H},`structurelayer-${H.url}`)):C.jsx(C.Fragment,{}),f?C.jsx(ta,{...f}):C.jsx(C.Fragment,{}),d?d.map(H=>C.jsx(fa,{...H},`gridDiagram-${H.url}`)):C.jsx(C.Fragment,{}),x?x.map(H=>C.jsx(ea,{...H},`attributebody-${H.url}`)):C.jsx(C.Fragment,{}),h?h.map(H=>C.jsxs(wa,{...H,children:[H.charts?H.charts.map(Q=>C.jsx(No,{...Q},`tubechart-${Q.url}`)):C.jsx(C.Fragment,{}),H.layers?H.layers.map(Q=>C.jsx(Io,{...Q},`tubelayer-${Q.url}`)):C.jsx(C.Fragment,{}),H.tools?H.tools.map(Q=>C.jsx(Eo,{...Q},`tubelayer-${Q.name}`)):C.jsx(C.Fragment,{})]},`tube-${H.url}`)):C.jsx(C.Fragment,{}),T?T.map(H=>C.jsx(Pa,{...H},`roadway-${H.url}`)):C.jsx(C.Fragment,{}),_?_.map((H,Q)=>C.jsx(Ca,{...H},`rayclick-${Q}`)):C.jsx(C.Fragment,{}),b?b.map((H,Q)=>C.jsx(Uo,{...H},`line-${Q}`)):C.jsx(C.Fragment,{}),k?k.map((H,Q)=>C.jsx(ka,{...H},`spaceheat-${Q}`)):C.jsx(C.Fragment,{}),M?C.jsx(pa,{target:void 0,distance:0}):C.jsx(C.Fragment,{}),w?C.jsx(aa,{}):C.jsx(C.Fragment,{}),S?C.jsx(ra,{...S},"coordinate"):C.jsx(C.Fragment,{}),N?N.map((H,Q)=>C.jsx(Na,{...H},`tilemap-${Q}`)):C.jsx(C.Fragment,{}),F?F.map((H,Q)=>C.jsx(xa,{...H},`pointClickZone-${Q}`)):C.jsx(C.Fragment,{}),B?B.map((H,Q)=>C.jsx(ya,{...H},`progressedAttributeBody-${Q}`)):C.jsx(C.Fragment,{}),I?I.map((H,Q)=>C.jsx(_a,{...H},`ribbonlayer-${Q}`)):C.jsx(C.Fragment,{}),D?D.map((H,Q)=>C.jsx(da,{...H},`intersectingLine-${Q}`)):C.jsx(C.Fragment,{}),E?E.map((H,Q)=>C.jsx(Aa,{...H},`tubeinstance-${Q}`)):C.jsx(C.Fragment,{}),L?C.jsx(ma,{}):C.jsx(C.Fragment,{}),y?y.map((H,Q)=>C.jsx(Da,{...H},`voxelgrid-${Q}`)):C.jsx(C.Fragment,{}),A?A.map((H,Q)=>C.jsx(ga,{...H},`planeimage-${Q}`)):C.jsx(C.Fragment,{}),V?V.map((H,Q)=>C.jsx(Wu,{...H},`guitext-${Q}`)):C.jsx(C.Fragment,{}),$&&C.jsx(Sa,{...$}),W?W.map((H,Q)=>C.jsx(cf,{...H},`particlesystem-${Q}`)):C.jsx(C.Fragment,{}),ne?ne.map((H,Q)=>C.jsx(uf,{...H},`waterEffect-${Q}`)):C.jsx(C.Fragment,{}),ee?ee.map((H,Q)=>C.jsx(Kn,{...H},`modelLoaders-${Q}`)):C.jsx(C.Fragment,{}),G?G.map((H,Q)=>C.jsx(lf,{...H},`modelanimtionloader-${Q}`)):C.jsx(C.Fragment,{}),le?le.map((H,Q)=>C.jsx(Rn,{...H,children:C.jsx(yf,{})},`animation-${Q}`)):C.jsx(C.Fragment,{}),re?re.map((H,Q)=>C.jsx(Rn,{...H,children:C.jsx(Pf,{roadwayWidth:H.roadwayWidth,textureLength:H.textureLength,url:H.imageUrl,isBlink:H.isBlink,visible:H.visible})},`animation-${Q}`)):C.jsx(C.Fragment,{}),oe?oe.map((H,Q)=>C.jsx(Rn,{...H,children:C.jsx(bf,{timeSpeed:H.timeSpeed,perlinMultiply:H.perlinMultiply,waterFlow:H.waterFlow,clippedHeight:H.clippedHeight,alpha:H.alpha,colorSteps:H.colorSteps,speed:H.speed})},`animation-${Q}`)):C.jsx(C.Fragment,{}),Y?Y.map((H,Q)=>C.jsx(Fu,{...H},`contourline-${Q}`)):C.jsx(C.Fragment,{}),ce?ce.map((H,Q)=>C.jsx(Eo,{...H},`tubeTool-${Q}`)):C.jsx(C.Fragment,{}),ae?ae.map((H,Q)=>C.jsx(Ba,{...H,children:H.main?H.main.map((Ee,ke)=>C.jsx(Ra,{...Ee},`tubeMain-${ke}`)):null},`tubeOil-${Q}`)):C.jsx(C.Fragment,{}),X?X.map((H,Q)=>C.jsx(Io,{...H},`tubeLayer-${Q}`)):C.jsx(C.Fragment,{}),Pe?Pe.map((H,Q)=>C.jsx(Ma,{...H},`tubeChartLine-${Q}`)):C.jsx(C.Fragment,{}),ge?ge.map((H,Q)=>C.jsx(No,{...H},`tubeChart-${Q}`)):C.jsx(C.Fragment,{})]})},Yf=m.forwardRef(Gf),Jf=e=>{const t=_e.useScene(),n=m.useRef(null),{keyFrames:a,speed:i}=e;return m.useEffect(()=>{if(t&&n.current&&n.current.animations.length===0){const o=new u.Animation("roam","position",40,u.Animation.ANIMATIONTYPE_VECTOR3,u.Animation.ANIMATIONLOOPMODE_CONSTANT);for(let r=0;r<a.length;r++)r!==a.length-1&&o.addEvent(new u.AnimationEvent(a[r].frame,()=>{var l;(l=n.current)==null||l.setTarget(a[r+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(i),()=>{n.current&&(n.current.position=a[0].value,n.current.setTarget(a[1].value))})}},[a,t,i]),C.jsxs(C.Fragment,{children:[C.jsx("freeCamera",{name:"roam-camera",position:new u.Vector3(0,0,0),ref:n}),C.jsx("lines",{name:"",points:a.map(o=>o.value)}),a.map((o,r)=>C.jsx("sphere",{name:"roam-sphere-"+r,diameter:1,position:o.value,children:C.jsx("standardMaterial",{name:"roam-sphere-mat",diffuseColor:u.Color3.Red(),specularColor:u.Color3.Black(),alpha:1})},r))]})};function xi(){return{name:"",origin:void 0,type:"",sliceList:[],vertices:[],normals:[],indices:[],uv:[]}}const za={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.origin!==void 0&&K.encode(e.origin,t.uint32(18).fork()).ldelim(),e.type!==""&&t.uint32(26).string(e.type);for(const n of e.sliceList)xn.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=xi();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 2:if(o!==18)break;i.origin=K.decode(n,n.uint32());continue;case 3:if(o!==26)break;i.type=n.string();continue;case 4:if(o!==34)break;i.sliceList.push(xn.decode(n,n.uint32()));continue;case 5:if(o===45){i.vertices.push(n.float());continue}if(o===42){const r=n.uint32()+n.pos;for(;n.pos<r;)i.vertices.push(n.float());continue}break;case 6:if(o===53){i.normals.push(n.float());continue}if(o===50){const r=n.uint32()+n.pos;for(;n.pos<r;)i.normals.push(n.float());continue}break;case 7:if(o===61){i.indices.push(n.float());continue}if(o===58){const r=n.uint32()+n.pos;for(;n.pos<r;)i.indices.push(n.float());continue}break;case 8:if(o===69){i.uv.push(n.float());continue}if(o===66){const r=n.uint32()+n.pos;for(;n.pos<r;)i.uv.push(n.float());continue}break}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{name:xt(e.name)?globalThis.String(e.name):"",origin:xt(e.origin)?K.fromJSON(e.origin):void 0,type:xt(e.type)?globalThis.String(e.type):"",sliceList:globalThis.Array.isArray(e==null?void 0:e.sliceList)?e.sliceList.map(t=>xn.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,i,o,r;const t={};return e.name!==""&&(t.name=e.name),e.origin!==void 0&&(t.origin=K.toJSON(e.origin)),e.type!==""&&(t.type=e.type),(n=e.sliceList)!=null&&n.length&&(t.sliceList=e.sliceList.map(l=>xn.toJSON(l))),(a=e.vertices)!=null&&a.length&&(t.vertices=e.vertices),(i=e.normals)!=null&&i.length&&(t.normals=e.normals),(o=e.indices)!=null&&o.length&&(t.indices=e.indices),(r=e.uv)!=null&&r.length&&(t.uv=e.uv),t},create(e){return za.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i,o,r,l,s;const t=xi();return t.name=(n=e.name)!=null?n:"",t.origin=e.origin!==void 0&&e.origin!==null?K.fromPartial(e.origin):void 0,t.type=(a=e.type)!=null?a:"",t.sliceList=((i=e.sliceList)==null?void 0:i.map(c=>xn.fromPartial(c)))||[],t.vertices=((o=e.vertices)==null?void 0:o.map(c=>c))||[],t.normals=((r=e.normals)==null?void 0:r.map(c=>c))||[],t.indices=((l=e.indices)==null?void 0:l.map(c=>c))||[],t.uv=((s=e.uv)==null?void 0:s.map(c=>c))||[],t}};function yi(){return{position:void 0,start:void 0,end:void 0,color:void 0,angle:0,radius:0,bottomRadius:0,texture:"",v:[]}}const xn={encode(e,t=se.Writer.create()){e.position!==void 0&&K.encode(e.position,t.uint32(10).fork()).ldelim(),e.start!==void 0&&K.encode(e.start,t.uint32(18).fork()).ldelim(),e.end!==void 0&&K.encode(e.end,t.uint32(26).fork()).ldelim(),e.color!==void 0&&ot.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const i=yi();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.position=K.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.start=K.decode(n,n.uint32());continue;case 3:if(o!==26)break;i.end=K.decode(n,n.uint32());continue;case 4:if(o!==34)break;i.color=ot.decode(n,n.uint32());continue;case 5:if(o!==45)break;i.angle=n.float();continue;case 6:if(o!==53)break;i.radius=n.float();continue;case 7:if(o!==61)break;i.bottomRadius=n.float();continue;case 8:if(o!==66)break;i.texture=n.string();continue;case 9:if(o!==74)break;i.v.push(n.string());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return i},fromJSON(e){return{position:xt(e.position)?K.fromJSON(e.position):void 0,start:xt(e.start)?K.fromJSON(e.start):void 0,end:xt(e.end)?K.fromJSON(e.end):void 0,color:xt(e.color)?ot.fromJSON(e.color):void 0,angle:xt(e.angle)?globalThis.Number(e.angle):0,radius:xt(e.radius)?globalThis.Number(e.radius):0,bottomRadius:xt(e.bottomRadius)?globalThis.Number(e.bottomRadius):0,texture:xt(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=K.toJSON(e.position)),e.start!==void 0&&(t.start=K.toJSON(e.start)),e.end!==void 0&&(t.end=K.toJSON(e.end)),e.color!==void 0&&(t.color=ot.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 xn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,i,o,r;const t=yi();return t.position=e.position!==void 0&&e.position!==null?K.fromPartial(e.position):void 0,t.start=e.start!==void 0&&e.start!==null?K.fromPartial(e.start):void 0,t.end=e.end!==void 0&&e.end!==null?K.fromPartial(e.end):void 0,t.color=e.color!==void 0&&e.color!==null?ot.fromPartial(e.color):void 0,t.angle=(n=e.angle)!=null?n:0,t.radius=(a=e.radius)!=null?a:0,t.bottomRadius=(i=e.bottomRadius)!=null?i:0,t.texture=(o=e.texture)!=null?o:"",t.v=((r=e.v)==null?void 0:r.map(l=>l))||[],t}};function xt(e){return e!=null}const Xf=e=>{const t=_e.useScene(),[n,a]=m.useState([]),[i,o]=m.useState([]),[r,l]=m.useState(u.Vector3.Zero()),s=m.useContext(Le),c=m.useRef(null),p=m.useRef(!1),[f,d]=m.useState([]),{url:x,name:h="rod",visible:T=!0,color:P}=e,v=m.useCallback(_=>{var N,F,B;const b=_.sliceList.filter(I=>!(I.v.length>0)).map(I=>{const D=I.start?I.start:{x:0,y:0,z:0};return new u.Vector3(D.x,D.y,D.z)}),k=_.sliceList[_.sliceList.length-1];if(b.length>0&&b.push(new u.Vector3((N=k.end)==null?void 0:N.x,(F=k.end)==null?void 0:F.y,(B=k.end)==null?void 0:B.z)),b.length<1)return;const M=u.MeshBuilder.CreateTube("tube-tmp",{path:b,radiusFunction:I=>{if(e.radius)return e.radius;const D=_.sliceList[I]?_.sliceList[I].radius:_.sliceList[I-1].radius;return D||1},cap:u.Mesh.CAP_ALL,tessellation:24,sideOrientation:u.Mesh.FRONTSIDE},t),w=M.getVerticesData(u.VertexBuffer.PositionKind),S=M.getIndices();a(w?w.slice():[]),o(S?S.slice():[]),t==null||t.removeMesh(M)},[e.radius,t]);return m.useEffect(()=>{p.current||(p.current=!0,Ut.get(x,{responseType:"arraybuffer"}).then(_=>{var k,M,w;const b=za.decode(new Uint8Array(_.data));b.sliceList.length!==0&&(d(b.sliceList),l(new u.Vector3((k=b.origin)==null?void 0:k.x,(M=b.origin)==null?void 0:M.y,(w=b.origin)==null?void 0:w.z)),console.log(b),v(b))}))},[v,x]),m.useEffect(()=>{if(c&&c.current&&t){const _=new u.VertexData;_.positions=n,_.indices=i,_.applyToMesh(c.current)}},[i,n,t]),m.useEffect(()=>{var b,k,M;let _;if(f.length>0&&t){_=u.MeshBuilder.CreateSphere("top",{diameter:f[0].bottomRadius*2,segments:32},t);const w=new u.StandardMaterial("myMaterial",t);_.material=w,_.setEnabled(!1),w.diffuseColor=new u.Color3(P.r,P.g,P.b);for(let S=0;S<f.length;S++){const N=f[S],F=_.createInstance("tubeinstance-sphere-"+S);F.setEnabled(T);const B=r.multiply(Oe(s));F.position=B.add(new u.Vector3((b=N.position)==null?void 0:b.x,(k=N.position)==null?void 0:k.y,(M=N.position)==null?void 0:M.z).multiply(Oe(s)))}}return()=>{_&&_.dispose()}},[P.b,P.g,P.r,s,r,t,f,T]),C.jsx("transformNode",{name:`${h}-rod-node`,position:r.multiply(Oe(s)),setEnabled:T,scaling:new u.Vector3(s?s.scalePlane:1,s?s.scaleDepth:1,s?s.scalePlane:1),children:C.jsx("mesh",{name:`${h}-mesh`,ref:c,isPickable:!1,children:C.jsx("standardMaterial",{name:`${h}-material`,diffuseColor:new u.Color3(P.r,P.g,P.b)})})})};class qf{constructor(t){ve(this,"children",[]);ve(this,"params",{});ve(this,"ref",m.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=as.createRoot(t);console.log("create root!");const a=m.createElement(Jo,{ref:this.ref,...this.params},this.children);n.render(a)}}const Kf=(e,t)=>{const[n,a]=m.useState();return m.useEffect(()=>{a(e.props)},[e]),m.useImperativeHandle(t,()=>({update:i=>{a(i)}}),[]),n?C.jsx(e.type,{...n}):null},Qf=m.forwardRef(Kf);class jf{constructor(t,n){ve(this,"value");ve(this,"type");ve(this,"ref",m.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 m.createElement(Qf,{ref:this.ref,key:(t=this.value.id)!=null?t:0,props:this.value,type:this.type})}}function ed(e,t){return new jf(e,t)}const Bn=1e-8;function xo(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}function Va(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function $a(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}function Yt(e){return Math.hypot(e.x,e.y,e.z)}function yo(e,t){const n=Yt(e);if(n<Bn)throw new Error(`Invalid plane basis: ${t} length is zero`);return{x:e.x/n,y:e.y/n,z:e.z/n}}function Wa(e,t,n){const a=yo(t,"u axis"),i=Va(n,a),o={x:n.x-a.x*i,y:n.y-a.y*i,z:n.z-a.z*i},r=yo(o,"v axis"),l=yo($a(a,r),"plane normal");return{origin:e,uDir:a,vDir:r,normal:l}}function qo(e,t){if(!t)return e;const n=e.slice();for(let a=0;a<n.length;a+=3)n[a]+=t.x,n[a+1]+=t.y,n[a+2]+=t.z;return n}function td(e){return{vertices:qo(e.points,e.center?{x:e.center.x,y:e.center.y,z:e.center.z}:void 0),indices:e.indices,values:e.value,vMin:e.vMin,vMax:e.vMax,colorId:e.colorId}}function Ua(e){return{vertices:e.vertices,indices:e.indices,values:[],vMin:0,vMax:1,colorId:e.colorId}}function Ha(e){return{vertices:qo(e.points,e.center?{x:e.center.x,y:e.center.y,z:e.center.z}:void 0),indices:e.indices,values:e.value,vMin:e.vMin,vMax:e.vMax,colorId:e.colorId}}function nd(e){const t=e[0],n=e[1],a=e[2],i=e[3],o=e[4],r=e[5],l=e[6],s=e[7],c=e[8];return Wa({x:t,y:n,z:a},{x:i-t,y:o-n,z:r-a},{x:l-t,y:s-n,z:c-a})}function od(e){const[t,n,a,i]=e,o=xo(i,t),r=xo(n,t),l=$a(o,r),s=Yt(l);if(Yt(o)<Bn)throw new Error("Invalid planeCorners: point1 and point4 must define a non-zero edge");if(Yt(r)<Bn)throw new Error("Invalid planeCorners: point1 and point2 must define a non-zero edge");if(s<Bn)throw new Error("Invalid planeCorners: the first, second, and fourth points do not form a plane");const c=xo(a,t),p=Math.abs(Va(c,l))/s,f=Math.max(Yt(o),Yt(r),Yt(c),1);if(p>f*1e-5)throw new Error(`Invalid planeCorners: the four points are not coplanar (distance=${p})`);return Wa(t,o,r)}function Za(e,t){const n=[];for(let a=0;a<e.length;a+=3){const i=e[a]-t.origin.x,o=e[a+1]-t.origin.y,r=e[a+2]-t.origin.z;n.push({u:i*t.uDir.x+o*t.uDir.y+r*t.uDir.z,v:i*t.vDir.x+o*t.vDir.y+r*t.vDir.z})}return n}function rd(e,t){const n=[];for(const a of e)n.push(a.x,a.y,a.z);return Za(n,t)}function id(e,t,n,a,i){const o=(t.v-n.v)*(e.u-n.u)+(n.u-t.u)*(e.v-n.v);if(Math.abs(o)<1e-10)return[0,0,0,!1];const r=((t.v-n.v)*(a-n.u)+(n.u-t.u)*(i-n.v))/o,l=((n.v-e.v)*(a-n.u)+(e.u-n.u)*(i-n.v))/o,s=1-r-l;return[r,l,s,r>=-.01&&l>=-.01&&s>=-.01]}function Co(e,t,n,a){const i=a-n||1,o=Math.trunc((t-n)/i*(e.array.length-1)),r=e.array[Math.max(0,Math.min(e.array.length-1,o))];return[r.r,r.g,r.b,1]}function _o(e,t){if(t==null||!e[t])return[1,1,1,1];const n=e[t];return[n.r,n.g,n.b,n.a]}function ad(e,t,n,a,i,o){const{indices:r,values:l,vMin:s,vMax:c,colorId:p}=e,{colorCodecs:f,colorIDs:d,colorCodecKey:x}=o,h=i.data,T=!!(x&&f&&f[x]),P=T?f[x]:null;for(let v=0;v<r.length;v+=3){const _=r[v],b=r[v+1],k=r[v+2],M=a[_],w=a[b],S=a[k],N=Math.max(0,Math.floor(Math.min(M.u,w.u,S.u))),F=Math.min(t-1,Math.ceil(Math.max(M.u,w.u,S.u))),B=Math.max(0,Math.floor(Math.min(M.v,w.v,S.v))),I=Math.min(n-1,Math.ceil(Math.max(M.v,w.v,S.v)));let D,E,L;T&&P?(D=Co(P,l[_],s,c),E=Co(P,l[b],s,c),L=Co(P,l[k],s,c)):(D=_o(d!=null?d:{},p),E=_o(d!=null?d:{},p),L=_o(d!=null?d:{},p));for(let y=B;y<=I;y++)for(let A=N;A<=F;A++){const[V,$,W,ne]=id(M,w,S,A,y);if(!ne)continue;const ee=(y*t+A)*4;h[ee]=Math.round(Math.max(0,Math.min(255,(V*D[0]+$*E[0]+W*L[0])*255))),h[ee+1]=Math.round(Math.max(0,Math.min(255,(V*D[1]+$*E[1]+W*L[1])*255))),h[ee+2]=Math.round(Math.max(0,Math.min(255,(V*D[2]+$*E[2]+W*L[2])*255))),h[ee+3]=Math.round(Math.max(0,Math.min(255,(V*D[3]+$*E[3]+W*L[3])*255)))}}}function Ci(e){let t=1/0,n=-1/0,a=1/0,i=-1/0;for(const o of e)o.u<t&&(t=o.u),o.u>n&&(n=o.u),o.v<a&&(a=o.v),o.v>i&&(i=o.v);return{minU:t,maxU:n,minV:a,maxV:i}}function sd(e,t,n,a){var s,c,p;const i=(s=a.renderScale)!=null?s:1,o=(c=a.maxCanvasWidth)!=null?c:8192,r=(p=a.maxCanvasHeight)!=null?p:8192;if(a.pixelsPerUnit!=null&&a.pixelsPerUnit>0){const f=Math.max(1,Math.round(t*a.pixelsPerUnit*i)),d=Math.max(1,Math.round(n*a.pixelsPerUnit*i)),x=Math.min(o/f,r/d,1);return{width:Math.max(1,Math.round(f*x)),height:Math.max(1,Math.round(d*x))}}if(a.width!=null&&a.height!=null)return{width:Math.max(1,Math.min(o,Math.round(a.width*i))),height:Math.max(1,Math.min(r,Math.round(a.height*i)))};if(a.width!=null){const f=Math.max(1,Math.min(o,Math.round(a.width*i)));return{width:f,height:Math.max(1,Math.min(r,Math.round(f/e)))}}if(a.height!=null){const f=Math.max(1,Math.min(r,Math.round(a.height*i)));return{width:Math.max(1,Math.min(o,Math.round(f*e))),height:f}}const l=Math.max(1,Math.round(1024*i));return e>=1?{width:Math.min(o,l),height:Math.max(1,Math.min(r,Math.round(l/e)))}:{width:Math.max(1,Math.min(o,Math.round(l*e))),height:Math.min(r,l)}}function _i(e,t){var i,o;const n=(i=t.widthScale)!=null?i:1,a=(o=t.heightScale)!=null?o:1;return n===1&&a===1?e:e.map(r=>({u:r.u*n,v:r.v*a}))}function Ga(e,t){const n=e.filter(N=>N.vertices.length>=9&&N.indices.length>=3),a=n[0];if(!a)throw new Error("No valid mesh data to render");const i=t.planeCorners?od(t.planeCorners):nd(a.vertices),o=n.map(N=>({meshData:N,points2D:_i(Za(N.vertices,i),t)}));let r=1/0,l=-1/0,s=1/0,c=-1/0;if(t.planeCorners){const N=Ci(_i(rd(t.planeCorners,i),t));r=N.minU,l=N.maxU,s=N.minV,c=N.maxV}else for(const{points2D:N}of o){const F=Ci(N);F.minU<r&&(r=F.minU),F.maxU>l&&(l=F.maxU),F.minV<s&&(s=F.minV),F.maxV>c&&(c=F.maxV)}const p=l-r||1,f=c-s||1,d=p/f,{width:x,height:h}=sd(d,p,f,t);let T=x,P=h,v=0,_=0;d>x/h?(P=x/d,_=(h-P)/2):(T=h*d,v=(x-T)/2);const b=T/p,k=P/f,M=document.createElement("canvas");M.width=x,M.height=h;const w=M.getContext("2d");w.fillStyle="#fff",w.fillRect(0,0,x,h);const S=w.getImageData(0,0,x,h);for(const{meshData:N,points2D:F}of o){const B=F.map(I=>({u:(I.u-r)*b+v,v:(I.v-s)*k+_}));ad(N,x,h,B,S,t)}return w.putImageData(S,0,0),{canvas:M,imageData:S}}function Qn(e,t){return Ga([e],t)}function Ya(e,t={}){return Qn(td(e),t)}function Ja(e,t={}){var o;const n=(o=t.sliceIndex)!=null?o:0,a=e.slices[n];if(!a)throw new Error(`FormationSlices slice at index ${n} not found (total: ${e.slices.length})`);const i=Ua(a);return e.center&&(i.vertices=qo(i.vertices,{x:e.center.x,y:e.center.y,z:e.center.z})),Qn(i,t)}function ld(e,t={}){return Qn(Ua(e),t)}function Xa(e,t={}){return Qn(Ha(e),t)}function qa(e,t={}){return Ga(e.map(Ha),t)}function Ka(e,t={}){return Ya(Ho.decode(new Uint8Array(e)),t)}function Qa(e,t={}){return Ja(Go.decode(new Uint8Array(e)),t)}function ja(e,t={}){return Xa(Wt.decode(new Uint8Array(e)),t)}function es(e,t,n={}){if(kn.decode(new Uint8Array(e)).formations.length>0&&t.length===0)throw new Error("FormationGroup contains formations but no formation buffers were provided");const i=t.map(o=>Wt.decode(new Uint8Array(o)));return qa(i,n)}async function cd(e,t,n={}){const a=await fetch(e);if(!a.ok)throw new Error(`Failed to fetch slice data: ${a.status} ${a.statusText}`);const i=await a.arrayBuffer(),o=t==="density"?Ka(i,n):t==="formation"?Qa(i,n):ja(i,n),r=await ts(o.canvas);return URL.createObjectURL(r)}async function ud(e,t={}){var l;const n=await fetch(e);if(!n.ok)throw new Error(`Failed to fetch formation group data: ${n.status} ${n.statusText}`);const a=await n.arrayBuffer(),i=kn.decode(new Uint8Array(a)),o=(l=t.urlResolver)!=null?l:s=>s,r=await Promise.all(i.formations.map(async s=>{const c=await o(s.url),p=await fetch(c);if(!p.ok)throw new Error(`Failed to fetch formation data: ${c}`);return p.arrayBuffer()}));return es(a,r,t)}function ts(e){return new Promise((t,n)=>{e.toBlob(a=>{a?t(a):n(new Error("Failed to create PNG blob"))},"image/png")})}function fd(e){return e.toDataURL("image/png")}exports.PureComponents=Ot.PureComponents;exports.AttributeBody=ea;exports.AxesViewerPosition=Bt;exports.CachePreload=Ns;exports.CacheType=Me;exports.ColorCodec=ta;exports.ComplexFormationManager=oa;exports.Coordinate=ra;exports.CustomShader=lt;exports.DarkMetalMaterial=Jn;exports.DataBinding=Yf;exports.DensitySlice=Zo;exports.FPS=aa;exports.FlatMaterial=_u;exports.FormationFace=Xn;exports.FormationManager=sa;exports.FormationSlice=Yo;exports.FormationVolume=qn;exports.GUIText=Je;exports.Geo3DCamera=la;exports.Geo3DUniversalCamera=Hu;exports.Geo3DViewer=Jo;exports.GridDiagram=fa;exports.Ground=Rn;exports.HoverType=yn;exports.IntersectingLine=da;exports.LightMetalMaterial=Yn;exports.Line=Uo;exports.LoadingScreen=Ao;exports.LookAt=pa;exports.MaterialType=$e;exports.ModelLoader=Kn;exports.Optimizer=ma;exports.PlaneImage=ga;exports.PointClickZone=xa;exports.PointClickZoneObjectType=va;exports.ProgressedAttributeBody=ya;exports.ProgressedRemapColorByRedChannelMaterial=Qi;exports.ProgressedRepeatedTextureMaterial=ji;exports.RayClick=Ca;exports.RemapColorByRedChannelMaterial=Mt;exports.RepeatedTextureMaterial=Kt;exports.RibbonLayer=_a;exports.RoadWay=Pa;exports.Roam=Jf;exports.Rod=Xf;exports.ScaleMode=It;exports.Scene=qf;exports.SkyBox=Sa;exports.SpaceHeat=ka;exports.SpaceHeatObjectType=ba;exports.StructureLayer=Wo;exports.TileMap=Na;exports.TileMapMode=Ea;exports.Tube=wa;exports.TubeChart=No;exports.TubeChartLine=Ma;exports.TubeInstance=Aa;exports.TubeLayer=Io;exports.TubeMain=Ra;exports.TubeOil=Ba;exports.TubeTool=Eo;exports.Utils=Cs;exports.VoxelGrid=Da;exports.calcCompass=_s;exports.calcGUIScale=ct;exports.calcInvTransformNodeScale=wi;exports.calcTransformNodeScale=Oe;exports.canvasToPngBlob=ts;exports.canvasToPngDataUrl=fd;exports.createComponentInstance=ed;exports.renderDensitySliceFromBuffer=Ka;exports.renderDensitySliceToCanvas=Ya;exports.renderFormationFromBuffer=ja;exports.renderFormationGroupFromBuffers=es;exports.renderFormationGroupFromUrl=ud;exports.renderFormationGroupToCanvas=qa;exports.renderFormationSliceToCanvas=ld;exports.renderFormationSlicesFromBuffer=Qa;exports.renderFormationSlicesToCanvas=Ja;exports.renderFormationToCanvas=Xa;exports.renderSliceFromUrl=cd;
1352
+ }`,zf=e=>{const t=m.useRef(null),{billboardMode:n="All",zOffset:a,zOffsetUnits:r}=e,[o,i]=m.useState(),l=_e.useScene();return m.useEffect(()=>{const s=()=>{const c=l==null?void 0:l.activeCamera;i(c==null?void 0:c.getDirection(u.Vector3.Right()))};return l&&l.activeCamera&&(s(),l==null||l.activeCamera.onViewMatrixChangedObservable.add(s)),()=>{l&&l.activeCamera&&(l==null||l.activeCamera.onViewMatrixChangedObservable.removeCallback(s))}},[l]),m.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]),C.jsx(lt,{ref:t,name:e.name,backFaceCulling:!1,needDepthPrePass:e.needDepthPrePass,vertex:Df,fragment:Ff,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:u.Material.CounterClockWiseSideOrientation})},Vf=(e,t)=>{const n=_e.useScene(),a=m.useRef(null),r=m.useRef(null),o=m.useContext(Le),{id:i,visible:l=!0,vertices:s,indices:c,colors:p,uvs:f,position:d,customMaterial:x}=e,{title:h,color:T,fontSize:P}=e.style;return m.useImperativeHandle(t,()=>r.current,[]),m.useEffect(()=>{if(n&&a.current){const v=new u.VertexData;v.positions=s,v.indices=c,v.colors=p,v.uvs=f,v.applyToMesh(a.current)}},[p,x,i,c,n,f,s]),C.jsxs("transformNode",{name:`node-curve-${i}`,position:d?d.multiply(new u.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1)):new u.Vector3(0,0,0),scaling:new u.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1),ref:r,setEnabled:l,children:[C.jsx("mesh",{name:"curve",ref:a,scaling:new u.Vector3(1,1,1),children:x?C.jsx(zf,{name:`material-${i}`,billboardMode:"none"}):C.jsx("standardMaterial",{name:`material-${i}`,backFaceCulling:!1})}),C.jsx("transformNode",{name:"title",position:e.style.position?e.style.position:new u.Vector3(0,0,0),scaling:ct(o),children:h&&C.jsx(Je,{text:h,fontSize:P||40,color:T||"white"})})]})},$f=m.forwardRef(Vf),No=e=>{var E,L;const t=_e.useScene(),[n,a]=m.useState([]),[r,o]=m.useState([]),[i,l]=m.useState([]),[s,c]=m.useState([]),[p,f]=m.useState(),[d,x]=m.useState(),[h,T]=m.useState(),{colorCodecs:P}=m.useContext(Lt),{id:v,url:_,callback:b,visible:k=!0,customMaterial:M=!1,colorType:w,width:S=20,offset:N=new u.Vector3(0,0,0),direction:F="right"}=e,B=je({url:_,cacheType:Me.EXACTLY_MATCH}),I=m.useCallback((y,A,V,$,W=!0)=>{if(t){const ne=u.MeshBuilder.CreateRibbon("ribbon",{pathArray:[V,$],sideOrientation:W?u.Mesh.FRONTSIDE:u.Mesh.DOUBLESIDE},t),ee=ne.getVerticesData(u.VertexBuffer.PositionKind),G=ne.getIndices();if(ee&&G){const le=Ot.buildTubeChartColors(ee,Y=>{if(w&&P&&P[w]){const ce=y.max,ae=y.min;let X=new u.Color3(1,1,1);return ae===ae?X=P[w].array[P[w].array.length-1]:X=P[w].array[Math.trunc((y.chart[Y].value-ae)/(ce-ae)*(P[w].array.length-1))],new u.Color4(X.r,X.g,X.b,1)}return b?b(A[Y],Y,y.max,y.min):Ot.colorMapTubeChart()},W),re=[],oe=ee.length/3;for(let Y=0;Y<oe;Y++)Y>=oe/2?re.push($[Y-oe/2].x-V[Y-oe/2].x,1):re.push(0,1);a(ee.slice()),o(G.slice()),l(le),c(re)}t==null||t.removeMesh(ne)}},[b,P,w,t]);m.useEffect(()=>{var y,A,V,$,W;if(B){const ne=Ko.decode(new Uint8Array(B)),ee=S/(ne.max-ne.min),G=ne.min<0?-ne.min:0,le=F==="right"?S/2:S;console.log(ne);const re=[],oe=ne.chart.map(X=>{const Pe=X.position?X.position:{x:0,y:0,z:0};return re.push(X.value),new u.Vector3(Pe.x-le,Pe.y+10,Pe.z)}),Y=ne.chart.map(X=>{const Pe=X.position?X.position:{x:0,y:0,z:0},ge=F==="right"?(X.value+G)*ee:-(X.value+G)*ee;return new u.Vector3(Pe.x+ge-le,Pe.y+10,Pe.z)});T(ne.name),f(new u.Vector3((y=ne.origin)==null?void 0:y.x,(A=ne.origin)==null?void 0:A.y,(V=ne.origin)==null?void 0:V.z).add(N));const ce=S/2-(($=e.style)!=null&&$.fontSize?e.style.fontSize/2:0),ae=oe[oe.length-1].add(new u.Vector3(F==="right"?ce:-ce,0,0)).add((W=e.style)!=null&&W.offset?e.style.offset:new u.Vector3(0,0,0));x(new u.Vector3(ae.x,ae.y,ae.z)),I(ne,re,oe.splice(0,oe.length),Y.splice(0,Y.length),!0)}},[I,_,t,N,(E=e.style)==null?void 0:E.offset,S,(L=e.style)==null?void 0:L.fontSize,B,F]);const D=m.useCallback(()=>{},[]);return m.useEffect(()=>{const y=()=>{D()};return t&&t.activeCamera&&(y(),t==null||t.activeCamera.onViewMatrixChangedObservable.add(y)),()=>{t&&t.activeCamera&&(t==null||t.activeCamera.onViewMatrixChangedObservable.removeCallback(y))}},[D,t]),C.jsx(C.Fragment,{children:k&&n.length>0&&i.length>0&&C.jsx($f,{id:v,visible:k,vertices:n,colors:i,uvs:s,indices:r,position:p,style:{...e.style,title:h,position:d},customMaterial:M})})},Wf=e=>{const t=m.useRef(null),n=m.useContext(Le),{id:a,visible:r=!0,position:o}=e,{title:i,color:l,fontSize:s}=e.style;return C.jsx("transformNode",{name:`node-curve-${a}`,position:o?o.multiply(new u.Vector3(n?n.scalePlane:1,n?n.scaleDepth:1,n?n.scalePlane:1)):new u.Vector3(0,0,0),scaling:new u.Vector3(n?n.scalePlane:1,n?n.scaleDepth:1,n?n.scalePlane:1),ref:t,setEnabled:r,children:C.jsx("transformNode",{name:"title",position:e.style.position?e.style.position:new u.Vector3(0,0,0),scaling:ct(n),children:i&&C.jsx(Je,{text:i,fontSize:s||40,color:l||"white"})})})},Ma=e=>{var _,b;const t=_e.useScene(),[n,a]=m.useState(),[r,o]=m.useState(),[i,l]=m.useState(),[s,c]=m.useState([]),{id:p,url:f,visible:d=!0,offset:x=new u.Vector3(0,0,0),color:h,width:T=20}=e,P=je({url:f,cacheType:Me.EXACTLY_MATCH}),v=m.useContext(Le);return m.useEffect(()=>{var k,M,w,S,N,F,B,I;if(P){const D=Ko.decode(new Uint8Array(P)),E=T/(D.max-D.min),L=D.min<0?-D.min:0,y=new u.Vector3((k=D.origin)==null?void 0:k.x,(M=D.origin)==null?void 0:M.y,(w=D.origin)==null?void 0:w.z).add(x);a(y);const A=D.chart,V=[];for(let W=0;W<A.length;W++)V.push(y.add(new u.Vector3((S=A[W].position)==null?void 0:S.x,(N=A[W].position)==null?void 0:N.y,(F=A[W].position)==null?void 0:F.z)).add(new u.Vector3((A[W].value+L)*E,0,0)).multiply(Oe(v)));c([V]);const $=A[A.length-1].position;if($){const W=new u.Vector3($.x,$.y,$.z).add(new u.Vector3(T/2-((B=e.style)!=null&&B.fontSize?e.style.fontSize/2:0),0,0)).add((I=e.style)!=null&&I.offset?e.style.offset:new u.Vector3(0,0,0));o(new u.Vector3(W.x,W.y,W.z))}l(D.name)}},[f,t,x,(_=e.style)==null?void 0:_.offset,(b=e.style)==null?void 0:b.fontSize,P,v,T]),C.jsxs(C.Fragment,{children:[C.jsx(Wf,{id:p,visible:d,position:n,style:{...e.style,title:i,position:r}}),s.length>0&&C.jsx("lineSystem",{name:"line",lines:s,color:h,setEnabled:d})]})};function mi(){return{name:"",origin:void 0,layerList:[]}}const La={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.origin!==void 0&&K.encode(e.origin,t.uint32(18).fork()).ldelim();for(const n of e.layerList)gn.encode(n,t.uint32(26).fork()).ldelim();return t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=mi();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=K.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.layerList.push(gn.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:Ft(e.name)?globalThis.String(e.name):"",origin:Ft(e.origin)?K.fromJSON(e.origin):void 0,layerList:globalThis.Array.isArray(e==null?void 0:e.layerList)?e.layerList.map(t=>gn.fromJSON(t)):[]}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),e.origin!==void 0&&(t.origin=K.toJSON(e.origin)),(n=e.layerList)!=null&&n.length&&(t.layerList=e.layerList.map(a=>gn.toJSON(a))),t},create(e){return La.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=mi();return t.name=(n=e.name)!=null?n:"",t.origin=e.origin!==void 0&&e.origin!==null?K.fromPartial(e.origin):void 0,t.layerList=((a=e.layerList)==null?void 0:a.map(r=>gn.fromPartial(r)))||[],t}};function gi(){return{name:"",position:void 0,start:void 0,end:void 0,radius:0,colorId:0,v:[]}}const gn={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.position!==void 0&&K.encode(e.position,t.uint32(18).fork()).ldelim(),e.start!==void 0&&K.encode(e.start,t.uint32(26).fork()).ldelim(),e.end!==void 0&&K.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=gi();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=K.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.start=K.decode(n,n.uint32());continue;case 4:if(o!==34)break;r.end=K.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:Ft(e.name)?globalThis.String(e.name):"",position:Ft(e.position)?K.fromJSON(e.position):void 0,start:Ft(e.start)?K.fromJSON(e.start):void 0,end:Ft(e.end)?K.fromJSON(e.end):void 0,radius:Ft(e.radius)?globalThis.Number(e.radius):0,colorId:Ft(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=K.toJSON(e.position)),e.start!==void 0&&(t.start=K.toJSON(e.start)),e.end!==void 0&&(t.end=K.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 gn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o;const t=gi();return t.name=(n=e.name)!=null?n:"",t.position=e.position!==void 0&&e.position!==null?K.fromPartial(e.position):void 0,t.start=e.start!==void 0&&e.start!==null?K.fromPartial(e.start):void 0,t.end=e.end!==void 0&&e.end!==null?K.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 Ft(e){return e!=null}const Uf=(e,t)=>{const n=_e.useScene(),a=m.useRef(null),r=m.useRef(null),o=m.useContext(Le),{id:i,visible:l=!0,vertices:s,indices:c,colors:p,position:f,materialType:d="custom",children:x,alphaBlend:h=!1,alpha:T=1,name:P="tube",actions:v,slices:_}=e;m.useImperativeHandle(t,()=>r.current,[]),m.useEffect(()=>{a.current&&(a.current.metadata={pickable:v?{needWorldPosition:!0,name:P,onLeftClick:v.onLeftClick,onRightClick:v.onRightClick,onMiddleClick:v.onMiddleClick,onHover:(k,M,w,S,N)=>{var F,B,I,D,E,L;if(v.onHover&&n&&_&&w){const y=w;for(let A=0;A<_.length;A++){const V=new u.Vector3((F=_[A].start)==null?void 0:F.x,(B=_[A].start)==null?void 0:B.y,(I=_[A].start)==null?void 0:I.z).add(f).multiply(Oe(o)),$=new u.Vector3((D=_[A].end)==null?void 0:D.x,(E=_[A].end)==null?void 0:E.y,(L=_[A].end)==null?void 0:L.z).add(f).multiply(Oe(o)),W=Math.sqrt(Math.pow(V.x-$.x,2)+Math.pow(V.y-$.y,2)+Math.pow(V.z-$.z,2)),ne=new u.Vector3(V.x,V.y-W,V.z),ee=$.subtract(V),G=ne.subtract(V),le=y.subtract(V),re=u.Vector3.Cross(ee,G),oe=Math.acos(u.Vector3.Dot(ee.normalize(),G.normalize())),Y=u.Matrix.RotationAxis(re,oe),ce=u.Vector3.TransformCoordinates(le,Y);if(0>=ce.y&&-W<=ce.y){v.onHover(k,M,w,S,_[A],N);break}}}},valueCallback:null,extra:v.extra}:null})},[v,o,f,n,_]),m.useEffect(()=>{if(a&&a.current&&n){const k=new u.VertexData;k.positions=s,k.indices=c,p&&d!=="pbr-dark"&&d!=="pbr-light"&&(k.colors=p),k.applyToMesh(a.current)}},[c,s,n,p,i,d]);const b=m.useCallback(()=>{if(d==="custom")return C.jsx(lt,{name:`${P}-material-${i}`,vertex:Gn,fragment:Zn,needDepthPrePass:!1,transparencyMode:h?u.Material.MATERIAL_ALPHABLEND:u.Material.MATERIAL_OPAQUE,options:{needAlphaBlending:!!h}});if(d==="standard")return C.jsx("standardMaterial",{name:`${P}-material`,alphaMode:u.Engine.ALPHA_COMBINE,transparencyMode:h?u.Material.MATERIAL_ALPHABLEND:u.Material.MATERIAL_OPAQUE,alpha:T});if(d==="pbr-light")return C.jsx(Yn,{alpha:T});if(d==="pbr-dark")return C.jsx(Jn,{alpha:T})},[T,h,i,d,P]);return C.jsxs("transformNode",{name:`node-${P}-${i}`,setEnabled:l,children:[C.jsx("transformNode",{name:`${P}`,position:f?f.multiply(new u.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1)):new u.Vector3(0,0,0),scaling:new u.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1),ref:r,children:C.jsx("mesh",{name:`${P}-mesh`,ref:a,children:b()})}),x]})},Hf=m.forwardRef(Uf),Zf=(e,t)=>{const n=m.useRef(null),a=m.useContext(Le);m.useImperativeHandle(t,()=>n.current,[]);const{id:r,visible:o=!0,position:i,data:l,offset:s=new u.Vector3(0,0,0),color:c="white",fontSize:p=40,showLabel:f=!0}=e;return C.jsx("transformNode",{name:`node-layer-${r}`,position:i?i.add(s).multiply(new u.Vector3(a?a.scalePlane:1,a?a.scaleDepth:1,a?a.scalePlane:1)):new u.Vector3(0,0,0).add(s),scaling:new u.Vector3(a?a.scalePlane:1,a?a.scaleDepth:1,a?a.scalePlane:1),ref:n,setEnabled:o,children:f?l.map((d,x)=>C.jsx("transformNode",{name:"layer-text",position:d.position,scaling:ct(a),children:C.jsx(Je,{text:d.name,fontSize:p,color:c})},x)):C.jsx(C.Fragment,{})})},Gf=m.forwardRef(Zf),Io=e=>{var I,D,E,L,y;const t=_e.useScene(),[n,a]=m.useState([]),[r,o]=m.useState([]),[i,l]=m.useState([]),[s,c]=m.useState(),[p,f]=m.useState([]),[d,x]=m.useState(0),[h,T]=m.useState(),{colorIDs:P}=m.useContext(Lt),{id:v,url:_,color:b,layers:k=[],visible:M=!0,tessellation:w=64,frontSide:S=!1,customMaterial:N=!1,actions:F}=e,B=je({url:_,cacheType:Me.EXACTLY_MATCH});return m.useEffect(()=>{var A,V,$,W,ne,ee;if(B){const G=La.decode(new Uint8Array(B)),le=[];G.layerList.forEach((ge,H)=>{var Q,Ee,ke,te,me,ue;le.push(ge),H<G.layerList.length&&le.push({...ge,name:ge.name+"opacity",start:{x:(Ee=(Q=ge==null?void 0:ge.end)==null?void 0:Q.x)!=null?Ee:0,y:(te=(ke=ge==null?void 0:ge.end)==null?void 0:ke.y)!=null?te:0,z:(ue=(me=ge==null?void 0:ge.end)==null?void 0:me.z)!=null?ue:0}})});const re=le.map(ge=>{const H=ge.start?ge.start:{x:0,y:0,z:0};return new u.Vector3(H.x,H.y,H.z)}),oe=u.MeshBuilder.CreateTube("tube-tmp",{path:re,radiusFunction:ge=>{var Q;const H=(Q=le[ge])==null?void 0:Q.radius;return H||1},cap:u.Mesh.NO_CAP,tessellation:w,sideOrientation:S?u.Mesh.FRONTSIDE:u.Mesh.DOUBLESIDE},t),Y=oe.getVerticesData(u.VertexBuffer.PositionKind),ce=N?Ot.correctTubeMainIndices(oe.getIndices()):oe.getIndices(),ae=b;let X=[];Y&&(X=Ot.buildTubeMainColors(Y,le.map(ge=>{const H=ae||(P&&P[ge.colorId]?P[ge.colorId]:Ot.randomColorMap()),Q=k.findIndex(Ee=>Ee===ge.name)!==-1?H.a:0;return new u.Color4(H.r,H.g,H.b,Q)}),w,!!S)),T(G),a(Y?Y.slice():[]),o(ce?ce.slice():[]),l(X),c(new u.Vector3((A=G.origin)==null?void 0:A.x,(V=G.origin)==null?void 0:V.y,($=G.origin)==null?void 0:$.z)),t==null||t.removeMesh(oe);const Pe=[];for(let ge=0;ge<G.layerList.length;ge++){const H=G.layerList[ge];k.findIndex(Q=>Q===H.name)!==-1&&Pe.push({name:H.name,position:new u.Vector3((W=H.position)==null?void 0:W.x,(ne=H.position)==null?void 0:ne.y,(ee=H.position)==null?void 0:ee.z)})}f(Pe),x(G.layerList?G.layerList[0].radius:0)}},[_,t,S,w,N,k,P,B,b]),C.jsxs("transformNode",{name:`node-layer-${v}`,children:[n.length>0&&r.length>0&&C.jsx(Hf,{id:v,name:"tube-layer",visible:M,vertices:n,slices:h==null?void 0:h.layerList,indices:r,position:s,colors:i.length>0?i:void 0,materialType:N?"custom":"standard",alphaBlend:!0,actions:F}),p.length>0&&C.jsx(Gf,{id:v,data:p,visible:M,position:s,fontSize:(I=e.style)==null?void 0:I.fontSize,color:(D=e.style)==null?void 0:D.color,offset:(L=(E=e.style)==null?void 0:E.offset)==null?void 0:L.add(new u.Vector3(d,0,0)),showLabel:(y=e.style)==null?void 0:y.showLabel})]})},vi=e=>{const t=_e.useScene(),n=m.useRef(null),[a,r]=m.useState([]),[o,i]=m.useState([]),[l,s]=m.useState([]),{color:c,type:p,name:f="cap",materialType:d,tessellation:x,data:h}=e,T=m.useCallback(()=>{const v=[],_=[];for(let F=0;F<2*x+1;F++)if(p==="start")v.push(new u.Vector3(h[F*3],h[F*3+1],h[F*3+2]));else{const B=h.length-2*x*3;v.push(new u.Vector3(h[F*3+B],h[F*3+1+B],h[F*3+2+B]))}const b=[],k=[];for(let F=0;F<x;F++)b.push(v[F]),k.push(v[2*x-F-1]);_.push(b,k);const M=u.MeshBuilder.CreateRibbon("ribbon-tmp",{pathArray:_,sideOrientation:u.Mesh.DOUBLESIDE},t),w=M.getVerticesData(u.VertexBuffer.PositionKind),S=M.getIndices(),N=M.getNormalsData();r(w?w.slice():[]),i(S?S.slice():[]),s(N?N.slice():[]),t==null||t.removeMesh(M)},[t,x,p,h]);m.useEffect(()=>{T()},[T]),m.useEffect(()=>{if(n&&n.current&&t){const v=new u.VertexData;v.positions=a,v.indices=o,v.normals=l,v.applyToMesh(n.current)}},[o,a,t,l]);const P=m.useCallback(()=>d==="pbr"?C.jsx("pbrMaterial",{name:"cap-pbr-material",alpha:.8,metallic:1,roughness:.03,albedoColor:new u.Color3(248/255,163/255,151/255),emissiveColor:new u.Color3(36/255,36/255,36/255),transparencyMode:u.Material.MATERIAL_OPAQUE}):C.jsx("standardMaterial",{name:`${f}-material`,alphaMode:u.Engine.ALPHA_COMBINE,transparencyMode:u.Material.MATERIAL_OPAQUE,diffuseColor:new u.Color3(c.r,c.g,c.b)}),[c.b,c.g,c.r,d,f]);return C.jsx("mesh",{name:`${f}-mesh`,ref:n,isPickable:!0,children:P()})},Ra=e=>{const t=_e.useScene(),n=m.useRef(null),[a,r]=m.useState(u.Vector3.Zero()),[o,i]=m.useState([]),[l,s]=m.useState([]),[c,p]=m.useState([]),[f,d]=m.useState(""),[x,h]=m.useState(new u.Vector3(0,0,0)),[T,P]=m.useState([]),v=m.useContext(Le),{id:_,color:b,url:k,name:M="tube",children:w,materialType:S="standard",actions:N,tessellation:F=32,style:B}=e,I=m.useRef(!1),D=m.useCallback(L=>{var ee,G,le;const y=L.sliceList.filter(re=>!(re.v.length>0)).map(re=>{const oe=re.start?re.start:{x:0,y:0,z:0};return new u.Vector3(oe.x,oe.y,oe.z)}),A=L.sliceList[L.sliceList.length-1];if(y.length>0&&y.push(new u.Vector3((ee=A.end)==null?void 0:ee.x,(G=A.end)==null?void 0:G.y,(le=A.end)==null?void 0:le.z)),y.length<1)return;const V=u.MeshBuilder.ExtrudeShape("tmp",{path:y,sideOrientation:u.Mesh.DOUBLESIDE,shape:Ot.buildSemiRing(A.innerRadius,A.radius,F),cap:u.Mesh.NO_CAP},t);P(V.getVerticesData(u.VertexBuffer.PositionKind)),V.convertToFlatShadedMesh(),V.computeWorldMatrix(!0),V._updateBoundingInfo();const $=V.getVerticesData(u.VertexBuffer.PositionKind),W=V.getIndices(),ne=V.getNormalsData();i($?$.slice():[]),s(W?W.slice():[]),p(ne?ne.slice():[]),t==null||t.removeMesh(V)},[t,F]);m.useEffect(()=>{I.current||(I.current=!0,Ut.get(k,{responseType:"arraybuffer"}).then(L=>{var V,$,W;const y=Nt.decode(new Uint8Array(L.data));if(console.log(y),y.sliceList.length===0)return;d(y.name);const A=B!=null&&B.basePosition&&B.basePosition==="top"?y.sliceList[0].start:y.sliceList[y.sliceList.length-1].end;h(new u.Vector3(A==null?void 0:A.x,A==null?void 0:A.y,A==null?void 0:A.z)),r(new u.Vector3((V=y.origin)==null?void 0:V.x,($=y.origin)==null?void 0:$.y,(W=y.origin)==null?void 0:W.z)),D(y)}))},[D,B==null?void 0:B.basePosition,k]),m.useEffect(()=>{if(n&&n.current&&t){const L=new u.VertexData;L.positions=o,L.indices=l,L.normals=c,L.applyToMesh(n.current)}},[l,o,t,c]),m.useEffect(()=>{n.current&&(n.current.metadata={pickable:N?{name:M,value:_,onLeftClick:N.onLeftClick,valueCallback:()=>_,onRightClick:N.onRightClick,onMiddleClick:N.onMiddleClick,onHover:N.onHover,needWorldPosition:N.needWorldPosition}:null})},[N,_,v,M,a,t]);const E=m.useCallback(()=>S==="pbr"?C.jsx("pbrMaterial",{name:"main-pbr-material",alpha:1,metallic:1,roughness:.03,albedoColor:new u.Color3(230/255,230/255,230/255),emissiveColor:new u.Color3(71/255,71/255,71/255),transparencyMode:u.Material.MATERIAL_OPAQUE}):C.jsx("standardMaterial",{name:`${M}-material`,alphaMode:u.Engine.ALPHA_COMBINE,transparencyMode:u.Material.MATERIAL_OPAQUE,diffuseColor:new u.Color3(b.r,b.g,b.b)}),[b.b,b.g,b.r,S,M]);return C.jsxs("transformNode",{name:`${M}-main-node`,position:a.multiply(Oe(v)),scaling:Oe(v),children:[C.jsx("mesh",{name:`${M}-mesh`,ref:n,isPickable:!0,children:E()}),T.length>0&&C.jsx(vi,{id:1,name:"start",color:b,type:"start",tessellation:F,data:T,materialType:S}),T.length>0&&C.jsx(vi,{id:2,name:"end",color:b,type:"end",tessellation:F,data:T,materialType:S}),B&&C.jsx(Ia,{id:_,style:{title:f,position:x,offset:B.offset,fontSize:B.fontSize,color:B.color}}),w]})},Ba=e=>{const{id:t,visible:n=!0,children:a,offset:r=new u.Vector3(0,0,0)}=e;return C.jsx(C.Fragment,{children:C.jsx("transformNode",{name:`tube-${t}`,setEnabled:n,position:r,children:a})})};function xi(){return{name:"",origin:void 0,dataPoints:[],size:void 0}}const Fa={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.origin!==void 0&&K.encode(e.origin,t.uint32(18).fork()).ldelim();for(const n of e.dataPoints)vn.encode(n,t.uint32(26).fork()).ldelim();return e.size!==void 0&&K.encode(e.size,t.uint32(34).fork()).ldelim(),t},decode(e,t){const n=e instanceof se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=xi();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=K.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.dataPoints.push(vn.decode(n,n.uint32()));continue;case 4:if(o!==34)break;r.size=K.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:zt(e.name)?globalThis.String(e.name):"",origin:zt(e.origin)?K.fromJSON(e.origin):void 0,dataPoints:globalThis.Array.isArray(e==null?void 0:e.dataPoints)?e.dataPoints.map(t=>vn.fromJSON(t)):[],size:zt(e.size)?K.fromJSON(e.size):void 0}},toJSON(e){var n;const t={};return e.name!==""&&(t.name=e.name),e.origin!==void 0&&(t.origin=K.toJSON(e.origin)),(n=e.dataPoints)!=null&&n.length&&(t.dataPoints=e.dataPoints.map(a=>vn.toJSON(a))),e.size!==void 0&&(t.size=K.toJSON(e.size)),t},create(e){return Fa.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=xi();return t.name=(n=e.name)!=null?n:"",t.origin=e.origin!==void 0&&e.origin!==null?K.fromPartial(e.origin):void 0,t.dataPoints=((a=e.dataPoints)==null?void 0:a.map(r=>vn.fromPartial(r)))||[],t.size=e.size!==void 0&&e.size!==null?K.fromPartial(e.size):void 0,t}};function yi(){return{point:void 0,colorId:0,vScale:0,rotation:void 0,pointType:0}}const vn={encode(e,t=se.Writer.create()){return e.point!==void 0&&K.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&&K.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=yi();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.point=K.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=K.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:zt(e.point)?K.fromJSON(e.point):void 0,colorId:zt(e.colorId)?globalThis.Number(e.colorId):0,vScale:zt(e.vScale)?globalThis.Number(e.vScale):0,rotation:zt(e.rotation)?K.fromJSON(e.rotation):void 0,pointType:zt(e.pointType)?globalThis.Number(e.pointType):0}},toJSON(e){const t={};return e.point!==void 0&&(t.point=K.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=K.toJSON(e.rotation)),e.pointType!==0&&(t.pointType=Math.round(e.pointType)),t},create(e){return vn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=yi();return t.point=e.point!==void 0&&e.point!==null?K.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?K.fromPartial(e.rotation):void 0,t.pointType=(r=e.pointType)!=null?r:0,t}};function zt(e){return e!=null}const Yf=[0,.05,.1,.15,.2,.25,.3,.35,.4,.45,.5,.55,.6,.65,.7,.75,.8,.85,.9,.95,1],Da=({url:e,alpha:t={typeAlpha0:1,typeAlpha1:1},offset:n=u.Vector3.Zero(),visible:a=!0})=>{const r=_e.useScene(),o=m.useContext(Le),i=m.useContext(Lt),[l,s]=m.useState(""),[c,p]=m.useState(u.Vector3.Zero()),f=je({url:e,cacheType:Me.URL_PREFIX_MATCH}),d=m.useRef(null),x=m.useRef(null);m.useEffect(()=>{console.log("[Geo3DViewer] VoxelGrid Loading: ",e)},[e]);const h=T=>Yf[T];return m.useEffect(()=>{if(r&&f){const T=Fa.decode(new Uint8Array(f)),{name:P,origin:v,dataPoints:_,size:b}=T;if(v&&_){s(P),p(new u.Vector3(v.x,v.y,v.z));let k=null;b&&(k=u.MeshBuilder.CreateBox("voxel",{width:b.x-1e-5,height:b.y-1e-5,depth:b.z-1e-5},r),k.material=d.current,u.Tags.EnableFor(k),u.Tags.AddTagsTo(k,"loading"));const M=new Float32Array(_.length*16),w=new Float32Array(_.length*4);return _.forEach((S,N)=>{if(S.point){const F=new u.Vector3(S.point.x,S.point.y,S.point.z),B=S.rotation?u.Quaternion.FromEulerAngles(S.rotation.x,S.rotation.y,S.rotation.z):u.Quaternion.Identity(),I=new u.Vector3(S.vScale+1,S.vScale+1,S.vScale+1);u.Matrix.Compose(I,B,F).copyToArray(M,N*16);let E=i.colorIDs[S.colorId];E||(E=u.Color4.FromColor3(u.Color3.Random())),w.set([E.r,E.g,E.b,h(S.pointType)],N*4)}}),k&&(k.thinInstanceSetBuffer("matrix",M),k.thinInstanceSetBuffer("color",w,4),k.parent=x.current),u.Tags.RemoveTagsFrom(k,"loading"),()=>{k&&(k.thinInstanceSetBuffer("matrix",new Float32Array),k.thinInstanceSetBuffer("color",new Float32Array),r.removeMesh(k))}}}},[i.colorIDs,r,f]),C.jsx("transformNode",{setEnabled:a,name:`transform-voxel-${l}`,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 u.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1),ref:x,children:C.jsx(Nu,{name:`voxel-${l}-mat`,typeAlpha:t,ref:d})})},Jf=(e,t)=>{const{viewer:n,camera:a,useUniversalCamera:r=!1,lights:o,complexFormationManagers:i,formationManagers:l,formationFaces:s,formationVolumes:c,structureLayers:p,colorCodec:f,gridDiagrams:d,attributeBodies:x,tubes:h,roadways:T,densitySlices:P,formationSlices:v,rayClick:_,lines:b,spaceHeats:k,lookAt:M,fps:w,coordinate:S,tileMaps:N,pointClickZones:F,progressedAttributeBodies:B,ribbonLayers:I,intersectingLines:D,tubeInstances:E,optimizer:L,voxelGrids:y,planeImages:A,guiTexts:V,skybox:$,particleSystems:W,waterEffects:ne,modelLoaders:ee,modelAnimationLoaders:G,roadwayAnimations:le,roadwayNearAnimations:re,roadwayWaterAnimations:oe,contourlines:Y,tubeTools:ce,tubeOils:ae,tubeLayers:X,tubeChartLines:Pe,tubeCharts:ge}=e;return C.jsxs(qo,{...n,ref:t,children:[r?C.jsx(Ju,{...a}):C.jsx(la,{...a}),o?o.map((H,Q)=>C.jsx("hemisphericLight",{...H,name:`extra-light-${Q}`},`extra-light-${Q}`)):C.jsx(C.Fragment,{}),i?i.map(H=>C.jsx(oa,{...H},`complexFormationManager-${H.url}`)):C.jsx(C.Fragment,{}),P?P.map(H=>C.jsx(Yo,{...H},`densitySlice-${H.url}`)):C.jsx(C.Fragment,{}),v?v.map(H=>C.jsx(Xo,{...H},`formationSlice-${H.url}`)):C.jsx(C.Fragment,{}),l?l.map(H=>C.jsx(sa,{...H},`formationManager-${H.url}`)):C.jsx(C.Fragment,{}),s?s.map(H=>C.jsx(Xn,{...H},`formation-face-${H.urlTopLayer}`)):C.jsx(C.Fragment,{}),c?c.map(H=>C.jsx(qn,{...H},`formation-volume-${H.url}`)):C.jsx(C.Fragment,{}),p?p.map(H=>C.jsx(Ho,{...H},`structurelayer-${H.url}`)):C.jsx(C.Fragment,{}),f?C.jsx(ta,{...f}):C.jsx(C.Fragment,{}),d?d.map(H=>C.jsx(fa,{...H},`gridDiagram-${H.url}`)):C.jsx(C.Fragment,{}),x?x.map(H=>C.jsx(ea,{...H},`attributebody-${H.url}`)):C.jsx(C.Fragment,{}),h?h.map(H=>C.jsxs(wa,{...H,children:[H.charts?H.charts.map(Q=>C.jsx(No,{...Q},`tubechart-${Q.url}`)):C.jsx(C.Fragment,{}),H.layers?H.layers.map(Q=>C.jsx(Io,{...Q},`tubelayer-${Q.url}`)):C.jsx(C.Fragment,{}),H.tools?H.tools.map(Q=>C.jsx(Eo,{...Q},`tubelayer-${Q.name}`)):C.jsx(C.Fragment,{})]},`tube-${H.url}`)):C.jsx(C.Fragment,{}),T?T.map(H=>C.jsx(Pa,{...H},`roadway-${H.url}`)):C.jsx(C.Fragment,{}),_?_.map((H,Q)=>C.jsx(Ca,{...H},`rayclick-${Q}`)):C.jsx(C.Fragment,{}),b?b.map((H,Q)=>C.jsx(Zo,{...H},`line-${Q}`)):C.jsx(C.Fragment,{}),k?k.map((H,Q)=>C.jsx(ka,{...H},`spaceheat-${Q}`)):C.jsx(C.Fragment,{}),M?C.jsx(pa,{target:void 0,distance:0}):C.jsx(C.Fragment,{}),w?C.jsx(aa,{}):C.jsx(C.Fragment,{}),S?C.jsx(ra,{...S},"coordinate"):C.jsx(C.Fragment,{}),N?N.map((H,Q)=>C.jsx(Na,{...H},`tilemap-${Q}`)):C.jsx(C.Fragment,{}),F?F.map((H,Q)=>C.jsx(xa,{...H},`pointClickZone-${Q}`)):C.jsx(C.Fragment,{}),B?B.map((H,Q)=>C.jsx(ya,{...H},`progressedAttributeBody-${Q}`)):C.jsx(C.Fragment,{}),I?I.map((H,Q)=>C.jsx(_a,{...H},`ribbonlayer-${Q}`)):C.jsx(C.Fragment,{}),D?D.map((H,Q)=>C.jsx(da,{...H},`intersectingLine-${Q}`)):C.jsx(C.Fragment,{}),E?E.map((H,Q)=>C.jsx(Aa,{...H},`tubeinstance-${Q}`)):C.jsx(C.Fragment,{}),L?C.jsx(ma,{}):C.jsx(C.Fragment,{}),y?y.map((H,Q)=>C.jsx(Da,{...H},`voxelgrid-${Q}`)):C.jsx(C.Fragment,{}),A?A.map((H,Q)=>C.jsx(ga,{...H},`planeimage-${Q}`)):C.jsx(C.Fragment,{}),V?V.map((H,Q)=>C.jsx(Hu,{...H},`guitext-${Q}`)):C.jsx(C.Fragment,{}),$&&C.jsx(Sa,{...$}),W?W.map((H,Q)=>C.jsx(ff,{...H},`particlesystem-${Q}`)):C.jsx(C.Fragment,{}),ne?ne.map((H,Q)=>C.jsx(df,{...H},`waterEffect-${Q}`)):C.jsx(C.Fragment,{}),ee?ee.map((H,Q)=>C.jsx(Kn,{...H},`modelLoaders-${Q}`)):C.jsx(C.Fragment,{}),G?G.map((H,Q)=>C.jsx(uf,{...H},`modelanimtionloader-${Q}`)):C.jsx(C.Fragment,{}),le?le.map((H,Q)=>C.jsx(Rn,{...H,children:C.jsx(_f,{})},`animation-${Q}`)):C.jsx(C.Fragment,{}),re?re.map((H,Q)=>C.jsx(Rn,{...H,children:C.jsx(Tf,{roadwayWidth:H.roadwayWidth,textureLength:H.textureLength,url:H.imageUrl,isBlink:H.isBlink,visible:H.visible})},`animation-${Q}`)):C.jsx(C.Fragment,{}),oe?oe.map((H,Q)=>C.jsx(Rn,{...H,children:C.jsx(Ef,{timeSpeed:H.timeSpeed,perlinMultiply:H.perlinMultiply,waterFlow:H.waterFlow,clippedHeight:H.clippedHeight,alpha:H.alpha,colorSteps:H.colorSteps,speed:H.speed})},`animation-${Q}`)):C.jsx(C.Fragment,{}),Y?Y.map((H,Q)=>C.jsx(zu,{...H},`contourline-${Q}`)):C.jsx(C.Fragment,{}),ce?ce.map((H,Q)=>C.jsx(Eo,{...H},`tubeTool-${Q}`)):C.jsx(C.Fragment,{}),ae?ae.map((H,Q)=>C.jsx(Ba,{...H,children:H.main?H.main.map((Ee,ke)=>C.jsx(Ra,{...Ee},`tubeMain-${ke}`)):null},`tubeOil-${Q}`)):C.jsx(C.Fragment,{}),X?X.map((H,Q)=>C.jsx(Io,{...H},`tubeLayer-${Q}`)):C.jsx(C.Fragment,{}),Pe?Pe.map((H,Q)=>C.jsx(Ma,{...H},`tubeChartLine-${Q}`)):C.jsx(C.Fragment,{}),ge?ge.map((H,Q)=>C.jsx(No,{...H},`tubeChart-${Q}`)):C.jsx(C.Fragment,{})]})},Xf=m.forwardRef(Jf),qf=e=>{const t=_e.useScene(),n=m.useRef(null),{keyFrames:a,speed:r}=e;return m.useEffect(()=>{if(t&&n.current&&n.current.animations.length===0){const o=new u.Animation("roam","position",40,u.Animation.ANIMATIONTYPE_VECTOR3,u.Animation.ANIMATIONLOOPMODE_CONSTANT);for(let i=0;i<a.length;i++)i!==a.length-1&&o.addEvent(new u.AnimationEvent(a[i].frame,()=>{var l;(l=n.current)==null||l.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]),C.jsxs(C.Fragment,{children:[C.jsx("freeCamera",{name:"roam-camera",position:new u.Vector3(0,0,0),ref:n}),C.jsx("lines",{name:"",points:a.map(o=>o.value)}),a.map((o,i)=>C.jsx("sphere",{name:"roam-sphere-"+i,diameter:1,position:o.value,children:C.jsx("standardMaterial",{name:"roam-sphere-mat",diffuseColor:u.Color3.Red(),specularColor:u.Color3.Black(),alpha:1})},i))]})};function Ci(){return{name:"",origin:void 0,type:"",sliceList:[],vertices:[],normals:[],indices:[],uv:[]}}const za={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name),e.origin!==void 0&&K.encode(e.origin,t.uint32(18).fork()).ldelim(),e.type!==""&&t.uint32(26).string(e.type);for(const n of e.sliceList)xn.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=Ci();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=K.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(xn.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:xt(e.name)?globalThis.String(e.name):"",origin:xt(e.origin)?K.fromJSON(e.origin):void 0,type:xt(e.type)?globalThis.String(e.type):"",sliceList:globalThis.Array.isArray(e==null?void 0:e.sliceList)?e.sliceList.map(t=>xn.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=K.toJSON(e.origin)),e.type!==""&&(t.type=e.type),(n=e.sliceList)!=null&&n.length&&(t.sliceList=e.sliceList.map(l=>xn.toJSON(l))),(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 za.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,l,s;const t=Ci();return t.name=(n=e.name)!=null?n:"",t.origin=e.origin!==void 0&&e.origin!==null?K.fromPartial(e.origin):void 0,t.type=(a=e.type)!=null?a:"",t.sliceList=((r=e.sliceList)==null?void 0:r.map(c=>xn.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=((l=e.indices)==null?void 0:l.map(c=>c))||[],t.uv=((s=e.uv)==null?void 0:s.map(c=>c))||[],t}};function _i(){return{position:void 0,start:void 0,end:void 0,color:void 0,angle:0,radius:0,bottomRadius:0,texture:"",v:[]}}const xn={encode(e,t=se.Writer.create()){e.position!==void 0&&K.encode(e.position,t.uint32(10).fork()).ldelim(),e.start!==void 0&&K.encode(e.start,t.uint32(18).fork()).ldelim(),e.end!==void 0&&K.encode(e.end,t.uint32(26).fork()).ldelim(),e.color!==void 0&&ot.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 se.Reader?e:se.Reader.create(e);let a=t===void 0?n.len:n.pos+t;const r=_i();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.position=K.decode(n,n.uint32());continue;case 2:if(o!==18)break;r.start=K.decode(n,n.uint32());continue;case 3:if(o!==26)break;r.end=K.decode(n,n.uint32());continue;case 4:if(o!==34)break;r.color=ot.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:xt(e.position)?K.fromJSON(e.position):void 0,start:xt(e.start)?K.fromJSON(e.start):void 0,end:xt(e.end)?K.fromJSON(e.end):void 0,color:xt(e.color)?ot.fromJSON(e.color):void 0,angle:xt(e.angle)?globalThis.Number(e.angle):0,radius:xt(e.radius)?globalThis.Number(e.radius):0,bottomRadius:xt(e.bottomRadius)?globalThis.Number(e.bottomRadius):0,texture:xt(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=K.toJSON(e.position)),e.start!==void 0&&(t.start=K.toJSON(e.start)),e.end!==void 0&&(t.end=K.toJSON(e.end)),e.color!==void 0&&(t.color=ot.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 xn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=_i();return t.position=e.position!==void 0&&e.position!==null?K.fromPartial(e.position):void 0,t.start=e.start!==void 0&&e.start!==null?K.fromPartial(e.start):void 0,t.end=e.end!==void 0&&e.end!==null?K.fromPartial(e.end):void 0,t.color=e.color!==void 0&&e.color!==null?ot.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(l=>l))||[],t}};function xt(e){return e!=null}const Kf=e=>{const t=_e.useScene(),[n,a]=m.useState([]),[r,o]=m.useState([]),[i,l]=m.useState(u.Vector3.Zero()),s=m.useContext(Le),c=m.useRef(null),p=m.useRef(!1),[f,d]=m.useState([]),{url:x,name:h="rod",visible:T=!0,color:P}=e,v=m.useCallback(_=>{var N,F,B;const b=_.sliceList.filter(I=>!(I.v.length>0)).map(I=>{const D=I.start?I.start:{x:0,y:0,z:0};return new u.Vector3(D.x,D.y,D.z)}),k=_.sliceList[_.sliceList.length-1];if(b.length>0&&b.push(new u.Vector3((N=k.end)==null?void 0:N.x,(F=k.end)==null?void 0:F.y,(B=k.end)==null?void 0:B.z)),b.length<1)return;const M=u.MeshBuilder.CreateTube("tube-tmp",{path:b,radiusFunction:I=>{if(e.radius)return e.radius;const D=_.sliceList[I]?_.sliceList[I].radius:_.sliceList[I-1].radius;return D||1},cap:u.Mesh.CAP_ALL,tessellation:24,sideOrientation:u.Mesh.FRONTSIDE},t),w=M.getVerticesData(u.VertexBuffer.PositionKind),S=M.getIndices();a(w?w.slice():[]),o(S?S.slice():[]),t==null||t.removeMesh(M)},[e.radius,t]);return m.useEffect(()=>{p.current||(p.current=!0,Ut.get(x,{responseType:"arraybuffer"}).then(_=>{var k,M,w;const b=za.decode(new Uint8Array(_.data));b.sliceList.length!==0&&(d(b.sliceList),l(new u.Vector3((k=b.origin)==null?void 0:k.x,(M=b.origin)==null?void 0:M.y,(w=b.origin)==null?void 0:w.z)),console.log(b),v(b))}))},[v,x]),m.useEffect(()=>{if(c&&c.current&&t){const _=new u.VertexData;_.positions=n,_.indices=r,_.applyToMesh(c.current)}},[r,n,t]),m.useEffect(()=>{var b,k,M;let _;if(f.length>0&&t){_=u.MeshBuilder.CreateSphere("top",{diameter:f[0].bottomRadius*2,segments:32},t);const w=new u.StandardMaterial("myMaterial",t);_.material=w,_.setEnabled(!1),w.diffuseColor=new u.Color3(P.r,P.g,P.b);for(let S=0;S<f.length;S++){const N=f[S],F=_.createInstance("tubeinstance-sphere-"+S);F.setEnabled(T);const B=i.multiply(Oe(s));F.position=B.add(new u.Vector3((b=N.position)==null?void 0:b.x,(k=N.position)==null?void 0:k.y,(M=N.position)==null?void 0:M.z).multiply(Oe(s)))}}return()=>{_&&_.dispose()}},[P.b,P.g,P.r,s,i,t,f,T]),C.jsx("transformNode",{name:`${h}-rod-node`,position:i.multiply(Oe(s)),setEnabled:T,scaling:new u.Vector3(s?s.scalePlane:1,s?s.scaleDepth:1,s?s.scalePlane:1),children:C.jsx("mesh",{name:`${h}-mesh`,ref:c,isPickable:!1,children:C.jsx("standardMaterial",{name:`${h}-material`,diffuseColor:new u.Color3(P.r,P.g,P.b)})})})};class Qf{constructor(t){ve(this,"children",[]);ve(this,"params",{});ve(this,"ref",m.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=ls.createRoot(t);console.log("create root!");const a=m.createElement(qo,{ref:this.ref,...this.params},this.children);n.render(a)}}const jf=(e,t)=>{const[n,a]=m.useState();return m.useEffect(()=>{a(e.props)},[e]),m.useImperativeHandle(t,()=>({update:r=>{a(r)}}),[]),n?C.jsx(e.type,{...n}):null},ed=m.forwardRef(jf);class td{constructor(t,n){ve(this,"value");ve(this,"type");ve(this,"ref",m.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 m.createElement(ed,{ref:this.ref,key:(t=this.value.id)!=null?t:0,props:this.value,type:this.type})}}function nd(e,t){return new td(e,t)}const Bn=1e-8;function xo(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}function Va(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function $a(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}function Yt(e){return Math.hypot(e.x,e.y,e.z)}function yo(e,t){const n=Yt(e);if(n<Bn)throw new Error(`Invalid plane basis: ${t} length is zero`);return{x:e.x/n,y:e.y/n,z:e.z/n}}function Wa(e,t,n){const a=yo(t,"u axis"),r=Va(n,a),o={x:n.x-a.x*r,y:n.y-a.y*r,z:n.z-a.z*r},i=yo(o,"v axis"),l=yo($a(a,i),"plane normal");return{origin:e,uDir:a,vDir:i,normal:l}}function Qo(e,t){if(!t)return e;const n=e.slice();for(let a=0;a<n.length;a+=3)n[a]+=t.x,n[a+1]+=t.y,n[a+2]+=t.z;return n}function od(e){return{vertices:Qo(e.points,e.center?{x:e.center.x,y:e.center.y,z:e.center.z}:void 0),indices:e.indices,values:e.value,vMin:e.vMin,vMax:e.vMax,colorId:e.colorId}}function Ua(e){return{vertices:e.vertices,indices:e.indices,values:[],vMin:0,vMax:1,colorId:e.colorId}}function Ha(e){return{vertices:Qo(e.points,e.center?{x:e.center.x,y:e.center.y,z:e.center.z}:void 0),indices:e.indices,values:e.value,vMin:e.vMin,vMax:e.vMax,colorId:e.colorId}}function rd(e){const t=e[0],n=e[1],a=e[2],r=e[3],o=e[4],i=e[5],l=e[6],s=e[7],c=e[8];return Wa({x:t,y:n,z:a},{x:r-t,y:o-n,z:i-a},{x:l-t,y:s-n,z:c-a})}function Za(e){const[t,n,a,r]=e,o=xo(r,t),i=xo(n,t),l=$a(o,i),s=Yt(l);if(Yt(o)<Bn)throw new Error("Invalid planeCorners: point1 and point4 must define a non-zero edge");if(Yt(i)<Bn)throw new Error("Invalid planeCorners: point1 and point2 must define a non-zero edge");if(s<Bn)throw new Error("Invalid planeCorners: the first, second, and fourth points do not form a plane");const c=xo(a,t),p=Math.abs(Va(c,l))/s,f=Math.max(Yt(o),Yt(i),Yt(c),1);if(p>f*1e-5)throw new Error(`Invalid planeCorners: the four points are not coplanar (distance=${p})`);return Wa(t,o,i)}function Ga(e,t){const n=[];for(let a=0;a<e.length;a+=3){const r=e[a]-t.origin.x,o=e[a+1]-t.origin.y,i=e[a+2]-t.origin.z;n.push({u:r*t.uDir.x+o*t.uDir.y+i*t.uDir.z,v:r*t.vDir.x+o*t.vDir.y+i*t.vDir.z})}return n}function Ya(e,t){const n=[];for(const a of e)n.push(a.x,a.y,a.z);return Ga(n,t)}function id(e,t,n,a,r){const o=(t.v-n.v)*(e.u-n.u)+(n.u-t.u)*(e.v-n.v);if(Math.abs(o)<1e-10)return[0,0,0,!1];const i=((t.v-n.v)*(a-n.u)+(n.u-t.u)*(r-n.v))/o,l=((n.v-e.v)*(a-n.u)+(e.u-n.u)*(r-n.v))/o,s=1-i-l;return[i,l,s,i>=-.01&&l>=-.01&&s>=-.01]}function Co(e,t,n,a){const r=a-n||1,o=Math.trunc((t-n)/r*(e.array.length-1)),i=e.array[Math.max(0,Math.min(e.array.length-1,o))];return[i.r,i.g,i.b,1]}function _o(e,t){if(t==null||!e[t])return[1,1,1,1];const n=e[t];return[n.r,n.g,n.b,n.a]}function ad(e,t,n,a,r,o){const{indices:i,values:l,vMin:s,vMax:c,colorId:p}=e,{colorCodecs:f,colorIDs:d,colorCodecKey:x}=o,h=r.data,T=!!(x&&f&&f[x]),P=T?f[x]:null;for(let v=0;v<i.length;v+=3){const _=i[v],b=i[v+1],k=i[v+2],M=a[_],w=a[b],S=a[k],N=Math.max(0,Math.floor(Math.min(M.u,w.u,S.u))),F=Math.min(t-1,Math.ceil(Math.max(M.u,w.u,S.u))),B=Math.max(0,Math.floor(Math.min(M.v,w.v,S.v))),I=Math.min(n-1,Math.ceil(Math.max(M.v,w.v,S.v)));let D,E,L;T&&P?(D=Co(P,l[_],s,c),E=Co(P,l[b],s,c),L=Co(P,l[k],s,c)):(D=_o(d!=null?d:{},p),E=_o(d!=null?d:{},p),L=_o(d!=null?d:{},p));for(let y=B;y<=I;y++)for(let A=N;A<=F;A++){const[V,$,W,ne]=id(M,w,S,A,y);if(!ne)continue;const ee=(y*t+A)*4;h[ee]=Math.round(Math.max(0,Math.min(255,(V*D[0]+$*E[0]+W*L[0])*255))),h[ee+1]=Math.round(Math.max(0,Math.min(255,(V*D[1]+$*E[1]+W*L[1])*255))),h[ee+2]=Math.round(Math.max(0,Math.min(255,(V*D[2]+$*E[2]+W*L[2])*255))),h[ee+3]=Math.round(Math.max(0,Math.min(255,(V*D[3]+$*E[3]+W*L[3])*255)))}}}function wo(e){let t=1/0,n=-1/0,a=1/0,r=-1/0;for(const o of e)o.u<t&&(t=o.u),o.u>n&&(n=o.u),o.v<a&&(a=o.v),o.v>r&&(r=o.v);return{minU:t,maxU:n,minV:a,maxV:r}}function sd(e,t={}){const n=Za(e),a=Oo(Ya(e,n),t),r=wo(a);return{basis:n,points2D:a,bounds:r,width:r.maxU-r.minU,height:r.maxV-r.minV}}function ld(e,t,n,a){var s,c,p;const r=(s=a.renderScale)!=null?s:1,o=(c=a.maxCanvasWidth)!=null?c:8192,i=(p=a.maxCanvasHeight)!=null?p:8192;if(a.pixelsPerUnit!=null&&a.pixelsPerUnit>0){const f=Math.max(1,Math.round(t*a.pixelsPerUnit*r)),d=Math.max(1,Math.round(n*a.pixelsPerUnit*r)),x=Math.min(o/f,i/d,1);return{width:Math.max(1,Math.round(f*x)),height:Math.max(1,Math.round(d*x))}}if(a.width!=null&&a.height!=null)return{width:Math.max(1,Math.min(o,Math.round(a.width*r))),height:Math.max(1,Math.min(i,Math.round(a.height*r)))};if(a.width!=null){const f=Math.max(1,Math.min(o,Math.round(a.width*r)));return{width:f,height:Math.max(1,Math.min(i,Math.round(f/e)))}}if(a.height!=null){const f=Math.max(1,Math.min(i,Math.round(a.height*r)));return{width:Math.max(1,Math.min(o,Math.round(f*e))),height:f}}const l=Math.max(1,Math.round(1024*r));return e>=1?{width:Math.min(o,l),height:Math.max(1,Math.min(i,Math.round(l/e)))}:{width:Math.max(1,Math.min(o,Math.round(l*e))),height:Math.min(i,l)}}function Oo(e,t){var r,o;const n=(r=t.widthScale)!=null?r:1,a=(o=t.heightScale)!=null?o:1;return n===1&&a===1?e:e.map(i=>({u:i.u*n,v:i.v*a}))}function Ja(e,t){const n=e.filter(N=>N.vertices.length>=9&&N.indices.length>=3),a=n[0];if(!a)throw new Error("No valid mesh data to render");const r=t.planeCorners?Za(t.planeCorners):rd(a.vertices),o=n.map(N=>({meshData:N,points2D:Oo(Ga(N.vertices,r),t)}));let i=1/0,l=-1/0,s=1/0,c=-1/0;if(t.planeCorners){const N=wo(Oo(Ya(t.planeCorners,r),t));i=N.minU,l=N.maxU,s=N.minV,c=N.maxV}else for(const{points2D:N}of o){const F=wo(N);F.minU<i&&(i=F.minU),F.maxU>l&&(l=F.maxU),F.minV<s&&(s=F.minV),F.maxV>c&&(c=F.maxV)}const p=l-i||1,f=c-s||1,d=p/f,{width:x,height:h}=ld(d,p,f,t);let T=x,P=h,v=0,_=0;d>x/h?(P=x/d,_=(h-P)/2):(T=h*d,v=(x-T)/2);const b=T/p,k=P/f,M=document.createElement("canvas");M.width=x,M.height=h;const w=M.getContext("2d");w.fillStyle="#fff",w.fillRect(0,0,x,h);const S=w.getImageData(0,0,x,h);for(const{meshData:N,points2D:F}of o){const B=F.map(I=>({u:(I.u-i)*b+v,v:(I.v-s)*k+_}));ad(N,x,h,B,S,t)}return w.putImageData(S,0,0),{canvas:M,imageData:S}}function Qn(e,t){return Ja([e],t)}function Xa(e,t={}){return Qn(od(e),t)}function qa(e,t={}){var o;const n=(o=t.sliceIndex)!=null?o:0,a=e.slices[n];if(!a)throw new Error(`FormationSlices slice at index ${n} not found (total: ${e.slices.length})`);const r=Ua(a);return e.center&&(r.vertices=Qo(r.vertices,{x:e.center.x,y:e.center.y,z:e.center.z})),Qn(r,t)}function cd(e,t={}){return Qn(Ua(e),t)}function Ka(e,t={}){return Qn(Ha(e),t)}function Qa(e,t={}){return Ja(e.map(Ha),t)}function ja(e,t={}){return Xa(Go.decode(new Uint8Array(e)),t)}function es(e,t={}){return qa(Jo.decode(new Uint8Array(e)),t)}function ts(e,t={}){return Ka(Wt.decode(new Uint8Array(e)),t)}function ns(e,t,n={}){if(kn.decode(new Uint8Array(e)).formations.length>0&&t.length===0)throw new Error("FormationGroup contains formations but no formation buffers were provided");const r=t.map(o=>Wt.decode(new Uint8Array(o)));return Qa(r,n)}async function ud(e,t,n={}){const a=await fetch(e);if(!a.ok)throw new Error(`Failed to fetch slice data: ${a.status} ${a.statusText}`);const r=await a.arrayBuffer(),o=t==="density"?ja(r,n):t==="formation"?es(r,n):ts(r,n),i=await os(o.canvas);return URL.createObjectURL(i)}async function fd(e,t={}){var l;const n=await fetch(e);if(!n.ok)throw new Error(`Failed to fetch formation group data: ${n.status} ${n.statusText}`);const a=await n.arrayBuffer(),r=kn.decode(new Uint8Array(a)),o=(l=t.urlResolver)!=null?l:s=>s,i=await Promise.all(r.formations.map(async s=>{const c=await o(s.url),p=await fetch(c);if(!p.ok)throw new Error(`Failed to fetch formation data: ${c}`);return p.arrayBuffer()}));return ns(a,i,t)}function os(e){return new Promise((t,n)=>{e.toBlob(a=>{a?t(a):n(new Error("Failed to create PNG blob"))},"image/png")})}function dd(e){return e.toDataURL("image/png")}exports.PureComponents=Ot.PureComponents;exports.AttributeBody=ea;exports.AxesViewerPosition=Bt;exports.CachePreload=ws;exports.CacheType=Me;exports.ColorCodec=ta;exports.ComplexFormationManager=oa;exports.Coordinate=ra;exports.CustomShader=lt;exports.DarkMetalMaterial=Jn;exports.DataBinding=Xf;exports.DensitySlice=Yo;exports.FPS=aa;exports.FlatMaterial=Su;exports.FormationFace=Xn;exports.FormationManager=sa;exports.FormationSlice=Xo;exports.FormationVolume=qn;exports.GUIText=Je;exports.Geo3DCamera=la;exports.Geo3DUniversalCamera=Gu;exports.Geo3DViewer=qo;exports.GridDiagram=fa;exports.Ground=Rn;exports.HoverType=yn;exports.IntersectingLine=da;exports.LightMetalMaterial=Yn;exports.Line=Zo;exports.LoadingScreen=Lo;exports.LookAt=pa;exports.MaterialType=$e;exports.ModelLoader=Kn;exports.Optimizer=ma;exports.PlaneImage=ga;exports.PointClickZone=xa;exports.PointClickZoneObjectType=va;exports.ProgressedAttributeBody=ya;exports.ProgressedRemapColorByRedChannelMaterial=Qi;exports.ProgressedRepeatedTextureMaterial=ji;exports.RayClick=Ca;exports.RemapColorByRedChannelMaterial=Mt;exports.RepeatedTextureMaterial=Kt;exports.RibbonLayer=_a;exports.RoadWay=Pa;exports.Roam=qf;exports.Rod=Kf;exports.ScaleMode=It;exports.Scene=Qf;exports.SkyBox=Sa;exports.SpaceHeat=ka;exports.SpaceHeatObjectType=ba;exports.StructureLayer=Ho;exports.TileMap=Na;exports.TileMapMode=Ea;exports.Tube=wa;exports.TubeChart=No;exports.TubeChartLine=Ma;exports.TubeInstance=Aa;exports.TubeLayer=Io;exports.TubeMain=Ra;exports.TubeOil=Ba;exports.TubeTool=Eo;exports.Utils=Ps;exports.VoxelGrid=Da;exports.calcCompass=Ss;exports.calcGUIScale=ct;exports.calcInvTransformNodeScale=wi;exports.calcTransformNodeScale=Oe;exports.canvasToPngBlob=os;exports.canvasToPngDataUrl=dd;exports.createComponentInstance=nd;exports.describePlaneProjectionFromCorners=sd;exports.renderDensitySliceFromBuffer=ja;exports.renderDensitySliceToCanvas=Xa;exports.renderFormationFromBuffer=ts;exports.renderFormationGroupFromBuffers=ns;exports.renderFormationGroupFromUrl=fd;exports.renderFormationGroupToCanvas=Qa;exports.renderFormationSliceToCanvas=cd;exports.renderFormationSlicesFromBuffer=es;exports.renderFormationSlicesToCanvas=qa;exports.renderFormationToCanvas=Ka;exports.renderSliceFromUrl=ud;