@pan-ya/libgeo3dviewer 1.7.35 → 1.7.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/libgeo3dviewer.cjs.js +14 -14
- package/dist/libgeo3dviewer.es.js +1975 -1951
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Xa=Object.defineProperty;var qa=(e,t,n)=>t in e?Xa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ve=(e,t,n)=>qa(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("react/jsx-runtime"),f=require("@babylonjs/core"),xi=require("@babylonjs/core/Collisions/gpuPicker"),m=require("react"),_e=require("react-babylonjs"),Wt=require("axios"),Kn=require("@babylonjs/inspector");require("@babylonjs/core/Engines/Extensions/engine.query");require("@babylonjs/core/Legacy/legacy");const Ka=require("@babylonjs/loaders/dynamic"),nt=require("@babylonjs/gui"),Qa=require("@babylonjs/materials");require("@babylonjs/materials/legacy/legacy-grid");const ja=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 es=require("react-dom");var Rt=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function yi(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function xo(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 Ci={exports:{}},Qn={},Jo;function Ht(){return Jo||(Jo=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,u;for(s=0,i=0,l=o.length;i<l;i++)s+=o[i].length;for(u=new Uint8Array(s),c=0,i=0,l=o.length;i<l;i++)p=o[i],u.set(p,c),c+=p.length;return u}},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)}(Qn)),Qn}var Qt={},ht={},Zt={},Xo;function ts(){if(Xo)return Zt;Xo=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,u=29,d=256,x=d+1+u,h=30,T=19,P=2*x+1,y=15,_=16,b=7,k=256,L=16,I=17,S=18,E=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],B=[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],F=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],w=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],D=512,N=new Array((x+2)*2);o(N);var M=new Array(h*2);o(M);var v=new Array(D);o(v);var A=new Array(p-c+1);o(A);var V=new Array(u);o(V);var $=new Array(h);o($);function U(z,fe,pe,xe,Z){this.static_tree=z,this.extra_bits=fe,this.extra_base=pe,this.elems=xe,this.max_length=Z,this.has_stree=z&&z.length}var ie,ne,G;function ae(z,fe){this.dyn_tree=z,this.max_code=0,this.stat_desc=fe}function oe(z){return z<256?v[z]:v[256+(z>>>7)]}function j(z,fe){z.pending_buf[z.pending++]=fe&255,z.pending_buf[z.pending++]=fe>>>8&255}function Y(z,fe,pe){z.bi_valid>_-pe?(z.bi_buf|=fe<<z.bi_valid&65535,j(z,z.bi_buf),z.bi_buf=fe>>_-z.bi_valid,z.bi_valid+=pe-_):(z.bi_buf|=fe<<z.bi_valid&65535,z.bi_valid+=pe)}function ce(z,fe,pe){Y(z,pe[fe*2],pe[fe*2+1])}function le(z,fe){var pe=0;do pe|=z&1,z>>>=1,pe<<=1;while(--fe>0);return pe>>>1}function X(z){z.bi_valid===16?(j(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 pe=fe.dyn_tree,xe=fe.max_code,Z=fe.stat_desc.static_tree,re=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,te,R,W,J,Te=0;for(R=0;R<=y;R++)z.bl_count[R]=0;for(pe[z.heap[z.heap_max]*2+1]=0,g=z.heap_max+1;g<P;g++)q=z.heap[g],R=pe[pe[q*2+1]*2+1]+1,R>Se&&(R=Se,Te++),pe[q*2+1]=R,!(q>xe)&&(z.bl_count[R]++,W=0,q>=de&&(W=O[q-de]),J=pe[q*2],z.opt_len+=J*(R+W),re&&(z.static_len+=J*(Z[q*2+1]+W)));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;)te=z.heap[--g],!(te>xe)&&(pe[te*2+1]!==R&&(z.opt_len+=(R-pe[te*2+1])*pe[te*2],pe[te*2+1]=R),q--)}}function ge(z,fe,pe){var xe=new Array(y+1),Z=0,re,O;for(re=1;re<=y;re++)xe[re]=Z=Z+pe[re-1]<<1;for(O=0;O<=fe;O++){var de=z[O*2+1];de!==0&&(z[O*2]=le(xe[de]++,de))}}function H(){var z,fe,pe,xe,Z,re=new Array(y+1);for(pe=0,xe=0;xe<u-1;xe++)for(V[xe]=pe,z=0;z<1<<E[xe];z++)A[pe++]=xe;for(A[pe-1]=xe,Z=0,xe=0;xe<16;xe++)for($[xe]=Z,z=0;z<1<<B[xe];z++)v[Z++]=xe;for(Z>>=7;xe<h;xe++)for($[xe]=Z<<7,z=0;z<1<<B[xe]-7;z++)v[256+Z++]=xe;for(fe=0;fe<=y;fe++)re[fe]=0;for(z=0;z<=143;)N[z*2+1]=8,z++,re[8]++;for(;z<=255;)N[z*2+1]=9,z++,re[9]++;for(;z<=279;)N[z*2+1]=7,z++,re[7]++;for(;z<=287;)N[z*2+1]=8,z++,re[8]++;for(ge(N,x+1,re),z=0;z<h;z++)M[z*2+1]=5,M[z*2]=le(z,5);ie=new U(N,E,d+1,x,y),ne=new U(M,B,0,h,y),G=new U(new Array(0),F,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?j(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 be(z,fe,pe,xe){Ee(z),j(z,pe),j(z,~pe),e.arraySet(z.pending_buf,z.window,fe,pe,z.pending),z.pending+=pe}function ee(z,fe,pe,xe){var Z=fe*2,re=pe*2;return z[Z]<z[re]||z[Z]===z[re]&&xe[fe]<=xe[pe]}function he(z,fe,pe){for(var xe=z.heap[pe],Z=pe<<1;Z<=z.heap_len&&(Z<z.heap_len&&ee(fe,z.heap[Z+1],z.heap[Z],z.depth)&&Z++,!ee(fe,xe,z.heap[Z],z.depth));)z.heap[pe]=z.heap[Z],pe=Z,Z<<=1;z.heap[pe]=xe}function ue(z,fe,pe){var xe,Z,re=0,O,de;if(z.last_lit!==0)do xe=z.pending_buf[z.d_buf+re*2]<<8|z.pending_buf[z.d_buf+re*2+1],Z=z.pending_buf[z.l_buf+re],re++,xe===0?ce(z,Z,fe):(O=A[Z],ce(z,O+d+1,fe),de=E[O],de!==0&&(Z-=V[O],Y(z,Z,de)),xe--,O=oe(xe),ce(z,O,pe),de=B[O],de!==0&&(xe-=$[O],Y(z,xe,de)));while(re<z.last_lit);ce(z,k,fe)}function me(z,fe){var pe=fe.dyn_tree,xe=fe.stat_desc.static_tree,Z=fe.stat_desc.has_stree,re=fe.stat_desc.elems,O,de,Se=-1,g;for(z.heap_len=0,z.heap_max=P,O=0;O<re;O++)pe[O*2]!==0?(z.heap[++z.heap_len]=Se=O,z.depth[O]=0):pe[O*2+1]=0;for(;z.heap_len<2;)g=z.heap[++z.heap_len]=Se<2?++Se:0,pe[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--)he(z,pe,O);g=re;do O=z.heap[1],z.heap[1]=z.heap[z.heap_len--],he(z,pe,1),de=z.heap[1],z.heap[--z.heap_max]=O,z.heap[--z.heap_max]=de,pe[g*2]=pe[O*2]+pe[de*2],z.depth[g]=(z.depth[O]>=z.depth[de]?z.depth[O]:z.depth[de])+1,pe[O*2+1]=pe[de*2+1]=g,z.heap[1]=g++,he(z,pe,1);while(z.heap_len>=2);z.heap[--z.heap_max]=z.heap[1],Pe(z,fe),ge(pe,Se,z.bl_count)}function Ie(z,fe,pe){var xe,Z=-1,re,O=fe[0*2+1],de=0,Se=7,g=4;for(O===0&&(Se=138,g=3),fe[(pe+1)*2+1]=65535,xe=0;xe<=pe;xe++)re=O,O=fe[(xe+1)*2+1],!(++de<Se&&re===O)&&(de<g?z.bl_tree[re*2]+=de:re!==0?(re!==Z&&z.bl_tree[re*2]++,z.bl_tree[L*2]++):de<=10?z.bl_tree[I*2]++:z.bl_tree[S*2]++,de=0,Z=re,O===0?(Se=138,g=3):re===O?(Se=6,g=3):(Se=7,g=4))}function ke(z,fe,pe){var xe,Z=-1,re,O=fe[0*2+1],de=0,Se=7,g=4;for(O===0&&(Se=138,g=3),xe=0;xe<=pe;xe++)if(re=O,O=fe[(xe+1)*2+1],!(++de<Se&&re===O)){if(de<g)do ce(z,re,z.bl_tree);while(--de!==0);else re!==0?(re!==Z&&(ce(z,re,z.bl_tree),de--),ce(z,L,z.bl_tree),Y(z,de-3,2)):de<=10?(ce(z,I,z.bl_tree),Y(z,de-3,3)):(ce(z,S,z.bl_tree),Y(z,de-11,7));de=0,Z=re,O===0?(Se=138,g=3):re===O?(Se=6,g=3):(Se=7,g=4)}}function Ae(z){var fe;for(Ie(z,z.dyn_ltree,z.l_desc.max_code),Ie(z,z.dyn_dtree,z.d_desc.max_code),me(z,z.bl_desc),fe=T-1;fe>=3&&z.bl_tree[w[fe]*2+1]===0;fe--);return z.opt_len+=3*(fe+1)+5+5+4,fe}function Ne(z,fe,pe,xe){var Z;for(Y(z,fe-257,5),Y(z,pe-1,5),Y(z,xe-4,4),Z=0;Z<xe;Z++)Y(z,z.bl_tree[w[Z]*2+1],3);ke(z,z.dyn_ltree,fe-1),ke(z,z.dyn_dtree,pe-1)}function we(z){var fe=4093624447,pe;for(pe=0;pe<=31;pe++,fe>>>=1)if(fe&1&&z.dyn_ltree[pe*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(pe=32;pe<d;pe++)if(z.dyn_ltree[pe*2]!==0)return a;return n}var Re=!1;function Ve(z){Re||(H(),Re=!0),z.l_desc=new ae(z.dyn_ltree,ie),z.d_desc=new ae(z.dyn_dtree,ne),z.bl_desc=new ae(z.bl_tree,G),z.bi_buf=0,z.bi_valid=0,Q(z)}function We(z,fe,pe,xe){Y(z,(i<<1)+(xe?1:0),3),be(z,fe,pe)}function Be(z){Y(z,l<<1,3),ce(z,k,N),X(z)}function Ge(z,fe,pe,xe){var Z,re,O=0;z.level>0?(z.strm.data_type===r&&(z.strm.data_type=we(z)),me(z,z.l_desc),me(z,z.d_desc),O=Ae(z),Z=z.opt_len+3+7>>>3,re=z.static_len+3+7>>>3,re<=Z&&(Z=re)):Z=re=pe+5,pe+4<=Z&&fe!==-1?We(z,fe,pe,xe):z.strategy===t||re===Z?(Y(z,(l<<1)+(xe?1:0),3),ue(z,N,M)):(Y(z,(s<<1)+(xe?1:0),3),Ne(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,pe){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]=pe&255,z.last_lit++,fe===0?z.dyn_ltree[pe*2]++:(z.matches++,fe--,z.dyn_ltree[(A[pe]+d+1)*2]++,z.dyn_dtree[oe(fe)*2]++),z.last_lit===z.lit_bufsize-1}return Zt._tr_init=Ve,Zt._tr_stored_block=We,Zt._tr_flush_block=Ge,Zt._tr_tally=Ke,Zt._tr_align=Be,Zt}var jn,qo;function _i(){if(qo)return jn;qo=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 jn=e,jn}var eo,Ko;function Pi(){if(Ko)return eo;Ko=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 eo=n,eo}var to,Qo;function ko(){return Qo||(Qo=1,to={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"}),to}var jo;function ns(){if(jo)return ht;jo=1;var e=Ht(),t=ts(),n=_i(),a=Pi(),r=ko(),o=0,i=1,l=3,s=4,c=5,p=0,u=1,d=-2,x=-3,h=-5,T=-1,P=1,y=2,_=3,b=4,k=0,L=2,I=8,S=9,E=15,B=8,F=29,w=256,D=w+1+F,N=30,M=19,v=2*D+1,A=15,V=3,$=258,U=$+V+1,ie=32,ne=42,G=69,ae=73,oe=91,j=103,Y=113,ce=666,le=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 be(g){for(var q=g.length;--q>=0;)g[q]=0}function ee(g){var q=g.state,te=q.pending;te>g.avail_out&&(te=g.avail_out),te!==0&&(e.arraySet(g.output,q.pending_buf,q.pending_out,te,g.next_out),g.next_out+=te,q.pending_out+=te,g.total_out+=te,g.avail_out-=te,q.pending-=te,q.pending===0&&(q.pending_out=0))}function he(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,ee(g.strm)}function ue(g,q){g.pending_buf[g.pending++]=q}function me(g,q){g.pending_buf[g.pending++]=q>>>8&255,g.pending_buf[g.pending++]=q&255}function Ie(g,q,te,R){var W=g.avail_in;return W>R&&(W=R),W===0?0:(g.avail_in-=W,e.arraySet(q,g.input,g.next_in,W,te),g.state.wrap===1?g.adler=n(g.adler,q,W,te):g.state.wrap===2&&(g.adler=a(g.adler,q,W,te)),g.next_in+=W,g.total_in+=W,W)}function ke(g,q){var te=g.max_chain_length,R=g.strstart,W,J,Te=g.prev_length,ye=g.nice_match,Ce=g.strstart>g.w_size-U?g.strstart-(g.w_size-U):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&&(te>>=2),ye>g.lookahead&&(ye=g.lookahead);do if(W=q,!(Fe[W+Te]!==et||Fe[W+Te-1]!==qe||Fe[W]!==Fe[R]||Fe[++W]!==Fe[R+1])){R+=2,W++;do;while(Fe[++R]===Fe[++W]&&Fe[++R]===Fe[++W]&&Fe[++R]===Fe[++W]&&Fe[++R]===Fe[++W]&&Fe[++R]===Fe[++W]&&Fe[++R]===Fe[++W]&&Fe[++R]===Fe[++W]&&Fe[++R]===Fe[++W]&&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&&--te!==0);return Te<=g.lookahead?Te:g.lookahead}function Ae(g){var q=g.w_size,te,R,W,J,Te;do{if(J=g.window_size-g.lookahead-g.strstart,g.strstart>=q+(q-U)){e.arraySet(g.window,g.window,q,q,0),g.match_start-=q,g.strstart-=q,g.block_start-=q,R=g.hash_size,te=R;do W=g.head[--te],g.head[te]=W>=q?W-q:0;while(--R);R=q,te=R;do W=g.prev[--te],g.prev[te]=W>=q?W-q:0;while(--R);J+=q}if(g.strm.avail_in===0)break;if(R=Ie(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<U&&g.strm.avail_in!==0)}function Ne(g,q){var te=65535;for(te>g.pending_buf_size-5&&(te=g.pending_buf_size-5);;){if(g.lookahead<=1){if(Ae(g),g.lookahead===0&&q===o)return le;if(g.lookahead===0)break}g.strstart+=g.lookahead,g.lookahead=0;var R=g.block_start+te;if((g.strstart===0||g.strstart>=R)&&(g.lookahead=g.strstart-R,g.strstart=R,he(g,!1),g.strm.avail_out===0)||g.strstart-g.block_start>=g.w_size-U&&(he(g,!1),g.strm.avail_out===0))return le}return g.insert=0,q===s?(he(g,!0),g.strm.avail_out===0?Pe:ge):(g.strstart>g.block_start&&(he(g,!1),g.strm.avail_out===0),le)}function we(g,q){for(var te,R;;){if(g.lookahead<U){if(Ae(g),g.lookahead<U&&q===o)return le;if(g.lookahead===0)break}if(te=0,g.lookahead>=V&&(g.ins_h=(g.ins_h<<g.hash_shift^g.window[g.strstart+V-1])&g.hash_mask,te=g.prev[g.strstart&g.w_mask]=g.head[g.ins_h],g.head[g.ins_h]=g.strstart),te!==0&&g.strstart-te<=g.w_size-U&&(g.match_length=ke(g,te)),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,te=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&&(he(g,!1),g.strm.avail_out===0))return le}return g.insert=g.strstart<V-1?g.strstart:V-1,q===s?(he(g,!0),g.strm.avail_out===0?Pe:ge):g.last_lit&&(he(g,!1),g.strm.avail_out===0)?le:X}function Re(g,q){for(var te,R,W;;){if(g.lookahead<U){if(Ae(g),g.lookahead<U&&q===o)return le;if(g.lookahead===0)break}if(te=0,g.lookahead>=V&&(g.ins_h=(g.ins_h<<g.hash_shift^g.window[g.strstart+V-1])&g.hash_mask,te=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,te!==0&&g.prev_length<g.max_lazy_match&&g.strstart-te<=g.w_size-U&&(g.match_length=ke(g,te),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){W=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<=W&&(g.ins_h=(g.ins_h<<g.hash_shift^g.window[g.strstart+V-1])&g.hash_mask,te=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&&(he(g,!1),g.strm.avail_out===0))return le}else if(g.match_available){if(R=t._tr_tally(g,0,g.window[g.strstart-1]),R&&he(g,!1),g.strstart++,g.lookahead--,g.strm.avail_out===0)return le}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?(he(g,!0),g.strm.avail_out===0?Pe:ge):g.last_lit&&(he(g,!1),g.strm.avail_out===0)?le:X}function Ve(g,q){for(var te,R,W,J,Te=g.window;;){if(g.lookahead<=$){if(Ae(g),g.lookahead<=$&&q===o)return le;if(g.lookahead===0)break}if(g.match_length=0,g.lookahead>=V&&g.strstart>0&&(W=g.strstart-1,R=Te[W],R===Te[++W]&&R===Te[++W]&&R===Te[++W])){J=g.strstart+$;do;while(R===Te[++W]&&R===Te[++W]&&R===Te[++W]&&R===Te[++W]&&R===Te[++W]&&R===Te[++W]&&R===Te[++W]&&R===Te[++W]&&W<J);g.match_length=$-(J-W),g.match_length>g.lookahead&&(g.match_length=g.lookahead)}if(g.match_length>=V?(te=t._tr_tally(g,1,g.match_length-V),g.lookahead-=g.match_length,g.strstart+=g.match_length,g.match_length=0):(te=t._tr_tally(g,0,g.window[g.strstart]),g.lookahead--,g.strstart++),te&&(he(g,!1),g.strm.avail_out===0))return le}return g.insert=0,q===s?(he(g,!0),g.strm.avail_out===0?Pe:ge):g.last_lit&&(he(g,!1),g.strm.avail_out===0)?le:X}function We(g,q){for(var te;;){if(g.lookahead===0&&(Ae(g),g.lookahead===0)){if(q===o)return le;break}if(g.match_length=0,te=t._tr_tally(g,0,g.window[g.strstart]),g.lookahead--,g.strstart++,te&&(he(g,!1),g.strm.avail_out===0))return le}return g.insert=0,q===s?(he(g,!0),g.strm.avail_out===0?Pe:ge):g.last_lit&&(he(g,!1),g.strm.avail_out===0)?le:X}function Be(g,q,te,R,W){this.good_length=g,this.max_lazy=q,this.nice_length=te,this.max_chain=R,this.func=W}var Ge;Ge=[new Be(0,0,0,0,Ne),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,be(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=I,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(v*2),this.dyn_dtree=new e.Buf16((2*N+1)*2),this.bl_tree=new e.Buf16((2*M+1)*2),be(this.dyn_ltree),be(this.dyn_dtree),be(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),be(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new e.Buf16(2*D+1),be(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=L,q=g.state,q.pending=0,q.pending_out=0,q.wrap<0&&(q.wrap=-q.wrap),q.status=q.wrap?ne:Y,g.adler=q.wrap===2?0:1,q.last_flush=o,t._tr_init(q),p)}function pe(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,te,R,W,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),W<1||W>S||te!==I||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=W+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<<W+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=te,pe(g)}function re(g,q){return Z(g,q,I,E,B,k)}function O(g,q){var te,R,W,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,te=R.last_flush,R.last_flush=q,R.status===ne)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>=y||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>=y||R.level<2?4:0),ue(R,H),R.status=Y);else{var Te=I+(R.w_bits-8<<4)<<8,ye=-1;R.strategy>=y||R.level<2?ye=0:R.level<6?ye=1:R.level===6?ye=2:ye=3,Te|=ye<<6,R.strstart!==0&&(Te|=ie),Te+=31-Te%31,R.status=Y,me(R,Te),R.strstart!==0&&(me(R,g.adler>>>16),me(R,g.adler&65535)),g.adler=1}if(R.status===G)if(R.gzhead.extra){for(W=R.pending;R.gzindex<(R.gzhead.extra.length&65535)&&!(R.pending===R.pending_buf_size&&(R.gzhead.hcrc&&R.pending>W&&(g.adler=a(g.adler,R.pending_buf,R.pending-W,W)),ee(g),W=R.pending,R.pending===R.pending_buf_size));)ue(R,R.gzhead.extra[R.gzindex]&255),R.gzindex++;R.gzhead.hcrc&&R.pending>W&&(g.adler=a(g.adler,R.pending_buf,R.pending-W,W)),R.gzindex===R.gzhead.extra.length&&(R.gzindex=0,R.status=ae)}else R.status=ae;if(R.status===ae)if(R.gzhead.name){W=R.pending;do{if(R.pending===R.pending_buf_size&&(R.gzhead.hcrc&&R.pending>W&&(g.adler=a(g.adler,R.pending_buf,R.pending-W,W)),ee(g),W=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>W&&(g.adler=a(g.adler,R.pending_buf,R.pending-W,W)),J===0&&(R.gzindex=0,R.status=oe)}else R.status=oe;if(R.status===oe)if(R.gzhead.comment){W=R.pending;do{if(R.pending===R.pending_buf_size&&(R.gzhead.hcrc&&R.pending>W&&(g.adler=a(g.adler,R.pending_buf,R.pending-W,W)),ee(g),W=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>W&&(g.adler=a(g.adler,R.pending_buf,R.pending-W,W)),J===0&&(R.status=j)}else R.status=j;if(R.status===j&&(R.gzhead.hcrc?(R.pending+2>R.pending_buf_size&&ee(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(ee(g),g.avail_out===0)return R.last_flush=-1,p}else if(g.avail_in===0&&Ee(q)<=Ee(te)&&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===y?We(R,q):R.strategy===_?Ve(R,q):Ge[R.level].func(R,q);if((Ce===Pe||Ce===ge)&&(R.status=ce),Ce===le||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&&(be(R.head),R.lookahead===0&&(R.strstart=0,R.block_start=0,R.insert=0))),ee(g),g.avail_out===0))return R.last_flush=-1,p}return q!==s?p:R.wrap<=0?u:(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)):(me(R,g.adler>>>16),me(R,g.adler&65535)),ee(g),R.wrap>0&&(R.wrap=-R.wrap),R.pending!==0?p:u)}function de(g){var q;return!g||!g.state?d:(q=g.state.status,q!==ne&&q!==G&&q!==ae&&q!==oe&&q!==j&&q!==Y&&q!==ce?Q(g,d):(g.state=null,q===Y?Q(g,x):p))}function Se(g,q){var te=q.length,R,W,J,Te,ye,Ce,Fe,Tt;if(!g||!g.state||(R=g.state,Te=R.wrap,Te===2||Te===1&&R.status!==ne||R.lookahead))return d;for(Te===1&&(g.adler=n(g.adler,q,te,0)),R.wrap=0,te>=R.w_size&&(Te===0&&(be(R.head),R.strstart=0,R.block_start=0,R.insert=0),Tt=new e.Buf8(R.w_size),e.arraySet(Tt,q,te-R.w_size,R.w_size,0),q=Tt,te=R.w_size),ye=g.avail_in,Ce=g.next_in,Fe=g.input,g.avail_in=te,g.next_in=0,g.input=q,Ae(R);R.lookahead>=V;){W=R.strstart,J=R.lookahead-(V-1);do R.ins_h=(R.ins_h<<R.hash_shift^R.window[W+V-1])&R.hash_mask,R.prev[W&R.w_mask]=R.head[R.ins_h],R.head[R.ins_h]=W,W++;while(--J);R.strstart=W,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=re,ht.deflateInit2=Z,ht.deflateReset=pe,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={},er;function Si(){if(er)return Gt;er=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,u,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),u=0,p=0;u<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[u++]=s:s<2048?(l[u++]=192|s>>>6,l[u++]=128|s&63):s<65536?(l[u++]=224|s>>>12,l[u++]=128|s>>>6&63,l[u++]=128|s&63):(l[u++]=240|s>>>18,l[u++]=128|s>>>12&63,l[u++]=128|s>>>6&63,l[u++]=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,u,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(u=a[p],u>4){x[c++]=65533,s+=u-1;continue}for(p&=u===2?31:u===3?15:7;u>1&&s<d;)p=p<<6|i[s++]&63,u--;if(u>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 no,tr;function Ti(){if(tr)return no;tr=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 no=e,no}var nr;function os(){if(nr)return Qt;nr=1;var e=ns(),t=Ht(),n=Si(),a=ko(),r=Ti(),o=Object.prototype.toString,i=0,l=4,s=0,c=1,p=2,u=-1,d=0,x=8;function h(_){if(!(this instanceof h))return new h(_);this.options=t.assign({level:u,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 L;if(typeof b.dictionary=="string"?L=n.string2buf(b.dictionary):o.call(b.dictionary)==="[object ArrayBuffer]"?L=new Uint8Array(b.dictionary):L=b.dictionary,k=e.deflateSetDictionary(this.strm,L),k!==s)throw new Error(a[k]);this._dict_set=!0}}h.prototype.push=function(_,b){var k=this.strm,L=this.options.chunkSize,I,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(L),k.next_out=0,k.avail_out=L),I=e.deflate(k,S),I!==c&&I!==s)return this.onEnd(I),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)&&I!==c);return S===l?(I=e.deflateEnd(this.strm),this.onEnd(I),this.ended=!0,I===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 y(_,b){return b=b||{},b.gzip=!0,T(_,b)}return Qt.Deflate=h,Qt.deflate=T,Qt.deflateRaw=P,Qt.gzip=y,Qt}var jt={},ft={},oo,or;function rs(){if(or)return oo;or=1;var e=30,t=12;return oo=function(a,r){var o,i,l,s,c,p,u,d,x,h,T,P,y,_,b,k,L,I,S,E,B,F,w,D,N;o=a.state,i=a.next_in,D=a.input,l=i+(a.avail_in-5),s=a.next_out,N=a.output,c=s-(r-a.avail_out),p=s+(a.avail_out-257),u=o.dmax,d=o.wsize,x=o.whave,h=o.wnext,T=o.window,P=o.hold,y=o.bits,_=o.lencode,b=o.distcode,k=(1<<o.lenbits)-1,L=(1<<o.distbits)-1;e:do{y<15&&(P+=D[i++]<<y,y+=8,P+=D[i++]<<y,y+=8),I=_[P&k];t:for(;;){if(S=I>>>24,P>>>=S,y-=S,S=I>>>16&255,S===0)N[s++]=I&65535;else if(S&16){E=I&65535,S&=15,S&&(y<S&&(P+=D[i++]<<y,y+=8),E+=P&(1<<S)-1,P>>>=S,y-=S),y<15&&(P+=D[i++]<<y,y+=8,P+=D[i++]<<y,y+=8),I=b[P&L];n:for(;;){if(S=I>>>24,P>>>=S,y-=S,S=I>>>16&255,S&16){if(B=I&65535,S&=15,y<S&&(P+=D[i++]<<y,y+=8,y<S&&(P+=D[i++]<<y,y+=8)),B+=P&(1<<S)-1,B>u){a.msg="invalid distance too far back",o.mode=e;break e}if(P>>>=S,y-=S,S=s-c,B>S){if(S=B-S,S>x&&o.sane){a.msg="invalid distance too far back",o.mode=e;break e}if(F=0,w=T,h===0){if(F+=d-S,S<E){E-=S;do N[s++]=T[F++];while(--S);F=s-B,w=N}}else if(h<S){if(F+=d+h-S,S-=h,S<E){E-=S;do N[s++]=T[F++];while(--S);if(F=0,h<E){S=h,E-=S;do N[s++]=T[F++];while(--S);F=s-B,w=N}}}else if(F+=h-S,S<E){E-=S;do N[s++]=T[F++];while(--S);F=s-B,w=N}for(;E>2;)N[s++]=w[F++],N[s++]=w[F++],N[s++]=w[F++],E-=3;E&&(N[s++]=w[F++],E>1&&(N[s++]=w[F++]))}else{F=s-B;do N[s++]=N[F++],N[s++]=N[F++],N[s++]=N[F++],E-=3;while(E>2);E&&(N[s++]=N[F++],E>1&&(N[s++]=N[F++]))}}else if(S&64){a.msg="invalid distance code",o.mode=e;break e}else{I=b[(I&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{I=_[(I&65535)+(P&(1<<S)-1)];continue t}break}}while(i<l&&s<p);E=y>>3,i-=E,y-=E<<3,P&=(1<<y)-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=y},oo}var ro,rr;function is(){if(rr)return ro;rr=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 ro=function(d,x,h,T,P,y,_,b){var k=b.bits,L=0,I=0,S=0,E=0,B=0,F=0,w=0,D=0,N=0,M=0,v,A,V,$,U,ie=null,ne=0,G,ae=new e.Buf16(t+1),oe=new e.Buf16(t+1),j=null,Y=0,ce,le,X;for(L=0;L<=t;L++)ae[L]=0;for(I=0;I<T;I++)ae[x[h+I]]++;for(B=k,E=t;E>=1&&ae[E]===0;E--);if(B>E&&(B=E),E===0)return P[y++]=1<<24|64<<16|0,P[y++]=1<<24|64<<16|0,b.bits=1,0;for(S=1;S<E&&ae[S]===0;S++);for(B<S&&(B=S),D=1,L=1;L<=t;L++)if(D<<=1,D-=ae[L],D<0)return-1;if(D>0&&(d===r||E!==1))return-1;for(oe[1]=0,L=1;L<t;L++)oe[L+1]=oe[L]+ae[L];for(I=0;I<T;I++)x[h+I]!==0&&(_[oe[x[h+I]]++]=I);if(d===r?(ie=j=_,G=19):d===o?(ie=l,ne-=257,j=s,Y-=257,G=256):(ie=c,j=p,G=-1),M=0,I=0,L=S,U=y,F=B,w=0,V=-1,N=1<<B,$=N-1,d===o&&N>n||d===i&&N>a)return 1;for(;;){ce=L-w,_[I]<G?(le=0,X=_[I]):_[I]>G?(le=j[Y+_[I]],X=ie[ne+_[I]]):(le=96,X=0),v=1<<L-w,A=1<<F,S=A;do A-=v,P[U+(M>>w)+A]=ce<<24|le<<16|X|0;while(A!==0);for(v=1<<L-1;M&v;)v>>=1;if(v!==0?(M&=v-1,M+=v):M=0,I++,--ae[L]===0){if(L===E)break;L=x[h+_[I]]}if(L>B&&(M&$)!==V){for(w===0&&(w=B),U+=S,F=L-w,D=1<<F;F+w<E&&(D-=ae[F+w],!(D<=0));)F++,D<<=1;if(N+=1<<F,d===o&&N>n||d===i&&N>a)return 1;V=M&$,P[V]=B<<24|F<<16|U-y|0}}return M!==0&&(P[U+M]=L-w<<24|64<<16|0),b.bits=B,0},ro}var ir;function as(){if(ir)return ft;ir=1;var e=Ht(),t=_i(),n=Pi(),a=rs(),r=is(),o=0,i=1,l=2,s=4,c=5,p=6,u=0,d=1,x=2,h=-2,T=-3,P=-4,y=-5,_=8,b=1,k=2,L=3,I=4,S=5,E=6,B=7,F=8,w=9,D=10,N=11,M=12,v=13,A=14,V=15,$=16,U=17,ie=18,ne=19,G=20,ae=21,oe=22,j=23,Y=24,ce=25,le=26,X=27,Pe=28,ge=29,H=30,Q=31,Ee=32,be=852,ee=592,he=15,ue=he;function me(Z){return(Z>>>24&255)+(Z>>>8&65280)+((Z&65280)<<8)+((Z&255)<<24)}function Ie(){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 ke(Z){var re;return!Z||!Z.state?h:(re=Z.state,Z.total_in=Z.total_out=re.total=0,Z.msg="",re.wrap&&(Z.adler=re.wrap&1),re.mode=b,re.last=0,re.havedict=0,re.dmax=32768,re.head=null,re.hold=0,re.bits=0,re.lencode=re.lendyn=new e.Buf32(be),re.distcode=re.distdyn=new e.Buf32(ee),re.sane=1,re.back=-1,u)}function Ae(Z){var re;return!Z||!Z.state?h:(re=Z.state,re.wsize=0,re.whave=0,re.wnext=0,ke(Z))}function Ne(Z,re){var O,de;return!Z||!Z.state||(de=Z.state,re<0?(O=0,re=-re):(O=(re>>4)+1,re<48&&(re&=15)),re&&(re<8||re>15))?h:(de.window!==null&&de.wbits!==re&&(de.window=null),de.wrap=O,de.wbits=re,Ae(Z))}function we(Z,re){var O,de;return Z?(de=new Ie,Z.state=de,de.window=null,O=Ne(Z,re),O!==u&&(Z.state=null),O):h}function Re(Z){return we(Z,ue)}var Ve=!0,We,Be;function Ge(Z){if(Ve){var re;for(We=new e.Buf32(512),Be=new e.Buf32(32),re=0;re<144;)Z.lens[re++]=8;for(;re<256;)Z.lens[re++]=9;for(;re<280;)Z.lens[re++]=7;for(;re<288;)Z.lens[re++]=8;for(r(i,Z.lens,0,288,We,0,Z.work,{bits:9}),re=0;re<32;)Z.lens[re++]=5;r(l,Z.lens,0,32,Be,0,Z.work,{bits:5}),Ve=!1}Z.lencode=We,Z.lenbits=9,Z.distcode=Be,Z.distbits=5}function Ke(Z,re,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,re,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,re,O-de,Se,g.wnext),de-=Se,de?(e.arraySet(g.window,re,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,re){var O,de,Se,g,q,te,R,W,J,Te,ye,Ce,Fe,Tt,Ye=0,De,qe,et,at,kn,En,Xe,ut,Qe=new e.Buf8(4),bt,Ct,Yo=[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===M&&(O.mode=v),q=Z.next_out,Se=Z.output,R=Z.avail_out,g=Z.next_in,de=Z.input,te=Z.avail_in,W=O.hold,J=O.bits,Te=te,ye=R,ut=u;e:for(;;)switch(O.mode){case b:if(O.wrap===0){O.mode=v;break}for(;J<16;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}if(O.wrap&2&&W===35615){O.check=0,Qe[0]=W&255,Qe[1]=W>>>8&255,O.check=n(O.check,Qe,2,0),W=0,J=0,O.mode=k;break}if(O.flags=0,O.head&&(O.head.done=!1),!(O.wrap&1)||(((W&255)<<8)+(W>>8))%31){Z.msg="incorrect header check",O.mode=H;break}if((W&15)!==_){Z.msg="unknown compression method",O.mode=H;break}if(W>>>=4,J-=4,Xe=(W&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=W&512?D:M,W=0,J=0;break;case k:for(;J<16;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}if(O.flags=W,(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=W>>8&1),O.flags&512&&(Qe[0]=W&255,Qe[1]=W>>>8&255,O.check=n(O.check,Qe,2,0)),W=0,J=0,O.mode=L;case L:for(;J<32;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}O.head&&(O.head.time=W),O.flags&512&&(Qe[0]=W&255,Qe[1]=W>>>8&255,Qe[2]=W>>>16&255,Qe[3]=W>>>24&255,O.check=n(O.check,Qe,4,0)),W=0,J=0,O.mode=I;case I:for(;J<16;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}O.head&&(O.head.xflags=W&255,O.head.os=W>>8),O.flags&512&&(Qe[0]=W&255,Qe[1]=W>>>8&255,O.check=n(O.check,Qe,2,0)),W=0,J=0,O.mode=S;case S:if(O.flags&1024){for(;J<16;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}O.length=W,O.head&&(O.head.extra_len=W),O.flags&512&&(Qe[0]=W&255,Qe[1]=W>>>8&255,O.check=n(O.check,Qe,2,0)),W=0,J=0}else O.head&&(O.head.extra=null);O.mode=E;case E:if(O.flags&1024&&(Ce=O.length,Ce>te&&(Ce=te),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)),te-=Ce,g+=Ce,O.length-=Ce),O.length))break e;O.length=0,O.mode=B;case B:if(O.flags&2048){if(te===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<te);if(O.flags&512&&(O.check=n(O.check,de,Ce,g)),te-=Ce,g+=Ce,Xe)break e}else O.head&&(O.head.name=null);O.length=0,O.mode=F;case F:if(O.flags&4096){if(te===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<te);if(O.flags&512&&(O.check=n(O.check,de,Ce,g)),te-=Ce,g+=Ce,Xe)break e}else O.head&&(O.head.comment=null);O.mode=w;case w:if(O.flags&512){for(;J<16;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}if(W!==(O.check&65535)){Z.msg="header crc mismatch",O.mode=H;break}W=0,J=0}O.head&&(O.head.hcrc=O.flags>>9&1,O.head.done=!0),Z.adler=O.check=0,O.mode=M;break;case D:for(;J<32;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}Z.adler=O.check=me(W),W=0,J=0,O.mode=N;case N:if(O.havedict===0)return Z.next_out=q,Z.avail_out=R,Z.next_in=g,Z.avail_in=te,O.hold=W,O.bits=J,x;Z.adler=O.check=1,O.mode=M;case M:if(re===c||re===p)break e;case v:if(O.last){W>>>=J&7,J-=J&7,O.mode=X;break}for(;J<3;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}switch(O.last=W&1,W>>>=1,J-=1,W&3){case 0:O.mode=A;break;case 1:if(Ge(O),O.mode=G,re===p){W>>>=2,J-=2;break e}break;case 2:O.mode=U;break;case 3:Z.msg="invalid block type",O.mode=H}W>>>=2,J-=2;break;case A:for(W>>>=J&7,J-=J&7;J<32;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}if((W&65535)!==(W>>>16^65535)){Z.msg="invalid stored block lengths",O.mode=H;break}if(O.length=W&65535,W=0,J=0,O.mode=V,re===p)break e;case V:O.mode=$;case $:if(Ce=O.length,Ce){if(Ce>te&&(Ce=te),Ce>R&&(Ce=R),Ce===0)break e;e.arraySet(Se,de,g,Ce,q),te-=Ce,g+=Ce,R-=Ce,q+=Ce,O.length-=Ce;break}O.mode=M;break;case U:for(;J<14;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}if(O.nlen=(W&31)+257,W>>>=5,J-=5,O.ndist=(W&31)+1,W>>>=5,J-=5,O.ncode=(W&15)+4,W>>>=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=ie;case ie:for(;O.have<O.ncode;){for(;J<3;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}O.lens[Yo[O.have++]]=W&7,W>>>=3,J-=3}for(;O.have<19;)O.lens[Yo[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=ne;case ne:for(;O.have<O.nlen+O.ndist;){for(;Ye=O.lencode[W&(1<<O.lenbits)-1],De=Ye>>>24,qe=Ye>>>16&255,et=Ye&65535,!(De<=J);){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}if(et<16)W>>>=De,J-=De,O.lens[O.have++]=et;else{if(et===16){for(Ct=De+2;J<Ct;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}if(W>>>=De,J-=De,O.have===0){Z.msg="invalid bit length repeat",O.mode=H;break}Xe=O.lens[O.have-1],Ce=3+(W&3),W>>>=2,J-=2}else if(et===17){for(Ct=De+3;J<Ct;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}W>>>=De,J-=De,Xe=0,Ce=3+(W&7),W>>>=3,J-=3}else{for(Ct=De+7;J<Ct;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}W>>>=De,J-=De,Xe=0,Ce=11+(W&127),W>>>=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,re===p)break e;case G:O.mode=ae;case ae:if(te>=6&&R>=258){Z.next_out=q,Z.avail_out=R,Z.next_in=g,Z.avail_in=te,O.hold=W,O.bits=J,a(Z,ye),q=Z.next_out,Se=Z.output,R=Z.avail_out,g=Z.next_in,de=Z.input,te=Z.avail_in,W=O.hold,J=O.bits,O.mode===M&&(O.back=-1);break}for(O.back=0;Ye=O.lencode[W&(1<<O.lenbits)-1],De=Ye>>>24,qe=Ye>>>16&255,et=Ye&65535,!(De<=J);){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}if(qe&&!(qe&240)){for(at=De,kn=qe,En=et;Ye=O.lencode[En+((W&(1<<at+kn)-1)>>at)],De=Ye>>>24,qe=Ye>>>16&255,et=Ye&65535,!(at+De<=J);){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}W>>>=at,J-=at,O.back+=at}if(W>>>=De,J-=De,O.back+=De,O.length=et,qe===0){O.mode=le;break}if(qe&32){O.back=-1,O.mode=M;break}if(qe&64){Z.msg="invalid literal/length code",O.mode=H;break}O.extra=qe&15,O.mode=oe;case oe:if(O.extra){for(Ct=O.extra;J<Ct;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}O.length+=W&(1<<O.extra)-1,W>>>=O.extra,J-=O.extra,O.back+=O.extra}O.was=O.length,O.mode=j;case j:for(;Ye=O.distcode[W&(1<<O.distbits)-1],De=Ye>>>24,qe=Ye>>>16&255,et=Ye&65535,!(De<=J);){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}if(!(qe&240)){for(at=De,kn=qe,En=et;Ye=O.distcode[En+((W&(1<<at+kn)-1)>>at)],De=Ye>>>24,qe=Ye>>>16&255,et=Ye&65535,!(at+De<=J);){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}W>>>=at,J-=at,O.back+=at}if(W>>>=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(te===0)break e;te--,W+=de[g++]<<J,J+=8}O.offset+=W&(1<<O.extra)-1,W>>>=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=ae);break;case le:if(R===0)break e;Se[q++]=O.length,R--,O.mode=ae;break;case X:if(O.wrap){for(;J<32;){if(te===0)break e;te--,W|=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?W:me(W))!==O.check){Z.msg="incorrect data check",O.mode=H;break}W=0,J=0}O.mode=Pe;case Pe:if(O.wrap&&O.flags){for(;J<32;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}if(W!==(O.total&4294967295)){Z.msg="incorrect length check",O.mode=H;break}W=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=te,O.hold=W,O.bits=J,(O.wsize||ye!==Z.avail_out&&O.mode<H&&(O.mode<X||re!==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===M?128:0)+(O.mode===G||O.mode===V?256:0),(Te===0&&ye===0||re===s)&&ut===u&&(ut=y),ut}function fe(Z){if(!Z||!Z.state)return h;var re=Z.state;return re.window&&(re.window=null),Z.state=null,u}function pe(Z,re){var O;return!Z||!Z.state||(O=Z.state,!(O.wrap&2))?h:(O.head=re,re.done=!1,u)}function xe(Z,re){var O=re.length,de,Se,g;return!Z||!Z.state||(de=Z.state,de.wrap!==0&&de.mode!==N)?h:de.mode===N&&(Se=1,Se=t(Se,re,O,0),Se!==de.check)?T:(g=Ke(Z,re,O,O),g?(de.mode=Q,P):(de.havedict=1,u))}return ft.inflateReset=Ae,ft.inflateReset2=Ne,ft.inflateResetKeep=ke,ft.inflateInit=Re,ft.inflateInit2=we,ft.inflate=z,ft.inflateEnd=fe,ft.inflateGetHeader=pe,ft.inflateSetDictionary=xe,ft.inflateInfo="pako inflate (from Nodeca project)",ft}var io,ar;function bi(){return ar||(ar=1,io={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}),io}var ao,sr;function ss(){if(sr)return ao;sr=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 ao=e,ao}var lr;function ls(){if(lr)return jt;lr=1;var e=as(),t=Ht(),n=Si(),a=bi(),r=ko(),o=Ti(),i=ss(),l=Object.prototype.toString;function s(u){if(!(this instanceof s))return new s(u);this.options=t.assign({chunkSize:16384,windowBits:0,to:""},u||{});var d=this.options;d.raw&&d.windowBits>=0&&d.windowBits<16&&(d.windowBits=-d.windowBits,d.windowBits===0&&(d.windowBits=-15)),d.windowBits>=0&&d.windowBits<16&&!(u&&u.windowBits)&&(d.windowBits+=32),d.windowBits>15&&d.windowBits<48&&(d.windowBits&15||(d.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new o,this.strm.avail_out=0;var 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(u,d){var x=this.strm,h=this.options.chunkSize,T=this.options.dictionary,P,y,_,b,k,L=!1;if(this.ended)return!1;y=d===~~d?d:d===!0?a.Z_FINISH:a.Z_NO_FLUSH,typeof u=="string"?x.input=n.binstring2buf(u):l.call(u)==="[object ArrayBuffer]"?x.input=new Uint8Array(u):x.input=u,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&&L===!0&&(P=a.Z_OK,L=!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&&(y===a.Z_FINISH||y===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&&(L=!0)}while((x.avail_in>0||x.avail_out===0)&&P!==a.Z_STREAM_END);return P===a.Z_STREAM_END&&(y=a.Z_FINISH),y===a.Z_FINISH?(P=e.inflateEnd(this.strm),this.onEnd(P),this.ended=!0,P===a.Z_OK):(y===a.Z_SYNC_FLUSH&&(this.onEnd(a.Z_OK),x.avail_out=0),!0)},s.prototype.onData=function(u){this.chunks.push(u)},s.prototype.onEnd=function(u){u===a.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=t.flattenChunks(this.chunks)),this.chunks=[],this.err=u,this.msg=this.strm.msg};function c(u,d){var x=new s(d);if(x.push(u,!0),x.err)throw x.msg||r[x.err];return x.result}function p(u,d){return d=d||{},d.raw=!0,c(u,d)}return jt.Inflate=s,jt.inflate=c,jt.inflateRaw=p,jt.ungzip=c,jt}var so,cr;function cs(){if(cr)return so;cr=1;var e=Ht().assign,t=os(),n=ls(),a=bi(),r={};return e(r,t,n,a),so=r,so}(function(e){(function(){var t={},n;e.exports=t,typeof xo=="function"?n=cs():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),u=0;u<o.frames.length;u++){var d=o.frames[u],x=d.rect.x,h=d.rect.y,T=d.rect.width,P=d.rect.height,y=a.toRGBA8.decodeImage(d.data,T,P,o);if(u==0?c=y:d.blend==0?a._copyTile(y,T,P,c,i,l,x,h,0):d.blend==1&&a._copyTile(y,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 _=u-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),u=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 y=c<<2;if(T==8)for(var _=0;_<y;_++)d[_]=o[_];if(T==16)for(var _=0;_<y;_++)d[_]=o[_<<1]}else if(h==2){var b=s.tabs.tRNS,k=-1,L=-1,I=-1;if(b&&(k=b[0],L=b[1],I=b[2]),T==8)for(var _=0;_<c;_++){var S=_<<2,E=_*3;d[S]=o[E],d[S+1]=o[E+1],d[S+2]=o[E+2],d[S+3]=255,k!=-1&&o[E]==k&&o[E+1]==L&&o[E+2]==I&&(d[S+3]=0)}if(T==16)for(var _=0;_<c;_++){var S=_<<2,E=_*6;d[S]=o[E],d[S+1]=o[E+2],d[S+2]=o[E+4],d[S+3]=255,k!=-1&&P(o,E)==k&&P(o,E+2)==L&&P(o,E+4)==I&&(d[S+3]=0)}}else if(h==3){var B=s.tabs.PLTE,F=s.tabs.tRNS,w=F?F.length:0;if(T==1)for(var D=0;D<l;D++)for(var N=D*u,M=D*i,_=0;_<i;_++){var S=M+_<<2,v=o[N+(_>>3)]>>7-((_&7)<<0)&1,A=3*v;d[S]=B[A],d[S+1]=B[A+1],d[S+2]=B[A+2],d[S+3]=v<w?F[v]:255}if(T==2)for(var D=0;D<l;D++)for(var N=D*u,M=D*i,_=0;_<i;_++){var S=M+_<<2,v=o[N+(_>>2)]>>6-((_&3)<<1)&3,A=3*v;d[S]=B[A],d[S+1]=B[A+1],d[S+2]=B[A+2],d[S+3]=v<w?F[v]:255}if(T==4)for(var D=0;D<l;D++)for(var N=D*u,M=D*i,_=0;_<i;_++){var S=M+_<<2,v=o[N+(_>>1)]>>4-((_&1)<<2)&15,A=3*v;d[S]=B[A],d[S+1]=B[A+1],d[S+2]=B[A+2],d[S+3]=v<w?F[v]:255}if(T==8)for(var _=0;_<c;_++){var S=_<<2,v=o[_],A=3*v;d[S]=B[A],d[S+1]=B[A+1],d[S+2]=B[A+2],d[S+3]=v<w?F[v]: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),U=$==k*255?0:255;x[_]=U<<24|$<<16|$<<8|$}if(T==2)for(var _=0;_<c;_++){var $=85*(o[_>>2]>>6-((_&3)<<1)&3),U=$==k*85?0:255;x[_]=U<<24|$<<16|$<<8|$}if(T==4)for(var _=0;_<c;_++){var $=17*(o[_>>1]>>4-((_&1)<<2)&15),U=$==k*17?0:255;x[_]=U<<24|$<<16|$<<8|$}if(T==8)for(var _=0;_<c;_++){var $=o[_],U=$==k?0:255;x[_]=U<<24|$<<16|$<<8|$}if(T==16)for(var _=0;_<c;_++){var $=o[_<<1],U=P(o,_<<1)==k?0:255;x[_]=U<<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,u={tabs:{},frames:[]},d=new Uint8Array(i.length),x=0,h,T=0,P=[137,80,78,71,13,10,26,10],y=0;y<8;y++)if(i[y]!=P[y])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,u);else if(b=="IDAT"){for(var y=0;y<_;y++)d[x+y]=i[l+y];x+=_}else if(b=="acTL")u.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=u.frames[u.frames.length-1];k.data=a.decode._decompress(u,h.slice(0,T),k.rect.width,k.rect.height),T=0}var L={x:p(i,l+12),y:p(i,l+16),width:p(i,l+4),height:p(i,l+8)},I=c(i,l+22);I=c(i,l+20)/(I==0?100:I);var S={rect:L,delay:Math.round(I*1e3),dispose:i[l+24],blend:i[l+25]};u.frames.push(S)}else if(b=="fdAT"){for(var y=0;y<_-4;y++)h[T+y]=i[l+y+4];T+=_-4}else if(b=="pHYs")u.tabs[b]=[s.readUint(i,l),s.readUint(i,l+4),i[l+8]];else if(b=="cHRM"){u.tabs[b]=[];for(var y=0;y<8;y++)u.tabs[b].push(s.readUint(i,l+y*4))}else if(b=="tEXt"){u.tabs[b]==null&&(u.tabs[b]={});var E=s.nextZero(i,l),B=s.readASCII(i,l,E-l),F=s.readASCII(i,E+1,l+_-E-1);u.tabs[b][B]=F}else if(b=="iTXt"){u.tabs[b]==null&&(u.tabs[b]={});var E=0,w=l;E=s.nextZero(i,w);var B=s.readASCII(i,w,E-w);w=E+1,i[w],i[w+1],w+=2,E=s.nextZero(i,w),s.readASCII(i,w,E-w),w=E+1,E=s.nextZero(i,w),s.readUTF8(i,w,E-w),w=E+1;var F=s.readUTF8(i,w,_-(w-l));u.tabs[b][B]=F}else if(b=="PLTE")u.tabs[b]=s.readBytes(i,l,_);else if(b=="hIST"){var D=u.tabs.PLTE.length/3;u.tabs[b]=[];for(var y=0;y<D;y++)u.tabs[b].push(c(i,l+y*2))}else if(b=="tRNS")u.ctype==3?u.tabs[b]=s.readBytes(i,l,_):u.ctype==0?u.tabs[b]=c(i,l):u.ctype==2&&(u.tabs[b]=[c(i,l),c(i,l+2),c(i,l+4)]);else if(b=="gAMA")u.tabs[b]=s.readUint(i,l)/1e5;else if(b=="sRGB")u.tabs[b]=i[l];else if(b=="bKGD")u.ctype==0||u.ctype==4?u.tabs[b]=[c(i,l)]:u.ctype==2||u.ctype==6?u.tabs[b]=[c(i,l),c(i,l+2),c(i,l+4)]:u.ctype==3&&(u.tabs[b]=i[l]);else if(b=="IEND"){if(T!=0){var k=u.frames[u.frames.length-1];k.data=a.decode._decompress(u,h.slice(0,T),k.rect.width,k.rect.height),T=0}u.data=a.decode._decompress(u,d,u.width,u.height);break}l+=_,s.readUint(i,l),l+=4}return delete u.compress,delete u.interlace,delete u.filter,u},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,u=Math.ceil(l*c/8),d=new Uint8Array(s*u),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],y=[8,8,4,4,2,2,1],_=0;_<7;){for(var b=P[_],k=y[_],L=0,I=0,S=h[_];S<s;)S+=b,I++;for(var E=T[_];E<l;)E+=k,L++;var B=Math.ceil(L*c/8);a.decode._filterZero(o,i,x,L,I);for(var F=0,w=h[_];w<s;){for(var D=T[_],N=x+F*B<<3;D<l;){if(c==1){var M=o[N>>3];M=M>>7-(N&7)&1,d[w*u+(D>>3)]|=M<<7-((D&3)<<0)}if(c==2){var M=o[N>>3];M=M>>6-(N&7)&3,d[w*u+(D>>2)]|=M<<6-((D&3)<<1)}if(c==4){var M=o[N>>3];M=M>>4-(N&7)&15,d[w*u+(D>>1)]|=M<<4-((D&1)<<2)}if(c>=8)for(var v=w*u+D*p,A=0;A<p;A++)d[v+A]=o[(N>>3)+A];N+=c,D+=k}F++,w+=b}L*I!=0&&(x+=I*(1+B)),_=_+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),u=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*u,T=h+x+1,P=o[T-1];if(P==0)for(var y=0;y<u;y++)o[h+y]=o[T+y];else if(P==1){for(var y=0;y<p;y++)o[h+y]=o[T+y];for(var y=p;y<u;y++)o[h+y]=o[T+y]+o[h+y-p]&255}else if(x==0){for(var y=0;y<p;y++)o[h+y]=o[T+y];if(P==2)for(var y=p;y<u;y++)o[h+y]=o[T+y]&255;if(P==3)for(var y=p;y<u;y++)o[h+y]=o[T+y]+(o[h+y-p]>>1)&255;if(P==4)for(var y=p;y<u;y++)o[h+y]=o[T+y]+d(o[h+y-p],0,0)&255}else{if(P==2)for(var y=0;y<u;y++)o[h+y]=o[T+y]+o[h+y-u]&255;if(P==3){for(var y=0;y<p;y++)o[h+y]=o[T+y]+(o[h+y-u]>>1)&255;for(var y=p;y<u;y++)o[h+y]=o[T+y]+(o[h+y-u]+o[h+y-p]>>1)&255}if(P==4){for(var y=0;y<p;y++)o[h+y]=o[T+y]+d(0,o[h+y-u],0)&255;for(var y=p;y<u;y++)o[h+y]=o[T+y]+d(o[h+y-p],o[h+y-u],o[h+y-p-u])&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),u=Math.abs(s-l);return c<=p&&c<=u?o:p<=u?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(u){return a._bin.readASCII(o,i,l)}return c}},a._copyTile=function(o,i,l,s,c,p,u,d,x){for(var h=Math.min(i,c),T=Math.min(l,p),P=0,y=0,_=0;_<T;_++)for(var b=0;b<h;b++)if(u>=0&&d>=0?(P=_*i+b<<2,y=(d+_)*c+u+b<<2):(P=(-d+_)*i-u+b<<2,y=_*c+b<<2),x==0)s[y]=o[P],s[y+1]=o[P+1],s[y+2]=o[P+2],s[y+3]=o[P+3];else if(x==1){var k=o[P+3]*.00392156862745098,L=o[P]*k,I=o[P+1]*k,S=o[P+2]*k,E=s[y+3]*(1/255),B=s[y]*E,F=s[y+1]*E,w=s[y+2]*E,D=1-k,N=k+E*D,M=N==0?0:1/N;s[y+3]=255*N,s[y+0]=(L+B*D)*M,s[y+1]=(I+F*D)*M,s[y+2]=(S+w*D)*M}else if(x==2){var k=o[P+3],L=o[P],I=o[P+1],S=o[P+2],E=s[y+3],B=s[y],F=s[y+1],w=s[y+2];k==E&&L==B&&I==F&&S==w?(s[y]=0,s[y+1]=0,s[y+2]=0,s[y+3]=0):(s[y]=L,s[y+1]=I,s[y+2]=S,s[y+3]=k)}else if(x==3){var k=o[P+3],L=o[P],I=o[P+1],S=o[P+2],E=s[y+3],B=s[y],F=s[y+1],w=s[y+2];if(k==E&&L==B&&I==F&&S==w)continue;if(k<220&&E>20)return!1}return!0},a.encode=function(o,i,l,s,c,p){s==null&&(s=0),p==null&&(p=!1);for(var u=new Uint8Array(o[0].byteLength*o.length+100),d=[137,80,78,71,13,10,26,10],x=0;x<8;x++)u[x]=d[x];var h=8,T=a._bin,P=a.crc.crc,y=T.writeUint,_=T.writeUshort,b=T.writeASCII,k=a.encode.compressPNG(o,i,l,s,p);y(u,h,13),h+=4,b(u,h,"IHDR"),h+=4,y(u,h,i),h+=4,y(u,h,l),h+=4,u[h]=k.depth,h++,u[h]=k.ctype,h++,u[h]=0,h++,u[h]=0,h++,u[h]=0,h++,y(u,h,P(u,h-17,17)),h+=4,y(u,h,1),h+=4,b(u,h,"sRGB"),h+=4,u[h]=1,h++,y(u,h,P(u,h-5,5)),h+=4;var L=o.length>1;if(L&&(y(u,h,8),h+=4,b(u,h,"acTL"),h+=4,y(u,h,o.length),h+=4,y(u,h,0),h+=4,y(u,h,P(u,h-12,12)),h+=4),k.ctype==3){var I=k.plte.length;y(u,h,I*3),h+=4,b(u,h,"PLTE"),h+=4;for(var x=0;x<I;x++){var S=x*3,E=k.plte[x],B=E&255,F=E>>8&255,w=E>>16&255;u[h+S+0]=B,u[h+S+1]=F,u[h+S+2]=w}if(h+=I*3,y(u,h,P(u,h-I*3-4,I*3+4)),h+=4,k.gotAlpha){y(u,h,I),h+=4,b(u,h,"tRNS"),h+=4;for(var x=0;x<I;x++)u[h+x]=k.plte[x]>>24&255;h+=I,y(u,h,P(u,h-I-4,I+4)),h+=4}}for(var D=0,N=0;N<k.frames.length;N++){var M=k.frames[N];L&&(y(u,h,26),h+=4,b(u,h,"fcTL"),h+=4,y(u,h,D++),h+=4,y(u,h,M.rect.width),h+=4,y(u,h,M.rect.height),h+=4,y(u,h,M.rect.x),h+=4,y(u,h,M.rect.y),h+=4,_(u,h,c[N]),h+=2,_(u,h,1e3),h+=2,u[h]=M.dispose,h++,u[h]=M.blend,h++,y(u,h,P(u,h-30,30)),h+=4);var v=M.cimg,I=v.length;y(u,h,I+(N==0?0:4)),h+=4;var A=h;b(u,h,N==0?"IDAT":"fdAT"),h+=4,N!=0&&(y(u,h,D++),h+=4);for(var x=0;x<I;x++)u[h+x]=v[x];h+=I,y(u,h,P(u,A,h-A)),h+=4}return y(u,h,0),h+=4,b(u,h,"IEND"),h+=4,y(u,h,P(u,h-4,4)),h+=4,u.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),u=0;u<o.length;u++){var d=p.frames[u];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 u=6,d=8,x=4,h=255,T=0;T<o.length;T++)for(var P=new Uint8Array(o[T]),y=P.length,_=0;_<y;_+=4)h&=P[_+3];var b=h!=255,k={},L=[];if(o.length!=0&&(k[0]=0,L.push(0),s!=0&&s--),s!=0){var I=a.quantize(o,s,c);o=I.bufs;for(var _=0;_<I.plte.length;_++){var S=I.plte[_].est.rgba;k[S]==null&&(k[S]=L.length,L.push(S))}}else for(var T=0;T<o.length;T++)for(var E=new Uint32Array(o[T]),y=E.length,_=0;_<y;_++){var S=E[_];if((_<i||S!=E[_-1]&&S!=E[_-i])&&k[S]==null&&(k[S]=L.length,L.push(S),L.length>=300))break}var B=b?c:!1,F=L.length;F<=256&&p==!1&&(F<=2?d=1:F<=4?d=2:F<=16?d=4:d=8,c&&(d=8),b=!0);for(var w=[],T=0;T<o.length;T++){var D=new Uint8Array(o[T]),N=new Uint32Array(D.buffer),M=0,v=0,A=i,V=l,$=0;if(T!=0&&!B){for(var U=c||T==1||w[w.length-2].dispose==2?1:2,ie=0,ne=1e9,G=0;G<U;G++){for(var ge=new Uint8Array(o[T-1-G]),ae=new Uint32Array(o[T-1-G]),oe=i,j=l,Y=-1,ce=-1,le=0;le<l;le++)for(var X=0;X<i;X++){var _=le*i+X;N[_]!=ae[_]&&(X<oe&&(oe=X),X>Y&&(Y=X),le<j&&(j=le),le>ce&&(ce=le))}var Pe=Y==-1?1:(Y-oe+1)*(ce-j+1);Pe<ne&&(ne=Pe,ie=G,Y==-1?(M=v=0,A=V=1):(M=oe,v=j,A=Y-oe+1,V=ce-j+1))}var ge=new Uint8Array(o[T-1-ie]);ie==1&&(w[w.length-1].dispose=2);var H=new Uint8Array(A*V*4);new Uint32Array(H.buffer),a._copyTile(ge,i,l,H,A,V,-M,-v,0),a._copyTile(D,i,l,H,A,V,-M,-v,3)?(a._copyTile(D,i,l,H,A,V,-M,-v,2),$=1):(a._copyTile(D,i,l,H,A,V,-M,-v,0),$=0),D=H,N=new Uint32Array(D.buffer)}var Q=4*A;if(F<=256&&p==!1){Q=Math.ceil(d*A/8);for(var H=new Uint8Array(Q*V),le=0;le<V;le++){var _=le*Q,Ee=le*A;if(d==8)for(var X=0;X<A;X++)H[_+X]=k[N[Ee+X]];else if(d==4)for(var X=0;X<A;X++)H[_+(X>>1)]|=k[N[Ee+X]]<<4-(X&1)*4;else if(d==2)for(var X=0;X<A;X++)H[_+(X>>2)]|=k[N[Ee+X]]<<6-(X&3)*2;else if(d==1)for(var X=0;X<A;X++)H[_+(X>>3)]|=k[N[Ee+X]]<<7-(X&7)*1}D=H,u=3,x=1}else if(b==!1&&o.length==1){for(var H=new Uint8Array(A*V*3),be=A*V,_=0;_<be;_++){var ee=_*3,he=_*4;H[ee]=D[he],H[ee+1]=D[he+1],H[ee+2]=D[he+2]}D=H,u=2,x=3,Q=3*A}w.push({rect:{x:M,y:v,width:A,height:V},img:D,bpl:Q,bpp:x,blend:$,dispose:B?1:0})}return{ctype:u,depth:d,plte:L,gotAlpha:b,frames:w}},a.encode._filterZero=function(o,i,l,s,c){for(var p=[],u=0;u<5;u++)if(!(i*s>5e5&&(u==2||u==3||u==4))){for(var d=0;d<i;d++)a.encode._filterLine(c,o,d,s,l,u);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 u=l*s,d=u+l,x=a.decode._paeth;if(o[d]=p,d++,p==0)for(var h=0;h<s;h++)o[d+h]=i[u+h];else if(p==1){for(var h=0;h<c;h++)o[d+h]=i[u+h];for(var h=c;h<s;h++)o[d+h]=i[u+h]-i[u+h-c]+256&255}else if(l==0){for(var h=0;h<c;h++)o[d+h]=i[u+h];if(p==2)for(var h=c;h<s;h++)o[d+h]=i[u+h];if(p==3)for(var h=c;h<s;h++)o[d+h]=i[u+h]-(i[u+h-c]>>1)+256&255;if(p==4)for(var h=c;h<s;h++)o[d+h]=i[u+h]-x(i[u+h-c],0,0)+256&255}else{if(p==2)for(var h=0;h<s;h++)o[d+h]=i[u+h]+256-i[u+h-s]&255;if(p==3){for(var h=0;h<c;h++)o[d+h]=i[u+h]+256-(i[u+h-s]>>1)&255;for(var h=c;h<s;h++)o[d+h]=i[u+h]+256-(i[u+h-s]+i[u+h-c]>>1)&255}if(p==4){for(var h=0;h<c;h++)o[d+h]=i[u+h]+256-x(0,i[u+h-s],0)&255;for(var h=c;h<s;h++)o[d+h]=i[u+h]+256-x(i[u+h-c],i[u+h-s],i[u+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 u=new Uint8Array(c),d=new Uint32Array(u.buffer),x=0,p=0;p<s.length;p++){for(var h=s[p],T=h.length,P=0;P<T;P++)u[x+P]=h[P];x+=T}var y={i0:0,i1:u.length,bst:null,est:null,tdst:0,left:null,right:null};y.bst=a.quantize.stats(u,y.i0,y.i1),y.est=a.quantize.estats(y.bst);for(var _=[y];_.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 L=_[k],I=a.quantize.splitPixels(u,d,L.i0,L.i1,L.est.e,L.est.eMq255),S={i0:L.i0,i1:I,bst:null,est:null,tdst:0,left:null,right:null};S.bst=a.quantize.stats(u,S.i0,S.i1),S.est=a.quantize.estats(S.bst);var E={i0:I,i1:L.i1,bst:null,est:null,tdst:0,left:null,right:null};E.bst={R:[],m:[],N:L.bst.N-S.bst.N};for(var p=0;p<16;p++)E.bst.R[p]=L.bst.R[p]-S.bst.R[p];for(var p=0;p<4;p++)E.bst.m[p]=L.bst.m[p]-S.bst.m[p];E.est=a.quantize.estats(E.bst),L.left=S,L.right=E,_[k]=S,_.push(E)}_.sort(function(U,ie){return ie.bst.N-U.bst.N});for(var B=0;B<s.length;B++){for(var F=a.quantize.planeDst,w=new Uint8Array(s[B].buffer),D=new Uint32Array(s[B].buffer),N=w.length,p=0;p<N;p+=4){for(var M=w[p]*.00392156862745098,v=w[p+1]*(1/255),A=w[p+2]*(1/255),V=w[p+3]*(1/255),$=y;$.left;)$=F($.est,M,v,A,V)<=0?$.left:$.right;D[p>>2]=$.est.rgba}s[B]=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),u=o.left,d=o.right;p>0&&(u=o.right,d=o.left);var x=a.quantize.getNearest(u,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],u=l-o[1],d=s-o[2],x=c-o[3];return p*p+u*u+d*d+x*x},a.quantize.splitPixels=function(o,i,l,s,c,p){var u=a.quantize.vecDot;for(s-=4;l<s;){for(;u(o,l,c)<=p;)l+=4;for(;u(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(;u(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,u=i;u<l;u+=4){var d=o[u]*.00392156862745098,x=o[u+1]*(1/255),h=o[u+2]*(1/255),T=o[u+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],u=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*u*x,i[3]-c*d*x,i[4]-p*c*x,i[5]-p*p*x,i[6]-p*u*x,i[7]-p*d*x,i[8]-u*c*x,i[9]-u*p*x,i[10]-u*u*x,i[11]-u*d*x,i[12]-d*c*x,i[13]-d*p*x,i[14]-d*u*x,i[15]-d*d*x],T=h,P=a.M4,y=[.5,.5,.5,.5],_=0,b=0;if(s!=0)for(var k=0;k<10&&(y=P.multVec(T,y),b=Math.sqrt(P.dot(y,y)),y=P.sml(1/b,y),!(Math.abs(b-_)<1e-9));k++)_=b;var L=[c*x,p*x,u*x,d*x],I=P.dot(P.sml(255,L),y),S=L[3]<.001?0:1/L[3];return{Cov:h,q:L,e:y,L:_,eMq255:I,eMq:P.dot(y,L),rgba:(Math.round(255*L[3])<<24|Math.round(255*L[2]*S)<<16|Math.round(255*L[1]*S)<<8|Math.round(255*L[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,u=o[p+3];i&&(u=u<128?0:255);var d=u*(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]=u}return l}}(t,n)})()})(Ci);var us=Ci.exports;const fs=yi(us),ds=es.unstable_batchedUpdates,ps={batchUpdate:ds},ct=e=>new f.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 f.Vector3(e?e.scalePlane:1,e?e.scaleDepth:1,e?e.scalePlane:1),ki=e=>e?new f.Vector3(1/(e.scalePlane?e.scalePlane:1),1/(e.scaleDepth?e.scaleDepth:1),1/(e.scalePlane?e.scalePlane:1)):f.Vector3.One(),hs=e=>{if(e instanceof f.ArcRotateCamera){const t=e.alpha;return(t>0?t:Math.PI-t)/Math.PI*180%360}return 0},ms=e=>{const t=[];return e.forEach(n=>{t.push(Ei(n))}),t},Ei=e=>new f.Vector3(e.x,e.y,e.z),At=e=>new f.Vector3(e.x,e.y,e.z),gs=e=>new f.Color3(e.r,e.g,e.b);var xn=(e=>(e[e.START=0]="START",e[e.CONTINUE=1]="CONTINUE",e[e.END=2]="END",e))(xn||{}),$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||{}),Ni=(e=>(e[e.ClockWiseSideOrientation=f.Material.ClockWiseSideOrientation]="ClockWiseSideOrientation",e[e.CounterClockWiseSideOrientation=f.Material.CounterClockWiseSideOrientation]="CounterClockWiseSideOrientation",e))(Ni||{}),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),Eo=m.createContext({viewCamera:void 0,setViewCamera:()=>{},cameraRefObject:void 0}),Lt=m.createContext({colorIDs:{},colorCodecs:{}}),Dn=m.createContext(null);var No=(e=>(e[e.ENGINE_DEFAULT=0]="ENGINE_DEFAULT",e[e.NONE=1]="NONE",e))(No||{});const Io=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}),Ii=m.createContext(null),vs=(e,t)=>{var ge,H,Q,Ee,be;const{children:n,workspaceMeta:a={max:new f.Vector3(Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER),min:new f.Vector3(Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER),scaleDepth:1,scalePlane:1,origin:f.Vector3.Zero(),_isDefault:!0},colorProvider:r={colorIDs:{},colorCodecs:{}},cacheProvider:o={onPreFetch:ee=>new Promise(he=>{he(ee)}),onFinish:()=>{console.log("Loaded")},onProgress:(ee,he)=>{console.log(`Loading ${ee} of ${he}`)},useLoadingScreen:1}}=e,i=_e.useScene(),l=_e.useCanvas(),[s,c]=m.useState(void 0),p=m.useRef({}),[u,d]=m.useState({}),x=m.useRef(0),h=m.useRef(0),T=m.useRef(new Set),P=m.useRef(new Map),y=m.useRef({lastReportedLoaded:-1,lastReportedTotal:-1}),[,_]=m.useState(0),b=m.useRef(null),k=m.useRef(null),L=m.useRef(!1),I=m.useRef(null),S=m.useRef([]),E=m.useRef(null),B=m.useRef(0),F=m.useRef(new WeakMap),w=m.useRef(1),D=m.useRef(new Map),N=m.useRef(0),M=m.useRef({isDown:!1,pointerId:-1,startX:0,startY:0,isDragging:!1});m.useEffect(()=>{if(r.colorCodecs){console.log("[Geo3DViewer] 开始色标刷新");const ee={};if(Object.keys(r.colorCodecs).forEach(ue=>{console.log(`[Geo3DViewer] 正在生成色标 ${ue}`);const me=r.colorCodecs[ue],Ie=new Uint8Array(me.array.length*4);me.array.forEach((Ne,we)=>{Ie[we*4+0]=Math.trunc(Ne.r*255),Ie[we*4+1]=Math.trunc(Ne.g*255),Ie[we*4+2]=Math.trunc(Ne.b*255),Ie[we*4+3]=255}),console.log(`[Geo3DViewer] 正在创建色标采样贴图 ${ue}`);const ke=f.RawTexture.CreateRGBATexture(Ie,1,me.array.length,i,!0,!1);ke.name=`color-codec-${ue}`,console.log(`[Geo3DViewer] 正在创建色标图例 ${ue}`);const Ae=URL.createObjectURL(new Blob([fs.encode([Ie.buffer],1,me.array.length,0)]));console.log(`[Geo3DViewer] 正在构建色标 ${ue}`),ee[ue]={blobUrl:Ae,min:me.min,max:me.max,texture:ke}}),i){console.log(`[Geo3DViewer] 正在移除原有色标 共 ${Object.keys(p.current).length} 个`),Object.keys(p.current).forEach(me=>{console.log(`[Geo3DViewer] 正在移除色标 ${me}`),i.removeTexture(p.current[me].texture),p.current[me].texture.dispose(),URL.revokeObjectURL(p.current[me].blobUrl)}),p.current=ee;const ue=i.getMaterialByTags("remap");console.log("[Geo3DViewer] 已完成色标刷新,正在更新关联的材质"),ue.forEach(me=>{me instanceof f.ShaderMaterial?me.setTexture("textureSampler",ee[me.metadata.colorCodec].texture):(me.getBlockByName("RemappedTexture").texture=ee[me.metadata.colorCodec].texture,me.markAsDirty(f.NodeMaterial.TextureDirtyFlag))}),console.log(`[Geo3DViewer] 已有 ${ue.length} 个材质执行了更新`)}}},[r.colorCodecs,i]);const v=m.useCallback(ee=>!ee||ee.isDisposed()||!ee.metadata||!("pickable"in ee.metadata)||!ee.metadata.pickable?null:ee.metadata.pickable,[]),A=m.useCallback(ee=>!!(ee&&(ee.onHover||ee.onLeftClick||ee.onMiddleClick||ee.onRightClick)),[]),V=m.useCallback(ee=>{if(l){if(ee&&(ee.onLeftClick||ee.onMiddleClick||ee.onRightClick)){l.style.setProperty("cursor","pointer");return}l.style.setProperty("cursor","default")}},[l]),$=m.useCallback(()=>{var he;const ee=(he=k.current)==null?void 0:he._pickingTexture;b.current!==(ee!=null?ee:null)&&(b.current=ee!=null?ee:null,_(ue=>ue+1))},[]),U=m.useCallback(ee=>{const he=F.current.get(ee);if(he)return he;const ue=w.current++;return F.current.set(ee,ue),ue},[]),ie=m.useCallback(()=>{const ee=[],he=new Set;if(!i)return ee;i.meshes.forEach(me=>{if(!me||me.isDisposed())return;const Ie=v(me);if(!(!(A(Ie)&&me.isEnabled()&&me.isVisible&&me.isReady(!0)&&me.isPickable)||he.has(me))&&(he.add(me),ee.push(me),me.isAnInstance)){const Ae=me.sourceMesh;Ae&&!Ae.isDisposed()&&Ae.isEnabled()&&Ae.isVisible&&Ae.isReady(!0)&&!he.has(Ae)&&(he.add(Ae),ee.push(Ae))}});const ue=S.current.length===ee.length&&S.current.every((me,Ie)=>me===ee[Ie]);return k.current||(k.current=new xi.GPUPicker),ue||(k.current.setPickingList(ee.length>0?ee.slice():null),S.current=ee,$()),ee},[v,A,i,$]),ne=m.useCallback(async(ee,he)=>{if(!i)return null;if(!ie().length||!k.current)return $(),null;$();const me=await k.current.pickAsync(ee,he,!1);return $(),me},[i,ie,$]);m.useEffect(()=>{if(!i)return;const ee=i.onBeforeRenderObservable.add(()=>{ie()});return()=>{i.onBeforeRenderObservable.remove(ee)}},[i,ie]);const G=m.useCallback((ee,he,ue)=>i?i.pick(he,ue,me=>me===ee,!1,void 0):null,[i]),ae=m.useCallback(()=>{B.current+=1,D.current.clear()},[]),oe=m.useCallback(ee=>new Proxy({},{get:(he,ue)=>{const me=ee();if(!me)return;const Ie=me[ue];return typeof Ie=="function"?Ie.bind(me):Ie},set:(he,ue,me)=>{const Ie=ee();return Ie?(Ie[ue]=me,!0):!1},has:(he,ue)=>{const me=ee();return me?ue in me:!1},ownKeys:()=>{const he=ee();return he?Reflect.ownKeys(he):[]},getOwnPropertyDescriptor:(he,ue)=>{const me=ee();if(me)return Object.getOwnPropertyDescriptor(me,ue)}}),[]),j=m.useCallback((ee,he,ue)=>{const me=B.current,Ie=U(ee),ke=`${me}:${Ie}:${Math.round(he)}:${Math.round(ue)}`,Ae=()=>{var Be,Ge,Ke;const Ne=D.current.get(ke);if(Ne)return Ne;const we=G(ee,he,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:f.Vector3.Zero()))!=null?Ke:null,We={raw:Re,world:Ve};return D.current.set(ke,We),We};return{rawWorldPosition:oe(()=>Ae().raw),worldPosition:oe(()=>Ae().world)}},[oe,U,G,a.origin]),Y=m.useCallback((ee,he,ue,me,Ie)=>{var Re,Ve;const ke=v(ee);if(!ke||!ke.onHover)return;const Ae=new f.Vector2(ue.clientX,ue.clientY),Ne=he!==xn.END&&ke.needWorldPosition?j(ee,me,Ie):null,we=ke.valueCallback?ke.valueCallback(Ae,(Re=Ne==null?void 0:Ne.worldPosition)!=null?Re:null,(Ve=Ne==null?void 0:Ne.rawWorldPosition)!=null?Ve:null):null;ke.onHover(ke.name,Ae,Ne==null?void 0:Ne.worldPosition,he,we,ke.extra)},[j,v]),ce=m.useCallback((ee,he)=>{const ue=ee&&v(ee)&&A(v(ee))?ee:null,me=I.current;me&&me!==ue&&Y(me,xn.END,he.event,he.x,he.y),ue&&Y(ue,me===ue?xn.CONTINUE:xn.START,he.event,he.x,he.y),I.current=ue,V(ue?v(ue):null)},[v,A,Y,V]),le=m.useCallback(async()=>{var ee;if(!L.current){for(L.current=!0;E.current;){const he=E.current;if(E.current=null,!i||i.skipPointerMovePicking){ce(null,he);continue}const ue=await ne(he.x,he.y),me=(ee=ue==null?void 0:ue.mesh)!=null?ee:null;if(ae(),i.skipPointerMovePicking){ce(null,he);continue}ce(me,he)}L.current=!1}},[ae,ne,i,ce]),X=m.useCallback(async(ee,he,ue)=>{var Re;if(!i)return;for(;L.current;)await new Promise(Ve=>setTimeout(Ve,8));if(Date.now()-N.current<100){N.current=Date.now();return}N.current=Date.now();const me=await ne(he,ue);ae();const Ie=(Re=me==null?void 0:me.mesh)!=null?Re:null,ke=v(Ie);if(console.log(`[Geo3DViewer] 指针拾取 ${!!Ie} 于面 ${Ie}`,ke,me),!Ie||!ke)return;const Ae=new f.Vector2(ee.clientX,ee.clientY),Ne=j(Ie,he,ue),we=ke.valueCallback?ke.valueCallback(Ae,Ne.worldPosition,Ne.rawWorldPosition):null;if(ee.button===0&&ke.onLeftClick){ke.onLeftClick(ke.name,Ae,Ne.worldPosition,we,ke.extra);return}if(ee.button===1&&ke.onMiddleClick){ke.onMiddleClick(ke.name,Ae,Ne.worldPosition,we,ke.extra);return}ee.button===2&&ke.onRightClick&&ke.onRightClick(ke.name,Ae,Ne.worldPosition,we,ke.extra)},[ae,j,v,ne,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 ee=4,he=i.onPointerObservable.add(ue=>{const me=ue.event;if(ue.type===f.PointerEventTypes.POINTERDOWN){M.current.isDown=!0,M.current.pointerId=me.pointerId,M.current.startX=i.pointerX,M.current.startY=i.pointerY,M.current.isDragging=!1;return}if(ue.type===f.PointerEventTypes.POINTERMOVE){if(M.current.isDown&&M.current.pointerId===me.pointerId&&!M.current.isDragging){const Ie=i.pointerX-M.current.startX,ke=i.pointerY-M.current.startY;Ie*Ie+ke*ke>=ee*ee&&(M.current.isDragging=!0)}if(i.skipPointerMovePicking||M.current.isDragging){I.current&&ce(null,{event:me,x:i.pointerX,y:i.pointerY});return}E.current={event:me,x:i.pointerX,y:i.pointerY},le();return}if(ue.type===f.PointerEventTypes.POINTERUP){const Ie=M.current.isDragging;if(M.current.isDown=!1,M.current.pointerId=-1,M.current.isDragging=!1,i.skipPointerMovePicking||Ie)return;X(me,i.pointerX,i.pointerY)}});return()=>{i.onPointerObservable.remove(he),E.current=null,I.current=null,M.current.isDown=!1,M.current.pointerId=-1,M.current.isDragging=!1,V(null)}},[X,le,i,V,ce]),m.useEffect(()=>()=>{var ee;E.current=null,S.current=[],I.current=null,D.current.clear(),(ee=k.current)==null||ee.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 f.Vector3(Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER),max:(H=a.max)!=null?H:new f.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:(be=a._isDefault)!=null?be:!0,origin:f.Vector3.Zero()},children:C.jsx(Eo.Provider,{value:{viewCamera:s,setViewCamera:c,cameraRefObject:Pe},children:C.jsx(Io.Provider,{value:o,children:C.jsxs(wo.Provider,{value:{cache:u,setCache:d,loadedCount:h,totalCount:x,pending:T,inflight:P,reported:y},children:[C.jsx(Cs,{}),C.jsx(Dn.Provider,{value:{colorCodecsImage:p},children:C.jsx(Lt.Provider,{value:r,children:C.jsx(Ii.Provider,{value:{gpuPickingTexture:b},children:n})})})]})})})})},xs=m.forwardRef(vs),ys=new TextDecoder;var Me=(e=>(e[e.URL_PREFIX_MATCH=0]="URL_PREFIX_MATCH",e[e.EXACTLY_MATCH=1]="EXACTLY_MATCH",e))(Me||{}),wi=(e=>(e[e.BINARY=0]="BINARY",e[e.TEXTURE=1]="TEXTURE",e[e.MODEL=2]="MODEL",e[e.JSON=3]="JSON",e))(wi||{});const zn=({url:e,cacheType:t=0,assetType:n=0})=>{var L,I,S,E,B,F;const a=_e.useScene(),{onPreFetch:r}=m.useContext(Io),o=m.useContext(wo),i=m.useRef(0),l=m.useRef(0),s=m.useRef(new Set),c=m.useRef(new Map),[p,u]=m.useState(void 0),d=(L=o==null?void 0:o.cache)!=null?L:{},x=(I=o==null?void 0:o.setCache)!=null?I:()=>{},h=(S=o==null?void 0:o.loadedCount)!=null?S:l,T=(E=o==null?void 0:o.totalCount)!=null?E:i,P=(B=o==null?void 0:o.pending)!=null?B:s,y=(F=o==null?void 0:o.inflight)!=null?F:c,_=m.useCallback(async w=>{let D=1,N;for(;D>=0;)try{return(await Wt.get(w,{responseType:"arraybuffer",timeout:2e4})).data}catch(M){N=M,D-=1,D>=0&&await new Promise(v=>setTimeout(v,300))}throw N},[]),b=m.useCallback((w,D)=>{if(w){if(D===1)return d[w];if(D===0){const N=w.split("?")[0];return d[N]}}},[d]),k=m.useCallback(async(w,D,N)=>{const M=y.current.get(w);if(M){const A=await M;A&&u(A);return}const v=(async()=>{P.current.add(w),T.current=T.current+1;try{const A=await r(w),V=[];A!==w&&V.push(w),D===0?(V.push(A.split("?")[0]),V.push(A)):D===1&&V.push(A);const $=await _(A),U={};let ie;if(N===0)ie={buffer:$};else if(N===1){const ne=URL.createObjectURL(new Blob([$])),G=new f.Texture(ne,a,!0,!1,void 0,()=>{URL.revokeObjectURL(ne)},()=>{URL.revokeObjectURL(ne)});ie={buffer:$,texture:G}}else if(N===2){if(!a)throw new Error("Scene not ready for model loading");const ne=URL.createObjectURL(new Blob([$]));try{let G=A.split("?")[0];G=(G==null?void 0:G.split(".").pop())||"";const ae=await f.LoadAssetContainerAsync(ne,a,{pluginExtension:`.${G}`});ie={buffer:$,assets:ae}}finally{URL.revokeObjectURL(ne)}}else ie={buffer:$,json:JSON.parse(ys.decode($))};return V.forEach(ne=>{U[ne]=ie}),x(ne=>{let G=!1;const ae={...ne};return V.forEach(oe=>{ae[oe]||(ae[oe]=ie,G=!0)}),G?ae:ne}),h.current=h.current+1,u(ie),ie}catch(A){console.error(A),h.current=h.current+1;return}finally{P.current.delete(w),y.current.delete(w)}})();y.current.set(w,v),await v},[_,r,y,h,P,x,T,a]);return m.useEffect(()=>{if(e){const w=b(e,t);if(w){u(w);return}P.current.has(e)||k(e,t,n)}},[n,t,k,b,P,e]),p},je=({url:e,cacheType:t=0})=>{const n=zn({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=zn({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},Oi=({url:e,cacheType:t=0})=>{const n=zn({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},wo=m.createContext(void 0),Cs=()=>{var b,k,L,I;const e=_e.useScene(),t=_e.useEngine(),{onFinish:n,onProgress:a,useLoadingScreen:r,hideLoadingWhenPostCalculate:o}=m.useContext(Io),i=m.useContext(wo),l=m.useRef(0),s=m.useRef(0),c=m.useRef({lastReportedLoaded:-1,lastReportedTotal:-1}),p=m.useRef([]),u=(b=i==null?void 0:i.totalCount)!=null?b:l,d=(k=i==null?void 0:i.loadedCount)!=null?k:s,x=(L=i==null?void 0:i.reported)!=null?L:c,h=(I=i==null?void 0:i.pending)!=null?I:p,T=m.useRef(null),P=Array.isArray(h.current)?h.current.length:h.current.size,y=m.useCallback(S=>{r===No.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!=u.current||P>0){console.log("[Geo3DViewer] 加载进度",d.current,u.current,P,"使用 Post 加载器",o,e.getMeshesByTags("loading").length+e.getTransformNodesByTags("loading").length);const S=a||(()=>{}),E=n||(()=>{});d.current<u.current||P>0||o&&e.getMeshesByTags("loading").length+e.getTransformNodesByTags("loading").length>0?(console.log("[Geo3DViewer] 加载进度",d.current,u.current),S(d.current,u.current),y(!0)):o?e.getMeshesByTags("loading").length+e.getTransformNodesByTags("loading").length===0&&(E(),y(!1)):d.current===u.current&&(E(),y(!1))}x.current.lastReportedLoaded=d.current,x.current.lastReportedTotal=u.current}},[x,d,u,a,h,y,o,e,n]);return m.useEffect(()=>{_();const S=setInterval(()=>{_()},1e3);return()=>clearInterval(S)},[_]),C.jsx(C.Fragment,{})},_s=({url:e,cacheType:t,assetType:n=wi.BINARY})=>(zn({url:e,cacheType:t,assetType:n}),C.jsx(C.Fragment,{}));class Ps{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 Ai={},lo={},Ss=Ts;function Ts(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 u=new Array(arguments.length-1),d=0;d<u.length;)u[d++]=arguments[d];l.apply(null,u)}};try{e.apply(t||null,n)}catch(c){o&&(o=!1,s(c))}})}var Mi={};(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,u=[],d=0,x=0,h;s<c;){var T=l[s++];switch(x){case 0:u[d++]=n[T>>2],h=(T&3)<<4,x=1;break;case 1:u[d++]=n[h|T>>4],h=(T&15)<<2,x=2;break;case 2:u[d++]=n[h|T>>6],u[d++]=n[T&63],x=0;break}d>8191&&((p||(p=[])).push(String.fromCharCode.apply(String,u)),d=0)}return x&&(u[d++]=n[h],u[d++]=61,x===1&&(u[d++]=61)),p?(d&&p.push(String.fromCharCode.apply(String,u.slice(0,d))),p.join("")):String.fromCharCode.apply(String,u.slice(0,d))};var o="invalid encoding";t.decode=function(l,s,c){for(var p=c,u=0,d,x=0;x<l.length;){var h=l.charCodeAt(x++);if(h===61&&u>1)break;if((h=a[h])===void 0)throw Error(o);switch(u){case 0:d=h,u=1;break;case 1:s[c++]=d<<2|(h&48)>>4,d=h,u=2;break;case 2:s[c++]=(d&15)<<4|(h&60)>>2,d=h,u=3;break;case 3:s[c++]=(d&3)<<6|h,u=0;break}}if(u===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)}})(Mi);var bs=Vn;function Vn(){this._listeners=Object.create(null)}Vn.prototype.on=function(t,n,a){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:n,ctx:a||this}),this};Vn.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};Vn.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 ks=ur(ur);function ur(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,fr),e.writeFloatBE=t.bind(null,dr);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,pr),e.readFloatBE=n.bind(null,hr)}(),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 u=Math.floor(Math.log(i)/Math.LN2);u===1024&&(u=1023),p=i*Math.pow(2,-u),a(p*4503599627370496>>>0,l,s+r),a((c<<31|u+1023<<20|p*1048576&1048575)>>>0,l,s+o)}}}e.writeDoubleLE=t.bind(null,fr,0,4),e.writeDoubleBE=t.bind(null,dr,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,u=c>>>20&2047,d=4294967296*(c&1048575)+s;return u===2047?d?NaN:p*(1/0):u===0?p*5e-324*d:p*Math.pow(2,u-1075)*(d+4503599627370496)}e.readDoubleLE=n.bind(null,pr,0,4),e.readDoubleBE=n.bind(null,hr,4,0)}(),e}function fr(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 dr(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 pr(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function hr(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}var Es=Ns;function Ns(e){try{if(typeof xo!="function")return null;var t=xo(e);return t&&(t.length||Object.keys(t).length)?t:null}catch(n){return null}}var Li={};(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 u=(c&15)<<12|(r[s++]&63)<<6|r[s++]&63;l+=u>=2048?String.fromCharCode(u):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}})(Li);var Is=ws;function ws(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 co,mr;function Os(){if(mr)return co;mr=1,co=t;var e=Kt();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},co}var Nn={exports:{}},gr;function As(){return gr||(gr=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;/**
|
|
1
|
+
"use strict";var Xa=Object.defineProperty;var qa=(e,t,n)=>t in e?Xa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ve=(e,t,n)=>qa(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("react/jsx-runtime"),u=require("@babylonjs/core"),xi=require("@babylonjs/core/Collisions/gpuPicker"),m=require("react"),_e=require("react-babylonjs"),Wt=require("axios"),Kn=require("@babylonjs/inspector");require("@babylonjs/core/Engines/Extensions/engine.query");require("@babylonjs/core/Legacy/legacy");const Ka=require("@babylonjs/loaders/dynamic"),nt=require("@babylonjs/gui"),Qa=require("@babylonjs/materials");require("@babylonjs/materials/legacy/legacy-grid");const ja=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 es=require("react-dom");var Rt=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function yi(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function xo(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 Ci={exports:{}},Qn={},Jo;function Ht(){return Jo||(Jo=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)}(Qn)),Qn}var Qt={},ht={},Zt={},Xo;function ts(){if(Xo)return Zt;Xo=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,y=d+1+f,h=30,T=19,P=2*y+1,v=15,_=16,b=7,E=256,L=16,I=17,S=18,k=[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],B=[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],F=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],w=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],D=512,N=new Array((y+2)*2);o(N);var M=new Array(h*2);o(M);var x=new Array(D);o(x);var A=new Array(p-c+1);o(A);var V=new Array(f);o(V);var $=new Array(h);o($);function U(z,fe,pe,xe,Z){this.static_tree=z,this.extra_bits=fe,this.extra_base=pe,this.elems=xe,this.max_length=Z,this.has_stree=z&&z.length}var re,oe,G;function ae(z,fe){this.dyn_tree=z,this.max_code=0,this.stat_desc=fe}function ne(z){return z<256?x[z]:x[256+(z>>>7)]}function j(z,fe){z.pending_buf[z.pending++]=fe&255,z.pending_buf[z.pending++]=fe>>>8&255}function Y(z,fe,pe){z.bi_valid>_-pe?(z.bi_buf|=fe<<z.bi_valid&65535,j(z,z.bi_buf),z.bi_buf=fe>>_-z.bi_valid,z.bi_valid+=pe-_):(z.bi_buf|=fe<<z.bi_valid&65535,z.bi_valid+=pe)}function ce(z,fe,pe){Y(z,pe[fe*2],pe[fe*2+1])}function le(z,fe){var pe=0;do pe|=z&1,z>>>=1,pe<<=1;while(--fe>0);return pe>>>1}function X(z){z.bi_valid===16?(j(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 pe=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,te,R,W,J,Te=0;for(R=0;R<=v;R++)z.bl_count[R]=0;for(pe[z.heap[z.heap_max]*2+1]=0,g=z.heap_max+1;g<P;g++)q=z.heap[g],R=pe[pe[q*2+1]*2+1]+1,R>Se&&(R=Se,Te++),pe[q*2+1]=R,!(q>xe)&&(z.bl_count[R]++,W=0,q>=de&&(W=O[q-de]),J=pe[q*2],z.opt_len+=J*(R+W),ie&&(z.static_len+=J*(Z[q*2+1]+W)));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;)te=z.heap[--g],!(te>xe)&&(pe[te*2+1]!==R&&(z.opt_len+=(R-pe[te*2+1])*pe[te*2],pe[te*2+1]=R),q--)}}function ge(z,fe,pe){var xe=new Array(v+1),Z=0,ie,O;for(ie=1;ie<=v;ie++)xe[ie]=Z=Z+pe[ie-1]<<1;for(O=0;O<=fe;O++){var de=z[O*2+1];de!==0&&(z[O*2]=le(xe[de]++,de))}}function H(){var z,fe,pe,xe,Z,ie=new Array(v+1);for(pe=0,xe=0;xe<f-1;xe++)for(V[xe]=pe,z=0;z<1<<k[xe];z++)A[pe++]=xe;for(A[pe-1]=xe,Z=0,xe=0;xe<16;xe++)for($[xe]=Z,z=0;z<1<<B[xe];z++)x[Z++]=xe;for(Z>>=7;xe<h;xe++)for($[xe]=Z<<7,z=0;z<1<<B[xe]-7;z++)x[256+Z++]=xe;for(fe=0;fe<=v;fe++)ie[fe]=0;for(z=0;z<=143;)N[z*2+1]=8,z++,ie[8]++;for(;z<=255;)N[z*2+1]=9,z++,ie[9]++;for(;z<=279;)N[z*2+1]=7,z++,ie[7]++;for(;z<=287;)N[z*2+1]=8,z++,ie[8]++;for(ge(N,y+1,ie),z=0;z<h;z++)M[z*2+1]=5,M[z*2]=le(z,5);re=new U(N,k,d+1,y,v),oe=new U(M,B,0,h,v),G=new U(new Array(0),F,0,T,b)}function Q(z){var fe;for(fe=0;fe<y;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[E*2]=1,z.opt_len=z.static_len=0,z.last_lit=z.matches=0}function Ee(z){z.bi_valid>8?j(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 be(z,fe,pe,xe){Ee(z),j(z,pe),j(z,~pe),e.arraySet(z.pending_buf,z.window,fe,pe,z.pending),z.pending+=pe}function ee(z,fe,pe,xe){var Z=fe*2,ie=pe*2;return z[Z]<z[ie]||z[Z]===z[ie]&&xe[fe]<=xe[pe]}function he(z,fe,pe){for(var xe=z.heap[pe],Z=pe<<1;Z<=z.heap_len&&(Z<z.heap_len&&ee(fe,z.heap[Z+1],z.heap[Z],z.depth)&&Z++,!ee(fe,xe,z.heap[Z],z.depth));)z.heap[pe]=z.heap[Z],pe=Z,Z<<=1;z.heap[pe]=xe}function ue(z,fe,pe){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=k[O],de!==0&&(Z-=V[O],Y(z,Z,de)),xe--,O=ne(xe),ce(z,O,pe),de=B[O],de!==0&&(xe-=$[O],Y(z,xe,de)));while(ie<z.last_lit);ce(z,E,fe)}function me(z,fe){var pe=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++)pe[O*2]!==0?(z.heap[++z.heap_len]=Se=O,z.depth[O]=0):pe[O*2+1]=0;for(;z.heap_len<2;)g=z.heap[++z.heap_len]=Se<2?++Se:0,pe[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--)he(z,pe,O);g=ie;do O=z.heap[1],z.heap[1]=z.heap[z.heap_len--],he(z,pe,1),de=z.heap[1],z.heap[--z.heap_max]=O,z.heap[--z.heap_max]=de,pe[g*2]=pe[O*2]+pe[de*2],z.depth[g]=(z.depth[O]>=z.depth[de]?z.depth[O]:z.depth[de])+1,pe[O*2+1]=pe[de*2+1]=g,z.heap[1]=g++,he(z,pe,1);while(z.heap_len>=2);z.heap[--z.heap_max]=z.heap[1],Pe(z,fe),ge(pe,Se,z.bl_count)}function Ie(z,fe,pe){var xe,Z=-1,ie,O=fe[0*2+1],de=0,Se=7,g=4;for(O===0&&(Se=138,g=3),fe[(pe+1)*2+1]=65535,xe=0;xe<=pe;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[L*2]++):de<=10?z.bl_tree[I*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 ke(z,fe,pe){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<=pe;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,L,z.bl_tree),Y(z,de-3,2)):de<=10?(ce(z,I,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(Ie(z,z.dyn_ltree,z.l_desc.max_code),Ie(z,z.dyn_dtree,z.d_desc.max_code),me(z,z.bl_desc),fe=T-1;fe>=3&&z.bl_tree[w[fe]*2+1]===0;fe--);return z.opt_len+=3*(fe+1)+5+5+4,fe}function Ne(z,fe,pe,xe){var Z;for(Y(z,fe-257,5),Y(z,pe-1,5),Y(z,xe-4,4),Z=0;Z<xe;Z++)Y(z,z.bl_tree[w[Z]*2+1],3);ke(z,z.dyn_ltree,fe-1),ke(z,z.dyn_dtree,pe-1)}function we(z){var fe=4093624447,pe;for(pe=0;pe<=31;pe++,fe>>>=1)if(fe&1&&z.dyn_ltree[pe*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(pe=32;pe<d;pe++)if(z.dyn_ltree[pe*2]!==0)return a;return n}var Re=!1;function Ve(z){Re||(H(),Re=!0),z.l_desc=new ae(z.dyn_ltree,re),z.d_desc=new ae(z.dyn_dtree,oe),z.bl_desc=new ae(z.bl_tree,G),z.bi_buf=0,z.bi_valid=0,Q(z)}function We(z,fe,pe,xe){Y(z,(i<<1)+(xe?1:0),3),be(z,fe,pe)}function Be(z){Y(z,l<<1,3),ce(z,E,N),X(z)}function Ge(z,fe,pe,xe){var Z,ie,O=0;z.level>0?(z.strm.data_type===r&&(z.strm.data_type=we(z)),me(z,z.l_desc),me(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=pe+5,pe+4<=Z&&fe!==-1?We(z,fe,pe,xe):z.strategy===t||ie===Z?(Y(z,(l<<1)+(xe?1:0),3),ue(z,N,M)):(Y(z,(s<<1)+(xe?1:0),3),Ne(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,pe){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]=pe&255,z.last_lit++,fe===0?z.dyn_ltree[pe*2]++:(z.matches++,fe--,z.dyn_ltree[(A[pe]+d+1)*2]++,z.dyn_dtree[ne(fe)*2]++),z.last_lit===z.lit_bufsize-1}return Zt._tr_init=Ve,Zt._tr_stored_block=We,Zt._tr_flush_block=Ge,Zt._tr_tally=Ke,Zt._tr_align=Be,Zt}var jn,qo;function _i(){if(qo)return jn;qo=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 jn=e,jn}var eo,Ko;function Pi(){if(Ko)return eo;Ko=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 eo=n,eo}var to,Qo;function ko(){return Qo||(Qo=1,to={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"}),to}var jo;function ns(){if(jo)return ht;jo=1;var e=Ht(),t=ts(),n=_i(),a=Pi(),r=ko(),o=0,i=1,l=3,s=4,c=5,p=0,f=1,d=-2,y=-3,h=-5,T=-1,P=1,v=2,_=3,b=4,E=0,L=2,I=8,S=9,k=15,B=8,F=29,w=256,D=w+1+F,N=30,M=19,x=2*D+1,A=15,V=3,$=258,U=$+V+1,re=32,oe=42,G=69,ae=73,ne=91,j=103,Y=113,ce=666,le=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 be(g){for(var q=g.length;--q>=0;)g[q]=0}function ee(g){var q=g.state,te=q.pending;te>g.avail_out&&(te=g.avail_out),te!==0&&(e.arraySet(g.output,q.pending_buf,q.pending_out,te,g.next_out),g.next_out+=te,q.pending_out+=te,g.total_out+=te,g.avail_out-=te,q.pending-=te,q.pending===0&&(q.pending_out=0))}function he(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,ee(g.strm)}function ue(g,q){g.pending_buf[g.pending++]=q}function me(g,q){g.pending_buf[g.pending++]=q>>>8&255,g.pending_buf[g.pending++]=q&255}function Ie(g,q,te,R){var W=g.avail_in;return W>R&&(W=R),W===0?0:(g.avail_in-=W,e.arraySet(q,g.input,g.next_in,W,te),g.state.wrap===1?g.adler=n(g.adler,q,W,te):g.state.wrap===2&&(g.adler=a(g.adler,q,W,te)),g.next_in+=W,g.total_in+=W,W)}function ke(g,q){var te=g.max_chain_length,R=g.strstart,W,J,Te=g.prev_length,ye=g.nice_match,Ce=g.strstart>g.w_size-U?g.strstart-(g.w_size-U):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&&(te>>=2),ye>g.lookahead&&(ye=g.lookahead);do if(W=q,!(Fe[W+Te]!==et||Fe[W+Te-1]!==qe||Fe[W]!==Fe[R]||Fe[++W]!==Fe[R+1])){R+=2,W++;do;while(Fe[++R]===Fe[++W]&&Fe[++R]===Fe[++W]&&Fe[++R]===Fe[++W]&&Fe[++R]===Fe[++W]&&Fe[++R]===Fe[++W]&&Fe[++R]===Fe[++W]&&Fe[++R]===Fe[++W]&&Fe[++R]===Fe[++W]&&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&&--te!==0);return Te<=g.lookahead?Te:g.lookahead}function Ae(g){var q=g.w_size,te,R,W,J,Te;do{if(J=g.window_size-g.lookahead-g.strstart,g.strstart>=q+(q-U)){e.arraySet(g.window,g.window,q,q,0),g.match_start-=q,g.strstart-=q,g.block_start-=q,R=g.hash_size,te=R;do W=g.head[--te],g.head[te]=W>=q?W-q:0;while(--R);R=q,te=R;do W=g.prev[--te],g.prev[te]=W>=q?W-q:0;while(--R);J+=q}if(g.strm.avail_in===0)break;if(R=Ie(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<U&&g.strm.avail_in!==0)}function Ne(g,q){var te=65535;for(te>g.pending_buf_size-5&&(te=g.pending_buf_size-5);;){if(g.lookahead<=1){if(Ae(g),g.lookahead===0&&q===o)return le;if(g.lookahead===0)break}g.strstart+=g.lookahead,g.lookahead=0;var R=g.block_start+te;if((g.strstart===0||g.strstart>=R)&&(g.lookahead=g.strstart-R,g.strstart=R,he(g,!1),g.strm.avail_out===0)||g.strstart-g.block_start>=g.w_size-U&&(he(g,!1),g.strm.avail_out===0))return le}return g.insert=0,q===s?(he(g,!0),g.strm.avail_out===0?Pe:ge):(g.strstart>g.block_start&&(he(g,!1),g.strm.avail_out===0),le)}function we(g,q){for(var te,R;;){if(g.lookahead<U){if(Ae(g),g.lookahead<U&&q===o)return le;if(g.lookahead===0)break}if(te=0,g.lookahead>=V&&(g.ins_h=(g.ins_h<<g.hash_shift^g.window[g.strstart+V-1])&g.hash_mask,te=g.prev[g.strstart&g.w_mask]=g.head[g.ins_h],g.head[g.ins_h]=g.strstart),te!==0&&g.strstart-te<=g.w_size-U&&(g.match_length=ke(g,te)),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,te=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&&(he(g,!1),g.strm.avail_out===0))return le}return g.insert=g.strstart<V-1?g.strstart:V-1,q===s?(he(g,!0),g.strm.avail_out===0?Pe:ge):g.last_lit&&(he(g,!1),g.strm.avail_out===0)?le:X}function Re(g,q){for(var te,R,W;;){if(g.lookahead<U){if(Ae(g),g.lookahead<U&&q===o)return le;if(g.lookahead===0)break}if(te=0,g.lookahead>=V&&(g.ins_h=(g.ins_h<<g.hash_shift^g.window[g.strstart+V-1])&g.hash_mask,te=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,te!==0&&g.prev_length<g.max_lazy_match&&g.strstart-te<=g.w_size-U&&(g.match_length=ke(g,te),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){W=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<=W&&(g.ins_h=(g.ins_h<<g.hash_shift^g.window[g.strstart+V-1])&g.hash_mask,te=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&&(he(g,!1),g.strm.avail_out===0))return le}else if(g.match_available){if(R=t._tr_tally(g,0,g.window[g.strstart-1]),R&&he(g,!1),g.strstart++,g.lookahead--,g.strm.avail_out===0)return le}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?(he(g,!0),g.strm.avail_out===0?Pe:ge):g.last_lit&&(he(g,!1),g.strm.avail_out===0)?le:X}function Ve(g,q){for(var te,R,W,J,Te=g.window;;){if(g.lookahead<=$){if(Ae(g),g.lookahead<=$&&q===o)return le;if(g.lookahead===0)break}if(g.match_length=0,g.lookahead>=V&&g.strstart>0&&(W=g.strstart-1,R=Te[W],R===Te[++W]&&R===Te[++W]&&R===Te[++W])){J=g.strstart+$;do;while(R===Te[++W]&&R===Te[++W]&&R===Te[++W]&&R===Te[++W]&&R===Te[++W]&&R===Te[++W]&&R===Te[++W]&&R===Te[++W]&&W<J);g.match_length=$-(J-W),g.match_length>g.lookahead&&(g.match_length=g.lookahead)}if(g.match_length>=V?(te=t._tr_tally(g,1,g.match_length-V),g.lookahead-=g.match_length,g.strstart+=g.match_length,g.match_length=0):(te=t._tr_tally(g,0,g.window[g.strstart]),g.lookahead--,g.strstart++),te&&(he(g,!1),g.strm.avail_out===0))return le}return g.insert=0,q===s?(he(g,!0),g.strm.avail_out===0?Pe:ge):g.last_lit&&(he(g,!1),g.strm.avail_out===0)?le:X}function We(g,q){for(var te;;){if(g.lookahead===0&&(Ae(g),g.lookahead===0)){if(q===o)return le;break}if(g.match_length=0,te=t._tr_tally(g,0,g.window[g.strstart]),g.lookahead--,g.strstart++,te&&(he(g,!1),g.strm.avail_out===0))return le}return g.insert=0,q===s?(he(g,!0),g.strm.avail_out===0?Pe:ge):g.last_lit&&(he(g,!1),g.strm.avail_out===0)?le:X}function Be(g,q,te,R,W){this.good_length=g,this.max_lazy=q,this.nice_length=te,this.max_chain=R,this.func=W}var Ge;Ge=[new Be(0,0,0,0,Ne),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,be(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=I,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(x*2),this.dyn_dtree=new e.Buf16((2*N+1)*2),this.bl_tree=new e.Buf16((2*M+1)*2),be(this.dyn_ltree),be(this.dyn_dtree),be(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),be(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new e.Buf16(2*D+1),be(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=L,q=g.state,q.pending=0,q.pending_out=0,q.wrap<0&&(q.wrap=-q.wrap),q.status=q.wrap?oe:Y,g.adler=q.wrap===2?0:1,q.last_flush=o,t._tr_init(q),p)}function pe(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,te,R,W,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),W<1||W>S||te!==I||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=W+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<<W+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=te,pe(g)}function ie(g,q){return Z(g,q,I,k,B,E)}function O(g,q){var te,R,W,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,te=R.last_flush,R.last_flush=q,R.status===oe)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=I+(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|=re),Te+=31-Te%31,R.status=Y,me(R,Te),R.strstart!==0&&(me(R,g.adler>>>16),me(R,g.adler&65535)),g.adler=1}if(R.status===G)if(R.gzhead.extra){for(W=R.pending;R.gzindex<(R.gzhead.extra.length&65535)&&!(R.pending===R.pending_buf_size&&(R.gzhead.hcrc&&R.pending>W&&(g.adler=a(g.adler,R.pending_buf,R.pending-W,W)),ee(g),W=R.pending,R.pending===R.pending_buf_size));)ue(R,R.gzhead.extra[R.gzindex]&255),R.gzindex++;R.gzhead.hcrc&&R.pending>W&&(g.adler=a(g.adler,R.pending_buf,R.pending-W,W)),R.gzindex===R.gzhead.extra.length&&(R.gzindex=0,R.status=ae)}else R.status=ae;if(R.status===ae)if(R.gzhead.name){W=R.pending;do{if(R.pending===R.pending_buf_size&&(R.gzhead.hcrc&&R.pending>W&&(g.adler=a(g.adler,R.pending_buf,R.pending-W,W)),ee(g),W=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>W&&(g.adler=a(g.adler,R.pending_buf,R.pending-W,W)),J===0&&(R.gzindex=0,R.status=ne)}else R.status=ne;if(R.status===ne)if(R.gzhead.comment){W=R.pending;do{if(R.pending===R.pending_buf_size&&(R.gzhead.hcrc&&R.pending>W&&(g.adler=a(g.adler,R.pending_buf,R.pending-W,W)),ee(g),W=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>W&&(g.adler=a(g.adler,R.pending_buf,R.pending-W,W)),J===0&&(R.status=j)}else R.status=j;if(R.status===j&&(R.gzhead.hcrc?(R.pending+2>R.pending_buf_size&&ee(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(ee(g),g.avail_out===0)return R.last_flush=-1,p}else if(g.avail_in===0&&Ee(q)<=Ee(te)&&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?We(R,q):R.strategy===_?Ve(R,q):Ge[R.level].func(R,q);if((Ce===Pe||Ce===ge)&&(R.status=ce),Ce===le||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&&(be(R.head),R.lookahead===0&&(R.strstart=0,R.block_start=0,R.insert=0))),ee(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)):(me(R,g.adler>>>16),me(R,g.adler&65535)),ee(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!==oe&&q!==G&&q!==ae&&q!==ne&&q!==j&&q!==Y&&q!==ce?Q(g,d):(g.state=null,q===Y?Q(g,y):p))}function Se(g,q){var te=q.length,R,W,J,Te,ye,Ce,Fe,Tt;if(!g||!g.state||(R=g.state,Te=R.wrap,Te===2||Te===1&&R.status!==oe||R.lookahead))return d;for(Te===1&&(g.adler=n(g.adler,q,te,0)),R.wrap=0,te>=R.w_size&&(Te===0&&(be(R.head),R.strstart=0,R.block_start=0,R.insert=0),Tt=new e.Buf8(R.w_size),e.arraySet(Tt,q,te-R.w_size,R.w_size,0),q=Tt,te=R.w_size),ye=g.avail_in,Ce=g.next_in,Fe=g.input,g.avail_in=te,g.next_in=0,g.input=q,Ae(R);R.lookahead>=V;){W=R.strstart,J=R.lookahead-(V-1);do R.ins_h=(R.ins_h<<R.hash_shift^R.window[W+V-1])&R.hash_mask,R.prev[W&R.w_mask]=R.head[R.ins_h],R.head[R.ins_h]=W,W++;while(--J);R.strstart=W,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=pe,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={},er;function Si(){if(er)return Gt;er=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,y=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++)),y+=s<128?1:s<2048?2:s<65536?3:4;for(l=new e.Buf8(y),f=0,p=0;f<y;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,y=new Array(d*2);for(c=0,s=0;s<d;){if(p=i[s++],p<128){y[c++]=p;continue}if(f=a[p],f>4){y[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){y[c++]=65533;continue}p<65536?y[c++]=p:(p-=65536,y[c++]=55296|p>>10&1023,y[c++]=56320|p&1023)}return o(y,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 no,tr;function Ti(){if(tr)return no;tr=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 no=e,no}var nr;function os(){if(nr)return Qt;nr=1;var e=ns(),t=Ht(),n=Si(),a=ko(),r=Ti(),o=Object.prototype.toString,i=0,l=4,s=0,c=1,p=2,f=-1,d=0,y=8;function h(_){if(!(this instanceof h))return new h(_);this.options=t.assign({level:f,method:y,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 E=e.deflateInit2(this.strm,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(E!==s)throw new Error(a[E]);if(b.header&&e.deflateSetHeader(this.strm,b.header),b.dictionary){var L;if(typeof b.dictionary=="string"?L=n.string2buf(b.dictionary):o.call(b.dictionary)==="[object ArrayBuffer]"?L=new Uint8Array(b.dictionary):L=b.dictionary,E=e.deflateSetDictionary(this.strm,L),E!==s)throw new Error(a[E]);this._dict_set=!0}}h.prototype.push=function(_,b){var E=this.strm,L=this.options.chunkSize,I,S;if(this.ended)return!1;S=b===~~b?b:b===!0?l:i,typeof _=="string"?E.input=n.string2buf(_):o.call(_)==="[object ArrayBuffer]"?E.input=new Uint8Array(_):E.input=_,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new t.Buf8(L),E.next_out=0,E.avail_out=L),I=e.deflate(E,S),I!==c&&I!==s)return this.onEnd(I),this.ended=!0,!1;(E.avail_out===0||E.avail_in===0&&(S===l||S===p))&&(this.options.to==="string"?this.onData(n.buf2binstring(t.shrinkBuf(E.output,E.next_out))):this.onData(t.shrinkBuf(E.output,E.next_out)))}while((E.avail_in>0||E.avail_out===0)&&I!==c);return S===l?(I=e.deflateEnd(this.strm),this.onEnd(I),this.ended=!0,I===s):(S===p&&(this.onEnd(s),E.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 E=new h(b);if(E.push(_,!0),E.err)throw E.msg||a[E.err];return E.result}function P(_,b){return b=b||{},b.raw=!0,T(_,b)}function v(_,b){return b=b||{},b.gzip=!0,T(_,b)}return Qt.Deflate=h,Qt.deflate=T,Qt.deflateRaw=P,Qt.gzip=v,Qt}var jt={},ft={},oo,or;function rs(){if(or)return oo;or=1;var e=30,t=12;return oo=function(a,r){var o,i,l,s,c,p,f,d,y,h,T,P,v,_,b,E,L,I,S,k,B,F,w,D,N;o=a.state,i=a.next_in,D=a.input,l=i+(a.avail_in-5),s=a.next_out,N=a.output,c=s-(r-a.avail_out),p=s+(a.avail_out-257),f=o.dmax,d=o.wsize,y=o.whave,h=o.wnext,T=o.window,P=o.hold,v=o.bits,_=o.lencode,b=o.distcode,E=(1<<o.lenbits)-1,L=(1<<o.distbits)-1;e:do{v<15&&(P+=D[i++]<<v,v+=8,P+=D[i++]<<v,v+=8),I=_[P&E];t:for(;;){if(S=I>>>24,P>>>=S,v-=S,S=I>>>16&255,S===0)N[s++]=I&65535;else if(S&16){k=I&65535,S&=15,S&&(v<S&&(P+=D[i++]<<v,v+=8),k+=P&(1<<S)-1,P>>>=S,v-=S),v<15&&(P+=D[i++]<<v,v+=8,P+=D[i++]<<v,v+=8),I=b[P&L];n:for(;;){if(S=I>>>24,P>>>=S,v-=S,S=I>>>16&255,S&16){if(B=I&65535,S&=15,v<S&&(P+=D[i++]<<v,v+=8,v<S&&(P+=D[i++]<<v,v+=8)),B+=P&(1<<S)-1,B>f){a.msg="invalid distance too far back",o.mode=e;break e}if(P>>>=S,v-=S,S=s-c,B>S){if(S=B-S,S>y&&o.sane){a.msg="invalid distance too far back",o.mode=e;break e}if(F=0,w=T,h===0){if(F+=d-S,S<k){k-=S;do N[s++]=T[F++];while(--S);F=s-B,w=N}}else if(h<S){if(F+=d+h-S,S-=h,S<k){k-=S;do N[s++]=T[F++];while(--S);if(F=0,h<k){S=h,k-=S;do N[s++]=T[F++];while(--S);F=s-B,w=N}}}else if(F+=h-S,S<k){k-=S;do N[s++]=T[F++];while(--S);F=s-B,w=N}for(;k>2;)N[s++]=w[F++],N[s++]=w[F++],N[s++]=w[F++],k-=3;k&&(N[s++]=w[F++],k>1&&(N[s++]=w[F++]))}else{F=s-B;do N[s++]=N[F++],N[s++]=N[F++],N[s++]=N[F++],k-=3;while(k>2);k&&(N[s++]=N[F++],k>1&&(N[s++]=N[F++]))}}else if(S&64){a.msg="invalid distance code",o.mode=e;break e}else{I=b[(I&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{I=_[(I&65535)+(P&(1<<S)-1)];continue t}break}}while(i<l&&s<p);k=v>>3,i-=k,v-=k<<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},oo}var ro,rr;function is(){if(rr)return ro;rr=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 ro=function(d,y,h,T,P,v,_,b){var E=b.bits,L=0,I=0,S=0,k=0,B=0,F=0,w=0,D=0,N=0,M=0,x,A,V,$,U,re=null,oe=0,G,ae=new e.Buf16(t+1),ne=new e.Buf16(t+1),j=null,Y=0,ce,le,X;for(L=0;L<=t;L++)ae[L]=0;for(I=0;I<T;I++)ae[y[h+I]]++;for(B=E,k=t;k>=1&&ae[k]===0;k--);if(B>k&&(B=k),k===0)return P[v++]=1<<24|64<<16|0,P[v++]=1<<24|64<<16|0,b.bits=1,0;for(S=1;S<k&&ae[S]===0;S++);for(B<S&&(B=S),D=1,L=1;L<=t;L++)if(D<<=1,D-=ae[L],D<0)return-1;if(D>0&&(d===r||k!==1))return-1;for(ne[1]=0,L=1;L<t;L++)ne[L+1]=ne[L]+ae[L];for(I=0;I<T;I++)y[h+I]!==0&&(_[ne[y[h+I]]++]=I);if(d===r?(re=j=_,G=19):d===o?(re=l,oe-=257,j=s,Y-=257,G=256):(re=c,j=p,G=-1),M=0,I=0,L=S,U=v,F=B,w=0,V=-1,N=1<<B,$=N-1,d===o&&N>n||d===i&&N>a)return 1;for(;;){ce=L-w,_[I]<G?(le=0,X=_[I]):_[I]>G?(le=j[Y+_[I]],X=re[oe+_[I]]):(le=96,X=0),x=1<<L-w,A=1<<F,S=A;do A-=x,P[U+(M>>w)+A]=ce<<24|le<<16|X|0;while(A!==0);for(x=1<<L-1;M&x;)x>>=1;if(x!==0?(M&=x-1,M+=x):M=0,I++,--ae[L]===0){if(L===k)break;L=y[h+_[I]]}if(L>B&&(M&$)!==V){for(w===0&&(w=B),U+=S,F=L-w,D=1<<F;F+w<k&&(D-=ae[F+w],!(D<=0));)F++,D<<=1;if(N+=1<<F,d===o&&N>n||d===i&&N>a)return 1;V=M&$,P[V]=B<<24|F<<16|U-v|0}}return M!==0&&(P[U+M]=L-w<<24|64<<16|0),b.bits=B,0},ro}var ir;function as(){if(ir)return ft;ir=1;var e=Ht(),t=_i(),n=Pi(),a=rs(),r=is(),o=0,i=1,l=2,s=4,c=5,p=6,f=0,d=1,y=2,h=-2,T=-3,P=-4,v=-5,_=8,b=1,E=2,L=3,I=4,S=5,k=6,B=7,F=8,w=9,D=10,N=11,M=12,x=13,A=14,V=15,$=16,U=17,re=18,oe=19,G=20,ae=21,ne=22,j=23,Y=24,ce=25,le=26,X=27,Pe=28,ge=29,H=30,Q=31,Ee=32,be=852,ee=592,he=15,ue=he;function me(Z){return(Z>>>24&255)+(Z>>>8&65280)+((Z&65280)<<8)+((Z&255)<<24)}function Ie(){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 ke(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(be),ie.distcode=ie.distdyn=new e.Buf32(ee),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,ke(Z))}function Ne(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 Ie,Z.state=de,de.window=null,O=Ne(Z,ie),O!==f&&(Z.state=null),O):h}function Re(Z){return we(Z,ue)}var Ve=!0,We,Be;function Ge(Z){if(Ve){var ie;for(We=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,We,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=We,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,te,R,W,J,Te,ye,Ce,Fe,Tt,Ye=0,De,qe,et,at,kn,En,Xe,ut,Qe=new e.Buf8(4),bt,Ct,Yo=[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===M&&(O.mode=x),q=Z.next_out,Se=Z.output,R=Z.avail_out,g=Z.next_in,de=Z.input,te=Z.avail_in,W=O.hold,J=O.bits,Te=te,ye=R,ut=f;e:for(;;)switch(O.mode){case b:if(O.wrap===0){O.mode=x;break}for(;J<16;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}if(O.wrap&2&&W===35615){O.check=0,Qe[0]=W&255,Qe[1]=W>>>8&255,O.check=n(O.check,Qe,2,0),W=0,J=0,O.mode=E;break}if(O.flags=0,O.head&&(O.head.done=!1),!(O.wrap&1)||(((W&255)<<8)+(W>>8))%31){Z.msg="incorrect header check",O.mode=H;break}if((W&15)!==_){Z.msg="unknown compression method",O.mode=H;break}if(W>>>=4,J-=4,Xe=(W&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=W&512?D:M,W=0,J=0;break;case E:for(;J<16;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}if(O.flags=W,(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=W>>8&1),O.flags&512&&(Qe[0]=W&255,Qe[1]=W>>>8&255,O.check=n(O.check,Qe,2,0)),W=0,J=0,O.mode=L;case L:for(;J<32;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}O.head&&(O.head.time=W),O.flags&512&&(Qe[0]=W&255,Qe[1]=W>>>8&255,Qe[2]=W>>>16&255,Qe[3]=W>>>24&255,O.check=n(O.check,Qe,4,0)),W=0,J=0,O.mode=I;case I:for(;J<16;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}O.head&&(O.head.xflags=W&255,O.head.os=W>>8),O.flags&512&&(Qe[0]=W&255,Qe[1]=W>>>8&255,O.check=n(O.check,Qe,2,0)),W=0,J=0,O.mode=S;case S:if(O.flags&1024){for(;J<16;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}O.length=W,O.head&&(O.head.extra_len=W),O.flags&512&&(Qe[0]=W&255,Qe[1]=W>>>8&255,O.check=n(O.check,Qe,2,0)),W=0,J=0}else O.head&&(O.head.extra=null);O.mode=k;case k:if(O.flags&1024&&(Ce=O.length,Ce>te&&(Ce=te),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)),te-=Ce,g+=Ce,O.length-=Ce),O.length))break e;O.length=0,O.mode=B;case B:if(O.flags&2048){if(te===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<te);if(O.flags&512&&(O.check=n(O.check,de,Ce,g)),te-=Ce,g+=Ce,Xe)break e}else O.head&&(O.head.name=null);O.length=0,O.mode=F;case F:if(O.flags&4096){if(te===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<te);if(O.flags&512&&(O.check=n(O.check,de,Ce,g)),te-=Ce,g+=Ce,Xe)break e}else O.head&&(O.head.comment=null);O.mode=w;case w:if(O.flags&512){for(;J<16;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}if(W!==(O.check&65535)){Z.msg="header crc mismatch",O.mode=H;break}W=0,J=0}O.head&&(O.head.hcrc=O.flags>>9&1,O.head.done=!0),Z.adler=O.check=0,O.mode=M;break;case D:for(;J<32;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}Z.adler=O.check=me(W),W=0,J=0,O.mode=N;case N:if(O.havedict===0)return Z.next_out=q,Z.avail_out=R,Z.next_in=g,Z.avail_in=te,O.hold=W,O.bits=J,y;Z.adler=O.check=1,O.mode=M;case M:if(ie===c||ie===p)break e;case x:if(O.last){W>>>=J&7,J-=J&7,O.mode=X;break}for(;J<3;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}switch(O.last=W&1,W>>>=1,J-=1,W&3){case 0:O.mode=A;break;case 1:if(Ge(O),O.mode=G,ie===p){W>>>=2,J-=2;break e}break;case 2:O.mode=U;break;case 3:Z.msg="invalid block type",O.mode=H}W>>>=2,J-=2;break;case A:for(W>>>=J&7,J-=J&7;J<32;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}if((W&65535)!==(W>>>16^65535)){Z.msg="invalid stored block lengths",O.mode=H;break}if(O.length=W&65535,W=0,J=0,O.mode=V,ie===p)break e;case V:O.mode=$;case $:if(Ce=O.length,Ce){if(Ce>te&&(Ce=te),Ce>R&&(Ce=R),Ce===0)break e;e.arraySet(Se,de,g,Ce,q),te-=Ce,g+=Ce,R-=Ce,q+=Ce,O.length-=Ce;break}O.mode=M;break;case U:for(;J<14;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}if(O.nlen=(W&31)+257,W>>>=5,J-=5,O.ndist=(W&31)+1,W>>>=5,J-=5,O.ncode=(W&15)+4,W>>>=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=re;case re:for(;O.have<O.ncode;){for(;J<3;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}O.lens[Yo[O.have++]]=W&7,W>>>=3,J-=3}for(;O.have<19;)O.lens[Yo[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=oe;case oe:for(;O.have<O.nlen+O.ndist;){for(;Ye=O.lencode[W&(1<<O.lenbits)-1],De=Ye>>>24,qe=Ye>>>16&255,et=Ye&65535,!(De<=J);){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}if(et<16)W>>>=De,J-=De,O.lens[O.have++]=et;else{if(et===16){for(Ct=De+2;J<Ct;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}if(W>>>=De,J-=De,O.have===0){Z.msg="invalid bit length repeat",O.mode=H;break}Xe=O.lens[O.have-1],Ce=3+(W&3),W>>>=2,J-=2}else if(et===17){for(Ct=De+3;J<Ct;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}W>>>=De,J-=De,Xe=0,Ce=3+(W&7),W>>>=3,J-=3}else{for(Ct=De+7;J<Ct;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}W>>>=De,J-=De,Xe=0,Ce=11+(W&127),W>>>=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=ae;case ae:if(te>=6&&R>=258){Z.next_out=q,Z.avail_out=R,Z.next_in=g,Z.avail_in=te,O.hold=W,O.bits=J,a(Z,ye),q=Z.next_out,Se=Z.output,R=Z.avail_out,g=Z.next_in,de=Z.input,te=Z.avail_in,W=O.hold,J=O.bits,O.mode===M&&(O.back=-1);break}for(O.back=0;Ye=O.lencode[W&(1<<O.lenbits)-1],De=Ye>>>24,qe=Ye>>>16&255,et=Ye&65535,!(De<=J);){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}if(qe&&!(qe&240)){for(at=De,kn=qe,En=et;Ye=O.lencode[En+((W&(1<<at+kn)-1)>>at)],De=Ye>>>24,qe=Ye>>>16&255,et=Ye&65535,!(at+De<=J);){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}W>>>=at,J-=at,O.back+=at}if(W>>>=De,J-=De,O.back+=De,O.length=et,qe===0){O.mode=le;break}if(qe&32){O.back=-1,O.mode=M;break}if(qe&64){Z.msg="invalid literal/length code",O.mode=H;break}O.extra=qe&15,O.mode=ne;case ne:if(O.extra){for(Ct=O.extra;J<Ct;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}O.length+=W&(1<<O.extra)-1,W>>>=O.extra,J-=O.extra,O.back+=O.extra}O.was=O.length,O.mode=j;case j:for(;Ye=O.distcode[W&(1<<O.distbits)-1],De=Ye>>>24,qe=Ye>>>16&255,et=Ye&65535,!(De<=J);){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}if(!(qe&240)){for(at=De,kn=qe,En=et;Ye=O.distcode[En+((W&(1<<at+kn)-1)>>at)],De=Ye>>>24,qe=Ye>>>16&255,et=Ye&65535,!(at+De<=J);){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}W>>>=at,J-=at,O.back+=at}if(W>>>=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(te===0)break e;te--,W+=de[g++]<<J,J+=8}O.offset+=W&(1<<O.extra)-1,W>>>=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=ae);break;case le:if(R===0)break e;Se[q++]=O.length,R--,O.mode=ae;break;case X:if(O.wrap){for(;J<32;){if(te===0)break e;te--,W|=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?W:me(W))!==O.check){Z.msg="incorrect data check",O.mode=H;break}W=0,J=0}O.mode=Pe;case Pe:if(O.wrap&&O.flags){for(;J<32;){if(te===0)break e;te--,W+=de[g++]<<J,J+=8}if(W!==(O.total&4294967295)){Z.msg="incorrect length check",O.mode=H;break}W=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=te,O.hold=W,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===M?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 pe(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!==N)?h:de.mode===N&&(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=Ne,ft.inflateResetKeep=ke,ft.inflateInit=Re,ft.inflateInit2=we,ft.inflate=z,ft.inflateEnd=fe,ft.inflateGetHeader=pe,ft.inflateSetDictionary=xe,ft.inflateInfo="pako inflate (from Nodeca project)",ft}var io,ar;function bi(){return ar||(ar=1,io={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}),io}var ao,sr;function ss(){if(sr)return ao;sr=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 ao=e,ao}var lr;function ls(){if(lr)return jt;lr=1;var e=as(),t=Ht(),n=Si(),a=bi(),r=ko(),o=Ti(),i=ss(),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 y=e.inflateInit2(this.strm,d.windowBits);if(y!==a.Z_OK)throw new Error(r[y]);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&&(y=e.inflateSetDictionary(this.strm,d.dictionary),y!==a.Z_OK)))throw new Error(r[y])}s.prototype.push=function(f,d){var y=this.strm,h=this.options.chunkSize,T=this.options.dictionary,P,v,_,b,E,L=!1;if(this.ended)return!1;v=d===~~d?d:d===!0?a.Z_FINISH:a.Z_NO_FLUSH,typeof f=="string"?y.input=n.binstring2buf(f):l.call(f)==="[object ArrayBuffer]"?y.input=new Uint8Array(f):y.input=f,y.next_in=0,y.avail_in=y.input.length;do{if(y.avail_out===0&&(y.output=new t.Buf8(h),y.next_out=0,y.avail_out=h),P=e.inflate(y,a.Z_NO_FLUSH),P===a.Z_NEED_DICT&&T&&(P=e.inflateSetDictionary(this.strm,T)),P===a.Z_BUF_ERROR&&L===!0&&(P=a.Z_OK,L=!1),P!==a.Z_STREAM_END&&P!==a.Z_OK)return this.onEnd(P),this.ended=!0,!1;y.next_out&&(y.avail_out===0||P===a.Z_STREAM_END||y.avail_in===0&&(v===a.Z_FINISH||v===a.Z_SYNC_FLUSH))&&(this.options.to==="string"?(_=n.utf8border(y.output,y.next_out),b=y.next_out-_,E=n.buf2string(y.output,_),y.next_out=b,y.avail_out=h-b,b&&t.arraySet(y.output,y.output,_,b,0),this.onData(E)):this.onData(t.shrinkBuf(y.output,y.next_out))),y.avail_in===0&&y.avail_out===0&&(L=!0)}while((y.avail_in>0||y.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),y.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 y=new s(d);if(y.push(f,!0),y.err)throw y.msg||r[y.err];return y.result}function p(f,d){return d=d||{},d.raw=!0,c(f,d)}return jt.Inflate=s,jt.inflate=c,jt.inflateRaw=p,jt.ungzip=c,jt}var so,cr;function cs(){if(cr)return so;cr=1;var e=Ht().assign,t=os(),n=ls(),a=bi(),r={};return e(r,t,n,a),so=r,so}(function(e){(function(){var t={},n;e.exports=t,typeof xo=="function"?n=cs():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],y=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,y,h,0):d.blend==1&&a._copyTile(v,T,P,c,i,l,y,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,y,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),y=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,E=-1,L=-1,I=-1;if(b&&(E=b[0],L=b[1],I=b[2]),T==8)for(var _=0;_<c;_++){var S=_<<2,k=_*3;d[S]=o[k],d[S+1]=o[k+1],d[S+2]=o[k+2],d[S+3]=255,E!=-1&&o[k]==E&&o[k+1]==L&&o[k+2]==I&&(d[S+3]=0)}if(T==16)for(var _=0;_<c;_++){var S=_<<2,k=_*6;d[S]=o[k],d[S+1]=o[k+2],d[S+2]=o[k+4],d[S+3]=255,E!=-1&&P(o,k)==E&&P(o,k+2)==L&&P(o,k+4)==I&&(d[S+3]=0)}}else if(h==3){var B=s.tabs.PLTE,F=s.tabs.tRNS,w=F?F.length:0;if(T==1)for(var D=0;D<l;D++)for(var N=D*f,M=D*i,_=0;_<i;_++){var S=M+_<<2,x=o[N+(_>>3)]>>7-((_&7)<<0)&1,A=3*x;d[S]=B[A],d[S+1]=B[A+1],d[S+2]=B[A+2],d[S+3]=x<w?F[x]:255}if(T==2)for(var D=0;D<l;D++)for(var N=D*f,M=D*i,_=0;_<i;_++){var S=M+_<<2,x=o[N+(_>>2)]>>6-((_&3)<<1)&3,A=3*x;d[S]=B[A],d[S+1]=B[A+1],d[S+2]=B[A+2],d[S+3]=x<w?F[x]:255}if(T==4)for(var D=0;D<l;D++)for(var N=D*f,M=D*i,_=0;_<i;_++){var S=M+_<<2,x=o[N+(_>>1)]>>4-((_&1)<<2)&15,A=3*x;d[S]=B[A],d[S+1]=B[A+1],d[S+2]=B[A+2],d[S+3]=x<w?F[x]:255}if(T==8)for(var _=0;_<c;_++){var S=_<<2,x=o[_],A=3*x;d[S]=B[A],d[S+1]=B[A+1],d[S+2]=B[A+2],d[S+3]=x<w?F[x]: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 E=s.tabs.tRNS?s.tabs.tRNS:-1;if(T==1)for(var _=0;_<c;_++){var $=255*(o[_>>3]>>7-(_&7)&1),U=$==E*255?0:255;y[_]=U<<24|$<<16|$<<8|$}if(T==2)for(var _=0;_<c;_++){var $=85*(o[_>>2]>>6-((_&3)<<1)&3),U=$==E*85?0:255;y[_]=U<<24|$<<16|$<<8|$}if(T==4)for(var _=0;_<c;_++){var $=17*(o[_>>1]>>4-((_&1)<<2)&15),U=$==E*17?0:255;y[_]=U<<24|$<<16|$<<8|$}if(T==8)for(var _=0;_<c;_++){var $=o[_],U=$==E?0:255;y[_]=U<<24|$<<16|$<<8|$}if(T==16)for(var _=0;_<c;_++){var $=o[_<<1],U=P(o,_<<1)==E?0:255;y[_]=U<<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),y=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[y+v]=i[l+v];y+=_}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 E=f.frames[f.frames.length-1];E.data=a.decode._decompress(f,h.slice(0,T),E.rect.width,E.rect.height),T=0}var L={x:p(i,l+12),y:p(i,l+16),width:p(i,l+4),height:p(i,l+8)},I=c(i,l+22);I=c(i,l+20)/(I==0?100:I);var S={rect:L,delay:Math.round(I*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 k=s.nextZero(i,l),B=s.readASCII(i,l,k-l),F=s.readASCII(i,k+1,l+_-k-1);f.tabs[b][B]=F}else if(b=="iTXt"){f.tabs[b]==null&&(f.tabs[b]={});var k=0,w=l;k=s.nextZero(i,w);var B=s.readASCII(i,w,k-w);w=k+1,i[w],i[w+1],w+=2,k=s.nextZero(i,w),s.readASCII(i,w,k-w),w=k+1,k=s.nextZero(i,w),s.readUTF8(i,w,k-w),w=k+1;var F=s.readUTF8(i,w,_-(w-l));f.tabs[b][B]=F}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 E=f.frames[f.frames.length-1];E.data=a.decode._decompress(f,h.slice(0,T),E.rect.width,E.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),y=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[_],E=v[_],L=0,I=0,S=h[_];S<s;)S+=b,I++;for(var k=T[_];k<l;)k+=E,L++;var B=Math.ceil(L*c/8);a.decode._filterZero(o,i,y,L,I);for(var F=0,w=h[_];w<s;){for(var D=T[_],N=y+F*B<<3;D<l;){if(c==1){var M=o[N>>3];M=M>>7-(N&7)&1,d[w*f+(D>>3)]|=M<<7-((D&3)<<0)}if(c==2){var M=o[N>>3];M=M>>6-(N&7)&3,d[w*f+(D>>2)]|=M<<6-((D&3)<<1)}if(c==4){var M=o[N>>3];M=M>>4-(N&7)&15,d[w*f+(D>>1)]|=M<<4-((D&1)<<2)}if(c>=8)for(var x=w*f+D*p,A=0;A<p;A++)d[x+A]=o[(N>>3)+A];N+=c,D+=E}F++,w+=b}L*I!=0&&(y+=I*(1+B)),_=_+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 y=0;y<c;y++){var h=l+y*f,T=h+y+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(y==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,y){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),y==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(y==1){var E=o[P+3]*.00392156862745098,L=o[P]*E,I=o[P+1]*E,S=o[P+2]*E,k=s[v+3]*(1/255),B=s[v]*k,F=s[v+1]*k,w=s[v+2]*k,D=1-E,N=E+k*D,M=N==0?0:1/N;s[v+3]=255*N,s[v+0]=(L+B*D)*M,s[v+1]=(I+F*D)*M,s[v+2]=(S+w*D)*M}else if(y==2){var E=o[P+3],L=o[P],I=o[P+1],S=o[P+2],k=s[v+3],B=s[v],F=s[v+1],w=s[v+2];E==k&&L==B&&I==F&&S==w?(s[v]=0,s[v+1]=0,s[v+2]=0,s[v+3]=0):(s[v]=L,s[v+1]=I,s[v+2]=S,s[v+3]=E)}else if(y==3){var E=o[P+3],L=o[P],I=o[P+1],S=o[P+2],k=s[v+3],B=s[v],F=s[v+1],w=s[v+2];if(E==k&&L==B&&I==F&&S==w)continue;if(E<220&&k>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],y=0;y<8;y++)f[y]=d[y];var h=8,T=a._bin,P=a.crc.crc,v=T.writeUint,_=T.writeUshort,b=T.writeASCII,E=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]=E.depth,h++,f[h]=E.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 L=o.length>1;if(L&&(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),E.ctype==3){var I=E.plte.length;v(f,h,I*3),h+=4,b(f,h,"PLTE"),h+=4;for(var y=0;y<I;y++){var S=y*3,k=E.plte[y],B=k&255,F=k>>8&255,w=k>>16&255;f[h+S+0]=B,f[h+S+1]=F,f[h+S+2]=w}if(h+=I*3,v(f,h,P(f,h-I*3-4,I*3+4)),h+=4,E.gotAlpha){v(f,h,I),h+=4,b(f,h,"tRNS"),h+=4;for(var y=0;y<I;y++)f[h+y]=E.plte[y]>>24&255;h+=I,v(f,h,P(f,h-I-4,I+4)),h+=4}}for(var D=0,N=0;N<E.frames.length;N++){var M=E.frames[N];L&&(v(f,h,26),h+=4,b(f,h,"fcTL"),h+=4,v(f,h,D++),h+=4,v(f,h,M.rect.width),h+=4,v(f,h,M.rect.height),h+=4,v(f,h,M.rect.x),h+=4,v(f,h,M.rect.y),h+=4,_(f,h,c[N]),h+=2,_(f,h,1e3),h+=2,f[h]=M.dispose,h++,f[h]=M.blend,h++,v(f,h,P(f,h-30,30)),h+=4);var x=M.cimg,I=x.length;v(f,h,I+(N==0?0:4)),h+=4;var A=h;b(f,h,N==0?"IDAT":"fdAT"),h+=4,N!=0&&(v(f,h,D++),h+=4);for(var y=0;y<I;y++)f[h+y]=x[y];h+=I,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 y=d.rect.height,h=d.bpl,T=d.bpp,P=new Uint8Array(y*h+y);d.cimg=a.encode._filterZero(d.img,y,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,y=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,E={},L=[];if(o.length!=0&&(E[0]=0,L.push(0),s!=0&&s--),s!=0){var I=a.quantize(o,s,c);o=I.bufs;for(var _=0;_<I.plte.length;_++){var S=I.plte[_].est.rgba;E[S]==null&&(E[S]=L.length,L.push(S))}}else for(var T=0;T<o.length;T++)for(var k=new Uint32Array(o[T]),v=k.length,_=0;_<v;_++){var S=k[_];if((_<i||S!=k[_-1]&&S!=k[_-i])&&E[S]==null&&(E[S]=L.length,L.push(S),L.length>=300))break}var B=b?c:!1,F=L.length;F<=256&&p==!1&&(F<=2?d=1:F<=4?d=2:F<=16?d=4:d=8,c&&(d=8),b=!0);for(var w=[],T=0;T<o.length;T++){var D=new Uint8Array(o[T]),N=new Uint32Array(D.buffer),M=0,x=0,A=i,V=l,$=0;if(T!=0&&!B){for(var U=c||T==1||w[w.length-2].dispose==2?1:2,re=0,oe=1e9,G=0;G<U;G++){for(var ge=new Uint8Array(o[T-1-G]),ae=new Uint32Array(o[T-1-G]),ne=i,j=l,Y=-1,ce=-1,le=0;le<l;le++)for(var X=0;X<i;X++){var _=le*i+X;N[_]!=ae[_]&&(X<ne&&(ne=X),X>Y&&(Y=X),le<j&&(j=le),le>ce&&(ce=le))}var Pe=Y==-1?1:(Y-ne+1)*(ce-j+1);Pe<oe&&(oe=Pe,re=G,Y==-1?(M=x=0,A=V=1):(M=ne,x=j,A=Y-ne+1,V=ce-j+1))}var ge=new Uint8Array(o[T-1-re]);re==1&&(w[w.length-1].dispose=2);var H=new Uint8Array(A*V*4);new Uint32Array(H.buffer),a._copyTile(ge,i,l,H,A,V,-M,-x,0),a._copyTile(D,i,l,H,A,V,-M,-x,3)?(a._copyTile(D,i,l,H,A,V,-M,-x,2),$=1):(a._copyTile(D,i,l,H,A,V,-M,-x,0),$=0),D=H,N=new Uint32Array(D.buffer)}var Q=4*A;if(F<=256&&p==!1){Q=Math.ceil(d*A/8);for(var H=new Uint8Array(Q*V),le=0;le<V;le++){var _=le*Q,Ee=le*A;if(d==8)for(var X=0;X<A;X++)H[_+X]=E[N[Ee+X]];else if(d==4)for(var X=0;X<A;X++)H[_+(X>>1)]|=E[N[Ee+X]]<<4-(X&1)*4;else if(d==2)for(var X=0;X<A;X++)H[_+(X>>2)]|=E[N[Ee+X]]<<6-(X&3)*2;else if(d==1)for(var X=0;X<A;X++)H[_+(X>>3)]|=E[N[Ee+X]]<<7-(X&7)*1}D=H,f=3,y=1}else if(b==!1&&o.length==1){for(var H=new Uint8Array(A*V*3),be=A*V,_=0;_<be;_++){var ee=_*3,he=_*4;H[ee]=D[he],H[ee+1]=D[he+1],H[ee+2]=D[he+2]}D=H,f=2,y=3,Q=3*A}w.push({rect:{x:M,y:x,width:A,height:V},img:D,bpl:Q,bpp:y,blend:$,dispose:B?1:0})}return{ctype:f,depth:d,plte:L,gotAlpha:b,frames:w}},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 y,h=1e9,T=0;T<p.length;T++)p[T].length<h&&(y=T,h=p[T].length);return p[y]},a.encode._filterLine=function(o,i,l,s,c,p){var f=l*s,d=f+l,y=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]-y(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-y(0,i[f+h-s],0)&255;for(var h=c;h<s;h++)o[d+h]=i[f+h]+256-y(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),y=0,p=0;p<s.length;p++){for(var h=s[p],T=h.length,P=0;P<T;P++)f[y+P]=h[P];y+=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,E=0,p=0;p<_.length;p++)_[p].est.L>b&&(b=_[p].est.L,E=p);if(b<.001)break;var L=_[E],I=a.quantize.splitPixels(f,d,L.i0,L.i1,L.est.e,L.est.eMq255),S={i0:L.i0,i1:I,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 k={i0:I,i1:L.i1,bst:null,est:null,tdst:0,left:null,right:null};k.bst={R:[],m:[],N:L.bst.N-S.bst.N};for(var p=0;p<16;p++)k.bst.R[p]=L.bst.R[p]-S.bst.R[p];for(var p=0;p<4;p++)k.bst.m[p]=L.bst.m[p]-S.bst.m[p];k.est=a.quantize.estats(k.bst),L.left=S,L.right=k,_[E]=S,_.push(k)}_.sort(function(U,re){return re.bst.N-U.bst.N});for(var B=0;B<s.length;B++){for(var F=a.quantize.planeDst,w=new Uint8Array(s[B].buffer),D=new Uint32Array(s[B].buffer),N=w.length,p=0;p<N;p+=4){for(var M=w[p]*.00392156862745098,x=w[p+1]*(1/255),A=w[p+2]*(1/255),V=w[p+3]*(1/255),$=v;$.left;)$=F($.est,M,x,A,V)<=0?$.left:$.right;D[p>>2]=$.est.rgba}s[B]=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 y=a.quantize.getNearest(f,i,l,s,c);if(y.tdst<=p*p)return y;var h=a.quantize.getNearest(d,i,l,s,c);return h.tdst<y.tdst?h:y},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],y=c-o[3];return p*p+f*f+d*d+y*y},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,y=o[f+1]*(1/255),h=o[f+2]*(1/255),T=o[f+3]*(1/255);c[0]+=d,c[1]+=y,c[2]+=h,c[3]+=T,s[0]+=d*d,s[1]+=d*y,s[2]+=d*h,s[3]+=d*T,s[5]+=y*y,s[6]+=y*h,s[7]+=y*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],y=s==0?0:1/s,h=[i[0]-c*c*y,i[1]-c*p*y,i[2]-c*f*y,i[3]-c*d*y,i[4]-p*c*y,i[5]-p*p*y,i[6]-p*f*y,i[7]-p*d*y,i[8]-f*c*y,i[9]-f*p*y,i[10]-f*f*y,i[11]-f*d*y,i[12]-d*c*y,i[13]-d*p*y,i[14]-d*f*y,i[15]-d*d*y],T=h,P=a.M4,v=[.5,.5,.5,.5],_=0,b=0;if(s!=0)for(var E=0;E<10&&(v=P.multVec(T,v),b=Math.sqrt(P.dot(v,v)),v=P.sml(1/b,v),!(Math.abs(b-_)<1e-9));E++)_=b;var L=[c*y,p*y,f*y,d*y],I=P.dot(P.sml(255,L),v),S=L[3]<.001?0:1/L[3];return{Cov:h,q:L,e:v,L:_,eMq255:I,eMq:P.dot(v,L),rgba:(Math.round(255*L[3])<<24|Math.round(255*L[2]*S)<<16|Math.round(255*L[1]*S)<<8|Math.round(255*L[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)})()})(Ci);var us=Ci.exports;const fs=yi(us),ds=es.unstable_batchedUpdates,ps={batchUpdate:ds},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),ki=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(),hs=e=>{if(e instanceof u.ArcRotateCamera){const t=e.alpha;return(t>0?t:Math.PI-t)/Math.PI*180%360}return 0},ms=e=>{const t=[];return e.forEach(n=>{t.push(Ei(n))}),t},Ei=e=>new u.Vector3(e.x,e.y,e.z),At=e=>new u.Vector3(e.x,e.y,e.z),gs=e=>new u.Color3(e.r,e.g,e.b);var xn=(e=>(e[e.START=0]="START",e[e.CONTINUE=1]="CONTINUE",e[e.END=2]="END",e))(xn||{}),$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||{}),Ni=(e=>(e[e.ClockWiseSideOrientation=u.Material.ClockWiseSideOrientation]="ClockWiseSideOrientation",e[e.CounterClockWiseSideOrientation=u.Material.CounterClockWiseSideOrientation]="CounterClockWiseSideOrientation",e))(Ni||{}),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),Eo=m.createContext({viewCamera:void 0,setViewCamera:()=>{},cameraRefObject:void 0}),Lt=m.createContext({colorIDs:{},colorCodecs:{}}),Dn=m.createContext(null);var No=(e=>(e[e.ENGINE_DEFAULT=0]="ENGINE_DEFAULT",e[e.NONE=1]="NONE",e))(No||{});const Io=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}),Ii=m.createContext(null),vs=(e,t)=>{var ge,H,Q,Ee,be;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:ee=>new Promise(he=>{he(ee)}),onFinish:()=>{console.log("Loaded")},onProgress:(ee,he)=>{console.log(`Loading ${ee} of ${he}`)},useLoadingScreen:1}}=e,i=_e.useScene(),l=_e.useCanvas(),[s,c]=m.useState(void 0),p=m.useRef({}),[f,d]=m.useState({}),y=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),E=m.useRef(null),L=m.useRef(!1),I=m.useRef(null),S=m.useRef([]),k=m.useRef(null),B=m.useRef(0),F=m.useRef(new WeakMap),w=m.useRef(1),D=m.useRef(new Map),N=m.useRef(0),M=m.useRef({isDown:!1,pointerId:-1,startX:0,startY:0,isDragging:!1});m.useEffect(()=>{if(r.colorCodecs){console.log("[Geo3DViewer] 开始色标刷新");const ee={};if(Object.keys(r.colorCodecs).forEach(ue=>{console.log(`[Geo3DViewer] 正在生成色标 ${ue}`);const me=r.colorCodecs[ue],Ie=new Uint8Array(me.array.length*4);me.array.forEach((Ne,we)=>{Ie[we*4+0]=Math.trunc(Ne.r*255),Ie[we*4+1]=Math.trunc(Ne.g*255),Ie[we*4+2]=Math.trunc(Ne.b*255),Ie[we*4+3]=255}),console.log(`[Geo3DViewer] 正在创建色标采样贴图 ${ue}`);const ke=u.RawTexture.CreateRGBATexture(Ie,1,me.array.length,i,!0,!1);ke.name=`color-codec-${ue}`,console.log(`[Geo3DViewer] 正在创建色标图例 ${ue}`);const Ae=URL.createObjectURL(new Blob([fs.encode([Ie.buffer],1,me.array.length,0)]));console.log(`[Geo3DViewer] 正在构建色标 ${ue}`),ee[ue]={blobUrl:Ae,min:me.min,max:me.max,texture:ke}}),i){console.log(`[Geo3DViewer] 正在移除原有色标 共 ${Object.keys(p.current).length} 个`),Object.keys(p.current).forEach(me=>{console.log(`[Geo3DViewer] 正在移除色标 ${me}`),i.removeTexture(p.current[me].texture),p.current[me].texture.dispose(),URL.revokeObjectURL(p.current[me].blobUrl)}),p.current=ee;const ue=i.getMaterialByTags("remap");console.log("[Geo3DViewer] 已完成色标刷新,正在更新关联的材质"),ue.forEach(me=>{me instanceof u.ShaderMaterial?me.setTexture("textureSampler",ee[me.metadata.colorCodec].texture):(me.getBlockByName("RemappedTexture").texture=ee[me.metadata.colorCodec].texture,me.markAsDirty(u.NodeMaterial.TextureDirtyFlag))}),console.log(`[Geo3DViewer] 已有 ${ue.length} 个材质执行了更新`)}}},[r.colorCodecs,i]);const x=m.useCallback(ee=>!ee||ee.isDisposed()||!ee.metadata||!("pickable"in ee.metadata)||!ee.metadata.pickable?null:ee.metadata.pickable,[]),A=m.useCallback(ee=>!!(ee&&(ee.onHover||ee.onLeftClick||ee.onMiddleClick||ee.onRightClick)),[]),V=m.useCallback(ee=>{if(l){if(ee&&(ee.onLeftClick||ee.onMiddleClick||ee.onRightClick)){l.style.setProperty("cursor","pointer");return}l.style.setProperty("cursor","default")}},[l]),$=m.useCallback(()=>{var he;const ee=(he=E.current)==null?void 0:he._pickingTexture;b.current!==(ee!=null?ee:null)&&(b.current=ee!=null?ee:null,_(ue=>ue+1))},[]),U=m.useCallback(ee=>{const he=F.current.get(ee);if(he)return he;const ue=w.current++;return F.current.set(ee,ue),ue},[]),re=m.useCallback(()=>{const ee=[],he=new Set;if(!i)return ee;i.meshes.forEach(me=>{if(!me||me.isDisposed())return;const Ie=x(me);if(!(!(A(Ie)&&me.isEnabled()&&me.isVisible&&me.isReady(!0)&&me.isPickable)||he.has(me))&&(he.add(me),ee.push(me),me.isAnInstance)){const Ae=me.sourceMesh;Ae&&!Ae.isDisposed()&&Ae.isEnabled()&&Ae.isVisible&&Ae.isReady(!0)&&!he.has(Ae)&&(he.add(Ae),ee.push(Ae))}});const ue=S.current.length===ee.length&&S.current.every((me,Ie)=>me===ee[Ie]);return E.current||(E.current=new xi.GPUPicker),ue||(E.current.setPickingList(ee.length>0?ee.slice():null),S.current=ee,$()),ee},[x,A,i,$]),oe=m.useCallback(async(ee,he)=>{if(!i)return null;if(!re().length||!E.current)return $(),null;$();const me=await E.current.pickAsync(ee,he,!1);return $(),me},[i,re,$]);m.useEffect(()=>{if(!i)return;const ee=i.onBeforeRenderObservable.add(()=>{re()});return()=>{i.onBeforeRenderObservable.remove(ee)}},[i,re]);const G=m.useCallback((ee,he,ue)=>i?i.pick(he,ue,me=>me===ee,!1,void 0):null,[i]),ae=m.useCallback(()=>{B.current+=1,D.current.clear()},[]),ne=m.useCallback(ee=>new Proxy({},{get:(he,ue)=>{const me=ee();if(!me)return;const Ie=me[ue];return typeof Ie=="function"?Ie.bind(me):Ie},set:(he,ue,me)=>{const Ie=ee();return Ie?(Ie[ue]=me,!0):!1},has:(he,ue)=>{const me=ee();return me?ue in me:!1},ownKeys:()=>{const he=ee();return he?Reflect.ownKeys(he):[]},getOwnPropertyDescriptor:(he,ue)=>{const me=ee();if(me)return Object.getOwnPropertyDescriptor(me,ue)}}),[]),j=m.useCallback((ee,he,ue)=>{const me=B.current,Ie=U(ee),ke=`${me}:${Ie}:${Math.round(he)}:${Math.round(ue)}`,Ae=()=>{var Be,Ge,Ke;const Ne=D.current.get(ke);if(Ne)return Ne;const we=G(ee,he,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,We={raw:Re,world:Ve};return D.current.set(ke,We),We};return{rawWorldPosition:ne(()=>Ae().raw),worldPosition:ne(()=>Ae().world)}},[ne,U,G,a.origin]),Y=m.useCallback((ee,he,ue,me,Ie)=>{var Re,Ve;const ke=x(ee);if(!ke||!ke.onHover)return;const Ae=new u.Vector2(ue.clientX,ue.clientY),Ne=he!==xn.END&&ke.needWorldPosition?j(ee,me,Ie):null,we=ke.valueCallback?ke.valueCallback(Ae,(Re=Ne==null?void 0:Ne.worldPosition)!=null?Re:null,(Ve=Ne==null?void 0:Ne.rawWorldPosition)!=null?Ve:null):null;ke.onHover(ke.name,Ae,Ne==null?void 0:Ne.worldPosition,he,we,ke.extra)},[j,x]),ce=m.useCallback((ee,he)=>{const ue=ee&&x(ee)&&A(x(ee))?ee:null,me=I.current;me&&me!==ue&&Y(me,xn.END,he.event,he.x,he.y),ue&&Y(ue,me===ue?xn.CONTINUE:xn.START,he.event,he.x,he.y),I.current=ue,V(ue?x(ue):null)},[x,A,Y,V]),le=m.useCallback(async()=>{var ee;if(!L.current){for(L.current=!0;k.current;){const he=k.current;if(k.current=null,!i||i.skipPointerMovePicking){ce(null,he);continue}const ue=await oe(he.x,he.y),me=(ee=ue==null?void 0:ue.mesh)!=null?ee:null;if(ae(),i.skipPointerMovePicking){ce(null,he);continue}ce(me,he)}L.current=!1}},[ae,oe,i,ce]),X=m.useCallback(async(ee,he,ue)=>{var Re;if(!i)return;for(;L.current;)await new Promise(Ve=>setTimeout(Ve,8));if(Date.now()-N.current<100){N.current=Date.now();return}N.current=Date.now();const me=await oe(he,ue);ae();const Ie=(Re=me==null?void 0:me.mesh)!=null?Re:null,ke=x(Ie);if(console.log(`[Geo3DViewer] 指针拾取 ${!!Ie} 于面 ${Ie}`,ke,me),!Ie||!ke)return;const Ae=new u.Vector2(ee.clientX,ee.clientY),Ne=j(Ie,he,ue),we=ke.valueCallback?ke.valueCallback(Ae,Ne.worldPosition,Ne.rawWorldPosition):null;if(ee.button===0&&ke.onLeftClick){ke.onLeftClick(ke.name,Ae,Ne.worldPosition,we,ke.extra);return}if(ee.button===1&&ke.onMiddleClick){ke.onMiddleClick(ke.name,Ae,Ne.worldPosition,we,ke.extra);return}ee.button===2&&ke.onRightClick&&ke.onRightClick(ke.name,Ae,Ne.worldPosition,we,ke.extra)},[ae,j,x,oe,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 ee=4,he=i.onPointerObservable.add(ue=>{const me=ue.event;if(ue.type===u.PointerEventTypes.POINTERDOWN){M.current.isDown=!0,M.current.pointerId=me.pointerId,M.current.startX=i.pointerX,M.current.startY=i.pointerY,M.current.isDragging=!1;return}if(ue.type===u.PointerEventTypes.POINTERMOVE){if(M.current.isDown&&M.current.pointerId===me.pointerId&&!M.current.isDragging){const Ie=i.pointerX-M.current.startX,ke=i.pointerY-M.current.startY;Ie*Ie+ke*ke>=ee*ee&&(M.current.isDragging=!0)}if(i.skipPointerMovePicking||M.current.isDragging){I.current&&ce(null,{event:me,x:i.pointerX,y:i.pointerY});return}k.current={event:me,x:i.pointerX,y:i.pointerY},le();return}if(ue.type===u.PointerEventTypes.POINTERUP){const Ie=M.current.isDragging;if(M.current.isDown=!1,M.current.pointerId=-1,M.current.isDragging=!1,i.skipPointerMovePicking||Ie)return;X(me,i.pointerX,i.pointerY)}});return()=>{i.onPointerObservable.remove(he),k.current=null,I.current=null,M.current.isDown=!1,M.current.pointerId=-1,M.current.isDragging=!1,V(null)}},[X,le,i,V,ce]),m.useEffect(()=>()=>{var ee;k.current=null,S.current=[],I.current=null,D.current.clear(),(ee=E.current)==null||ee.dispose(),E.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:(be=a._isDefault)!=null?be:!0,origin:u.Vector3.Zero()},children:C.jsx(Eo.Provider,{value:{viewCamera:s,setViewCamera:c,cameraRefObject:Pe},children:C.jsx(Io.Provider,{value:o,children:C.jsxs(wo.Provider,{value:{cache:f,setCache:d,loadedCount:h,totalCount:y,pending:T,inflight:P,reported:v},children:[C.jsx(Cs,{}),C.jsx(Dn.Provider,{value:{colorCodecsImage:p},children:C.jsx(Lt.Provider,{value:r,children:C.jsx(Ii.Provider,{value:{gpuPickingTexture:b},children:n})})})]})})})})},xs=m.forwardRef(vs),ys=new TextDecoder;var Me=(e=>(e[e.URL_PREFIX_MATCH=0]="URL_PREFIX_MATCH",e[e.EXACTLY_MATCH=1]="EXACTLY_MATCH",e))(Me||{}),wi=(e=>(e[e.BINARY=0]="BINARY",e[e.TEXTURE=1]="TEXTURE",e[e.MODEL=2]="MODEL",e[e.JSON=3]="JSON",e))(wi||{});const zn=({url:e,cacheType:t=0,assetType:n=0})=>{var L,I,S,k,B,F;const a=_e.useScene(),{onPreFetch:r}=m.useContext(Io),o=m.useContext(wo),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=(L=o==null?void 0:o.cache)!=null?L:{},y=(I=o==null?void 0:o.setCache)!=null?I:()=>{},h=(S=o==null?void 0:o.loadedCount)!=null?S:l,T=(k=o==null?void 0:o.totalCount)!=null?k:i,P=(B=o==null?void 0:o.pending)!=null?B:s,v=(F=o==null?void 0:o.inflight)!=null?F:c,_=m.useCallback(async w=>{let D=1,N;for(;D>=0;)try{return(await Wt.get(w,{responseType:"arraybuffer",timeout:2e4})).data}catch(M){N=M,D-=1,D>=0&&await new Promise(x=>setTimeout(x,300))}throw N},[]),b=m.useCallback((w,D)=>{if(w){if(D===1)return d[w];if(D===0){const N=w.split("?")[0];return d[N]}}},[d]),E=m.useCallback(async(w,D,N)=>{const M=v.current.get(w);if(M){const A=await M;A&&f(A);return}const x=(async()=>{P.current.add(w),T.current=T.current+1;try{const A=await r(w),V=[];A!==w&&V.push(w),D===0?(V.push(A.split("?")[0]),V.push(A)):D===1&&V.push(A);const $=await _(A),U={};let re;if(N===0)re={buffer:$};else if(N===1){const oe=URL.createObjectURL(new Blob([$])),G=new u.Texture(oe,a,!0,!1,void 0,()=>{URL.revokeObjectURL(oe)},()=>{URL.revokeObjectURL(oe)});re={buffer:$,texture:G}}else if(N===2){if(!a)throw new Error("Scene not ready for model loading");const oe=URL.createObjectURL(new Blob([$]));try{let G=A.split("?")[0];G=(G==null?void 0:G.split(".").pop())||"";const ae=await u.LoadAssetContainerAsync(oe,a,{pluginExtension:`.${G}`});re={buffer:$,assets:ae}}finally{URL.revokeObjectURL(oe)}}else re={buffer:$,json:JSON.parse(ys.decode($))};return V.forEach(oe=>{U[oe]=re}),y(oe=>{let G=!1;const ae={...oe};return V.forEach(ne=>{ae[ne]||(ae[ne]=re,G=!0)}),G?ae:oe}),h.current=h.current+1,f(re),re}catch(A){console.error(A),h.current=h.current+1;return}finally{P.current.delete(w),v.current.delete(w)}})();v.current.set(w,x),await x},[_,r,v,h,P,y,T,a]);return m.useEffect(()=>{if(e){const w=b(e,t);if(w){f(w);return}P.current.has(e)||E(e,t,n)}},[n,t,E,b,P,e]),p},je=({url:e,cacheType:t=0})=>{const n=zn({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=zn({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},Oi=({url:e,cacheType:t=0})=>{const n=zn({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},wo=m.createContext(void 0),Cs=()=>{var b,E,L,I;const e=_e.useScene(),t=_e.useEngine(),{onFinish:n,onProgress:a,useLoadingScreen:r,hideLoadingWhenPostCalculate:o}=m.useContext(Io),i=m.useContext(wo),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=(E=i==null?void 0:i.loadedCount)!=null?E:s,y=(L=i==null?void 0:i.reported)!=null?L:c,h=(I=i==null?void 0:i.pending)!=null?I:p,T=m.useRef(null),P=Array.isArray(h.current)?h.current.length:h.current.size,v=m.useCallback(S=>{r===No.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&&y&&y.current){if(y.current.lastReportedLoaded!=d.current||y.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||(()=>{}),k=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&&(k(),v(!1)):d.current===f.current&&(k(),v(!1))}y.current.lastReportedLoaded=d.current,y.current.lastReportedTotal=f.current}},[y,d,f,a,h,v,o,e,n]);return m.useEffect(()=>{_();const S=setInterval(()=>{_()},1e3);return()=>clearInterval(S)},[_]),C.jsx(C.Fragment,{})},_s=({url:e,cacheType:t,assetType:n=wi.BINARY})=>(zn({url:e,cacheType:t,assetType:n}),C.jsx(C.Fragment,{}));class Ps{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 Ai={},lo={},Ss=Ts;function Ts(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 Mi={};(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,y=0,h;s<c;){var T=l[s++];switch(y){case 0:f[d++]=n[T>>2],h=(T&3)<<4,y=1;break;case 1:f[d++]=n[h|T>>4],h=(T&15)<<2,y=2;break;case 2:f[d++]=n[h|T>>6],f[d++]=n[T&63],y=0;break}d>8191&&((p||(p=[])).push(String.fromCharCode.apply(String,f)),d=0)}return y&&(f[d++]=n[h],f[d++]=61,y===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,y=0;y<l.length;){var h=l.charCodeAt(y++);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)}})(Mi);var bs=Vn;function Vn(){this._listeners=Object.create(null)}Vn.prototype.on=function(t,n,a){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:n,ctx:a||this}),this};Vn.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};Vn.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 ks=ur(ur);function ur(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,fr),e.writeFloatBE=t.bind(null,dr);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,pr),e.readFloatBE=n.bind(null,hr)}(),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,fr,0,4),e.writeDoubleBE=t.bind(null,dr,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,pr,0,4),e.readDoubleBE=n.bind(null,hr,4,0)}(),e}function fr(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 dr(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 pr(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function hr(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}var Es=Ns;function Ns(e){try{if(typeof xo!="function")return null;var t=xo(e);return t&&(t.length||Object.keys(t).length)?t:null}catch(n){return null}}var Li={};(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}})(Li);var Is=ws;function ws(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 co,mr;function Os(){if(mr)return co;mr=1,co=t;var e=Kt();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},co}var Nn={exports:{}},gr;function As(){return gr||(gr=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(M){}function r(M,v,A){this.low=M|0,this.high=v|0,this.unsigned=!!A}r.prototype.__isLong__,Object.defineProperty(r.prototype,"__isLong__",{value:!0});function o(M){return(M&&M.__isLong__)===!0}function i(M){var v=Math.clz32(M&-M);return M?31-v:v}r.isLong=o;var l={},s={};function c(M,v){var A,V,$;return v?(M>>>=0,($=0<=M&&M<256)&&(V=s[M],V)?V:(A=u(M,0,!0),$&&(s[M]=A),A)):(M|=0,($=-128<=M&&M<128)&&(V=l[M],V)?V:(A=u(M,M<0?-1:0,!1),$&&(l[M]=A),A))}r.fromInt=c;function p(M,v){if(isNaN(M))return v?I:L;if(v){if(M<0)return I;if(M>=_)return w}else{if(M<=-b)return D;if(M+1>=b)return F}return M<0?p(-M,v).neg():u(M%y|0,M/y|0,v)}r.fromNumber=p;function u(M,v,A){return new r(M,v,A)}r.fromBits=u;var d=Math.pow;function x(M,v,A){if(M.length===0)throw Error("empty string");if(typeof v=="number"?(A=v,v=!1):v=!!v,M==="NaN"||M==="Infinity"||M==="+Infinity"||M==="-Infinity")return v?I:L;if(A=A||10,A<2||36<A)throw RangeError("radix");var V;if((V=M.indexOf("-"))>0)throw Error("interior hyphen");if(V===0)return x(M.substring(1),v,A).neg();for(var $=p(d(A,8)),U=L,ie=0;ie<M.length;ie+=8){var ne=Math.min(8,M.length-ie),G=parseInt(M.substring(ie,ie+ne),A);if(ne<8){var ae=p(d(A,ne));U=U.mul(ae).add(p(G))}else U=U.mul($),U=U.add(p(G))}return U.unsigned=v,U}r.fromString=x;function h(M,v){return typeof M=="number"?p(M,v):typeof M=="string"?x(M,v):u(M.low,M.high,typeof v=="boolean"?v:M.unsigned)}r.fromValue=h;var T=65536,P=1<<24,y=T*T,_=y*y,b=_/2,k=c(P),L=c(0);r.ZERO=L;var I=c(0,!0);r.UZERO=I;var S=c(1);r.ONE=S;var E=c(1,!0);r.UONE=E;var B=c(-1);r.NEG_ONE=B;var F=u(-1,2147483647,!1);r.MAX_VALUE=F;var w=u(-1,-1,!0);r.MAX_UNSIGNED_VALUE=w;var D=u(0,-2147483648,!1);r.MIN_VALUE=D;var N=r.prototype;N.toInt=function(){return this.unsigned?this.low>>>0:this.low},N.toNumber=function(){return this.unsigned?(this.high>>>0)*y+(this.low>>>0):this.high*y+(this.low>>>0)},N.toString=function(v){if(v=v||10,v<2||36<v)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(D)){var A=p(v),V=this.div(A),$=V.mul(A).sub(this);return V.toString(v)+$.toInt().toString(v)}else return"-"+this.neg().toString(v);for(var U=p(d(v,6),this.unsigned),ie=this,ne="";;){var G=ie.div(U),ae=ie.sub(G.mul(U)).toInt()>>>0,oe=ae.toString(v);if(ie=G,ie.isZero())return oe+ne;for(;oe.length<6;)oe="0"+oe;ne=""+oe+ne}},N.getHighBits=function(){return this.high},N.getHighBitsUnsigned=function(){return this.high>>>0},N.getLowBits=function(){return this.low},N.getLowBitsUnsigned=function(){return this.low>>>0},N.getNumBitsAbs=function(){if(this.isNegative())return this.eq(D)?64:this.neg().getNumBitsAbs();for(var v=this.high!=0?this.high:this.low,A=31;A>0&&!(v&1<<A);A--);return this.high!=0?A+33:A+1},N.isSafeInteger=function(){var v=this.high>>21;return v?this.unsigned?!1:v===-1&&!(this.low===0&&this.high===-2097152):!0},N.isZero=function(){return this.high===0&&this.low===0},N.eqz=N.isZero,N.isNegative=function(){return!this.unsigned&&this.high<0},N.isPositive=function(){return this.unsigned||this.high>=0},N.isOdd=function(){return(this.low&1)===1},N.isEven=function(){return(this.low&1)===0},N.equals=function(v){return o(v)||(v=h(v)),this.unsigned!==v.unsigned&&this.high>>>31===1&&v.high>>>31===1?!1:this.high===v.high&&this.low===v.low},N.eq=N.equals,N.notEquals=function(v){return!this.eq(v)},N.neq=N.notEquals,N.ne=N.notEquals,N.lessThan=function(v){return this.comp(v)<0},N.lt=N.lessThan,N.lessThanOrEqual=function(v){return this.comp(v)<=0},N.lte=N.lessThanOrEqual,N.le=N.lessThanOrEqual,N.greaterThan=function(v){return this.comp(v)>0},N.gt=N.greaterThan,N.greaterThanOrEqual=function(v){return this.comp(v)>=0},N.gte=N.greaterThanOrEqual,N.ge=N.greaterThanOrEqual,N.compare=function(v){if(o(v)||(v=h(v)),this.eq(v))return 0;var A=this.isNegative(),V=v.isNegative();return A&&!V?-1:!A&&V?1:this.unsigned?v.high>>>0>this.high>>>0||v.high===this.high&&v.low>>>0>this.low>>>0?-1:1:this.sub(v).isNegative()?-1:1},N.comp=N.compare,N.negate=function(){return!this.unsigned&&this.eq(D)?D:this.not().add(S)},N.neg=N.negate,N.add=function(v){o(v)||(v=h(v));var A=this.high>>>16,V=this.high&65535,$=this.low>>>16,U=this.low&65535,ie=v.high>>>16,ne=v.high&65535,G=v.low>>>16,ae=v.low&65535,oe=0,j=0,Y=0,ce=0;return ce+=U+ae,Y+=ce>>>16,ce&=65535,Y+=$+G,j+=Y>>>16,Y&=65535,j+=V+ne,oe+=j>>>16,j&=65535,oe+=A+ie,oe&=65535,u(Y<<16|ce,oe<<16|j,this.unsigned)},N.subtract=function(v){return o(v)||(v=h(v)),this.add(v.neg())},N.sub=N.subtract,N.multiply=function(v){if(this.isZero())return this;if(o(v)||(v=h(v)),a){var A=a.mul(this.low,this.high,v.low,v.high);return u(A,a.get_high(),this.unsigned)}if(v.isZero())return this.unsigned?I:L;if(this.eq(D))return v.isOdd()?D:L;if(v.eq(D))return this.isOdd()?D:L;if(this.isNegative())return v.isNegative()?this.neg().mul(v.neg()):this.neg().mul(v).neg();if(v.isNegative())return this.mul(v.neg()).neg();if(this.lt(k)&&v.lt(k))return p(this.toNumber()*v.toNumber(),this.unsigned);var V=this.high>>>16,$=this.high&65535,U=this.low>>>16,ie=this.low&65535,ne=v.high>>>16,G=v.high&65535,ae=v.low>>>16,oe=v.low&65535,j=0,Y=0,ce=0,le=0;return le+=ie*oe,ce+=le>>>16,le&=65535,ce+=U*oe,Y+=ce>>>16,ce&=65535,ce+=ie*ae,Y+=ce>>>16,ce&=65535,Y+=$*oe,j+=Y>>>16,Y&=65535,Y+=U*ae,j+=Y>>>16,Y&=65535,Y+=ie*G,j+=Y>>>16,Y&=65535,j+=V*oe+$*ae+U*G+ie*ne,j&=65535,u(ce<<16|le,j<<16|Y,this.unsigned)},N.mul=N.multiply,N.divide=function(v){if(o(v)||(v=h(v)),v.isZero())throw Error("division by zero");if(a){if(!this.unsigned&&this.high===-2147483648&&v.low===-1&&v.high===-1)return this;var A=(this.unsigned?a.div_u:a.div_s)(this.low,this.high,v.low,v.high);return u(A,a.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?I:L;var V,$,U;if(this.unsigned){if(v.unsigned||(v=v.toUnsigned()),v.gt(this))return I;if(v.gt(this.shru(1)))return E;U=I}else{if(this.eq(D)){if(v.eq(S)||v.eq(B))return D;if(v.eq(D))return S;var ie=this.shr(1);return V=ie.div(v).shl(1),V.eq(L)?v.isNegative()?S:B:($=this.sub(v.mul(V)),U=V.add($.div(v)),U)}else if(v.eq(D))return this.unsigned?I:L;if(this.isNegative())return v.isNegative()?this.neg().div(v.neg()):this.neg().div(v).neg();if(v.isNegative())return this.div(v.neg()).neg();U=L}for($=this;$.gte(v);){V=Math.max(1,Math.floor($.toNumber()/v.toNumber()));for(var ne=Math.ceil(Math.log(V)/Math.LN2),G=ne<=48?1:d(2,ne-48),ae=p(V),oe=ae.mul(v);oe.isNegative()||oe.gt($);)V-=G,ae=p(V,this.unsigned),oe=ae.mul(v);ae.isZero()&&(ae=S),U=U.add(ae),$=$.sub(oe)}return U},N.div=N.divide,N.modulo=function(v){if(o(v)||(v=h(v)),a){var A=(this.unsigned?a.rem_u:a.rem_s)(this.low,this.high,v.low,v.high);return u(A,a.get_high(),this.unsigned)}return this.sub(this.div(v).mul(v))},N.mod=N.modulo,N.rem=N.modulo,N.not=function(){return u(~this.low,~this.high,this.unsigned)},N.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},N.clz=N.countLeadingZeros,N.countTrailingZeros=function(){return this.low?i(this.low):i(this.high)+32},N.ctz=N.countTrailingZeros,N.and=function(v){return o(v)||(v=h(v)),u(this.low&v.low,this.high&v.high,this.unsigned)},N.or=function(v){return o(v)||(v=h(v)),u(this.low|v.low,this.high|v.high,this.unsigned)},N.xor=function(v){return o(v)||(v=h(v)),u(this.low^v.low,this.high^v.high,this.unsigned)},N.shiftLeft=function(v){return o(v)&&(v=v.toInt()),(v&=63)===0?this:v<32?u(this.low<<v,this.high<<v|this.low>>>32-v,this.unsigned):u(0,this.low<<v-32,this.unsigned)},N.shl=N.shiftLeft,N.shiftRight=function(v){return o(v)&&(v=v.toInt()),(v&=63)===0?this:v<32?u(this.low>>>v|this.high<<32-v,this.high>>v,this.unsigned):u(this.high>>v-32,this.high>=0?0:-1,this.unsigned)},N.shr=N.shiftRight,N.shiftRightUnsigned=function(v){return o(v)&&(v=v.toInt()),(v&=63)===0?this:v<32?u(this.low>>>v|this.high<<32-v,this.high>>>v,this.unsigned):v===32?u(this.high,0,this.unsigned):u(this.high>>>v-32,0,this.unsigned)},N.shru=N.shiftRightUnsigned,N.shr_u=N.shiftRightUnsigned,N.rotateLeft=function(v){var A;return o(v)&&(v=v.toInt()),(v&=63)===0?this:v===32?u(this.high,this.low,this.unsigned):v<32?(A=32-v,u(this.low<<v|this.high>>>A,this.high<<v|this.low>>>A,this.unsigned)):(v-=32,A=32-v,u(this.high<<v|this.low>>>A,this.low<<v|this.high>>>A,this.unsigned))},N.rotl=N.rotateLeft,N.rotateRight=function(v){var A;return o(v)&&(v=v.toInt()),(v&=63)===0?this:v===32?u(this.high,this.low,this.unsigned):v<32?(A=32-v,u(this.high<<A|this.low>>>v,this.low<<A|this.high>>>v,this.unsigned)):(v-=32,A=32-v,u(this.low<<A|this.high>>>v,this.high<<A|this.low>>>v,this.unsigned))},N.rotr=N.rotateRight,N.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},N.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},N.toBytes=function(v){return v?this.toBytesLE():this.toBytesBE()},N.toBytesLE=function(){var v=this.high,A=this.low;return[A&255,A>>>8&255,A>>>16&255,A>>>24,v&255,v>>>8&255,v>>>16&255,v>>>24]},N.toBytesBE=function(){var v=this.high,A=this.low;return[v>>>24,v>>>16&255,v>>>8&255,v&255,A>>>24,A>>>16&255,A>>>8&255,A&255]},r.fromBytes=function(v,A,V){return V?r.fromBytesLE(v,A):r.fromBytesBE(v,A)},r.fromBytesLE=function(v,A){return new r(v[0]|v[1]<<8|v[2]<<16|v[3]<<24,v[4]|v[5]<<8|v[6]<<16|v[7]<<24,A)},r.fromBytesBE=function(v,A){return new r(v[4]<<24|v[5]<<16|v[6]<<8|v[7],v[0]<<24|v[1]<<16|v[2]<<8|v[3],A)},typeof BigInt=="function"&&(r.fromBigInt=function(v,A){var V=Number(BigInt.asIntN(32,v)),$=Number(BigInt.asIntN(32,v>>BigInt(32)));return u(V,$,A)},r.fromValue=function(v,A){return typeof v=="bigint"?r.fromBigInt(v,A):h(v,A)},N.toBigInt=function(){var v=BigInt(this.low>>>0),A=BigInt(this.unsigned?this.high>>>0:this.high);return A<<BigInt(32)|v}),n.default=r})}(Nn,Nn.exports)),Nn.exports}var vr;function Kt(){return vr||(vr=1,function(e){var t=e;t.asPromise=Ss,t.base64=Mi,t.EventEmitter=bs,t.float=ks,t.inquire=Es,t.utf8=Li,t.pool=Is,t.LongBits=Os();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=As();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),u=0;u<p.length;++u)!n(p[u])&&(o[p[u]]===void 0||!i)&&(o[p[u]]=c[p[u]])}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)}}}(lo)),lo}var Ri=ze,dt=Kt(),yo,$n=dt.LongBits,xr=dt.base64,yr=dt.utf8;function Tn(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}function Oo(){}function Ms(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 Tn(Oo,0,0),this.tail=this.head,this.states=null}var Bi=function(){return dt.Buffer?function(){return(ze.create=function(){return new yo})()}:function(){return new ze}};ze.create=Bi();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 Tn(t,n,a),this.len+=n,this};function Ao(e,t,n){t[n]=e&255}function Ls(e,t,n){for(;e>127;)t[n++]=e&127|128,e>>>=7;t[n]=e}function Mo(e,t){this.len=e,this.next=void 0,this.val=t}Mo.prototype=Object.create(Tn.prototype);Mo.prototype.fn=Ls;ze.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new Mo((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(Lo,10,$n.fromNumber(t)):this.uint32(t)};ze.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)};function Lo(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=$n.from(t);return this._push(Lo,n.length(),n)};ze.prototype.int64=ze.prototype.uint64;ze.prototype.sint64=function(t){var n=$n.from(t).zzEncode();return this._push(Lo,n.length(),n)};ze.prototype.bool=function(t){return this._push(Ao,1,t?1:0)};function Co(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(Co,4,t>>>0)};ze.prototype.sfixed32=ze.prototype.fixed32;ze.prototype.fixed64=function(t){var n=$n.from(t);return this._push(Co,4,n.lo)._push(Co,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 Rs=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(Ao,1,0);if(dt.isString(t)){var a=ze.alloc(n=xr.length(t));xr.decode(t,a,0),t=a}return this.uint32(n)._push(Rs,n,t)};ze.prototype.string=function(t){var n=yr.length(t);return n?this.uint32(n)._push(yr.write,n,t):this._push(Ao,1,0)};ze.prototype.fork=function(){return this.states=new Ms(this),this.head=this.tail=new Tn(Oo,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 Tn(Oo,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){yo=e,ze.create=Bi(),yo._configure()};var Bs=St,Fi=Ri;(St.prototype=Object.create(Fi.prototype)).constructor=St;var Vt=Kt();function St(){Fi.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 Fs(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(Fs,n,t),this};St._configure();var Di=Ze,pt=Kt(),_o,zi=pt.LongBits,Ds=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 Cr=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")},Vi=function(){return pt.Buffer?function(n){return(Ze.create=function(r){return pt.Buffer.isBuffer(r)?new _o(r):Cr(r)})(n)}:Cr};Ze.create=Vi();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 uo(){var e=new zi(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 Rn(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 Rn(this.buf,this.pos+=4)};Ze.prototype.sfixed32=function(){if(this.pos+4>this.len)throw yt(this,4);return Rn(this.buf,this.pos+=4)|0};function _r(){if(this.pos+8>this.len)throw yt(this,8);return new zi(Rn(this.buf,this.pos+=4),Rn(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 Ds.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){_o=e,Ze.create=Vi(),_o._configure();var t=pt.Long?"toLong":"toNumber";pt.merge(Ze.prototype,{int64:function(){return uo.call(this)[t](!1)},uint64:function(){return uo.call(this)[t](!0)},sint64:function(){return uo.call(this).zzDecode()[t](!1)},fixed64:function(){return _r.call(this)[t](!0)},sfixed64:function(){return _r.call(this)[t](!1)}})};var zs=Jt,$i=Di;(Jt.prototype=Object.create($i.prototype)).constructor=Jt;var Pr=Kt();function Jt(e){$i.call(this,e)}Jt._configure=function(){Pr.Buffer&&(Jt.prototype._slice=Pr.Buffer.prototype.slice)};Jt.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))};Jt._configure();var Ui={},Vs=Sn,Ro=Kt();(Sn.prototype=Object.create(Ro.EventEmitter.prototype)).constructor=Sn;function Sn(e,t,n){if(typeof e!="function")throw TypeError("rpcImpl must be a function");Ro.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=!!t,this.responseDelimited=!!n}Sn.prototype.rpcCall=function e(t,n,a,r,o){if(!r)throw TypeError("request must be specified");var i=this;if(!o)return Ro.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}};Sn.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=Vs})(Ui);var $s=Object.create(null);(function(e){var t=e;t.build="minimal",t.Writer=Ri,t.BufferWriter=Bs,t.Reader=Di,t.BufferReader=zs,t.util=Kt(),t.rpc=Ui,t.roots=$s,t.configure=n;function n(){t.util._configure(),t.Writer._configure(t.BufferWriter),t.Reader._configure(t.BufferReader)}n()})(Ai);var se=Ai;function Us(e){switch(e){case 0:case"UNKNOWN":return 0;case 4:case"ROADWAY":return 4;case-1:case"UNRECOGNIZED":default:return-1}}function Ws(e){switch(e){case 0:return"UNKNOWN";case 4:return"ROADWAY";case-1:default:return"UNRECOGNIZED"}}function Sr(){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=Sr();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=Sr();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 Tr(){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=Tr();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=Tr();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 br(){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=br();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=br();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 kr(){return{vertices:[],normals:[],indices:[],colors:[],uv:[]}}const Ue={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=kr();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 Ue.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=kr();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 Hs(e){switch(e){case 0:case"RECTANGLE":return 0;case 1:case"CICLE":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function Zs(e){switch(e){case 0:return"RECTANGLE";case 1:return"CICLE";case-1:default:return"UNRECOGNIZED"}}function Er(){return{dataType:0,name:"",position:void 0,boxes:[]}}const Wi={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=Er();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)?Us(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=Ws(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 Wi.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=Er();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 Nr(){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&&Ue.encode(e.topMesh,t.uint32(58).fork()).ldelim(),e.sideMesh!==void 0&&Ue.encode(e.sideMesh,t.uint32(66).fork()).ldelim(),e.bottomMesh!==void 0&&Ue.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=Nr();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=Ue.decode(n,n.uint32());continue;case 8:if(o!==66)break;r.sideMesh=Ue.decode(n,n.uint32());continue;case 9:if(o!==74)break;r.bottomMesh=Ue.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)?Hs(e.type):0,topMesh:tt(e.topMesh)?Ue.fromJSON(e.topMesh):void 0,sideMesh:tt(e.sideMesh)?Ue.fromJSON(e.sideMesh):void 0,bottomMesh:tt(e.bottomMesh)?Ue.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=Zs(e.type)),e.topMesh!==void 0&&(t.topMesh=Ue.toJSON(e.topMesh)),e.sideMesh!==void 0&&(t.sideMesh=Ue.toJSON(e.sideMesh)),e.bottomMesh!==void 0&&(t.bottomMesh=Ue.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=Nr();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?Ue.fromPartial(e.topMesh):void 0,t.sideMesh=e.sideMesh!==void 0&&e.sideMesh!==null?Ue.fromPartial(e.sideMesh):void 0,t.bottomMesh=e.bottomMesh!==void 0&&e.bottomMesh!==null?Ue.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 Gs(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 Ys(e){switch(e){case 0:return"NORMAL_FRAME";case 1:return"KEY_FRAME";case-1:default:return"UNRECOGNIZED"}}var Mn=(e=>(e[e.RUN=0]="RUN",e[e.WATER=1]="WATER",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Mn||{});function Js(e){switch(e){case 0:case"RUN":return 0;case 1:case"WATER":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function Xs(e){switch(e){case 0:return"RUN";case 1:return"WATER";case-1:default:return"UNRECOGNIZED"}}function Ir(){return{name:"",frameRate:0,type:0,frames:[],boxes:[],animType:0,colors:[]}}const Hi={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)nn.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=Ir();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(nn.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)?Gs(e.type):0,frames:globalThis.Array.isArray(e==null?void 0:e.frames)?e.frames.map(t=>nn.fromJSON(t)):[],boxes:globalThis.Array.isArray(e==null?void 0:e.boxes)?e.boxes.map(t=>it.fromJSON(t)):[],animType:wt(e.animType)?Js(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=Ys(e.type)),(n=e.frames)!=null&&n.length&&(t.frames=e.frames.map(o=>nn.toJSON(o))),(a=e.boxes)!=null&&a.length&&(t.boxes=e.boxes.map(o=>it.toJSON(o))),e.animType!==0&&(t.animType=Xs(e.animType)),(r=e.colors)!=null&&r.length&&(t.colors=e.colors.map(o=>ot.toJSON(o))),t},create(e){return Hi.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,l,s;const t=Ir();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=>nn.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 wr(){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=wr();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=wr();return t.start=(n=e.start)!=null?n:0,t.end=(a=e.end)!=null?a:0,t}};function Or(){return{index:0,name:"",percent:[],colorPercent:[]}}const tn={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=Or();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 tn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o;const t=Or();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 Ar(){return{node:[],time:0}}const nn={encode(e,t=se.Writer.create()){for(const n of e.node)tn.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=Ar();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.node.push(tn.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=>tn.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=>tn.toJSON(a))),e.time!==0&&(t.time=e.time),t},create(e){return nn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=Ar();return t.node=((n=e.node)==null?void 0:n.map(r=>tn.fromPartial(r)))||[],t.time=(a=e.time)!=null?a:0,t}};function wt(e){return e!=null}function qs(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 Ks(e){switch(e){case 0:return"NORMAL_FRAME";case 1:return"KEY_FRAME";case-1:default:return"UNRECOGNIZED"}}function Mr(){return{name:"",frameRate:0,type:0,nodes:[],boxes:[]}}const Zi={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)on.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=Mr();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(on.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)?qs(e.type):0,nodes:globalThis.Array.isArray(e==null?void 0:e.nodes)?e.nodes.map(t=>on.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=Ks(e.type)),(n=e.nodes)!=null&&n.length&&(t.nodes=e.nodes.map(r=>on.toJSON(r))),(a=e.boxes)!=null&&a.length&&(t.boxes=e.boxes.map(r=>it.toJSON(r))),t},create(e){return Zi.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=Mr();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=>on.fromPartial(l)))||[],t.boxes=((i=e.boxes)==null?void 0:i.map(l=>it.fromPartial(l)))||[],t}};function Lr(){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=Lr();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=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:"",frames:[]}}const on={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)rn.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=Rr();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(rn.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=>rn.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=>rn.toJSON(a))),t},create(e){return on.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=Rr();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=>rn.fromPartial(o)))||[],t}};function Br(){return{time:0,percent:[],colorPercent:[]}}const rn={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=Br();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 rn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=Br();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 Qs(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 js(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,frames:[],url:""}}const Gi={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)sn.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=Fr();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(sn.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:Yt(e.name)?globalThis.String(e.name):"",frameRate:Yt(e.frameRate)?globalThis.Number(e.frameRate):0,type:Yt(e.type)?Qs(e.type):0,frames:globalThis.Array.isArray(e==null?void 0:e.frames)?e.frames.map(t=>sn.fromJSON(t)):[],url:Yt(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=js(e.type)),(n=e.frames)!=null&&n.length&&(t.frames=e.frames.map(a=>sn.toJSON(a))),e.url!==""&&(t.url=e.url),t},create(e){return Gi.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=Fr();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=>sn.fromPartial(l)))||[],t.url=(i=e.url)!=null?i:"",t}};function Dr(){return{name:"",position:void 0}}const an={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=Dr();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:Yt(e.name)?globalThis.String(e.name):"",position:Yt(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 an.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=Dr();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 sn={encode(e,t=se.Writer.create()){for(const n of e.nodes)an.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(an.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=>an.fromJSON(t)):[],time:Yt(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=>an.toJSON(a))),e.time!==0&&(t.time=e.time),t},create(e){return sn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=zr();return t.nodes=((n=e.nodes)==null?void 0:n.map(r=>an.fromPartial(r)))||[],t.time=(a=e.time)!=null?a:0,t}};function Yt(e){return e!=null}class _n{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 f.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 Un{constructor(t){ve(this,"_curves",[]);this._curves=t}get curves(){return this._curves}update(t){}reset(){}}class el extends Un{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 f.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 f.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,u=(s=this.curves[2].evaluate(n))!=null?s:0;this._start=this.getStartPosition(),this._current=new f.Vector3(c,p,u),this._end=this.getEndPosition();return}const a=this.curves[0].getLastKey().value,r=this.curves[1].getLastKey().value,o=this.curves[2].getLastKey().value;this._start=this.getStartPosition(),this._current=new f.Vector3(a,r,o),this._end=this.getEndPosition()}reset(){}}class tl extends Un{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 Yi extends Un{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 fo,po,ho,mo,In,wn,Vr,$r;function nl(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 fo=r,po=r*(t-1)*n,ho=r*(t+1)*n,mo=-r*a,In=2*n,wn=-a,Vr=(fo+po)/(1-In-wn),$r=(ho+mo)/(1-In-wn),new Float32Array([fo,po,ho,mo,In,wn,Vr,$r])}function Ur(e,t,n,a,r,o){var i,l,s,c,p,u,d,x,h,T,P,y,_,b,k,L,I,S,E,B,F,w,D,N,M,v,A,V,$,U;for(M=0;M<o;M++){for(w=M*r,D=M,N=0,i=e[w],l=i&255,s=i>>8&255,c=i>>16&255,p=i>>24&255,S=l*a[6],E=s*a[6],B=c*a[6],F=p*a[6],b=S,k=E,L=B,I=F,A=a[0],V=a[1],$=a[4],U=a[5],v=0;v<r;v++)i=e[w],u=i&255,d=i>>8&255,x=i>>16&255,h=i>>24&255,T=u*A+l*V+b*$+S*U,P=d*A+s*V+k*$+E*U,y=x*A+c*V+L*$+B*U,_=h*A+p*V+I*$+F*U,S=b,E=k,B=L,F=I,b=T,k=P,L=y,I=_,l=u,s=d,c=x,p=h,n[N]=b,n[N+1]=k,n[N+2]=L,n[N+3]=I,N+=4,w++;for(w--,N-=4,D+=o*(r-1),i=e[w],l=i&255,s=i>>8&255,c=i>>16&255,p=i>>24&255,S=l*a[7],E=s*a[7],B=c*a[7],F=p*a[7],b=S,k=E,L=B,I=F,u=l,d=s,x=c,h=p,A=a[2],V=a[3],v=r-1;v>=0;v--)T=u*A+l*V+b*$+S*U,P=d*A+s*V+k*$+E*U,y=x*A+c*V+L*$+B*U,_=h*A+p*V+I*$+F*U,S=b,E=k,B=L,F=I,b=T,k=P,L=y,I=_,l=u,s=d,c=x,p=h,i=e[w],u=i&255,d=i>>8&255,x=i>>16&255,h=i>>24&255,i=(n[N]+b<<0)+(n[N+1]+k<<8)+(n[N+2]+L<<16)+(n[N+3]+I<<24),t[D]=i,w--,N-=4,D-=o}}function ol(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=nl(a);Ur(r,o,i,l,t,n),Ur(o,r,i,l,n,t)}}var rl=ol;const il=yi(rl);class al extends Un{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 f.Vector3.Center(this._start||f.Vector3.Zero(),this._end||f.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;il(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 Wr=e=>{const t=Hi.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 _n);let s=0;for(let p=0;p<t.frames.length;p++){const u=t.frames[p],d=u.node.findIndex(x=>x.name===a[r]);if(d!==-1){for(let x=0;x<i;x++){const h=new st(u.time*1e3,u.node[d].percent[x].start),T=new st(u.time*1e3,u.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(u.time*1e3,u.node[d].colorPercent[x].start),T=new st(u.time*1e3,u.node[d].colorPercent[x].end);o[i*2+x*2].addKey(h),o[i*2+x*2+1].addKey(T)}s=u.node[d].index}}const c=t.animType===Mn.WATER?new Yi(o):new tl(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===Mn.RUN?"run":"water",c.colors=t.colors.map(p=>gs(p)),t.animType===Mn.WATER&&(c.percentLength=i*2);for(let p=0;p<c.curves.length;p++)if(c.curves[p].keys[0].time!==0){const u=c.curves[p].keys[0],d=new st(0,u.value);d.time=0,c.curves[p].keys.unshift(d)}n.push(c)}return n},sl=e=>{const t=Gi.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 _n),o.push(new _n),o.push(new _n);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),u=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(u),o[2].addKey(d)}}const i=new el(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},ll=e=>{const t=Zi.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 _n);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 y=new st(T.time*1e3,T.percent[P].start),_=new st(T.time*1e3,T.percent[P].end);r[P*2].addKey(y),r[P*2+1].addKey(_)}for(let P=0;P<i;P++){const y=new st(T.time*1e3,T.colorPercent[P].start),_=new st(T.time*1e3,T.colorPercent[P].end);r[o*2+P*2].addKey(y),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 al(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=f.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 f.Vector3(t.boxes[l].bottomMesh.vertices[h],t.boxes[l].bottomMesh.vertices[h+1],t.boxes[l].bottomMesh.vertices[h+2]));const p=new f.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),u=new f.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>u.x&&(u.x=h.x),h.y>u.y&&(u.y=h.y),h.z>u.z&&(u.z=h.z)});const d=[];t.boxes[l].bottomMesh.indices.forEach(h=>{d.push(c[h].subtract(p).multiplyByFloats(1/(u.x-p.x),1/(u.y-p.y),1/(u.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},Ln=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}),u=(d,x)=>{let h=[];switch(d){case"roadway":h=Wr(x);break;case"roadwaynear":h=sl(x);break;case"water":h=ll(x);break;default:h=Wr(x)}return h};return m.useEffect(()=>{if(p&&!c.current){c.current=!0;const d=u(r,p);console.log(d);const x=new Ps(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 Hr(){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 Bo={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=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!==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 Bo.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,l,s,c,p,u,d,x;const t=Hr();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=((u=e.points)==null?void 0:u.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 cl=(e,t)=>{const n=m.useRef(null),{name:a,vertex:r,fragment:o,needDepthPrePass:i=!1,backFaceCulling:l,transparencyMode:s=f.Material.MATERIAL_OPAQUE,alphaMode:c=f.Engine.ALPHA_COMBINE,alpha:p=1,options:u,zOffset:d=1,zOffsetUnits:x,disableDepthWrite:h=!1,clipPlane:T,depthFunction:P,sideOrientation:y=f.Material.ClockWiseSideOrientation}=e;return m.useImperativeHandle(t,()=>n.current,[]),C.jsx(C.Fragment,{children:C.jsx("shaderMaterial",{ref:n,name:`${a}-material`,sideOrientation:y,needDepthPrePass:i,backFaceCulling:l,transparencyMode:s,alphaMode:c,depthFunction:P,alpha:p,shaderPath:{vertexSource:r,fragmentSource:o},options:u,zOffset:d,zOffsetUnits:x,clipPlane:T,disableDepthWrite:h})})},lt=m.forwardRef(cl),ul=`#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(M){}function r(M,x,A){this.low=M|0,this.high=x|0,this.unsigned=!!A}r.prototype.__isLong__,Object.defineProperty(r.prototype,"__isLong__",{value:!0});function o(M){return(M&&M.__isLong__)===!0}function i(M){var x=Math.clz32(M&-M);return M?31-x:x}r.isLong=o;var l={},s={};function c(M,x){var A,V,$;return x?(M>>>=0,($=0<=M&&M<256)&&(V=s[M],V)?V:(A=f(M,0,!0),$&&(s[M]=A),A)):(M|=0,($=-128<=M&&M<128)&&(V=l[M],V)?V:(A=f(M,M<0?-1:0,!1),$&&(l[M]=A),A))}r.fromInt=c;function p(M,x){if(isNaN(M))return x?I:L;if(x){if(M<0)return I;if(M>=_)return w}else{if(M<=-b)return D;if(M+1>=b)return F}return M<0?p(-M,x).neg():f(M%v|0,M/v|0,x)}r.fromNumber=p;function f(M,x,A){return new r(M,x,A)}r.fromBits=f;var d=Math.pow;function y(M,x,A){if(M.length===0)throw Error("empty string");if(typeof x=="number"?(A=x,x=!1):x=!!x,M==="NaN"||M==="Infinity"||M==="+Infinity"||M==="-Infinity")return x?I:L;if(A=A||10,A<2||36<A)throw RangeError("radix");var V;if((V=M.indexOf("-"))>0)throw Error("interior hyphen");if(V===0)return y(M.substring(1),x,A).neg();for(var $=p(d(A,8)),U=L,re=0;re<M.length;re+=8){var oe=Math.min(8,M.length-re),G=parseInt(M.substring(re,re+oe),A);if(oe<8){var ae=p(d(A,oe));U=U.mul(ae).add(p(G))}else U=U.mul($),U=U.add(p(G))}return U.unsigned=x,U}r.fromString=y;function h(M,x){return typeof M=="number"?p(M,x):typeof M=="string"?y(M,x):f(M.low,M.high,typeof x=="boolean"?x:M.unsigned)}r.fromValue=h;var T=65536,P=1<<24,v=T*T,_=v*v,b=_/2,E=c(P),L=c(0);r.ZERO=L;var I=c(0,!0);r.UZERO=I;var S=c(1);r.ONE=S;var k=c(1,!0);r.UONE=k;var B=c(-1);r.NEG_ONE=B;var F=f(-1,2147483647,!1);r.MAX_VALUE=F;var w=f(-1,-1,!0);r.MAX_UNSIGNED_VALUE=w;var D=f(0,-2147483648,!1);r.MIN_VALUE=D;var N=r.prototype;N.toInt=function(){return this.unsigned?this.low>>>0:this.low},N.toNumber=function(){return this.unsigned?(this.high>>>0)*v+(this.low>>>0):this.high*v+(this.low>>>0)},N.toString=function(x){if(x=x||10,x<2||36<x)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(D)){var A=p(x),V=this.div(A),$=V.mul(A).sub(this);return V.toString(x)+$.toInt().toString(x)}else return"-"+this.neg().toString(x);for(var U=p(d(x,6),this.unsigned),re=this,oe="";;){var G=re.div(U),ae=re.sub(G.mul(U)).toInt()>>>0,ne=ae.toString(x);if(re=G,re.isZero())return ne+oe;for(;ne.length<6;)ne="0"+ne;oe=""+ne+oe}},N.getHighBits=function(){return this.high},N.getHighBitsUnsigned=function(){return this.high>>>0},N.getLowBits=function(){return this.low},N.getLowBitsUnsigned=function(){return this.low>>>0},N.getNumBitsAbs=function(){if(this.isNegative())return this.eq(D)?64:this.neg().getNumBitsAbs();for(var x=this.high!=0?this.high:this.low,A=31;A>0&&!(x&1<<A);A--);return this.high!=0?A+33:A+1},N.isSafeInteger=function(){var x=this.high>>21;return x?this.unsigned?!1:x===-1&&!(this.low===0&&this.high===-2097152):!0},N.isZero=function(){return this.high===0&&this.low===0},N.eqz=N.isZero,N.isNegative=function(){return!this.unsigned&&this.high<0},N.isPositive=function(){return this.unsigned||this.high>=0},N.isOdd=function(){return(this.low&1)===1},N.isEven=function(){return(this.low&1)===0},N.equals=function(x){return o(x)||(x=h(x)),this.unsigned!==x.unsigned&&this.high>>>31===1&&x.high>>>31===1?!1:this.high===x.high&&this.low===x.low},N.eq=N.equals,N.notEquals=function(x){return!this.eq(x)},N.neq=N.notEquals,N.ne=N.notEquals,N.lessThan=function(x){return this.comp(x)<0},N.lt=N.lessThan,N.lessThanOrEqual=function(x){return this.comp(x)<=0},N.lte=N.lessThanOrEqual,N.le=N.lessThanOrEqual,N.greaterThan=function(x){return this.comp(x)>0},N.gt=N.greaterThan,N.greaterThanOrEqual=function(x){return this.comp(x)>=0},N.gte=N.greaterThanOrEqual,N.ge=N.greaterThanOrEqual,N.compare=function(x){if(o(x)||(x=h(x)),this.eq(x))return 0;var A=this.isNegative(),V=x.isNegative();return A&&!V?-1:!A&&V?1:this.unsigned?x.high>>>0>this.high>>>0||x.high===this.high&&x.low>>>0>this.low>>>0?-1:1:this.sub(x).isNegative()?-1:1},N.comp=N.compare,N.negate=function(){return!this.unsigned&&this.eq(D)?D:this.not().add(S)},N.neg=N.negate,N.add=function(x){o(x)||(x=h(x));var A=this.high>>>16,V=this.high&65535,$=this.low>>>16,U=this.low&65535,re=x.high>>>16,oe=x.high&65535,G=x.low>>>16,ae=x.low&65535,ne=0,j=0,Y=0,ce=0;return ce+=U+ae,Y+=ce>>>16,ce&=65535,Y+=$+G,j+=Y>>>16,Y&=65535,j+=V+oe,ne+=j>>>16,j&=65535,ne+=A+re,ne&=65535,f(Y<<16|ce,ne<<16|j,this.unsigned)},N.subtract=function(x){return o(x)||(x=h(x)),this.add(x.neg())},N.sub=N.subtract,N.multiply=function(x){if(this.isZero())return this;if(o(x)||(x=h(x)),a){var A=a.mul(this.low,this.high,x.low,x.high);return f(A,a.get_high(),this.unsigned)}if(x.isZero())return this.unsigned?I:L;if(this.eq(D))return x.isOdd()?D:L;if(x.eq(D))return this.isOdd()?D:L;if(this.isNegative())return x.isNegative()?this.neg().mul(x.neg()):this.neg().mul(x).neg();if(x.isNegative())return this.mul(x.neg()).neg();if(this.lt(E)&&x.lt(E))return p(this.toNumber()*x.toNumber(),this.unsigned);var V=this.high>>>16,$=this.high&65535,U=this.low>>>16,re=this.low&65535,oe=x.high>>>16,G=x.high&65535,ae=x.low>>>16,ne=x.low&65535,j=0,Y=0,ce=0,le=0;return le+=re*ne,ce+=le>>>16,le&=65535,ce+=U*ne,Y+=ce>>>16,ce&=65535,ce+=re*ae,Y+=ce>>>16,ce&=65535,Y+=$*ne,j+=Y>>>16,Y&=65535,Y+=U*ae,j+=Y>>>16,Y&=65535,Y+=re*G,j+=Y>>>16,Y&=65535,j+=V*ne+$*ae+U*G+re*oe,j&=65535,f(ce<<16|le,j<<16|Y,this.unsigned)},N.mul=N.multiply,N.divide=function(x){if(o(x)||(x=h(x)),x.isZero())throw Error("division by zero");if(a){if(!this.unsigned&&this.high===-2147483648&&x.low===-1&&x.high===-1)return this;var A=(this.unsigned?a.div_u:a.div_s)(this.low,this.high,x.low,x.high);return f(A,a.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?I:L;var V,$,U;if(this.unsigned){if(x.unsigned||(x=x.toUnsigned()),x.gt(this))return I;if(x.gt(this.shru(1)))return k;U=I}else{if(this.eq(D)){if(x.eq(S)||x.eq(B))return D;if(x.eq(D))return S;var re=this.shr(1);return V=re.div(x).shl(1),V.eq(L)?x.isNegative()?S:B:($=this.sub(x.mul(V)),U=V.add($.div(x)),U)}else if(x.eq(D))return this.unsigned?I:L;if(this.isNegative())return x.isNegative()?this.neg().div(x.neg()):this.neg().div(x).neg();if(x.isNegative())return this.div(x.neg()).neg();U=L}for($=this;$.gte(x);){V=Math.max(1,Math.floor($.toNumber()/x.toNumber()));for(var oe=Math.ceil(Math.log(V)/Math.LN2),G=oe<=48?1:d(2,oe-48),ae=p(V),ne=ae.mul(x);ne.isNegative()||ne.gt($);)V-=G,ae=p(V,this.unsigned),ne=ae.mul(x);ae.isZero()&&(ae=S),U=U.add(ae),$=$.sub(ne)}return U},N.div=N.divide,N.modulo=function(x){if(o(x)||(x=h(x)),a){var A=(this.unsigned?a.rem_u:a.rem_s)(this.low,this.high,x.low,x.high);return f(A,a.get_high(),this.unsigned)}return this.sub(this.div(x).mul(x))},N.mod=N.modulo,N.rem=N.modulo,N.not=function(){return f(~this.low,~this.high,this.unsigned)},N.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},N.clz=N.countLeadingZeros,N.countTrailingZeros=function(){return this.low?i(this.low):i(this.high)+32},N.ctz=N.countTrailingZeros,N.and=function(x){return o(x)||(x=h(x)),f(this.low&x.low,this.high&x.high,this.unsigned)},N.or=function(x){return o(x)||(x=h(x)),f(this.low|x.low,this.high|x.high,this.unsigned)},N.xor=function(x){return o(x)||(x=h(x)),f(this.low^x.low,this.high^x.high,this.unsigned)},N.shiftLeft=function(x){return o(x)&&(x=x.toInt()),(x&=63)===0?this:x<32?f(this.low<<x,this.high<<x|this.low>>>32-x,this.unsigned):f(0,this.low<<x-32,this.unsigned)},N.shl=N.shiftLeft,N.shiftRight=function(x){return o(x)&&(x=x.toInt()),(x&=63)===0?this:x<32?f(this.low>>>x|this.high<<32-x,this.high>>x,this.unsigned):f(this.high>>x-32,this.high>=0?0:-1,this.unsigned)},N.shr=N.shiftRight,N.shiftRightUnsigned=function(x){return o(x)&&(x=x.toInt()),(x&=63)===0?this:x<32?f(this.low>>>x|this.high<<32-x,this.high>>>x,this.unsigned):x===32?f(this.high,0,this.unsigned):f(this.high>>>x-32,0,this.unsigned)},N.shru=N.shiftRightUnsigned,N.shr_u=N.shiftRightUnsigned,N.rotateLeft=function(x){var A;return o(x)&&(x=x.toInt()),(x&=63)===0?this:x===32?f(this.high,this.low,this.unsigned):x<32?(A=32-x,f(this.low<<x|this.high>>>A,this.high<<x|this.low>>>A,this.unsigned)):(x-=32,A=32-x,f(this.high<<x|this.low>>>A,this.low<<x|this.high>>>A,this.unsigned))},N.rotl=N.rotateLeft,N.rotateRight=function(x){var A;return o(x)&&(x=x.toInt()),(x&=63)===0?this:x===32?f(this.high,this.low,this.unsigned):x<32?(A=32-x,f(this.high<<A|this.low>>>x,this.low<<A|this.high>>>x,this.unsigned)):(x-=32,A=32-x,f(this.low<<A|this.high>>>x,this.high<<A|this.low>>>x,this.unsigned))},N.rotr=N.rotateRight,N.toSigned=function(){return this.unsigned?f(this.low,this.high,!1):this},N.toUnsigned=function(){return this.unsigned?this:f(this.low,this.high,!0)},N.toBytes=function(x){return x?this.toBytesLE():this.toBytesBE()},N.toBytesLE=function(){var x=this.high,A=this.low;return[A&255,A>>>8&255,A>>>16&255,A>>>24,x&255,x>>>8&255,x>>>16&255,x>>>24]},N.toBytesBE=function(){var x=this.high,A=this.low;return[x>>>24,x>>>16&255,x>>>8&255,x&255,A>>>24,A>>>16&255,A>>>8&255,A&255]},r.fromBytes=function(x,A,V){return V?r.fromBytesLE(x,A):r.fromBytesBE(x,A)},r.fromBytesLE=function(x,A){return new r(x[0]|x[1]<<8|x[2]<<16|x[3]<<24,x[4]|x[5]<<8|x[6]<<16|x[7]<<24,A)},r.fromBytesBE=function(x,A){return new r(x[4]<<24|x[5]<<16|x[6]<<8|x[7],x[0]<<24|x[1]<<16|x[2]<<8|x[3],A)},typeof BigInt=="function"&&(r.fromBigInt=function(x,A){var V=Number(BigInt.asIntN(32,x)),$=Number(BigInt.asIntN(32,x>>BigInt(32)));return f(V,$,A)},r.fromValue=function(x,A){return typeof x=="bigint"?r.fromBigInt(x,A):h(x,A)},N.toBigInt=function(){var x=BigInt(this.low>>>0),A=BigInt(this.unsigned?this.high>>>0:this.high);return A<<BigInt(32)|x}),n.default=r})}(Nn,Nn.exports)),Nn.exports}var vr;function Kt(){return vr||(vr=1,function(e){var t=e;t.asPromise=Ss,t.base64=Mi,t.EventEmitter=bs,t.float=ks,t.inquire=Es,t.utf8=Li,t.pool=Is,t.LongBits=Os();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=As();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)}}}(lo)),lo}var Ri=ze,dt=Kt(),yo,$n=dt.LongBits,xr=dt.base64,yr=dt.utf8;function Tn(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}function Oo(){}function Ms(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 Tn(Oo,0,0),this.tail=this.head,this.states=null}var Bi=function(){return dt.Buffer?function(){return(ze.create=function(){return new yo})()}:function(){return new ze}};ze.create=Bi();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 Tn(t,n,a),this.len+=n,this};function Ao(e,t,n){t[n]=e&255}function Ls(e,t,n){for(;e>127;)t[n++]=e&127|128,e>>>=7;t[n]=e}function Mo(e,t){this.len=e,this.next=void 0,this.val=t}Mo.prototype=Object.create(Tn.prototype);Mo.prototype.fn=Ls;ze.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new Mo((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(Lo,10,$n.fromNumber(t)):this.uint32(t)};ze.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)};function Lo(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=$n.from(t);return this._push(Lo,n.length(),n)};ze.prototype.int64=ze.prototype.uint64;ze.prototype.sint64=function(t){var n=$n.from(t).zzEncode();return this._push(Lo,n.length(),n)};ze.prototype.bool=function(t){return this._push(Ao,1,t?1:0)};function Co(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(Co,4,t>>>0)};ze.prototype.sfixed32=ze.prototype.fixed32;ze.prototype.fixed64=function(t){var n=$n.from(t);return this._push(Co,4,n.lo)._push(Co,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 Rs=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(Ao,1,0);if(dt.isString(t)){var a=ze.alloc(n=xr.length(t));xr.decode(t,a,0),t=a}return this.uint32(n)._push(Rs,n,t)};ze.prototype.string=function(t){var n=yr.length(t);return n?this.uint32(n)._push(yr.write,n,t):this._push(Ao,1,0)};ze.prototype.fork=function(){return this.states=new Ms(this),this.head=this.tail=new Tn(Oo,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 Tn(Oo,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){yo=e,ze.create=Bi(),yo._configure()};var Bs=St,Fi=Ri;(St.prototype=Object.create(Fi.prototype)).constructor=St;var Vt=Kt();function St(){Fi.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 Fs(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(Fs,n,t),this};St._configure();var Di=Ze,pt=Kt(),_o,zi=pt.LongBits,Ds=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 Cr=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")},Vi=function(){return pt.Buffer?function(n){return(Ze.create=function(r){return pt.Buffer.isBuffer(r)?new _o(r):Cr(r)})(n)}:Cr};Ze.create=Vi();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 uo(){var e=new zi(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 Rn(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 Rn(this.buf,this.pos+=4)};Ze.prototype.sfixed32=function(){if(this.pos+4>this.len)throw yt(this,4);return Rn(this.buf,this.pos+=4)|0};function _r(){if(this.pos+8>this.len)throw yt(this,8);return new zi(Rn(this.buf,this.pos+=4),Rn(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 Ds.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){_o=e,Ze.create=Vi(),_o._configure();var t=pt.Long?"toLong":"toNumber";pt.merge(Ze.prototype,{int64:function(){return uo.call(this)[t](!1)},uint64:function(){return uo.call(this)[t](!0)},sint64:function(){return uo.call(this).zzDecode()[t](!1)},fixed64:function(){return _r.call(this)[t](!0)},sfixed64:function(){return _r.call(this)[t](!1)}})};var zs=Jt,$i=Di;(Jt.prototype=Object.create($i.prototype)).constructor=Jt;var Pr=Kt();function Jt(e){$i.call(this,e)}Jt._configure=function(){Pr.Buffer&&(Jt.prototype._slice=Pr.Buffer.prototype.slice)};Jt.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))};Jt._configure();var Ui={},Vs=Sn,Ro=Kt();(Sn.prototype=Object.create(Ro.EventEmitter.prototype)).constructor=Sn;function Sn(e,t,n){if(typeof e!="function")throw TypeError("rpcImpl must be a function");Ro.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=!!t,this.responseDelimited=!!n}Sn.prototype.rpcCall=function e(t,n,a,r,o){if(!r)throw TypeError("request must be specified");var i=this;if(!o)return Ro.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}};Sn.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=Vs})(Ui);var $s=Object.create(null);(function(e){var t=e;t.build="minimal",t.Writer=Ri,t.BufferWriter=Bs,t.Reader=Di,t.BufferReader=zs,t.util=Kt(),t.rpc=Ui,t.roots=$s,t.configure=n;function n(){t.util._configure(),t.Writer._configure(t.BufferWriter),t.Reader._configure(t.BufferReader)}n()})(Ai);var se=Ai;function Us(e){switch(e){case 0:case"UNKNOWN":return 0;case 4:case"ROADWAY":return 4;case-1:case"UNRECOGNIZED":default:return-1}}function Ws(e){switch(e){case 0:return"UNKNOWN";case 4:return"ROADWAY";case-1:default:return"UNRECOGNIZED"}}function Sr(){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=Sr();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=Sr();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 Tr(){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=Tr();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=Tr();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 br(){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=br();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=br();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 kr(){return{vertices:[],normals:[],indices:[],colors:[],uv:[]}}const Ue={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=kr();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 Ue.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=kr();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 Hs(e){switch(e){case 0:case"RECTANGLE":return 0;case 1:case"CICLE":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function Zs(e){switch(e){case 0:return"RECTANGLE";case 1:return"CICLE";case-1:default:return"UNRECOGNIZED"}}function Er(){return{dataType:0,name:"",position:void 0,boxes:[]}}const Wi={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=Er();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)?Us(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=Ws(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 Wi.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=Er();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 Nr(){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&&Ue.encode(e.topMesh,t.uint32(58).fork()).ldelim(),e.sideMesh!==void 0&&Ue.encode(e.sideMesh,t.uint32(66).fork()).ldelim(),e.bottomMesh!==void 0&&Ue.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=Nr();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=Ue.decode(n,n.uint32());continue;case 8:if(o!==66)break;r.sideMesh=Ue.decode(n,n.uint32());continue;case 9:if(o!==74)break;r.bottomMesh=Ue.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)?Hs(e.type):0,topMesh:tt(e.topMesh)?Ue.fromJSON(e.topMesh):void 0,sideMesh:tt(e.sideMesh)?Ue.fromJSON(e.sideMesh):void 0,bottomMesh:tt(e.bottomMesh)?Ue.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=Zs(e.type)),e.topMesh!==void 0&&(t.topMesh=Ue.toJSON(e.topMesh)),e.sideMesh!==void 0&&(t.sideMesh=Ue.toJSON(e.sideMesh)),e.bottomMesh!==void 0&&(t.bottomMesh=Ue.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=Nr();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?Ue.fromPartial(e.topMesh):void 0,t.sideMesh=e.sideMesh!==void 0&&e.sideMesh!==null?Ue.fromPartial(e.sideMesh):void 0,t.bottomMesh=e.bottomMesh!==void 0&&e.bottomMesh!==null?Ue.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 Gs(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 Ys(e){switch(e){case 0:return"NORMAL_FRAME";case 1:return"KEY_FRAME";case-1:default:return"UNRECOGNIZED"}}var Mn=(e=>(e[e.RUN=0]="RUN",e[e.WATER=1]="WATER",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Mn||{});function Js(e){switch(e){case 0:case"RUN":return 0;case 1:case"WATER":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function Xs(e){switch(e){case 0:return"RUN";case 1:return"WATER";case-1:default:return"UNRECOGNIZED"}}function Ir(){return{name:"",frameRate:0,type:0,frames:[],boxes:[],animType:0,colors:[]}}const Hi={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)nn.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=Ir();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(nn.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)?Gs(e.type):0,frames:globalThis.Array.isArray(e==null?void 0:e.frames)?e.frames.map(t=>nn.fromJSON(t)):[],boxes:globalThis.Array.isArray(e==null?void 0:e.boxes)?e.boxes.map(t=>it.fromJSON(t)):[],animType:wt(e.animType)?Js(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=Ys(e.type)),(n=e.frames)!=null&&n.length&&(t.frames=e.frames.map(o=>nn.toJSON(o))),(a=e.boxes)!=null&&a.length&&(t.boxes=e.boxes.map(o=>it.toJSON(o))),e.animType!==0&&(t.animType=Xs(e.animType)),(r=e.colors)!=null&&r.length&&(t.colors=e.colors.map(o=>ot.toJSON(o))),t},create(e){return Hi.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,l,s;const t=Ir();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=>nn.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 wr(){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=wr();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=wr();return t.start=(n=e.start)!=null?n:0,t.end=(a=e.end)!=null?a:0,t}};function Or(){return{index:0,name:"",percent:[],colorPercent:[]}}const tn={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=Or();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 tn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o;const t=Or();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 Ar(){return{node:[],time:0}}const nn={encode(e,t=se.Writer.create()){for(const n of e.node)tn.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=Ar();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.node.push(tn.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=>tn.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=>tn.toJSON(a))),e.time!==0&&(t.time=e.time),t},create(e){return nn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=Ar();return t.node=((n=e.node)==null?void 0:n.map(r=>tn.fromPartial(r)))||[],t.time=(a=e.time)!=null?a:0,t}};function wt(e){return e!=null}function qs(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 Ks(e){switch(e){case 0:return"NORMAL_FRAME";case 1:return"KEY_FRAME";case-1:default:return"UNRECOGNIZED"}}function Mr(){return{name:"",frameRate:0,type:0,nodes:[],boxes:[]}}const Zi={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)on.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=Mr();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(on.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)?qs(e.type):0,nodes:globalThis.Array.isArray(e==null?void 0:e.nodes)?e.nodes.map(t=>on.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=Ks(e.type)),(n=e.nodes)!=null&&n.length&&(t.nodes=e.nodes.map(r=>on.toJSON(r))),(a=e.boxes)!=null&&a.length&&(t.boxes=e.boxes.map(r=>it.toJSON(r))),t},create(e){return Zi.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=Mr();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=>on.fromPartial(l)))||[],t.boxes=((i=e.boxes)==null?void 0:i.map(l=>it.fromPartial(l)))||[],t}};function Lr(){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=Lr();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=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:"",frames:[]}}const on={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)rn.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=Rr();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(rn.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=>rn.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=>rn.toJSON(a))),t},create(e){return on.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=Rr();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=>rn.fromPartial(o)))||[],t}};function Br(){return{time:0,percent:[],colorPercent:[]}}const rn={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=Br();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 rn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=Br();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 Qs(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 js(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,frames:[],url:""}}const Gi={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)sn.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=Fr();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(sn.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:Yt(e.name)?globalThis.String(e.name):"",frameRate:Yt(e.frameRate)?globalThis.Number(e.frameRate):0,type:Yt(e.type)?Qs(e.type):0,frames:globalThis.Array.isArray(e==null?void 0:e.frames)?e.frames.map(t=>sn.fromJSON(t)):[],url:Yt(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=js(e.type)),(n=e.frames)!=null&&n.length&&(t.frames=e.frames.map(a=>sn.toJSON(a))),e.url!==""&&(t.url=e.url),t},create(e){return Gi.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=Fr();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=>sn.fromPartial(l)))||[],t.url=(i=e.url)!=null?i:"",t}};function Dr(){return{name:"",position:void 0}}const an={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=Dr();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:Yt(e.name)?globalThis.String(e.name):"",position:Yt(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 an.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=Dr();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 sn={encode(e,t=se.Writer.create()){for(const n of e.nodes)an.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(an.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=>an.fromJSON(t)):[],time:Yt(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=>an.toJSON(a))),e.time!==0&&(t.time=e.time),t},create(e){return sn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=zr();return t.nodes=((n=e.nodes)==null?void 0:n.map(r=>an.fromPartial(r)))||[],t.time=(a=e.time)!=null?a:0,t}};function Yt(e){return e!=null}class _n{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 Un{constructor(t){ve(this,"_curves",[]);this._curves=t}get curves(){return this._curves}update(t){}reset(){}}class el extends Un{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 tl extends Un{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 Yi extends Un{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 fo,po,ho,mo,In,wn,Vr,$r;function nl(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 fo=r,po=r*(t-1)*n,ho=r*(t+1)*n,mo=-r*a,In=2*n,wn=-a,Vr=(fo+po)/(1-In-wn),$r=(ho+mo)/(1-In-wn),new Float32Array([fo,po,ho,mo,In,wn,Vr,$r])}function Ur(e,t,n,a,r,o){var i,l,s,c,p,f,d,y,h,T,P,v,_,b,E,L,I,S,k,B,F,w,D,N,M,x,A,V,$,U;for(M=0;M<o;M++){for(w=M*r,D=M,N=0,i=e[w],l=i&255,s=i>>8&255,c=i>>16&255,p=i>>24&255,S=l*a[6],k=s*a[6],B=c*a[6],F=p*a[6],b=S,E=k,L=B,I=F,A=a[0],V=a[1],$=a[4],U=a[5],x=0;x<r;x++)i=e[w],f=i&255,d=i>>8&255,y=i>>16&255,h=i>>24&255,T=f*A+l*V+b*$+S*U,P=d*A+s*V+E*$+k*U,v=y*A+c*V+L*$+B*U,_=h*A+p*V+I*$+F*U,S=b,k=E,B=L,F=I,b=T,E=P,L=v,I=_,l=f,s=d,c=y,p=h,n[N]=b,n[N+1]=E,n[N+2]=L,n[N+3]=I,N+=4,w++;for(w--,N-=4,D+=o*(r-1),i=e[w],l=i&255,s=i>>8&255,c=i>>16&255,p=i>>24&255,S=l*a[7],k=s*a[7],B=c*a[7],F=p*a[7],b=S,E=k,L=B,I=F,f=l,d=s,y=c,h=p,A=a[2],V=a[3],x=r-1;x>=0;x--)T=f*A+l*V+b*$+S*U,P=d*A+s*V+E*$+k*U,v=y*A+c*V+L*$+B*U,_=h*A+p*V+I*$+F*U,S=b,k=E,B=L,F=I,b=T,E=P,L=v,I=_,l=f,s=d,c=y,p=h,i=e[w],f=i&255,d=i>>8&255,y=i>>16&255,h=i>>24&255,i=(n[N]+b<<0)+(n[N+1]+E<<8)+(n[N+2]+L<<16)+(n[N+3]+I<<24),t[D]=i,w--,N-=4,D-=o}}function ol(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=nl(a);Ur(r,o,i,l,t,n),Ur(o,r,i,l,n,t)}}var rl=ol;const il=yi(rl);class al extends Un{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;il(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 Wr=e=>{const t=Hi.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 _n);let s=0;for(let p=0;p<t.frames.length;p++){const f=t.frames[p],d=f.node.findIndex(y=>y.name===a[r]);if(d!==-1){for(let y=0;y<i;y++){const h=new st(f.time*1e3,f.node[d].percent[y].start),T=new st(f.time*1e3,f.node[d].percent[y].end);o[y*2].addKey(h),o[y*2+1].addKey(T)}for(let y=0;y<l;y++){const h=new st(f.time*1e3,f.node[d].colorPercent[y].start),T=new st(f.time*1e3,f.node[d].colorPercent[y].end);o[i*2+y*2].addKey(h),o[i*2+y*2+1].addKey(T)}s=f.node[d].index}}const c=t.animType===Mn.WATER?new Yi(o):new tl(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===Mn.RUN?"run":"water",c.colors=t.colors.map(p=>gs(p)),t.animType===Mn.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},sl=e=>{const t=Gi.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 _n),o.push(new _n),o.push(new _n);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 el(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},ll=e=>{const t=Zi.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 _n);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 al(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 y=[];for(let h=0;h<d.length;h+=3)y.push([d[h],d[h+1],d[h+2]]);s.bottomShape=y,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},Ln=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,y)=>{let h=[];switch(d){case"roadway":h=Wr(y);break;case"roadwaynear":h=sl(y);break;case"water":h=ll(y);break;default:h=Wr(y)}return h};return m.useEffect(()=>{if(p&&!c.current){c.current=!0;const d=f(r,p);console.log(d);const y=new Ps(t);y.nodes=d,i.current=y,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 Hr(){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 Bo={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=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!==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 Bo.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,l,s,c,p,f,d,y;const t=Hr();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=((y=e.value)==null?void 0:y.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 cl=(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:y,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:y,clipPlane:T,disableDepthWrite:h})})},lt=m.forwardRef(cl),ul=`#ifdef GL_ES
|
|
20
20
|
precision highp float;
|
|
21
21
|
#endif
|
|
22
22
|
|
|
@@ -177,7 +177,7 @@ void main(void) {
|
|
|
177
177
|
overlayCoord = vec2(normalizedCoord.y, 1.0 - normalizedCoord.x);
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
}`,On=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:
|
|
180
|
+
}`,On=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:y={textureIncludeSide:!0},disableDepthWrite:h,lightPosition:T=new u.Vector3(0,3e5,1e5),intensity:P=1,contrast:v=3,sideIntensity:_=.3,cullFace:b=0,zOffset:E,zOffsetUnits:L}=e,{textureIncludeSide:I}=y;return m.useEffect(()=>{r.current&&(console.log("[Geo3DViewer] 设置材质 ",c,p),r.current.setColor3("color",c),r.current.setFloat("alpha",p),r.current.setFloat("textureIncludeSide",I==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),E!==void 0&&L!==void 0&&(r.current.zOffset=E,r.current.zOffsetUnits=L))},[c,p,I,P,T,E,L,v,_,b]),m.useEffect(()=>{var k;const S=r.current;if(S&&o)if(i){const B=(k=i.startHeight)!=null?k:o.maximumWorld.y/l;return S.setFloat("contourLineStartHeight",B*l),S.setColor3("contourLineColor",i.color),S.setFloat("contourLineWidth",i.width),S.setFloat("contourLineStep",i.stepHeight*l),console.log("[Geo3DViewer] 等高线设置 ",i,o.centerWorld.y,B*l,B*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(k=>{let B=(o.maximum.x-o.minimum.x)/s,F=(o.maximum.z-o.minimum.z)/s,w=0;if(B<F){const M=B;B=F,F=M,w=1}const D=B/F;B*F>2048*2048&&(B=2048,F=2048/D);let N;return k?(k.scaleTo(B,F),k.update(),N=k):N=new u.DynamicTexture("dynamic-texture",{width:B,height:F},t,!1),N.clear(),N.update(),console.log("[Geo3DViewer] 设置动态划线 ",o,B,F,s),S.setVector3("oMin",o.minimum),S.setVector3("oMax",o.maximum),S.setFloat("textureOverlayRotate",w),S.setTexture("textureOverlaySampler",N),N})},[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,k=(o.maximum.z-o.minimum.z)/s;if(S<k){const w=S;S=k,k=w}const B=S/k;S*k>2048*2048&&(S=2048,k=2048/B);const F=n.getContext();f.forEach(w=>{if(w.points.length<2)return;F.beginPath();const D=w.offset?w.offset:new u.Vector2(0,0),N=1-w.points[0].x+D.x,M=1-w.points[0].y+D.y;F.moveTo(N*S,M*k);for(let x=1;x<w.points.length;x++){const A=w.offset?w.offset:new u.Vector2(0,0),V=1-w.points[x].x+A.x,$=1-w.points[x].y+A.y;F.lineTo(V*S,$*k)}F.strokeStyle=`rgb(${w.color.r*255}, ${w.color.g*255}, ${w.color.b*255})`,S*k>2048*2048?F.lineWidth=w.width/B:F.lineWidth=w.width,F.stroke()}),d.forEach(w=>{var x,A;F.font=`${w.fontSize}px Arial`;const D=(x=w.color)!=null?x:u.Color3.White(),N=w.offset?w.offset:new u.Vector2(0,0),M=(A=w.rotation)!=null?A:0;if(F.save(),F.translate((1-w.position.x+N.x)*S,(1-w.position.y+N.y)*k),F.rotate(M),w.clearArea){const V=F.measureText(w.text);F.clearRect(-V.width*.15,.5*w.fontSize*(1-.3),V.width*1.3,-w.fontSize*1.3)}if(w.background){F.fillStyle=`rgba(${w.background.r*255}, ${w.background.g*255}, ${w.background.b*255})`;const V=F.measureText(w.text);F.fillRect(-V.width*.05,.5*(w.fontSize*(.5-.1)),V.width*1.1,-w.fontSize*1.1)}F.fillStyle=`rgb(${D.r*255}, ${D.g*255}, ${D.b*255})`,F.fillText(w.text,0,0),F.restore()}),n.update()}},[f,n,o,s,d]),C.jsx(lt,{ref:r,name:e.name,backFaceCulling:e.backFaceCulling,needDepthPrePass:e.needDepthPrePass,vertex:fl,fragment:ul,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})},Wn=`#version 300 es
|
|
181
181
|
precision highp float;
|
|
182
182
|
|
|
183
183
|
in vec2 vUV;
|
|
@@ -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
|
-
}`,Zn=({alpha:e,zOffset:t,zOffsetUnits:n,disableDepthWrite:a})=>C.jsx("pbrMaterial",{name:"metal-pbr-material",alpha:e,transparencyMode:e!==void 0&&e<1?f.Material.MATERIAL_ALPHABLEND:f.Material.MATERIAL_OPAQUE,alphaMode:f.Engine.ALPHA_COMBINE,roughness:.25,metallic:1,albedoColor:new f.Color3(.7,.7,.7),metallicF0Factor:.1,zOffset:t,zOffsetUnits:n,disableDepthWrite:a}),Gn=({alpha:e,zOffset:t,zOffsetUnits:n,disableDepthWrite:a})=>C.jsx("pbrMaterial",{name:"metal-pbr-material",alpha:e,transparencyMode:e!==void 0&&e<1?f.Material.MATERIAL_ALPHABLEND:f.Material.MATERIAL_OPAQUE,alphaMode:f.Engine.ALPHA_COMBINE,roughness:.25,metallic:1,albedoColor:new f.Color3(.2,.2,.2),metallicF0Factor:.1,zOffsetUnits:n,zOffset:t,disableDepthWrite:a});var Xt=(e=>(e[e.TRIGONOMETRIC=0]="TRIGONOMETRIC",e[e.PLANE=1]="PLANE",e[e.FLAT=2]="FLAT",e))(Xt||{});const qt=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:u,zOffsetUnits:d,sideTexture:x,uvOffset:h=f.Vector2.Zero(),counterLine:T=void 0,scalePlane:P=1,scaleDepth:y=1,boundingBox:_=void 0,lines:b=[],text:k=[],disableDepthWrite:L,flatModeRotate:I=0}=e,S=E=>{a(E)};return m.useEffect(()=>{n&&s&&(n.setTexture("textureSampler",s),n.setFloat("textureFlatRotate",I),n.setVector2("uvOffset",h))},[I,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 E;if(n)if(T&&_){const B=(E=T.startHeight)!=null?E:_.minimumWorld.y/y;return n.setFloat("contourLineStartHeight",B*y),n.setColor3("contourLineColor",T.color),n.setFloat("contourLineWidth",T.width),n.setFloat("contourLineStep",T.stepHeight*y),console.log("[Geo3DViewer] 等高线设置 ",T,_.centerWorld.y,B*y,B*y+16*T.stepHeight*y),()=>{n&&(n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new f.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0))}}else n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new f.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[T,y,P,_,n]),m.useEffect(()=>{t&&n&&_&&o(E=>{E&&E.dispose();let B=(_.maximum.x-_.minimum.x)/P,F=(_.maximum.z-_.minimum.z)/P,w=0;if(B<F){const M=B;B=F,F=M,w=1}const D=B/F;B*F>2048*2048&&(B=2048,F=2048/D);const N=new f.DynamicTexture("dynamic-texture",{width:B,height:F},t,!1);return N.clear(),console.log("[Geo3DViewer] 设置动态划线 ",_,B,F,P),n.setVector3("oMin",_.minimum),n.setVector3("oMax",_.maximum),n.setFloat("textureOverlayRotate",w),n.setTexture("textureOverlaySampler",N),N})},[_,n,P,t]),m.useEffect(()=>{var E;if(r&&_)if((E=r.getScene())!=null&&E.getEngine()){r.clear();let B=(_.maximum.x-_.minimum.x)/P,F=(_.maximum.z-_.minimum.z)/P;if(B<F){const N=B;B=F,F=N}const w=B/F;B*F>2048*2048&&(B=2048,F=2048/w);const D=r.getContext();b.forEach(N=>{if(N.points.length<2)return;D.beginPath();const M=N.offset?N.offset:new f.Vector2(0,0),v=1-N.points[0].x+M.x,A=1-N.points[0].y+M.y;D.moveTo(v*B,A*F);for(let V=1;V<N.points.length;V++){const $=N.offset?N.offset:new f.Vector2(0,0),U=1-N.points[V].x+$.x,ie=1-N.points[V].y+$.y;D.lineTo(U*B,ie*F)}D.strokeStyle=`rgb(${N.color.r*255}, ${N.color.g*255}, ${N.color.b*255})`,B*F>2048*2048?D.lineWidth=N.width/w:D.lineWidth=N.width,D.stroke()}),k.forEach(N=>{var V,$;D.font=`${N.fontSize}px Arial`;const M=(V=N.color)!=null?V:f.Color3.White(),v=N.offset?N.offset:new f.Vector2(0,0),A=($=N.rotation)!=null?$:0;if(D.save(),D.translate((1-N.position.x+v.x)*B,(1-N.position.y+v.y)*F),D.rotate(A),N.clearArea){const U=D.measureText(N.text);D.clearRect(-U.width*.15,.5*N.fontSize*(1-.3),U.width*1.3,-N.fontSize*1.3)}if(N.background){D.fillStyle=`rgba(${N.background.r*255}, ${N.background.g*255}, ${N.background.b*255})`;const U=D.measureText(N.text);D.fillRect(-U.width*.05,.5*(N.fontSize*(.5-.1)),U.width*1.1,-N.fontSize*1.1)}D.fillStyle=`rgb(${M.r*255}, ${M.g*255}, ${M.b*255})`,D.fillText(N.text,0,0),D.restore()}),r.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[b,k,r,_,P]),C.jsx(lt,{...e,ref:S,vertex:cu,fragment:lu,options:{attributes:["position","color","alpha","normal"],uniforms:["worldViewProjection","tilingFactor","sideTilingFactor","mode","uvOffset","contourLineStartHeight","contourLineColor","contourLineWidth","contourLineStep","oMin","oMax","textureOverlayRotate","textureFlatRotate"],samplers:["textureSampler","textureOverlaySampler","textureSideSampler"],needAlphaBlending:!0,needAlphaTesting:!0},zOffset:u,zOffsetUnits:d,disableDepthWrite:L})},Mt=e=>{const t=_e.useScene(),n=m.useRef(null),a=m.useContext(Dn),[r,o]=m.useState(null),{name:i,colorCodec:l,alpha:s=1,backFaceCulling:c,needDepthPrePass:p=!1,transparencyMode:u=f.Material.MATERIAL_OPAQUE,alphaMode:d=f.Engine.ALPHA_COMBINE,zOffset:x,zOffsetUnits:h,clipPlane:T,counterLine:P=void 0,scalePlane:y=1,scaleDepth:_=1,boundingBox:b,lines:k=[],text:L=[],disableDepthWrite:I}=e;return m.useEffect(()=>{const S=n.current;S&&t&&(S.loadFromSerialization(iu,""),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=u,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=I!=null?I:!1)},[s,d,c,T,I,i,p,u,x,h]),m.useEffect(()=>{if(l){const S=n.current;S&&(S.metadata={colorCodec:l},f.Tags.EnableFor(S),f.Tags.AddTagsTo(S,"remap"))}if(l&&a&&t&&a.colorCodecsImage.current[l]){const S=n.current;if(S){const E=S.getBlockByName("RemappedTexture");E&&(E.texture=a.colorCodecsImage.current[l].texture,S.markAsDirty(f.NodeMaterial.TextureDirtyFlag))}}},[l,t]),m.useEffect(()=>{n.current&&t&&(console.log("[Geo3DViewer] RemapColorByRedChannel 透明度更新 ",s),n.current.alpha=s)},[t,s]),m.useEffect(()=>{var E;const S=n.current;if(S){const B=S.getBlockByName("contourLineStartHeight"),F=S.getBlockByName("contourLineColor"),w=S.getBlockByName("contourLineWidth"),D=S.getBlockByName("contourLineStep");if(P&&b){const N=(E=P.startHeight)!=null?E:b.centerWorld.y/_;return B&&(B.value=N*_),F&&(F.value=P.color),w&&(w.value=P.width),D&&(D.value=P.stepHeight*_),console.log("[Geo3DViewer] 等高线设置 ",P,b.centerWorld,b.centerWorld.y,N*_,N*_+16*P.stepHeight*_),()=>{S&&(B&&(B.value=0),F&&(F.value=new f.Color3(0,0,0)),w&&(w.value=0),D&&(D.value=0))}}else B&&(B.value=0),F&&(F.value=new f.Color3(0,0,0)),w&&(w.value=0),D&&(D.value=0),console.log("[Geo3DViewer] 等高线设置 关闭");S.markAsDirty(f.NodeMaterial.MiscDirtyFlag)}},[P,_,y,b]),m.useEffect(()=>{t&&b&&o(S=>{var v,A;S&&S.dispose();let E=(b.maximum.x-b.minimum.x)/y,B=(b.maximum.z-b.minimum.z)/y,F=0;if(E<B){const V=E;E=B,B=V,F=1}const w=E/B;E*B>2048*2048&&(E=2048,B=2048/w);const D=new f.DynamicTexture("dynamic-texture",{width:E,height:B},t,!1);D.clear(),console.log("[Geo3DViewer] 设置动态划线 ",b,E,B,y);const N=(v=n.current)==null?void 0:v.getBlockByName("angle"),M=(A=n.current)==null?void 0:A.getBlockByName("OverlayTexture");return N&&(N.value=F*(Math.PI/2)),M&&(M.texture=D),D})},[b,y,t]),m.useEffect(()=>{var S;if(r&&b)if((S=r.getScene())!=null&&S.getEngine()){r.clear();let E=(b.maximum.x-b.minimum.x)/y,B=(b.maximum.z-b.minimum.z)/y;if(E<B){const D=E;E=B,B=D}const F=E/B;E*B>2048*2048&&(E=2048,B=2048/F);const w=r.getContext();k.forEach(D=>{if(D.points.length<2)return;w.beginPath();const N=D.offset?D.offset:new f.Vector2(0,0),M=1-D.points[0].x+N.x,v=1-D.points[0].y+N.y;w.moveTo(M*E,v*B);for(let A=1;A<D.points.length;A++){const V=D.offset?D.offset:new f.Vector2(0,0),$=1-D.points[A].x+V.x,U=1-D.points[A].y+V.y;w.lineTo($*E,U*B)}w.strokeStyle=`rgb(${D.color.r*255}, ${D.color.g*255}, ${D.color.b*255})`,E*B>2048*2048?w.lineWidth=D.width/F:w.lineWidth=D.width,w.stroke()}),L.forEach(D=>{var A,V;w.font=`${D.fontSize}px Arial`;const N=(A=D.color)!=null?A:f.Color3.White(),M=D.offset?D.offset:new f.Vector2(0,0),v=(V=D.rotation)!=null?V:0;if(w.save(),w.translate((1-D.position.x+M.x)*E,(1-D.position.y+M.y)*B),w.rotate(v),D.clearArea){const $=w.measureText(D.text);w.clearRect(-$.width*.15,.5*D.fontSize*(1-.3),$.width*1.3,-D.fontSize*1.3)}if(D.background){w.fillStyle=`rgba(${D.background.r*255}, ${D.background.g*255}, ${D.background.b*255})`;const $=w.measureText(D.text);w.fillRect(-$.width*.05,.5*(D.fontSize*(.5-.1)),$.width*1.1,-D.fontSize*1.1)}w.fillStyle=`rgb(${N.r*255}, ${N.g*255}, ${N.b*255})`,w.fillText(D.text,0,0),w.restore()}),r.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[k,r,b,y,L]),C.jsx("nodeMaterial",{ref:n,name:`${i}-material`,backFaceCulling:c,needDepthPrePass:p,transparencyMode:u,alphaMode:d,alpha:s,zOffset:x,zOffsetUnits:h,clipPlane:T,disableDepthWrite:I})},Ji=e=>{const t=_e.useScene(),n=m.useContext(Dn),a=m.useRef(null),[r,o]=m.useState(null),[i,l]=m.useState(null),[s,c]=m.useState(null),[p,u]=m.useState(null),[d,x]=m.useState(null),[h,T]=m.useState(null),[P,y]=m.useState(null),[_,b]=m.useState(null),{boundingBox:k,colorCodec:L,alphaStage:I,cutNormal:S,value:E,zOffset:B,zOffsetUnits:F,counterLine:w=void 0,scaleDepth:D=1,scalePlane:N=1,lines:M=[],text:v=[],disableDepthWrite:A}=e;return m.useEffect(()=>{const V=($,U,ie)=>{if(k){const ne=k.maximumWorld.multiply(U),G=k.minimumWorld.multiply(U),ae=k.centerWorld.multiply(U),oe=Math.max(ne.x,ne.y,ne.z),j=Math.max(G.x,G.y,G.z),Y=Math.max(ae.x,ae.y,ae.z),ce=Math.max(Math.abs(U.x),Math.abs(U.z));$(new f.Plane(U.x,U.y,U.z,((oe-j)*(1-ie-.5)*ce+Y)*-1))}else $(null)};k&&_&&(V(o,_.cutPlane1,E.value1),_.cutPlane2&&E.value2?V(l,_.cutPlane2,E.value2):l(null),_.cutPlane3&&E.value3?V(c,_.cutPlane3,E.value3):c(null),_.cutPlane4&&E.value4?V(u,_.cutPlane4,E.value4):u(null),_.cutPlane5&&E.value5?V(x,_.cutPlane5,E.value5):c(null),_.cutPlane6&&E.value6?V(T,_.cutPlane6,E.value6):T(null))},[k,_,E]),m.useEffect(()=>{b({cutPlane1:f.Vector3.Normalize(S.cutPlane1),cutPlane2:S.cutPlane2?f.Vector3.Normalize(S.cutPlane2):void 0,cutPlane3:S.cutPlane3?f.Vector3.Normalize(S.cutPlane3):void 0,cutPlane4:S.cutPlane4?f.Vector3.Normalize(S.cutPlane4):void 0,cutPlane5:S.cutPlane5?f.Vector3.Normalize(S.cutPlane5):void 0,cutPlane6:S.cutPlane6?f.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,$,U,ie,ne;a.current&&t&&(a.current.setFloat("alpha1",I.alpha1),a.current.setFloat("alpha2",(V=I.alpha2)!=null?V:1),a.current.setFloat("alpha3",($=I.alpha3)!=null?$:1),a.current.setFloat("alpha4",(U=I.alpha4)!=null?U:1),a.current.setFloat("alpha5",(ie=I.alpha5)!=null?ie:1),a.current.setFloat("alpha6",(ne=I.alpha6)!=null?ne:1))},[t,I]),m.useEffect(()=>{if(L){const V=a.current;V&&(V.metadata={colorCodec:L},f.Tags.EnableFor(V),f.Tags.AddTagsTo(V,"remap"))}if(L&&n&&t&&n.colorCodecsImage.current[L]){const V=a.current;V&&(console.log(n.colorCodecsImage.current[L]),V.setTexture("textureSampler",n.colorCodecsImage.current[L].texture),V.metadata={colorCodec:L},f.Tags.EnableFor(V),f.Tags.AddTagsTo(V,"remap"))}},[L,t]),m.useEffect(()=>{var $;const V=a.current;if(V&&k)if(w){const U=($=w.startHeight)!=null?$:k.minimumWorld.y/D;return V.setFloat("contourLineStartHeight",U*D),V.setColor3("contourLineColor",w.color),V.setFloat("contourLineWidth",w.width),V.setFloat("contourLineStep",w.stepHeight*D),console.log("[Geo3DViewer] 等高线设置 ",w,k.centerWorld.y,U*D,U*D+16*w.stepHeight*D),()=>{V&&(V.setFloat("contourLineStartHeight",0),V.setColor3("contourLineColor",new f.Color3(0,0,0)),V.setFloat("contourLineWidth",0),V.setFloat("contourLineStep",0))}}else V.setFloat("contourLineStartHeight",0),V.setColor3("contourLineColor",new f.Color3(0,0,0)),V.setFloat("contourLineWidth",0),V.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[w,D,N,k]),m.useEffect(()=>{t&&k&&y(V=>{var ae,oe,j,Y;V&&V.dispose();let $=(k.maximum.x-k.minimum.x)/N,U=(k.maximum.z-k.minimum.z)/N,ie=0;if($<U){const ce=$;$=U,U=ce,ie=1}const ne=$/U;$*U>2048*2048&&($=2048,U=2048/ne);const G=new f.DynamicTexture("dynamic-texture",{width:$,height:U},t,!1);return G.clear(),console.log("[Geo3DViewer] 设置动态划线 ",k,$,U,N),(ae=a.current)==null||ae.setVector3("oMin",k.minimum),(oe=a.current)==null||oe.setVector3("oMax",k.maximum),(j=a.current)==null||j.setFloat("textureOverlayRotate",ie),(Y=a.current)==null||Y.setTexture("textureOverlaySampler",G),G})},[k,N,t]),m.useEffect(()=>{var V;if(P&&k)if((V=P.getScene())!=null&&V.getEngine()){P.clear();let $=(k.maximum.x-k.minimum.x)/N,U=(k.maximum.z-k.minimum.z)/N;if($<U){const G=$;$=U,U=G}const ie=$/U;$*U>2048*2048&&($=2048,U=2048/ie);const ne=P.getContext();M.forEach(G=>{if(G.points.length<2)return;ne.beginPath();const ae=G.offset?G.offset:new f.Vector2(0,0),oe=1-G.points[0].x+ae.x,j=1-G.points[0].y+ae.y;ne.moveTo(oe*$,j*U);for(let Y=1;Y<G.points.length;Y++){const ce=G.offset?G.offset:new f.Vector2(0,0),le=1-G.points[Y].x+ce.x,X=1-G.points[Y].y+ce.y;ne.lineTo(le*$,X*U)}ne.strokeStyle=`rgb(${G.color.r*255}, ${G.color.g*255}, ${G.color.b*255})`,$*U>2048*2048?ne.lineWidth=G.width/ie:ne.lineWidth=G.width,ne.stroke()}),v.forEach(G=>{var Y,ce;ne.font=`${G.fontSize}px Arial`;const ae=(Y=G.color)!=null?Y:f.Color3.White(),oe=G.offset?G.offset:new f.Vector2(0,0),j=(ce=G.rotation)!=null?ce:0;if(ne.save(),ne.translate((1-G.position.x+oe.x)*$,(1-G.position.y+oe.y)*U),ne.rotate(j),G.clearArea){const le=ne.measureText(G.text);ne.clearRect(-le.width*.15,.5*G.fontSize*(1-.3),le.width*1.3,-G.fontSize*1.3)}if(G.background){ne.fillStyle=`rgba(${G.background.r*255}, ${G.background.g*255}, ${G.background.b*255})`;const le=ne.measureText(G.text);ne.fillRect(-le.width*.05,.5*(G.fontSize*(.5-.1)),le.width*1.1,-G.fontSize*1.1)}ne.fillStyle=`rgb(${ae.r*255}, ${ae.g*255}, ${ae.b*255})`,ne.fillText(G.text,0,0),ne.restore()}),P.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[M,P,k,N,v]),C.jsx(lt,{...e,ref:a,vertex:su,fragment:au,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:B,zOffsetUnits:F})},Xi=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,u]=m.useState(null),[d,x]=m.useState(null),[h,T]=m.useState(null),[P,y]=m.useState(null),[_,b]=m.useState(null),{boundingBox:k=void 0,texture:L,sideTexture:I,alphaStage:S,cutNormal:E,value:B,tilingFactor:F=.1,sideTilingFactor:w=.1,mode:D=0,zOffset:N,zOffsetUnits:M,overlay:v={},counterLine:A=void 0,scalePlane:V=1,scaleDepth:$=1,lines:U=[],text:ie=[],disableDepthWrite:ne,textureFlatRotate:G=0}=e,ae=oe=>{a(oe)};return m.useEffect(()=>{n&&n.setFloat("textureFlatRotate",G)},[n,G]),m.useEffect(()=>{const oe=(j,Y,ce)=>{if(k){const le=k.maximumWorld.multiply(Y),X=k.minimumWorld.multiply(Y),Pe=k.centerWorld.multiply(Y),ge=Math.max(le.x,le.y,le.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)),be=new f.Plane(Y.x,Y.y,Y.z,((ge-H)*(1-ce-.5)*Ee+Q)*-1);j(be),console.log("[Geo3DViewer] 设置实际 CutPlane 为 ",be,Ee)}else j(null)};k&&_&&(oe(o,_.cutPlane1,B.value1),_.cutPlane2&&B.value2?oe(l,_.cutPlane2,B.value2):l(null),_.cutPlane3&&B.value3?oe(c,_.cutPlane3,B.value3):c(null),_.cutPlane4&&B.value4?oe(u,_.cutPlane4,B.value4):u(null),_.cutPlane5&&B.value5?oe(x,_.cutPlane5,B.value5):c(null),_.cutPlane6&&B.value6?oe(T,_.cutPlane6,B.value6):T(null))},[_,k,B]),m.useEffect(()=>{b({cutPlane1:f.Vector3.Normalize(E.cutPlane1),cutPlane2:E.cutPlane2?f.Vector3.Normalize(E.cutPlane2):void 0,cutPlane3:E.cutPlane3?f.Vector3.Normalize(E.cutPlane3):void 0,cutPlane4:E.cutPlane4?f.Vector3.Normalize(E.cutPlane4):void 0,cutPlane5:E.cutPlane5?f.Vector3.Normalize(E.cutPlane5):void 0,cutPlane6:E.cutPlane6?f.Vector3.Normalize(E.cutPlane6):void 0})},[E]),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 oe,j,Y,ce,le;n&&t&&(n.setFloat("alpha1",S.alpha1),n.setFloat("alpha2",(oe=S.alpha2)!=null?oe:1),n.setFloat("alpha3",(j=S.alpha3)!=null?j:1),n.setFloat("alpha4",(Y=S.alpha4)!=null?Y:1),n.setFloat("alpha5",(ce=S.alpha5)!=null?ce:1),n.setFloat("alpha6",(le=S.alpha6)!=null?le:1))},[t,S,n]),m.useEffect(()=>{n&&L&&n.setTexture("textureSampler",L)},[n,L]),m.useEffect(()=>{n&&F&&n.setFloat("tilingFactor",F),n&&w&&n.setFloat("sideTilingFactor",w)},[F,w,n]),m.useEffect(()=>{n&&D&&n.setInt("mode",D)},[n,D]),m.useEffect(()=>{n&&(I?n.setTexture("textureSideSampler",I):n.setTexture("textureSideSampler",L))},[n,I,L]),m.useEffect(()=>{n&&(v.texture1?n.setTexture("textureSampler1",v.texture1):n.setTexture("textureSampler1",L),v.sideTexture1?n.setTexture("textureSideSampler1",v.sideTexture1):n.setTexture("textureSideSampler1",L),v.color1?n.setColor3("vColor1",v.color1):n.setColor3("vColor1",new f.Color3(1,1,1)),v.texture2?n.setTexture("textureSampler2",v.texture2):n.setTexture("textureSampler2",L),v.sideTexture2?n.setTexture("textureSideSampler2",v.sideTexture2):n.setTexture("textureSideSampler2",L),v.color2?n.setColor3("vColor2",v.color2):n.setColor3("vColor2",new f.Color3(1,1,1)),v.texture3?n.setTexture("textureSampler3",v.texture3):n.setTexture("textureSampler3",L),v.sideTexture3?n.setTexture("textureSideSampler3",v.sideTexture3):n.setTexture("textureSideSampler2",L),v.color3?n.setColor3("vColor3",v.color3):n.setColor3("vColor3",new f.Color3(1,1,1)),v.texture4?n.setTexture("textureSampler4",v.texture4):n.setTexture("textureSampler4",L),v.sideTexture4?n.setTexture("textureSideSampler4",v.sideTexture4):n.setTexture("textureSideSampler4",L),v.color4?n.setColor3("vColor4",v.color4):n.setColor3("vColor4",new f.Color3(1,1,1)),v.texture5?n.setTexture("textureSampler5",v.texture5):n.setTexture("textureSampler5",L),v.sideTexture5?n.setTexture("textureSideSampler5",v.sideTexture5):n.setTexture("textureSideSampler5",L),v.color5?n.setColor3("vColor5",v.color5):n.setColor3("vColor5",new f.Color3(1,1,1)),v.texture6?n.setTexture("textureSampler6",v.texture6):n.setTexture("textureSampler6",L),v.sideTexture6?n.setTexture("textureSideSampler6",v.sideTexture6):n.setTexture("textureSideSampler6",L),v.color6?n.setColor3("vColor6",v.color6):n.setColor3("vColor6",new f.Color3(1,1,1)))},[n,v,L]),m.useEffect(()=>{var oe;if(n&&k)if(A){const j=(oe=A.startHeight)!=null?oe:k.minimumWorld.y/$;return n.setFloat("contourLineStartHeight",j*$),n.setColor3("contourLineColor",A.color),n.setFloat("contourLineWidth",A.width),n.setFloat("contourLineStep",A.stepHeight*$),console.log("[Geo3DViewer] 等高线设置 ",A,k.centerWorld.y,j*$,j*$+16*A.stepHeight*$),()=>{n&&(n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new f.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0))}}else n.setFloat("contourLineStartHeight",0),n.setColor3("contourLineColor",new f.Color3(0,0,0)),n.setFloat("contourLineWidth",0),n.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[A,$,V,k,n]),m.useEffect(()=>{t&&n&&k&&y(oe=>{oe&&oe.dispose();let j=(k.maximum.x-k.minimum.x)/V,Y=(k.maximum.z-k.minimum.z)/V,ce=0;if(j<Y){const Pe=j;j=Y,Y=Pe,ce=1}const le=j/Y;j*Y>2048*2048&&(j=2048,Y=2048/le);const X=new f.DynamicTexture("dynamic-texture",{width:j,height:Y},t,!1);return X.clear(),console.log("[Geo3DViewer] 设置动态划线 ",k,j,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 oe;if(P&&k)if((oe=P.getScene())!=null&&oe.getEngine()){P.clear();let j=(k.maximum.x-k.minimum.x)/V,Y=(k.maximum.z-k.minimum.z)/V;if(j<Y){const X=j;j=Y,Y=X}const ce=j/Y;j*Y>2048*2048&&(j=2048,Y=2048/ce);const le=P.getContext();U.forEach(X=>{if(X.points.length<2)return;le.beginPath();const Pe=X.offset?X.offset:new f.Vector2(0,0),ge=1-X.points[0].x+Pe.x,H=1-X.points[0].y+Pe.y;le.moveTo(ge*j,H*Y);for(let Q=1;Q<X.points.length;Q++){const Ee=X.offset?X.offset:new f.Vector2(0,0),be=1-X.points[Q].x+Ee.x,ee=1-X.points[Q].y+Ee.y;le.lineTo(be*j,ee*Y)}le.strokeStyle=`rgb(${X.color.r*255}, ${X.color.g*255}, ${X.color.b*255})`,j*Y>2048*2048?le.lineWidth=X.width/ce:le.lineWidth=X.width,le.stroke()}),ie.forEach(X=>{var Q,Ee;le.font=`${X.fontSize}px Arial`;const Pe=(Q=X.color)!=null?Q:f.Color3.White(),ge=X.offset?X.offset:new f.Vector2(0,0),H=(Ee=X.rotation)!=null?Ee:0;if(le.save(),le.translate((1-X.position.x+ge.x)*j,(1-X.position.y+ge.y)*Y),le.rotate(H),X.clearArea){const be=le.measureText(X.text);le.clearRect(-be.width*.15,.5*X.fontSize*(1-.3),be.width*1.3,-X.fontSize*1.3)}if(X.background){le.fillStyle=`rgba(${X.background.r*255}, ${X.background.g*255}, ${X.background.b*255})`;const be=le.measureText(X.text);le.fillRect(-be.width*.05,.5*(X.fontSize*(.5-.1)),be.width*1.1,-X.fontSize*1.1)}le.fillStyle=`rgb(${Pe.r*255}, ${Pe.g*255}, ${Pe.b*255})`,le.fillText(X.text,0,0),le.restore()}),P.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[U,P,k,V,ie]),C.jsx(lt,{...e,ref:ae,vertex:fu,fragment:uu,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:N,zOffsetUnits:M,disableDepthWrite:ne})},hu=e=>C.jsx(lt,{...e,vertex:Hn,fragment:Wn,options:{needAlphaBlending:!0},zOffset:e.zOffset,zOffsetUnits:e.zOffsetUnits,disableDepthWrite:e.disableDepthWrite}),mu=()=>C.jsx(lt,{name:"picking-material",vertex:bc,fragment:Tc,backFaceCulling:!1,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","pickingColor","isPickable"]}}),gu=({name:e,scene:t})=>{const n=f.NodeMaterial.Parse(_c,t);return n.name=e,n.backFaceCulling=!1,n.build(!1,!0,!1),n},vu=({name:e,lineColor:t,lineWidth:n=.5})=>{const a=_e.useScene(),[r,o]=m.useState(null);return m.useEffect(()=>{if(a){const i=f.NodeMaterial.Parse(Wl,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},xu=(e,t)=>{const n=m.useRef(null);return m.useEffect(()=>{n.current&&(n.current.setVector4("typeAlpha1",new f.Vector4(e.typeAlpha.typeAlpha0===void 0?1:e.typeAlpha.typeAlpha0,e.typeAlpha.typeAlpha1,e.typeAlpha.typeAlpha2,e.typeAlpha.typeAlpha3)),n.current.setVector4("typeAlpha2",new f.Vector4(e.typeAlpha.typeAlpha4,e.typeAlpha.typeAlpha5,e.typeAlpha.typeAlpha6,e.typeAlpha.typeAlpha7)),n.current.setVector4("typeAlpha3",new f.Vector4(e.typeAlpha.typeAlpha8,e.typeAlpha.typeAlpha9,e.typeAlpha.typeAlpha10,e.typeAlpha.typeAlpha11)),n.current.setVector4("typeAlpha4",new f.Vector4(e.typeAlpha.typeAlpha12,e.typeAlpha.typeAlpha13,e.typeAlpha.typeAlpha14,e.typeAlpha.typeAlpha15)),n.current.setVector4("typeAlpha5",new f.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:du,transparencyMode:f.Material.MATERIAL_ALPHABLEND,alphaMode:f.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}})},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:u=[],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 y=r.current;if(y&&o)if(i){const b=(_=i.startHeight)!=null?_:o.maximumWorld.y/l;return y.setFloat("contourLineStartHeight",b*l),y.setColor3("contourLineColor",i.color),y.setFloat("contourLineWidth",i.width),y.setFloat("contourLineStep",i.stepHeight*l),console.log("[Geo3DViewer] 等高线设置 ",i,o.centerWorld.y,b*l,b*l-16*i.stepHeight*l),()=>{y&&(y.setFloat("contourLineStartHeight",0),y.setColor3("contourLineColor",new f.Color3(0,0,0)),y.setFloat("contourLineWidth",0),y.setFloat("contourLineStep",0))}}else y.setFloat("contourLineStartHeight",0),y.setColor3("contourLineColor",new f.Color3(0,0,0)),y.setFloat("contourLineWidth",0),y.setFloat("contourLineStep",0),console.log("[Geo3DViewer] 等高线设置 关闭")},[o,i,l,s]),m.useEffect(()=>{const y=r.current;t&&o&&y&&a(_=>{let b=(o.maximum.x-o.minimum.x)/s,k=(o.maximum.z-o.minimum.z)/s,L=0;if(b<k){const E=b;b=k,k=E,L=1}const I=b/k;b*k>2048*2048&&(b=2048,k=2048/I);let S;return _?(_.scaleTo(b,k),_.update(),S=_):S=new f.DynamicTexture("dynamic-texture",{width:b,height:k},t,!1),S.clear(),S.update(),console.log("[Geo3DViewer] 设置动态划线 ",o,b,k,s),y.setVector3("oMin",o.minimum),y.setVector3("oMax",o.maximum),y.setFloat("textureOverlayRotate",L),y.setTexture("textureOverlaySampler",S),S})},[o,s,t]),m.useEffect(()=>{var y;if(n&&o&&(u.length>0||d.length>0))if((y=n.getScene())!=null&&y.getEngine()){n.clear();let _=(o.maximum.x-o.minimum.x)/s,b=(o.maximum.z-o.minimum.z)/s;if(_<b){const I=_;_=b,b=I}const k=_/b;_*b>2048*2048&&(_=2048,b=2048/k);const L=n.getContext();u.forEach(I=>{if(I.points.length<2)return;L.beginPath();const S=I.offset?I.offset:new f.Vector2(0,0),E=1-I.points[0].x+S.x,B=1-I.points[0].y+S.y;L.moveTo(E*_,B*b);for(let F=1;F<I.points.length;F++){const w=I.offset?I.offset:new f.Vector2(0,0),D=1-I.points[F].x+w.x,N=1-I.points[F].y+w.y;L.lineTo(D*_,N*b)}L.strokeStyle=`rgb(${I.color.r*255}, ${I.color.g*255}, ${I.color.b*255})`,_*b>2048*2048?L.lineWidth=I.width/k:L.lineWidth=I.width,L.stroke()}),d.forEach(I=>{var F,w;L.font=`${I.fontSize}px Arial`;const S=(F=I.color)!=null?F:f.Color3.White(),E=I.offset?I.offset:new f.Vector2(0,0),B=(w=I.rotation)!=null?w:0;if(L.save(),L.translate((1-I.position.x+E.x)*_,(1-I.position.y+E.y)*b),L.rotate(B),I.clearArea){const D=L.measureText(I.text);L.clearRect(-D.width*.15,.5*I.fontSize*(1-.3),D.width*1.3,-I.fontSize*1.3)}if(I.background){L.fillStyle=`rgba(${I.background.r*255}, ${I.background.g*255}, ${I.background.b*255})`;const D=L.measureText(I.text);L.fillRect(-D.width*.05,.5*(I.fontSize*(.5-.1)),D.width*1.1,-I.fontSize*1.1)}L.fillStyle=`rgb(${S.r*255}, ${S.g*255}, ${S.b*255})`,L.fillText(I.text,0,0),L.restore()}),n.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[u,n,o,s,d]),m.useEffect(()=>{const y=r.current;if(y){if(T)return y.setFloat("disableNormalShadow",1),console.log("[Geo3DViewer] 禁用法向阴影 启用"),()=>{y&&y.setFloat("disableNormalShadow",0)};y.setFloat("disableNormalShadow",0),console.log("[Geo3DViewer] 禁用法向阴影 禁用")}},[T]),C.jsx(lt,{ref:r,name:e.name,backFaceCulling:e.backFaceCulling,needDepthPrePass:e.needDepthPrePass,vertex:Sc,fragment:Pc,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})},yu=m.forwardRef(xu),qi=({name:e,url:t,offset:n=f.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}),u=He({url:r.texture,cacheType:Me.URL_PREFIX_MATCH}),d=He({url:r.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),[x,h]=m.useState(f.Vector3.Zero()),[T,P]=m.useState();return m.useEffect(()=>{console.log("[Geo3DViewer] AttributeBody Loading: ",t)},[t]),m.useEffect(()=>{if(l&&s.current&&t&&p){f.Tags.EnableFor(s.current),f.Tags.AddTagsTo(s.current,"loading");const y=Bo.decode(new Uint8Array(p)),{points:_,indices:b,value:k,center:L}=y,I=new f.VertexData;I.positions=_,I.indices=b,I.colors=k;const S=[];f.VertexData.ComputeNormals(_,b,S),I.normals=S,L&&h(new f.Vector3(L.x,L.y,L.z));const E=s.current;E&&(I.applyToMesh(E),E.getScene().onAfterRenderObservable.addOnce(()=>{if(!E.isDisposed()){const F=E.getBoundingInfo();P(F.boundingBox)}})),f.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,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 f.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:f.Material.MATERIAL_ALPHABLEND,alphaMode:f.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:f.Material.MATERIAL_ALPHABLEND,specularColor:new f.Color3(0,0,0),ambientColor:new f.Color3(1,1,1),diffuseColor:new f.Color3(r.color.r,r.color.g,r.color.b),emissiveColor:f.Color3.Black(),alphaMode:f.Engine.ALPHA_COMBINE,alpha:r.alpha?r.alpha:a,zOffset:-3,disableDepthWrite:r.disableDepthWrite}):r.type===$e.TEXTURE&&u?C.jsx(qt,{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:f.Material.MATERIAL_ALPHABLEND,alphaMode:f.Engine.ALPHA_COMBINE,texture:u,sideTexture:d,mode:r.textureMode===void 0?Xt.PLANE:r.textureMode,boundingBox:T,disableDepthWrite:r.disableDepthWrite}):C.jsx(C.Fragment,{})})})})},Ki=({codec:e,showValue:t=!1,showTitle:n=!0,width:a=80,height:r=200})=>{const o=m.useContext(Dn);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 Zr(){return{name:"",colorId:0,points:[],indices:[],bottomIndices:[],value:[],vMin:0,vMax:0,border:[],side:[],sideIndices:[],sideValue:[],center:void 0}}const Ut={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=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.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:Cn(e.name)?globalThis.String(e.name):"",colorId:Cn(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:Cn(e.vMin)?globalThis.Number(e.vMin):0,vMax:Cn(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:Cn(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 Ut.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,l,s,c,p,u,d,x;const t=Zr();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=((u=e.side)==null?void 0:u.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 Cn(e){return e!=null}const Cu=64,_u=32,Qi='"Noto Sans SC", sans-serif';function Pu(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 ${Qi}`;const i=Math.ceil(a.measureText(e||" ").width),l=Math.ceil(t*1.6);return{textureWidth:Math.max(Cu,Gr(i+r*2)),textureHeight:Math.max(_u,Gr(l+o*2))}}function Gr(e){let t=1;for(;t<e;)t<<=1;return t}function Su(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=f.Mesh.BILLBOARDMODE_ALL,lowPriority:c=!0}=e;return m.useEffect(()=>{if(!t)return;const p=r!=null?r:"gui-text-no-name",{textureWidth:u,textureHeight:d}=Pu(o,i),x=f.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*(u/d),x.scaling.y=h;const T=nt.AdvancedDynamicTexture.CreateForMesh(x,u,d,!1,!1);T.rootContainer.isPointerBlocker=!1;const P=new nt.TextBlock(`${p}-text`,o);P.color=Su(l),P.fontFamily=Qi,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 y=x.material;return y&&y instanceof f.StandardMaterial&&(y.backFaceCulling=!1,y.disableLighting=!0,y.forceDepthWrite=!1,y.needDepthPrePass=!1,y.transparencyMode=f.Material.MATERIAL_ALPHABLEND,y.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})},Yn=({urlTopLayer:e,urlBottomLayer:t,showLayerLabel:n=!1,labelStyle:a,position:r=f.Vector3.Zero(),visible:o=!0,showBottomLayer:i=!1,actions:l,material:s={type:$e.COLOR_ID,alpha:1}})=>{var N,M;const c=m.useRef(null),p=m.useRef(null),[u,d]=m.useState(""),[x,h]=m.useState(null),T=m.useContext(Le),P=m.useContext(Lt),[y,_]=m.useState(f.Color3.White()),b=je({url:e,cacheType:Me.URL_PREFIX_MATCH}),k=je({url:t,cacheType:Me.URL_PREFIX_MATCH}),L=He({url:s==null?void 0:s.texture,cacheType:Me.URL_PREFIX_MATCH}),I=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,E]=m.useState(),[B,F]=m.useState(f.Vector3.Zero()),[w,D]=m.useState(void 0);return m.useEffect(()=>{if(b){const v=c.current;v&&(f.Tags.EnableFor(v),f.Tags.AddTagsTo(v,"loading"));let A=[],V=[],$=[];const U=Ut.decode(new Uint8Array(b));{const{name:G,points:ae,indices:oe,colorId:j,value:Y,center:ce}=U;A=ae,V=oe,$=Y,h(j),d(G),ce&&F(new f.Vector3(ce.x,ce.y,ce.z))}const ie=new f.VertexData;ie.positions=A,ie.indices=V,ie.colors=$;const ne=[];if(f.VertexData.ComputeNormals(A,V,ne),ie.normals=ne,v){ie.applyToMesh(v);const G=v.getBoundingInfo();E(G.boundingBox.center.add(new f.Vector3(G.boundingBox.extendSize.x,0,0))),i||v.getScene().onAfterRenderObservable.addOnce(()=>{if(!v.isDisposed()){const oe=v.getBoundingInfo();D(oe.boundingBox)}})}return v&&f.Tags.RemoveTagsFrom(v,"loading"),()=>{v&&new f.VertexData().applyToMesh(v)}}},[b,i]),m.useEffect(()=>{if(b&&k){const v=p.current;v&&(f.Tags.EnableFor(v),f.Tags.AddTagsTo(v,"loading"));let A=[],V=[],$=[],U=[],ie=[],ne=[],G=[],ae=[];{const ge=Ut.decode(new Uint8Array(b)),{points:H,indices:Q,border:Ee,value:be}=ge;A=H,V=Q,U=Ee,$=be}{const ge=Ut.decode(new Uint8Array(k)),{points:H,bottomIndices:Q,border:Ee,value:be}=ge;ie=H,ne=Q,G=Ee,ae=be}const oe=new f.VertexData,j=new Float32Array(A.length+ie.length);let Y=V.length+ne.length;Y=Y+((U.length<1?1:U.length)-1)*6;const ce=new Int32Array(Y),le=new Float32Array($.length+ae.length);j.set(A),ce.set(V),le.set($),j.set(ie,A.length),ce.set(ne,V.length),le.set(ae,$.length);const X=[];for(let ge=0;ge<U.length-1;ge++)X.push(U[ge+1]),X.push(U[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(U[ge+1]);ce.set(X,V.length+ne.length),oe.positions=j,oe.indices=ce,oe.colors=le;const Pe=[];return f.VertexData.ComputeNormals(j,ce,Pe),oe.normals=Pe,v&&(oe.applyToMesh(v),i&&v.getScene().onAfterRenderObservable.addOnce(()=>{if(!v.isDisposed()){const H=v.getBoundingInfo();D(H.boundingBox)}})),v&&f.Tags.RemoveTagsFrom(v,"loading"),()=>{v&&new f.VertexData().applyToMesh(v)}}},[k,b,i]),m.useEffect(()=>{var v;_(s.type===$e.ONE_COLOR?(v=s==null?void 0:s.color)!=null?v:f.Color3.Random():x&&P.colorIDs[x]?new f.Color3(P.colorIDs[x].r,P.colorIDs[x].g,P.colorIDs[x].b):f.Color3.Random())},[P.colorIDs,x,s==null?void 0:s.color,s.type]),m.useEffect(()=>{c.current&&(c.current.metadata={pickable:l?{name:u,onLeftClick:l.onLeftClick,onRightClick:l.onRightClick,onMiddleClick:l.onMiddleClick,onHover:l.onHover,extra:l.extra}:null}),p.current&&(p.current.metadata={pickable:l?{name:u,onLeftClick:l.onLeftClick,onRightClick:l.onRightClick,onMiddleClick:l.onMiddleClick,onHover:l.onHover,extra:l.extra}:null})},[l,u]),C.jsx(C.Fragment,{children:C.jsxs("transformNode",{name:`transform-formation-${u}-${e}`,position:B.add(r).multiplyByFloats(T&&T.scalePlane?T.scalePlane:1,T&&T.scaleDepth?T.scaleDepth:1,T&&T.scalePlane?T.scalePlane:1),scaling:new f.Vector3(T?T.scalePlane:1,T?T.scaleDepth:1,T?T.scalePlane:1),setEnabled:o,children:[C.jsx("mesh",{name:`formation-${u}-mesh-${e}`,ref:c,setEnabled:!i,useVertexColors:s.type===$e.COLOR_CODEC,alwaysSelectAsActiveMesh:!0,children:s.type===$e.TEXTURE?L?C.jsx(qt,{name:`formation-${u}-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,transparencyMode:f.Material.MATERIAL_ALPHABLEND,alphaMode:f.Engine.ALPHA_COMBINE,alpha:s.alpha,texture:L,sideTexture:I,tilingFactor:s.tilingFactor,sideTilingFactor:(N=s==null?void 0:s.sideTilingFactor)!=null?N:s==null?void 0:s.tilingFactor,mode:s.textureMode===void 0?Xt.PLANE:s.textureMode,boundingBox:w,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-${u}-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,alpha:s.alpha,transparencyMode:f.Material.MATERIAL_ALPHABLEND,alphaMode:f.Engine.ALPHA_COMBINE,colorCodec:s.colorCodec,boundingBox:w,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(An,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,surfaceCanvasOptions:s.surfaceCanvasOptions,color:y,alphaMode:f.Engine.ALPHA_COMBINE,alpha:s.alpha,boundingBox:w,transparencyMode:f.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(An,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,color:y,surfaceCanvasOptions:s.surfaceCanvasOptions,alphaMode:f.Engine.ALPHA_COMBINE,alpha:s.alpha,boundingBox:w,transparencyMode:f.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-${u}-vol-${e}`,ref:p,setEnabled:i,useVertexColors:s.type===$e.COLOR_CODEC,alwaysSelectAsActiveMesh:!0,children:s.type===$e.TEXTURE?L?C.jsx(qt,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,transparencyMode:f.Material.MATERIAL_ALPHABLEND,alphaMode:f.Engine.ALPHA_COMBINE,alpha:s.alpha,sideTexture:I,texture:L,tilingFactor:s.tilingFactor,sideTilingFactor:(M=s==null?void 0:s.sideTilingFactor)!=null?M:s==null?void 0:s.tilingFactor,mode:s.textureMode===void 0?Xt.PLANE:s.textureMode,boundingBox:w,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-${u}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,alpha:s.alpha,transparencyMode:f.Material.MATERIAL_ALPHABLEND,alphaMode:f.Engine.ALPHA_COMBINE,colorCodec:s.colorCodec,boundingBox:w,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(An,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,surfaceCanvasOptions:s.surfaceCanvasOptions,color:y,alphaMode:f.Engine.ALPHA_COMBINE,alpha:s.alpha,transparencyMode:f.Material.MATERIAL_ALPHABLEND,boundingBox:w,lines:s.lines,text:s.text,scaleDepth:T?T.scaleDepth:1,scalePlane:T?T.scalePlane:1,disableDepthWrite:s.disableDepthWrite,disableNormalShadow:s.disableNormalShadow}):C.jsx(An,{name:`formation-${u}-vol-mat-${e}`,backFaceCulling:s.backFaceCulling===void 0?!0:s.backFaceCulling,needDepthPrePass:s.needDepthPrePass===void 0?!0:s.needDepthPrePass,surfaceCanvasOptions:s.surfaceCanvasOptions,color:y,alphaMode:f.Engine.ALPHA_COMBINE,alpha:s.alpha,transparencyMode:f.Material.MATERIAL_ALPHABLEND,boundingBox:w,lines:s.lines,text:s.text,scaleDepth:T?T.scaleDepth:1,scalePlane:T?T.scalePlane:1,disableDepthWrite:s.disableDepthWrite,disableNormalShadow:s.disableNormalShadow})}),u&&S&&C.jsx("transformNode",{name:`${u}-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):f.Vector3.Zero()),scaling:ct(T).multiply(new f.Vector3(3,3,3)),setEnabled:n,children:C.jsx(Je,{text:u,fontSize:a!=null&&a.fontSize?a.fontSize:40,color:a!=null&&a.color?a.color:"white"})})]})})},Jn=({url:e,showLayerLabel:t=!1,labelStyle:n,position:a=f.Vector3.Zero(),visible:r=!0,showBottomLayer:o=!1,actions:i,material:l={type:$e.COLOR_ID,counterLine:void 0,alpha:1}})=>{var w,D;const s=m.useRef(null),c=m.useRef(null),[p,u]=m.useState(""),[d,x]=m.useState(null),[h,T]=m.useState(f.Color3.White()),P=m.useContext(Le),y=m.useContext(Lt),[_,b]=m.useState(f.Vector3.Zero()),[k,L]=m.useState(),I=je({url:e,cacheType:Me.URL_PREFIX_MATCH}),S=He({url:l==null?void 0:l.texture,cacheType:Me.URL_PREFIX_MATCH}),E=He({url:l==null?void 0:l.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),[B,F]=m.useState(void 0);return m.useEffect(()=>{console.log("[Geo3DViewer] FormationVolume Loading: ",e)},[e]),m.useEffect(()=>{if(I){const N=s.current,M=c.current;f.Tags.EnableFor(N),f.Tags.AddTagsTo(N,"loading"),f.Tags.EnableFor(c),f.Tags.AddTagsTo(c,"loading");let v=[],A=[],V=[],$=[];const U=Ut.decode(new Uint8Array(I)),{name:ie,points:ne,indices:G,colorId:ae,side:oe,sideIndices:j,center:Y,value:ce,sideValue:le}=U;Y&&b(new f.Vector3(Y.x,Y.y,Y.z)),v=ne,A=G,V=oe,$=j,x(ae),u(ie);const X=new f.VertexData,Pe=new f.VertexData,ge=new Float32Array(v.length+V.length),H=new Int32Array(A.length+$.length),Q=new Float32Array(ce.length+le.length);X.positions=v,X.indices=A,X.colors=ce;const Ee=[];f.VertexData.ComputeNormals(ne,G,Ee),X.normals=Ee,ge.set(v),H.set(A),Q.set(ce),ge.set(V,v.length),H.set($,A.length),Q.set(le,ce.length),Pe.positions=ge,Pe.indices=H,Pe.colors=Q;const be=[];if(f.VertexData.ComputeNormals(ge,H,be),Pe.normals=be,N){X.applyToMesh(N);const ee=N.getBoundingInfo();L(ee.boundingBox.center.add(new f.Vector3(ee.boundingBox.extendSize.x,0,0))),o||N.getScene().onAfterRenderObservable.addOnce(()=>{if(!N.isDisposed()){const ue=N.getBoundingInfo();F(ue.boundingBox)}})}return M&&(Pe.applyToMesh(M),o&&M.getScene().onAfterRenderObservable.addOnce(()=>{if(!M.isDisposed()){const he=M.getBoundingInfo();F(he.boundingBox)}})),f.Tags.RemoveTagsFrom(N,"loading"),f.Tags.RemoveTagsFrom(c,"loading"),()=>{N&&new f.VertexData().applyToMesh(N),M&&new f.VertexData().applyToMesh(M)}}},[I,o]),m.useEffect(()=>{var N;T(l.type===$e.ONE_COLOR?(N=l==null?void 0:l.color)!=null?N:f.Color3.Random():d&&y.colorIDs[d]?new f.Color3(y.colorIDs[d].r,y.colorIDs[d].g,y.colorIDs[d].b):f.Color3.Random())},[y.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,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,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 f.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(qt,{name:`formation-${p}-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,transparencyMode:f.Material.MATERIAL_ALPHABLEND,alphaMode:f.Engine.ALPHA_COMBINE,alpha:l.alpha,flatModeRotate:l.flatModeRotate,sideTexture:E,texture:S,tilingFactor:l.tilingFactor,sideTilingFactor:(w=l==null?void 0:l.sideTilingFactor)!=null?w:l==null?void 0:l.tilingFactor,mode:l.textureMode===void 0?Xt.PLANE:l.textureMode,counterLine:l.counterLine,boundingBox:B,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:f.Material.MATERIAL_ALPHABLEND,alphaMode:f.Engine.ALPHA_COMBINE,colorCodec:l.colorCodec,counterLine:l.counterLine,boundingBox:B,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(On,{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:f.Engine.ALPHA_COMBINE,alpha:l.alpha,lightPosition:l.lightPosition,intensity:l.intensity,surfaceCanvasOptions:l.surfaceCanvasOptions,transparencyMode:f.Material.MATERIAL_ALPHABLEND,boundingBox:B,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(On,{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:f.Engine.ALPHA_COMBINE,surfaceCanvasOptions:l.surfaceCanvasOptions,alpha:l.alpha,lightPosition:l.lightPosition,intensity:l.intensity,transparencyMode:f.Material.MATERIAL_ALPHABLEND,boundingBox:B,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(qt,{name:`formation-${p}-vol-mat-${e}`,backFaceCulling:l.backFaceCulling===void 0?!0:l.backFaceCulling,needDepthPrePass:l.needDepthPrePass===void 0?!0:l.needDepthPrePass,transparencyMode:f.Material.MATERIAL_ALPHABLEND,alphaMode:f.Engine.ALPHA_COMBINE,alpha:l.alpha,sideTexture:E,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?Xt.PLANE:l.textureMode,flatModeRotate:l.flatModeRotate,counterLine:l.counterLine,boundingBox:B,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:f.Material.MATERIAL_ALPHABLEND,alphaMode:f.Engine.ALPHA_COMBINE,colorCodec:l.colorCodec,counterLine:l.counterLine,boundingBox:B,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(On,{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:f.Engine.ALPHA_COMBINE,alpha:l.alpha,lightPosition:l.lightPosition,intensity:l.intensity,transparencyMode:f.Material.MATERIAL_ALPHABLEND,boundingBox:B,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(On,{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:f.Engine.ALPHA_COMBINE,alpha:l.alpha,lightPosition:l.lightPosition,intensity:l.intensity,transparencyMode:f.Material.MATERIAL_ALPHABLEND,boundingBox:B,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):f.Vector3.Zero()),scaling:ct(P).multiply(new f.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 Fo=(e=>(e[e.FACE=0]="FACE",e[e.VOLUME=1]="VOLUME",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Fo||{});function Tu(e){switch(e){case 0:case"FACE":return 0;case 1:case"VOLUME":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function bu(e){switch(e){case 0:return"FACE";case 1:return"VOLUME";case-1:default:return"UNRECOGNIZED"}}function Yr(){return{name:"",formations:[],mode:0,effectMeshs:[]}}const bn={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.formations)ln.encode(n,t.uint32(34).fork()).ldelim();e.mode!==0&&t.uint32(40).int32(e.mode);for(const n of e.effectMeshs)Ue.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=Yr();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(ln.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(Ue.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:Bn(e.name)?globalThis.String(e.name):"",formations:globalThis.Array.isArray(e==null?void 0:e.formations)?e.formations.map(t=>ln.fromJSON(t)):[],mode:Bn(e.mode)?Tu(e.mode):0,effectMeshs:globalThis.Array.isArray(e==null?void 0:e.effectMeshs)?e.effectMeshs.map(t=>Ue.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=>ln.toJSON(r))),e.mode!==0&&(t.mode=bu(e.mode)),(a=e.effectMeshs)!=null&&a.length&&(t.effectMeshs=e.effectMeshs.map(r=>Ue.toJSON(r))),t},create(e){return bn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o;const t=Yr();return t.name=(n=e.name)!=null?n:"",t.formations=((a=e.formations)==null?void 0:a.map(i=>ln.fromPartial(i)))||[],t.mode=(r=e.mode)!=null?r:0,t.effectMeshs=((o=e.effectMeshs)==null?void 0:o.map(i=>Ue.fromPartial(i)))||[],t}};function Jr(){return{name:"",url:""}}const ln={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=Jr();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:Bn(e.name)?globalThis.String(e.name):"",url:Bn(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 ln.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=Jr();return t.name=(n=e.name)!=null?n:"",t.url=(a=e.url)!=null?a:"",t}};function Bn(e){return e!=null}const Do=({url:e,alpha:t=1,position:n=f.Vector3.Zero(),visible:a=!0,colorCodec:r,actions:o,counterLine:i=void 0,lines:l,text:s,disableDepthWrite:c})=>{const p=m.useRef(null),[u,d]=m.useState(""),x=m.useContext(Le),h=m.useContext(Lt),[T,P]=m.useState(null),[y,_]=m.useState(f.Color3.White()),b=je({url:e,cacheType:Me.URL_PREFIX_MATCH}),[k,L]=m.useState(f.Vector3.Zero()),[I,S]=m.useState();return m.useEffect(()=>{console.log("[Geo3DViewer] StructureLayer Loading: ",e)},[e]),m.useEffect(()=>{if(b){const E=p.current;f.Tags.EnableFor(E),f.Tags.AddTagsTo(E,"loading");const B=Ut.decode(new Uint8Array(b)),{name:F,points:w,indices:D,value:N,colorId:M,center:v}=B;v&&L(new f.Vector3(v.x,v.y,v.z));const A=new f.VertexData;A.positions=w,A.indices=D,A.colors=N;const V=[];return f.VertexData.ComputeNormals(w,D,V),A.normals=V,P(M),d(F),E&&(A.applyToMesh(E),E.getScene().onAfterRenderObservable.addOnce(()=>{if(!E.isDisposed()){const U=E.getBoundingInfo();S(U.boundingBox)}})),f.Tags.RemoveTagsFrom(E,"loading"),()=>{P(null),d(""),E&&new f.VertexData().applyToMesh(E)}}},[b]),m.useEffect(()=>{const E=T&&h.colorIDs[T]?h.colorIDs[T]:f.Color3.White();_(f.Color3.FromArray([E.r,E.g,E.b]))},[T,h.colorIDs]),m.useEffect(()=>{p.current&&(p.current.metadata={pickable:o?{name:u,onLeftClick:o.onLeftClick,onRightClick:o.onRightClick,onMiddleClick:o.onMiddleClick,onHover:o.onHover,extra:o.extra}:null})},[o,u]),C.jsx(C.Fragment,{children:C.jsxs("transformNode",{name:`transform-structurelayer-${u}`,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 f.Vector3(x?x.scalePlane:1,x?x.scaleDepth:1,x?x.scalePlane:1),setEnabled:a,children:[C.jsx("transformNode",{name:`structurelayer-${u}-load`}),C.jsx("mesh",{name:`structurelayer-${u}-mesh`,ref:p,useVertexColors:r!=null,children:r?C.jsx(Mt,{name:`structurelayer-${u}-mat`,backFaceCulling:!1,alpha:t,transparencyMode:f.Material.MATERIAL_ALPHABLEND,alphaMode:f.Engine.ALPHA_COMBINE,colorCodec:r,needDepthPrePass:!0,counterLine:i,boundingBox:I,lines:l,scaleDepth:x?x.scaleDepth:1,scalePlane:x?x.scalePlane:1,text:s,disableDepthWrite:c}):C.jsx("standardMaterial",{name:`structurelayer-${u}-mat`,backFaceCulling:!1,specularColor:new f.Color3(0,0,0),ambientColor:new f.Color3(1,1,1),diffuseColor:y,needDepthPrePass:!0,transparencyMode:f.Material.MATERIAL_ALPHABLEND,alphaMode:f.Engine.ALPHA_COMBINE,alpha:t,disableDepthWrite:c})})]})})},ku=e=>{const{id:t,visible:n=!0,position:a=f.Vector3.Zero(),diffuseTextureUrl:r,diffuseTextureSufaceUrl:o,bumpTextureUrl:i,mesh:l}=e,s=m.useRef(null),c=m.useContext(Le),[p,u]=m.useState(),[d,x]=m.useState(),[h,T]=m.useState();return m.useEffect(()=>{const P=s.current;if(P&&l){const y=new f.VertexData;y.positions=l.vertices,y.indices=l.indices,y.uvs=l.uv;const _=[];f.VertexData.ComputeNormals(l.vertices,l.indices,_),y.normals=_,y.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 f.Texture(r);if(P.uScale=500,P.vScale=.5,u(P),o){const _=new f.Texture(o);_.uScale=500,_.vScale=.5,x(_)}const y=new f.Texture(i);y.uScale=500,y.vScale=.5,T(y)},[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 f.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})})})})},ji=({url:e,visible:t=!0,filter:n,explodedView:a=0,showLayerLabel:r,labelStyle:o,offset:i=new f.Vector3(0,0,0),showTopLayerAsStructureLayer:l=!1,useColorCodecOnTopLayer:s=!1,colorCodec:c,actions:p,materials:u,topLayerCounterLine:d=void 0,topLayerHeightOffset:x=1,diffuseTextureUrl:h,diffuseTextureSufaceUrl:T,bumpTextureUrl:P,visibleEdgeEffect:y=!1})=>{var D,N;const[_,b]=m.useState(),k=m.useContext(Le),[L,I]=m.useState(!0),[S,E]=m.useState(""),B=je({url:e,cacheType:Me.URL_PREFIX_MATCH}),[F,w]=m.useState([]);return m.useEffect(()=>{console.log("[Geo3DViewer] ComplexFormationManager Loading: ",e)},[e]),m.useEffect(()=>{if(B){const M=bn.decode(new Uint8Array(B)),v=M.formations;if(M.mode==Fo.FACE){I(!0),E(M.name);const A=[];v.forEach((V,$)=>{const U={name:V.name,topUrl:V.url,bottomUrl:v[$+1]?v[$+1].url:void 0};A.push(U)}),b(A)}else{I(!1),E(M.name);const A=[];v.forEach(V=>{const $={name:V.name,topUrl:V.url};A.push($)}),b(A)}return console.log(M),w(M.effectMeshs),()=>{b([])}}},[B]),C.jsxs("abstractMesh",{name:`complexformationmanager-${S}`,children:[l&&_&&_.length>1?C.jsx(Do,{url:_[0].topUrl,alpha:(D=u==null?void 0:u[_[0].name])==null?void 0:D.alpha,position:new f.Vector3(0,x>=0?x*(k&&(N=k.scaleDepth)!=null?N:1):0,0).add(i),visible:t&&(n?n.includes(_[0].name):!0),colorCodec:c,counterLine:d},`${S}-${_[0].name}-SL`):null,_?_.map((M,v)=>L?l&&v===0?C.jsx(C.Fragment,{}):C.jsx("transformNode",{name:`${S}-${M.name}-EV`,position:i.add(new f.Vector3(0,v*(-1*a*(k&&k.scaleDepth?k.scaleDepth:0)),0)),children:C.jsx(Yn,{showLayerLabel:r,labelStyle:o,urlTopLayer:M.topUrl,urlBottomLayer:M.bottomUrl,visible:t&&(n?n.includes(M.name):!0),showBottomLayer:_[v+1]?n?n.includes(_[v+1].name):!0:!1,actions:p,material:v===0&&s?{...u==null?void 0:u[M.name],colorCodec:c,type:$e.COLOR_CODEC}:u==null?void 0:u[M.name]},`${S}-${M.name}`)},`${S}-${M.name}`):l&&v===0?C.jsx(C.Fragment,{}):C.jsx("transformNode",{name:`${S}-${M.name}-EV`,position:i.add(new f.Vector3(0,v*(-1*a*(k&&k.scaleDepth?k.scaleDepth:0)),0)),children:C.jsx(Jn,{url:M.topUrl,showLayerLabel:r,labelStyle:o,visible:t&&(n?n.includes(M.name):!0),showBottomLayer:_[v+1]?n?n.includes(_[v+1].name):!0:!1,actions:p,material:u==null?void 0:u[M.name]},`${S}-${M.name}`)},`${S}-${M.name}`)):null,F&&h&&P&&a===0&&F.map((M,v)=>C.jsx(ku,{visible:y,id:v,diffuseTextureUrl:h,diffuseTextureSufaceUrl:v===0?T:void 0,bumpTextureUrl:P,mesh:M},v))]})},ea=({visible:e=!0,color:t=f.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(),u=m.useRef(null),d=m.useContext(Le),[x,h]=m.useState([]),[T,P]=m.useState([]),[y,_]=m.useState([]),[b,k]=m.useState(0),L=m.useCallback(I=>{if(p&&I){const S=new Qa.GridMaterial("axis-material",p);S.majorUnitFrequency=o.length>0?o[0]:50,S.minorUnitVisibility=0,S.gridRatio=2,S.sideOrientation=f.Material.ClockWiseSideOrientation,S.backFaceCulling=!0,S.mainColor=t,S.lineColor=t,S.opacity=.98,I.material=S}},[t,o,p]);return m.useEffect(()=>()=>{var I;(I=u.current)==null||I.dispose()},[]),m.useEffect(()=>{const I=()=>{const S=(p==null?void 0:p.activeCamera).radius;for(let E=0;E<r.length;E++)if(S<=r[E]){k(E);break}};return p&&p.activeCamera&&(p==null||p.activeCamera.onViewMatrixChangedObservable.add(I)),()=>{p&&p.activeCamera&&(p==null||p.activeCamera.onViewMatrixChangedObservable.removeCallback(I))}},[r,i,o,p,e]),m.useEffect(()=>{if(d&&d.min&&d.max&&c){const I=d.origin||f.Vector3.Zero(),S=[],E=[],B=[],F=[...o];F.length===0&&F.push(a);for(let w=0;w<F.length;w++){let D=F[w]/1;D<1&&(D=200);const N=[];for(let A=0;A<=d.max.x-d.min.x;A+=D)N.push({text:`${A+d.min.x+I.x}`,position:new f.Vector3(A,0,0)}),N.push({text:`${A+d.min.x+I.x}`,position:new f.Vector3(A,d.max.y-d.min.y,d.max.z-d.min.z)}),N.push({text:`${A+d.min.x+I.x}`,position:new f.Vector3(A,d.max.y-d.min.y,0)}),N.push({text:`${A+d.min.x+I.x}`,position:new f.Vector3(A,0,d.max.z-d.min.z)});S.push(N);const M=[];for(let A=0;A<=d.max.y-d.min.y;A+=D)M.push({text:`${A+d.min.y+I.y}`,position:new f.Vector3(0,A,0)}),M.push({text:`${A+d.min.y+I.y}`,position:new f.Vector3(d.max.x-d.min.x,A,d.max.z-d.min.z)}),M.push({text:`${A+d.min.y+I.y}`,position:new f.Vector3(d.max.x-d.min.x,A,0)}),M.push({text:`${A+d.min.y+I.y}`,position:new f.Vector3(0,A,d.max.z-d.min.z)});E.push(M);const v=[];for(let A=0;A<=d.max.z-d.min.z;A+=D)v.push({text:`${A+d.min.z+I.z}`,position:new f.Vector3(0,0,A)}),v.push({text:`${A+d.min.z+I.z}`,position:new f.Vector3(d.max.x-d.min.x,d.max.y-d.min.y,A)}),v.push({text:`${A+d.min.z+I.z}`,position:new f.Vector3(0,d.max.y-d.min.y,A)}),v.push({text:`${A+d.min.z+I.z}`,position:new f.Vector3(d.max.x-d.min.x,0,A)});B.push(v)}h(S),P(E),_(B)}},[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?f.Vector3.Center(d.min,d.max):f.Vector3.Zero()).multiply(Oe(d)),scaling:new f.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:L,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 f.Vector3(-(d.max.x-d.min.x)/2,-(d.max.y-d.min.y)/2,-(d.max.z-d.min.z)/2):f.Vector3.Zero(),children:[x.map((I,S)=>I.map((E,B)=>{var w;const F=E;return C.jsx("transformNode",{name:`axis-x-${S}-${B}`,position:F==null?void 0:F.position,setEnabled:S===b,scaling:new f.Vector3(1/Oe(d).x,1/Oe(d).y,1/Oe(d).z),children:C.jsx(Je,{text:`${F?F.text:""}`,fontSize:(w=i[S])!=null?w:n,color:t.toHexString()})},`axis-x-${S}-${B}`)})),T.map((I,S)=>I.map((E,B)=>{var w;const F=E;return C.jsx("transformNode",{name:`axis-x-${S}-${B}`,position:F==null?void 0:F.position,setEnabled:S===b,scaling:new f.Vector3(1/Oe(d).x,1/Oe(d).y,1/Oe(d).z),children:C.jsx(Je,{text:`${F?F.text:""}`,fontSize:(w=i[S])!=null?w:n,color:t.toHexString()})},`axis-x-${S}-${B}`)})),y.map((I,S)=>I.map((E,B)=>{var w;const F=E;return C.jsx("transformNode",{name:`axis-x-${S}-${B}`,position:F==null?void 0:F.position,setEnabled:S===b,scaling:new f.Vector3(1/Oe(d).x,1/Oe(d).y,1/Oe(d).z),children:C.jsx(Je,{text:`${F?F.text:""}`,fontSize:(w=i[S])!=null?w:n,color:t.toHexString()})},`axis-x-${S}-${B}`)}))]})]},`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 Eu(e){switch(e){case 0:case"NORMAL":return 0;case 1:case"CICLE":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function Nu(e){switch(e){case 0:return"NORMAL";case 1:return"CICLE";case-1:default:return"UNRECOGNIZED"}}function Xr(){return{name:"",lines:[]}}const ta={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.lines)un.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=Xr();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(un.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:Po(e.name)?globalThis.String(e.name):"",lines:globalThis.Array.isArray(e==null?void 0:e.lines)?e.lines.map(t=>un.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=>un.toJSON(a))),t},create(e){return ta.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=Xr();return t.name=(n=e.name)!=null?n:"",t.lines=((a=e.lines)==null?void 0:a.map(r=>un.fromPartial(r)))||[],t}};function qr(){return{positions:[]}}const cn={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=qr();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 cn.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=qr();return t.positions=((n=e.positions)==null?void 0:n.map(a=>rt.fromPartial(a)))||[],t}};function Kr(){return{segments:[],type:0,position:void 0}}const un={encode(e,t=se.Writer.create()){for(const n of e.segments)cn.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=Kr();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.segments.push(cn.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=>cn.fromJSON(t)):[],type:Po(e.type)?Eu(e.type):0,position:Po(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=>cn.toJSON(a))),e.type!==0&&(t.type=Nu(e.type)),e.position!==void 0&&(t.position=rt.toJSON(e.position)),t},create(e){return un.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=Kr();return t.segments=((n=e.segments)==null?void 0:n.map(r=>cn.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 Po(e){return e!=null}const zo=({points:e=[],showPoint:t=!0,color:n=f.Color3.White(),pointSize:a=2,alwaysOnTop:r=!1,offset:o=f.Vector3.Zero(),alpha:i,lineWidth:l})=>{const s=_e.useScene(),c=m.useRef(null),p=m.useContext(Le);return m.useEffect(()=>{if(s){const u=[],d=Oe(p);if(e.forEach(x=>{u.push(x.add(o).multiply(d))}),l){const x={path:u,radius:l,updatable:!0};if(c.current)x.instance=c.current,f.MeshBuilder.CreateTube("line",x);else{c.current=f.MeshBuilder.CreateTube("line",x,s);const h=new f.StandardMaterial("line-mat");return h.diffuseColor=n,h.specularColor=f.Color3.Black(),h.emissiveColor=n,i!==void 0&&(h.alpha=i,h.transparencyMode=2),h.depthFunction=r?f.Constants.ALWAYS:0,c.current.material=h,()=>{c.current&&(s.removeMesh(c.current),c.current=null)}}}else{const x={points:u,updateable:!0};if(c.current)x.instance=c.current,f.MeshBuilder.CreateLines("line",x);else{c.current=f.MeshBuilder.CreateLines("line",x,s);const h=new f.StandardMaterial("line-mat");return h.diffuseColor=n,h.specularColor=f.Color3.Black(),h.emissiveColor=n,i!==void 0&&(h.alpha=i,h.transparencyMode=2),h.depthFunction=r?f.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((u,d)=>C.jsx("sphere",{diameter:a,name:`lines-point-${d}`,position:u.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:f.Color3.White(),depthFunction:r?f.Constants.ALWAYS:void 0})},`lines-point-${u.x}-${u.y}-${u.z}`))}):C.jsx(C.Fragment,{})})},Iu=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],u=f.Vector3.Normalize(a.subtract(n)),d=new f.Vector3(1,0,0),x=Math.acos(f.Vector3.Dot(u,d)),h=f.Vector3.Cross(u,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:f.Vector3.Lerp(n,a,.5),ref:l,children:C.jsx(Je,{text:t,fontSize:o,color:r,billboardMode:f.Mesh.BILLBOARDMODE_NONE})})},wu=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([]),[u,d]=m.useState([]),x=m.useContext(Le);return m.useEffect(()=>{Wt.get(t,{responseType:"arraybuffer"}).then(h=>{const T=ta.decode(new Uint8Array(h.data));console.log(T);const P=[],y=[];for(let _=0;_<T.lines.length;_++){const b=T.lines[_];if(b.segments.length<2)continue;const k=[];for(let L=0;L<b.segments.length;L++){const I=[...ms(b.segments[L].positions)];P.push([...I]),k.push(I[0]),k.push(I[I.length-1])}b.type===1&&k.push(Ei(b.segments[0].positions[0])),y.push(k)}p(P),d(y),console.log(y),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)),u.map(h=>h.map((T,P)=>P%2===0||P===h.length-1?null:C.jsx(Iu,{name:T.y.toFixed(0),prev:Oe(x).multiply(T),next:Oe(x).multiply(h[P+1]),fontSize:o,textColor:i},P)))]})};function Ou(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 Au(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 Qr(){return{layer:0,direction:0,colorId:0,points:[],indices:[],value:[],vMin:0,vMax:0,center:void 0}}const Vo={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=Qr();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:en(e.layer)?globalThis.Number(e.layer):0,direction:en(e.direction)?Ou(e.direction):0,colorId:en(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:en(e.vMin)?globalThis.Number(e.vMin):0,vMax:en(e.vMax)?globalThis.Number(e.vMax):0,center:en(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=Au(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 Vo.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,l,s,c;const t=Qr();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 en(e){return e!=null}const $o=({name:e,url:t,visible:n=!0,colorCodec:a,alpha:r=1,position:o=f.Vector3.Zero(),actions:i})=>{const l=m.useRef(null),[s,c]=m.useState(""),[p,u]=m.useState(""),d=m.useContext(Le),x=je({url:t,cacheType:Me.URL_PREFIX_MATCH}),[h,T]=m.useState(f.Vector3.Zero());return m.useEffect(()=>{if(x){f.Tags.EnableFor(l.current),f.Tags.AddTagsTo(l.current,"loading");const P=Vo.decode(new Uint8Array(x)),{layer:y,direction:_,points:b,indices:k,value:L,center:I}=P,S=new f.VertexData;S.positions=b,S.indices=k,S.colors=L;const E=[];f.VertexData.ComputeNormals(b,k,E),S.normals=E,I&&T(new f.Vector3(I.x,I.y,I.z));const B=l.current;return B&&(S.applyToMesh(B),c(y.toString()),u(_.toString())),f.Tags.RemoveTagsFrom(B,"loading"),()=>{c(""),u(""),B&&new f.VertexData().applyToMesh(B)}}},[x]),m.useEffect(()=>{l.current&&(l.current.metadata={pickable:i?{name:e,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null})},[i,e]),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 f.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,children:C.jsx(Mt,{name:`densityslice-${e}-${p}-${s}-mat`,backFaceCulling:!1,needDepthPrePass:!0,alpha:r,transparencyMode:f.Material.MATERIAL_ALPHABLEND,alphaMode:f.Engine.ALPHA_COMBINE,colorCodec:a})})})})},na=()=>{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},oa=({url:e,visible:t=!0,filter:n,explodedView:a=0,offset:r=new f.Vector3(0,0,0),showLayerLabel:o,labelStyle:i,actions:l,materials:s})=>{const[c,p]=m.useState(),u=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 y=bn.decode(new Uint8Array(P)),_=y.formations;if(y.mode==Fo.FACE){x(!0),T(y.name);const b=[];_.forEach((k,L)=>{const I={name:k.name,topUrl:k.url,bottomUrl:_[L+1]?_[L+1].url:void 0};b.push(I)}),p(b)}else{x(!1),T(y.name);const b=[];_.forEach(k=>{const L={name:k.name,topUrl:k.url};b.push(L)}),p(b)}return console.log(_),()=>{T(""),p([])}}},[P]),C.jsx("abstractMesh",{name:`formationmanager-${h}`,children:c?c.map((y,_)=>d?C.jsx("transformNode",{name:`${h}-${y.name}-EV`,position:r.add(new f.Vector3(0,_*(-1*a*(u&&u.scaleDepth?u.scaleDepth:0)),0)),children:C.jsx(Yn,{showLayerLabel:o,labelStyle:i,urlTopLayer:y.topUrl,urlBottomLayer:y.bottomUrl,visible:t&&(n?n.includes(y.name):!0),showBottomLayer:c[_+1]?n?n.includes(c[_+1].name):!0:!1,actions:l,material:s==null?void 0:s[y.name]},`${h}-${y.name}`)},`${h}-${y.name}`):C.jsx("transformNode",{name:`${h}-${y.name}-EV`,position:r.add(new f.Vector3(0,_*(-1*a*(u&&u.scaleDepth?u.scaleDepth:0)),0)),children:C.jsx(Jn,{url:y.topUrl,showLayerLabel:o,labelStyle:i,visible:t&&(n?n.includes(y.name):!0),showBottomLayer:c[_+1]?n?n.includes(c[_+1].name):!0:!1,actions:l,material:s==null?void 0:s[y.name]},`${h}-${y.name}`)},`${h}-${y.name}`)):null})};function jr(){return{name:"",slices:[],center:void 0}}const Uo={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.slices)fn.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=jr();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(fn.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:Fn(e.name)?globalThis.String(e.name):"",slices:globalThis.Array.isArray(e==null?void 0:e.slices)?e.slices.map(t=>fn.fromJSON(t)):[],center:Fn(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=>fn.toJSON(a))),e.center!==void 0&&(t.center=K.toJSON(e.center)),t},create(e){return Uo.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=jr();return t.name=(n=e.name)!=null?n:"",t.slices=((a=e.slices)==null?void 0:a.map(r=>fn.fromPartial(r)))||[],t.center=e.center!==void 0&&e.center!==null?K.fromPartial(e.center):void 0,t}};function ei(){return{name:"",colorId:0,vertices:[],indices:[],edges:[]}}const fn={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=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!==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:Fn(e.name)?globalThis.String(e.name):"",colorId:Fn(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 fn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=ei();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 Fn(e){return e!=null}const Mu=(e,t)=>{var N,M,v,A;const n=_e.useScene(),a=m.useRef(null),r=m.useRef(null),o=m.useContext(Le),i=m.useContext(Lt),[l,s]=m.useState(f.Color3.White()),{id:c,visible:p=!0,vertices:u,indices:d,colorId:x,position:h,normals:T,material:P={type:$e.COLOR_ID},children:y,alpha:_=1,style:b,name:k="formation",highStyle:L,lowStyle:I,edges:S=[]}=e,E=He({url:P==null?void 0:P.texture,cacheType:Me.URL_PREFIX_MATCH}),B=He({url:P==null?void 0:P.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),[F,w]=m.useState();m.useImperativeHandle(t,()=>r.current,[]),m.useEffect(()=>{if(a&&a.current&&n){const V=new f.VertexData;V.positions=u,V.indices=d,V.normals=T;const $=a.current;V.applyToMesh($),$.getScene().onAfterRenderObservable.addOnce(()=>{if(!$.isDisposed()){const ie=$.getBoundingInfo();w(ie.boundingBox)}})}},[d,u,n,c,T]),m.useEffect(()=>{var V;s(P.type===$e.ONE_COLOR?(V=P==null?void 0:P.color)!=null?V:f.Color3.Random():x&&i.colorIDs[x]?new f.Color3(i.colorIDs[x].r,i.colorIDs[x].g,i.colorIDs[x].b):f.Color3.Random())},[i.colorIDs,x,P==null?void 0:P.color,P.type]);const D=(V,$,U)=>{const ie=$.subtract(V),ne=1+1e3/f.Vector3.Distance(V,$)*(U-1),G=ie.scale(ne);return V.add(G)};return C.jsxs("transformNode",{name:`node-${k}-${c}`,setEnabled:p,children:[C.jsxs("transformNode",{name:`${k}`,position:h?h.multiply(Oe(o)):new f.Vector3(0,0,0),scaling:Oe(o),ref:r,children:[C.jsx("mesh",{name:`${k}-mesh`,ref:a,children:P.type===$e.TEXTURE?E?C.jsx(qt,{name:`formationslice-${k}-mat`,backFaceCulling:!1,needDepthPrePass:P.needDepthPrePass===void 0?!1:P.needDepthPrePass,transparencyMode:f.Material.MATERIAL_ALPHABLEND,alphaMode:f.Engine.ALPHA_COMBINE,alpha:_,sideTexture:B,texture:E,tilingFactor:P.tilingFactor,sideTilingFactor:(N=P==null?void 0:P.sideTilingFactor)!=null?N:P==null?void 0:P.tilingFactor,mode:P.textureMode===void 0?Xt.PLANE:P.textureMode,boundingBox:F,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:f.Material.MATERIAL_ALPHABLEND,alphaMode:f.Engine.ALPHA_COMBINE,colorCodec:P.colorCodec,boundingBox:F,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 f.Color3(0,0,0),ambientColor:new f.Color3(1,1,1),diffuseColor:l,alphaMode:f.Engine.ALPHA_COMBINE,alpha:_,transparencyMode:f.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 f.Color3(0,0,0),ambientColor:new f.Color3(1,1,1),diffuseColor:l,alphaMode:f.Engine.ALPHA_COMBINE,alpha:_,transparencyMode:f.Material.MATERIAL_ALPHABLEND,disableDepthWrite:P.disableDepthWrite})}),b.position&&C.jsx("transformNode",{name:`${k}-title`,position:D(At(b.basePosition==="left"?S[4]:S[5]),b.position,(M=b.offset)!=null?M: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"})}),I&&I.position&&C.jsx("transformNode",{name:`${k}-up-title`,position:D(At(I.basePosition==="left"?S[4]:S[5]),I.position,(v=I.offset)!=null?v:1),scaling:ct(o),children:I.title&&C.jsx(Je,{text:I.title,fontSize:I.fontSize?I.fontSize:40,color:I.color?I.color:"black"})}),L&&L.position&&C.jsx("transformNode",{name:`${k}-down-title`,position:D(At(L.basePosition==="left"?S[4]:S[5]),L.position,(A=L.offset)!=null?A:1),scaling:ct(o),children:L.title&&C.jsx(Je,{text:L.title,fontSize:L.fontSize?L.fontSize:40,color:L.color?L.color:"black"})})]}),y]})},Lu=m.forwardRef(Mu),Wo=e=>{const[t,n]=m.useState([]),[a,r]=m.useState(""),{url:o,visible:i=!0,materials:l,actions:s,style:c,highStyle:p,lowStyle:u,basePosition:d="left"}=e,x=m.useRef(null),h=m.useContext(Le),T=je({url:o,cacheType:Me.URL_PREFIX_MATCH}),[P,y]=m.useState(f.Vector3.Zero());return m.useEffect(()=>{console.log("[Geo3DViewer] FormationSlice Loading: ",o)},[o]),m.useEffect(()=>{if(T){const _=Uo.decode(new Uint8Array(T));_.center&&y(new f.Vector3(_.center.x,_.center.y,_.center.z));const b=_.slices.map(k=>{const L=[];return f.VertexData.ComputeNormals(k.vertices,k.indices,L),{name:k.name,colorId:k.colorId,vertices:k.vertices,indices:k.indices,edges:k.edges,normals:L}});return r(_.name),n(b),()=>{r(""),n([])}}},[T]),m.useEffect(()=>{var b;const _=(b=x.current)==null?void 0:b.getChildMeshes()[0];_&&(_.metadata={pickable:s?{name:a,onLeftClick:s.onLeftClick,onRightClick:s.onRightClick,onMiddleClick:s.onMiddleClick,onHover:s.onHover,extra:s.extra}:null})},[s,a]),C.jsx(C.Fragment,{children:C.jsx("transformNode",{name:`foramtionslice-${a}-holder`,setEnabled:i,position:P.multiply(Oe(h)),children:t.map((_,b)=>{const k=_.edges.length>0?At(d==="left"?_.edges[0]:_.edges[2]):new f.Vector3(0,0,0),L=_.edges.length>0?At(d==="left"?_.edges[1]:_.edges[3]):new f.Vector3(0,0,0),I=f.Vector3.Lerp(k,L,.5);return C.jsx(Lu,{id:b,vertices:_.vertices,indices:_.indices,colorId:_.colorId,normals:_.normals,name:_.name,edges:_.edges,style:c?{position:I,title:_.name,basePosition:d,...c}:{},lowStyle:u?{position:L,title:(P.y+L.y).toFixed(0).toString(),basePosition:d,...u}:{},highStyle:p&&b===t.length-1?{position:k,title:(P.y+k.y).toFixed(0).toString(),basePosition:d,...p}:{},material:l?{...l[_.name],backFaceCulling:!1}:void 0,ref:x},b)})})})},Ru=e=>{const{name:t="node",text:n,fontSize:a,color:r,position:o=f.Vector3.Zero(),scale:i=f.Vector3.One(),blink:l=!1}=e,[s,c]=m.useState(!0);return m.useEffect(()=>{const p=setInterval(()=>{l&&c(u=>!u)},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 ra=({target:e,radius:t,alpha:n,beta:a,axesViewerOffset:r=f.Vector3.Zero(),panningSensibility:o=2,wheelDeltaPercentage:i=0,axesViewer:l=0,farPlane:s=1e4,skipPickingWhenCameraMoves:c=!1})=>{const p=_e.useScene(),u=m.useContext(Le),[d,x]=m.useState(null),[h,T]=m.useState(null),[P,y]=m.useState(n),[_,b]=m.useState(a),[,k]=m.useState(null),L=m.useCallback(F=>{T(F)},[]),{setViewCamera:I}=m.useContext(Eo),S=m.useCallback(()=>{if(h&&d){const F=new f.Vector3;F.addInPlace(h.position),F.addInPlace(h.getDirection(new f.Vector3(0,0,25))),l==4?(F.addInPlace(h.getDirection(new f.Vector3(0,7+r.y,0))),F.addInPlace(h.getDirection(new f.Vector3(15+r.x,0,0)))):l==3?(F.addInPlace(h.getDirection(new f.Vector3(0,7+r.y,0))),F.addInPlace(h.getDirection(new f.Vector3(-15+r.x,0,0)))):l==2?(F.addInPlace(h.getDirection(new f.Vector3(0,-7+r.y,0))),F.addInPlace(h.getDirection(new f.Vector3(15+r.x,0,0)))):l==1&&(F.addInPlace(h.getDirection(new f.Vector3(0,-7+r.y,0))),F.addInPlace(h.getDirection(new f.Vector3(-15+r.x,0,0)))),d.xAxis.position=F.clone(),d.yAxis.position=F.clone(),d.zAxis.position=F.clone()}},[h,d,l,r.y,r.x]);m.useEffect(()=>{if(p&&l!=0){const F=new f.AxesViewer(p,2,null);return x(F),()=>{F==null||F.dispose(),x(null)}}},[p,l]),m.useEffect(()=>{S()},[S]);const E=m.useCallback(F=>{if(u&&u.min&&u.max)return f.Vector3.Clamp(F,u==null?void 0:u.min,u==null?void 0:u.max)},[u]),B=m.useCallback(F=>{p&&(p.skipPointerMovePicking=F)},[p]);return m.useEffect(()=>{if(!p||!h)return;const F=h.onViewMatrixChangedObservable.add(()=>{c&&(B(!0),k(w=>(w&&clearTimeout(w),setTimeout(()=>{B(!1),k(null)},250)))),y(h.alpha),b(h.beta),S()});return()=>{h.onViewMatrixChangedObservable.remove(F),k(w=>(w&&clearTimeout(w),null)),B(!1)}},[p,l,h,u,d,S,E,B,c]),m.useEffect(()=>{I(p&&h?h:void 0)},[p,h,I]),m.useEffect(()=>{},[E,u,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:L,setActiveOnSceneIfNoneActive:!0})})},Bu=(e,t)=>{const{position:n=f.Vector3.Zero(),axesViewer:a=Bt.NONE,axesViewerOffset:r=f.Vector3.Zero(),skipPickingWhenCameraMoves:o=!1,wheelDeltaPercentage:i=3,rotationSensibility:l=1,panningSensibility:s=10}=e,c=_e.useScene(),p=m.useContext(Le),[u,d]=m.useState(null),[x,h]=m.useState(null),{setViewCamera:T,cameraRefObject:P}=m.useContext(Eo),[,y]=m.useState(null),_=m.useRef(null),[b,k]=m.useState(null),L=m.useRef(null),I=m.useCallback(w=>{c&&(c.skipPointerMovePicking=w)},[c]);m.useEffect(()=>(L.current=new f.ArcRotateCamera("dummy-camera",0,0,.1,f.Vector3.Zero(),c||void 0,!1),()=>{var w;(w=L.current)==null||w.dispose()}),[c]),m.useEffect(()=>{if(c){const w=x,D=c.onPointerObservable.add(N=>{if(N.type===f.PointerEventTypes.POINTERDOWN&&(_.current=new f.Vector2(N.event.clientX,N.event.clientY)),N.type===f.PointerEventTypes.POINTERUP&&(_.current=null),N.type===f.PointerEventTypes.POINTERMOVE&&_.current){const M=N.event.clientX-_.current.x,v=N.event.clientY-_.current.y;if(N.event.buttons===1){let A=null;(w.lockedTarget||b)&&(w.lockedTarget&&(A=w.lockedTarget.position),b&&(A=b)),A&&L.current?(L.current.target=A,L.current.position=w.position.clone(),L.current.wheelDeltaPercentage=i,L.current.panningSensibility=s,L.current.alpha+=M/100*l,L.current.beta+=v/100*l,L.current.update(),w.position=L.current.position.clone(),w.rotation=L.current.rotation.clone()):(w.rotation.y-=M/100*l,w.rotation.x-=v/100*l)}N.event.buttons===2&&(w.position.x-=M/100*s,w.position.y+=v/100*s),_.current=new f.Vector2(N.event.clientX,N.event.clientY)}});return()=>{c.onPointerObservable.remove(D)}}},[b,s,x,l,c,i]);const S=m.useCallback(w=>{w&&(w.inputs.addMouseWheel(),w.inputs.removeMouse(),T(w),h(w))},[T]);m.useEffect(()=>{if(x){const w=x.inputs.attached.mousewheel;w.wheelPrecisionX=i,w.wheelPrecisionY=i,w.wheelPrecisionZ=i}},[x,i]);const E=m.useCallback(()=>{if(x&&u){const w=new f.Vector3;w.addInPlace(x.position),w.addInPlace(x.getDirection(new f.Vector3(0,0,25))),a==Bt.TOP_RIGHT?(w.addInPlace(x.getDirection(new f.Vector3(0,7+r.y,0))),w.addInPlace(x.getDirection(new f.Vector3(15+r.x,0,0)))):a==Bt.TOP_LEFT?(w.addInPlace(x.getDirection(new f.Vector3(0,7+r.y,0))),w.addInPlace(x.getDirection(new f.Vector3(-15+r.x,0,0)))):a==Bt.BOTTOM_RIGHT?(w.addInPlace(x.getDirection(new f.Vector3(0,-7+r.y,0))),w.addInPlace(x.getDirection(new f.Vector3(15+r.x,0,0)))):a==Bt.BOTTOM_LEFT&&(w.addInPlace(x.getDirection(new f.Vector3(0,-7+r.y,0))),w.addInPlace(x.getDirection(new f.Vector3(-15+r.x,0,0)))),u.xAxis.position=w.clone(),u.yAxis.position=w.clone(),u.zAxis.position=w.clone()}},[x,u,a,r.y,r.x]);m.useEffect(()=>{if(c&&a!=Bt.NONE){const w=new f.AxesViewer(c,2,null);return d(w),()=>{w==null||w.dispose(),d(null)}}},[c,a]),m.useEffect(()=>{E()},[E]),m.useEffect(()=>{T(c&&x?x:void 0)},[c,x,T]),m.useEffect(()=>{if(!c||!x)return;const w=x.onViewMatrixChangedObservable.add(()=>{o&&(I(!0),y(D=>(D&&clearTimeout(D),setTimeout(()=>{I(!1),y(null)},250)))),E()});return()=>{x.onViewMatrixChangedObservable.remove(w),y(D=>(D&&clearTimeout(D),null)),I(!1)}},[c,a,x,p,u,E,o,I]);const[B,F]=m.useState();return m.useEffect(()=>{if(x){const w={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))}};F(w),P&&P.current&&(P.current.rawCamera=x,P.current.cameraTools=w)}},[P,x]),m.useImperativeHandle(t,()=>({rawCamera:x,cameraTools:B}),[B,x]),C.jsx("universalCamera",{name:"universal-main-camera",position:n,ref:S,maxZ:0})},Fu=m.forwardRef(Bu);class Du extends f.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),f.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=f.Quaternion.FromEulerAngles(this.camera.rotation.x,this.camera.rotation.y,this.camera.rotation.z),i=f.Quaternion.RotationAxis(f.Axis.Y,f.Tools.ToDegrees(a/this.angularSensibility)),l=f.Quaternion.RotationAxis(f.Axis.X,f.Tools.ToDegrees(r/this.angularSensibility)),s=o.multiply(i).multiply(l);this.camera.rotation=s.toEulerAngles()}}onLostFocus(){this._isPanClick=!1,this._isPinching=!1}}const zu=e=>{const{position:t,target:n=new f.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 Du,u=new f.FreeCameraMouseWheelInput;l.current.inputs.add(p),l.current.inputs.add(u)}},[]),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 u;(u=l.current)==null||u.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 Vu extends f.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:f.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 $u=()=>{const e=_e.useEngine(),t=_e.useScene();return m.useEffect(()=>{if(t&&e){f.Effect.ShadersStore.depthbufferPixelShader=`#ifdef GL_ES
|
|
1211
|
+
}`,Zn=({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}),Gn=({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 Xt=(e=>(e[e.TRIGONOMETRIC=0]="TRIGONOMETRIC",e[e.PLANE=1]="PLANE",e[e.FLAT=2]="FLAT",e))(Xt||{});const qt=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:y,uvOffset:h=u.Vector2.Zero(),counterLine:T=void 0,scalePlane:P=1,scaleDepth:v=1,boundingBox:_=void 0,lines:b=[],text:E=[],disableDepthWrite:L,flatModeRotate:I=0}=e,S=k=>{a(k)};return m.useEffect(()=>{n&&s&&(n.setTexture("textureSampler",s),n.setFloat("textureFlatRotate",I),n.setVector2("uvOffset",h))},[I,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&&(y?n.setTexture("textureSideSampler",y):n.setTexture("textureSideSampler",s))},[n,y,s]),m.useEffect(()=>{var k;if(n)if(T&&_){const B=(k=T.startHeight)!=null?k:_.minimumWorld.y/v;return n.setFloat("contourLineStartHeight",B*v),n.setColor3("contourLineColor",T.color),n.setFloat("contourLineWidth",T.width),n.setFloat("contourLineStep",T.stepHeight*v),console.log("[Geo3DViewer] 等高线设置 ",T,_.centerWorld.y,B*v,B*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(k=>{k&&k.dispose();let B=(_.maximum.x-_.minimum.x)/P,F=(_.maximum.z-_.minimum.z)/P,w=0;if(B<F){const M=B;B=F,F=M,w=1}const D=B/F;B*F>2048*2048&&(B=2048,F=2048/D);const N=new u.DynamicTexture("dynamic-texture",{width:B,height:F},t,!1);return N.clear(),console.log("[Geo3DViewer] 设置动态划线 ",_,B,F,P),n.setVector3("oMin",_.minimum),n.setVector3("oMax",_.maximum),n.setFloat("textureOverlayRotate",w),n.setTexture("textureOverlaySampler",N),N})},[_,n,P,t]),m.useEffect(()=>{var k;if(r&&_)if((k=r.getScene())!=null&&k.getEngine()){r.clear();let B=(_.maximum.x-_.minimum.x)/P,F=(_.maximum.z-_.minimum.z)/P;if(B<F){const N=B;B=F,F=N}const w=B/F;B*F>2048*2048&&(B=2048,F=2048/w);const D=r.getContext();b.forEach(N=>{if(N.points.length<2)return;D.beginPath();const M=N.offset?N.offset:new u.Vector2(0,0),x=1-N.points[0].x+M.x,A=1-N.points[0].y+M.y;D.moveTo(x*B,A*F);for(let V=1;V<N.points.length;V++){const $=N.offset?N.offset:new u.Vector2(0,0),U=1-N.points[V].x+$.x,re=1-N.points[V].y+$.y;D.lineTo(U*B,re*F)}D.strokeStyle=`rgb(${N.color.r*255}, ${N.color.g*255}, ${N.color.b*255})`,B*F>2048*2048?D.lineWidth=N.width/w:D.lineWidth=N.width,D.stroke()}),E.forEach(N=>{var V,$;D.font=`${N.fontSize}px Arial`;const M=(V=N.color)!=null?V:u.Color3.White(),x=N.offset?N.offset:new u.Vector2(0,0),A=($=N.rotation)!=null?$:0;if(D.save(),D.translate((1-N.position.x+x.x)*B,(1-N.position.y+x.y)*F),D.rotate(A),N.clearArea){const U=D.measureText(N.text);D.clearRect(-U.width*.15,.5*N.fontSize*(1-.3),U.width*1.3,-N.fontSize*1.3)}if(N.background){D.fillStyle=`rgba(${N.background.r*255}, ${N.background.g*255}, ${N.background.b*255})`;const U=D.measureText(N.text);D.fillRect(-U.width*.05,.5*(N.fontSize*(.5-.1)),U.width*1.1,-N.fontSize*1.1)}D.fillStyle=`rgb(${M.r*255}, ${M.g*255}, ${M.b*255})`,D.fillText(N.text,0,0),D.restore()}),r.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[b,E,r,_,P]),C.jsx(lt,{...e,ref:S,vertex:cu,fragment:lu,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:L})},Mt=e=>{const t=_e.useScene(),n=m.useRef(null),a=m.useContext(Dn),[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:y,zOffsetUnits:h,clipPlane:T,counterLine:P=void 0,scalePlane:v=1,scaleDepth:_=1,boundingBox:b,lines:E=[],text:L=[],disableDepthWrite:I}=e;return m.useEffect(()=>{const S=n.current;S&&t&&(S.loadFromSerialization(iu,""),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=y!=null?y:1,S.zOffsetUnits=h!=null?h:0,S.clipPlane=T!=null?T:null,S.disableDepthWrite=I!=null?I:!1)},[s,d,c,T,I,i,p,f,y,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 k=S.getBlockByName("RemappedTexture");k&&(k.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 k;const S=n.current;if(S){const B=S.getBlockByName("contourLineStartHeight"),F=S.getBlockByName("contourLineColor"),w=S.getBlockByName("contourLineWidth"),D=S.getBlockByName("contourLineStep");if(P&&b){const N=(k=P.startHeight)!=null?k:b.centerWorld.y/_;return B&&(B.value=N*_),F&&(F.value=P.color),w&&(w.value=P.width),D&&(D.value=P.stepHeight*_),console.log("[Geo3DViewer] 等高线设置 ",P,b.centerWorld,b.centerWorld.y,N*_,N*_+16*P.stepHeight*_),()=>{S&&(B&&(B.value=0),F&&(F.value=new u.Color3(0,0,0)),w&&(w.value=0),D&&(D.value=0))}}else B&&(B.value=0),F&&(F.value=new u.Color3(0,0,0)),w&&(w.value=0),D&&(D.value=0),console.log("[Geo3DViewer] 等高线设置 关闭");S.markAsDirty(u.NodeMaterial.MiscDirtyFlag)}},[P,_,v,b]),m.useEffect(()=>{t&&b&&o(S=>{var x,A;S&&S.dispose();let k=(b.maximum.x-b.minimum.x)/v,B=(b.maximum.z-b.minimum.z)/v,F=0;if(k<B){const V=k;k=B,B=V,F=1}const w=k/B;k*B>2048*2048&&(k=2048,B=2048/w);const D=new u.DynamicTexture("dynamic-texture",{width:k,height:B},t,!1);D.clear(),console.log("[Geo3DViewer] 设置动态划线 ",b,k,B,v);const N=(x=n.current)==null?void 0:x.getBlockByName("angle"),M=(A=n.current)==null?void 0:A.getBlockByName("OverlayTexture");return N&&(N.value=F*(Math.PI/2)),M&&(M.texture=D),D})},[b,v,t]),m.useEffect(()=>{var S;if(r&&b)if((S=r.getScene())!=null&&S.getEngine()){r.clear();let k=(b.maximum.x-b.minimum.x)/v,B=(b.maximum.z-b.minimum.z)/v;if(k<B){const D=k;k=B,B=D}const F=k/B;k*B>2048*2048&&(k=2048,B=2048/F);const w=r.getContext();E.forEach(D=>{if(D.points.length<2)return;w.beginPath();const N=D.offset?D.offset:new u.Vector2(0,0),M=1-D.points[0].x+N.x,x=1-D.points[0].y+N.y;w.moveTo(M*k,x*B);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,U=1-D.points[A].y+V.y;w.lineTo($*k,U*B)}w.strokeStyle=`rgb(${D.color.r*255}, ${D.color.g*255}, ${D.color.b*255})`,k*B>2048*2048?w.lineWidth=D.width/F:w.lineWidth=D.width,w.stroke()}),L.forEach(D=>{var A,V;w.font=`${D.fontSize}px Arial`;const N=(A=D.color)!=null?A:u.Color3.White(),M=D.offset?D.offset:new u.Vector2(0,0),x=(V=D.rotation)!=null?V:0;if(w.save(),w.translate((1-D.position.x+M.x)*k,(1-D.position.y+M.y)*B),w.rotate(x),D.clearArea){const $=w.measureText(D.text);w.clearRect(-$.width*.15,.5*D.fontSize*(1-.3),$.width*1.3,-D.fontSize*1.3)}if(D.background){w.fillStyle=`rgba(${D.background.r*255}, ${D.background.g*255}, ${D.background.b*255})`;const $=w.measureText(D.text);w.fillRect(-$.width*.05,.5*(D.fontSize*(.5-.1)),$.width*1.1,-D.fontSize*1.1)}w.fillStyle=`rgb(${N.r*255}, ${N.g*255}, ${N.b*255})`,w.fillText(D.text,0,0),w.restore()}),r.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[E,r,b,v,L]),C.jsx("nodeMaterial",{ref:n,name:`${i}-material`,backFaceCulling:c,needDepthPrePass:p,transparencyMode:f,alphaMode:d,alpha:s,zOffset:y,zOffsetUnits:h,clipPlane:T,disableDepthWrite:I})},Ji=e=>{const t=_e.useScene(),n=m.useContext(Dn),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,y]=m.useState(null),[h,T]=m.useState(null),[P,v]=m.useState(null),[_,b]=m.useState(null),{boundingBox:E,colorCodec:L,alphaStage:I,cutNormal:S,value:k,zOffset:B,zOffsetUnits:F,counterLine:w=void 0,scaleDepth:D=1,scalePlane:N=1,lines:M=[],text:x=[],disableDepthWrite:A}=e;return m.useEffect(()=>{const V=($,U,re)=>{if(E){const oe=E.maximumWorld.multiply(U),G=E.minimumWorld.multiply(U),ae=E.centerWorld.multiply(U),ne=Math.max(oe.x,oe.y,oe.z),j=Math.max(G.x,G.y,G.z),Y=Math.max(ae.x,ae.y,ae.z),ce=Math.max(Math.abs(U.x),Math.abs(U.z));$(new u.Plane(U.x,U.y,U.z,((ne-j)*(1-re-.5)*ce+Y)*-1))}else $(null)};E&&_&&(V(o,_.cutPlane1,k.value1),_.cutPlane2&&k.value2?V(l,_.cutPlane2,k.value2):l(null),_.cutPlane3&&k.value3?V(c,_.cutPlane3,k.value3):c(null),_.cutPlane4&&k.value4?V(f,_.cutPlane4,k.value4):f(null),_.cutPlane5&&k.value5?V(y,_.cutPlane5,k.value5):c(null),_.cutPlane6&&k.value6?V(T,_.cutPlane6,k.value6):T(null))},[E,_,k]),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,$,U,re,oe;a.current&&t&&(a.current.setFloat("alpha1",I.alpha1),a.current.setFloat("alpha2",(V=I.alpha2)!=null?V:1),a.current.setFloat("alpha3",($=I.alpha3)!=null?$:1),a.current.setFloat("alpha4",(U=I.alpha4)!=null?U:1),a.current.setFloat("alpha5",(re=I.alpha5)!=null?re:1),a.current.setFloat("alpha6",(oe=I.alpha6)!=null?oe:1))},[t,I]),m.useEffect(()=>{if(L){const V=a.current;V&&(V.metadata={colorCodec:L},u.Tags.EnableFor(V),u.Tags.AddTagsTo(V,"remap"))}if(L&&n&&t&&n.colorCodecsImage.current[L]){const V=a.current;V&&(console.log(n.colorCodecsImage.current[L]),V.setTexture("textureSampler",n.colorCodecsImage.current[L].texture),V.metadata={colorCodec:L},u.Tags.EnableFor(V),u.Tags.AddTagsTo(V,"remap"))}},[L,t]),m.useEffect(()=>{var $;const V=a.current;if(V&&E)if(w){const U=($=w.startHeight)!=null?$:E.minimumWorld.y/D;return V.setFloat("contourLineStartHeight",U*D),V.setColor3("contourLineColor",w.color),V.setFloat("contourLineWidth",w.width),V.setFloat("contourLineStep",w.stepHeight*D),console.log("[Geo3DViewer] 等高线设置 ",w,E.centerWorld.y,U*D,U*D+16*w.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] 等高线设置 关闭")},[w,D,N,E]),m.useEffect(()=>{t&&E&&v(V=>{var ae,ne,j,Y;V&&V.dispose();let $=(E.maximum.x-E.minimum.x)/N,U=(E.maximum.z-E.minimum.z)/N,re=0;if($<U){const ce=$;$=U,U=ce,re=1}const oe=$/U;$*U>2048*2048&&($=2048,U=2048/oe);const G=new u.DynamicTexture("dynamic-texture",{width:$,height:U},t,!1);return G.clear(),console.log("[Geo3DViewer] 设置动态划线 ",E,$,U,N),(ae=a.current)==null||ae.setVector3("oMin",E.minimum),(ne=a.current)==null||ne.setVector3("oMax",E.maximum),(j=a.current)==null||j.setFloat("textureOverlayRotate",re),(Y=a.current)==null||Y.setTexture("textureOverlaySampler",G),G})},[E,N,t]),m.useEffect(()=>{var V;if(P&&E)if((V=P.getScene())!=null&&V.getEngine()){P.clear();let $=(E.maximum.x-E.minimum.x)/N,U=(E.maximum.z-E.minimum.z)/N;if($<U){const G=$;$=U,U=G}const re=$/U;$*U>2048*2048&&($=2048,U=2048/re);const oe=P.getContext();M.forEach(G=>{if(G.points.length<2)return;oe.beginPath();const ae=G.offset?G.offset:new u.Vector2(0,0),ne=1-G.points[0].x+ae.x,j=1-G.points[0].y+ae.y;oe.moveTo(ne*$,j*U);for(let Y=1;Y<G.points.length;Y++){const ce=G.offset?G.offset:new u.Vector2(0,0),le=1-G.points[Y].x+ce.x,X=1-G.points[Y].y+ce.y;oe.lineTo(le*$,X*U)}oe.strokeStyle=`rgb(${G.color.r*255}, ${G.color.g*255}, ${G.color.b*255})`,$*U>2048*2048?oe.lineWidth=G.width/re:oe.lineWidth=G.width,oe.stroke()}),x.forEach(G=>{var Y,ce;oe.font=`${G.fontSize}px Arial`;const ae=(Y=G.color)!=null?Y:u.Color3.White(),ne=G.offset?G.offset:new u.Vector2(0,0),j=(ce=G.rotation)!=null?ce:0;if(oe.save(),oe.translate((1-G.position.x+ne.x)*$,(1-G.position.y+ne.y)*U),oe.rotate(j),G.clearArea){const le=oe.measureText(G.text);oe.clearRect(-le.width*.15,.5*G.fontSize*(1-.3),le.width*1.3,-G.fontSize*1.3)}if(G.background){oe.fillStyle=`rgba(${G.background.r*255}, ${G.background.g*255}, ${G.background.b*255})`;const le=oe.measureText(G.text);oe.fillRect(-le.width*.05,.5*(G.fontSize*(.5-.1)),le.width*1.1,-G.fontSize*1.1)}oe.fillStyle=`rgb(${ae.r*255}, ${ae.g*255}, ${ae.b*255})`,oe.fillText(G.text,0,0),oe.restore()}),P.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[M,P,E,N,x]),C.jsx(lt,{...e,ref:a,vertex:su,fragment:au,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:B,zOffsetUnits:F})},Xi=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,y]=m.useState(null),[h,T]=m.useState(null),[P,v]=m.useState(null),[_,b]=m.useState(null),{boundingBox:E=void 0,texture:L,sideTexture:I,alphaStage:S,cutNormal:k,value:B,tilingFactor:F=.1,sideTilingFactor:w=.1,mode:D=0,zOffset:N,zOffsetUnits:M,overlay:x={},counterLine:A=void 0,scalePlane:V=1,scaleDepth:$=1,lines:U=[],text:re=[],disableDepthWrite:oe,textureFlatRotate:G=0}=e,ae=ne=>{a(ne)};return m.useEffect(()=>{n&&n.setFloat("textureFlatRotate",G)},[n,G]),m.useEffect(()=>{const ne=(j,Y,ce)=>{if(E){const le=E.maximumWorld.multiply(Y),X=E.minimumWorld.multiply(Y),Pe=E.centerWorld.multiply(Y),ge=Math.max(le.x,le.y,le.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)),be=new u.Plane(Y.x,Y.y,Y.z,((ge-H)*(1-ce-.5)*Ee+Q)*-1);j(be),console.log("[Geo3DViewer] 设置实际 CutPlane 为 ",be,Ee)}else j(null)};E&&_&&(ne(o,_.cutPlane1,B.value1),_.cutPlane2&&B.value2?ne(l,_.cutPlane2,B.value2):l(null),_.cutPlane3&&B.value3?ne(c,_.cutPlane3,B.value3):c(null),_.cutPlane4&&B.value4?ne(f,_.cutPlane4,B.value4):f(null),_.cutPlane5&&B.value5?ne(y,_.cutPlane5,B.value5):c(null),_.cutPlane6&&B.value6?ne(T,_.cutPlane6,B.value6):T(null))},[_,E,B]),m.useEffect(()=>{b({cutPlane1:u.Vector3.Normalize(k.cutPlane1),cutPlane2:k.cutPlane2?u.Vector3.Normalize(k.cutPlane2):void 0,cutPlane3:k.cutPlane3?u.Vector3.Normalize(k.cutPlane3):void 0,cutPlane4:k.cutPlane4?u.Vector3.Normalize(k.cutPlane4):void 0,cutPlane5:k.cutPlane5?u.Vector3.Normalize(k.cutPlane5):void 0,cutPlane6:k.cutPlane6?u.Vector3.Normalize(k.cutPlane6):void 0})},[k]),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 ne,j,Y,ce,le;n&&t&&(n.setFloat("alpha1",S.alpha1),n.setFloat("alpha2",(ne=S.alpha2)!=null?ne:1),n.setFloat("alpha3",(j=S.alpha3)!=null?j:1),n.setFloat("alpha4",(Y=S.alpha4)!=null?Y:1),n.setFloat("alpha5",(ce=S.alpha5)!=null?ce:1),n.setFloat("alpha6",(le=S.alpha6)!=null?le:1))},[t,S,n]),m.useEffect(()=>{n&&L&&n.setTexture("textureSampler",L)},[n,L]),m.useEffect(()=>{n&&F&&n.setFloat("tilingFactor",F),n&&w&&n.setFloat("sideTilingFactor",w)},[F,w,n]),m.useEffect(()=>{n&&D&&n.setInt("mode",D)},[n,D]),m.useEffect(()=>{n&&(I?n.setTexture("textureSideSampler",I):n.setTexture("textureSideSampler",L))},[n,I,L]),m.useEffect(()=>{n&&(x.texture1?n.setTexture("textureSampler1",x.texture1):n.setTexture("textureSampler1",L),x.sideTexture1?n.setTexture("textureSideSampler1",x.sideTexture1):n.setTexture("textureSideSampler1",L),x.color1?n.setColor3("vColor1",x.color1):n.setColor3("vColor1",new u.Color3(1,1,1)),x.texture2?n.setTexture("textureSampler2",x.texture2):n.setTexture("textureSampler2",L),x.sideTexture2?n.setTexture("textureSideSampler2",x.sideTexture2):n.setTexture("textureSideSampler2",L),x.color2?n.setColor3("vColor2",x.color2):n.setColor3("vColor2",new u.Color3(1,1,1)),x.texture3?n.setTexture("textureSampler3",x.texture3):n.setTexture("textureSampler3",L),x.sideTexture3?n.setTexture("textureSideSampler3",x.sideTexture3):n.setTexture("textureSideSampler2",L),x.color3?n.setColor3("vColor3",x.color3):n.setColor3("vColor3",new u.Color3(1,1,1)),x.texture4?n.setTexture("textureSampler4",x.texture4):n.setTexture("textureSampler4",L),x.sideTexture4?n.setTexture("textureSideSampler4",x.sideTexture4):n.setTexture("textureSideSampler4",L),x.color4?n.setColor3("vColor4",x.color4):n.setColor3("vColor4",new u.Color3(1,1,1)),x.texture5?n.setTexture("textureSampler5",x.texture5):n.setTexture("textureSampler5",L),x.sideTexture5?n.setTexture("textureSideSampler5",x.sideTexture5):n.setTexture("textureSideSampler5",L),x.color5?n.setColor3("vColor5",x.color5):n.setColor3("vColor5",new u.Color3(1,1,1)),x.texture6?n.setTexture("textureSampler6",x.texture6):n.setTexture("textureSampler6",L),x.sideTexture6?n.setTexture("textureSideSampler6",x.sideTexture6):n.setTexture("textureSideSampler6",L),x.color6?n.setColor3("vColor6",x.color6):n.setColor3("vColor6",new u.Color3(1,1,1)))},[n,x,L]),m.useEffect(()=>{var ne;if(n&&E)if(A){const j=(ne=A.startHeight)!=null?ne:E.minimumWorld.y/$;return n.setFloat("contourLineStartHeight",j*$),n.setColor3("contourLineColor",A.color),n.setFloat("contourLineWidth",A.width),n.setFloat("contourLineStep",A.stepHeight*$),console.log("[Geo3DViewer] 等高线设置 ",A,E.centerWorld.y,j*$,j*$+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,E,n]),m.useEffect(()=>{t&&n&&E&&v(ne=>{ne&&ne.dispose();let j=(E.maximum.x-E.minimum.x)/V,Y=(E.maximum.z-E.minimum.z)/V,ce=0;if(j<Y){const Pe=j;j=Y,Y=Pe,ce=1}const le=j/Y;j*Y>2048*2048&&(j=2048,Y=2048/le);const X=new u.DynamicTexture("dynamic-texture",{width:j,height:Y},t,!1);return X.clear(),console.log("[Geo3DViewer] 设置动态划线 ",E,j,Y,V),n.setVector3("oMin",E.minimum),n.setVector3("oMax",E.maximum),n.setFloat("textureOverlayRotate",ce),n.setTexture("textureOverlaySampler",X),X})},[E,n,V,t]),m.useEffect(()=>{var ne;if(P&&E)if((ne=P.getScene())!=null&&ne.getEngine()){P.clear();let j=(E.maximum.x-E.minimum.x)/V,Y=(E.maximum.z-E.minimum.z)/V;if(j<Y){const X=j;j=Y,Y=X}const ce=j/Y;j*Y>2048*2048&&(j=2048,Y=2048/ce);const le=P.getContext();U.forEach(X=>{if(X.points.length<2)return;le.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;le.moveTo(ge*j,H*Y);for(let Q=1;Q<X.points.length;Q++){const Ee=X.offset?X.offset:new u.Vector2(0,0),be=1-X.points[Q].x+Ee.x,ee=1-X.points[Q].y+Ee.y;le.lineTo(be*j,ee*Y)}le.strokeStyle=`rgb(${X.color.r*255}, ${X.color.g*255}, ${X.color.b*255})`,j*Y>2048*2048?le.lineWidth=X.width/ce:le.lineWidth=X.width,le.stroke()}),re.forEach(X=>{var Q,Ee;le.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(le.save(),le.translate((1-X.position.x+ge.x)*j,(1-X.position.y+ge.y)*Y),le.rotate(H),X.clearArea){const be=le.measureText(X.text);le.clearRect(-be.width*.15,.5*X.fontSize*(1-.3),be.width*1.3,-X.fontSize*1.3)}if(X.background){le.fillStyle=`rgba(${X.background.r*255}, ${X.background.g*255}, ${X.background.b*255})`;const be=le.measureText(X.text);le.fillRect(-be.width*.05,.5*(X.fontSize*(.5-.1)),be.width*1.1,-X.fontSize*1.1)}le.fillStyle=`rgb(${Pe.r*255}, ${Pe.g*255}, ${Pe.b*255})`,le.fillText(X.text,0,0),le.restore()}),P.update()}else console.log("[Geo3DViewer] 动态纹理未准备好,正准备下一次绘制")},[U,P,E,V,re]),C.jsx(lt,{...e,ref:ae,vertex:fu,fragment:uu,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:N,zOffsetUnits:M,disableDepthWrite:oe})},hu=e=>C.jsx(lt,{...e,vertex:Hn,fragment:Wn,options:{needAlphaBlending:!0},zOffset:e.zOffset,zOffsetUnits:e.zOffsetUnits,disableDepthWrite:e.disableDepthWrite}),mu=()=>C.jsx(lt,{name:"picking-material",vertex:bc,fragment:Tc,backFaceCulling:!1,options:{attributes:["position","color","normal"],uniforms:["world","worldViewProjection","pickingColor","isPickable"]}}),gu=({name:e,scene:t})=>{const n=u.NodeMaterial.Parse(_c,t);return n.name=e,n.backFaceCulling=!1,n.build(!1,!0,!1),n},vu=({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(Wl,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},xu=(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:du,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}})},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:y={textureIncludeSide:!0},disableDepthWrite:h,disableNormalShadow:T=!1}=e,{textureIncludeSide:P}=y;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,E=(o.maximum.z-o.minimum.z)/s,L=0;if(b<E){const k=b;b=E,E=k,L=1}const I=b/E;b*E>2048*2048&&(b=2048,E=2048/I);let S;return _?(_.scaleTo(b,E),_.update(),S=_):S=new u.DynamicTexture("dynamic-texture",{width:b,height:E},t,!1),S.clear(),S.update(),console.log("[Geo3DViewer] 设置动态划线 ",o,b,E,s),v.setVector3("oMin",o.minimum),v.setVector3("oMax",o.maximum),v.setFloat("textureOverlayRotate",L),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 I=_;_=b,b=I}const E=_/b;_*b>2048*2048&&(_=2048,b=2048/E);const L=n.getContext();f.forEach(I=>{if(I.points.length<2)return;L.beginPath();const S=I.offset?I.offset:new u.Vector2(0,0),k=1-I.points[0].x+S.x,B=1-I.points[0].y+S.y;L.moveTo(k*_,B*b);for(let F=1;F<I.points.length;F++){const w=I.offset?I.offset:new u.Vector2(0,0),D=1-I.points[F].x+w.x,N=1-I.points[F].y+w.y;L.lineTo(D*_,N*b)}L.strokeStyle=`rgb(${I.color.r*255}, ${I.color.g*255}, ${I.color.b*255})`,_*b>2048*2048?L.lineWidth=I.width/E:L.lineWidth=I.width,L.stroke()}),d.forEach(I=>{var F,w;L.font=`${I.fontSize}px Arial`;const S=(F=I.color)!=null?F:u.Color3.White(),k=I.offset?I.offset:new u.Vector2(0,0),B=(w=I.rotation)!=null?w:0;if(L.save(),L.translate((1-I.position.x+k.x)*_,(1-I.position.y+k.y)*b),L.rotate(B),I.clearArea){const D=L.measureText(I.text);L.clearRect(-D.width*.15,.5*I.fontSize*(1-.3),D.width*1.3,-I.fontSize*1.3)}if(I.background){L.fillStyle=`rgba(${I.background.r*255}, ${I.background.g*255}, ${I.background.b*255})`;const D=L.measureText(I.text);L.fillRect(-D.width*.05,.5*(I.fontSize*(.5-.1)),D.width*1.1,-I.fontSize*1.1)}L.fillStyle=`rgb(${S.r*255}, ${S.g*255}, ${S.b*255})`,L.fillText(I.text,0,0),L.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:Sc,fragment:Pc,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})},yu=m.forwardRef(xu),qi=({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}),[y,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=Bo.decode(new Uint8Array(p)),{points:_,indices:b,value:E,center:L}=v,I=new u.VertexData;I.positions=_,I.indices=b,I.colors=E;const S=[];u.VertexData.ComputeNormals(_,b,S),I.normals=S,L&&h(new u.Vector3(L.x,L.y,L.z));const k=s.current;k&&(I.applyToMesh(k),k.getScene().onAfterRenderObservable.addOnce(()=>{if(!k.isDisposed()){const F=k.getBoundingInfo();P(F.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,extra:i.extra}:null})},[i,e]),C.jsx(C.Fragment,{children:C.jsx("transformNode",{name:`transform-attribute-${e}`,position:y.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(qt,{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?Xt.PLANE:r.textureMode,boundingBox:T,disableDepthWrite:r.disableDepthWrite}):C.jsx(C.Fragment,{})})})})},Ki=({codec:e,showValue:t=!1,showTitle:n=!0,width:a=80,height:r=200})=>{const o=m.useContext(Dn);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 Zr(){return{name:"",colorId:0,points:[],indices:[],bottomIndices:[],value:[],vMin:0,vMax:0,border:[],side:[],sideIndices:[],sideValue:[],center:void 0}}const Ut={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=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.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:Cn(e.name)?globalThis.String(e.name):"",colorId:Cn(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:Cn(e.vMin)?globalThis.Number(e.vMin):0,vMax:Cn(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:Cn(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 Ut.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,l,s,c,p,f,d,y;const t=Zr();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=((y=e.sideValue)==null?void 0:y.map(h=>h))||[],t.center=e.center!==void 0&&e.center!==null?K.fromPartial(e.center):void 0,t}};function Cn(e){return e!=null}const Cu=64,_u=32,Qi='"Noto Sans SC", sans-serif';function Pu(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 ${Qi}`;const i=Math.ceil(a.measureText(e||" ").width),l=Math.ceil(t*1.6);return{textureWidth:Math.max(Cu,Gr(i+r*2)),textureHeight:Math.max(_u,Gr(l+o*2))}}function Gr(e){let t=1;for(;t<e;)t<<=1;return t}function Su(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}=Pu(o,i),y=u.MeshBuilder.CreatePlane(p,{width:1,height:1},t);y.parent=n.current,y.isPickable=!1,y.billboardMode=s,y.alwaysSelectAsActiveMesh=!0;const h=Math.max(i,1);y.scaling.x=h*(f/d),y.scaling.y=h;const T=nt.AdvancedDynamicTexture.CreateForMesh(y,f,d,!1,!1);T.rootContainer.isPointerBlocker=!1;const P=new nt.TextBlock(`${p}-text`,o);P.color=Su(l),P.fontFamily=Qi,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=y.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),y.renderingGroupId=2,a.current={plane:y,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})},Yn=({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 N,M;const c=m.useRef(null),p=m.useRef(null),[f,d]=m.useState(""),[y,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}),E=je({url:t,cacheType:Me.URL_PREFIX_MATCH}),L=He({url:s==null?void 0:s.texture,cacheType:Me.URL_PREFIX_MATCH}),I=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,k]=m.useState(),[B,F]=m.useState(u.Vector3.Zero()),[w,D]=m.useState(void 0);return m.useEffect(()=>{if(b){const x=c.current;x&&(u.Tags.EnableFor(x),u.Tags.AddTagsTo(x,"loading"));let A=[],V=[],$=[];const U=Ut.decode(new Uint8Array(b));{const{name:G,points:ae,indices:ne,colorId:j,value:Y,center:ce}=U;A=ae,V=ne,$=Y,h(j),d(G),ce&&F(new u.Vector3(ce.x,ce.y,ce.z))}const re=new u.VertexData;re.positions=A,re.indices=V,re.colors=$;const oe=[];if(u.VertexData.ComputeNormals(A,V,oe),re.normals=oe,x){re.applyToMesh(x);const G=x.getBoundingInfo();k(G.boundingBox.center.add(new u.Vector3(G.boundingBox.extendSize.x,0,0))),i||x.getScene().onAfterRenderObservable.addOnce(()=>{if(!x.isDisposed()){const ne=x.getBoundingInfo();D(ne.boundingBox)}})}return x&&u.Tags.RemoveTagsFrom(x,"loading"),()=>{x&&new u.VertexData().applyToMesh(x)}}},[b,i]),m.useEffect(()=>{if(b&&E){const x=p.current;x&&(u.Tags.EnableFor(x),u.Tags.AddTagsTo(x,"loading"));let A=[],V=[],$=[],U=[],re=[],oe=[],G=[],ae=[];{const ge=Ut.decode(new Uint8Array(b)),{points:H,indices:Q,border:Ee,value:be}=ge;A=H,V=Q,U=Ee,$=be}{const ge=Ut.decode(new Uint8Array(E)),{points:H,bottomIndices:Q,border:Ee,value:be}=ge;re=H,oe=Q,G=Ee,ae=be}const ne=new u.VertexData,j=new Float32Array(A.length+re.length);let Y=V.length+oe.length;Y=Y+((U.length<1?1:U.length)-1)*6;const ce=new Int32Array(Y),le=new Float32Array($.length+ae.length);j.set(A),ce.set(V),le.set($),j.set(re,A.length),ce.set(oe,V.length),le.set(ae,$.length);const X=[];for(let ge=0;ge<U.length-1;ge++)X.push(U[ge+1]),X.push(U[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(U[ge+1]);ce.set(X,V.length+oe.length),ne.positions=j,ne.indices=ce,ne.colors=le;const Pe=[];return u.VertexData.ComputeNormals(j,ce,Pe),ne.normals=Pe,x&&(ne.applyToMesh(x),i&&x.getScene().onAfterRenderObservable.addOnce(()=>{if(!x.isDisposed()){const H=x.getBoundingInfo();D(H.boundingBox)}})),x&&u.Tags.RemoveTagsFrom(x,"loading"),()=>{x&&new u.VertexData().applyToMesh(x)}}},[E,b,i]),m.useEffect(()=>{var x;_(s.type===$e.ONE_COLOR?(x=s==null?void 0:s.color)!=null?x:u.Color3.Random():y&&P.colorIDs[y]?new u.Color3(P.colorIDs[y].r,P.colorIDs[y].g,P.colorIDs[y].b):u.Color3.Random())},[P.colorIDs,y,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,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,extra:l.extra}:null})},[l,f]),C.jsx(C.Fragment,{children:C.jsxs("transformNode",{name:`transform-formation-${f}-${e}`,position:B.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?L?C.jsx(qt,{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:L,sideTexture:I,tilingFactor:s.tilingFactor,sideTilingFactor:(N=s==null?void 0:s.sideTilingFactor)!=null?N:s==null?void 0:s.tilingFactor,mode:s.textureMode===void 0?Xt.PLANE:s.textureMode,boundingBox:w,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:w,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(An,{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:w,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(An,{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:w,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?L?C.jsx(qt,{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:I,texture:L,tilingFactor:s.tilingFactor,sideTilingFactor:(M=s==null?void 0:s.sideTilingFactor)!=null?M:s==null?void 0:s.tilingFactor,mode:s.textureMode===void 0?Xt.PLANE:s.textureMode,boundingBox:w,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:w,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(An,{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:w,lines:s.lines,text:s.text,scaleDepth:T?T.scaleDepth:1,scalePlane:T?T.scalePlane:1,disableDepthWrite:s.disableDepthWrite,disableNormalShadow:s.disableNormalShadow}):C.jsx(An,{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:w,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"})})]})})},Jn=({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 w,D;const s=m.useRef(null),c=m.useRef(null),[p,f]=m.useState(""),[d,y]=m.useState(null),[h,T]=m.useState(u.Color3.White()),P=m.useContext(Le),v=m.useContext(Lt),[_,b]=m.useState(u.Vector3.Zero()),[E,L]=m.useState(),I=je({url:e,cacheType:Me.URL_PREFIX_MATCH}),S=He({url:l==null?void 0:l.texture,cacheType:Me.URL_PREFIX_MATCH}),k=He({url:l==null?void 0:l.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),[B,F]=m.useState(void 0);return m.useEffect(()=>{console.log("[Geo3DViewer] FormationVolume Loading: ",e)},[e]),m.useEffect(()=>{if(I){const N=s.current,M=c.current;u.Tags.EnableFor(N),u.Tags.AddTagsTo(N,"loading"),u.Tags.EnableFor(c),u.Tags.AddTagsTo(c,"loading");let x=[],A=[],V=[],$=[];const U=Ut.decode(new Uint8Array(I)),{name:re,points:oe,indices:G,colorId:ae,side:ne,sideIndices:j,center:Y,value:ce,sideValue:le}=U;Y&&b(new u.Vector3(Y.x,Y.y,Y.z)),x=oe,A=G,V=ne,$=j,y(ae),f(re);const X=new u.VertexData,Pe=new u.VertexData,ge=new Float32Array(x.length+V.length),H=new Int32Array(A.length+$.length),Q=new Float32Array(ce.length+le.length);X.positions=x,X.indices=A,X.colors=ce;const Ee=[];u.VertexData.ComputeNormals(oe,G,Ee),X.normals=Ee,ge.set(x),H.set(A),Q.set(ce),ge.set(V,x.length),H.set($,A.length),Q.set(le,ce.length),Pe.positions=ge,Pe.indices=H,Pe.colors=Q;const be=[];if(u.VertexData.ComputeNormals(ge,H,be),Pe.normals=be,N){X.applyToMesh(N);const ee=N.getBoundingInfo();L(ee.boundingBox.center.add(new u.Vector3(ee.boundingBox.extendSize.x,0,0))),o||N.getScene().onAfterRenderObservable.addOnce(()=>{if(!N.isDisposed()){const ue=N.getBoundingInfo();F(ue.boundingBox)}})}return M&&(Pe.applyToMesh(M),o&&M.getScene().onAfterRenderObservable.addOnce(()=>{if(!M.isDisposed()){const he=M.getBoundingInfo();F(he.boundingBox)}})),u.Tags.RemoveTagsFrom(N,"loading"),u.Tags.RemoveTagsFrom(c,"loading"),()=>{N&&new u.VertexData().applyToMesh(N),M&&new u.VertexData().applyToMesh(M)}}},[I,o]),m.useEffect(()=>{var N;T(l.type===$e.ONE_COLOR?(N=l==null?void 0:l.color)!=null?N: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,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,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(qt,{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:k,texture:S,tilingFactor:l.tilingFactor,sideTilingFactor:(w=l==null?void 0:l.sideTilingFactor)!=null?w:l==null?void 0:l.tilingFactor,mode:l.textureMode===void 0?Xt.PLANE:l.textureMode,counterLine:l.counterLine,boundingBox:B,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:B,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(On,{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:B,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(On,{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:B,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(qt,{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:k,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?Xt.PLANE:l.textureMode,flatModeRotate:l.flatModeRotate,counterLine:l.counterLine,boundingBox:B,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:B,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(On,{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:B,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(On,{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:B,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&&E&&C.jsx("transformNode",{name:`${p}-title-${e}`,position:E.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 Fo=(e=>(e[e.FACE=0]="FACE",e[e.VOLUME=1]="VOLUME",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Fo||{});function Tu(e){switch(e){case 0:case"FACE":return 0;case 1:case"VOLUME":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function bu(e){switch(e){case 0:return"FACE";case 1:return"VOLUME";case-1:default:return"UNRECOGNIZED"}}function Yr(){return{name:"",formations:[],mode:0,effectMeshs:[]}}const bn={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.formations)ln.encode(n,t.uint32(34).fork()).ldelim();e.mode!==0&&t.uint32(40).int32(e.mode);for(const n of e.effectMeshs)Ue.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=Yr();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(ln.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(Ue.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:Bn(e.name)?globalThis.String(e.name):"",formations:globalThis.Array.isArray(e==null?void 0:e.formations)?e.formations.map(t=>ln.fromJSON(t)):[],mode:Bn(e.mode)?Tu(e.mode):0,effectMeshs:globalThis.Array.isArray(e==null?void 0:e.effectMeshs)?e.effectMeshs.map(t=>Ue.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=>ln.toJSON(r))),e.mode!==0&&(t.mode=bu(e.mode)),(a=e.effectMeshs)!=null&&a.length&&(t.effectMeshs=e.effectMeshs.map(r=>Ue.toJSON(r))),t},create(e){return bn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o;const t=Yr();return t.name=(n=e.name)!=null?n:"",t.formations=((a=e.formations)==null?void 0:a.map(i=>ln.fromPartial(i)))||[],t.mode=(r=e.mode)!=null?r:0,t.effectMeshs=((o=e.effectMeshs)==null?void 0:o.map(i=>Ue.fromPartial(i)))||[],t}};function Jr(){return{name:"",url:""}}const ln={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=Jr();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:Bn(e.name)?globalThis.String(e.name):"",url:Bn(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 ln.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=Jr();return t.name=(n=e.name)!=null?n:"",t.url=(a=e.url)!=null?a:"",t}};function Bn(e){return e!=null}const Do=({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(""),y=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}),[E,L]=m.useState(u.Vector3.Zero()),[I,S]=m.useState();return m.useEffect(()=>{console.log("[Geo3DViewer] StructureLayer Loading: ",e)},[e]),m.useEffect(()=>{if(b){const k=p.current;u.Tags.EnableFor(k),u.Tags.AddTagsTo(k,"loading");const B=Ut.decode(new Uint8Array(b)),{name:F,points:w,indices:D,value:N,colorId:M,center:x}=B;x&&L(new u.Vector3(x.x,x.y,x.z));const A=new u.VertexData;A.positions=w,A.indices=D,A.colors=N;const V=[];return u.VertexData.ComputeNormals(w,D,V),A.normals=V,P(M),d(F),k&&(A.applyToMesh(k),k.getScene().onAfterRenderObservable.addOnce(()=>{if(!k.isDisposed()){const U=k.getBoundingInfo();S(U.boundingBox)}})),u.Tags.RemoveTagsFrom(k,"loading"),()=>{P(null),d(""),k&&new u.VertexData().applyToMesh(k)}}},[b]),m.useEffect(()=>{const k=T&&h.colorIDs[T]?h.colorIDs[T]:u.Color3.White();_(u.Color3.FromArray([k.r,k.g,k.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,extra:o.extra}:null})},[o,f]),C.jsx(C.Fragment,{children:C.jsxs("transformNode",{name:`transform-structurelayer-${f}`,position:E.add(n).multiplyByFloats(y&&y.scalePlane?y.scalePlane:1,y&&y.scaleDepth?y.scaleDepth:1,y&&y.scalePlane?y.scalePlane:1),scaling:new u.Vector3(y?y.scalePlane:1,y?y.scaleDepth:1,y?y.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:I,lines:l,scaleDepth:y?y.scaleDepth:1,scalePlane:y?y.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})})]})})},ku=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,y]=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,y(_)}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})})})})},ji=({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:y=1,diffuseTextureUrl:h,diffuseTextureSufaceUrl:T,bumpTextureUrl:P,visibleEdgeEffect:v=!1})=>{var D,N;const[_,b]=m.useState(),E=m.useContext(Le),[L,I]=m.useState(!0),[S,k]=m.useState(""),B=je({url:e,cacheType:Me.URL_PREFIX_MATCH}),[F,w]=m.useState([]);return m.useEffect(()=>{console.log("[Geo3DViewer] ComplexFormationManager Loading: ",e)},[e]),m.useEffect(()=>{if(B){const M=bn.decode(new Uint8Array(B)),x=M.formations;if(M.mode==Fo.FACE){I(!0),k(M.name);const A=[];x.forEach((V,$)=>{const U={name:V.name,topUrl:V.url,bottomUrl:x[$+1]?x[$+1].url:void 0};A.push(U)}),b(A)}else{I(!1),k(M.name);const A=[];x.forEach(V=>{const $={name:V.name,topUrl:V.url};A.push($)}),b(A)}return console.log(M),w(M.effectMeshs),()=>{b([])}}},[B]),C.jsxs("abstractMesh",{name:`complexformationmanager-${S}`,children:[l&&_&&_.length>1?C.jsx(Do,{url:_[0].topUrl,alpha:(D=f==null?void 0:f[_[0].name])==null?void 0:D.alpha,position:new u.Vector3(0,y>=0?y*(E&&(N=E.scaleDepth)!=null?N:1):0,0).add(i),visible:t&&(n?n.includes(_[0].name):!0),colorCodec:c,counterLine:d},`${S}-${_[0].name}-SL`):null,_?_.map((M,x)=>L?l&&x===0?C.jsx(C.Fragment,{}):C.jsx("transformNode",{name:`${S}-${M.name}-EV`,position:i.add(new u.Vector3(0,x*(-1*a*(E&&E.scaleDepth?E.scaleDepth:0)),0)),children:C.jsx(Yn,{showLayerLabel:r,labelStyle:o,urlTopLayer:M.topUrl,urlBottomLayer:M.bottomUrl,visible:t&&(n?n.includes(M.name):!0),showBottomLayer:_[x+1]?n?n.includes(_[x+1].name):!0:!1,actions:p,material:x===0&&s?{...f==null?void 0:f[M.name],colorCodec:c,type:$e.COLOR_CODEC}:f==null?void 0:f[M.name]},`${S}-${M.name}`)},`${S}-${M.name}`):l&&x===0?C.jsx(C.Fragment,{}):C.jsx("transformNode",{name:`${S}-${M.name}-EV`,position:i.add(new u.Vector3(0,x*(-1*a*(E&&E.scaleDepth?E.scaleDepth:0)),0)),children:C.jsx(Jn,{url:M.topUrl,showLayerLabel:r,labelStyle:o,visible:t&&(n?n.includes(M.name):!0),showBottomLayer:_[x+1]?n?n.includes(_[x+1].name):!0:!1,actions:p,material:f==null?void 0:f[M.name]},`${S}-${M.name}`)},`${S}-${M.name}`)):null,F&&h&&P&&a===0&&F.map((M,x)=>C.jsx(ku,{visible:v,id:x,diffuseTextureUrl:h,diffuseTextureSufaceUrl:x===0?T:void 0,bumpTextureUrl:P,mesh:M},x))]})},ea=({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),[y,h]=m.useState([]),[T,P]=m.useState([]),[v,_]=m.useState([]),[b,E]=m.useState(0),L=m.useCallback(I=>{if(p&&I){const S=new Qa.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,I.material=S}},[t,o,p]);return m.useEffect(()=>()=>{var I;(I=f.current)==null||I.dispose()},[]),m.useEffect(()=>{const I=()=>{const S=(p==null?void 0:p.activeCamera).radius;for(let k=0;k<r.length;k++)if(S<=r[k]){E(k);break}};return p&&p.activeCamera&&(p==null||p.activeCamera.onViewMatrixChangedObservable.add(I)),()=>{p&&p.activeCamera&&(p==null||p.activeCamera.onViewMatrixChangedObservable.removeCallback(I))}},[r,i,o,p,e]),m.useEffect(()=>{if(d&&d.min&&d.max&&c){const I=d.origin||u.Vector3.Zero(),S=[],k=[],B=[],F=[...o];F.length===0&&F.push(a);for(let w=0;w<F.length;w++){let D=F[w]/1;D<1&&(D=200);const N=[];for(let A=0;A<=d.max.x-d.min.x;A+=D)N.push({text:`${A+d.min.x+I.x}`,position:new u.Vector3(A,0,0)}),N.push({text:`${A+d.min.x+I.x}`,position:new u.Vector3(A,d.max.y-d.min.y,d.max.z-d.min.z)}),N.push({text:`${A+d.min.x+I.x}`,position:new u.Vector3(A,d.max.y-d.min.y,0)}),N.push({text:`${A+d.min.x+I.x}`,position:new u.Vector3(A,0,d.max.z-d.min.z)});S.push(N);const M=[];for(let A=0;A<=d.max.y-d.min.y;A+=D)M.push({text:`${A+d.min.y+I.y}`,position:new u.Vector3(0,A,0)}),M.push({text:`${A+d.min.y+I.y}`,position:new u.Vector3(d.max.x-d.min.x,A,d.max.z-d.min.z)}),M.push({text:`${A+d.min.y+I.y}`,position:new u.Vector3(d.max.x-d.min.x,A,0)}),M.push({text:`${A+d.min.y+I.y}`,position:new u.Vector3(0,A,d.max.z-d.min.z)});k.push(M);const x=[];for(let A=0;A<=d.max.z-d.min.z;A+=D)x.push({text:`${A+d.min.z+I.z}`,position:new u.Vector3(0,0,A)}),x.push({text:`${A+d.min.z+I.z}`,position:new u.Vector3(d.max.x-d.min.x,d.max.y-d.min.y,A)}),x.push({text:`${A+d.min.z+I.z}`,position:new u.Vector3(0,d.max.y-d.min.y,A)}),x.push({text:`${A+d.min.z+I.z}`,position:new u.Vector3(d.max.x-d.min.x,0,A)});B.push(x)}h(S),P(k),_(B)}},[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:L,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:[y.map((I,S)=>I.map((k,B)=>{var w;const F=k;return C.jsx("transformNode",{name:`axis-x-${S}-${B}`,position:F==null?void 0:F.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:`${F?F.text:""}`,fontSize:(w=i[S])!=null?w:n,color:t.toHexString()})},`axis-x-${S}-${B}`)})),T.map((I,S)=>I.map((k,B)=>{var w;const F=k;return C.jsx("transformNode",{name:`axis-x-${S}-${B}`,position:F==null?void 0:F.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:`${F?F.text:""}`,fontSize:(w=i[S])!=null?w:n,color:t.toHexString()})},`axis-x-${S}-${B}`)})),v.map((I,S)=>I.map((k,B)=>{var w;const F=k;return C.jsx("transformNode",{name:`axis-x-${S}-${B}`,position:F==null?void 0:F.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:`${F?F.text:""}`,fontSize:(w=i[S])!=null?w:n,color:t.toHexString()})},`axis-x-${S}-${B}`)}))]})]},`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 Eu(e){switch(e){case 0:case"NORMAL":return 0;case 1:case"CICLE":return 1;case-1:case"UNRECOGNIZED":default:return-1}}function Nu(e){switch(e){case 0:return"NORMAL";case 1:return"CICLE";case-1:default:return"UNRECOGNIZED"}}function Xr(){return{name:"",lines:[]}}const ta={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.lines)un.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=Xr();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(un.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:Po(e.name)?globalThis.String(e.name):"",lines:globalThis.Array.isArray(e==null?void 0:e.lines)?e.lines.map(t=>un.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=>un.toJSON(a))),t},create(e){return ta.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=Xr();return t.name=(n=e.name)!=null?n:"",t.lines=((a=e.lines)==null?void 0:a.map(r=>un.fromPartial(r)))||[],t}};function qr(){return{positions:[]}}const cn={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=qr();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 cn.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=qr();return t.positions=((n=e.positions)==null?void 0:n.map(a=>rt.fromPartial(a)))||[],t}};function Kr(){return{segments:[],type:0,position:void 0}}const un={encode(e,t=se.Writer.create()){for(const n of e.segments)cn.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=Kr();for(;n.pos<a;){const o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;r.segments.push(cn.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=>cn.fromJSON(t)):[],type:Po(e.type)?Eu(e.type):0,position:Po(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=>cn.toJSON(a))),e.type!==0&&(t.type=Nu(e.type)),e.position!==void 0&&(t.position=rt.toJSON(e.position)),t},create(e){return un.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=Kr();return t.segments=((n=e.segments)==null?void 0:n.map(r=>cn.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 Po(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(y=>{f.push(y.add(o).multiply(d))}),l){const y={path:f,radius:l,updatable:!0};if(c.current)y.instance=c.current,u.MeshBuilder.CreateTube("line",y);else{c.current=u.MeshBuilder.CreateTube("line",y,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 y={points:f,updateable:!0};if(c.current)y.instance=c.current,u.MeshBuilder.CreateLines("line",y);else{c.current=u.MeshBuilder.CreateLines("line",y,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,{})})},Iu=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),y=Math.acos(u.Vector3.Dot(f,d)),h=u.Vector3.Cross(f,d);p.rotation.z=h.y>0?y:Math.PI*2-y,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})})},wu=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([]),y=m.useContext(Le);return m.useEffect(()=>{Wt.get(t,{responseType:"arraybuffer"}).then(h=>{const T=ta.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 E=[];for(let L=0;L<b.segments.length;L++){const I=[...ms(b.segments[L].positions)];P.push([...I]),E.push(I[0]),E.push(I[I.length-1])}b.type===1&&E.push(Ei(b.segments[0].positions[0])),v.push(E)}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(Iu,{name:T.y.toFixed(0),prev:Oe(y).multiply(T),next:Oe(y).multiply(h[P+1]),fontSize:o,textColor:i},P)))]})};function Ou(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 Au(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 Qr(){return{layer:0,direction:0,colorId:0,points:[],indices:[],value:[],vMin:0,vMax:0,center:void 0}}const Vo={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=Qr();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:en(e.layer)?globalThis.Number(e.layer):0,direction:en(e.direction)?Ou(e.direction):0,colorId:en(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:en(e.vMin)?globalThis.Number(e.vMin):0,vMax:en(e.vMax)?globalThis.Number(e.vMax):0,center:en(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=Au(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 Vo.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,l,s,c;const t=Qr();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 en(e){return e!=null}const $o=({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),y=je({url:t,cacheType:Me.URL_PREFIX_MATCH}),[h,T]=m.useState(u.Vector3.Zero());return m.useEffect(()=>{if(y){u.Tags.EnableFor(l.current),u.Tags.AddTagsTo(l.current,"loading");const P=Vo.decode(new Uint8Array(y)),{layer:v,direction:_,points:b,indices:E,value:L,center:I}=P,S=new u.VertexData;S.positions=b,S.indices=E,S.colors=L;const k=[];u.VertexData.ComputeNormals(b,E,k),S.normals=k,I&&T(new u.Vector3(I.x,I.y,I.z));const B=l.current;return B&&(S.applyToMesh(B),c(v.toString()),f(_.toString())),u.Tags.RemoveTagsFrom(B,"loading"),()=>{c(""),f(""),B&&new u.VertexData().applyToMesh(B)}}},[y]),m.useEffect(()=>{l.current&&(l.current.metadata={pickable:i?{name:e,onLeftClick:i.onLeftClick,onRightClick:i.onRightClick,onMiddleClick:i.onMiddleClick,onHover:i.onHover,extra:i.extra}:null})},[i,e]),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,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})})})})},na=()=>{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},oa=({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,y]=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=bn.decode(new Uint8Array(P)),_=v.formations;if(v.mode==Fo.FACE){y(!0),T(v.name);const b=[];_.forEach((E,L)=>{const I={name:E.name,topUrl:E.url,bottomUrl:_[L+1]?_[L+1].url:void 0};b.push(I)}),p(b)}else{y(!1),T(v.name);const b=[];_.forEach(E=>{const L={name:E.name,topUrl:E.url};b.push(L)}),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(Yn,{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(Jn,{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 jr(){return{name:"",slices:[],center:void 0}}const Uo={encode(e,t=se.Writer.create()){e.name!==""&&t.uint32(10).string(e.name);for(const n of e.slices)fn.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=jr();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(fn.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:Fn(e.name)?globalThis.String(e.name):"",slices:globalThis.Array.isArray(e==null?void 0:e.slices)?e.slices.map(t=>fn.fromJSON(t)):[],center:Fn(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=>fn.toJSON(a))),e.center!==void 0&&(t.center=K.toJSON(e.center)),t},create(e){return Uo.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=jr();return t.name=(n=e.name)!=null?n:"",t.slices=((a=e.slices)==null?void 0:a.map(r=>fn.fromPartial(r)))||[],t.center=e.center!==void 0&&e.center!==null?K.fromPartial(e.center):void 0,t}};function ei(){return{name:"",colorId:0,vertices:[],indices:[],edges:[]}}const fn={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=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!==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:Fn(e.name)?globalThis.String(e.name):"",colorId:Fn(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 fn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=ei();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 Fn(e){return e!=null}const Mu=(e,t)=>{var x,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:y,position:h,normals:T,material:P={type:$e.COLOR_ID},children:v,alpha:_=1,style:b,name:E="formation",highStyle:L,lowStyle:I,edges:S=[],actions:k,actionName:B}=e,F=He({url:P==null?void 0:P.texture,cacheType:Me.URL_PREFIX_MATCH}),w=He({url:P==null?void 0:P.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),[D,N]=m.useState();m.useImperativeHandle(t,()=>r.current,[]),m.useEffect(()=>{if(a&&a.current&&n){const U=new u.VertexData;U.positions=f,U.indices=d,U.normals=T;const re=a.current;U.applyToMesh(re),re.getScene().onAfterRenderObservable.addOnce(()=>{if(!re.isDisposed()){const G=re.getBoundingInfo();N(G.boundingBox)}})}},[d,f,n,c,T]),m.useEffect(()=>{a.current&&(a.current.metadata={pickable:k?{name:B!=null?B:E,onLeftClick:k.onLeftClick,onRightClick:k.onRightClick,onMiddleClick:k.onMiddleClick,onHover:k.onHover,extra:k.extra,needWorldPosition:k.needWorldPosition}:null})},[B,k,E]),m.useEffect(()=>{var U;s(P.type===$e.ONE_COLOR?(U=P==null?void 0:P.color)!=null?U:u.Color3.Random():y&&i.colorIDs[y]?new u.Color3(i.colorIDs[y].r,i.colorIDs[y].g,i.colorIDs[y].b):u.Color3.Random())},[i.colorIDs,y,P==null?void 0:P.color,P.type]);const M=(U,re,oe)=>{const G=re.subtract(U),ae=1+1e3/u.Vector3.Distance(U,re)*(oe-1),ne=G.scale(ae);return U.add(ne)};return C.jsxs("transformNode",{name:`node-${E}-${c}`,setEnabled:p,children:[C.jsxs("transformNode",{name:`${E}`,position:h?h.multiply(Oe(o)):new u.Vector3(0,0,0),scaling:Oe(o),ref:r,children:[C.jsx("mesh",{name:`${E}-mesh`,ref:a,children:P.type===$e.TEXTURE?F?C.jsx(qt,{name:`formationslice-${E}-mat`,backFaceCulling:!1,needDepthPrePass:P.needDepthPrePass===void 0?!1:P.needDepthPrePass,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,alpha:_,sideTexture:w,texture:F,tilingFactor:P.tilingFactor,sideTilingFactor:(x=P==null?void 0:P.sideTilingFactor)!=null?x:P==null?void 0:P.tilingFactor,mode:P.textureMode===void 0?Xt.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-${E}-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-${E}-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-${E}-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:`${E}-title`,position:M(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"})}),I&&I.position&&C.jsx("transformNode",{name:`${E}-up-title`,position:M(At(I.basePosition==="left"?S[4]:S[5]),I.position,(V=I.offset)!=null?V:1),scaling:ct(o),children:I.title&&C.jsx(Je,{text:I.title,fontSize:I.fontSize?I.fontSize:40,color:I.color?I.color:"black"})}),L&&L.position&&C.jsx("transformNode",{name:`${E}-down-title`,position:M(At(L.basePosition==="left"?S[4]:S[5]),L.position,($=L.offset)!=null?$:1),scaling:ct(o),children:L.title&&C.jsx(Je,{text:L.title,fontSize:L.fontSize?L.fontSize:40,color:L.color?L.color:"black"})})]}),v]})},Lu=m.forwardRef(Mu),Wo=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,y=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=Uo.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 E=[];return u.VertexData.ComputeNormals(b.vertices,b.indices,E),{name:b.name,colorId:b.colorId,vertices:b.vertices,indices:b.indices,edges:b.edges,normals:E}});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(y)),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),E=v.edges.length>0?At(d==="left"?v.edges[1]:v.edges[3]):new u.Vector3(0,0,0),L=u.Vector3.Lerp(b,E,.5);return C.jsx(Lu,{id:_,vertices:v.vertices,indices:v.indices,colorId:v.colorId,normals:v.normals,name:v.name,edges:v.edges,style:c?{position:L,title:v.name,basePosition:d,...c}:{},lowStyle:f?{position:E,title:(T.y+E.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},_)})})})},Ru=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 ra=({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,y]=m.useState(null),[h,T]=m.useState(null),[P,v]=m.useState(n),[_,b]=m.useState(a),[,E]=m.useState(null),L=m.useCallback(F=>{T(F)},[]),{setViewCamera:I}=m.useContext(Eo),S=m.useCallback(()=>{if(h&&d){const F=new u.Vector3;F.addInPlace(h.position),F.addInPlace(h.getDirection(new u.Vector3(0,0,25))),l==4?(F.addInPlace(h.getDirection(new u.Vector3(0,7+r.y,0))),F.addInPlace(h.getDirection(new u.Vector3(15+r.x,0,0)))):l==3?(F.addInPlace(h.getDirection(new u.Vector3(0,7+r.y,0))),F.addInPlace(h.getDirection(new u.Vector3(-15+r.x,0,0)))):l==2?(F.addInPlace(h.getDirection(new u.Vector3(0,-7+r.y,0))),F.addInPlace(h.getDirection(new u.Vector3(15+r.x,0,0)))):l==1&&(F.addInPlace(h.getDirection(new u.Vector3(0,-7+r.y,0))),F.addInPlace(h.getDirection(new u.Vector3(-15+r.x,0,0)))),d.xAxis.position=F.clone(),d.yAxis.position=F.clone(),d.zAxis.position=F.clone()}},[h,d,l,r.y,r.x]);m.useEffect(()=>{if(p&&l!=0){const F=new u.AxesViewer(p,2,null);return y(F),()=>{F==null||F.dispose(),y(null)}}},[p,l]),m.useEffect(()=>{S()},[S]);const k=m.useCallback(F=>{if(f&&f.min&&f.max)return u.Vector3.Clamp(F,f==null?void 0:f.min,f==null?void 0:f.max)},[f]),B=m.useCallback(F=>{p&&(p.skipPointerMovePicking=F)},[p]);return m.useEffect(()=>{if(!p||!h)return;const F=h.onViewMatrixChangedObservable.add(()=>{c&&(B(!0),E(w=>(w&&clearTimeout(w),setTimeout(()=>{B(!1),E(null)},250)))),v(h.alpha),b(h.beta),S()});return()=>{h.onViewMatrixChangedObservable.remove(F),E(w=>(w&&clearTimeout(w),null)),B(!1)}},[p,l,h,f,d,S,k,B,c]),m.useEffect(()=>{I(p&&h?h:void 0)},[p,h,I]),m.useEffect(()=>{},[k,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:L,setActiveOnSceneIfNoneActive:!0})})},Bu=(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),[y,h]=m.useState(null),{setViewCamera:T,cameraRefObject:P}=m.useContext(Eo),[,v]=m.useState(null),_=m.useRef(null),[b,E]=m.useState(null),L=m.useRef(null),I=m.useCallback(w=>{c&&(c.skipPointerMovePicking=w)},[c]);m.useEffect(()=>(L.current=new u.ArcRotateCamera("dummy-camera",0,0,.1,u.Vector3.Zero(),c||void 0,!1),()=>{var w;(w=L.current)==null||w.dispose()}),[c]),m.useEffect(()=>{if(c){const w=y,D=c.onPointerObservable.add(N=>{if(N.type===u.PointerEventTypes.POINTERDOWN&&(_.current=new u.Vector2(N.event.clientX,N.event.clientY)),N.type===u.PointerEventTypes.POINTERUP&&(_.current=null),N.type===u.PointerEventTypes.POINTERMOVE&&_.current){const M=N.event.clientX-_.current.x,x=N.event.clientY-_.current.y;if(N.event.buttons===1){let A=null;(w.lockedTarget||b)&&(w.lockedTarget&&(A=w.lockedTarget.position),b&&(A=b)),A&&L.current?(L.current.target=A,L.current.position=w.position.clone(),L.current.wheelDeltaPercentage=i,L.current.panningSensibility=s,L.current.alpha+=M/100*l,L.current.beta+=x/100*l,L.current.update(),w.position=L.current.position.clone(),w.rotation=L.current.rotation.clone()):(w.rotation.y-=M/100*l,w.rotation.x-=x/100*l)}N.event.buttons===2&&(w.position.x-=M/100*s,w.position.y+=x/100*s),_.current=new u.Vector2(N.event.clientX,N.event.clientY)}});return()=>{c.onPointerObservable.remove(D)}}},[b,s,y,l,c,i]);const S=m.useCallback(w=>{w&&(w.inputs.addMouseWheel(),w.inputs.removeMouse(),T(w),h(w))},[T]);m.useEffect(()=>{if(y){const w=y.inputs.attached.mousewheel;w.wheelPrecisionX=i,w.wheelPrecisionY=i,w.wheelPrecisionZ=i}},[y,i]);const k=m.useCallback(()=>{if(y&&f){const w=new u.Vector3;w.addInPlace(y.position),w.addInPlace(y.getDirection(new u.Vector3(0,0,25))),a==Bt.TOP_RIGHT?(w.addInPlace(y.getDirection(new u.Vector3(0,7+r.y,0))),w.addInPlace(y.getDirection(new u.Vector3(15+r.x,0,0)))):a==Bt.TOP_LEFT?(w.addInPlace(y.getDirection(new u.Vector3(0,7+r.y,0))),w.addInPlace(y.getDirection(new u.Vector3(-15+r.x,0,0)))):a==Bt.BOTTOM_RIGHT?(w.addInPlace(y.getDirection(new u.Vector3(0,-7+r.y,0))),w.addInPlace(y.getDirection(new u.Vector3(15+r.x,0,0)))):a==Bt.BOTTOM_LEFT&&(w.addInPlace(y.getDirection(new u.Vector3(0,-7+r.y,0))),w.addInPlace(y.getDirection(new u.Vector3(-15+r.x,0,0)))),f.xAxis.position=w.clone(),f.yAxis.position=w.clone(),f.zAxis.position=w.clone()}},[y,f,a,r.y,r.x]);m.useEffect(()=>{if(c&&a!=Bt.NONE){const w=new u.AxesViewer(c,2,null);return d(w),()=>{w==null||w.dispose(),d(null)}}},[c,a]),m.useEffect(()=>{k()},[k]),m.useEffect(()=>{T(c&&y?y:void 0)},[c,y,T]),m.useEffect(()=>{if(!c||!y)return;const w=y.onViewMatrixChangedObservable.add(()=>{o&&(I(!0),v(D=>(D&&clearTimeout(D),setTimeout(()=>{I(!1),v(null)},250)))),k()});return()=>{y.onViewMatrixChangedObservable.remove(w),v(D=>(D&&clearTimeout(D),null)),I(!1)}},[c,a,y,p,f,k,o,I]);const[B,F]=m.useState();return m.useEffect(()=>{if(y){const w={lookAt:D=>{y&&y.setTarget(D)},updatePosition:D=>{y&&(y.position=D)},lockTarget:D=>{y&&(E(null),y.lockedTarget=D)},lockTo:D=>{y&&(y.lockedTarget=null,E(D))}};F(w),P&&P.current&&(P.current.rawCamera=y,P.current.cameraTools=w)}},[P,y]),m.useImperativeHandle(t,()=>({rawCamera:y,cameraTools:B}),[B,y]),C.jsx("universalCamera",{name:"universal-main-camera",position:n,ref:S,maxZ:0})},Fu=m.forwardRef(Bu);class Du 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 zu=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 Du,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 Vu 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 $u=()=>{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
|
|
|
@@ -1219,12 +1219,12 @@ void main(void)
|
|
|
1219
1219
|
{
|
|
1220
1220
|
vec4 depth = texture2D(textureSampler, vUV);
|
|
1221
1221
|
gl_FragColor = vec4(depth.r, depth.r, depth.r, 1.0);
|
|
1222
|
-
}`,
|
|
1222
|
+
}`,u.Effect.ShadersStore.depthbufferFragmentShader=`#ifdef GL_ES
|
|
1223
1223
|
precision highp float;
|
|
1224
1224
|
#endif
|
|
1225
1225
|
|
|
1226
1226
|
void main(void)
|
|
1227
|
-
{}`;const n=new
|
|
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 Vu("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 Uu 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 Wu=()=>{const e=_e.useEngine(),t=_e.useScene(),n=m.useContext(Ii);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
|
|
|
@@ -1235,14 +1235,14 @@ void main(void)
|
|
|
1235
1235
|
{
|
|
1236
1236
|
vec4 picking = texture2D(textureSampler, vUV);
|
|
1237
1237
|
gl_FragColor = picking;
|
|
1238
|
-
}`,
|
|
1238
|
+
}`,u.Effect.ShadersStore.gpuPickingBufferFragmentShader=`#ifdef GL_ES
|
|
1239
1239
|
precision highp float;
|
|
1240
1240
|
#endif
|
|
1241
1241
|
|
|
1242
1242
|
void main(void)
|
|
1243
|
-
{}`;const a=new
|
|
1244
|
-
%c Geo3DViewer Library %c Version: 1.7.
|
|
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:u,camera:null}),[u]),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(Zu,{}),C.jsx("ground",{name:"picking-material-holder",setEnabled:!1,children:C.jsx(mu,{})}),C.jsx(ia.Provider,{value:new Gu,children:C.jsxs(xs,{workspaceMeta:r,colorProvider:o,cacheProvider:i,ref:u,children:[d||a?C.jsx(Hu,{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,{})]})})},Ho=m.forwardRef(Ju);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 Xu(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 qu(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 ti(){return{name:"",step:0,xCount:0,yCount:0,zCount:0,xSliceUrl:"",ySliceUrl:"",zSliceUrl:"",mode:0}}const aa={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=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!==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)?Xu(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=qu(e.mode)),t},create(e){return aa.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,l,s,c,p;const t=ti();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 sa=({name:e,url:t,step:n,visible:a=!0,colorCodec:r,alpha:o=1,actions:i,materials:l})=>{const[s,c]=m.useState(),[p,u]=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=aa.decode(new Uint8Array(d)),{xCount:h,zCount:T,xSliceUrl:P,zSliceUrl:y}=x,_=[];if(x.mode===Et.ATTRIBUTE||x.mode===Et.COLOR){if(n<=0){console.error("[Geo3DViewer] 此文件为动态数据文件,step 值必须大于 0"),c([]),u(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(y.replace("%s",k.toString())),b=k;b>=T&&_.push(y.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([]),u(0);return}for(let b=0;b<h;b+=1)_.push(P.replace("%s",b.toString()))}return c(_),u(x.mode===Et.ATTRIBUTE?1:x.mode===Et.COLOR?2:x.mode===Et.STATIC_ATTRIBUTE?1:x.mode===Et.STATIC_COLOR?2:0),()=>{c([]),u(0)}}},[d,n]),C.jsx("abstractMesh",{name:`gridDiagram-${e}`,children:p===1?s?s.map((x,h)=>C.jsx($o,{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(Wo,{url:x,visible:a,materials:l,actions:i},`formationslice-group-${e}-${x}-${h}`)):C.jsx(C.Fragment,{}):C.jsx(C.Fragment,{})})},la=({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=vu({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||f.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:f.Color3.Gray(),backFaceCulling:!1,alpha:.5,transparencyMode:f.Material.MATERIAL_ALPHABLEND})})]})},ca=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 f.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 f.ArcRotateCamera){r.setTarget(o),r.radius=a;return}if(r instanceof f.FreeCamera){const i=o,l=r.position.clone(),s=a/f.Vector3.Distance(i,l),p=l.subtract(i).scale(s),u=i.add(p);r.position=u,r.setTarget(o)}return}},[a,t,n]),null},ua=e=>{const t=e.getChildren();return t.length>0?[e,...ua(t[0])]:[e]},Ku=({name:e,url:t,position:n=f.Vector3.Zero(),rotation:a=f.Vector3.Zero(),localScale:r=1,visible:o=!0,showPickingBox:i=!1,useGlobalScale:l=!1,actions:s,alpha:c=1,boneRotation:p,pickingBoxScale:u=f.Vector3.One(),labelStyle:d},x)=>{const h=_e.useScene(),T=Oi({url:t}),P=m.useRef(null),y=m.useRef(null),[_,b]=m.useState(null),[k,L]=m.useState(5),[I,S]=m.useState(5),[E,B]=m.useState(5),[F,w]=m.useState(f.Vector3.Zero()),[D,N]=m.useState(f.Vector3.One()),[M,v]=m.useState([]),A=m.useContext(Le),{scaleWithParent:V=!0}=d||{};return m.useEffect(()=>{console.log("[Geo3DViewer] ModelLoader Loading: ",t)},[t]),m.useImperativeHandle(x,()=>y.current,[]),m.useEffect(()=>{if(T){const $=T.instantiateModelsToScene(U=>`${e}-${U}`,!0);return console.log("[Geo3DViewer] ModelLoader 实例化: ",e),b($),()=>{console.log("[Geo3DViewer] ModelLoader 反实例化: ",e),b(null)}}},[T,e]),m.useEffect(()=>{if(_){const $=_,U=$.skeletons;if(U&&U.length>0){const ne=U[0].bones,G=[];ne.filter(ae=>ae.name==="MorphBoneBase").forEach((ae,oe)=>{if(oe===0){const j=ua(ae);G.push(...j.map(Y=>{var ce;return(ce=Y.getTransformNode())!=null?ce:Y}))}}),v(G),console.log("[Geo3DViewer] ModelLoader 设定 Morph 骨骼: ",G)}return()=>{console.log("[Geo3DViewer] ModelLoader 注销 Model"),$.dispose(),v([])}}},[_]),m.useEffect(()=>{p&&M&&(console.log("[Geo3DViewer] ModelLoader 设定骨骼旋转"),M.forEach(($,U)=>{p.length>U?$.rotation=p[U]:$.rotation=f.Vector3.Zero()}),(!p||p.length===0)&&console.log("[Geo3DViewer] ModelLoader 的鼠标拾取功能由于 boneRotation 被禁用"))},[p,M]),m.useEffect(()=>{P.current&&(P.current.metadata={pickable:s?{name:e,onLeftClick:s.onLeftClick,onRightClick:s.onRightClick,onMiddleClick:s.onMiddleClick,onHover:s.onHover,valueCallback:null,extra:s.extra}:null})},[s,e]),m.useEffect(()=>{if(h&&_&&y.current){console.log("[Geo3DViewer] ModelLoader 创建容器: ",e);const $=new f.TransformNode(`amesh-model-${e}`);$.parent=y.current,_.rootNodes.forEach(j=>{j&&(j.parent=$)}),$.computeWorldMatrix(!0),f.PivotTools._RemoveAndStorePivotPoint($);const U=$.parent;$.parent=null;const ie=f.Quaternion.RotationYawPitchRoll($.rotation.y,$.rotation.x,$.rotation.z),ne=new f.Vector3($.position.x,$.position.y,$.position.z);$.rotation.set(0,0,0),$.position.set(0,0,0);const G=$.getHierarchyBoundingVectors(!0),ae=G.max.subtract(G.min);L(ae.y),S(ae.z),B(ae.x),N(ie.toEulerAngles());const oe=new f.Vector3((G.max.x+G.min.x)/2,(G.max.y+G.min.y)/2,(G.max.z+G.min.z)/2);return w(oe),$.position=ne,$.rotationQuaternion=ie,$.parent=U,f.PivotTools._RestorePivotPoint($),console.log("[Geo3DViewer] 创建 ModelLoader 鼠标拾取外框 ",e," 于 ",oe," 大小为 ",ae.x,ae.y,ae.z),()=>{console.log("[Geo3DViewer] ModelLoader 注销容器: ",e),$.dispose()}}},[_,e,h]),m.useEffect(()=>{_&&_.rootNodes.forEach($=>{$.getChildMeshes().forEach(U=>{U.material&&(U.material.transparencyMode=f.Material.MATERIAL_ALPHABLEND,U.material.alpha=c)})})},[_,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:y,scaling:l?new f.Vector3(A&&A.scalePlane?A.scalePlane:1,A&&A.scaleDepth?A.scaleDepth:1,A&&A.scalePlane?A.scalePlane:1):new f.Vector3(1,1,1),children:[d?C.jsx("transformNode",{name:`transform-model-label-${e}`,position:F.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):f.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 f.Vector3(E,k,I).multiply(u),position:F,rotation:D,setEnabled:p?p.length===0:!0,children:C.jsx("standardMaterial",{name:`pick-mesh-${e}-mat`,alpha:i?.5:0})})]})})},Xn=m.forwardRef(Ku),Qu=({name:e,url:t,position:n=f.Vector3.Zero(),rotation:a=f.Vector3.Zero(),localScale:r=1,visible:o=!0},i)=>{const l=_e.useScene(),s=Oi({url:t}),c=m.useRef(null),[p,u]=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),u(d),()=>{console.log("[Geo3DViewer] ModelLoader 反实例化: ",e),u(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})},ju=m.forwardRef(Qu),fa=()=>{const e=_e.useScene();return m.useEffect(()=>{if(e){const t=f.SceneOptimizerOptions.ModerateDegradationAllowed();t.optimizations;const n=new f.SceneOptimizer(e,t,!0,!0);return n.start(),console.log("[Geo3DViewer] 渐进式优化器已启动,如遭遇技术性渲染问题,请优先尝试禁用此优化器。"),()=>{n.stop(),n.dispose(),console.log("[Geo3DViewer] 渐进式优化器已停止。")}}},[e]),C.jsx(C.Fragment,{})},ef=e=>{const{name:t,url:n,rootURL:a,doNotStart:r,capacity:o,position:i=new f.Vector3}=e,l=_e.useScene(),[s,c]=m.useState();return m.useEffect(()=>()=>{s&&s.dispose()},[s]),m.useEffect(()=>{if(l&&!s){const p=new f.AssetsManager(l),u=p.addTextFileTask(t!=null?t:"particle-system",n);p.load(),p.onFinish=function(d){console.log("task successful",d);const x=JSON.parse(u.text),h=f.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},tf=e=>{const{id:t,position:n,useGPU:a=!0,renderAsFluid:r,numParticles:o=1e3,emitRate:i=1500*2,blendMode:l=f.ParticleSystem.BLENDMODE_ADD,color1:s,color2:c,colorDead:p,minSize:u,maxSize:d,minLifeTime:x,maxLifeTime:h,gravity:T,minEmitPower:P,maxEmitPower:y,updateSpeed:_,textureUrl:b,angle:k=Math.PI/2,radius:L=4,fluidRender:I}=e,S=_e.useScene(),[E,B]=m.useState(),F=m.useRef(null);return m.useEffect(()=>{E&&(E.blendMode=l,s&&(E.color1=s),c&&(E.color2=c),p&&(E.colorDead=p),u!==void 0&&(E.minSize=u),d!==void 0&&(E.maxSize=d),x!==void 0&&(E.minLifeTime=x),h!==void 0&&(E.maxLifeTime=h),P!==void 0&&(E.minEmitPower=P),y!==void 0&&(E.maxEmitPower=y),_!==void 0&&(E.updateSpeed=_),E.preWarmCycles=60*8,T&&(E.gravity=T),E.createConeEmitter(L,k),b&&(E.particleTexture=new f.Texture(b),E.particleTexture.onLoadObservable.add(()=>{E.start()})))},[k,l,s,c,p,T,y,h,d,P,x,u,E,L,b,_]),m.useEffect(()=>{if(!E&&S)if(a){const w=new f.GPUParticleSystem("particle-"+t,{capacity:o},S);B(w)}else{const w=new f.ParticleSystem("particle-"+t,o,S);B(w)}return()=>{console.log("particlesystem disposed!"),F.current&&(F.current.object.particleSize=0)}},[t,o,E,S,a]),m.useEffect(()=>{E&&(S==null||S.executeWhenReady(()=>{var w,D,N;if(S.updateTransformMatrix(!0),E==null||E.render(),r&&E){const M=S.enableFluidRenderer();if(M){M.addParticleSystem(E);const v=M.getRenderObjectFromParticleSystem(E);F.current=v,v&&(v.object.particleSize=(w=I==null?void 0:I.particleSize)!=null?w:.75,v.object.particleThicknessAlpha=.02,v.object.useTrueRenderingForDiffuseTexture=!0,v.targetRenderer.minimumThickness=v.object.particleThicknessAlpha,v.targetRenderer.blurDepthFilterSize=10,v.targetRenderer.blurDepthDepthScale=10,v.targetRenderer.thicknessMapSize=1024,v.targetRenderer.density=(D=I==null?void 0:I.density)!=null?D:8,v.targetRenderer.fresnelClamp=.04,v.targetRenderer.fluidColor=(N=I==null?void 0:I.fluidColor)!=null?N:new f.Color3(219/255,228/255,1),v.targetRenderer.generateDiffuseTexture=!1)}}}))},[I==null?void 0:I.density,I==null?void 0:I.fluidColor,I==null?void 0:I.particleSize,E,r,S]),m.useEffect(()=>{E&&(E.emitter=n,E.emitRate=i)},[i,E,n]),null},nf=(e,t)=>{var I,S,E;const n=_e.useScene(),a=m.useContext(Le),{name:r,width:o,height:i,localScale:l=f.Vector3.One(),rotation:s=f.Vector3.Zero(),position:c=f.Vector3.Zero(),textureUrl:p,videoUrl:u,canvas:d,backFaceCulling:x=!0,billboard:h=!1,actions:T,labelStyle:P}=e,y=He({url:p}),_=m.useRef(null),b=m.useRef(null),[k,L]=m.useState(null);return m.useEffect(()=>{if(u)return L(B=>{B==null||B.dispose();const F=new f.VideoTexture("video-texture",u,n,!1,!1,void 0,{autoPlay:!0,autoUpdateTexture:!0});return F.hasAlpha=!0,F}),()=>{L(B=>(B==null||B.dispose(),null))}},[u]),m.useEffect(()=>{if(d){const B=new f.DynamicTexture("dyn-texture",d,n);return B.hasAlpha=!0,_.current=B,()=>{var F;(F=_.current)==null||F.dispose()}}},[d]),m.useEffect(()=>{_.current&&(_.current.name=r)},[r]),m.useImperativeHandle(t,()=>_,[_]),m.useEffect(()=>{var F;const B=(F=b.current)==null?void 0:F.getChildMeshes()[0];B&&(B.metadata={pickable:T?{name:r,onLeftClick:T.onLeftClick,onRightClick:T.onRightClick,onMiddleClick:T.onMiddleClick,onHover:T.onHover,extra:T.extra}:null})},[T,r]),C.jsxs("transformNode",{ref:b,name:`transform-planeimage-${r}`,position:c.multiply(a?new f.Vector3((I=a.scalePlane)!=null?I:1,(S=a.scaleDepth)!=null?S:1,(E=a.scalePlane)!=null?E:1):f.Vector3.One()),rotation:h?f.Vector3.Zero():s,billboardMode:h?f.Mesh.BILLBOARDMODE_ALL:f.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:f.Color3.White(),specularColor:f.Color3.Black(),diffuseTexture:_.current?_.current:k||y,useAlphaFromDiffuseTexture:!0,backFaceCulling:x,transparencyMode:f.Material.MATERIAL_ALPHABLEND})}),P&&C.jsx(Je,{...P})]})},da=m.forwardRef(nf);var pa=(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))(pa||{});const ha=({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),u=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,extra:i.extra}:null})},[i,o]);const[d,x]=m.useState(1);return m.useEffect(()=>{switch(c){case It.PLANE:x(u&&u.scalePlane?u.scalePlane:1);break;case It.DEPTH:x(u&&u.scaleDepth?u.scaleDepth:1);break;case It.NONE:x(1);break}},[u,c]),C.jsxs("transformNode",{setEnabled:a,name:`transform-spaceheat-${o}`,position:n.multiplyByFloats(u&&u.scalePlane?u.scalePlane:1,u&&u.scaleDepth?u.scaleDepth:1,u&&u.scalePlane?u.scalePlane:1),scalingDeterminant:d,children:[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 f.Color3(0,0,0),ambientColor:new f.Color3(1,1,1),emissiveColor:f.Color3.Black(),alphaMode:f.Engine.ALPHA_COMBINE,diffuseColor:s,alpha:t})}),C.jsx("transformNode",{name:`${o}-title`,position:l!=null&&l.offset?l.offset.multiplyByFloats(u!=null&&u.scalePlane?u==null?void 0:u.scalePlane:1,1,u!=null&&u.scalePlane?u==null?void 0:u.scalePlane:1):f.Vector3.Zero(),scaling:ct(u).multiply(new f.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"})})]})},ma=({name:e,url:t,offset:n=f.Vector3.Zero(),alpha:a,color:r,visible:o=!0,cutNormal:i,value:l,actions:s,textureOverride:c,progressTexture:p={},counterLine:u=void 0,lines:d=[],text:x=[],disableDepthWrite:h=!1,checkLines:T=[],checkLineWidth:P=4})=>{var oe,j,Y,ce,le,X,Pe,ge,H,Q,Ee,be,ee,he,ue,me,Ie,ke,Ae;const y=_e.useScene(),_=m.useRef(null),b=m.useContext(Le),k=je({url:t,cacheType:Me.URL_PREFIX_MATCH}),[L,I]=m.useState(f.Vector3.Zero()),[S,E]=m.useState(void 0),B=He({url:c==null?void 0:c.texture,cacheType:Me.URL_PREFIX_MATCH}),F=He({url:c==null?void 0:c.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),w=He({url:(oe=p.segment1)==null?void 0:oe.texture,cacheType:Me.URL_PREFIX_MATCH}),D=He({url:(j=p.segment1)==null?void 0:j.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),N=He({url:(Y=p.segment2)==null?void 0:Y.texture,cacheType:Me.URL_PREFIX_MATCH}),M=He({url:(ce=p.segment2)==null?void 0:ce.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),v=He({url:(le=p.segment3)==null?void 0:le.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}),U=He({url:(H=p.segment5)==null?void 0:H.texture,cacheType:Me.URL_PREFIX_MATCH}),ie=He({url:(Q=p.segment5)==null?void 0:Q.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),ne=He({url:(Ee=p.segment6)==null?void 0:Ee.texture,cacheType:Me.URL_PREFIX_MATCH}),G=He({url:(be=p.segment6)==null?void 0:be.sideTexture,cacheType:Me.URL_PREFIX_MATCH});m.useEffect(()=>{console.log("[Geo3DViewer] ProgressedAttributeBody Loading: ",t)},[t]),m.useEffect(()=>{if(y&&_.current&&t&&k){const Ne=_.current;f.Tags.EnableFor(Ne),f.Tags.AddTagsTo(Ne,"loading");const we=Bo.decode(new Uint8Array(k)),{points:Re,indices:Ve,value:We,center:Be}=we;Be&&I(new f.Vector3(Be.x,Be.y,Be.z));const Ge=new f.VertexData;Ge.positions=Re,Ge.indices=Ve,Ge.colors=We;const Ke=[];f.VertexData.ComputeNormals(Re,Ve,Ke),Ge.normals=Ke,Ne&&(Ge.applyToMesh(Ne),Ne.getScene().onAfterRenderObservable.addOnce(()=>{if(!Ne.isDisposed()){const fe=Ne.getBoundingInfo();E(fe.boundingBox)}})),f.Tags.RemoveTagsFrom(Ne,"loading")}},[t,y,k]);function ae(Ne,we,Re){const Ve=Re.subtract(we),We=Ne.subtract(we),Be=f.Vector3.Dot(f.Vector3.Normalize(Ve),f.Vector3.Normalize(We)),Ge=We.length()/Be,Ke=we.add(Ve.scale(Ge/f.Vector3.Distance(we,Re)));return f.Vector3.Distance(Ne,Ke)}return m.useEffect(()=>{_.current&&(_.current.metadata={pickable:s?{name:e,valueCallback:(Ne,we,Re)=>{if(console.log(e,Ne,we,Re),_.current&&we){const Ve=_.current.getBoundingInfo().boundingBox;console.log(Ve);for(let We=0;We<T.length;We++){const Be=T[We];if(ae(new f.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),pe=Be.start.add(fe.scale(z/10)),xe=new f.Vector3(pe.x,we.y+Ve.extendSize.y*4,pe.z),Z=new f.Vector3(pe.x,we.y+Ve.extendSize.y*2,pe.z),re=f.Vector3.Normalize(Z.subtract(xe)),O=Ve.extendSize.y*10,de=new f.Ray(xe,re,O),Se=y==null?void 0:y.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),pe=Be.start.add(fe.scale(z/10)),xe=new f.Vector3(pe.x,we.y-Ve.extendSize.y*4,pe.z),Z=new f.Vector3(pe.x,we.y-Ve.extendSize.y*2,pe.z),re=f.Vector3.Normalize(Z.subtract(xe)),O=Ve.extendSize.y*10,de=new f.Ray(xe,re,O),Se=y==null?void 0:y.pickWithRay(de,g=>g===_.current);Se!=null&&Se.hit&&Se.pickedPoint&&Ke.push(Se.pickedPoint)}return{value:We,points:Ke}}}}},onLeftClick:s.onLeftClick,onRightClick:s.onRightClick,onMiddleClick:s.onMiddleClick,onHover:s.onHover,extra:s.extra}:null})},[s,e,T]),C.jsx(C.Fragment,{children:C.jsx("transformNode",{name:`transform-progressedattribute-${e}`,position:L.add(n).multiplyByFloats(b&&b.scalePlane?b.scalePlane:1,b&&b.scaleDepth?b.scaleDepth:1,b&&b.scalePlane?b.scalePlane:1),scaling:new f.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:!B,alwaysSelectAsActiveMesh:!0,children:S&&origin?B?C.jsx(Xi,{name:`progressedattributebody-${e}-mat`,backFaceCulling:!0,needDepthPrePass:!1,transparencyMode:f.Material.MATERIAL_ALPHABLEND,alphaMode:f.Engine.ALPHA_COMBINE,texture:B,sideTexture:F,alphaStage:a,cutNormal:i,value:l,boundingBox:S,tilingFactor:c==null?void 0:c.tilingFactor,textureFlatRotate:c==null?void 0:c.flatModeRotate,sideTilingFactor:(ee=c==null?void 0:c.sideTilingFactor)!=null?ee:c==null?void 0:c.tilingFactor,mode:c==null?void 0:c.mode,overlay:{texture1:w,sideTexture1:D,texture2:N,sideTexture2:M,texture3:v,sideTexture3:A,texture4:V,sideTexture4:$,texture5:U,sideTexture5:ie,texture6:ne,sideTexture6:G,color1:(he=p.segment1)==null?void 0:he.color,color2:(ue=p.segment2)==null?void 0:ue.color,color3:(me=p.segment3)==null?void 0:me.color,color4:(Ie=p.segment4)==null?void 0:Ie.color,color5:(ke=p.segment5)==null?void 0:ke.color,color6:(Ae=p.segment6)==null?void 0:Ae.color},scaleDepth:b?b.scaleDepth:1,scalePlane:b?b.scalePlane:1,counterLine:u,lines:d,text:x,disableDepthWrite:h}):r?C.jsx(Ji,{name:`progressedattributebody-${e}-mat`,backFaceCulling:!0,needDepthPrePass:!1,transparencyMode:f.Material.MATERIAL_ALPHABLEND,alphaMode:f.Engine.ALPHA_COMBINE,colorCodec:r,alphaStage:a,cutNormal:i,value:l,boundingBox:S,scaleDepth:b?b.scaleDepth:1,scalePlane:b?b.scalePlane:1,counterLine:u,lines:d,text:x,disableDepthWrite:h}):C.jsx(C.Fragment,{}):C.jsx(C.Fragment,{})})})})},ga=({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 f.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 xi.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]),u=m.useCallback(d=>{switch(d.type){case f.PointerEventTypes.POINTERUP:{t?p():c();break}}},[t,p,c]);return m.useEffect(()=>{if(n){const d=n.onPointerObservable.add(u);return()=>{n.onPointerObservable.remove(d)}}},[u,n]),m.useEffect(()=>()=>{var d;(d=r.current)==null||d.dispose(),r.current=null,o.current=[],i.current=!1},[]),C.jsx(C.Fragment,{})},va=({name:e,paths:t,color:n,alpha:a,sideOrientation:r=Ni.CounterClockWiseSideOrientation,position:o=f.Vector3.Zero(),rotation:i=f.Vector3.Zero(),scaling:l=f.Vector3.One(),backFaceCulling:s=!1,labelStyle:c,showLayerLabel:p=!1,actions:u})=>{const d=m.useContext(Le),x=Oe(d),h=m.useRef(null),[T,P]=m.useState();return m.useEffect(()=>{if(h.current){const y=h.current.getBoundingInfo();P(y.boundingBox.centerWorld)}},[t,o,i,l]),m.useEffect(()=>{h.current&&(h.current.metadata={pickable:u?{name:e,onLeftClick:u.onLeftClick,onRightClick:u.onRightClick,onMiddleClick:u.onMiddleClick,onHover:u.onHover,extra:u.extra}:null})},[u,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:f.Color3.Black(),ambientColor:f.Color3.White(),transparencyMode:f.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):f.Vector3.Zero()),scaling:ct(d).multiply(new f.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"})})]})},of=`#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 Uu("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,{})},Hu=({showDebugLayer:e=!1})=>{const t=_e.useScene(),n=_e.useEngine();return m.useEffect(()=>{n&&t&&(e?(n.captureGPUFrameTime=a=>{},Kn.Inspector.Show(t,{embedMode:!0})):Kn.Inspector.Hide())},[n,t,e]),m.useEffect(()=>()=>{t&&Kn.Inspector.Hide()},[t]),C.jsxs("transformNode",{name:"Debugger",children:[C.jsx($u,{}),C.jsx(Wu,{})]})},Zu=()=>{const e=_e.useScene(),t=_e.useEngine();return m.useEffect(()=>{const n=t;if(window.BABYLON&&n)return window.BABYLON.EngineStore.Instances.push(n),Ka.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 Gu{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"){Wt.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 ia=m.createContext(void 0),Yu=(e,t="BIN")=>{const n=m.useContext(ia),[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},Ju=(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,y]=m.useState(!1);return m.useEffect(()=>{console.log(`
|
|
1244
|
+
%c Geo3DViewer Library %c Version: 1.7.37 %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&&y(!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(Zu,{}),C.jsx("ground",{name:"picking-material-holder",setEnabled:!1,children:C.jsx(mu,{})}),C.jsx(ia.Provider,{value:new Gu,children:C.jsxs(xs,{workspaceMeta:r,colorProvider:o,cacheProvider:i,ref:f,children:[d||a?C.jsx(Hu,{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,{})]})})},Ho=m.forwardRef(Ju);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 Xu(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 qu(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 ti(){return{name:"",step:0,xCount:0,yCount:0,zCount:0,xSliceUrl:"",ySliceUrl:"",zSliceUrl:"",mode:0}}const aa={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=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!==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)?Xu(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=qu(e.mode)),t},create(e){return aa.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,l,s,c,p;const t=ti();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 sa=({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 y=aa.decode(new Uint8Array(d)),{xCount:h,zCount:T,xSliceUrl:P,zSliceUrl:v}=y,_=[];if(y.mode===Et.ATTRIBUTE||y.mode===Et.COLOR){if(n<=0){console.error("[Geo3DViewer] 此文件为动态数据文件,step 值必须大于 0"),c([]),f(0);return}let b=0;for(let E=0;E<h;E+=n)_.push(P.replace("%s",E.toString())),b=E;b>=h&&_.push(P.replace("%s",(h-1).toString()));for(let E=0;E<T;E+=n)_.push(v.replace("%s",E.toString())),b=E;b>=T&&_.push(v.replace("%s",(T-1).toString()))}else if(y.mode===Et.STATIC_ATTRIBUTE||y.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(y.mode===Et.ATTRIBUTE?1:y.mode===Et.COLOR?2:y.mode===Et.STATIC_ATTRIBUTE?1:y.mode===Et.STATIC_COLOR?2:0),()=>{c([]),f(0)}}},[d,n]),C.jsx("abstractMesh",{name:`gridDiagram-${e}`,children:p===1?s?s.map((y,h)=>C.jsx($o,{name:e,url:y,visible:a,colorCodec:r,alpha:o,actions:i},`densityslice-group-${e}-${y}-${h}`)):C.jsx(C.Fragment,{}):p===2?s?s.map((y,h)=>C.jsx(Wo,{url:y,visible:a,materials:l,actions:i},`formationslice-group-${e}-${y}-${h}`)):C.jsx(C.Fragment,{}):C.jsx(C.Fragment,{})})},la=({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=vu({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})})]})},ca=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},ua=e=>{const t=e.getChildren();return t.length>0?[e,...ua(t[0])]:[e]},Ku=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},Qu=({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},y)=>{const h=_e.useScene(),T=Oi({url:t}),P=m.useRef(null),v=m.useRef(null),[_,b]=m.useState(null),[E,L]=m.useState(5),[I,S]=m.useState(5),[k,B]=m.useState(5),[F,w]=m.useState(u.Vector3.Zero()),[D,N]=m.useState(u.Vector3.One()),[M,x]=m.useState([]),A=m.useContext(Le),{scaleWithParent:V=!0}=d||{};return m.useEffect(()=>{console.log("[Geo3DViewer] ModelLoader Loading: ",t)},[t]),m.useImperativeHandle(y,()=>v.current,[]),m.useEffect(()=>{if(T){const $=T.instantiateModelsToScene(U=>`${e}-${U}`,!0);return console.log("[Geo3DViewer] ModelLoader 实例化: ",e),b($),()=>{console.log("[Geo3DViewer] ModelLoader 反实例化: ",e),b(null)}}},[T,e]),m.useEffect(()=>{if(_){const $=_,U=$.skeletons;if(U&&U.length>0){const oe=U[0].bones,G=[];oe.filter(ae=>ae.name==="MorphBoneBase").forEach((ae,ne)=>{if(ne===0){const j=ua(ae);G.push(...j.map(Y=>{var ce;return(ce=Y.getTransformNode())!=null?ce:Y}))}}),x(G),console.log("[Geo3DViewer] ModelLoader 设定 Morph 骨骼: ",G)}return()=>{console.log("[Geo3DViewer] ModelLoader 注销 Model"),$.dispose(),x([])}}},[_]),m.useEffect(()=>{p&&M&&(console.log("[Geo3DViewer] ModelLoader 设定骨骼旋转"),M.forEach(($,U)=>{p.length>U?$.rotation=p[U]:$.rotation=u.Vector3.Zero()}),(!p||p.length===0)&&console.log("[Geo3DViewer] ModelLoader 的鼠标拾取功能由于 boneRotation 被禁用"))},[p,M]),m.useEffect(()=>{P.current&&(P.current.metadata={pickable:s?{name:e,onLeftClick:s.onLeftClick,onRightClick:s.onRightClick,onMiddleClick:s.onMiddleClick,onHover:s.onHover,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(j=>{j&&(j.parent=$)}),$.computeWorldMatrix(!0),u.PivotTools._RemoveAndStorePivotPoint($);const U=$.parent;$.parent=null;const re=u.Quaternion.RotationYawPitchRoll($.rotation.y,$.rotation.x,$.rotation.z),oe=new u.Vector3($.position.x,$.position.y,$.position.z);$.rotation.set(0,0,0),$.position.set(0,0,0);const G=$.getHierarchyBoundingVectors(!0),ae=G.max.subtract(G.min);L(ae.y),S(ae.z),B(ae.x),N(re.toEulerAngles());const ne=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 w(ne),$.position=oe,$.rotationQuaternion=re,$.parent=U,u.PivotTools._RestorePivotPoint($),console.log("[Geo3DViewer] 创建 ModelLoader 鼠标拾取外框 ",e," 于 ",ne," 大小为 ",ae.x,ae.y,ae.z),()=>{console.log("[Geo3DViewer] ModelLoader 注销容器: ",e),$.dispose()}}},[_,e,h]),m.useEffect(()=>{_&&_.rootNodes.forEach($=>{$.getChildMeshes().forEach(U=>{Ku(U)&&(console.warn(`[Geo3DViewer] ModelLoader disabled broken vertex alpha for ${U.name||e}`),U.hasVertexAlpha=!1),U.material&&(U.material.alpha=c,U.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:F.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(k,E,I).multiply(f),position:F,rotation:D,setEnabled:p?p.length===0:!0,children:C.jsx("standardMaterial",{name:`pick-mesh-${e}-mat`,alpha:i?.5:0})})]})})},Xn=m.forwardRef(Qu),ju=({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=Oi({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(y=>`${e}-${y}`,!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})},ef=m.forwardRef(ju),fa=()=>{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,{})},tf=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 y=JSON.parse(f.text),h=u.ParticleSystem.Parse(y,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},nf=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:y,maxLifeTime:h,gravity:T,minEmitPower:P,maxEmitPower:v,updateSpeed:_,textureUrl:b,angle:E=Math.PI/2,radius:L=4,fluidRender:I}=e,S=_e.useScene(),[k,B]=m.useState(),F=m.useRef(null);return m.useEffect(()=>{k&&(k.blendMode=l,s&&(k.color1=s),c&&(k.color2=c),p&&(k.colorDead=p),f!==void 0&&(k.minSize=f),d!==void 0&&(k.maxSize=d),y!==void 0&&(k.minLifeTime=y),h!==void 0&&(k.maxLifeTime=h),P!==void 0&&(k.minEmitPower=P),v!==void 0&&(k.maxEmitPower=v),_!==void 0&&(k.updateSpeed=_),k.preWarmCycles=60*8,T&&(k.gravity=T),k.createConeEmitter(L,E),b&&(k.particleTexture=new u.Texture(b),k.particleTexture.onLoadObservable.add(()=>{k.start()})))},[E,l,s,c,p,T,v,h,d,P,y,f,k,L,b,_]),m.useEffect(()=>{if(!k&&S)if(a){const w=new u.GPUParticleSystem("particle-"+t,{capacity:o},S);B(w)}else{const w=new u.ParticleSystem("particle-"+t,o,S);B(w)}return()=>{console.log("particlesystem disposed!"),F.current&&(F.current.object.particleSize=0)}},[t,o,k,S,a]),m.useEffect(()=>{k&&(S==null||S.executeWhenReady(()=>{var w,D,N;if(S.updateTransformMatrix(!0),k==null||k.render(),r&&k){const M=S.enableFluidRenderer();if(M){M.addParticleSystem(k);const x=M.getRenderObjectFromParticleSystem(k);F.current=x,x&&(x.object.particleSize=(w=I==null?void 0:I.particleSize)!=null?w:.75,x.object.particleThicknessAlpha=.02,x.object.useTrueRenderingForDiffuseTexture=!0,x.targetRenderer.minimumThickness=x.object.particleThicknessAlpha,x.targetRenderer.blurDepthFilterSize=10,x.targetRenderer.blurDepthDepthScale=10,x.targetRenderer.thicknessMapSize=1024,x.targetRenderer.density=(D=I==null?void 0:I.density)!=null?D:8,x.targetRenderer.fresnelClamp=.04,x.targetRenderer.fluidColor=(N=I==null?void 0:I.fluidColor)!=null?N:new u.Color3(219/255,228/255,1),x.targetRenderer.generateDiffuseTexture=!1)}}}))},[I==null?void 0:I.density,I==null?void 0:I.fluidColor,I==null?void 0:I.particleSize,k,r,S]),m.useEffect(()=>{k&&(k.emitter=n,k.emitRate=i)},[i,k,n]),null},of=(e,t)=>{var I,S,k;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:y=!0,billboard:h=!1,actions:T,labelStyle:P}=e,v=He({url:p}),_=m.useRef(null),b=m.useRef(null),[E,L]=m.useState(null);return m.useEffect(()=>{if(f)return L(B=>{B==null||B.dispose();const F=new u.VideoTexture("video-texture",f,n,!1,!1,void 0,{autoPlay:!0,autoUpdateTexture:!0});return F.hasAlpha=!0,F}),()=>{L(B=>(B==null||B.dispose(),null))}},[f]),m.useEffect(()=>{if(d){const B=new u.DynamicTexture("dyn-texture",d,n);return B.hasAlpha=!0,_.current=B,()=>{var F;(F=_.current)==null||F.dispose()}}},[d]),m.useEffect(()=>{_.current&&(_.current.name=r)},[r]),m.useImperativeHandle(t,()=>_,[_]),m.useEffect(()=>{var F;const B=(F=b.current)==null?void 0:F.getChildMeshes()[0];B&&(B.metadata={pickable:T?{name:r,onLeftClick:T.onLeftClick,onRightClick:T.onRightClick,onMiddleClick:T.onMiddleClick,onHover:T.onHover,extra:T.extra}:null})},[T,r]),C.jsxs("transformNode",{ref:b,name:`transform-planeimage-${r}`,position:c.multiply(a?new u.Vector3((I=a.scalePlane)!=null?I:1,(S=a.scaleDepth)!=null?S:1,(k=a.scalePlane)!=null?k: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:E||v,useAlphaFromDiffuseTexture:!0,backFaceCulling:y,transparencyMode:u.Material.MATERIAL_ALPHABLEND})}),P&&C.jsx(Je,{...P})]})},da=m.forwardRef(of);var pa=(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))(pa||{});const ha=({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,extra:i.extra}:null})},[i,o]);const[d,y]=m.useState(1);return m.useEffect(()=>{switch(c){case It.PLANE:y(f&&f.scalePlane?f.scalePlane:1);break;case It.DEPTH:y(f&&f.scaleDepth?f.scaleDepth:1);break;case It.NONE:y(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"})})]})},ma=({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:y=[],disableDepthWrite:h=!1,checkLines:T=[],checkLineWidth:P=4})=>{var ne,j,Y,ce,le,X,Pe,ge,H,Q,Ee,be,ee,he,ue,me,Ie,ke,Ae;const v=_e.useScene(),_=m.useRef(null),b=m.useContext(Le),E=je({url:t,cacheType:Me.URL_PREFIX_MATCH}),[L,I]=m.useState(u.Vector3.Zero()),[S,k]=m.useState(void 0),B=He({url:c==null?void 0:c.texture,cacheType:Me.URL_PREFIX_MATCH}),F=He({url:c==null?void 0:c.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),w=He({url:(ne=p.segment1)==null?void 0:ne.texture,cacheType:Me.URL_PREFIX_MATCH}),D=He({url:(j=p.segment1)==null?void 0:j.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),N=He({url:(Y=p.segment2)==null?void 0:Y.texture,cacheType:Me.URL_PREFIX_MATCH}),M=He({url:(ce=p.segment2)==null?void 0:ce.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),x=He({url:(le=p.segment3)==null?void 0:le.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}),U=He({url:(H=p.segment5)==null?void 0:H.texture,cacheType:Me.URL_PREFIX_MATCH}),re=He({url:(Q=p.segment5)==null?void 0:Q.sideTexture,cacheType:Me.URL_PREFIX_MATCH}),oe=He({url:(Ee=p.segment6)==null?void 0:Ee.texture,cacheType:Me.URL_PREFIX_MATCH}),G=He({url:(be=p.segment6)==null?void 0:be.sideTexture,cacheType:Me.URL_PREFIX_MATCH});m.useEffect(()=>{console.log("[Geo3DViewer] ProgressedAttributeBody Loading: ",t)},[t]),m.useEffect(()=>{if(v&&_.current&&t&&E){const Ne=_.current;u.Tags.EnableFor(Ne),u.Tags.AddTagsTo(Ne,"loading");const we=Bo.decode(new Uint8Array(E)),{points:Re,indices:Ve,value:We,center:Be}=we;Be&&I(new u.Vector3(Be.x,Be.y,Be.z));const Ge=new u.VertexData;Ge.positions=Re,Ge.indices=Ve,Ge.colors=We;const Ke=[];u.VertexData.ComputeNormals(Re,Ve,Ke),Ge.normals=Ke,Ne&&(Ge.applyToMesh(Ne),Ne.getScene().onAfterRenderObservable.addOnce(()=>{if(!Ne.isDisposed()){const fe=Ne.getBoundingInfo();k(fe.boundingBox)}})),u.Tags.RemoveTagsFrom(Ne,"loading")}},[t,v,E]);function ae(Ne,we,Re){const Ve=Re.subtract(we),We=Ne.subtract(we),Be=u.Vector3.Dot(u.Vector3.Normalize(Ve),u.Vector3.Normalize(We)),Ge=We.length()/Be,Ke=we.add(Ve.scale(Ge/u.Vector3.Distance(we,Re)));return u.Vector3.Distance(Ne,Ke)}return m.useEffect(()=>{_.current&&(_.current.metadata={pickable:s?{name:e,valueCallback:(Ne,we,Re)=>{if(console.log(e,Ne,we,Re),_.current&&we){const Ve=_.current.getBoundingInfo().boundingBox;console.log(Ve);for(let We=0;We<T.length;We++){const Be=T[We];if(ae(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),pe=Be.start.add(fe.scale(z/10)),xe=new u.Vector3(pe.x,we.y+Ve.extendSize.y*4,pe.z),Z=new u.Vector3(pe.x,we.y+Ve.extendSize.y*2,pe.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),pe=Be.start.add(fe.scale(z/10)),xe=new u.Vector3(pe.x,we.y-Ve.extendSize.y*4,pe.z),Z=new u.Vector3(pe.x,we.y-Ve.extendSize.y*2,pe.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:We,points:Ke}}}}},onLeftClick:s.onLeftClick,onRightClick:s.onRightClick,onMiddleClick:s.onMiddleClick,onHover:s.onHover,extra:s.extra}:null})},[s,e,T]),C.jsx(C.Fragment,{children:C.jsx("transformNode",{name:`transform-progressedattribute-${e}`,position:L.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:!B,alwaysSelectAsActiveMesh:!0,children:S&&origin?B?C.jsx(Xi,{name:`progressedattributebody-${e}-mat`,backFaceCulling:!0,needDepthPrePass:!1,transparencyMode:u.Material.MATERIAL_ALPHABLEND,alphaMode:u.Engine.ALPHA_COMBINE,texture:B,sideTexture:F,alphaStage:a,cutNormal:i,value:l,boundingBox:S,tilingFactor:c==null?void 0:c.tilingFactor,textureFlatRotate:c==null?void 0:c.flatModeRotate,sideTilingFactor:(ee=c==null?void 0:c.sideTilingFactor)!=null?ee:c==null?void 0:c.tilingFactor,mode:c==null?void 0:c.mode,overlay:{texture1:w,sideTexture1:D,texture2:N,sideTexture2:M,texture3:x,sideTexture3:A,texture4:V,sideTexture4:$,texture5:U,sideTexture5:re,texture6:oe,sideTexture6:G,color1:(he=p.segment1)==null?void 0:he.color,color2:(ue=p.segment2)==null?void 0:ue.color,color3:(me=p.segment3)==null?void 0:me.color,color4:(Ie=p.segment4)==null?void 0:Ie.color,color5:(ke=p.segment5)==null?void 0:ke.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:y,disableDepthWrite:h}):r?C.jsx(Ji,{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:y,disableDepthWrite:h}):C.jsx(C.Fragment,{}):C.jsx(C.Fragment,{})})})})},ga=({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 y=1,h=1;a&&(a.scalePlane&&(y=a.scalePlane),a.scaleDepth&&(h=a.scaleDepth)),e(new u.Vector3(d.x/y,d.y/h,d.z/y))},[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)),y=d.length!==o.current.length||d.some((h,T)=>o.current[T]!==h);return r.current||(r.current=new xi.GPUPicker),y&&(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 y=await r.current.pickAsync(n.pointerX,n.pointerY,!1),h=y==null?void 0:y.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 y;if(!n||n.skipPointerMovePicking)return;const d=n.pick(n.pointerX,n.pointerY,void 0,!1,void 0);l((y=d==null?void 0:d.pickedPoint)!=null?y: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,{})},va=({name:e,paths:t,color:n,alpha:a,sideOrientation:r=Ni.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),y=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,extra:f.extra}:null})},[f,e]),C.jsxs("transformNode",{name:`${e}-transform`,position:o.multiply(y),rotation:i,scaling:l.multiply(y),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"})})]})},rf=`#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
|
-
}`,
|
|
1287
|
+
}`,af=`#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
|
-
}`,af=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||f.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:rf,fragment:of,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:f.Material.CounterClockWiseSideOrientation})},sf=(e,t)=>{m.useEffect(()=>{e.current&&(e.current.metadata={pickable:t})},[t,e])},lf=(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:u,color:d,start:x=new f.Vector3,end:h=new f.Vector3,percent:T,position:P,materialType:y="custom",children:_,alphaBlend:b=!1,alpha:k=1,name:L="roadway",actions:I,gpuPick:S=!0}=e;m.useImperativeHandle(t,()=>r.current,[]),m.useEffect(()=>{if(a&&a.current&&n){const B=new f.VertexData;B.positions=s,B.indices=c,p&&y!=="pbr-dark"&&y!=="pbr-light"&&(B.colors=p),B.applyToMesh(a.current)}},[c,s,n,p,i,y]),sf(a,I&&S?{onLeftClick:I.onLeftClick,onRightClick:I.onRightClick,onMiddleClick:I.onMiddleClick,onHover:I.onHover,extra:""}:void 0);const E=m.useCallback(()=>{if(y==="custom")return C.jsx(lt,{name:`${L}-material-${i}`,vertex:Hn,fragment:Wn,needDepthPrePass:!1,transparencyMode:b?f.Material.MATERIAL_ALPHABLEND:f.Material.MATERIAL_OPAQUE,options:{needAlphaBlending:!!b}});if(y==="percent")return C.jsx(af,{name:`${L}-percentmaterial-${i}`,backgroundColor:u,color:d!=null?d:f.Color3.Black(),startPercent:T?T[0]:1,endPercent:T?T[1]:1,zOffset:-2,zOffsetUnits:-10,start:x,end:h});if(y==="standard")return C.jsx("standardMaterial",{name:`${L}-material`,alphaMode:f.Engine.ALPHA_COMBINE,transparencyMode:b?f.Material.MATERIAL_ALPHABLEND:f.Material.MATERIAL_OPAQUE,alpha:k});if(y==="pbr-light")return C.jsx(Zn,{alpha:k});if(y==="pbr-dark")return C.jsx(Gn,{alpha:k})},[k,b,u,d,h,i,y,L,T,x]);return C.jsxs("transformNode",{name:`node-${L}-${i}`,setEnabled:l,children:[C.jsxs("transformNode",{name:`${L}`,position:P?P.multiply(Oe(o)):new f.Vector3(0,0,0),scaling:Oe(o),ref:r,children:[C.jsx("mesh",{name:`roadway-${i}-mesh`,ref:a,isPickable:!0,children:E()}),C.jsx("transformNode",{name:`${L}-title`,position:e.style.position?e.style.position:new f.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"})})]}),_]})},Pn=m.forwardRef(lf),xa=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 f.Vector3(0,0,0)),i=m.useRef(!1),[l,s]=m.useState([]),[c,p]=m.useState(""),{id:u,url:d,visible:x=!0,offset:h=new f.Vector3(0,0,0),children:T,actions:P,rayPick:y,showRoadwayWall:_={top:!0,bottom:!0,side:!0},roadwayName:b={nameList:[],offset:new f.Vector3(0,0,0)}}=e,{top:k=!0,bottom:L=!0,side:I=!0}=_,S=Yu(d);return m.useEffect(()=>{if(S&&!i.current){i.current=!0;const E=Wi.decode(new Uint8Array(S));console.log(E),p(E.name);const{boxes:B}=E,F=[],w=[],D=[],N=[],M=[],v=[],A=[],V=[],$=[];let U=0,ie=0,ne=0;const G=E.position?new f.Vector3(E.position.x,E.position.y,E.position.z):new f.Vector3(0,0,0);return B.forEach(ae=>{var Pe,ge,H,Q,Ee,be;const{topMesh:oe,bottomMesh:j,sideMesh:Y}=ae;let ce=0;oe&&oe.vertices&&oe.indices&&oe.colors&&(F.push(...oe.vertices),w.push(...oe.indices.map(ee=>ee+U)),D.push(...oe.colors),ce=Math.max(...oe.indices)),U+=ce+1;let le=0;Y&&Y.vertices&&Y.indices&&Y.colors&&(N.push(...Y.vertices),M.push(...Y.indices.map(ee=>ee+ie)),v.push(...Y.colors),le=Math.max(...Y.indices)),ie+=le+1;let X=0;if(j&&j.vertices&&j.indices&&j.colors&&(A.push(...j.vertices),V.push(...j.indices.map(ee=>ee+ne)),$.push(...j.colors),X=Math.max(...j.indices)),ne+=X+1,(b==null?void 0:b.nameList.length)>0&&ae.name&&b.nameList.includes(ae.name)){const ee=new f.Vector3((Pe=ae.startPosition)==null?void 0:Pe.x,(ge=ae.startPosition)==null?void 0:ge.y,(H=ae.startPosition)==null?void 0:H.z),he=new f.Vector3((Q=ae.endPosition)==null?void 0:Q.x,(Ee=ae.endPosition)==null?void 0:Ee.y,(be=ae.endPosition)==null?void 0:be.z),ue=ee.add(he).scale(.5);s(me=>[...me,{name:ae.name,position:ue}])}}),n({top:{vertices:F,indices:w,colors:D},side:{vertices:N,indices:M,colors:v},bottom:{vertices:A,indices:V,colors:$}}),o(G),()=>{i.current=!1,n({top:{vertices:[],indices:[],colors:[]},side:{vertices:[],indices:[],colors:[]},bottom:{vertices:[],indices:[],colors:[]}}),o(new f.Vector3(0,0,0))}}},[S]),m.useEffect(()=>{const E=a==null?void 0:a.onPointerObservable.add(function(B){if(y)switch(B.type){case f.PointerEventTypes.POINTERUP:const F=a.pick(a.pointerX,a.pointerY);if(F.hit){const w=F.pickedMesh;(w==null?void 0:w.name)===`roadway-${u}-mesh`&&P!=null&&P.onLeftClick&&P.onLeftClick(w.name,void 0,F.pickedPoint)}break}});return()=>{a==null||a.onPointerObservable.remove(E)}},[P,u,c,y,a]),C.jsxs(C.Fragment,{children:[t.top.vertices.length>0&&t.top.indices.length>0&&C.jsx(Pn,{id:u,name:c,visible:x&&k,vertices:t.top.vertices,indices:t.top.indices,position:r.add(h),colors:t.top.colors.length>0?t.top.colors:void 0,style:{},actions:P,materialType:"standard",gpuPick:!y,children:T}),t.side.vertices.length>0&&t.side.indices.length>0&&C.jsx(Pn,{id:u,name:c,visible:x&&I,vertices:t.side.vertices,indices:t.side.indices,position:r.add(h),colors:t.side.colors.length>0?t.side.colors:void 0,style:{},actions:P,materialType:"standard",gpuPick:!y,children:T}),t.bottom.vertices.length>0&&t.bottom.indices.length>0&&C.jsx(Pn,{id:u,name:c,visible:x&&L,vertices:t.bottom.vertices,indices:t.bottom.indices,position:r.add(h),colors:t.bottom.colors.length>0?t.bottom.colors:void 0,style:{},actions:P,gpuPick:!y,materialType:"standard",children:T}),l.map((E,B)=>C.jsxs("transformNode",{name:`roadway-name-${E.name}-${B}-root`,children:[C.jsx("transformNode",{name:`roadway-name-${E.name}-${B}`,position:E.position.add(h).add((b==null?void 0:b.offset)||new f.Vector3(0,0,0)),billboardMode:f.Mesh.BILLBOARDMODE_ALL,children:C.jsx(Je,{text:E.name,fontSize:(b==null?void 0:b.fontSize)||18,color:(b==null?void 0:b.color)||"#FFFFFF"})},B),b.offset&&b.offset.y!==0?C.jsx("lineSystem",{name:`roadway-name-${E.name}-${B}-line`,lines:[[E.position,E.position.add(b.offset)]],color:f.Color3.White()}):null]}))]})},cf=e=>{const{id:t,node:n}=e,[a,r]=m.useState([]),[o,i]=m.useState([]),l=(c,p)=>{const u=[];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&&u.push([T,p[d][0]]),T=Math.max(T,p[d][1]),!(p[d][1]>=h));)d++;T<h&&u.push([T,h])}return u};m.useEffect(()=>{if(n.range){const c=[],p=[];let u=[];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]))}u=l(x,h),u.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((u,d)=>c[0]===c[1]?null:C.jsx(Pn,{id:t,visible:!0,vertices:u.vertices,indices:u.indices,position:new f.Vector3(0,0,0),color:o[p],percent:c,start:n.start,end:n.end,style:{},materialType:"percent"},d))},p))})},uf=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,u)=>p-u);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 Yi){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(Pn,{id:0,name:"animation-merged-mesh",visible:!0,vertices:r.vertices,indices:r.indices,position:new f.Vector3(0,0,0),color:t[0].colors[1],percent:[0,1],start:t[0].start,end:t[0].end,style:{},materialType:"percent"})]})},ff=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 u=new f.Texture(t);u.hasAlpha=!0,u.uScale=r,u.vScale=o,s(u)},[t,r,o]),m.useEffect(()=>{const u=setInterval(()=>{i&&p(d=>d===0?1:0)},1e3);return()=>{clearInterval(u)}},[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:f.Material.CounterClockWiseSideOrientation})},df=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,u]=m.useState(),[d,x]=m.useState(!1),[h,T]=m.useState(1),P=(y,_,b,k)=>{const I=f.Vector3.Distance(y,_)/k,S=f.Vector3.Distance(y,b),E=Math.floor(S/I);return Math.min(E,k-1)};return m.useEffect(()=>{if(t.start&&t.end&&t.current){const y=f.Vector3.Distance(t.start,t.end),_=Math.floor(y/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){u(void 0);return}if(t.start&&t.end&&t.current){const y=f.Vector3.Lerp(t.start,t.end,.5+(1-h)/2);u(y)}},[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:f.Vector3.Distance(t.start,t.end),height:n,ref:c,position:p,setEnabled:d&&o,scaling:new f.Vector3(h,1,1),children:C.jsx(ff,{name:t.name,alphaMode:f.Engine.ALPHA_COMBINE,transparencyMode:f.Material.MATERIAL_ALPHABLEND,url:r,uScale:l,vScale:1,zOffset:-10,zOffsetUnits:-10,isBlink:i})})})},pf=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(df,{node:c,roadwayWidth:n,textureLength:a,url:r,visible:o,isBlink:i},s)})})};class hf{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 mf=({position:e=f.Vector3.Zero(),id:t,node:n,timeSpeed:a=-6,perlinMultiply:r=.5,waterFlow:o=1,clippedHeight:i=0,alpha:l=1,colorSteps:s=[new f.GradientBlockColorStep(0,new f.Color3(25,92,255)),new f.GradientBlockColorStep(1,new f.Color3(127,223,252))],subdivideX:c=15,subdivideY:p=150})=>{const u=_e.useScene(),d=m.useContext(Le),x=m.useRef(null),h=m.useRef(null),[T,P]=m.useState(f.Vector3.Zero()),y=m.useRef(null),_=m.useRef(null),b=m.useRef(null);return m.useEffect(()=>{const k=x.current;if(u&&k){y.current=gu({name:`waterMat-${t}-${n.name}`,scene:u}),y.current.getBlockByName("TimeSpeed").value=a,y.current.getBlockByName("PerlinMultiply").value=r,y.current.getBlockByName("waterFlow").value=o,y.current.getBlockByName("ClippedHeight").value=i,y.current.alpha=l,y.current.getBlockByName("Gradient").colorSteps=s;const L=y.current;L.getBlockByName("MaskEnabled").value=0,L.build(!1,!0,!0);const I=n.start,S=n.end,E=f.Vector3.Normalize(S.subtract(I)),B=Math.asin(E.y),F=Math.atan2(E.x,E.z),w=new f.Vector3(-B,F,0);return P(w),k.morphTargetManager=new f.MorphTargetManager,k.morphTargetManager.enableNormalMorphing=!0,b.current=k.getVerticesData(f.VertexBuffer.PositionKind).slice(0),b.current.length===0&&console.log("[Geo3DViewer] 水模拟,原始 SourceKind 为空",t,n.name),k.material=y.current,()=>{var D;(D=y.current)==null||D.dispose()}}},[t,n.end,n.name,n.start,u]),m.useEffect(()=>{const k=x.current,L=x.current;if(k&&L){console.log(`[Geo3DViewer] 正在更新 ${t} / ${n.name} 的进度 Time: ${n.time/1e3}`);const I=L.getVerticesData(f.VertexBuffer.PositionKind).slice(0);I.length===0&&console.log("[Geo3DViewer] 水模拟 SourceKind 为空",t,n.name),L.updateMeshPositions(F=>{for(let w=0;w<F.length;w++)F[w]=b.current[w]});const S=L.applyDisplacementMapFromBuffer(n.glurHeightMap,1,n.waterLength,0,n.height,f.Vector2.Zero(),f.Vector2.One(),!1).getVerticesData(f.VertexBuffer.PositionKind).slice(0);S.length===0&&console.log("[Geo3DViewer] 水模拟 SourceKind 为空",t,n.name),k.updateMeshPositions(F=>{for(let w=0;w<F.length;w++)F[w]=S[w]});const E=new hf(I,S,k),B=new f.Animation("waterAnimation","influence",1e3/30,f.Animation.ANIMATIONTYPE_FLOAT,f.Animation.ANIMATIONLOOPMODE_CONSTANT);B.setKeys([{frame:0,value:0},{frame:10,value:1}]),u==null||u.beginDirectAnimation(E,[B],0,10,!1,10)}},[t,n.glurHeightMap,n.height,n.name,n.waterLength,n.time]),m.useEffect(()=>{const k=y.current;k&&(k.getBlockByName("TimeSpeed").value=a)},[a]),m.useEffect(()=>{const k=y.current;k&&(k.getBlockByName("PerlinMultiply").value=r)},[r]),m.useEffect(()=>{const k=y.current;k&&(k.getBlockByName("waterFlow").value=o)},[o]),m.useEffect(()=>{const k=y.current;k&&(k.getBlockByName("ClippedHeight").value=i)},[i]),m.useEffect(()=>{const k=y.current;k&&(k.alpha=l)},[l]),m.useEffect(()=>{const k=y.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 f.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})]})})},gf=e=>{const{nodes:t}=e;return C.jsx(C.Fragment,{children:t&&t.map((n,a)=>C.jsx(mf,{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))})},ya=e=>{const{rootUrl:t,size:n=1e3,name:a="skybox"}=e;return C.jsx(_e.Skybox,{rootUrl:t,size:n,name:a})};function ni(){return{name:"",origin:void 0,dataPoints:[]}}const Ca={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)dn.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=ni();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(dn.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:yn(e.name)?globalThis.String(e.name):"",origin:yn(e.origin)?K.fromJSON(e.origin):void 0,dataPoints:globalThis.Array.isArray(e==null?void 0:e.dataPoints)?e.dataPoints.map(t=>dn.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=>dn.toJSON(a))),t},create(e){return Ca.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=ni();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=>dn.fromPartial(r)))||[],t}};function oi(){return{point:void 0,colorId:0,vColor:0,vRadius:0}}const dn={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=oi();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:yn(e.point)?K.fromJSON(e.point):void 0,colorId:yn(e.colorId)?globalThis.Number(e.colorId):0,vColor:yn(e.vColor)?globalThis.Number(e.vColor):0,vRadius:yn(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 dn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=oi();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 yn(e){return e!=null}var _a=(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))(_a||{});const Pa=({url:e,colorCodec:t,alpha:n=1,visible:a=!0,offset:r=f.Vector3.Zero(),scale:o=1,objectType:i=2})=>{const l=_e.useScene(),s=m.useRef(null),c=m.useContext(Le),p=m.useContext(Lt),u=m.useRef(null),[d,x]=m.useState(""),[h,T]=m.useState(f.Vector3.Zero()),P=je({url:e,cacheType:Me.URL_PREFIX_MATCH}),[y,_]=m.useState(null);return m.useEffect(()=>{console.log("[Geo3DViewer] SpaceHeat Loading: ",e)},[e]),m.useEffect(()=>{if(l&&s.current&&P){const b=s.current;f.Tags.EnableFor(b),f.Tags.AddTagsTo(b,"loading");const k=Ca.decode(new Uint8Array(P)),{name:L,origin:I,dataPoints:S}=k;if(I&&S){x(L),T(new f.Vector3(I.x,I.y,I.z));const E=new Float32Array(S.length*16),B=new Float32Array(S.length*4);return S.forEach((F,w)=>{if(F.point){const D=new f.Vector3(F.point.x,F.point.y,F.point.z).multiplyByFloats(c&&c.scalePlane?c.scalePlane:1,c&&c.scaleDepth?c.scaleDepth:1,c&&c.scalePlane?c.scalePlane:1),N=f.Quaternion.Identity(),M=new f.Vector3(F.vRadius*o,F.vRadius*o,F.vRadius*o);if(f.Matrix.Compose(M,N,D).copyToArray(E,w*16),t){const A=p.colorCodecs[t].array,V=A[Math.floor(F.vColor*(A.length-1))];B.set([V.r,V.g,V.b,n],w*4)}else{const A=p.colorIDs[F.colorId];B.set([A.r,A.g,A.b,n],w*4)}}}),b&&(b.thinInstanceSetBuffer("matrix",E),b.thinInstanceSetBuffer("color",B,4)),f.Tags.RemoveTagsFrom(b,"loading"),y==null||y.addMesh(b,f.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,y,c==null?void 0:c.scaleDepth,c==null?void 0:c.scalePlane]),m.useEffect(()=>(u.current&&l&&n&&u.current.setFloat("alpha",n),l&&i===5&&_(new f.HighlightLayer(`highlight-layer-spaceheat-${d}`,l)),()=>{y&&y.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:f.Mesh.DOUBLESIDE,billboardMode:f.Mesh.BILLBOARDMODE_ALL,children:t?C.jsx("standardMaterial",{name:`spaceheat-${d}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new f.Color3(0,0,0),ambientColor:new f.Color3(1,1,1),emissiveColor:f.Color3.White(),alphaMode:f.Engine.ALPHA_COMBINE,alpha:n,zOffset:-3}):C.jsx("standardMaterial",{name:`spaceheat-${d}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new f.Color3(0,0,0),ambientColor:new f.Color3(1,1,1),emissiveColor:f.Color3.White(),alphaMode:f.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 f.Color3(0,0,0),ambientColor:new f.Color3(1,1,1),emissiveColor:f.Color3.Black(),alphaMode:f.Engine.ALPHA_COMBINE,alpha:n,zOffset:-3}):C.jsx("standardMaterial",{name:`spaceheat-${d}-mat`,backFaceCulling:!1,needDepthPrePass:!0,specularColor:new f.Color3(0,0,0),ambientColor:new f.Color3(1,1,1),emissiveColor:f.Color3.Black(),alphaMode:f.Engine.ALPHA_COMBINE,alpha:n,zOffset:-3})})})};var Sa=(e=>(e[e.OSM=1]="OSM",e[e.AMAP=2]="AMAP",e))(Sa||{});const Ta=({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:u={w:8,h:8},offset:d=f.Vector3.Zero(),scale:x=1})=>{const h=_e.useScene(),T=m.useRef(null),P=m.useRef(null),[y,_]=m.useState([]),[b,k]=m.useState([]);return m.useEffect(()=>{const L=T.current,I=P.current;if(L&&I){const S=L.getTotalVertices(),E=L.getIndices().length/(u.w*u.h),B=[];let F=0,w=0;for(let N=0;N<u.h;N++)for(let M=0;M<u.w;M++){const v=new f.SubMesh(F++,0,S,w,E,L);B.push(v),w+=E}const D=[];return[...Array(u.h).keys()].flatMap(N=>[...Array(u.w).keys()].map(M=>{const v=new f.StandardMaterial(`tileMap-material-${N}-${M}`),A=[`${t}/${l}/${s+M}/${c-N}.png`,`${t}/appmaptile?z=${l}&x=${s+M}&y=${c-N}&style=6`];return v.diffuseTexture=new f.Texture(A[A!=null&&A[e-1]?e-1:0],h),v.diffuseTexture.wrapU=f.Texture.CLAMP_ADDRESSMODE,v.diffuseTexture.wrapV=f.Texture.CLAMP_ADDRESSMODE,v.specularColor=f.Color3.Black(),v.backFaceCulling=!1,v})).forEach(N=>{D.push(N)}),k(B),_(D),L.subMeshes=B,I.subMaterials=D,()=>{I.subMaterials=[],L.subMeshes=[],_([]),k([])}}},[t,e,h,u.h,u.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:u,precision:p,subMeshes:b,ref:T,children:C.jsx("multiMaterial",{name:"submaterial-tile-map",subMaterials:y,ref:P})})})};function ri(){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)pn.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)Ue.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=ri();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(pn.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(Ue.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=>pn.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=>Ue.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=>pn.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=>Ue.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=ri();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(u=>pn.fromPartial(u)))||[],t.vertices=((o=e.vertices)==null?void 0:o.map(u=>u))||[],t.normals=((i=e.normals)==null?void 0:i.map(u=>u))||[],t.indices=((l=e.indices)==null?void 0:l.map(u=>u))||[],t.colors=((s=e.colors)==null?void 0:s.map(u=>u))||[],t.uv=((c=e.uv)==null?void 0:c.map(u=>u))||[],t.meshs=((p=e.meshs)==null?void 0:p.map(u=>Ue.fromPartial(u)))||[],t}};function ii(){return{position:void 0,start:void 0,end:void 0,color:void 0,angle:0,radius:0,innerRadius:0,texture:"",v:[]}}const pn={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=ii();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 pn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=ii();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 vf=(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 f.Vector3(0,0,0),scaling:c?Oe(a):f.Vector3.One(),ref:n,children:s})},xf=m.forwardRef(vf),yf=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,extra:i}:null})},[l,a,i]),m.useEffect(()=>{if(n.current){const u=new f.VertexData;u.positions=p.vertices,u.indices=p.indices,u.normals=p.normals,u.uvs=p.uv,u.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 f.Color3(o.r,o.g,o.b):void 0,diffuseTexture:r!==""?new f.Texture(r):void 0})})},Cf=(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,u,d,x,h,T;return C.jsx(yf,{id:c,v:s.v,position:a.add(new f.Vector3(0,0,0)),path:[new f.Vector3((p=s.start)==null?void 0:p.x,(u=s.start)==null?void 0:u.y,(d=s.start)==null?void 0:d.z),new f.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 f.Color4(s.color.r,s.color.g,s.color.b,s.color.a):new f.Color4(0,0,0,1),url:s.texture},c)})})},_f=m.forwardRef(Cf),Pf=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:u=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:(y,_,b,k,L)=>{var I,S,E,B,F,w;if(T.onHover&&t&&d&&b){const D=b;for(let N=0;N<d.length;N++){const M=new f.Vector3((I=d[N].start)==null?void 0:I.x,(S=d[N].start)==null?void 0:S.y,(E=d[N].start)==null?void 0:E.z).add(x).multiply(Oe(a)),v=new f.Vector3((B=d[N].end)==null?void 0:B.x,(F=d[N].end)==null?void 0:F.y,(w=d[N].end)==null?void 0:w.z).add(x).multiply(Oe(a)),A=f.MeshBuilder.CreateTube("boundingbox-tmp",{path:[M,v],radiusFunction:()=>{const $=d[N].radius;return $||1},cap:f.Mesh.NO_CAP,tessellation:8,sideOrientation:f.Mesh.DOUBLESIDE},t),V=A.getBoundingInfo().intersectsPoint(D);if(A.dispose(),V){T.onHover(y,new f.Vector2(t==null?void 0:t.pointerX,t==null?void 0:t.pointerY),b,k,L,d[N].v);break}}}}}:null})},[T,a,x,t,d]),m.useEffect(()=>{if(n&&n.current&&t){const y=new f.VertexData;y.positions=o,y.indices=i,l&&c!=="pbr-dark"&&c!=="standard"&&c!=="pbr-light"&&(y.colors=l),y.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:Hn,fragment:Wn,needDepthPrePass:!1,transparencyMode:p?f.Material.MATERIAL_ALPHABLEND:f.Material.MATERIAL_OPAQUE,options:{needAlphaBlending:!!p}});if(c==="standard")return C.jsx("standardMaterial",{name:`${h}-material`,alphaMode:f.Engine.ALPHA_COMBINE,transparencyMode:p?f.Material.MATERIAL_ALPHABLEND:f.Material.MATERIAL_OPAQUE,alpha:u,diffuseColor:s||void 0});if(c==="pbr-light")return C.jsx(Zn,{alpha:u});if(c==="pbr-dark")return C.jsx(Gn,{alpha:u})},[u,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()})})},Sf=(e,t)=>{const{id:n,visible:a=!0,materialType:r="custom",vertices:o,indices:i,colors:l,color:s,slices:c,position:p,actions:u}=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(Pf,{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:u,slices:c})})},Tf=m.forwardRef(Sf),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 f.Vector3(0,0,0)):new f.Vector3(0,0,0).add(r.offset?r.offset:new f.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"})})},ba=m.forwardRef(bf),ka=e=>{var le,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),[u,d]=m.useState(""),[x,h]=m.useState(new f.Vector3(0,0,0)),T=m.useRef(null),P=m.useRef(null),y=m.useRef(null),[_,b]=m.useState([]),k=m.useRef(!1),L=m.useContext(Le),[I,S]=m.useState([]),[E,B]=m.useState(!1),[F,w]=m.useState(!1),{id:D,url:N,color:M,visible:v=!0,materialType:A="custom",children:V,style:$,actions:U,noLod:ie=!1,lodDistance:ne=[200,1e3],loadDistance:G=0,offset:ae=new f.Vector3(0,0,0),position:oe,topPosition:j,bottomPosition:Y,isRegular:ce=!0}=e;return m.useEffect(()=>{oe&&j&&Y?(s.current=oe,c.current=j,p.current=Y):w(!0)},[Y,oe,j]),m.useEffect(()=>{!k.current&&F&&(k.current=!0,Wt.get(N,{responseType:"arraybuffer"}).then(H=>{var he,ue,me,Ie,ke,Ae,Ne,we,Re;const Q=Nt.decode(new Uint8Array(H.data));console.log(Q);const Ee=Q.sliceList[0],be=Q.sliceList[Q.sliceList.length-1];d(Q.name);const ee=e.style.basePosition&&e.style.basePosition==="top"?Ee.start:be.end;h(new f.Vector3(ee==null?void 0:ee.x,ee==null?void 0:ee.y,ee==null?void 0:ee.z)),s.current=new f.Vector3((he=Q.origin)==null?void 0:he.x,(ue=Q.origin)==null?void 0:ue.y,(me=Q.origin)==null?void 0:me.z).add(ae),b(Q.sliceList.filter(Ve=>Ve.v)),c.current=new f.Vector3((Ie=Ee.start)==null?void 0:Ie.x,(ke=Ee.start)==null?void 0:ke.y,(Ae=Ee.start)==null?void 0:Ae.z).add(s.current),p.current=new f.Vector3((Ne=be.end)==null?void 0:Ne.x,(we=be.end)==null?void 0:we.y,(Re=be.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)}))},[N,t,M,A,e.style.basePosition,ae,F,L]),m.useEffect(()=>{const H=setInterval(()=>{var Q,Ee,be,ee,he,ue,me,Ie,ke,Ae,Ne,we,Re,Ve;if(t&&t.cameras.length>0&&t.activeCamera&&s.current&&c.current&&p.current){const We=Ot.calcLodDistance(c.current.multiply(Oe(L)),s.current.multiply(Oe(L)),p.current.multiply(Oe(L)),t.activeCamera.position);We>=G&&w(!0),ie?(I.length===0?((Q=T.current)==null||Q.setEnabled(!0),(Ee=P.current)==null||Ee.setEnabled(!1)):((be=T.current)==null||be.setEnabled(!1),(ee=P.current)==null||ee.setEnabled(!0)),(he=y.current)==null||he.setEnabled(!0)):We<ne[0]?(B(!0),(ue=T.current)==null||ue.setEnabled(!0),(me=P.current)==null||me.setEnabled(I.length===0),(Ie=y.current)==null||Ie.setEnabled(!0)):ne[1]&&We<ne[1]?((ke=T.current)==null||ke.setEnabled(!1),(Ae=P.current)==null||Ae.setEnabled(!0),(Ne=y.current)==null||Ne.setEnabled(!0)):((we=T.current)==null||we.setEnabled(!1),(Re=P.current)==null||Re.setEnabled(!1),(Ve=y.current)==null||Ve.setEnabled(!1))}},1e3);return()=>{clearInterval(H)}},[G,ne,I.length,L,t]),C.jsx(C.Fragment,{children:C.jsxs("transformNode",{name:`tube-${D} `,children:[C.jsxs(xf,{id:D,name:u,visible:v,position:(le=s.current)!=null?le:new f.Vector3(0,0,0),isRegular:ce,children:[F&&C.jsx(ba,{id:D,style:{title:u,position:x,offset:(X=$.offset)==null?void 0:X.multiply(ki(L)),fontSize:$.fontSize,color:$.color},ref:y}),E&&F&&ne[0]&&I.length>0&&C.jsx(_f,{id:D,name:u,meshs:I,position:(Pe=s.current)!=null?Pe:new f.Vector3(0,0,0),materialType:A,slices:_,actions:U,ref:T}),F&&C.jsx(Tf,{id:D,name:u,position:(ge=s.current)!=null?ge:new f.Vector3(0,0,0),vertices:n,indices:r,colors:i,color:M?new f.Color3(M.r,M.g,M.b):void 0,slices:_,actions:U,materialType:A,ref:P})]}),V]})})};function ai(){return{group:[]}}const Ea={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=ai();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 Ea.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=ai();return t.group=((n=e.group)==null?void 0:n.map(a=>Nt.fromPartial(a)))||[],t}},Na=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,u=m.useCallback((d,x)=>x?new f.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 f.Color4(1,1,1,1),[]);return m.useEffect(()=>{if(!r.current&&(r.current=!0,l&&Wt.get(l,{responseType:"arraybuffer"}).then(d=>{const x=Ea.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(Wt.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,y,_,b,k,L;let d;if(n.length>0){const I=[],S=[];for(let E=0;E<n.length;E++){const B=n[E],F=new f.Vector3((x=B.origin)==null?void 0:x.x,(h=B.origin)==null?void 0:h.y,(T=B.origin)==null?void 0:T.z),w=B.sliceList;if(w){const D=[],N=[];for(let M=0;M<w.length;M++)D.push(F.add(new f.Vector3((P=w[M].start)==null?void 0:P.x,(y=w[M].start)==null?void 0:y.y,(_=w[M].start)==null?void 0:_.z)).multiply(Oe(o))),N.push(u(void 0,w[M].color)),M===w.length-1&&(D.push(F.add(new f.Vector3((b=w[M].end)==null?void 0:b.x,(k=w[M].end)==null?void 0:k.y,(L=w[M].end)==null?void 0:L.z)).multiply(Oe(o))),N.push(u(void 0,w[M].color)));I.push(D),S.push(N)}}d=f.MeshBuilder.CreateLineSystem("linesystem",{lines:I,colors:S},t),d.setEnabled(i)}return()=>{d&&d.dispose()}},[u,o,t,n,i]),C.jsx(C.Fragment,{children:s&&n&&n.length>0?n.map(d=>{var x,h,T,P,y,_;return C.jsx(Xn,{position:new f.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 f.Vector3((P=d.sliceList[0].start)==null?void 0:P.x,(y=d.sliceList[0].start)==null?void 0:y.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,{})})},So=e=>{const t=m.useContext(Le),{position:n=f.Vector3.Zero(),localScale:a=1,scaleMode:r=It.NONE}=e,[o,i]=m.useState(1),{modelRoation:l=new f.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 u=s.current.getChildren()[1];u.rotation=l,c&&clearInterval(c)}},500)),()=>{c&&clearInterval(c)}},[l]),C.jsx(Xn,{...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 si(){return{name:"",tubeName:"",min:0,max:0,origin:void 0,chart:[]}}const Zo={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)hn.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=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!==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(hn.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=>hn.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=>hn.toJSON(a))),t},create(e){return Zo.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=si();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=>hn.fromPartial(l)))||[],t}};function li(){return{position:void 0,depth:0,value:0}}const hn={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=li();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 hn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=li();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 kf=`#version 300 es
|
|
1313
|
+
}`,sf=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:af,fragment:rf,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})},lf=(e,t)=>{m.useEffect(()=>{e.current&&(e.current.metadata={pickable:t})},[t,e])},cf=(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:y=new u.Vector3,end:h=new u.Vector3,percent:T,position:P,materialType:v="custom",children:_,alphaBlend:b=!1,alpha:E=1,name:L="roadway",actions:I,gpuPick:S=!0}=e;m.useImperativeHandle(t,()=>r.current,[]),m.useEffect(()=>{if(a&&a.current&&n){const B=new u.VertexData;B.positions=s,B.indices=c,p&&v!=="pbr-dark"&&v!=="pbr-light"&&(B.colors=p),B.applyToMesh(a.current)}},[c,s,n,p,i,v]),lf(a,I&&S?{onLeftClick:I.onLeftClick,onRightClick:I.onRightClick,onMiddleClick:I.onMiddleClick,onHover:I.onHover,extra:""}:void 0);const k=m.useCallback(()=>{if(v==="custom")return C.jsx(lt,{name:`${L}-material-${i}`,vertex:Hn,fragment:Wn,needDepthPrePass:!1,transparencyMode:b?u.Material.MATERIAL_ALPHABLEND:u.Material.MATERIAL_OPAQUE,options:{needAlphaBlending:!!b}});if(v==="percent")return C.jsx(sf,{name:`${L}-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:y,end:h});if(v==="standard")return C.jsx("standardMaterial",{name:`${L}-material`,alphaMode:u.Engine.ALPHA_COMBINE,transparencyMode:b?u.Material.MATERIAL_ALPHABLEND:u.Material.MATERIAL_OPAQUE,alpha:E});if(v==="pbr-light")return C.jsx(Zn,{alpha:E});if(v==="pbr-dark")return C.jsx(Gn,{alpha:E})},[E,b,f,d,h,i,v,L,T,y]);return C.jsxs("transformNode",{name:`node-${L}-${i}`,setEnabled:l,children:[C.jsxs("transformNode",{name:`${L}`,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:k()}),C.jsx("transformNode",{name:`${L}-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"})})]}),_]})},Pn=m.forwardRef(cf),xa=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(""),{id:f,url:d,visible:y=!0,offset:h=new u.Vector3(0,0,0),children:T,actions:P,rayPick:v,showRoadwayWall:_={top:!0,bottom:!0,side:!0},roadwayName:b={nameList:[],offset:new u.Vector3(0,0,0)}}=e,{top:E=!0,bottom:L=!0,side:I=!0}=_,S=Yu(d);return m.useEffect(()=>{if(S&&!i.current){i.current=!0;const k=Wi.decode(new Uint8Array(S));console.log(k),p(k.name);const{boxes:B}=k,F=[],w=[],D=[],N=[],M=[],x=[],A=[],V=[],$=[];let U=0,re=0,oe=0;const G=k.position?new u.Vector3(k.position.x,k.position.y,k.position.z):new u.Vector3(0,0,0);return B.forEach(ae=>{var Pe,ge,H,Q,Ee,be;const{topMesh:ne,bottomMesh:j,sideMesh:Y}=ae;let ce=0;ne&&ne.vertices&&ne.indices&&ne.colors&&(F.push(...ne.vertices),w.push(...ne.indices.map(ee=>ee+U)),D.push(...ne.colors),ce=Math.max(...ne.indices)),U+=ce+1;let le=0;Y&&Y.vertices&&Y.indices&&Y.colors&&(N.push(...Y.vertices),M.push(...Y.indices.map(ee=>ee+re)),x.push(...Y.colors),le=Math.max(...Y.indices)),re+=le+1;let X=0;if(j&&j.vertices&&j.indices&&j.colors&&(A.push(...j.vertices),V.push(...j.indices.map(ee=>ee+oe)),$.push(...j.colors),X=Math.max(...j.indices)),oe+=X+1,(b==null?void 0:b.nameList.length)>0&&ae.name&&b.nameList.includes(ae.name)){const ee=new u.Vector3((Pe=ae.startPosition)==null?void 0:Pe.x,(ge=ae.startPosition)==null?void 0:ge.y,(H=ae.startPosition)==null?void 0:H.z),he=new u.Vector3((Q=ae.endPosition)==null?void 0:Q.x,(Ee=ae.endPosition)==null?void 0:Ee.y,(be=ae.endPosition)==null?void 0:be.z),ue=ee.add(he).scale(.5);s(me=>[...me,{name:ae.name,position:ue}])}}),n({top:{vertices:F,indices:w,colors:D},side:{vertices:N,indices:M,colors:x},bottom:{vertices:A,indices:V,colors:$}}),o(G),()=>{i.current=!1,n({top:{vertices:[],indices:[],colors:[]},side:{vertices:[],indices:[],colors:[]},bottom:{vertices:[],indices:[],colors:[]}}),o(new u.Vector3(0,0,0))}}},[S]),m.useEffect(()=>{const k=a==null?void 0:a.onPointerObservable.add(function(B){if(v)switch(B.type){case u.PointerEventTypes.POINTERUP:const F=a.pick(a.pointerX,a.pointerY);if(F.hit){const w=F.pickedMesh;(w==null?void 0:w.name)===`roadway-${f}-mesh`&&P!=null&&P.onLeftClick&&P.onLeftClick(w.name,void 0,F.pickedPoint)}break}});return()=>{a==null||a.onPointerObservable.remove(k)}},[P,f,c,v,a]),C.jsxs(C.Fragment,{children:[t.top.vertices.length>0&&t.top.indices.length>0&&C.jsx(Pn,{id:f,name:c,visible:y&&E,vertices:t.top.vertices,indices:t.top.indices,position:r.add(h),colors:t.top.colors.length>0?t.top.colors:void 0,style:{},actions:P,materialType:"standard",gpuPick:!v,children:T}),t.side.vertices.length>0&&t.side.indices.length>0&&C.jsx(Pn,{id:f,name:c,visible:y&&I,vertices:t.side.vertices,indices:t.side.indices,position:r.add(h),colors:t.side.colors.length>0?t.side.colors:void 0,style:{},actions:P,materialType:"standard",gpuPick:!v,children:T}),t.bottom.vertices.length>0&&t.bottom.indices.length>0&&C.jsx(Pn,{id:f,name:c,visible:y&&L,vertices:t.bottom.vertices,indices:t.bottom.indices,position:r.add(h),colors:t.bottom.colors.length>0?t.bottom.colors:void 0,style:{},actions:P,gpuPick:!v,materialType:"standard",children:T}),l.map((k,B)=>C.jsxs("transformNode",{name:`roadway-name-${k.name}-${B}-root`,children:[C.jsx("transformNode",{name:`roadway-name-${k.name}-${B}`,position:k.position.add(h).add((b==null?void 0:b.offset)||new u.Vector3(0,0,0)),billboardMode:u.Mesh.BILLBOARDMODE_ALL,children:C.jsx(Je,{text:k.name,fontSize:(b==null?void 0:b.fontSize)||18,color:(b==null?void 0:b.color)||"#FFFFFF"})},B),b.offset&&b.offset.y!==0?C.jsx("lineSystem",{name:`roadway-name-${k.name}-${B}-line`,lines:[[k.position,k.position.add(b.offset)]],color:u.Color3.White()}):null]}))]})},uf=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[y,h]of c){let T=y;for(;d<p.length&&p[d][1]<=y;)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,y=[],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]&&y.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(y,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(Pn,{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))})},ff=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 Yi){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 y=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)),y=Math.max(...d.indices)),s+=y+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(uf,{id:s,node:l},l.name)),t&&r&&r.vertices.length>0&&C.jsx(Pn,{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"})]})},df=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})},pf=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,y]=m.useState(!1),[h,T]=m.useState(1),P=(v,_,b,E)=>{const I=u.Vector3.Distance(v,_)/E,S=u.Vector3.Distance(v,b),k=Math.floor(S/I);return Math.min(k,E-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,y(!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(df,{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})})})},hf=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(pf,{node:c,roadwayWidth:n,textureLength:a,url:r,visible:o,isBlink:i},s)})})};class mf{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 gf=({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),y=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 E=y.current;if(f&&E){v.current=gu({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 L=v.current;L.getBlockByName("MaskEnabled").value=0,L.build(!1,!0,!0);const I=n.start,S=n.end,k=u.Vector3.Normalize(S.subtract(I)),B=Math.asin(k.y),F=Math.atan2(k.x,k.z),w=new u.Vector3(-B,F,0);return P(w),E.morphTargetManager=new u.MorphTargetManager,E.morphTargetManager.enableNormalMorphing=!0,b.current=E.getVerticesData(u.VertexBuffer.PositionKind).slice(0),b.current.length===0&&console.log("[Geo3DViewer] 水模拟,原始 SourceKind 为空",t,n.name),E.material=v.current,()=>{var D;(D=v.current)==null||D.dispose()}}},[t,n.end,n.name,n.start,f]),m.useEffect(()=>{const E=y.current,L=y.current;if(E&&L){console.log(`[Geo3DViewer] 正在更新 ${t} / ${n.name} 的进度 Time: ${n.time/1e3}`);const I=L.getVerticesData(u.VertexBuffer.PositionKind).slice(0);I.length===0&&console.log("[Geo3DViewer] 水模拟 SourceKind 为空",t,n.name),L.updateMeshPositions(F=>{for(let w=0;w<F.length;w++)F[w]=b.current[w]});const S=L.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),E.updateMeshPositions(F=>{for(let w=0;w<F.length;w++)F[w]=S[w]});const k=new mf(I,S,E),B=new u.Animation("waterAnimation","influence",1e3/30,u.Animation.ANIMATIONTYPE_FLOAT,u.Animation.ANIMATIONLOOPMODE_CONSTANT);B.setKeys([{frame:0,value:0},{frame:10,value:1}]),f==null||f.beginDirectAnimation(k,[B],0,10,!1,10)}},[t,n.glurHeightMap,n.height,n.name,n.waterLength,n.time]),m.useEffect(()=>{const E=v.current;E&&(E.getBlockByName("TimeSpeed").value=a)},[a]),m.useEffect(()=>{const E=v.current;E&&(E.getBlockByName("PerlinMultiply").value=r)},[r]),m.useEffect(()=>{const E=v.current;E&&(E.getBlockByName("waterFlow").value=o)},[o]),m.useEffect(()=>{const E=v.current;E&&(E.getBlockByName("ClippedHeight").value=i)},[i]),m.useEffect(()=>{const E=v.current;E&&(E.alpha=l)},[l]),m.useEffect(()=>{const E=v.current;E&&(E.getBlockByName("Gradient").colorSteps=s,E.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:y,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})]})})},vf=e=>{const{nodes:t}=e;return C.jsx(C.Fragment,{children:t&&t.map((n,a)=>C.jsx(gf,{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))})},ya=e=>{const{rootUrl:t,size:n=1e3,name:a="skybox"}=e;return C.jsx(_e.Skybox,{rootUrl:t,size:n,name:a})};function ni(){return{name:"",origin:void 0,dataPoints:[]}}const Ca={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)dn.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=ni();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(dn.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skipType(o&7)}return r},fromJSON(e){return{name:yn(e.name)?globalThis.String(e.name):"",origin:yn(e.origin)?K.fromJSON(e.origin):void 0,dataPoints:globalThis.Array.isArray(e==null?void 0:e.dataPoints)?e.dataPoints.map(t=>dn.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=>dn.toJSON(a))),t},create(e){return Ca.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=ni();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=>dn.fromPartial(r)))||[],t}};function oi(){return{point:void 0,colorId:0,vColor:0,vRadius:0}}const dn={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=oi();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:yn(e.point)?K.fromJSON(e.point):void 0,colorId:yn(e.colorId)?globalThis.Number(e.colorId):0,vColor:yn(e.vColor)?globalThis.Number(e.vColor):0,vRadius:yn(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 dn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=oi();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 yn(e){return e!=null}var _a=(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))(_a||{});const Pa=({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,y]=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 E=Ca.decode(new Uint8Array(P)),{name:L,origin:I,dataPoints:S}=E;if(I&&S){y(L),T(new u.Vector3(I.x,I.y,I.z));const k=new Float32Array(S.length*16),B=new Float32Array(S.length*4);return S.forEach((F,w)=>{if(F.point){const D=new u.Vector3(F.point.x,F.point.y,F.point.z).multiplyByFloats(c&&c.scalePlane?c.scalePlane:1,c&&c.scaleDepth?c.scaleDepth:1,c&&c.scalePlane?c.scalePlane:1),N=u.Quaternion.Identity(),M=new u.Vector3(F.vRadius*o,F.vRadius*o,F.vRadius*o);if(u.Matrix.Compose(M,N,D).copyToArray(k,w*16),t){const A=p.colorCodecs[t].array,V=A[Math.floor(F.vColor*(A.length-1))];B.set([V.r,V.g,V.b,n],w*4)}else{const A=p.colorIDs[F.colorId];B.set([A.r,A.g,A.b,n],w*4)}}}),b&&(b.thinInstanceSetBuffer("matrix",k),b.thinInstanceSetBuffer("color",B,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 Sa=(e=>(e[e.OSM=1]="OSM",e[e.AMAP=2]="AMAP",e))(Sa||{});const Ta=({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:y=1})=>{const h=_e.useScene(),T=m.useRef(null),P=m.useRef(null),[v,_]=m.useState([]),[b,E]=m.useState([]);return m.useEffect(()=>{const L=T.current,I=P.current;if(L&&I){const S=L.getTotalVertices(),k=L.getIndices().length/(f.w*f.h),B=[];let F=0,w=0;for(let N=0;N<f.h;N++)for(let M=0;M<f.w;M++){const x=new u.SubMesh(F++,0,S,w,k,L);B.push(x),w+=k}const D=[];return[...Array(f.h).keys()].flatMap(N=>[...Array(f.w).keys()].map(M=>{const x=new u.StandardMaterial(`tileMap-material-${N}-${M}`),A=[`${t}/${l}/${s+M}/${c-N}.png`,`${t}/appmaptile?z=${l}&x=${s+M}&y=${c-N}&style=6`];return x.diffuseTexture=new u.Texture(A[A!=null&&A[e-1]?e-1:0],h),x.diffuseTexture.wrapU=u.Texture.CLAMP_ADDRESSMODE,x.diffuseTexture.wrapV=u.Texture.CLAMP_ADDRESSMODE,x.specularColor=u.Color3.Black(),x.backFaceCulling=!1,x})).forEach(N=>{D.push(N)}),E(B),_(D),L.subMeshes=B,I.subMaterials=D,()=>{I.subMaterials=[],L.subMeshes=[],_([]),E([])}}},[t,e,h,f.h,f.w,s,c,l]),C.jsx("transformNode",{name:"tileMap",setEnabled:n,position:d,scalingDeterminant:y,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 ri(){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)pn.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)Ue.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=ri();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(pn.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(Ue.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=>pn.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=>Ue.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=>pn.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=>Ue.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=ri();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=>pn.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=>Ue.fromPartial(f)))||[],t}};function ii(){return{position:void 0,start:void 0,end:void 0,color:void 0,angle:0,radius:0,innerRadius:0,texture:"",v:[]}}const pn={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=ii();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 pn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=ii();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 xf=(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})},yf=m.forwardRef(xf),Cf=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,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})})},_f=(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,y,h,T;return C.jsx(Cf,{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((y=s.end)==null?void 0:y.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)})})},Pf=m.forwardRef(_f),Sf=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:y,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,E,L)=>{var I,S,k,B,F,w;if(T.onHover&&t&&d&&b){const D=b;for(let N=0;N<d.length;N++){const M=new u.Vector3((I=d[N].start)==null?void 0:I.x,(S=d[N].start)==null?void 0:S.y,(k=d[N].start)==null?void 0:k.z).add(y).multiply(Oe(a)),x=new u.Vector3((B=d[N].end)==null?void 0:B.x,(F=d[N].end)==null?void 0:F.y,(w=d[N].end)==null?void 0:w.z).add(y).multiply(Oe(a)),A=u.MeshBuilder.CreateTube("boundingbox-tmp",{path:[M,x],radiusFunction:()=>{const $=d[N].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,E,L,d[N].v);break}}}}}:null})},[T,a,y,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:Hn,fragment:Wn,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(Zn,{alpha:f});if(c==="pbr-dark")return C.jsx(Gn,{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()})})},Tf=(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(Sf,{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})})},bf=m.forwardRef(Tf),kf=(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"})})},ba=m.forwardRef(kf),ka=e=>{var le,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(""),[y,h]=m.useState(new u.Vector3(0,0,0)),T=m.useRef(null),P=m.useRef(null),v=m.useRef(null),[_,b]=m.useState([]),E=m.useRef(!1),L=m.useContext(Le),[I,S]=m.useState([]),[k,B]=m.useState(!1),[F,w]=m.useState(!1),{id:D,url:N,color:M,visible:x=!0,materialType:A="custom",children:V,style:$,actions:U,noLod:re=!1,lodDistance:oe=[200,1e3],loadDistance:G=0,offset:ae=new u.Vector3(0,0,0),position:ne,topPosition:j,bottomPosition:Y,isRegular:ce=!0}=e;return m.useEffect(()=>{ne&&j&&Y?(s.current=ne,c.current=j,p.current=Y):w(!0)},[Y,ne,j]),m.useEffect(()=>{!E.current&&F&&(E.current=!0,Wt.get(N,{responseType:"arraybuffer"}).then(H=>{var he,ue,me,Ie,ke,Ae,Ne,we,Re;const Q=Nt.decode(new Uint8Array(H.data));console.log(Q);const Ee=Q.sliceList[0],be=Q.sliceList[Q.sliceList.length-1];d(Q.name);const ee=e.style.basePosition&&e.style.basePosition==="top"?Ee.start:be.end;h(new u.Vector3(ee==null?void 0:ee.x,ee==null?void 0:ee.y,ee==null?void 0:ee.z)),s.current=new u.Vector3((he=Q.origin)==null?void 0:he.x,(ue=Q.origin)==null?void 0:ue.y,(me=Q.origin)==null?void 0:me.z).add(ae),b(Q.sliceList.filter(Ve=>Ve.v)),c.current=new u.Vector3((Ie=Ee.start)==null?void 0:Ie.x,(ke=Ee.start)==null?void 0:ke.y,(Ae=Ee.start)==null?void 0:Ae.z).add(s.current),p.current=new u.Vector3((Ne=be.end)==null?void 0:Ne.x,(we=be.end)==null?void 0:we.y,(Re=be.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)}))},[N,t,M,A,e.style.basePosition,ae,F,L]),m.useEffect(()=>{const H=setInterval(()=>{var Q,Ee,be,ee,he,ue,me,Ie,ke,Ae,Ne,we,Re,Ve;if(t&&t.cameras.length>0&&t.activeCamera&&s.current&&c.current&&p.current){const We=Ot.calcLodDistance(c.current.multiply(Oe(L)),s.current.multiply(Oe(L)),p.current.multiply(Oe(L)),t.activeCamera.position);We>=G&&w(!0),re?(I.length===0?((Q=T.current)==null||Q.setEnabled(!0),(Ee=P.current)==null||Ee.setEnabled(!1)):((be=T.current)==null||be.setEnabled(!1),(ee=P.current)==null||ee.setEnabled(!0)),(he=v.current)==null||he.setEnabled(!0)):We<oe[0]?(B(!0),(ue=T.current)==null||ue.setEnabled(!0),(me=P.current)==null||me.setEnabled(I.length===0),(Ie=v.current)==null||Ie.setEnabled(!0)):oe[1]&&We<oe[1]?((ke=T.current)==null||ke.setEnabled(!1),(Ae=P.current)==null||Ae.setEnabled(!0),(Ne=v.current)==null||Ne.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,oe,I.length,L,t]),C.jsx(C.Fragment,{children:C.jsxs("transformNode",{name:`tube-${D} `,children:[C.jsxs(yf,{id:D,name:f,visible:x,position:(le=s.current)!=null?le:new u.Vector3(0,0,0),isRegular:ce,children:[F&&C.jsx(ba,{id:D,style:{title:f,position:y,offset:(X=$.offset)==null?void 0:X.multiply(ki(L)),fontSize:$.fontSize,color:$.color},ref:v}),k&&F&&oe[0]&&I.length>0&&C.jsx(Pf,{id:D,name:f,meshs:I,position:(Pe=s.current)!=null?Pe:new u.Vector3(0,0,0),materialType:A,slices:_,actions:U,ref:T}),F&&C.jsx(bf,{id:D,name:f,position:(ge=s.current)!=null?ge:new u.Vector3(0,0,0),vertices:n,indices:r,colors:i,color:M?new u.Color3(M.r,M.g,M.b):void 0,slices:_,actions:U,materialType:A,ref:P})]}),V]})})};function ai(){return{group:[]}}const Ea={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=ai();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 Ea.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=ai();return t.group=((n=e.group)==null?void 0:n.map(a=>Nt.fromPartial(a)))||[],t}},Na=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,y)=>y?new u.Color4(y==null?void 0:y.r,y==null?void 0:y.g,y==null?void 0:y.b,y==null?void 0:y.a):d||new u.Color4(1,1,1,1),[]);return m.useEffect(()=>{if(!r.current&&(r.current=!0,l&&Wt.get(l,{responseType:"arraybuffer"}).then(d=>{const y=Ea.decode(new Uint8Array(d.data)),h=[];for(let T=0;T<y.group.length;T++)h.push(y.group[T]);a(h)}),c&&c.length>0)){const d=[];for(let y=0;y<c.length;y++)d.push(Wt.get(c[y].url,{responseType:"arraybuffer"}));Promise.all(d).then(y=>{const h=[];for(let T=0;T<y.length;T++){const P=Nt.decode(new Uint8Array(y[T].data));h.push(P)}a(h)})}}),m.useEffect(()=>{var y,h,T,P,v,_,b,E,L;let d;if(n.length>0){const I=[],S=[];for(let k=0;k<n.length;k++){const B=n[k],F=new u.Vector3((y=B.origin)==null?void 0:y.x,(h=B.origin)==null?void 0:h.y,(T=B.origin)==null?void 0:T.z),w=B.sliceList;if(w){const D=[],N=[];for(let M=0;M<w.length;M++)D.push(F.add(new u.Vector3((P=w[M].start)==null?void 0:P.x,(v=w[M].start)==null?void 0:v.y,(_=w[M].start)==null?void 0:_.z)).multiply(Oe(o))),N.push(f(void 0,w[M].color)),M===w.length-1&&(D.push(F.add(new u.Vector3((b=w[M].end)==null?void 0:b.x,(E=w[M].end)==null?void 0:E.y,(L=w[M].end)==null?void 0:L.z)).multiply(Oe(o))),N.push(f(void 0,w[M].color)));I.push(D),S.push(N)}}d=u.MeshBuilder.CreateLineSystem("linesystem",{lines:I,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 y,h,T,P,v,_;return C.jsx(Xn,{position:new u.Vector3((y=d.origin)==null?void 0:y.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,{})})},So=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(Xn,{...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 si(){return{name:"",tubeName:"",min:0,max:0,origin:void 0,chart:[]}}const Zo={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)hn.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=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!==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(hn.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=>hn.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=>hn.toJSON(a))),t},create(e){return Zo.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=si();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=>hn.fromPartial(l)))||[],t}};function li(){return{position:void 0,depth:0,value:0}}const hn={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=li();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 hn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=li();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 Ef=`#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
|
-
}`,
|
|
1324
|
+
}`,Nf=`#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
|
-
}`,Nf=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(f.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:Ef,fragment:kf,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:f.Material.CounterClockWiseSideOrientation})},If=(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:u,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 y=new f.VertexData;y.positions=s,y.indices=c,y.colors=p,y.uvs=u,y.applyToMesh(a.current)}},[p,x,i,c,n,u,s]),C.jsxs("transformNode",{name:`node-curve-${i}`,position:d?d.multiply(new f.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1)):new f.Vector3(0,0,0),scaling:new f.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 f.Vector3(1,1,1),children:x?C.jsx(Nf,{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 f.Vector3(0,0,0),scaling:ct(o),children:h&&C.jsx(Je,{text:h,fontSize:P||40,color:T||"white"})})]})},wf=m.forwardRef(If),To=e=>{var N,M;const t=_e.useScene(),[n,a]=m.useState([]),[r,o]=m.useState([]),[i,l]=m.useState([]),[s,c]=m.useState([]),[p,u]=m.useState(),[d,x]=m.useState(),[h,T]=m.useState(),{colorCodecs:P}=m.useContext(Lt),{id:y,url:_,callback:b,visible:k=!0,customMaterial:L=!1,colorType:I,width:S=20,offset:E=new f.Vector3(0,0,0),direction:B="right"}=e,F=je({url:_,cacheType:Me.EXACTLY_MATCH}),w=m.useCallback((v,A,V,$,U=!0)=>{if(t){const ie=f.MeshBuilder.CreateRibbon("ribbon",{pathArray:[V,$],sideOrientation:U?f.Mesh.FRONTSIDE:f.Mesh.DOUBLESIDE},t),ne=ie.getVerticesData(f.VertexBuffer.PositionKind),G=ie.getIndices();if(ne&&G){const ae=Ot.buildTubeChartColors(ne,Y=>{if(I&&P&&P[I]){const ce=v.max,le=v.min;let X=new f.Color3(1,1,1);return le===le?X=P[I].array[P[I].array.length-1]:X=P[I].array[Math.trunc((v.chart[Y].value-le)/(ce-le)*(P[I].array.length-1))],new f.Color4(X.r,X.g,X.b,1)}return b?b(A[Y],Y,v.max,v.min):Ot.colorMapTubeChart()},U),oe=[],j=ne.length/3;for(let Y=0;Y<j;Y++)Y>=j/2?oe.push($[Y-j/2].x-V[Y-j/2].x,1):oe.push(0,1);a(ne.slice()),o(G.slice()),l(ae),c(oe)}t==null||t.removeMesh(ie)}},[b,P,I,t]);m.useEffect(()=>{var v,A,V,$,U;if(F){const ie=Zo.decode(new Uint8Array(F)),ne=S/(ie.max-ie.min),G=ie.min<0?-ie.min:0,ae=B==="right"?S/2:S;console.log(ie);const oe=[],j=ie.chart.map(X=>{const Pe=X.position?X.position:{x:0,y:0,z:0};return oe.push(X.value),new f.Vector3(Pe.x-ae,Pe.y+10,Pe.z)}),Y=ie.chart.map(X=>{const Pe=X.position?X.position:{x:0,y:0,z:0},ge=B==="right"?(X.value+G)*ne:-(X.value+G)*ne;return new f.Vector3(Pe.x+ge-ae,Pe.y+10,Pe.z)});T(ie.name),u(new f.Vector3((v=ie.origin)==null?void 0:v.x,(A=ie.origin)==null?void 0:A.y,(V=ie.origin)==null?void 0:V.z).add(E));const ce=S/2-(($=e.style)!=null&&$.fontSize?e.style.fontSize/2:0),le=j[j.length-1].add(new f.Vector3(B==="right"?ce:-ce,0,0)).add((U=e.style)!=null&&U.offset?e.style.offset:new f.Vector3(0,0,0));x(new f.Vector3(le.x,le.y,le.z)),w(ie,oe,j.splice(0,j.length),Y.splice(0,Y.length),!0)}},[w,_,t,E,(N=e.style)==null?void 0:N.offset,S,(M=e.style)==null?void 0:M.fontSize,F,B]);const D=m.useCallback(()=>{},[]);return m.useEffect(()=>{const v=()=>{D()};return t&&t.activeCamera&&(v(),t==null||t.activeCamera.onViewMatrixChangedObservable.add(v)),()=>{t&&t.activeCamera&&(t==null||t.activeCamera.onViewMatrixChangedObservable.removeCallback(v))}},[D,t]),C.jsx(C.Fragment,{children:k&&n.length>0&&i.length>0&&C.jsx(wf,{id:y,visible:k,vertices:n,colors:i,uvs:s,indices:r,position:p,style:{...e.style,title:h,position:d},customMaterial:L})})},Of=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 f.Vector3(n?n.scalePlane:1,n?n.scaleDepth:1,n?n.scalePlane:1)):new f.Vector3(0,0,0),scaling:new f.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 f.Vector3(0,0,0),scaling:ct(n),children:i&&C.jsx(Je,{text:i,fontSize:s||40,color:l||"white"})})})},Ia=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:u,visible:d=!0,offset:x=new f.Vector3(0,0,0),color:h,width:T=20}=e,P=je({url:u,cacheType:Me.EXACTLY_MATCH}),y=m.useContext(Le);return m.useEffect(()=>{var k,L,I,S,E,B,F,w;if(P){const D=Zo.decode(new Uint8Array(P)),N=T/(D.max-D.min),M=D.min<0?-D.min:0,v=new f.Vector3((k=D.origin)==null?void 0:k.x,(L=D.origin)==null?void 0:L.y,(I=D.origin)==null?void 0:I.z).add(x);a(v);const A=D.chart,V=[];for(let U=0;U<A.length;U++)V.push(v.add(new f.Vector3((S=A[U].position)==null?void 0:S.x,(E=A[U].position)==null?void 0:E.y,(B=A[U].position)==null?void 0:B.z)).add(new f.Vector3((A[U].value+M)*N,0,0)).multiply(Oe(y)));c([V]);const $=A[A.length-1].position;if($){const U=new f.Vector3($.x,$.y,$.z).add(new f.Vector3(T/2-((F=e.style)!=null&&F.fontSize?e.style.fontSize/2:0),0,0)).add((w=e.style)!=null&&w.offset?e.style.offset:new f.Vector3(0,0,0));o(new f.Vector3(U.x,U.y,U.z))}l(D.name)}},[u,t,x,(_=e.style)==null?void 0:_.offset,(b=e.style)==null?void 0:b.fontSize,P,y,T]),C.jsxs(C.Fragment,{children:[C.jsx(Of,{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 ci(){return{name:"",origin:void 0,layerList:[]}}const wa={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)mn.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=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.layerList.push(mn.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=>mn.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=>mn.toJSON(a))),t},create(e){return wa.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;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.layerList=((a=e.layerList)==null?void 0:a.map(r=>mn.fromPartial(r)))||[],t}};function ui(){return{name:"",position:void 0,start:void 0,end:void 0,radius:0,colorId:0,v:[]}}const mn={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=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.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 mn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o;const t=ui();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 Af=(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:u,materialType:d="custom",children:x,alphaBlend:h=!1,alpha:T=1,name:P="tube",actions:y,slices:_}=e;m.useImperativeHandle(t,()=>r.current,[]),m.useEffect(()=>{a.current&&(a.current.metadata={pickable:y?{needWorldPosition:!0,name:P,onLeftClick:y.onLeftClick,onRightClick:y.onRightClick,onMiddleClick:y.onMiddleClick,onHover:(k,L,I,S,E)=>{var B,F,w,D,N,M;if(y.onHover&&n&&_&&I){const v=I;for(let A=0;A<_.length;A++){const V=new f.Vector3((B=_[A].start)==null?void 0:B.x,(F=_[A].start)==null?void 0:F.y,(w=_[A].start)==null?void 0:w.z).add(u).multiply(Oe(o)),$=new f.Vector3((D=_[A].end)==null?void 0:D.x,(N=_[A].end)==null?void 0:N.y,(M=_[A].end)==null?void 0:M.z).add(u).multiply(Oe(o)),U=Math.sqrt(Math.pow(V.x-$.x,2)+Math.pow(V.y-$.y,2)+Math.pow(V.z-$.z,2)),ie=new f.Vector3(V.x,V.y-U,V.z),ne=$.subtract(V),G=ie.subtract(V),ae=v.subtract(V),oe=f.Vector3.Cross(ne,G),j=Math.acos(f.Vector3.Dot(ne.normalize(),G.normalize())),Y=f.Matrix.RotationAxis(oe,j),ce=f.Vector3.TransformCoordinates(ae,Y);if(0>=ce.y&&-U<=ce.y){y.onHover(k,L,I,S,_[A],E);break}}}},valueCallback:null,extra:y.extra}:null})},[y,o,u,n,_]),m.useEffect(()=>{if(a&&a.current&&n){const k=new f.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:Hn,fragment:Wn,needDepthPrePass:!1,transparencyMode:h?f.Material.MATERIAL_ALPHABLEND:f.Material.MATERIAL_OPAQUE,options:{needAlphaBlending:!!h}});if(d==="standard")return C.jsx("standardMaterial",{name:`${P}-material`,alphaMode:f.Engine.ALPHA_COMBINE,transparencyMode:h?f.Material.MATERIAL_ALPHABLEND:f.Material.MATERIAL_OPAQUE,alpha:T});if(d==="pbr-light")return C.jsx(Zn,{alpha:T});if(d==="pbr-dark")return C.jsx(Gn,{alpha:T})},[T,h,i,d,P]);return C.jsxs("transformNode",{name:`node-${P}-${i}`,setEnabled:l,children:[C.jsx("transformNode",{name:`${P}`,position:u?u.multiply(new f.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1)):new f.Vector3(0,0,0),scaling:new f.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]})},Mf=m.forwardRef(Af),Lf=(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 f.Vector3(0,0,0),color:c="white",fontSize:p=40,showLabel:u=!0}=e;return C.jsx("transformNode",{name:`node-layer-${r}`,position:i?i.add(s).multiply(new f.Vector3(a?a.scalePlane:1,a?a.scaleDepth:1,a?a.scalePlane:1)):new f.Vector3(0,0,0).add(s),scaling:new f.Vector3(a?a.scalePlane:1,a?a.scaleDepth:1,a?a.scalePlane:1),ref:n,setEnabled:o,children:u?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,{})})},Rf=m.forwardRef(Lf),bo=e=>{var w,D,N,M,v;const t=_e.useScene(),[n,a]=m.useState([]),[r,o]=m.useState([]),[i,l]=m.useState([]),[s,c]=m.useState(),[p,u]=m.useState([]),[d,x]=m.useState(0),[h,T]=m.useState(),{colorIDs:P}=m.useContext(Lt),{id:y,url:_,color:b,layers:k=[],visible:L=!0,tessellation:I=64,frontSide:S=!1,customMaterial:E=!1,actions:B}=e,F=je({url:_,cacheType:Me.EXACTLY_MATCH});return m.useEffect(()=>{var A,V,$,U,ie,ne;if(F){const G=wa.decode(new Uint8Array(F)),ae=[];G.layerList.forEach((ge,H)=>{var Q,Ee,be,ee,he,ue;ae.push(ge),H<G.layerList.length&&ae.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:(ee=(be=ge==null?void 0:ge.end)==null?void 0:be.y)!=null?ee:0,z:(ue=(he=ge==null?void 0:ge.end)==null?void 0:he.z)!=null?ue:0}})});const oe=ae.map(ge=>{const H=ge.start?ge.start:{x:0,y:0,z:0};return new f.Vector3(H.x,H.y,H.z)}),j=f.MeshBuilder.CreateTube("tube-tmp",{path:oe,radiusFunction:ge=>{var Q;const H=(Q=ae[ge])==null?void 0:Q.radius;return H||1},cap:f.Mesh.NO_CAP,tessellation:I,sideOrientation:S?f.Mesh.FRONTSIDE:f.Mesh.DOUBLESIDE},t),Y=j.getVerticesData(f.VertexBuffer.PositionKind),ce=E?Ot.correctTubeMainIndices(j.getIndices()):j.getIndices(),le=b;let X=[];Y&&(X=Ot.buildTubeMainColors(Y,ae.map(ge=>{const H=le||(P&&P[ge.colorId]?P[ge.colorId]:Ot.randomColorMap()),Q=k.findIndex(Ee=>Ee===ge.name)!==-1?H.a:0;return new f.Color4(H.r,H.g,H.b,Q)}),I,!!S)),T(G),a(Y?Y.slice():[]),o(ce?ce.slice():[]),l(X),c(new f.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(j);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 f.Vector3((U=H.position)==null?void 0:U.x,(ie=H.position)==null?void 0:ie.y,(ne=H.position)==null?void 0:ne.z)})}u(Pe),x(G.layerList?G.layerList[0].radius:0)}},[_,t,S,I,E,k,P,F,b]),C.jsxs("transformNode",{name:`node-layer-${y}`,children:[n.length>0&&r.length>0&&C.jsx(Mf,{id:y,name:"tube-layer",visible:L,vertices:n,slices:h==null?void 0:h.layerList,indices:r,position:s,colors:i.length>0?i:void 0,materialType:E?"custom":"standard",alphaBlend:!0,actions:B}),p.length>0&&C.jsx(Rf,{id:y,data:p,visible:L,position:s,fontSize:(w=e.style)==null?void 0:w.fontSize,color:(D=e.style)==null?void 0:D.color,offset:(M=(N=e.style)==null?void 0:N.offset)==null?void 0:M.add(new f.Vector3(d,0,0)),showLabel:(v=e.style)==null?void 0:v.showLabel})]})},fi=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:u="cap",materialType:d,tessellation:x,data:h}=e,T=m.useCallback(()=>{const y=[],_=[];for(let B=0;B<2*x+1;B++)if(p==="start")y.push(new f.Vector3(h[B*3],h[B*3+1],h[B*3+2]));else{const F=h.length-2*x*3;y.push(new f.Vector3(h[B*3+F],h[B*3+1+F],h[B*3+2+F]))}const b=[],k=[];for(let B=0;B<x;B++)b.push(y[B]),k.push(y[2*x-B-1]);_.push(b,k);const L=f.MeshBuilder.CreateRibbon("ribbon-tmp",{pathArray:_,sideOrientation:f.Mesh.DOUBLESIDE},t),I=L.getVerticesData(f.VertexBuffer.PositionKind),S=L.getIndices(),E=L.getNormalsData();r(I?I.slice():[]),i(S?S.slice():[]),s(E?E.slice():[]),t==null||t.removeMesh(L)},[t,x,p,h]);m.useEffect(()=>{T()},[T]),m.useEffect(()=>{if(n&&n.current&&t){const y=new f.VertexData;y.positions=a,y.indices=o,y.normals=l,y.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 f.Color3(248/255,163/255,151/255),emissiveColor:new f.Color3(36/255,36/255,36/255),transparencyMode:f.Material.MATERIAL_OPAQUE}):C.jsx("standardMaterial",{name:`${u}-material`,alphaMode:f.Engine.ALPHA_COMBINE,transparencyMode:f.Material.MATERIAL_OPAQUE,diffuseColor:new f.Color3(c.r,c.g,c.b)}),[c.b,c.g,c.r,d,u]);return C.jsx("mesh",{name:`${u}-mesh`,ref:n,isPickable:!0,children:P()})},Oa=e=>{const t=_e.useScene(),n=m.useRef(null),[a,r]=m.useState(f.Vector3.Zero()),[o,i]=m.useState([]),[l,s]=m.useState([]),[c,p]=m.useState([]),[u,d]=m.useState(""),[x,h]=m.useState(new f.Vector3(0,0,0)),[T,P]=m.useState([]),y=m.useContext(Le),{id:_,color:b,url:k,name:L="tube",children:I,materialType:S="standard",actions:E,tessellation:B=32,style:F}=e,w=m.useRef(!1),D=m.useCallback(M=>{var ne,G,ae;const v=M.sliceList.filter(oe=>!(oe.v.length>0)).map(oe=>{const j=oe.start?oe.start:{x:0,y:0,z:0};return new f.Vector3(j.x,j.y,j.z)}),A=M.sliceList[M.sliceList.length-1];if(v.length>0&&v.push(new f.Vector3((ne=A.end)==null?void 0:ne.x,(G=A.end)==null?void 0:G.y,(ae=A.end)==null?void 0:ae.z)),v.length<1)return;const V=f.MeshBuilder.ExtrudeShape("tmp",{path:v,sideOrientation:f.Mesh.DOUBLESIDE,shape:Ot.buildSemiRing(A.innerRadius,A.radius,B),cap:f.Mesh.NO_CAP},t);P(V.getVerticesData(f.VertexBuffer.PositionKind)),V.convertToFlatShadedMesh(),V.computeWorldMatrix(!0),V._updateBoundingInfo();const $=V.getVerticesData(f.VertexBuffer.PositionKind),U=V.getIndices(),ie=V.getNormalsData();i($?$.slice():[]),s(U?U.slice():[]),p(ie?ie.slice():[]),t==null||t.removeMesh(V)},[t,B]);m.useEffect(()=>{w.current||(w.current=!0,Wt.get(k,{responseType:"arraybuffer"}).then(M=>{var V,$,U;const v=Nt.decode(new Uint8Array(M.data));if(console.log(v),v.sliceList.length===0)return;d(v.name);const A=F!=null&&F.basePosition&&F.basePosition==="top"?v.sliceList[0].start:v.sliceList[v.sliceList.length-1].end;h(new f.Vector3(A==null?void 0:A.x,A==null?void 0:A.y,A==null?void 0:A.z)),r(new f.Vector3((V=v.origin)==null?void 0:V.x,($=v.origin)==null?void 0:$.y,(U=v.origin)==null?void 0:U.z)),D(v)}))},[D,F==null?void 0:F.basePosition,k]),m.useEffect(()=>{if(n&&n.current&&t){const M=new f.VertexData;M.positions=o,M.indices=l,M.normals=c,M.applyToMesh(n.current)}},[l,o,t,c]),m.useEffect(()=>{n.current&&(n.current.metadata={pickable:E?{name:L,value:_,onLeftClick:E.onLeftClick,valueCallback:()=>_,onRightClick:E.onRightClick,onMiddleClick:E.onMiddleClick,onHover:E.onHover}:null})},[E,_,y,L,a,t]);const N=m.useCallback(()=>S==="pbr"?C.jsx("pbrMaterial",{name:"main-pbr-material",alpha:1,metallic:1,roughness:.03,albedoColor:new f.Color3(230/255,230/255,230/255),emissiveColor:new f.Color3(71/255,71/255,71/255),transparencyMode:f.Material.MATERIAL_OPAQUE}):C.jsx("standardMaterial",{name:`${L}-material`,alphaMode:f.Engine.ALPHA_COMBINE,transparencyMode:f.Material.MATERIAL_OPAQUE,diffuseColor:new f.Color3(b.r,b.g,b.b)}),[b.b,b.g,b.r,S,L]);return C.jsxs("transformNode",{name:`${L}-main-node`,position:a.multiply(Oe(y)),scaling:Oe(y),children:[C.jsx("mesh",{name:`${L}-mesh`,ref:n,isPickable:!0,children:N()}),T.length>0&&C.jsx(fi,{id:1,name:"start",color:b,type:"start",tessellation:B,data:T,materialType:S}),T.length>0&&C.jsx(fi,{id:2,name:"end",color:b,type:"end",tessellation:B,data:T,materialType:S}),F&&C.jsx(ba,{id:_,style:{title:u,position:x,offset:F.offset,fontSize:F.fontSize,color:F.color}}),I]})},Aa=e=>{const{id:t,visible:n=!0,children:a,offset:r=new f.Vector3(0,0,0)}=e;return C.jsx(C.Fragment,{children:C.jsx("transformNode",{name:`tube-${t}`,setEnabled:n,position:r,children:a})})};function di(){return{name:"",origin:void 0,dataPoints:[],size:void 0}}const Ma={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)gn.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=di();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(gn.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=>gn.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=>gn.toJSON(a))),e.size!==void 0&&(t.size=K.toJSON(e.size)),t},create(e){return Ma.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=di();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=>gn.fromPartial(r)))||[],t.size=e.size!==void 0&&e.size!==null?K.fromPartial(e.size):void 0,t}};function pi(){return{point:void 0,colorId:0,vScale:0,rotation:void 0,pointType:0}}const gn={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=pi();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 gn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=pi();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 Bf=[0,.05,.1,.15,.2,.25,.3,.35,.4,.45,.5,.55,.6,.65,.7,.75,.8,.85,.9,.95,1],La=({url:e,alpha:t={typeAlpha0:1,typeAlpha1:1},offset:n=f.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(f.Vector3.Zero()),u=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=>Bf[T];return m.useEffect(()=>{if(r&&u){const T=Ma.decode(new Uint8Array(u)),{name:P,origin:y,dataPoints:_,size:b}=T;if(y&&_){s(P),p(new f.Vector3(y.x,y.y,y.z));let k=null;b&&(k=f.MeshBuilder.CreateBox("voxel",{width:b.x-1e-5,height:b.y-1e-5,depth:b.z-1e-5},r),k.material=d.current,f.Tags.EnableFor(k),f.Tags.AddTagsTo(k,"loading"));const L=new Float32Array(_.length*16),I=new Float32Array(_.length*4);return _.forEach((S,E)=>{if(S.point){const B=new f.Vector3(S.point.x,S.point.y,S.point.z),F=S.rotation?f.Quaternion.FromEulerAngles(S.rotation.x,S.rotation.y,S.rotation.z):f.Quaternion.Identity(),w=new f.Vector3(S.vScale+1,S.vScale+1,S.vScale+1);f.Matrix.Compose(w,F,B).copyToArray(L,E*16);let N=i.colorIDs[S.colorId];N||(N=f.Color4.FromColor3(f.Color3.Random())),I.set([N.r,N.g,N.b,h(S.pointType)],E*4)}}),k&&(k.thinInstanceSetBuffer("matrix",L),k.thinInstanceSetBuffer("color",I,4),k.parent=x.current),f.Tags.RemoveTagsFrom(k,"loading"),()=>{k&&(k.thinInstanceSetBuffer("matrix",new Float32Array),k.thinInstanceSetBuffer("color",new Float32Array),r.removeMesh(k))}}}},[i.colorIDs,r,u]),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 f.Vector3(o?o.scalePlane:1,o?o.scaleDepth:1,o?o.scalePlane:1),ref:x,children:C.jsx(yu,{name:`voxel-${l}-mat`,typeAlpha:t,ref:d})})},Ff=(e,t)=>{const{viewer:n,camera:a,useUniversalCamera:r=!1,lights:o,complexFormationManagers:i,formationManagers:l,formationFaces:s,formationVolumes:c,structureLayers:p,colorCodec:u,gridDiagrams:d,attributeBodies:x,tubes:h,roadways:T,densitySlices:P,formationSlices:y,rayClick:_,lines:b,spaceHeats:k,lookAt:L,fps:I,coordinate:S,tileMaps:E,pointClickZones:B,progressedAttributeBodies:F,ribbonLayers:w,intersectingLines:D,tubeInstances:N,optimizer:M,voxelGrids:v,planeImages:A,guiTexts:V,skybox:$,particleSystems:U,waterEffects:ie,modelLoaders:ne,modelAnimationLoaders:G,roadwayAnimations:ae,roadwayNearAnimations:oe,roadwayWaterAnimations:j,contourlines:Y,tubeTools:ce,tubeOils:le,tubeLayers:X,tubeChartLines:Pe,tubeCharts:ge}=e;return C.jsxs(Ho,{...n,ref:t,children:[r?C.jsx(zu,{...a}):C.jsx(ra,{...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(ji,{...H},`complexFormationManager-${H.url}`)):C.jsx(C.Fragment,{}),P?P.map(H=>C.jsx($o,{...H},`densitySlice-${H.url}`)):C.jsx(C.Fragment,{}),y?y.map(H=>C.jsx(Wo,{...H},`formationSlice-${H.url}`)):C.jsx(C.Fragment,{}),l?l.map(H=>C.jsx(oa,{...H},`formationManager-${H.url}`)):C.jsx(C.Fragment,{}),s?s.map(H=>C.jsx(Yn,{...H},`formation-face-${H.urlTopLayer}`)):C.jsx(C.Fragment,{}),c?c.map(H=>C.jsx(Jn,{...H},`formation-volume-${H.url}`)):C.jsx(C.Fragment,{}),p?p.map(H=>C.jsx(Do,{...H},`structurelayer-${H.url}`)):C.jsx(C.Fragment,{}),u?C.jsx(Ki,{...u}):C.jsx(C.Fragment,{}),d?d.map(H=>C.jsx(sa,{...H},`gridDiagram-${H.url}`)):C.jsx(C.Fragment,{}),x?x.map(H=>C.jsx(qi,{...H},`attributebody-${H.url}`)):C.jsx(C.Fragment,{}),h?h.map(H=>C.jsxs(ka,{...H,children:[H.charts?H.charts.map(Q=>C.jsx(To,{...Q},`tubechart-${Q.url}`)):C.jsx(C.Fragment,{}),H.layers?H.layers.map(Q=>C.jsx(bo,{...Q},`tubelayer-${Q.url}`)):C.jsx(C.Fragment,{}),H.tools?H.tools.map(Q=>C.jsx(So,{...Q},`tubelayer-${Q.name}`)):C.jsx(C.Fragment,{})]},`tube-${H.url}`)):C.jsx(C.Fragment,{}),T?T.map(H=>C.jsx(xa,{...H},`roadway-${H.url}`)):C.jsx(C.Fragment,{}),_?_.map((H,Q)=>C.jsx(ga,{...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(Pa,{...H},`spaceheat-${Q}`)):C.jsx(C.Fragment,{}),L?C.jsx(ca,{target:void 0,distance:0}):C.jsx(C.Fragment,{}),I?C.jsx(na,{}):C.jsx(C.Fragment,{}),S?C.jsx(ea,{...S},"coordinate"):C.jsx(C.Fragment,{}),E?E.map((H,Q)=>C.jsx(Ta,{...H},`tilemap-${Q}`)):C.jsx(C.Fragment,{}),B?B.map((H,Q)=>C.jsx(ha,{...H},`pointClickZone-${Q}`)):C.jsx(C.Fragment,{}),F?F.map((H,Q)=>C.jsx(ma,{...H},`progressedAttributeBody-${Q}`)):C.jsx(C.Fragment,{}),w?w.map((H,Q)=>C.jsx(va,{...H},`ribbonlayer-${Q}`)):C.jsx(C.Fragment,{}),D?D.map((H,Q)=>C.jsx(la,{...H},`intersectingLine-${Q}`)):C.jsx(C.Fragment,{}),N?N.map((H,Q)=>C.jsx(Na,{...H},`tubeinstance-${Q}`)):C.jsx(C.Fragment,{}),M?C.jsx(fa,{}):C.jsx(C.Fragment,{}),v?v.map((H,Q)=>C.jsx(La,{...H},`voxelgrid-${Q}`)):C.jsx(C.Fragment,{}),A?A.map((H,Q)=>C.jsx(da,{...H},`planeimage-${Q}`)):C.jsx(C.Fragment,{}),V?V.map((H,Q)=>C.jsx(Ru,{...H},`guitext-${Q}`)):C.jsx(C.Fragment,{}),$&&C.jsx(ya,{...$}),U?U.map((H,Q)=>C.jsx(ef,{...H},`particlesystem-${Q}`)):C.jsx(C.Fragment,{}),ie?ie.map((H,Q)=>C.jsx(tf,{...H},`waterEffect-${Q}`)):C.jsx(C.Fragment,{}),ne?ne.map((H,Q)=>C.jsx(Xn,{...H},`modelLoaders-${Q}`)):C.jsx(C.Fragment,{}),G?G.map((H,Q)=>C.jsx(ju,{...H},`modelanimtionloader-${Q}`)):C.jsx(C.Fragment,{}),ae?ae.map((H,Q)=>C.jsx(Ln,{...H,children:C.jsx(uf,{})},`animation-${Q}`)):C.jsx(C.Fragment,{}),oe?oe.map((H,Q)=>C.jsx(Ln,{...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,{}),j?j.map((H,Q)=>C.jsx(Ln,{...H,children:C.jsx(gf,{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(wu,{...H},`contourline-${Q}`)):C.jsx(C.Fragment,{}),ce?ce.map((H,Q)=>C.jsx(So,{...H},`tubeTool-${Q}`)):C.jsx(C.Fragment,{}),le?le.map((H,Q)=>C.jsx(Aa,{...H,children:H.main?H.main.map((Ee,be)=>C.jsx(Oa,{...Ee},`tubeMain-${be}`)):null},`tubeOil-${Q}`)):C.jsx(C.Fragment,{}),X?X.map((H,Q)=>C.jsx(bo,{...H},`tubeLayer-${Q}`)):C.jsx(C.Fragment,{}),Pe?Pe.map((H,Q)=>C.jsx(Ia,{...H},`tubeChartLine-${Q}`)):C.jsx(C.Fragment,{}),ge?ge.map((H,Q)=>C.jsx(To,{...H},`tubeChart-${Q}`)):C.jsx(C.Fragment,{})]})},Df=m.forwardRef(Ff),zf=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 f.Animation("roam","position",40,f.Animation.ANIMATIONTYPE_VECTOR3,f.Animation.ANIMATIONLOOPMODE_CONSTANT);for(let i=0;i<a.length;i++)i!==a.length-1&&o.addEvent(new f.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 f.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:f.Color3.Red(),specularColor:f.Color3.Black(),alpha:1})},i))]})};function hi(){return{name:"",origin:void 0,type:"",sliceList:[],vertices:[],normals:[],indices:[],uv:[]}}const Ra={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)vn.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=hi();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(vn.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=>vn.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=>vn.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 Ra.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,l,s;const t=hi();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=>vn.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 mi(){return{position:void 0,start:void 0,end:void 0,color:void 0,angle:0,radius:0,bottomRadius:0,texture:"",v:[]}}const vn={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=mi();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 vn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=mi();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 Vf=e=>{const t=_e.useScene(),[n,a]=m.useState([]),[r,o]=m.useState([]),[i,l]=m.useState(f.Vector3.Zero()),s=m.useContext(Le),c=m.useRef(null),p=m.useRef(!1),[u,d]=m.useState([]),{url:x,name:h="rod",visible:T=!0,color:P}=e,y=m.useCallback(_=>{var E,B,F;const b=_.sliceList.filter(w=>!(w.v.length>0)).map(w=>{const D=w.start?w.start:{x:0,y:0,z:0};return new f.Vector3(D.x,D.y,D.z)}),k=_.sliceList[_.sliceList.length-1];if(b.length>0&&b.push(new f.Vector3((E=k.end)==null?void 0:E.x,(B=k.end)==null?void 0:B.y,(F=k.end)==null?void 0:F.z)),b.length<1)return;const L=f.MeshBuilder.CreateTube("tube-tmp",{path:b,radiusFunction:w=>{if(e.radius)return e.radius;const D=_.sliceList[w]?_.sliceList[w].radius:_.sliceList[w-1].radius;return D||1},cap:f.Mesh.CAP_ALL,tessellation:24,sideOrientation:f.Mesh.FRONTSIDE},t),I=L.getVerticesData(f.VertexBuffer.PositionKind),S=L.getIndices();a(I?I.slice():[]),o(S?S.slice():[]),t==null||t.removeMesh(L)},[e.radius,t]);return m.useEffect(()=>{p.current||(p.current=!0,Wt.get(x,{responseType:"arraybuffer"}).then(_=>{var k,L,I;const b=Ra.decode(new Uint8Array(_.data));b.sliceList.length!==0&&(d(b.sliceList),l(new f.Vector3((k=b.origin)==null?void 0:k.x,(L=b.origin)==null?void 0:L.y,(I=b.origin)==null?void 0:I.z)),console.log(b),y(b))}))},[y,x]),m.useEffect(()=>{if(c&&c.current&&t){const _=new f.VertexData;_.positions=n,_.indices=r,_.applyToMesh(c.current)}},[r,n,t]),m.useEffect(()=>{var b,k,L;let _;if(u.length>0&&t){_=f.MeshBuilder.CreateSphere("top",{diameter:u[0].bottomRadius*2,segments:32},t);const I=new f.StandardMaterial("myMaterial",t);_.material=I,_.setEnabled(!1),I.diffuseColor=new f.Color3(P.r,P.g,P.b);for(let S=0;S<u.length;S++){const E=u[S],B=_.createInstance("tubeinstance-sphere-"+S);B.setEnabled(T);const F=i.multiply(Oe(s));B.position=F.add(new f.Vector3((b=E.position)==null?void 0:b.x,(k=E.position)==null?void 0:k.y,(L=E.position)==null?void 0:L.z).multiply(Oe(s)))}}return()=>{_&&_.dispose()}},[P.b,P.g,P.r,s,i,t,u,T]),C.jsx("transformNode",{name:`${h}-rod-node`,position:i.multiply(Oe(s)),setEnabled:T,scaling:new f.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 f.Color3(P.r,P.g,P.b)})})})};class $f{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=ja.createRoot(t);console.log("create root!");const a=m.createElement(Ho,{ref:this.ref,...this.params},this.children);n.render(a)}}const Uf=(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},Wf=m.forwardRef(Uf);class Hf{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(Wf,{ref:this.ref,key:(t=this.value.id)!=null?t:0,props:this.value,type:this.type})}}function Zf(e,t){return new Hf(e,t)}function Go(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 Gf(e){return{vertices:Go(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 Ba(e){return{vertices:e.vertices,indices:e.indices,values:[],vMin:0,vMax:1,colorId:e.colorId}}function Fa(e){return{vertices:Go(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 Yf(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{origin:{x:t,y:n,z:a},uAxis:{x:r-t,y:o-n,z:i-a},vAxis:{x:l-t,y:s-n,z:c-a}}}function Jf(e){const[t,n,a]=e,r={x:a.x-t.x,y:0,z:a.z-t.z},o={x:0,y:n.y-t.y,z:0};if(r.x===0&&r.z===0)throw new Error("Invalid planeCorners: point1 and point3 must define a non-zero x/z diagonal");if(o.y===0)throw new Error("Invalid planeCorners: point1 and point2 must define a non-zero height");return{origin:t,uAxis:r,vAxis:o}}function Da(e,t){const n=[],a=Math.sqrt(t.uAxis.x**2+t.uAxis.y**2+t.uAxis.z**2),r=Math.sqrt(t.vAxis.x**2+t.vAxis.y**2+t.vAxis.z**2);if(a<1e-10||r<1e-10)throw new Error("Invalid plane basis: axis length is zero");const o={x:t.uAxis.x/a,y:t.uAxis.y/a,z:t.uAxis.z/a},i={x:t.vAxis.x/r,y:t.vAxis.y/r,z:t.vAxis.z/r};for(let l=0;l<e.length;l+=3){const s=e[l]-t.origin.x,c=e[l+1]-t.origin.y,p=e[l+2]-t.origin.z;n.push({u:s*o.x+c*o.y+p*o.z,v:s*i.x+c*i.y+p*i.z})}return n}function Xf(e,t){const n=[];for(const a of e)n.push(a.x,a.y,a.z);return Da(n,t)}function qf(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 go(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 vo(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 Kf(e,t,n,a,r,o){const{indices:i,values:l,vMin:s,vMax:c,colorId:p}=e,{colorCodecs:u,colorIDs:d,colorCodecKey:x}=o,h=r.data,T=!!(x&&u&&u[x]),P=T?u[x]:null;for(let y=0;y<i.length;y+=3){const _=i[y],b=i[y+1],k=i[y+2],L=a[_],I=a[b],S=a[k],E=Math.max(0,Math.floor(Math.min(L.u,I.u,S.u))),B=Math.min(t-1,Math.ceil(Math.max(L.u,I.u,S.u))),F=Math.max(0,Math.floor(Math.min(L.v,I.v,S.v))),w=Math.min(n-1,Math.ceil(Math.max(L.v,I.v,S.v)));let D,N,M;T&&P?(D=go(P,l[_],s,c),N=go(P,l[b],s,c),M=go(P,l[k],s,c)):(D=vo(d!=null?d:{},p),N=vo(d!=null?d:{},p),M=vo(d!=null?d:{},p));for(let v=F;v<=w;v++)for(let A=E;A<=B;A++){const[V,$,U,ie]=qf(L,I,S,A,v);if(!ie)continue;const ne=(v*t+A)*4;h[ne]=Math.round(Math.max(0,Math.min(255,(V*D[0]+$*N[0]+U*M[0])*255))),h[ne+1]=Math.round(Math.max(0,Math.min(255,(V*D[1]+$*N[1]+U*M[1])*255))),h[ne+2]=Math.round(Math.max(0,Math.min(255,(V*D[2]+$*N[2]+U*M[2])*255))),h[ne+3]=Math.round(Math.max(0,Math.min(255,(V*D[3]+$*N[3]+U*M[3])*255)))}}}function gi(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 Qf(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 u=Math.max(1,Math.round(t*a.pixelsPerUnit*r)),d=Math.max(1,Math.round(n*a.pixelsPerUnit*r)),x=Math.min(o/u,i/d,1);return{width:Math.max(1,Math.round(u*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 u=Math.max(1,Math.min(o,Math.round(a.width*r)));return{width:u,height:Math.max(1,Math.min(i,Math.round(u/e)))}}if(a.height!=null){const u=Math.max(1,Math.min(i,Math.round(a.height*r)));return{width:Math.max(1,Math.min(o,Math.round(u*e))),height:u}}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 vi(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 za(e,t){const n=e.filter(E=>E.vertices.length>=9&&E.indices.length>=3),a=n[0];if(!a)throw new Error("No valid mesh data to render");const r=t.planeCorners?Jf(t.planeCorners):Yf(a.vertices),o=n.map(E=>({meshData:E,points2D:vi(Da(E.vertices,r),t)}));let i=1/0,l=-1/0,s=1/0,c=-1/0;if(t.planeCorners){const E=gi(vi(Xf(t.planeCorners,r),t));i=E.minU,l=E.maxU,s=E.minV,c=E.maxV}else for(const{points2D:E}of o){const B=gi(E);B.minU<i&&(i=B.minU),B.maxU>l&&(l=B.maxU),B.minV<s&&(s=B.minV),B.maxV>c&&(c=B.maxV)}const p=l-i||1,u=c-s||1,d=p/u,{width:x,height:h}=Qf(d,p,u,t);let T=x,P=h,y=0,_=0;d>x/h?(P=x/d,_=(h-P)/2):(T=h*d,y=(x-T)/2);const b=T/p,k=P/u,L=document.createElement("canvas");L.width=x,L.height=h;const I=L.getContext("2d");I.fillStyle="#fff",I.fillRect(0,0,x,h);const S=I.getImageData(0,0,x,h);for(const{meshData:E,points2D:B}of o){const F=B.map(w=>({u:(w.u-i)*b+y,v:(w.v-s)*k+_}));Kf(E,x,h,F,S,t)}return I.putImageData(S,0,0),{canvas:L,imageData:S}}function qn(e,t){return za([e],t)}function Va(e,t={}){return qn(Gf(e),t)}function $a(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=Ba(a);return e.center&&(r.vertices=Go(r.vertices,{x:e.center.x,y:e.center.y,z:e.center.z})),qn(r,t)}function jf(e,t={}){return qn(Ba(e),t)}function Ua(e,t={}){return qn(Fa(e),t)}function Wa(e,t={}){return za(e.map(Fa),t)}function Ha(e,t={}){return Va(Vo.decode(new Uint8Array(e)),t)}function Za(e,t={}){return $a(Uo.decode(new Uint8Array(e)),t)}function Ga(e,t={}){return Ua(Ut.decode(new Uint8Array(e)),t)}function Ya(e,t,n={}){if(bn.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=>Ut.decode(new Uint8Array(o)));return Wa(r,n)}async function ed(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"?Ha(r,n):t==="formation"?Za(r,n):Ga(r,n),i=await Ja(o.canvas);return URL.createObjectURL(i)}async function td(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=bn.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 Ya(a,i,t)}function Ja(e){return new Promise((t,n)=>{e.toBlob(a=>{a?t(a):n(new Error("Failed to create PNG blob"))},"image/png")})}function nd(e){return e.toDataURL("image/png")}exports.PureComponents=Ot.PureComponents;exports.AttributeBody=qi;exports.AxesViewerPosition=Bt;exports.CachePreload=_s;exports.CacheType=Me;exports.ColorCodec=Ki;exports.ComplexFormationManager=ji;exports.Coordinate=ea;exports.CustomShader=lt;exports.DarkMetalMaterial=Gn;exports.DataBinding=Df;exports.DensitySlice=$o;exports.FPS=na;exports.FlatMaterial=hu;exports.FormationFace=Yn;exports.FormationManager=oa;exports.FormationSlice=Wo;exports.FormationVolume=Jn;exports.GUIText=Je;exports.Geo3DCamera=ra;exports.Geo3DUniversalCamera=Fu;exports.Geo3DViewer=Ho;exports.GridDiagram=sa;exports.Ground=Ln;exports.HoverType=xn;exports.IntersectingLine=la;exports.LightMetalMaterial=Zn;exports.Line=zo;exports.LoadingScreen=No;exports.LookAt=ca;exports.MaterialType=$e;exports.ModelLoader=Xn;exports.Optimizer=fa;exports.PlaneImage=da;exports.PointClickZone=ha;exports.PointClickZoneObjectType=pa;exports.ProgressedAttributeBody=ma;exports.ProgressedRemapColorByRedChannelMaterial=Ji;exports.ProgressedRepeatedTextureMaterial=Xi;exports.RayClick=ga;exports.RemapColorByRedChannelMaterial=Mt;exports.RepeatedTextureMaterial=qt;exports.RibbonLayer=va;exports.RoadWay=xa;exports.Roam=zf;exports.Rod=Vf;exports.ScaleMode=It;exports.Scene=$f;exports.SkyBox=ya;exports.SpaceHeat=Pa;exports.SpaceHeatObjectType=_a;exports.StructureLayer=Do;exports.TileMap=Ta;exports.TileMapMode=Sa;exports.Tube=ka;exports.TubeChart=To;exports.TubeChartLine=Ia;exports.TubeInstance=Na;exports.TubeLayer=bo;exports.TubeMain=Oa;exports.TubeOil=Aa;exports.TubeTool=So;exports.Utils=ps;exports.VoxelGrid=La;exports.calcCompass=hs;exports.calcGUIScale=ct;exports.calcInvTransformNodeScale=ki;exports.calcTransformNodeScale=Oe;exports.canvasToPngBlob=Ja;exports.canvasToPngDataUrl=nd;exports.createComponentInstance=Zf;exports.renderDensitySliceFromBuffer=Ha;exports.renderDensitySliceToCanvas=Va;exports.renderFormationFromBuffer=Ga;exports.renderFormationGroupFromBuffers=Ya;exports.renderFormationGroupFromUrl=td;exports.renderFormationGroupToCanvas=Wa;exports.renderFormationSliceToCanvas=jf;exports.renderFormationSlicesFromBuffer=Za;exports.renderFormationSlicesToCanvas=$a;exports.renderFormationToCanvas=Ua;exports.renderSliceFromUrl=ed;
|
|
1352
|
+
}`,If=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:Nf,fragment:Ef,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})},wf=(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:y}=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,y,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:y?C.jsx(If,{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"})})]})},Of=m.forwardRef(wf),To=e=>{var N,M;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,y]=m.useState(),[h,T]=m.useState(),{colorCodecs:P}=m.useContext(Lt),{id:v,url:_,callback:b,visible:E=!0,customMaterial:L=!1,colorType:I,width:S=20,offset:k=new u.Vector3(0,0,0),direction:B="right"}=e,F=je({url:_,cacheType:Me.EXACTLY_MATCH}),w=m.useCallback((x,A,V,$,U=!0)=>{if(t){const re=u.MeshBuilder.CreateRibbon("ribbon",{pathArray:[V,$],sideOrientation:U?u.Mesh.FRONTSIDE:u.Mesh.DOUBLESIDE},t),oe=re.getVerticesData(u.VertexBuffer.PositionKind),G=re.getIndices();if(oe&&G){const ae=Ot.buildTubeChartColors(oe,Y=>{if(I&&P&&P[I]){const ce=x.max,le=x.min;let X=new u.Color3(1,1,1);return le===le?X=P[I].array[P[I].array.length-1]:X=P[I].array[Math.trunc((x.chart[Y].value-le)/(ce-le)*(P[I].array.length-1))],new u.Color4(X.r,X.g,X.b,1)}return b?b(A[Y],Y,x.max,x.min):Ot.colorMapTubeChart()},U),ne=[],j=oe.length/3;for(let Y=0;Y<j;Y++)Y>=j/2?ne.push($[Y-j/2].x-V[Y-j/2].x,1):ne.push(0,1);a(oe.slice()),o(G.slice()),l(ae),c(ne)}t==null||t.removeMesh(re)}},[b,P,I,t]);m.useEffect(()=>{var x,A,V,$,U;if(F){const re=Zo.decode(new Uint8Array(F)),oe=S/(re.max-re.min),G=re.min<0?-re.min:0,ae=B==="right"?S/2:S;console.log(re);const ne=[],j=re.chart.map(X=>{const Pe=X.position?X.position:{x:0,y:0,z:0};return ne.push(X.value),new u.Vector3(Pe.x-ae,Pe.y+10,Pe.z)}),Y=re.chart.map(X=>{const Pe=X.position?X.position:{x:0,y:0,z:0},ge=B==="right"?(X.value+G)*oe:-(X.value+G)*oe;return new u.Vector3(Pe.x+ge-ae,Pe.y+10,Pe.z)});T(re.name),f(new u.Vector3((x=re.origin)==null?void 0:x.x,(A=re.origin)==null?void 0:A.y,(V=re.origin)==null?void 0:V.z).add(k));const ce=S/2-(($=e.style)!=null&&$.fontSize?e.style.fontSize/2:0),le=j[j.length-1].add(new u.Vector3(B==="right"?ce:-ce,0,0)).add((U=e.style)!=null&&U.offset?e.style.offset:new u.Vector3(0,0,0));y(new u.Vector3(le.x,le.y,le.z)),w(re,ne,j.splice(0,j.length),Y.splice(0,Y.length),!0)}},[w,_,t,k,(N=e.style)==null?void 0:N.offset,S,(M=e.style)==null?void 0:M.fontSize,F,B]);const D=m.useCallback(()=>{},[]);return m.useEffect(()=>{const x=()=>{D()};return t&&t.activeCamera&&(x(),t==null||t.activeCamera.onViewMatrixChangedObservable.add(x)),()=>{t&&t.activeCamera&&(t==null||t.activeCamera.onViewMatrixChangedObservable.removeCallback(x))}},[D,t]),C.jsx(C.Fragment,{children:E&&n.length>0&&i.length>0&&C.jsx(Of,{id:v,visible:E,vertices:n,colors:i,uvs:s,indices:r,position:p,style:{...e.style,title:h,position:d},customMaterial:L})})},Af=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"})})})},Ia=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:y=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 E,L,I,S,k,B,F,w;if(P){const D=Zo.decode(new Uint8Array(P)),N=T/(D.max-D.min),M=D.min<0?-D.min:0,x=new u.Vector3((E=D.origin)==null?void 0:E.x,(L=D.origin)==null?void 0:L.y,(I=D.origin)==null?void 0:I.z).add(y);a(x);const A=D.chart,V=[];for(let U=0;U<A.length;U++)V.push(x.add(new u.Vector3((S=A[U].position)==null?void 0:S.x,(k=A[U].position)==null?void 0:k.y,(B=A[U].position)==null?void 0:B.z)).add(new u.Vector3((A[U].value+M)*N,0,0)).multiply(Oe(v)));c([V]);const $=A[A.length-1].position;if($){const U=new u.Vector3($.x,$.y,$.z).add(new u.Vector3(T/2-((F=e.style)!=null&&F.fontSize?e.style.fontSize/2:0),0,0)).add((w=e.style)!=null&&w.offset?e.style.offset:new u.Vector3(0,0,0));o(new u.Vector3(U.x,U.y,U.z))}l(D.name)}},[f,t,y,(_=e.style)==null?void 0:_.offset,(b=e.style)==null?void 0:b.fontSize,P,v,T]),C.jsxs(C.Fragment,{children:[C.jsx(Af,{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 ci(){return{name:"",origin:void 0,layerList:[]}}const wa={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)mn.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=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.layerList.push(mn.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=>mn.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=>mn.toJSON(a))),t},create(e){return wa.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;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.layerList=((a=e.layerList)==null?void 0:a.map(r=>mn.fromPartial(r)))||[],t}};function ui(){return{name:"",position:void 0,start:void 0,end:void 0,radius:0,colorId:0,v:[]}}const mn={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=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.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 mn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o;const t=ui();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 Mf=(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:y,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:(E,L,I,S,k)=>{var B,F,w,D,N,M;if(v.onHover&&n&&_&&I){const x=I;for(let A=0;A<_.length;A++){const V=new u.Vector3((B=_[A].start)==null?void 0:B.x,(F=_[A].start)==null?void 0:F.y,(w=_[A].start)==null?void 0:w.z).add(f).multiply(Oe(o)),$=new u.Vector3((D=_[A].end)==null?void 0:D.x,(N=_[A].end)==null?void 0:N.y,(M=_[A].end)==null?void 0:M.z).add(f).multiply(Oe(o)),U=Math.sqrt(Math.pow(V.x-$.x,2)+Math.pow(V.y-$.y,2)+Math.pow(V.z-$.z,2)),re=new u.Vector3(V.x,V.y-U,V.z),oe=$.subtract(V),G=re.subtract(V),ae=x.subtract(V),ne=u.Vector3.Cross(oe,G),j=Math.acos(u.Vector3.Dot(oe.normalize(),G.normalize())),Y=u.Matrix.RotationAxis(ne,j),ce=u.Vector3.TransformCoordinates(ae,Y);if(0>=ce.y&&-U<=ce.y){v.onHover(E,L,I,S,_[A],k);break}}}},valueCallback:null,extra:v.extra}:null})},[v,o,f,n,_]),m.useEffect(()=>{if(a&&a.current&&n){const E=new u.VertexData;E.positions=s,E.indices=c,p&&d!=="pbr-dark"&&d!=="pbr-light"&&(E.colors=p),E.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:Hn,fragment:Wn,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(Zn,{alpha:T});if(d==="pbr-dark")return C.jsx(Gn,{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()})}),y]})},Lf=m.forwardRef(Mf),Rf=(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,y)=>C.jsx("transformNode",{name:"layer-text",position:d.position,scaling:ct(a),children:C.jsx(Je,{text:d.name,fontSize:p,color:c})},y)):C.jsx(C.Fragment,{})})},Bf=m.forwardRef(Rf),bo=e=>{var w,D,N,M,x;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,y]=m.useState(0),[h,T]=m.useState(),{colorIDs:P}=m.useContext(Lt),{id:v,url:_,color:b,layers:E=[],visible:L=!0,tessellation:I=64,frontSide:S=!1,customMaterial:k=!1,actions:B}=e,F=je({url:_,cacheType:Me.EXACTLY_MATCH});return m.useEffect(()=>{var A,V,$,U,re,oe;if(F){const G=wa.decode(new Uint8Array(F)),ae=[];G.layerList.forEach((ge,H)=>{var Q,Ee,be,ee,he,ue;ae.push(ge),H<G.layerList.length&&ae.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:(ee=(be=ge==null?void 0:ge.end)==null?void 0:be.y)!=null?ee:0,z:(ue=(he=ge==null?void 0:ge.end)==null?void 0:he.z)!=null?ue:0}})});const ne=ae.map(ge=>{const H=ge.start?ge.start:{x:0,y:0,z:0};return new u.Vector3(H.x,H.y,H.z)}),j=u.MeshBuilder.CreateTube("tube-tmp",{path:ne,radiusFunction:ge=>{var Q;const H=(Q=ae[ge])==null?void 0:Q.radius;return H||1},cap:u.Mesh.NO_CAP,tessellation:I,sideOrientation:S?u.Mesh.FRONTSIDE:u.Mesh.DOUBLESIDE},t),Y=j.getVerticesData(u.VertexBuffer.PositionKind),ce=k?Ot.correctTubeMainIndices(j.getIndices()):j.getIndices(),le=b;let X=[];Y&&(X=Ot.buildTubeMainColors(Y,ae.map(ge=>{const H=le||(P&&P[ge.colorId]?P[ge.colorId]:Ot.randomColorMap()),Q=E.findIndex(Ee=>Ee===ge.name)!==-1?H.a:0;return new u.Color4(H.r,H.g,H.b,Q)}),I,!!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(j);const Pe=[];for(let ge=0;ge<G.layerList.length;ge++){const H=G.layerList[ge];E.findIndex(Q=>Q===H.name)!==-1&&Pe.push({name:H.name,position:new u.Vector3((U=H.position)==null?void 0:U.x,(re=H.position)==null?void 0:re.y,(oe=H.position)==null?void 0:oe.z)})}f(Pe),y(G.layerList?G.layerList[0].radius:0)}},[_,t,S,I,k,E,P,F,b]),C.jsxs("transformNode",{name:`node-layer-${v}`,children:[n.length>0&&r.length>0&&C.jsx(Lf,{id:v,name:"tube-layer",visible:L,vertices:n,slices:h==null?void 0:h.layerList,indices:r,position:s,colors:i.length>0?i:void 0,materialType:k?"custom":"standard",alphaBlend:!0,actions:B}),p.length>0&&C.jsx(Bf,{id:v,data:p,visible:L,position:s,fontSize:(w=e.style)==null?void 0:w.fontSize,color:(D=e.style)==null?void 0:D.color,offset:(M=(N=e.style)==null?void 0:N.offset)==null?void 0:M.add(new u.Vector3(d,0,0)),showLabel:(x=e.style)==null?void 0:x.showLabel})]})},fi=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:y,data:h}=e,T=m.useCallback(()=>{const v=[],_=[];for(let B=0;B<2*y+1;B++)if(p==="start")v.push(new u.Vector3(h[B*3],h[B*3+1],h[B*3+2]));else{const F=h.length-2*y*3;v.push(new u.Vector3(h[B*3+F],h[B*3+1+F],h[B*3+2+F]))}const b=[],E=[];for(let B=0;B<y;B++)b.push(v[B]),E.push(v[2*y-B-1]);_.push(b,E);const L=u.MeshBuilder.CreateRibbon("ribbon-tmp",{pathArray:_,sideOrientation:u.Mesh.DOUBLESIDE},t),I=L.getVerticesData(u.VertexBuffer.PositionKind),S=L.getIndices(),k=L.getNormalsData();r(I?I.slice():[]),i(S?S.slice():[]),s(k?k.slice():[]),t==null||t.removeMesh(L)},[t,y,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()})},Oa=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(""),[y,h]=m.useState(new u.Vector3(0,0,0)),[T,P]=m.useState([]),v=m.useContext(Le),{id:_,color:b,url:E,name:L="tube",children:I,materialType:S="standard",actions:k,tessellation:B=32,style:F}=e,w=m.useRef(!1),D=m.useCallback(M=>{var oe,G,ae;const x=M.sliceList.filter(ne=>!(ne.v.length>0)).map(ne=>{const j=ne.start?ne.start:{x:0,y:0,z:0};return new u.Vector3(j.x,j.y,j.z)}),A=M.sliceList[M.sliceList.length-1];if(x.length>0&&x.push(new u.Vector3((oe=A.end)==null?void 0:oe.x,(G=A.end)==null?void 0:G.y,(ae=A.end)==null?void 0:ae.z)),x.length<1)return;const V=u.MeshBuilder.ExtrudeShape("tmp",{path:x,sideOrientation:u.Mesh.DOUBLESIDE,shape:Ot.buildSemiRing(A.innerRadius,A.radius,B),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),U=V.getIndices(),re=V.getNormalsData();i($?$.slice():[]),s(U?U.slice():[]),p(re?re.slice():[]),t==null||t.removeMesh(V)},[t,B]);m.useEffect(()=>{w.current||(w.current=!0,Wt.get(E,{responseType:"arraybuffer"}).then(M=>{var V,$,U;const x=Nt.decode(new Uint8Array(M.data));if(console.log(x),x.sliceList.length===0)return;d(x.name);const A=F!=null&&F.basePosition&&F.basePosition==="top"?x.sliceList[0].start:x.sliceList[x.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=x.origin)==null?void 0:V.x,($=x.origin)==null?void 0:$.y,(U=x.origin)==null?void 0:U.z)),D(x)}))},[D,F==null?void 0:F.basePosition,E]),m.useEffect(()=>{if(n&&n.current&&t){const M=new u.VertexData;M.positions=o,M.indices=l,M.normals=c,M.applyToMesh(n.current)}},[l,o,t,c]),m.useEffect(()=>{n.current&&(n.current.metadata={pickable:k?{name:L,value:_,onLeftClick:k.onLeftClick,valueCallback:()=>_,onRightClick:k.onRightClick,onMiddleClick:k.onMiddleClick,onHover:k.onHover}:null})},[k,_,v,L,a,t]);const N=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:`${L}-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,L]);return C.jsxs("transformNode",{name:`${L}-main-node`,position:a.multiply(Oe(v)),scaling:Oe(v),children:[C.jsx("mesh",{name:`${L}-mesh`,ref:n,isPickable:!0,children:N()}),T.length>0&&C.jsx(fi,{id:1,name:"start",color:b,type:"start",tessellation:B,data:T,materialType:S}),T.length>0&&C.jsx(fi,{id:2,name:"end",color:b,type:"end",tessellation:B,data:T,materialType:S}),F&&C.jsx(ba,{id:_,style:{title:f,position:y,offset:F.offset,fontSize:F.fontSize,color:F.color}}),I]})},Aa=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 di(){return{name:"",origin:void 0,dataPoints:[],size:void 0}}const Ma={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)gn.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=di();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(gn.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=>gn.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=>gn.toJSON(a))),e.size!==void 0&&(t.size=K.toJSON(e.size)),t},create(e){return Ma.fromPartial(e!=null?e:{})},fromPartial(e){var n,a;const t=di();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=>gn.fromPartial(r)))||[],t.size=e.size!==void 0&&e.size!==null?K.fromPartial(e.size):void 0,t}};function pi(){return{point:void 0,colorId:0,vScale:0,rotation:void 0,pointType:0}}const gn={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=pi();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 gn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r;const t=pi();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 Ff=[0,.05,.1,.15,.2,.25,.3,.35,.4,.45,.5,.55,.6,.65,.7,.75,.8,.85,.9,.95,1],La=({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),y=m.useRef(null);m.useEffect(()=>{console.log("[Geo3DViewer] VoxelGrid Loading: ",e)},[e]);const h=T=>Ff[T];return m.useEffect(()=>{if(r&&f){const T=Ma.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 E=null;b&&(E=u.MeshBuilder.CreateBox("voxel",{width:b.x-1e-5,height:b.y-1e-5,depth:b.z-1e-5},r),E.material=d.current,u.Tags.EnableFor(E),u.Tags.AddTagsTo(E,"loading"));const L=new Float32Array(_.length*16),I=new Float32Array(_.length*4);return _.forEach((S,k)=>{if(S.point){const B=new u.Vector3(S.point.x,S.point.y,S.point.z),F=S.rotation?u.Quaternion.FromEulerAngles(S.rotation.x,S.rotation.y,S.rotation.z):u.Quaternion.Identity(),w=new u.Vector3(S.vScale+1,S.vScale+1,S.vScale+1);u.Matrix.Compose(w,F,B).copyToArray(L,k*16);let N=i.colorIDs[S.colorId];N||(N=u.Color4.FromColor3(u.Color3.Random())),I.set([N.r,N.g,N.b,h(S.pointType)],k*4)}}),E&&(E.thinInstanceSetBuffer("matrix",L),E.thinInstanceSetBuffer("color",I,4),E.parent=y.current),u.Tags.RemoveTagsFrom(E,"loading"),()=>{E&&(E.thinInstanceSetBuffer("matrix",new Float32Array),E.thinInstanceSetBuffer("color",new Float32Array),r.removeMesh(E))}}}},[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:y,children:C.jsx(yu,{name:`voxel-${l}-mat`,typeAlpha:t,ref:d})})},Df=(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:y,tubes:h,roadways:T,densitySlices:P,formationSlices:v,rayClick:_,lines:b,spaceHeats:E,lookAt:L,fps:I,coordinate:S,tileMaps:k,pointClickZones:B,progressedAttributeBodies:F,ribbonLayers:w,intersectingLines:D,tubeInstances:N,optimizer:M,voxelGrids:x,planeImages:A,guiTexts:V,skybox:$,particleSystems:U,waterEffects:re,modelLoaders:oe,modelAnimationLoaders:G,roadwayAnimations:ae,roadwayNearAnimations:ne,roadwayWaterAnimations:j,contourlines:Y,tubeTools:ce,tubeOils:le,tubeLayers:X,tubeChartLines:Pe,tubeCharts:ge}=e;return C.jsxs(Ho,{...n,ref:t,children:[r?C.jsx(zu,{...a}):C.jsx(ra,{...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(ji,{...H},`complexFormationManager-${H.url}`)):C.jsx(C.Fragment,{}),P?P.map(H=>C.jsx($o,{...H},`densitySlice-${H.url}`)):C.jsx(C.Fragment,{}),v?v.map(H=>C.jsx(Wo,{...H},`formationSlice-${H.url}`)):C.jsx(C.Fragment,{}),l?l.map(H=>C.jsx(oa,{...H},`formationManager-${H.url}`)):C.jsx(C.Fragment,{}),s?s.map(H=>C.jsx(Yn,{...H},`formation-face-${H.urlTopLayer}`)):C.jsx(C.Fragment,{}),c?c.map(H=>C.jsx(Jn,{...H},`formation-volume-${H.url}`)):C.jsx(C.Fragment,{}),p?p.map(H=>C.jsx(Do,{...H},`structurelayer-${H.url}`)):C.jsx(C.Fragment,{}),f?C.jsx(Ki,{...f}):C.jsx(C.Fragment,{}),d?d.map(H=>C.jsx(sa,{...H},`gridDiagram-${H.url}`)):C.jsx(C.Fragment,{}),y?y.map(H=>C.jsx(qi,{...H},`attributebody-${H.url}`)):C.jsx(C.Fragment,{}),h?h.map(H=>C.jsxs(ka,{...H,children:[H.charts?H.charts.map(Q=>C.jsx(To,{...Q},`tubechart-${Q.url}`)):C.jsx(C.Fragment,{}),H.layers?H.layers.map(Q=>C.jsx(bo,{...Q},`tubelayer-${Q.url}`)):C.jsx(C.Fragment,{}),H.tools?H.tools.map(Q=>C.jsx(So,{...Q},`tubelayer-${Q.name}`)):C.jsx(C.Fragment,{})]},`tube-${H.url}`)):C.jsx(C.Fragment,{}),T?T.map(H=>C.jsx(xa,{...H},`roadway-${H.url}`)):C.jsx(C.Fragment,{}),_?_.map((H,Q)=>C.jsx(ga,{...H},`rayclick-${Q}`)):C.jsx(C.Fragment,{}),b?b.map((H,Q)=>C.jsx(zo,{...H},`line-${Q}`)):C.jsx(C.Fragment,{}),E?E.map((H,Q)=>C.jsx(Pa,{...H},`spaceheat-${Q}`)):C.jsx(C.Fragment,{}),L?C.jsx(ca,{target:void 0,distance:0}):C.jsx(C.Fragment,{}),I?C.jsx(na,{}):C.jsx(C.Fragment,{}),S?C.jsx(ea,{...S},"coordinate"):C.jsx(C.Fragment,{}),k?k.map((H,Q)=>C.jsx(Ta,{...H},`tilemap-${Q}`)):C.jsx(C.Fragment,{}),B?B.map((H,Q)=>C.jsx(ha,{...H},`pointClickZone-${Q}`)):C.jsx(C.Fragment,{}),F?F.map((H,Q)=>C.jsx(ma,{...H},`progressedAttributeBody-${Q}`)):C.jsx(C.Fragment,{}),w?w.map((H,Q)=>C.jsx(va,{...H},`ribbonlayer-${Q}`)):C.jsx(C.Fragment,{}),D?D.map((H,Q)=>C.jsx(la,{...H},`intersectingLine-${Q}`)):C.jsx(C.Fragment,{}),N?N.map((H,Q)=>C.jsx(Na,{...H},`tubeinstance-${Q}`)):C.jsx(C.Fragment,{}),M?C.jsx(fa,{}):C.jsx(C.Fragment,{}),x?x.map((H,Q)=>C.jsx(La,{...H},`voxelgrid-${Q}`)):C.jsx(C.Fragment,{}),A?A.map((H,Q)=>C.jsx(da,{...H},`planeimage-${Q}`)):C.jsx(C.Fragment,{}),V?V.map((H,Q)=>C.jsx(Ru,{...H},`guitext-${Q}`)):C.jsx(C.Fragment,{}),$&&C.jsx(ya,{...$}),U?U.map((H,Q)=>C.jsx(tf,{...H},`particlesystem-${Q}`)):C.jsx(C.Fragment,{}),re?re.map((H,Q)=>C.jsx(nf,{...H},`waterEffect-${Q}`)):C.jsx(C.Fragment,{}),oe?oe.map((H,Q)=>C.jsx(Xn,{...H},`modelLoaders-${Q}`)):C.jsx(C.Fragment,{}),G?G.map((H,Q)=>C.jsx(ef,{...H},`modelanimtionloader-${Q}`)):C.jsx(C.Fragment,{}),ae?ae.map((H,Q)=>C.jsx(Ln,{...H,children:C.jsx(ff,{})},`animation-${Q}`)):C.jsx(C.Fragment,{}),ne?ne.map((H,Q)=>C.jsx(Ln,{...H,children:C.jsx(hf,{roadwayWidth:H.roadwayWidth,textureLength:H.textureLength,url:H.imageUrl,isBlink:H.isBlink,visible:H.visible})},`animation-${Q}`)):C.jsx(C.Fragment,{}),j?j.map((H,Q)=>C.jsx(Ln,{...H,children:C.jsx(vf,{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(wu,{...H},`contourline-${Q}`)):C.jsx(C.Fragment,{}),ce?ce.map((H,Q)=>C.jsx(So,{...H},`tubeTool-${Q}`)):C.jsx(C.Fragment,{}),le?le.map((H,Q)=>C.jsx(Aa,{...H,children:H.main?H.main.map((Ee,be)=>C.jsx(Oa,{...Ee},`tubeMain-${be}`)):null},`tubeOil-${Q}`)):C.jsx(C.Fragment,{}),X?X.map((H,Q)=>C.jsx(bo,{...H},`tubeLayer-${Q}`)):C.jsx(C.Fragment,{}),Pe?Pe.map((H,Q)=>C.jsx(Ia,{...H},`tubeChartLine-${Q}`)):C.jsx(C.Fragment,{}),ge?ge.map((H,Q)=>C.jsx(To,{...H},`tubeChart-${Q}`)):C.jsx(C.Fragment,{})]})},zf=m.forwardRef(Df),Vf=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 hi(){return{name:"",origin:void 0,type:"",sliceList:[],vertices:[],normals:[],indices:[],uv:[]}}const Ra={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)vn.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=hi();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(vn.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=>vn.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=>vn.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 Ra.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i,l,s;const t=hi();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=>vn.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 mi(){return{position:void 0,start:void 0,end:void 0,color:void 0,angle:0,radius:0,bottomRadius:0,texture:"",v:[]}}const vn={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=mi();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 vn.fromPartial(e!=null?e:{})},fromPartial(e){var n,a,r,o,i;const t=mi();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 $f=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:y,name:h="rod",visible:T=!0,color:P}=e,v=m.useCallback(_=>{var k,B,F;const b=_.sliceList.filter(w=>!(w.v.length>0)).map(w=>{const D=w.start?w.start:{x:0,y:0,z:0};return new u.Vector3(D.x,D.y,D.z)}),E=_.sliceList[_.sliceList.length-1];if(b.length>0&&b.push(new u.Vector3((k=E.end)==null?void 0:k.x,(B=E.end)==null?void 0:B.y,(F=E.end)==null?void 0:F.z)),b.length<1)return;const L=u.MeshBuilder.CreateTube("tube-tmp",{path:b,radiusFunction:w=>{if(e.radius)return e.radius;const D=_.sliceList[w]?_.sliceList[w].radius:_.sliceList[w-1].radius;return D||1},cap:u.Mesh.CAP_ALL,tessellation:24,sideOrientation:u.Mesh.FRONTSIDE},t),I=L.getVerticesData(u.VertexBuffer.PositionKind),S=L.getIndices();a(I?I.slice():[]),o(S?S.slice():[]),t==null||t.removeMesh(L)},[e.radius,t]);return m.useEffect(()=>{p.current||(p.current=!0,Wt.get(y,{responseType:"arraybuffer"}).then(_=>{var E,L,I;const b=Ra.decode(new Uint8Array(_.data));b.sliceList.length!==0&&(d(b.sliceList),l(new u.Vector3((E=b.origin)==null?void 0:E.x,(L=b.origin)==null?void 0:L.y,(I=b.origin)==null?void 0:I.z)),console.log(b),v(b))}))},[v,y]),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,E,L;let _;if(f.length>0&&t){_=u.MeshBuilder.CreateSphere("top",{diameter:f[0].bottomRadius*2,segments:32},t);const I=new u.StandardMaterial("myMaterial",t);_.material=I,_.setEnabled(!1),I.diffuseColor=new u.Color3(P.r,P.g,P.b);for(let S=0;S<f.length;S++){const k=f[S],B=_.createInstance("tubeinstance-sphere-"+S);B.setEnabled(T);const F=i.multiply(Oe(s));B.position=F.add(new u.Vector3((b=k.position)==null?void 0:b.x,(E=k.position)==null?void 0:E.y,(L=k.position)==null?void 0:L.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 Uf{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=ja.createRoot(t);console.log("create root!");const a=m.createElement(Ho,{ref:this.ref,...this.params},this.children);n.render(a)}}const Wf=(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},Hf=m.forwardRef(Wf);class Zf{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(Hf,{ref:this.ref,key:(t=this.value.id)!=null?t:0,props:this.value,type:this.type})}}function Gf(e,t){return new Zf(e,t)}function Go(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 Yf(e){return{vertices:Go(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 Ba(e){return{vertices:e.vertices,indices:e.indices,values:[],vMin:0,vMax:1,colorId:e.colorId}}function Fa(e){return{vertices:Go(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 Jf(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{origin:{x:t,y:n,z:a},uAxis:{x:r-t,y:o-n,z:i-a},vAxis:{x:l-t,y:s-n,z:c-a}}}function Xf(e){const[t,n,a]=e,r={x:a.x-t.x,y:0,z:a.z-t.z},o={x:0,y:n.y-t.y,z:0};if(r.x===0&&r.z===0)throw new Error("Invalid planeCorners: point1 and point3 must define a non-zero x/z diagonal");if(o.y===0)throw new Error("Invalid planeCorners: point1 and point2 must define a non-zero height");return{origin:t,uAxis:r,vAxis:o}}function Da(e,t){const n=[],a=Math.sqrt(t.uAxis.x**2+t.uAxis.y**2+t.uAxis.z**2),r=Math.sqrt(t.vAxis.x**2+t.vAxis.y**2+t.vAxis.z**2);if(a<1e-10||r<1e-10)throw new Error("Invalid plane basis: axis length is zero");const o={x:t.uAxis.x/a,y:t.uAxis.y/a,z:t.uAxis.z/a},i={x:t.vAxis.x/r,y:t.vAxis.y/r,z:t.vAxis.z/r};for(let l=0;l<e.length;l+=3){const s=e[l]-t.origin.x,c=e[l+1]-t.origin.y,p=e[l+2]-t.origin.z;n.push({u:s*o.x+c*o.y+p*o.z,v:s*i.x+c*i.y+p*i.z})}return n}function qf(e,t){const n=[];for(const a of e)n.push(a.x,a.y,a.z);return Da(n,t)}function Kf(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 go(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 vo(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 Qf(e,t,n,a,r,o){const{indices:i,values:l,vMin:s,vMax:c,colorId:p}=e,{colorCodecs:f,colorIDs:d,colorCodecKey:y}=o,h=r.data,T=!!(y&&f&&f[y]),P=T?f[y]:null;for(let v=0;v<i.length;v+=3){const _=i[v],b=i[v+1],E=i[v+2],L=a[_],I=a[b],S=a[E],k=Math.max(0,Math.floor(Math.min(L.u,I.u,S.u))),B=Math.min(t-1,Math.ceil(Math.max(L.u,I.u,S.u))),F=Math.max(0,Math.floor(Math.min(L.v,I.v,S.v))),w=Math.min(n-1,Math.ceil(Math.max(L.v,I.v,S.v)));let D,N,M;T&&P?(D=go(P,l[_],s,c),N=go(P,l[b],s,c),M=go(P,l[E],s,c)):(D=vo(d!=null?d:{},p),N=vo(d!=null?d:{},p),M=vo(d!=null?d:{},p));for(let x=F;x<=w;x++)for(let A=k;A<=B;A++){const[V,$,U,re]=Kf(L,I,S,A,x);if(!re)continue;const oe=(x*t+A)*4;h[oe]=Math.round(Math.max(0,Math.min(255,(V*D[0]+$*N[0]+U*M[0])*255))),h[oe+1]=Math.round(Math.max(0,Math.min(255,(V*D[1]+$*N[1]+U*M[1])*255))),h[oe+2]=Math.round(Math.max(0,Math.min(255,(V*D[2]+$*N[2]+U*M[2])*255))),h[oe+3]=Math.round(Math.max(0,Math.min(255,(V*D[3]+$*N[3]+U*M[3])*255)))}}}function gi(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 jf(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)),y=Math.min(o/f,i/d,1);return{width:Math.max(1,Math.round(f*y)),height:Math.max(1,Math.round(d*y))}}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 vi(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 za(e,t){const n=e.filter(k=>k.vertices.length>=9&&k.indices.length>=3),a=n[0];if(!a)throw new Error("No valid mesh data to render");const r=t.planeCorners?Xf(t.planeCorners):Jf(a.vertices),o=n.map(k=>({meshData:k,points2D:vi(Da(k.vertices,r),t)}));let i=1/0,l=-1/0,s=1/0,c=-1/0;if(t.planeCorners){const k=gi(vi(qf(t.planeCorners,r),t));i=k.minU,l=k.maxU,s=k.minV,c=k.maxV}else for(const{points2D:k}of o){const B=gi(k);B.minU<i&&(i=B.minU),B.maxU>l&&(l=B.maxU),B.minV<s&&(s=B.minV),B.maxV>c&&(c=B.maxV)}const p=l-i||1,f=c-s||1,d=p/f,{width:y,height:h}=jf(d,p,f,t);let T=y,P=h,v=0,_=0;d>y/h?(P=y/d,_=(h-P)/2):(T=h*d,v=(y-T)/2);const b=T/p,E=P/f,L=document.createElement("canvas");L.width=y,L.height=h;const I=L.getContext("2d");I.fillStyle="#fff",I.fillRect(0,0,y,h);const S=I.getImageData(0,0,y,h);for(const{meshData:k,points2D:B}of o){const F=B.map(w=>({u:(w.u-i)*b+v,v:(w.v-s)*E+_}));Qf(k,y,h,F,S,t)}return I.putImageData(S,0,0),{canvas:L,imageData:S}}function qn(e,t){return za([e],t)}function Va(e,t={}){return qn(Yf(e),t)}function $a(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=Ba(a);return e.center&&(r.vertices=Go(r.vertices,{x:e.center.x,y:e.center.y,z:e.center.z})),qn(r,t)}function ed(e,t={}){return qn(Ba(e),t)}function Ua(e,t={}){return qn(Fa(e),t)}function Wa(e,t={}){return za(e.map(Fa),t)}function Ha(e,t={}){return Va(Vo.decode(new Uint8Array(e)),t)}function Za(e,t={}){return $a(Uo.decode(new Uint8Array(e)),t)}function Ga(e,t={}){return Ua(Ut.decode(new Uint8Array(e)),t)}function Ya(e,t,n={}){if(bn.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=>Ut.decode(new Uint8Array(o)));return Wa(r,n)}async function td(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"?Ha(r,n):t==="formation"?Za(r,n):Ga(r,n),i=await Ja(o.canvas);return URL.createObjectURL(i)}async function nd(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=bn.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 Ya(a,i,t)}function Ja(e){return new Promise((t,n)=>{e.toBlob(a=>{a?t(a):n(new Error("Failed to create PNG blob"))},"image/png")})}function od(e){return e.toDataURL("image/png")}exports.PureComponents=Ot.PureComponents;exports.AttributeBody=qi;exports.AxesViewerPosition=Bt;exports.CachePreload=_s;exports.CacheType=Me;exports.ColorCodec=Ki;exports.ComplexFormationManager=ji;exports.Coordinate=ea;exports.CustomShader=lt;exports.DarkMetalMaterial=Gn;exports.DataBinding=zf;exports.DensitySlice=$o;exports.FPS=na;exports.FlatMaterial=hu;exports.FormationFace=Yn;exports.FormationManager=oa;exports.FormationSlice=Wo;exports.FormationVolume=Jn;exports.GUIText=Je;exports.Geo3DCamera=ra;exports.Geo3DUniversalCamera=Fu;exports.Geo3DViewer=Ho;exports.GridDiagram=sa;exports.Ground=Ln;exports.HoverType=xn;exports.IntersectingLine=la;exports.LightMetalMaterial=Zn;exports.Line=zo;exports.LoadingScreen=No;exports.LookAt=ca;exports.MaterialType=$e;exports.ModelLoader=Xn;exports.Optimizer=fa;exports.PlaneImage=da;exports.PointClickZone=ha;exports.PointClickZoneObjectType=pa;exports.ProgressedAttributeBody=ma;exports.ProgressedRemapColorByRedChannelMaterial=Ji;exports.ProgressedRepeatedTextureMaterial=Xi;exports.RayClick=ga;exports.RemapColorByRedChannelMaterial=Mt;exports.RepeatedTextureMaterial=qt;exports.RibbonLayer=va;exports.RoadWay=xa;exports.Roam=Vf;exports.Rod=$f;exports.ScaleMode=It;exports.Scene=Uf;exports.SkyBox=ya;exports.SpaceHeat=Pa;exports.SpaceHeatObjectType=_a;exports.StructureLayer=Do;exports.TileMap=Ta;exports.TileMapMode=Sa;exports.Tube=ka;exports.TubeChart=To;exports.TubeChartLine=Ia;exports.TubeInstance=Na;exports.TubeLayer=bo;exports.TubeMain=Oa;exports.TubeOil=Aa;exports.TubeTool=So;exports.Utils=ps;exports.VoxelGrid=La;exports.calcCompass=hs;exports.calcGUIScale=ct;exports.calcInvTransformNodeScale=ki;exports.calcTransformNodeScale=Oe;exports.canvasToPngBlob=Ja;exports.canvasToPngDataUrl=od;exports.createComponentInstance=Gf;exports.renderDensitySliceFromBuffer=Ha;exports.renderDensitySliceToCanvas=Va;exports.renderFormationFromBuffer=Ga;exports.renderFormationGroupFromBuffers=Ya;exports.renderFormationGroupFromUrl=nd;exports.renderFormationGroupToCanvas=Wa;exports.renderFormationSliceToCanvas=ed;exports.renderFormationSlicesFromBuffer=Za;exports.renderFormationSlicesToCanvas=$a;exports.renderFormationToCanvas=Ua;exports.renderSliceFromUrl=td;
|